diff options
| author | Jabier Arraiza Cenoz <jabier.arraiza@marker.es> | 2016-10-03 20:51:05 +0000 |
|---|---|---|
| committer | jabiertxof <info@marker.es> | 2016-10-03 20:51:05 +0000 |
| commit | 4db35e8a6706ddece9e977e5f26d4a6867ff8cbe (patch) | |
| tree | f9711f260f694d96e26bf3216fb64f2b38611b2b /src | |
| parent | update to trunk (diff) | |
| parent | Merge in jabiertxof's hover information for measure tool (diff) | |
| download | inkscape-4db35e8a6706ddece9e977e5f26d4a6867ff8cbe.tar.gz inkscape-4db35e8a6706ddece9e977e5f26d4a6867ff8cbe.zip | |
Update to trunk
(bzr r15017.1.35)
Diffstat (limited to 'src')
695 files changed, 6928 insertions, 31567 deletions
diff --git a/src/2geom/CMakeLists.txt b/src/2geom/CMakeLists.txt index 97b47b630..aa51d51bd 100644 --- a/src/2geom/CMakeLists.txt +++ b/src/2geom/CMakeLists.txt @@ -60,13 +60,16 @@ set(2geom_SRC bezier-to-sbasis.h bezier-utils.h bezier.h + cairo-path-sink.h choose.h circle.h + circulator.h concepts.h conic_section_clipper.h conic_section_clipper_cr.h conic_section_clipper_impl.h conicsec.h + convex-hull.h coord.h crossing.h curve.h @@ -82,10 +85,13 @@ set(2geom_SRC int-interval.h int-point.h int-rect.h + intersection-graph.h + intersection.h interval.h line.h linear.h math-utils.h + nearest-time.h ord.h path-intersection.h path-sink.h @@ -106,8 +112,8 @@ set(2geom_SRC solver.h svg-path-parser.h svg-path-writer.h - sweeper.h sweep-bounds.h + sweeper.h toposweep.h transforms.h utils.h diff --git a/src/2geom/Makefile_insert b/src/2geom/Makefile_insert deleted file mode 100644 index 4d41de297..000000000 --- a/src/2geom/Makefile_insert +++ /dev/null @@ -1,131 +0,0 @@ -## Makefile.am fragment sourced by src/Makefile.am. - -2geom/all: 2geom/lib2geom.a - -2geom/clean: - rm -f 2geom/lib2geom.a $(2geom_lib2geom_a_OBJECTS) - -2geom_lib2geom_a_SOURCES = \ - 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.cpp \ - 2geom/bezier.h \ - 2geom/bezier-to-sbasis.h \ - 2geom/bezier-utils.cpp \ - 2geom/bezier-utils.h \ - 2geom/cairo-path-sink.cpp \ - 2geom/cairo-path-sink.h \ - 2geom/choose.h \ - 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/convex-hull.cpp \ - 2geom/convex-hull.h \ - 2geom/coord.cpp \ - 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/ellipse.cpp \ - 2geom/ellipse.h \ - 2geom/elliptical-arc.cpp \ - 2geom/elliptical-arc.h \ - 2geom/elliptical-arc-from-sbasis.cpp \ - 2geom/exception.h \ - 2geom/forward.h \ - 2geom/generic-interval.h \ - 2geom/generic-rect.h \ - 2geom/geom.cpp \ - 2geom/geom.h \ - 2geom/intersection.h \ - 2geom/intersection-graph.cpp \ - 2geom/intersection-graph.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-time.cpp \ - 2geom/nearest-time.h \ - 2geom/ord.h \ - 2geom/path.cpp \ - 2geom/path.h \ - 2geom/path-intersection.cpp \ - 2geom/path-intersection.h \ - 2geom/path-sink.cpp \ - 2geom/path-sink.h \ - 2geom/pathvector.cpp \ - 2geom/pathvector.h \ - 2geom/piecewise.cpp \ - 2geom/piecewise.h \ - 2geom/point.cpp \ - 2geom/point.h \ - 2geom/polynomial.cpp \ - 2geom/polynomial.h \ - 2geom/ray.h \ - 2geom/rect.cpp \ - 2geom/rect.h \ - 2geom/recursive-bezier-intersection.cpp \ - 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/solve-bezier.cpp \ - 2geom/solve-bezier-one-d.cpp \ - 2geom/solve-bezier-parametric.cpp \ - 2geom/solver.h \ - 2geom/svg-path-parser.cpp \ - 2geom/svg-path-parser.h \ - 2geom/svg-path-writer.cpp \ - 2geom/svg-path-writer.h \ - 2geom/sweep-bounds.cpp \ - 2geom/sweep-bounds.h \ - 2geom/sweeper.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/2geom/sbasis-geometric.cpp b/src/2geom/sbasis-geometric.cpp index 3fe27748e..19eccc451 100644 --- a/src/2geom/sbasis-geometric.cpp +++ b/src/2geom/sbasis-geometric.cpp @@ -227,7 +227,7 @@ Geom::unitVector(D2<SBasis> const &V_in, double tol, unsigned order){ // -This approach is numerically bad. Find a stable way to rescale V_in to have non vanishing ends. // -This done, unitVector will have jumps at zeros: fill the gaps with arcs of circles. D2<SBasis> V = RescaleForNonVanishingEnds(V_in); - if (V[0].isZero(tol) && V[1].isZero(tol)) + if (V[0].isZero(0) && V[1].isZero(0)) return Piecewise<D2<SBasis> >(D2<SBasis>(Linear(1),SBasis())); SBasis x = V[0], y = V[1]; diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ef855d950..3c4f28aa8 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -44,9 +44,9 @@ set(sp_SRC sp-marker.cpp sp-mask.cpp sp-mesh-array.cpp + sp-mesh-gradient.cpp sp-mesh-patch.cpp sp-mesh-row.cpp - sp-mesh.cpp sp-metadata.cpp sp-missing-glyph.cpp sp-namedview.cpp @@ -112,7 +112,6 @@ set(sp_SRC sp-glyph.h sp-gradient-reference.h sp-gradient-spread.h - sp-gradient-test.h sp-gradient-units.h sp-gradient-vector.h sp-gradient.h @@ -135,9 +134,9 @@ set(sp_SRC sp-marker.h sp-mask.h sp-mesh-array.h + sp-mesh-gradient.h sp-mesh-patch.h sp-mesh-row.h - sp-mesh.h sp-metadata.h sp-missing-glyph.h sp-namedview.h @@ -160,7 +159,6 @@ set(sp_SRC sp-star.h sp-stop.h sp-string.h - sp-style-elem-test.h sp-style-elem.h sp-switch.h sp-symbol.h @@ -228,6 +226,7 @@ set(inkscape_SRC message-stack.cpp mod360.cpp object-hierarchy.cpp + object-set.cpp object-snapper.cpp path-chemistry.cpp persp3d-reference.cpp @@ -277,7 +276,6 @@ set(inkscape_SRC MultiPrinter.h PylogFormatter.h TRPIFormatter.h - attributes-test.h attributes.h axis-manip.h bad-uri-exception.h @@ -286,7 +284,6 @@ set(inkscape_SRC cms-color-types.h cms-system.h color-profile-cms-fns.h - color-profile-test.h color-profile.h color-rgba.h color.h @@ -301,7 +298,6 @@ set(inkscape_SRC desktop-style.h desktop.h device-manager.h - dir-util-test.h dir-util.h document-private.h document-subset.h @@ -311,7 +307,6 @@ set(inkscape_SRC enums.h event-log.h event.h - extract-uri-test.h extract-uri.h file.h fill-or-stroke.h @@ -342,25 +337,22 @@ set(inkscape_SRC line-snapper.h macros.h main-cmdlineact.h - marker-test.h media.h menus-skeleton.h message-context.h message-stack.h message.h - mod360-test.h mod360.h number-opt-number.h object-hierarchy.h + object-set.h object-snapper.h - object-test.h path-chemistry.h path-prefix.h persp3d-reference.h persp3d.h perspective-line.h preferences-skeleton.h - preferences-test.h preferences.h prefix.h print.h @@ -372,7 +364,6 @@ set(inkscape_SRC removeoverlap.h require-config.h resource-manager.h - round-test.h round.h rubberband.h satisfied-guide-cns.h @@ -396,13 +387,11 @@ set(inkscape_SRC strneq.h style-enums.h style-internal.h - style-test.h style.h svg-profile.h svg-view-widget.h svg-view.h syseq.h - test-helpers.h text-chemistry.h text-editing.h text-tag-attributes.h @@ -411,10 +400,8 @@ set(inkscape_SRC undo-stack-observer.h unicoderange.h uri-references.h - uri-test.h uri.h vanishing-point.h - verbs-test.h verbs.h version.h ) @@ -467,7 +454,6 @@ add_subdirectory(libavoid) add_subdirectory(libcola) add_subdirectory(libcroco) add_subdirectory(inkgc) -add_subdirectory(libgdl) add_subdirectory(libuemf) add_subdirectory(libvpsc) add_subdirectory(livarot) @@ -538,11 +524,6 @@ set(INKSCAPE_TARGET_LIBS ${INKSCAPE_LIBS} ) -if (NOT "${WITH_EXT_GDL}") - # Insert it at the beginning of the list as the windows build fails otherwise - list (INSERT INKSCAPE_TARGET_LIBS 0 "gdl_LIB") -endif() - # Build everything except main and inkview.c in a shared library. add_library(inkscape_base SHARED ${inkscape_SRC} ${sp_SRC}) diff --git a/src/Makefile.am b/src/Makefile.am deleted file mode 100644 index 087a727de..000000000 --- a/src/Makefile.am +++ /dev/null @@ -1,289 +0,0 @@ -## Process this file with automake to produce Makefile.in - -# ################################################ -# G L O B A L -# ################################################ - -# Should work in either automake1.7 or 1.8, but 1.6 doesn't -# handle foo/libfoo_a_CPPFLAGS properly (if at all). -# Update: We now avoid setting foo/libfoo_a_CPPFLAGS, -# so perhaps 1.6 will work. -AUTOMAKE_OPTIONS = 1.7 subdir-objects - -# Executables compiled by "make" and installed by "make install" -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_EXT_GDL -internal_GDL = libgdl/libgdl.a -endif - - -noinst_LIBRARIES = \ - libcroco/libcroco.a \ - libavoid/libavoid.a \ - $(internal_GDL) \ - libuemf/libuemf.a \ - libcola/libcola.a \ - inkgc/libinkgc.a \ - libvpsc/libvpsc.a \ - livarot/libvarot.a \ - 2geom/lib2geom.a \ - libdepixelize/libdepixelize.a \ - util/libutil.a \ - libinkversion.a -# libinkscape.a - -all_libs = \ - $(noinst_LIBRARIES) \ - $(INKSCAPE_LIBS) \ - $(INKSCAPE_CXX_DEPS_LIBS) \ - $(EXIF_LIBS) \ - $(GNOME_VFS_LIBS) \ - $(XFT_LIBS) \ - $(FREETYPE_LIBS) \ - $(kdeldadd) \ - $(win32ldflags) \ - $(LIBWPG_LIBS) \ - $(LIBVISIO_LIBS) \ - $(LIBCDR_LIBS) \ - $(DBUS_LIBS) \ - $(GDL_LIBS) \ - $(IMAGEMAGICK_LIBS) \ - $(X11_LIBS) - -# Add sources common for Inkscape and Inkview to this variable. -ink_common_sources = -# Add Inkscape-only sources here. -inkscape_SOURCES = -# Add Inkview-only sources here. -inkview_SOURCES = -# Add sources that are built from meta files -BUILT_SOURCES = -# Extra files to distribute -EXTRA_DIST = - -# C++-specific flags defined here -AM_CXXFLAGS = \ - $(INKSCAPE_CXX_DEPS_CFLAGS) - -AM_CPPFLAGS = \ - -I$(top_srcdir)/cxxtest \ - -I$(builddir)/extension/dbus \ - $(EXIF_CFLAGS) \ - $(FREETYPE_CFLAGS) \ - $(GNOME_PRINT_CFLAGS) \ - $(GNOME_VFS_CFLAGS) \ - $(IMAGEMAGICK_CFLAGS) \ - $(LIBWPG_CFLAGS) \ - $(LIBVISIO_CFLAGS) \ - $(LIBCDR_CFLAGS) \ - $(DBUS_CFLAGS) \ - $(GDL_CFLAGS) \ - $(XFT_CFLAGS) \ - $(LCMS_CFLAGS) \ - $(POPPLER_CFLAGS) \ - $(POPPLER_GLIB_CFLAGS) \ - -DPOTRACE=\"potrace\" \ - $(INKSCAPE_CFLAGS) \ - $(WIN32_CFLAGS) \ - $(X11_CFLAGS) - -CXXTEST_TEMPLATE = $(srcdir)/cxxtest-template.tpl -CXXTESTGENFLAGS = --root --have-eh --template=$(CXXTEST_TEMPLATE) -CXXTESTGEN = $(top_srcdir)/cxxtest/cxxtestgen.pl $(CXXTESTGENFLAGS) -# Add test cases to this variable -CXXTEST_TESTSUITES = - -# ################################################ -# -# E X T R A -# -# ################################################ - -if PLATFORM_WIN32 -win32_sources = winmain.cpp registrytool.cpp registrytool.h -win32ldflags = -lcomdlg32 -lmscms -mwindows = -mwindows -endif - -# Include all partial makefiles from subdirectories -include Makefile_insert -include display/Makefile_insert -include extension/Makefile_insert -include extension/dbus/Makefile_insert -include extension/implementation/Makefile_insert -include extension/internal/Makefile_insert -include filters/Makefile_insert -include helper/Makefile_insert -include io/Makefile_insert -include libcroco/Makefile_insert -include inkgc/Makefile_insert -include libgdl/Makefile_insert -include libnrtype/Makefile_insert -include libavoid/Makefile_insert -include livarot/Makefile_insert -include live_effects/Makefile_insert -include live_effects/parameter/Makefile_insert -include libvpsc/Makefile_insert -include libcola/Makefile_insert -include libuemf/Makefile_insert -include svg/Makefile_insert -include widgets/Makefile_insert -include debug/Makefile_insert -include xml/Makefile_insert -include ui/Makefile_insert -include ui/cache/Makefile_insert -include ui/dialog/Makefile_insert -include ui/tool/Makefile_insert -include ui/tools/Makefile_insert -include ui/view/Makefile_insert -include ui/widget/Makefile_insert -include util/Makefile_insert -include trace/Makefile_insert -include 2geom/Makefile_insert -include libdepixelize/Makefile_insert - -# Extra files not mentioned as sources to include in the source tarball -EXTRA_DIST += \ - 2geom/makefile.in \ - debug/makefile.in \ - display/makefile.in \ - extension/implementation/makefile.in \ - extension/internal/makefile.in \ - extension/makefile.in \ - filters/makefile.in \ - helper/makefile.in \ - io/makefile.in \ - libavoid/makefile.in \ - libcroco/makefile.in \ - libgdl/makefile.in \ - libnrtype/makefile.in \ - libuemf/makefile.in \ - livarot/makefile.in \ - live_effects/makefile.in \ - live_effects/parameter/makefile.in \ - svg/makefile.in \ - trace/makefile.in \ - ui/cache/makefile.in \ - ui/dialog/makefile.in \ - ui/makefile.in \ - ui/view/makefile.in \ - ui/widget/makefile.in \ - util/makefile.in \ - util/makefile.in \ - widgets/makefile.in \ - xml/makefile.in \ - \ - $(top_srcdir)/Doxyfile \ - extension/internal/emf-inout.cpp \ - extension/internal/emf-inout.h \ - extension/internal/emf-print.cpp \ - extension/internal/emf-print.h \ - helper/sp-marshal.list \ - io/crystalegg.xml \ - io/doc2html.xsl \ - show-preview.bmp \ - winconsole.cpp \ - libdepixelize/makefile.in \ - $(CXXTEST_TEMPLATE) - -# Extra files to remove when doing "make distclean" -DISTCLEANFILES = \ - helper/sp-marshal.cpp \ - helper/sp-marshal.h \ - inkscape-version.cpp - -# ################################################ -# B I N A R I E S -# ################################################ - -# this should speed up the build -#libinkscape_a_SOURCES = $(ink_common_sources) - -inkscape_SOURCES += main.cpp $(ink_common_sources) $(win32_sources) -inkscape_LDADD = $(all_libs) -inkscape_LDFLAGS = $(kdeldflags) $(mwindows) - -inkview_SOURCES += inkview.cpp $(ink_common_sources) $(win32_sources) -inkview_LDADD = $(all_libs) -inkview_LDFLAGS = $(mwindows) - -# ################################################ -# VERSION REPORTING -# ################################################ - -libinkversion_a_SOURCES = inkscape-version.cpp inkscape-version.h - -if USE_BZR_VERSION -inkscape_version_deps = $(top_srcdir)/.bzr/branch/last-revision -endif - -# If this is an BZR snapshot build, regenerate this file every time -# someone updates the BZR working directory. -inkscape-version.cpp: $(inkscape_version_deps) - VER_PREFIX="$(VERSION)";\ - VER_BZRREV=" r`bzr revno --tree $(top_srcdir)`"; \ - if test ! -z "`bzr status -S -V $(srcdir)`"; then \ - VER_CUSTOM=" custom"; \ - fi; \ - VERSION="$$VER_PREFIX$$VER_BZRREV$$VER_CUSTOM"; \ - echo "namespace Inkscape { " \ - "char const *version_string = \"$$VERSION\"; " \ - "}" > inkscape-version.new.cpp; \ - if cmp -s inkscape-version.new.cpp inkscape-version.cpp; then \ - rm inkscape-version.new.cpp; \ - else \ - mv inkscape-version.new.cpp inkscape-version.cpp; \ - fi; \ - echo $$VERSION - -# ################################# -# ## TESTING STUFF (make check) ### -# ################################# - -# List of all programs that should be built before testing. Note that this is -# different from TESTS, because some tests can be scripts that don't -# need to be built. There should be one test program per directory. -# automake adds $(EXEEXT) to check_PROGRAMS items but not to TESTS items: -# TESTS items can be scripts etc. -check_PROGRAMS = cxxtests - -# streamtest is unfinished and can't handle the relocations done during -# "make distcheck". - -# List of all tests to be run. -TESTS = $(check_PROGRAMS) -check-local: - $(top_srcdir)/share/extensions/test/run-all-extension-tests - -# FIXME: Currently, a number of cxxtest tests fail. These should be fixed and -# the XFAIL_TESTS build target should be removed. -# See the following Launchpad bugs: -# -# LP #1208013 <cxxtest: curve-test.h fails> -# LP #1208005 <cxxtest: svg-path-geom-test.h fails> -# LP #1207502 <cxxtest: svg-affine-test.h fails> - -XFAIL_TESTS = $(check_PROGRAMS) - -# including the testsuites here ensures that they get distributed -cxxtests_SOURCES = cxxtests.cpp $(CXXTEST_TESTSUITES) $(ink_common_sources) $(win32_sources) -cxxtests_LDADD = $(all_libs) - -cxxtests.cpp: $(CXXTEST_TESTSUITES) $(CXXTEST_TEMPLATE) - $(CXXTESTGEN) -o cxxtests.cpp $(CXXTEST_TESTSUITES) - -# ################################################ -# D I S T -# ################################################ - -dist-hook: - mkdir $(distdir)/pixmaps - cp $(srcdir)/pixmaps/*xpm $(distdir)/pixmaps - -distclean-local: - rm -f cxxtests.xml cxxtests.log diff --git a/src/Makefile_insert b/src/Makefile_insert deleted file mode 100644 index 55fde4dd2..000000000 --- a/src/Makefile_insert +++ /dev/null @@ -1,251 +0,0 @@ -## Makefile.am fragment, included by src/Makefile.am. - -ink_common_sources += \ - util/find-last-if.h \ - util/longest-common-suffix.h \ - remove-last.h \ - attributes.cpp attributes.h \ - attribute-rel-svg.cpp attribute-rel-svg.h \ - attribute-rel-css.cpp attribute-rel-css.h \ - attribute-rel-util.cpp attribute-rel-util.h \ - attribute-sort-util.cpp attribute-sort-util.h \ - axis-manip.cpp axis-manip.h \ - bad-uri-exception.h \ - box3d.cpp box3d.h \ - box3d-side.cpp box3d-side.h \ - brokenimage.xpm \ - cms-color-types.h \ - cms-system.h \ - color.cpp color.h \ - color-profile.cpp color-profile.h \ - color-profile-cms-fns.h \ - color-rgba.h \ - colorspace.h \ - composite-undo-stack-observer.cpp \ - composite-undo-stack-observer.h \ - conditions.cpp conditions.h \ - conn-avoid-ref.cpp conn-avoid-ref.h \ - console-output-undo-observer.h console-output-undo-observer.cpp \ - context-fns.cpp context-fns.h \ - decimal-round.h \ - desktop.cpp desktop.h \ - desktop-events.cpp desktop-events.h \ - desktop-style.cpp desktop-style.h \ - device-manager.cpp device-manager.h \ - dir-util.cpp dir-util.h \ - document.cpp document.h document-private.h \ - document-subset.cpp document-subset.h \ - document-undo.cpp document-undo.h \ - ege-color-prof-tracker.cpp ege-color-prof-tracker.h \ - enums.h \ - event-log.cpp event-log.h event.h \ - extract-uri.cpp extract-uri.h \ - file.cpp file.h \ - fill-or-stroke.h \ - filter-chemistry.cpp filter-chemistry.h \ - filter-enums.cpp filter-enums.h \ - gc-anchored.cpp gc-anchored.h \ - gc-finalized.cpp gc-finalized.h \ - gradient-chemistry.cpp gradient-chemistry.h \ - gradient-drag.cpp gradient-drag.h \ - graphlayout.cpp graphlayout.h \ - guide-snapper.cpp guide-snapper.h \ - help.cpp help.h \ - helper-fns.h \ - helper/pixbuf-ops.cpp \ - helper/pixbuf-ops.h \ - icon-size.h \ - id-clash.cpp id-clash.h \ - inkscape.cpp inkscape.h \ - isinf.h \ - knot.cpp knot.h \ - knot-enums.h \ - knotholder.cpp knotholder.h \ - knot-holder-entity.h knot-holder-entity.cpp \ - knot-ptr.h knot-ptr.cpp \ - layer-fns.cpp layer-fns.h \ - layer-manager.cpp layer-manager.h \ - layer-model.cpp layer-model.h \ - line-geometry.cpp line-geometry.h \ - line-snapper.cpp line-snapper.h \ - macros.h \ - main-cmdlineact.cpp main-cmdlineact.h \ - media.cpp media.h \ - menus-skeleton.h \ - message-context.cpp message-context.h \ - message.h \ - message-stack.cpp message-stack.h \ - mod360.cpp mod360.h \ - object-hierarchy.cpp object-hierarchy.h \ - object-snapper.cpp object-snapper.h \ - path-chemistry.cpp path-chemistry.h \ - path-prefix.h \ - persp3d.cpp persp3d.h \ - persp3d-reference.cpp persp3d-reference.h \ - perspective-line.cpp perspective-line.h \ - preferences.cpp preferences.h \ - preferences-skeleton.h \ - prefix.cpp prefix.h \ - print.cpp print.h \ - profile-manager.cpp profile-manager.h \ - proj_pt.cpp proj_pt.h \ - pure-transform.cpp pure-transform.h \ - removeoverlap.cpp removeoverlap.h \ - rdf.cpp rdf.h \ - resource-manager.cpp resource-manager.h \ - require-config.h \ - round.h \ - rubberband.cpp rubberband.h \ - satisfied-guide-cns.cpp satisfied-guide-cns.h \ - selcue.cpp selcue.h \ - selection-chemistry.cpp selection-chemistry.h \ - selection.cpp selection.h \ - selection-describer.cpp selection-describer.h \ - seltrans.cpp seltrans.h \ - seltrans-handles.cpp seltrans-handles.h \ - shortcuts.cpp shortcuts.h \ - snap.cpp snap.h \ - snap-enums.h snap-candidate.h \ - snapped-curve.cpp snapped-curve.h \ - snapped-line.cpp snapped-line.h \ - snapped-point.cpp snapped-point.h \ - snapper.cpp snapper.h \ - snap-preferences.cpp snap-preferences.h \ - sp-anchor.cpp sp-anchor.h \ - sp-clippath.cpp sp-clippath.h \ - sp-conn-end.cpp sp-conn-end.h \ - sp-conn-end-pair.cpp sp-conn-end-pair.h \ - sp-cursor.cpp sp-cursor.h \ - sp-defs.cpp sp-defs.h \ - sp-desc.cpp sp-desc.h \ - sp-ellipse.cpp sp-ellipse.h \ - sp-factory.h sp-factory.cpp \ - sp-filter.cpp sp-filter.h number-opt-number.h \ - sp-filter-primitive.cpp sp-filter-primitive.h \ - sp-filter-reference.cpp sp-filter-reference.h \ - sp-filter-units.h \ - sp-flowdiv.h sp-flowdiv.cpp \ - sp-flowregion.h sp-flowregion.cpp \ - sp-flowtext.h sp-flowtext.cpp \ - sp-font.cpp sp-font.h \ - sp-font-face.cpp sp-font-face.h \ - sp-glyph.cpp sp-glyph.h \ - sp-glyph-kerning.cpp sp-glyph-kerning.h \ - sp-gradient.cpp sp-gradient.h \ - sp-gradient-reference.cpp sp-gradient-reference.h \ - sp-gradient-spread.h \ - sp-gradient-units.h \ - sp-gradient-vector.h \ - sp-guide-attachment.h \ - sp-guide-constraint.h \ - sp-guide.cpp sp-guide.h \ - sp-hatch.cpp sp-hatch.h \ - sp-hatch-path.cpp sp-hatch-path.h \ - sp-image.cpp sp-image.h \ - sp-item.cpp sp-item.h \ - sp-item-group.cpp sp-item-group.h \ - sp-item-notify-moveto.cpp sp-item-notify-moveto.h \ - sp-item-rm-unsatisfied-cns.cpp sp-item-rm-unsatisfied-cns.h \ - sp-item-transform.cpp sp-item-transform.h \ - sp-item-update-cns.cpp sp-item-update-cns.h \ - sp-linear-gradient.cpp sp-linear-gradient.h \ - sp-line.cpp sp-line.h \ - splivarot.cpp splivarot.h \ - sp-lpe-item.cpp sp-lpe-item.h \ - sp-marker.cpp sp-marker.h \ - sp-marker-loc.h \ - sp-mask.cpp sp-mask.h \ - sp-metadata.cpp sp-metadata.h \ - sp-mesh.cpp sp-mesh.h \ - sp-mesh-array.cpp sp-mesh-array.h \ - sp-mesh-patch.cpp sp-mesh-patch.h \ - sp-mesh-row.cpp sp-mesh-row.h \ - sp-missing-glyph.cpp sp-missing-glyph.h \ - sp-namedview.cpp sp-namedview.h \ - sp-object.cpp sp-object.h \ - sp-object-group.cpp sp-object-group.h \ - sp-offset.cpp sp-offset.h \ - sp-paint-server.cpp sp-paint-server.h \ - sp-paint-server-reference.h \ - sp-path.cpp sp-path.h \ - sp-pattern.cpp sp-pattern.h \ - sp-polygon.cpp sp-polygon.h \ - sp-polyline.cpp sp-polyline.h \ - sp-radial-gradient.cpp sp-radial-gradient.h \ - sp-rect.cpp sp-rect.h \ - sp-root.cpp sp-root.h \ - sp-script.cpp sp-script.h \ - sp-shape.cpp sp-shape.h \ - sp-solid-color.cpp sp-solid-color.h \ - sp-spiral.cpp sp-spiral.h \ - sp-star.cpp sp-star.h \ - sp-stop.cpp sp-stop.h \ - sp-string.cpp sp-string.h \ - sp-style-elem.cpp sp-style-elem.h \ - sp-switch.cpp sp-switch.h \ - sp-symbol.cpp sp-symbol.h \ - sp-tag.cpp sp-tag.h \ - sp-tag-use.cpp sp-tag-use.h \ - sp-tag-use-reference.cpp sp-tag-use-reference.h \ - sp-text.cpp sp-text.h \ - sp-textpath.h \ - sp-title.cpp sp-title.h \ - sp-tref.cpp sp-tref.h \ - sp-tref-reference.cpp sp-tref-reference.h \ - sp-tspan.cpp sp-tspan.h \ - sp-use.cpp sp-use.h \ - sp-use-reference.cpp sp-use-reference.h \ - streq.h \ - strneq.h \ - style.cpp style.h \ - style-enums.h \ - style-internal.cpp style-internal.h \ - svg-profile.h \ - svg-view.cpp svg-view.h \ - svg-view-widget.cpp svg-view-widget.h \ - syseq.h \ - text-chemistry.cpp text-chemistry.h \ - text-editing.cpp text-editing.h \ - text-tag-attributes.h \ - transf_mat_3x4.cpp transf_mat_3x4.h \ - unclump.cpp unclump.h \ - undo-stack-observer.h \ - unicoderange.cpp unicoderange.h \ - uri.cpp uri.h \ - uri-references.cpp uri-references.h \ - vanishing-point.cpp vanishing-point.h \ - verbs.cpp verbs.h \ - version.cpp version.h \ - viewbox.cpp viewbox.h - -# Additional dependencies - -desktop.$(OBJEXT): helper/sp-marshal.h -document.$(OBJEXT): helper/sp-marshal.h -inkscape.$(OBJEXT): helper/sp-marshal.h -knot.$(OBJEXT): helper/sp-marshal.h -selection.$(OBJEXT): helper/sp-marshal.h -sp-object.$(OBJEXT): helper/sp-marshal.h -view.$(OBJEXT): helper/sp-marshal.h - -# ###################### -# ### CxxTest stuff #### -# ###################### -CXXTEST_TESTSUITES += \ - $(srcdir)/MultiPrinter.h \ - $(srcdir)/TRPIFormatter.h \ - $(srcdir)/PylogFormatter.h \ - $(srcdir)/attributes-test.h \ - $(srcdir)/color-profile-test.h \ - $(srcdir)/dir-util-test.h \ - $(srcdir)/extract-uri-test.h \ - $(srcdir)/marker-test.h \ - $(srcdir)/mod360-test.h \ - $(srcdir)/object-test.h \ - $(srcdir)/preferences-test.h \ - $(srcdir)/round-test.h \ - $(srcdir)/sp-gradient-test.h \ - $(srcdir)/sp-style-elem-test.h \ - $(srcdir)/style-test.h \ - $(srcdir)/test-helpers.h \ - $(srcdir)/verbs-test.h diff --git a/src/attribute-rel-css.cpp b/src/attribute-rel-css.cpp index b904cd5f4..f8483d538 100644 --- a/src/attribute-rel-css.cpp +++ b/src/attribute-rel-css.cpp @@ -18,7 +18,6 @@ #include <fstream> #include <sstream> -#include <string> #include <iostream> #include "attribute-rel-css.h" diff --git a/src/attribute-rel-svg.cpp b/src/attribute-rel-svg.cpp index 0064f4c62..afa578061 100644 --- a/src/attribute-rel-svg.cpp +++ b/src/attribute-rel-svg.cpp @@ -18,7 +18,6 @@ #include <fstream> #include <sstream> -#include <string> #include "attribute-rel-svg.h" diff --git a/src/attribute-rel-util.cpp b/src/attribute-rel-util.cpp index 15c71daa7..5e770d4ae 100644 --- a/src/attribute-rel-util.cpp +++ b/src/attribute-rel-util.cpp @@ -11,7 +11,6 @@ #include <fstream> #include <sstream> -#include <string> #include <iostream> #include "preferences.h" @@ -264,6 +263,42 @@ void sp_attribute_clean_style(Node* repr, SPCSSAttr *css, unsigned int flags) { } /** + * Remove CSS style properties with default values. + */ +void sp_attribute_purge_default_style(SPCSSAttr *css, unsigned int flags) { + + g_return_if_fail (css != NULL); + + // Loop over all properties in "style" node, keeping track of which to delete. + std::set<Glib::ustring> toDelete; + for ( List<AttributeRecord const> iter = css->attributeList() ; iter ; ++iter ) { + + gchar const * property = g_quark_to_string(iter->key); + gchar const * value = iter->value; + + // If property value is same as default mark for deletion. + if ( SPAttributeRelCSS::findIfDefault( property, value ) ) { + + if ( flags & SP_ATTR_CLEAN_DEFAULT_WARN ) { + g_warning( "Preferences CSS Style property: \"%s\" with default value (%s) not needed.", + property, value ); + } + if ( flags & SP_ATTR_CLEAN_DEFAULT_REMOVE ) { + toDelete.insert( property ); + } + continue; + } + + } // End loop over style properties + + // Delete unneeded style properties. Do this at the end so as to not perturb List iterator. + for( std::set<Glib::ustring>::const_iterator iter_d = toDelete.begin(); iter_d != toDelete.end(); ++iter_d ) { + sp_repr_css_set_property( css, (*iter_d).c_str(), NULL ); + } + +} + +/** * Check one attribute on an element */ bool sp_attribute_check_attribute(Glib::ustring element, Glib::ustring id, Glib::ustring attribute, bool warn) { diff --git a/src/attribute-rel-util.h b/src/attribute-rel-util.h index 604987779..b8b1f6875 100644 --- a/src/attribute-rel-util.h +++ b/src/attribute-rel-util.h @@ -68,6 +68,11 @@ Glib::ustring sp_attribute_clean_style(Node *repr, gchar const *string, unsigned void sp_attribute_clean_style(Node* repr, SPCSSAttr *css, unsigned int flags); /** + * Remove CSS style properties with default values. + */ +void sp_attribute_purge_default_style(SPCSSAttr *css, unsigned int flags); + +/** * Check one attribute on an element */ bool sp_attribute_check_attribute(Glib::ustring element, Glib::ustring id, Glib::ustring attribute, bool warn); diff --git a/src/attribute-sort-util.cpp b/src/attribute-sort-util.cpp index 5c01f7914..7aa8d8357 100644 --- a/src/attribute-sort-util.cpp +++ b/src/attribute-sort-util.cpp @@ -11,7 +11,6 @@ #include <fstream> #include <sstream> -#include <string> #include <iostream> #include <vector> #include <utility> // std::pair @@ -21,7 +20,6 @@ #include "xml/repr.h" #include "xml/attribute-record.h" -#include "xml/sp-css-attr.h" #include "attributes.h" diff --git a/src/attributes-test.h b/src/attributes-test.h deleted file mode 100644 index bfb67064b..000000000 --- a/src/attributes-test.h +++ /dev/null @@ -1,611 +0,0 @@ - -#ifndef SEEN_ATTRIBUTES_TEST_H -#define SEEN_ATTRIBUTES_TEST_H - -#include <cxxtest/TestSuite.h> - -#include <vector> -#include <glib.h> -#include <glib/gprintf.h> -#include "attributes.h" -#include "streq.h" - -class AttributesTest : public CxxTest::TestSuite -{ -public: - - AttributesTest() - { - } - virtual ~AttributesTest() {} - -// createSuite and destroySuite get us per-suite setup and teardown -// without us having to worry about static initialization order, etc. - static AttributesTest *createSuite() { return new AttributesTest(); } - static void destroySuite( AttributesTest *suite ) { delete suite; } - - - void testAttributes() - { -/* Extracted mechanically from http://www.w3.org/TR/SVG11/attindex.html: - - tidy -wrap 999 -asxml < attindex.html 2>/dev/null | - tr -d \\n | - sed 's,<tr>,@,g' | - tr @ \\n | - sed 's,</td>.*,,;s,^<td>,,;1,/^%/d;/^%/d;s,^, {",;s/$/", false},/' | - uniq - - attindex.html lacks attributeName, begin, additive, font, marker; - I've added these manually. - - SVG 2: white-space, shape-inside, shape-outside, shape-padding, shape-margin - SVG 2: text-decoration-fill, text-decoration-stroke - SVG 2: solid-color, solid-opacity - SVG 2: Hatches and Meshes, radial gradient 'fr' - CSS 3: text-orientation - CSS 3: font-variant-xxx, font-feature-settings -*/ -struct {char const *attr; bool supported;} const all_attrs[] = { - {"attributeName", true}, - {"begin", true}, - {"additive", true}, - {"font", true}, - {"-inkscape-font-specification", true}, // TODO look into this attribute's name - {"marker", true}, - {"line-height", true}, - - {"accent-height", true}, - {"accumulate", true}, - {"alignment-baseline", true}, - {"alphabetic", true}, - {"amplitude", true}, - {"animate", false}, - {"arabic-form", true}, - {"ascent", true}, - {"attributeType", true}, - {"azimuth", true}, - {"baseFrequency", true}, - {"baseline-shift", true}, - {"baseProfile", false}, - {"bbox", true}, - {"bias", true}, - {"by", true}, - {"calcMode", true}, - {"cap-height", true}, - {"class", false}, - {"clip", true}, - {"clip-path", true}, - {"clip-rule", true}, - {"clipPathUnits", true}, - {"color", true}, - {"color-interpolation", true}, - {"color-interpolation-filters", true}, - {"color-profile", true}, - {"color-rendering", true}, - {"contentScriptType", false}, - {"contentStyleType", false}, - {"cursor", true}, - {"cx", true}, - {"cy", true}, - {"d", true}, - {"descent", true}, - {"diffuseConstant", true}, - {"direction", true}, - {"display", true}, - {"divisor", true}, - {"dominant-baseline", true}, - {"dur", true}, - {"dx", true}, - {"dy", true}, - {"edgeMode", true}, - {"elevation", true}, - {"enable-background", true}, - {"end", true}, - {"exponent", true}, - {"externalResourcesRequired", false}, - {"fill", true}, - {"fill-opacity", true}, - {"fill-rule", true}, - {"filter", true}, - {"filterRes", true}, - {"filterUnits", true}, - {"flood-color", true}, - {"flood-opacity", true}, - {"font-family", true}, - {"font-feature-settings", true}, - {"font-size", true}, - {"font-size-adjust", true}, - {"font-stretch", true}, - {"font-style", true}, - {"font-variant", true}, - {"font-variant-ligatures", true}, - {"font-variant-position", true}, - {"font-variant-caps", true}, - {"font-variant-numeric", true}, - {"font-variant-east-asian", true}, - {"font-variant-alternates", true}, - {"font-weight", true}, - {"format", false}, - {"from", true}, - {"fx", true}, - {"fy", true}, - {"fr", true}, - {"g1", true}, - {"g2", true}, - {"glyph-name", true}, - {"glyph-orientation-horizontal", true}, - {"glyph-orientation-vertical", true}, - {"glyphRef", false}, - {"gradientTransform", true}, - {"gradientUnits", true}, - {"hanging", true}, - {"height", true}, - {"horiz-adv-x", true}, - {"horiz-origin-x", true}, - {"horiz-origin-y", true}, - {"ideographic", true}, - {"image-rendering", true}, - {"in", true}, - {"in2", true}, - {"intercept", true}, - {"isolation", true}, - {"k", true}, - {"k1", true}, - {"k2", true}, - {"k3", true}, - {"k4", true}, - {"kernelMatrix", true}, - {"kernelUnitLength", true}, - {"kerning", true}, - {"keyPoints", false}, - {"keySplines", true}, - {"keyTimes", true}, - {"lang", true}, - {"lengthAdjust", true}, - {"letter-spacing", true}, - {"lighting-color", true}, - {"limitingConeAngle", true}, - {"local", true}, - {"marker-end", true}, - {"marker-mid", true}, - {"marker-start", true}, - {"markerHeight", true}, - {"markerUnits", true}, - {"markerWidth", true}, - {"mask", true}, - {"maskContentUnits", true}, - {"maskUnits", true}, - {"mathematical", true}, - {"max", true}, - {"media", false}, - {"method", false}, - {"min", true}, - {"mix-blend-mode", true}, - {"mode", true}, - {"name", true}, - {"numOctaves", true}, - {"offset", true}, - {"onabort", false}, - {"onactivate", false}, - {"onbegin", false}, - {"onclick", false}, - {"onend", false}, - {"onerror", false}, - {"onfocusin", false}, - {"onfocusout", false}, - {"onload", true}, - {"onmousedown", false}, - {"onmousemove", false}, - {"onmouseout", false}, - {"onmouseover", false}, - {"onmouseup", false}, - {"onrepeat", false}, - {"onresize", false}, - {"onscroll", false}, - {"onunload", false}, - {"onzoom", false}, - {"opacity", true}, - {"operator", true}, - {"order", true}, - {"orient", true}, - {"orientation", true}, - {"origin", false}, - {"overflow", true}, - {"overline-position", true}, - {"overline-thickness", true}, - {"paint-order", true}, - {"panose-1", true}, - {"path", true}, - {"pathLength", false}, - {"patternContentUnits", true}, - {"patternTransform", true}, - {"patternUnits", true}, - {"pointer-events", true}, - {"points", true}, - {"pointsAtX", true}, - {"pointsAtY", true}, - {"pointsAtZ", true}, - {"preserveAlpha", true}, - {"preserveAspectRatio", true}, - {"primitiveUnits", true}, - {"r", true}, - {"radius", true}, - {"refX", true}, - {"refY", true}, - {"rendering-intent", true}, - {"repeatCount", true}, - {"repeatDur", true}, - {"requiredFeatures", true}, - {"requiredExtensions", true}, - {"restart", true}, - {"result", true}, - {"rotate", true}, - {"rx", true}, - {"ry", true}, - {"scale", true}, - {"seed", true}, - {"shape-inside", true}, - {"shape-margin", true}, - {"shape-outside", true}, - {"shape-padding", true}, - {"shape-rendering", true}, - {"slope", true}, - {"spacing", false}, - {"specularConstant", true}, - {"specularExponent", true}, - {"spreadMethod", true}, - {"startOffset", true}, - {"stdDeviation", true}, - {"stemh", true}, - {"stemv", true}, - {"stitchTiles", true}, - {"stop-color", true}, - {"stop-opacity", true}, - {"strikethrough-position", true}, - {"strikethrough-thickness", true}, - {"stroke", true}, - {"stroke-dasharray", true}, - {"stroke-dashoffset", true}, - {"stroke-linecap", true}, - {"stroke-linejoin", true}, - {"stroke-miterlimit", true}, - {"stroke-opacity", true}, - {"stroke-width", true}, - {"style", true}, - {"surfaceScale", true}, - {"systemLanguage", true}, - {"tableValues", true}, - {"target", true}, - {"targetX", true}, - {"targetY", true}, - {"text-align", true}, - {"text-anchor", true}, - {"text-decoration", true}, - {"text-decoration-line", true}, - {"text-decoration-style", true}, - {"text-decoration-color", true}, - {"text-decoration-fill", true}, - {"text-decoration-stroke", true}, - {"text-indent", true}, - {"text-rendering", true}, - {"text-transform", true}, - {"textLength", true}, - {"title", false}, - {"to", true}, - {"transform", true}, - {"type", true}, - {"u1", true}, - {"u2", true}, - {"underline-position", true}, - {"underline-thickness", true}, - {"unicode", true}, - {"unicode-bidi", true}, - {"unicode-range", true}, - {"units-per-em", true}, - {"v-alphabetic", true}, - {"v-hanging", true}, - {"v-ideographic", true}, - {"v-mathematical", true}, - {"values", true}, - {"version", true}, - {"vert-adv-y", true}, - {"vert-origin-x", true}, - {"vert-origin-y", true}, - {"viewBox", true}, - {"viewTarget", false}, - {"visibility", true}, - {"white-space", true}, - {"width", true}, - {"widths", true}, - {"word-spacing", true}, - {"writing-mode", true}, - {"text-orientation", true}, - {"x", true}, - {"x-height", true}, - {"x1", true}, - {"x2", true}, - {"xChannelSelector", true}, - {"xlink:actuate", true}, - {"xlink:arcrole", true}, - {"xlink:href", true}, - {"xlink:role", true}, - {"xlink:show", true}, - {"xlink:title", true}, - {"xlink:type", true}, - {"xml:base", false}, - {"xml:space", true}, - {"xmlns", false}, - {"xmlns:xlink", false}, - {"y", true}, - {"y1", true}, - {"y2", true}, - {"yChannelSelector", true}, - {"z", true}, - {"zoomAndPan", false}, - - /* Extra attributes. */ - {"id", true}, - {"sodipodi:docname", true}, - {"sodipodi:insensitive", true}, - {"sodipodi:type", true}, - {"inkscape:collect", true}, - {"inkscape:document-units", true}, - {"inkscape:label", true}, - {"inkscape:groupmode", true}, - {"inkscape:version", true}, - {"inkscape:object-paths", true}, - - {"inkscape:original-d", true}, - {"inkscape:pageopacity", true}, - {"inkscape:pageshadow", true}, - {"inkscape:path-effect", true}, - - // SPItem - {"inkscape:transform-center-x", true}, - {"inkscape:transform-center-y", true}, - {"inkscape:highlight-color", true}, - - // Measure tool - {"inkscape:measure-start", true}, - {"inkscape:measure-end", true}, - - // Spray tool - {"inkscape:spray-origin", true}, - - // Connector tool - {"inkscape:connector-type", true}, - {"inkscape:connection-start", true}, - {"inkscape:connection-end", true}, - {"inkscape:connection-points", true}, - {"inkscape:connection-start-point", true}, - {"inkscape:connection-end-point", true}, - {"inkscape:connector-curvature", true}, - {"inkscape:connector-avoid", true}, - {"inkscape:connector-spacing", true}, - - // Ellipse, Spiral, Star - {"sodipodi:cx", true}, - {"sodipodi:cy", true}, - {"sodipodi:rx", true}, - {"sodipodi:ry", true}, - - // Box tool - {"inkscape:perspectiveID", true}, - {"inkscape:corner0", true}, - {"inkscape:corner7", true}, - {"inkscape:box3dsidetype", true}, - {"inkscape:persp3d", true}, - {"inkscape:vp_x", true}, - {"inkscape:vp_y", true}, - {"inkscape:vp_z", true}, - {"inkscape:persp3d-origin", true}, - - // Star tool - {"sodipodi:start", true}, - {"sodipodi:end", true}, - {"sodipodi:open", true}, - {"sodipodi:sides", true}, - {"sodipodi:r1", true}, - {"sodipodi:r2", true}, - {"sodipodi:arg1", true}, - {"sodipodi:arg2", true}, - {"inkscape:flatsided", true}, - {"inkscape:rounded", true}, - {"inkscape:randomized", true}, - {"sodipodi:expansion", true}, - {"sodipodi:revolution", true}, - {"sodipodi:radius", true}, - {"sodipodi:argument", true}, - {"sodipodi:t0", true}, - {"sodipodi:original", true}, - {"inkscape:original", true}, - {"inkscape:href", true}, - {"inkscape:radius", true}, - {"sodipodi:role", true}, - {"sodipodi:linespacing", true}, - {"inkscape:srcNoMarkup", true}, - {"inkscape:srcPango", true}, - {"inkscape:dstShape", true}, - {"inkscape:dstPath", true}, - {"inkscape:dstBox", true}, - {"inkscape:dstColumn", true}, - {"inkscape:excludeShape", true}, - {"inkscape:layoutOptions", true}, - {"osb:paint", true}, - - /* SPSolidColor" */ - {"solid-color", true}, - {"solid-opacity", true}, - - /* SPMeshPatch */ - {"tensor", true}, - - /* SPHash */ - {"hatchUnits", true}, - {"hatchContentUnits", true}, - {"hatchTransform", true}, - {"pitch", true}, - - /* SPNamedView */ - {"fit-margin-top", true}, - {"fit-margin-left", true}, - {"fit-margin-right", true}, - {"fit-margin-bottom", true}, - {"units", true}, - {"viewonly", true}, - {"showgrid", true}, -// {"gridtype", true}, - {"showguides", true}, -// {"inkscape:lockguides", false}, //not sure about uncomment - {"gridtolerance", true}, - {"guidetolerance", true}, - {"objecttolerance", true}, -/* {"gridoriginx", true}, - {"gridoriginy", true}, - {"gridspacingx", true}, - {"gridspacingy", true}, - {"gridanglex", true}, - {"gridanglez", true}, - {"gridcolor", true}, - {"gridopacity", true}, - {"gridempcolor", true}, - {"gridempopacity", true}, - {"gridempspacing", true}, */ - {"guidecolor", true}, - {"guideopacity", true}, - {"guidehicolor", true}, - {"guidehiopacity", true}, - {"showborder", true}, - {"inkscape:showpageshadow", true}, - {"borderlayer", true}, - {"bordercolor", true}, - {"borderopacity", true}, - {"pagecolor", true}, - - {"inkscape:zoom", true}, - {"inkscape:cx", true}, - {"inkscape:cy", true}, - {"inkscape:window-width", true}, - {"inkscape:window-height", true}, - {"inkscape:window-x", true}, - {"inkscape:window-y", true}, - {"inkscape:window-maximized", true}, - {"inkscape:current-layer", true}, - {"inkscape:pagecheckerboard", true}, - - /* SPGuide */ - {"position", true}, - {"inkscape:color", true}, - {"inkscape:lockguides", true}, - {"inkscape:locked", true}, - - /* Snapping */ - {"inkscape:snap-perpendicular", true}, - {"inkscape:snap-tangential", true}, - {"inkscape:snap-path-clip", true}, - {"inkscape:snap-path-mask", true}, - {"inkscape:object-nodes", true}, - {"inkscape:bbox-paths", true}, - {"inkscape:bbox-nodes", true}, - {"inkscape:snap-page", true}, - {"inkscape:snap-global", true}, - {"inkscape:snap-bbox", true}, - {"inkscape:snap-nodes", true}, - {"inkscape:snap-others", true}, - {"inkscape:snap-from-guide", true}, - {"inkscape:snap-center", true}, - {"inkscape:snap-smooth-nodes", true}, - {"inkscape:snap-midpoints", true}, - {"inkscape:snap-object-midpoints", true}, - {"inkscape:snap-text-baseline", true}, - {"inkscape:snap-bbox-edge-midpoints", true}, - {"inkscape:snap-bbox-midpoints", true}, - {"inkscape:snap-grids", true}, - {"inkscape:snap-to-guides", true}, - {"inkscape:snap-intersection-paths", true}, - - /* SPTag */ - {"inkscape:expanded", true} -}; - - - - std::vector<bool> ids; - ids.reserve(256); - - for (unsigned i = 0; i < G_N_ELEMENTS(all_attrs); ++i) { - char const *const attr_str = all_attrs[i].attr; - unsigned const id = sp_attribute_lookup(attr_str); - bool const recognized(id); - TSM_ASSERT_EQUALS( std::string(all_attrs[i].attr), recognized, all_attrs[i].supported ); - if (recognized) { - if (ids.size() <= id) { - ids.resize(id + 1); - } - TS_ASSERT(!ids[id]); - ids[id] = true; - - unsigned char const *reverse_ustr = sp_attribute_name(id); - char const *reverse_str = reinterpret_cast<char const *>(reverse_ustr); - TS_ASSERT(streq(reverse_str, attr_str)); - } - } - - /* Test for any attributes that this test program doesn't know about. - * - * If any are found, then: - * - * If it is in the `inkscape:' namespace then simply add it to all_attrs with - * `true' as the second field (`supported'). - * - * If it is in the `sodipodi:' namespace then check the spelling against sodipodi - * sources. If you don't have sodipodi sources, then don't add it: leave to someone - * else. - * - * Otherwise, it's probably a bug: ~all SVG 1.1 attributes should already be - * in the all_attrs table. However, the comment above all_attrs does mention - * some things missing from attindex.html, so there may be more. Check the SVG - * spec. Another possibility is that the attribute is new in SVG 1.2. In this case, - * check the spelling against the [draft] SVG 1.2 spec before adding to all_attrs. - * (If you can't be bothered checking the spec, then don't update all_attrs.) - * - * If the attribute isn't in either SVG 1.1 or 1.2 then it's probably a mistake - * for it not to be in the inkscape namespace. (Not sure about attributes used only - * on elements in the inkscape namespace though.) - * - * In any case, make sure that the attribute's source is documented accordingly. - */ - bool found = false; - unsigned const n_ids = ids.size(); - for (unsigned id = 1; id < n_ids; ++id) { - if (!ids[id]) { - gchar* tmp = g_strdup_printf( "Attribute string with enum %d {%s} not handled", id, sp_attribute_name(id) ); - TS_WARN( std::string((const char*)tmp) ); - g_free( tmp ); - found = true; - } - } - TS_ASSERT(!found); - - for ( unsigned int index = 1; index < n_ids; index++ ) { - guchar const* name = sp_attribute_name(index); - unsigned int postLookup = sp_attribute_lookup( reinterpret_cast<gchar const*>(name) ); - TSM_ASSERT_EQUALS( std::string("Enum round-trip through string {") + (char const*)name + "} failed.", index, postLookup ); - } - - } -}; - -#endif // SEEN_ATTRIBUTES_TEST_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/attributes.cpp b/src/attributes.cpp index e281dad65..b06ff6048 100644 --- a/src/attributes.cpp +++ b/src/attributes.cpp @@ -14,7 +14,6 @@ #include <glib.h> // g_assert() #include "attributes.h" -#include <iostream> typedef struct { gint code; diff --git a/src/box3d-side.cpp b/src/box3d-side.cpp index 93d55232e..14b457ea6 100644 --- a/src/box3d-side.cpp +++ b/src/box3d-side.cpp @@ -22,9 +22,7 @@ #include "persp3d.h" #include "persp3d-reference.h" #include "ui/tools/box3d-tool.h" -#include "preferences.h" #include "desktop-style.h" -#include "box3d.h" static void box3d_side_compute_corner_ids(Box3DSide *side, unsigned int corners[4]); diff --git a/src/box3d.cpp b/src/box3d.cpp index c4c2728e4..dfc4d06e7 100644 --- a/src/box3d.cpp +++ b/src/box3d.cpp @@ -23,18 +23,12 @@ #include "box3d.h" #include "box3d-side.h" #include "ui/tools/box3d-tool.h" -#include "proj_pt.h" -#include "transf_mat_3x4.h" #include "perspective-line.h" -#include "inkscape.h" -#include "persp3d.h" -#include "line-geometry.h" #include "persp3d-reference.h" #include "uri.h" #include <2geom/line.h> #include "sp-guide.h" #include "sp-namedview.h" -#include "preferences.h" #include "desktop.h" @@ -259,8 +253,8 @@ void box3d_position_set(SPBox3D *box) { /* This draws the curve and calls requestDisplayUpdate() for each side (the latter is done in box3d_side_position_set() to avoid update conflicts with the parent box) */ - for ( SPObject *obj = box->firstChild(); obj; obj = obj->getNext() ) { - Box3DSide *side = dynamic_cast<Box3DSide *>(obj); + for (auto& obj: box->children) { + Box3DSide *side = dynamic_cast<Box3DSide *>(&obj); if (side) { box3d_side_position_set(side); } @@ -275,8 +269,8 @@ Geom::Affine SPBox3D::set_transform(Geom::Affine const &xform) { gdouble const sw = hypot(ret[0], ret[1]); gdouble const sh = hypot(ret[2], ret[3]); - for ( SPObject *child = firstChild(); child; child = child->getNext() ) { - SPItem *childitem = dynamic_cast<SPItem *>(child); + for (auto& child: children) { + SPItem *childitem = dynamic_cast<SPItem *>(&child); if (childitem) { // Adjust stroke width childitem->adjust_stroke(sqrt(fabs(sw * sh))); @@ -1074,8 +1068,8 @@ box3d_recompute_z_orders (SPBox3D *box) { static std::map<int, Box3DSide *> box3d_get_sides(SPBox3D *box) { std::map<int, Box3DSide *> sides; - for ( SPObject *obj = box->firstChild(); obj; obj = obj->getNext() ) { - Box3DSide *side = dynamic_cast<Box3DSide *>(obj); + for (auto& obj: box->children) { + Box3DSide *side = dynamic_cast<Box3DSide *>(&obj); if (side) { sides[Box3D::face_to_int(side->getFaceId())] = side; } @@ -1217,8 +1211,8 @@ static void box3d_extract_boxes_rec(SPObject *obj, std::list<SPBox3D *> &boxes) if (box) { boxes.push_back(box); } else if (dynamic_cast<SPGroup *>(obj)) { - for ( SPObject *child = obj->firstChild(); child; child = child->getNext() ) { - box3d_extract_boxes_rec(child, boxes); + for (auto& child: obj->children) { + box3d_extract_boxes_rec(&child, boxes); } } } @@ -1276,8 +1270,8 @@ SPGroup *box3d_convert_to_group(SPBox3D *box) // create a new group and add the sides (converted to ordinary paths) as its children Inkscape::XML::Node *grepr = xml_doc->createElement("svg:g"); - for ( SPObject *obj = box->firstChild(); obj; obj = obj->getNext() ) { - Box3DSide *side = dynamic_cast<Box3DSide *>(obj); + for (auto& obj: box->children) { + Box3DSide *side = dynamic_cast<Box3DSide *>(&obj); if (side) { Inkscape::XML::Node *repr = box3d_side_convert_to_path(side); grepr->appendChild(repr); diff --git a/src/color-profile-test.h b/src/color-profile-test.h deleted file mode 100644 index 4276eb774..000000000 --- a/src/color-profile-test.h +++ /dev/null @@ -1,150 +0,0 @@ - -#ifndef SEEN_COLOR_PROFILE_TEST_H -#define SEEN_COLOR_PROFILE_TEST_H - -#include <cxxtest/TestSuite.h> -#include <cassert> - -#include "test-helpers.h" - - -#include "color-profile.h" -#include "cms-system.h" - -class ColorProfileTest : public CxxTest::TestSuite -{ -public: - SPDocument* _doc; - - ColorProfileTest() : - _doc(0) - { - } - - virtual ~ColorProfileTest() - { - if ( _doc ) - { - _doc->doUnref(); - } - } - - static void createSuiteSubclass( ColorProfileTest*& dst ) - { - Inkscape::ColorProfile *prof = new Inkscape::ColorProfile(); - if ( prof ) { - if ( prof->rendering_intent == (guint)Inkscape::RENDERING_INTENT_UNKNOWN ) { - TS_ASSERT_EQUALS( prof->rendering_intent, (guint)Inkscape::RENDERING_INTENT_UNKNOWN ); - dst = new ColorProfileTest(); - } - delete prof; - } - } - -// createSuite and destroySuite get us per-suite setup and teardown -// without us having to worry about static initialization order, etc. - static ColorProfileTest *createSuite() - { - ColorProfileTest* suite = Inkscape::createSuiteAndDocument<ColorProfileTest>( createSuiteSubclass ); - return suite; - } - - static void destroySuite( ColorProfileTest *suite ) - { - delete suite; - } - - // --------------------------------------------------------------- - // --------------------------------------------------------------- - // --------------------------------------------------------------- - - void testSetRenderingIntent() - { - struct { - gchar const *attr; - guint intVal; - } - const cases[] = { - {"auto", (guint)Inkscape::RENDERING_INTENT_AUTO}, - {"perceptual", (guint)Inkscape::RENDERING_INTENT_PERCEPTUAL}, - {"relative-colorimetric", (guint)Inkscape::RENDERING_INTENT_RELATIVE_COLORIMETRIC}, - {"saturation", (guint)Inkscape::RENDERING_INTENT_SATURATION}, - {"absolute-colorimetric", (guint)Inkscape::RENDERING_INTENT_ABSOLUTE_COLORIMETRIC}, - {"something-else", (guint)Inkscape::RENDERING_INTENT_UNKNOWN}, - {"auto2", (guint)Inkscape::RENDERING_INTENT_UNKNOWN}, - }; - - Inkscape::ColorProfile *prof = new Inkscape::ColorProfile(); - TS_ASSERT( prof ); - SP_OBJECT(prof)->document = _doc; - - for ( size_t i = 0; i < G_N_ELEMENTS( cases ); i++ ) { - std::string descr(cases[i].attr); - SP_OBJECT(prof)->setKeyValue( SP_ATTR_RENDERING_INTENT, cases[i].attr); - TSM_ASSERT_EQUALS( descr, prof->rendering_intent, (guint)cases[i].intVal ); - } - - delete prof; - } - - void testSetLocal() - { - gchar const* cases[] = { - "local", - "something", - }; - - Inkscape::ColorProfile *prof = new Inkscape::ColorProfile(); - TS_ASSERT( prof ); - SP_OBJECT(prof)->document = _doc; - - for ( size_t i = 0; i < G_N_ELEMENTS( cases ); i++ ) { - SP_OBJECT(prof)->setKeyValue( SP_ATTR_LOCAL, cases[i]); - TS_ASSERT( prof->local ); - if ( prof->local ) { - TS_ASSERT_EQUALS( std::string(prof->local), std::string(cases[i]) ); - } - } - SP_OBJECT(prof)->setKeyValue( SP_ATTR_LOCAL, NULL); - TS_ASSERT_EQUALS( prof->local, (gchar*)0 ); - - delete prof; - } - - void testSetName() - { - gchar const* cases[] = { - "name", - "something", - }; - - Inkscape::ColorProfile *prof = new Inkscape::ColorProfile(); - TS_ASSERT( prof ); - SP_OBJECT(prof)->document = _doc; - - for ( size_t i = 0; i < G_N_ELEMENTS( cases ); i++ ) { - SP_OBJECT(prof)->setKeyValue( SP_ATTR_NAME, cases[i]); - TS_ASSERT( prof->name ); - if ( prof->name ) { - TS_ASSERT_EQUALS( std::string(prof->name), std::string(cases[i]) ); - } - } - SP_OBJECT(prof)->setKeyValue( SP_ATTR_NAME, NULL); - TS_ASSERT_EQUALS( prof->name, (gchar*)0 ); - - delete prof; - } -}; - -#endif // SEEN_COLOR_PROFILE_TEST_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/color-profile.cpp b/src/color-profile.cpp index aea9ccab0..51b1505c5 100644 --- a/src/color-profile.cpp +++ b/src/color-profile.cpp @@ -4,13 +4,8 @@ #define noDEBUG_LCMS -#if WITH_GTKMM_3_0 -# include <gdkmm/rgba.h> -#else -# include <gdkmm/color.h> -#endif +#include <gdkmm/rgba.h> -#include <glibmm/checksum.h> #include <glib/gstdio.h> #include <fcntl.h> #include <glib/gi18n.h> @@ -21,7 +16,6 @@ #include <unistd.h> #include <cstring> -#include <string> #include <io/sys.h> #ifdef WIN32 @@ -46,15 +40,14 @@ #include "inkscape.h" #include "document.h" #include "preferences.h" - +#include <glibmm/checksum.h> +#include <glibmm/convert.h> #include "uri.h" #ifdef WIN32 #include <icm.h> #endif // WIN32 -#include <glibmm/convert.h> - using Inkscape::ColorProfile; using Inkscape::ColorProfileImpl; @@ -589,9 +582,9 @@ bool ColorProfile::GamutCheck(SPColor color) static_cast<guchar>(SP_RGBA32_B_U(val)), 255}; - cmsHTRANSFORM gamutCheck = ColorProfile::getTransfGamutCheck();
- if (gamutCheck) {
- cmsDoTransform(gamutCheck, &check_color, &outofgamut, 1);
+ cmsHTRANSFORM gamutCheck = ColorProfile::getTransfGamutCheck(); + if (gamutCheck) { + cmsDoTransform(gamutCheck, &check_color, &outofgamut, 1); } #if HAVE_LIBLCMS1 @@ -620,8 +613,6 @@ private: cmsProfileClassSignature _profileClass; }; -#include <iostream> - ProfileInfo::ProfileInfo( cmsHPROFILE prof, Glib::ustring const & path ) : _path( path ), _name( getNameFromProfile(prof) ), @@ -1002,11 +993,7 @@ void loadProfiles() static bool gamutWarn = false; -#if WITH_GTKMM_3_0 static Gdk::RGBA lastGamutColor("#808080"); -#else -static Gdk::Color lastGamutColor("#808080"); -#endif static bool lastBPC = false; #if defined(cmsFLAGS_PRESERVEBLACK) @@ -1152,12 +1139,7 @@ cmsHTRANSFORM Inkscape::CMSSystem::getDisplayTransform() bool preserveBlack = prefs->getBool( "/options/softproof/preserveblack"); #endif //defined(cmsFLAGS_PRESERVEBLACK) Glib::ustring colorStr = prefs->getString("/options/softproof/gamutcolor"); - -#if WITH_GTKMM_3_0 Gdk::RGBA gamutColor( colorStr.empty() ? "#808080" : colorStr ); -#else - Gdk::Color gamutColor( colorStr.empty() ? "#808080" : colorStr ); -#endif if ( (warn != gamutWarn) || (lastIntent != intent) @@ -1189,15 +1171,9 @@ cmsHTRANSFORM Inkscape::CMSSystem::getDisplayTransform() if ( gamutWarn ) { dwFlags |= cmsFLAGS_GAMUTCHECK; -#if WITH_GTKMM_3_0 - gushort gamutColor_r = gamutColor.get_red_u(); - gushort gamutColor_g = gamutColor.get_green_u(); - gushort gamutColor_b = gamutColor.get_blue_u(); -#else - gushort gamutColor_r = gamutColor.get_red(); - gushort gamutColor_g = gamutColor.get_green(); - gushort gamutColor_b = gamutColor.get_blue(); -#endif + auto gamutColor_r = gamutColor.get_red_u(); + auto gamutColor_g = gamutColor.get_green_u(); + auto gamutColor_b = gamutColor.get_blue_u(); #if HAVE_LIBLCMS1 cmsSetAlarmCodes(gamutColor_r >> 8, gamutColor_g >> 8, gamutColor_b >> 8); @@ -1338,12 +1314,7 @@ cmsHTRANSFORM Inkscape::CMSSystem::getDisplayPer( Glib::ustring const& id ) bool preserveBlack = prefs->getBool( "/options/softproof/preserveblack"); #endif //defined(cmsFLAGS_PRESERVEBLACK) Glib::ustring colorStr = prefs->getString("/options/softproof/gamutcolor"); - -#if WITH_GTKMM_3_0 Gdk::RGBA gamutColor( colorStr.empty() ? "#808080" : colorStr ); -#else - Gdk::Color gamutColor( colorStr.empty() ? "#808080" : colorStr ); -#endif if ( (warn != gamutWarn) || (lastIntent != intent) @@ -1373,16 +1344,9 @@ cmsHTRANSFORM Inkscape::CMSSystem::getDisplayPer( Glib::ustring const& id ) cmsUInt32Number dwFlags = cmsFLAGS_SOFTPROOFING; if ( gamutWarn ) { dwFlags |= cmsFLAGS_GAMUTCHECK; - -#if WITH_GTKMM_3_0 - gushort gamutColor_r = gamutColor.get_red_u(); - gushort gamutColor_g = gamutColor.get_green_u(); - gushort gamutColor_b = gamutColor.get_blue_u(); -#else - gushort gamutColor_r = gamutColor.get_red(); - gushort gamutColor_g = gamutColor.get_green(); - gushort gamutColor_b = gamutColor.get_blue(); -#endif + auto gamutColor_r = gamutColor.get_red_u(); + auto gamutColor_g = gamutColor.get_green_u(); + auto gamutColor_b = gamutColor.get_blue_u(); #if HAVE_LIBLCMS1 cmsSetAlarmCodes(gamutColor_r >> 8, gamutColor_g >> 8, gamutColor_b >> 8); diff --git a/src/conn-avoid-ref.cpp b/src/conn-avoid-ref.cpp index 9190fe633..71743fda5 100644 --- a/src/conn-avoid-ref.cpp +++ b/src/conn-avoid-ref.cpp @@ -18,17 +18,12 @@ #include "sp-item.h" #include "display/curve.h" #include "2geom/line.h" -#include "2geom/crossing.h" #include "2geom/convex-hull.h" -#include "helper/geom-curves.h" #include "svg/stringstream.h" #include "conn-avoid-ref.h" #include "sp-conn-end.h" #include "sp-path.h" #include "libavoid/router.h" -#include "libavoid/connector.h" -#include "libavoid/geomtypes.h" -#include "libavoid/shape.h" #include "xml/node.h" #include "document.h" #include "desktop.h" @@ -38,7 +33,6 @@ #include "sp-item-group.h" #include "inkscape.h" #include "verbs.h" -#include <glibmm/i18n.h> using Inkscape::DocumentUndo; @@ -334,19 +328,19 @@ static Avoid::Polygon avoid_item_poly(SPItem const *item) std::vector<SPItem *> get_avoided_items(std::vector<SPItem *> &list, SPObject *from, SPDesktop *desktop, bool initialised) { - for (SPObject *child = from->firstChild() ; child != NULL; child = child->next ) { - if (SP_IS_ITEM(child) && - !desktop->isLayer(SP_ITEM(child)) && - !SP_ITEM(child)->isLocked() && - !desktop->itemIsHidden(SP_ITEM(child)) && - (!initialised || SP_ITEM(child)->avoidRef->shapeRef) + for (auto& child: from->children) { + if (SP_IS_ITEM(&child) && + !desktop->isLayer(SP_ITEM(&child)) && + !SP_ITEM(&child)->isLocked() && + !desktop->itemIsHidden(SP_ITEM(&child)) && + (!initialised || SP_ITEM(&child)->avoidRef->shapeRef) ) { - list.push_back(SP_ITEM(child)); + list.push_back(SP_ITEM(&child)); } - if (SP_IS_ITEM(child) && desktop->isLayer(SP_ITEM(child))) { - list = get_avoided_items(list, child, desktop, initialised); + if (SP_IS_ITEM(&child) && desktop->isLayer(SP_ITEM(&child))) { + list = get_avoided_items(list, &child, desktop, initialised); } } diff --git a/src/context-fns.cpp b/src/context-fns.cpp index e1df53d98..46bd19cb3 100644 --- a/src/context-fns.cpp +++ b/src/context-fns.cpp @@ -6,7 +6,6 @@ #include "message-context.h" #include "message-stack.h" #include "snap.h" -#include "sp-item.h" #include "sp-namedview.h" #include "ui/tools/tool-base.h" diff --git a/src/cxxtest-template.tpl b/src/cxxtest-template.tpl deleted file mode 100644 index df20bebfd..000000000 --- a/src/cxxtest-template.tpl +++ /dev/null @@ -1,13 +0,0 @@ -// -*- C++ -*- -// - -#include "MultiPrinter.h" - -int main( int argc, char *argv[] ) -{ - (void)argc; - return CxxTest::MultiPrinter( argv[0] ).run(); -} - -// The CxxTest "world" -<CxxTest world> diff --git a/src/debug/Makefile_insert b/src/debug/Makefile_insert deleted file mode 100644 index 47cc2b704..000000000 --- a/src/debug/Makefile_insert +++ /dev/null @@ -1,15 +0,0 @@ -## Makefile.am fragment sourced by src/Makefile.am. - -ink_common_sources += \ - debug/demangle.cpp debug/demangle.h \ - debug/event.h \ - debug/event-tracker.h \ - debug/heap.cpp debug/heap.h \ - debug/gc-heap.h \ - debug/logger.cpp debug/logger.h \ - debug/log-display-config.cpp debug/log-display-config.h \ - debug/simple-event.h \ - debug/sysv-heap.cpp debug/sysv-heap.h \ - debug/gdk-event-latency-tracker.cpp debug/gdk-event-latency-tracker.h \ - debug/timestamp.cpp debug/timestamp.h - diff --git a/src/desktop-events.cpp b/src/desktop-events.cpp index b9bd949ff..5fef8cbfc 100644 --- a/src/desktop-events.cpp +++ b/src/desktop-events.cpp @@ -21,7 +21,10 @@ #include "ui/dialog/guides.h" #include "desktop-events.h" -#if WITH_GTKMM_3_0 +#include <gdkmm/display.h> +#if GTK_CHECK_VERSION(3, 20, 0) +# include <gdkmm/seat.h> +#else # include <gdkmm/devicemanager.h> #endif @@ -97,14 +100,9 @@ static gint sp_dt_ruler_event(GtkWidget *widget, GdkEvent *event, SPDesktopWidge gint width, height; -#if GTK_CHECK_VERSION(3,0,0) - GdkDevice *device = gdk_event_get_device(event); + auto device = gdk_event_get_device(event); gdk_window_get_device_position(window, device, &wx, &wy, NULL); gdk_window_get_geometry(window, NULL /*x*/, NULL /*y*/, &width, &height); -#else - gdk_window_get_pointer(window, &wx, &wy, NULL); - gdk_window_get_geometry(window, NULL /*x*/, NULL /*y*/, &width, &height, NULL/*depth*/); -#endif Geom::Point const event_win(wx, wy); @@ -160,7 +158,6 @@ static gint sp_dt_ruler_event(GtkWidget *widget, GdkEvent *event, SPDesktopWidge guide = sp_guideline_new(desktop->guides, NULL, event_dt, normal); sp_guideline_set_color(SP_GUIDELINE(guide), desktop->namedview->guidehicolor); -#if GTK_CHECK_VERSION(3,0,0) gdk_device_grab(device, gtk_widget_get_window(widget), GDK_OWNERSHIP_NONE, @@ -168,12 +165,6 @@ static gint sp_dt_ruler_event(GtkWidget *widget, GdkEvent *event, SPDesktopWidge (GdkEventMask)(GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK ), NULL, event->button.time); -#else - gdk_pointer_grab(gtk_widget_get_window (widget), FALSE, - (GdkEventMask)(GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK ), - NULL, NULL, - event->button.time); -#endif } break; case GDK_MOTION_NOTIFY: @@ -208,11 +199,7 @@ static gint sp_dt_ruler_event(GtkWidget *widget, GdkEvent *event, SPDesktopWidge if (clicked && event->button.button == 1) { sp_event_context_discard_delayed_snap_event(desktop->event_context); -#if GTK_CHECK_VERSION(3,0,0) gdk_device_ungrab(device, event->button.time); -#else - gdk_pointer_ungrab(event->button.time); -#endif Geom::Point const event_w(sp_canvas_window_to_world(dtw->canvas, event_win)); Geom::Point event_dt(desktop->w2d(event_w)); @@ -537,11 +524,7 @@ gint sp_dt_guide_event(SPCanvasItem *item, GdkEvent *event, gpointer data) guide_cursor = sp_cursor_new_from_xpm(cursor_select_xpm , 1, 1); } gdk_window_set_cursor(gtk_widget_get_window (GTK_WIDGET(desktop->getCanvas())), guide_cursor); -#if GTK_CHECK_VERSION(3,0,0) g_object_unref(guide_cursor); -#else - gdk_cursor_unref(guide_cursor); -#endif char *guide_description = guide->description(); desktop->guidesMessageContext()->setF(Inkscape::NORMAL_MESSAGE, _("<b>Guideline</b>: %s"), guide_description); @@ -575,11 +558,7 @@ gint sp_dt_guide_event(SPCanvasItem *item, GdkEvent *event, gpointer data) GdkDisplay *display = gdk_display_get_default(); GdkCursor *guide_cursor = gdk_cursor_new_for_display(display, GDK_EXCHANGE); gdk_window_set_cursor(gtk_widget_get_window (GTK_WIDGET(desktop->getCanvas())), guide_cursor); -#if GTK_CHECK_VERSION(3,0,0) g_object_unref(guide_cursor); -#else - gdk_cursor_unref(guide_cursor); -#endif ret = TRUE; break; } @@ -597,11 +576,7 @@ gint sp_dt_guide_event(SPCanvasItem *item, GdkEvent *event, gpointer data) GdkDisplay *display = gdk_display_get_default(); GdkCursor *guide_cursor = gdk_cursor_new_for_display(display, GDK_EXCHANGE); gdk_window_set_cursor(gtk_widget_get_window (GTK_WIDGET(desktop->getCanvas())), guide_cursor); -#if GTK_CHECK_VERSION(3,0,0) g_object_unref(guide_cursor); -#else - gdk_cursor_unref(guide_cursor); -#endif break; } default: @@ -624,19 +599,20 @@ static GdkInputSource lastType = GDK_SOURCE_MOUSE; static void init_extended() { Glib::ustring avoidName("pad"); - Glib::RefPtr<Gdk::Display> display = Gdk::Display::get_default(); + auto display = Gdk::Display::get_default(); -#if GTK_CHECK_VERSION(3,0,0) - Glib::RefPtr<const Gdk::DeviceManager> dm = display->get_device_manager(); - std::vector< Glib::RefPtr<const Gdk::Device> > devices = dm->list_devices(Gdk::DEVICE_TYPE_SLAVE); +#if GTK_CHECK_VERSION(3, 20, 0) + auto seat = display->get_default_seat(); + auto const devices = seat->get_slaves(Gdk::SEAT_CAPABILITY_ALL); #else - std::vector< Glib::RefPtr<const Gdk::Device> > devices = display->list_devices(); + auto dm = display->get_device_manager(); + auto const devices = dm->list_devices(Gdk::DEVICE_TYPE_SLAVE); #endif if ( !devices.empty() ) { - for ( std::vector< Glib::RefPtr<const Gdk::Device> >::const_iterator dev = devices.begin(); dev != devices.end(); ++dev ) { - Glib::ustring const devName = (*dev)->get_name(); - Gdk::InputSource devSrc = (*dev)->get_source(); + for (auto const dev : devices) { + auto const devName = dev->get_name(); + auto devSrc = dev->get_source(); if ( !devName.empty() && (avoidName != devName) diff --git a/src/desktop-style.cpp b/src/desktop-style.cpp index 7f9b46c7d..81aa95b48 100644 --- a/src/desktop-style.cpp +++ b/src/desktop-style.cpp @@ -24,11 +24,7 @@ #include "selection.h" #include "inkscape.h" #include "style.h" -#include "preferences.h" -#include "sp-use.h" #include "filters/blend.h" -#include "sp-filter.h" -#include "sp-filter-reference.h" #include "filters/gaussian-blur.h" #include "sp-flowtext.h" #include "sp-flowregion.h" @@ -39,15 +35,12 @@ #include "sp-textpath.h" #include "sp-tref.h" #include "sp-tspan.h" -#include "xml/repr.h" #include "xml/sp-css-attr.h" #include "sp-path.h" #include "ui/tools/tool-base.h" #include "desktop-style.h" -#include "svg/svg-icc-color.h" #include "box3d-side.h" -#include <2geom/math-utils.h> namespace { @@ -163,17 +156,17 @@ sp_desktop_apply_css_recursive(SPObject *o, SPCSSAttr *css, bool skip_lines) return; } - for ( SPObject *child = o->firstChild() ; child ; child = child->getNext() ) { + for (auto& child: o->children) { if (sp_repr_css_property(css, "opacity", NULL) != NULL) { // Unset properties which are accumulating and thus should not be set recursively. // For example, setting opacity 0.5 on a group recursively would result in the visible opacity of 0.25 for an item in the group. SPCSSAttr *css_recurse = sp_repr_css_attr_new(); sp_repr_css_merge(css_recurse, css); sp_repr_css_set_property(css_recurse, "opacity", NULL); - sp_desktop_apply_css_recursive(child, css_recurse, skip_lines); + sp_desktop_apply_css_recursive(&child, css_recurse, skip_lines); sp_repr_css_attr_unref(css_recurse); } else { - sp_desktop_apply_css_recursive(child, css, skip_lines); + sp_desktop_apply_css_recursive(&child, css, skip_lines); } } } @@ -194,8 +187,8 @@ sp_desktop_set_style(SPDesktop *desktop, SPCSSAttr *css, bool change, bool write sp_repr_css_merge(css_write, css); sp_css_attr_unset_uris(css_write); prefs->mergeStyle("/desktop/style", css_write); - std::vector<SPItem*> const itemlist = desktop->selection->itemList(); - for (std::vector<SPItem*>::const_iterator i = itemlist.begin(); i!= itemlist.end(); ++i) { + auto itemlist = desktop->selection->items(); + for (auto i = itemlist.begin(); i!= itemlist.end(); ++i) { /* last used styles for 3D box faces are stored separately */ SPObject *obj = *i; Box3DSide *side = dynamic_cast<Box3DSide *>(obj); @@ -234,8 +227,8 @@ sp_desktop_set_style(SPDesktop *desktop, SPCSSAttr *css, bool change, bool write sp_repr_css_merge(css_no_text, css); css_no_text = sp_css_attr_unset_text(css_no_text); - std::vector<SPItem*> const itemlist = desktop->selection->itemList(); - for (std::vector<SPItem*>::const_iterator i = itemlist.begin(); i!= itemlist.end(); ++i) { + auto itemlist = desktop->selection->items(); + for (auto i = itemlist.begin(); i!= itemlist.end(); ++i) { SPItem *item = *i; // If not text, don't apply text attributes (can a group have text attributes? Yes! FIXME) @@ -1714,10 +1707,11 @@ objects_query_blend (const std::vector<SPItem*> &objects, SPStyle *style_res) int blendcount = 0; // determine whether filter is simple (blend and/or blur) or complex - for(SPObject *primitive_obj = style->getFilter()->children; - primitive_obj && dynamic_cast<SPFilterPrimitive *>(primitive_obj); - primitive_obj = primitive_obj->next) { - SPFilterPrimitive *primitive = dynamic_cast<SPFilterPrimitive *>(primitive_obj); + for(auto& primitive_obj: style->getFilter()->children) { + SPFilterPrimitive *primitive = dynamic_cast<SPFilterPrimitive *>(&primitive_obj); + if (!primitive) { + break; + } if (dynamic_cast<SPFeBlend *>(primitive)) { ++blendcount; } else if (dynamic_cast<SPGaussianBlur *>(primitive)) { @@ -1730,10 +1724,12 @@ objects_query_blend (const std::vector<SPItem*> &objects, SPStyle *style_res) // simple filter if(blurcount == 1 || blendcount == 1) { - for(SPObject *primitive_obj = style->getFilter()->children; - primitive_obj && dynamic_cast<SPFilterPrimitive *>(primitive_obj); - primitive_obj = primitive_obj->next) { - SPFeBlend *spblend = dynamic_cast<SPFeBlend *>(primitive_obj); + for(auto& primitive_obj: style->getFilter()->children) { + SPFilterPrimitive *primitive = dynamic_cast<SPFilterPrimitive *>(&primitive_obj); + if (!primitive) { + break; + } + SPFeBlend *spblend = dynamic_cast<SPFeBlend *>(&primitive_obj); if (spblend) { blend = spblend->blend_mode; } @@ -1807,9 +1803,8 @@ objects_query_blur (const std::vector<SPItem*> &objects, SPStyle *style_res) //if object has a filter if (style->filter.set && style->getFilter()) { //cycle through filter primitives - SPObject *primitive_obj = style->getFilter()->children; - while (primitive_obj) { - SPFilterPrimitive *primitive = dynamic_cast<SPFilterPrimitive *>(primitive_obj); + for(auto& primitive_obj: style->getFilter()->children) { + SPFilterPrimitive *primitive = dynamic_cast<SPFilterPrimitive *>(&primitive_obj); if (primitive) { //if primitive is gaussianblur @@ -1827,7 +1822,6 @@ objects_query_blur (const std::vector<SPItem*> &objects, SPStyle *style_res) } } } - primitive_obj = primitive_obj->next; } } } @@ -1917,7 +1911,8 @@ sp_desktop_query_style(SPDesktop *desktop, SPStyle *style, int property) // otherwise, do querying and averaging over selection if (desktop->selection != NULL) { - return sp_desktop_query_style_from_list (desktop->selection->itemList(), style, property); + std::vector<SPItem *> vec(desktop->selection->items().begin(), desktop->selection->items().end()); + return sp_desktop_query_style_from_list (vec, style, property); } return QUERY_STYLE_NOTHING; diff --git a/src/desktop.cpp b/src/desktop.cpp index d482d0d7f..7efa3e438 100644 --- a/src/desktop.cpp +++ b/src/desktop.cpp @@ -23,12 +23,11 @@ #ifdef HAVE_CONFIG_H -# include "config.h" +#include <config.h> #endif #include "ui/dialog/dialog-manager.h" #include <glibmm/i18n.h> -#include <sigc++/functors/mem_fun.h> #include <2geom/transforms.h> #include <2geom/rect.h> @@ -45,35 +44,24 @@ #include "display/canvas-temporary-item-list.h" #include "display/drawing-group.h" #include "display/gnome-canvas-acetate.h" -#include "display/drawing.h" #include "display/snap-indicator.h" #include "display/sodipodi-ctrlrect.h" #include "display/sp-canvas-group.h" -#include "display/sp-canvas.h" #include "display/sp-canvas-util.h" -#include "document.h" #include "document-undo.h" #include "event-log.h" #include "helper/action-context.h" #include "ui/interface.h" #include "layer-fns.h" #include "layer-manager.h" -#include "layer-model.h" -#include "macros.h" #include "message-context.h" #include "message-stack.h" -#include "preferences.h" #include "resource-manager.h" #include "ui/tools/select-tool.h" -#include "selection.h" -#include "sp-item-group.h" -#include "sp-item-group.h" #include "sp-namedview.h" #include "sp-root.h" -#include "sp-defs.h" #include "ui/tool-factory.h" #include "widgets/desktop-widget.h" -#include "xml/repr.h" #include "helper/action.h" //sp_action_perform // TODO those includes are only for node tool quick zoom. Remove them after fixing it. @@ -1444,11 +1432,7 @@ void SPDesktop::setWaitingCursor() GdkDisplay *display = gdk_display_get_default(); GdkCursor *waiting = gdk_cursor_new_for_display(display, GDK_WATCH); gdk_window_set_cursor(gtk_widget_get_window(GTK_WIDGET(getCanvas())), waiting); -#if GTK_CHECK_VERSION(3,0,0) g_object_unref(waiting); -#else - gdk_cursor_unref(waiting); -#endif // GDK needs the flush for the cursor change to take effect gdk_flush(); waiting_cursor = true; diff --git a/src/device-manager.cpp b/src/device-manager.cpp index aa3874da8..6c8d4514c 100644 --- a/src/device-manager.cpp +++ b/src/device-manager.cpp @@ -8,21 +8,24 @@ */ #include "device-manager.h" -#include <map> + #include <set> #include "preferences.h" -#include <gdkmm/display.h> -#include <gtkmm/accelkey.h> - -#if WITH_GTKMM_3_0 -# include <gdkmm/devicemanager.h> -#endif #include <glibmm/regex.h> #include <gtk/gtk.h> +#include <gdkmm/display.h> +#if GTK_CHECK_VERSION(3, 20, 0) +# include <gdkmm/seat.h> +#else +# include <gdkmm/devicemanager.h> +#endif + +#include <gtkmm/accelkey.h> + #define noDEBUG_VERBOSE 1 @@ -49,11 +52,7 @@ static bool isValidDevice(Glib::RefPtr<Gdk::Device> device) const bool source_matches = (device->get_source() == (*it).source); const bool mode_matches = (device->get_mode() == (*it).mode); const bool num_axes_matches = (device->get_n_axes() == (*it).num_axes); -#if WITH_GTKMM_3_0 const bool num_keys_matches = (device->get_n_keys() == (*it).num_keys); -#else - const bool num_keys_matches = (gdk_device_get_n_keys(device->gobj()) == (*it).num_keys); -#endif if (name_matches && source_matches && mode_matches && num_axes_matches && num_keys_matches) @@ -177,13 +176,7 @@ public: virtual Gdk::InputMode getMode() const {return (device->get_mode());} virtual gint getNumAxes() const {return device->get_n_axes();} virtual bool hasCursor() const {return device->get_has_cursor();} - -#if WITH_GTKMM_3_0 virtual int getNumKeys() const {return device->get_n_keys();} -#else - virtual int getNumKeys() const {return gdk_device_get_n_keys(device->gobj());} -#endif - virtual Glib::ustring getLink() const {return link;} virtual void setLink( Glib::ustring const& link ) {this->link = link;} virtual gint getLiveAxes() const {return liveAxes;} @@ -328,11 +321,12 @@ DeviceManagerImpl::DeviceManagerImpl() : { Glib::RefPtr<Gdk::Display> display = Gdk::Display::get_default(); -#if WITH_GTKMM_3_0 - Glib::RefPtr<Gdk::DeviceManager> dm = display->get_device_manager(); - std::vector< Glib::RefPtr<Gdk::Device> > devList = dm->list_devices(Gdk::DEVICE_TYPE_SLAVE); +#if GTK_CHECK_VERSION(3, 20, 0) + auto seat = display->get_default_seat(); + auto devList = seat->get_slaves(Gdk::SEAT_CAPABILITY_ALL); #else - std::vector< Glib::RefPtr<Gdk::Device> > devList = display->list_devices(); + auto dm = display->get_device_manager(); + auto devList = dm->list_devices(Gdk::DEVICE_TYPE_SLAVE); #endif if (fakeList.empty()) { @@ -342,24 +336,19 @@ DeviceManagerImpl::DeviceManagerImpl() : std::set<Glib::ustring> knownIDs; - for ( std::vector< Glib::RefPtr<Gdk::Device> >::iterator dev = devList.begin(); dev != devList.end(); ++dev ) { -#if WITH_GTKMM_3_0 + for (auto dev : devList) { // GTK+ 3 has added keyboards to the list of supported devices. - if((*dev)->get_source() != Gdk::SOURCE_KEYBOARD) { -#endif + if(dev->get_source() != Gdk::SOURCE_KEYBOARD) { #if DEBUG_VERBOSE g_message("device: name[%s] source[0x%x] mode[0x%x] cursor[%s] axis count[%d] key count[%d]", dev->name, dev->source, dev->mode, dev->has_cursor?"Yes":"no", dev->num_axes, dev->num_keys); #endif - InputDeviceImpl* device = new InputDeviceImpl(*dev, knownIDs); + InputDeviceImpl* device = new InputDeviceImpl(dev, knownIDs); device->reference(); devices.push_back(Glib::RefPtr<InputDeviceImpl>(device)); - -#if WITH_GTKMM_3_0 } -#endif } } @@ -669,11 +658,12 @@ static void createFakeList() { // try to find the first *real* core pointer Glib::RefPtr<Gdk::Display> display = Gdk::Display::get_default(); -#if WITH_GTKMM_3_0 - Glib::RefPtr<Gdk::DeviceManager> dm = display->get_device_manager(); - std::vector< Glib::RefPtr<Gdk::Device> > devList = dm->list_devices(Gdk::DEVICE_TYPE_SLAVE); +#if GTK_CHECK_VERSION(3, 20, 0) + auto seat = display->get_default_seat(); + auto devList = seat->get_slaves(Gdk::SEAT_CAPABILITY_ALL); #else - std::vector< Glib::RefPtr<Gdk::Device> > devList = display->list_devices(); + auto dm = display->get_device_manager(); + auto devList = dm->list_devices(Gdk::DEVICE_TYPE_SLAVE); #endif // Set iterator to point at beginning of device list @@ -691,11 +681,7 @@ static void createFakeList() { fakeList[4].mode = device->get_mode(); fakeList[4].has_cursor = device->get_has_cursor(); fakeList[4].num_axes = device->get_n_axes(); -#if WITH_GTKMM_3_0 fakeList[4].num_keys = device->get_n_keys(); -#else - fakeList[4].num_keys = gdk_device_get_n_keys(device->gobj()); -#endif } else { fakeList[4].name = "Core Pointer"; fakeList[4].source = Gdk::SOURCE_MOUSE; diff --git a/src/dir-util-test.h b/src/dir-util-test.h deleted file mode 100644 index 735f0174e..000000000 --- a/src/dir-util-test.h +++ /dev/null @@ -1,56 +0,0 @@ - -#ifndef SEEN_DIR_UTIL_TEST_H -#define SEEN_DIR_UTIL_TEST_H - -#include <cxxtest/TestSuite.h> - -#include "dir-util.h" - -class DirUtilTest : public CxxTest::TestSuite -{ -public: - void testBase() - { - char const* cases[][3] = { -#if defined(WIN32) || defined(__WIN32__) - {"\\foo\\bar", "\\foo", "bar"}, - {"\\foo\\barney", "\\foo\\bar", "\\foo\\barney"}, - {"\\foo\\bar\\baz", "\\foo\\", "bar\\baz"}, - {"\\foo\\bar\\baz", "\\", "foo\\bar\\baz"}, - {"\\foo\\bar\\baz", "\\foo\\qux", "\\foo\\bar\\baz"}, -#else - {"/foo/bar", "/foo", "bar"}, - {"/foo/barney", "/foo/bar", "/foo/barney"}, - {"/foo/bar/baz", "/foo/", "bar/baz"}, - {"/foo/bar/baz", "/", "foo/bar/baz"}, - {"/foo/bar/baz", "/foo/qux", "/foo/bar/baz"}, -#endif - }; - - for ( size_t i = 0; i < G_N_ELEMENTS(cases); i++ ) - { - if ( cases[i][0] && cases[i][1] ) { // std::string can't use null. - std::string result = sp_relative_path_from_path( cases[i][0], cases[i][1] ); - TS_ASSERT( !result.empty() ); - if ( !result.empty() ) - { - TS_ASSERT_EQUALS( result, std::string(cases[i][2]) ); - } - } - } - } - -}; - -#endif // SEEN_DIR_UTIL_TEST_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/display/Makefile_insert b/src/display/Makefile_insert deleted file mode 100644 index 419852f7d..000000000 --- a/src/display/Makefile_insert +++ /dev/null @@ -1,125 +0,0 @@ -## Makefile.am fragment sourced by src/Makefile.am. - -display/canvas-arena.$(OBJEXT): helper/sp-marshal.h -display/sp-canvas.$(OBJEXT): helper/sp-marshal.h - -ink_common_sources += \ - display/cairo-templates.h \ - display/cairo-utils.cpp \ - display/cairo-utils.h \ - display/canvas-arena.cpp \ - display/canvas-arena.h \ - display/canvas-axonomgrid.cpp \ - display/canvas-axonomgrid.h \ - display/canvas-bpath.cpp \ - display/canvas-bpath.h \ - display/canvas-grid.cpp \ - display/canvas-grid.h \ - display/canvas-temporary-item.cpp \ - display/canvas-temporary-item.h \ - display/canvas-temporary-item-list.cpp \ - display/canvas-temporary-item-list.h \ - display/canvas-text.cpp \ - display/canvas-text.h \ - display/curve.cpp \ - display/curve.h \ - display/drawing.cpp \ - display/drawing.h \ - display/drawing-context.cpp \ - display/drawing-context.h \ - display/drawing-group.cpp \ - display/drawing-group.h \ - display/drawing-image.cpp \ - display/drawing-image.h \ - display/drawing-item.cpp \ - display/drawing-item.h \ - display/drawing-pattern.cpp \ - display/drawing-pattern.h \ - display/drawing-shape.cpp \ - display/drawing-shape.h \ - display/drawing-surface.cpp \ - display/drawing-surface.h \ - display/drawing-text.cpp \ - display/drawing-text.h \ - display/gnome-canvas-acetate.cpp \ - display/gnome-canvas-acetate.h \ - display/grayscale.cpp \ - display/grayscale.h \ - display/guideline.cpp \ - display/guideline.h \ - display/nr-3dutils.cpp \ - display/nr-3dutils.h \ - display/nr-filter-blend.cpp \ - display/nr-filter-blend.h \ - display/nr-filter-colormatrix.cpp \ - display/nr-filter-colormatrix.h \ - display/nr-filter-component-transfer.cpp \ - display/nr-filter-component-transfer.h \ - display/nr-filter-composite.cpp \ - display/nr-filter-composite.h \ - display/nr-filter-convolve-matrix.cpp \ - display/nr-filter-convolve-matrix.h \ - display/nr-filter.cpp \ - display/nr-filter-diffuselighting.cpp \ - display/nr-filter-diffuselighting.h \ - display/nr-filter-displacement-map.cpp \ - display/nr-filter-displacement-map.h \ - display/nr-filter-flood.cpp \ - display/nr-filter-flood.h \ - display/nr-filter-gaussian.cpp \ - display/nr-filter-gaussian.h \ - display/nr-filter.h \ - display/nr-filter-image.cpp \ - display/nr-filter-image.h \ - display/nr-filter-merge.cpp \ - display/nr-filter-merge.h \ - display/nr-filter-morphology.cpp \ - display/nr-filter-morphology.h \ - display/nr-filter-offset.cpp \ - display/nr-filter-offset.h \ - display/nr-filter-primitive.cpp \ - display/nr-filter-primitive.h \ - display/nr-filter-slot.cpp \ - display/nr-filter-slot.h \ - display/nr-filter-specularlighting.cpp \ - display/nr-filter-specularlighting.h \ - display/nr-filter-tile.cpp \ - display/nr-filter-tile.h \ - display/nr-filter-turbulence.cpp \ - display/nr-filter-turbulence.h \ - display/nr-filter-types.h \ - display/nr-filter-units.cpp \ - display/nr-filter-units.h \ - display/nr-filter-utils.h \ - display/nr-light.cpp \ - display/nr-light.h \ - display/nr-light-types.h \ - display/nr-style.cpp \ - display/nr-style.h \ - display/nr-svgfonts.cpp \ - display/nr-svgfonts.h \ - display/rendermode.h \ - display/snap-indicator.cpp \ - display/snap-indicator.h \ - display/sodipodi-ctrl.cpp \ - display/sodipodi-ctrl.h \ - display/sodipodi-ctrlrect.cpp \ - 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 \ - display/sp-ctrlcurve.h \ - display/sp-ctrlline.cpp \ - display/sp-ctrlline.h \ - display/sp-ctrlquadr.cpp \ - display/sp-ctrlquadr.h - -# ###################### -# ### CxxTest stuff #### -# ###################### -CXXTEST_TESTSUITES += \ - $(srcdir)/display/curve-test.h diff --git a/src/display/cairo-utils.cpp b/src/display/cairo-utils.cpp index 24a75de4c..a7625f4a1 100644 --- a/src/display/cairo-utils.cpp +++ b/src/display/cairo-utils.cpp @@ -13,6 +13,7 @@ #endif #include "display/cairo-utils.h" +#include <arpa/inet.h> #include <stdexcept> #include <glib/gstdio.h> @@ -1321,6 +1322,91 @@ guint32 argb32_from_rgba(guint32 in) return px; } + +/** + * Converts a pixbuf to a PNG data structure. + * For 8-but RGBA png, this is like copying. + * + */ +const guchar* pixbuf_to_png(guchar const**rows, guchar* px, int num_rows, int num_cols, int stride, int color_type, int bit_depth) +{ + int n_fields = 1 + (color_type&2) + (color_type&4)/4; + const guchar* new_data = (const guchar*)malloc((n_fields * bit_depth * num_rows * num_cols)/8 + 64); + char* ptr = (char*) new_data; + int pad=0; //used when we write image data smaller than one byte (for instance in black and white images where 1px = 1bit) + for(int row = 0; row < num_rows; ++row){ + rows[row] = (const guchar*)ptr; + for(int col = 0; col < num_cols; ++col){ + guint32 *pixel = reinterpret_cast<guint32*>(px + row*stride)+col; +#if G_BYTE_ORDER == G_LITTLE_ENDIAN + //this part should probably be rewritten as (a tested, working) big endian, using htons() and ntohs() + guint64 a = (*pixel & 0xff000000) >> 24; + guint64 b = (*pixel & 0x00ff0000) >> 16; + guint64 g = (*pixel & 0x0000ff00) >> 8; + guint64 r = (*pixel & 0x000000ff); + + //one of possible rgb to greyscale formulas. This one is called "luminance, "luminosity" or "luma" + guint16 gray = (guint16)((guint32)((0.2126*(r<<24) + 0.7152*(g<<24) + 0.0722*(b<<24)))>>16); + + if (!pad) *((guint64*)ptr)=0; + if (color_type & 2) { //RGB + // for 8bit->16bit transition, I take the FF -> FFFF convention (multiplication by 0x101). + // If you prefer FF -> FF00 (multiplication by 0x100), remove the <<8, <<24, <<40 and <<56 + if (color_type & 4) { //RGBA + if (bit_depth==8) + *((guint32*)ptr) = *pixel; + else + *((guint64*)ptr) = (guint64)((a<<56)+(a<<48)+(b<<40)+(b<<32)+(g<<24)+(g<<16)+(r<<8)+(r)); + } + else{ //no alpha + if(bit_depth==8) + *((guint32*)ptr) = ((*pixel)<<8)>>8; + else + *((guint64*)ptr) = (guint64)((b<<40)+(b<<32)+(g<<24)+(g<<16)+(r<<8)+r); + } + } else { //Grayscale + if(bit_depth==16) + *(guint16*)ptr= ((gray & 0xff00)>>8) + ((gray &0x00ff)<<8); + else *((guint16*)ptr) += guint16(((gray >> (16-bit_depth))<<pad) ); //note the "+=" + + if(color_type & 4) { //Alpha channel + if (bit_depth == 16) + *((guint32*)(ptr+2)) = a + (a<<8); + else + *((guint32*)(ptr)) += guint32((a << 8) >> (16 - bit_depth))<<(bit_depth + pad); + } + } + +#else + // I don't have any access to a big-endian machine to test this. It should still work with default export settings. + guint64 r = (*pixel & 0xff000000) >> 24; + guint64 g = (*pixel & 0x00ff0000) >> 16; + guint64 b = (*pixel & 0x0000ff00) >> 8; + guint64 a = (*pixel & 0x000000ff); + guint32 gray = (guint32)(0.2126*(r<<24) + 0.7152*(g<<24) + 0.0722*(b<<24)); + if(color_type & 2){ + if(bit_depth==8)*ptr = *pixel; else *ptr = (guint64)((r<<56)+(g<<40)+(b<<24)+(a<<8)); + } else { + *((guint32*)ptr) += guint32(gray>>pad); + if(color_type & 4) *((guint32*)ptr) += guint32((a>>pad)>> bit_depth); + } +#endif + pad+=bit_depth*n_fields; + ptr+=(pad/8); + pad%=8; + } + if(pad){pad=0;ptr++;}//align bytes on rows + } + return new_data; +} + + + + + + + + /* Local Variables: mode:c++ diff --git a/src/display/cairo-utils.h b/src/display/cairo-utils.h index 2a7e460e8..72087471d 100644 --- a/src/display/cairo-utils.h +++ b/src/display/cairo-utils.h @@ -178,6 +178,8 @@ void convert_pixels_argb32_to_pixbuf(guchar *data, int w, int h, int rs); G_GNUC_CONST guint32 argb32_from_pixbuf(guint32 in); G_GNUC_CONST guint32 pixbuf_from_argb32(guint32 in); +const guchar* pixbuf_to_png(guchar const**rows, guchar* px, int nrows, int ncols, int stride, int color_type, int bit_depth); + /** Convert a pixel in 0xRRGGBBAA format to Cairo ARGB32 format. */ G_GNUC_CONST guint32 argb32_from_rgba(guint32 in); diff --git a/src/display/canvas-axonomgrid.cpp b/src/display/canvas-axonomgrid.cpp index 14f36376f..421a39fbd 100644 --- a/src/display/canvas-axonomgrid.cpp +++ b/src/display/canvas-axonomgrid.cpp @@ -19,12 +19,7 @@ #include <gtkmm/box.h> #include <gtkmm/label.h> - -#if WITH_GTKMM_3_0 -# include <gtkmm/grid.h> -#else -# include <gtkmm/table.h> -#endif +#include <gtkmm/grid.h> #include <glibmm/i18n.h> @@ -94,15 +89,10 @@ namespace Inkscape { #define SPACE_SIZE_X 15 #define SPACE_SIZE_Y 10 static inline void -#if WITH_GTKMM_3_0 attach_all(Gtk::Grid &table, Gtk::Widget const *const arr[], unsigned size, int start = 0) -#else -attach_all(Gtk::Table &table, Gtk::Widget const *const arr[], unsigned size, int start = 0) -#endif { for (unsigned i=0, r=start; i<size/sizeof(Gtk::Widget*); i+=2) { if (arr[i] && arr[i+1]) { -#if WITH_GTKMM_3_0 (const_cast<Gtk::Widget&>(*arr[i])).set_hexpand(); (const_cast<Gtk::Widget&>(*arr[i])).set_valign(Gtk::ALIGN_CENTER); table.attach(const_cast<Gtk::Widget&>(*arr[i]), 1, r, 1, 1); @@ -110,44 +100,23 @@ attach_all(Gtk::Table &table, Gtk::Widget const *const arr[], unsigned size, int (const_cast<Gtk::Widget&>(*arr[i+1])).set_hexpand(); (const_cast<Gtk::Widget&>(*arr[i+1])).set_valign(Gtk::ALIGN_CENTER); table.attach(const_cast<Gtk::Widget&>(*arr[i+1]), 2, r, 1, 1); -#else - 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); -#endif } else { if (arr[i+1]) { -#if WITH_GTKMM_3_0 (const_cast<Gtk::Widget&>(*arr[i+1])).set_hexpand(); (const_cast<Gtk::Widget&>(*arr[i+1])).set_valign(Gtk::ALIGN_CENTER); table.attach(const_cast<Gtk::Widget&>(*arr[i+1]), 1, r, 2, 1); -#else - table.attach (const_cast<Gtk::Widget&>(*arr[i+1]), 1, 3, r, r+1, - Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0,0,0); -#endif } else if (arr[i]) { Gtk::Label& label = reinterpret_cast<Gtk::Label&> (const_cast<Gtk::Widget&>(*arr[i])); label.set_alignment (0.0); -#if WITH_GTKMM_3_0 label.set_hexpand(); label.set_valign(Gtk::ALIGN_CENTER); table.attach(label, 0, r, 3, 1); -#else - table.attach (label, 0, 3, r, r+1, - Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0,0,0); -#endif } else { Gtk::HBox *space = Gtk::manage (new Gtk::HBox); space->set_size_request (SPACE_SIZE_X, SPACE_SIZE_Y); -#if WITH_GTKMM_3_0 space->set_halign(Gtk::ALIGN_CENTER); space->set_valign(Gtk::ALIGN_CENTER); table.attach(*space, 0, r, 1, 1); -#else - table.attach (*space, 0, 1, r, r+1, - (Gtk::AttachOptions)0, (Gtk::AttachOptions)0,0,0); -#endif } } ++r; @@ -342,14 +311,9 @@ CanvasAxonomGrid::onReprAttrChanged(Inkscape::XML::Node */*repr*/, gchar const * Gtk::Widget * CanvasAxonomGrid::newSpecificWidget() { -#if WITH_GTKMM_3_0 - Gtk::Grid *table = Gtk::manage(new Gtk::Grid()); + auto table = Gtk::manage(new Gtk::Grid()); table->set_row_spacing(2); table->set_column_spacing(2); -#else - Gtk::Table * table = Gtk::manage( new Gtk::Table(1,1) ); - table->set_spacings(2); -#endif _wr.setUpdating (true); diff --git a/src/display/canvas-bpath.cpp b/src/display/canvas-bpath.cpp index 46b59d25a..fc6b79b43 100644 --- a/src/display/canvas-bpath.cpp +++ b/src/display/canvas-bpath.cpp @@ -53,6 +53,7 @@ sp_canvas_bpath_init (SPCanvasBPath * bpath) bpath->stroke_linejoin = SP_STROKE_LINEJOIN_MITER; bpath->stroke_linecap = SP_STROKE_LINECAP_BUTT; bpath->stroke_miterlimit = 11.0; + bpath->phantom_line = false; } static void sp_canvas_bpath_destroy(SPCanvasItem *object) @@ -71,7 +72,7 @@ static void sp_canvas_bpath_update(SPCanvasItem *item, Geom::Affine const &affin { SPCanvasBPath *cbp = SP_CANVAS_BPATH(item); - item->canvas->requestRedraw((int)item->x1, (int)item->y1, (int)item->x2, (int)item->y2); + item->canvas->requestRedraw((int)item->x1 - 1, (int)item->y1 - 1, (int)item->x2 + 1 , (int)item->y2 + 1); if (reinterpret_cast<SPCanvasItemClass *>(sp_canvas_bpath_parent_class)->update) { reinterpret_cast<SPCanvasItemClass *>(sp_canvas_bpath_parent_class)->update(item, affine, flags); @@ -86,10 +87,10 @@ static void sp_canvas_bpath_update(SPCanvasItem *item, Geom::Affine const &affin Geom::OptRect bbox = bounds_exact_transformed(cbp->curve->get_pathvector(), affine); if (bbox) { - item->x1 = (int)bbox->min()[Geom::X] - 1; - item->y1 = (int)bbox->min()[Geom::Y] - 1; - item->x2 = (int)bbox->max()[Geom::X] + 1; - item->y2 = (int)bbox->max()[Geom::Y] + 1; + item->x1 = (int)floor(bbox->min()[Geom::X]) - 1; + item->y1 = (int)floor(bbox->min()[Geom::Y]) - 1; + item->x2 = (int)ceil(bbox->max()[Geom::X]) + 1; + item->y2 = (int)ceil(bbox->max()[Geom::Y]) + 1; } else { item->x1 = 0; item->y1 = 0; @@ -131,7 +132,21 @@ sp_canvas_bpath_render (SPCanvasItem *item, SPCanvasBuf *buf) cairo_fill_preserve(buf->ct); } - if (dostroke) { + if (dostroke && cbp->phantom_line) { + ink_cairo_set_source_rgba32(buf->ct, 0xffffff4d); + cairo_set_line_width(buf->ct, 2); + if (cbp->dashes[0] != 0 && cbp->dashes[1] != 0) { + cairo_set_dash (buf->ct, cbp->dashes, 2, 0); + } + cairo_stroke(buf->ct); + cairo_set_tolerance(buf->ct, 0.5); + cairo_new_path(buf->ct); + feed_pathvector_to_cairo (buf->ct, cbp->curve->get_pathvector(), cbp->affine, area, + /* optimized_stroke = */ !dofill, 1); + ink_cairo_set_source_rgba32(buf->ct, cbp->stroke_rgba); + cairo_set_line_width(buf->ct, 1); + cairo_stroke(buf->ct); + } else if (dostroke) { ink_cairo_set_source_rgba32(buf->ct, cbp->stroke_rgba); cairo_set_line_width(buf->ct, 1); if (cbp->dashes[0] != 0 && cbp->dashes[1] != 0) { @@ -167,24 +182,25 @@ sp_canvas_bpath_point (SPCanvasItem *item, Geom::Point p, SPCanvasItem **actual_ } SPCanvasItem * -sp_canvas_bpath_new (SPCanvasGroup *parent, SPCurve *curve) +sp_canvas_bpath_new (SPCanvasGroup *parent, SPCurve *curve, bool phantom_line) { g_return_val_if_fail (parent != NULL, NULL); g_return_val_if_fail (SP_IS_CANVAS_GROUP (parent), NULL); SPCanvasItem *item = sp_canvas_item_new (parent, SP_TYPE_CANVAS_BPATH, NULL); - sp_canvas_bpath_set_bpath (SP_CANVAS_BPATH (item), curve); + sp_canvas_bpath_set_bpath (SP_CANVAS_BPATH (item), curve, phantom_line); return item; } void -sp_canvas_bpath_set_bpath (SPCanvasBPath *cbp, SPCurve *curve) +sp_canvas_bpath_set_bpath (SPCanvasBPath *cbp, SPCurve *curve, bool phantom_line) { g_return_if_fail (cbp != NULL); g_return_if_fail (SP_IS_CANVAS_BPATH (cbp)); + cbp->phantom_line = phantom_line; if (cbp->curve) { cbp->curve = cbp->curve->unref(); } diff --git a/src/display/canvas-bpath.h b/src/display/canvas-bpath.h index 72eca6eeb..686eb7c5a 100644 --- a/src/display/canvas-bpath.h +++ b/src/display/canvas-bpath.h @@ -80,7 +80,7 @@ struct SPCanvasBPath { SPStrokeJoinType stroke_linejoin; SPStrokeCapType stroke_linecap; gdouble stroke_miterlimit; - + bool phantom_line; /* State */ Shape *fill_shp; Shape *stroke_shp; @@ -92,9 +92,9 @@ struct SPCanvasBPathClass { GType sp_canvas_bpath_get_type (void); -SPCanvasItem *sp_canvas_bpath_new (SPCanvasGroup *parent, SPCurve *curve); +SPCanvasItem *sp_canvas_bpath_new (SPCanvasGroup *parent, SPCurve *curve, bool phantom_line = false); -void sp_canvas_bpath_set_bpath (SPCanvasBPath *cbp, SPCurve *curve); +void sp_canvas_bpath_set_bpath (SPCanvasBPath *cbp, SPCurve *curve, bool phantom_line = false); void sp_canvas_bpath_set_fill (SPCanvasBPath *cbp, guint32 rgba, SPWindRule rule); void sp_canvas_bpath_set_stroke (SPCanvasBPath *cbp, guint32 rgba, gdouble width, SPStrokeJoinType join, SPStrokeCapType cap, double dash=0, double gap=0); diff --git a/src/display/canvas-grid.cpp b/src/display/canvas-grid.cpp index decf93626..fa45fe02c 100644 --- a/src/display/canvas-grid.cpp +++ b/src/display/canvas-grid.cpp @@ -19,12 +19,7 @@ #include <gtkmm/box.h> #include <gtkmm/label.h> - -#if WITH_GTKMM_3_0 -# include <gtkmm/grid.h> -#else -# include <gtkmm/table.h> -#endif +#include <gtkmm/grid.h> #include <glibmm/i18n.h> @@ -400,15 +395,10 @@ void CanvasGrid::setOrigin(Geom::Point const &origin_px) **/ #define SPACE_SIZE_X 15 #define SPACE_SIZE_Y 10 -#if WITH_GTKMM_3_0 static inline void attach_all(Gtk::Grid &table, Gtk::Widget const *const arr[], unsigned size, int start = 0) -#else -static inline void attach_all(Gtk::Table &table, Gtk::Widget const *const arr[], unsigned size, int start = 0) -#endif { for (unsigned i=0, r=start; i<size/sizeof(Gtk::Widget*); i+=2) { if (arr[i] && arr[i+1]) { -#if WITH_GTKMM_3_0 (const_cast<Gtk::Widget&>(*arr[i])).set_hexpand(); (const_cast<Gtk::Widget&>(*arr[i])).set_valign(Gtk::ALIGN_CENTER); table.attach(const_cast<Gtk::Widget&>(*arr[i]), 1, r, 1, 1); @@ -416,44 +406,23 @@ static inline void attach_all(Gtk::Table &table, Gtk::Widget const *const arr[], (const_cast<Gtk::Widget&>(*arr[i+1])).set_hexpand(); (const_cast<Gtk::Widget&>(*arr[i+1])).set_valign(Gtk::ALIGN_CENTER); table.attach(const_cast<Gtk::Widget&>(*arr[i+1]), 2, r, 1, 1); -#else - 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); -#endif } else { if (arr[i+1]) { -#if WITH_GTKMM_3_0 (const_cast<Gtk::Widget&>(*arr[i+1])).set_hexpand(); (const_cast<Gtk::Widget&>(*arr[i+1])).set_valign(Gtk::ALIGN_CENTER); table.attach(const_cast<Gtk::Widget&>(*arr[i+1]), 1, r, 2, 1); -#else - table.attach (const_cast<Gtk::Widget&>(*arr[i+1]), 1, 3, r, r+1, - Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0,0,0); -#endif } else if (arr[i]) { Gtk::Label& label = reinterpret_cast<Gtk::Label&> (const_cast<Gtk::Widget&>(*arr[i])); label.set_alignment (0.0); -#if WITH_GTKMM_3_0 label.set_hexpand(); label.set_valign(Gtk::ALIGN_CENTER); table.attach(label, 0, r, 3, 1); -#else - table.attach (label, 0, 3, r, r+1, - Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0,0,0); -#endif } else { Gtk::HBox *space = Gtk::manage (new Gtk::HBox); space->set_size_request (SPACE_SIZE_X, SPACE_SIZE_Y); -#if WITH_GTKMM_3_0 space->set_halign(Gtk::ALIGN_CENTER); space->set_valign(Gtk::ALIGN_CENTER); table.attach(*space, 0, r, 1, 1); -#else - table.attach (*space, 0, 1, r, r+1, - (Gtk::AttachOptions)0, (Gtk::AttachOptions)0,0,0); -#endif } } ++r; @@ -684,14 +653,9 @@ CanvasXYGrid::onReprAttrChanged(Inkscape::XML::Node */*repr*/, gchar const */*ke Gtk::Widget * CanvasXYGrid::newSpecificWidget() { -#if WITH_GTKMM_3_0 - Gtk::Grid * table = Gtk::manage( new Gtk::Grid() ); + auto table = Gtk::manage( new Gtk::Grid() ); table->set_row_spacing(2); table->set_column_spacing(2); -#else - Gtk::Table * table = Gtk::manage( new Gtk::Table(1,1) ); - table->set_spacings(2); -#endif Inkscape::UI::Widget::RegisteredUnitMenu *_rumg = Gtk::manage( new Inkscape::UI::Widget::RegisteredUnitMenu( _("Grid _units:"), "units", _wr, repr, doc) ); diff --git a/src/display/canvas-text.cpp b/src/display/canvas-text.cpp index 7c019caf5..efef018e6 100644 --- a/src/display/canvas-text.cpp +++ b/src/display/canvas-text.cpp @@ -84,6 +84,7 @@ sp_canvastext_render (SPCanvasItem *item, SPCanvasBuf *buf) if (!buf->ct) return; + cairo_select_font_face(buf->ct, "sans-serif", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL); cairo_set_font_size(buf->ct, cl->fontsize); if (cl->background){ @@ -138,6 +139,7 @@ sp_canvastext_update (SPCanvasItem *item, Geom::Affine const &affine, unsigned i cairo_surface_t *tmp_surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 1, 1); cairo_t* tmp_buf = cairo_create(tmp_surface); + cairo_select_font_face(tmp_buf, "sans-serif", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL); cairo_set_font_size(tmp_buf, cl->fontsize); cairo_text_extents_t extents; cairo_text_extents(tmp_buf, cl->text, &extents); diff --git a/src/display/drawing-text.cpp b/src/display/drawing-text.cpp index f0d83abfd..a0918e9f5 100644 --- a/src/display/drawing-text.cpp +++ b/src/display/drawing-text.cpp @@ -269,7 +269,7 @@ void DrawingText::decorateStyle(DrawingContext &dc, double vextent, double xphas int dashes[16]={ 8, 7, 6, 5, 4, 3, 2, 1, - -8, -7, -6, -5 + -8, -7, -6, -5, -4, -3, -2, -1 }; int dots[16]={ diff --git a/src/display/guideline.cpp b/src/display/guideline.cpp index 126fcf87c..f66b65e1a 100644 --- a/src/display/guideline.cpp +++ b/src/display/guideline.cpp @@ -48,7 +48,7 @@ static void sp_guideline_init(SPGuideLine *gl) gl->locked = false; gl->normal_to_line = Geom::Point(0,1); - gl->angle = 3.14159265358979323846/2; + gl->angle = M_PI_2; gl->point_on_line = Geom::Point(0,0); gl->sensitive = 0; diff --git a/src/display/nr-svgfonts.cpp b/src/display/nr-svgfonts.cpp index 011f51977..fd092aed8 100644 --- a/src/display/nr-svgfonts.cpp +++ b/src/display/nr-svgfonts.cpp @@ -197,21 +197,27 @@ SvgFont::scaled_font_text_to_glyphs (cairo_scaled_font_t */*scaled_font*/, bool is_horizontal_text = true; //TODO _utf8 = (char*) utf8; + double font_height = units_per_em(); while(g_utf8_get_char(_utf8)){ len = 0; for (i=0; i < (unsigned long) this->glyphs.size(); i++){ //check whether is there a glyph declared on the SVG document // that matches with the text string in its current position if ( (len = size_of_substring(this->glyphs[i]->unicode.c_str(), _utf8)) ){ - for(SPObject* node = this->font->children;previous_unicode && node;node=node->next){ + for(auto& node: font->children) { + if (!previous_unicode) { + break; + } //apply glyph kerning if appropriate - SPHkern *hkern = dynamic_cast<SPHkern *>(node); - if (hkern && is_horizontal_text && MatchHKerningRule(hkern, this->glyphs[i], previous_unicode, previous_glyph_name) ){ - x -= (hkern->k / 1000.0);//TODO: use here the height of the font + SPHkern *hkern = dynamic_cast<SPHkern *>(&node); + if (hkern && is_horizontal_text && + MatchHKerningRule(hkern, this->glyphs[i], previous_unicode, previous_glyph_name) ){ + x -= (hkern->k / font_height); } - SPVkern *vkern = dynamic_cast<SPVkern *>(node); - if (vkern && !is_horizontal_text && MatchVKerningRule(vkern, this->glyphs[i], previous_unicode, previous_glyph_name) ){ - y -= (vkern->k / 1000.0);//TODO: use here the "height" of the font + SPVkern *vkern = dynamic_cast<SPVkern *>(&node); + if (vkern && !is_horizontal_text && + MatchVKerningRule(vkern, this->glyphs[i], previous_unicode, previous_glyph_name) ){ + y -= (vkern->k / font_height); } } previous_unicode = const_cast<char*>(this->glyphs[i]->unicode.c_str());//used for kerning checking @@ -221,8 +227,15 @@ SvgFont::scaled_font_text_to_glyphs (cairo_scaled_font_t */*scaled_font*/, (*glyphs)[count++].y = y; //advance glyph coordinates: - if (is_horizontal_text) x+=(this->font->horiz_adv_x/1000.0);//TODO: use here the height of the font - else y+=(this->font->vert_adv_y/1000.0);//TODO: use here the "height" of the font + if (is_horizontal_text) { + if (this->glyphs[i]->horiz_adv_x != 0) { + x+=(this->glyphs[i]->horiz_adv_x/font_height); + } else { + x+=(this->font->horiz_adv_x/font_height); + } + } else { + y+=(this->font->vert_adv_y/font_height); + } _utf8+=len; //advance 'len' bytes in our string pointer //continue; goto raptorz; @@ -235,8 +248,8 @@ SvgFont::scaled_font_text_to_glyphs (cairo_scaled_font_t */*scaled_font*/, (*glyphs)[count++].y = y; //advance glyph coordinates: - if (is_horizontal_text) x+=(this->font->horiz_adv_x/1000.0);//TODO: use here the height of the font - else y+=(this->font->vert_adv_y/1000.0);//TODO: use here the "height" of the font + if (is_horizontal_text) x+=(this->font->horiz_adv_x/font_height);//TODO: use here the height of the font + else y+=(this->font->vert_adv_y/font_height);//TODO: use here the "height" of the font _utf8 = g_utf8_next_char(_utf8); //advance 1 char in our string pointer } @@ -252,9 +265,7 @@ SvgFont::render_glyph_path(cairo_t* cr, Geom::PathVector* pathv){ cairo_new_path(cr); //adjust scale of the glyph -// Geom::Scale s(1.0/((SPFont*) node->parent)->horiz_adv_x); - Geom::Scale s(1.0/1000);//TODO: use here the units-per-em attribute? - + Geom::Scale s(1.0/units_per_em()); Geom::Rect area( Geom::Point(0,0), Geom::Point(1,1) ); //I need help here! (reaction: note that the 'area' parameter is an *optional* rect, so you can pass an empty Geom::OptRect() ) feed_pathvector_to_cairo (cr, *pathv, s, area, false, 0); @@ -270,11 +281,11 @@ SvgFont::glyph_modified(SPObject* /* blah */, unsigned int /* bleh */){ Geom::PathVector SvgFont::flip_coordinate_system(SPFont* spfont, Geom::PathVector pathv){ - double units_per_em = 1000; - for (SPObject *obj = spfont->children; obj; obj = obj->next){ - if (dynamic_cast<SPFontFace *>(obj)) { + double units_per_em = 1024; + for(auto& obj: spfont->children) { + if (dynamic_cast<SPFontFace *>(&obj)) { //XML Tree being directly used here while it shouldn't be. - sp_repr_get_double(obj->getRepr(), "units_per_em", &units_per_em); + sp_repr_get_double(obj.getRepr(), "units_per_em", &units_per_em); } } @@ -339,19 +350,19 @@ SvgFont::scaled_font_render_glyph (cairo_scaled_font_t */*scaled_font*/, if (node->hasChildren()){ //render the SVG described on this glyph's child nodes. - for(node = node->children; node; node=node->next){ + for(auto& child: node->children) { { - SPPath *path = dynamic_cast<SPPath *>(node); + SPPath *path = dynamic_cast<SPPath *>(&child); if (path) { pathv = path->_curve->get_pathvector(); pathv = flip_coordinate_system(spfont, pathv); render_glyph_path(cr, &pathv); } } - if (dynamic_cast<SPObjectGroup *>(node)) { + if (dynamic_cast<SPObjectGroup *>(&child)) { g_warning("TODO: svgfonts: render OBJECTGROUP"); } - SPUse *use = dynamic_cast<SPUse *>(node); + SPUse *use = dynamic_cast<SPUse *>(&child); if (use) { SPItem* item = use->ref->getObject(); SPPath *path = dynamic_cast<SPPath *>(item); @@ -374,12 +385,12 @@ SvgFont::scaled_font_render_glyph (cairo_scaled_font_t */*scaled_font*/, cairo_font_face_t* SvgFont::get_font_face(){ if (!this->userfont) { - for(SPObject* node = this->font->children;node;node=node->next){ - SPGlyph *glyph = dynamic_cast<SPGlyph *>(node); + for(auto& node: font->children) { + SPGlyph *glyph = dynamic_cast<SPGlyph *>(&node); if (glyph) { glyphs.push_back(glyph); } - SPMissingGlyph *missing = dynamic_cast<SPMissingGlyph *>(node); + SPMissingGlyph *missing = dynamic_cast<SPMissingGlyph *>(&node); if (missing) { missingglyph = missing; } @@ -395,6 +406,20 @@ void SvgFont::refresh(){ this->userfont = NULL; } +double SvgFont::units_per_em() { + double units_per_em = 1024; + for (auto& obj: font->children) { + if (dynamic_cast<SPFontFace *>(&obj)) { + //XML Tree being directly used here while it shouldn't be. + sp_repr_get_double(obj.getRepr(), "units-per-em", &units_per_em); + } + } + if (units_per_em <= 0.0) { + units_per_em = 1024; + } + return units_per_em; +} + /* Local Variables: mode:c++ diff --git a/src/display/nr-svgfonts.h b/src/display/nr-svgfonts.h index 21ab3ed02..d4488fb17 100644 --- a/src/display/nr-svgfonts.h +++ b/src/display/nr-svgfonts.h @@ -52,7 +52,8 @@ private: SPMissingGlyph* missingglyph; sigc::connection glyph_modified_connection; - bool drawing_expose_cb (Gtk::Widget *widget, GdkEventExpose *event, void* data); + double units_per_em(); + //bool drawing_expose_cb (Gtk::Widget *widget, GdkEventExpose *event, void* data); }; #endif //#ifndef NR_SVGFONTS_H_SEEN diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index 7d76fa043..9201168ef 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -322,13 +322,9 @@ void sp_canvas_item_dispose(GObject *object) if (item == item->canvas->_grabbed_item) { item->canvas->_grabbed_item = NULL; -#if GTK_CHECK_VERSION(3,0,0) - GdkDeviceManager *dm = gdk_display_get_device_manager(gdk_display_get_default()); - GdkDevice *device = gdk_device_manager_get_client_pointer(dm); + auto dm = gdk_display_get_device_manager(gdk_display_get_default()); + auto device = gdk_device_manager_get_client_pointer(dm); gdk_device_ungrab(device, GDK_CURRENT_TIME); -#else - gdk_pointer_ungrab (GDK_CURRENT_TIME); -#endif } if (item == item->canvas->_focused_item) { @@ -617,9 +613,8 @@ int sp_canvas_item_grab(SPCanvasItem *item, guint event_mask, GdkCursor *cursor, // fixme: Top hack (Lauris) // fixme: If we add key masks to event mask, Gdk will abort (Lauris) // fixme: But Canvas actualle does get key events, so all we need is routing these here -#if GTK_CHECK_VERSION(3,0,0) - GdkDeviceManager *dm = gdk_display_get_device_manager(gdk_display_get_default()); - GdkDevice *device = gdk_device_manager_get_client_pointer(dm); + auto dm = gdk_display_get_device_manager(gdk_display_get_default()); + auto device = gdk_device_manager_get_client_pointer(dm); gdk_device_grab(device, getWindow(item->canvas), GDK_OWNERSHIP_NONE, @@ -627,11 +622,6 @@ int sp_canvas_item_grab(SPCanvasItem *item, guint event_mask, GdkCursor *cursor, (GdkEventMask)(event_mask & (~(GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK))), cursor, etime); -#else - gdk_pointer_grab( getWindow(item->canvas), FALSE, - (GdkEventMask)(event_mask & (~(GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK))), - NULL, cursor, etime); -#endif item->canvas->_grabbed_item = item; item->canvas->_grabbed_event_mask = event_mask; @@ -658,13 +648,9 @@ void sp_canvas_item_ungrab(SPCanvasItem *item, guint32 etime) item->canvas->_grabbed_item = NULL; -#if GTK_CHECK_VERSION(3,0,0) - GdkDeviceManager *dm = gdk_display_get_device_manager(gdk_display_get_default()); - GdkDevice *device = gdk_device_manager_get_client_pointer(dm); + auto dm = gdk_display_get_device_manager(gdk_display_get_default()); + auto device = gdk_device_manager_get_client_pointer(dm); gdk_device_ungrab(device, etime); -#else - gdk_pointer_ungrab (etime); -#endif } /** @@ -913,16 +899,9 @@ void sp_canvas_class_init(SPCanvasClass *klass) widget_class->realize = SPCanvas::handle_realize; widget_class->unrealize = SPCanvas::handle_unrealize; - -#if GTK_CHECK_VERSION(3,0,0) widget_class->get_preferred_width = SPCanvas::handle_get_preferred_width; widget_class->get_preferred_height = SPCanvas::handle_get_preferred_height; widget_class->draw = SPCanvas::handle_draw; -#else - widget_class->size_request = SPCanvas::handle_size_request; - widget_class->expose_event = SPCanvas::handle_expose; -#endif - widget_class->size_allocate = SPCanvas::handle_size_allocate; widget_class->button_press_event = SPCanvas::handle_button; widget_class->button_release_event = SPCanvas::handle_button; @@ -980,13 +959,9 @@ void SPCanvas::shutdownTransients() if (_grabbed_item) { _grabbed_item = NULL; -#if GTK_CHECK_VERSION(3,0,0) - GdkDeviceManager *dm = gdk_display_get_device_manager(gdk_display_get_default()); - GdkDevice *device = gdk_device_manager_get_client_pointer(dm); + auto dm = gdk_display_get_device_manager(gdk_display_get_default()); + auto device = gdk_device_manager_get_client_pointer(dm); gdk_device_ungrab(device, GDK_CURRENT_TIME); -#else - gdk_pointer_ungrab(GDK_CURRENT_TIME); -#endif } removeIdle(); } @@ -1053,10 +1028,6 @@ void SPCanvas::handle_realize(GtkWidget *widget) attributes.wclass = GDK_INPUT_OUTPUT; attributes.visual = gdk_visual_get_system(); -#if !GTK_CHECK_VERSION(3,0,0) - attributes.colormap = gdk_colormap_get_system(); -#endif - attributes.event_mask = (gtk_widget_get_events (widget) | GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK | @@ -1073,11 +1044,7 @@ void SPCanvas::handle_realize(GtkWidget *widget) GDK_SCROLL_MASK | GDK_FOCUS_CHANGE_MASK); -#if GTK_CHECK_VERSION(3,0,0) gint attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL; -#else - gint attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; -#endif GdkWindow *window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask); gtk_widget_set_window (widget, window); @@ -1086,18 +1053,8 @@ void SPCanvas::handle_realize(GtkWidget *widget) Inkscape::Preferences *prefs = Inkscape::Preferences::get(); if (prefs->getBool("/options/useextinput/value", true)) { gtk_widget_set_events(widget, attributes.event_mask); -#if !GTK_CHECK_VERSION(3,0,0) - gtk_widget_set_extension_events(widget, GDK_EXTENSION_EVENTS_ALL); - // TODO: Extension event stuff has been deprecated in GTK+ 3 -#endif } -#if !GTK_CHECK_VERSION(3,0,0) - // This does nothing in GTK+ 3 - GtkStyle *style = gtk_widget_get_style (widget); - gtk_widget_set_style (widget, gtk_style_attach (style, window)); -#endif - gtk_widget_set_realized (widget, TRUE); } @@ -1115,8 +1072,6 @@ void SPCanvas::handle_unrealize(GtkWidget *widget) (* GTK_WIDGET_CLASS(sp_canvas_parent_class)->unrealize)(widget); } - -#if GTK_CHECK_VERSION(3,0,0) void SPCanvas::handle_get_preferred_width(GtkWidget *widget, gint *minimum_width, gint *natural_width) { static_cast<void>(SP_CANVAS (widget)); @@ -1130,16 +1085,6 @@ void SPCanvas::handle_get_preferred_height(GtkWidget *widget, gint *minimum_heig *minimum_height = 256; *natural_height = 256; } -#else -void SPCanvas::handle_size_request(GtkWidget *widget, GtkRequisition *req) -{ - static_cast<void>(SP_CANVAS (widget)); - - req->width = 256; - req->height = 256; -} -#endif - void SPCanvas::handle_size_allocate(GtkWidget *widget, GtkAllocation *allocation) { @@ -1219,9 +1164,7 @@ int SPCanvas::emitEvent(GdkEvent *event) break; case GDK_SCROLL: mask = GDK_SCROLL_MASK; -#if GTK_CHECK_VERSION(3,0,0) mask |= GDK_SMOOTH_SCROLL_MASK; -#endif break; default: mask = 0; @@ -1503,13 +1446,9 @@ gint SPCanvas::handle_scroll(GtkWidget *widget, GdkEventScroll *event) } static inline void request_motions(GdkWindow *w, GdkEventMotion *event) { -#if GTK_CHECK_VERSION(3,0,0) gdk_window_get_device_position(w, gdk_event_get_device((GdkEvent *)(event)), NULL, NULL, NULL); -#else - gdk_window_get_pointer(w, NULL, NULL, NULL); -#endif gdk_event_request_motions(event); } @@ -1746,16 +1685,12 @@ bool SPCanvas::paintRect(int xx0, int yy0, int xx1, int yy1) // Save the mouse location gint x, y; -#if GTK_CHECK_VERSION(3,0,0) - GdkDeviceManager *dm = gdk_display_get_device_manager(gdk_display_get_default()); - GdkDevice *device = gdk_device_manager_get_client_pointer(dm); + auto dm = gdk_display_get_device_manager(gdk_display_get_default()); + auto device = gdk_device_manager_get_client_pointer(dm); gdk_window_get_device_position(gtk_widget_get_window(GTK_WIDGET(this)), device, &x, &y, NULL); -#else - gdk_window_get_pointer(gtk_widget_get_window(GTK_WIDGET(this)), &x, &y, NULL); -#endif setup.mouse_loc = sp_canvas_window_to_world(this, Geom::Point(x,y)); @@ -1818,21 +1753,6 @@ gboolean SPCanvas::handle_draw(GtkWidget *widget, cairo_t *cr) { return TRUE; } -#if !GTK_CHECK_VERSION(3,0,0) -gboolean SPCanvas::handle_expose(GtkWidget *widget, GdkEventExpose *event) -{ - cairo_t *cr = gdk_cairo_create(gtk_widget_get_window(widget)); - - gdk_cairo_region (cr, event->region); - cairo_clip (cr); - gboolean result = SPCanvas::handle_draw(widget, cr); - - cairo_destroy (cr); - - return result; -} -#endif - gint SPCanvas::handle_key_event(GtkWidget *widget, GdkEventKey *event) { diff --git a/src/display/sp-canvas.h b/src/display/sp-canvas.h index 171fdaf67..78d96d728 100644 --- a/src/display/sp-canvas.h +++ b/src/display/sp-canvas.h @@ -145,12 +145,8 @@ public: static void dispose(GObject *object); static void handle_realize(GtkWidget *widget); static void handle_unrealize(GtkWidget *widget); -#if GTK_CHECK_VERSION(3,0,0) static void handle_get_preferred_width(GtkWidget *widget, gint *min_w, gint *nat_w); static void handle_get_preferred_height(GtkWidget *widget, gint *min_h, gint *nat_h); -#else - static void handle_size_request(GtkWidget *widget, GtkRequisition *req); -#endif static void handle_size_allocate(GtkWidget *widget, GtkAllocation *allocation); static gint handle_button(GtkWidget *widget, GdkEventButton *event); @@ -162,9 +158,6 @@ public: static gint handle_scroll(GtkWidget *widget, GdkEventScroll *event); static gint handle_motion(GtkWidget *widget, GdkEventMotion *event); static gboolean handle_draw(GtkWidget *widget, cairo_t *cr); -#if !GTK_CHECK_VERSION(3,0,0) - static gboolean handle_expose(GtkWidget *widget, GdkEventExpose *event); -#endif static gint handle_key_event(GtkWidget *widget, GdkEventKey *event); static gint handle_crossing(GtkWidget *widget, GdkEventCrossing *event); static gint handle_focus_in(GtkWidget *widget, GdkEventFocus *event); diff --git a/src/display/sp-ctrlline.cpp b/src/display/sp-ctrlline.cpp index 1bde540c0..6c5674935 100644 --- a/src/display/sp-ctrlline.cpp +++ b/src/display/sp-ctrlline.cpp @@ -84,7 +84,7 @@ void sp_ctrlline_render(SPCanvasItem *item, SPCanvasBuf *buf) Geom::Point s = cl->s * cl->affine; Geom::Point e = cl->e * cl->affine; - ink_cairo_set_source_rgba32(buf->ct, 0xffffffbf); + ink_cairo_set_source_rgba32(buf->ct, 0xffffff7f); cairo_set_line_width(buf->ct, 2); cairo_new_path(buf->ct); diff --git a/src/document-subset.cpp b/src/document-subset.cpp index 7fad73d9e..649b1a406 100644 --- a/src/document-subset.cpp +++ b/src/document-subset.cpp @@ -13,18 +13,7 @@ #include "document.h" #include "sp-object.h" -#include <glib.h> - -#include <sigc++/signal.h> -#include <sigc++/functors/mem_fun.h> - -#include "util/list.h" -#include "util/reverse-list.h" - -#include <vector> #include <map> -#include <algorithm> -#include <iterator> namespace Inkscape { diff --git a/src/document-undo.cpp b/src/document-undo.cpp index c27904ea8..113d09d66 100644 --- a/src/document-undo.cpp +++ b/src/document-undo.cpp @@ -45,7 +45,6 @@ */ #include <string> -#include <cstring> #include "xml/repr.h" #include "document-private.h" #include "inkscape.h" diff --git a/src/document.cpp b/src/document.cpp index 9f408788b..920e47cb8 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -37,7 +37,7 @@ #define noSP_DOCUMENT_DEBUG_UNDO #ifdef HAVE_CONFIG_H -# include "config.h" +#include <config.h> #endif #include <string> #include <cstring> @@ -47,7 +47,6 @@ #include "desktop.h" #include "dir-util.h" #include "display/drawing.h" -#include "display/drawing-item.h" #include "document-private.h" #include "document-undo.h" #include "id-clash.h" @@ -55,18 +54,12 @@ #include "inkscape-version.h" #include "libavoid/router.h" #include "persp3d.h" -#include "preferences.h" #include "profile-manager.h" #include "rdf.h" #include "sp-factory.h" -#include "sp-item-group.h" #include "sp-namedview.h" #include "sp-symbol.h" -#include "transf_mat_3x4.h" -#include "util/units.h" -#include "xml/repr.h" #include "xml/rebase-hrefs.h" -#include "libcroco/cr-cascade.h" using Inkscape::DocumentUndo; using Inkscape::Util::unit_table; @@ -257,9 +250,9 @@ void SPDocument::setCurrentPersp3D(Persp3D * const persp) { void SPDocument::getPerspectivesInDefs(std::vector<Persp3D*> &list) const { - for (SPObject *i = root->defs->firstChild(); i; i = i->getNext() ) { - if (SP_IS_PERSP3D(i)) { - list.push_back(SP_PERSP3D(i)); + for (auto& i: root->defs->children) { + if (SP_IS_PERSP3D(&i)) { + list.push_back(SP_PERSP3D(&i)); } } } @@ -1259,12 +1252,12 @@ static std::vector<SPItem*> &find_items_in_area(std::vector<SPItem*> &s, SPGroup { g_return_val_if_fail(SP_IS_GROUP(group), s); - for ( SPObject *o = group->firstChild() ; o ; o = o->getNext() ) { - if ( SP_IS_ITEM(o) ) { - if (SP_IS_GROUP(o) && (SP_GROUP(o)->effectiveLayerMode(dkey) == SPGroup::LAYER || into_groups)) { - s = find_items_in_area(s, SP_GROUP(o), dkey, area, test, take_insensitive, into_groups); + for (auto& o: group->children) { + if ( SP_IS_ITEM(&o) ) { + if (SP_IS_GROUP(&o) && (SP_GROUP(&o)->effectiveLayerMode(dkey) == SPGroup::LAYER || into_groups)) { + s = find_items_in_area(s, SP_GROUP(&o), dkey, area, test, take_insensitive, into_groups); } else { - SPItem *child = SP_ITEM(o); + SPItem *child = SP_ITEM(&o); Geom::OptRect box = child->desktopVisualBounds(); if ( box && test(area, *box) && (take_insensitive || child->isVisibleAndUnlocked(dkey))) { s.push_back(child); @@ -1281,17 +1274,16 @@ Returns true if an item is among the descendants of group (recursively). */ static bool item_is_in_group(SPItem *item, SPGroup *group) { - bool inGroup = false; - for ( SPObject *o = group->firstChild() ; o && !inGroup; o = o->getNext() ) { - if ( SP_IS_ITEM(o) ) { - if (SP_ITEM(o) == item) { - inGroup = true; - } else if ( SP_IS_GROUP(o) ) { - inGroup = item_is_in_group(item, SP_GROUP(o)); + for (auto& o: group->children) { + if ( SP_IS_ITEM(&o) ) { + if (SP_ITEM(&o) == item) { + return true; + } else if (SP_IS_GROUP(&o) && item_is_in_group(item, SP_GROUP(&o))) { + return true; } } } - return inGroup; + return false; } SPItem *SPDocument::getItemFromListAtPointBottom(unsigned int dkey, SPGroup *group, std::vector<SPItem*> const &list,Geom::Point const &p, bool take_insensitive) @@ -1302,21 +1294,24 @@ SPItem *SPDocument::getItemFromListAtPointBottom(unsigned int dkey, SPGroup *gro Inkscape::Preferences *prefs = Inkscape::Preferences::get(); gdouble delta = prefs->getDouble("/options/cursortolerance/value", 1.0); - for ( SPObject *o = group->firstChild() ; o && !bottomMost; o = o->getNext() ) { - if ( SP_IS_ITEM(o) ) { - SPItem *item = SP_ITEM(o); + for (auto& o: group->children) { + if (bottomMost) { + break; + } + if (SP_IS_ITEM(&o)) { + SPItem *item = SP_ITEM(&o); Inkscape::DrawingItem *arenaitem = item->get_arenaitem(dkey); arenaitem->drawing().update(); if (arenaitem && arenaitem->pick(p, delta, 1) != NULL && (take_insensitive || item->isVisibleAndUnlocked(dkey))) { - if (find(list.begin(),list.end(),item)!=list.end() ) { + if (find(list.begin(), list.end(), item) != list.end()) { bottomMost = item; } } - if ( !bottomMost && SP_IS_GROUP(o) ) { + if (!bottomMost && SP_IS_GROUP(&o)) { // return null if not found: - bottomMost = getItemFromListAtPointBottom(dkey, SP_GROUP(o), list, p, take_insensitive); + bottomMost = getItemFromListAtPointBottom(dkey, SP_GROUP(&o), list, p, take_insensitive); } } } @@ -1329,15 +1324,15 @@ The list can be persisted, which improves "find at multiple points" speed. */ void SPDocument::build_flat_item_list(unsigned int dkey, SPGroup *group, gboolean into_groups) const { - for ( SPObject *o = group->firstChild() ; o ; o = o->getNext() ) { - if (!SP_IS_ITEM(o)) { + for (auto& o: group->children) { + if (!SP_IS_ITEM(&o)) { continue; } - if (SP_IS_GROUP(o) && (SP_GROUP(o)->effectiveLayerMode(dkey) == SPGroup::LAYER || into_groups)) { - build_flat_item_list(dkey, SP_GROUP(o), into_groups); + if (SP_IS_GROUP(&o) && (SP_GROUP(&o)->effectiveLayerMode(dkey) == SPGroup::LAYER || into_groups)) { + build_flat_item_list(dkey, SP_GROUP(&o), into_groups); } else { - SPItem *child = SP_ITEM(o); + SPItem *child = SP_ITEM(&o); if (child->isVisibleAndUnlocked(dkey)) { _node_cache.push_front(child); @@ -1393,18 +1388,18 @@ static SPItem *find_group_at_point(unsigned int dkey, SPGroup *group, Geom::Poin Inkscape::Preferences *prefs = Inkscape::Preferences::get(); gdouble delta = prefs->getDouble("/options/cursortolerance/value", 1.0); - for ( SPObject *o = group->firstChild() ; o ; o = o->getNext() ) { - if (!SP_IS_ITEM(o)) { + for (auto& o: group->children) { + if (!SP_IS_ITEM(&o)) { continue; } - if (SP_IS_GROUP(o) && SP_GROUP(o)->effectiveLayerMode(dkey) == SPGroup::LAYER) { - SPItem *newseen = find_group_at_point(dkey, SP_GROUP(o), p); + if (SP_IS_GROUP(&o) && SP_GROUP(&o)->effectiveLayerMode(dkey) == SPGroup::LAYER) { + SPItem *newseen = find_group_at_point(dkey, SP_GROUP(&o), p); if (newseen) { seen = newseen; } } - if (SP_IS_GROUP(o) && SP_GROUP(o)->effectiveLayerMode(dkey) != SPGroup::LAYER ) { - SPItem *child = SP_ITEM(o); + if (SP_IS_GROUP(&o) && SP_GROUP(&o)->effectiveLayerMode(dkey) != SPGroup::LAYER ) { + SPItem *child = SP_ITEM(&o); Inkscape::DrawingItem *arenaitem = child->get_arenaitem(dkey); arenaitem->drawing().update(); @@ -1598,8 +1593,8 @@ static unsigned int count_objects_recursive(SPObject *obj, unsigned int count) { count++; // obj itself - for ( SPObject *i = obj->firstChild(); i; i = i->getNext() ) { - count = count_objects_recursive(i, count); + for (auto& i: obj->children) { + count = count_objects_recursive(&i, count); } return count; @@ -1624,13 +1619,13 @@ static unsigned int objects_in_document(SPDocument *document) static void vacuum_document_recursive(SPObject *obj) { if (SP_IS_DEFS(obj)) { - for ( SPObject *def = obj->firstChild(); def; def = def->getNext()) { + for (auto& def: obj->children) { // fixme: some inkscape-internal nodes in the future might not be collectable - def->requestOrphanCollection(); + def.requestOrphanCollection(); } } else { - for ( SPObject *i = obj->firstChild(); i; i = i->getNext() ) { - vacuum_document_recursive(i); + for (auto& i: obj->children) { + vacuum_document_recursive(&i); } } } @@ -1758,14 +1753,14 @@ void SPDocument::importDefsNode(SPDocument *source, Inkscape::XML::Node *defs, I // Prevent duplicates of solid swatches by checking if equivalent swatch already exists if (src && SP_IS_GRADIENT(src)) { SPGradient *s_gr = SP_GRADIENT(src); - for (SPObject *trg = this->getDefs()->firstChild() ; trg ; trg = trg->getNext()) { - if (trg && (src != trg) && SP_IS_GRADIENT(trg)) { - SPGradient *t_gr = SP_GRADIENT(trg); + for (auto& trg: getDefs()->children) { + if (&trg && (src != &trg) && SP_IS_GRADIENT(&trg)) { + SPGradient *t_gr = SP_GRADIENT(&trg); if (t_gr && s_gr->isEquivalent(t_gr)) { // Change object references to the existing equivalent gradient - Glib::ustring newid = trg->getId(); + Glib::ustring newid = trg.getId(); if(newid != defid){ // id could be the same if it is a second paste into the same document - change_def_references(src, trg); + change_def_references(src, &trg); } gchar *longid = g_strdup_printf("%s_%9.9d", DuplicateDefString.c_str(), stagger++); def->setAttribute("id", longid ); @@ -1829,9 +1824,9 @@ void SPDocument::importDefsNode(SPDocument *source, Inkscape::XML::Node *defs, I 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"); + for (auto& trg: getDefs()->children) { + if(&trg && SP_IS_SYMBOL(&trg) && src != &trg ) { + std::string id2 = trg.getRepr()->attribute("id"); if( !id.compare( id2 ) ) { duplicate = true; diff --git a/src/ege-color-prof-tracker.cpp b/src/ege-color-prof-tracker.cpp index 78ee6b8b5..332a16d3c 100644 --- a/src/ege-color-prof-tracker.cpp +++ b/src/ege-color-prof-tracker.cpp @@ -45,7 +45,6 @@ #ifdef GDK_WINDOWING_X11 #include <X11/Xlib.h> -#include <X11/Xatom.h> #include <gdk/gdkx.h> #endif /* GDK_WINDOWING_X11 */ diff --git a/src/event-log.cpp b/src/event-log.cpp index db680d6d2..5a73b649e 100644 --- a/src/event-log.cpp +++ b/src/event-log.cpp @@ -12,17 +12,13 @@ #include "event-log.h" #include <glibmm/i18n.h> -#include <gtkmm/treemodel.h> #include <boost/shared_ptr.hpp> #include <boost/make_shared.hpp> #include "desktop.h" #include "inkscape.h" -#include "util/signal-blocker.h" #include "util/ucompose.hpp" #include "document.h" -#include "xml/repr.h" -#include "sp-object.h" namespace { diff --git a/src/extension/Makefile_insert b/src/extension/Makefile_insert deleted file mode 100644 index fb9713904..000000000 --- a/src/extension/Makefile_insert +++ /dev/null @@ -1,54 +0,0 @@ -## Makefile.am fragment sourced by src/Makefile.am. - -ink_common_sources += \ - extension/extension.cpp \ - extension/extension.h \ - extension/db.cpp \ - extension/db.h \ - extension/dependency.cpp \ - extension/dependency.h \ - extension/error-file.cpp \ - extension/error-file.h \ - extension/execution-env.cpp \ - extension/execution-env.h \ - extension/init.cpp \ - extension/init.h \ - extension/loader.h \ - extension/loader.cpp \ - extension/param/parameter.h \ - extension/param/parameter.cpp \ - extension/param/notebook.h \ - extension/param/notebook.cpp \ - extension/param/bool.h \ - extension/param/bool.cpp \ - extension/param/color.h \ - extension/param/color.cpp \ - extension/param/description.h \ - extension/param/description.cpp \ - extension/param/enum.h \ - extension/param/enum.cpp \ - extension/param/float.h \ - extension/param/float.cpp \ - extension/param/int.h \ - extension/param/int.cpp \ - extension/param/radiobutton.h \ - extension/param/radiobutton.cpp \ - extension/param/string.h \ - extension/param/string.cpp \ - extension/prefdialog.cpp \ - extension/prefdialog.h \ - extension/system.cpp \ - extension/system.h \ - extension/timer.cpp \ - extension/timer.h \ - extension/input.h \ - extension/input.cpp \ - extension/output.h \ - extension/output.cpp \ - extension/effect.h \ - extension/effect.cpp \ - extension/patheffect.h \ - extension/patheffect.cpp \ - extension/print.h \ - extension/print.cpp - diff --git a/src/extension/db.cpp b/src/extension/db.cpp index a3c54915d..f17b784a9 100644 --- a/src/extension/db.cpp +++ b/src/extension/db.cpp @@ -13,7 +13,7 @@ */ #ifdef HAVE_CONFIG_H -# include <config.h> +#include <config.h> #endif #include "db.h" #include "input.h" diff --git a/src/extension/dbus/Makefile_insert b/src/extension/dbus/Makefile_insert deleted file mode 100644 index 192651d87..000000000 --- a/src/extension/dbus/Makefile_insert +++ /dev/null @@ -1,111 +0,0 @@ -## Makefile.am fragment sourced by src/Makefile.am. - -if WITH_DBUS - -############################# -# Sources for DBus interface -############################# - -ink_common_sources += \ - extension/dbus/dbus-init.cpp \ - extension/dbus/dbus-init.h \ - extension/dbus/application-interface.cpp \ - extension/dbus/application-interface.h \ - extension/dbus/document-interface.cpp \ - extension/dbus/document-interface.h \ - extension/dbus/org.inkscape.service.in - -########################### -# Build DBus wrapper files -########################### - -extension/dbus/application-server-glue.h: extension/dbus/application-interface.xml - dbus-binding-tool --mode=glib-server --output=$@ --prefix=application_interface $^ - -extension/dbus/document-server-glue.h: extension/dbus/document-interface.xml - dbus-binding-tool --mode=glib-server --output=$@ --prefix=document_interface $^ - -extension/dbus/document-client-glue.h: extension/dbus/document-interface.xml - dbus-binding-tool --mode=glib-client --output=$@ --prefix=document_interface $^ - -BUILT_SOURCES += \ - extension/dbus/application-server-glue.h \ - extension/dbus/document-server-glue.h \ - extension/dbus/document-client-glue.h - -########################### -# Distribut DBus interface -########################### - -EXTRA_DIST += \ - extension/dbus/application-interface.xml \ - extension/dbus/document-interface.xml - -########################### -# DBus Activation Service -########################### - -# Dbus service file -servicedir = $(DBUSSERVICEDIR) -service_in_files = extension/dbus/org.inkscape.service.in -service_DATA = $(service_in_files:.service.in=.service) - -# Rule to make the service file with bindir expanded -$(service_DATA): $(service_in_files) Makefile - @sed -e "s|bindir|$(prefix)|" $<> $@ - -############################ -# DBus Interface Helper Lib -############################ - -lib_LTLIBRARIES = \ - libinkdbus.la - -libinkdbusincludedir = $(includedir)/libinkdbus-0.48/libinkdbus -libinkdbusinclude_HEADERS = \ - extension/dbus/wrapper/inkscape-dbus-wrapper.h - -libinkdbus_la_SOURCES = \ - extension/dbus/wrapper/inkscape-dbus-wrapper.h \ - extension/dbus/wrapper/inkscape-dbus-wrapper.c - -libinkdbus_la_LDFLAGS = \ - -version-info 0:0:0 \ - -no-undefined \ - -export-symbols-regex "^[^_d].*" - -libinkdbus_la_CFLAGS = \ - $(DBUS_CFLAGS) \ - $(INKSCAPE_CFLAGS) \ - -I$(builddir)/extension/dbus \ - -Wall - -libinkdbus_la_LIBADD = \ - $(DBUS_LIBS) \ - $(INKSCAPE_LIBS) - -############################ -# DBus Pkgconfig file -############################ - -pkgconfig_DATA = extension/dbus/wrapper/inkdbus.pc -pkgconfigdir = $(libdir)/pkgconfig - -else # WITH_DBUS - -EXTRA_DIST += \ - extension/dbus/dbus-init.cpp \ - extension/dbus/dbus-init.h \ - extension/dbus/application-interface.cpp \ - extension/dbus/application-interface.h \ - extension/dbus/document-interface.cpp \ - extension/dbus/document-interface.h \ - extension/dbus/wrapper/inkscape-dbus-wrapper.h \ - extension/dbus/wrapper/inkscape-dbus-wrapper.c \ - extension/dbus/wrapper/inkdbus.pc \ - extension/dbus/org.inkscape.service.in \ - extension/dbus/application-interface.xml \ - extension/dbus/document-interface.xml - -endif - diff --git a/src/extension/dbus/document-interface.cpp b/src/extension/dbus/document-interface.cpp index d0a2e81aa..667830997 100644 --- a/src/extension/dbus/document-interface.cpp +++ b/src/extension/dbus/document-interface.cpp @@ -189,7 +189,7 @@ selection_get_center_y (Inkscape::Selection *sel){ std::vector<SPObject*> selection_swap(Inkscape::Selection *sel, gchar *name, GError **error) { - std::vector<SPObject*> oldsel = sel->list(); + std::vector<SPObject*> oldsel = std::vector<SPObject*>(sel->objects().begin(), sel->objects().end()); sel->set(get_object_by_name(sel->layers()->getDocument(), name, error)); return oldsel; @@ -405,7 +405,7 @@ document_interface_polygon (DocumentInterface *doc_interface, int cx, int cy, int radius, int rotation, int sides, GError **error) { - gdouble rot = ((rotation / 180.0) * 3.14159265) - ( 3.14159265 / 2.0); + gdouble rot = ((rotation / 180.0) * M_PI) - M_PI_2; Inkscape::XML::Node *newNode = dbus_create_node(doc_interface->target.getDocument(), "svg:path"); newNode->setAttribute("inkscape:flatsided", "true"); newNode->setAttribute("sodipodi:type", "star"); @@ -1087,14 +1087,14 @@ void document_interface_update(DocumentInterface *doc_interface, GError ** error gboolean document_interface_selection_get(DocumentInterface *doc_interface, char ***out, GError ** /*error*/) { Inkscape::Selection * sel = doc_interface->target.getSelection(); - std::vector<SPObject*> oldsel = sel->list(); + auto oldsel = sel->objects(); int size = oldsel.size(); *out = g_new0 (char *, size + 1); int i = 0; - for (std::vector<SPObject*>::iterator iter = oldsel.begin(), e = oldsel.end(); iter != e; ++iter) { + for (auto iter = oldsel.begin(); iter != oldsel.end(); ++iter) { (*out)[i] = g_strdup((*iter)->getId()); i++; } @@ -1252,7 +1252,7 @@ gboolean document_interface_selection_move_to(DocumentInterface *doc_interface, Geom::OptRect sel_bbox = sel->visualBounds(); if (sel_bbox) { Geom::Point m( x - selection_get_center_x(sel) , 0 - (y - selection_get_center_y(sel)) ); - sp_selection_move_relative(sel, m, true); + sp_object_set_move_relative(sel, m, true); } return TRUE; } diff --git a/src/extension/dependency.cpp b/src/extension/dependency.cpp index 624be12f9..837520381 100644 --- a/src/extension/dependency.cpp +++ b/src/extension/dependency.cpp @@ -9,14 +9,12 @@ */ #ifdef HAVE_CONFIG_H -#include "config.h" +#include <config.h> #endif #include <glibmm/i18n.h> #include <glibmm/fileutils.h> #include <glibmm/miscutils.h> -#include "config.h" -#include "path-prefix.h" #include "dependency.h" #include "db.h" #include "extension.h" diff --git a/src/extension/effect.cpp b/src/extension/effect.cpp index e7299ba51..ef254f623 100644 --- a/src/extension/effect.cpp +++ b/src/extension/effect.cpp @@ -13,7 +13,6 @@ #include "helper/action.h" #include "ui/view/view.h" -#include "selection.h" #include "sp-namedview.h" #include "desktop.h" #include "implementation/implementation.h" diff --git a/src/extension/error-file.cpp b/src/extension/error-file.cpp index db354c0ce..342511ec9 100644 --- a/src/extension/error-file.cpp +++ b/src/extension/error-file.cpp @@ -9,7 +9,7 @@ #ifdef HAVE_CONFIG_H -#include "config.h" +#include <config.h> #endif #include "ui/dialog/extensions.h" @@ -56,11 +56,7 @@ ErrorFileNotice::ErrorFileNotice (void) : g_free(ext_error_file); set_message(dialog_text, true); -#if WITH_GTKMM_3_0 - Gtk::Box * vbox = get_content_area(); -#else - Gtk::Box * vbox = get_vbox(); -#endif + auto vbox = get_content_area(); /* This is some filler text, needs to change before relase */ Inkscape::Preferences *prefs = Inkscape::Preferences::get(); diff --git a/src/extension/execution-env.cpp b/src/extension/execution-env.cpp index d5c80f26e..624813863 100644 --- a/src/extension/execution-env.cpp +++ b/src/extension/execution-env.cpp @@ -8,10 +8,8 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include <config.h> - #ifdef HAVE_CONFIG_H -# include <config.h> +#include <config.h> #endif #include "gtkmm/messagedialog.h" @@ -25,7 +23,6 @@ #include "document.h" #include "document-undo.h" #include "desktop.h" -#include "ui/view/view.h" #include "sp-namedview.h" #include "display/sp-canvas.h" @@ -58,8 +55,8 @@ ExecutionEnv::ExecutionEnv (Effect * effect, Inkscape::UI::View::View * doc, Imp sp_namedview_document_from_window(desktop); if (desktop != NULL) { - std::vector<SPItem*> selected = desktop->getSelection()->itemList(); - for(std::vector<SPItem*>::const_iterator x = selected.begin(); x != selected.end(); ++x){ + auto selected = desktop->getSelection()->items(); + for(auto x = selected.begin(); x != selected.end(); ++x){ Glib::ustring selected_id; selected_id = (*x)->getId(); _selected.insert(_selected.end(), selected_id); diff --git a/src/extension/extension.cpp b/src/extension/extension.cpp index 6f7539360..c6dee1b70 100644 --- a/src/extension/extension.cpp +++ b/src/extension/extension.cpp @@ -16,18 +16,13 @@ */ #ifdef HAVE_CONFIG_H -# include "config.h" +#include <config.h> #endif #include <gtkmm/box.h> #include <gtkmm/label.h> #include <gtkmm/frame.h> - -#if WITH_GTKMM_3_0 -# include <gtkmm/grid.h> -#else -# include <gtkmm/table.h> -#endif +#include <gtkmm/grid.h> #include <glibmm/i18n.h> #include "inkscape.h" @@ -766,11 +761,7 @@ Extension::get_info_widget(void) Gtk::Frame * info = Gtk::manage(new Gtk::Frame("General Extension Information")); retval->pack_start(*info, true, true, 5); -#if WITH_GTKMM_3_0 - Gtk::Grid * table = Gtk::manage(new Gtk::Grid()); -#else - Gtk::Table * table = Gtk::manage(new Gtk::Table()); -#endif + auto table = Gtk::manage(new Gtk::Grid()); info->add(*table); @@ -784,11 +775,7 @@ Extension::get_info_widget(void) return retval; } -#if WITH_GTKMM_3_0 void Extension::add_val(Glib::ustring labelstr, Glib::ustring valuestr, Gtk::Grid * table, int * row) -#else -void Extension::add_val(Glib::ustring labelstr, Glib::ustring valuestr, Gtk::Table * table, int * row) -#endif { Gtk::Label * label; Gtk::Label * value; @@ -797,13 +784,8 @@ void Extension::add_val(Glib::ustring labelstr, Glib::ustring valuestr, Gtk::Tab label = Gtk::manage(new Gtk::Label(labelstr)); value = Gtk::manage(new Gtk::Label(valuestr)); -#if WITH_GTKMM_3_0 table->attach(*label, 0, (*row) - 1, 1, 1); table->attach(*value, 1, (*row) - 1, 1, 1); -#else - table->attach(*label, 0, 1, (*row) - 1, *row); - table->attach(*value, 1, 2, (*row) - 1, *row); -#endif label->show(); value->show(); diff --git a/src/extension/extension.h b/src/extension/extension.h index 1fb8bdfec..cd29e1636 100644 --- a/src/extension/extension.h +++ b/src/extension/extension.h @@ -22,12 +22,7 @@ #include <sigc++/signal.h> namespace Gtk { -#if WITH_GTKMM_3_0 class Grid; -#else - class Table; -#endif - class VBox; class Widget; } @@ -300,11 +295,7 @@ public: Gtk::VBox * get_help_widget(void); Gtk::VBox * get_params_widget(void); protected: -#if WITH_GTKMM_3_0 inline static void add_val(Glib::ustring labelstr, Glib::ustring valuestr, Gtk::Grid * table, int * row); -#else - inline static void add_val(Glib::ustring labelstr, Glib::ustring valuestr, Gtk::Table * table, int * row); -#endif }; diff --git a/src/extension/implementation/Makefile_insert b/src/extension/implementation/Makefile_insert deleted file mode 100644 index 1b9080f1a..000000000 --- a/src/extension/implementation/Makefile_insert +++ /dev/null @@ -1,9 +0,0 @@ -## Makefile.am fragment sourced by src/Makefile.am. - -ink_common_sources += \ - extension/implementation/implementation.cpp \ - extension/implementation/implementation.h \ - extension/implementation/script.cpp \ - extension/implementation/script.h \ - extension/implementation/xslt.cpp \ - extension/implementation/xslt.h diff --git a/src/extension/implementation/implementation.cpp b/src/extension/implementation/implementation.cpp index 92a8a2833..6e6100d2b 100644 --- a/src/extension/implementation/implementation.cpp +++ b/src/extension/implementation/implementation.cpp @@ -11,7 +11,7 @@ */ #ifdef HAVE_CONFIG_H -# include <config.h> +#include <config.h> #endif #include "implementation.h" @@ -22,7 +22,6 @@ #include "selection.h" #include "desktop.h" -#include "ui/view/view.h" namespace Inkscape { namespace Extension { @@ -46,10 +45,10 @@ Gtk::Widget *Implementation::prefs_effect(Inkscape::Extension::Effect *module, I SPDocument * current_document = view->doc(); - std::vector<SPItem*> selected = ((SPDesktop *)view)->getSelection()->itemList(); + auto selected = ((SPDesktop *) view)->getSelection()->items(); Inkscape::XML::Node const* first_select = NULL; if (!selected.empty()) { - const SPItem * item = selected[0]; + const SPItem * item = selected.front(); first_select = item->getRepr(); } diff --git a/src/extension/implementation/script.cpp b/src/extension/implementation/script.cpp index 01323bee2..d2319c2e0 100644 --- a/src/extension/implementation/script.cpp +++ b/src/extension/implementation/script.cpp @@ -689,9 +689,9 @@ void Script::effect(Inkscape::Extension::Effect *module, return; } - std::vector<SPItem*> selected = - desktop->getSelection()->itemList(); //desktop should not be NULL since doc was checked and desktop is a casted pointer - for(std::vector<SPItem*>::const_iterator x = selected.begin(); x != selected.end(); ++x){ + auto selected = + desktop->getSelection()->items(); //desktop should not be NULL since doc was checked and desktop is a casted pointer + for(auto x = selected.begin(); x != selected.end(); ++x){ Glib::ustring selected_id; selected_id += "--id="; selected_id += (*x)->getId(); @@ -942,11 +942,7 @@ void Script::checkStderr (const Glib::ustring &data, GtkWidget *dlg = GTK_WIDGET(warning.gobj()); sp_transientize(dlg); -#if WITH_GTKMM_3_0 - Gtk::Box * vbox = warning.get_content_area(); -#else - Gtk::Box * vbox = warning.get_vbox(); -#endif + auto vbox = warning.get_content_area(); /* Gtk::TextView * textview = new Gtk::TextView(Gtk::TextBuffer::create()); */ Gtk::TextView * textview = new Gtk::TextView(); diff --git a/src/extension/implementation/xslt.cpp b/src/extension/implementation/xslt.cpp index 85ae9efde..373378d97 100644 --- a/src/extension/implementation/xslt.cpp +++ b/src/extension/implementation/xslt.cpp @@ -13,7 +13,7 @@ */ #ifdef HAVE_CONFIG_H -# include <config.h> +#include <config.h> #endif #include "file.h" @@ -22,13 +22,11 @@ #include "../output.h" #include "extension/input.h" -#include "xml/repr.h" #include "io/sys.h" #include <unistd.h> #include <cstring> #include "document.h" -#include <libxml/parser.h> #include <libxslt/transform.h> #include <libxslt/xsltutils.h> diff --git a/src/extension/input.cpp b/src/extension/input.cpp index 5cef38009..2ba48ffda 100644 --- a/src/extension/input.cpp +++ b/src/extension/input.cpp @@ -8,14 +8,12 @@ */ #ifdef HAVE_CONFIG_H -# include "config.h" #endif #include "prefdialog.h" #include "implementation/implementation.h" #include "timer.h" #include "input.h" -#include "io/sys.h" /* Inkscape::Extension::Input */ diff --git a/src/extension/internal/Makefile_insert b/src/extension/internal/Makefile_insert deleted file mode 100644 index 125776d41..000000000 --- a/src/extension/internal/Makefile_insert +++ /dev/null @@ -1,173 +0,0 @@ -## Makefile.am fragment sourced by src/Makefile.am. - -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 WITH_LIBCDR -ink_common_sources += \ - extension/internal/cdr-input.cpp \ - extension/internal/cdr-input.h -endif - -if USE_IMAGE_MAGICK -ink_common_sources += \ - extension/internal/bitmap/imagemagick.cpp \ - extension/internal/bitmap/imagemagick.h \ - extension/internal/bitmap/adaptiveThreshold.cpp \ - extension/internal/bitmap/adaptiveThreshold.h \ - extension/internal/bitmap/addNoise.cpp \ - extension/internal/bitmap/addNoise.h \ - extension/internal/bitmap/blur.cpp \ - extension/internal/bitmap/blur.h \ - extension/internal/bitmap/channel.cpp \ - extension/internal/bitmap/channel.h \ - extension/internal/bitmap/charcoal.cpp \ - extension/internal/bitmap/charcoal.h \ - extension/internal/bitmap/colorize.cpp \ - extension/internal/bitmap/colorize.h \ - extension/internal/bitmap/contrast.cpp \ - extension/internal/bitmap/contrast.h \ - extension/internal/bitmap/crop.cpp \ - extension/internal/bitmap/crop.h \ - extension/internal/bitmap/cycleColormap.cpp \ - extension/internal/bitmap/cycleColormap.h \ - extension/internal/bitmap/despeckle.cpp \ - extension/internal/bitmap/despeckle.h \ - extension/internal/bitmap/edge.cpp \ - extension/internal/bitmap/edge.h \ - extension/internal/bitmap/emboss.cpp \ - extension/internal/bitmap/emboss.h \ - extension/internal/bitmap/enhance.cpp \ - extension/internal/bitmap/enhance.h \ - extension/internal/bitmap/equalize.cpp \ - extension/internal/bitmap/equalize.h \ - extension/internal/bitmap/gaussianBlur.cpp \ - extension/internal/bitmap/gaussianBlur.h \ - extension/internal/bitmap/implode.cpp \ - extension/internal/bitmap/implode.h \ - extension/internal/bitmap/level.cpp \ - extension/internal/bitmap/level.h \ - extension/internal/bitmap/levelChannel.cpp \ - extension/internal/bitmap/levelChannel.h \ - extension/internal/bitmap/medianFilter.cpp \ - extension/internal/bitmap/medianFilter.h \ - extension/internal/bitmap/modulate.cpp \ - extension/internal/bitmap/modulate.h \ - extension/internal/bitmap/negate.cpp \ - extension/internal/bitmap/negate.h \ - extension/internal/bitmap/normalize.cpp \ - extension/internal/bitmap/normalize.h \ - extension/internal/bitmap/oilPaint.cpp \ - extension/internal/bitmap/oilPaint.h \ - extension/internal/bitmap/opacity.cpp \ - extension/internal/bitmap/opacity.h \ - extension/internal/bitmap/raise.cpp \ - extension/internal/bitmap/raise.h \ - extension/internal/bitmap/reduceNoise.cpp \ - extension/internal/bitmap/reduceNoise.h \ - extension/internal/bitmap/sample.cpp \ - extension/internal/bitmap/sample.h \ - extension/internal/bitmap/shade.cpp \ - extension/internal/bitmap/shade.h \ - extension/internal/bitmap/sharpen.cpp \ - extension/internal/bitmap/sharpen.h \ - extension/internal/bitmap/solarize.cpp \ - extension/internal/bitmap/solarize.h \ - extension/internal/bitmap/spread.cpp \ - extension/internal/bitmap/spread.h \ - extension/internal/bitmap/swirl.cpp \ - extension/internal/bitmap/swirl.h \ - extension/internal/bitmap/threshold.cpp \ - extension/internal/bitmap/threshold.h \ - extension/internal/bitmap/unsharpmask.cpp \ - extension/internal/bitmap/unsharpmask.h \ - extension/internal/bitmap/wave.cpp \ - extension/internal/bitmap/wave.h -endif - -ink_common_sources += \ - extension/internal/bluredge.h \ - extension/internal/bluredge.cpp \ - extension/internal/clear-n_.h \ - extension/internal/grid.h \ - extension/internal/grid.cpp \ - extension/internal/gimpgrad.h \ - extension/internal/gimpgrad.cpp \ - extension/internal/svg.h \ - extension/internal/svg.cpp \ - extension/internal/svgz.h \ - extension/internal/svgz.cpp \ - extension/internal/cairo-ps-out.h \ - extension/internal/cairo-ps-out.cpp \ - extension/internal/cairo-render-context.h \ - extension/internal/cairo-render-context.cpp \ - extension/internal/cairo-renderer.h \ - extension/internal/cairo-renderer.cpp \ - extension/internal/cairo-renderer-pdf-out.h \ - extension/internal/cairo-renderer-pdf-out.cpp \ - extension/internal/cairo-png-out.h \ - extension/internal/cairo-png-out.cpp \ - extension/internal/javafx-out.cpp \ - extension/internal/javafx-out.h \ - extension/internal/gdkpixbuf-input.h \ - extension/internal/gdkpixbuf-input.cpp \ - extension/internal/latex-text-renderer.h \ - extension/internal/latex-text-renderer.cpp \ - extension/internal/pdfinput/svg-builder.h \ - extension/internal/pdfinput/svg-builder.cpp \ - extension/internal/pdfinput/pdf-parser.h \ - extension/internal/pdfinput/pdf-parser.cpp \ - extension/internal/pdfinput/pdf-input.h \ - extension/internal/pdfinput/pdf-input.cpp \ - extension/internal/pov-out.cpp \ - extension/internal/pov-out.h \ - extension/internal/odf.cpp \ - extension/internal/odf.h \ - extension/internal/latex-pstricks.cpp \ - 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/text_reassemble.c \ - extension/internal/text_reassemble.h \ - extension/internal/emf-print.h \ - extension/internal/emf-print.cpp \ - extension/internal/emf-inout.h \ - extension/internal/emf-inout.cpp \ - extension/internal/metafile-inout.h \ - extension/internal/metafile-inout.cpp \ - extension/internal/metafile-print.h \ - extension/internal/metafile-print.cpp \ - extension/internal/wmf-print.h \ - extension/internal/wmf-print.cpp \ - extension/internal/wmf-inout.h \ - extension/internal/wmf-inout.cpp \ - extension/internal/image-resolution.h \ - extension/internal/image-resolution.cpp - diff --git a/src/extension/internal/bitmap/imagemagick.cpp b/src/extension/internal/bitmap/imagemagick.cpp index a235dcb0f..472c2db91 100644 --- a/src/extension/internal/bitmap/imagemagick.cpp +++ b/src/extension/internal/bitmap/imagemagick.cpp @@ -65,8 +65,8 @@ ImageMagickDocCache::ImageMagickDocCache(Inkscape::UI::View::View * view) : _imageItems(NULL) { SPDesktop *desktop = (SPDesktop*)view; - const std::vector<SPItem*> selectedItemList = desktop->selection->itemList(); - int selectCount = selectedItemList.size(); + auto selectedItemList = desktop->selection->items(); + int selectCount = (int) boost::distance(selectedItemList); // Init the data-holders _nodes = new Inkscape::XML::Node*[selectCount]; @@ -78,7 +78,7 @@ ImageMagickDocCache::ImageMagickDocCache(Inkscape::UI::View::View * view) : _imageItems = new SPItem*[selectCount]; // Loop through selected items - for (std::vector<SPItem*>::const_iterator i = selectedItemList.begin(); i != selectedItemList.end(); ++i) { + for (auto i = selectedItemList.begin(); i != selectedItemList.end(); ++i) { SPItem *item = *i; Inkscape::XML::Node *node = reinterpret_cast<Inkscape::XML::Node *>(item->getRepr()); if (!strcmp(node->name(), "image") || !strcmp(node->name(), "svg:image")) @@ -235,7 +235,7 @@ ImageMagick::prefs_effect(Inkscape::Extension::Effect *module, Inkscape::UI::Vie { SPDocument * current_document = view->doc(); - std::vector<SPItem*> selected = ((SPDesktop *)view)->getSelection()->itemList(); + auto selected = ((SPDesktop *) view)->getSelection()->items(); Inkscape::XML::Node * first_select = NULL; if (!selected.empty()) { first_select = (selected.front())->getRepr(); diff --git a/src/extension/internal/bluredge.cpp b/src/extension/internal/bluredge.cpp index 4a04e3c33..4f66b39fc 100644 --- a/src/extension/internal/bluredge.cpp +++ b/src/extension/internal/bluredge.cpp @@ -62,7 +62,7 @@ BlurEdge::effect (Inkscape::Extension::Effect *module, Inkscape::UI::View::View double old_offset = prefs->getDouble("/options/defaultoffsetwidth/value", 1.0, "px"); // TODO need to properly refcount the items, at least - std::vector<SPItem*> items(selection->itemList()); + std::vector<SPItem*> items(selection->items().begin(), selection->items().end()); selection->clear(); for(std::vector<SPItem*>::iterator item = items.begin(); diff --git a/src/extension/internal/cairo-render-context.cpp b/src/extension/internal/cairo-render-context.cpp index 5d8b0e076..e65752c84 100644 --- a/src/extension/internal/cairo-render-context.cpp +++ b/src/extension/internal/cairo-render-context.cpp @@ -42,7 +42,7 @@ #include "sp-hatch.h" #include "sp-linear-gradient.h" #include "sp-radial-gradient.h" -#include "sp-mesh.h" +#include "sp-mesh-gradient.h" #include "sp-pattern.h" #include "sp-mask.h" #include "sp-clippath.h" @@ -986,13 +986,12 @@ void CairoRenderContext::popState(void) static bool pattern_hasItemChildren(SPPattern *pat) { - bool hasItems = false; - for ( SPObject *child = pat->firstChild() ; child && !hasItems; child = child->getNext() ) { - if (SP_IS_ITEM (child)) { - hasItems = true; + for (auto& child: pat->children) { + if (SP_IS_ITEM (&child)) { + return true; } } - return hasItems; + return false; } cairo_pattern_t* @@ -1087,10 +1086,10 @@ CairoRenderContext::_createPatternPainter(SPPaintServer const *const paintserver // show items and render them for (SPPattern *pat_i = pat; pat_i != NULL; pat_i = pat_i->ref ? pat_i->ref->getObject() : NULL) { if (pat_i && SP_IS_OBJECT(pat_i) && pattern_hasItemChildren(pat_i)) { // find the first one with item children - for ( SPObject *child = pat_i->firstChild() ; child; child = child->getNext() ) { - if (SP_IS_ITEM(child)) { - SP_ITEM(child)->invoke_show(drawing, dkey, SP_ITEM_REFERENCE_FLAGS); - _renderer->renderItem(pattern_ctx, SP_ITEM(child)); + for (auto& child: pat_i->children) { + if (SP_IS_ITEM(&child)) { + SP_ITEM(&child)->invoke_show(drawing, dkey, SP_ITEM_REFERENCE_FLAGS); + _renderer->renderItem(pattern_ctx, SP_ITEM(&child)); } } break; // do not go further up the chain if children are found @@ -1116,9 +1115,9 @@ CairoRenderContext::_createPatternPainter(SPPaintServer const *const paintserver // hide all items for (SPPattern *pat_i = pat; pat_i != NULL; pat_i = pat_i->ref ? pat_i->ref->getObject() : NULL) { if (pat_i && SP_IS_OBJECT(pat_i) && pattern_hasItemChildren(pat_i)) { // find the first one with item children - for ( SPObject *child = pat_i->firstChild() ; child; child = child->getNext() ) { - if (SP_IS_ITEM(child)) { - SP_ITEM(child)->invoke_hide(dkey); + for (auto& child: pat_i->children) { + if (SP_IS_ITEM(&child)) { + SP_ITEM(&child)->invoke_hide(dkey); } } break; // do not go further up the chain if children are found @@ -1258,8 +1257,8 @@ CairoRenderContext::_createPatternForPaintServer(SPPaintServer const *const pain sp_color_get_rgb_floatv(&rg->vector.stops[i].color, rgb); cairo_pattern_add_color_stop_rgba(pattern, rg->vector.stops[i].offset, rgb[0], rgb[1], rgb[2], rg->vector.stops[i].opacity * alpha); } - } else if (SP_IS_MESH (paintserver)) { - SPMesh *mg = SP_MESH(paintserver); + } else if (SP_IS_MESHGRADIENT (paintserver)) { + SPMeshGradient *mg = SP_MESHGRADIENT(paintserver); pattern = mg->pattern_new(_cr, pbox, 1.0); } else if (SP_IS_PATTERN (paintserver)) { diff --git a/src/extension/internal/cairo-renderer.cpp b/src/extension/internal/cairo-renderer.cpp index 5dc20ab06..cd96a7f58 100644 --- a/src/extension/internal/cairo-renderer.cpp +++ b/src/extension/internal/cairo-renderer.cpp @@ -741,8 +741,8 @@ CairoRenderer::applyClipPath(CairoRenderContext *ctx, SPClipPath const *cp) TRACE(("BEGIN clip\n")); SPObject const *co = cp; - for ( SPObject const *child = co->firstChild() ; child; child = child->getNext() ) { - SPItem const *item = dynamic_cast<SPItem const *>(child); + for (auto& child: co->children) { + SPItem const *item = dynamic_cast<SPItem const *>(&child); if (item) { // combine transform of the item in clippath and the item using clippath: @@ -800,8 +800,8 @@ CairoRenderer::applyMask(CairoRenderContext *ctx, SPMask const *mask) TRACE(("BEGIN mask\n")); SPObject const *co = mask; - for ( SPObject const *child = co->firstChild() ; child; child = child->getNext() ) { - SPItem const *item = dynamic_cast<SPItem const *>(child); + for (auto& child: co->children) { + SPItem const *item = dynamic_cast<SPItem const *>(&child); if (item) { // TODO fix const correctness: renderItem(ctx, const_cast<SPItem*>(item)); diff --git a/src/extension/internal/cdr-input.cpp b/src/extension/internal/cdr-input.cpp index a26af2078..b94b6d019 100644 --- a/src/extension/internal/cdr-input.cpp +++ b/src/extension/internal/cdr-input.cpp @@ -111,11 +111,7 @@ CdrImportDialog::CdrImportDialog(const std::vector<RVNGString> &vec) _previewArea = Gtk::manage(new class Gtk::VBox()); vbox1 = Gtk::manage(new class Gtk::VBox()); vbox1->pack_start(*_previewArea, Gtk::PACK_EXPAND_WIDGET, 0); -#if WITH_GTKMM_3_0 this->get_content_area()->pack_start(*vbox1); -#else - this->get_vbox()->pack_start(*vbox1); -#endif // CONTROLS @@ -137,13 +133,8 @@ CdrImportDialog::CdrImportDialog(const std::vector<RVNGString> &vec) g_free(label_text); // Adjustment + spinner -#if WITH_GTKMM_3_0 - Glib::RefPtr<Gtk::Adjustment> _pageNumberSpin_adj = Gtk::Adjustment::create(1, 1, _vec.size(), 1, 10, 0); + auto _pageNumberSpin_adj = Gtk::Adjustment::create(1, 1, _vec.size(), 1, 10, 0); _pageNumberSpin = Gtk::manage(new Gtk::SpinButton(_pageNumberSpin_adj, 1, 0)); -#else - Gtk::Adjustment *_pageNumberSpin_adj = Gtk::manage(new class Gtk::Adjustment(1, 1, _vec.size(), 1, 10, 0)); - _pageNumberSpin = Gtk::manage(new Gtk::SpinButton(*_pageNumberSpin_adj, 1, 0)); -#endif _pageNumberSpin->set_can_focus(); _pageNumberSpin->set_update_policy(Gtk::UPDATE_ALWAYS); _pageNumberSpin->set_numeric(true); diff --git a/src/extension/internal/emf-print.cpp b/src/extension/internal/emf-print.cpp index 9f3b5475f..d4c5d95a3 100644 --- a/src/extension/internal/emf-print.cpp +++ b/src/extension/internal/emf-print.cpp @@ -1042,8 +1042,12 @@ void PrintEmf::do_clip_if_present(SPStyle const *style){ /* find the clipping path */ Geom::PathVector combined_pathvector; Geom::Affine tfc; // clipping transform, generally not the same as item transform - for(item = SP_ITEM(scp->firstChild()); item; item=SP_ITEM(item->getNext())){ - if (SP_IS_GROUP(item)) { // not implemented + for (auto& child: scp->children) { + item = SP_ITEM(&child); + if (!item) { + break; + } + if (SP_IS_GROUP(item)) { // not implemented // return sp_group_render(item); combined_pathvector = merge_PathVector_with_group(combined_pathvector, item, tfc); } else if (SP_IS_SHAPE(item)) { @@ -1081,7 +1085,11 @@ Geom::PathVector PrintEmf::merge_PathVector_with_group(Geom::PathVector const &c new_combined_pathvector = combined_pathvector; SPGroup *group = SP_GROUP(item); Geom::Affine tfc = item->transform * transform; - for(SPItem *item = SP_ITEM(group->firstChild()); item; item=SP_ITEM(item->getNext())){ + for (auto& child: group->children) { + item = SP_ITEM(&child); + if (!item) { + break; + } if (SP_IS_GROUP(item)) { new_combined_pathvector = merge_PathVector_with_group(new_combined_pathvector, item, tfc); // could be endlessly recursive on a badly formed SVG } else if (SP_IS_SHAPE(item)) { diff --git a/src/extension/internal/filter/filter.cpp b/src/extension/internal/filter/filter.cpp index 25e89bbf3..0907845f8 100644 --- a/src/extension/internal/filter/filter.cpp +++ b/src/extension/internal/filter/filter.cpp @@ -125,7 +125,7 @@ void Filter::effect(Inkscape::Extension::Effect *module, Inkscape::UI::View::Vie Inkscape::Selection * selection = ((SPDesktop *)document)->selection; // TODO need to properly refcount the items, at least - std::vector<SPItem*> items(selection->itemList()); + std::vector<SPItem*> items(selection->items().begin(), selection->items().end()); Inkscape::XML::Document * xmldoc = document->doc()->getReprDoc(); Inkscape::XML::Node * defsrepr = document->doc()->getDefs()->getRepr(); diff --git a/src/extension/internal/gdkpixbuf-input.cpp b/src/extension/internal/gdkpixbuf-input.cpp index b30c67a4d..e0dc90981 100644 --- a/src/extension/internal/gdkpixbuf-input.cpp +++ b/src/extension/internal/gdkpixbuf-input.cpp @@ -134,8 +134,13 @@ GdkpixbufInput::open(Inkscape::Extension::Input *mod, char const *uri) } // Add it to the current layer - doc->getRoot()->appendChildRepr(image_node); + Inkscape::XML::Node *layer_node = xml_doc->createElement("svg:g"); + layer_node->setAttribute("inkscape:groupmode", "layer"); + layer_node->setAttribute("inkscape:label", "Image"); + doc->getRoot()->appendChildRepr(layer_node); + layer_node->appendChild(image_node); Inkscape::GC::release(image_node); + Inkscape::GC::release(layer_node); fit_canvas_to_drawing(doc); // Set viewBox if it doesn't exist diff --git a/src/extension/internal/grid.cpp b/src/extension/internal/grid.cpp index c766bd828..9e730f5e5 100644 --- a/src/extension/internal/grid.cpp +++ b/src/extension/internal/grid.cpp @@ -180,10 +180,10 @@ Grid::prefs_effect(Inkscape::Extension::Effect *module, Inkscape::UI::View::View { SPDocument * current_document = view->doc(); - std::vector<SPItem*> selected = ((SPDesktop *)view)->getSelection()->itemList(); + auto selected = ((SPDesktop *) view)->getSelection()->items(); Inkscape::XML::Node * first_select = NULL; if (!selected.empty()) { - first_select = selected[0]->getRepr(); + first_select = selected.front()->getRepr(); } return module->autogui(current_document, first_select, changeSignal); diff --git a/src/extension/internal/javafx-out.cpp b/src/extension/internal/javafx-out.cpp index 386bde1d6..d7ad7e6f7 100644 --- a/src/extension/internal/javafx-out.cpp +++ b/src/extension/internal/javafx-out.cpp @@ -732,9 +732,9 @@ bool JavaFXOutput::doTreeRecursive(SPDocument *doc, SPObject *obj) /** * Descend into children */ - for (SPObject *child = obj->firstChild() ; child ; child = child->next) + for (auto &child: obj->children) { - if (!doTreeRecursive(doc, child)) { + if (!doTreeRecursive(doc, &child)) { return false; } } @@ -804,9 +804,9 @@ bool JavaFXOutput::doBody(SPDocument *doc, SPObject *obj) /** * Descend into children */ - for (SPObject *child = obj->firstChild() ; child ; child = child->next) + for (auto &child: obj->children) { - if (!doBody(doc, child)) { + if (!doBody(doc, &child)) { return false; } } diff --git a/src/extension/internal/metafile-print.cpp b/src/extension/internal/metafile-print.cpp index 47ba5971c..061eb634d 100644 --- a/src/extension/internal/metafile-print.cpp +++ b/src/extension/internal/metafile-print.cpp @@ -293,20 +293,22 @@ void PrintMetafile::brush_classify(SPObject *parent, int depth, Inkscape::Pixbuf } // still looking? Look at this pattern's children, if there are any - SPObject *child = pat_i->firstChild(); - while (child && !(*epixbuf) && (*hatchType == -1)) { - brush_classify(child, depth, epixbuf, hatchType, hatchColor, bkColor); - child = child->getNext(); + for (auto& child: pat_i->children) { + if (*epixbuf || *hatchType != -1) { + break; + } + brush_classify(&child, depth, epixbuf, hatchType, hatchColor, bkColor); } } } else if (SP_IS_IMAGE(parent)) { *epixbuf = ((SPImage *)parent)->pixbuf; return; } else { // some inkscape rearrangements pass through nodes between pattern and image which are not classified as either. - SPObject *child = parent->firstChild(); - while (child && !(*epixbuf) && (*hatchType == -1)) { - brush_classify(child, depth, epixbuf, hatchType, hatchColor, bkColor); - child = child->getNext(); + for (auto& child: parent->children) { + if (*epixbuf || *hatchType != -1) { + break; + } + brush_classify(&child, depth, epixbuf, hatchType, hatchColor, bkColor); } } } diff --git a/src/extension/internal/odf.cpp b/src/extension/internal/odf.cpp index 6904eb2fd..f885ef5e5 100644 --- a/src/extension/internal/odf.cpp +++ b/src/extension/internal/odf.cpp @@ -873,11 +873,8 @@ int SingularValueDecomposition::rank() -#define pi 3.14159 //#define pxToCm 0.0275 #define pxToCm 0.03 -#define piToRad 0.0174532925 -#define docHeightCm 22.86 //######################################################################## @@ -1565,7 +1562,7 @@ bool OdfOutput::processGradient(SPItem *item, output += buf; //TODO: apply maths, to define begin of gradient, taking gradient begin and end, as well as object boundary into account double angle = (gi.y2-gi.y1); - angle = (angle != 0.) ? (atan((gi.x2-gi.x1)/(gi.y2-gi.y1))* 180. / pi) : 90; + angle = (angle != 0.) ? (atan((gi.x2-gi.x1)/(gi.y2-gi.y1))* 180. / M_PI) : 90; angle = (angle < 0)?(180+angle):angle; angle = angle * 10; //why do we need this: precision????????????? output += Glib::ustring::compose(" draw:start-intensity=\"%1\" draw:end-intensity=\"%2\" draw:angle=\"%3\"/>\n", diff --git a/src/extension/internal/pdfinput/pdf-input.cpp b/src/extension/internal/pdfinput/pdf-input.cpp index c1940b16a..0c22fa399 100644 --- a/src/extension/internal/pdfinput/pdf-input.cpp +++ b/src/extension/internal/pdfinput/pdf-input.cpp @@ -39,10 +39,8 @@ #include <gtkmm/radiobutton.h> #include <gtkmm/scale.h> -#if WITH_GTKMM_3_0 #include <glibmm/convert.h> #include <glibmm/miscutils.h> -#endif #include "extension/system.h" #include "extension/input.h" @@ -92,14 +90,8 @@ PdfImportDialog::PdfImportDialog(PDFDoc *doc, const gchar */*uri*/) _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, _pdf_doc->getNumPages(), 1, 10, 0); + auto _pageNumberSpin_adj = Gtk::Adjustment::create(1, 1, _pdf_doc->getNumPages(), 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, _pdf_doc->getNumPages(), 1, 10, 0)); - _pageNumberSpin = Gtk::manage(new class Inkscape::UI::Widget::SpinButton(*_pageNumberSpin_adj, 1, 1)); -#endif _labelTotalPages = Gtk::manage(new class Gtk::Label()); hbox2 = Gtk::manage(new class Gtk::HBox(false, 0)); // Disable the page selector when there's only one page @@ -137,13 +129,8 @@ PdfImportDialog::PdfImportDialog(PDFDoc *doc, const gchar */*uri*/) _labelViaInternal = Gtk::manage(new class Gtk::Label(_("Import via internal (Poppler derived) library. Text is stored as text but white space is missing. Meshes are converted to tiles, the number depends on the precision set below."))); #endif -#if WITH_GTKMM_3_0 _fallbackPrecisionSlider_adj = Gtk::Adjustment::create(2, 1, 256, 1, 10, 10); _fallbackPrecisionSlider = Gtk::manage(new class Gtk::Scale(_fallbackPrecisionSlider_adj)); -#else - _fallbackPrecisionSlider_adj = Gtk::manage(new class Gtk::Adjustment(2, 1, 256, 1, 10, 10)); - _fallbackPrecisionSlider = Gtk::manage(new class Gtk::HScale(*_fallbackPrecisionSlider_adj)); -#endif _fallbackPrecisionSlider->set_value(2.0); _labelPrecisionComment = Gtk::manage(new class Gtk::Label(_("rough"))); hbox6 = Gtk::manage(new class Gtk::HBox(false, 4)); @@ -278,15 +265,9 @@ PdfImportDialog::PdfImportDialog(PDFDoc *doc, const gchar */*uri*/) hbox1->pack_start(*vbox1); hbox1->pack_start(*_previewArea, Gtk::PACK_EXPAND_WIDGET, 4); -#if WITH_GTKMM_3_0 get_content_area()->set_homogeneous(false); get_content_area()->set_spacing(0); get_content_area()->pack_start(*hbox1); -#else - this->get_vbox()->set_homogeneous(false); - this->get_vbox()->set_spacing(0); - this->get_vbox()->pack_start(*hbox1); -#endif this->set_title(_("PDF Import Settings")); this->set_modal(true); @@ -300,12 +281,7 @@ PdfImportDialog::PdfImportDialog(PDFDoc *doc, const gchar */*uri*/) this->show_all(); // Connect signals -#if WITH_GTKMM_3_0 _previewArea->signal_draw().connect(sigc::mem_fun(*this, &PdfImportDialog::_onDraw)); -#else - _previewArea->signal_expose_event().connect(sigc::mem_fun(*this, &PdfImportDialog::_onExposePreview)); -#endif - _pageNumberSpin_adj->signal_value_changed().connect(sigc::mem_fun(*this, &PdfImportDialog::_onPageNumberChanged)); _cropCheck->signal_toggled().connect(sigc::mem_fun(*this, &PdfImportDialog::_onToggleCropping)); _fallbackPrecisionSlider_adj->signal_value_changed().connect(sigc::mem_fun(*this, &PdfImportDialog::_onPrecisionChanged)); @@ -527,16 +503,6 @@ static void copy_cairo_surface_to_pixbuf (cairo_surface_t *surface, #endif -/** - * \brief Updates the preview area with the previously rendered thumbnail - */ -#if !WITH_GTKMM_3_0 -bool PdfImportDialog::_onExposePreview(GdkEventExpose * /*event*/) { - Cairo::RefPtr<Cairo::Context> cr = _previewArea->get_window()->create_cairo_context(); - return _onDraw(cr); -} -#endif - bool PdfImportDialog::_onDraw(const Cairo::RefPtr<Cairo::Context>& cr) { // Check if we have a thumbnail at all if (!_thumb_data) { diff --git a/src/extension/internal/pdfinput/pdf-input.h b/src/extension/internal/pdfinput/pdf-input.h index 6e36603c3..c338207c1 100644 --- a/src/extension/internal/pdfinput/pdf-input.h +++ b/src/extension/internal/pdfinput/pdf-input.h @@ -39,11 +39,7 @@ namespace Gtk { class DrawingArea; class Frame; class HBox; -#if WITH_GTKMM_3_0 class Scale; -#else - class HScale; -#endif class RadioButton; class VBox; class Label; @@ -79,10 +75,6 @@ private: void _setPreviewPage(int page); // Signal handlers -#if !WITH_GTKMM_3_0 - bool _onExposePreview(GdkEventExpose *event); -#endif - bool _onDraw(const Cairo::RefPtr<Cairo::Context>& cr); void _onPageNumberChanged(); void _onToggleCropping(); @@ -110,13 +102,8 @@ private: class Gtk::RadioButton * _importViaInternal; // Use native (poppler based) importing class Gtk::Label * _labelViaInternal; #endif -#if WITH_GTKMM_3_0 - class Gtk::Scale * _fallbackPrecisionSlider; + Gtk::Scale * _fallbackPrecisionSlider; Glib::RefPtr<Gtk::Adjustment> _fallbackPrecisionSlider_adj; -#else - class Gtk::HScale * _fallbackPrecisionSlider; - class Gtk::Adjustment *_fallbackPrecisionSlider_adj; -#endif class Gtk::Label * _labelPrecisionComment; class Gtk::HBox * hbox6; class Gtk::Label * _labelText; diff --git a/src/extension/internal/pov-out.cpp b/src/extension/internal/pov-out.cpp index bd2168b68..8df883069 100644 --- a/src/extension/internal/pov-out.cpp +++ b/src/extension/internal/pov-out.cpp @@ -479,9 +479,9 @@ bool PovOutput::doTreeRecursive(SPDocument *doc, SPObject *obj) /** * Descend into children */ - for (SPObject *child = obj->firstChild() ; child ; child = child->next) + for (auto &child: obj->children) { - if (!doTreeRecursive(doc, child)) + if (!doTreeRecursive(doc, &child)) return false; } diff --git a/src/extension/internal/svg.cpp b/src/extension/internal/svg.cpp index a94bc2141..9cde90519 100644 --- a/src/extension/internal/svg.cpp +++ b/src/extension/internal/svg.cpp @@ -78,6 +78,28 @@ static void pruneExtendedNamespaces( Inkscape::XML::Node *repr ) } } +/* + * Similar to the above sodipodi and inkscape prune, but used on all documents + * to remove problematic elements (for example Adobe's i:pgf tag) only removes + * known garbage tags. + */ +static void pruneProprietaryGarbage( Inkscape::XML::Node *repr ) +{ + if (repr) { + std::vector<Inkscape::XML::Node *> nodesRemoved; + for ( Node *child = repr->firstChild(); child; child = child->next() ) { + if((strncmp("i:pgf", child->name(), 5) == 0)) { + nodesRemoved.push_back(child); + g_warning( "An Adobe proprietary tag was found which is known to cause issues. It was removed before saving."); + } else { + pruneProprietaryGarbage(child); + } + } + for ( std::vector<Inkscape::XML::Node *>::iterator it = nodesRemoved.begin(); it != nodesRemoved.end(); ++it ) { + repr->removeChild(*it); + } + } +} /** \return None @@ -246,6 +268,10 @@ Svg::save(Inkscape::Extension::Output *mod, SPDocument *doc, gchar const *filena || !strcmp (mod->get_id(), SP_MODULE_KEY_OUTPUT_SVG_INKSCAPE) || !strcmp (mod->get_id(), SP_MODULE_KEY_OUTPUT_SVGZ_INKSCAPE)); + // We prune the in-use document and deliberately loose data, because there + // is no known use for this data at the present time. + pruneProprietaryGarbage(rdoc->root()); + if (!exportExtensions) { // We make a duplicate document so we don't prune the in-use document // and loose data. Perhaps the user intends to save as inkscape-svg next. diff --git a/src/extension/internal/vsd-input.cpp b/src/extension/internal/vsd-input.cpp index a3d4aad37..2de2d0ec6 100644 --- a/src/extension/internal/vsd-input.cpp +++ b/src/extension/internal/vsd-input.cpp @@ -113,12 +113,7 @@ VsdImportDialog::VsdImportDialog(const std::vector<RVNGString> &vec) _previewArea = Gtk::manage(new class Gtk::VBox()); vbox1 = Gtk::manage(new class Gtk::VBox()); vbox1->pack_start(*_previewArea, Gtk::PACK_EXPAND_WIDGET, 0); -#if WITH_GTKMM_3_0 this->get_content_area()->pack_start(*vbox1); -#else - this->get_vbox()->pack_start(*vbox1); -#endif - // CONTROLS @@ -140,13 +135,8 @@ VsdImportDialog::VsdImportDialog(const std::vector<RVNGString> &vec) g_free(label_text); // Adjustment + spinner -#if WITH_GTKMM_3_0 - Glib::RefPtr<Gtk::Adjustment> _pageNumberSpin_adj = Gtk::Adjustment::create(1, 1, _vec.size(), 1, 10, 0); + auto _pageNumberSpin_adj = Gtk::Adjustment::create(1, 1, _vec.size(), 1, 10, 0); _pageNumberSpin = Gtk::manage(new Gtk::SpinButton(_pageNumberSpin_adj, 1, 0)); -#else - Gtk::Adjustment *_pageNumberSpin_adj = Gtk::manage(new class Gtk::Adjustment(1, 1, _vec.size(), 1, 10, 0)); - _pageNumberSpin = Gtk::manage(new Gtk::SpinButton(*_pageNumberSpin_adj, 1, 0)); -#endif _pageNumberSpin->set_can_focus(); _pageNumberSpin->set_update_policy(Gtk::UPDATE_ALWAYS); _pageNumberSpin->set_numeric(true); diff --git a/src/extension/loader.cpp b/src/extension/loader.cpp index 863a176ca..164a5cecf 100644 --- a/src/extension/loader.cpp +++ b/src/extension/loader.cpp @@ -10,8 +10,10 @@ */ #include "loader.h" + +#include <gmodule.h> + #include "system.h" -#include <exception> #include <string.h> #include "dependency.h" #include "inkscape-version.h" diff --git a/src/extension/loader.h b/src/extension/loader.h index 0d3a69061..0eecc02b9 100644 --- a/src/extension/loader.h +++ b/src/extension/loader.h @@ -14,8 +14,6 @@ #define INKSCAPE_EXTENSION_LOADER_H_ #include "extension.h" -#include "implementation/implementation.h" -#include <gmodule.h> namespace Inkscape { diff --git a/src/extension/param/bool.cpp b/src/extension/param/bool.cpp index d64f798ba..ca61d8c51 100644 --- a/src/extension/param/bool.cpp +++ b/src/extension/param/bool.cpp @@ -14,6 +14,7 @@ #include <gtkmm/box.h> #include <gtkmm/spinbutton.h> #include <gtkmm/checkbutton.h> +#include <glib/gi18n.h> #include "xml/node.h" #include "../extension.h" @@ -129,14 +130,10 @@ Gtk::Widget *ParamBool::get_widget(SPDocument * doc, Inkscape::XML::Node * node, return NULL; } -#if WITH_GTKMM_3_0 - Gtk::Box * hbox = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL, 4)); + auto hbox = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL, 4)); hbox->set_homogeneous(false); -#else - Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox(false, 4)); -#endif - Gtk::Label * label = Gtk::manage(new Gtk::Label(_text, Gtk::ALIGN_START)); + Gtk::Label * label = Gtk::manage(new Gtk::Label(_(_text), Gtk::ALIGN_START)); label->show(); hbox->pack_end(*label, true, true); diff --git a/src/extension/param/enum.cpp b/src/extension/param/enum.cpp index 4e7420807..8bc0fbda7 100644 --- a/src/extension/param/enum.cpp +++ b/src/extension/param/enum.cpp @@ -251,7 +251,7 @@ Gtk::Widget *ParamComboBox::get_widget(SPDocument * doc, Inkscape::XML::Node * n } Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox(false, 4)); - Gtk::Label * label = Gtk::manage(new Gtk::Label(_text, Gtk::ALIGN_START)); + Gtk::Label * label = Gtk::manage(new Gtk::Label(_(_text), Gtk::ALIGN_START)); label->show(); hbox->pack_start(*label, false, false, _indent); diff --git a/src/extension/param/float.cpp b/src/extension/param/float.cpp index dff7cbf46..23a03ea8f 100644 --- a/src/extension/param/float.cpp +++ b/src/extension/param/float.cpp @@ -15,6 +15,7 @@ #include <gtkmm/scale.h> #include "ui/widget/spinbutton.h" #include "ui/widget/spin-scale.h" +#include <glib/gi18n.h> #include "xml/node.h" #include "extension/extension.h" @@ -176,16 +177,12 @@ Gtk::Widget * ParamFloat::get_widget(SPDocument * doc, Inkscape::XML::Node * nod Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox(false, 4)); -#if WITH_GTKMM_3_0 - ParamFloatAdjustment * pfa = new ParamFloatAdjustment(this, doc, node, changeSignal); + auto pfa = new ParamFloatAdjustment(this, doc, node, changeSignal); Glib::RefPtr<Gtk::Adjustment> fadjust(pfa); -#else - ParamFloatAdjustment * fadjust = Gtk::manage(new ParamFloatAdjustment(this, doc, node, changeSignal)); -#endif if (_mode == FULL) { - UI::Widget::SpinScale *scale = new UI::Widget::SpinScale(_text, fadjust, _precision); + 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); @@ -193,15 +190,11 @@ Gtk::Widget * ParamFloat::get_widget(SPDocument * doc, Inkscape::XML::Node * nod } else if (_mode == MINIMAL) { - Gtk::Label * label = Gtk::manage(new Gtk::Label(_text, Gtk::ALIGN_START)); + 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 + auto spin = Gtk::manage(new Inkscape::UI::Widget::SpinButton(fadjust, 0.1, _precision)); spin->show(); hbox->pack_start(*spin, false, false); } diff --git a/src/extension/param/int.cpp b/src/extension/param/int.cpp index dda801282..222d4f243 100644 --- a/src/extension/param/int.cpp +++ b/src/extension/param/int.cpp @@ -15,6 +15,7 @@ #include <gtkmm/scale.h> #include "ui/widget/spinbutton.h" #include "ui/widget/spin-scale.h" +#include <glib/gi18n.h> #include "xml/node.h" #include "extension/extension.h" @@ -157,32 +158,23 @@ ParamInt::get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc::signal Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox(false, 4)); - -#if WITH_GTKMM_3_0 - ParamIntAdjustment * pia = new ParamIntAdjustment(this, doc, node, changeSignal); + auto pia = new ParamIntAdjustment(this, doc, node, changeSignal); Glib::RefPtr<Gtk::Adjustment> fadjust(pia); -#else - ParamIntAdjustment * fadjust = Gtk::manage(new ParamIntAdjustment(this, doc, node, changeSignal)); -#endif if (_mode == FULL) { - UI::Widget::SpinScale *scale = new UI::Widget::SpinScale(_text, fadjust, 0); + 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)); + 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 + auto spin = Gtk::manage(new Inkscape::UI::Widget::SpinButton(fadjust, 1.0, 0)); spin->show(); hbox->pack_start(*spin, false, false); } diff --git a/src/extension/param/notebook.cpp b/src/extension/param/notebook.cpp index 20c8e8481..957d12d06 100644 --- a/src/extension/param/notebook.cpp +++ b/src/extension/param/notebook.cpp @@ -353,11 +353,7 @@ public: // hook function this->signal_switch_page().connect(sigc::mem_fun(this, &ParamNotebookWdg::changed_page)); }; -#if WITH_GTKMM_3_0 void changed_page(Gtk::Widget *page, guint pagenum); -#else - void changed_page(GtkNotebookPage *page, guint pagenum); -#endif bool activated; }; @@ -368,11 +364,7 @@ public: * is actually visible. This to exclude 'fake' changes when the * notebookpages are added or removed. */ -#if WITH_GTKMM_3_0 void ParamNotebookWdg::changed_page(Gtk::Widget * /*page*/, guint pagenum) -#else -void ParamNotebookWdg::changed_page(GtkNotebookPage * /*page*/, guint pagenum) -#endif { if (get_visible()) { _pref->set((int)pagenum, _doc, _node); diff --git a/src/extension/param/parameter.cpp b/src/extension/param/parameter.cpp index e4a614667..a5632a39a 100644 --- a/src/extension/param/parameter.cpp +++ b/src/extension/param/parameter.cpp @@ -58,16 +58,6 @@ Parameter *Parameter::make(Inkscape::XML::Node *in_repr, Inkscape::Extension::Ex const char *guitext = in_repr->attribute("gui-text"); if (guitext == NULL) { guitext = in_repr->attribute("_gui-text"); - if (guitext == NULL) { - // guitext = ""; // propably better to require devs to explicitly set an empty gui-text if this is what they want - } else { - const char *context = in_repr->attribute("msgctxt"); - if (context != NULL) { - guitext = g_dpgettext2(NULL, context, guitext); - } else { - guitext = _(guitext); - } - } } const char *gui_tip = in_repr->attribute("gui-tip"); if (gui_tip == NULL) { diff --git a/src/extension/param/radiobutton.cpp b/src/extension/param/radiobutton.cpp index 1d1b860c6..c54cc0ec3 100644 --- a/src/extension/param/radiobutton.cpp +++ b/src/extension/param/radiobutton.cpp @@ -303,17 +303,12 @@ Gtk::Widget * ParamRadioButton::get_widget(SPDocument * doc, Inkscape::XML::Node return NULL; } -#if WITH_GTKMM_3_0 - Gtk::Box * hbox = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL, 4)); + auto hbox = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL, 4)); hbox->set_homogeneous(false); - Gtk::Box * vbox = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_VERTICAL, 0)); + auto vbox = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_VERTICAL, 0)); vbox->set_homogeneous(false); -#else - Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox(false, 4)); - Gtk::VBox * vbox = Gtk::manage(new Gtk::VBox(false, 0)); -#endif - Gtk::Label * label = Gtk::manage(new Gtk::Label(_text, Gtk::ALIGN_START, Gtk::ALIGN_START)); + Gtk::Label * label = Gtk::manage(new Gtk::Label(_(_text), Gtk::ALIGN_START, Gtk::ALIGN_START)); label->show(); hbox->pack_start(*label, false, false, _indent); diff --git a/src/extension/param/string.cpp b/src/extension/param/string.cpp index 6b082b133..1d9205502 100644 --- a/src/extension/param/string.cpp +++ b/src/extension/param/string.cpp @@ -166,7 +166,7 @@ Gtk::Widget * ParamString::get_widget(SPDocument * doc, Inkscape::XML::Node * no } Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox(false, 4)); - Gtk::Label * label = Gtk::manage(new Gtk::Label(_text, Gtk::ALIGN_START)); + Gtk::Label * label = Gtk::manage(new Gtk::Label(_(_text), Gtk::ALIGN_START)); label->show(); hbox->pack_start(*label, false, false, _indent); diff --git a/src/extension/patheffect.cpp b/src/extension/patheffect.cpp index bedab7fd8..e30ec97df 100644 --- a/src/extension/patheffect.cpp +++ b/src/extension/patheffect.cpp @@ -8,7 +8,6 @@ */ #include "document-private.h" -#include "sp-object.h" #include "patheffect.h" #include "db.h" diff --git a/src/extension/plugins/grid2/grid.cpp b/src/extension/plugins/grid2/grid.cpp index 6880c574d..233d4e522 100644 --- a/src/extension/plugins/grid2/grid.cpp +++ b/src/extension/plugins/grid2/grid.cpp @@ -186,10 +186,10 @@ Grid::prefs_effect(Inkscape::Extension::Effect *module, Inkscape::UI::View::View { SPDocument * current_document = view->doc(); - std::vector<SPItem*> selected = ((SPDesktop *)view)->getSelection()->itemList(); + auto selected = ((SPDesktop *) view)->getSelection()->items(); Inkscape::XML::Node * first_select = NULL; if (!selected.empty()) { - first_select = selected[0]->getRepr(); + first_select = selected.front()->getRepr(); } return module->autogui(current_document, first_select, changeSignal); diff --git a/src/extension/prefdialog.cpp b/src/extension/prefdialog.cpp index 2521dc1de..1ca590e85 100644 --- a/src/extension/prefdialog.cpp +++ b/src/extension/prefdialog.cpp @@ -41,11 +41,7 @@ namespace Extension { 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 Gtk::Dialog(_(name.c_str()), true), -#else - Gtk::Dialog(_(name.c_str()), true, true), -#endif _help(help), _name(name), _button_ok(NULL), @@ -68,11 +64,7 @@ PrefDialog::PrefDialog (Glib::ustring name, gchar const * help, Gtk::Widget * co hbox->pack_start(*controls, true, true, 6); hbox->show(); -#if WITH_GTKMM_3_0 this->get_content_area()->pack_start(*hbox, true, true, 6); -#else - this->get_vbox()->pack_start(*hbox, true, true, 6); -#endif /* Gtk::Button * help_button = add_button(Gtk::Stock::HELP, Gtk::RESPONSE_HELP); @@ -97,19 +89,10 @@ PrefDialog::PrefDialog (Glib::ustring name, gchar const * help, Gtk::Widget * co _param_preview = Parameter::make(doc->root(), _effect); } -#if WITH_GTKMM_3_0 - Gtk::Separator * sep = Gtk::manage(new Gtk::Separator()); -#else - Gtk::HSeparator * sep = Gtk::manage(new Gtk::HSeparator()); -#endif - + auto sep = Gtk::manage(new Gtk::Separator()); sep->show(); -#if WITH_GTKMM_3_0 this->get_content_area()->pack_start(*sep, true, true, 4); -#else - this->get_vbox()->pack_start(*sep, true, true, 4); -#endif hbox = Gtk::manage(new Gtk::HBox()); _button_preview = _param_preview->get_widget(NULL, NULL, &_signal_preview); @@ -117,19 +100,11 @@ PrefDialog::PrefDialog (Glib::ustring name, gchar const * help, Gtk::Widget * co hbox->pack_start(*_button_preview, true, true,6); hbox->show(); -#if WITH_GTKMM_3_0 this->get_content_area()->pack_start(*hbox, true, true, 6); -#else - this->get_vbox()->pack_start(*hbox, true, true, 6); -#endif Gtk::Box * hbox = dynamic_cast<Gtk::Box *>(_button_preview); if (hbox != NULL) { -#if WITH_GTKMM_3_0 _checkbox_preview = dynamic_cast<Gtk::CheckButton *>(hbox->get_children().front()); -#else - _checkbox_preview = dynamic_cast<Gtk::CheckButton *>(hbox->children().back().get_widget()); -#endif } preview_toggle(); diff --git a/src/extension/system.cpp b/src/extension/system.cpp index 3c623455a..afa8346df 100644 --- a/src/extension/system.cpp +++ b/src/extension/system.cpp @@ -17,12 +17,10 @@ */ #ifdef HAVE_CONFIG_H -# include <config.h> +#include <config.h> #endif #include "ui/interface.h" -#include <unistd.h> -#include <glibmm/miscutils.h> #include "system.h" #include "preferences.h" @@ -41,6 +39,7 @@ #include "document-undo.h" #include "loader.h" +#include <glibmm/miscutils.h> namespace Inkscape { namespace Extension { diff --git a/src/extract-uri-test.h b/src/extract-uri-test.h deleted file mode 100644 index e795960a9..000000000 --- a/src/extract-uri-test.h +++ /dev/null @@ -1,88 +0,0 @@ - -#ifndef SEEN_EXTRACT_URI_TEST_H -#define SEEN_EXTRACT_URI_TEST_H - -#include <cxxtest/TestSuite.h> - -#include "extract-uri.h" - -class ExtractURITest : public CxxTest::TestSuite -{ -public: - void checkOne( char const* str, char const* expected ) - { - gchar* result = extract_uri( str ); - TS_ASSERT_EQUALS( ( result == NULL ), ( expected == NULL ) ); - if ( result && expected ) { - TS_ASSERT_EQUALS( std::string(result), std::string(expected) ); - } else if ( result ) { - TS_FAIL( std::string("Expected null, found (") + result + ")" ); - } else if ( expected ) { - TS_FAIL( std::string("Expected (") + expected + "), found null" ); - } - g_free( result ); - } - - void testBase() - { - char const* cases[][2] = { - { "url(#foo)", "#foo" }, - { "url foo ", NULL }, - { "url", NULL }, - { "url ", NULL }, - { "url()", NULL }, - { "url ( ) ", NULL }, - { "url foo bar ", NULL }, - }; - - for ( size_t i = 0; i < G_N_ELEMENTS(cases); i++ ) - { - checkOne( cases[i][0], cases[i][1] ); - } - } - - void testWithTrailing() - { - char const* cases[][2] = { - { "url(#foo) bar", "#foo" }, - { "url() bar", NULL }, - { "url ( ) bar ", NULL } - }; - - for ( size_t i = 0; i < G_N_ELEMENTS(cases); i++ ) - { - checkOne( cases[i][0], cases[i][1] ); - } - } - - void testQuoted() - { - char const* cases[][2] = { - { "url('#foo')", "#foo" }, - { "url(\"#foo\")", "#foo" }, - { "url('#f o o')", "#f o o" }, - { "url(\"#f o o\")", "#f o o" }, - { "url('#fo\"o')", "#fo\"o" }, - { "url(\"#fo'o\")", "#fo'o" }, - }; - - for ( size_t i = 0; i < G_N_ELEMENTS(cases); i++ ) - { - checkOne( cases[i][0], cases[i][1] ); - } - } - -}; - -#endif // SEEN_EXTRACT_URI_TEST_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/file.cpp b/src/file.cpp index 650ce5d0f..7c17a6158 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -33,14 +33,12 @@ #include "ui/dialog/ocaldialogs.h" #include "desktop.h" -#include "dir-util.h" #include "document-private.h" #include "document-undo.h" #include "ui/tools/tool-base.h" #include "extension/db.h" #include "extension/input.h" #include "extension/output.h" -#include "extension/system.h" #include "file.h" #include "helper/png-write.h" #include "id-clash.h" @@ -48,33 +46,24 @@ #include "inkscape-version.h" #include "ui/interface.h" #include "io/sys.h" -#include "message.h" #include "message-stack.h" #include "path-prefix.h" -#include "preferences.h" #include "print.h" #include "resource-manager.h" #include "rdf.h" #include "selection-chemistry.h" -#include "selection.h" #include "sp-namedview.h" #include "style.h" #include "ui/view/view-widget.h" -#include "uri.h" #include "xml/rebase-hrefs.h" #include "xml/sp-css-attr.h" #include "verbs.h" #include "event-log.h" #include "ui/dialog/font-substitution.h" -#include <gtk/gtk.h> #include <gtkmm/main.h> - -#include <glibmm/convert.h> -#include <glibmm/i18n.h> #include <glibmm/miscutils.h> - -#include <string> +#include <glibmm/convert.h> using Inkscape::DocumentUndo; @@ -1129,14 +1118,14 @@ void sp_import_document(SPDesktop *desktop, SPDocument *clipdoc, bool in_place) Inkscape::Selection *selection = desktop->getSelection(); selection->setReprList(pasted_objects_not); Geom::Affine doc2parent = SP_ITEM(desktop->currentLayer())->i2doc_affine().inverse(); - sp_selection_apply_affine(selection, desktop->dt2doc() * doc2parent * desktop->doc2dt(), true, false, false); + sp_object_set_apply_affine(selection, desktop->dt2doc() * doc2parent * desktop->doc2dt(), true, false, false); sp_selection_delete(desktop); // Change the selection to the freshly pasted objects selection->setReprList(pasted_objects); // Apply inverse of parent transform - sp_selection_apply_affine(selection, desktop->dt2doc() * doc2parent * desktop->doc2dt(), true, false, false); + sp_object_set_apply_affine(selection, desktop->dt2doc() * doc2parent * desktop->doc2dt(), true, false, false); // Update (among other things) all curves in paths, for bounds() to work target_document->ensureUpToDate(); @@ -1166,7 +1155,7 @@ void sp_import_document(SPDesktop *desktop, SPDocument *clipdoc, bool in_place) m.unSetup(); } - sp_selection_move_relative(selection, offset); + sp_object_set_move_relative(selection, offset); } } @@ -1204,8 +1193,8 @@ file_import(SPDocument *in_doc, const Glib::ustring &uri, // Count the number of top-level items in the imported document. guint items_count = 0; - for ( SPObject *child = doc->getRoot()->firstChild(); child; child = child->getNext()) { - if (SP_IS_ITEM(child)) { + for (auto& child: doc->getRoot()->children) { + if (SP_IS_ITEM(&child)) { items_count++; } } @@ -1234,9 +1223,9 @@ file_import(SPDocument *in_doc, const Glib::ustring &uri, // Construct a new object representing the imported image, // and insert it into the current document. SPObject *new_obj = NULL; - for ( SPObject *child = doc->getRoot()->firstChild(); child; child = child->getNext() ) { - if (SP_IS_ITEM(child)) { - Inkscape::XML::Node *newitem = child->getRepr()->duplicate(xml_in_doc); + for (auto& child: doc->getRoot()->children) { + if (SP_IS_ITEM(&child)) { + Inkscape::XML::Node *newitem = child.getRepr()->duplicate(xml_in_doc); // convert layers to groups, and make sure they are unlocked // FIXME: add "preserve layers" mode where each layer from @@ -1249,10 +1238,10 @@ file_import(SPDocument *in_doc, const Glib::ustring &uri, } // don't lose top-level defs or style elements - else if (child->getRepr()->type() == Inkscape::XML::ELEMENT_NODE) { - const gchar *tag = child->getRepr()->name(); + else if (child.getRepr()->type() == Inkscape::XML::ELEMENT_NODE) { + const gchar *tag = child.getRepr()->name(); if (!strcmp(tag, "svg:style")) { - in_doc->getRoot()->appendChildRepr(child->getRepr()->duplicate(xml_in_doc)); + in_doc->getRoot()->appendChildRepr(child.getRepr()->duplicate(xml_in_doc)); } } } @@ -1271,7 +1260,7 @@ file_import(SPDocument *in_doc, const Glib::ustring &uri, // c2p is identity matrix at this point unless ensureUpToDate is called doc->ensureUpToDate(); Geom::Affine affine = doc->getRoot()->c2p * SP_ITEM(place_to_insert)->i2doc_affine().inverse(); - sp_selection_apply_affine(selection, desktop->dt2doc() * affine * desktop->doc2dt(), true, false, false); + sp_object_set_apply_affine(selection, desktop->dt2doc() * affine * desktop->doc2dt(), true, false, false); // move to mouse pointer { @@ -1279,7 +1268,7 @@ file_import(SPDocument *in_doc, const Glib::ustring &uri, Geom::OptRect sel_bbox = selection->visualBounds(); if (sel_bbox) { Geom::Point m( desktop->point() - sel_bbox->midpoint() ); - sp_selection_move_relative(selection, m, false); + sp_object_set_move_relative(selection, m, false); } } } diff --git a/src/filter-chemistry.cpp b/src/filter-chemistry.cpp index 9298a1ffc..560e73322 100644 --- a/src/filter-chemistry.cpp +++ b/src/filter-chemistry.cpp @@ -26,11 +26,6 @@ #include "filters/blend.h" #include "filters/gaussian-blur.h" -#include "sp-filter.h" -#include "sp-filter-reference.h" -#include "svg/css-ostringstream.h" - -#include "xml/repr.h" /** * Count how many times the filter is used by the styles of o and its @@ -51,8 +46,8 @@ static guint count_filter_hrefs(SPObject *o, SPFilter *filter) i ++; } - for ( SPObject *child = o->firstChild(); child; child = child->getNext() ) { - i += count_filter_hrefs(child, filter); + for (auto& child: o->children) { + i += count_filter_hrefs(&child, filter); } return i; @@ -491,16 +486,14 @@ void remove_filter_gaussian_blur (SPObject *item) bool filter_is_single_gaussian_blur(SPFilter *filter) { - return (filter->firstChild() && - (filter->firstChild() == filter->lastChild()) && - SP_IS_GAUSSIANBLUR(filter->firstChild())); + return (filter->children.size() == 1 && + SP_IS_GAUSSIANBLUR(&filter->children.front())); } double get_single_gaussian_blur_radius(SPFilter *filter) { - if (filter->firstChild() && - (filter->firstChild() == filter->lastChild()) && - SP_IS_GAUSSIANBLUR(filter->firstChild())) { + if (filter->children.size() == 1 && + SP_IS_GAUSSIANBLUR(&filter->children.front())) { SPGaussianBlur *gb = SP_GAUSSIANBLUR(filter->firstChild()); double x = gb->stdDeviation.getNumber(); diff --git a/src/filters/Makefile_insert b/src/filters/Makefile_insert deleted file mode 100644 index ea9ff4b56..000000000 --- a/src/filters/Makefile_insert +++ /dev/null @@ -1,46 +0,0 @@ -## Makefile.am fragment sourced by src/Makefile.am. - -ink_common_sources += \ - filters/blend.cpp \ - filters/blend.h \ - filters/colormatrix.cpp \ - filters/colormatrix.h \ - filters/componenttransfer.cpp \ - filters/componenttransfer-funcnode.cpp \ - filters/componenttransfer-funcnode.h \ - filters/componenttransfer.h \ - filters/composite.cpp \ - filters/composite.h \ - filters/convolvematrix.cpp \ - filters/convolvematrix.h \ - filters/diffuselighting.cpp \ - filters/diffuselighting.h \ - filters/displacementmap.cpp \ - filters/displacementmap.h \ - filters/distantlight.cpp \ - filters/distantlight.h \ - filters/flood.cpp \ - filters/flood.h \ - filters/gaussian-blur.cpp \ - filters/gaussian-blur.h \ - filters/image.cpp \ - filters/image.h \ - filters/merge.cpp \ - filters/merge.h \ - filters/mergenode.cpp \ - filters/mergenode.h \ - filters/morphology.cpp \ - filters/morphology.h \ - filters/offset.cpp \ - filters/offset.h \ - filters/pointlight.cpp \ - filters/pointlight.h \ - filters/specularlighting.cpp \ - filters/specularlighting.h \ - filters/spotlight.cpp \ - filters/spotlight.h \ - filters/tile.cpp \ - filters/tile.h \ - filters/turbulence.cpp \ - filters/turbulence.h - diff --git a/src/filters/blend.cpp b/src/filters/blend.cpp index 6e92ef50f..9ef544828 100644 --- a/src/filters/blend.cpp +++ b/src/filters/blend.cpp @@ -18,13 +18,9 @@ #include "sp-filter.h" #include "filters/blend.h" #include "attributes.h" -#include "svg/svg.h" #include "xml/repr.h" #include "display/nr-filter.h" -#include "display/nr-filter-primitive.h" -#include "display/nr-filter-blend.h" -#include "display/nr-filter-types.h" SPFeBlend::SPFeBlend() : SPFilterPrimitive(), blend_mode(Inkscape::Filters::BLEND_NORMAL), @@ -82,7 +78,7 @@ static Inkscape::Filters::FilterBlendMode sp_feBlend_readmode(gchar const *value case 's': if (strncmp(value, "screen", 6) == 0) return Inkscape::Filters::BLEND_SCREEN; - if (strncmp(value, "saturation", 6) == 0) + if (strncmp(value, "saturation", 10) == 0) return Inkscape::Filters::BLEND_SATURATION; break; case 'd': @@ -110,7 +106,7 @@ static Inkscape::Filters::FilterBlendMode sp_feBlend_readmode(gchar const *value return Inkscape::Filters::BLEND_COLOR; break; case 'h': - if (strncmp(value, "hard-light", 7) == 0) + if (strncmp(value, "hard-light", 10) == 0) return Inkscape::Filters::BLEND_HARDLIGHT; if (strncmp(value, "hue", 3) == 0) return Inkscape::Filters::BLEND_HUE; @@ -199,11 +195,11 @@ Inkscape::XML::Node* SPFeBlend::write(Inkscape::XML::Document *doc, Inkscape::XM if( !in2_name ) { // This code is very similar to sp_filter_primtive_name_previous_out() - SPObject *i = parent->children; + SPObject *i = parent->firstChild(); // Find previous filter primitive - while (i && i->next != this) { - i = i->next; + while (i && i->getNext() != this) { + i = i->getNext(); } if( i ) { diff --git a/src/filters/colormatrix.cpp b/src/filters/colormatrix.cpp index a7f0296c2..0e8398ace 100644 --- a/src/filters/colormatrix.cpp +++ b/src/filters/colormatrix.cpp @@ -23,7 +23,6 @@ #include "helper-fns.h" #include "display/nr-filter.h" -#include "display/nr-filter-colormatrix.h" SPFeColorMatrix::SPFeColorMatrix() : SPFilterPrimitive(), type(Inkscape::Filters::COLORMATRIX_MATRIX), value(0) diff --git a/src/filters/componenttransfer-funcnode.cpp b/src/filters/componenttransfer-funcnode.cpp index 76e99a648..23c8dbd96 100644 --- a/src/filters/componenttransfer-funcnode.cpp +++ b/src/filters/componenttransfer-funcnode.cpp @@ -19,12 +19,10 @@ #include "document.h" #include "componenttransfer.h" #include "componenttransfer-funcnode.h" -#include "display/nr-filter-component-transfer.h" #include "xml/repr.h" #include "helper-fns.h" #define SP_MACROS_SILENT -#include "macros.h" /* FeFuncNode class */ diff --git a/src/filters/componenttransfer.cpp b/src/filters/componenttransfer.cpp index 3d0264390..19843eebd 100644 --- a/src/filters/componenttransfer.cpp +++ b/src/filters/componenttransfer.cpp @@ -12,16 +12,12 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include <string.h> - #include "document.h" #include "attributes.h" -#include "svg/svg.h" #include "filters/componenttransfer.h" #include "filters/componenttransfer-funcnode.h" #include "xml/repr.h" #include "display/nr-filter.h" -#include "display/nr-filter-component-transfer.h" SPFeComponentTransfer::SPFeComponentTransfer() : SPFilterPrimitive(), renderer(NULL) @@ -49,11 +45,10 @@ static void sp_feComponentTransfer_children_modified(SPFeComponentTransfer *sp_c { if (sp_componenttransfer->renderer) { bool set[4] = {false, false, false, false}; - SPObject* node = sp_componenttransfer->children; - for(;node;node=node->next){ + for(auto& node: sp_componenttransfer->children) { int i = 4; - SPFeFuncNode *funcNode = SP_FEFUNCNODE(node); + SPFeFuncNode *funcNode = SP_FEFUNCNODE(&node); switch (funcNode->channel) { case SPFeFuncNode::R: @@ -74,13 +69,13 @@ static void sp_feComponentTransfer_children_modified(SPFeComponentTransfer *sp_c g_warning("Unrecognized channel for component transfer."); break; } - sp_componenttransfer->renderer->type[i] = ((SPFeFuncNode *) node)->type; - sp_componenttransfer->renderer->tableValues[i] = ((SPFeFuncNode *) node)->tableValues; - sp_componenttransfer->renderer->slope[i] = ((SPFeFuncNode *) node)->slope; - sp_componenttransfer->renderer->intercept[i] = ((SPFeFuncNode *) node)->intercept; - sp_componenttransfer->renderer->amplitude[i] = ((SPFeFuncNode *) node)->amplitude; - sp_componenttransfer->renderer->exponent[i] = ((SPFeFuncNode *) node)->exponent; - sp_componenttransfer->renderer->offset[i] = ((SPFeFuncNode *) node)->offset; + sp_componenttransfer->renderer->type[i] = ((SPFeFuncNode *) &node)->type; + sp_componenttransfer->renderer->tableValues[i] = ((SPFeFuncNode *) &node)->tableValues; + sp_componenttransfer->renderer->slope[i] = ((SPFeFuncNode *) &node)->slope; + sp_componenttransfer->renderer->intercept[i] = ((SPFeFuncNode *) &node)->intercept; + sp_componenttransfer->renderer->amplitude[i] = ((SPFeFuncNode *) &node)->amplitude; + sp_componenttransfer->renderer->exponent[i] = ((SPFeFuncNode *) &node)->exponent; + sp_componenttransfer->renderer->offset[i] = ((SPFeFuncNode *) &node)->offset; set[i] = true; } // Set any types not explicitly set to the identity transform diff --git a/src/filters/composite.cpp b/src/filters/composite.cpp index 3e651a778..42f06915f 100644 --- a/src/filters/composite.cpp +++ b/src/filters/composite.cpp @@ -221,11 +221,11 @@ Inkscape::XML::Node* SPFeComposite::write(Inkscape::XML::Document *doc, Inkscape if( !in2_name ) { // This code is very similar to sp_filter_primitive_name_previous_out() - SPObject *i = parent->children; + SPObject *i = parent->firstChild(); // Find previous filter primitive - while (i && i->next != this) { - i = i->next; + while (i && i->getNext() != this) { + i = i->getNext(); } if( i ) { diff --git a/src/filters/convolvematrix.cpp b/src/filters/convolvematrix.cpp index 3a443bebc..1b1e58407 100644 --- a/src/filters/convolvematrix.cpp +++ b/src/filters/convolvematrix.cpp @@ -17,12 +17,10 @@ #include <math.h> #include <vector> #include "attributes.h" -#include "svg/svg.h" #include "filters/convolvematrix.h" #include "helper-fns.h" #include "xml/repr.h" #include "display/nr-filter.h" -#include "display/nr-filter-convolve-matrix.h" SPFeConvolveMatrix::SPFeConvolveMatrix() : SPFilterPrimitive() { this->bias = 0; diff --git a/src/filters/diffuselighting.cpp b/src/filters/diffuselighting.cpp index 120c058d2..a46b367ec 100644 --- a/src/filters/diffuselighting.cpp +++ b/src/filters/diffuselighting.cpp @@ -258,17 +258,17 @@ static void sp_feDiffuseLighting_children_modified(SPFeDiffuseLighting *sp_diffu { if (sp_diffuselighting->renderer) { sp_diffuselighting->renderer->light_type = Inkscape::Filters::NO_LIGHT; - if (SP_IS_FEDISTANTLIGHT(sp_diffuselighting->children)) { + if (SP_IS_FEDISTANTLIGHT(sp_diffuselighting->firstChild())) { sp_diffuselighting->renderer->light_type = Inkscape::Filters::DISTANT_LIGHT; - sp_diffuselighting->renderer->light.distant = SP_FEDISTANTLIGHT(sp_diffuselighting->children); + sp_diffuselighting->renderer->light.distant = SP_FEDISTANTLIGHT(sp_diffuselighting->firstChild()); } - if (SP_IS_FEPOINTLIGHT(sp_diffuselighting->children)) { + if (SP_IS_FEPOINTLIGHT(sp_diffuselighting->firstChild())) { sp_diffuselighting->renderer->light_type = Inkscape::Filters::POINT_LIGHT; - sp_diffuselighting->renderer->light.point = SP_FEPOINTLIGHT(sp_diffuselighting->children); + sp_diffuselighting->renderer->light.point = SP_FEPOINTLIGHT(sp_diffuselighting->firstChild()); } - if (SP_IS_FESPOTLIGHT(sp_diffuselighting->children)) { + if (SP_IS_FESPOTLIGHT(sp_diffuselighting->firstChild())) { sp_diffuselighting->renderer->light_type = Inkscape::Filters::SPOT_LIGHT; - sp_diffuselighting->renderer->light.spot = SP_FESPOTLIGHT(sp_diffuselighting->children); + sp_diffuselighting->renderer->light.spot = SP_FESPOTLIGHT(sp_diffuselighting->firstChild()); } } } @@ -293,19 +293,19 @@ void SPFeDiffuseLighting::build_renderer(Inkscape::Filters::Filter* filter) { //We assume there is at most one child nr_diffuselighting->light_type = Inkscape::Filters::NO_LIGHT; - if (SP_IS_FEDISTANTLIGHT(this->children)) { + if (SP_IS_FEDISTANTLIGHT(this->firstChild())) { nr_diffuselighting->light_type = Inkscape::Filters::DISTANT_LIGHT; - nr_diffuselighting->light.distant = SP_FEDISTANTLIGHT(this->children); + nr_diffuselighting->light.distant = SP_FEDISTANTLIGHT(this->firstChild()); } - if (SP_IS_FEPOINTLIGHT(this->children)) { + if (SP_IS_FEPOINTLIGHT(this->firstChild())) { nr_diffuselighting->light_type = Inkscape::Filters::POINT_LIGHT; - nr_diffuselighting->light.point = SP_FEPOINTLIGHT(this->children); + nr_diffuselighting->light.point = SP_FEPOINTLIGHT(this->firstChild()); } - if (SP_IS_FESPOTLIGHT(this->children)) { + if (SP_IS_FESPOTLIGHT(this->firstChild())) { nr_diffuselighting->light_type = Inkscape::Filters::SPOT_LIGHT; - nr_diffuselighting->light.spot = SP_FESPOTLIGHT(this->children); + nr_diffuselighting->light.spot = SP_FESPOTLIGHT(this->firstChild()); } //nr_offset->set_dx(sp_offset->dx); diff --git a/src/filters/displacementmap.cpp b/src/filters/displacementmap.cpp index 1dbea67ff..f0ca36079 100644 --- a/src/filters/displacementmap.cpp +++ b/src/filters/displacementmap.cpp @@ -193,11 +193,11 @@ Inkscape::XML::Node* SPFeDisplacementMap::write(Inkscape::XML::Document *doc, In if( !in2_name ) { // This code is very similar to sp_filter_primtive_name_previous_out() - SPObject *i = parent->children; + SPObject *i = parent->firstChild(); // Find previous filter primitive - while (i && i->next != this) { - i = i->next; + while (i && i->getNext() != this) { + i = i->getNext(); } if( i ) { diff --git a/src/filters/distantlight.cpp b/src/filters/distantlight.cpp index fb7380174..617f53121 100644 --- a/src/filters/distantlight.cpp +++ b/src/filters/distantlight.cpp @@ -23,7 +23,6 @@ #include "xml/repr.h" #define SP_MACROS_SILENT -#include "macros.h" SPFeDistantLight::SPFeDistantLight() diff --git a/src/filters/flood.cpp b/src/filters/flood.cpp index 94ca61b98..cbcaa83eb 100644 --- a/src/filters/flood.cpp +++ b/src/filters/flood.cpp @@ -19,7 +19,6 @@ #include "svg/svg-color.h" #include "filters/flood.h" #include "xml/repr.h" -#include "helper-fns.h" #include "display/nr-filter.h" #include "display/nr-filter-flood.h" diff --git a/src/filters/gaussian-blur.cpp b/src/filters/gaussian-blur.cpp index 43a1f6dfb..814224ab1 100644 --- a/src/filters/gaussian-blur.cpp +++ b/src/filters/gaussian-blur.cpp @@ -14,7 +14,7 @@ */ #ifdef HAVE_CONFIG_H -# include "config.h" +#include <config.h> #endif #include "attributes.h" @@ -23,9 +23,7 @@ #include "xml/repr.h" #include "display/nr-filter.h" -#include "display/nr-filter-primitive.h" #include "display/nr-filter-gaussian.h" -#include "display/nr-filter-types.h" SPGaussianBlur::SPGaussianBlur() : SPFilterPrimitive() { } diff --git a/src/filters/image.cpp b/src/filters/image.cpp index 62e8b76b9..887201eb3 100644 --- a/src/filters/image.cpp +++ b/src/filters/image.cpp @@ -18,12 +18,9 @@ #include "display/nr-filter-image.h" #include "uri.h" #include "uri-references.h" -#include "enums.h" #include "attributes.h" -#include "svg/svg.h" #include "image.h" #include "xml/repr.h" -#include <string.h> #include "display/nr-filter.h" diff --git a/src/filters/merge.cpp b/src/filters/merge.cpp index 68f671b11..8ec40cb46 100644 --- a/src/filters/merge.cpp +++ b/src/filters/merge.cpp @@ -92,17 +92,14 @@ void SPFeMerge::build_renderer(Inkscape::Filters::Filter* filter) { sp_filter_primitive_renderer_common(this, nr_primitive); - SPObject *input = this->children; int in_nr = 0; - while (input) { - if (SP_IS_FEMERGENODE(input)) { - SPFeMergeNode *node = SP_FEMERGENODE(input); + for(auto& input: children) { + if (SP_IS_FEMERGENODE(&input)) { + SPFeMergeNode *node = SP_FEMERGENODE(&input); nr_merge->set_input(in_nr, node->input); in_nr++; } - - input = input->next; } } diff --git a/src/filters/morphology.cpp b/src/filters/morphology.cpp index 326c9b7a6..b3cfa0697 100644 --- a/src/filters/morphology.cpp +++ b/src/filters/morphology.cpp @@ -20,7 +20,6 @@ #include "morphology.h" #include "xml/repr.h" #include "display/nr-filter.h" -#include "display/nr-filter-morphology.h" SPFeMorphology::SPFeMorphology() : SPFilterPrimitive() { this->Operator = Inkscape::Filters::MORPHOLOGY_OPERATOR_ERODE; diff --git a/src/filters/pointlight.cpp b/src/filters/pointlight.cpp index dd3a78f4c..e42d21999 100644 --- a/src/filters/pointlight.cpp +++ b/src/filters/pointlight.cpp @@ -13,17 +13,18 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ +#include "filters/pointlight.h" + #include <glib.h> #include "attributes.h" #include "document.h" -#include "filters/pointlight.h" #include "filters/diffuselighting.h" #include "filters/specularlighting.h" +#include "xml/node.h" #include "xml/repr.h" #define SP_MACROS_SILENT -#include "macros.h" SPFePointLight::SPFePointLight() : SPObject(), x(0), x_set(FALSE), y(0), y_set(FALSE), z(0), z_set(FALSE) { diff --git a/src/filters/pointlight.h b/src/filters/pointlight.h index 1e26d45e7..1d60895c4 100644 --- a/src/filters/pointlight.h +++ b/src/filters/pointlight.h @@ -1,9 +1,9 @@ -#ifndef SP_FEPOINTLIGHT_H_SEEN -#define SP_FEPOINTLIGHT_H_SEEN - /** \file * SVG <filter> implementation, see sp-filter.cpp. */ +#ifndef SP_FEPOINTLIGHT_H_SEEN +#define SP_FEPOINTLIGHT_H_SEEN + /* * Authors: * Hugo Rodrigues <haa.rodrigues@gmail.com> diff --git a/src/filters/specularlighting.cpp b/src/filters/specularlighting.cpp index bda1a0f30..ac7253ad9 100644 --- a/src/filters/specularlighting.cpp +++ b/src/filters/specularlighting.cpp @@ -266,19 +266,19 @@ static void sp_feSpecularLighting_children_modified(SPFeSpecularLighting *sp_spe if (sp_specularlighting->renderer) { sp_specularlighting->renderer->light_type = Inkscape::Filters::NO_LIGHT; - if (SP_IS_FEDISTANTLIGHT(sp_specularlighting->children)) { + if (SP_IS_FEDISTANTLIGHT(sp_specularlighting->firstChild())) { sp_specularlighting->renderer->light_type = Inkscape::Filters::DISTANT_LIGHT; - sp_specularlighting->renderer->light.distant = SP_FEDISTANTLIGHT(sp_specularlighting->children); + sp_specularlighting->renderer->light.distant = SP_FEDISTANTLIGHT(sp_specularlighting->firstChild()); } - if (SP_IS_FEPOINTLIGHT(sp_specularlighting->children)) { + if (SP_IS_FEPOINTLIGHT(sp_specularlighting->firstChild())) { sp_specularlighting->renderer->light_type = Inkscape::Filters::POINT_LIGHT; - sp_specularlighting->renderer->light.point = SP_FEPOINTLIGHT(sp_specularlighting->children); + sp_specularlighting->renderer->light.point = SP_FEPOINTLIGHT(sp_specularlighting->firstChild()); } - if (SP_IS_FESPOTLIGHT(sp_specularlighting->children)) { + if (SP_IS_FESPOTLIGHT(sp_specularlighting->firstChild())) { sp_specularlighting->renderer->light_type = Inkscape::Filters::SPOT_LIGHT; - sp_specularlighting->renderer->light.spot = SP_FESPOTLIGHT(sp_specularlighting->children); + sp_specularlighting->renderer->light.spot = SP_FESPOTLIGHT(sp_specularlighting->firstChild()); } } } @@ -304,19 +304,19 @@ void SPFeSpecularLighting::build_renderer(Inkscape::Filters::Filter* filter) { //We assume there is at most one child nr_specularlighting->light_type = Inkscape::Filters::NO_LIGHT; - if (SP_IS_FEDISTANTLIGHT(this->children)) { + if (SP_IS_FEDISTANTLIGHT(this->firstChild())) { nr_specularlighting->light_type = Inkscape::Filters::DISTANT_LIGHT; - nr_specularlighting->light.distant = SP_FEDISTANTLIGHT(this->children); + nr_specularlighting->light.distant = SP_FEDISTANTLIGHT(this->firstChild()); } - if (SP_IS_FEPOINTLIGHT(this->children)) { + if (SP_IS_FEPOINTLIGHT(this->firstChild())) { nr_specularlighting->light_type = Inkscape::Filters::POINT_LIGHT; - nr_specularlighting->light.point = SP_FEPOINTLIGHT(this->children); + nr_specularlighting->light.point = SP_FEPOINTLIGHT(this->firstChild()); } - if (SP_IS_FESPOTLIGHT(this->children)) { + if (SP_IS_FESPOTLIGHT(this->firstChild())) { nr_specularlighting->light_type = Inkscape::Filters::SPOT_LIGHT; - nr_specularlighting->light.spot = SP_FESPOTLIGHT(this->children); + nr_specularlighting->light.spot = SP_FESPOTLIGHT(this->firstChild()); } //nr_offset->set_dx(sp_offset->dx); diff --git a/src/filters/spotlight.cpp b/src/filters/spotlight.cpp index 2e55d39d0..a1e7207f3 100644 --- a/src/filters/spotlight.cpp +++ b/src/filters/spotlight.cpp @@ -23,7 +23,6 @@ #include "xml/repr.h" #define SP_MACROS_SILENT -#include "macros.h" SPFeSpotLight::SPFeSpotLight() : SPObject(), x(0), x_set(FALSE), y(0), y_set(FALSE), z(0), z_set(FALSE), pointsAtX(0), pointsAtX_set(FALSE), diff --git a/src/filters/turbulence.cpp b/src/filters/turbulence.cpp index 7541175ed..9af51892e 100644 --- a/src/filters/turbulence.cpp +++ b/src/filters/turbulence.cpp @@ -19,10 +19,8 @@ #include "turbulence.h" #include "helper-fns.h" #include "xml/repr.h" -#include <string.h> #include "display/nr-filter.h" -#include "display/nr-filter-turbulence.h" SPFeTurbulence::SPFeTurbulence() : SPFilterPrimitive() { this->stitchTiles = 0; diff --git a/src/gc-anchored.cpp b/src/gc-anchored.cpp index 0350e6bdd..4abd44b57 100644 --- a/src/gc-anchored.cpp +++ b/src/gc-anchored.cpp @@ -14,7 +14,6 @@ #include "debug/event-tracker.h" #include "debug/simple-event.h" #include "debug/demangle.h" -#include "util/share.h" #include "util/format.h" namespace Inkscape { diff --git a/src/gc-finalized.cpp b/src/gc-finalized.cpp index 88685ae52..1deadcb1f 100644 --- a/src/gc-finalized.cpp +++ b/src/gc-finalized.cpp @@ -17,7 +17,6 @@ #include "debug/simple-event.h" #include "debug/event-tracker.h" #include "util/format.h" -#include "util/share.h" #include "gc-finalized.h" namespace Inkscape { diff --git a/src/gradient-chemistry.cpp b/src/gradient-chemistry.cpp index edeb523d7..cf5cda180 100644 --- a/src/gradient-chemistry.cpp +++ b/src/gradient-chemistry.cpp @@ -24,7 +24,6 @@ #include <2geom/bezier-curve.h> #include <2geom/crossing.h> #include <2geom/line.h> -#include <2geom/angle.h> #include "style.h" #include "document-private.h" @@ -38,21 +37,18 @@ #include <glibmm/i18n.h> #include "sp-gradient-reference.h" -#include "sp-gradient-vector.h" #include "sp-linear-gradient.h" #include "sp-radial-gradient.h" -#include "sp-mesh.h" +#include "sp-mesh-gradient.h" #include "sp-stop.h" #include "gradient-drag.h" #include "gradient-chemistry.h" #include "sp-text.h" #include "sp-tspan.h" -#include "xml/repr.h" #include "svg/svg.h" #include "svg/svg-color.h" #include "svg/css-ostringstream.h" -#include "preferences.h" #define noSP_GR_VERBOSE @@ -151,7 +147,7 @@ static SPGradient *sp_gradient_get_private_normalized(SPDocument *document, SPGr repr = xml_doc->createElement("svg:radialGradient"); } else { // Rows/patches added in sp_gradient_reset_to_userspace for new meshes. - repr = xml_doc->createElement("svg:mesh"); + repr = xml_doc->createElement("svg:meshgradient"); } // privates are garbage-collectable @@ -199,8 +195,8 @@ static guint count_gradient_hrefs(SPObject *o, SPGradient *gr) i ++; } - for ( SPObject *child = o->firstChild(); child; child = child->getNext() ) { - i += count_gradient_hrefs(child, gr); + for (auto& child: o->children) { + i += count_gradient_hrefs(&child, gr); } return i; @@ -275,7 +271,7 @@ static SPGradient *sp_gradient_fork_private_if_necessary(SPGradient *gr, SPGradi repr_new->setAttribute("x2", repr->attribute("x2")); repr_new->setAttribute("y2", repr->attribute("y2")); } else { - std::cout << "sp_gradient_fork_private_if_necessary: mesh not implemented" << std::endl; + std::cerr << "sp_gradient_fork_private_if_necessary: mesh not implemented" << std::endl; } return gr_new; @@ -413,7 +409,7 @@ SPGradient *sp_gradient_reset_to_userspace(SPGradient *gr, SPItem *item) // IN SPMeshNodeArray::create() //sp_repr_set_svg_double(repr, "x", bbox->min()[Geom::X]); //sp_repr_set_svg_double(repr, "y", bbox->min()[Geom::Y]); - SPMesh* mg = SP_MESH( gr ); + SPMeshGradient* mg = SP_MESHGRADIENT( gr ); mg->array.create( mg, item, bbox ); } @@ -438,6 +434,11 @@ SPGradient *sp_gradient_convert_to_userspace(SPGradient *gr, SPItem *item, gchar return gr; } + // FIXME Transforming a mesh gradient is more complicated... probably need to add function to SPMeshArray.wq + if ( gr && SP_IS_MESHGRADIENT( gr ) ) { + return gr; + } + // First, fork it if it is shared gr = sp_gradient_fork_private_if_necessary(gr, gr->getVector(), SP_IS_RADIALGRADIENT(gr) ? SP_GRADIENT_TYPE_RADIAL : SP_GRADIENT_TYPE_LINEAR, item); @@ -758,10 +759,10 @@ guint32 sp_item_gradient_stop_query_style(SPItem *item, GrPointType point_type, break; } return 0; - } else if (SP_IS_MESH(gradient)) { + } else if (SP_IS_MESHGRADIENT(gradient)) { // Mesh gradient - SPMesh *mg = SP_MESH(gradient); + SPMeshGradient *mg = SP_MESHGRADIENT(gradient); switch (point_type) { case POINT_MG_CORNER: { @@ -859,12 +860,13 @@ void sp_item_gradient_stop_set_style(SPItem *item, GrPointType point_type, guint } else { // Mesh gradient - SPMesh *mg = SP_MESH(gradient); + SPMeshGradient *mg = SP_MESHGRADIENT(gradient); bool changed = false; switch (point_type) { case POINT_MG_CORNER: { + // Update mesh array (which is not updated automatically when stop is changed?) gchar const* color_str = sp_repr_css_property( stop, "stop-color", NULL ); if( color_str ) { SPColor color( 0 ); @@ -884,9 +886,14 @@ void sp_item_gradient_stop_set_style(SPItem *item, GrPointType point_type, guint mg->array.corners[ point_i ]->opacity = opacity; changed = true; } + // Update stop if( changed ) { - gradient->requestModified(SP_OBJECT_MODIFIED_FLAG); - mg->array.write( mg ); + SPStop *stopi = mg->array.corners[ point_i ]->stop; + if (stopi) { + sp_repr_css_change(stopi->getRepr(), stop, "style"); + } else { + std::cerr << "sp_item_gradient_stop_set_style: null stopi" << std::endl; + } } break; } @@ -926,11 +933,11 @@ void sp_item_gradient_reverse_vector(SPItem *item, Inkscape::PaintTarget fill_or GSList *child_objects = NULL; std::vector<double> offsets; double offset; - for ( SPObject *child = vector->firstChild(); child; child = child->getNext()) { - child_reprs = g_slist_prepend (child_reprs, child->getRepr()); - child_objects = g_slist_prepend (child_objects, child); + for (auto& child: vector->children) { + child_reprs = g_slist_prepend (child_reprs, child.getRepr()); + child_objects = g_slist_prepend (child_objects, &child); offset=0; - sp_repr_get_double(child->getRepr(), "offset", &offset); + sp_repr_get_double(child.getRepr(), "offset", &offset); offsets.push_back(offset); } @@ -979,9 +986,9 @@ void sp_item_gradient_invert_vector_color(SPItem *item, Inkscape::PaintTarget fi 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(child)->get_rgba32(); + for (auto& child: vector->children) { + if (SP_IS_STOP(&child)) { + guint32 color = SP_STOP(&child)->get_rgba32(); //g_message("Stop color %d", color); gchar c[64]; sp_svg_write_color (c, sizeof(c), @@ -994,7 +1001,7 @@ void sp_item_gradient_invert_vector_color(SPItem *item, Inkscape::PaintTarget fi ); 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_change(child.getRepr(), css, "style"); sp_repr_css_attr_unref (css); } } @@ -1209,8 +1216,8 @@ void sp_item_gradient_set_coords(SPItem *item, GrPointType point_type, guint poi gradient->requestModified(SP_OBJECT_MODIFIED_FLAG); } } - } else if (SP_IS_MESH(gradient)) { - SPMesh *mg = SP_MESH(gradient); + } else if (SP_IS_MESHGRADIENT(gradient)) { + SPMeshGradient *mg = SP_MESHGRADIENT(gradient); //Geom::Affine new_transform; //bool transform_set = false; @@ -1240,7 +1247,7 @@ void sp_item_gradient_set_coords(SPItem *item, GrPointType point_type, guint poi } if( write_repr ) { //std::cout << "Write mesh repr" << std::endl; - sp_mesh_repr_write( mg ); + mg->array.write( mg ); } } @@ -1346,8 +1353,8 @@ Geom::Point getGradientCoords(SPItem *item, GrPointType point_type, guint point_ g_warning( "Bad radial gradient handle type" ); break; } - } else if (SP_IS_MESH(gradient)) { - SPMesh *mg = SP_MESH(gradient); + } else if (SP_IS_MESHGRADIENT(gradient)) { + SPMeshGradient *mg = SP_MESHGRADIENT(gradient); switch (point_type) { case POINT_MG_CORNER: @@ -1570,8 +1577,8 @@ void sp_gradient_invert_selected_gradients(SPDesktop *desktop, Inkscape::PaintTa { Inkscape::Selection *selection = desktop->getSelection(); - const std::vector<SPItem*> list=selection->itemList(); - for (std::vector<SPItem*>::const_iterator i = list.begin(); i != list.end(); ++i) { + auto list= selection->items(); + for (auto i = list.begin(); i != list.end(); ++i) { sp_item_gradient_invert_vector_color(*i, fill_or_stroke); } @@ -1595,8 +1602,8 @@ void sp_gradient_reverse_selected_gradients(SPDesktop *desktop) if (drag && !drag->selected.empty()) { drag->selected_reverse_vector(); } else { // If no drag or no dragger selected, act on selection (both fill and stroke gradients) - const std::vector<SPItem*> list=selection->itemList(); - for (std::vector<SPItem*>::const_iterator i = list.begin(); i != list.end(); ++i) { + auto list= selection->items(); + for (auto i = list.begin(); i != list.end(); ++i) { sp_item_gradient_reverse_vector(*i, Inkscape::FOR_FILL); sp_item_gradient_reverse_vector(*i, Inkscape::FOR_STROKE); } diff --git a/src/gradient-drag.cpp b/src/gradient-drag.cpp index 613dc2fc1..eb33bdf9a 100644 --- a/src/gradient-drag.cpp +++ b/src/gradient-drag.cpp @@ -15,7 +15,7 @@ */ #ifdef HAVE_CONFIG_H -#include "config.h" +#include <config.h> #endif #include <glibmm/i18n.h> @@ -32,20 +32,15 @@ #include "display/sp-ctrlline.h" #include "display/sp-ctrlcurve.h" #include "display/sp-canvas-util.h" -#include "xml/repr.h" #include "xml/sp-css-attr.h" #include "svg/css-ostringstream.h" #include "svg/svg.h" -#include "preferences.h" #include "inkscape.h" -#include "sp-item.h" #include "style.h" #include "knot.h" #include "sp-linear-gradient.h" #include "sp-radial-gradient.h" -#include "sp-mesh.h" -#include "sp-mesh-row.h" -#include "sp-mesh-patch.h" +#include "sp-mesh-gradient.h" #include "gradient-chemistry.h" #include "gradient-drag.h" #include "sp-stop.h" @@ -412,7 +407,7 @@ SPStop *GrDrag::addStopNearPoint(SPItem *item, Geom::Point mouse_p, double toler //r1_knot = false; } } - } else if (SP_IS_MESH(gradient)) { + } else if (SP_IS_MESHGRADIENT(gradient)) { // add_stop_near_point() // Find out which curve pointer is over and use that curve to determine @@ -420,7 +415,7 @@ SPStop *GrDrag::addStopNearPoint(SPItem *item, Geom::Point mouse_p, double toler // This is silly as we already should know which line we are over... // but that information is not saved (sp_gradient_context_is_over_line). - SPMesh *mg = SP_MESH(gradient); + SPMeshGradient *mg = SP_MESHGRADIENT(gradient); Geom::Affine transform = Geom::Affine(mg->gradientTransform)*(Geom::Affine)item->i2dt_affine(); guint rows = mg->array.patch_rows(); @@ -548,7 +543,7 @@ SPStop *GrDrag::addStopNearPoint(SPItem *item, Geom::Point mouse_p, double toler } else { - SPMesh *mg = SP_MESH(gradient); + SPMeshGradient *mg = SP_MESHGRADIENT(gradient); if( divide_row > -1 ) { mg->array.split_row( divide_row, divide_coord ); @@ -557,7 +552,7 @@ SPStop *GrDrag::addStopNearPoint(SPItem *item, Geom::Point mouse_p, double toler } // Update repr - sp_mesh_repr_write( mg ); + mg->array.write( mg ); mg->array.built = false; mg->ensureArray(); // How do we do this? @@ -906,7 +901,7 @@ static void gr_knot_moved_handler(SPKnot *knot, Geom::Point const &ppointer, gui dragger->point = p; dragger->fireDraggables (false, scale_radial); dragger->updateDependencies(false); - dragger->updateHandles( p_old, MG_NODE_NO_SCALE ); + dragger->moveMeshHandles( p_old, MG_NODE_NO_SCALE ); } } @@ -1081,7 +1076,7 @@ static void gr_knot_ungrabbed_handler(SPKnot *knot, unsigned int state, gpointer } else { dragger->fireDraggables (true); } - dragger->updateHandles( dragger->point_original, MG_NODE_NO_SCALE ); + dragger->moveMeshHandles( dragger->point_original, MG_NODE_NO_SCALE ); for (std::set<GrDragger *>::const_iterator it = dragger->parent->selected.begin(); it != dragger->parent->selected.end() ; ++it ) { if (*it == dragger) @@ -1311,9 +1306,8 @@ bool GrDragger::mayMerge(GrDraggable *da2) * Ooops, needs to be reimplemented. */ void -GrDragger::updateHandles ( Geom::Point pc_old, MeshNodeOperation op ) +GrDragger::moveMeshHandles ( Geom::Point pc_old, MeshNodeOperation op ) { - // This routine might more properly be in mesh-context.cpp but moving knots is // handled here rather than there. @@ -1345,7 +1339,7 @@ GrDragger::updateHandles ( Geom::Point pc_old, MeshNodeOperation op ) // Must be a mesh gradient SPGradient *gradient = getGradient(draggable->item, draggable->fill_or_stroke); - if ( !SP_IS_MESH( gradient ) ) continue; + if ( !SP_IS_MESHGRADIENT( gradient ) ) continue; selected_corners[ gradient ].push_back( draggable->point_i ); } @@ -1370,8 +1364,8 @@ GrDragger::updateHandles ( Geom::Point pc_old, MeshNodeOperation op ) // Must be a mesh gradient SPGradient *gradient = getGradient(item, fill_or_stroke); - if ( !SP_IS_MESH( gradient ) ) continue; - SPMesh *mg = SP_MESH( gradient ); + if ( !SP_IS_MESHGRADIENT( gradient ) ) continue; + SPMeshGradient *mg = SP_MESHGRADIENT( gradient ); // pc_old is the old corner position in desktop coordinates, we need it in gradient coordinate. gradient = sp_gradient_convert_to_userspace (gradient, item, (fill_or_stroke == Inkscape::FOR_FILL) ? "fill" : "stroke"); @@ -1949,8 +1943,9 @@ void GrDrag::addDraggersLinear(SPLinearGradient *lg, SPItem *item, Inkscape::Pai /** *Add draggers for the mesh gradient mg on item */ -void GrDrag::addDraggersMesh(SPMesh *mg, SPItem *item, Inkscape::PaintTarget fill_or_stroke) +void GrDrag::addDraggersMesh(SPMeshGradient *mg, SPItem *item, Inkscape::PaintTarget fill_or_stroke) { + mg->ensureArray(); std::vector< std::vector< SPMeshNode* > > nodes = mg->array.nodes; // Show/hide mesh on fill/stroke. This doesn't work at the moment... and prevents node color updating. @@ -1968,7 +1963,7 @@ void GrDrag::addDraggersMesh(SPMesh *mg, SPItem *item, Inkscape::PaintTarget fil // Make sure we have at least one patch defined. if( mg->array.patch_rows() == 0 || mg->array.patch_columns() == 0 ) { - std::cout << "Empty Mesh, No Draggers to Add" << std::endl; + std::cerr << "Empty Mesh, No Draggers to Add" << std::endl; return; } @@ -2023,14 +2018,14 @@ void GrDrag::addDraggersMesh(SPMesh *mg, SPItem *item, Inkscape::PaintTarget fil } default: - std::cout << "Bad Mesh draggable type" << std::endl; + std::cerr << "Bad Mesh draggable type" << std::endl; break; } } } } - mg->array.drag_valid = true; + mg->array.draggers_valid = true; } /** @@ -2070,8 +2065,8 @@ void GrDrag::updateDraggers() this->draggers.clear(); g_return_if_fail(this->selection != NULL); - std::vector<SPItem*> list = this->selection->itemList(); - for (std::vector<SPItem*>::const_iterator i = list.begin(); i != list.end(); ++i) { + auto list = this->selection->items(); + for (auto i = list.begin(); i != list.end(); ++i) { SPItem *item = *i; SPStyle *style = item->style; @@ -2085,8 +2080,8 @@ void GrDrag::updateDraggers() 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_MESH(server) ) { - addDraggersMesh( SP_MESH(server), item, Inkscape::FOR_FILL ); + } else if ( SP_IS_MESHGRADIENT(server) ) { + addDraggersMesh( SP_MESHGRADIENT(server), item, Inkscape::FOR_FILL ); } } } @@ -2101,8 +2096,8 @@ void GrDrag::updateDraggers() 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_MESH(server) ) { - addDraggersMesh( SP_MESH(server), item, Inkscape::FOR_STROKE ); + } else if ( SP_IS_MESHGRADIENT(server) ) { + addDraggersMesh( SP_MESHGRADIENT(server), item, Inkscape::FOR_STROKE ); } } } @@ -2138,8 +2133,8 @@ void GrDrag::updateLines() g_return_if_fail(this->selection != NULL); - std::vector<SPItem*> list = this->selection->itemList(); - for (std::vector<SPItem*>::const_iterator i = list.begin(); i != list.end(); ++i) { + auto list = this->selection->items(); + for (auto i = list.begin(); i != list.end(); ++i) { SPItem *item = *i; SPStyle *style = item->style; @@ -2156,9 +2151,9 @@ void GrDrag::updateLines() 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_MESH(server) ) { + } else if ( SP_IS_MESHGRADIENT(server) ) { - SPMesh *mg = SP_MESH(server); + SPMeshGradient *mg = SP_MESHGRADIENT(server); guint rows = mg->array.patch_rows(); guint columns = mg->array.patch_columns(); @@ -2218,10 +2213,10 @@ void GrDrag::updateLines() 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_MESH(server) ) { + } else if ( SP_IS_MESHGRADIENT(server) ) { // MESH FIXME: TURN ROUTINE INTO FUNCTION AND CALL FOR BOTH FILL AND STROKE. - SPMesh *mg = SP_MESH(server); + SPMeshGradient *mg = SP_MESHGRADIENT(server); guint rows = mg->array.patch_rows(); guint columns = mg->array.patch_columns(); @@ -2282,8 +2277,8 @@ void GrDrag::updateLevels() g_return_if_fail (this->selection != NULL); - std::vector<SPItem*> list = this->selection->itemList(); - for (std::vector<SPItem*>::const_iterator i = list.begin(); i != list.end(); ++i) { + auto list = this->selection->items(); + for (auto i = list.begin(); i != list.end(); ++i) { SPItem *item = *i; Geom::OptRect rect = item->desktopVisualBounds(); if (rect) { @@ -2353,7 +2348,7 @@ void GrDrag::selected_move(double x, double y, bool write_repr, bool scale_radia d->knot->moveto(d->point); d->fireDraggables (write_repr, scale_radial); - d->updateHandles( p_old, MG_NODE_NO_SCALE ); + d->moveMeshHandles( p_old, MG_NODE_NO_SCALE ); d->updateDependencies(write_repr); } } @@ -2539,9 +2534,9 @@ void GrDrag::deleteSelected(bool just_one) // cannot use vector->vector.stops.size() because the vector might be invalidated by deletion of a midstop // manually count the children, don't know if there already exists a function for this... int len = 0; - for ( SPObject *child = (stopinfo->vector)->firstChild() ; child ; child = child->getNext() ) + for (auto& child: stopinfo->vector->children) { - if ( SP_IS_STOP(child) ) { + if ( SP_IS_STOP(&child) ) { len ++; } } diff --git a/src/gradient-drag.h b/src/gradient-drag.h index b07f748a7..cf0a35c89 100644 --- a/src/gradient-drag.h +++ b/src/gradient-drag.h @@ -34,7 +34,7 @@ class SPKnot; class SPDesktop; class SPCSSAttr; class SPLinearGradient; -class SPMesh; +class SPMeshGradient; class SPItem; class SPObject; class SPRadialGradient; @@ -105,7 +105,7 @@ struct GrDragger { void updateDependencies(bool write_repr); /* Update handles/tensors when mesh corner moved */ - void updateHandles( Geom::Point pc_old, MeshNodeOperation op ); + void moveMeshHandles( Geom::Point pc_old, MeshNodeOperation op ); bool mayMerge(GrDragger *other); bool mayMerge(GrDraggable *da2); @@ -209,7 +209,7 @@ private: void addDraggersRadial(SPRadialGradient *rg, SPItem *item, Inkscape::PaintTarget fill_or_stroke); void addDraggersLinear(SPLinearGradient *lg, SPItem *item, Inkscape::PaintTarget fill_or_stroke); - void addDraggersMesh( SPMesh *mg, SPItem *item, Inkscape::PaintTarget fill_or_stroke); + void addDraggersMesh( SPMeshGradient *mg, SPItem *item, Inkscape::PaintTarget fill_or_stroke); bool styleSet( const SPCSSAttr *css ); diff --git a/src/graphlayout.cpp b/src/graphlayout.cpp index 3956b39fe..52bb6b6a2 100644 --- a/src/graphlayout.cpp +++ b/src/graphlayout.cpp @@ -13,31 +13,21 @@ */ #include <iostream> -#include <config.h> #include <map> #include <vector> #include <algorithm> #include <cstring> -#include <cstdlib> -#include <float.h> #include <2geom/transforms.h> #include "desktop.h" #include "inkscape.h" #include "sp-namedview.h" #include "graphlayout.h" -#include "sp-path.h" -#include "sp-item.h" #include "sp-item-transform.h" -#include "sp-conn-end-pair.h" #include "style.h" #include "conn-avoid-ref.h" -#include "libavoid/connector.h" #include "libavoid/router.h" -#include "libavoid/geomtypes.h" #include "libcola/cola.h" -#include "libvpsc/generate-constraints.h" -#include "preferences.h" using namespace std; using namespace cola; diff --git a/src/helper/Makefile_insert b/src/helper/Makefile_insert deleted file mode 100644 index e59fcfb70..000000000 --- a/src/helper/Makefile_insert +++ /dev/null @@ -1,45 +0,0 @@ -## Makefile.am fragment sourced by src/Makefile.am. - -helper/unit-menu.$(OBJEXT): helper/sp-marshal.h - -ink_common_sources += \ - helper/action.cpp \ - helper/action.h \ - helper/action-context.cpp \ - helper/action-context.h \ - helper/geom.cpp \ - helper/geom.h \ - helper/geom-curves.h \ - helper/geom-nodetype.cpp \ - helper/geom-nodetype.h \ - helper/geom-pathstroke.cpp \ - helper/geom-pathstroke.h \ - helper/gnome-utils.cpp \ - helper/gnome-utils.h \ - helper/mathfns.h \ - helper/png-write.cpp \ - helper/png-write.h \ - helper/sp-marshal.cpp \ - helper/sp-marshal.h \ - helper/window.cpp \ - helper/window.h \ - helper/stock-items.cpp \ - helper/stock-items.h - -# cmp exits with status 0 when there are no differences. "if" executes the commands -# after "then" when the exit status of the if command is 0 (this is crazy). -helper/sp-marshal.h: helper/sp-marshal.list - glib-genmarshal --prefix=sp_marshal --header $(srcdir)/helper/sp-marshal.list > helper/tmp.sp-marshal.h - if cmp -s helper/sp-marshal.h helper/tmp.sp-marshal.h; \ - then rm helper/tmp.sp-marshal.h; \ - else mv helper/tmp.sp-marshal.h helper/sp-marshal.h; fi - -helper/sp-marshal.cpp: helper/sp-marshal.list helper/sp-marshal.h - ( echo '#include "helper/sp-marshal.h"' && \ - glib-genmarshal --prefix=sp_marshal --body $(srcdir)/helper/sp-marshal.list ) \ - > helper/tmp.sp-marshal.cpp; \ - if cmp -s helper/sp-marshal.cpp helper/tmp.sp-marshal.cpp; \ - then rm helper/tmp.sp-marshal.cpp; \ - else mv helper/tmp.sp-marshal.cpp helper/sp-marshal.cpp; fi - -helper/sp-marshal.cpp helper/sp-marshal.h: helper/sp-marshal.list diff --git a/src/helper/action-context.cpp b/src/helper/action-context.cpp index d52e43d96..1ea12776b 100644 --- a/src/helper/action-context.cpp +++ b/src/helper/action-context.cpp @@ -14,7 +14,6 @@ #include "layer-model.h" #include "selection.h" #include "helper/action-context.h" -#include "ui/view/view.h" namespace Inkscape { diff --git a/src/helper/action.cpp b/src/helper/action.cpp index 060bf317c..e37575a9c 100644 --- a/src/helper/action.cpp +++ b/src/helper/action.cpp @@ -9,8 +9,6 @@ * This code is in public domain */ -#include <string.h> - #include "debug/logger.h" #include "debug/timestamp.h" #include "debug/simple-event.h" diff --git a/src/helper/geom-nodetype.cpp b/src/helper/geom-nodetype.cpp index fe8e8af0e..da620b3fd 100644 --- a/src/helper/geom-nodetype.cpp +++ b/src/helper/geom-nodetype.cpp @@ -12,8 +12,6 @@ #include "helper/geom-nodetype.h" #include <2geom/curve.h> -#include <2geom/point.h> -#include <vector> namespace Geom { diff --git a/src/helper/geom-pathstroke.cpp b/src/helper/geom-pathstroke.cpp index d2e9f9a1b..10641692d 100644 --- a/src/helper/geom-pathstroke.cpp +++ b/src/helper/geom-pathstroke.cpp @@ -9,13 +9,9 @@ #include <iomanip> #include <2geom/path-sink.h> -#include <2geom/point.h> -#include <2geom/bezier-curve.h> -#include <2geom/elliptical-arc.h> #include <2geom/sbasis-to-bezier.h> // cubicbezierpath_from_sbasis #include <2geom/path-intersection.h> #include <2geom/circle.h> -#include <math.h> #include "helper/geom-pathstroke.h" diff --git a/src/helper/geom.cpp b/src/helper/geom.cpp index ecb330b01..42c494c00 100644 --- a/src/helper/geom.cpp +++ b/src/helper/geom.cpp @@ -12,15 +12,8 @@ #include <algorithm> #include "helper/geom.h" #include "helper/geom-curves.h" -#include <typeinfo> -#include <2geom/pathvector.h> -#include <2geom/path.h> #include <2geom/curves.h> -#include <2geom/transforms.h> -#include <2geom/rect.h> -#include <2geom/coord.h> #include <2geom/sbasis-to-bezier.h> -#include <math.h> // for M_PI using Geom::X; using Geom::Y; diff --git a/src/helper/pixbuf-ops.cpp b/src/helper/pixbuf-ops.cpp index 9639096fb..bab998fdb 100644 --- a/src/helper/pixbuf-ops.cpp +++ b/src/helper/pixbuf-ops.cpp @@ -12,10 +12,9 @@ */ #ifdef HAVE_CONFIG_H -# include "config.h" +#include <config.h> #endif -#include <png.h> #include <boost/scoped_ptr.hpp> #include <2geom/transforms.h> @@ -24,11 +23,8 @@ #include "display/cairo-utils.h" #include "display/drawing.h" #include "display/drawing-context.h" -#include "display/drawing-item.h" #include "document.h" -#include "sp-item.h" #include "sp-root.h" -#include "sp-use.h" #include "sp-defs.h" #include "util/units.h" @@ -53,8 +49,8 @@ static void hide_other_items_recursively(SPObject *o, GSList *list, unsigned dke // recurse if (!g_slist_find(list, o)) { - for ( SPObject *child = o->firstChild() ; child; child = child->getNext() ) { - hide_other_items_recursively(child, list, dkey); + for (auto& child: o->children) { + hide_other_items_recursively(&child, list, dkey); } } } diff --git a/src/helper/png-write.cpp b/src/helper/png-write.cpp index 9430feeff..2433e2777 100644 --- a/src/helper/png-write.cpp +++ b/src/helper/png-write.cpp @@ -14,19 +14,17 @@ */ #ifdef HAVE_CONFIG_H -# include "config.h" +#include <config.h> #endif #include <png.h> #include "ui/interface.h" #include <2geom/rect.h> #include <2geom/transforms.h> -#include <glib.h> #include "png-write.h" #include "io/sys.h" #include "display/drawing.h" #include "display/drawing-context.h" -#include "display/drawing-item.h" #include "document.h" #include "sp-item.h" #include "sp-root.h" @@ -125,8 +123,8 @@ void PngTextList::add(gchar const* key, gchar const* text) static bool sp_png_write_rgba_striped(SPDocument *doc, gchar const *filename, unsigned long int width, unsigned long int height, double xdpi, double ydpi, - int (* get_rows)(guchar const **rows, void **to_free, int row, int num_rows, void *data), - void *data) + int (* get_rows)(guchar const **rows, void **to_free, int row, int num_rows, void *data, int color_type, int bit_depth), + void *data, bool interlace, int color_type, int bit_depth, int zlib) { g_return_val_if_fail(filename != NULL, false); g_return_val_if_fail(data != NULL, false); @@ -186,22 +184,28 @@ sp_png_write_rgba_striped(SPDocument *doc, * PNG_INTERLACE_ADAM7, and the compression_type and filter_type MUST * currently be PNG_COMPRESSION_TYPE_BASE and PNG_FILTER_TYPE_BASE. REQUIRED */ + + png_set_compression_level(png_ptr, zlib); + png_set_IHDR(png_ptr, info_ptr, width, height, - 8, /* bit_depth */ - PNG_COLOR_TYPE_RGB_ALPHA, - PNG_INTERLACE_NONE, + bit_depth, + color_type, + interlace ? PNG_INTERLACE_ADAM7 : PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE); - /* otherwise, if we are dealing with a color image then */ - sig_bit.red = 8; - sig_bit.green = 8; - sig_bit.blue = 8; - /* if the image has an alpha channel then */ - sig_bit.alpha = 8; - png_set_sBIT(png_ptr, info_ptr, &sig_bit); + if ((color_type&2) && bit_depth == 16) { + // otherwise, if we are dealing with a color image then + sig_bit.red = 8; + sig_bit.green = 8; + sig_bit.blue = 8; + // if the image has an alpha channel then + if (color_type&4) + sig_bit.alpha = 8; + png_set_sBIT(png_ptr, info_ptr, &sig_bit); + } PngTextList textList; @@ -250,7 +254,10 @@ sp_png_write_rgba_striped(SPDocument *doc, /* other optional chunks like cHRM, bKGD, tRNS, tIME, oFFs, pHYs, */ /* note that if sRGB is present the cHRM chunk must be ignored * on read and must be written in accordance with the sRGB profile */ - png_set_pHYs(png_ptr, info_ptr, unsigned(xdpi / 0.0254 + 0.5), unsigned(ydpi / 0.0254 + 0.5), PNG_RESOLUTION_METER); + if(xdpi < 0.0254 ) xdpi = 0.0255; + if(ydpi < 0.0254 ) ydpi = 0.0255; + + png_set_pHYs(png_ptr, info_ptr, unsigned(xdpi / 0.0254 ), unsigned(ydpi / 0.0254 ), PNG_RESOLUTION_METER); /* Write the file header information. REQUIRED */ png_write_info(png_ptr, info_ptr); @@ -273,15 +280,18 @@ sp_png_write_rgba_striped(SPDocument *doc, */ png_bytep* row_pointers = new png_bytep[ebp->sheight]; - - r = 0; - while (r < static_cast<png_uint_32>(height)) { - void *to_free; - int n = get_rows((unsigned char const **) row_pointers, &to_free, r, height-r, data); - if (!n) break; - png_write_rows(png_ptr, row_pointers, n); - g_free(to_free); - r += n; + int number_of_passes = interlace ? png_set_interlace_handling(png_ptr) : 1; + + for(int i=0;i<number_of_passes; ++i){ + r = 0; + while (r < static_cast<png_uint_32>(height)) { + void *to_free; + int n = get_rows((unsigned char const **) row_pointers, &to_free, r, height-r, data, color_type, bit_depth); + if (!n) break; + png_write_rows(png_ptr, row_pointers, n); + g_free(to_free); + r += n; + } } delete[] row_pointers; @@ -310,7 +320,7 @@ sp_png_write_rgba_striped(SPDocument *doc, * */ static int -sp_export_get_rows(guchar const **rows, void **to_free, int row, int num_rows, void *data) +sp_export_get_rows(guchar const **rows, void **to_free, int row, int num_rows, void *data, int color_type, int bit_depth) { struct SPEBP *ebp = (struct SPEBP *) data; @@ -345,15 +355,14 @@ sp_export_get_rows(guchar const **rows, void **to_free, int row, int num_rows, v ebp->drawing->render(dc, bbox); cairo_surface_destroy(s); - *to_free = px; - // PNG stores data as unpremultiplied big-endian RGBA, which means // it's identical to the GdkPixbuf format. convert_pixels_argb32_to_pixbuf(px, ebp->width, num_rows, stride); - - for (int r = 0; r < num_rows; r++) { - rows[r] = px + r * stride; - } + + // If a custom bit depth or color type is asked, then convert rgb to grayscale, etc. + const guchar* new_data = pixbuf_to_png(rows, px, num_rows, ebp->width, stride, color_type, bit_depth); + *to_free = (void*) new_data; + free(px); return num_rows; } @@ -374,8 +383,8 @@ static void hide_other_items_recursively(SPObject *o, const std::vector<SPItem*> // recurse if (list.end()==find(list.begin(),list.end(),o)) { - for ( SPObject *child = o->firstChild() ; child; child = child->getNext() ) { - hide_other_items_recursively(child, list, dkey); + for (auto& child: o->children) { + hide_other_items_recursively(&child, list, dkey); } } } @@ -387,10 +396,10 @@ ExportResult sp_export_png_file(SPDocument *doc, gchar const *filename, unsigned long bgcolor, unsigned int (*status) (float, void *), void *data, bool force_overwrite, - const std::vector<SPItem*> &items_only) + const std::vector<SPItem*> &items_only, bool interlace, int color_type, int bit_depth, int zlib) { return sp_export_png_file(doc, filename, Geom::Rect(Geom::Point(x0,y0),Geom::Point(x1,y1)), - width, height, xdpi, ydpi, bgcolor, status, data, force_overwrite, items_only); + width, height, xdpi, ydpi, bgcolor, status, data, force_overwrite, items_only, interlace, color_type, bit_depth, zlib); } ExportResult sp_export_png_file(SPDocument *doc, gchar const *filename, @@ -399,7 +408,7 @@ ExportResult sp_export_png_file(SPDocument *doc, gchar const *filename, unsigned long bgcolor, unsigned (*status)(float, void *), void *data, bool force_overwrite, - const std::vector<SPItem*> &items_only) + const std::vector<SPItem*> &items_only, bool interlace, int color_type, int bit_depth, int zlib) { g_return_val_if_fail(doc != NULL, EXPORT_ERROR); g_return_val_if_fail(filename != NULL, EXPORT_ERROR); @@ -470,7 +479,7 @@ ExportResult sp_export_png_file(SPDocument *doc, gchar const *filename, ebp.px = g_try_new(guchar, 4 * ebp.sheight * width); if (ebp.px) { - write_status = sp_png_write_rgba_striped(doc, filename, width, height, xdpi, ydpi, sp_export_get_rows, &ebp); + write_status = sp_png_write_rgba_striped(doc, filename, width, height, xdpi, ydpi, sp_export_get_rows, &ebp, interlace, color_type, bit_depth, zlib); g_free(ebp.px); } diff --git a/src/helper/png-write.h b/src/helper/png-write.h index 2657fb635..e47f01743 100644 --- a/src/helper/png-write.h +++ b/src/helper/png-write.h @@ -34,12 +34,14 @@ ExportResult sp_export_png_file(SPDocument *doc, gchar const *filename, double x0, double y0, double x1, double y1, unsigned long int width, unsigned long int height, double xdpi, double ydpi, unsigned long bgcolor, - unsigned int (*status) (float, void *), void *data, bool force_overwrite = false, const std::vector<SPItem*> &items_only = std::vector<SPItem*>()); + unsigned int (*status) (float, void *), void *data, bool force_overwrite = false, const std::vector<SPItem*> &items_only = std::vector<SPItem*>(), + bool interlace = false, int color_type = 6, int bit_depth = 8, int zlib = 6); ExportResult sp_export_png_file(SPDocument *doc, gchar const *filename, Geom::Rect const &area, unsigned long int width, unsigned long int height, double xdpi, double ydpi, unsigned long bgcolor, - unsigned int (*status) (float, void *), void *data, bool force_overwrite = false, const std::vector<SPItem*> &items_only = std::vector<SPItem*>()); + unsigned int (*status) (float, void *), void *data, bool force_overwrite = false, const std::vector<SPItem*> &items_only = std::vector<SPItem*>(), + bool interlace = false, int color_type = 6, int bit_depth = 8, int zlib = 6); #endif // SEEN_SP_PNG_WRITE_H diff --git a/src/helper/stock-items.cpp b/src/helper/stock-items.cpp index 5a56b89ff..647e42916 100644 --- a/src/helper/stock-items.cpp +++ b/src/helper/stock-items.cpp @@ -204,37 +204,37 @@ SPObject *get_stock_item(gchar const *urn, gboolean stock) } SPObject *object = NULL; if (!strcmp(base, "marker") && !stock) { - for ( SPObject *child = defs->firstChild(); child; child = child->getNext() ) + for (auto& child: defs->children) { - if (child->getRepr()->attribute("inkscape:stockid") && - !strcmp(name_p, child->getRepr()->attribute("inkscape:stockid")) && - SP_IS_MARKER(child)) + if (child.getRepr()->attribute("inkscape:stockid") && + !strcmp(name_p, child.getRepr()->attribute("inkscape:stockid")) && + SP_IS_MARKER(&child)) { - object = child; + object = &child; } } } else if (!strcmp(base,"pattern") && !stock) { - for ( SPObject *child = defs->firstChild() ; child; child = child->getNext() ) + for (auto& child: defs->children) { - if (child->getRepr()->attribute("inkscape:stockid") && - !strcmp(name_p, child->getRepr()->attribute("inkscape:stockid")) && - SP_IS_PATTERN(child)) + if (child.getRepr()->attribute("inkscape:stockid") && + !strcmp(name_p, child.getRepr()->attribute("inkscape:stockid")) && + SP_IS_PATTERN(&child)) { - object = child; + object = &child; } } } else if (!strcmp(base,"gradient") && !stock) { - for ( SPObject *child = defs->firstChild(); child; child = child->getNext() ) + for (auto& child: defs->children) { - if (child->getRepr()->attribute("inkscape:stockid") && - !strcmp(name_p, child->getRepr()->attribute("inkscape:stockid")) && - SP_IS_GRADIENT(child)) + if (child.getRepr()->attribute("inkscape:stockid") && + !strcmp(name_p, child.getRepr()->attribute("inkscape:stockid")) && + SP_IS_GRADIENT(&child)) { - object = child; + object = &child; } } diff --git a/src/id-clash.cpp b/src/id-clash.cpp index 4bd66e858..c284843b8 100644 --- a/src/id-clash.cpp +++ b/src/id-clash.cpp @@ -23,8 +23,6 @@ #include "sp-object.h" #include "style.h" #include "sp-paint-server.h" -#include "xml/node.h" -#include "xml/repr.h" #include "sp-root.h" #include "sp-gradient.h" @@ -187,9 +185,9 @@ find_references(SPObject *elem, refmap_type &refmap) } // recurse - for (SPObject *child = elem->firstChild(); child; child = child->getNext() ) + for (auto& child: elem->children) { - find_references(child, refmap); + find_references(&child, refmap); } } @@ -242,9 +240,9 @@ change_clashing_ids(SPDocument *imported_doc, SPDocument *current_doc, // recurse - for (SPObject *child = elem->firstChild(); child; child = child->getNext() ) + for (auto& child: elem->children) { - change_clashing_ids(imported_doc, current_doc, child, refmap, id_changes); + change_clashing_ids(imported_doc, current_doc, &child, refmap, id_changes); } } diff --git a/src/inkgc/Makefile_insert b/src/inkgc/Makefile_insert deleted file mode 100644 index 58aa39bb9..000000000 --- a/src/inkgc/Makefile_insert +++ /dev/null @@ -1,13 +0,0 @@ -## Makefile.am fragment sourced by src/Makefile.am. - -inkgc/all: inkgc/libinkgc.a - -inkgc/clean: - rm -f inkgc/libinkgc.a $(inkgc_libinkgc_a_OBJECTS) - -inkgc_libinkgc_a_SOURCES = \ - inkgc/gc.cpp \ - inkgc/gc-alloc.h \ - inkgc/gc-core.h \ - inkgc/gc-managed.h \ - inkgc/gc-soft-ptr.h diff --git a/src/inkscape-x64.rc b/src/inkscape-x64.rc index 2f4710a36..f5d3b5b99 100644 --- a/src/inkscape-x64.rc +++ b/src/inkscape-x64.rc @@ -3,8 +3,8 @@ APPLICATION_ICON ICON DISCARDABLE "../inkscape.ico" 1 24 DISCARDABLE "./inkscape-manifest-x64.xml" 1 VERSIONINFO - FILEVERSION 0,92,0,0 - PRODUCTVERSION 0,92,0,0 + FILEVERSION 0,93,0,0 + PRODUCTVERSION 0,93,0,0 BEGIN BLOCK "StringFileInfo" BEGIN @@ -13,11 +13,11 @@ BEGIN VALUE "Comments", "Published under the GNU GPL" VALUE "CompanyName", "inkscape.org" VALUE "FileDescription", "Inkscape" - VALUE "FileVersion", "0.92pre1" + VALUE "FileVersion", "0.92+devel" VALUE "InternalName", "Inkscape" - VALUE "LegalCopyright", "© 2014 Inkscape" + VALUE "LegalCopyright", "© 2016 Inkscape" VALUE "ProductName", "Inkscape" - VALUE "ProductVersion", "0.92pre1" + VALUE "ProductVersion", "0.92+devel" END END BLOCK "VarFileInfo" diff --git a/src/inkscape.cpp b/src/inkscape.cpp index 888a64430..6f8ea4324 100644 --- a/src/inkscape.cpp +++ b/src/inkscape.cpp @@ -15,13 +15,17 @@ */ #ifdef HAVE_CONFIG_H -# include "config.h" +#include <config.h> #endif #include <errno.h> #include <map> +#include <glibmm/fileutils.h> + +#include <gtkmm/cssprovider.h> +#include <gtkmm/icontheme.h> #include <gtkmm/messagedialog.h> #include "debug/simple-event.h" #include "debug/event-tracker.h" @@ -40,14 +44,10 @@ # include <shlobj.h> #endif -#include <cstring> #include <glib/gstdio.h> #include <glibmm/i18n.h> #include <glibmm/miscutils.h> #include <glibmm/convert.h> -#include <gtk/gtk.h> -#include <signal.h> -#include <string> #include "desktop.h" @@ -58,17 +58,13 @@ #include "extension/output.h" #include "extension/system.h" #include "helper/action-context.h" -#include "helper/sp-marshal.h" #include "inkscape.h" #include "io/sys.h" -#include "layer-model.h" #include "message-stack.h" -#include "preferences.h" +#include "path-prefix.h" #include "resource-manager.h" -#include "selection.h" #include "ui/tools/tool-base.h" #include "ui/dialog/debug.h" -#include "xml/repr.h" /* Backbones of configuration xml data */ #include "menus-skeleton.h" @@ -388,6 +384,103 @@ void Application::argv0(char const* argv) _argv0 = g_strdup(argv); } +/** + * \brief Add our icon theme to the search path + */ +void +Application::add_icon_theme() +{ + // Get list of the possible folders containing the theme + auto dataDirs = Glib::get_system_data_dirs(); + dataDirs.insert(dataDirs.begin(), Glib::get_user_data_dir()); + + auto icon_theme = Gtk::IconTheme::get_default(); + + for (auto it : dataDirs) + { + std::vector<Glib::ustring> listing; + listing.push_back(it); + listing.push_back("inkscape"); + listing.push_back("icons"); + auto dir = Glib::build_filename(listing); + icon_theme->append_search_path(dir); + } + + // Add our icon directory to the search path for icon theme lookups. + auto const usericondir = Inkscape::Application::profile_path("icons"); + icon_theme->append_search_path(usericondir); + icon_theme->append_search_path(INKSCAPE_PIXMAPDIR); +#ifdef INKSCAPE_THEMEDIR + icon_theme->append_search_path(INKSCAPE_THEMEDIR); + icon_theme->rescan_if_needed(); +#endif + g_free(usericondir); +} + +/** + * \brief Add our CSS style sheets + */ +void +Application::add_style_sheet() +{ + // Add style sheet (GTK3) + auto const screen = Gdk::Screen::get_default(); + + Glib::ustring inkscape_style = INKSCAPE_UIDIR; + inkscape_style += "/style.css"; + // std::cout << "CSS Stylesheet Inkscape: " << inkscape_style << std::endl; + + if (Glib::file_test(inkscape_style, Glib::FILE_TEST_EXISTS)) { + auto provider = Gtk::CssProvider::create(); + + // From 3.16, throws an error which we must catch. + try { + provider->load_from_path (inkscape_style); + } +#if GTK_CHECK_VERSION(3,16,0) + // Gtk::CssProviderError not defined until 3.16. + catch (const Gtk::CssProviderError& ex) + { + std::cerr << "CSSProviderError::load_from_path(): failed to load: " << inkscape_style + << "\n (" << ex.what() << ")" << std::endl; + } +#else + catch (...) + {} +#endif + + Gtk::StyleContext::add_provider_for_screen (screen, provider, GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); + } else { + std::cerr << "sp_main_gui: Cannot find default style file:\n (" << inkscape_style + << ")" << std::endl; + } + + Glib::ustring user_style = Inkscape::Application::profile_path("ui/style.css"); + // std::cout << "CSS Stylesheet User: " << user_style << std::endl; + + if (Glib::file_test(user_style, Glib::FILE_TEST_EXISTS)) { + auto provider2 = Gtk::CssProvider::create(); + + // From 3.16, throws an error which we must catch. + try { + provider2->load_from_path (user_style); + } +#if GTK_CHECK_VERSION(3,16,0) + // Gtk::CssProviderError not defined until 3.16. + catch (const Gtk::CssProviderError& ex) + { + std::cerr << "CSSProviderError::load_from_path(): failed to load: " << user_style + << "\n (" << ex.what() << ")" << std::endl; + } +#else + catch (...) + {} +#endif + + Gtk::StyleContext::add_provider_for_screen (screen, provider2, GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); + } + +} /* \brief Constructor for the application. * Creates a new Inkscape::Application. * @@ -432,9 +525,12 @@ Application::Application(const char* argv, bool use_gui) : } if (use_gui) { + add_icon_theme(); + add_style_sheet(); load_menus(); Inkscape::DeviceManager::getManager().loadConfig(); } + Inkscape::ResourceManager::getManager(); /* set language for user interface according setting in preferences */ @@ -560,6 +656,7 @@ Application::crash_handler (int /*signum*/) repr = doc->getReprRoot(); if (doc->isModifiedSinceSave()) { const gchar *docname; + char n[64]; /* originally, the document name was retrieved from * the sodipod:docname attribute */ @@ -575,7 +672,6 @@ Application::crash_handler (int /*signum*/) if (*d=='.') dots++; } if (*d=='.' && d>docname && dots==2) { - char n[64]; size_t len = MIN (d - docname, 63); memcpy (n, docname, len); n[len] = '\0'; diff --git a/src/inkscape.h b/src/inkscape.h index fe424377c..3f4416f2f 100644 --- a/src/inkscape.h +++ b/src/inkscape.h @@ -205,6 +205,9 @@ private: Application& operator=(Application const&); // no assign Application* operator&() const; // no pointer access + void add_icon_theme(); + void add_style_sheet(); + Inkscape::XML::Document * _menus; std::map<SPDocument *, int> _document_set; std::map<SPDocument *, AppSelectionModel *> _selection_models; diff --git a/src/inkscape.rc b/src/inkscape.rc index 087c5862d..ddb55ac30 100644 --- a/src/inkscape.rc +++ b/src/inkscape.rc @@ -3,8 +3,8 @@ APPLICATION_ICON ICON DISCARDABLE "../inkscape.ico" 1 24 DISCARDABLE "./inkscape-manifest.xml" 1 VERSIONINFO - FILEVERSION 0,92,0,0 - PRODUCTVERSION 0,92,0,0 + FILEVERSION 0,93,0,0 + PRODUCTVERSION 0,93,0,0 BEGIN BLOCK "StringFileInfo" BEGIN @@ -13,11 +13,11 @@ BEGIN VALUE "Comments", "Published under the GNU GPL" VALUE "CompanyName", "inkscape.org" VALUE "FileDescription", "Inkscape" - VALUE "FileVersion", "0.92pre1" + VALUE "FileVersion", "0.92+devel" VALUE "InternalName", "Inkscape" - VALUE "LegalCopyright", "© 2014 Inkscape" + VALUE "LegalCopyright", "© 2016 Inkscape" VALUE "ProductName", "Inkscape" - VALUE "ProductVersion", "0.92pre1" + VALUE "ProductVersion", "0.92+devel" END END BLOCK "VarFileInfo" diff --git a/src/inkview-x64.rc b/src/inkview-x64.rc index 465de4af1..397d9710f 100644 --- a/src/inkview-x64.rc +++ b/src/inkview-x64.rc @@ -3,8 +3,8 @@ APPLICATION_ICON ICON DISCARDABLE "../inkscape.ico" 1 24 DISCARDABLE "./inkview-manifest-x64.xml" 1 VERSIONINFO - FILEVERSION 0,92,0,0 - PRODUCTVERSION 0,92,0,0 + FILEVERSION 0,93,0,0 + PRODUCTVERSION 0,93,0,0 BEGIN BLOCK "StringFileInfo" BEGIN @@ -13,11 +13,11 @@ BEGIN VALUE "Comments", "Published under the GNU GPL" VALUE "CompanyName", "inkscape.org" VALUE "FileDescription", "Inkview" - VALUE "FileVersion", "0.92pre1" + VALUE "FileVersion", "0.92+devel" VALUE "InternalName", "Inkview" - VALUE "LegalCopyright", "© 2014 Inkscape" + VALUE "LegalCopyright", "© 2016 Inkscape" VALUE "ProductName", "Inkview" - VALUE "ProductVersion", "0.92pre1" + VALUE "ProductVersion", "0.92+devel" END END BLOCK "VarFileInfo" diff --git a/src/inkview.cpp b/src/inkview.cpp index db4b1aeb0..7acaa83dd 100644 --- a/src/inkview.cpp +++ b/src/inkview.cpp @@ -34,14 +34,16 @@ #include <sys/stat.h> #include <locale.h> -#include <gtkmm/main.h> -#include <glib.h> +#include <glibmm/optionentry.h> -// #include <stropts.h> +#include <gtkmm/applicationwindow.h> +#include <gtkmm/button.h> +#include <gtkmm/buttonbox.h> +#include <gtkmm/image.h> +#include <gtkmm/main.h> #include <libxml/tree.h> #include <gdk/gdkkeysyms.h> -#include <gtk/gtk.h> #include "inkgc/gc-core.h" #include "preferences.h" @@ -52,51 +54,97 @@ #include "svg-view-widget.h" #include "util/units.h" -#ifdef WITH_INKJAR -#include "io/inkjar.h" -#endif - #include "inkscape.h" -#include <iostream> - #ifndef HAVE_BIND_TEXTDOMAIN_CODESET #define bind_textdomain_codeset(p,c) #endif #include "ui/icon-names.h" -extern char *optarg; -extern int optind, opterr; - -struct SPSlideShow { - char **slides; - int size; - int length; - int current; - SPDocument *doc; - GtkWidget *view; - GtkWidget *window; - bool fullscreen; - int timer; +class SPSlideShow; + +static int sp_svgview_main_delete (GtkWidget *widget, + GdkEvent *event, + struct SPSlideShow *ss); + +static int sp_svgview_main_key_press (GtkWidget *widget, + GdkEventKey *event, + struct SPSlideShow *ss); + +/** + * The main application window for the slideshow + */ +class SPSlideShow : public Gtk::ApplicationWindow { +private: + std::vector<Glib::ustring> _slides; ///< List of filenames for each slide + int _current; ///< Index of the currently displayed slide + SPDocument *_doc; ///< The currently displayed slide + int _timer; + GtkWidget *_view; + Gtk::Window *_ctrlwin; ///< Window containing slideshow control buttons + +public: + /// Current state of application (full-screen or windowed) + bool is_fullscreen; + + /// Update the window title with current document name + void update_title() + { + set_title(_doc->getName()); + } + + SPSlideShow(std::vector<Glib::ustring> const &slides); + + void set_timer(int timer) {_timer = timer;} + void control_show(); + void show_next(); + void show_prev(); + void goto_first(); + void goto_last(); + + static int ctrlwin_delete (GtkWidget *widget, + GdkEvent *event, + void *data); +protected: + void waiting_cursor(); + void normal_cursor(); + void set_document(SPDocument *doc, + int current); }; -static GtkWidget *sp_svgview_control_show (struct SPSlideShow *ss); -static void sp_svgview_show_next (struct SPSlideShow *ss); -static void sp_svgview_show_prev (struct SPSlideShow *ss); -static void sp_svgview_goto_first (struct SPSlideShow *ss); -static void sp_svgview_goto_last (struct SPSlideShow *ss); - -static int sp_svgview_show_next_cb (GtkWidget *widget, void *data); -static int sp_svgview_show_prev_cb (GtkWidget *widget, void *data); -static int sp_svgview_goto_first_cb (GtkWidget *widget, void *data); -static int sp_svgview_goto_last_cb (GtkWidget *widget, void *data); -#ifdef WITH_INKJAR -static bool is_jar(char const *filename); -#endif +SPSlideShow::SPSlideShow(std::vector<Glib::ustring> const &slides) + : + _slides(slides), + _current(0), + _doc(SPDocument::createNewDoc(_slides[0].c_str(), true, false)), + _view(NULL), + is_fullscreen(false), + _timer(0), + _ctrlwin(NULL) +{ + update_title(); + + auto default_screen = Gdk::Screen::get_default(); + + set_default_size(MIN ((int)_doc->getWidth().value("px"), default_screen->get_width() - 64), + MIN ((int)_doc->getHeight().value("px"), default_screen->get_height() - 64)); + + g_signal_connect (G_OBJECT (gobj()), "delete_event", (GCallback) sp_svgview_main_delete, this); + g_signal_connect (G_OBJECT (gobj()), "key_press_event", (GCallback) sp_svgview_main_key_press, this); + + _doc->ensureUpToDate(); + _view = sp_svg_view_widget_new (_doc); + _doc->doUnref (); + SP_SVG_VIEW_WIDGET(_view)->setResize( false, _doc->getWidth().value("px"), _doc->getHeight().value("px") ); + gtk_widget_show (_view); + add(*Glib::wrap(_view)); + + show(); +} + static void usage(); -static GtkWidget *ctrlwin = NULL; // Dummy functions to keep linker happy int sp_main_gui (int, char const**) { return 0; } @@ -106,7 +154,7 @@ static int sp_svgview_main_delete (GtkWidget */*widget*/, GdkEvent */*event*/, struct SPSlideShow */*ss*/) { - gtk_main_quit (); + Gtk::Main::quit(); return FALSE; } @@ -117,85 +165,96 @@ static int sp_svgview_main_key_press (GtkWidget */*widget*/, switch (event->keyval) { case GDK_KEY_Up: case GDK_KEY_Home: - sp_svgview_goto_first(ss); + ss->goto_first(); break; case GDK_KEY_Down: case GDK_KEY_End: - sp_svgview_goto_last(ss); + ss->goto_last(); break; case GDK_KEY_F11: - if (ss->fullscreen) { - gtk_window_unfullscreen (GTK_WINDOW(ss->window)); - ss->fullscreen = false; + if (ss->is_fullscreen) { + ss->unfullscreen(); + ss->is_fullscreen = false; } else { - gtk_window_fullscreen (GTK_WINDOW(ss->window)); - ss->fullscreen = true; + ss->fullscreen(); + ss->is_fullscreen = true; } break; case GDK_KEY_Return: - sp_svgview_control_show (ss); + ss->control_show(); break; case GDK_KEY_KP_Page_Down: case GDK_KEY_Page_Down: case GDK_KEY_Right: case GDK_KEY_space: - sp_svgview_show_next (ss); + ss->show_next(); break; case GDK_KEY_KP_Page_Up: case GDK_KEY_Page_Up: case GDK_KEY_Left: case GDK_KEY_BackSpace: - sp_svgview_show_prev (ss); + ss->show_prev(); break; case GDK_KEY_Escape: case GDK_KEY_q: case GDK_KEY_Q: - gtk_main_quit(); + Gtk::Main::quit(); break; default: break; } - gtk_window_set_title(GTK_WINDOW(ss->window), ss->doc->getName()); + + ss->update_title(); return TRUE; } -int main (int argc, const char **argv) +/// List of all input filenames +static Glib::OptionGroup::vecustrings filenames; + +/// Input timer option +static int timer = 0; + +/** + * \brief Set of command-line options for Inkview + */ +class InkviewOptionsGroup : public Glib::OptionGroup { - if (argc == 1) { - usage(); +public: + InkviewOptionsGroup() + : + Glib::OptionGroup(_("Inkscape Options"), + _("Default program options")), + _entry_timer(), + _entry_args() + { + // Entry for the "timer" option + _entry_timer.set_short_name('t'); + _entry_timer.set_long_name("timer"); + _entry_timer.set_arg_description(_("NUM")); + add_entry(_entry_timer, timer); + + // Entry for the remaining non-option arguments + _entry_args.set_short_name('\0'); + _entry_args.set_long_name(G_OPTION_REMAINING); + _entry_args.set_arg_description(_("FILES...")); + + add_entry(_entry_args, filenames); } +private: + Glib::OptionEntry _entry_timer; + Glib::OptionEntry _entry_args; +}; + +int main (int argc, char **argv) +{ + Glib::OptionContext opt(_("Open SVG files")); + InkviewOptionsGroup grp; + opt.set_main_group(grp); + // Prevents errors like "Unable to wrap GdkPixbuf..." (in nr-filter-image.cpp for example) Gtk::Main::init_gtkmm_internals(); - - Gtk::Main main_instance (&argc, const_cast<char ***>(&argv)); - - struct SPSlideShow ss; - - int num_parsed_options = 0; - - // the list of arguments is in the net line - for (int i = 1; i < argc; i++) { - if ((argv[i][0] == '-')) { - if (!strcmp(argv[i], "--")) { - break; - } - else if ((!strcmp(argv[i], "-t"))) { - if (i + 1 >= argc) { - usage(); - } - ss.timer = atoi(argv[i+1]); - num_parsed_options = i+1; - i++; - } - else { - usage(); - } - } - } - - GtkWidget *w; - int i; + Gtk::Main main_instance (argc, argv, opt); bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); @@ -206,8 +265,6 @@ int main (int argc, const char **argv) Inkscape::GC::init(); Inkscape::Preferences::get(); // ensure preferences are initialized - gtk_init (&argc, (char ***) &argv); - #ifdef lalaWITH_MODULES g_warning ("Have to autoinit modules (lauris)"); sp_modulesys_init(); @@ -218,349 +275,203 @@ int main (int argc, const char **argv) setlocale (LC_NUMERIC, "C"); - ss.size = 32; - ss.length = 0; - ss.current = 0; - ss.slides = g_new (char *, ss.size); - ss.current = 0; - ss.doc = NULL; - ss.view = NULL; - ss.fullscreen = false; - Inkscape::Application::create(argv[0], true); - //Inkscape::Application &inkscape = Inkscape::Application::instance(); - // starting at where the commandline options stopped parsing because - // we want all the files to be in the list - for (i = num_parsed_options + 1 ; i < argc; i++) { - struct stat st; - if (stat (argv[i], &st) - || !S_ISREG (st.st_mode) - || (st.st_size < 64)) { - fprintf(stderr, "could not open file %s\n", argv[i]); - } else { + if(filenames.empty()) + { + std::cout << opt.get_help(); + exit(EXIT_FAILURE); + } - #ifdef WITH_INKJAR - if (is_jar(argv[i])) { - Inkjar::JarFileReader jar_file_reader(argv[i]); - for (;;) { - GByteArray *gba = jar_file_reader.get_next_file(); - if (gba == NULL) { - char *c_ptr; - gchar *last_filename = jar_file_reader.get_last_filename(); - if (last_filename == NULL) - break; - if ((c_ptr = std::strrchr(last_filename, '/')) != NULL) { - if (*(++c_ptr) == '\0') { - g_free(last_filename); - continue; - } - } - } else if (gba->len > 0) { - //::write(1, gba->data, gba->len); - /* Append to list */ - if (ss.length >= ss.size) { - /* Expand */ - ss.size <<= 1; - ss.slides = g_renew (char *, ss.slides, ss.size); - } - - ss.doc = SPDocument::createNewDocFromMem ((const gchar *)gba->data, - gba->len, - TRUE); - gchar *last_filename = jar_file_reader.get_last_filename(); - if (ss.doc) { - ss.slides[ss.length++] = strdup (last_filename); - (ss.doc)->setUri (last_filename); - } - g_byte_array_free(gba, TRUE); - g_free(last_filename); - } else { - break; - } - } - } else { - #endif /* WITH_INKJAR */ - /* Append to list */ - if (ss.length >= ss.size) { - /* Expand */ - ss.size <<= 1; - ss.slides = g_renew (char *, ss.slides, ss.size); - } + std::vector<Glib::ustring> valid_files; - ss.slides[ss.length++] = strdup (argv[i]); + for(auto file : filenames) + { + struct stat st; + if (stat(file.c_str(), &st) + || !S_ISREG (st.st_mode) + || (st.st_size < 64)) { + std::cerr << "could not open file " << file << std::endl; + } else { + auto doc = SPDocument::createNewDoc(file.c_str(), TRUE, false); - if (!ss.doc) { - ss.doc = SPDocument::createNewDoc (ss.slides[ss.current], TRUE, false); - if (!ss.doc) { - ++ss.current; - } - } - #ifdef WITH_INKJAR + if(doc) + { + /* Append to list */ + valid_files.push_back(file); } - #endif } } - if(!ss.doc) { + if(valid_files.empty()) { return 1; /* none of the slides loadable */ } - w = gtk_window_new (GTK_WINDOW_TOPLEVEL); - gtk_window_set_title( GTK_WINDOW(w), ss.doc->getName() ); - gtk_window_set_default_size (GTK_WINDOW (w), - MIN ((int)(ss.doc)->getWidth().value("px"), (int)gdk_screen_width() - 64), - MIN ((int)(ss.doc)->getHeight().value("px"), (int)gdk_screen_height() - 64)); - ss.window = w; - - g_signal_connect (G_OBJECT (w), "delete_event", (GCallback) sp_svgview_main_delete, &ss); - g_signal_connect (G_OBJECT (w), "key_press_event", (GCallback) sp_svgview_main_key_press, &ss); - - (ss.doc)->ensureUpToDate(); - ss.view = sp_svg_view_widget_new (ss.doc); - (ss.doc)->doUnref (); - SP_SVG_VIEW_WIDGET(ss.view)->setResize( false, ss.doc->getWidth().value("px"), ss.doc->getHeight().value("px") ); - gtk_widget_show (ss.view); - gtk_container_add (GTK_CONTAINER (w), ss.view); - - gtk_widget_show (w); - - gtk_main (); + SPSlideShow ss(valid_files); + ss.set_timer(timer); + main_instance.run(); return 0; } -static int sp_svgview_ctrlwin_delete (GtkWidget */*widget*/, - GdkEvent */*event*/, - void */*data*/) +int SPSlideShow::ctrlwin_delete (GtkWidget */*widget*/, + GdkEvent */*event*/, + void *data) { - ctrlwin = NULL; + auto ss = reinterpret_cast<SPSlideShow *>(data); + if(ss->_ctrlwin) delete ss->_ctrlwin; + + ss->_ctrlwin = NULL; return FALSE; } -static GtkWidget* sp_svgview_control_show(struct SPSlideShow *ss) +/** + * @brief Show the control buttons (next, previous etc) for the application + */ +void SPSlideShow::control_show() { - if (!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); - -#if GTK_CHECK_VERSION(3,10,0) - GtkWidget *b = gtk_button_new_from_icon_name(INKSCAPE_ICON("go-first"), GTK_ICON_SIZE_BUTTON); -#else - GtkWidget *b = gtk_button_new(); - GtkWidget *img = gtk_image_new_from_icon_name(INKSCAPE_ICON("go-first"), GTK_ICON_SIZE_BUTTON); - gtk_button_set_image(GTK_BUTTON(b), img); -#endif - gtk_container_add(GTK_CONTAINER(t), b); - - g_signal_connect(G_OBJECT(b), "clicked", (GCallback) sp_svgview_goto_first_cb, ss); -#if GTK_CHECK_VERSION(3,10,0) - b = gtk_button_new_from_icon_name(INKSCAPE_ICON("go-previous"), GTK_ICON_SIZE_BUTTON); -#else - b = gtk_button_new(); - img = gtk_image_new_from_icon_name(INKSCAPE_ICON("go-previous"), GTK_ICON_SIZE_BUTTON); - gtk_button_set_image(GTK_BUTTON(b), img); -#endif - gtk_container_add(GTK_CONTAINER(t), b); - - g_signal_connect(G_OBJECT(b), "clicked", (GCallback) sp_svgview_show_prev_cb, ss); -#if GTK_CHECK_VERSION(3,10,0) - b = gtk_button_new_from_icon_name(INKSCAPE_ICON("go-next"), GTK_ICON_SIZE_BUTTON); -#else - b = gtk_button_new(); - img = gtk_image_new_from_icon_name(INKSCAPE_ICON("go-next"), GTK_ICON_SIZE_BUTTON); - gtk_button_set_image(GTK_BUTTON(b), img); -#endif - gtk_container_add(GTK_CONTAINER(t), b); - - g_signal_connect(G_OBJECT(b), "clicked", (GCallback) sp_svgview_show_next_cb, ss); -#if GTK_CHECK_VERSION(3,10,0) - b = gtk_button_new_from_icon_name(INKSCAPE_ICON("go-last"), GTK_ICON_SIZE_BUTTON); -#else - b = gtk_button_new(); - img = gtk_image_new_from_icon_name(INKSCAPE_ICON("go-last"), GTK_ICON_SIZE_BUTTON); - gtk_button_set_image(GTK_BUTTON(b), img); -#endif - 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); + if (!_ctrlwin) { + _ctrlwin = new Gtk::Window(); + _ctrlwin->set_resizable(false); + _ctrlwin->set_transient_for(*this); + g_signal_connect(G_OBJECT (_ctrlwin->gobj()), "key_press_event", (GCallback) sp_svgview_main_key_press, this); + g_signal_connect(G_OBJECT (_ctrlwin->gobj()), "delete_event", (GCallback) SPSlideShow::ctrlwin_delete, this); + auto t = Gtk::manage(new Gtk::ButtonBox()); + _ctrlwin->add(*t); + + auto btn_go_first = Gtk::manage(new Gtk::Button()); + auto img_go_first = Gtk::manage(new Gtk::Image()); + img_go_first->set_from_icon_name(INKSCAPE_ICON("go-first"), Gtk::ICON_SIZE_BUTTON); + btn_go_first->set_image(*img_go_first); + t->add(*btn_go_first); + btn_go_first->signal_clicked().connect(sigc::mem_fun(*this, &SPSlideShow::goto_first)); + + auto btn_go_prev = Gtk::manage(new Gtk::Button()); + auto img_go_prev = Gtk::manage(new Gtk::Image()); + img_go_prev->set_from_icon_name(INKSCAPE_ICON("go-previous"), Gtk::ICON_SIZE_BUTTON); + btn_go_prev->set_image(*img_go_prev); + t->add(*btn_go_prev); + btn_go_prev->signal_clicked().connect(sigc::mem_fun(*this, &SPSlideShow::show_prev)); + + auto btn_go_next = Gtk::manage(new Gtk::Button()); + auto img_go_next = Gtk::manage(new Gtk::Image()); + img_go_next->set_from_icon_name(INKSCAPE_ICON("go-next"), Gtk::ICON_SIZE_BUTTON); + btn_go_next->set_image(*img_go_next); + t->add(*btn_go_next); + btn_go_next->signal_clicked().connect(sigc::mem_fun(*this, &SPSlideShow::show_next)); + + auto btn_go_last = Gtk::manage(new Gtk::Button()); + auto img_go_last = Gtk::manage(new Gtk::Image()); + img_go_last->set_from_icon_name(INKSCAPE_ICON("go-last"), Gtk::ICON_SIZE_BUTTON); + btn_go_last->set_image(*img_go_last); + t->add(*btn_go_last); + btn_go_last->signal_clicked().connect(sigc::mem_fun(*this, &SPSlideShow::goto_last)); + + _ctrlwin->show_all(); } else { - gtk_window_present(GTK_WINDOW(ctrlwin)); + _ctrlwin->present(); } - - return NULL; -} - -static int sp_svgview_show_next_cb (GtkWidget */*widget*/, void *data) -{ - sp_svgview_show_next(static_cast<struct SPSlideShow *>(data)); - return FALSE; -} - -static int sp_svgview_show_prev_cb (GtkWidget */*widget*/, void *data) -{ - sp_svgview_show_prev(static_cast<struct SPSlideShow *>(data)); - return FALSE; -} - -static int sp_svgview_goto_first_cb (GtkWidget */*widget*/, void *data) -{ - sp_svgview_goto_first(static_cast<struct SPSlideShow *>(data)); - return FALSE; } -static int sp_svgview_goto_last_cb (GtkWidget */*widget*/, void *data) +void SPSlideShow::waiting_cursor() { - sp_svgview_goto_last(static_cast<struct SPSlideShow *>(data)); - return FALSE; -} - -static void sp_svgview_waiting_cursor(struct SPSlideShow *ss) -{ - GdkDisplay *display = gdk_display_get_default(); - GdkCursor *waiting = gdk_cursor_new_for_display(display, GDK_WATCH); - gdk_window_set_cursor(gtk_widget_get_window(GTK_WIDGET(ss->window)), waiting); -#if GTK_CHECK_VERSION(3,0,0) - g_object_unref(waiting); -#else - gdk_cursor_unref(waiting); -#endif - if (ctrlwin) { - GdkCursor *waiting = gdk_cursor_new_for_display(display, GDK_WATCH); - gdk_window_set_cursor(gtk_widget_get_window(GTK_WIDGET(ctrlwin)), waiting); -#if GTK_CHECK_VERSION(3,0,0) - g_object_unref(waiting); -#else - gdk_cursor_unref(waiting); -#endif + auto display = Gdk::Display::get_default(); + auto waiting = Gdk::Cursor::create(display, Gdk::WATCH); + get_window()->set_cursor(waiting); + + if (_ctrlwin) { + _ctrlwin->get_window()->set_cursor(waiting); } - while(gtk_events_pending()) { - gtk_main_iteration(); + while(Gtk::Main::events_pending()) { + Gtk::Main::iteration(); } } -static void sp_svgview_normal_cursor(struct SPSlideShow *ss) +void SPSlideShow::normal_cursor() { - gdk_window_set_cursor(gtk_widget_get_window(GTK_WIDGET(ss->window)), NULL); - if (ctrlwin) { - gdk_window_set_cursor(gtk_widget_get_window(GTK_WIDGET(ctrlwin)), NULL); + get_window()->set_cursor(); + if (_ctrlwin) { + _ctrlwin->get_window()->set_cursor(); } } -static void sp_svgview_set_document(struct SPSlideShow *ss, - SPDocument *doc, - int current) +void SPSlideShow::set_document(SPDocument *doc, + int current) { - if (doc && doc != ss->doc) { + if (doc && doc != _doc) { doc->ensureUpToDate(); - reinterpret_cast<SPSVGView*>(SP_VIEW_WIDGET_VIEW (ss->view))->setDocument (doc); - ss->doc = doc; - ss->current = current; + reinterpret_cast<SPSVGView*>(SP_VIEW_WIDGET_VIEW (_view))->setDocument (doc); + _doc = doc; + _current = current; } } -static void sp_svgview_show_next (struct SPSlideShow *ss) +/** + * @brief Show the next file in the slideshow + */ +void SPSlideShow::show_next() { - sp_svgview_waiting_cursor(ss); + waiting_cursor(); SPDocument *doc = NULL; - int current = ss->current; - while (!doc && (current < ss->length - 1)) { - doc = SPDocument::createNewDoc (ss->slides[++current], TRUE, false); + while (!doc && (_current < _slides.size() - 1)) { + doc = SPDocument::createNewDoc ((_slides[++_current]).c_str(), TRUE, false); } - sp_svgview_set_document(ss, doc, current); - - sp_svgview_normal_cursor(ss); + set_document(doc, _current); + normal_cursor(); } -static void sp_svgview_show_prev (struct SPSlideShow *ss) +/** + * @brief Show the previous file in the slideshow + */ +void SPSlideShow::show_prev() { - sp_svgview_waiting_cursor(ss); + waiting_cursor(); SPDocument *doc = NULL; - int current = ss->current; - while (!doc && (current > 0)) { - doc = SPDocument::createNewDoc (ss->slides[--current], TRUE, false); + while (!doc && (_current > 0)) { + doc = SPDocument::createNewDoc ((_slides[--_current]).c_str(), TRUE, false); } - sp_svgview_set_document(ss, doc, current); - - sp_svgview_normal_cursor(ss); + set_document(doc, _current); + normal_cursor(); } -static void sp_svgview_goto_first (struct SPSlideShow *ss) +/** + * @brief Switch to first slide in slideshow + */ +void SPSlideShow::goto_first() { - sp_svgview_waiting_cursor(ss); + waiting_cursor(); SPDocument *doc = NULL; int current = 0; - while ( !doc && (current < ss->length - 1)) { - if (current == ss->current) { - break; - } - doc = SPDocument::createNewDoc (ss->slides[current++], TRUE, false); + while ( !doc && (current < _slides.size() - 1)) { + doc = SPDocument::createNewDoc((_slides[current++]).c_str(), TRUE, false); } - sp_svgview_set_document(ss, doc, current - 1); + set_document(doc, current - 1); - sp_svgview_normal_cursor(ss); + normal_cursor(); } -static void sp_svgview_goto_last (struct SPSlideShow *ss) +/** + * @brief Switch to last slide in slideshow + */ +void SPSlideShow::goto_last() { - sp_svgview_waiting_cursor(ss); + waiting_cursor(); SPDocument *doc = NULL; - int current = ss->length - 1; + int current = _slides.size() - 1; while (!doc && (current >= 0)) { - if (current == ss->current) { - break; - } - doc = SPDocument::createNewDoc (ss->slides[current--], TRUE, false); + doc = SPDocument::createNewDoc((_slides[current--]).c_str(), TRUE, false); } - sp_svgview_set_document(ss, doc, current + 1); - - sp_svgview_normal_cursor(ss); -} - -#ifdef WITH_INKJAR -static bool is_jar(char const *filename) -{ - /* fixme: Check MIME type or something. /usr/share/misc/file/magic suggests that checking for - initial string "PK\003\004" in content should suffice. */ - size_t const filename_len = strlen(filename); - if (filename_len < 5) { - return false; - } - char const *extension = filename + filename_len - 4; - return ((memcmp(extension, ".jar", 4) == 0) || - (memcmp(extension, ".sxw", 4) == 0) ); -} -#endif /* WITH_INKJAR */ + set_document(doc, current + 1); -static void usage() -{ - fprintf(stderr, - "Usage: inkview [OPTIONS...] [FILES ...]\n" - "\twhere FILES are SVG (.svg or .svgz)" -#ifdef WITH_INKJAR - " or archives of SVGs (.sxw, .jar)" -#endif - "\n"); - exit(1); + normal_cursor(); } /* diff --git a/src/inkview.rc b/src/inkview.rc index 34632bd14..5c439981a 100644 --- a/src/inkview.rc +++ b/src/inkview.rc @@ -3,8 +3,8 @@ APPLICATION_ICON ICON DISCARDABLE "../inkscape.ico" 1 24 DISCARDABLE "./inkview-manifest.xml" 1 VERSIONINFO - FILEVERSION 0,92,0,0 - PRODUCTVERSION 0,92,0,0 + FILEVERSION 0,93,0,0 + PRODUCTVERSION 0,93,0,0 BEGIN BLOCK "StringFileInfo" BEGIN @@ -13,11 +13,11 @@ BEGIN VALUE "Comments", "Published under the GNU GPL" VALUE "CompanyName", "inkscape.org" VALUE "FileDescription", "Inkview" - VALUE "FileVersion", "0.92pre1" + VALUE "FileVersion", "0.92+devel" VALUE "InternalName", "Inkview" - VALUE "LegalCopyright", "© 2014 Inkscape" + VALUE "LegalCopyright", "© 2016 Inkscape" VALUE "ProductName", "Inkview" - VALUE "ProductVersion", "0.92pre1" + VALUE "ProductVersion", "0.92+devel" END END BLOCK "VarFileInfo" diff --git a/src/io/CMakeLists.txt b/src/io/CMakeLists.txt index ef577b014..5ab48ab84 100644 --- a/src/io/CMakeLists.txt +++ b/src/io/CMakeLists.txt @@ -3,7 +3,6 @@ set(io_SRC base64stream.cpp bufferstream.cpp gzipstream.cpp - inkjar.cpp inkscapestream.cpp resource.cpp stringstream.cpp @@ -16,7 +15,6 @@ set(io_SRC base64stream.h bufferstream.h gzipstream.h - inkjar.h inkscapestream.h resource.h stringstream.h diff --git a/src/io/Makefile_insert b/src/io/Makefile_insert deleted file mode 100644 index 35119ec7b..000000000 --- a/src/io/Makefile_insert +++ /dev/null @@ -1,26 +0,0 @@ -## Makefile.am fragment sourced by src/Makefile.am. - -ink_common_sources += \ - io/base64stream.h \ - io/base64stream.cpp \ - io/bufferstream.cpp \ - io/bufferstream.h \ - io/gzipstream.cpp \ - io/gzipstream.h \ - io/inkjar.cpp \ - io/inkjar.h \ - io/inkscapestream.cpp \ - io/inkscapestream.h \ - io/resource.cpp \ - io/resource.h \ - io/stringstream.cpp \ - io/stringstream.h \ - io/sys.h \ - io/sys.cpp \ - io/uristream.cpp \ - io/uristream.h \ - io/xsltstream.cpp \ - io/xsltstream.h - -#io_streamtest_SOURCES = io/streamtest.cpp -#io_streamtest_LDADD = $(all_libs) diff --git a/src/io/gzipstream.cpp b/src/io/gzipstream.cpp index 380c42411..330191ecd 100644 --- a/src/io/gzipstream.cpp +++ b/src/io/gzipstream.cpp @@ -171,12 +171,12 @@ bool GzipInputStream::load() } srcLen = inputBuf.size(); - srcBuf = new Byte [srcLen]; + srcBuf = new (std::nothrow) Byte [srcLen]; if (!srcBuf) { return false; } - outputBuf = new unsigned char [OUT_SIZE]; + outputBuf = new (std::nothrow) unsigned char [OUT_SIZE]; if ( !outputBuf ) { delete[] srcBuf; srcBuf = NULL; @@ -386,14 +386,14 @@ void GzipOutputStream::flush() } uLong srclen = inputBuf.size(); - Bytef *srcbuf = new Bytef [srclen]; + Bytef *srcbuf = new (std::nothrow) Bytef [srclen]; if (!srcbuf) { return; } uLong destlen = srclen; - Bytef *destbuf = new Bytef [(destlen + (srclen/100) + 13)]; + Bytef *destbuf = new (std::nothrow) Bytef [(destlen + (srclen/100) + 13)]; if (!destbuf) { delete[] srcbuf; diff --git a/src/io/inkjar.cpp b/src/io/inkjar.cpp deleted file mode 100644 index 345455c4a..000000000 --- a/src/io/inkjar.cpp +++ /dev/null @@ -1,552 +0,0 @@ -/* - * Copyright (C) 1999, 2000 Bryan Burns - * Copyright (C) 2004 Johan Ceuppens - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -/* - * TODO/FIXME: - * - configure #ifdefs should be enabled - * - move to cstdlib instead of stdlib.h etc. - * - remove exit functions - * - move to clean C++ code - * - windowsify - * - remove a few g_free/g_mallocs - * - unseekable files - * - move to LGPL by rewriting macros - * - crcs for compressed files - * - put in eof - */ - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - - -//#ifdef STDC_HEADERS -//#endif - -//#ifdef HAVE_UNISTD_H -//#endif - -//#ifdef HAVE_SYS_PARAM_H -//#else -//#define MAXPATHLEN 1024 -//#endif - -//#ifdef HAVE_DIRENT_H -//#endif - -//#ifdef HAVE_FCNTL_H -#include <fcntl.h> -//#endif - -#include <cstring> -#include <string> -#include <cstdlib> -#include <glib.h> -#include <zlib.h> - -#include "inkjar.h" - -#include <fstream> -#ifdef WORDS_BIGENDIAN - -#define L2BI(l) ((l & 0xff000000) >> 24) | \ -((l & 0x00ff0000) >> 8) | \ -((l & 0x0000ff00) << 8) | \ -((l & 0x000000ff) << 24); - -#define L2BS(l) ((l & 0xff00) >> 8) | ((l & 0x00ff) << 8); - -#endif - -namespace Inkjar { - -JarFile::JarFile(gchar const*new_filename) : - _file(NULL), - _filename(g_strdup(new_filename)), - _last_filename(NULL) -{} - -//fixme: the following should probably just return a const gchar* and not -// use strdup -gchar *JarFile::get_last_filename() const -{ - return (_last_filename != NULL ? g_strdup(_last_filename) : NULL); -} - -JarFile::~JarFile() -{ - if (_filename != NULL) - g_free(_filename); - if (_last_filename != NULL) - g_free(_last_filename); -} - -bool JarFile::init_inflation() -{ - memset(&_zs, 0, sizeof(z_stream)); - - _zs.zalloc = Z_NULL; - _zs.zfree = Z_NULL; - _zs.opaque = Z_NULL; - - if(inflateInit2(&_zs, -15) != Z_OK) { - fprintf(stderr,"error initializing inflation!\n"); - return false; - } - - return true; -} - -bool JarFile::open() -{ - if (_file != NULL) { - fclose(_file); - } - if ((_file = fopen(_filename, "r")) == NULL) { - fprintf(stderr, "open failed.\n"); - return false; - } - if (!init_inflation()) { - return false; - } - else { - return true; - } -} - -bool JarFile::close() -{ - if (_file != NULL && (fclose(_file) == 0)) { - inflateEnd(&_zs); - return true; - } - return false; -} - -bool JarFile::read_signature() -{ - guint8 *bytes = (guint8 *)g_malloc(sizeof(guint8) * 4); - if (!read(bytes, 4)) { - g_free(bytes); - return false; - } - - guint32 signature = UNPACK_UB4(bytes, 0); - g_free(bytes); - -#ifdef DEBUG - std::printf("signature is %x\n", signature); -#endif - - if (signature == 0x08074b50) { - //skip data descriptor - bytes = (guint8 *)g_malloc(sizeof(guint8) * 12); - if (!read(bytes, 12)) { - g_free(bytes); - return false; - } else { - g_free(bytes); - } - } else if (signature == 0x02014b50 || signature == 0x04034b50) { - return true; - } else { - return false; - } - return false; -} - -guint32 JarFile::get_crc(guint8 *bytes, guint16 flags) -{ - guint32 crc = 0; - //no data descriptor - if (!(flags & 0x0008)) { - crc = UNPACK_UB4(bytes, LOC_CRC); - -#ifdef DEBUG - std::printf("CRC from file is %x\n", crc); -#endif - } - - return crc; -} - -guint8 *JarFile::read_filename(guint16 filename_length) -{ - guint8 *filename = (guint8 *)g_malloc(sizeof(guint8) - * (filename_length+1)); - if (!read(filename, filename_length)) { - g_free(filename); - return NULL; - } - filename[filename_length] = '\0'; - -#ifdef DEBUG - std::printf("Filename is %s\n", filename); -#endif - - return filename; -} - -bool JarFile::check_compression_method(guint16 method, guint16 flags) -{ - return !(method != 8 && flags & 0x0008); -} - -GByteArray *JarFile::get_next_file_contents() -{ - guint8 *bytes; - GByteArray *gba = g_byte_array_new(); - - read_signature(); - - //get compressed size - bytes = (guint8 *)g_malloc(sizeof(guint8) * 30); - if (!read(bytes+4, 26)) { - g_free(bytes); - return NULL; - } - guint32 compressed_size = UNPACK_UB4(bytes, LOC_CSIZE); - guint16 filename_length = UNPACK_UB2(bytes, LOC_FNLEN); - guint16 eflen = UNPACK_UB2(bytes, LOC_EFLEN); - guint16 flags = UNPACK_UB2(bytes, LOC_EXTRA); - guint16 method = UNPACK_UB2(bytes, LOC_COMP); - - if (filename_length == 0) { - g_byte_array_free(gba, TRUE); - if (_last_filename != NULL) - g_free(_last_filename); - _last_filename = NULL; - g_free(bytes); - return NULL; - } - - -#ifdef DEBUG - std::printf("Compressed size is %u\n", compressed_size); - std::printf("Filename length is %hu\n", filename_length); - std::printf("Extra field length is %hu\n", eflen); - std::printf("Flags are %#hx\n", flags); - std::printf("Compression method is %#hx\n", method); -#endif - - guint32 crc = get_crc(bytes, flags); - - gchar *filename = (gchar *)read_filename(filename_length); - g_free(bytes); - - if (filename == NULL) - return NULL; - - if (_last_filename != NULL) - g_free(_last_filename); - _last_filename = filename; - - //check if this is a directory and skip - - char *c_ptr; - if ((c_ptr = std::strrchr(filename, '/')) != NULL) { - if (*(++c_ptr) == '\0') { - return NULL; - } - } - - if (!check_compression_method(method, flags)) { - std::fprintf(stderr, "error in jar file\n"); - return NULL; - } - - if (method == 8 || flags & 0x0008) { - unsigned int file_length = 0;//uncompressed file length - fseek(_file, eflen, SEEK_CUR); - guint8 *file_data = get_compressed_file(compressed_size, file_length, - crc, flags); - if (file_data == NULL) { - g_byte_array_free(gba, FALSE); - return NULL; - } - g_byte_array_append(gba, file_data, file_length); - } else if (method == 0) { - guint8 *file_data = get_uncompressed_file(compressed_size, crc, - eflen, flags); - - if (file_data == NULL) { - g_byte_array_free(gba, TRUE); - return NULL; - } - g_byte_array_append(gba, file_data, compressed_size); - } else { - fseek(_file, compressed_size+eflen, SEEK_CUR); - g_byte_array_free(gba, FALSE); - return NULL; - } - - - return gba; -} - -guint8 *JarFile::get_uncompressed_file(guint32 compressed_size, guint32 crc, - guint16 eflen, guint16 flags) -{ - GByteArray *gba = g_byte_array_new(); - unsigned int out_a = 0; - unsigned int in_a = compressed_size; - guint8 *bytes; - guint32 crc2 = 0; - - crc2 = crc32(crc2, NULL, 0); - - bytes = (guint8 *)g_malloc(sizeof(guint8) * RDSZ); - while(out_a < compressed_size){ - unsigned int nbytes = (in_a > RDSZ ? RDSZ : in_a); - - if (!(nbytes = read(bytes, nbytes))) { - g_free(bytes); - return NULL; - } - - crc2 = crc32(crc2, (Bytef*)bytes, nbytes); - - g_byte_array_append (gba, bytes, nbytes); - out_a += nbytes; - in_a -= nbytes; - -#ifdef DEBUG - std::printf("%u bytes written\n", out_a); -#endif - } - fseek(_file, eflen, SEEK_CUR); - g_free(bytes); - - if (!check_crc(crc, crc2, flags)) { - bytes = gba->data; - g_byte_array_free(gba, FALSE);//FALSE argument does not free actual data - return NULL; - } - - return bytes; -} - -int JarFile::read(guint8 *buf, unsigned int count) -{ - size_t nbytes; - if ((nbytes = fread(buf, 1, count, _file)) != count) { - fprintf(stderr, "read error\n"); - exit(1); - return 0; - } - return nbytes; -} - -/* FIXME: this could probably use ZlibBuffer */ -guint8 *JarFile::get_compressed_file(guint32 compressed_size, - unsigned int& file_length, - guint32 oldcrc, guint16 flags) -{ - if (compressed_size == 0) - return NULL; - - guint8 in_buffer[RDSZ]; - guint8 out_buffer[RDSZ]; - size_t nbytes; - unsigned int leftover_in = compressed_size; - GByteArray *gba = g_byte_array_new(); - - _zs.avail_in = 0; - guint32 crc = crc32(0, Z_NULL, 0); - - do { - if (!_zs.avail_in) { - nbytes = fread(in_buffer, 1, - (leftover_in < RDSZ ? leftover_in : RDSZ), _file); - - if(ferror(_file) != 0) { - fprintf(stderr, "jarfile read error"); - } - - _zs.avail_in = nbytes; - _zs.next_in = in_buffer; - crc = crc32(crc, in_buffer, _zs.avail_in); - leftover_in -= RDSZ; - } - _zs.next_out = out_buffer; - _zs.avail_out = RDSZ; - - int ret = inflate(&_zs, Z_NO_FLUSH); - if (RDSZ != _zs.avail_out) { - unsigned int tmp_len = RDSZ - _zs.avail_out; - guint8 *tmp_bytes = (guint8 *)g_malloc(sizeof(guint8) - * tmp_len); - memcpy(tmp_bytes, out_buffer, tmp_len); - g_byte_array_append(gba, tmp_bytes, tmp_len); - } - - if (ret == Z_STREAM_END) { - break; - } - if (ret != Z_OK) - std::printf("decompression error %d\n", ret); - } while (_zs.total_in < compressed_size); - - file_length = _zs.total_out; -#ifdef DEBUG - std::printf("done inflating\n"); - std::printf("%d bytes left over\n", _zs.avail_in); - std::printf("CRC is %x\n", crc); -#endif - - guint8 *ret_bytes; - if (check_crc(oldcrc, crc, flags) && gba->len > 0) - ret_bytes = gba->data; - else - ret_bytes = NULL; - g_byte_array_free(gba, FALSE); - - inflateReset(&_zs); - return ret_bytes; -} - -bool JarFile::check_crc(guint32 oldcrc, guint32 crc, guint16 flags) -{ - //fixme: does not work yet - - if(flags & 0x0008) { - guint8 *bytes = (guint8 *)g_malloc(sizeof(guint8) * 16); - if (!read(bytes, 16)) { - g_free(bytes); - return false; - } - - guint32 signature = UNPACK_UB4(bytes, 0); - g_free(bytes); - if(signature != 0x08074b50) { - fprintf(stderr, "missing data descriptor!\n"); - } - - crc = UNPACK_UB4(bytes, 4); - - } - if (oldcrc != crc) { -#ifdef DEBUG - std::fprintf(stderr, "Error! CRCs do not match! Got %x, expected %x\n", - oldcrc, crc); -#endif - } - return true; -} - -JarFile::JarFile(JarFile const& rhs) -{ - *this = rhs; -} - -JarFile& JarFile::operator=(JarFile const& rhs) -{ - if (this == &rhs) - return *this; - - _zs = rhs._zs;//fixme - if (_filename == NULL) - _filename = NULL; - else - _filename = g_strdup(rhs._filename); - if (_last_filename == NULL) - _last_filename = NULL; - else - _last_filename = g_strdup(rhs._last_filename); - _file = rhs._file; - - return *this; -} - - -///////////////////////// -// JarFileReader // -///////////////////////// - -GByteArray *JarFileReader::get_next_file() -{ - if (_state == CLOSED) { - _jarfile.open(); - _state = OPEN; - } - - return _jarfile.get_next_file_contents(); -} - -JarFileReader& JarFileReader::operator=(JarFileReader const& rhs) -{ - if (&rhs == this) - return *this; - - _jarfile = rhs._jarfile; - _state = rhs._state; - - return *this; -} - -/* - * If the filename gets reset, a jarfile object gets generated again, - * ready to be opened for reading. - */ -void JarFileReader::set_filename(gchar const *new_filename) -{ - _jarfile.close(); - _jarfile = JarFile(new_filename); -} - -void JarFileReader::set_jarfile(JarFile const& new_jarfile) -{ - _jarfile = new_jarfile; -} - -JarFileReader::JarFileReader(JarFileReader const& rhs) -{ - *this = rhs; -} - -} // namespace Inkjar - - -#if 0 //testing code -#include "jar.h" -/* - * This program writes all the files from a jarfile to stdout and inflates - * where needed. - */ -int main(int argc, char *argv[]) -{ - gchar *filename; - if (argc < 2) { - filename = "./ide.jar\0"; - } else { - filename = argv[1]; - } - - Inkjar::JarFileReader jar_file_reader(filename); - - for (;;) { - GByteArray *gba = jar_file_reader.get_next_file(); - if (gba == NULL) { - char *c_ptr; - gchar *last_filename = jar_file_reader.get_last_filename(); - if (last_filename == NULL) - break; - if ((c_ptr = std::strrchr(last_filename, '/')) != NULL) { - if (*(++c_ptr) == '\0') { - g_free(last_filename); - continue; - } - } - } else if (gba->len > 0) - ::write(1, gba->data, gba->len); - else - break; - } - return 0; -} -#endif -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/src/io/inkjar.h b/src/io/inkjar.h deleted file mode 100644 index d7de9ff4a..000000000 --- a/src/io/inkjar.h +++ /dev/null @@ -1,162 +0,0 @@ -#ifndef __INKJAR_JAR_H_ -#define __INKJAR_JAR_H_ -/* - * Copyright (C) 1999 Bryan Burns - * Copyright (C) 2004 Johan Ceuppens - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#if defined(WIN32) || defined(__WIN32__) -# include <zlib.h> -#endif - -#ifdef HAVE_ZLIB_H -# include <zlib.h> -#endif - -#include <stdint.h> - -#include <glib.h> -#include <cstdio> - -namespace Inkjar { - -unsigned const RDSZ = 4096; - -//#define DEBUG 1 //uncommment for debug messages - -enum JarFileReaderState {CLOSED, OPEN}; - -//fixme: The following will be removed -typedef uint8_t ub1; -typedef uint16_t ub2; -typedef uint32_t ub4; - -#define LOC_EXTRA 6 /* extra bytes */ -#define LOC_COMP 8 /* compression method */ -#define LOC_MODTIME 10 /* last modification time */ -#define LOC_MODDATE 12 /* last modification date */ -#define LOC_CRC 14 /* CRC */ -#define LOC_CSIZE 18 /* compressed size */ -#define LOC_USIZE 22 /* uncompressed size */ -#define LOC_FNLEN 26 /* filename length */ -#define LOC_EFLEN 28 /* extra-field length */ - -#define CEN_COMP 10 /* compression method */ -#define CEN_MODTIME 12 -#define CEN_MODDATE 14 -#define CEN_CRC 16 -#define CEN_CSIZE 20 -#define CEN_USIZE 24 -#define CEN_FNLEN 28 -#define CEN_EFLEN 30 -#define CEN_COMLEN 32 -#define CEN_OFFSET 42 - - -/* macros */ -#define PACK_UB4(d, o, v) d[o] = (ub1)((v) & 0x000000ff); \ - d[o + 1] = (ub1)(((v) & 0x0000ff00) >> 8); \ - d[o + 2] = (ub1)(((v) & 0x00ff0000) >> 16); \ - d[o + 3] = (ub1)(((v) & 0xff000000) >> 24) - -#define PACK_UB2(d, o, v) d[o] = (ub1)((v) & 0x00ff); \ - d[o + 1] = (ub1)(((v) & 0xff00) >> 8) - -#define UNPACK_UB4(s, o) (ub4)s[o] + (((ub4)s[o + 1]) << 8) +\ - (((ub4)s[o + 2]) << 16) + (((ub4)s[o + 3]) << 24) - -#define UNPACK_UB2(s, o) (ub2)s[o] + (((ub2)s[o + 1]) << 8) - - - -/* - * JarFile: - * - * This is a wrapper class for canonical jarfile functions like reading, - * writing, seeking etc. JarFile is a dumb class with no state information. - * - * All memory allocations are done with g_malloc. - */ -class JarFile { -public: - - JarFile() : _file(NULL), _filename(NULL), _last_filename(NULL) {} - virtual ~JarFile(); - JarFile(gchar const *new_filename); - - GByteArray *get_next_file_contents(); - gchar *get_last_filename() const; - bool open(); - bool close(); - int read(guint8 *buf, unsigned int count); - - JarFile(JarFile const &rhs); - JarFile &operator=(JarFile const &rhs); - -private: - - FILE *_file; // File descriptor - gchar *_filename; - z_stream _zs; - gchar *_last_filename; - - bool init_inflation(); - bool read_signature(); - guint32 get_crc(guint8 *bytes, guint16 flags); - guint8 *read_filename(guint16 filename_length); - bool check_compression_method(guint16 method, guint16 flags); - bool check_crc(guint32 oldcrc, guint32 crc, guint16 flags); - guint8 *get_compressed_file(guint32 compressed_size, - unsigned int &file_length, - guint32 oldcrc, guint16 flags); - guint8 *get_uncompressed_file(guint32 compressed_szie, guint32 crc, - guint16 eflen, guint16 flags); -}; // class JarFile - - -/* - * JarFileReader: - * - * This provides some smarter functions for operating on a jarfile object - * It should be able to grep for files or return the contents of a specific - * file. - */ - -class JarFileReader { -public: - - JarFileReader(gchar const *new_filename) - : _state(CLOSED), _jarfile(new_filename) {} - JarFileReader() : _state(CLOSED) {} - virtual ~JarFileReader() { if (_state == OPEN) _jarfile.close(); } - //fixme return types are incorrect - GByteArray *get_next_file();//fixme clean up return type - void set_filename(gchar const *new_filename); - void set_jarfile(JarFile const &new_jarfile); - gchar *get_last_filename() const { return _jarfile.get_last_filename(); }; - JarFileReader(JarFileReader const &rhs); - JarFileReader &operator=(JarFileReader const &rhs); -private: - JarFileReaderState _state; - JarFile _jarfile; - -}; // class JarFileReader - -} // namespace Inkjar -#endif // header guard - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : diff --git a/src/knot-holder-entity.cpp b/src/knot-holder-entity.cpp index 173025920..95b135be0 100644 --- a/src/knot-holder-entity.cpp +++ b/src/knot-holder-entity.cpp @@ -25,8 +25,6 @@ #include "snap.h" #include "desktop.h" #include "sp-namedview.h" -#include <2geom/affine.h> -#include <2geom/transforms.h> int KnotHolderEntity::counter = 0; diff --git a/src/knot.cpp b/src/knot.cpp index bfc0c4f0b..b57c938c3 100644 --- a/src/knot.cpp +++ b/src/knot.cpp @@ -13,7 +13,6 @@ */ #ifdef HAVE_CONFIG_H -# include <config.h> #endif #include <gdk/gdkkeysyms.h> #include <glibmm/i18n.h> @@ -24,7 +23,6 @@ #include "knot-ptr.h" #include "document.h" #include "document-undo.h" -#include "preferences.h" #include "message-stack.h" #include "message-context.h" #include "ui/tools-switch.h" @@ -126,21 +124,14 @@ SPKnot::SPKnot(SPDesktop *desktop, gchar const *tip) } SPKnot::~SPKnot() { -#if GTK_CHECK_VERSION(3,0,0) - GdkDisplay *display = gdk_display_get_default(); - GdkDeviceManager *dm = gdk_display_get_device_manager(display); - GdkDevice *device = gdk_device_manager_get_client_pointer(dm); + auto display = gdk_display_get_default(); + auto dm = gdk_display_get_device_manager(display); + auto device = gdk_device_manager_get_client_pointer(dm); if ((this->flags & SP_KNOT_GRABBED) && gdk_display_device_is_grabbed(display, device)) { // This happens e.g. when deleting a node in node tool while dragging it gdk_device_ungrab(device, GDK_CURRENT_TIME); } -#else - if ((this->flags & SP_KNOT_GRABBED) && gdk_pointer_is_grabbed ()) { - // This happens e.g. when deleting a node in node tool while dragging it - gdk_pointer_ungrab (GDK_CURRENT_TIME); - } -#endif if (this->_event_handler_id > 0) { g_signal_handler_disconnect(G_OBJECT (this->item), this->_event_handler_id); @@ -154,11 +145,7 @@ SPKnot::~SPKnot() { for (gint i = 0; i < SP_KNOT_VISIBLE_STATES; i++) { if (this->cursor[i]) { -#if GTK_CHECK_VERSION(3,0,0) g_object_unref(this->cursor[i]); -#else - gdk_cursor_unref(this->cursor[i]); -#endif this->cursor[i] = NULL; } } @@ -525,57 +512,33 @@ void SPKnot::setImage(guchar* normal, guchar* mouseover, guchar* dragging) { void SPKnot::setCursor(GdkCursor* normal, GdkCursor* mouseover, GdkCursor* dragging) { if (cursor[SP_KNOT_STATE_NORMAL]) { -#if GTK_CHECK_VERSION(3,0,0) g_object_unref(cursor[SP_KNOT_STATE_NORMAL]); -#else - gdk_cursor_unref(cursor[SP_KNOT_STATE_NORMAL]); -#endif } cursor[SP_KNOT_STATE_NORMAL] = normal; if (normal) { -#if GTK_CHECK_VERSION(3,0,0) g_object_ref(normal); -#else - gdk_cursor_ref(normal); -#endif } if (cursor[SP_KNOT_STATE_MOUSEOVER]) { -#if GTK_CHECK_VERSION(3,0,0) g_object_unref(cursor[SP_KNOT_STATE_MOUSEOVER]); -#else - gdk_cursor_unref(cursor[SP_KNOT_STATE_MOUSEOVER]); -#endif } cursor[SP_KNOT_STATE_MOUSEOVER] = mouseover; if (mouseover) { -#if GTK_CHECK_VERSION(3,0,0) g_object_ref(mouseover); -#else - gdk_cursor_ref(mouseover); -#endif } if (cursor[SP_KNOT_STATE_DRAGGING]) { -#if GTK_CHECK_VERSION(3,0,0) g_object_unref(cursor[SP_KNOT_STATE_DRAGGING]); -#else - gdk_cursor_unref(cursor[SP_KNOT_STATE_DRAGGING]); -#endif } cursor[SP_KNOT_STATE_DRAGGING] = dragging; if (dragging) { -#if GTK_CHECK_VERSION(3,0,0) g_object_ref(dragging); -#else - gdk_cursor_ref(dragging); -#endif } } diff --git a/src/knotholder.cpp b/src/knotholder.cpp index a2d1cf017..98348a59f 100644 --- a/src/knotholder.cpp +++ b/src/knotholder.cpp @@ -22,7 +22,6 @@ #include "knotholder.h" #include "knot-holder-entity.h" #include "ui/tools/rect-tool.h" -#include "sp-rect.h" #include "ui/tools/arc-tool.h" #include "sp-ellipse.h" #include "ui/tools/tweak-tool.h" @@ -37,12 +36,9 @@ #include "live_effects/effect.h" #include "desktop.h" #include "display/sp-canvas.h" -#include "display/sp-canvas-item.h" #include "verbs.h" #include "ui/control-manager.h" -#include "xml/repr.h" // for debugging only - using Inkscape::ControlManager; using Inkscape::DocumentUndo; diff --git a/src/layer-fns.cpp b/src/layer-fns.cpp index 3e794a0a4..030ebc07e 100644 --- a/src/layer-fns.cpp +++ b/src/layer-fns.cpp @@ -36,11 +36,9 @@ bool is_layer(SPObject &object) { * @returns NULL if there are no further layers under a parent */ SPObject *next_sibling_layer(SPObject *layer) { - using std::find_if; - - return find_if<SPObject::SiblingIterator>( - layer->getNext(), NULL, &is_layer - ); + SPObject::ChildrenList &list = layer->parent->children; + auto l = std::find_if(++list.iterator_to(*layer), list.end(), &is_layer); + return l != list.end() ? &*l : nullptr; } /** Finds the previous sibling layer for a \a layer @@ -50,11 +48,9 @@ SPObject *next_sibling_layer(SPObject *layer) { SPObject *previous_sibling_layer(SPObject *layer) { using Inkscape::Algorithms::find_last_if; - SPObject *sibling(find_last_if<SPObject::SiblingIterator>( - layer->parent->firstChild(), layer, &is_layer - )); - - return ( sibling != layer ) ? sibling : NULL; + SPObject::ChildrenList &list = layer->parent->children; + auto l = find_last_if(list.begin(), list.iterator_to(*layer), &is_layer); + return l != list.iterator_to(*layer) ? &*(l) : nullptr; } /** Finds the first child of a \a layer @@ -62,16 +58,15 @@ SPObject *previous_sibling_layer(SPObject *layer) { * @returns NULL if layer has no sublayers */ SPObject *first_descendant_layer(SPObject *layer) { - using std::find_if; - - SPObject *first_descendant=NULL; - while (layer) { - layer = find_if<SPObject::SiblingIterator>( - layer->firstChild(), NULL, &is_layer - ); - if (layer) { + SPObject *first_descendant = nullptr; + while (true) { + auto tmp = std::find_if(layer->children.begin(), layer->children.end(), &is_layer); + if (tmp != layer->children.end()) { first_descendant = layer; + } else { + break; } + layer = &*tmp; } return first_descendant; @@ -84,9 +79,8 @@ SPObject *first_descendant_layer(SPObject *layer) { SPObject *last_child_layer(SPObject *layer) { using Inkscape::Algorithms::find_last_if; - return find_last_if<SPObject::SiblingIterator>( - layer->firstChild(), NULL, &is_layer - ); + auto l = find_last_if(layer->children.begin(), layer->children.end(), &is_layer); + return l != layer->children.end() ? &*l : nullptr; } SPObject *last_elder_layer(SPObject *root, SPObject *layer) { diff --git a/src/layer-manager.cpp b/src/layer-manager.cpp index 19c4b890c..3a6cce99c 100644 --- a/src/layer-manager.cpp +++ b/src/layer-manager.cpp @@ -17,16 +17,10 @@ #include "desktop.h" #include "layer-manager.h" -#include "preferences.h" -#include "ui/view/view.h" #include "selection.h" -#include "sp-object.h" #include "sp-item-group.h" -#include "xml/node.h" #include "xml/node-observer.h" #include "util/format.h" -// #include "debug/event-tracker.h" -// #include "debug/simple-event.h" namespace Inkscape { diff --git a/src/layer-model.cpp b/src/layer-model.cpp index 6833852ad..b941e43b1 100644 --- a/src/layer-model.cpp +++ b/src/layer-model.cpp @@ -22,7 +22,7 @@ */ #ifdef HAVE_CONFIG_H -# include "config.h" +#include <config.h> #endif #include "document.h" @@ -32,11 +32,7 @@ #include "sp-defs.h" #include "sp-item.h" #include "sp-item-group.h" -#include "sp-object.h" #include "sp-root.h" -#include <glib.h> -#include <glibmm/i18n.h> -#include <sigc++/functors/ptr_fun.h> // Callbacks static void _layer_activated(SPObject *layer, Inkscape::LayerModel *layer_model); diff --git a/src/libavoid/Makefile_insert b/src/libavoid/Makefile_insert deleted file mode 100644 index 3a9b97cef..000000000 --- a/src/libavoid/Makefile_insert +++ /dev/null @@ -1,37 +0,0 @@ -## Makefile.am fragment sourced by src/Makefile.am. - -libavoid/all: libavoid/libavoid.a - -libavoid/clean: - rm -f libavoid/libavoid.a $(libavoid_libavoid_a_OBJECTS) - -libavoid_libavoid_a_SOURCES = \ - libavoid/assertions.h \ - libavoid/connector.cpp \ - libavoid/connector.h \ - libavoid/debug.h \ - libavoid/geometry.cpp \ - libavoid/geometry.h \ - libavoid/geomtypes.cpp \ - libavoid/geomtypes.h \ - libavoid/graph.cpp \ - libavoid/graph.h \ - libavoid/makepath.cpp \ - libavoid/makepath.h \ - libavoid/orthogonal.cpp \ - libavoid/orthogonal.h \ - libavoid/vpsc.cpp \ - libavoid/vpsc.h \ - libavoid/router.cpp \ - libavoid/router.h \ - libavoid/shape.cpp \ - libavoid/shape.h \ - libavoid/timer.cpp \ - libavoid/timer.h \ - libavoid/vertices.cpp \ - libavoid/vertices.h \ - libavoid/visibility.cpp \ - libavoid/visibility.h \ - libavoid/viscluster.cpp \ - libavoid/viscluster.h \ - libavoid/libavoid.h diff --git a/src/libcola/Makefile_insert b/src/libcola/Makefile_insert deleted file mode 100644 index dc032a289..000000000 --- a/src/libcola/Makefile_insert +++ /dev/null @@ -1,18 +0,0 @@ -## Makefile.am fragment sourced by src/Makefile.am. - -libcola/all: libcola.a - -libcola/clean: - rm -f libcola/libcola.a $(libcola_libcola_a_OBJECTS) - -libcola_libcola_a_SOURCES = libcola/cola.h\ - libcola/cola.cpp\ - libcola/conjugate_gradient.cpp\ - libcola/conjugate_gradient.h\ - libcola/gradient_projection.cpp\ - libcola/gradient_projection.h\ - libcola/shortest_paths.cpp\ - libcola/shortest_paths.h\ - libcola/straightener.h\ - libcola/straightener.cpp\ - libcola/connected_components.cpp diff --git a/src/libcroco/Makefile_insert b/src/libcroco/Makefile_insert deleted file mode 100644 index 97ed49ee8..000000000 --- a/src/libcroco/Makefile_insert +++ /dev/null @@ -1,64 +0,0 @@ -## Makefile.am fragment sourced by src/Makefile.am. - -libcroco/all: libcroco/libcroco.a - -libcroco/clean: - rm -f libcroco/libcroco.a $(libcroco_libcroco_a_OBJECTS) - -libcroco_libcroco_a_SOURCES = \ - libcroco/cr-utils.c \ - libcroco/cr-utils.h \ - libcroco/cr-input.c \ - libcroco/cr-input.h \ - libcroco/cr-enc-handler.c \ - libcroco/cr-enc-handler.h \ - libcroco/cr-num.c \ - libcroco/cr-num.h \ - libcroco/cr-rgb.c \ - libcroco/cr-rgb.h \ - libcroco/cr-token.c \ - libcroco/cr-token.h \ - libcroco/cr-tknzr.c \ - libcroco/cr-tknzr.h \ - libcroco/cr-term.c \ - libcroco/cr-term.h \ - libcroco/cr-attr-sel.c \ - libcroco/cr-attr-sel.h \ - libcroco/cr-pseudo.c \ - libcroco/cr-pseudo.h \ - libcroco/cr-additional-sel.c \ - libcroco/cr-additional-sel.h \ - libcroco/cr-simple-sel.c \ - libcroco/cr-simple-sel.h \ - libcroco/cr-selector.c \ - libcroco/cr-selector.h \ - libcroco/cr-doc-handler.c \ - libcroco/cr-doc-handler.h \ - libcroco/cr-parser.c \ - libcroco/cr-parser.h \ - libcroco/cr-declaration.c \ - libcroco/cr-declaration.h \ - libcroco/cr-statement.c \ - libcroco/cr-statement.h \ - libcroco/cr-stylesheet.c \ - libcroco/cr-stylesheet.h \ - libcroco/cr-cascade.c \ - libcroco/cr-cascade.h \ - libcroco/cr-om-parser.c \ - libcroco/cr-om-parser.h \ - libcroco/cr-style.c \ - libcroco/cr-style.h \ - libcroco/cr-libxml-node-iface.c \ - libcroco/cr-libxml-node-iface.h \ - libcroco/cr-node-iface.h \ - libcroco/cr-sel-eng.c \ - libcroco/cr-sel-eng.h \ - libcroco/cr-fonts.c \ - libcroco/cr-fonts.h \ - libcroco/cr-prop-list.c \ - libcroco/cr-prop-list.h \ - libcroco/cr-parsing-location.c \ - libcroco/cr-parsing-location.h \ - libcroco/cr-string.c \ - libcroco/cr-string.h \ - libcroco/libcroco.h diff --git a/src/libdepixelize/Makefile_insert b/src/libdepixelize/Makefile_insert deleted file mode 100644 index 8aed7244f..000000000 --- a/src/libdepixelize/Makefile_insert +++ /dev/null @@ -1,22 +0,0 @@ -## Makefile.am fragment sourced by src/Makefile.am. - -libdepixelize/all: libdepixelize/libdepixelize.a - -libdepixelize/clean: - rm -f libdepixelize/libdepixelize.a $(libdepixelize_libdepixelize_a_OBJECTS) - -libdepixelize_libdepixelize_a_SOURCES = \ - libdepixelize/kopftracer2011.cpp \ - libdepixelize/kopftracer2011.h \ - libdepixelize/splines.h \ - libdepixelize/priv/branchless.h \ - libdepixelize/priv/colorspace.h \ - libdepixelize/priv/curvature.h \ - libdepixelize/priv/homogeneoussplines.h \ - libdepixelize/priv/integral.h \ - libdepixelize/priv/iterator.h \ - libdepixelize/priv/optimization-kopf2011.h \ - libdepixelize/priv/pixelgraph.h \ - libdepixelize/priv/point.h \ - libdepixelize/priv/simplifiedvoronoi.h \ - libdepixelize/priv/splines-kopf2011.h diff --git a/src/libgdl/CMakeLists.txt b/src/libgdl/CMakeLists.txt deleted file mode 100644 index a452320f7..000000000 --- a/src/libgdl/CMakeLists.txt +++ /dev/null @@ -1,50 +0,0 @@ -if (NOT "${WITH_EXT_GDL}") - - set(libgdl_SRC - gdl-dock-bar.c - gdl-dock-item-button-image.c - gdl-dock-item-grip.c - gdl-dock-item.c - gdl-dock-master.c - gdl-dock-notebook.c - gdl-dock-object.c - gdl-dock-paned.c - gdl-dock-placeholder.c - gdl-dock-tablabel.c - gdl-dock.c - gdl-i18n.c - gdl-switcher.c - libgdlmarshal.c - libgdltypebuiltins.c - - - # ------- - # Headers - gdl-dock-bar.h - gdl-dock-item-button-image.h - gdl-dock-item-grip.h - gdl-dock-item.h - gdl-dock-master.h - gdl-dock-notebook.h - gdl-dock-object.h - gdl-dock-paned.h - gdl-dock-placeholder.h - gdl-dock-tablabel.h - gdl-dock.h - gdl-i18n.h - gdl-switcher.h - gdl.h - libgdlmarshal.h - libgdltypebuiltins.h - ) - - if(WIN32) - list(APPEND libgdl_SRC - gdl-win32.c - gdl-win32.h - ) - endif() - - add_inkscape_lib(gdl_LIB "${libgdl_SRC}") - -endif() diff --git a/src/libgdl/Makefile_insert b/src/libgdl/Makefile_insert deleted file mode 100644 index e4cab95fc..000000000 --- a/src/libgdl/Makefile_insert +++ /dev/null @@ -1,92 +0,0 @@ -## Makefile.am fragment sourced by src/Makefile.am. - -if WITH_EXT_GDL - -EXTRA_DIST += \ - libgdl/gdl-dock-object.h \ - libgdl/gdl-dock-master.h \ - libgdl/gdl-dock.h \ - libgdl/gdl-dock-item.h \ - libgdl/gdl-dock-notebook.h \ - libgdl/gdl-dock-paned.h \ - libgdl/gdl-dock-tablabel.h \ - libgdl/gdl-dock-placeholder.h \ - libgdl/gdl-dock-bar.h \ - libgdl/gdl-i18n.h \ - libgdl/gdl-i18n.c \ - libgdl/gdl-dock-object.c \ - libgdl/gdl-dock-master.c \ - libgdl/gdl-dock.c \ - libgdl/gdl-dock-item.c \ - libgdl/gdl-dock-item-button-image.c \ - libgdl/gdl-dock-item-button-image.h \ - libgdl/gdl-dock-item-grip.h \ - libgdl/gdl-dock-item-grip.c \ - libgdl/gdl-dock-notebook.c \ - libgdl/gdl-dock-paned.c \ - libgdl/gdl-dock-tablabel.c \ - libgdl/gdl-dock-placeholder.c \ - libgdl/gdl-dock-bar.c \ - libgdl/gdl-switcher.h \ - libgdl/gdl-switcher.c \ - libgdl/gdl-win32.h \ - libgdl/gdl-win32.c \ - libgdl/libgdltypebuiltins.h \ - libgdl/libgdltypebuiltins.c \ - libgdl/libgdlmarshal.h \ - libgdl/libgdlmarshal.c \ - libgdl/gdl.h - -else # WITH_EXT_GDL - -libgdl/all: libgdl/libgdl.a - -libgdl/clean: - rm -f libgdl/libgdl.a $(libgdl_gdl_a_OBJECTS) - -# Suppress some non-critical warnings for libgdl. We will drop our forked copy -# of GDL once we upgrade to Gtk+ 3 so it's more important to minimise the number -# of changes we make to GDL than to fix these minor issues in trunk. - -if CC_WNO_UNUSED_BUT_SET_VARIABLE_SUPPORTED -libgdl_libgdl_a_CFLAGS = -Wno-unused-parameter -Wno-sign-compare -Wno-unused-variable -Wno-unused-but-set-variable -Wno-missing-field-initializers $(AM_CFLAGS) -else -libgdl_libgdl_a_CFLAGS = -Wno-unused-parameter -Wno-sign-compare -Wno-unused-variable -Wno-missing-field-initializers $(AM_CFLAGS) -endif - -libgdl_libgdl_a_SOURCES = \ - libgdl/gdl-dock-object.h \ - libgdl/gdl-dock-master.h \ - libgdl/gdl-dock.h \ - libgdl/gdl-dock-item.h \ - libgdl/gdl-dock-notebook.h \ - libgdl/gdl-dock-paned.h \ - libgdl/gdl-dock-tablabel.h \ - libgdl/gdl-dock-placeholder.h \ - libgdl/gdl-dock-bar.h \ - libgdl/gdl-i18n.h \ - libgdl/gdl-i18n.c \ - libgdl/gdl-dock-object.c \ - libgdl/gdl-dock-master.c \ - libgdl/gdl-dock.c \ - libgdl/gdl-dock-item.c \ - libgdl/gdl-dock-item-button-image.c \ - libgdl/gdl-dock-item-button-image.h \ - libgdl/gdl-dock-item-grip.h \ - libgdl/gdl-dock-item-grip.c \ - libgdl/gdl-dock-notebook.c \ - libgdl/gdl-dock-paned.c \ - libgdl/gdl-dock-tablabel.c \ - libgdl/gdl-dock-placeholder.c \ - libgdl/gdl-dock-bar.c \ - libgdl/gdl-switcher.h \ - libgdl/gdl-switcher.c \ - libgdl/gdl-win32.h \ - libgdl/gdl-win32.c \ - libgdl/libgdltypebuiltins.h \ - libgdl/libgdltypebuiltins.c \ - libgdl/libgdlmarshal.h \ - libgdl/libgdlmarshal.c \ - libgdl/gdl.h - -endif diff --git a/src/libgdl/README.gdl-dock b/src/libgdl/README.gdl-dock deleted file mode 100644 index 113926dbe..000000000 --- a/src/libgdl/README.gdl-dock +++ /dev/null @@ -1,184 +0,0 @@ -This file is meant to contain a little documentation about the GdlDock -and related widgets. It's incomplete and probably a bit out of date. -And it probably belongs to a doc/ subdirectory. - -Please send comments to the devtools list (gnome-devtools@gnome.org) -and report bugs to bugzilla (bugzilla.gnome.org). Also check the todo -list at the end of this document. - -Have fun, -Gustavo - - -Overview --------- - -The GdlDock is a hierarchical based docking widget. It is composed of -widgets derived from the abstract class GdlDockObject which defines -the basic interface for docking widgets on top of others. - -The toplevel entries for docks are GdlDock widgets, which in turn hold -a tree of GdlDockItem widgets. For the toplevel docks to be able to -interact with each other (when the user drags items from one place to -another) they're all kept in a user-invisible and automatic object -called the master. To participate in docking operations every -GdlDockObject must have the same master (the binding to the master is -done automatically). The master also keeps track of the manual items -(mostly those created with gdl_dock_*_new functions) which are in the -dock. - -Layout loading/saving service is provided by a separate object called -GdlDockLayout. Currently it stores information in XML format, but -another backend could be easily written. To keep the external XML -file in sync with the dock, monitor the "dirty" property of the layout -object and call gdl_dock_layout_save_to_file when this changes to -TRUE. No other action is required (the layout_changed is monitored by -the layout object for you now). - - -GdlDockObject -============= - -A DockObject has: - -- a master, which manages all the objects in a dock ring ("master" - property, construct only). - -- a name. If the object is manual the name can be used to recall the - object from any other object in the ring ("name" property). - -- a long, descriptive name ("long-name" property). - -A DockObject can be: - -- automatic or manual. If it's automatic it means the lifecycle of - the object is entirely managed by the dock master. If it's manual - in general means the user specified such object, and so it's not to - be destroyed automatically at any time. - -- frozen. In this case any call to reduce on the object has no - immediate effect. When the object is later thawn, any pending - reduce calls are made (maybe leading to the destruction of the - object). - -- attached or detached. In general for dock items, being attached - will mean the item has its widget->parent set. For docks it will - mean they belong to some dock master's ring. In general, automatic - objects which are detached will be destroyed (unless frozen). - -- bound to a master or free. In order to participate in dock - operations, each dock object must be bound to a dock master (which - is a separate, non-gui object). In general, bindings are treated - automatically by the object, and this is entirely true for automatic - objects. For manual objects, the master holds an additional - reference and has structures to store and recall them by nick names. - Normally, a manual object will only be destroyed when it's unbound - from the master. - -- simple or compound. This actually depends on the subclass of the - dock object. The difference is made so we can put restrictions in - how the objects are docked on top of another (e.g. you can't dock a - compound object inside a notebook). If you look at the whole - docking layout as a tree, simple objects are the leaves, while all - the interior nodes are compound. - -- reduced. This is only meaningful for compound objects. If the - number of contained items has decreased to one the compound type - object is no longer necessary to hold the child. In this case the - child is reattached to the object's parent. If the number of - contained items has reached zero, the object is detached and reduce - is called on its parent. For toplevel docks, the object is only - detached if it's automatic. In any case, the future of the object - itself depends on whether it's automatic or manual. - -- requested to possibly dock another object. Depending on the - type's behavior, the object can accept or reject this request. If - it accepts it, it should fill in some additional information - regarding how it will host the peer object. - -- asked to dock another object. Depending on the object's internal - structure and behavior two options can be taken: to dock the object - directly (e.g. a notebook docking another object); or to create an - automatic compound object which will be attached in place of the - actual object, and will host both the original object and the - requestor (e.g. a simple item docking another simple item, which - should create a paned/notebook). The type of the new object will be - decided by the original objet based on the docking position. - - -DETACHING: the action by which an object is unparented. The object is -then ready to be docked in some other place. Newly created objects -are always detached, except for toplevels (which are created attached -by default). An automatic object which is detached gets destroyed -afterwards, since its ref count drops to zero. Floating automatic -toplevels never reach a zero ref count when detached, since the -GtkWindow always keeps a reference to it (and the GtkWindow has a user -reference). That's why floating automatic toplevels are destroyed -when reduced. - -REDUCING: for compound objects, when the number of contained children -drops to one or zero, the container is no longer necessary. In this -case, the object is detached, and any remaining child is reattached to -the object's former parent. The limit for toplevels is one for -automatic objects and zero for manual (i.e. they can even be empty). -For simple (not compound) objects reducing doesn't make sense. - -UNBINDING: to participate in a dock ring, every object must be bound -to a master. The master connects to dock item signals and keeps a -list of bound toplevels. Additionally, a reference is kept for manual -objects (this is so the user doesn't need to keep track of them, but -can perform operations like hiding and such). - - - -GdlDock -======= - -- Properties: - - "floating" (gboolean, construct-only): whether the dock is floating in - its own window or not. - - "default-title" (gchar, read-write): title for new floating docks. - This property is proxied to the master, which truly holds it. - -The title for the floating docks is: the user supplied title -(GdlDockObject's long_name property) if it's set, the default title -(from the master) or an automatically generated title. - - -- Signals: - - "layout-changed": emitted when the user changed the layout of the - dock somehow. - - -TODO LIST -========= - -- Functionality for the item grip: provide a11y - -- Implement notebook tab reordering - -- Implement dock bands for toolbars and menus. - -- A dock-related thing is to build resizable toolbars (something like - the ones Windows have, where the buttons are reflowed according to - the space available). - -- Redesign paneds so they can hold more than two items and resize all - of them at once by using the handle (see if gimpdock does that). - -- Find a way to allow the merging of menu items to the item's popup - menu. Also, there should be a way for the master to insert some - menu items. - -- Bonobo UI synchronizer. - -- Item behavoirs: implement the ones missing and maybe think more of - them (e.g. positions where it's possible to dock the item, etc.) - -- Make a nicer dragbar for the items, with buttons for undocking, - closing, hidding, etc. (See sodipodi, kdevelop) - - diff --git a/src/libgdl/gdl-dock-bar.c b/src/libgdl/gdl-dock-bar.c deleted file mode 100644 index c1fe21872..000000000 --- a/src/libgdl/gdl-dock-bar.c +++ /dev/null @@ -1,1049 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This file is part of the GNOME Devtools Libraries. - * - * Copyright (C) 2003 Jeroen Zwartepoorte <jeroen@xs4all.nl> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include "gdl-i18n.h" -#include <stdlib.h> -#include <string.h> - -#include "gdl-dock.h" -#include "gdl-dock-master.h" -#include "gdl-dock-bar.h" -#include "libgdltypebuiltins.h" - -enum { - PROP_0, - PROP_MASTER, - PROP_DOCKBAR_STYLE -}; - -/* ----- Private prototypes ----- */ - -static void gdl_dock_bar_class_init (GdlDockBarClass *klass); - -static void gdl_dock_bar_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec); -static void gdl_dock_bar_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec); - -static void gdl_dock_bar_destroy (GtkObject *object); - -static void gdl_dock_bar_attach (GdlDockBar *dockbar, - GdlDockMaster *master); -static void gdl_dock_bar_remove_item (GdlDockBar *dockbar, - GdlDockItem *item); - -/* ----- Class variables and definitions ----- */ - -struct _GdlDockBarPrivate { - GdlDockMaster *master; - GSList *items; - GtkOrientation orientation; - GdlDockBarStyle dockbar_style; -}; - -/* ----- Private functions ----- */ - -G_DEFINE_TYPE (GdlDockBar, gdl_dock_bar, GTK_TYPE_BOX) - -static void gdl_dock_bar_size_request (GtkWidget *widget, - GtkRequisition *requisition ); -static void gdl_dock_bar_size_allocate (GtkWidget *widget, - GtkAllocation *allocation ); -static void gdl_dock_bar_size_vrequest (GtkWidget *widget, - GtkRequisition *requisition ); -static void gdl_dock_bar_size_vallocate (GtkWidget *widget, - GtkAllocation *allocation ); -static void gdl_dock_bar_size_hrequest (GtkWidget *widget, - GtkRequisition *requisition ); -static void gdl_dock_bar_size_hallocate (GtkWidget *widget, - GtkAllocation *allocation ); -static void update_dock_items (GdlDockBar *dockbar, gboolean full_update); - -void -gdl_dock_bar_class_init (GdlDockBarClass *klass) -{ - GObjectClass *g_object_class; - GtkObjectClass *gtk_object_class; - GtkWidgetClass *widget_class; - - g_object_class = G_OBJECT_CLASS (klass); - gtk_object_class = GTK_OBJECT_CLASS (klass); - - g_object_class->get_property = gdl_dock_bar_get_property; - g_object_class->set_property = gdl_dock_bar_set_property; - - gtk_object_class->destroy = gdl_dock_bar_destroy; - - g_object_class_install_property ( - g_object_class, PROP_MASTER, - g_param_spec_object ("master", _("Master"), - _("GdlDockMaster object which the dockbar widget " - "is attached to"), - GDL_TYPE_DOCK_MASTER, - G_PARAM_READWRITE)); - - g_object_class_install_property ( - g_object_class, PROP_DOCKBAR_STYLE, - g_param_spec_enum ("dockbar-style", _("Dockbar style"), - _("Dockbar style to show items on it"), - GDL_TYPE_DOCK_BAR_STYLE, - GDL_DOCK_BAR_BOTH, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); - - widget_class = GTK_WIDGET_CLASS (klass); - widget_class->size_request = gdl_dock_bar_size_request; - widget_class->size_allocate = gdl_dock_bar_size_allocate; -} - -static void -gdl_dock_bar_init (GdlDockBar *dockbar) -{ - dockbar->_priv = g_new0 (GdlDockBarPrivate, 1); - dockbar->_priv->master = NULL; - dockbar->_priv->items = NULL; - dockbar->_priv->orientation = GTK_ORIENTATION_VERTICAL; - dockbar->_priv->dockbar_style = GDL_DOCK_BAR_BOTH; -} - -static void -gdl_dock_bar_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) -{ - GdlDockBar *dockbar = GDL_DOCK_BAR (object); - - switch (prop_id) { - case PROP_MASTER: - g_value_set_object (value, dockbar->_priv->master); - break; - case PROP_DOCKBAR_STYLE: - g_value_set_enum (value, dockbar->_priv->dockbar_style); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - }; -} - -static void -gdl_dock_bar_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) -{ - GdlDockBar *dockbar = GDL_DOCK_BAR (object); - - switch (prop_id) { - case PROP_MASTER: - gdl_dock_bar_attach (dockbar, g_value_get_object (value)); - break; - case PROP_DOCKBAR_STYLE: - dockbar->_priv->dockbar_style = g_value_get_enum (value); - update_dock_items (dockbar, TRUE); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - }; -} - -static void -on_dock_item_foreach_disconnect (GdlDockItem *item, GdlDockBar *dock_bar) -{ - g_signal_handlers_disconnect_by_func (item, gdl_dock_bar_remove_item, - dock_bar); -} - -static void -gdl_dock_bar_destroy (GtkObject *object) -{ - GdlDockBar *dockbar = GDL_DOCK_BAR (object); - - if (dockbar->_priv) { - GdlDockBarPrivate *priv = dockbar->_priv; - - if (priv->items) { - g_slist_foreach (priv->items, - (GFunc) on_dock_item_foreach_disconnect, - object); - g_slist_free (priv->items); - } - - if (priv->master) { - g_signal_handlers_disconnect_matched (priv->master, - G_SIGNAL_MATCH_DATA, - 0, 0, NULL, NULL, dockbar); - g_object_unref (priv->master); - priv->master = NULL; - } - - dockbar->_priv = NULL; - - g_free (priv); - } - - GTK_OBJECT_CLASS (gdl_dock_bar_parent_class)->destroy (object); -} - -static void -gdl_dock_bar_remove_item (GdlDockBar *dockbar, - GdlDockItem *item) -{ - GdlDockBarPrivate *priv; - GtkWidget *button; - - g_return_if_fail (GDL_IS_DOCK_BAR (dockbar)); - g_return_if_fail (GDL_IS_DOCK_ITEM (item)); - - priv = dockbar->_priv; - - if (g_slist_index (priv->items, item) == -1) { - g_warning ("Item has not been added to the dockbar"); - return; - } - - priv->items = g_slist_remove (priv->items, item); - - button = g_object_get_data (G_OBJECT (item), "GdlDockBarButton"); - g_assert (button != NULL); - gtk_container_remove (GTK_CONTAINER (dockbar), button); - g_object_set_data (G_OBJECT (item), "GdlDockBarButton", NULL); - g_signal_handlers_disconnect_by_func (item, - G_CALLBACK (gdl_dock_bar_remove_item), - dockbar); -} - -static void -gdl_dock_bar_item_clicked (GtkWidget *button, - GdlDockItem *item) -{ - GdlDockBar *dockbar; - GdlDockObject *controller; - - g_return_if_fail (item != NULL); - - dockbar = g_object_get_data (G_OBJECT (item), "GdlDockBar"); - g_assert (dockbar != NULL); - g_object_set_data (G_OBJECT (item), "GdlDockBar", NULL); - - controller = gdl_dock_master_get_controller (GDL_DOCK_OBJECT_GET_MASTER (item)); - - GDL_DOCK_OBJECT_UNSET_FLAGS (item, GDL_DOCK_ICONIFIED); - gdl_dock_item_show_item (item); - gdl_dock_bar_remove_item (dockbar, item); - gtk_widget_queue_resize (GTK_WIDGET (controller)); -} - -static void -gdl_dock_bar_add_item (GdlDockBar *dockbar, - GdlDockItem *item) -{ - GdlDockBarPrivate *priv; - GtkWidget *button; - gchar *stock_id; - gchar *name; - GdkPixbuf *pixbuf_icon; - GtkWidget *image, *box, *label; - - g_return_if_fail (GDL_IS_DOCK_BAR (dockbar)); - g_return_if_fail (GDL_IS_DOCK_ITEM (item)); - - priv = dockbar->_priv; - - if (g_slist_index (priv->items, item) != -1) { - g_warning ("Item has already been added to the dockbar"); - return; - } - - priv->items = g_slist_append (priv->items, item); - - /* Create a button for the item. */ - button = gtk_button_new (); - gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE); - - if (dockbar->_priv->orientation == GTK_ORIENTATION_HORIZONTAL) - box = gtk_hbox_new (FALSE, 0); - else - box = gtk_vbox_new (FALSE, 0); - - g_object_get (item, "stock-id", &stock_id, "pixbuf-icon", &pixbuf_icon, - "long-name", &name, NULL); - - if (dockbar->_priv->dockbar_style == GDL_DOCK_BAR_TEXT || - dockbar->_priv->dockbar_style == GDL_DOCK_BAR_BOTH) { - label = gtk_label_new (name); - if (dockbar->_priv->orientation == GTK_ORIENTATION_VERTICAL) - gtk_label_set_angle (GTK_LABEL (label), 90); - gtk_box_pack_start (GTK_BOX (box), label, TRUE, TRUE, 0); - } - - /* FIXME: For now AUTO behaves same as BOTH */ - - if (dockbar->_priv->dockbar_style == GDL_DOCK_BAR_ICONS || - dockbar->_priv->dockbar_style == GDL_DOCK_BAR_BOTH || - dockbar->_priv->dockbar_style == GDL_DOCK_BAR_AUTO) { - if (stock_id) { - image = gtk_image_new_from_stock (stock_id, - GTK_ICON_SIZE_SMALL_TOOLBAR); - g_free (stock_id); - } else if (pixbuf_icon) { - image = gtk_image_new_from_pixbuf (pixbuf_icon); - } else { - image = gtk_image_new_from_stock ("gtk-new", - GTK_ICON_SIZE_SMALL_TOOLBAR); - } - gtk_box_pack_start (GTK_BOX (box), image, TRUE, TRUE, 0); - } - - gtk_container_add (GTK_CONTAINER (button), box); - gtk_box_pack_start (GTK_BOX (dockbar), button, FALSE, FALSE, 0); - - gtk_widget_set_tooltip_text (button, name); - g_free (name); - - g_object_set_data (G_OBJECT (item), "GdlDockBar", dockbar); - g_object_set_data (G_OBJECT (item), "GdlDockBarButton", button); - g_signal_connect (G_OBJECT (button), "clicked", - G_CALLBACK (gdl_dock_bar_item_clicked), item); - - gtk_widget_show_all (button); - - /* Set up destroy notify */ - g_signal_connect_swapped (item, "destroy", - G_CALLBACK (gdl_dock_bar_remove_item), - dockbar); -} - -static void -build_list (GdlDockObject *object, GList **list) -{ - /* add only items, not toplevels */ - if (GDL_IS_DOCK_ITEM (object)) - *list = g_list_prepend (*list, object); -} - -static void -update_dock_items (GdlDockBar *dockbar, gboolean full_update) -{ - GdlDockMaster *master; - GList *items, *l; - - g_return_if_fail (dockbar != NULL); - - if (!dockbar->_priv->master) - return; - - master = dockbar->_priv->master; - - /* build items list */ - items = NULL; - gdl_dock_master_foreach (master, (GFunc) build_list, &items); - - if (!full_update) { - for (l = items; l != NULL; l = l->next) { - GdlDockItem *item = GDL_DOCK_ITEM (l->data); - - if (g_slist_index (dockbar->_priv->items, item) != -1 && - !GDL_DOCK_ITEM_ICONIFIED (item)) - gdl_dock_bar_remove_item (dockbar, item); - else if (g_slist_index (dockbar->_priv->items, item) == -1 && - GDL_DOCK_ITEM_ICONIFIED (item)) - gdl_dock_bar_add_item (dockbar, item); - } - } else { - for (l = items; l != NULL; l = l->next) { - GdlDockItem *item = GDL_DOCK_ITEM (l->data); - - if (g_slist_index (dockbar->_priv->items, item) != -1) - gdl_dock_bar_remove_item (dockbar, item); - if (GDL_DOCK_ITEM_ICONIFIED (item)) - gdl_dock_bar_add_item (dockbar, item); - } - } - g_list_free (items); -} - -static void -gdl_dock_bar_layout_changed_cb (GdlDockMaster *master, - GdlDockBar *dockbar) -{ - update_dock_items (dockbar, FALSE); -} - -static void -gdl_dock_bar_attach (GdlDockBar *dockbar, - GdlDockMaster *master) -{ - g_return_if_fail (dockbar != NULL); - g_return_if_fail (master == NULL || GDL_IS_DOCK_MASTER (master)); - - if (dockbar->_priv->master) { - g_signal_handlers_disconnect_matched (dockbar->_priv->master, - G_SIGNAL_MATCH_DATA, - 0, 0, NULL, NULL, dockbar); - g_object_unref (dockbar->_priv->master); - } - - dockbar->_priv->master = master; - if (dockbar->_priv->master) { - g_object_ref (dockbar->_priv->master); - g_signal_connect (dockbar->_priv->master, "layout-changed", - G_CALLBACK (gdl_dock_bar_layout_changed_cb), - dockbar); - } - - update_dock_items (dockbar, FALSE); -} - -static void gdl_dock_bar_size_request (GtkWidget *widget, - GtkRequisition *requisition ) -{ - GdlDockBar *dockbar; - - dockbar = GDL_DOCK_BAR (widget); - - /* default to vertical for unknown values */ - switch (dockbar->_priv->orientation) { - case GTK_ORIENTATION_HORIZONTAL: - gdl_dock_bar_size_hrequest (widget, requisition); - break; - case GTK_ORIENTATION_VERTICAL: - default: - gdl_dock_bar_size_vrequest (widget, requisition); - break; - } -} - -static void gdl_dock_bar_size_allocate (GtkWidget *widget, - GtkAllocation *allocation ) -{ - GdlDockBar *dockbar; - - dockbar = GDL_DOCK_BAR (widget); - - /* default to vertical for unknown values */ - switch (dockbar->_priv->orientation) { - case GTK_ORIENTATION_HORIZONTAL: - gdl_dock_bar_size_hallocate (widget, allocation); - break; - case GTK_ORIENTATION_VERTICAL: - default: - gdl_dock_bar_size_vallocate (widget, allocation); - break; - } -} - -static void gdl_dock_bar_size_vrequest (GtkWidget *widget, - GtkRequisition *requisition ) -{ - GtkBox *box; - GtkRequisition child_requisition; - GList *child; - gint nvis_children; - gint height; - guint border_width; - - box = GTK_BOX (widget); - requisition->width = 0; - requisition->height = 0; - nvis_children = 0; - - - for (child = gtk_container_get_children (GTK_CONTAINER (box)); - child != NULL; child = g_list_next (child)) - { - if (gtk_widget_get_visible (GTK_WIDGET (child->data))) - { - guint padding; - gboolean expand; - gboolean fill; - GtkPackType pack_type; - - gtk_widget_size_request (GTK_WIDGET (child->data), &child_requisition); - - gtk_box_query_child_packing (box, - child->data, - &expand, - &fill, - &padding, - &pack_type); - - if (gtk_box_get_homogeneous (box)) - { - height = child_requisition.height + padding * 2; - requisition->height = MAX (requisition->height, height); - } - else - { - requisition->height += child_requisition.height + padding * 2; - } - - requisition->width = MAX (requisition->width, child_requisition.width); - - nvis_children += 1; - } - } - - if (nvis_children > 0) - { - if (gtk_box_get_homogeneous (box)) - requisition->height *= nvis_children; - requisition->height += (nvis_children - 1) * gtk_box_get_spacing (box); - } - - border_width = gtk_container_get_border_width (GTK_CONTAINER (box)); - requisition->width += border_width * 2; - requisition->height += border_width * 2; - -} - -static void gdl_dock_bar_size_vallocate (GtkWidget *widget, - GtkAllocation *allocation) -{ - GtkBox *box; - GList *child; - GtkAllocation child_allocation; - gint nvis_children; - gint nexpand_children; - gint child_height; - gint height; - gint extra; - gint y; - guint border_width; - GtkRequisition requisition; - - box = GTK_BOX (widget); - gtk_widget_set_allocation (widget, allocation); - - gtk_widget_get_requisition (widget, &requisition); - - nvis_children = 0; - nexpand_children = 0; - - for (child = gtk_container_get_children (GTK_CONTAINER (box)); - child != NULL; child = g_list_next (child)) - { - guint padding; - gboolean expand; - gboolean fill; - GtkPackType pack_type; - - gtk_box_query_child_packing (box, - child->data, - &expand, - &fill, - &padding, - &pack_type); - if (gtk_widget_get_visible (GTK_WIDGET(child->data))) - { - nvis_children += 1; - if (expand) - nexpand_children += 1; - } - } - - border_width = gtk_container_get_border_width (GTK_CONTAINER (box)); - - if (nvis_children > 0) - { - if (gtk_box_get_homogeneous (box)) - { - height = (allocation->height - - border_width * 2 - - (nvis_children - 1) * gtk_box_get_spacing (box)); - extra = height / nvis_children; - } - else if (nexpand_children > 0) - { - height = (gint) allocation->height - (gint) requisition.height; - extra = height / nexpand_children; - } - else - { - height = 0; - extra = 0; - } - - y = allocation->y + border_width; - child_allocation.x = allocation->x + border_width; - child_allocation.width = MAX (1, (gint) allocation->width - (gint) border_width * 2); - - for (child = gtk_container_get_children (GTK_CONTAINER (box)); - child != NULL; child = g_list_next (child)) - { - guint padding; - gboolean expand; - gboolean fill; - GtkPackType pack_type; - - gtk_box_query_child_packing (box, - child->data, - &expand, - &fill, - &padding, - &pack_type); - - if ((pack_type == GTK_PACK_START) && gtk_widget_get_visible (GTK_WIDGET (child->data))) - { - if (gtk_box_get_homogeneous (box)) - { - if (nvis_children == 1) - child_height = height; - else - child_height = extra; - - nvis_children -= 1; - height -= extra; - } - else - { - GtkRequisition child_requisition; - - gtk_widget_get_child_requisition (GTK_WIDGET (child->data), &child_requisition); - child_height = child_requisition.height + padding * 2; - - if (expand) - { - if (nexpand_children == 1) - child_height += height; - else - child_height += extra; - - nexpand_children -= 1; - height -= extra; - } - } - - if (fill) - { - child_allocation.height = MAX (1, child_height - padding * 2); - child_allocation.y = y + padding; - } - else - { - GtkRequisition child_requisition; - - gtk_widget_get_child_requisition (GTK_WIDGET (child->data), &child_requisition); - child_allocation.height = child_requisition.height; - child_allocation.y = y + (child_height - child_allocation.height) / 2; - } - - gtk_widget_size_allocate (GTK_WIDGET (child->data), &child_allocation); - - y += child_height + gtk_box_get_spacing (box); - } - } - - y = allocation->y + allocation->height - border_width; - - for (child = gtk_container_get_children (GTK_CONTAINER (box)); - child != NULL; child = g_list_next (child)) - { - guint padding; - gboolean expand; - gboolean fill; - GtkPackType pack_type; - - gtk_box_query_child_packing (box, - child->data, - &expand, - &fill, - &padding, - &pack_type); - - if ((pack_type == GTK_PACK_END) && gtk_widget_get_visible (GTK_WIDGET (child->data))) - { - GtkRequisition child_requisition; - gtk_widget_get_child_requisition (GTK_WIDGET (child->data), &child_requisition); - - if (gtk_box_get_homogeneous (box)) - { - if (nvis_children == 1) - child_height = height; - else - child_height = extra; - - nvis_children -= 1; - height -= extra; - } - else - { - child_height = child_requisition.height + padding * 2; - - if (expand) - { - if (nexpand_children == 1) - child_height += height; - else - child_height += extra; - - nexpand_children -= 1; - height -= extra; - } - } - - if (fill) - { - child_allocation.height = MAX (1, child_height - padding * 2); - child_allocation.y = y + padding - child_height; - } - else - { - child_allocation.height = child_requisition.height; - child_allocation.y = y + (child_height - child_allocation.height) / 2 - child_height; - } - - gtk_widget_size_allocate (GTK_WIDGET (child->data), &child_allocation); - - y -= (child_height + gtk_box_get_spacing (box)); - } - } - } -} - -static void gdl_dock_bar_size_hrequest (GtkWidget *widget, - GtkRequisition *requisition ) -{ - GtkBox *box; - GList *child; - gint nvis_children; - gint width; - guint border_width; - - box = GTK_BOX (widget); - requisition->width = 0; - requisition->height = 0; - nvis_children = 0; - - for (child = gtk_container_get_children (GTK_CONTAINER (box)); - child != NULL; child = g_list_next (child)) - { - guint padding; - gboolean expand; - gboolean fill; - GtkPackType pack_type; - - gtk_box_query_child_packing (box, - child->data, - &expand, - &fill, - &padding, - &pack_type); - - - if (gtk_widget_get_visible (GTK_WIDGET (child->data))) - { - GtkRequisition child_requisition; - - gtk_widget_size_request (GTK_WIDGET (child->data), &child_requisition); - - if (gtk_box_get_homogeneous (box)) - { - width = child_requisition.width + padding * 2; - requisition->width = MAX (requisition->width, width); - } - else - { - requisition->width += child_requisition.width + padding * 2; - } - - requisition->height = MAX (requisition->height, child_requisition.height); - - nvis_children += 1; - } - } - - if (nvis_children > 0) - { - if (gtk_box_get_homogeneous (box)) - requisition->width *= nvis_children; - requisition->width += (nvis_children - 1) * gtk_box_get_spacing (box); - } - - border_width = gtk_container_get_border_width (GTK_CONTAINER (box)); - requisition->width += border_width * 2; - requisition->height += border_width * 2; -} - -static void gdl_dock_bar_size_hallocate (GtkWidget *widget, - GtkAllocation *allocation) -{ - GtkBox *box; - GList *child; - GtkAllocation child_allocation; - gint nvis_children; - gint nexpand_children; - gint child_width; - gint width; - gint extra; - gint x; - guint border_width; - GtkTextDirection direction; - GtkRequisition requisition; - - box = GTK_BOX (widget); - gtk_widget_set_allocation (widget, allocation); - gtk_widget_get_requisition (widget, &requisition); - - direction = gtk_widget_get_direction (widget); - - nvis_children = 0; - nexpand_children = 0; - - for (child = gtk_container_get_children (GTK_CONTAINER (box)); - child != NULL; child = g_list_next (child)) - { - guint padding; - gboolean expand; - gboolean fill; - GtkPackType pack_type; - - gtk_box_query_child_packing (box, - child->data, - &expand, - &fill, - &padding, - &pack_type); - - if (gtk_widget_get_visible (GTK_WIDGET (child->data))) - { - nvis_children += 1; - if (expand) - nexpand_children += 1; - } - } - - border_width = gtk_container_get_border_width (GTK_CONTAINER (box)); - - if (nvis_children > 0) - { - if (gtk_box_get_homogeneous (box)) - { - width = (allocation->width - - border_width * 2 - - (nvis_children - 1) * gtk_box_get_spacing (box)); - extra = width / nvis_children; - } - else if (nexpand_children > 0) - { - width = (gint) allocation->width - (gint) requisition.width; - extra = width / nexpand_children; - } - else - { - width = 0; - extra = 0; - } - - x = allocation->x + border_width; - child_allocation.y = allocation->y + border_width; - child_allocation.height = MAX (1, (gint) allocation->height - (gint) border_width * 2); - - for (child = gtk_container_get_children (GTK_CONTAINER (box)); - child != NULL; child = g_list_next (child)) - { - guint padding; - gboolean expand; - gboolean fill; - GtkPackType pack_type; - - gtk_box_query_child_packing (box, - child->data, - &expand, - &fill, - &padding, - &pack_type); - - if ((pack_type == GTK_PACK_START) && gtk_widget_get_visible (GTK_WIDGET (child->data))) - { - if (gtk_box_get_homogeneous (box)) - { - if (nvis_children == 1) - child_width = width; - else - child_width = extra; - - nvis_children -= 1; - width -= extra; - } - else - { - GtkRequisition child_requisition; - - gtk_widget_get_child_requisition (GTK_WIDGET (child->data), &child_requisition); - - child_width = child_requisition.width + padding * 2; - - if (expand) - { - if (nexpand_children == 1) - child_width += width; - else - child_width += extra; - - nexpand_children -= 1; - width -= extra; - } - } - - if (fill) - { - child_allocation.width = MAX (1, child_width - padding * 2); - child_allocation.x = x + padding; - } - else - { - GtkRequisition child_requisition; - - gtk_widget_get_child_requisition (GTK_WIDGET (child->data), &child_requisition); - child_allocation.width = child_requisition.width; - child_allocation.x = x + (child_width - child_allocation.width) / 2; - } - - if (direction == GTK_TEXT_DIR_RTL) - child_allocation.x = allocation->x + allocation->width - (child_allocation.x - allocation->x) - child_allocation.width; - - gtk_widget_size_allocate (GTK_WIDGET (child->data), &child_allocation); - - x += child_width + gtk_box_get_spacing (box); - } - } - - x = allocation->x + allocation->width - border_width; - - for (child = gtk_container_get_children (GTK_CONTAINER (box)); - child != NULL; child = g_list_next (child)) - { - guint padding; - gboolean expand; - gboolean fill; - GtkPackType pack_type; - - gtk_box_query_child_packing (box, - child->data, - &expand, - &fill, - &padding, - &pack_type); - - if ((pack_type == GTK_PACK_END) && gtk_widget_get_visible (GTK_WIDGET (child->data))) - { - GtkRequisition child_requisition; - gtk_widget_get_child_requisition (GTK_WIDGET (child->data), &child_requisition); - - if (gtk_box_get_homogeneous (box)) - { - if (nvis_children == 1) - child_width = width; - else - child_width = extra; - - nvis_children -= 1; - width -= extra; - } - else - { - child_width = child_requisition.width + padding * 2; - - if (expand) - { - if (nexpand_children == 1) - child_width += width; - else - child_width += extra; - - nexpand_children -= 1; - width -= extra; - } - } - - if (fill) - { - child_allocation.width = MAX (1, child_width - padding * 2); - child_allocation.x = x + padding - child_width; - } - else - { - child_allocation.width = child_requisition.width; - child_allocation.x = x + (child_width - child_allocation.width) / 2 - child_width; - } - - if (direction == GTK_TEXT_DIR_RTL) - child_allocation.x = allocation->x + allocation->width - (child_allocation.x - allocation->x) - child_allocation.width; - - gtk_widget_size_allocate (GTK_WIDGET (child->data), &child_allocation); - - x -= (child_width + gtk_box_get_spacing (box)); - } - } - } -} - -GtkWidget * -gdl_dock_bar_new (GdlDock *dock) -{ - GdlDockMaster *master = NULL; - - /* get the master of the given dock */ - if (dock) - master = GDL_DOCK_OBJECT_GET_MASTER (dock); - - return g_object_new (GDL_TYPE_DOCK_BAR, - "master", master, NULL); -} - -GtkOrientation gdl_dock_bar_get_orientation (GdlDockBar *dockbar) -{ - g_return_val_if_fail (GDL_IS_DOCK_BAR (dockbar), - GTK_ORIENTATION_VERTICAL); - - return dockbar->_priv->orientation; -} - -void gdl_dock_bar_set_orientation (GdlDockBar *dockbar, - GtkOrientation orientation) -{ - g_return_if_fail (GDL_IS_DOCK_BAR (dockbar)); - - dockbar->_priv->orientation = orientation; - - gtk_widget_queue_resize (GTK_WIDGET (dockbar)); -} - -void gdl_dock_bar_set_style(GdlDockBar* dockbar, - GdlDockBarStyle style) -{ - g_object_set(G_OBJECT(dockbar), "dockbar-style", style, NULL); -} - -GdlDockBarStyle gdl_dock_bar_get_style(GdlDockBar* dockbar) -{ - GdlDockBarStyle style; - g_object_get(G_OBJECT(dockbar), "dockbar-style", &style, NULL); - return style; -} diff --git a/src/libgdl/gdl-dock-bar.h b/src/libgdl/gdl-dock-bar.h deleted file mode 100644 index ca6da1d26..000000000 --- a/src/libgdl/gdl-dock-bar.h +++ /dev/null @@ -1,74 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This file is part of the GNOME Devtools Libraries. - * - * Copyright (C) 2003 Jeroen Zwartepoorte <jeroen@xs4all.nl> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef __GDL_DOCK_BAR_H__ -#define __GDL_DOCK_BAR_H__ - -#include <gtk/gtk.h> - -G_BEGIN_DECLS - -/* standard macros */ -#define GDL_TYPE_DOCK_BAR (gdl_dock_bar_get_type ()) -#define GDL_DOCK_BAR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDL_TYPE_DOCK_BAR, GdlDockBar)) -#define GDL_DOCK_BAR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDL_TYPE_DOCK_BAR, GdlDockBarClass)) -#define GDL_IS_DOCK_BAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GDL_TYPE_DOCK_BAR)) -#define GDL_IS_DOCK_BAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDL_TYPE_DOCK_BAR)) -#define GDL_DOCK_BAR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_DOCK_BAR, GdlDockBarClass)) - -/* data types & structures */ -typedef struct _GdlDockBar GdlDockBar; -typedef struct _GdlDockBarClass GdlDockBarClass; -typedef struct _GdlDockBarPrivate GdlDockBarPrivate; - -typedef enum { - GDL_DOCK_BAR_ICONS, - GDL_DOCK_BAR_TEXT, - GDL_DOCK_BAR_BOTH, - GDL_DOCK_BAR_AUTO -} GdlDockBarStyle; - -struct _GdlDockBar { - GtkBox parent; - - GdlDock *dock; - - GdlDockBarPrivate *_priv; -}; - -struct _GdlDockBarClass { - GtkVBoxClass parent_class; -}; - -GType gdl_dock_bar_get_type (void); - -GtkWidget *gdl_dock_bar_new (GdlDock *dock); - -GtkOrientation gdl_dock_bar_get_orientation (GdlDockBar *dockbar); -void gdl_dock_bar_set_orientation (GdlDockBar *dockbar, - GtkOrientation orientation); -void gdl_dock_bar_set_style (GdlDockBar *dockbar, - GdlDockBarStyle style); -GdlDockBarStyle gdl_dock_bar_get_style (GdlDockBar *dockbar); - -G_END_DECLS - -#endif /* __GDL_DOCK_BAR_H__ */ diff --git a/src/libgdl/gdl-dock-item-button-image.c b/src/libgdl/gdl-dock-item-button-image.c deleted file mode 100644 index 77cfe5d6c..000000000 --- a/src/libgdl/gdl-dock-item-button-image.c +++ /dev/null @@ -1,166 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * gdl-dock-item-button-image.c - * - * Author: Joel Holdsworth <joel@airwebreathe.org.uk> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include "gdl-dock-item-button-image.h" - -#include <math.h> - -#define ICON_SIZE 12 - -G_DEFINE_TYPE (GdlDockItemButtonImage, - gdl_dock_item_button_image, - GTK_TYPE_WIDGET); - -static gint -gdl_dock_item_button_image_expose (GtkWidget *widget, - GdkEventExpose *event) -{ - GdlDockItemButtonImage *button_image; - GtkStyle *style; - GdkColor *color; - - g_return_val_if_fail (widget != NULL, 0); - button_image = GDL_DOCK_ITEM_BUTTON_IMAGE (widget); - - cairo_t *cr = gdk_cairo_create (event->window); - cairo_translate (cr, event->area.x, event->area.y); - - /* Set up the pen */ - cairo_set_line_width(cr, 1.0); - - style = gtk_widget_get_style (widget); - g_return_val_if_fail (style != NULL, 0); - color = &style->fg[GTK_STATE_NORMAL]; - cairo_set_source_rgba(cr, color->red / 65535.0, - color->green / 65535.0, color->blue / 65535.0, 0.55); - - /* Draw the icon border */ - cairo_move_to (cr, 10.5, 2.5); - cairo_arc (cr, 10.5, 4.5, 2, -0.5 * M_PI, 0); - cairo_line_to (cr, 12.5, 10.5); - cairo_arc (cr, 10.5, 10.5, 2, 0, 0.5 * M_PI); - cairo_line_to (cr, 4.5, 12.5); - cairo_arc (cr, 4.5, 10.5, 2, 0.5 * M_PI, M_PI); - cairo_line_to (cr, 2.5, 4.5); - cairo_arc (cr, 4.5, 4.5, 2, M_PI, 1.5 * M_PI); - cairo_close_path (cr); - - cairo_stroke (cr); - - /* Draw the icon */ - cairo_new_path (cr); - - switch(button_image->image_type) { - case GDL_DOCK_ITEM_BUTTON_IMAGE_CLOSE: - cairo_move_to (cr, 4.0, 5.5); - cairo_line_to (cr, 4.0, 5.5); - cairo_line_to (cr, 6.0, 7.5); - cairo_line_to (cr, 4.0, 9.5); - cairo_line_to (cr, 5.5, 11.0); - cairo_line_to (cr, 7.5, 9.0); - cairo_line_to (cr, 9.5, 11.0); - cairo_line_to (cr, 11.0, 9.5); - cairo_line_to (cr, 9.0, 7.5); - cairo_line_to (cr, 11.0, 5.5); - cairo_line_to (cr, 9.5, 4.0); - cairo_line_to (cr, 7.5, 6.0); - cairo_line_to (cr, 5.5, 4.0); - cairo_close_path (cr); - break; - - case GDL_DOCK_ITEM_BUTTON_IMAGE_ICONIFY: - if (gtk_widget_get_direction (widget) != GTK_TEXT_DIR_RTL) { - cairo_move_to (cr, 4.5, 7.5); - cairo_line_to (cr, 10.0, 4.75); - cairo_line_to (cr, 10.0, 10.25); - cairo_close_path (cr); - } else { - cairo_move_to (cr, 10.5, 7.5); - cairo_line_to (cr, 5, 4.75); - cairo_line_to (cr, 5, 10.25); - cairo_close_path (cr); - } - break; - - default: - break; - } - - cairo_fill (cr); - - /* Finish up */ - cairo_destroy (cr); - - return 0; -} - -static void -gdl_dock_item_button_image_init ( - GdlDockItemButtonImage *button_image) -{ - gtk_widget_set_has_window (GTK_WIDGET (button_image), FALSE); -} - -static void -gdl_dock_item_button_image_size_request (GtkWidget *widget, - GtkRequisition *requisition) -{ - g_return_if_fail (GDL_IS_DOCK_ITEM_BUTTON_IMAGE (widget)); - g_return_if_fail (requisition != NULL); - - requisition->width = ICON_SIZE; - requisition->height = ICON_SIZE; -} - -static void -gdl_dock_item_button_image_class_init ( - GdlDockItemButtonImageClass *klass) -{ - //GObjectClass *gobject_class = G_OBJECT_CLASS (klass); - //GtkObjectClass *gtk_object_class = GTK_OBJECT_CLASS (klass); - GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); - - widget_class->expose_event = - gdl_dock_item_button_image_expose; - widget_class->size_request = - gdl_dock_item_button_image_size_request; -} - -/* ----- Public interface ----- */ - -/** - * gdl_dock_item_button_image_new: - * @image_type: Specifies what type of image the widget should - * display - * - * Creates a new GDL dock button image object. - * Returns: The newly created dock item button image widget. - **/ -GtkWidget* -gdl_dock_item_button_image_new (GdlDockItemButtonImageType image_type) -{ - GdlDockItemButtonImage *button_image = g_object_new ( - GDL_TYPE_DOCK_ITEM_BUTTON_IMAGE, NULL); - button_image->image_type = image_type; - - return GTK_WIDGET (button_image); -} diff --git a/src/libgdl/gdl-dock-item-button-image.h b/src/libgdl/gdl-dock-item-button-image.h deleted file mode 100644 index ce0c6faaf..000000000 --- a/src/libgdl/gdl-dock-item-button-image.h +++ /dev/null @@ -1,70 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * gdl-dock-item-button-image.h - * - * Author: Joel Holdsworth <joel@airwebreathe.org.uk> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef _GDL_DOCK_ITEM_BUTTON_IMAGE_H_ -#define _GDL_DOCK_ITEM_BUTTON_IMAGE_H_ - -#include <gtk/gtk.h> - -G_BEGIN_DECLS - -/* Standard Macros */ -#define GDL_TYPE_DOCK_ITEM_BUTTON_IMAGE \ - (gdl_dock_item_button_image_get_type()) -#define GDL_DOCK_ITEM_BUTTON_IMAGE(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDL_TYPE_DOCK_ITEM_BUTTON_IMAGE, GdlDockItemButtonImage)) -#define GDL_DOCK_ITEM_BUTTON_IMAGE_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST ((klass), GDL_TYPE_DOCK_ITEM_BUTTON_IMAGE, GdlDockItemButtonImageClass)) -#define GDL_IS_DOCK_ITEM_BUTTON_IMAGE(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GDL_TYPE_DOCK_ITEM_BUTTON_IMAGE)) -#define GDL_IS_DOCK_ITEM_BUTTON_IMAGE_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE ((klass), GDL_TYPE_DOCK_ITEM_BUTTON_IMAGE)) -#define GDL_DOCK_ITEM_BUTTON_IMAGE_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS ((obj), GDL_TYPE_DOCK_ITEM_BUTTON_IMAGE, GdlDockItemButtonImageClass)) - -/* Data Types & Structures */ -typedef enum { - GDL_DOCK_ITEM_BUTTON_IMAGE_CLOSE, - GDL_DOCK_ITEM_BUTTON_IMAGE_ICONIFY -} GdlDockItemButtonImageType; - -typedef struct _GdlDockItemButtonImage GdlDockItemButtonImage; -typedef struct _GdlDockItemButtonImageClass GdlDockItemButtonImageClass; - -struct _GdlDockItemButtonImage { - GtkWidget parent; - - GdlDockItemButtonImageType image_type; -}; - -struct _GdlDockItemButtonImageClass { - GtkWidgetClass parent_class; -}; - -/* Data Public Functions */ -GType gdl_dock_item_button_image_get_type (void); -GtkWidget *gdl_dock_item_button_image_new ( - GdlDockItemButtonImageType image_type); - -G_END_DECLS - -#endif /* _GDL_DOCK_ITEM_BUTTON_IMAGE_H_ */ diff --git a/src/libgdl/gdl-dock-item-grip.c b/src/libgdl/gdl-dock-item-grip.c deleted file mode 100644 index 9b3810c20..000000000 --- a/src/libgdl/gdl-dock-item-grip.c +++ /dev/null @@ -1,809 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4; tab-width: 8 -*- */ -/* - * gdl-dock-item-grip.c - * - * Author: Michael Meeks Copyright (C) 2002 Sun Microsystems, Inc. - * - * Based on BonoboDockItemGrip. Original copyright notice follows. - * - * Copyright (C) 1998 Ettore Perazzoli - * Copyright (C) 1998 Elliot Lee - * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald - * All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include "gdl-i18n.h" -#include <string.h> -#include <glib-object.h> -#include <gtk/gtk.h> -#include "gdl-dock-item.h" -#include "gdl-dock-item-grip.h" -#include "gdl-dock-item-button-image.h" -#include "gdl-switcher.h" - -#define ALIGN_BORDER 5 -#define DRAG_HANDLE_SIZE 10 - -enum { - PROP_0, - PROP_ITEM -}; - -struct _GdlDockItemGripPrivate { - GtkWidget *label; - - GtkWidget *close_button; - GtkWidget *iconify_button; - - gboolean handle_shown; -}; - -G_DEFINE_TYPE (GdlDockItemGrip, gdl_dock_item_grip, GTK_TYPE_CONTAINER); - -GtkWidget* -gdl_dock_item_create_label_widget(GdlDockItemGrip *grip) -{ - GtkHBox *label_box; - GtkImage *image; - GtkLabel *label; - gchar *stock_id = NULL; - gchar *title = NULL; - GdkPixbuf *pixbuf; - - label_box = (GtkHBox*)gtk_hbox_new (FALSE, 0); - - g_object_get (G_OBJECT (grip->item), "stock-id", &stock_id, NULL); - g_object_get (G_OBJECT (grip->item), "pixbuf-icon", &pixbuf, NULL); - if(stock_id) { - image = GTK_IMAGE(gtk_image_new_from_stock (stock_id, GTK_ICON_SIZE_MENU)); - - gtk_widget_show (GTK_WIDGET(image)); - gtk_box_pack_start(GTK_BOX(label_box), GTK_WIDGET(image), FALSE, TRUE, 0); - - g_free (stock_id); - } - else if (pixbuf) { - image = GTK_IMAGE(gtk_image_new_from_pixbuf (pixbuf)); - - gtk_widget_show (GTK_WIDGET(image)); - gtk_box_pack_start(GTK_BOX(label_box), GTK_WIDGET(image), FALSE, TRUE, 0); - } - - g_object_get (G_OBJECT (grip->item), "long-name", &title, NULL); - if (title) { - label = GTK_LABEL(gtk_label_new(title)); - gtk_label_set_ellipsize(label, PANGO_ELLIPSIZE_END); - gtk_label_set_justify(label, GTK_JUSTIFY_LEFT); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); - gtk_widget_show (GTK_WIDGET(label)); - - if (gtk_widget_get_direction (GTK_WIDGET(grip)) == GTK_TEXT_DIR_RTL) { - gtk_box_pack_end(GTK_BOX(label_box), GTK_WIDGET(label), TRUE, TRUE, 1); - } else { - gtk_box_pack_start(GTK_BOX(label_box), GTK_WIDGET(label), TRUE, TRUE, 1); - } - - g_free(title); - } - - return GTK_WIDGET(label_box); -} - -static gint -gdl_dock_item_grip_expose (GtkWidget *widget, - GdkEventExpose *event) -{ - GdlDockItemGrip *grip; - GtkAllocation allocation; - GdkRectangle handle_area; - GdkRectangle expose_area; - - grip = GDL_DOCK_ITEM_GRIP (widget); - - if(grip->_priv->handle_shown) { - - gtk_widget_get_allocation (widget, &allocation); - - if (gtk_widget_get_direction (widget) != GTK_TEXT_DIR_RTL) { - handle_area.x = allocation.x; - handle_area.y = allocation.y; - handle_area.width = DRAG_HANDLE_SIZE; - handle_area.height = allocation.height; - } else { - handle_area.x = allocation.x + allocation.width - DRAG_HANDLE_SIZE; - handle_area.y = allocation.y; - handle_area.width = DRAG_HANDLE_SIZE; - handle_area.height = allocation.height; - } - - if (gdk_rectangle_intersect (&handle_area, &event->area, &expose_area)) { - - gtk_paint_handle (gtk_widget_get_style (widget), - gtk_widget_get_window (widget), - gtk_widget_get_state (widget), - GTK_SHADOW_NONE, &expose_area, widget, - "handlebox", handle_area.x, handle_area.y, - handle_area.width, handle_area.height, - GTK_ORIENTATION_VERTICAL); - - } - - } - -/* see bug #950556: may contribute to regression with GTK2/Quartz */ -#if !defined(GDK_WINDOWING_QUARTZ) - if (gdl_dock_item_or_child_has_focus(grip->item)) { - - gtk_paint_focus (gtk_widget_get_style (widget), - gtk_widget_get_window (widget), - gtk_widget_get_state (widget), - &event->area, widget, - NULL, 0, 0, -1, -1); - } -#endif //GDK_WINDOWING_QUARTZ - - return GTK_WIDGET_CLASS (gdl_dock_item_grip_parent_class)->expose_event (widget, event); -} - -static void -gdl_dock_item_grip_item_notify (GObject *master, - GParamSpec *pspec, - gpointer data) -{ - GdlDockItemGrip *grip; - gboolean cursor; - - grip = GDL_DOCK_ITEM_GRIP (data); - - if ((strcmp (pspec->name, "stock-id") == 0) || - (strcmp (pspec->name, "long-name") == 0)) { - - gdl_dock_item_grip_set_label (grip, - gdl_dock_item_create_label_widget(grip)); - - } else if (strcmp (pspec->name, "behavior") == 0) { - cursor = FALSE; - if (grip->_priv->close_button) { - if (GDL_DOCK_ITEM_CANT_CLOSE (grip->item)) { - gtk_widget_hide (GTK_WIDGET (grip->_priv->close_button)); - } else { - gtk_widget_show (GTK_WIDGET (grip->_priv->close_button)); - cursor = TRUE; - } - } - if (grip->_priv->iconify_button) { - if (GDL_DOCK_ITEM_CANT_ICONIFY (grip->item)) { - gtk_widget_hide (GTK_WIDGET (grip->_priv->iconify_button)); - } else { - gtk_widget_show (GTK_WIDGET (grip->_priv->iconify_button)); - cursor = TRUE; - } - } - if (grip->title_window && !cursor) - gdk_window_set_cursor (grip->title_window, NULL); - - } -} - -static void -gdl_dock_item_grip_destroy (GtkObject *object) -{ - GdlDockItemGrip *grip = GDL_DOCK_ITEM_GRIP (object); - - if (grip->_priv) { - GdlDockItemGripPrivate *priv = grip->_priv; - - if (priv->label) { - gtk_widget_unparent(grip->_priv->label); - priv->label = NULL; - } - - if (grip->item) - g_signal_handlers_disconnect_by_func (grip->item, - gdl_dock_item_grip_item_notify, - grip); - grip->item = NULL; - - grip->_priv = NULL; - g_free (priv); - } - - GTK_OBJECT_CLASS (gdl_dock_item_grip_parent_class)->destroy (object); -} - -static void -gdl_dock_item_grip_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) -{ - GdlDockItemGrip *grip; - - g_return_if_fail (GDL_IS_DOCK_ITEM_GRIP (object)); - - grip = GDL_DOCK_ITEM_GRIP (object); - - switch (prop_id) { - case PROP_ITEM: - grip->item = g_value_get_object (value); - if (grip->item) { - g_signal_connect (grip->item, "notify::long-name", - G_CALLBACK (gdl_dock_item_grip_item_notify), - grip); - g_signal_connect (grip->item, "notify::stock-id", - G_CALLBACK (gdl_dock_item_grip_item_notify), - grip); - g_signal_connect (grip->item, "notify::behavior", - G_CALLBACK (gdl_dock_item_grip_item_notify), - grip); - - if (!GDL_DOCK_ITEM_CANT_CLOSE (grip->item) && grip->_priv->close_button) - gtk_widget_show (grip->_priv->close_button); - if (!GDL_DOCK_ITEM_CANT_ICONIFY (grip->item) && grip->_priv->iconify_button) - gtk_widget_show (grip->_priv->iconify_button); - } - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -gdl_dock_item_grip_close_clicked (GtkWidget *widget, - GdlDockItemGrip *grip) -{ - (void)widget; - g_return_if_fail (grip->item != NULL); - - gdl_dock_item_hide_item (grip->item); -} - -static void -gdl_dock_item_grip_fix_iconify_button (GdlDockItemGrip *grip) -{ - GtkWidget *iconify_button = grip->_priv->iconify_button; - GdkWindow *window = NULL; - GdkEvent *event = NULL; - - GdkModifierType modifiers; - gint x = 0, y = 0; - gboolean ev_ret; - - g_return_if_fail (gtk_widget_get_realized (iconify_button)); - - window = gtk_widget_get_parent_window (iconify_button); - event = gdk_event_new (GDK_LEAVE_NOTIFY); - - g_assert (GDK_IS_WINDOW (window)); - gdk_window_get_pointer (window, &x, &y, &modifiers); - - event->crossing.window = g_object_ref (window); - event->crossing.send_event = FALSE; - event->crossing.subwindow = g_object_ref (window); - event->crossing.time = GDK_CURRENT_TIME; - event->crossing.x = x; - event->crossing.y = y; - event->crossing.x_root = event->crossing.y_root = 0; - event->crossing.mode = GDK_CROSSING_STATE_CHANGED; - event->crossing.detail = GDK_NOTIFY_NONLINEAR; - event->crossing.focus = FALSE; - event->crossing.state = modifiers; - - //GTK_BUTTON (iconify_button)->in_button = FALSE; - g_signal_emit_by_name (iconify_button, "leave-notify-event", - event, &ev_ret, 0); - - gdk_event_free (event); -} - -static void -gdl_dock_item_grip_iconify_clicked (GtkWidget *widget, - GdlDockItemGrip *grip) -{ - GtkWidget *parent; - - g_return_if_fail (grip->item != NULL); - - /* Workaround to unhighlight the iconify button. */ - gdl_dock_item_grip_fix_iconify_button (grip); - - parent = gtk_widget_get_parent (GTK_WIDGET (grip->item)); - if (GDL_IS_SWITCHER (parent)) - { - /* Note: We can not use gtk_container_foreach (parent) here because - * during iconificatoin, the internal children changes in parent. - * Instead we keep a list of items to iconify and iconify them - * one by one. - */ - GList *node; - GList *items = - gtk_container_get_children (GTK_CONTAINER (parent)); - for (node = items; node != NULL; node = node->next) - { - GdlDockItem *item = GDL_DOCK_ITEM (node->data); - if (!GDL_DOCK_ITEM_CANT_ICONIFY (item)) - gdl_dock_item_iconify_item (item); - } - g_list_free (items); - } - else - { - gdl_dock_item_iconify_item (grip->item); - } -} - -static void -gdl_dock_item_grip_init (GdlDockItemGrip *grip) -{ - GtkWidget *image; - - gtk_widget_set_has_window (GTK_WIDGET (grip), FALSE); - - grip->_priv = g_new0 (GdlDockItemGripPrivate, 1); - grip->_priv->label = NULL; - grip->_priv->handle_shown = FALSE; - - /* create the close button */ - gtk_widget_push_composite_child (); - grip->_priv->close_button = gtk_button_new (); - gtk_widget_pop_composite_child (); - - gtk_widget_set_can_focus (grip->_priv->close_button, FALSE); - gtk_widget_set_parent (grip->_priv->close_button, GTK_WIDGET (grip)); - gtk_button_set_relief (GTK_BUTTON (grip->_priv->close_button), GTK_RELIEF_NONE); - gtk_widget_show (grip->_priv->close_button); - - image = gdl_dock_item_button_image_new(GDL_DOCK_ITEM_BUTTON_IMAGE_CLOSE); - gtk_container_add (GTK_CONTAINER (grip->_priv->close_button), image); - gtk_widget_show (image); - - g_signal_connect (G_OBJECT (grip->_priv->close_button), "clicked", - G_CALLBACK (gdl_dock_item_grip_close_clicked), grip); - - /* create the iconify button */ - gtk_widget_push_composite_child (); - grip->_priv->iconify_button = gtk_button_new (); - gtk_widget_pop_composite_child (); - - gtk_widget_set_can_focus (grip->_priv->iconify_button, FALSE); - gtk_widget_set_parent (grip->_priv->iconify_button, GTK_WIDGET (grip)); - gtk_button_set_relief (GTK_BUTTON (grip->_priv->iconify_button), GTK_RELIEF_NONE); - gtk_widget_show (grip->_priv->iconify_button); - - image = gdl_dock_item_button_image_new(GDL_DOCK_ITEM_BUTTON_IMAGE_ICONIFY); - gtk_container_add (GTK_CONTAINER (grip->_priv->iconify_button), image); - gtk_widget_show (image); - - g_signal_connect (G_OBJECT (grip->_priv->iconify_button), "clicked", - G_CALLBACK (gdl_dock_item_grip_iconify_clicked), grip); - - /* set tooltips on the buttons */ - gtk_widget_set_tooltip_text (grip->_priv->iconify_button, - _("Iconify this dock")); - gtk_widget_set_tooltip_text (grip->_priv->close_button, - _("Close this dock")); -} - -static void -gdl_dock_item_grip_realize (GtkWidget *widget) -{ - GdlDockItemGrip *grip = GDL_DOCK_ITEM_GRIP (widget); - - GTK_WIDGET_CLASS (gdl_dock_item_grip_parent_class)->realize (widget); - - g_return_if_fail (grip->_priv != NULL); - - if (!grip->title_window) { - GtkAllocation allocation; - GdkWindowAttr attributes; - GdkCursor *cursor; - - g_return_if_fail (grip->_priv->label != NULL); - - gtk_widget_get_allocation (grip->_priv->label, &allocation); - - attributes.x = allocation.x; - attributes.y = allocation.y; - attributes.width = allocation.width; - attributes.height = allocation.height; - attributes.window_type = GDK_WINDOW_CHILD; - attributes.wclass = GDK_INPUT_OUTPUT; - attributes.event_mask = GDK_ALL_EVENTS_MASK; - - grip->title_window = gdk_window_new (gtk_widget_get_parent_window (widget), - &attributes, (GDK_WA_X | GDK_WA_Y)); - - gdk_window_set_user_data (grip->title_window, grip); - - /* Unref the ref from parent realize for NO_WINDOW */ - g_object_unref (gtk_widget_get_window (widget)); - - /* Need to ref widget->window, because parent unrealize unrefs it */ - gtk_widget_set_window (widget, g_object_ref (grip->title_window)); - gtk_widget_set_has_window (widget, TRUE); - - /* Unset the background so as to make the colour match the parent window */ - gtk_widget_modify_bg(widget, GTK_STATE_NORMAL, NULL); - - if (GDL_DOCK_ITEM_CANT_CLOSE (grip->item) && - GDL_DOCK_ITEM_CANT_ICONIFY (grip->item)) - cursor = NULL; - else - cursor = gdk_cursor_new_for_display (gtk_widget_get_display (widget), - GDK_HAND2); - gdk_window_set_cursor (grip->title_window, cursor); - if (cursor) - gdk_cursor_unref (cursor); - } -} - -static void -gdl_dock_item_grip_unrealize (GtkWidget *widget) -{ - GdlDockItemGrip *grip = GDL_DOCK_ITEM_GRIP (widget); - - if (grip->title_window) { - gtk_widget_set_has_window (widget, FALSE); - gdk_window_set_user_data (grip->title_window, NULL); - gdk_window_destroy (grip->title_window); - grip->title_window = NULL; - } - - GTK_WIDGET_CLASS (gdl_dock_item_grip_parent_class)->unrealize (widget); -} - -static void -gdl_dock_item_grip_map (GtkWidget *widget) -{ - GdlDockItemGrip *grip = GDL_DOCK_ITEM_GRIP (widget); - - GTK_WIDGET_CLASS (gdl_dock_item_grip_parent_class)->map (widget); - - if (grip->title_window) - gdk_window_show (grip->title_window); -} - -static void -gdl_dock_item_grip_unmap (GtkWidget *widget) -{ - GdlDockItemGrip *grip = GDL_DOCK_ITEM_GRIP (widget); - - if (grip->title_window) - gdk_window_hide (grip->title_window); - - GTK_WIDGET_CLASS (gdl_dock_item_grip_parent_class)->unmap (widget); -} - -static void -gdl_dock_item_grip_size_request (GtkWidget *widget, - GtkRequisition *requisition) -{ - GtkRequisition child_requisition; - GdlDockItemGrip *grip; - gint layout_height = 0; - guint border_width; - - g_return_if_fail (GDL_IS_DOCK_ITEM_GRIP (widget)); - g_return_if_fail (requisition != NULL); - - border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)); - grip = GDL_DOCK_ITEM_GRIP (widget); - - requisition->width = border_width * 2/* + ALIGN_BORDER*/; - requisition->height = border_width * 2; - - if(grip->_priv->handle_shown) - requisition->width += DRAG_HANDLE_SIZE; - - gtk_widget_size_request (grip->_priv->close_button, &child_requisition); - layout_height = MAX (layout_height, child_requisition.height); - if (gtk_widget_get_visible (grip->_priv->close_button)) { - requisition->width += child_requisition.width; - } - - gtk_widget_size_request (grip->_priv->iconify_button, &child_requisition); - layout_height = MAX (layout_height, child_requisition.height); - if (gtk_widget_get_visible (grip->_priv->iconify_button)) { - requisition->width += child_requisition.width; - } - - gtk_widget_size_request (grip->_priv->label, &child_requisition); - requisition->width += child_requisition.width; - layout_height = MAX (layout_height, child_requisition.height); - - requisition->height += layout_height; -} - -static void -gdl_dock_item_grip_size_allocate (GtkWidget *widget, - GtkAllocation *allocation) -{ - GdlDockItemGrip *grip; - GtkRequisition close_requisition = { 0, 0 }; - GtkRequisition iconify_requisition = { 0, 0 }; - GtkAllocation child_allocation; - guint border_width; - - g_return_if_fail (GDL_IS_DOCK_ITEM_GRIP (widget)); - g_return_if_fail (allocation != NULL); - - grip = GDL_DOCK_ITEM_GRIP (widget); - border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)); - - GTK_WIDGET_CLASS (gdl_dock_item_grip_parent_class)->size_allocate (widget, allocation); - - gtk_widget_size_request (grip->_priv->close_button, - &close_requisition); - gtk_widget_size_request (grip->_priv->iconify_button, - &iconify_requisition); - - /* Calculate the Minimum Width where buttons will fit */ - int min_width = close_requisition.width + iconify_requisition.width - + border_width * 2; - if(grip->_priv->handle_shown) - min_width += DRAG_HANDLE_SIZE; - const gboolean space_for_buttons = (allocation->width >= min_width); - - /* Set up the rolling child_allocation rectangle */ - if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) - child_allocation.x = border_width/* + ALIGN_BORDER*/; - else - child_allocation.x = allocation->width - border_width; - child_allocation.y = border_width; - - /* Layout Close Button */ - if (gtk_widget_get_visible (grip->_priv->close_button)) { - - if(space_for_buttons) { - if (gtk_widget_get_direction (widget) != GTK_TEXT_DIR_RTL) - child_allocation.x -= close_requisition.width; - - child_allocation.width = close_requisition.width; - child_allocation.height = close_requisition.height; - } else { - child_allocation.width = 0; - } - - gtk_widget_size_allocate (grip->_priv->close_button, &child_allocation); - - if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) - child_allocation.x += close_requisition.width; - } - - /* Layout Iconify Button */ - if (gtk_widget_get_visible (grip->_priv->iconify_button)) { - - if(space_for_buttons) { - if (gtk_widget_get_direction (widget) != GTK_TEXT_DIR_RTL) - child_allocation.x -= iconify_requisition.width; - - child_allocation.width = iconify_requisition.width; - child_allocation.height = iconify_requisition.height; - } else { - child_allocation.width = 0; - } - - gtk_widget_size_allocate (grip->_priv->iconify_button, &child_allocation); - - if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) - child_allocation.x += iconify_requisition.width; - } - - /* Layout the Grip Handle*/ - if (gtk_widget_get_direction (widget) != GTK_TEXT_DIR_RTL) { - child_allocation.width = child_allocation.x; - child_allocation.x = border_width/* + ALIGN_BORDER*/; - - if(grip->_priv->handle_shown) { - child_allocation.x += DRAG_HANDLE_SIZE; - child_allocation.width -= DRAG_HANDLE_SIZE; - } - - } else { - child_allocation.width = allocation->width - - (child_allocation.x - allocation->x)/* - ALIGN_BORDER*/; - - if(grip->_priv->handle_shown) - child_allocation.width -= DRAG_HANDLE_SIZE; - } - - if(child_allocation.width < 0) - child_allocation.width = 0; - - child_allocation.y = border_width; - child_allocation.height = allocation->height - border_width * 2; - if(grip->_priv->label) { - gtk_widget_size_allocate (grip->_priv->label, &child_allocation); - } - - if (grip->title_window) { - gdk_window_move_resize (grip->title_window, - allocation->x, - allocation->y, - allocation->width, - allocation->height); - } -} - -static void -gdl_dock_item_grip_add (GtkContainer *container, - GtkWidget *widget) -{ - g_warning ("gtk_container_add not implemented for GdlDockItemGrip"); -} - -static void -gdl_dock_item_grip_remove (GtkContainer *container, - GtkWidget *widget) -{ - gdl_dock_item_grip_set_label (GDL_DOCK_ITEM_GRIP (container), NULL); -} - -static void -gdl_dock_item_grip_forall (GtkContainer *container, - gboolean include_internals, - GtkCallback callback, - gpointer callback_data) -{ - GdlDockItemGrip *grip; - - g_return_if_fail (GDL_IS_DOCK_ITEM_GRIP (container)); - grip = GDL_DOCK_ITEM_GRIP (container); - - if (grip->_priv) { - if(grip->_priv->label) { - (* callback) (grip->_priv->label, callback_data); - } - - if (include_internals) { - (* callback) (grip->_priv->close_button, callback_data); - (* callback) (grip->_priv->iconify_button, callback_data); - } - } -} - -static GType -gdl_dock_item_grip_child_type (GtkContainer *container) -{ - return G_TYPE_NONE; -} - -static void -gdl_dock_item_grip_class_init (GdlDockItemGripClass *klass) -{ - GObjectClass *gobject_class; - GtkObjectClass *gtk_object_class; - GtkWidgetClass *widget_class; - GtkContainerClass *container_class; - - gobject_class = G_OBJECT_CLASS (klass); - gtk_object_class = GTK_OBJECT_CLASS (klass); - widget_class = GTK_WIDGET_CLASS (klass); - container_class = GTK_CONTAINER_CLASS (klass); - - gobject_class->set_property = gdl_dock_item_grip_set_property; - - gtk_object_class->destroy = gdl_dock_item_grip_destroy; - - widget_class->expose_event = gdl_dock_item_grip_expose; - widget_class->realize = gdl_dock_item_grip_realize; - widget_class->unrealize = gdl_dock_item_grip_unrealize; - widget_class->map = gdl_dock_item_grip_map; - widget_class->unmap = gdl_dock_item_grip_unmap; - widget_class->size_request = gdl_dock_item_grip_size_request; - widget_class->size_allocate = gdl_dock_item_grip_size_allocate; - - container_class->add = gdl_dock_item_grip_add; - container_class->remove = gdl_dock_item_grip_remove; - container_class->forall = gdl_dock_item_grip_forall; - container_class->child_type = gdl_dock_item_grip_child_type; - - g_object_class_install_property ( - gobject_class, PROP_ITEM, - g_param_spec_object ("item", _("Controlling dock item"), - _("Dockitem which 'owns' this grip"), - GDL_TYPE_DOCK_ITEM, - G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY)); -} - -static void -gdl_dock_item_grip_showhide_handle (GdlDockItemGrip *grip) -{ - gtk_widget_queue_resize (GTK_WIDGET (grip)); -} - -/* ----- Public interface ----- */ - -/** - * gdl_dock_item_grip_new: - * @item: The dock item that will "own" this grip widget. - * - * Creates a new GDL dock item grip object. - * Returns: The newly created dock item grip widget. - **/ -GtkWidget * -gdl_dock_item_grip_new (GdlDockItem *item) -{ - GdlDockItemGrip *grip = g_object_new (GDL_TYPE_DOCK_ITEM_GRIP, "item", item, - NULL); - - return GTK_WIDGET (grip); -} - -/** - * gdl_dock_item_grip_set_label: - * @grip: The grip that will get it's label widget set. - * @label: The widget that will become the label. - * - * Replaces the current label widget with another widget. - **/ -void -gdl_dock_item_grip_set_label (GdlDockItemGrip *grip, - GtkWidget *label) -{ - g_return_if_fail (grip != NULL); - - if (grip->_priv->label) { - gtk_widget_unparent(grip->_priv->label); - g_object_unref (grip->_priv->label); - grip->_priv->label = NULL; - } - - if (label) { - g_object_ref (label); - gtk_widget_set_parent (label, GTK_WIDGET (grip)); - gtk_widget_show (label); - grip->_priv->label = label; - } -} -/** - * gdl_dock_item_grip_hide_handle: - * @grip: The dock item grip to hide the handle of. - * - * This function hides the dock item's grip widget handle hatching. - **/ -void -gdl_dock_item_grip_hide_handle (GdlDockItemGrip *grip) -{ - g_return_if_fail (grip != NULL); - if (grip->_priv->handle_shown) { - grip->_priv->handle_shown = FALSE; - gdl_dock_item_grip_showhide_handle (grip); - }; -} - -/** - * gdl_dock_item_grip_show_handle: - * @grip: The dock item grip to show the handle of. - * - * This function shows the dock item's grip widget handle hatching. - **/ -void -gdl_dock_item_grip_show_handle (GdlDockItemGrip *grip) -{ - g_return_if_fail (grip != NULL); - if (!grip->_priv->handle_shown) { - grip->_priv->handle_shown = TRUE; - gdl_dock_item_grip_showhide_handle (grip); - }; -} diff --git a/src/libgdl/gdl-dock-item-grip.h b/src/libgdl/gdl-dock-item-grip.h deleted file mode 100644 index a44ef91fb..000000000 --- a/src/libgdl/gdl-dock-item-grip.h +++ /dev/null @@ -1,77 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4; tab-width: 8 -*- */ -/* - * gdl-dock-item-grip.h - * - * Author: Michael Meeks Copyright (C) 2002 Sun Microsystems, Inc. - * - * Based on BonoboDockItemGrip. Original copyright notice follows. - * - * Copyright (C) 1998 Ettore Perazzoli - * Copyright (C) 1998 Elliot Lee - * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald - * All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef _GDL_DOCK_ITEM_GRIP_H_ -#define _GDL_DOCK_ITEM_GRIP_H_ - -#include <gtk/gtk.h> -#include "libgdl/gdl-dock-item.h" - -G_BEGIN_DECLS - -#define GDL_TYPE_DOCK_ITEM_GRIP (gdl_dock_item_grip_get_type()) -#define GDL_DOCK_ITEM_GRIP(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDL_TYPE_DOCK_ITEM_GRIP, GdlDockItemGrip)) -#define GDL_DOCK_ITEM_GRIP_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST ((klass), GDL_TYPE_DOCK_ITEM_GRIP, GdlDockItemGripClass)) -#define GDL_IS_DOCK_ITEM_GRIP(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GDL_TYPE_DOCK_ITEM_GRIP)) -#define GDL_IS_DOCK_ITEM_GRIP_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE ((klass), GDL_TYPE_DOCK_ITEM_GRIP)) -#define GDL_DOCK_ITEM_GRIP_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS ((obj), GDL_TYPE_DOCK_ITEM_GRIP, GdlDockItemGripClass)) - -typedef struct _GdlDockItemGrip GdlDockItemGrip; -typedef struct _GdlDockItemGripClass GdlDockItemGripClass; -typedef struct _GdlDockItemGripPrivate GdlDockItemGripPrivate; - -struct _GdlDockItemGrip { - GtkContainer parent; - - GdlDockItem *item; - - GdkWindow *title_window; - - GdlDockItemGripPrivate *_priv; -}; - -struct _GdlDockItemGripClass { - GtkContainerClass parent_class; -}; - -GType gdl_dock_item_grip_get_type (void); -GtkWidget *gdl_dock_item_grip_new (GdlDockItem *item); -void gdl_dock_item_grip_set_label (GdlDockItemGrip *grip, - GtkWidget *label); -void gdl_dock_item_grip_hide_handle (GdlDockItemGrip *grip); -void gdl_dock_item_grip_show_handle (GdlDockItemGrip *grip); - -G_END_DECLS - -#endif /* _GDL_DOCK_ITEM_GRIP_H_ */ diff --git a/src/libgdl/gdl-dock-item.c b/src/libgdl/gdl-dock-item.c deleted file mode 100644 index af630e681..000000000 --- a/src/libgdl/gdl-dock-item.c +++ /dev/null @@ -1,2401 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * gdl-dock-item.c - * - * Author: Gustavo Giráldez <gustavo.giraldez@gmx.net> - * Naba Kumar <naba@gnome.org> - * - * Based on GnomeDockItem/BonoboDockItem. Original copyright notice follows. - * - * Copyright (C) 1998 Ettore Perazzoli - * Copyright (C) 1998 Elliot Lee - * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald - * All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include "gdl-i18n.h" -#include <string.h> -#include <gdk/gdkkeysyms.h> - -#include "gdl-dock.h" -#include "gdl-dock-item.h" -#include "gdl-dock-item-grip.h" -#include "gdl-dock-notebook.h" -#include "gdl-dock-paned.h" -#include "gdl-dock-tablabel.h" -#include "gdl-dock-placeholder.h" -#include "gdl-dock-master.h" -#include "libgdltypebuiltins.h" -#include "libgdlmarshal.h" - -#define NEW_DOCK_ITEM_RATIO 0.3 - -/* ----- Private prototypes ----- */ - -static void gdl_dock_item_class_init (GdlDockItemClass *class); - -static GObject *gdl_dock_item_constructor (GType type, - guint n_construct_properties, - GObjectConstructParam *construct_param); - -static void gdl_dock_item_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec); -static void gdl_dock_item_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec); - -static void gdl_dock_item_destroy (GtkObject *object); - -static void gdl_dock_item_add (GtkContainer *container, - GtkWidget *widget); -static void gdl_dock_item_remove (GtkContainer *container, - GtkWidget *widget); -static void gdl_dock_item_forall (GtkContainer *container, - gboolean include_internals, - GtkCallback callback, - gpointer callback_data); -static GType gdl_dock_item_child_type (GtkContainer *container); - -static void gdl_dock_item_set_focus_child (GtkContainer *container, - GtkWidget *widget); - -static void gdl_dock_item_size_request (GtkWidget *widget, - GtkRequisition *requisition); -static void gdl_dock_item_size_allocate (GtkWidget *widget, - GtkAllocation *allocation); -static void gdl_dock_item_map (GtkWidget *widget); -static void gdl_dock_item_unmap (GtkWidget *widget); -static void gdl_dock_item_realize (GtkWidget *widget); -static void gdl_dock_item_style_set (GtkWidget *widget, - GtkStyle *previous_style); -static gint gdl_dock_item_expose (GtkWidget *widget, - GdkEventExpose *event); - -static void gdl_dock_item_move_focus_child (GdlDockItem *item, - GtkDirectionType dir); - -static gint gdl_dock_item_button_changed (GtkWidget *widget, - GdkEventButton *event); -static gint gdl_dock_item_motion (GtkWidget *widget, - GdkEventMotion *event); -static gboolean gdl_dock_item_key_press (GtkWidget *widget, - GdkEventKey *event); - -static gboolean gdl_dock_item_dock_request (GdlDockObject *object, - gint x, - gint y, - GdlDockRequest *request); -static void gdl_dock_item_dock (GdlDockObject *object, - GdlDockObject *requestor, - GdlDockPlacement position, - GValue *other_data); - -static void gdl_dock_item_popup_menu (GdlDockItem *item, - guint button, - guint32 time); -static void gdl_dock_item_drag_start (GdlDockItem *item); -static void gdl_dock_item_drag_end (GdlDockItem *item, - gboolean cancel); - -static void gdl_dock_item_tab_button (GtkWidget *widget, - GdkEventButton *event, - gpointer data); - -static void gdl_dock_item_hide_cb (GtkWidget *widget, - GdlDockItem *item); - -static void gdl_dock_item_lock_cb (GtkWidget *widget, - GdlDockItem *item); - -static void gdl_dock_item_unlock_cb (GtkWidget *widget, - GdlDockItem *item); - -static void gdl_dock_item_showhide_grip (GdlDockItem *item); - -static void gdl_dock_item_real_set_orientation (GdlDockItem *item, - GtkOrientation orientation); - -static void gdl_dock_param_export_gtk_orientation (const GValue *src, - GValue *dst); -static void gdl_dock_param_import_gtk_orientation (const GValue *src, - GValue *dst); - - - -/* ----- Class variables and definitions ----- */ - -enum { - PROP_0, - PROP_ORIENTATION, - PROP_RESIZE, - PROP_BEHAVIOR, - PROP_LOCKED, - PROP_PREFERRED_WIDTH, - PROP_PREFERRED_HEIGHT -}; - -enum { - DOCK_DRAG_BEGIN, - DOCK_DRAG_MOTION, - DOCK_DRAG_END, - SELECTED, - MOVE_FOCUS_CHILD, - LAST_SIGNAL -}; - -static guint gdl_dock_item_signals [LAST_SIGNAL] = { 0 }; - -#define GDL_DOCK_ITEM_GRIP_SHOWN(item) \ - (GDL_DOCK_ITEM_HAS_GRIP (item)) - -struct _GdlDockItemPrivate { - GtkWidget *menu; - - gboolean grip_shown; - GtkWidget *grip; - guint grip_size; - - GtkWidget *tab_label; - gboolean intern_tab_label; - guint notify_label; - guint notify_stock_id; - - gint preferred_width; - gint preferred_height; - - GdlDockPlaceholder *ph; - - gint start_x, start_y; -}; - -/* FIXME: implement the rest of the behaviors */ - -#define SPLIT_RATIO 0.4 - - -/* ----- Private functions ----- */ - -G_DEFINE_TYPE (GdlDockItem, gdl_dock_item, GDL_TYPE_DOCK_OBJECT); - -static void -add_tab_bindings (GtkBindingSet *binding_set, - GdkModifierType modifiers, - GtkDirectionType direction) -{ - gtk_binding_entry_add_signal (binding_set, GDK_KEY_Tab, modifiers, - "move_focus_child", 1, - GTK_TYPE_DIRECTION_TYPE, direction); - gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Tab, modifiers, - "move_focus_child", 1, - GTK_TYPE_DIRECTION_TYPE, direction); -} - -static void -add_arrow_bindings (GtkBindingSet *binding_set, - guint keysym, - GtkDirectionType direction) -{ - guint keypad_keysym = keysym - GDK_KEY_Left + GDK_KEY_KP_Left; - - gtk_binding_entry_add_signal (binding_set, keysym, 0, - "move_focus_child", 1, - GTK_TYPE_DIRECTION_TYPE, direction); - gtk_binding_entry_add_signal (binding_set, keysym, GDK_CONTROL_MASK, - "move_focus_child", 1, - GTK_TYPE_DIRECTION_TYPE, direction); - gtk_binding_entry_add_signal (binding_set, keysym, GDK_CONTROL_MASK, - "move_focus_child", 1, - GTK_TYPE_DIRECTION_TYPE, direction); - gtk_binding_entry_add_signal (binding_set, keypad_keysym, GDK_CONTROL_MASK, - "move_focus_child", 1, - GTK_TYPE_DIRECTION_TYPE, direction); -} - -static void -gdl_dock_item_class_init (GdlDockItemClass *klass) -{ - static gboolean style_initialized = FALSE; - - GObjectClass *g_object_class; - GtkObjectClass *gtk_object_class; - GtkWidgetClass *widget_class; - GtkContainerClass *container_class; - GdlDockObjectClass *object_class; - GtkBindingSet *binding_set; - - g_object_class = G_OBJECT_CLASS (klass); - gtk_object_class = GTK_OBJECT_CLASS (klass); - widget_class = GTK_WIDGET_CLASS (klass); - container_class = GTK_CONTAINER_CLASS (klass); - object_class = GDL_DOCK_OBJECT_CLASS (klass); - - g_object_class->constructor = gdl_dock_item_constructor; - g_object_class->set_property = gdl_dock_item_set_property; - g_object_class->get_property = gdl_dock_item_get_property; - - gtk_object_class->destroy = gdl_dock_item_destroy; - - widget_class->realize = gdl_dock_item_realize; - widget_class->map = gdl_dock_item_map; - widget_class->unmap = gdl_dock_item_unmap; - widget_class->size_request = gdl_dock_item_size_request; - widget_class->size_allocate = gdl_dock_item_size_allocate; - widget_class->style_set = gdl_dock_item_style_set; - widget_class->expose_event = gdl_dock_item_expose; - widget_class->button_press_event = gdl_dock_item_button_changed; - widget_class->button_release_event = gdl_dock_item_button_changed; - widget_class->motion_notify_event = gdl_dock_item_motion; - widget_class->key_press_event = gdl_dock_item_key_press; - - container_class->add = gdl_dock_item_add; - container_class->remove = gdl_dock_item_remove; - container_class->forall = gdl_dock_item_forall; - container_class->child_type = gdl_dock_item_child_type; - container_class->set_focus_child = gdl_dock_item_set_focus_child; - - object_class->is_compound = FALSE; - - object_class->dock_request = gdl_dock_item_dock_request; - object_class->dock = gdl_dock_item_dock; - - /* properties */ - - /** - * GdlDockItem:orientation: - * - * The orientation of the docking item. If the orientation is set to - * #GTK_ORIENTATION_VERTICAL, the grip widget will be shown along - * the top of the edge of item (if it is not hidden). If the - * orientation is set to #GTK_ORIENTATION_HORIZONTAL, the grip - * widget will be shown down the left edge of the item (even if the - * widget text direction is set to RTL). - */ - g_object_class_install_property ( - g_object_class, PROP_ORIENTATION, - g_param_spec_enum ("orientation", _("Orientation"), - _("Orientation of the docking item"), - GTK_TYPE_ORIENTATION, - GTK_ORIENTATION_VERTICAL, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT | - GDL_DOCK_PARAM_EXPORT)); - - /* --- register exporter/importer for GTK_ORIENTATION */ - g_value_register_transform_func (GTK_TYPE_ORIENTATION, GDL_TYPE_DOCK_PARAM, - gdl_dock_param_export_gtk_orientation); - g_value_register_transform_func (GDL_TYPE_DOCK_PARAM, GTK_TYPE_ORIENTATION, - gdl_dock_param_import_gtk_orientation); - /* --- end of registration */ - - g_object_class_install_property ( - g_object_class, PROP_RESIZE, - g_param_spec_boolean ("resize", _("Resizable"), - _("If set, the dock item can be resized when " - "docked in a GtkPanel widget"), - TRUE, - G_PARAM_READWRITE)); - - g_object_class_install_property ( - g_object_class, PROP_BEHAVIOR, - g_param_spec_flags ("behavior", _("Item behavior"), - _("General behavior for the dock item (i.e. " - "whether it can float, if it's locked, etc.)"), - GDL_TYPE_DOCK_ITEM_BEHAVIOR, - GDL_DOCK_ITEM_BEH_NORMAL, - G_PARAM_READWRITE)); - - g_object_class_install_property ( - g_object_class, PROP_LOCKED, - g_param_spec_boolean ("locked", _("Locked"), - _("If set, the dock item cannot be dragged around " - "and it doesn't show a grip"), - FALSE, - G_PARAM_READWRITE | - GDL_DOCK_PARAM_EXPORT)); - - g_object_class_install_property ( - g_object_class, PROP_PREFERRED_WIDTH, - g_param_spec_int ("preferred-width", _("Preferred width"), - _("Preferred width for the dock item"), - -1, G_MAXINT, -1, - G_PARAM_READWRITE)); - - g_object_class_install_property ( - g_object_class, PROP_PREFERRED_HEIGHT, - g_param_spec_int ("preferred-height", _("Preferred height"), - _("Preferred height for the dock item"), - -1, G_MAXINT, -1, - G_PARAM_READWRITE)); - - /* signals */ - - /** - * GdlDockItem::dock-drag-begin: - * @item: The dock item which is being dragged. - * - * Signals that the dock item has begun to be dragged. - **/ - gdl_dock_item_signals [DOCK_DRAG_BEGIN] = - g_signal_new ("dock-drag-begin", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (GdlDockItemClass, dock_drag_begin), - NULL, /* accumulator */ - NULL, /* accu_data */ - gdl_marshal_VOID__VOID, - G_TYPE_NONE, - 0); - - /** - * GdlDockItem::dock-drag-motion: - * @item: The dock item which is being dragged. - * @x: The x-position that the dock item has been dragged to. - * @y: The y-position that the dock item has been dragged to. - * - * Signals that a dock item dragging motion event has occured. - **/ - gdl_dock_item_signals [DOCK_DRAG_MOTION] = - g_signal_new ("dock-drag-motion", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (GdlDockItemClass, dock_drag_motion), - NULL, /* accumulator */ - NULL, /* accu_data */ - gdl_marshal_VOID__INT_INT, - G_TYPE_NONE, - 2, - G_TYPE_INT, - G_TYPE_INT); - - /** - * GdlDockItem::dock-drag-end: - * @item: The dock item which is no longer being dragged. - * @cancel: This value is set to TRUE if the drag was cancelled by - * the user. #cancel is set to FALSE if the drag was accepted. - * - * Signals that the dock item dragging has ended. - **/ - gdl_dock_item_signals [DOCK_DRAG_END] = - g_signal_new ("dock_drag_end", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (GdlDockItemClass, dock_drag_end), - NULL, /* accumulator */ - NULL, /* accu_data */ - gdl_marshal_VOID__BOOLEAN, - G_TYPE_NONE, - 1, - G_TYPE_BOOLEAN); - - /** - * GdlDockItem::selected: - * - * Signals that this dock has been selected from a switcher. - */ - gdl_dock_item_signals [SELECTED] = - g_signal_new ("selected", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_FIRST, - 0, - NULL, - NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, - 0); - - gdl_dock_item_signals [MOVE_FOCUS_CHILD] = - g_signal_new ("move_focus_child", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, - G_STRUCT_OFFSET (GdlDockItemClass, move_focus_child), - NULL, /* accumulator */ - NULL, /* accu_data */ - gdl_marshal_VOID__ENUM, - G_TYPE_NONE, - 1, - GTK_TYPE_DIRECTION_TYPE); - - - /* key bindings */ - - binding_set = gtk_binding_set_by_class (klass); - - add_arrow_bindings (binding_set, GDK_KEY_Up, GTK_DIR_UP); - add_arrow_bindings (binding_set, GDK_KEY_Down, GTK_DIR_DOWN); - add_arrow_bindings (binding_set, GDK_KEY_Left, GTK_DIR_LEFT); - add_arrow_bindings (binding_set, GDK_KEY_Right, GTK_DIR_RIGHT); - - add_tab_bindings (binding_set, 0, GTK_DIR_TAB_FORWARD); - add_tab_bindings (binding_set, GDK_CONTROL_MASK, GTK_DIR_TAB_FORWARD); - add_tab_bindings (binding_set, GDK_SHIFT_MASK, GTK_DIR_TAB_BACKWARD); - add_tab_bindings (binding_set, GDK_CONTROL_MASK | GDK_SHIFT_MASK, GTK_DIR_TAB_BACKWARD); - - klass->has_grip = TRUE; - klass->dock_drag_begin = NULL; - klass->dock_drag_motion = NULL; - klass->dock_drag_end = NULL; - klass->move_focus_child = gdl_dock_item_move_focus_child; - klass->set_orientation = gdl_dock_item_real_set_orientation; - - if (!style_initialized) - { - style_initialized = TRUE; - gtk_rc_parse_string ( - "style \"gdl-dock-item-default\" {\n" - "xthickness = 0\n" - "ythickness = 0\n" - "}\n" - "class \"GdlDockItem\" " - "style : gtk \"gdl-dock-item-default\"\n"); - } -} - -static void -gdl_dock_item_init (GdlDockItem *item) -{ - gtk_widget_set_has_window (GTK_WIDGET (item), TRUE); - gtk_widget_set_can_focus (GTK_WIDGET (item), TRUE); - - item->child = NULL; - - item->orientation = GTK_ORIENTATION_VERTICAL; - item->behavior = GDL_DOCK_ITEM_BEH_NORMAL; - - item->resize = TRUE; - - item->dragoff_x = item->dragoff_y = 0; - - item->_priv = g_new0 (GdlDockItemPrivate, 1); - item->_priv->menu = NULL; - - item->_priv->preferred_width = item->_priv->preferred_height = -1; - item->_priv->tab_label = NULL; - item->_priv->intern_tab_label = FALSE; - - item->_priv->ph = NULL; -} - -static void -on_long_name_changed (GObject* item, - GParamSpec* spec, - gpointer user_data) -{ - gchar* long_name; - g_object_get (item, "long-name", &long_name, NULL); - gtk_label_set_label (GTK_LABEL (user_data), long_name); - g_free(long_name); -} - -static void -on_stock_id_changed (GObject* item, - GParamSpec* spec, - gpointer user_data) -{ - gchar* stock_id; - g_object_get (item, "stock_id", &stock_id, NULL); - gtk_image_set_from_stock (GTK_IMAGE (user_data), stock_id, GTK_ICON_SIZE_MENU); - g_free(stock_id); -} - -static GObject * -gdl_dock_item_constructor (GType type, - guint n_construct_properties, - GObjectConstructParam *construct_param) -{ - GObject *g_object; - - g_object = G_OBJECT_CLASS (gdl_dock_item_parent_class)-> constructor (type, - n_construct_properties, - construct_param); - if (g_object) { - GdlDockItem *item = GDL_DOCK_ITEM (g_object); - GtkWidget *hbox; - GtkWidget *label; - GtkWidget *icon; - gchar* long_name; - gchar* stock_id; - - if (GDL_DOCK_ITEM_HAS_GRIP (item)) { - item->_priv->grip_shown = TRUE; - item->_priv->grip = gdl_dock_item_grip_new (item); - gtk_widget_set_parent (item->_priv->grip, GTK_WIDGET (item)); - gtk_widget_show (item->_priv->grip); - } - else { - item->_priv->grip_shown = FALSE; - } - - g_object_get (g_object, "long-name", &long_name, "stock-id", &stock_id, NULL); - - hbox = gtk_hbox_new (FALSE, 5); - label = gtk_label_new (long_name); - icon = gtk_image_new (); - if (stock_id) - gtk_image_set_from_stock (GTK_IMAGE (icon), stock_id, - GTK_ICON_SIZE_MENU); - gtk_box_pack_start (GTK_BOX (hbox), icon, FALSE, FALSE, 0); - gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); - - item->_priv->notify_label = - g_signal_connect (item, "notify::long-name", G_CALLBACK (on_long_name_changed), - label); - item->_priv->notify_stock_id = - g_signal_connect (item, "notify::stock-id", G_CALLBACK (on_stock_id_changed), - icon); - - gtk_widget_show_all (hbox); - - gdl_dock_item_set_tablabel (item, hbox); - item->_priv->intern_tab_label = TRUE; - - g_free (long_name); - g_free (stock_id); - } - - return g_object; -} - -static void -gdl_dock_item_set_property (GObject *g_object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) -{ - GdlDockItem *item = GDL_DOCK_ITEM (g_object); - - switch (prop_id) { - case PROP_ORIENTATION: - gdl_dock_item_set_orientation (item, g_value_get_enum (value)); - break; - case PROP_RESIZE: - item->resize = g_value_get_boolean (value); - gtk_widget_queue_resize (GTK_WIDGET (item)); - break; - case PROP_BEHAVIOR: - { - GdlDockItemBehavior old_beh = item->behavior; - item->behavior = g_value_get_flags (value); - - if ((old_beh ^ item->behavior) & GDL_DOCK_ITEM_BEH_LOCKED) { - if (GDL_DOCK_OBJECT_GET_MASTER (item)) - g_signal_emit_by_name (GDL_DOCK_OBJECT_GET_MASTER (item), - "layout-changed"); - g_object_notify (g_object, "locked"); - gdl_dock_item_showhide_grip (item); - } - - break; - } - case PROP_LOCKED: - { - GdlDockItemBehavior old_beh = item->behavior; - - if (g_value_get_boolean (value)) - item->behavior |= GDL_DOCK_ITEM_BEH_LOCKED; - else - item->behavior &= ~GDL_DOCK_ITEM_BEH_LOCKED; - - if (old_beh ^ item->behavior) { - gdl_dock_item_showhide_grip (item); - g_object_notify (g_object, "behavior"); - - if (GDL_DOCK_OBJECT_GET_MASTER (item)) - g_signal_emit_by_name (GDL_DOCK_OBJECT_GET_MASTER (item), - "layout-changed"); - } - break; - } - case PROP_PREFERRED_WIDTH: - item->_priv->preferred_width = g_value_get_int (value); - break; - case PROP_PREFERRED_HEIGHT: - item->_priv->preferred_height = g_value_get_int (value); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (g_object, prop_id, pspec); - break; - } -} - -static void -gdl_dock_item_get_property (GObject *g_object, - guint prop_id, - GValue *value, - GParamSpec *pspec) -{ - GdlDockItem *item = GDL_DOCK_ITEM (g_object); - - switch (prop_id) { - case PROP_ORIENTATION: - g_value_set_enum (value, item->orientation); - break; - case PROP_RESIZE: - g_value_set_boolean (value, item->resize); - break; - case PROP_BEHAVIOR: - g_value_set_flags (value, item->behavior); - break; - case PROP_LOCKED: - g_value_set_boolean (value, !GDL_DOCK_ITEM_NOT_LOCKED (item)); - break; - case PROP_PREFERRED_WIDTH: - g_value_set_int (value, item->_priv->preferred_width); - break; - case PROP_PREFERRED_HEIGHT: - g_value_set_int (value, item->_priv->preferred_height); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (g_object, prop_id, pspec); - break; - } -} - -static void -gdl_dock_item_destroy (GtkObject *object) -{ - GdlDockItem *item = GDL_DOCK_ITEM (object); - - if (item->_priv) { - GdlDockItemPrivate *priv = item->_priv; - - if (priv->tab_label) { - gdl_dock_item_set_tablabel (item, NULL); - }; - if (priv->menu) { - gtk_menu_detach (GTK_MENU (priv->menu)); - priv->menu = NULL; - }; - if (priv->grip) { - gtk_container_remove (GTK_CONTAINER (item), priv->grip); - priv->grip = NULL; - } - if (priv->ph) { - g_object_unref (priv->ph); - priv->ph = NULL; - } - - item->_priv = NULL; - g_free (priv); - } - - GTK_OBJECT_CLASS (gdl_dock_item_parent_class)->destroy (object); -} - -static void -gdl_dock_item_add (GtkContainer *container, - GtkWidget *widget) -{ - GdlDockItem *item; - - g_return_if_fail (GDL_IS_DOCK_ITEM (container)); - - item = GDL_DOCK_ITEM (container); - if (GDL_IS_DOCK_OBJECT (widget)) { - g_warning (_("You can't add a dock object (%p of type %s) inside a %s. " - "Use a GdlDock or some other compound dock object."), - widget, G_OBJECT_TYPE_NAME (widget), G_OBJECT_TYPE_NAME (item)); - return; - } - - if (item->child != NULL) { - g_warning (_("Attempting to add a widget with type %s to a %s, " - "but it can only contain one widget at a time; " - "it already contains a widget of type %s"), - G_OBJECT_TYPE_NAME (widget), - G_OBJECT_TYPE_NAME (item), - G_OBJECT_TYPE_NAME (item->child)); - return; - } - - gtk_widget_set_parent (widget, GTK_WIDGET (item)); - item->child = widget; -} - -static void -gdl_dock_item_remove (GtkContainer *container, - GtkWidget *widget) -{ - GdlDockItem *item; - gboolean was_visible; - - g_return_if_fail (GDL_IS_DOCK_ITEM (container)); - - item = GDL_DOCK_ITEM (container); - if (item->_priv && widget == item->_priv->grip) { - gboolean grip_was_visible = gtk_widget_get_visible (widget); - gtk_widget_unparent (widget); - item->_priv->grip = NULL; - if (grip_was_visible) - gtk_widget_queue_resize (GTK_WIDGET (item)); - return; - } - - if (GDL_DOCK_ITEM_IN_DRAG (item)) { - gdl_dock_item_drag_end (item, TRUE); - } - - g_return_if_fail (item->child == widget); - - was_visible = gtk_widget_get_visible (widget); - - gtk_widget_unparent (widget); - item->child = NULL; - - if (was_visible) - gtk_widget_queue_resize (GTK_WIDGET (container)); -} - -static void -gdl_dock_item_forall (GtkContainer *container, - gboolean include_internals, - GtkCallback callback, - gpointer callback_data) -{ - GdlDockItem *item = (GdlDockItem *) container; - - g_return_if_fail (callback != NULL); - - if (include_internals && item->_priv->grip) - (* callback) (item->_priv->grip, callback_data); - - if (item->child) - (* callback) (item->child, callback_data); -} - -static GType -gdl_dock_item_child_type (GtkContainer *container) -{ - g_return_val_if_fail (GDL_IS_DOCK_ITEM (container), G_TYPE_NONE); - - if (!GDL_DOCK_ITEM (container)->child) - return GTK_TYPE_WIDGET; - else - return G_TYPE_NONE; -} - -static void -gdl_dock_item_set_focus_child (GtkContainer *container, - GtkWidget *child) -{ - g_return_if_fail (GDL_IS_DOCK_ITEM (container)); - - if (GTK_CONTAINER_CLASS (gdl_dock_item_parent_class)->set_focus_child) { - (* GTK_CONTAINER_CLASS (gdl_dock_item_parent_class)->set_focus_child) (container, child); - } - - gdl_dock_item_showhide_grip (GDL_DOCK_ITEM (container)); -} - -static void -gdl_dock_item_size_request (GtkWidget *widget, - GtkRequisition *requisition) -{ - GdlDockItem *item; - GtkRequisition child_requisition; - GtkRequisition grip_requisition; - GtkStyle *style; - guint border_width; - - g_return_if_fail (GDL_IS_DOCK_ITEM (widget)); - g_return_if_fail (requisition != NULL); - - item = GDL_DOCK_ITEM (widget); - - /* If our child is not visible, we still request its size, since - we won't have any useful hint for our size otherwise. */ - if (item->child) - gtk_widget_size_request (item->child, &child_requisition); - else { - child_requisition.width = 0; - child_requisition.height = 0; - } - - if (item->orientation == GTK_ORIENTATION_HORIZONTAL) { - if (GDL_DOCK_ITEM_GRIP_SHOWN (item)) { - gtk_widget_size_request (item->_priv->grip, &grip_requisition); - requisition->width = grip_requisition.width; - } else { - requisition->width = 0; - } - - if (item->child) { - requisition->width += child_requisition.width; - requisition->height = child_requisition.height; - } else - requisition->height = 0; - } else { - if (GDL_DOCK_ITEM_GRIP_SHOWN (item)) { - gtk_widget_size_request (item->_priv->grip, &grip_requisition); - requisition->height = grip_requisition.height; - } else { - requisition->height = 0; - } - - if (item->child) { - requisition->width = child_requisition.width; - requisition->height += child_requisition.height; - } else - requisition->width = 0; - } - - border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)); - style = gtk_widget_get_style (widget); - - requisition->width += (border_width + style->xthickness) * 2; - requisition->height += (border_width + style->ythickness) * 2; - - //gtk_widget_size_request (widget, requisition); -} - -static void -gdl_dock_item_size_allocate (GtkWidget *widget, - GtkAllocation *allocation) -{ - GdlDockItem *item; - - g_return_if_fail (GDL_IS_DOCK_ITEM (widget)); - g_return_if_fail (allocation != NULL); - - item = GDL_DOCK_ITEM (widget); - - gtk_widget_set_allocation (widget, allocation); - - /* Once size is allocated, preferred size is no longer necessary */ - item->_priv->preferred_height = -1; - item->_priv->preferred_width = -1; - - if (gtk_widget_get_realized (widget)) - gdk_window_move_resize (gtk_widget_get_window (widget), - allocation->x, - allocation->y, - allocation->width, - allocation->height); - - if (item->child && gtk_widget_get_visible (item->child)) { - GtkAllocation child_allocation; - GtkStyle *style; - guint border_width; - - border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)); - style = gtk_widget_get_style (widget); - - child_allocation.x = border_width + style->xthickness; - child_allocation.y = border_width + style->ythickness; - child_allocation.width = allocation->width - - 2 * (border_width + style->xthickness); - child_allocation.height = allocation->height - - 2 * (border_width + style->ythickness); - - if (GDL_DOCK_ITEM_GRIP_SHOWN (item)) { - GtkAllocation grip_alloc = child_allocation; - GtkRequisition grip_req; - - gtk_widget_size_request (item->_priv->grip, &grip_req); - - if (item->orientation == GTK_ORIENTATION_HORIZONTAL) { - child_allocation.x += grip_req.width; - child_allocation.width -= grip_req.width; - grip_alloc.width = grip_req.width; - } else { - child_allocation.y += grip_req.height; - child_allocation.height -= grip_req.height; - grip_alloc.height = grip_req.height; - } - if (item->_priv->grip) - gtk_widget_size_allocate (item->_priv->grip, &grip_alloc); - } - /* Allocation can't be negative */ - if (child_allocation.width < 0) - child_allocation.width = 0; - if (child_allocation.height < 0) - child_allocation.height = 0; - gtk_widget_size_allocate (item->child, &child_allocation); - } -} - -static void -gdl_dock_item_map (GtkWidget *widget) -{ - GdlDockItem *item; - - g_return_if_fail (widget != NULL); - g_return_if_fail (GDL_IS_DOCK_ITEM (widget)); - - gtk_widget_set_mapped (widget, TRUE); - - item = GDL_DOCK_ITEM (widget); - - gdk_window_show (gtk_widget_get_window (widget)); - - if (item->child - && gtk_widget_get_visible (item->child) - && !gtk_widget_get_mapped (item->child)) - gtk_widget_map (item->child); - - if (item->_priv->grip - && gtk_widget_get_visible (GTK_WIDGET (item->_priv->grip)) - && !gtk_widget_get_mapped (GTK_WIDGET (item->_priv->grip))) - gtk_widget_map (item->_priv->grip); -} - -static void -gdl_dock_item_unmap (GtkWidget *widget) -{ - GdlDockItem *item; - - g_return_if_fail (widget != NULL); - g_return_if_fail (GDL_IS_DOCK_ITEM (widget)); - - gtk_widget_set_mapped (widget, FALSE); - - item = GDL_DOCK_ITEM (widget); - - gdk_window_hide (gtk_widget_get_window (widget)); - - if (item->_priv->grip) - gtk_widget_unmap (item->_priv->grip); -} - -static void -gdl_dock_item_realize (GtkWidget *widget) -{ - GdlDockItem *item; - GtkAllocation allocation; - GdkWindow *window; - GdkWindowAttr attributes; - gint attributes_mask; - - g_return_if_fail (widget != NULL); - g_return_if_fail (GDL_IS_DOCK_ITEM (widget)); - - item = GDL_DOCK_ITEM (widget); - - gtk_widget_set_realized (widget, TRUE); - - /* widget window */ - gtk_widget_get_allocation (widget, &allocation); - attributes.x = allocation.x; - attributes.y = allocation.y; - attributes.width = allocation.width; - attributes.height = allocation.height; - attributes.window_type = GDK_WINDOW_CHILD; - attributes.wclass = GDK_INPUT_OUTPUT; - attributes.visual = gtk_widget_get_visual (widget); - attributes.colormap = gtk_widget_get_colormap (widget); - attributes.event_mask = (gtk_widget_get_events (widget) | - GDK_EXPOSURE_MASK | - GDK_BUTTON1_MOTION_MASK | - GDK_BUTTON_PRESS_MASK | - GDK_BUTTON_RELEASE_MASK); - attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; - window = gdk_window_new (gtk_widget_get_parent_window (widget), - &attributes, attributes_mask); - gtk_widget_set_window (widget, window); - gdk_window_set_user_data (window, widget); - - gtk_widget_style_attach (widget); - gtk_style_set_background (gtk_widget_get_style (widget), window, - gtk_widget_get_state (GTK_WIDGET (item))); - gdk_window_set_back_pixmap (window, NULL, TRUE); - - if (item->child) - gtk_widget_set_parent_window (item->child, window); - - if (item->_priv->grip) - gtk_widget_set_parent_window (item->_priv->grip, window); -} - -static void -gdl_dock_item_style_set (GtkWidget *widget, - GtkStyle *previous_style) -{ - GdkWindow *window; - - g_return_if_fail (widget != NULL); - g_return_if_fail (GDL_IS_DOCK_ITEM (widget)); - - if (gtk_widget_get_realized (widget) && - gtk_widget_get_has_window (widget)) - { - window = gtk_widget_get_window (widget); - gtk_style_set_background (gtk_widget_get_style (widget), - window, - gtk_widget_get_state (widget)); - if (gtk_widget_is_drawable (widget)) - gdk_window_clear (window); - } -} - -static void -gdl_dock_item_paint (GtkWidget *widget, - GdkEventExpose *event) -{ - GdlDockItem *item; - - item = GDL_DOCK_ITEM (widget); - - gtk_paint_box (gtk_widget_get_style (widget), - gtk_widget_get_window (widget), - gtk_widget_get_state (widget), - GTK_SHADOW_NONE, - &event->area, widget, - "dockitem", - 0, 0, -1, -1); - -/* see bug #950556: avoid regression with GTK2/Quartz */ -#if !defined(GDK_WINDOWING_QUARTZ) - if (GTK_IS_WIDGET(item->_priv->grip)) - gtk_widget_queue_draw (GTK_WIDGET(item->_priv->grip)); -#endif -} - -static gint -gdl_dock_item_expose (GtkWidget *widget, - GdkEventExpose *event) -{ - g_return_val_if_fail (widget != NULL, FALSE); - g_return_val_if_fail (GDL_IS_DOCK_ITEM (widget), FALSE); - g_return_val_if_fail (event != NULL, FALSE); - - if (gtk_widget_is_drawable (widget) && - event->window == gtk_widget_get_window (widget)) - { - gdl_dock_item_paint (widget, event); - GTK_WIDGET_CLASS (gdl_dock_item_parent_class)->expose_event (widget,event); - } - - return FALSE; -} - -static void -gdl_dock_item_move_focus_child (GdlDockItem *item, - GtkDirectionType dir) -{ - g_return_if_fail (GDL_IS_DOCK_ITEM (item)); - gtk_widget_child_focus (GTK_WIDGET (item->child), dir); -} - -#define EVENT_IN_GRIP_EVENT_WINDOW(ev,gr) \ - ((gr) != NULL && (ev)->window == GDL_DOCK_ITEM_GRIP (gr)->title_window) - -#define EVENT_IN_TABLABEL_EVENT_WINDOW(ev,tl) \ - ((tl) != NULL && (ev)->window == GDL_DOCK_TABLABEL (tl)->event_window) - -static gint -gdl_dock_item_button_changed (GtkWidget *widget, - GdkEventButton *event) -{ - GdlDockItem *item; - GtkAllocation allocation; - GdkCursor *cursor; - gboolean locked; - gboolean event_handled; - gboolean in_handle; - - g_return_val_if_fail (widget != NULL, FALSE); - g_return_val_if_fail (GDL_IS_DOCK_ITEM (widget), FALSE); - g_return_val_if_fail (event != NULL, FALSE); - - item = GDL_DOCK_ITEM (widget); - - if (!EVENT_IN_GRIP_EVENT_WINDOW (event, item->_priv->grip)) - return FALSE; - - locked = !GDL_DOCK_ITEM_NOT_LOCKED (item); - - event_handled = FALSE; - - gtk_widget_get_allocation (item->_priv->grip, &allocation); - - /* Check if user clicked on the drag handle. */ - switch (item->orientation) { - case GTK_ORIENTATION_HORIZONTAL: - in_handle = event->x < allocation.width; - break; - case GTK_ORIENTATION_VERTICAL: - in_handle = event->y < allocation.height; - break; - default: - in_handle = FALSE; - break; - } - - /* Left mousebutton click on dockitem. */ - if (!locked && event->button == 1 && event->type == GDK_BUTTON_PRESS) { - - if (!gdl_dock_item_or_child_has_focus (item)) - gtk_widget_grab_focus (GTK_WIDGET (item)); - - /* Set in_drag flag, grab pointer and call begin drag operation. */ - if (in_handle) { - item->_priv->start_x = event->x; - item->_priv->start_y = event->y; - - GDL_DOCK_ITEM_SET_FLAGS (item, GDL_DOCK_IN_PREDRAG); - - cursor = gdk_cursor_new_for_display (gtk_widget_get_display (widget), - GDK_FLEUR); - gdk_window_set_cursor (GDL_DOCK_ITEM_GRIP (item->_priv->grip)->title_window, - cursor); - gdk_cursor_unref (cursor); - - event_handled = TRUE; - }; - - } else if (!locked &&event->type == GDK_BUTTON_RELEASE && event->button == 1) { - if (GDL_DOCK_ITEM_IN_DRAG (item)) { - /* User dropped widget somewhere. */ - gdl_dock_item_drag_end (item, FALSE); - gtk_widget_grab_focus (GTK_WIDGET (item)); - event_handled = TRUE; - } - else if (GDL_DOCK_ITEM_IN_PREDRAG (item)) { - GDL_DOCK_ITEM_UNSET_FLAGS (item, GDL_DOCK_IN_PREDRAG); - event_handled = TRUE; - } - - /* we check the window since if the item was redocked it's - been unrealized and maybe it's not realized again yet */ - if (GDL_DOCK_ITEM_GRIP (item->_priv->grip)->title_window) { - cursor = gdk_cursor_new_for_display (gtk_widget_get_display (widget), - GDK_HAND2); - gdk_window_set_cursor (GDL_DOCK_ITEM_GRIP (item->_priv->grip)->title_window, - cursor); - gdk_cursor_unref (cursor); - } - - } else if (event->button == 3 && event->type == GDK_BUTTON_PRESS && in_handle) { - gdl_dock_item_popup_menu (item, event->button, event->time); - event_handled = TRUE; - } - - return event_handled; -} - -static gint -gdl_dock_item_motion (GtkWidget *widget, - GdkEventMotion *event) -{ - GdlDockItem *item; - gint new_x, new_y; - - g_return_val_if_fail (widget != NULL, FALSE); - g_return_val_if_fail (GDL_IS_DOCK_ITEM (widget), FALSE); - g_return_val_if_fail (event != NULL, FALSE); - - item = GDL_DOCK_ITEM (widget); - - if (!EVENT_IN_GRIP_EVENT_WINDOW (event, item->_priv->grip)) - return FALSE; - - if (GDL_DOCK_ITEM_IN_PREDRAG (item)) { - if (gtk_drag_check_threshold (widget, - item->_priv->start_x, - item->_priv->start_y, - event->x, - event->y)) { - GDL_DOCK_ITEM_UNSET_FLAGS (item, GDL_DOCK_IN_PREDRAG); - item->dragoff_x = item->_priv->start_x; - item->dragoff_y = item->_priv->start_y; - - gdl_dock_item_drag_start (item); - } - } - - if (!GDL_DOCK_ITEM_IN_DRAG (item)) - return FALSE; - - new_x = event->x_root; - new_y = event->y_root; - - g_signal_emit (item, gdl_dock_item_signals [DOCK_DRAG_MOTION], - 0, new_x, new_y); - - return TRUE; -} - -static gboolean -gdl_dock_item_key_press (GtkWidget *widget, - GdkEventKey *event) -{ - gboolean event_handled = FALSE; - - if (GDL_DOCK_ITEM_IN_DRAG (widget)) { - if (event->keyval == GDK_Escape) { - gdl_dock_item_drag_end (GDL_DOCK_ITEM (widget), TRUE); - event_handled = TRUE; - } - } - - if (event_handled) - return TRUE; - else - return GTK_WIDGET_CLASS (gdl_dock_item_parent_class)->key_press_event (widget, event); -} - -static gboolean -gdl_dock_item_dock_request (GdlDockObject *object, - gint x, - gint y, - GdlDockRequest *request) -{ - GtkAllocation alloc; - gint rel_x, rel_y; - - /* we get (x,y) in our allocation coordinates system */ - - /* Get item's allocation. */ - gtk_widget_get_allocation (GTK_WIDGET (object), &alloc); - - /* Get coordinates relative to our window. */ - rel_x = x - alloc.x; - rel_y = y - alloc.y; - - /* Location is inside. */ - if (rel_x > 0 && rel_x < alloc.width && - rel_y > 0 && rel_y < alloc.height) { - float rx, ry; - GtkRequisition my, other; - gint divider = -1; - - /* this are for calculating the extra docking parameter */ - gdl_dock_item_preferred_size (GDL_DOCK_ITEM (request->applicant), &other); - gdl_dock_item_preferred_size (GDL_DOCK_ITEM (object), &my); - - /* Calculate location in terms of the available space (0-100%). */ - rx = (float) rel_x / alloc.width; - ry = (float) rel_y / alloc.height; - - /* Determine dock location. */ - if (rx < SPLIT_RATIO) { - request->position = GDL_DOCK_LEFT; - divider = other.width; - } - else if (rx > (1 - SPLIT_RATIO)) { - request->position = GDL_DOCK_RIGHT; - rx = 1 - rx; - divider = MAX (0, my.width - other.width); - } - else if (ry < SPLIT_RATIO && ry < rx) { - request->position = GDL_DOCK_TOP; - divider = other.height; - } - else if (ry > (1 - SPLIT_RATIO) && (1 - ry) < rx) { - request->position = GDL_DOCK_BOTTOM; - divider = MAX (0, my.height - other.height); - } - else - request->position = GDL_DOCK_CENTER; - - /* Reset rectangle coordinates to entire item. */ - request->rect.x = 0; - request->rect.y = 0; - request->rect.width = alloc.width; - request->rect.height = alloc.height; - - GdlDockItemBehavior behavior = GDL_DOCK_ITEM(object)->behavior; - - /* Calculate docking indicator rectangle size for new locations. Only - do this when we're not over the item's current location. */ - if (request->applicant != object) { - switch (request->position) { - case GDL_DOCK_TOP: - if (behavior & GDL_DOCK_ITEM_BEH_CANT_DOCK_TOP) - return FALSE; - request->rect.height *= SPLIT_RATIO; - break; - case GDL_DOCK_BOTTOM: - if (behavior & GDL_DOCK_ITEM_BEH_CANT_DOCK_BOTTOM) - return FALSE; - request->rect.y += request->rect.height * (1 - SPLIT_RATIO); - request->rect.height *= SPLIT_RATIO; - break; - case GDL_DOCK_LEFT: - if (behavior & GDL_DOCK_ITEM_BEH_CANT_DOCK_LEFT) - return FALSE; - request->rect.width *= SPLIT_RATIO; - break; - case GDL_DOCK_RIGHT: - if (behavior & GDL_DOCK_ITEM_BEH_CANT_DOCK_RIGHT) - return FALSE; - request->rect.x += request->rect.width * (1 - SPLIT_RATIO); - request->rect.width *= SPLIT_RATIO; - break; - case GDL_DOCK_CENTER: - if (behavior & GDL_DOCK_ITEM_BEH_CANT_DOCK_CENTER) - return FALSE; - request->rect.x = request->rect.width * SPLIT_RATIO/2; - request->rect.y = request->rect.height * SPLIT_RATIO/2; - request->rect.width = (request->rect.width * - (1 - SPLIT_RATIO/2)) - request->rect.x; - request->rect.height = (request->rect.height * - (1 - SPLIT_RATIO/2)) - request->rect.y; - break; - default: - break; - } - } - - /* adjust returned coordinates so they are have the same - origin as our window */ - request->rect.x += alloc.x; - request->rect.y += alloc.y; - - /* Set possible target location and return TRUE. */ - request->target = object; - - /* fill-in other dock information */ - if (request->position != GDL_DOCK_CENTER && divider >= 0) { - if (G_IS_VALUE (&request->extra)) - g_value_unset (&request->extra); - g_value_init (&request->extra, G_TYPE_UINT); - g_value_set_uint (&request->extra, (guint) divider); - } - - return TRUE; - } - else /* No docking possible at this location. */ - return FALSE; -} - -static void -gdl_dock_item_dock (GdlDockObject *object, - GdlDockObject *requestor, - GdlDockPlacement position, - GValue *other_data) -{ - GdlDockObject *new_parent = NULL; - GdlDockObject *parent, *requestor_parent; - GtkAllocation allocation; - gboolean add_ourselves_first = FALSE; - - guint available_space=0; - gint pref_size=-1; - guint splitpos=0; - GtkRequisition req, object_req, parent_req; - - parent = gdl_dock_object_get_parent_object (object); - gdl_dock_item_preferred_size (GDL_DOCK_ITEM (requestor), &req); - gdl_dock_item_preferred_size (GDL_DOCK_ITEM (object), &object_req); - if (GDL_IS_DOCK_ITEM (parent)) - gdl_dock_item_preferred_size (GDL_DOCK_ITEM (parent), &parent_req); - else - { - gtk_widget_get_allocation (GTK_WIDGET (parent), &allocation); - parent_req.height = allocation.height; - parent_req.width = allocation.width; - } - - /* If preferred size is not set on the requestor (perhaps a new item), - * then estimate and set it. The default value (either 0 or 1 pixels) is - * not any good. - */ - switch (position) { - case GDL_DOCK_TOP: - case GDL_DOCK_BOTTOM: - if (req.width < 2) - { - req.width = object_req.width; - g_object_set (requestor, "preferred-width", req.width, NULL); - } - if (req.height < 2) - { - req.height = NEW_DOCK_ITEM_RATIO * object_req.height; - g_object_set (requestor, "preferred-height", req.height, NULL); - } - if (req.width > 1) - g_object_set (object, "preferred-width", req.width, NULL); - if (req.height > 1) - g_object_set (object, "preferred-height", - object_req.height - req.height, NULL); - break; - case GDL_DOCK_LEFT: - case GDL_DOCK_RIGHT: - if (req.height < 2) - { - req.height = object_req.height; - g_object_set (requestor, "preferred-height", req.height, NULL); - } - if (req.width < 2) - { - req.width = NEW_DOCK_ITEM_RATIO * object_req.width; - g_object_set (requestor, "preferred-width", req.width, NULL); - } - if (req.height > 1) - g_object_set (object, "preferred-height", req.height, NULL); - if (req.width > 1) - g_object_set (object, "preferred-width", - object_req.width - req.width, NULL); - break; - case GDL_DOCK_CENTER: - if (req.height < 2) - { - req.height = object_req.height; - g_object_set (requestor, "preferred-height", req.height, NULL); - } - if (req.width < 2) - { - req.width = object_req.width; - g_object_set (requestor, "preferred-width", req.width, NULL); - } - if (req.height > 1) - g_object_set (object, "preferred-height", req.height, NULL); - if (req.width > 1) - g_object_set (object, "preferred-width", req.width, NULL); - break; - default: - { - GEnumClass *enum_class = G_ENUM_CLASS (g_type_class_ref (GDL_TYPE_DOCK_PLACEMENT)); - GEnumValue *enum_value = g_enum_get_value (enum_class, position); - const gchar *name = enum_value ? enum_value->value_name : NULL; - - g_warning (_("Unsupported docking strategy %s in dock object of type %s"), - name, G_OBJECT_TYPE_NAME (object)); - g_type_class_unref (enum_class); - return; - } - } - switch (position) { - case GDL_DOCK_TOP: - case GDL_DOCK_BOTTOM: - /* get a paned style dock object */ - new_parent = g_object_new (gdl_dock_object_type_from_nick ("paned"), - "orientation", GTK_ORIENTATION_VERTICAL, - "preferred-width", object_req.width, - "preferred-height", object_req.height, - NULL); - add_ourselves_first = (position == GDL_DOCK_BOTTOM); - if (parent) - available_space = parent_req.height; - pref_size = req.height; - break; - case GDL_DOCK_LEFT: - case GDL_DOCK_RIGHT: - new_parent = g_object_new (gdl_dock_object_type_from_nick ("paned"), - "orientation", GTK_ORIENTATION_HORIZONTAL, - "preferred-width", object_req.width, - "preferred-height", object_req.height, - NULL); - add_ourselves_first = (position == GDL_DOCK_RIGHT); - if(parent) - available_space = parent_req.width; - pref_size = req.width; - break; - case GDL_DOCK_CENTER: - /* If the parent is already a DockNotebook, we don't need - to create a new one. */ - if (!GDL_IS_DOCK_NOTEBOOK (parent)) - { - new_parent = g_object_new (gdl_dock_object_type_from_nick ("notebook"), - "preferred-width", object_req.width, - "preferred-height", object_req.height, - NULL); - add_ourselves_first = TRUE; - } - break; - default: - { - GEnumClass *enum_class = G_ENUM_CLASS (g_type_class_ref (GDL_TYPE_DOCK_PLACEMENT)); - GEnumValue *enum_value = g_enum_get_value (enum_class, position); - const gchar *name = enum_value ? enum_value->value_name : NULL; - - g_warning (_("Unsupported docking strategy %s in dock object of type %s"), - name, G_OBJECT_TYPE_NAME (object)); - g_type_class_unref (enum_class); - return; - } - } - - /* freeze the parent so it doesn't reduce automatically */ - if (parent) - gdl_dock_object_freeze (parent); - - - if (new_parent) - { - /* ref ourselves since we could be destroyed when detached */ - g_object_ref (object); - GDL_DOCK_OBJECT_SET_FLAGS (object, GDL_DOCK_IN_REFLOW); - gdl_dock_object_detach (object, FALSE); - - /* freeze the new parent, so reduce won't get called before it's - actually added to our parent */ - gdl_dock_object_freeze (new_parent); - - /* bind the new parent to our master, so the following adds work */ - gdl_dock_object_bind (new_parent, G_OBJECT (GDL_DOCK_OBJECT_GET_MASTER (object))); - - /* add the objects */ - if (add_ourselves_first) { - gtk_container_add (GTK_CONTAINER (new_parent), GTK_WIDGET (object)); - gtk_container_add (GTK_CONTAINER (new_parent), GTK_WIDGET (requestor)); - splitpos = available_space - pref_size; - } else { - gtk_container_add (GTK_CONTAINER (new_parent), GTK_WIDGET (requestor)); - gtk_container_add (GTK_CONTAINER (new_parent), GTK_WIDGET (object)); - splitpos = pref_size; - } - - /* add the new parent to the parent */ - if (parent) - gtk_container_add (GTK_CONTAINER (parent), GTK_WIDGET (new_parent)); - - /* show automatic object */ - if (gtk_widget_get_visible (GTK_WIDGET (object))) - { - gtk_widget_show (GTK_WIDGET (new_parent)); - GDL_DOCK_OBJECT_UNSET_FLAGS (object, GDL_DOCK_IN_REFLOW); - } - gdl_dock_object_thaw (new_parent); - - /* use extra docking parameter */ - if (position != GDL_DOCK_CENTER && other_data && - G_VALUE_HOLDS (other_data, G_TYPE_UINT)) { - - g_object_set (G_OBJECT (new_parent), - "position", g_value_get_uint (other_data), - NULL); - } else if (splitpos > 0 && splitpos < available_space) { - g_object_set (G_OBJECT (new_parent), "position", splitpos, NULL); - } - - g_object_unref (object); - } - else - { - /* If the parent is already a DockNotebook, we don't need - to create a new one. */ - gtk_container_add (GTK_CONTAINER (parent), GTK_WIDGET (requestor)); - } - - requestor_parent = gdl_dock_object_get_parent_object (requestor); - if (GDL_IS_DOCK_NOTEBOOK (requestor_parent)) - { - /* Activate the page we just added */ - GdlDockItem* notebook = GDL_DOCK_ITEM (gdl_dock_object_get_parent_object (requestor)); - gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook->child), - gtk_notebook_page_num (GTK_NOTEBOOK (notebook->child), GTK_WIDGET (requestor))); - } - - if (parent) - gdl_dock_object_thaw (parent); -} - -static void -gdl_dock_item_detach_menu (GtkWidget *widget, - GtkMenu *menu) -{ - GdlDockItem *item; - - item = GDL_DOCK_ITEM (widget); - item->_priv->menu = NULL; -} - -static void -gdl_dock_item_popup_menu (GdlDockItem *item, - guint button, - guint32 time) -{ - GtkWidget *mitem; - - if (!item->_priv->menu) { - /* Create popup menu and attach it to the dock item */ - item->_priv->menu = gtk_menu_new (); - gtk_menu_attach_to_widget (GTK_MENU (item->_priv->menu), - GTK_WIDGET (item), - gdl_dock_item_detach_menu); - - if (item->behavior & GDL_DOCK_ITEM_BEH_LOCKED) { - /* UnLock menuitem */ - mitem = gtk_menu_item_new_with_label (_("UnLock")); - gtk_menu_shell_append (GTK_MENU_SHELL (item->_priv->menu), - mitem); - g_signal_connect (mitem, "activate", - G_CALLBACK (gdl_dock_item_unlock_cb), item); - } else { - /* Hide menuitem. */ - mitem = gtk_menu_item_new_with_label (_("Hide")); - gtk_menu_shell_append (GTK_MENU_SHELL (item->_priv->menu), mitem); - g_signal_connect (mitem, "activate", - G_CALLBACK (gdl_dock_item_hide_cb), item); - /* Lock menuitem */ - mitem = gtk_menu_item_new_with_label (_("Lock")); - gtk_menu_shell_append (GTK_MENU_SHELL (item->_priv->menu), mitem); - g_signal_connect (mitem, "activate", - G_CALLBACK (gdl_dock_item_lock_cb), item); - } - } - - /* Show popup menu. */ - gtk_widget_show_all (item->_priv->menu); - gtk_menu_popup (GTK_MENU (item->_priv->menu), NULL, NULL, NULL, NULL, - button, time); -} - -static void -gdl_dock_item_drag_start (GdlDockItem *item) -{ - GdkCursor *fleur; - - if (!gtk_widget_get_realized (GTK_WIDGET (item))) - gtk_widget_realize (GTK_WIDGET (item)); - - GDL_DOCK_ITEM_SET_FLAGS (item, GDL_DOCK_IN_DRAG); - - /* grab the pointer so we receive all mouse events */ - fleur = gdk_cursor_new (GDK_FLEUR); - - /* grab the keyboard & pointer */ - gtk_grab_add (GTK_WIDGET (item)); - - gdk_cursor_unref (fleur); - - g_signal_emit (item, gdl_dock_item_signals [DOCK_DRAG_BEGIN], 0); -} - -static void -gdl_dock_item_drag_end (GdlDockItem *item, - gboolean cancel) -{ - /* Release pointer & keyboard. */ - GtkWidget *widget = gtk_grab_get_current (); - if (widget == NULL) { - widget = GTK_WIDGET (item); - } - gtk_grab_remove (widget); - - g_signal_emit (item, gdl_dock_item_signals [DOCK_DRAG_END], 0, cancel); - - GDL_DOCK_ITEM_UNSET_FLAGS (item, GDL_DOCK_IN_DRAG); -} - -static void -gdl_dock_item_tab_button (GtkWidget *widget, - GdkEventButton *event, - gpointer data) -{ - GdlDockItem *item; - GtkAllocation allocation; - - item = GDL_DOCK_ITEM (data); - - if (!GDL_DOCK_ITEM_NOT_LOCKED (item)) - return; - - switch (event->button) { - case 1: - /* set dragoff_{x,y} as we the user clicked on the middle of the - drag handle */ - switch (item->orientation) { - case GTK_ORIENTATION_HORIZONTAL: - gtk_widget_get_allocation (GTK_WIDGET (data), &allocation); - /*item->dragoff_x = item->_priv->grip_size / 2;*/ - item->dragoff_y = allocation.height / 2; - break; - case GTK_ORIENTATION_VERTICAL: - /*item->dragoff_x = GTK_WIDGET (data)->allocation.width / 2;*/ - item->dragoff_y = item->_priv->grip_size / 2; - break; - }; - gdl_dock_item_drag_start (item); - break; - - case 3: - gdl_dock_item_popup_menu (item, event->button, event->time); - break; - - default: - break; - }; -} - -static void -gdl_dock_item_hide_cb (GtkWidget *widget, - GdlDockItem *item) -{ - GdlDockMaster *master; - - g_return_if_fail (item != NULL); - - master = GDL_DOCK_OBJECT_GET_MASTER (item); - gdl_dock_item_hide_item (item); -} - -static void -gdl_dock_item_lock_cb (GtkWidget *widget, - GdlDockItem *item) -{ - g_return_if_fail (item != NULL); - - gdl_dock_item_lock (item); -} - -static void -gdl_dock_item_unlock_cb (GtkWidget *widget, - GdlDockItem *item) -{ - g_return_if_fail (item != NULL); - - gdl_dock_item_unlock (item); -} - -static void -gdl_dock_item_showhide_grip (GdlDockItem *item) -{ - GdkDisplay *display; - GdkCursor *cursor; - - gdl_dock_item_detach_menu (GTK_WIDGET (item), NULL); - display = gtk_widget_get_display (GTK_WIDGET (item)); - cursor = NULL; - - if (item->_priv->grip) { - if (GDL_DOCK_ITEM_GRIP_SHOWN (item) && - GDL_DOCK_ITEM_NOT_LOCKED(item)) - cursor = gdk_cursor_new_for_display (display, GDK_HAND2); - } - if (item->_priv->grip && GDL_DOCK_ITEM_GRIP (item->_priv->grip)->title_window) - gdk_window_set_cursor (GDL_DOCK_ITEM_GRIP (item->_priv->grip)->title_window, cursor); - - if (cursor) - gdk_cursor_unref (cursor); - - gtk_widget_queue_resize (GTK_WIDGET (item)); -} - -static void -gdl_dock_item_real_set_orientation (GdlDockItem *item, - GtkOrientation orientation) -{ - item->orientation = orientation; - - if (gtk_widget_is_drawable (GTK_WIDGET (item))) - gtk_widget_queue_draw (GTK_WIDGET (item)); - gtk_widget_queue_resize (GTK_WIDGET (item)); -} - - -/* ----- Public interface ----- */ - -/** - * gdl_dock_item_new: - * @name: Unique name for identifying the dock object. - * @long_name: Human readable name for the dock object. - * @behavior: General behavior for the dock item (i.e. whether it can - * float, if it's locked, etc.), as specified by - * #GdlDockItemBehavior flags. - * - * Creates a new dock item widget. - * Returns: The newly created dock item grip widget. - **/ -GtkWidget * -gdl_dock_item_new (const gchar *name, - const gchar *long_name, - GdlDockItemBehavior behavior) -{ - GdlDockItem *item; - - item = GDL_DOCK_ITEM (g_object_new (GDL_TYPE_DOCK_ITEM, - "name", name, - "long-name", long_name, - "behavior", behavior, - NULL)); - GDL_DOCK_OBJECT_UNSET_FLAGS (item, GDL_DOCK_AUTOMATIC); - - return GTK_WIDGET (item); -} - -/** - * gdl_dock_item_new_with_stock: - * @name: Unique name for identifying the dock object. - * @long_name: Human readable name for the dock object. - * @stock_id: Stock icon for the dock object. - * @behavior: General behavior for the dock item (i.e. whether it can - * float, if it's locked, etc.), as specified by - * #GdlDockItemBehavior flags. - * - * Creates a new dock item grip widget with a given stock id. - * Returns: The newly created dock item grip widget. - **/ -GtkWidget * -gdl_dock_item_new_with_stock (const gchar *name, - const gchar *long_name, - const gchar *stock_id, - GdlDockItemBehavior behavior) -{ - GdlDockItem *item; - - item = GDL_DOCK_ITEM (g_object_new (GDL_TYPE_DOCK_ITEM, - "name", name, - "long-name", long_name, - "stock-id", stock_id, - "behavior", behavior, - NULL)); - GDL_DOCK_OBJECT_UNSET_FLAGS (item, GDL_DOCK_AUTOMATIC); - - return GTK_WIDGET (item); -} - -GtkWidget * -gdl_dock_item_new_with_pixbuf_icon (const gchar *name, - const gchar *long_name, - const GdkPixbuf *pixbuf_icon, - GdlDockItemBehavior behavior) -{ - GdlDockItem *item; - - item = GDL_DOCK_ITEM (g_object_new (GDL_TYPE_DOCK_ITEM, - "name", name, - "long-name", long_name, - "pixbuf-icon", pixbuf_icon, - "behavior", behavior, - NULL)); - - GDL_DOCK_OBJECT_UNSET_FLAGS (item, GDL_DOCK_AUTOMATIC); - gdl_dock_item_set_tablabel (item, gtk_label_new (long_name)); - - return GTK_WIDGET (item); -} - -/* convenient function (and to preserve source compat) */ -/** - * gdl_dock_item_dock_to: - * @item: The dock item that will be relocated to the dock position. - * @target: (allow-none): The dock item that will be used as the point of reference. - * @position: The position to dock #item, relative to #target. - * @docking_param: This value is unused, and will be ignored. - * - * Relocates a dock item to a new location relative to another dock item. - **/ -void -gdl_dock_item_dock_to (GdlDockItem *item, - GdlDockItem *target, - GdlDockPlacement position, - gint docking_param) -{ - g_return_if_fail (item != NULL); - g_return_if_fail (item != target); - g_return_if_fail (target != NULL || position == GDL_DOCK_FLOATING); - g_return_if_fail ((item->behavior & GDL_DOCK_ITEM_BEH_NEVER_FLOATING) == 0 || position != GDL_DOCK_FLOATING); - - if (position == GDL_DOCK_FLOATING || !target) { - GdlDockObject *controller; - - if (!gdl_dock_object_is_bound (GDL_DOCK_OBJECT (item))) { - g_warning (_("Attempt to bind an unbound item %p"), item); - return; - } - - controller = gdl_dock_master_get_controller (GDL_DOCK_OBJECT_GET_MASTER (item)); - - /* FIXME: save previous docking position for later - re-docking... does this make sense now? */ - - /* Create new floating dock for widget. */ - item->dragoff_x = item->dragoff_y = 0; - gdl_dock_add_floating_item (GDL_DOCK (controller), - item, 0, 0, -1, -1); - - } else - gdl_dock_object_dock (GDL_DOCK_OBJECT (target), - GDL_DOCK_OBJECT (item), - position, NULL); -} - -/** - * gdl_dock_item_set_orientation: - * @item: The dock item which will get it's orientation set. - * @orientation: The orientation to set the item to. If the orientation - * is set to #GTK_ORIENTATION_VERTICAL, the grip widget will be shown - * along the top of the edge of item (if it is not hidden). If the - * orientation is set to #GTK_ORIENTATION_HORIZONTAL, the grip widget - * will be shown down the left edge of the item (even if the widget - * text direction is set to RTL). - * - * This function sets the layout of the dock item. - **/ -void -gdl_dock_item_set_orientation (GdlDockItem *item, - GtkOrientation orientation) -{ - GParamSpec *pspec; - - g_return_if_fail (item != NULL); - - if (item->orientation != orientation) { - /* push the property down the hierarchy if our child supports it */ - if (item->child != NULL) { - pspec = g_object_class_find_property ( - G_OBJECT_GET_CLASS (item->child), "orientation"); - if (pspec && pspec->value_type == GTK_TYPE_ORIENTATION) - g_object_set (G_OBJECT (item->child), - "orientation", orientation, - NULL); - }; - if (GDL_DOCK_ITEM_GET_CLASS (item)->set_orientation) - GDL_DOCK_ITEM_GET_CLASS (item)->set_orientation (item, orientation); - g_object_notify (G_OBJECT (item), "orientation"); - } -} - -/** - * gdl_dock_item_get_tablabel: - * @item: The dock item from which to get the tab label widget. - * - * Gets the current tab label widget. Note that this label widget is - * only visible when the "switcher-style" property of the #GdlDockMaster - * is set to #GDL_SWITCHER_STYLE_TABS - * - * Returns: Returns the tab label widget. - **/ -GtkWidget * -gdl_dock_item_get_tablabel (GdlDockItem *item) -{ - g_return_val_if_fail (item != NULL, NULL); - g_return_val_if_fail (GDL_IS_DOCK_ITEM (item), NULL); - - return item->_priv->tab_label; -} - -/** - * gdl_dock_item_set_tablabel: - * @item: The dock item which will get it's tab label widget set. - * @tablabel: The widget that will become the tab label. - * - * Replaces the current tab label widget with another widget. Note that - * this label widget is only visible when the "switcher-style" property - * of the #GdlDockMaster is set to #GDL_SWITCHER_STYLE_TABS - **/ -void -gdl_dock_item_set_tablabel (GdlDockItem *item, - GtkWidget *tablabel) -{ - g_return_if_fail (item != NULL); - - if (item->_priv->intern_tab_label) - { - item->_priv->intern_tab_label = FALSE; - g_signal_handler_disconnect (item, item->_priv->notify_label); - g_signal_handler_disconnect (item, item->_priv->notify_stock_id); - } - - if (item->_priv->tab_label) { - /* disconnect and unref the previous tablabel */ - if (GDL_IS_DOCK_TABLABEL (item->_priv->tab_label)) { - g_signal_handlers_disconnect_matched (item->_priv->tab_label, - G_SIGNAL_MATCH_DATA, - 0, 0, NULL, - NULL, item); - g_object_set (item->_priv->tab_label, "item", NULL, NULL); - } - g_object_unref (item->_priv->tab_label); - item->_priv->tab_label = NULL; - } - - if (tablabel) { - g_object_ref_sink (G_OBJECT (tablabel)); - item->_priv->tab_label = tablabel; - if (GDL_IS_DOCK_TABLABEL (tablabel)) { - g_object_set (tablabel, "item", item, NULL); - /* connect to tablabel signal */ - g_signal_connect (tablabel, "button_pressed_handle", - G_CALLBACK (gdl_dock_item_tab_button), item); - } - } -} - -/** - * gdl_dock_item_get_grip: - * @item: The dock item from which to to get the grip of. - * - * This function returns the dock item's grip label widget. - * - * Returns: Returns the current label widget. - **/ -GtkWidget * -gdl_dock_item_get_grip(GdlDockItem *item) -{ - g_return_val_if_fail (item != NULL, NULL); - g_return_val_if_fail (GDL_IS_DOCK_ITEM (item), NULL); - - return item->_priv->grip; -} - -/** - * gdl_dock_item_hide_grip: - * @item: The dock item to hide the grip of. - * - * This function hides the dock item's grip widget. - **/ -void -gdl_dock_item_hide_grip (GdlDockItem *item) -{ - g_return_if_fail (item != NULL); - if (item->_priv->grip_shown) { - item->_priv->grip_shown = FALSE; - gdl_dock_item_showhide_grip (item); - }; - g_warning ("Grips always show unless GDL_DOCK_ITEM_BEH_NO_GRIP is set\n" ); -} - -/** - * gdl_dock_item_show_grip: - * @item: The dock item to show the grip of. - * - * This function shows the dock item's grip widget. - **/ -void -gdl_dock_item_show_grip (GdlDockItem *item) -{ - g_return_if_fail (item != NULL); - if (!item->_priv->grip_shown) { - item->_priv->grip_shown = TRUE; - gdl_dock_item_showhide_grip (item); - }; -} - -/** - * gdl_dock_item_notify_selected: - * @item: the dock item to emit a selected signal on. - * - * This function emits the selected signal. It is to be used by #GdlSwitcher - * to let clients know that this item has been switched to. - **/ -void -gdl_dock_item_notify_selected (GdlDockItem *item) -{ - g_signal_emit (item, gdl_dock_item_signals [SELECTED], 0); -} - -/* convenient function (and to preserve source compat) */ -/** - * gdl_dock_item_bind: - * @item: The item to bind. - * @dock: The #GdlDock widget to bind it to. Note that this widget must - * be a type of #GdlDock. - * - * Binds this dock item to a new dock master. - **/ -void -gdl_dock_item_bind (GdlDockItem *item, - GtkWidget *dock) -{ - g_return_if_fail (item != NULL); - g_return_if_fail (dock == NULL || GDL_IS_DOCK (dock)); - - gdl_dock_object_bind (GDL_DOCK_OBJECT (item), - G_OBJECT (GDL_DOCK_OBJECT_GET_MASTER (dock))); -} - -/* convenient function (and to preserve source compat) */ -/** - * gdl_dock_item_unbind: - * @item: The item to unbind. - * - * Unbinds this dock item from it's dock master. - **/ -void -gdl_dock_item_unbind (GdlDockItem *item) -{ - g_return_if_fail (item != NULL); - - gdl_dock_object_unbind (GDL_DOCK_OBJECT (item)); -} - -/** - * gdl_dock_item_hide_item: - * @item: The dock item to hide. - * - * This function hides the dock item. When dock items are hidden they - * are completely removed from the layout. - * - * The dock item close button causes the panel to be hidden. - **/ -void -gdl_dock_item_hide_item (GdlDockItem *item) -{ - GtkAllocation allocation; - - g_return_if_fail (item != NULL); - - if (!GDL_DOCK_OBJECT_ATTACHED (item)) - /* already hidden/detached */ - return; - - /* if the object is manual, create a new placeholder to be able to - restore the position later */ - if (!GDL_DOCK_OBJECT_AUTOMATIC (item)) { - if (item->_priv->ph) - g_object_unref (item->_priv->ph); - - gboolean isFloating = FALSE; - gint width=0, height=0, x=0, y = 0; - - if (GDL_IS_DOCK (gdl_dock_object_get_parent_object (GDL_DOCK_OBJECT (item)))) - { - GdlDock* dock = GDL_DOCK (gdl_dock_object_get_parent_object (GDL_DOCK_OBJECT (item))); - g_object_get (dock, - "floating", &isFloating, - "width", &width, - "height",&height, - "floatx",&x, - "floaty",&y, - NULL); - } else { - gtk_widget_get_allocation (GTK_WIDGET (item), &allocation); - item->_priv->preferred_width = allocation.width; - item->_priv->preferred_height = allocation.height; - } - item->_priv->ph = GDL_DOCK_PLACEHOLDER ( - g_object_new (GDL_TYPE_DOCK_PLACEHOLDER, - "sticky", FALSE, - "host", item, - "width", width, - "height", height, - "floating", isFloating, - "floatx", x, - "floaty", y, - NULL)); - g_object_ref_sink (item->_priv->ph); - } - - gdl_dock_object_freeze (GDL_DOCK_OBJECT (item)); - - /* hide our children first, so they can also set placeholders */ - if (gdl_dock_object_is_compound (GDL_DOCK_OBJECT (item))) - gtk_container_foreach (GTK_CONTAINER (item), - (GtkCallback) gdl_dock_item_hide_item, - NULL); - - /* detach the item recursively */ - gdl_dock_object_detach (GDL_DOCK_OBJECT (item), TRUE); - - gtk_widget_hide (GTK_WIDGET (item)); - - gdl_dock_object_thaw (GDL_DOCK_OBJECT (item)); -} - -/** - * gdl_dock_item_iconify_item: - * @item: The dock item to iconify. - * - * This function iconifies the dock item. When dock items are iconified - * they are hidden, and appear only as icons in dock bars. - * - * The dock item iconify button causes the panel to be iconified. - **/ -void -gdl_dock_item_iconify_item (GdlDockItem *item) -{ - g_return_if_fail (item != NULL); - - GDL_DOCK_OBJECT_SET_FLAGS (item, GDL_DOCK_ICONIFIED); - gdl_dock_item_hide_item (item); -} - -/** - * gdl_dock_item_show_item: - * @item: The dock item to show. - * - * This function shows the dock item. When dock items are shown, they - * are displayed in their normal layout position. - **/ -void -gdl_dock_item_show_item (GdlDockItem *item) -{ - g_return_if_fail (item != NULL); - - GDL_DOCK_OBJECT_UNSET_FLAGS (item, GDL_DOCK_ICONIFIED); - - if (item->_priv->ph) { - gboolean isFloating=FALSE; - gint width = 0, height = 0, x= 0, y = 0; - g_object_get (G_OBJECT(item->_priv->ph), - "width", &width, - "height", &height, - "floating",&isFloating, - "floatx", &x, - "floaty", &y, - NULL); - if (isFloating) { - GdlDockObject *controller = - gdl_dock_master_get_controller (GDL_DOCK_OBJECT_GET_MASTER (item)); - gdl_dock_add_floating_item (GDL_DOCK (controller), - item, x, y, width, height); - } else { - gtk_container_add (GTK_CONTAINER (item->_priv->ph), - GTK_WIDGET (item)); - } - g_object_unref (item->_priv->ph); - item->_priv->ph = NULL; - - } else if (gdl_dock_object_is_bound (GDL_DOCK_OBJECT (item))) { - GdlDockObject *toplevel; - - toplevel = gdl_dock_master_get_controller - (GDL_DOCK_OBJECT_GET_MASTER (item)); - - if (item->behavior & GDL_DOCK_ITEM_BEH_NEVER_FLOATING) { - g_warning("Object %s has no default position and flag GDL_DOCK_ITEM_BEH_NEVER_FLOATING is set.\n", - GDL_DOCK_OBJECT(item)->name); - } else if (toplevel) { - gdl_dock_object_dock (toplevel, GDL_DOCK_OBJECT (item), - GDL_DOCK_FLOATING, NULL); - } else - g_warning("There is no toplevel window. GdlDockItem %s cannot be shown.\n", GDL_DOCK_OBJECT(item)->name); - - } else - g_warning("GdlDockItem %s is not bound. It cannot be shown.\n", - GDL_DOCK_OBJECT(item)->name); - - gtk_widget_show (GTK_WIDGET (item)); -} - -/** - * gdl_dock_item_lock: - * @item: The dock item to lock. - * - * This function locks the dock item. When locked the dock item cannot - * be dragged around and it doesn't show a grip. - **/ -void -gdl_dock_item_lock (GdlDockItem *item) -{ - g_object_set (item, "locked", TRUE, NULL); -} - -/** - * gdl_dock_item_unlock: - * @item: The dock item to unlock. - * - * This function unlocks the dock item. When unlocked the dock item can - * be dragged around and can show a grip. - **/ -void -gdl_dock_item_unlock (GdlDockItem *item) -{ - g_object_set (item, "locked", FALSE, NULL); -} - -/** - * gdl_dock_item_set_default_position: - * @item: The dock item - * @reference: The GdlDockObject which is the default dock for @item - * - * This method has only an effect when you add you dock_item with - * GDL_DOCK_ITEM_BEH_NEVER_FLOATING. In this case you have to assign - * it a default position. - **/ -void -gdl_dock_item_set_default_position (GdlDockItem *item, - GdlDockObject *reference) -{ - g_return_if_fail (item != NULL); - - if (item->_priv->ph) { - g_object_unref (item->_priv->ph); - item->_priv->ph = NULL; - } - - if (reference && GDL_DOCK_OBJECT_ATTACHED (reference)) { - if (GDL_IS_DOCK_PLACEHOLDER (reference)) { - g_object_ref_sink (reference); - item->_priv->ph = GDL_DOCK_PLACEHOLDER (reference); - } else { - item->_priv->ph = GDL_DOCK_PLACEHOLDER ( - g_object_new (GDL_TYPE_DOCK_PLACEHOLDER, - "sticky", TRUE, - "host", reference, - NULL)); - g_object_ref_sink (item->_priv->ph); - } - } -} - -/** - * gdl_dock_item_preferred_size: - * @item: The dock item to get the preferred size of. - * @req: A pointer to a #GtkRequisition into which the preferred size - * will be written. - * - * Gets the preferred size of the dock item in pixels. - **/ -void -gdl_dock_item_preferred_size (GdlDockItem *item, - GtkRequisition *req) -{ - GtkAllocation allocation; - - if (!req) - return; - - gtk_widget_get_allocation (GTK_WIDGET (item), &allocation); - - req->width = MAX (item->_priv->preferred_width, allocation.width); - req->height = MAX (item->_priv->preferred_height, allocation.height); -} - - -gboolean -gdl_dock_item_or_child_has_focus (GdlDockItem *item) -{ - GtkWidget *item_child; - gboolean item_or_child_has_focus; - - g_return_val_if_fail (GDL_IS_DOCK_ITEM (item), FALSE); - - for (item_child = gtk_container_get_focus_child (GTK_CONTAINER (item)); - item_child && GTK_IS_CONTAINER (item_child) && gtk_container_get_focus_child (GTK_CONTAINER (item_child)); - item_child = gtk_container_get_focus_child (GTK_CONTAINER (item_child))) ; - - item_or_child_has_focus = - (gtk_widget_has_focus (GTK_WIDGET (item)) || - (GTK_IS_WIDGET (item_child) && gtk_widget_has_focus (item_child))); - - return item_or_child_has_focus; -} - - -/* ----- gtk orientation type exporter/importer ----- */ - -static void -gdl_dock_param_export_gtk_orientation (const GValue *src, - GValue *dst) -{ - dst->data [0].v_pointer = - g_strdup_printf ("%s", (src->data [0].v_int == GTK_ORIENTATION_HORIZONTAL) ? - "horizontal" : "vertical"); -} - -static void -gdl_dock_param_import_gtk_orientation (const GValue *src, - GValue *dst) -{ - if (!strcmp (src->data [0].v_pointer, "horizontal")) - dst->data [0].v_int = GTK_ORIENTATION_HORIZONTAL; - else - dst->data [0].v_int = GTK_ORIENTATION_VERTICAL; -} - diff --git a/src/libgdl/gdl-dock-item.h b/src/libgdl/gdl-dock-item.h deleted file mode 100644 index b9378f783..000000000 --- a/src/libgdl/gdl-dock-item.h +++ /dev/null @@ -1,223 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * gdl-dock-item.h - * - * Author: Gustavo Giráldez <gustavo.giraldez@gmx.net> - * - * Based on GnomeDockItem/BonoboDockItem. Original copyright notice follows. - * - * Copyright (C) 1998 Ettore Perazzoli - * Copyright (C) 1998 Elliot Lee - * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald - * All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef __GDL_DOCK_ITEM_H__ -#define __GDL_DOCK_ITEM_H__ - -#include "libgdl/gdl-dock-object.h" - -G_BEGIN_DECLS - -/* standard macros */ -#define GDL_TYPE_DOCK_ITEM (gdl_dock_item_get_type ()) -#define GDL_DOCK_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDL_TYPE_DOCK_ITEM, GdlDockItem)) -#define GDL_DOCK_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDL_TYPE_DOCK_ITEM, GdlDockItemClass)) -#define GDL_IS_DOCK_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GDL_TYPE_DOCK_ITEM)) -#define GDL_IS_DOCK_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDL_TYPE_DOCK_ITEM)) -#define GDL_DOCK_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_DOCK_ITEM, GdlDockItemClass)) - -/** - * GdlDockItemBehavior: - * @GDL_DOCK_ITEM_BEH_NORMAL: Normal dock item - * @GDL_DOCK_ITEM_BEH_NEVER_FLOATING: item cannot be undocked - * @GDL_DOCK_ITEM_BEH_NEVER_VERTICAL: item cannot be docked vertically - * @GDL_DOCK_ITEM_BEH_NEVER_HORIZONTAL: item cannot be docked horizontally - * @GDL_DOCK_ITEM_BEH_LOCKED: item is locked, it cannot be moved around - * @GDL_DOCK_ITEM_BEH_CANT_DOCK_TOP: item cannot be docked at top - * @GDL_DOCK_ITEM_BEH_CANT_DOCK_BOTTOM: item cannot be docked at bottom - * @GDL_DOCK_ITEM_BEH_CANT_DOCK_LEFT: item cannot be docked left - * @GDL_DOCK_ITEM_BEH_CANT_DOCK_RIGHT: item cannot be docked right - * @GDL_DOCK_ITEM_BEH_CANT_DOCK_CENTER: item cannot be docked at center - * @GDL_DOCK_ITEM_BEH_CANT_CLOSE: item cannot be closed - * @GDL_DOCK_ITEM_BEH_CANT_ICONIFY: item cannot be iconified - * @GDL_DOCK_ITEM_BEH_NO_GRIP: item doesn't have a grip - * - * Described the behaviour of a doc item. The item can have multiple flags set. - * - **/ - -typedef enum { - GDL_DOCK_ITEM_BEH_NORMAL = 0, - GDL_DOCK_ITEM_BEH_NEVER_FLOATING = 1 << 0, - GDL_DOCK_ITEM_BEH_NEVER_VERTICAL = 1 << 1, - GDL_DOCK_ITEM_BEH_NEVER_HORIZONTAL = 1 << 2, - GDL_DOCK_ITEM_BEH_LOCKED = 1 << 3, - GDL_DOCK_ITEM_BEH_CANT_DOCK_TOP = 1 << 4, - GDL_DOCK_ITEM_BEH_CANT_DOCK_BOTTOM = 1 << 5, - GDL_DOCK_ITEM_BEH_CANT_DOCK_LEFT = 1 << 6, - GDL_DOCK_ITEM_BEH_CANT_DOCK_RIGHT = 1 << 7, - GDL_DOCK_ITEM_BEH_CANT_DOCK_CENTER = 1 << 8, - GDL_DOCK_ITEM_BEH_CANT_CLOSE = 1 << 9, - GDL_DOCK_ITEM_BEH_CANT_ICONIFY = 1 << 10, - GDL_DOCK_ITEM_BEH_NO_GRIP = 1 << 11 -} GdlDockItemBehavior; - - -/** - * GdlDockItemFlags: - * @GDL_DOCK_IN_DRAG: item is in a drag operation - * @GDL_DOCK_IN_PREDRAG: item is in a predrag operation - * @GDL_DOCK_ICONIFIED: item is iconified - * @GDL_DOCK_USER_ACTION: indicates the user has started an action on the dock item - * - * Status flag of a GdlDockItem. Don't use unless you derive a widget from GdlDockItem - * - **/ -typedef enum { - GDL_DOCK_IN_DRAG = 1 << GDL_DOCK_OBJECT_FLAGS_SHIFT, - GDL_DOCK_IN_PREDRAG = 1 << (GDL_DOCK_OBJECT_FLAGS_SHIFT + 1), - GDL_DOCK_ICONIFIED = 1 << (GDL_DOCK_OBJECT_FLAGS_SHIFT + 2), - GDL_DOCK_USER_ACTION = 1 << (GDL_DOCK_OBJECT_FLAGS_SHIFT + 3) -} GdlDockItemFlags; - -typedef struct _GdlDockItem GdlDockItem; -typedef struct _GdlDockItemClass GdlDockItemClass; -typedef struct _GdlDockItemPrivate GdlDockItemPrivate; - -struct _GdlDockItem { - GdlDockObject object; - - GtkWidget *child; - GdlDockItemBehavior behavior; - GtkOrientation orientation; - - guint resize : 1; - - gint dragoff_x, dragoff_y; /* these need to be - accesible from - outside */ - GdlDockItemPrivate *_priv; -}; - -struct _GdlDockItemClass { - GdlDockObjectClass parent_class; - - gboolean has_grip; - - /* virtuals */ - void (* dock_drag_begin) (GdlDockItem *item); - void (* dock_drag_motion) (GdlDockItem *item, - gint x, - gint y); - void (* dock_drag_end) (GdlDockItem *item, - gboolean cancelled); - void (* move_focus_child) (GdlDockItem *item, - GtkDirectionType direction); - void (* set_orientation) (GdlDockItem *item, - GtkOrientation orientation); -}; - -#define GDL_DOCK_ITEM_FLAGS(item) (GDL_DOCK_OBJECT (item)->flags) -#define GDL_DOCK_ITEM_IN_DRAG(item) \ - ((GDL_DOCK_ITEM_FLAGS (item) & GDL_DOCK_IN_DRAG) != 0) -#define GDL_DOCK_ITEM_IN_PREDRAG(item) \ - ((GDL_DOCK_ITEM_FLAGS (item) & GDL_DOCK_IN_PREDRAG) != 0) -#define GDL_DOCK_ITEM_ICONIFIED(item) \ - ((GDL_DOCK_ITEM_FLAGS (item) & GDL_DOCK_ICONIFIED) != 0) -#define GDL_DOCK_ITEM_USER_ACTION(item) \ - ((GDL_DOCK_ITEM_FLAGS (item) & GDL_DOCK_USER_ACTION) != 0) -#define GDL_DOCK_ITEM_NOT_LOCKED(item) !((item)->behavior & GDL_DOCK_ITEM_BEH_LOCKED) -#define GDL_DOCK_ITEM_NO_GRIP(item) ((item)->behavior & GDL_DOCK_ITEM_BEH_NO_GRIP) - -#define GDL_DOCK_ITEM_SET_FLAGS(item,flag) \ - G_STMT_START { (GDL_DOCK_ITEM_FLAGS (item) |= (flag)); } G_STMT_END -#define GDL_DOCK_ITEM_UNSET_FLAGS(item,flag) \ - G_STMT_START { (GDL_DOCK_ITEM_FLAGS (item) &= ~(flag)); } G_STMT_END - -#define GDL_DOCK_ITEM_HAS_GRIP(item) ((GDL_DOCK_ITEM_GET_CLASS (item)->has_grip)&& \ - ! GDL_DOCK_ITEM_NO_GRIP (item)) - -#define GDL_DOCK_ITEM_CANT_CLOSE(item) \ - ((((item)->behavior & GDL_DOCK_ITEM_BEH_CANT_CLOSE) != 0)|| \ - ! GDL_DOCK_ITEM_NOT_LOCKED(item)) - -#define GDL_DOCK_ITEM_CANT_ICONIFY(item) \ - ((((item)->behavior & GDL_DOCK_ITEM_BEH_CANT_ICONIFY) != 0)|| \ - ! GDL_DOCK_ITEM_NOT_LOCKED(item)) - -/* public interface */ - -GtkWidget *gdl_dock_item_new (const gchar *name, - const gchar *long_name, - GdlDockItemBehavior behavior); -GtkWidget *gdl_dock_item_new_with_stock (const gchar *name, - const gchar *long_name, - const gchar *stock_id, - GdlDockItemBehavior behavior); - -GtkWidget *gdl_dock_item_new_with_pixbuf_icon (const gchar *name, - const gchar *long_name, - const GdkPixbuf *pixbuf_icon, - GdlDockItemBehavior behavior); - -GType gdl_dock_item_get_type (void); - -void gdl_dock_item_dock_to (GdlDockItem *item, - GdlDockItem *target, - GdlDockPlacement position, - gint docking_param); - -void gdl_dock_item_set_orientation (GdlDockItem *item, - GtkOrientation orientation); - -GtkWidget *gdl_dock_item_get_tablabel (GdlDockItem *item); -void gdl_dock_item_set_tablabel (GdlDockItem *item, - GtkWidget *tablabel); -GtkWidget *gdl_dock_item_get_grip (GdlDockItem *item); -void gdl_dock_item_hide_grip (GdlDockItem *item); -void gdl_dock_item_show_grip (GdlDockItem *item); -void gdl_dock_item_notify_selected (GdlDockItem *item); - -/* bind and unbind items to a dock */ -void gdl_dock_item_bind (GdlDockItem *item, - GtkWidget *dock); - -void gdl_dock_item_unbind (GdlDockItem *item); - -void gdl_dock_item_hide_item (GdlDockItem *item); - -void gdl_dock_item_iconify_item (GdlDockItem *item); - -void gdl_dock_item_show_item (GdlDockItem *item); - -void gdl_dock_item_lock (GdlDockItem *item); - -void gdl_dock_item_unlock (GdlDockItem *item); - -void gdl_dock_item_set_default_position (GdlDockItem *item, - GdlDockObject *reference); - -void gdl_dock_item_preferred_size (GdlDockItem *item, - GtkRequisition *req); - -gboolean gdl_dock_item_or_child_has_focus (GdlDockItem *item); - -G_END_DECLS - -#endif diff --git a/src/libgdl/gdl-dock-master.c b/src/libgdl/gdl-dock-master.c deleted file mode 100644 index 294614c7e..000000000 --- a/src/libgdl/gdl-dock-master.c +++ /dev/null @@ -1,1011 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * gdl-dock-master.c - Object which manages a dock ring - * - * This file is part of the GNOME Devtools Libraries. - * - * Copyright (C) 2002 Gustavo Giráldez <gustavo.giraldez@gmx.net> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include "gdl-i18n.h" - -#include "gdl-dock-master.h" -#include "gdl-dock.h" -#include "gdl-dock-item.h" -#include "gdl-dock-notebook.h" -#include "gdl-switcher.h" -#include "libgdlmarshal.h" -#include "libgdltypebuiltins.h" -#ifdef WIN32 -#include "gdl-win32.h" -#endif - -/* ----- Private prototypes ----- */ - -static void gdl_dock_master_class_init (GdlDockMasterClass *klass); - -static void gdl_dock_master_dispose (GObject *g_object); -static void gdl_dock_master_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec); -static void gdl_dock_master_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec); - -static void _gdl_dock_master_remove (GdlDockObject *object, - GdlDockMaster *master); - -static void gdl_dock_master_drag_begin (GdlDockItem *item, - gpointer data); -static void gdl_dock_master_drag_end (GdlDockItem *item, - gboolean cancelled, - gpointer data); -static void gdl_dock_master_drag_motion (GdlDockItem *item, - gint x, - gint y, - gpointer data); - -static void _gdl_dock_master_foreach (gpointer key, - gpointer value, - gpointer user_data); - -static void gdl_dock_master_xor_rect (GdlDockMaster *master); - -static void gdl_dock_master_layout_changed (GdlDockMaster *master); - -static void gdl_dock_master_set_switcher_style (GdlDockMaster *master, - GdlSwitcherStyle switcher_style); - -/* ----- Private data types and variables ----- */ - -enum { - PROP_0, - PROP_DEFAULT_TITLE, - PROP_LOCKED, - PROP_SWITCHER_STYLE -}; - -enum { - LAYOUT_CHANGED, - LAST_SIGNAL -}; - -struct _GdlDockMasterPrivate { - gint number; /* for naming nameless manual objects */ - gchar *default_title; - - GdkGC *root_xor_gc; - gboolean rect_drawn; - GdlDock *rect_owner; - - GdlDockRequest *drag_request; - - /* source id for the idle handler to emit a layout_changed signal */ - guint idle_layout_changed_id; - - /* hashes to quickly calculate the overall locked status: i.e. - * if size(unlocked_items) == 0 then locked = 1 - * else if size(locked_items) == 0 then locked = 0 - * else locked = -1 - */ - GHashTable *locked_items; - GHashTable *unlocked_items; - - GdlSwitcherStyle switcher_style; -}; - -#define COMPUTE_LOCKED(master) \ - (g_hash_table_size ((master)->_priv->unlocked_items) == 0 ? 1 : \ - (g_hash_table_size ((master)->_priv->locked_items) == 0 ? 0 : -1)) - -static guint master_signals [LAST_SIGNAL] = { 0 }; - - -/* ----- Private interface ----- */ - -G_DEFINE_TYPE (GdlDockMaster, gdl_dock_master, G_TYPE_OBJECT); - -static void -gdl_dock_master_class_init (GdlDockMasterClass *klass) -{ - GObjectClass *g_object_class; - - g_object_class = G_OBJECT_CLASS (klass); - - g_object_class->dispose = gdl_dock_master_dispose; - g_object_class->set_property = gdl_dock_master_set_property; - g_object_class->get_property = gdl_dock_master_get_property; - - g_object_class_install_property ( - g_object_class, PROP_DEFAULT_TITLE, - g_param_spec_string ("default-title", _("Default title"), - _("Default title for newly created floating docks"), - NULL, - G_PARAM_READWRITE)); - - g_object_class_install_property ( - g_object_class, PROP_LOCKED, - g_param_spec_int ("locked", _("Locked"), - _("If is set to 1, all the dock items bound to the master " - "are locked; if it's 0, all are unlocked; -1 indicates " - "inconsistency among the items"), - -1, 1, 0, - G_PARAM_READWRITE)); - - g_object_class_install_property ( - g_object_class, PROP_SWITCHER_STYLE, - g_param_spec_enum ("switcher-style", _("Switcher Style"), - _("Switcher buttons style"), - GDL_TYPE_SWITCHER_STYLE, - GDL_SWITCHER_STYLE_BOTH, - G_PARAM_READWRITE)); - - master_signals [LAYOUT_CHANGED] = - g_signal_new ("layout-changed", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GdlDockMasterClass, layout_changed), - NULL, /* accumulator */ - NULL, /* accu_data */ - gdl_marshal_VOID__VOID, - G_TYPE_NONE, /* return type */ - 0); - - klass->layout_changed = gdl_dock_master_layout_changed; -} - -static void -gdl_dock_master_init (GdlDockMaster *master) -{ - master->dock_objects = g_hash_table_new_full (g_str_hash, g_str_equal, - g_free, NULL); - master->toplevel_docks = NULL; - master->controller = NULL; - master->dock_number = 1; - - master->_priv = g_new0 (GdlDockMasterPrivate, 1); - master->_priv->number = 1; - master->_priv->switcher_style = GDL_SWITCHER_STYLE_BOTH; - master->_priv->locked_items = g_hash_table_new (g_direct_hash, g_direct_equal); - master->_priv->unlocked_items = g_hash_table_new (g_direct_hash, g_direct_equal); -} - -static void -_gdl_dock_master_remove (GdlDockObject *object, - GdlDockMaster *master) -{ - g_return_if_fail (master != NULL && object != NULL); - - if (GDL_IS_DOCK (object)) { - GList *found_link; - - found_link = g_list_find (master->toplevel_docks, object); - if (found_link) - master->toplevel_docks = g_list_delete_link (master->toplevel_docks, - found_link); - if (object == master->controller) { - GList *last; - GdlDockObject *new_controller = NULL; - - /* now find some other non-automatic toplevel to use as a - new controller. start from the last dock, since it's - probably a non-floating and manual */ - last = g_list_last (master->toplevel_docks); - while (last) { - if (!GDL_DOCK_OBJECT_AUTOMATIC (last->data)) { - new_controller = GDL_DOCK_OBJECT (last->data); - break; - } - last = last->prev; - }; - - if (new_controller) { - /* the new controller gets the ref (implicitly of course) */ - master->controller = new_controller; - } else { - master->controller = NULL; - /* no controller, no master */ - g_object_unref (master); - } - } - } - /* disconnect dock object signals */ - g_signal_handlers_disconnect_matched (object, G_SIGNAL_MATCH_DATA, - 0, 0, NULL, NULL, master); - - /* unref the object from the hash if it's there */ - if (object->name) { - GdlDockObject *found_object; - found_object = g_hash_table_lookup (master->dock_objects, object->name); - if (found_object == object) { - g_hash_table_remove (master->dock_objects, object->name); - g_object_unref (object); - } - } -} - -static void -ht_foreach_build_slist (gpointer key, - gpointer value, - GSList **slist) -{ - *slist = g_slist_prepend (*slist, value); -} - -static void -gdl_dock_master_dispose (GObject *g_object) -{ - GdlDockMaster *master; - - g_return_if_fail (GDL_IS_DOCK_MASTER (g_object)); - - master = GDL_DOCK_MASTER (g_object); - - if (master->toplevel_docks) { - g_list_foreach (master->toplevel_docks, - (GFunc) gdl_dock_object_unbind, NULL); - g_list_free (master->toplevel_docks); - master->toplevel_docks = NULL; - } - - if (master->dock_objects) { - GSList *alive_docks = NULL; - g_hash_table_foreach (master->dock_objects, - (GHFunc) ht_foreach_build_slist, &alive_docks); - while (alive_docks) { - gdl_dock_object_unbind (GDL_DOCK_OBJECT (alive_docks->data)); - alive_docks = g_slist_delete_link (alive_docks, alive_docks); - } - - g_hash_table_destroy (master->dock_objects); - master->dock_objects = NULL; - } - - if (master->_priv) { - if (master->_priv->idle_layout_changed_id) - g_source_remove (master->_priv->idle_layout_changed_id); - - if (master->_priv->root_xor_gc) { - g_object_unref (master->_priv->root_xor_gc); - master->_priv->root_xor_gc = NULL; - } - if (master->_priv->drag_request) { - if (G_IS_VALUE (&master->_priv->drag_request->extra)) - g_value_unset (&master->_priv->drag_request->extra); - g_free (master->_priv->drag_request); - master->_priv->drag_request = NULL; - } - g_free (master->_priv->default_title); - master->_priv->default_title = NULL; - - g_hash_table_destroy (master->_priv->locked_items); - master->_priv->locked_items = NULL; - g_hash_table_destroy (master->_priv->unlocked_items); - master->_priv->unlocked_items = NULL; - - g_free (master->_priv); - master->_priv = NULL; - } - - G_OBJECT_CLASS (gdl_dock_master_parent_class)->dispose (g_object); -} - -static void -foreach_lock_unlock (GdlDockItem *item, - gboolean locked) -{ - if (!GDL_IS_DOCK_ITEM (item)) - return; - - g_object_set (item, "locked", locked, NULL); - if (gdl_dock_object_is_compound (GDL_DOCK_OBJECT (item))) - gtk_container_foreach (GTK_CONTAINER (item), - (GtkCallback) foreach_lock_unlock, - GINT_TO_POINTER (locked)); -} - -static void -gdl_dock_master_lock_unlock (GdlDockMaster *master, - gboolean locked) -{ - GList *l; - - for (l = master->toplevel_docks; l; l = l->next) { - GdlDock *dock = GDL_DOCK (l->data); - if (dock->root) - foreach_lock_unlock (GDL_DOCK_ITEM (dock->root), locked); - } - - /* just to be sure hidden items are set too */ - gdl_dock_master_foreach (master, - (GFunc) foreach_lock_unlock, - GINT_TO_POINTER (locked)); -} - -static void -gdl_dock_master_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) -{ - GdlDockMaster *master = GDL_DOCK_MASTER (object); - - switch (prop_id) { - case PROP_DEFAULT_TITLE: - g_free (master->_priv->default_title); - master->_priv->default_title = g_value_dup_string (value); - break; - case PROP_LOCKED: - if (g_value_get_int (value) >= 0) - gdl_dock_master_lock_unlock (master, (g_value_get_int (value) > 0)); - break; - case PROP_SWITCHER_STYLE: - gdl_dock_master_set_switcher_style (master, g_value_get_enum (value)); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -gdl_dock_master_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) -{ - GdlDockMaster *master = GDL_DOCK_MASTER (object); - - switch (prop_id) { - case PROP_DEFAULT_TITLE: - g_value_set_string (value, master->_priv->default_title); - break; - case PROP_LOCKED: - g_value_set_int (value, COMPUTE_LOCKED (master)); - break; - case PROP_SWITCHER_STYLE: - g_value_set_enum (value, master->_priv->switcher_style); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -gdl_dock_master_drag_begin (GdlDockItem *item, - gpointer data) -{ - GdlDockMaster *master; - GdlDockRequest *request; - - g_return_if_fail (data != NULL); - g_return_if_fail (item != NULL); - - master = GDL_DOCK_MASTER (data); - - if (!master->_priv->drag_request) - master->_priv->drag_request = g_new0 (GdlDockRequest, 1); - - request = master->_priv->drag_request; - - /* Set the target to itself so it won't go floating with just a click. */ - request->applicant = GDL_DOCK_OBJECT (item); - request->target = GDL_DOCK_OBJECT (item); - request->position = GDL_DOCK_FLOATING; - if (G_IS_VALUE (&request->extra)) - g_value_unset (&request->extra); - - master->_priv->rect_drawn = FALSE; - master->_priv->rect_owner = NULL; -} - -static void -gdl_dock_master_drag_end (GdlDockItem *item, - gboolean cancelled, - gpointer data) -{ - GdlDockMaster *master; - GdlDockRequest *request; - - g_return_if_fail (data != NULL); - g_return_if_fail (item != NULL); - - master = GDL_DOCK_MASTER (data); - request = master->_priv->drag_request; - - g_return_if_fail (GDL_DOCK_OBJECT (item) == request->applicant); - - /* Erase previously drawn rectangle */ - if (master->_priv->rect_drawn) - gdl_dock_master_xor_rect (master); - - /* cancel conditions */ - if (cancelled || request->applicant == request->target) - return; - - /* dock object to the requested position */ - gdl_dock_object_dock (request->target, - request->applicant, - request->position, - &request->extra); - - g_signal_emit (master, master_signals [LAYOUT_CHANGED], 0); -} - -static void -gdl_dock_master_drag_motion (GdlDockItem *item, - gint root_x, - gint root_y, - gpointer data) -{ - GdlDockMaster *master; - GdlDockRequest my_request, *request; - GdkWindow *window; - GdkWindow *widget_window; - gint win_x, win_y; - gint x, y; - GdlDock *dock = NULL; - gboolean may_dock = FALSE; - - g_return_if_fail (item != NULL && data != NULL); - - master = GDL_DOCK_MASTER (data); - request = master->_priv->drag_request; - - g_return_if_fail (GDL_DOCK_OBJECT (item) == request->applicant); - - my_request = *request; - - /* first look under the pointer */ - window = gdk_window_at_pointer (&win_x, &win_y); - if (window) { - GtkWidget *widget; - /* ok, now get the widget who owns that window and see if we can - get to a GdlDock by walking up the hierarchy */ - gdk_window_get_user_data (window, (gpointer) &widget); - if (GTK_IS_WIDGET (widget)) { - while (widget && (!GDL_IS_DOCK (widget) || - GDL_DOCK_OBJECT_GET_MASTER (widget) != master)) - widget = gtk_widget_get_parent (widget); - if (widget) { - gint win_w, win_h; - - widget_window = gtk_widget_get_window (widget); - - /* verify that the pointer is still in that dock - (the user could have moved it) */ - gdk_window_get_geometry (widget_window, - NULL, NULL, &win_w, &win_h, NULL); - gdk_window_get_origin (widget_window, &win_x, &win_y); - if (root_x >= win_x && root_x < win_x + win_w && - root_y >= win_y && root_y < win_y + win_h) - dock = GDL_DOCK (widget); - } - } - } - - if (dock) { - GdkWindow *dock_window = gtk_widget_get_window (GTK_WIDGET (dock)); - - /* translate root coordinates into dock object coordinates - (i.e. widget coordinates) */ - gdk_window_get_origin (dock_window, &win_x, &win_y); - x = root_x - win_x; - y = root_y - win_y; - may_dock = gdl_dock_object_dock_request (GDL_DOCK_OBJECT (dock), - x, y, &my_request); - } - else { - GList *l; - - /* try to dock the item in all the docks in the ring in turn */ - for (l = master->toplevel_docks; l; l = l->next) { - GdkWindow *dock_window; - dock = GDL_DOCK (l->data); - dock_window = gtk_widget_get_window (GTK_WIDGET (dock)); - /* translate root coordinates into dock object coordinates - (i.e. widget coordinates) */ - gdk_window_get_origin (dock_window, &win_x, &win_y); - x = root_x - win_x; - y = root_y - win_y; - may_dock = gdl_dock_object_dock_request (GDL_DOCK_OBJECT (dock), - x, y, &my_request); - if (may_dock) - break; - } - } - - - if (!may_dock) { - GtkRequisition req; - /* Special case for GdlDockItems : they must respect the flags */ - if(GDL_IS_DOCK_ITEM(item) - && GDL_DOCK_ITEM(item)->behavior & GDL_DOCK_ITEM_BEH_NEVER_FLOATING) - return; - - dock = NULL; - my_request.target = GDL_DOCK_OBJECT ( - gdl_dock_object_get_toplevel (request->applicant)); - my_request.position = GDL_DOCK_FLOATING; - - gdl_dock_item_preferred_size (GDL_DOCK_ITEM (request->applicant), &req); - my_request.rect.width = req.width; - my_request.rect.height = req.height; - - my_request.rect.x = root_x - GDL_DOCK_ITEM (request->applicant)->dragoff_x; - my_request.rect.y = root_y - GDL_DOCK_ITEM (request->applicant)->dragoff_y; - - /* setup extra docking information */ - if (G_IS_VALUE (&my_request.extra)) - g_value_unset (&my_request.extra); - - g_value_init (&my_request.extra, GDK_TYPE_RECTANGLE); - g_value_set_boxed (&my_request.extra, &my_request.rect); - } - /* if we want to enforce GDL_DOCK_ITEM_BEH_NEVER_FLOATING */ - /* the item must remain attached to the controller, otherwise */ - /* it could be inserted in another floating dock */ - /* so check for the flag at this moment */ - else if(GDL_IS_DOCK_ITEM(item) - && GDL_DOCK_ITEM(item)->behavior & GDL_DOCK_ITEM_BEH_NEVER_FLOATING - && dock != GDL_DOCK(master->controller)) - return; - - if (!(my_request.rect.x == request->rect.x && - my_request.rect.y == request->rect.y && - my_request.rect.width == request->rect.width && - my_request.rect.height == request->rect.height && - dock == master->_priv->rect_owner)) { - - /* erase the previous rectangle */ - if (master->_priv->rect_drawn) - gdl_dock_master_xor_rect (master); - } - - /* set the new values */ - *request = my_request; - master->_priv->rect_owner = dock; - - /* draw the previous rectangle */ - if (~master->_priv->rect_drawn) - gdl_dock_master_xor_rect (master); -} - -static void -_gdl_dock_master_foreach (gpointer key, - gpointer value, - gpointer user_data) -{ - struct { - GFunc function; - gpointer user_data; - } *data = user_data; - - (* data->function) (GTK_WIDGET (value), data->user_data); -} - -static void -gdl_dock_master_xor_rect (GdlDockMaster *master) -{ - gint8 dash_list [2]; - GdkWindow *window; - GdkRectangle *rect; - - if (!master->_priv || !master->_priv->drag_request) - return; - - master->_priv->rect_drawn = ~master->_priv->rect_drawn; - - if (master->_priv->rect_owner) { - gdl_dock_xor_rect (master->_priv->rect_owner, - &master->_priv->drag_request->rect); - return; - } - - rect = &master->_priv->drag_request->rect; - window = gdk_get_default_root_window (); - - if (!master->_priv->root_xor_gc) { - GdkGCValues values; - - values.function = GDK_INVERT; - values.subwindow_mode = GDK_INCLUDE_INFERIORS; - master->_priv->root_xor_gc = gdk_gc_new_with_values ( - window, &values, GDK_GC_FUNCTION | GDK_GC_SUBWINDOW); - }; - -#ifdef WIN32 - GdkLineStyle lineStyle = GDK_LINE_ON_OFF_DASH; - if (is_os_vista()) - { - // On Vista the dash-line is increadibly slow to draw, it takes several minutes to draw the tracking lines - // With GDK_LINE_SOLID it is parts of a second - // No performance issue on WinXP - lineStyle = GDK_LINE_SOLID; - } -#else - GdkLineStyle lineStyle = GDK_LINE_ON_OFF_DASH; -#endif - gdk_gc_set_line_attributes (master->_priv->root_xor_gc, 1, - lineStyle, - GDK_CAP_NOT_LAST, - GDK_JOIN_BEVEL); - - dash_list[0] = 1; - dash_list[1] = 1; - gdk_gc_set_dashes (master->_priv->root_xor_gc, 1, dash_list, 2); - - gdk_draw_rectangle (window, master->_priv->root_xor_gc, 0, - rect->x, rect->y, - rect->width, rect->height); - - gdk_gc_set_dashes (master->_priv->root_xor_gc, 0, dash_list, 2); - - gdk_draw_rectangle (window, master->_priv->root_xor_gc, 0, - rect->x + 1, rect->y + 1, - rect->width - 2, rect->height - 2); -} - -static void -gdl_dock_master_layout_changed (GdlDockMaster *master) -{ - g_return_if_fail (GDL_IS_DOCK_MASTER (master)); - - /* emit "layout-changed" on the controller to notify the user who - * normally shouldn't have access to us */ - if (master->controller) - g_signal_emit_by_name (master->controller, "layout-changed"); - - /* remove the idle handler if there is one */ - if (master->_priv->idle_layout_changed_id) { - g_source_remove (master->_priv->idle_layout_changed_id); - master->_priv->idle_layout_changed_id = 0; - } -} - -static gboolean -idle_emit_layout_changed (gpointer user_data) -{ - GdlDockMaster *master = user_data; - - g_return_val_if_fail (master && GDL_IS_DOCK_MASTER (master), FALSE); - - master->_priv->idle_layout_changed_id = 0; - g_signal_emit (master, master_signals [LAYOUT_CHANGED], 0); - - return FALSE; -} - -static void -item_dock_cb (GdlDockObject *object, - GdlDockObject *requestor, - GdlDockPlacement position, - GValue *other_data, - gpointer user_data) -{ - GdlDockMaster *master = user_data; - - g_return_if_fail (requestor && GDL_IS_DOCK_OBJECT (requestor)); - g_return_if_fail (master && GDL_IS_DOCK_MASTER (master)); - - /* here we are in fact interested in the requestor, since it's - * assumed that object will not change its visibility... for the - * requestor, however, could mean that it's being shown */ - if (!GDL_DOCK_OBJECT_IN_REFLOW (requestor) && - !GDL_DOCK_OBJECT_AUTOMATIC (requestor)) { - if (!master->_priv->idle_layout_changed_id) - master->_priv->idle_layout_changed_id = - g_idle_add (idle_emit_layout_changed, master); - } -} - -static void -item_detach_cb (GdlDockObject *object, - gboolean recursive, - gpointer user_data) -{ - GdlDockMaster *master = user_data; - - g_return_if_fail (object && GDL_IS_DOCK_OBJECT (object)); - g_return_if_fail (master && GDL_IS_DOCK_MASTER (master)); - - if (!GDL_DOCK_OBJECT_IN_REFLOW (object) && - !GDL_DOCK_OBJECT_AUTOMATIC (object)) { - if (!master->_priv->idle_layout_changed_id) - master->_priv->idle_layout_changed_id = - g_idle_add (idle_emit_layout_changed, master); - } -} - -static void -item_notify_cb (GdlDockObject *object, - GParamSpec *pspec, - gpointer user_data) -{ - GdlDockMaster *master = user_data; - gint locked = COMPUTE_LOCKED (master); - gboolean item_locked; - - g_object_get (object, "locked", &item_locked, NULL); - - if (item_locked) { - g_hash_table_remove (master->_priv->unlocked_items, object); - g_hash_table_insert (master->_priv->locked_items, object, NULL); - } else { - g_hash_table_remove (master->_priv->locked_items, object); - g_hash_table_insert (master->_priv->unlocked_items, object, NULL); - } - - if (COMPUTE_LOCKED (master) != locked) - g_object_notify (G_OBJECT (master), "locked"); -} - -/* ----- Public interface ----- */ - -void -gdl_dock_master_add (GdlDockMaster *master, - GdlDockObject *object) -{ - g_return_if_fail (master != NULL && object != NULL); - - if (!GDL_DOCK_OBJECT_AUTOMATIC (object)) { - GdlDockObject *found_object; - - /* create a name for the object if it doesn't have one */ - if (!object->name) - /* directly set the name, since it's a construction only - property */ - object->name = g_strdup_printf ("__dock_%u", master->_priv->number++); - - /* add the object to our hash list */ - if ((found_object = g_hash_table_lookup (master->dock_objects, object->name))) { - g_warning (_("master %p: unable to add object %p[%s] to the hash. " - "There already is an item with that name (%p)."), - master, object, object->name, found_object); - } - else { - g_object_ref_sink (object); - g_hash_table_insert (master->dock_objects, g_strdup (object->name), object); - } - } - - if (GDL_IS_DOCK (object)) { - gboolean floating; - - /* if this is the first toplevel we are adding, name it controller */ - if (!master->toplevel_docks) - /* the dock should already have the ref */ - master->controller = object; - - /* add dock to the toplevel list */ - g_object_get (object, "floating", &floating, NULL); - if (floating) - master->toplevel_docks = g_list_prepend (master->toplevel_docks, object); - else - master->toplevel_docks = g_list_append (master->toplevel_docks, object); - - /* we are interested in the dock request this toplevel - * receives to update the layout */ - g_signal_connect (object, "dock", - G_CALLBACK (item_dock_cb), master); - - } - else if (GDL_IS_DOCK_ITEM (object)) { - /* we need to connect the item's signals */ - g_signal_connect (object, "dock_drag_begin", - G_CALLBACK (gdl_dock_master_drag_begin), master); - g_signal_connect (object, "dock_drag_motion", - G_CALLBACK (gdl_dock_master_drag_motion), master); - g_signal_connect (object, "dock_drag_end", - G_CALLBACK (gdl_dock_master_drag_end), master); - g_signal_connect (object, "dock", - G_CALLBACK (item_dock_cb), master); - g_signal_connect (object, "detach", - G_CALLBACK (item_detach_cb), master); - - /* register to "locked" notification if the item has a grip, - * and add the item to the corresponding hash */ - if (GDL_DOCK_ITEM_HAS_GRIP (GDL_DOCK_ITEM (object))) { - g_signal_connect (object, "notify::locked", - G_CALLBACK (item_notify_cb), master); - item_notify_cb (object, NULL, master); - } - - /* If the item is notebook, set the switcher style */ - if (GDL_IS_DOCK_NOTEBOOK (object) && - GDL_IS_SWITCHER (GDL_DOCK_ITEM (object)->child)) - { - g_object_set (GDL_DOCK_ITEM (object)->child, "switcher-style", - master->_priv->switcher_style, NULL); - } - - /* post a layout_changed emission if the item is not automatic - * (since it should be added to the items model) */ - if (!GDL_DOCK_OBJECT_AUTOMATIC (object)) { - if (!master->_priv->idle_layout_changed_id) - master->_priv->idle_layout_changed_id = - g_idle_add (idle_emit_layout_changed, master); - } - } -} - -void -gdl_dock_master_remove (GdlDockMaster *master, - GdlDockObject *object) -{ - g_return_if_fail (master != NULL && object != NULL); - - /* remove from locked/unlocked hashes and property change if - * that's the case */ - if (GDL_IS_DOCK_ITEM (object) && GDL_DOCK_ITEM_HAS_GRIP (GDL_DOCK_ITEM (object))) { - gint locked = COMPUTE_LOCKED (master); - if (g_hash_table_remove (master->_priv->locked_items, object) || - g_hash_table_remove (master->_priv->unlocked_items, object)) { - if (COMPUTE_LOCKED (master) != locked) - g_object_notify (G_OBJECT (master), "locked"); - } - } - - /* ref the master, since removing the controller could cause master disposal */ - g_object_ref (master); - - /* all the interesting stuff happens in _gdl_dock_master_remove */ - _gdl_dock_master_remove (object, master); - - /* post a layout_changed emission if the item is not automatic - * (since it should be removed from the items model) */ - if (!GDL_DOCK_OBJECT_AUTOMATIC (object)) { - if (!master->_priv->idle_layout_changed_id) - master->_priv->idle_layout_changed_id = - g_idle_add (idle_emit_layout_changed, master); - } - - /* balance ref count */ - g_object_unref (master); -} - -void -gdl_dock_master_foreach (GdlDockMaster *master, - GFunc function, - gpointer user_data) -{ - struct { - GFunc function; - gpointer user_data; - } data; - - g_return_if_fail (master != NULL && function != NULL); - - data.function = function; - data.user_data = user_data; - g_hash_table_foreach (master->dock_objects, _gdl_dock_master_foreach, &data); -} - -void -gdl_dock_master_foreach_toplevel (GdlDockMaster *master, - gboolean include_controller, - GFunc function, - gpointer user_data) -{ - GList *l; - - g_return_if_fail (master != NULL && function != NULL); - - for (l = master->toplevel_docks; l; ) { - GdlDockObject *object = GDL_DOCK_OBJECT (l->data); - l = l->next; - if (object != master->controller || include_controller) - (* function) (GTK_WIDGET (object), user_data); - } -} - -GdlDockObject * -gdl_dock_master_get_object (GdlDockMaster *master, - const gchar *nick_name) -{ - gpointer *found; - - g_return_val_if_fail (master != NULL, NULL); - - if (!nick_name) - return NULL; - - found = g_hash_table_lookup (master->dock_objects, nick_name); - - return found ? GDL_DOCK_OBJECT (found) : NULL; -} - -GdlDockObject * -gdl_dock_master_get_controller (GdlDockMaster *master) -{ - g_return_val_if_fail (master != NULL, NULL); - - return master->controller; -} - -void -gdl_dock_master_set_controller (GdlDockMaster *master, - GdlDockObject *new_controller) -{ - g_return_if_fail (master != NULL); - - if (new_controller) { - if (GDL_DOCK_OBJECT_AUTOMATIC (new_controller)) - g_warning (_("The new dock controller %p is automatic. Only manual " - "dock objects should be named controller."), new_controller); - - /* check that the controller is in the toplevel list */ - if (!g_list_find (master->toplevel_docks, new_controller)) - gdl_dock_master_add (master, new_controller); - master->controller = new_controller; - - } else { - master->controller = NULL; - /* no controller, no master */ - g_object_unref (master); - } -} - -static void -set_switcher_style_foreach (GtkWidget *obj, gpointer user_data) -{ - GdlSwitcherStyle style = GPOINTER_TO_INT (user_data); - - if (!GDL_IS_DOCK_ITEM (obj)) - return; - - if (GDL_IS_DOCK_NOTEBOOK (obj)) { - - GtkWidget *child = GDL_DOCK_ITEM (obj)->child; - if (GDL_IS_SWITCHER (child)) { - - g_object_set (child, "switcher-style", style, NULL); - } - } else if (gdl_dock_object_is_compound (GDL_DOCK_OBJECT (obj))) { - - gtk_container_foreach (GTK_CONTAINER (obj), - set_switcher_style_foreach, - user_data); - } -} - -static void -gdl_dock_master_set_switcher_style (GdlDockMaster *master, - GdlSwitcherStyle switcher_style) -{ - GList *l; - g_return_if_fail (GDL_IS_DOCK_MASTER (master)); - - master->_priv->switcher_style = switcher_style; - for (l = master->toplevel_docks; l; l = l->next) { - GdlDock *dock = GDL_DOCK (l->data); - if (dock->root) - set_switcher_style_foreach (GTK_WIDGET (dock->root), - GINT_TO_POINTER (switcher_style)); - } - - /* just to be sure hidden items are set too */ - gdl_dock_master_foreach (master, (GFunc) set_switcher_style_foreach, - GINT_TO_POINTER (switcher_style)); -} diff --git a/src/libgdl/gdl-dock-master.h b/src/libgdl/gdl-dock-master.h deleted file mode 100644 index 266ca7ee4..000000000 --- a/src/libgdl/gdl-dock-master.h +++ /dev/null @@ -1,106 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * gdl-dock-master.h - Object which manages a dock ring - * - * This file is part of the GNOME Devtools Libraries. - * - * Copyright (C) 2002 Gustavo Giráldez <gustavo.giraldez@gmx.net> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef __GDL_DOCK_MASTER_H__ -#define __GDL_DOCK_MASTER_H__ - -#include <glib-object.h> -#include <gtk/gtk.h> -#include "libgdl/gdl-dock-object.h" - - -G_BEGIN_DECLS - -/* standard macros */ -#define GDL_TYPE_DOCK_MASTER (gdl_dock_master_get_type ()) -#define GDL_DOCK_MASTER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDL_TYPE_DOCK_MASTER, GdlDockMaster)) -#define GDL_DOCK_MASTER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDL_TYPE_DOCK_MASTER, GdlDockMasterClass)) -#define GDL_IS_DOCK_MASTER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GDL_TYPE_DOCK_MASTER)) -#define GDL_IS_DOCK_MASTER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDL_TYPE_DOCK_MASTER)) -#define GDL_DOCK_MASTER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_DOCK_MASTER, GdlDockMasterClass)) - -/* data types & structures */ -typedef struct _GdlDockMaster GdlDockMaster; -typedef struct _GdlDockMasterClass GdlDockMasterClass; -typedef struct _GdlDockMasterPrivate GdlDockMasterPrivate; - -typedef enum { - GDL_SWITCHER_STYLE_TEXT, - GDL_SWITCHER_STYLE_ICON, - GDL_SWITCHER_STYLE_BOTH, - GDL_SWITCHER_STYLE_TOOLBAR, - GDL_SWITCHER_STYLE_TABS, - GDL_SWITCHER_STYLE_NONE -} GdlSwitcherStyle; - -struct _GdlDockMaster { - GObject object; - - GHashTable *dock_objects; - GList *toplevel_docks; - GdlDockObject *controller; /* GUI root object */ - - gint dock_number; /* for toplevel dock numbering */ - - GdlDockMasterPrivate *_priv; -}; - -struct _GdlDockMasterClass { - GObjectClass parent_class; - - void (* layout_changed) (GdlDockMaster *master); -}; - -/* additional macros */ - -#define GDL_DOCK_OBJECT_GET_MASTER(object) \ - (GDL_DOCK_OBJECT (object)->master ? \ - GDL_DOCK_MASTER (GDL_DOCK_OBJECT (object)->master) : NULL) - -/* public interface */ - -GType gdl_dock_master_get_type (void); - -void gdl_dock_master_add (GdlDockMaster *master, - GdlDockObject *object); -void gdl_dock_master_remove (GdlDockMaster *master, - GdlDockObject *object); -void gdl_dock_master_foreach (GdlDockMaster *master, - GFunc function, - gpointer user_data); - -void gdl_dock_master_foreach_toplevel (GdlDockMaster *master, - gboolean include_controller, - GFunc function, - gpointer user_data); - -GdlDockObject *gdl_dock_master_get_object (GdlDockMaster *master, - const gchar *nick_name); - -GdlDockObject *gdl_dock_master_get_controller (GdlDockMaster *master); -void gdl_dock_master_set_controller (GdlDockMaster *master, - GdlDockObject *new_controller); - -G_END_DECLS - -#endif /* __GDL_DOCK_MASTER_H__ */ diff --git a/src/libgdl/gdl-dock-notebook.c b/src/libgdl/gdl-dock-notebook.c deleted file mode 100644 index 0ffaac902..000000000 --- a/src/libgdl/gdl-dock-notebook.c +++ /dev/null @@ -1,530 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This file is part of the GNOME Devtools Libraries. - * - * Copyright (C) 2002 Gustavo Giráldez <gustavo.giraldez@gmx.net> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include "gdl-i18n.h" -#include "gdl-switcher.h" - -#include "gdl-dock-notebook.h" -#include "gdl-dock-tablabel.h" - - -/* Private prototypes */ - -static void gdl_dock_notebook_class_init (GdlDockNotebookClass *klass); -static void gdl_dock_notebook_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec); -static void gdl_dock_notebook_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec); - -static void gdl_dock_notebook_destroy (GtkObject *object); - -static void gdl_dock_notebook_add (GtkContainer *container, - GtkWidget *widget); -static void gdl_dock_notebook_forall (GtkContainer *container, - gboolean include_internals, - GtkCallback callback, - gpointer callback_data); -static GType gdl_dock_notebook_child_type (GtkContainer *container); - -static void gdl_dock_notebook_dock (GdlDockObject *object, - GdlDockObject *requestor, - GdlDockPlacement position, - GValue *other_data); - -static void gdl_dock_notebook_switch_page_cb (GtkNotebook *nb, - GtkWidget *page, - gint page_num, - gpointer data); - -static void gdl_dock_notebook_set_orientation (GdlDockItem *item, - GtkOrientation orientation); - -static gboolean gdl_dock_notebook_child_placement (GdlDockObject *object, - GdlDockObject *child, - GdlDockPlacement *placement); - -static void gdl_dock_notebook_present (GdlDockObject *object, - GdlDockObject *child); - -static gboolean gdl_dock_notebook_reorder (GdlDockObject *object, - GdlDockObject *requestor, - GdlDockPlacement new_position, - GValue *other_data); - - -/* Class variables and definitions */ - -enum { - PROP_0, - PROP_PAGE -}; - - -/* ----- Private functions ----- */ - -G_DEFINE_TYPE (GdlDockNotebook, gdl_dock_notebook, GDL_TYPE_DOCK_ITEM); - -static void -gdl_dock_notebook_class_init (GdlDockNotebookClass *klass) -{ - static gboolean style_initialized = FALSE; - - GObjectClass *g_object_class; - GtkObjectClass *gtk_object_class; - GtkWidgetClass *widget_class; - GtkContainerClass *container_class; - GdlDockObjectClass *object_class; - GdlDockItemClass *item_class; - - g_object_class = G_OBJECT_CLASS (klass); - gtk_object_class = GTK_OBJECT_CLASS (klass); - widget_class = GTK_WIDGET_CLASS (klass); - container_class = GTK_CONTAINER_CLASS (klass); - object_class = GDL_DOCK_OBJECT_CLASS (klass); - item_class = GDL_DOCK_ITEM_CLASS (klass); - - g_object_class->set_property = gdl_dock_notebook_set_property; - g_object_class->get_property = gdl_dock_notebook_get_property; - - gtk_object_class->destroy = gdl_dock_notebook_destroy; - - container_class->add = gdl_dock_notebook_add; - container_class->forall = gdl_dock_notebook_forall; - container_class->child_type = gdl_dock_notebook_child_type; - - object_class->is_compound = TRUE; - object_class->dock = gdl_dock_notebook_dock; - object_class->child_placement = gdl_dock_notebook_child_placement; - object_class->present = gdl_dock_notebook_present; - object_class->reorder = gdl_dock_notebook_reorder; - - item_class->has_grip = FALSE; - item_class->set_orientation = gdl_dock_notebook_set_orientation; - - g_object_class_install_property ( - g_object_class, PROP_PAGE, - g_param_spec_int ("page", _("Page"), - _("The index of the current page"), - 0, G_MAXINT, - 0, - G_PARAM_READWRITE | - GDL_DOCK_PARAM_EXPORT | GDL_DOCK_PARAM_AFTER)); - - if (!style_initialized) { - style_initialized = TRUE; - - gtk_rc_parse_string ( - "style \"gdl-dock-notebook-default\" {\n" - "xthickness = 2\n" - "ythickness = 2\n" - "}\n" - "widget_class \"*.GtkNotebook.GdlDockItem\" " - "style : gtk \"gdl-dock-notebook-default\"\n"); - } -} - -static void -gdl_dock_notebook_notify_cb (GObject *g_object, - GParamSpec *pspec, - gpointer user_data) -{ - g_return_if_fail (user_data != NULL && GDL_IS_DOCK_NOTEBOOK (user_data)); - - /* chain the notify signal */ - g_object_notify (G_OBJECT (user_data), pspec->name); -} - -static gboolean -gdl_dock_notebook_button_cb (GtkWidget *widget, - GdkEventButton *event, - gpointer user_data) -{ - if (event->type == GDK_BUTTON_PRESS) - GDL_DOCK_ITEM_SET_FLAGS (user_data, GDL_DOCK_USER_ACTION); - else - GDL_DOCK_ITEM_UNSET_FLAGS (user_data, GDL_DOCK_USER_ACTION); - - return FALSE; -} - -static void -gdl_dock_notebook_init (GdlDockNotebook *notebook) -{ - GdlDockItem *item; - - item = GDL_DOCK_ITEM (notebook); - - /* create the container notebook */ - item->child = gdl_switcher_new (); - gtk_widget_set_parent (item->child, GTK_WIDGET (notebook)); - gtk_notebook_set_tab_pos (GTK_NOTEBOOK (item->child), GTK_POS_BOTTOM); - g_signal_connect (item->child, "switch-page", - (GCallback) gdl_dock_notebook_switch_page_cb, (gpointer) item); - g_signal_connect (item->child, "notify::page", - (GCallback) gdl_dock_notebook_notify_cb, (gpointer) item); - g_signal_connect (item->child, "button-press-event", - (GCallback) gdl_dock_notebook_button_cb, (gpointer) item); - g_signal_connect (item->child, "button-release-event", - (GCallback) gdl_dock_notebook_button_cb, (gpointer) item); - gtk_notebook_set_scrollable (GTK_NOTEBOOK (item->child), TRUE); - gtk_widget_show (item->child); -} - -static void -gdl_dock_notebook_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) -{ - GdlDockItem *item = GDL_DOCK_ITEM (object); - - switch (prop_id) { - case PROP_PAGE: - if (item->child && GTK_IS_NOTEBOOK (item->child)) { - gtk_notebook_set_current_page (GTK_NOTEBOOK (item->child), - g_value_get_int (value)); - } - - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -gdl_dock_notebook_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) -{ - GdlDockItem *item = GDL_DOCK_ITEM (object); - - switch (prop_id) { - case PROP_PAGE: - if (item->child && GTK_IS_NOTEBOOK (item->child)) { - g_value_set_int (value, gtk_notebook_get_current_page - (GTK_NOTEBOOK (item->child))); - } - - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - - -static void -gdl_dock_notebook_destroy (GtkObject *object) -{ - GdlDockItem *item = GDL_DOCK_ITEM (object); - - /* we need to call the virtual first, since in GdlDockDestroy our - children dock objects are detached */ - GTK_OBJECT_CLASS (gdl_dock_notebook_parent_class)->destroy (object); - - /* after that we can remove the GtkNotebook */ - if (item->child) { - gtk_widget_unparent (item->child); - item->child = NULL; - }; -} - -static void -gdl_dock_notebook_switch_page_cb (GtkNotebook *nb, - GtkWidget *page, - gint page_num, - gpointer data) -{ - GdlDockNotebook *notebook; - GtkWidget *tablabel; - GdlDockItem *item; - - notebook = GDL_DOCK_NOTEBOOK (data); - - /* deactivate old tablabel */ - if (gtk_notebook_get_current_page (nb)) { - tablabel = gtk_notebook_get_tab_label ( - nb, gtk_notebook_get_nth_page ( - nb, gtk_notebook_get_current_page (nb))); - if (tablabel && GDL_IS_DOCK_TABLABEL (tablabel)) - gdl_dock_tablabel_deactivate (GDL_DOCK_TABLABEL (tablabel)); - }; - - /* activate new label */ - tablabel = gtk_notebook_get_tab_label ( - nb, page); - if (tablabel && GDL_IS_DOCK_TABLABEL (tablabel)) - gdl_dock_tablabel_activate (GDL_DOCK_TABLABEL (tablabel)); - - if (GDL_DOCK_ITEM_USER_ACTION (notebook) && - GDL_DOCK_OBJECT (notebook)->master) - g_signal_emit_by_name (GDL_DOCK_OBJECT (notebook)->master, - "layout-changed"); - - /* Signal that a new dock item has been selected */ - item = GDL_DOCK_ITEM (page); - gdl_dock_item_notify_selected (item); -} - -static void -gdl_dock_notebook_add (GtkContainer *container, - GtkWidget *widget) -{ - g_return_if_fail (container != NULL && widget != NULL); - g_return_if_fail (GDL_IS_DOCK_NOTEBOOK (container)); - g_return_if_fail (GDL_IS_DOCK_ITEM (widget)); - - gdl_dock_object_dock (GDL_DOCK_OBJECT (container), - GDL_DOCK_OBJECT (widget), - GDL_DOCK_CENTER, - NULL); -} - -static void -gdl_dock_notebook_forall (GtkContainer *container, - gboolean include_internals, - GtkCallback callback, - gpointer callback_data) -{ - GdlDockItem *item; - - g_return_if_fail (container != NULL); - g_return_if_fail (GDL_IS_DOCK_NOTEBOOK (container)); - g_return_if_fail (callback != NULL); - - if (include_internals) { - /* use GdlDockItem's forall */ - GTK_CONTAINER_CLASS (gdl_dock_notebook_parent_class)->forall - (container, include_internals, callback, callback_data); - } - else { - item = GDL_DOCK_ITEM (container); - if (item->child) - gtk_container_foreach (GTK_CONTAINER (item->child), callback, callback_data); - } -} - -static GType -gdl_dock_notebook_child_type (GtkContainer *container) -{ - return GDL_TYPE_DOCK_ITEM; -} - -static void -gdl_dock_notebook_dock_child (GdlDockObject *requestor, - gpointer user_data) -{ - struct { - GdlDockObject *object; - GdlDockPlacement position; - GValue *other_data; - } *data = user_data; - - gdl_dock_object_dock (data->object, requestor, data->position, data->other_data); -} - -static void -gdl_dock_notebook_dock (GdlDockObject *object, - GdlDockObject *requestor, - GdlDockPlacement position, - GValue *other_data) -{ - g_return_if_fail (GDL_IS_DOCK_NOTEBOOK (object)); - g_return_if_fail (GDL_IS_DOCK_ITEM (requestor)); - - /* we only add support for GDL_DOCK_CENTER docking strategy here... for the rest - use our parent class' method */ - if (position == GDL_DOCK_CENTER) { - /* we can only dock simple (not compound) items */ - if (gdl_dock_object_is_compound (requestor)) { - struct { - GdlDockObject *object; - GdlDockPlacement position; - GValue *other_data; - } data; - - gdl_dock_object_freeze (requestor); - - data.object = object; - data.position = position; - data.other_data = other_data; - - gtk_container_foreach (GTK_CONTAINER (requestor), - (GtkCallback) gdl_dock_notebook_dock_child, &data); - - gdl_dock_object_thaw (requestor); - } - else { - GdlDockItem *item = GDL_DOCK_ITEM (object); - GdlDockItem *requestor_item = GDL_DOCK_ITEM (requestor); - gchar *long_name, *stock_id; - GdkPixbuf *pixbuf_icon; - GtkWidget *label; - gint position = -1; - - g_object_get (requestor_item, "long-name", &long_name, - "stock-id", &stock_id, "pixbuf-icon", &pixbuf_icon, NULL); - label = gdl_dock_item_get_tablabel (requestor_item); - if (!label) { - label = gtk_label_new (long_name); - gdl_dock_item_set_tablabel (requestor_item, label); - } -#if 0 - if (GDL_IS_DOCK_TABLABEL (label)) { - gdl_dock_tablabel_deactivate (GDL_DOCK_TABLABEL (label)); - /* hide the item grip, as we will use the tablabel's */ - gdl_dock_item_hide_grip (requestor_item); - } -#endif - - if (other_data && G_VALUE_HOLDS (other_data, G_TYPE_INT)) - position = g_value_get_int (other_data); - - position = gdl_switcher_insert_page (GDL_SWITCHER (item->child), - GTK_WIDGET (requestor), label, - long_name, long_name, - stock_id, pixbuf_icon, position); - - GDL_DOCK_OBJECT_SET_FLAGS (requestor, GDL_DOCK_ATTACHED); - - /* Set current page to the newly docked widget. set current page - * really doesn't work if the page widget is not shown - */ - gtk_widget_show (GTK_WIDGET (requestor)); - gtk_notebook_set_current_page (GTK_NOTEBOOK (item->child), - position); - g_free (long_name); - g_free (stock_id); - } - } - else - GDL_DOCK_OBJECT_CLASS (gdl_dock_notebook_parent_class)->dock (object, requestor, position, other_data); -} - -static void -gdl_dock_notebook_set_orientation (GdlDockItem *item, - GtkOrientation orientation) -{ - if (item->child && GTK_IS_NOTEBOOK (item->child)) { - if (orientation == GTK_ORIENTATION_HORIZONTAL) - gtk_notebook_set_tab_pos (GTK_NOTEBOOK (item->child), GTK_POS_TOP); - else - gtk_notebook_set_tab_pos (GTK_NOTEBOOK (item->child), GTK_POS_LEFT); - } - - GDL_DOCK_ITEM_CLASS (gdl_dock_notebook_parent_class)->set_orientation (item, orientation); -} - -static gboolean -gdl_dock_notebook_child_placement (GdlDockObject *object, - GdlDockObject *child, - GdlDockPlacement *placement) -{ - GdlDockItem *item = GDL_DOCK_ITEM (object); - GdlDockPlacement pos = GDL_DOCK_NONE; - - if (item->child) { - GList *children, *l; - - children = gtk_container_get_children (GTK_CONTAINER (item->child)); - for (l = children; l; l = l->next) { - if (l->data == (gpointer) child) { - pos = GDL_DOCK_CENTER; - break; - } - } - g_list_free (children); - } - - if (pos != GDL_DOCK_NONE) { - if (placement) - *placement = pos; - return TRUE; - } - else - return FALSE; -} - -static void -gdl_dock_notebook_present (GdlDockObject *object, - GdlDockObject *child) -{ - GdlDockItem *item = GDL_DOCK_ITEM (object); - int i; - - i = gtk_notebook_page_num (GTK_NOTEBOOK (item->child), - GTK_WIDGET (child)); - if (i >= 0) - gtk_notebook_set_current_page (GTK_NOTEBOOK (item->child), i); - - GDL_DOCK_OBJECT_CLASS (gdl_dock_notebook_parent_class)->present (object, child); -} - -static gboolean -gdl_dock_notebook_reorder (GdlDockObject *object, - GdlDockObject *requestor, - GdlDockPlacement new_position, - GValue *other_data) -{ - GdlDockItem *item = GDL_DOCK_ITEM (object); - gint current_position, new_pos = -1; - gboolean handled = FALSE; - - if (item->child && new_position == GDL_DOCK_CENTER) { - current_position = gtk_notebook_page_num (GTK_NOTEBOOK (item->child), - GTK_WIDGET (requestor)); - if (current_position >= 0) { - handled = TRUE; - - if (other_data && G_VALUE_HOLDS (other_data, G_TYPE_INT)) - new_pos = g_value_get_int (other_data); - - gtk_notebook_reorder_child (GTK_NOTEBOOK (item->child), - GTK_WIDGET (requestor), - new_pos); - } - } - return handled; -} - -/* ----- Public interface ----- */ - -GtkWidget * -gdl_dock_notebook_new (void) -{ - GdlDockNotebook *notebook; - - notebook = GDL_DOCK_NOTEBOOK (g_object_new (GDL_TYPE_DOCK_NOTEBOOK, NULL)); - GDL_DOCK_OBJECT_UNSET_FLAGS (notebook, GDL_DOCK_AUTOMATIC); - - return GTK_WIDGET (notebook); -} - diff --git a/src/libgdl/gdl-dock-notebook.h b/src/libgdl/gdl-dock-notebook.h deleted file mode 100644 index 063f53642..000000000 --- a/src/libgdl/gdl-dock-notebook.h +++ /dev/null @@ -1,59 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This file is part of the GNOME Devtools Libraries. - * - * Copyright (C) 2002 Gustavo Giráldez <gustavo.giraldez@gmx.net> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef __GDL_DOCK_NOTEBOOK_H__ -#define __GDL_DOCK_NOTEBOOK_H__ - -#include "libgdl/gdl-dock-item.h" - -G_BEGIN_DECLS - -/* standard macros */ -#define GDL_TYPE_DOCK_NOTEBOOK (gdl_dock_notebook_get_type ()) -#define GDL_DOCK_NOTEBOOK(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDL_TYPE_DOCK_NOTEBOOK, GdlDockNotebook)) -#define GDL_DOCK_NOTEBOOK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDL_TYPE_DOCK_NOTEBOOK, GdlDockNotebookClass)) -#define GDL_IS_DOCK_NOTEBOOK(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GDL_TYPE_DOCK_NOTEBOOK)) -#define GDL_IS_DOCK_NOTEBOOK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDL_TYPE_DOCK_NOTEBOOK)) -#define GDL_DOCK_NOTEBOOK_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_DOCK_NOTEBOOK, GdlDockNotebookClass)) - -/* data types & structures */ -typedef struct _GdlDockNotebook GdlDockNotebook; -typedef struct _GdlDockNotebookClass GdlDockNotebookClass; - -struct _GdlDockNotebook { - GdlDockItem item; -}; - -struct _GdlDockNotebookClass { - GdlDockItemClass parent_class; -}; - - -/* public interface */ - -GtkWidget *gdl_dock_notebook_new (void); - -GType gdl_dock_notebook_get_type (void); - -G_END_DECLS - -#endif - diff --git a/src/libgdl/gdl-dock-object.c b/src/libgdl/gdl-dock-object.c deleted file mode 100644 index 4092ecc9f..000000000 --- a/src/libgdl/gdl-dock-object.c +++ /dev/null @@ -1,1027 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * gdl-dock-object.c - Abstract base class for all dock related objects - * - * This file is part of the GNOME Devtools Libraries. - * - * Copyright (C) 2002 Gustavo Giráldez <gustavo.giraldez@gmx.net> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include "gdl-i18n.h" -#include <stdlib.h> -#include <string.h> - -#include "gdl-dock-object.h" -#include "gdl-dock-master.h" -#include "libgdltypebuiltins.h" -#include "libgdlmarshal.h" - -/* for later use by the registry */ -#include "gdl-dock.h" -#include "gdl-dock-item.h" -#include "gdl-dock-paned.h" -#include "gdl-dock-notebook.h" -#include "gdl-dock-placeholder.h" - - -/* ----- Private prototypes ----- */ - -static void gdl_dock_object_class_init (GdlDockObjectClass *klass); - -static void gdl_dock_object_set_property (GObject *g_object, - guint prop_id, - const GValue *value, - GParamSpec *pspec); -static void gdl_dock_object_get_property (GObject *g_object, - guint prop_id, - GValue *value, - GParamSpec *pspec); -static void gdl_dock_object_finalize (GObject *g_object); - -static void gdl_dock_object_destroy (GtkObject *gtk_object); - -static void gdl_dock_object_show (GtkWidget *widget); -static void gdl_dock_object_hide (GtkWidget *widget); - -static void gdl_dock_object_real_detach (GdlDockObject *object, - gboolean recursive); -static void gdl_dock_object_real_reduce (GdlDockObject *object); -static void gdl_dock_object_dock_unimplemented (GdlDockObject *object, - GdlDockObject *requestor, - GdlDockPlacement position, - GValue *other_data); -static void gdl_dock_object_real_present (GdlDockObject *object, - GdlDockObject *child); - - -/* ----- Private data types and variables ----- */ - -enum { - PROP_0, - PROP_NAME, - PROP_LONG_NAME, - PROP_STOCK_ID, - PROP_PIXBUF_ICON, - PROP_MASTER, - PROP_EXPORT_PROPERTIES -}; - -enum { - DETACH, - DOCK, - LAST_SIGNAL -}; - -static guint gdl_dock_object_signals [LAST_SIGNAL] = { 0 }; - -struct DockRegisterItem { - gchar* nick; - gpointer type; -}; - -static GArray *dock_register = NULL; - -/* ----- Private interface ----- */ - -G_DEFINE_TYPE (GdlDockObject, gdl_dock_object, GTK_TYPE_CONTAINER); - -static void -gdl_dock_object_class_init (GdlDockObjectClass *klass) -{ - GObjectClass *g_object_class; - GtkObjectClass *object_class; - GtkWidgetClass *widget_class; - GtkContainerClass *container_class; - - g_object_class = G_OBJECT_CLASS (klass); - object_class = GTK_OBJECT_CLASS (klass); - widget_class = GTK_WIDGET_CLASS (klass); - container_class = GTK_CONTAINER_CLASS (klass); - - g_object_class->set_property = gdl_dock_object_set_property; - g_object_class->get_property = gdl_dock_object_get_property; - g_object_class->finalize = gdl_dock_object_finalize; - - g_object_class_install_property ( - g_object_class, PROP_NAME, - g_param_spec_string (GDL_DOCK_NAME_PROPERTY, _("Name"), - _("Unique name for identifying the dock object"), - NULL, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | - GDL_DOCK_PARAM_EXPORT)); - - g_object_class_install_property ( - g_object_class, PROP_LONG_NAME, - g_param_spec_string ("long-name", _("Long name"), - _("Human readable name for the dock object"), - NULL, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); - - g_object_class_install_property ( - g_object_class, PROP_STOCK_ID, - g_param_spec_string ("stock-id", _("Stock Icon"), - _("Stock icon for the dock object"), - NULL, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); - - g_object_class_install_property ( - g_object_class, PROP_PIXBUF_ICON, - g_param_spec_pointer ("pixbuf-icon", _("Pixbuf Icon"), - _("Pixbuf icon for the dock object"), - G_PARAM_READWRITE)); - - g_object_class_install_property ( - g_object_class, PROP_MASTER, - g_param_spec_object ("master", _("Dock master"), - _("Dock master this dock object is bound to"), - GDL_TYPE_DOCK_MASTER, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); - - object_class->destroy = gdl_dock_object_destroy; - - widget_class->show = gdl_dock_object_show; - widget_class->hide = gdl_dock_object_hide; - - klass->is_compound = TRUE; - - klass->detach = gdl_dock_object_real_detach; - klass->reduce = gdl_dock_object_real_reduce; - klass->dock_request = NULL; - klass->dock = gdl_dock_object_dock_unimplemented; - klass->reorder = NULL; - klass->present = gdl_dock_object_real_present; - klass->child_placement = NULL; - - gdl_dock_object_signals [DETACH] = - g_signal_new ("detach", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GdlDockObjectClass, detach), - NULL, - NULL, - gdl_marshal_VOID__BOOLEAN, - G_TYPE_NONE, - 1, - G_TYPE_BOOLEAN); - - gdl_dock_object_signals [DOCK] = - g_signal_new ("dock", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (GdlDockObjectClass, dock), - NULL, - NULL, - gdl_marshal_VOID__OBJECT_ENUM_BOXED, - G_TYPE_NONE, - 3, - GDL_TYPE_DOCK_OBJECT, - GDL_TYPE_DOCK_PLACEMENT, - G_TYPE_VALUE); -} - -static void -gdl_dock_object_init (GdlDockObject *object) -{ - object->flags = GDL_DOCK_AUTOMATIC; - object->freeze_count = 0; -} - -static void -gdl_dock_object_set_property (GObject *g_object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) -{ - GdlDockObject *object = GDL_DOCK_OBJECT (g_object); - - switch (prop_id) { - case PROP_NAME: - g_free (object->name); - object->name = g_value_dup_string (value); - break; - case PROP_LONG_NAME: - g_free (object->long_name); - object->long_name = g_value_dup_string (value); - break; - case PROP_STOCK_ID: - g_free (object->stock_id); - object->stock_id = g_value_dup_string (value); - break; - case PROP_PIXBUF_ICON: - object->pixbuf_icon = g_value_get_pointer (value); - break; - case PROP_MASTER: - if (g_value_get_object (value)) - gdl_dock_object_bind (object, g_value_get_object (value)); - else - gdl_dock_object_unbind (object); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -gdl_dock_object_get_property (GObject *g_object, - guint prop_id, - GValue *value, - GParamSpec *pspec) -{ - GdlDockObject *object = GDL_DOCK_OBJECT (g_object); - - switch (prop_id) { - case PROP_NAME: - g_value_set_string (value, object->name); - break; - case PROP_LONG_NAME: - g_value_set_string (value, object->long_name); - break; - case PROP_STOCK_ID: - g_value_set_string (value, object->stock_id); - break; - case PROP_PIXBUF_ICON: - g_value_set_pointer (value, object->pixbuf_icon); - break; - case PROP_MASTER: - g_value_set_object (value, object->master); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -gdl_dock_object_finalize (GObject *g_object) -{ - GdlDockObject *object; - - g_return_if_fail (g_object != NULL && GDL_IS_DOCK_OBJECT (g_object)); - - object = GDL_DOCK_OBJECT (g_object); - - g_free (object->name); - object->name = NULL; - g_free (object->long_name); - object->long_name = NULL; - g_free (object->stock_id); - object->stock_id = NULL; - object->pixbuf_icon = NULL; - - G_OBJECT_CLASS (gdl_dock_object_parent_class)->finalize (g_object); -} - -static void -gdl_dock_object_foreach_detach (GdlDockObject *object, - gpointer user_data) -{ - gdl_dock_object_detach (object, TRUE); -} - -static void -gdl_dock_object_destroy (GtkObject *gtk_object) -{ - GdlDockObject *object; - - g_return_if_fail (GDL_IS_DOCK_OBJECT (gtk_object)); - - object = GDL_DOCK_OBJECT (gtk_object); - if (gdl_dock_object_is_compound (object)) { - /* detach our dock object children if we have some, and even - if we are not attached, so they can get notification */ - gdl_dock_object_freeze (object); - gtk_container_foreach (GTK_CONTAINER (object), - (GtkCallback) gdl_dock_object_foreach_detach, - NULL); - object->reduce_pending = FALSE; - gdl_dock_object_thaw (object); - } - if (GDL_DOCK_OBJECT_ATTACHED (object)) { - /* detach ourselves */ - gdl_dock_object_detach (object, FALSE); - } - - /* finally unbind us */ - if (object->master) - gdl_dock_object_unbind (object); - - GTK_OBJECT_CLASS(gdl_dock_object_parent_class)->destroy (gtk_object); -} - -static void -gdl_dock_object_foreach_automatic (GdlDockObject *object, - gpointer user_data) -{ - void (* function) (GtkWidget *) = user_data; - - if (GDL_DOCK_OBJECT_AUTOMATIC (object)) - (* function) (GTK_WIDGET (object)); -} - -static void -gdl_dock_object_show (GtkWidget *widget) -{ - if (gdl_dock_object_is_compound (GDL_DOCK_OBJECT (widget))) { - gtk_container_foreach (GTK_CONTAINER (widget), - (GtkCallback) gdl_dock_object_foreach_automatic, - gtk_widget_show); - } - GTK_WIDGET_CLASS (gdl_dock_object_parent_class)->show (widget); -} - -static void -gdl_dock_object_hide (GtkWidget *widget) -{ - if (gdl_dock_object_is_compound (GDL_DOCK_OBJECT (widget))) { - gtk_container_foreach (GTK_CONTAINER (widget), - (GtkCallback) gdl_dock_object_foreach_automatic, - gtk_widget_hide); - } - GTK_WIDGET_CLASS (gdl_dock_object_parent_class)->hide (widget); -} - -static void -gdl_dock_object_real_detach (GdlDockObject *object, - gboolean recursive) -{ - GdlDockObject *parent; - GtkWidget *widget; - - g_return_if_fail (object != NULL); - - /* detach children */ - if (recursive && gdl_dock_object_is_compound (object)) { - gtk_container_foreach (GTK_CONTAINER (object), - (GtkCallback) gdl_dock_object_detach, - GINT_TO_POINTER (recursive)); - } - - /* detach the object itself */ - GDL_DOCK_OBJECT_UNSET_FLAGS (object, GDL_DOCK_ATTACHED); - parent = gdl_dock_object_get_parent_object (object); - widget = GTK_WIDGET (object); - if (gtk_widget_get_parent (widget)) - gtk_container_remove (GTK_CONTAINER (gtk_widget_get_parent (GTK_WIDGET (widget))), widget); - if (parent) - gdl_dock_object_reduce (parent); -} - -static void -gdl_dock_object_real_reduce (GdlDockObject *object) -{ - GdlDockObject *parent; - GList *children; - - g_return_if_fail (object != NULL); - - if (!gdl_dock_object_is_compound (object)) - return; - - parent = gdl_dock_object_get_parent_object (object); - children = gtk_container_get_children (GTK_CONTAINER (object)); - if (g_list_length (children) <= 1) { - GList *l; - GList *dchildren = NULL; - - /* detach ourselves and then re-attach our children to our - current parent. if we are not currently attached, the - children are detached */ - if (parent) - gdl_dock_object_freeze (parent); - gdl_dock_object_freeze (object); - /* Detach the children before detaching this object, since in this - * way the children can have access to the whole object hierarchy. - * Set the InDetach flag now, so the children know that this object - * is going to be detached. */ - - - GDL_DOCK_OBJECT_SET_FLAGS (object, GDL_DOCK_IN_DETACH); - - for (l = children; l; l = l->next) { - GdlDockObject *child; - - if (!GDL_IS_DOCK_OBJECT (l->data)) - continue; - - child = GDL_DOCK_OBJECT (l->data); - - g_object_ref (child); - gdl_dock_object_detach (child, FALSE); - GDL_DOCK_OBJECT_SET_FLAGS (child, GDL_DOCK_IN_REFLOW); - if (parent) - dchildren = g_list_append (dchildren, child); - GDL_DOCK_OBJECT_UNSET_FLAGS (child, GDL_DOCK_IN_REFLOW); - } - /* Now it can be detached */ - gdl_dock_object_detach (object, FALSE); - - /* After detaching the reduced object, we can add the - children (the only child in fact) to the new parent */ - for (l = dchildren; l; l = l->next) { - gtk_container_add (GTK_CONTAINER (parent), l->data); - g_object_unref (l->data); - } - g_list_free (dchildren); - - - /* sink the widget, so any automatic floating widget is destroyed */ - g_object_ref_sink (object); - /* don't reenter */ - object->reduce_pending = FALSE; - gdl_dock_object_thaw (object); - if (parent) - gdl_dock_object_thaw (parent); - } - g_list_free (children); -} - -static void -gdl_dock_object_dock_unimplemented (GdlDockObject *object, - GdlDockObject *requestor, - GdlDockPlacement position, - GValue *other_data) -{ - g_warning (_("Call to gdl_dock_object_dock in a dock object %p " - "(object type is %s) which hasn't implemented this method"), - object, G_OBJECT_TYPE_NAME (object)); -} - -static void -gdl_dock_object_real_present (GdlDockObject *object, - GdlDockObject *child) -{ - gtk_widget_show (GTK_WIDGET (object)); -} - - -/* ----- Public interface ----- */ - -gboolean -gdl_dock_object_is_compound (GdlDockObject *object) -{ - GdlDockObjectClass *klass; - - g_return_val_if_fail (object != NULL, FALSE); - g_return_val_if_fail (GDL_IS_DOCK_OBJECT (object), FALSE); - - klass = GDL_DOCK_OBJECT_GET_CLASS (object); - return klass->is_compound; -} - -void -gdl_dock_object_detach (GdlDockObject *object, - gboolean recursive) -{ - g_return_if_fail (object != NULL); - - if (!GDL_IS_DOCK_OBJECT (object)) - return; - - if (!GDL_DOCK_OBJECT_ATTACHED (object)) - return; - - /* freeze the object to avoid reducing while detaching children */ - gdl_dock_object_freeze (object); - GDL_DOCK_OBJECT_SET_FLAGS (object, GDL_DOCK_IN_DETACH); - g_signal_emit (object, gdl_dock_object_signals [DETACH], 0, recursive); - GDL_DOCK_OBJECT_UNSET_FLAGS (object, GDL_DOCK_IN_DETACH); - gdl_dock_object_thaw (object); -} - -GdlDockObject * -gdl_dock_object_get_parent_object (GdlDockObject *object) -{ - GtkWidget *parent; - - g_return_val_if_fail (object != NULL, NULL); - - parent = gtk_widget_get_parent (GTK_WIDGET (object)); - while (parent && !GDL_IS_DOCK_OBJECT (parent)) { - parent = gtk_widget_get_parent (parent); - } - - return parent ? GDL_DOCK_OBJECT (parent) : NULL; -} - -void -gdl_dock_object_freeze (GdlDockObject *object) -{ - g_return_if_fail (object != NULL); - - if (object->freeze_count == 0) { - g_object_ref (object); /* dock objects shouldn't be - destroyed if they are frozen */ - } - object->freeze_count++; -} - -void -gdl_dock_object_thaw (GdlDockObject *object) -{ - g_return_if_fail (object != NULL); - g_return_if_fail (object->freeze_count > 0); - - object->freeze_count--; - if (object->freeze_count == 0) { - if (object->reduce_pending) { - object->reduce_pending = FALSE; - gdl_dock_object_reduce (object); - } - g_object_unref (object); - } -} - -void -gdl_dock_object_reduce (GdlDockObject *object) -{ - g_return_if_fail (object != NULL); - - if (GDL_DOCK_OBJECT_FROZEN (object)) { - object->reduce_pending = TRUE; - return; - } - - if (GDL_DOCK_OBJECT_GET_CLASS (object)->reduce) - GDL_DOCK_OBJECT_GET_CLASS (object)->reduce (object); -} - -gboolean -gdl_dock_object_dock_request (GdlDockObject *object, - gint x, - gint y, - GdlDockRequest *request) -{ - g_return_val_if_fail (object != NULL && request != NULL, FALSE); - - if (GDL_DOCK_OBJECT_GET_CLASS (object)->dock_request) - return GDL_DOCK_OBJECT_GET_CLASS (object)->dock_request (object, x, y, request); - else - return FALSE; -} - -/** - * gdl_dock_object_dock: - * @object: - * @requestor: - * @position: - * @other_data: (allow-none): - **/ -void -gdl_dock_object_dock (GdlDockObject *object, - GdlDockObject *requestor, - GdlDockPlacement position, - GValue *other_data) -{ - GdlDockObject *parent; - - g_return_if_fail (object != NULL && requestor != NULL); - - if (object == requestor) - return; - - if (!object->master) - g_warning (_("Dock operation requested in a non-bound object %p. " - "The application might crash"), object); - - if (!gdl_dock_object_is_bound (requestor)) - gdl_dock_object_bind (requestor, object->master); - - if (requestor->master != object->master) { - g_warning (_("Cannot dock %p to %p because they belong to different masters"), - requestor, object); - return; - } - - /* first, see if we can optimize things by reordering */ - if (position != GDL_DOCK_NONE) { - parent = gdl_dock_object_get_parent_object (object); - if (gdl_dock_object_reorder (object, requestor, position, other_data) || - (parent && gdl_dock_object_reorder (parent, requestor, position, other_data))) - return; - } - - /* freeze the object, since under some conditions it might be destroyed when - detaching the requestor */ - gdl_dock_object_freeze (object); - - /* detach the requestor before docking */ - g_object_ref (requestor); - if (GDL_DOCK_OBJECT_ATTACHED (requestor)) - gdl_dock_object_detach (requestor, FALSE); - - if (position != GDL_DOCK_NONE) - g_signal_emit (object, gdl_dock_object_signals [DOCK], 0, - requestor, position, other_data); - - g_object_unref (requestor); - gdl_dock_object_thaw (object); -} - -void -gdl_dock_object_bind (GdlDockObject *object, - GObject *master) -{ - g_return_if_fail (object != NULL && master != NULL); - g_return_if_fail (GDL_IS_DOCK_MASTER (master)); - - if (object->master == master) - /* nothing to do here */ - return; - - if (object->master) { - g_warning (_("Attempt to bind to %p an already bound dock object %p " - "(current master: %p)"), master, object, object->master); - return; - } - - gdl_dock_master_add (GDL_DOCK_MASTER (master), object); - object->master = master; - g_object_add_weak_pointer (master, (gpointer *) &object->master); - - g_object_notify (G_OBJECT (object), "master"); -} - -void -gdl_dock_object_unbind (GdlDockObject *object) -{ - g_return_if_fail (object != NULL); - - g_object_ref (object); - - /* detach the object first */ - if (GDL_DOCK_OBJECT_ATTACHED (object)) - gdl_dock_object_detach (object, TRUE); - - if (object->master) { - GObject *master = object->master; - g_object_remove_weak_pointer (master, (gpointer *) &object->master); - object->master = NULL; - gdl_dock_master_remove (GDL_DOCK_MASTER (master), object); - g_object_notify (G_OBJECT (object), "master"); - } - g_object_unref (object); -} - -gboolean -gdl_dock_object_is_bound (GdlDockObject *object) -{ - g_return_val_if_fail (object != NULL, FALSE); - return (object->master != NULL); -} - -gboolean -gdl_dock_object_reorder (GdlDockObject *object, - GdlDockObject *child, - GdlDockPlacement new_position, - GValue *other_data) -{ - g_return_val_if_fail (object != NULL && child != NULL, FALSE); - - if (GDL_DOCK_OBJECT_GET_CLASS (object)->reorder) - return GDL_DOCK_OBJECT_GET_CLASS (object)->reorder (object, child, new_position, other_data); - else - return FALSE; -} - -void -gdl_dock_object_present (GdlDockObject *object, - GdlDockObject *child) -{ - GdlDockObject *parent; - - g_return_if_fail (object != NULL && GDL_IS_DOCK_OBJECT (object)); - - parent = gdl_dock_object_get_parent_object (object); - if (parent) - /* chain the call to our parent */ - gdl_dock_object_present (parent, object); - - if (GDL_DOCK_OBJECT_GET_CLASS (object)->present) - GDL_DOCK_OBJECT_GET_CLASS (object)->present (object, child); -} - -/** - * gdl_dock_object_child_placement: - * @object: the dock object we are asking for child placement - * @child: the child of the @object we want the placement for - * @placement: where to return the placement information - * - * This function returns information about placement of a child dock - * object inside another dock object. The function returns %TRUE if - * @child is effectively a child of @object. @placement should - * normally be initially setup to %GDL_DOCK_NONE. If it's set to some - * other value, this function will not touch the stored value if the - * specified placement is "compatible" with the actual placement of - * the child. - * - * @placement can be %NULL, in which case the function simply tells if - * @child is attached to @object. - * - * Returns: %TRUE if @child is a child of @object. - */ -gboolean -gdl_dock_object_child_placement (GdlDockObject *object, - GdlDockObject *child, - GdlDockPlacement *placement) -{ - g_return_val_if_fail (object != NULL && child != NULL, FALSE); - - /* simple case */ - if (!gdl_dock_object_is_compound (object)) - return FALSE; - - if (GDL_DOCK_OBJECT_GET_CLASS (object)->child_placement) - return GDL_DOCK_OBJECT_GET_CLASS (object)->child_placement (object, child, placement); - else - return FALSE; -} - - -/* ----- dock param type functions start here ------ */ - -static void -gdl_dock_param_export_int (const GValue *src, - GValue *dst) -{ - dst->data [0].v_pointer = g_strdup_printf ("%d", src->data [0].v_int); -} - -static void -gdl_dock_param_export_uint (const GValue *src, - GValue *dst) -{ - dst->data [0].v_pointer = g_strdup_printf ("%u", src->data [0].v_uint); -} - -static void -gdl_dock_param_export_string (const GValue *src, - GValue *dst) -{ - dst->data [0].v_pointer = g_strdup (src->data [0].v_pointer); -} - -static void -gdl_dock_param_export_bool (const GValue *src, - GValue *dst) -{ - dst->data [0].v_pointer = g_strdup_printf ("%s", src->data [0].v_int ? "yes" : "no"); -} - -static void -gdl_dock_param_export_placement (const GValue *src, - GValue *dst) -{ - switch (src->data [0].v_int) { - case GDL_DOCK_NONE: - dst->data [0].v_pointer = g_strdup (""); - break; - case GDL_DOCK_TOP: - dst->data [0].v_pointer = g_strdup ("top"); - break; - case GDL_DOCK_BOTTOM: - dst->data [0].v_pointer = g_strdup ("bottom"); - break; - case GDL_DOCK_LEFT: - dst->data [0].v_pointer = g_strdup ("left"); - break; - case GDL_DOCK_RIGHT: - dst->data [0].v_pointer = g_strdup ("right"); - break; - case GDL_DOCK_CENTER: - dst->data [0].v_pointer = g_strdup ("center"); - break; - case GDL_DOCK_FLOATING: - dst->data [0].v_pointer = g_strdup ("floating"); - break; - } -} - -static void -gdl_dock_param_import_int (const GValue *src, - GValue *dst) -{ - dst->data [0].v_int = atoi (src->data [0].v_pointer); -} - -static void -gdl_dock_param_import_uint (const GValue *src, - GValue *dst) -{ - dst->data [0].v_uint = (guint) atoi (src->data [0].v_pointer); -} - -static void -gdl_dock_param_import_string (const GValue *src, - GValue *dst) -{ - dst->data [0].v_pointer = g_strdup (src->data [0].v_pointer); -} - -static void -gdl_dock_param_import_bool (const GValue *src, - GValue *dst) -{ - dst->data [0].v_int = !strcmp (src->data [0].v_pointer, "yes"); -} - -static void -gdl_dock_param_import_placement (const GValue *src, - GValue *dst) -{ - if (!strcmp (src->data [0].v_pointer, "top")) - dst->data [0].v_int = GDL_DOCK_TOP; - else if (!strcmp (src->data [0].v_pointer, "bottom")) - dst->data [0].v_int = GDL_DOCK_BOTTOM; - else if (!strcmp (src->data [0].v_pointer, "center")) - dst->data [0].v_int = GDL_DOCK_CENTER; - else if (!strcmp (src->data [0].v_pointer, "left")) - dst->data [0].v_int = GDL_DOCK_LEFT; - else if (!strcmp (src->data [0].v_pointer, "right")) - dst->data [0].v_int = GDL_DOCK_RIGHT; - else if (!strcmp (src->data [0].v_pointer, "floating")) - dst->data [0].v_int = GDL_DOCK_FLOATING; - else - dst->data [0].v_int = GDL_DOCK_NONE; -} - -GType -gdl_dock_param_get_type (void) -{ - static GType our_type = 0; - - if (our_type == 0) { - GTypeInfo tinfo = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; - our_type = g_type_register_static (G_TYPE_STRING, "GdlDockParam", &tinfo, 0); - - /* register known transform functions */ - /* exporters */ - g_value_register_transform_func (G_TYPE_INT, our_type, gdl_dock_param_export_int); - g_value_register_transform_func (G_TYPE_UINT, our_type, gdl_dock_param_export_uint); - g_value_register_transform_func (G_TYPE_STRING, our_type, gdl_dock_param_export_string); - g_value_register_transform_func (G_TYPE_BOOLEAN, our_type, gdl_dock_param_export_bool); - g_value_register_transform_func (GDL_TYPE_DOCK_PLACEMENT, our_type, gdl_dock_param_export_placement); - /* importers */ - g_value_register_transform_func (our_type, G_TYPE_INT, gdl_dock_param_import_int); - g_value_register_transform_func (our_type, G_TYPE_UINT, gdl_dock_param_import_uint); - g_value_register_transform_func (our_type, G_TYPE_STRING, gdl_dock_param_import_string); - g_value_register_transform_func (our_type, G_TYPE_BOOLEAN, gdl_dock_param_import_bool); - g_value_register_transform_func (our_type, GDL_TYPE_DOCK_PLACEMENT, gdl_dock_param_import_placement); - } - - return our_type; -} - -/* -------------- nick <-> type conversion functions --------------- */ - -static void -gdl_dock_object_register_init (void) -{ - const size_t n_default = 5; - guint i = 0; - struct DockRegisterItem default_items[n_default]; - - if (dock_register) - return; - - dock_register - = g_array_new (FALSE, FALSE, sizeof (struct DockRegisterItem)); - - /* add known types */ - default_items[0].nick = "dock"; - default_items[0].type = (gpointer) GDL_TYPE_DOCK; - default_items[1].nick = "item"; - default_items[1].type = (gpointer) GDL_TYPE_DOCK_ITEM; - default_items[2].nick = "paned"; - default_items[2].type = (gpointer) GDL_TYPE_DOCK_PANED; - default_items[3].nick = "notebook"; - default_items[3].type = (gpointer) GDL_TYPE_DOCK_NOTEBOOK; - default_items[4].nick = "placeholder"; - default_items[4].type = (gpointer) GDL_TYPE_DOCK_PLACEHOLDER; - - for (i = 0; i < n_default; i++) - g_array_append_val (dock_register, default_items[i]); -} - -/** - * gdl_dock_object_nick_from_type: - * @type: The type for which to find the nickname - * - * Finds the nickname for a given type - * - * Returns: If the object has a nickname, then it is returned. - * Otherwise, the type name. - */ -const gchar * -gdl_dock_object_nick_from_type (GType type) -{ - gchar *nick = NULL; - guint i = 0; - - if (!dock_register) - gdl_dock_object_register_init (); - - for (i=0; i < dock_register->len; i++) { - struct DockRegisterItem item - = g_array_index (dock_register, struct DockRegisterItem, i); - - if (g_direct_equal (item.type, (gpointer) type)) - nick = g_strdup (item.nick); - } - - return nick ? nick : g_type_name (type); -} - -/** - * gdl_dock_object_type_from_nick: - * @nick: The nickname for the object type - * - * Finds the object type assigned to a given nickname. - * - * Returns: If the nickname has previously been assigned, then the corresponding - * object type is returned. Otherwise, %G_TYPE_NONE. - */ -GType -gdl_dock_object_type_from_nick (const gchar *nick) -{ - GType type = G_TYPE_NONE; - gboolean nick_is_in_register = FALSE; - guint i = 0; - - if (!dock_register) - gdl_dock_object_register_init (); - - for (i = 0; i < dock_register->len; i++) { - struct DockRegisterItem item - = g_array_index (dock_register, struct DockRegisterItem, i); - - if (!g_strcmp0 (nick, item.nick)) { - nick_is_in_register = TRUE; - type = (GType) item.type; - } - } - if (!nick_is_in_register) { - /* try searching in the glib type system */ - type = g_type_from_name (nick); - } - - return type; -} - -/** - * gdl_dock_object_set_type_for_nick: - * @nick: The nickname for the object type - * @type: The object type - * - * Assigns an object type to a given nickname. If the nickname already exists, - * then it reassigns it to a new object type. - * - * Returns: If the nick was previously assigned, the old type is returned. - * Otherwise, %G_TYPE_NONE. - */ -GType -gdl_dock_object_set_type_for_nick (const gchar *nick, - GType type) -{ - GType old_type = G_TYPE_NONE; - guint i = 0; - struct DockRegisterItem new_item; - new_item.nick = g_strdup(nick); - new_item.type = (gpointer) type; - - if (!dock_register) - gdl_dock_object_register_init (); - - g_return_val_if_fail (g_type_is_a (type, GDL_TYPE_DOCK_OBJECT), G_TYPE_NONE); - - for (i = 0; i < dock_register->len; i++) { - struct DockRegisterItem item - = g_array_index (dock_register, struct DockRegisterItem, i); - - if (!g_strcmp0 (nick, item.nick)) { - old_type = (GType) item.type; - g_array_insert_val (dock_register, i, new_item); - } - } - - return old_type; -} - diff --git a/src/libgdl/gdl-dock-object.h b/src/libgdl/gdl-dock-object.h deleted file mode 100644 index f8b192f35..000000000 --- a/src/libgdl/gdl-dock-object.h +++ /dev/null @@ -1,225 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * gdl-dock-object.h - Abstract base class for all dock related objects - * - * This file is part of the GNOME Devtools Libraries. - * - * Copyright (C) 2002 Gustavo Giráldez <gustavo.giraldez@gmx.net> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef __GDL_DOCK_OBJECT_H__ -#define __GDL_DOCK_OBJECT_H__ - -#include <gtk/gtk.h> - -G_BEGIN_DECLS - -/* standard macros */ -#define GDL_TYPE_DOCK_OBJECT (gdl_dock_object_get_type ()) -#define GDL_DOCK_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDL_TYPE_DOCK_OBJECT, GdlDockObject)) -#define GDL_DOCK_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDL_TYPE_DOCK_OBJECT, GdlDockObjectClass)) -#define GDL_IS_DOCK_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GDL_TYPE_DOCK_OBJECT)) -#define GDL_IS_DOCK_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDL_TYPE_DOCK_OBJECT)) -#define GDL_DOCK_OBJECT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_DOCK_OBJECT, GdlDockObjectClass)) - -/* data types & structures */ -typedef enum { - /* the parameter is to be exported for later layout rebuilding */ - GDL_DOCK_PARAM_EXPORT = 1 << G_PARAM_USER_SHIFT, - /* the parameter must be set after adding the children objects */ - GDL_DOCK_PARAM_AFTER = 1 << (G_PARAM_USER_SHIFT + 1) -} GdlDockParamFlags; - -#define GDL_DOCK_NAME_PROPERTY "name" -#define GDL_DOCK_MASTER_PROPERTY "master" - -typedef enum { - GDL_DOCK_AUTOMATIC = 1 << 0, - GDL_DOCK_ATTACHED = 1 << 1, - GDL_DOCK_IN_REFLOW = 1 << 2, - GDL_DOCK_IN_DETACH = 1 << 3 -} GdlDockObjectFlags; - -#define GDL_DOCK_OBJECT_FLAGS_SHIFT 8 - -typedef enum { - GDL_DOCK_NONE = 0, - GDL_DOCK_TOP, - GDL_DOCK_BOTTOM, - GDL_DOCK_RIGHT, - GDL_DOCK_LEFT, - GDL_DOCK_CENTER, - GDL_DOCK_FLOATING -} GdlDockPlacement; - -typedef struct _GdlDockObject GdlDockObject; -typedef struct _GdlDockObjectClass GdlDockObjectClass; -typedef struct _GdlDockRequest GdlDockRequest; - -struct _GdlDockRequest { - GdlDockObject *applicant; - GdlDockObject *target; - GdlDockPlacement position; - GdkRectangle rect; - GValue extra; -}; - -struct _GdlDockObject { - GtkContainer container; - - GdlDockObjectFlags flags; - gint freeze_count; - - GObject *master; - gchar *name; - gchar *long_name; - gchar *stock_id; - GdkPixbuf *pixbuf_icon; - - gboolean reduce_pending; -}; - -struct _GdlDockObjectClass { - GtkContainerClass parent_class; - - gboolean is_compound; - - void (* detach) (GdlDockObject *object, - gboolean recursive); - void (* reduce) (GdlDockObject *object); - - gboolean (* dock_request) (GdlDockObject *object, - gint x, - gint y, - GdlDockRequest *request); - - void (* dock) (GdlDockObject *object, - GdlDockObject *requestor, - GdlDockPlacement position, - GValue *other_data); - - gboolean (* reorder) (GdlDockObject *object, - GdlDockObject *child, - GdlDockPlacement new_position, - GValue *other_data); - - void (* present) (GdlDockObject *object, - GdlDockObject *child); - - gboolean (* child_placement) (GdlDockObject *object, - GdlDockObject *child, - GdlDockPlacement *placement); -}; - -/* additional macros */ -#define GDL_DOCK_OBJECT_FLAGS(obj) (GDL_DOCK_OBJECT (obj)->flags) -#define GDL_DOCK_OBJECT_AUTOMATIC(obj) \ - ((GDL_DOCK_OBJECT_FLAGS (obj) & GDL_DOCK_AUTOMATIC) != 0) -#define GDL_DOCK_OBJECT_ATTACHED(obj) \ - ((GDL_DOCK_OBJECT_FLAGS (obj) & GDL_DOCK_ATTACHED) != 0) -#define GDL_DOCK_OBJECT_IN_REFLOW(obj) \ - ((GDL_DOCK_OBJECT_FLAGS (obj) & GDL_DOCK_IN_REFLOW) != 0) -#define GDL_DOCK_OBJECT_IN_DETACH(obj) \ - ((GDL_DOCK_OBJECT_FLAGS (obj) & GDL_DOCK_IN_DETACH) != 0) - -#define GDL_DOCK_OBJECT_SET_FLAGS(obj,flag) \ - G_STMT_START { (GDL_DOCK_OBJECT_FLAGS (obj) |= (flag)); } G_STMT_END -#define GDL_DOCK_OBJECT_UNSET_FLAGS(obj,flag) \ - G_STMT_START { (GDL_DOCK_OBJECT_FLAGS (obj) &= ~(flag)); } G_STMT_END - -#define GDL_DOCK_OBJECT_FROZEN(obj) (GDL_DOCK_OBJECT (obj)->freeze_count > 0) - - -/* public interface */ - -GType gdl_dock_object_get_type (void); - -gboolean gdl_dock_object_is_compound (GdlDockObject *object); - -void gdl_dock_object_detach (GdlDockObject *object, - gboolean recursive); - -GdlDockObject *gdl_dock_object_get_parent_object (GdlDockObject *object); - -void gdl_dock_object_freeze (GdlDockObject *object); -void gdl_dock_object_thaw (GdlDockObject *object); - -void gdl_dock_object_reduce (GdlDockObject *object); - -gboolean gdl_dock_object_dock_request (GdlDockObject *object, - gint x, - gint y, - GdlDockRequest *request); -void gdl_dock_object_dock (GdlDockObject *object, - GdlDockObject *requestor, - GdlDockPlacement position, - GValue *other_data); - -void gdl_dock_object_bind (GdlDockObject *object, - GObject *master); -void gdl_dock_object_unbind (GdlDockObject *object); -gboolean gdl_dock_object_is_bound (GdlDockObject *object); - -gboolean gdl_dock_object_reorder (GdlDockObject *object, - GdlDockObject *child, - GdlDockPlacement new_position, - GValue *other_data); - -void gdl_dock_object_present (GdlDockObject *object, - GdlDockObject *child); - -gboolean gdl_dock_object_child_placement (GdlDockObject *object, - GdlDockObject *child, - GdlDockPlacement *placement); - -/* other types */ - -/* this type derives from G_TYPE_STRING and is meant to be the basic - type for serializing object parameters which are exported - (i.e. those that are needed for layout rebuilding) */ -#define GDL_TYPE_DOCK_PARAM (gdl_dock_param_get_type ()) - -GType gdl_dock_param_get_type (void); - -/* functions for setting/retrieving nick names for serializing GdlDockObject types */ -const gchar *gdl_dock_object_nick_from_type (GType type); -GType gdl_dock_object_type_from_nick (const gchar *nick); -GType gdl_dock_object_set_type_for_nick (const gchar *nick, - GType type); - - -/* helper macros */ -#define GDL_TRACE_OBJECT(object, format, args...) \ - G_STMT_START { \ - g_log (G_LOG_DOMAIN, \ - G_LOG_LEVEL_DEBUG, \ - "%s:%d (%s) %s [%p %d%s:%d]: " format, \ - __FILE__, \ - __LINE__, \ - __PRETTY_FUNCTION__, \ - G_OBJECT_TYPE_NAME (object), object, \ - G_OBJECT (object)->ref_count, \ - (GTK_IS_OBJECT (object) && g_object_is_floating (object)) ? "(float)" : "", \ - GDL_IS_DOCK_OBJECT (object) ? GDL_DOCK_OBJECT (object)->freeze_count : -1, \ - ##args); } G_STMT_END - - - -G_END_DECLS - -#endif /* __GDL_DOCK_OBJECT_H__ */ - diff --git a/src/libgdl/gdl-dock-paned.c b/src/libgdl/gdl-dock-paned.c deleted file mode 100644 index 5b4561ef3..000000000 --- a/src/libgdl/gdl-dock-paned.c +++ /dev/null @@ -1,678 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * gdl-dock-paned.h - * - * This file is part of the GNOME Devtools Libraries. - * - * Copyright (C) 2002 Gustavo Giráldez <gustavo.giraldez@gmx.net> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include "gdl-i18n.h" -#include <string.h> -#include <gtk/gtk.h> - -#include "gdl-dock-paned.h" - - -/* Private prototypes */ - -static void gdl_dock_paned_class_init (GdlDockPanedClass *klass); -static void gdl_dock_paned_init (GdlDockPaned *paned); -static GObject *gdl_dock_paned_constructor (GType type, - guint n_construct_properties, - GObjectConstructParam *construct_param); -static void gdl_dock_paned_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec); -static void gdl_dock_paned_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec); - -static void gdl_dock_paned_destroy (GtkObject *object); - -static void gdl_dock_paned_add (GtkContainer *container, - GtkWidget *widget); -static void gdl_dock_paned_forall (GtkContainer *container, - gboolean include_internals, - GtkCallback callback, - gpointer callback_data); -static GType gdl_dock_paned_child_type (GtkContainer *container); - -static gboolean gdl_dock_paned_dock_request (GdlDockObject *object, - gint x, - gint y, - GdlDockRequest *request); -static void gdl_dock_paned_dock (GdlDockObject *object, - GdlDockObject *requestor, - GdlDockPlacement position, - GValue *other_data); - -static void gdl_dock_paned_set_orientation (GdlDockItem *item, - GtkOrientation orientation); - -static gboolean gdl_dock_paned_child_placement (GdlDockObject *object, - GdlDockObject *child, - GdlDockPlacement *placement); - - -/* ----- Class variables and definitions ----- */ - -#define SPLIT_RATIO 0.3 - -enum { - PROP_0, - PROP_POSITION -}; - - -/* ----- Private functions ----- */ - -G_DEFINE_TYPE (GdlDockPaned, gdl_dock_paned, GDL_TYPE_DOCK_ITEM); - -static void -gdl_dock_paned_class_init (GdlDockPanedClass *klass) -{ - GObjectClass *g_object_class; - GtkObjectClass *gtk_object_class; - GtkWidgetClass *widget_class; - GtkContainerClass *container_class; - GdlDockObjectClass *object_class; - GdlDockItemClass *item_class; - - g_object_class = G_OBJECT_CLASS (klass); - gtk_object_class = GTK_OBJECT_CLASS (klass); - widget_class = GTK_WIDGET_CLASS (klass); - container_class = GTK_CONTAINER_CLASS (klass); - object_class = GDL_DOCK_OBJECT_CLASS (klass); - item_class = GDL_DOCK_ITEM_CLASS (klass); - - g_object_class->set_property = gdl_dock_paned_set_property; - g_object_class->get_property = gdl_dock_paned_get_property; - g_object_class->constructor = gdl_dock_paned_constructor; - - gtk_object_class->destroy = gdl_dock_paned_destroy; - - container_class->add = gdl_dock_paned_add; - container_class->forall = gdl_dock_paned_forall; - container_class->child_type = gdl_dock_paned_child_type; - - object_class->is_compound = TRUE; - - object_class->dock_request = gdl_dock_paned_dock_request; - object_class->dock = gdl_dock_paned_dock; - object_class->child_placement = gdl_dock_paned_child_placement; - - item_class->has_grip = FALSE; - item_class->set_orientation = gdl_dock_paned_set_orientation; - - g_object_class_install_property ( - g_object_class, PROP_POSITION, - g_param_spec_uint ("position", _("Position"), - _("Position of the divider in pixels"), - 0, G_MAXINT, 0, - G_PARAM_READWRITE | - GDL_DOCK_PARAM_EXPORT | GDL_DOCK_PARAM_AFTER)); -} - -static void -gdl_dock_paned_init (GdlDockPaned *paned) -{ - paned->position_changed = FALSE; -} - -static void -gdl_dock_paned_notify_cb (GObject *g_object, - GParamSpec *pspec, - gpointer user_data) -{ - GdlDockPaned *paned; - - g_return_if_fail (user_data != NULL && GDL_IS_DOCK_PANED (user_data)); - - /* chain the notification to the GdlDockPaned */ - g_object_notify (G_OBJECT (user_data), pspec->name); - - paned = GDL_DOCK_PANED (user_data); - - if (GDL_DOCK_ITEM_USER_ACTION (user_data) && !strcmp (pspec->name, "position")) - paned->position_changed = TRUE; -} - -static gboolean -gdl_dock_paned_button_cb (GtkWidget *widget, - GdkEventButton *event, - gpointer user_data) -{ - GdlDockPaned *paned; - - g_return_val_if_fail (user_data != NULL && GDL_IS_DOCK_PANED (user_data), FALSE); - - paned = GDL_DOCK_PANED (user_data); - if (event->button == 1) { - if (event->type == GDK_BUTTON_PRESS) - GDL_DOCK_ITEM_SET_FLAGS (user_data, GDL_DOCK_USER_ACTION); - else { - GDL_DOCK_ITEM_UNSET_FLAGS (user_data, GDL_DOCK_USER_ACTION); - if (paned->position_changed) { - /* emit pending layout changed signal to track separator position */ - if (GDL_DOCK_OBJECT (paned)->master) - g_signal_emit_by_name (GDL_DOCK_OBJECT (paned)->master, "layout-changed"); - paned->position_changed = FALSE; - } - } - } - - return FALSE; -} - -static void -gdl_dock_paned_create_child (GdlDockPaned *paned, - GtkOrientation orientation) -{ - GdlDockItem *item; - - item = GDL_DOCK_ITEM (paned); - - if (item->child) - gtk_widget_unparent (GTK_WIDGET (item->child)); - - /* create the container paned */ - if (orientation == GTK_ORIENTATION_HORIZONTAL) - item->child = gtk_hpaned_new (); - else - item->child = gtk_vpaned_new (); - - /* get notification for propagation */ - g_signal_connect (item->child, "notify::position", - (GCallback) gdl_dock_paned_notify_cb, (gpointer) item); - g_signal_connect (item->child, "button-press-event", - (GCallback) gdl_dock_paned_button_cb, (gpointer) item); - g_signal_connect (item->child, "button-release-event", - (GCallback) gdl_dock_paned_button_cb, (gpointer) item); - - gtk_widget_set_parent (item->child, GTK_WIDGET (item)); - gtk_widget_show (item->child); -} - -static GObject * -gdl_dock_paned_constructor (GType type, - guint n_construct_properties, - GObjectConstructParam *construct_param) -{ - GObject *g_object; - - g_object = G_OBJECT_CLASS (gdl_dock_paned_parent_class)-> constructor (type, - n_construct_properties, - construct_param); - if (g_object) { - GdlDockItem *item = GDL_DOCK_ITEM (g_object); - - if (!item->child) - gdl_dock_paned_create_child (GDL_DOCK_PANED (g_object), - item->orientation); - /* otherwise, the orientation was set as a construction - parameter and the child is already created */ - } - - return g_object; -} - -static void -gdl_dock_paned_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) -{ - GdlDockItem *item = GDL_DOCK_ITEM (object); - - switch (prop_id) { - case PROP_POSITION: - if (item->child && GTK_IS_PANED (item->child)) - gtk_paned_set_position (GTK_PANED (item->child), - g_value_get_uint (value)); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -gdl_dock_paned_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) -{ - GdlDockItem *item = GDL_DOCK_ITEM (object); - - switch (prop_id) { - case PROP_POSITION: - if (item->child && GTK_IS_PANED (item->child)) - g_value_set_uint (value, - gtk_paned_get_position (GTK_PANED (item->child))); - else - g_value_set_uint (value, 0); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -gdl_dock_paned_destroy (GtkObject *object) -{ - GdlDockItem *item = GDL_DOCK_ITEM (object); - - /* we need to call the virtual first, since in GdlDockDestroy our - children dock objects are detached */ - GTK_OBJECT_CLASS (gdl_dock_paned_parent_class)->destroy (object); - - /* after that we can remove the GtkNotebook */ - if (item->child) { - gtk_widget_unparent (item->child); - item->child = NULL; - }; -} - -static void -gdl_dock_paned_add (GtkContainer *container, - GtkWidget *widget) -{ - GdlDockItem *item; - GdlDockPlacement pos = GDL_DOCK_NONE; - GtkPaned *paned; - GtkWidget *child1, *child2; - - g_return_if_fail (container != NULL && widget != NULL); - g_return_if_fail (GDL_IS_DOCK_PANED (container)); - g_return_if_fail (GDL_IS_DOCK_ITEM (widget)); - - item = GDL_DOCK_ITEM (container); - g_return_if_fail (item->child != NULL); - - paned = GTK_PANED (item->child); - child1 = gtk_paned_get_child1 (paned); - child2 = gtk_paned_get_child2 (paned); - g_return_if_fail (!child1 || !child2); - - if (!child1) - pos = item->orientation == GTK_ORIENTATION_HORIZONTAL ? - GDL_DOCK_LEFT : GDL_DOCK_TOP; - else if (!child2) - pos = item->orientation == GTK_ORIENTATION_HORIZONTAL ? - GDL_DOCK_RIGHT : GDL_DOCK_BOTTOM; - - if (pos != GDL_DOCK_NONE) - gdl_dock_object_dock (GDL_DOCK_OBJECT (container), - GDL_DOCK_OBJECT (widget), - pos, NULL); -} - -static void -gdl_dock_paned_forall (GtkContainer *container, - gboolean include_internals, - GtkCallback callback, - gpointer callback_data) -{ - GdlDockItem *item; - - g_return_if_fail (container != NULL); - g_return_if_fail (GDL_IS_DOCK_PANED (container)); - g_return_if_fail (callback != NULL); - - if (include_internals) { - /* use GdlDockItem's forall */ - GTK_CONTAINER_CLASS (gdl_dock_paned_parent_class)->forall - (container, include_internals, callback, callback_data); - } - else { - item = GDL_DOCK_ITEM (container); - if (item->child) - gtk_container_foreach (GTK_CONTAINER (item->child), callback, callback_data); - } -} - -static GType -gdl_dock_paned_child_type (GtkContainer *container) -{ - GdlDockItem *item = GDL_DOCK_ITEM (container); - - if (gtk_container_child_type (GTK_CONTAINER (item->child)) == G_TYPE_NONE) - return G_TYPE_NONE; - else - return GDL_TYPE_DOCK_ITEM; -} - -static void -gdl_dock_paned_request_foreach (GdlDockObject *object, - gpointer user_data) -{ - struct { - gint x, y; - GdlDockRequest *request; - gboolean may_dock; - } *data = user_data; - - GdlDockRequest my_request; - gboolean may_dock; - - my_request = *data->request; - may_dock = gdl_dock_object_dock_request (object, data->x, data->y, &my_request); - if (may_dock) { - data->may_dock = TRUE; - *data->request = my_request; - } -} - -static gboolean -gdl_dock_paned_dock_request (GdlDockObject *object, - gint x, - gint y, - GdlDockRequest *request) -{ - GdlDockItem *item; - guint bw; - gint rel_x, rel_y; - GtkAllocation alloc; - gboolean may_dock = FALSE; - GdlDockRequest my_request; - - g_return_val_if_fail (GDL_IS_DOCK_ITEM (object), FALSE); - - /* we get (x,y) in our allocation coordinates system */ - - item = GDL_DOCK_ITEM (object); - - /* Get item's allocation. */ - gtk_widget_get_allocation (GTK_WIDGET (object), &alloc); - bw = gtk_container_get_border_width (GTK_CONTAINER (object)); - - /* Get coordinates relative to our window. */ - rel_x = x - alloc.x; - rel_y = y - alloc.y; - - if (request) - my_request = *request; - - /* Check if coordinates are inside the widget. */ - if (rel_x > 0 && rel_x < alloc.width && - rel_y > 0 && rel_y < alloc.height) { - GtkRequisition my, other; - gint divider = -1; - - gdl_dock_item_preferred_size (GDL_DOCK_ITEM (my_request.applicant), &other); - gdl_dock_item_preferred_size (GDL_DOCK_ITEM (object), &my); - - /* It's inside our area. */ - may_dock = TRUE; - - /* Set docking indicator rectangle to the widget size. */ - my_request.rect.x = bw; - my_request.rect.y = bw; - my_request.rect.width = alloc.width - 2*bw; - my_request.rect.height = alloc.height - 2*bw; - - my_request.target = object; - - /* See if it's in the border_width band. */ - if (rel_x < (gint)bw) { - my_request.position = GDL_DOCK_LEFT; - my_request.rect.width *= SPLIT_RATIO; - divider = other.width; - } else if (rel_x > alloc.width - (gint)bw) { - my_request.position = GDL_DOCK_RIGHT; - my_request.rect.x += my_request.rect.width * (1 - SPLIT_RATIO); - my_request.rect.width *= SPLIT_RATIO; - divider = MAX (0, my.width - other.width); - } else if (rel_y < (gint)bw) { - my_request.position = GDL_DOCK_TOP; - my_request.rect.height *= SPLIT_RATIO; - divider = other.height; - } else if (rel_y > alloc.height - (gint)bw) { - my_request.position = GDL_DOCK_BOTTOM; - my_request.rect.y += my_request.rect.height * (1 - SPLIT_RATIO); - my_request.rect.height *= SPLIT_RATIO; - divider = MAX (0, my.height - other.height); - - } else { /* Otherwise try our children. */ - struct { - gint x, y; - GdlDockRequest *request; - gboolean may_dock; - } data; - - /* give them coordinates in their allocation system... the - GtkPaned has no window, so our children allocation - coordinates are our window coordinates */ - data.x = rel_x; - data.y = rel_y; - data.request = &my_request; - data.may_dock = FALSE; - - gtk_container_foreach (GTK_CONTAINER (object), - (GtkCallback) gdl_dock_paned_request_foreach, - &data); - - may_dock = data.may_dock; - if (!may_dock) { - /* the pointer is on the handle, so snap to top/bottom - or left/right */ - may_dock = TRUE; - if (item->orientation == GTK_ORIENTATION_HORIZONTAL) { - if (rel_y < alloc.height / 2) { - my_request.position = GDL_DOCK_TOP; - my_request.rect.height *= SPLIT_RATIO; - divider = other.height; - } else { - my_request.position = GDL_DOCK_BOTTOM; - my_request.rect.y += my_request.rect.height * (1 - SPLIT_RATIO); - my_request.rect.height *= SPLIT_RATIO; - divider = MAX (0, my.height - other.height); - } - } else { - if (rel_x < alloc.width / 2) { - my_request.position = GDL_DOCK_LEFT; - my_request.rect.width *= SPLIT_RATIO; - divider = other.width; - } else { - my_request.position = GDL_DOCK_RIGHT; - my_request.rect.x += my_request.rect.width * (1 - SPLIT_RATIO); - my_request.rect.width *= SPLIT_RATIO; - divider = MAX (0, my.width - other.width); - } - } - } - } - - if (divider >= 0 && my_request.position != GDL_DOCK_CENTER) { - if (G_IS_VALUE (&my_request.extra)) - g_value_unset (&my_request.extra); - g_value_init (&my_request.extra, G_TYPE_UINT); - g_value_set_uint (&my_request.extra, (guint) divider); - } - - if (may_dock) { - /* adjust returned coordinates so they are relative to - our allocation */ - my_request.rect.x += alloc.x; - my_request.rect.y += alloc.y; - } - } - - if (may_dock && request) - *request = my_request; - - return may_dock; -} - -static void -gdl_dock_paned_dock (GdlDockObject *object, - GdlDockObject *requestor, - GdlDockPlacement position, - GValue *other_data) -{ - GtkPaned *paned; - GtkWidget *child1, *child2; - gboolean done = FALSE; - gboolean hresize = FALSE; - gboolean wresize = FALSE; - gint temp = 0; - - g_return_if_fail (GDL_IS_DOCK_PANED (object)); - g_return_if_fail (GDL_DOCK_ITEM (object)->child != NULL); - - paned = GTK_PANED (GDL_DOCK_ITEM (object)->child); - - if (GDL_IS_DOCK_ITEM (requestor)) { - g_object_get (G_OBJECT (requestor), "preferred_height", &temp, NULL); - if (temp == -2) - hresize = TRUE; - temp = 0; - g_object_get (G_OBJECT (requestor), "preferred_width", &temp, NULL); - if (temp == -2) - wresize = TRUE; - } - - child1 = gtk_paned_get_child1 (paned); - child2 = gtk_paned_get_child2 (paned); - - /* see if we can dock the item in our paned */ - switch (GDL_DOCK_ITEM (object)->orientation) { - case GTK_ORIENTATION_HORIZONTAL: - if (!child1 && position == GDL_DOCK_LEFT) { - gtk_paned_pack1 (paned, GTK_WIDGET (requestor), FALSE, FALSE); - done = TRUE; - } else if (!child2 && position == GDL_DOCK_RIGHT) { - gtk_paned_pack2 (paned, GTK_WIDGET (requestor), TRUE, FALSE); - done = TRUE; - } - break; - case GTK_ORIENTATION_VERTICAL: - if (!child1 && position == GDL_DOCK_TOP) { - gtk_paned_pack1 (paned, GTK_WIDGET (requestor), hresize, FALSE); - done = TRUE; - } else if (!child2 && position == GDL_DOCK_BOTTOM) { - gtk_paned_pack2 (paned, GTK_WIDGET (requestor), hresize, FALSE); - done = TRUE; - } - break; - default: - break; - } - - if (!done) { - /* this will create another paned and reparent us there */ - GDL_DOCK_OBJECT_CLASS (gdl_dock_paned_parent_class)->dock (object, requestor, position, - other_data); - } - else { - gdl_dock_item_show_grip (GDL_DOCK_ITEM (requestor)); - gtk_widget_show (GTK_WIDGET (requestor)); - GDL_DOCK_OBJECT_SET_FLAGS (requestor, GDL_DOCK_ATTACHED); - } -} - -static void -gdl_dock_paned_set_orientation (GdlDockItem *item, - GtkOrientation orientation) -{ - GtkPaned *old_paned = NULL, *new_paned; - GtkWidget *child1, *child2; - - g_return_if_fail (GDL_IS_DOCK_PANED (item)); - - if (item->child) { - old_paned = GTK_PANED (item->child); - g_object_ref (old_paned); - gtk_widget_unparent (GTK_WIDGET (old_paned)); - item->child = NULL; - } - - gdl_dock_paned_create_child (GDL_DOCK_PANED (item), orientation); - - if (old_paned) { - new_paned = GTK_PANED (item->child); - child1 = gtk_paned_get_child1 (old_paned); - child2 = gtk_paned_get_child2 (old_paned); - - if (child1) { - g_object_ref (child1); - gtk_container_remove (GTK_CONTAINER (old_paned), child1); - gtk_paned_pack1 (new_paned, child1, TRUE, FALSE); - g_object_unref (child1); - } - if (child2) { - g_object_ref (child2); - gtk_container_remove (GTK_CONTAINER (old_paned), child2); - gtk_paned_pack1 (new_paned, child2, TRUE, FALSE); - g_object_unref (child2); - } - } - - GDL_DOCK_ITEM_CLASS (gdl_dock_paned_parent_class)->set_orientation (item, orientation); -} - -static gboolean -gdl_dock_paned_child_placement (GdlDockObject *object, - GdlDockObject *child, - GdlDockPlacement *placement) -{ - GdlDockItem *item = GDL_DOCK_ITEM (object); - GtkPaned *paned; - GdlDockPlacement pos = GDL_DOCK_NONE; - - if (item->child) { - paned = GTK_PANED (item->child); - if (GTK_WIDGET (child) == gtk_paned_get_child1 (paned)) - pos = item->orientation == GTK_ORIENTATION_HORIZONTAL ? - GDL_DOCK_LEFT : GDL_DOCK_TOP; - else if (GTK_WIDGET (child) == gtk_paned_get_child2 (paned)) - pos = item->orientation == GTK_ORIENTATION_HORIZONTAL ? - GDL_DOCK_RIGHT : GDL_DOCK_BOTTOM; - } - - if (pos != GDL_DOCK_NONE) { - if (placement) - *placement = pos; - return TRUE; - } - else - return FALSE; -} - - -/* ----- Public interface ----- */ - -GtkWidget * -gdl_dock_paned_new (GtkOrientation orientation) -{ - GdlDockPaned *paned; - - paned = GDL_DOCK_PANED (g_object_new (GDL_TYPE_DOCK_PANED, - "orientation", orientation, NULL)); - GDL_DOCK_OBJECT_UNSET_FLAGS (paned, GDL_DOCK_AUTOMATIC); - - return GTK_WIDGET (paned); -} - diff --git a/src/libgdl/gdl-dock-paned.h b/src/libgdl/gdl-dock-paned.h deleted file mode 100644 index 2b4a40700..000000000 --- a/src/libgdl/gdl-dock-paned.h +++ /dev/null @@ -1,64 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * gdl-dock-paned.h - * - * This file is part of the GNOME Devtools Libraries. - * - * Copyright (C) 2002 Gustavo Giráldez <gustavo.giraldez@gmx.net> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef __GDL_DOCK_PANED_H__ -#define __GDL_DOCK_PANED_H__ - -#include "libgdl/gdl-dock-item.h" - -G_BEGIN_DECLS - -/* standard macros */ -#define GDL_TYPE_DOCK_PANED (gdl_dock_paned_get_type ()) -#define GDL_DOCK_PANED(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDL_TYPE_DOCK_PANED, GdlDockPaned)) -#define GDL_DOCK_PANED_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDL_TYPE_DOCK_PANED, GdlDockPanedClass)) -#define GDL_IS_DOCK_PANED(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GDL_TYPE_DOCK_PANED)) -#define GDL_IS_DOCK_PANED_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDL_TYPE_DOCK_PANED)) -#define GDL_DOCK_PANED_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDL_TYE_DOCK_PANED, GdlDockPanedClass)) - -/* data types & structures */ -typedef struct _GdlDockPaned GdlDockPaned; -typedef struct _GdlDockPanedClass GdlDockPanedClass; - -struct _GdlDockPaned { - GdlDockItem dock_item; - - gboolean position_changed; -}; - -struct _GdlDockPanedClass { - GdlDockItemClass parent_class; -}; - - -/* public interface */ - -GType gdl_dock_paned_get_type (void); - -GtkWidget *gdl_dock_paned_new (GtkOrientation orientation); - - -G_END_DECLS - -#endif /* __GDL_DOCK_PANED_H__ */ - diff --git a/src/libgdl/gdl-dock-placeholder.c b/src/libgdl/gdl-dock-placeholder.c deleted file mode 100644 index 8cde7a51d..000000000 --- a/src/libgdl/gdl-dock-placeholder.c +++ /dev/null @@ -1,827 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * gdl-dock-placeholder.c - Placeholders for docking items - * - * This file is part of the GNOME Devtools Libraries. - * - * Copyright (C) 2002 Gustavo Giráldez <gustavo.giraldez@gmx.net> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include "gdl-i18n.h" - -#include "gdl-dock-placeholder.h" -#include "gdl-dock-item.h" -#include "gdl-dock-paned.h" -#include "gdl-dock-master.h" -#include "libgdltypebuiltins.h" - - -#undef PLACEHOLDER_DEBUG - -/* ----- Private prototypes ----- */ - -static void gdl_dock_placeholder_class_init (GdlDockPlaceholderClass *klass); - -static void gdl_dock_placeholder_set_property (GObject *g_object, - guint prop_id, - const GValue *value, - GParamSpec *pspec); -static void gdl_dock_placeholder_get_property (GObject *g_object, - guint prop_id, - GValue *value, - GParamSpec *pspec); - -static void gdl_dock_placeholder_destroy (GtkObject *object); - -static void gdl_dock_placeholder_add (GtkContainer *container, - GtkWidget *widget); - -static void gdl_dock_placeholder_detach (GdlDockObject *object, - gboolean recursive); -static void gdl_dock_placeholder_reduce (GdlDockObject *object); -static void gdl_dock_placeholder_dock (GdlDockObject *object, - GdlDockObject *requestor, - GdlDockPlacement position, - GValue *other_data); - -static void gdl_dock_placeholder_weak_notify (gpointer data, - GObject *old_object); - -static void disconnect_host (GdlDockPlaceholder *ph); -static void connect_host (GdlDockPlaceholder *ph, - GdlDockObject *new_host); -static void do_excursion (GdlDockPlaceholder *ph); - -static void gdl_dock_placeholder_present (GdlDockObject *object, - GdlDockObject *child); - -static void detach_cb (GdlDockObject *object, - gboolean recursive, - gpointer user_data); - -/* ----- Private variables and data structures ----- */ - -enum { - PROP_0, - PROP_STICKY, - PROP_HOST, - PROP_NEXT_PLACEMENT, - PROP_WIDTH, - PROP_HEIGHT, - PROP_FLOATING, - PROP_FLOAT_X, - PROP_FLOAT_Y -}; - -struct _GdlDockPlaceholderPrivate { - /* current object this placeholder is pinned to */ - GdlDockObject *host; - gboolean sticky; - - /* when the placeholder is moved up the hierarchy, this stack - keeps track of the necessary dock positions needed to get the - placeholder to the original position */ - GSList *placement_stack; - - /* Width and height of the attachments */ - gint width; - gint height; - - /* connected signal handlers */ - guint host_detach_handler; - guint host_dock_handler; - - /* Window Coordinates if Dock was floating */ - gboolean floating; - gint floatx; - gint floaty; -}; - - -/* ----- Private interface ----- */ - -G_DEFINE_TYPE (GdlDockPlaceholder, gdl_dock_placeholder, GDL_TYPE_DOCK_OBJECT); - -static void -gdl_dock_placeholder_class_init (GdlDockPlaceholderClass *klass) -{ - GObjectClass *g_object_class; - GtkObjectClass *gtk_object_class; - GtkContainerClass *container_class; - GdlDockObjectClass *object_class; - - g_object_class = G_OBJECT_CLASS (klass); - gtk_object_class = GTK_OBJECT_CLASS (klass); - container_class = GTK_CONTAINER_CLASS (klass); - object_class = GDL_DOCK_OBJECT_CLASS (klass); - - g_object_class->get_property = gdl_dock_placeholder_get_property; - g_object_class->set_property = gdl_dock_placeholder_set_property; - - g_object_class_install_property ( - g_object_class, PROP_STICKY, - g_param_spec_boolean ("sticky", _("Sticky"), - _("Whether the placeholder will stick to its host or " - "move up the hierarchy when the host is redocked"), - FALSE, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); - - g_object_class_install_property ( - g_object_class, PROP_HOST, - g_param_spec_object ("host", _("Host"), - _("The dock object this placeholder is attached to"), - GDL_TYPE_DOCK_OBJECT, - G_PARAM_READWRITE)); - - /* this will return the top of the placement stack */ - g_object_class_install_property ( - g_object_class, PROP_NEXT_PLACEMENT, - g_param_spec_enum ("next-placement", _("Next placement"), - _("The position an item will be docked to our host if a " - "request is made to dock to us"), - GDL_TYPE_DOCK_PLACEMENT, - GDL_DOCK_CENTER, - G_PARAM_READWRITE | - GDL_DOCK_PARAM_EXPORT | GDL_DOCK_PARAM_AFTER)); - - g_object_class_install_property ( - g_object_class, PROP_WIDTH, - g_param_spec_int ("width", _("Width"), - _("Width for the widget when it's attached to the placeholder"), - -1, G_MAXINT, -1, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT | - GDL_DOCK_PARAM_EXPORT)); - - g_object_class_install_property ( - g_object_class, PROP_HEIGHT, - g_param_spec_int ("height", _("Height"), - _("Height for the widget when it's attached to the placeholder"), - -1, G_MAXINT, -1, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT | - GDL_DOCK_PARAM_EXPORT)); - g_object_class_install_property ( - g_object_class, PROP_FLOATING, - g_param_spec_boolean ("floating", _("Floating Toplevel"), - _("Whether the placeholder is standing in for a " - "floating toplevel dock"), - FALSE, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); - g_object_class_install_property ( - g_object_class, PROP_FLOAT_X, - g_param_spec_int ("floatx", _("X Coordinate"), - _("X coordinate for dock when floating"), - -1, G_MAXINT, -1, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | - GDL_DOCK_PARAM_EXPORT)); - g_object_class_install_property ( - g_object_class, PROP_FLOAT_Y, - g_param_spec_int ("floaty", _("Y Coordinate"), - _("Y coordinate for dock when floating"), - -1, G_MAXINT, -1, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | - GDL_DOCK_PARAM_EXPORT)); - - - gtk_object_class->destroy = gdl_dock_placeholder_destroy; - container_class->add = gdl_dock_placeholder_add; - - object_class->is_compound = FALSE; - object_class->detach = gdl_dock_placeholder_detach; - object_class->reduce = gdl_dock_placeholder_reduce; - object_class->dock = gdl_dock_placeholder_dock; - object_class->present = gdl_dock_placeholder_present; -} - -static void -gdl_dock_placeholder_init (GdlDockPlaceholder *ph) -{ - gtk_widget_set_has_window (GTK_WIDGET (ph), FALSE); - gtk_widget_set_can_focus (GTK_WIDGET (ph), FALSE); - - ph->_priv = g_new0 (GdlDockPlaceholderPrivate, 1); -} - -static void -gdl_dock_placeholder_set_property (GObject *g_object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) -{ - GdlDockPlaceholder *ph = GDL_DOCK_PLACEHOLDER (g_object); - - switch (prop_id) { - case PROP_STICKY: - if (ph->_priv) - ph->_priv->sticky = g_value_get_boolean (value); - break; - case PROP_HOST: - gdl_dock_placeholder_attach (ph, g_value_get_object (value)); - break; - case PROP_NEXT_PLACEMENT: - if (ph->_priv) { - ph->_priv->placement_stack = - g_slist_prepend (ph->_priv->placement_stack, - GINT_TO_POINTER (g_value_get_enum (value))); - } - break; - case PROP_WIDTH: - ph->_priv->width = g_value_get_int (value); - break; - case PROP_HEIGHT: - ph->_priv->height = g_value_get_int (value); - break; - case PROP_FLOATING: - ph->_priv->floating = g_value_get_boolean (value); - break; - case PROP_FLOAT_X: - ph->_priv->floatx = g_value_get_int (value); - break; - case PROP_FLOAT_Y: - ph->_priv->floaty = g_value_get_int (value); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (g_object, prop_id, pspec); - break; - } -} - -static void -gdl_dock_placeholder_get_property (GObject *g_object, - guint prop_id, - GValue *value, - GParamSpec *pspec) -{ - GdlDockPlaceholder *ph = GDL_DOCK_PLACEHOLDER (g_object); - - switch (prop_id) { - case PROP_STICKY: - if (ph->_priv) - g_value_set_boolean (value, ph->_priv->sticky); - else - g_value_set_boolean (value, FALSE); - break; - case PROP_HOST: - if (ph->_priv) - g_value_set_object (value, ph->_priv->host); - else - g_value_set_object (value, NULL); - break; - case PROP_NEXT_PLACEMENT: - if (ph->_priv && ph->_priv->placement_stack) - g_value_set_enum (value, (GdlDockPlacement) ph->_priv->placement_stack->data); - else - g_value_set_enum (value, GDL_DOCK_CENTER); - break; - case PROP_WIDTH: - g_value_set_int (value, ph->_priv->width); - break; - case PROP_HEIGHT: - g_value_set_int (value, ph->_priv->height); - break; - case PROP_FLOATING: - g_value_set_boolean (value, ph->_priv->floating); - break; - case PROP_FLOAT_X: - g_value_set_int (value, ph->_priv->floatx); - break; - case PROP_FLOAT_Y: - g_value_set_int (value, ph->_priv->floaty); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (g_object, prop_id, pspec); - break; - } -} - -static void -gdl_dock_placeholder_destroy (GtkObject *object) -{ - GdlDockPlaceholder *ph = GDL_DOCK_PLACEHOLDER (object); - - if (ph->_priv) { - if (ph->_priv->host) - gdl_dock_placeholder_detach (GDL_DOCK_OBJECT (object), FALSE); - g_free (ph->_priv); - ph->_priv = NULL; - } - - GTK_OBJECT_CLASS (gdl_dock_placeholder_parent_class)->destroy (object); -} - -static void -gdl_dock_placeholder_add (GtkContainer *container, - GtkWidget *widget) -{ - GdlDockPlaceholder *ph; - GdlDockPlacement pos = GDL_DOCK_CENTER; /* default position */ - - g_return_if_fail (GDL_IS_DOCK_PLACEHOLDER (container)); - g_return_if_fail (GDL_IS_DOCK_ITEM (widget)); - - ph = GDL_DOCK_PLACEHOLDER (container); - if (ph->_priv->placement_stack) - pos = (GdlDockPlacement) ph->_priv->placement_stack->data; - - gdl_dock_object_dock (GDL_DOCK_OBJECT (ph), GDL_DOCK_OBJECT (widget), - pos, NULL); -} - -static void -gdl_dock_placeholder_detach (GdlDockObject *object, - gboolean recursive) -{ - GdlDockPlaceholder *ph = GDL_DOCK_PLACEHOLDER (object); - - /* disconnect handlers */ - disconnect_host (ph); - - /* free the placement stack */ - g_slist_free (ph->_priv->placement_stack); - ph->_priv->placement_stack = NULL; - - GDL_DOCK_OBJECT_UNSET_FLAGS (object, GDL_DOCK_ATTACHED); -} - -static void -gdl_dock_placeholder_reduce (GdlDockObject *object) -{ - /* placeholders are not reduced */ - return; -} - -static void -find_biggest_dock_item (GtkContainer *container, GtkWidget **biggest_child, - gint *biggest_child_area) -{ - GList *children, *child; - GtkAllocation allocation; - - children = gtk_container_get_children (GTK_CONTAINER (container)); - child = children; - while (child) { - gint area; - GtkWidget *child_widget; - - child_widget = GTK_WIDGET (child->data); - - if (gdl_dock_object_is_compound (GDL_DOCK_OBJECT(child_widget))) { - find_biggest_dock_item (GTK_CONTAINER (child_widget), - biggest_child, biggest_child_area); - child = g_list_next (child); - continue; - } - gtk_widget_get_allocation (child_widget, &allocation); - area = allocation.width * allocation.height; - - if (area > *biggest_child_area) { - *biggest_child_area = area; - *biggest_child = child_widget; - } - child = g_list_next (child); - } -} - -static void -attempt_to_dock_on_host (GdlDockPlaceholder *ph, GdlDockObject *host, - GdlDockObject *requestor, GdlDockPlacement placement, - gpointer other_data) -{ - GdlDockObject *parent; - GtkAllocation allocation; - gint host_width; - gint host_height; - - gtk_widget_get_allocation (GTK_WIDGET (host), &allocation); - host_width = allocation.width; - host_height = allocation.height; - - if (placement != GDL_DOCK_CENTER || !GDL_IS_DOCK_PANED (host)) { - /* we simply act as a proxy for our host */ - gdl_dock_object_dock (host, requestor, - placement, other_data); - } else { - /* If the requested pos is center, we have to make sure that it - * does not colapses existing paned items. Find the larget item - * which is not a paned item to dock to. - */ - GtkWidget *biggest_child = NULL; - gint biggest_child_area = 0; - - find_biggest_dock_item (GTK_CONTAINER (host), &biggest_child, - &biggest_child_area); - - if (biggest_child) { - /* we simply act as a proxy for our host */ - gdl_dock_object_dock (GDL_DOCK_OBJECT (biggest_child), requestor, - placement, other_data); - } else { - g_warning ("No suitable child found! Should not be here!"); - /* we simply act as a proxy for our host */ - gdl_dock_object_dock (GDL_DOCK_OBJECT (host), requestor, - placement, other_data); - } - } - - parent = gdl_dock_object_get_parent_object (requestor); - - /* Restore dock item's dimention */ - switch (placement) { - case GDL_DOCK_LEFT: - if (ph->_priv->width > 0) { - g_object_set (G_OBJECT (parent), "position", - ph->_priv->width, NULL); - } - break; - case GDL_DOCK_RIGHT: - if (ph->_priv->width > 0) { - gint complementary_width = host_width - ph->_priv->width; - - if (complementary_width > 0) - g_object_set (G_OBJECT (parent), "position", - complementary_width, NULL); - } - break; - case GDL_DOCK_TOP: - if (ph->_priv->height > 0) { - g_object_set (G_OBJECT (parent), "position", - ph->_priv->height, NULL); - } - break; - case GDL_DOCK_BOTTOM: - if (ph->_priv->height > 0) { - gint complementary_height = host_height - ph->_priv->height; - - if (complementary_height > 0) - g_object_set (G_OBJECT (parent), "position", - complementary_height, NULL); - } - break; - default: - /* nothing */ - break; - } -} - -static void -gdl_dock_placeholder_dock (GdlDockObject *object, - GdlDockObject *requestor, - GdlDockPlacement position, - GValue *other_data) -{ - GdlDockPlaceholder *ph = GDL_DOCK_PLACEHOLDER (object); - - if (ph->_priv->host) { - attempt_to_dock_on_host (ph, ph->_priv->host, requestor, - position, other_data); - } - else { - GdlDockObject *toplevel; - - if (!gdl_dock_object_is_bound (GDL_DOCK_OBJECT (ph))) { - g_warning ("%s", _("Attempt to dock a dock object to an unbound placeholder")); - return; - } - - /* dock the item as a floating of the controller */ - toplevel = gdl_dock_master_get_controller (GDL_DOCK_OBJECT_GET_MASTER (ph)); - gdl_dock_object_dock (toplevel, requestor, - GDL_DOCK_FLOATING, NULL); - } -} - -#ifdef PLACEHOLDER_DEBUG -static void -print_placement_stack (GdlDockPlaceholder *ph) -{ - GSList *s = ph->_priv->placement_stack; - GEnumClass *enum_class = G_ENUM_CLASS (g_type_class_ref (GDL_TYPE_DOCK_PLACEMENT)); - GEnumValue *enum_value; - gchar *name; - GString *message; - - message = g_string_new (NULL); - g_string_printf (message, "[%p] host: %p (%s), stack: ", - ph, ph->_priv->host, G_OBJECT_TYPE_NAME (ph->_priv->host)); - for (; s; s = s->next) { - enum_value = g_enum_get_value (enum_class, (GdlDockPlacement) s->data); - name = enum_value ? enum_value->value_name : NULL; - g_string_append_printf (message, "%s, ", name); - } - g_message ("%s", message->str); - - g_string_free (message, TRUE); - g_type_class_unref (enum_class); -} -#endif - -static void -gdl_dock_placeholder_present (GdlDockObject *object, - GdlDockObject *child) -{ - /* do nothing */ - return; -} - -/* ----- Public interface ----- */ - -GtkWidget * -gdl_dock_placeholder_new (const gchar *name, - GdlDockObject *object, - GdlDockPlacement position, - gboolean sticky) -{ - GdlDockPlaceholder *ph; - - ph = GDL_DOCK_PLACEHOLDER (g_object_new (GDL_TYPE_DOCK_PLACEHOLDER, - "name", name, - "sticky", sticky, - "next-placement", position, - "host", object, - NULL)); - GDL_DOCK_OBJECT_UNSET_FLAGS (ph, GDL_DOCK_AUTOMATIC); - - return GTK_WIDGET (ph); -} - -static void -gdl_dock_placeholder_weak_notify (gpointer data, - GObject *old_object) -{ - GdlDockPlaceholder *ph; - - g_return_if_fail (data != NULL && GDL_IS_DOCK_PLACEHOLDER (data)); - - ph = GDL_DOCK_PLACEHOLDER (data); - -#ifdef PLACEHOLDER_DEBUG - g_message ("The placeholder just lost its host, ph = %p", ph); -#endif - - /* we shouldn't get here, so perform an emergency detach. instead - we should have gotten a detach signal from our host */ - ph->_priv->host = NULL; - - /* We didn't get a detach signal from the host. Detach from the - supposedly dead host (consequently attaching to the controller) */ - - detach_cb (NULL, TRUE, data); -#if 0 - /* free the placement stack */ - g_slist_free (ph->_priv->placement_stack); - ph->_priv->placement_stack = NULL; - GDL_DOCK_OBJECT_UNSET_FLAGS (ph, GDL_DOCK_ATTACHED); -#endif -} - -static void -detach_cb (GdlDockObject *object, - gboolean recursive, - gpointer user_data) -{ - GdlDockPlaceholder *ph; - GdlDockObject *new_host, *obj; - - g_return_if_fail (user_data != NULL && GDL_IS_DOCK_PLACEHOLDER (user_data)); - - /* we go up in the hierarchy and we store the hinted placement in - * the placement stack so we can rebuild the docking layout later - * when we get the host's dock signal. */ - - ph = GDL_DOCK_PLACEHOLDER (user_data); - obj = ph->_priv->host; - if (obj != object) { - g_warning (_("Got a detach signal from an object (%p) who is not " - "our host %p"), object, ph->_priv->host); - return; - } - - /* skip sticky objects */ - if (ph->_priv->sticky) - return; - - if (obj) - /* go up in the hierarchy */ - new_host = gdl_dock_object_get_parent_object (obj); - else - /* Detaching from the dead host */ - new_host = NULL; - - while (new_host) { - GdlDockPlacement pos = GDL_DOCK_NONE; - - /* get placement hint from the new host */ - if (gdl_dock_object_child_placement (new_host, obj, &pos)) { - ph->_priv->placement_stack = g_slist_prepend ( - ph->_priv->placement_stack, (gpointer) pos); - } - else { - g_warning (_("Something weird happened while getting the child " - "placement for %p from parent %p"), obj, new_host); - } - - if (!GDL_DOCK_OBJECT_IN_DETACH (new_host)) - /* we found a "stable" dock object */ - break; - - obj = new_host; - new_host = gdl_dock_object_get_parent_object (obj); - } - - /* disconnect host */ - disconnect_host (ph); - - if (!new_host) { -#ifdef PLACEHOLDER_DEBUG - g_message ("Detaching from the toplevel. Assignaing to controller"); -#endif - /* the toplevel was detached: we attach ourselves to the - controller with an initial placement of floating */ - new_host = gdl_dock_master_get_controller (GDL_DOCK_OBJECT_GET_MASTER (ph)); - - /* - ph->_priv->placement_stack = g_slist_prepend ( - ph->_priv->placement_stack, (gpointer) GDL_DOCK_FLOATING); - */ - } - if (new_host) - connect_host (ph, new_host); - -#ifdef PLACEHOLDER_DEBUG - print_placement_stack (ph); -#endif -} - -/** - * do_excursion: - * @ph: placeholder object - * - * Tries to shrink the placement stack by examining the host's - * children and see if any of them matches the placement which is at - * the top of the stack. If this is the case, it tries again with the - * new host. - **/ -static void -do_excursion (GdlDockPlaceholder *ph) -{ - if (ph->_priv->host && - !ph->_priv->sticky && - ph->_priv->placement_stack && - gdl_dock_object_is_compound (ph->_priv->host)) { - - GdlDockPlacement pos, stack_pos = - (GdlDockPlacement) ph->_priv->placement_stack->data; - GList *children, *l; - GdlDockObject *host = ph->_priv->host; - - children = gtk_container_get_children (GTK_CONTAINER (host)); - for (l = children; l; l = l->next) { - pos = stack_pos; - gdl_dock_object_child_placement (GDL_DOCK_OBJECT (host), - GDL_DOCK_OBJECT (l->data), - &pos); - if (pos == stack_pos) { - /* remove the stack position */ - ph->_priv->placement_stack = - g_slist_remove_link (ph->_priv->placement_stack, - ph->_priv->placement_stack); - - /* connect to the new host */ - disconnect_host (ph); - connect_host (ph, GDL_DOCK_OBJECT (l->data)); - - /* recurse... */ - if (!GDL_DOCK_OBJECT_IN_REFLOW (l->data)) - do_excursion (ph); - - break; - } - } - g_list_free (children); - } -} - -static void -dock_cb (GdlDockObject *object, - GdlDockObject *requestor, - GdlDockPlacement position, - GValue *other_data, - gpointer user_data) -{ - GdlDockPlacement pos = GDL_DOCK_NONE; - GdlDockPlaceholder *ph; - - g_return_if_fail (user_data != NULL && GDL_IS_DOCK_PLACEHOLDER (user_data)); - ph = GDL_DOCK_PLACEHOLDER (user_data); - g_return_if_fail (ph->_priv->host == object); - - /* see if the given position is compatible for the stack's top - element */ - if (!ph->_priv->sticky && ph->_priv->placement_stack) { - pos = (GdlDockPlacement) ph->_priv->placement_stack->data; - if (gdl_dock_object_child_placement (object, requestor, &pos)) { - if (pos == (GdlDockPlacement) ph->_priv->placement_stack->data) { - /* the position is compatible: excurse down */ - do_excursion (ph); - } - } - } -#ifdef PLACEHOLDER_DEBUG - print_placement_stack (ph); -#endif -} - -static void -disconnect_host (GdlDockPlaceholder *ph) -{ - if (!ph->_priv->host) - return; - - if (ph->_priv->host_detach_handler) - g_signal_handler_disconnect (ph->_priv->host, ph->_priv->host_detach_handler); - if (ph->_priv->host_dock_handler) - g_signal_handler_disconnect (ph->_priv->host, ph->_priv->host_dock_handler); - ph->_priv->host_detach_handler = 0; - ph->_priv->host_dock_handler = 0; - - /* remove weak ref to object */ - g_object_weak_unref (G_OBJECT (ph->_priv->host), - gdl_dock_placeholder_weak_notify, ph); - ph->_priv->host = NULL; - -#ifdef PLACEHOLDER_DEBUG - g_message ("Host just disconnected!, ph = %p", ph); -#endif -} - -static void -connect_host (GdlDockPlaceholder *ph, - GdlDockObject *new_host) -{ - if (ph->_priv->host) - disconnect_host (ph); - - ph->_priv->host = new_host; - g_object_weak_ref (G_OBJECT (ph->_priv->host), - gdl_dock_placeholder_weak_notify, ph); - - ph->_priv->host_detach_handler = - g_signal_connect (ph->_priv->host, - "detach", - (GCallback) detach_cb, - (gpointer) ph); - - ph->_priv->host_dock_handler = - g_signal_connect (ph->_priv->host, - "dock", - (GCallback) dock_cb, - (gpointer) ph); - -#ifdef PLACEHOLDER_DEBUG - g_message ("Host just connected!, ph = %p", ph); -#endif -} - -void -gdl_dock_placeholder_attach (GdlDockPlaceholder *ph, - GdlDockObject *object) -{ - g_return_if_fail (ph != NULL && GDL_IS_DOCK_PLACEHOLDER (ph)); - g_return_if_fail (ph->_priv != NULL); - g_return_if_fail (object != NULL); - - /* object binding */ - if (!gdl_dock_object_is_bound (GDL_DOCK_OBJECT (ph))) - gdl_dock_object_bind (GDL_DOCK_OBJECT (ph), object->master); - - g_return_if_fail (GDL_DOCK_OBJECT (ph)->master == object->master); - - gdl_dock_object_freeze (GDL_DOCK_OBJECT (ph)); - - /* detach from previous host first */ - if (ph->_priv->host) - gdl_dock_object_detach (GDL_DOCK_OBJECT (ph), FALSE); - - connect_host (ph, object); - - GDL_DOCK_OBJECT_SET_FLAGS (ph, GDL_DOCK_ATTACHED); - - gdl_dock_object_thaw (GDL_DOCK_OBJECT (ph)); -} diff --git a/src/libgdl/gdl-dock-placeholder.h b/src/libgdl/gdl-dock-placeholder.h deleted file mode 100644 index c7e57e204..000000000 --- a/src/libgdl/gdl-dock-placeholder.h +++ /dev/null @@ -1,69 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * gdl-dock-placeholder.h - Placeholders for docking items - * - * This file is part of the GNOME Devtools Libraries. - * - * Copyright (C) 2002 Gustavo Giráldez <gustavo.giraldez@gmx.net> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef __GDL_DOCK_PLACEHOLDER_H__ -#define __GDL_DOCK_PLACEHOLDER_H__ - -#include "libgdl/gdl-dock-object.h" - -G_BEGIN_DECLS - -/* standard macros */ -#define GDL_TYPE_DOCK_PLACEHOLDER (gdl_dock_placeholder_get_type ()) -#define GDL_DOCK_PLACEHOLDER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDL_TYPE_DOCK_PLACEHOLDER, GdlDockPlaceholder)) -#define GDL_DOCK_PLACEHOLDER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDL_TYPE_DOCK_PLACEHOLDER, GdlDockPlaceholderClass)) -#define GDL_IS_DOCK_PLACEHOLDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GDL_TYPE_DOCK_PLACEHOLDER)) -#define GDL_IS_DOCK_PLACEHOLDER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDL_TYPE_DOCK_PLACEHOLDER)) -#define GDL_DOCK_PLACEHOLDER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_DOCK_PLACEHOLDER, GdlDockPlaceholderClass)) - -/* data types & structures */ -typedef struct _GdlDockPlaceholder GdlDockPlaceholder; -typedef struct _GdlDockPlaceholderClass GdlDockPlaceholderClass; -typedef struct _GdlDockPlaceholderPrivate GdlDockPlaceholderPrivate; - -struct _GdlDockPlaceholder { - GdlDockObject object; - - GdlDockPlaceholderPrivate *_priv; -}; - -struct _GdlDockPlaceholderClass { - GdlDockObjectClass parent_class; -}; - -/* public interface */ - -GType gdl_dock_placeholder_get_type (void); - -GtkWidget *gdl_dock_placeholder_new (const gchar *name, - GdlDockObject *object, - GdlDockPlacement position, - gboolean sticky); - -void gdl_dock_placeholder_attach (GdlDockPlaceholder *ph, - GdlDockObject *object); - - -G_END_DECLS - -#endif /* __GDL_DOCK_PLACEHOLDER_H__ */ diff --git a/src/libgdl/gdl-dock-tablabel.c b/src/libgdl/gdl-dock-tablabel.c deleted file mode 100644 index 441db3438..000000000 --- a/src/libgdl/gdl-dock-tablabel.c +++ /dev/null @@ -1,632 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * gdl-dock-tablabel.c - * - * This file is part of the GNOME Devtools Libraries. - * - * Copyright (C) 2002 Gustavo Giráldez <gustavo.giraldez@gmx.net> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include "gdl-i18n.h" -#include <gtk/gtk.h> - -#include "gdl-dock-tablabel.h" -#include "gdl-dock-item.h" -#include "libgdlmarshal.h" - - -/* ----- Private prototypes ----- */ - -static void gdl_dock_tablabel_class_init (GdlDockTablabelClass *klass); - -static void gdl_dock_tablabel_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec); -static void gdl_dock_tablabel_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec); - -static void gdl_dock_tablabel_item_notify (GObject *master, - GParamSpec *pspec, - gpointer data); - -static void gdl_dock_tablabel_size_request (GtkWidget *widget, - GtkRequisition *requisition); -static void gdl_dock_tablabel_size_allocate (GtkWidget *widget, - GtkAllocation *allocation); - -static void gdl_dock_tablabel_paint (GtkWidget *widget, - GdkEventExpose *event); -static gint gdl_dock_tablabel_expose (GtkWidget *widget, - GdkEventExpose *event); - -static gboolean gdl_dock_tablabel_button_event (GtkWidget *widget, - GdkEventButton *event); -static gboolean gdl_dock_tablabel_motion_event (GtkWidget *widget, - GdkEventMotion *event); - -static void gdl_dock_tablabel_realize (GtkWidget *widget); -static void gdl_dock_tablabel_unrealize (GtkWidget *widget); -static void gdl_dock_tablabel_map (GtkWidget *widget); -static void gdl_dock_tablabel_unmap (GtkWidget *widget); - -/* ----- Private data types and variables ----- */ - -#define DEFAULT_DRAG_HANDLE_SIZE 10 -#define HANDLE_RATIO 1.0 - -enum { - BUTTON_PRESSED_HANDLE, - LAST_SIGNAL -}; - -enum { - PROP_0, - PROP_ITEM -}; - - -static guint dock_tablabel_signals [LAST_SIGNAL] = { 0 }; - - -/* ----- Private interface ----- */ - -G_DEFINE_TYPE (GdlDockTablabel, gdl_dock_tablabel, GTK_TYPE_BIN); - -static void -gdl_dock_tablabel_class_init (GdlDockTablabelClass *klass) -{ - GObjectClass *g_object_class; - GtkObjectClass *object_class; - GtkWidgetClass *widget_class; - GtkContainerClass *container_class; - - g_object_class = G_OBJECT_CLASS (klass); - object_class = GTK_OBJECT_CLASS (klass); - widget_class = GTK_WIDGET_CLASS (klass); - container_class = GTK_CONTAINER_CLASS (klass); - - g_object_class->set_property = gdl_dock_tablabel_set_property; - g_object_class->get_property = gdl_dock_tablabel_get_property; - - widget_class->size_request = gdl_dock_tablabel_size_request; - widget_class->size_allocate = gdl_dock_tablabel_size_allocate; - widget_class->expose_event = gdl_dock_tablabel_expose; - widget_class->button_press_event = gdl_dock_tablabel_button_event; - widget_class->button_release_event = gdl_dock_tablabel_button_event; - widget_class->motion_notify_event = gdl_dock_tablabel_motion_event; - widget_class->realize = gdl_dock_tablabel_realize; - widget_class->unrealize = gdl_dock_tablabel_unrealize; - widget_class->map = gdl_dock_tablabel_map; - widget_class->unmap = gdl_dock_tablabel_unmap; - - g_object_class_install_property ( - g_object_class, PROP_ITEM, - g_param_spec_object ("item", _("Controlling dock item"), - _("Dockitem which 'owns' this tablabel"), - GDL_TYPE_DOCK_ITEM, - G_PARAM_READWRITE)); - - dock_tablabel_signals [BUTTON_PRESSED_HANDLE] = - g_signal_new ("button_pressed_handle", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GdlDockTablabelClass, - button_pressed_handle), - NULL, NULL, - gdl_marshal_VOID__BOXED, - G_TYPE_NONE, - 1, - GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE); - - klass->button_pressed_handle = NULL; -} - -static void -gdl_dock_tablabel_init (GdlDockTablabel *tablabel) -{ - GtkWidget *widget; - GtkWidget *label_widget; - - widget = GTK_WIDGET (tablabel); - - tablabel->drag_handle_size = DEFAULT_DRAG_HANDLE_SIZE; - tablabel->item = NULL; - - label_widget = gtk_label_new ("Dock item"); - gtk_container_add (GTK_CONTAINER (tablabel), label_widget); - gtk_widget_show (label_widget); - - tablabel->active = FALSE; - gtk_widget_set_state (GTK_WIDGET (tablabel), GTK_STATE_ACTIVE); -} - -static void -gdl_dock_tablabel_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) -{ - GdlDockTablabel *tablabel; - GtkBin *bin; - - tablabel = GDL_DOCK_TABLABEL (object); - - switch (prop_id) { - case PROP_ITEM: - if (tablabel->item) { - g_object_remove_weak_pointer (G_OBJECT (tablabel->item), - (gpointer *) &tablabel->item); - g_signal_handlers_disconnect_by_func ( - tablabel->item, gdl_dock_tablabel_item_notify, tablabel); - }; - - tablabel->item = g_value_get_object (value); - if (tablabel->item) { - gboolean locked; - gchar *long_name; - - g_object_add_weak_pointer (G_OBJECT (tablabel->item), - (gpointer *) &tablabel->item); - - g_signal_connect (tablabel->item, "notify::locked", - G_CALLBACK (gdl_dock_tablabel_item_notify), - tablabel); - g_signal_connect (tablabel->item, "notify::long_name", - G_CALLBACK (gdl_dock_tablabel_item_notify), - tablabel); - g_signal_connect (tablabel->item, "notify::grip_size", - G_CALLBACK (gdl_dock_tablabel_item_notify), - tablabel); - - g_object_get (tablabel->item, - "locked", &locked, - "long-name", &long_name, - "grip-size", &tablabel->drag_handle_size, - NULL); - - if (locked) - tablabel->drag_handle_size = 0; - - bin = GTK_BIN (tablabel); - if (gtk_bin_get_child (bin) && g_object_class_find_property ( - G_OBJECT_GET_CLASS (gtk_bin_get_child (bin)), "label")) - g_object_set (gtk_bin_get_child (bin), "label", long_name, NULL); - g_free (long_name); - }; - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -gdl_dock_tablabel_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) -{ - GdlDockTablabel *tablabel; - - tablabel = GDL_DOCK_TABLABEL (object); - - switch (prop_id) { - case PROP_ITEM: - g_value_set_object (value, tablabel->item); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -gdl_dock_tablabel_item_notify (GObject *master, - GParamSpec *pspec, - gpointer data) -{ - GdlDockTablabel *tablabel = GDL_DOCK_TABLABEL (data); - gboolean locked; - gchar *label; - GtkBin *bin; - - g_object_get (master, - "locked", &locked, - "grip-size", &tablabel->drag_handle_size, - "long-name", &label, - NULL); - - if (locked) - tablabel->drag_handle_size = 0; - - bin = GTK_BIN (tablabel); - if (gtk_bin_get_child (bin) && g_object_class_find_property ( - G_OBJECT_GET_CLASS (gtk_bin_get_child (bin)), "label")) - g_object_set (gtk_bin_get_child (bin), "label", label, NULL); - g_free (label); - - gtk_widget_queue_resize (GTK_WIDGET (tablabel)); -} - -static void -gdl_dock_tablabel_size_request (GtkWidget *widget, - GtkRequisition *requisition) -{ - GtkBin *bin; - GtkRequisition child_req; - GdlDockTablabel *tablabel; - guint border_width; - - g_return_if_fail (widget != NULL); - g_return_if_fail (GDL_IS_DOCK_TABLABEL (widget)); - g_return_if_fail (requisition != NULL); - - tablabel = GDL_DOCK_TABLABEL (widget); - bin = GTK_BIN (widget); - - requisition->width = tablabel->drag_handle_size; - requisition->height = 0; - - if (gtk_bin_get_child (bin)) - gtk_widget_size_request (gtk_bin_get_child (bin), &child_req); - else - child_req.width = child_req.height = 0; - - requisition->width += child_req.width; - requisition->height += child_req.height; - - border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)); - - requisition->width += border_width * 2; - requisition->height += border_width * 2; - - //gtk_widget_size_request (widget, requisition); -} - -static void -gdl_dock_tablabel_size_allocate (GtkWidget *widget, - GtkAllocation *allocation) -{ - GtkBin *bin; - GtkAllocation widget_allocation; - GdlDockTablabel *tablabel; - gint border_width; - - g_return_if_fail (widget != NULL); - g_return_if_fail (GDL_IS_DOCK_TABLABEL (widget)); - g_return_if_fail (allocation != NULL); - - bin = GTK_BIN (widget); - tablabel = GDL_DOCK_TABLABEL (widget); - - border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)); - - gtk_widget_set_allocation (widget, allocation); - - if (gtk_widget_get_realized (widget)) - gdk_window_move_resize (tablabel->event_window, - allocation->x, - allocation->y, - allocation->width, - allocation->height); - - if (gtk_bin_get_child (bin) && gtk_widget_get_visible (gtk_bin_get_child (bin))) { - GtkAllocation child_allocation; - - gtk_widget_get_allocation (widget, &widget_allocation); - child_allocation.x = widget_allocation.x + border_width; - child_allocation.y = widget_allocation.y + border_width; - - allocation->width = MAX (1, (int) allocation->width - - (int) tablabel->drag_handle_size); - child_allocation.x += tablabel->drag_handle_size; - - child_allocation.width = - MAX (1, (int) allocation->width - 2 * border_width); - child_allocation.height = - MAX (1, (int) allocation->height - 2 * border_width); - - gtk_widget_size_allocate (gtk_bin_get_child (bin), &child_allocation); - } -} - -static void -gdl_dock_tablabel_paint (GtkWidget *widget, - GdkEventExpose *event) -{ - GdkRectangle dest, rect; - GtkBin *bin; - GtkAllocation widget_allocation; - GdlDockTablabel *tablabel; - gint border_width; - - bin = GTK_BIN (widget); - tablabel = GDL_DOCK_TABLABEL (widget); - border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)); - - gtk_widget_get_allocation (widget, &widget_allocation); - rect.x = widget_allocation.x + border_width; - rect.y = widget_allocation.y + border_width; - rect.width = tablabel->drag_handle_size * HANDLE_RATIO; - rect.height = widget_allocation.height - 2*border_width; - - if (gdk_rectangle_intersect (&event->area, &rect, &dest)) { - gtk_paint_handle (gtk_widget_get_style (widget), gtk_widget_get_window (widget), - tablabel->active ? GTK_STATE_NORMAL : GTK_STATE_ACTIVE, - GTK_SHADOW_NONE, - &dest, widget, "dock-tablabel", - rect.x, rect.y, rect.width, rect.height, - GTK_ORIENTATION_VERTICAL); - }; -} - -static gint -gdl_dock_tablabel_expose (GtkWidget *widget, - GdkEventExpose *event) -{ - g_return_val_if_fail (widget != NULL, FALSE); - g_return_val_if_fail (GDL_IS_DOCK_TABLABEL (widget), FALSE); - g_return_val_if_fail (event != NULL, FALSE); - - if (gtk_widget_get_visible (widget) && gtk_widget_get_mapped (widget)) { - GTK_WIDGET_CLASS (gdl_dock_tablabel_parent_class)->expose_event (widget,event); - gdl_dock_tablabel_paint (widget, event); - }; - - return FALSE; -} - -static gboolean -gdl_dock_tablabel_button_event (GtkWidget *widget, - GdkEventButton *event) -{ - GdlDockTablabel *tablabel; - GtkAllocation widget_allocation; - gboolean event_handled; - - g_return_val_if_fail (widget != NULL, FALSE); - g_return_val_if_fail (GDL_IS_DOCK_TABLABEL (widget), FALSE); - g_return_val_if_fail (event != NULL, FALSE); - - tablabel = GDL_DOCK_TABLABEL (widget); - - event_handled = FALSE; - - if (event->window != tablabel->event_window) - return FALSE; - - switch (event->type) { - case GDK_BUTTON_PRESS: - if (tablabel->active) { - gboolean in_handle; - gint rel_x, rel_y; - guint border_width; - GtkBin *bin; - - bin = GTK_BIN (widget); - border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)); - - rel_x = event->x - border_width; - rel_y = event->y - border_width; - - /* Check if user clicked on the drag handle. */ - in_handle = (rel_x < tablabel->drag_handle_size * HANDLE_RATIO) && - (rel_x > 0); - - if (event->button == 1) { - tablabel->pre_drag = TRUE; - tablabel->drag_start_event = *event; - } - else { - g_signal_emit (widget, - dock_tablabel_signals [BUTTON_PRESSED_HANDLE], - 0, - event); - } - - event_handled = TRUE; - } - break; - - case GDK_BUTTON_RELEASE: - tablabel->pre_drag = FALSE; - break; - - default: - break; - } - - if (!event_handled) { - /* propagate the event to the parent's gdkwindow */ - GdkEventButton e; - - e = *event; - e.window = gtk_widget_get_parent_window (widget); - gtk_widget_get_allocation (widget, &widget_allocation); - e.x += widget_allocation.x; - e.y += widget_allocation.y; - - gdk_event_put ((GdkEvent *) &e); - }; - - return event_handled; -} - -static gboolean -gdl_dock_tablabel_motion_event (GtkWidget *widget, - GdkEventMotion *event) -{ - GdlDockTablabel *tablabel; - GtkAllocation widget_allocation; - gboolean event_handled; - - g_return_val_if_fail (widget != NULL, FALSE); - g_return_val_if_fail (GDL_IS_DOCK_TABLABEL (widget), FALSE); - g_return_val_if_fail (event != NULL, FALSE); - - tablabel = GDL_DOCK_TABLABEL (widget); - - event_handled = FALSE; - - if (event->window != tablabel->event_window) - return FALSE; - - if (tablabel->pre_drag) { - if (gtk_drag_check_threshold (widget, - tablabel->drag_start_event.x, - tablabel->drag_start_event.y, - event->x, - event->y)) { - tablabel->pre_drag = FALSE; - g_signal_emit (widget, - dock_tablabel_signals [BUTTON_PRESSED_HANDLE], - 0, - &tablabel->drag_start_event); - event_handled = TRUE; - } - } - - if (!event_handled) { - /* propagate the event to the parent's gdkwindow */ - GdkEventMotion e; - - e = *event; - e.window = gtk_widget_get_parent_window (widget); - gtk_widget_get_allocation (widget, &widget_allocation); - e.x += widget_allocation.x; - e.y += widget_allocation.y; - - gdk_event_put ((GdkEvent *) &e); - }; - - return event_handled; -} - -static void -gdl_dock_tablabel_realize (GtkWidget *widget) -{ - GdlDockTablabel *tablabel; - GdkWindowAttr attributes; - GtkAllocation widget_allocation; - int attributes_mask; - - tablabel = GDL_DOCK_TABLABEL (widget); - - attributes.window_type = GDK_WINDOW_CHILD; - gtk_widget_get_allocation (widget, &widget_allocation); - attributes.x = widget_allocation.x; - attributes.y = widget_allocation.y; - attributes.width = widget_allocation.width; - attributes.height = widget_allocation.height; - attributes.wclass = GDK_INPUT_ONLY; - attributes.event_mask = gtk_widget_get_events (widget); - attributes.event_mask |= (GDK_EXPOSURE_MASK | - GDK_BUTTON_PRESS_MASK | - GDK_BUTTON_RELEASE_MASK | - GDK_ENTER_NOTIFY_MASK | - GDK_POINTER_MOTION_MASK | - GDK_LEAVE_NOTIFY_MASK); - attributes_mask = GDK_WA_X | GDK_WA_Y; - - gtk_widget_set_window (widget, gtk_widget_get_parent_window (widget)); - g_object_ref (gtk_widget_get_window (widget)); - - tablabel->event_window = - gdk_window_new (gtk_widget_get_parent_window (widget), - &attributes, attributes_mask); - gdk_window_set_user_data (tablabel->event_window, widget); - - gtk_widget_set_style (widget, gtk_style_attach (gtk_widget_get_style (widget), - gtk_widget_get_window (widget))); - - gtk_widget_set_realized (widget, TRUE); -} - -static void -gdl_dock_tablabel_unrealize (GtkWidget *widget) -{ - GdlDockTablabel *tablabel = GDL_DOCK_TABLABEL (widget); - - if (tablabel->event_window) { - gdk_window_set_user_data (tablabel->event_window, NULL); - gdk_window_destroy (tablabel->event_window); - tablabel->event_window = NULL; - } - - GTK_WIDGET_CLASS (gdl_dock_tablabel_parent_class)->unrealize (widget); -} - -static void -gdl_dock_tablabel_map (GtkWidget *widget) -{ - GdlDockTablabel *tablabel = GDL_DOCK_TABLABEL (widget); - - GTK_WIDGET_CLASS (gdl_dock_tablabel_parent_class)->map (widget); - - gdk_window_show (tablabel->event_window); -} - -static void -gdl_dock_tablabel_unmap (GtkWidget *widget) -{ - GdlDockTablabel *tablabel = GDL_DOCK_TABLABEL (widget); - - gdk_window_hide (tablabel->event_window); - - GTK_WIDGET_CLASS (gdl_dock_tablabel_parent_class)->unmap (widget); -} - -/* ----- Public interface ----- */ - -GtkWidget * -gdl_dock_tablabel_new (GdlDockItem *item) -{ - GdlDockTablabel *tablabel; - - tablabel = GDL_DOCK_TABLABEL (g_object_new (GDL_TYPE_DOCK_TABLABEL, - "item", item, - NULL)); - - return GTK_WIDGET (tablabel); -} - -void -gdl_dock_tablabel_activate (GdlDockTablabel *tablabel) -{ - g_return_if_fail (tablabel != NULL); - - tablabel->active = TRUE; - gtk_widget_set_state (GTK_WIDGET (tablabel), GTK_STATE_NORMAL); -} - -void -gdl_dock_tablabel_deactivate (GdlDockTablabel *tablabel) -{ - g_return_if_fail (tablabel != NULL); - - tablabel->active = FALSE; - /* yeah, i know it contradictive */ - gtk_widget_set_state (GTK_WIDGET (tablabel), GTK_STATE_ACTIVE); -} diff --git a/src/libgdl/gdl-dock-tablabel.h b/src/libgdl/gdl-dock-tablabel.h deleted file mode 100644 index b78c1c5c7..000000000 --- a/src/libgdl/gdl-dock-tablabel.h +++ /dev/null @@ -1,74 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * gdl-dock-tablabel.h - * - * This file is part of the GNOME Devtools Libraries. - * - * Copyright (C) 2002 Gustavo Giráldez <gustavo.giraldez@gmx.net> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef __GDL_DOCK_TABLABEL_H__ -#define __GDL_DOCK_TABLABEL_H__ - -#include <gtk/gtk.h> -#include "libgdl/gdl-dock-item.h" - - -G_BEGIN_DECLS - -/* standard macros */ -#define GDL_TYPE_DOCK_TABLABEL (gdl_dock_tablabel_get_type ()) -#define GDL_DOCK_TABLABEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDL_TYPE_DOCK_TABLABEL, GdlDockTablabel)) -#define GDL_DOCK_TABLABEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDL_TYPE_DOCK_TABLABEL, GdlDockTablabelClass)) -#define GDL_IS_DOCK_TABLABEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GDL_TYPE_DOCK_TABLABEL)) -#define GDL_IS_DOCK_TABLABEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDL_TYPE_DOCK_TABLABEL)) -#define GDL_DOCK_TABLABEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_DOCK_TABLABEL, GdlDockTablabelClass)) - -/* data types & structures */ -typedef struct _GdlDockTablabel GdlDockTablabel; -typedef struct _GdlDockTablabelClass GdlDockTablabelClass; - -struct _GdlDockTablabel { - GtkBin parent; - - guint drag_handle_size; - GtkWidget *item; - GdkWindow *event_window; - gboolean active; - - GdkEventButton drag_start_event; - gboolean pre_drag; -}; - -struct _GdlDockTablabelClass { - GtkBinClass parent_class; - - void (*button_pressed_handle) (GdlDockTablabel *tablabel, - GdkEventButton *event); -}; - -/* public interface */ - -GtkWidget *gdl_dock_tablabel_new (GdlDockItem *item); -GType gdl_dock_tablabel_get_type (void); - -void gdl_dock_tablabel_activate (GdlDockTablabel *tablabel); -void gdl_dock_tablabel_deactivate (GdlDockTablabel *tablabel); - -G_END_DECLS - -#endif diff --git a/src/libgdl/gdl-dock.c b/src/libgdl/gdl-dock.c deleted file mode 100644 index c87468e5c..000000000 --- a/src/libgdl/gdl-dock.c +++ /dev/null @@ -1,1365 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This file is part of the GNOME Devtools Libraries. - * - * Copyright (C) 2002 Gustavo Giráldez <gustavo.giraldez@gmx.net> - * 2007 Naba Kumar <naba@gnome.org> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include "gdl-i18n.h" -#include <stdlib.h> -#include <string.h> - -#include "gdl-dock.h" -#include "gdl-dock-master.h" -#include "gdl-dock-paned.h" -#include "gdl-dock-notebook.h" -#include "gdl-dock-placeholder.h" - -#include "libgdlmarshal.h" - -#ifndef __FUNCTION__ -#define __FUNCTION__ __func__ -#endif - -/* ----- Private prototypes ----- */ - -static void gdl_dock_class_init (GdlDockClass *class); - -static GObject *gdl_dock_constructor (GType type, - guint n_construct_properties, - GObjectConstructParam *construct_param); -static void gdl_dock_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec); -static void gdl_dock_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec); -static void gdl_dock_notify_cb (GObject *object, - GParamSpec *pspec, - gpointer user_data); - -static void gdl_dock_set_title (GdlDock *dock); - -static void gdl_dock_destroy (GtkObject *object); - -static void gdl_dock_size_request (GtkWidget *widget, - GtkRequisition *requisition); -static void gdl_dock_size_allocate (GtkWidget *widget, - GtkAllocation *allocation); -static void gdl_dock_map (GtkWidget *widget); -static void gdl_dock_unmap (GtkWidget *widget); -static void gdl_dock_show (GtkWidget *widget); -static void gdl_dock_hide (GtkWidget *widget); - -static void gdl_dock_add (GtkContainer *container, - GtkWidget *widget); -static void gdl_dock_remove (GtkContainer *container, - GtkWidget *widget); -static void gdl_dock_forall (GtkContainer *container, - gboolean include_internals, - GtkCallback callback, - gpointer callback_data); -static GType gdl_dock_child_type (GtkContainer *container); - -static void gdl_dock_detach (GdlDockObject *object, - gboolean recursive); -static void gdl_dock_reduce (GdlDockObject *object); -static gboolean gdl_dock_dock_request (GdlDockObject *object, - gint x, - gint y, - GdlDockRequest *request); -static void gdl_dock_dock (GdlDockObject *object, - GdlDockObject *requestor, - GdlDockPlacement position, - GValue *other_data); -static gboolean gdl_dock_reorder (GdlDockObject *object, - GdlDockObject *requestor, - GdlDockPlacement new_position, - GValue *other_data); - -static gboolean gdl_dock_floating_window_delete_event_cb (GtkWidget *widget); - -static gboolean gdl_dock_child_placement (GdlDockObject *object, - GdlDockObject *child, - GdlDockPlacement *placement); - -static void gdl_dock_present (GdlDockObject *object, - GdlDockObject *child); - - -/* ----- Class variables and definitions ----- */ - -struct _GdlDockPrivate -{ - /* for floating docks */ - gboolean floating; - GtkWidget *window; - gboolean auto_title; - - gint float_x; - gint float_y; - gint width; - gint height; - - /* auxiliary fields */ - GdkGC *xor_gc; -}; - -enum { - LAYOUT_CHANGED, - LAST_SIGNAL -}; - -enum { - PROP_0, - PROP_FLOATING, - PROP_DEFAULT_TITLE, - PROP_WIDTH, - PROP_HEIGHT, - PROP_FLOAT_X, - PROP_FLOAT_Y -}; - -static guint dock_signals [LAST_SIGNAL] = { 0 }; - -#define SPLIT_RATIO 0.3 - - -/* ----- Private functions ----- */ - -G_DEFINE_TYPE (GdlDock, gdl_dock, GDL_TYPE_DOCK_OBJECT); - -static void -gdl_dock_class_init (GdlDockClass *klass) -{ - GObjectClass *g_object_class; - GtkObjectClass *gtk_object_class; - GtkWidgetClass *widget_class; - GtkContainerClass *container_class; - GdlDockObjectClass *object_class; - - g_object_class = G_OBJECT_CLASS (klass); - gtk_object_class = GTK_OBJECT_CLASS (klass); - widget_class = GTK_WIDGET_CLASS (klass); - container_class = GTK_CONTAINER_CLASS (klass); - object_class = GDL_DOCK_OBJECT_CLASS (klass); - - g_object_class->constructor = gdl_dock_constructor; - g_object_class->set_property = gdl_dock_set_property; - g_object_class->get_property = gdl_dock_get_property; - - /* properties */ - - g_object_class_install_property ( - g_object_class, PROP_FLOATING, - g_param_spec_boolean ("floating", _("Floating"), - _("Whether the dock is floating in its own window"), - FALSE, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | - GDL_DOCK_PARAM_EXPORT)); - - g_object_class_install_property ( - g_object_class, PROP_DEFAULT_TITLE, - g_param_spec_string ("default-title", _("Default title"), - _("Default title for the newly created floating docks"), - NULL, - G_PARAM_READWRITE)); - - g_object_class_install_property ( - g_object_class, PROP_WIDTH, - g_param_spec_int ("width", _("Width"), - _("Width for the dock when it's of floating type"), - -1, G_MAXINT, -1, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT | - GDL_DOCK_PARAM_EXPORT)); - - g_object_class_install_property ( - g_object_class, PROP_HEIGHT, - g_param_spec_int ("height", _("Height"), - _("Height for the dock when it's of floating type"), - -1, G_MAXINT, -1, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT | - GDL_DOCK_PARAM_EXPORT)); - - g_object_class_install_property ( - g_object_class, PROP_FLOAT_X, - g_param_spec_int ("floatx", _("Float X"), - _("X coordinate for a floating dock"), - G_MININT, G_MAXINT, 0, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT | - GDL_DOCK_PARAM_EXPORT)); - - g_object_class_install_property ( - g_object_class, PROP_FLOAT_Y, - g_param_spec_int ("floaty", _("Float Y"), - _("Y coordinate for a floating dock"), - G_MININT, G_MAXINT, 0, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT | - GDL_DOCK_PARAM_EXPORT)); - - gtk_object_class->destroy = gdl_dock_destroy; - - widget_class->size_request = gdl_dock_size_request; - widget_class->size_allocate = gdl_dock_size_allocate; - widget_class->map = gdl_dock_map; - widget_class->unmap = gdl_dock_unmap; - widget_class->show = gdl_dock_show; - widget_class->hide = gdl_dock_hide; - - container_class->add = gdl_dock_add; - container_class->remove = gdl_dock_remove; - container_class->forall = gdl_dock_forall; - container_class->child_type = gdl_dock_child_type; - - object_class->is_compound = TRUE; - - object_class->detach = gdl_dock_detach; - object_class->reduce = gdl_dock_reduce; - object_class->dock_request = gdl_dock_dock_request; - object_class->dock = gdl_dock_dock; - object_class->reorder = gdl_dock_reorder; - object_class->child_placement = gdl_dock_child_placement; - object_class->present = gdl_dock_present; - - /* signals */ - - dock_signals [LAYOUT_CHANGED] = - g_signal_new ("layout-changed", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (GdlDockClass, layout_changed), - NULL, /* accumulator */ - NULL, /* accu_data */ - gdl_marshal_VOID__VOID, - G_TYPE_NONE, /* return type */ - 0); - - klass->layout_changed = NULL; -} - -static void -gdl_dock_init (GdlDock *dock) -{ - gtk_widget_set_has_window (GTK_WIDGET (dock), FALSE); - - dock->root = NULL; - dock->_priv = g_new0 (GdlDockPrivate, 1); - dock->_priv->width = -1; - dock->_priv->height = -1; -} - -static gboolean -gdl_dock_floating_configure_event_cb (GtkWidget *widget, - GdkEventConfigure *event, - gpointer user_data) -{ - GdlDock *dock; - - g_return_val_if_fail (user_data != NULL && GDL_IS_DOCK (user_data), TRUE); - - dock = GDL_DOCK (user_data); - dock->_priv->float_x = event->x; - dock->_priv->float_y = event->y; - dock->_priv->width = event->width; - dock->_priv->height = event->height; - - return FALSE; -} - -static GObject * -gdl_dock_constructor (GType type, - guint n_construct_properties, - GObjectConstructParam *construct_param) -{ - GObject *g_object; - - g_object = G_OBJECT_CLASS (gdl_dock_parent_class)-> constructor (type, - n_construct_properties, - construct_param); - if (g_object) { - GdlDock *dock = GDL_DOCK (g_object); - GdlDockMaster *master; - - /* create a master for the dock if none was provided in the construction */ - master = GDL_DOCK_OBJECT_GET_MASTER (GDL_DOCK_OBJECT (dock)); - if (!master) { - GDL_DOCK_OBJECT_UNSET_FLAGS (dock, GDL_DOCK_AUTOMATIC); - master = g_object_new (GDL_TYPE_DOCK_MASTER, NULL); - /* the controller owns the master ref */ - gdl_dock_object_bind (GDL_DOCK_OBJECT (dock), G_OBJECT (master)); - } - - if (dock->_priv->floating) { - /* create floating window for this dock */ - dock->_priv->window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - g_object_set_data (G_OBJECT (dock->_priv->window), "dock", dock); - - /* set position and default size */ - gtk_window_set_position (GTK_WINDOW (dock->_priv->window), - GTK_WIN_POS_MOUSE); - gtk_window_set_default_size (GTK_WINDOW (dock->_priv->window), - dock->_priv->width, - dock->_priv->height); - gtk_window_set_type_hint (GTK_WINDOW (dock->_priv->window), - GDK_WINDOW_TYPE_HINT_NORMAL); - - gtk_window_set_skip_taskbar_hint (GTK_WINDOW (dock->_priv->window), - TRUE); - - /* metacity ignores this */ - gtk_window_move (GTK_WINDOW (dock->_priv->window), - dock->_priv->float_x, - dock->_priv->float_y); - - /* connect to the configure event so we can track down window geometry */ - g_signal_connect (dock->_priv->window, "configure_event", - (GCallback) gdl_dock_floating_configure_event_cb, - dock); - - /* set the title and connect to the long_name notify queue - so we can reset the title when this prop changes */ - gdl_dock_set_title (dock); - g_signal_connect (dock, "notify::long-name", - (GCallback) gdl_dock_notify_cb, NULL); - - gtk_container_add (GTK_CONTAINER (dock->_priv->window), GTK_WIDGET (dock)); - - g_signal_connect (dock->_priv->window, "delete_event", - G_CALLBACK (gdl_dock_floating_window_delete_event_cb), - NULL); - } - GDL_DOCK_OBJECT_SET_FLAGS (dock, GDL_DOCK_ATTACHED); - } - - return g_object; -} - -static void -gdl_dock_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) -{ - GdlDock *dock = GDL_DOCK (object); - - switch (prop_id) { - case PROP_FLOATING: - dock->_priv->floating = g_value_get_boolean (value); - break; - case PROP_DEFAULT_TITLE: - if (GDL_DOCK_OBJECT (object)->master) - g_object_set (GDL_DOCK_OBJECT (object)->master, - "default-title", g_value_get_string (value), - NULL); - break; - case PROP_WIDTH: - dock->_priv->width = g_value_get_int (value); - break; - case PROP_HEIGHT: - dock->_priv->height = g_value_get_int (value); - break; - case PROP_FLOAT_X: - dock->_priv->float_x = g_value_get_int (value); - break; - case PROP_FLOAT_Y: - dock->_priv->float_y = g_value_get_int (value); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } - - switch (prop_id) { - case PROP_WIDTH: - case PROP_HEIGHT: - case PROP_FLOAT_X: - case PROP_FLOAT_Y: - if (dock->_priv->floating && dock->_priv->window) { - gtk_window_resize (GTK_WINDOW (dock->_priv->window), - dock->_priv->width, - dock->_priv->height); - } - break; - } -} - -static void -gdl_dock_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) -{ - GdlDock *dock = GDL_DOCK (object); - - switch (prop_id) { - case PROP_FLOATING: - g_value_set_boolean (value, dock->_priv->floating); - break; - case PROP_DEFAULT_TITLE: - if (GDL_DOCK_OBJECT (object)->master) { - gchar *default_title; - g_object_get (GDL_DOCK_OBJECT (object)->master, - "default-title", &default_title, - NULL); -#if GLIB_CHECK_VERSION(2,3,0) - g_value_take_string (value, default_title); -#else - g_value_set_string_take_ownership (value, default_title); -#endif - } - else - g_value_set_string (value, NULL); - break; - case PROP_WIDTH: - g_value_set_int (value, dock->_priv->width); - break; - case PROP_HEIGHT: - g_value_set_int (value, dock->_priv->height); - break; - case PROP_FLOAT_X: - g_value_set_int (value, dock->_priv->float_x); - break; - case PROP_FLOAT_Y: - g_value_set_int (value, dock->_priv->float_y); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -gdl_dock_set_title (GdlDock *dock) -{ - GdlDockObject *object = GDL_DOCK_OBJECT (dock); - gchar *title = NULL; - - if (!dock->_priv->window) - return; - - if (!dock->_priv->auto_title && object->long_name) { - title = object->long_name; - } - else if (object->master) { - g_object_get (object->master, "default-title", &title, NULL); - } - - if (!title && dock->root) { - g_object_get (dock->root, "long-name", &title, NULL); - } - - if (!title) { - /* set a default title in the long_name */ - dock->_priv->auto_title = TRUE; - title = g_strdup_printf ( - _("Dock #%d"), GDL_DOCK_MASTER (object->master)->dock_number++); - } - - gtk_window_set_title (GTK_WINDOW (dock->_priv->window), title); - - g_free (title); -} - -static void -gdl_dock_notify_cb (GObject *object, - GParamSpec *pspec, - gpointer user_data) -{ - GdlDock *dock; - gchar* long_name; - - g_return_if_fail (object != NULL || GDL_IS_DOCK (object)); - - g_object_get (object, "long-name", &long_name, NULL); - - if (long_name) - { - dock = GDL_DOCK (object); - dock->_priv->auto_title = FALSE; - gdl_dock_set_title (dock); - } - g_free (long_name); -} - -static void -gdl_dock_destroy (GtkObject *object) -{ - GdlDock *dock = GDL_DOCK (object); - - if (dock->_priv) { - GdlDockPrivate *priv = dock->_priv; - dock->_priv = NULL; - - if (priv->window) { - gtk_widget_destroy (priv->window); - priv->floating = FALSE; - priv->window = NULL; - } - - /* destroy the xor gc */ - if (priv->xor_gc) { - g_object_unref (priv->xor_gc); - priv->xor_gc = NULL; - } - - g_free (priv); - } - - GTK_OBJECT_CLASS (gdl_dock_parent_class)->destroy (object); -} - -static void -gdl_dock_size_request (GtkWidget *widget, - GtkRequisition *requisition) -{ - GdlDock *dock; - GtkContainer *container; - guint border_width; - - g_return_if_fail (widget != NULL); - g_return_if_fail (GDL_IS_DOCK (widget)); - - dock = GDL_DOCK (widget); - container = GTK_CONTAINER (widget); - border_width = gtk_container_get_border_width (container); - - /* make request to root */ - if (dock->root && gtk_widget_get_visible (GTK_WIDGET (dock->root))) - gtk_widget_size_request (GTK_WIDGET (dock->root), requisition); - else { - requisition->width = 0; - requisition->height = 0; - }; - - requisition->width += 2 * border_width; - requisition->height += 2 * border_width; - - //gtk_widget_size_request (widget, requisition); -} - -static void -gdl_dock_size_allocate (GtkWidget *widget, - GtkAllocation *allocation) -{ - GdlDock *dock; - GtkContainer *container; - guint border_width; - - g_return_if_fail (widget != NULL); - g_return_if_fail (GDL_IS_DOCK (widget)); - - dock = GDL_DOCK (widget); - container = GTK_CONTAINER (widget); - border_width = gtk_container_get_border_width (container); - - gtk_widget_set_allocation (widget, allocation); - - /* reduce allocation by border width */ - allocation->x += border_width; - allocation->y += border_width; - allocation->width = MAX (1, allocation->width - 2 * border_width); - allocation->height = MAX (1, allocation->height - 2 * border_width); - - if (dock->root && gtk_widget_get_visible (GTK_WIDGET (dock->root))) - gtk_widget_size_allocate (GTK_WIDGET (dock->root), allocation); -} - -static void -gdl_dock_map (GtkWidget *widget) -{ - GtkWidget *child; - GdlDock *dock; - - g_return_if_fail (widget != NULL); - g_return_if_fail (GDL_IS_DOCK (widget)); - - dock = GDL_DOCK (widget); - - GTK_WIDGET_CLASS (gdl_dock_parent_class)->map (widget); - - if (dock->root) { - child = GTK_WIDGET (dock->root); - if (gtk_widget_get_visible (child) && !gtk_widget_get_mapped (child)) - gtk_widget_map (child); - } -} - -static void -gdl_dock_unmap (GtkWidget *widget) -{ - GtkWidget *child; - GdlDock *dock; - - g_return_if_fail (widget != NULL); - g_return_if_fail (GDL_IS_DOCK (widget)); - - dock = GDL_DOCK (widget); - - GTK_WIDGET_CLASS (gdl_dock_parent_class)->unmap (widget); - - if (dock->root) { - child = GTK_WIDGET (dock->root); - if (gtk_widget_get_visible (child) && gtk_widget_get_mapped (child)) - gtk_widget_unmap (child); - } - - if (dock->_priv->window) - gtk_widget_unmap (dock->_priv->window); -} - -static void -gdl_dock_foreach_automatic (GdlDockObject *object, - gpointer user_data) -{ - void (* function) (GtkWidget *) = user_data; - - if (GDL_DOCK_OBJECT_AUTOMATIC (object)) - (* function) (GTK_WIDGET (object)); -} - -static void -gdl_dock_show (GtkWidget *widget) -{ - GdlDock *dock; - - g_return_if_fail (widget != NULL); - g_return_if_fail (GDL_IS_DOCK (widget)); - - GTK_WIDGET_CLASS (gdl_dock_parent_class)->show (widget); - - dock = GDL_DOCK (widget); - if (dock->_priv->floating && dock->_priv->window) - gtk_widget_show (dock->_priv->window); - - if (GDL_DOCK_IS_CONTROLLER (dock)) { - gdl_dock_master_foreach_toplevel (GDL_DOCK_OBJECT_GET_MASTER (dock), - FALSE, (GFunc) gdl_dock_foreach_automatic, - gtk_widget_show); - } -} - -static void -gdl_dock_hide (GtkWidget *widget) -{ - GdlDock *dock; - - g_return_if_fail (widget != NULL); - g_return_if_fail (GDL_IS_DOCK (widget)); - - GTK_WIDGET_CLASS (gdl_dock_parent_class)->hide (widget); - - dock = GDL_DOCK (widget); - if (dock->_priv->floating && dock->_priv->window) - gtk_widget_hide (dock->_priv->window); - - if (GDL_DOCK_IS_CONTROLLER (dock)) { - gdl_dock_master_foreach_toplevel (GDL_DOCK_OBJECT_GET_MASTER (dock), - FALSE, (GFunc) gdl_dock_foreach_automatic, - gtk_widget_hide); - } -} - -static void -gdl_dock_add (GtkContainer *container, - GtkWidget *widget) -{ - g_return_if_fail (container != NULL); - g_return_if_fail (GDL_IS_DOCK (container)); - g_return_if_fail (GDL_IS_DOCK_ITEM (widget)); - - gdl_dock_add_item (GDL_DOCK (container), - GDL_DOCK_ITEM (widget), - GDL_DOCK_TOP); /* default position */ -} - -static void -gdl_dock_remove (GtkContainer *container, - GtkWidget *widget) -{ - GdlDock *dock; - gboolean was_visible; - - g_return_if_fail (container != NULL); - g_return_if_fail (widget != NULL); - - dock = GDL_DOCK (container); - was_visible = gtk_widget_get_visible (widget); - - if (GTK_WIDGET (dock->root) == widget) { - dock->root = NULL; - GDL_DOCK_OBJECT_UNSET_FLAGS (widget, GDL_DOCK_ATTACHED); - gtk_widget_unparent (widget); - - if (was_visible && gtk_widget_get_visible (GTK_WIDGET (container))) - gtk_widget_queue_resize (GTK_WIDGET (dock)); - } -} - -static void -gdl_dock_forall (GtkContainer *container, - gboolean include_internals, - GtkCallback callback, - gpointer callback_data) -{ - GdlDock *dock; - - g_return_if_fail (container != NULL); - g_return_if_fail (GDL_IS_DOCK (container)); - g_return_if_fail (callback != NULL); - - dock = GDL_DOCK (container); - - if (dock->root) - (*callback) (GTK_WIDGET (dock->root), callback_data); -} - -static GType -gdl_dock_child_type (GtkContainer *container) -{ - return GDL_TYPE_DOCK_ITEM; -} - -static void -gdl_dock_detach (GdlDockObject *object, - gboolean recursive) -{ - GdlDock *dock = GDL_DOCK (object); - - /* detach children */ - if (recursive && dock->root) { - gdl_dock_object_detach (dock->root, recursive); - } - GDL_DOCK_OBJECT_UNSET_FLAGS (object, GDL_DOCK_ATTACHED); -} - -static void -gdl_dock_reduce (GdlDockObject *object) -{ - GdlDock *dock = GDL_DOCK (object); - GtkWidget *parent; - - if (dock->root) - return; - - if (GDL_DOCK_OBJECT_AUTOMATIC (dock)) { - gtk_widget_destroy (GTK_WIDGET (dock)); - - } else if (!GDL_DOCK_OBJECT_ATTACHED (dock)) { - /* if the user explicitly detached the object */ - if (dock->_priv->floating) - gtk_widget_hide (GTK_WIDGET (dock)); - else { - GtkWidget *widget = GTK_WIDGET (object); - parent = gtk_widget_get_parent (widget); - if (parent) - gtk_container_remove (GTK_CONTAINER (parent), widget); - } - } -} - -static gboolean -gdl_dock_dock_request (GdlDockObject *object, - gint x, - gint y, - GdlDockRequest *request) -{ - GdlDock *dock; - guint bw; - gint rel_x, rel_y; - GtkAllocation alloc; - gboolean may_dock = FALSE; - GdlDockRequest my_request; - - g_return_val_if_fail (GDL_IS_DOCK (object), FALSE); - - /* we get (x,y) in our allocation coordinates system */ - - dock = GDL_DOCK (object); - - /* Get dock size. */ - gtk_widget_get_allocation (GTK_WIDGET (dock), &alloc); - bw = gtk_container_get_border_width (GTK_CONTAINER (dock)); - - /* Get coordinates relative to our allocation area. */ - rel_x = x - alloc.x; - rel_y = y - alloc.y; - - if (request) - my_request = *request; - - /* Check if coordinates are in GdlDock widget. */ - if (rel_x > 0 && rel_x < alloc.width && - rel_y > 0 && rel_y < alloc.height) { - - /* It's inside our area. */ - may_dock = TRUE; - - /* Set docking indicator rectangle to the GdlDock size. */ - my_request.rect.x = alloc.x + bw; - my_request.rect.y = alloc.y + bw; - my_request.rect.width = alloc.width - 2*bw; - my_request.rect.height = alloc.height - 2*bw; - - /* If GdlDock has no root item yet, set the dock itself as - possible target. */ - if (!dock->root) { - my_request.position = GDL_DOCK_TOP; - my_request.target = object; - } else { - my_request.target = dock->root; - - /* See if it's in the border_width band. */ - if (rel_x < (gint)bw) { - my_request.position = GDL_DOCK_LEFT; - my_request.rect.width *= SPLIT_RATIO; - } else if (rel_x > alloc.width - (gint)bw) { - my_request.position = GDL_DOCK_RIGHT; - my_request.rect.x += my_request.rect.width * (1 - SPLIT_RATIO); - my_request.rect.width *= SPLIT_RATIO; - } else if (rel_y < (gint)bw) { - my_request.position = GDL_DOCK_TOP; - my_request.rect.height *= SPLIT_RATIO; - } else if (rel_y > alloc.height - (gint)bw) { - my_request.position = GDL_DOCK_BOTTOM; - my_request.rect.y += my_request.rect.height * (1 - SPLIT_RATIO); - my_request.rect.height *= SPLIT_RATIO; - } else { - /* Otherwise try our children. */ - /* give them allocation coordinates (we are a - GTK_NO_WINDOW) widget */ - may_dock = gdl_dock_object_dock_request (GDL_DOCK_OBJECT (dock->root), - x, y, &my_request); - } - } - } - - if (may_dock && request) - *request = my_request; - - return may_dock; -} - -static void -gdl_dock_dock (GdlDockObject *object, - GdlDockObject *requestor, - GdlDockPlacement position, - GValue *user_data) -{ - GdlDock *dock; - - g_return_if_fail (GDL_IS_DOCK (object)); - /* only dock items allowed at this time */ - g_return_if_fail (GDL_IS_DOCK_ITEM (requestor)); - - dock = GDL_DOCK (object); - - if (position == GDL_DOCK_FLOATING) { - GdlDockItem *item = GDL_DOCK_ITEM (requestor); - gint x, y, width, height; - - if (user_data && G_VALUE_HOLDS (user_data, GDK_TYPE_RECTANGLE)) { - GdkRectangle *rect; - - rect = g_value_get_boxed (user_data); - x = rect->x; - y = rect->y; - width = rect->width; - height = rect->height; - } - else { - x = y = 0; - width = height = -1; - } - - gdl_dock_add_floating_item (dock, item, - x, y, width, height); - } - else if (dock->root) { - /* This is somewhat a special case since we know which item to - pass the request on because we only have on child */ - gdl_dock_object_dock (dock->root, requestor, position, NULL); - gdl_dock_set_title (dock); - - } - else { /* Item about to be added is root item. */ - GtkWidget *widget = GTK_WIDGET (requestor); - - dock->root = requestor; - GDL_DOCK_OBJECT_SET_FLAGS (requestor, GDL_DOCK_ATTACHED); - gtk_widget_set_parent (widget, GTK_WIDGET (dock)); - - gdl_dock_item_show_grip (GDL_DOCK_ITEM (requestor)); - - /* Realize the item (create its corresponding GdkWindow) when - GdlDock has been realized. */ - if (gtk_widget_get_realized (GTK_WIDGET (dock))) - gtk_widget_realize (widget); - - /* Map the widget if it's visible and the parent is visible and has - been mapped. This is done to make sure that the GdkWindow is - visible. */ - if (gtk_widget_get_visible (GTK_WIDGET (dock)) && - gtk_widget_get_visible (widget)) { - if (gtk_widget_get_mapped (GTK_WIDGET (dock))) - gtk_widget_map (widget); - - /* Make the widget resize. */ - gtk_widget_queue_resize (widget); - } - gdl_dock_set_title (dock); - } -} - -static gboolean -gdl_dock_floating_window_delete_event_cb (GtkWidget *widget) -{ - GdlDock *dock; - - g_return_val_if_fail (GTK_IS_WINDOW (widget), FALSE); - - dock = GDL_DOCK (g_object_get_data (G_OBJECT (widget), "dock")); - if (dock->root) { - /* this will call reduce on ourselves, hiding the window if appropiate */ - gdl_dock_item_hide_item (GDL_DOCK_ITEM (dock->root)); - } - - return TRUE; -} - -static void -_gdl_dock_foreach_build_list (GdlDockObject *object, - gpointer user_data) -{ - GList **l = (GList **) user_data; - - if (GDL_IS_DOCK_ITEM (object)) - *l = g_list_prepend (*l, object); -} - -static gboolean -gdl_dock_reorder (GdlDockObject *object, - GdlDockObject *requestor, - GdlDockPlacement new_position, - GValue *other_data) -{ - GdlDock *dock = GDL_DOCK (object); - gboolean handled = FALSE; - - if (dock->_priv->floating && - new_position == GDL_DOCK_FLOATING && - dock->root == requestor) { - - if (other_data && G_VALUE_HOLDS (other_data, GDK_TYPE_RECTANGLE)) { - GdkRectangle *rect; - - rect = g_value_get_boxed (other_data); - gtk_window_move (GTK_WINDOW (dock->_priv->window), - rect->x, - rect->y); - handled = TRUE; - } - } - - return handled; -} - -static gboolean -gdl_dock_child_placement (GdlDockObject *object, - GdlDockObject *child, - GdlDockPlacement *placement) -{ - GdlDock *dock = GDL_DOCK (object); - gboolean retval = TRUE; - - if (dock->root == child) { - if (placement) { - if (*placement == GDL_DOCK_NONE || *placement == GDL_DOCK_FLOATING) - *placement = GDL_DOCK_TOP; - } - } else - retval = FALSE; - - return retval; -} - -static void -gdl_dock_present (GdlDockObject *object, - GdlDockObject *child) -{ - GdlDock *dock = GDL_DOCK (object); - - if (dock->_priv->floating) - gtk_window_present (GTK_WINDOW (dock->_priv->window)); -} - - -/* ----- Public interface ----- */ - -GtkWidget * -gdl_dock_new (void) -{ - GObject *dock; - - dock = g_object_new (GDL_TYPE_DOCK, NULL); - GDL_DOCK_OBJECT_UNSET_FLAGS (dock, GDL_DOCK_AUTOMATIC); - - return GTK_WIDGET (dock); -} - -GtkWidget * -gdl_dock_new_from (GdlDock *original, - gboolean floating) -{ - GObject *new_dock; - - g_return_val_if_fail (original != NULL, NULL); - - new_dock = g_object_new (GDL_TYPE_DOCK, - "master", GDL_DOCK_OBJECT_GET_MASTER (original), - "floating", floating, - NULL); - GDL_DOCK_OBJECT_UNSET_FLAGS (new_dock, GDL_DOCK_AUTOMATIC); - - return GTK_WIDGET (new_dock); -} - -/* Depending on where the dock item (where new item will be docked) locates - * in the dock, we might need to change the docking placement. If the - * item is does not touches the center of dock, the new-item-to-dock would - * require a center dock on this item. - */ -static GdlDockPlacement -gdl_dock_refine_placement (GdlDock *dock, GdlDockItem *dock_item, - GdlDockPlacement placement) -{ - GtkAllocation allocation; - GtkRequisition object_size; - - gdl_dock_item_preferred_size (dock_item, &object_size); - gtk_widget_get_allocation (GTK_WIDGET (dock), &allocation); - - g_return_val_if_fail (allocation.width > 0, placement); - g_return_val_if_fail (allocation.height > 0, placement); - g_return_val_if_fail (object_size.width > 0, placement); - g_return_val_if_fail (object_size.height > 0, placement); - - if (placement == GDL_DOCK_LEFT || placement == GDL_DOCK_RIGHT) { - /* Check if dock_object touches center in terms of width */ - if (allocation.width/2 > object_size.width) { - return GDL_DOCK_CENTER; - } - } else if (placement == GDL_DOCK_TOP || placement == GDL_DOCK_BOTTOM) { - /* Check if dock_object touches center in terms of height */ - if (allocation.height/2 > object_size.height) { - return GDL_DOCK_CENTER; - } - } - return placement; -} - -/* Determines the larger item of the two based on the placement: - * for left/right placement, height determines it. - * for top/bottom placement, width determines it. - * for center placement, area determines it. - */ -static GdlDockItem* -gdl_dock_select_larger_item (GdlDockItem *dock_item_1, - GdlDockItem *dock_item_2, - GdlDockPlacement placement, - gint level /* for debugging */) -{ - GtkRequisition size_1, size_2; - - g_return_val_if_fail (dock_item_1 != NULL, dock_item_2); - g_return_val_if_fail (dock_item_2 != NULL, dock_item_1); - - gdl_dock_item_preferred_size (dock_item_1, &size_1); - gdl_dock_item_preferred_size (dock_item_2, &size_2); - - g_return_val_if_fail (size_1.width > 0, dock_item_2); - g_return_val_if_fail (size_1.height > 0, dock_item_2); - g_return_val_if_fail (size_2.width > 0, dock_item_1); - g_return_val_if_fail (size_2.height > 0, dock_item_1); - - if (placement == GDL_DOCK_LEFT || placement == GDL_DOCK_RIGHT) - { - /* For left/right placement, height is what matters */ - return (size_1.height >= size_2.height? - dock_item_1 : dock_item_2); - } else if (placement == GDL_DOCK_TOP || placement == GDL_DOCK_BOTTOM) - { - /* For top/bottom placement, width is what matters */ - return (size_1.width >= size_2.width? - dock_item_1 : dock_item_2); - } else if (placement == GDL_DOCK_CENTER) { - /* For center place, area is what matters */ - return ((size_1.width * size_1.height) - >= (size_2.width * size_2.height)? - dock_item_1 : dock_item_2); - } else if (placement == GDL_DOCK_NONE) { - return dock_item_1; - } else { - g_warning ("Should not reach here: %s:%d", __FUNCTION__, __LINE__); - } - return dock_item_1; -} - -/* Determines the best dock item to dock a new item with the given placement. - * It traverses the dock tree and (based on the placement) tries to find - * the best located item wrt to the placement. The approach is to find the - * largest item on/around the placement side (for side placements) and to - * find the largest item for center placement. In most situations, this is - * what user wants and the heuristic should be therefore sufficient. - */ -static GdlDockItem* -gdl_dock_find_best_placement_item (GdlDockItem *dock_item, - GdlDockPlacement placement, - gint level /* for debugging */) -{ - GdlDockItem *ret_item = NULL; - - if (GDL_IS_DOCK_PANED (dock_item)) - { - GtkOrientation orientation; - GdlDockItem *dock_item_1, *dock_item_2; - GList* children; - - children = gtk_container_get_children (GTK_CONTAINER (dock_item)); - - g_assert (g_list_length (children) == 2); - - g_object_get (dock_item, "orientation", &orientation, NULL); - if ((orientation == GTK_ORIENTATION_HORIZONTAL && - placement == GDL_DOCK_LEFT) || - (orientation == GTK_ORIENTATION_VERTICAL && - placement == GDL_DOCK_TOP)) { - /* Return left or top pane widget */ - ret_item = - gdl_dock_find_best_placement_item (GDL_DOCK_ITEM - (children->data), - placement, level + 1); - } else if ((orientation == GTK_ORIENTATION_HORIZONTAL && - placement == GDL_DOCK_RIGHT) || - (orientation == GTK_ORIENTATION_VERTICAL && - placement == GDL_DOCK_BOTTOM)) { - /* Return right or top pane widget */ - ret_item = - gdl_dock_find_best_placement_item (GDL_DOCK_ITEM - (children->next->data), - placement, level + 1); - } else { - /* Evaluate which of the two sides is bigger */ - dock_item_1 = - gdl_dock_find_best_placement_item (GDL_DOCK_ITEM - (children->data), - placement, level + 1); - dock_item_2 = - gdl_dock_find_best_placement_item (GDL_DOCK_ITEM - (children->next->data), - placement, level + 1); - ret_item = gdl_dock_select_larger_item (dock_item_1, - dock_item_2, - placement, level); - } - g_list_free (children); - } - else if (GDL_IS_DOCK_ITEM (dock_item)) - { - ret_item = dock_item; - } - else - { - /* should not be here */ - g_warning ("Should not reach here: %s:%d", __FUNCTION__, __LINE__); - } - return ret_item; -} - -void -gdl_dock_add_item (GdlDock *dock, - GdlDockItem *item, - GdlDockPlacement placement) -{ - g_return_if_fail (dock != NULL); - g_return_if_fail (item != NULL); - - if (placement == GDL_DOCK_FLOATING) - /* Add the item to a new floating dock */ - gdl_dock_add_floating_item (dock, item, 0, 0, -1, -1); - - else { - GdlDockItem *best_dock_item; - /* Non-floating item. */ - if (dock->root) { - GdlDockPlacement local_placement; - - best_dock_item = - gdl_dock_find_best_placement_item (GDL_DOCK_ITEM (dock->root), - placement, 0); - local_placement = gdl_dock_refine_placement (dock, best_dock_item, - placement); - gdl_dock_object_dock (GDL_DOCK_OBJECT (best_dock_item), - GDL_DOCK_OBJECT (item), - local_placement, NULL); - } else { - gdl_dock_object_dock (GDL_DOCK_OBJECT (dock), - GDL_DOCK_OBJECT (item), - placement, NULL); - } - } -} - -void -gdl_dock_add_floating_item (GdlDock *dock, - GdlDockItem *item, - gint x, - gint y, - gint width, - gint height) -{ - GdlDock *new_dock; - - g_return_if_fail (dock != NULL); - g_return_if_fail (item != NULL); - - new_dock = GDL_DOCK (g_object_new (GDL_TYPE_DOCK, - "master", GDL_DOCK_OBJECT_GET_MASTER (dock), - "floating", TRUE, - "width", width, - "height", height, - "floatx", x, - "floaty", y, - NULL)); - - if (gtk_widget_get_visible (GTK_WIDGET (dock))) { - gtk_widget_show (GTK_WIDGET (new_dock)); - if (gtk_widget_get_mapped (GTK_WIDGET (dock))) - gtk_widget_map (GTK_WIDGET (new_dock)); - - /* Make the widget resize. */ - gtk_widget_queue_resize (GTK_WIDGET (new_dock)); - } - - gdl_dock_add_item (GDL_DOCK (new_dock), item, GDL_DOCK_TOP); -} - -GdlDockItem * -gdl_dock_get_item_by_name (GdlDock *dock, - const gchar *name) -{ - GdlDockObject *found; - - g_return_val_if_fail (dock != NULL && name != NULL, NULL); - - /* proxy the call to our master */ - found = gdl_dock_master_get_object (GDL_DOCK_OBJECT_GET_MASTER (dock), name); - - return (found && GDL_IS_DOCK_ITEM (found)) ? GDL_DOCK_ITEM (found) : NULL; -} - -GdlDockPlaceholder * -gdl_dock_get_placeholder_by_name (GdlDock *dock, - const gchar *name) -{ - GdlDockObject *found; - - g_return_val_if_fail (dock != NULL && name != NULL, NULL); - - /* proxy the call to our master */ - found = gdl_dock_master_get_object (GDL_DOCK_OBJECT_GET_MASTER (dock), name); - - return (found && GDL_IS_DOCK_PLACEHOLDER (found)) ? - GDL_DOCK_PLACEHOLDER (found) : NULL; -} - -GList * -gdl_dock_get_named_items (GdlDock *dock) -{ - GList *list = NULL; - - g_return_val_if_fail (dock != NULL, NULL); - - gdl_dock_master_foreach (GDL_DOCK_OBJECT_GET_MASTER (dock), - (GFunc) _gdl_dock_foreach_build_list, &list); - - return list; -} - -GdlDock * -gdl_dock_object_get_toplevel (GdlDockObject *object) -{ - GdlDockObject *parent = object; - - g_return_val_if_fail (object != NULL, NULL); - - while (parent && !GDL_IS_DOCK (parent)) - parent = gdl_dock_object_get_parent_object (parent); - - return parent ? GDL_DOCK (parent) : NULL; -} - -void -gdl_dock_xor_rect (GdlDock *dock, - GdkRectangle *rect) -{ - GtkWidget *widget; - GdkWindow *window; - gint8 dash_list [2]; - - widget = GTK_WIDGET (dock); - - if (!dock->_priv->xor_gc) { - if (gtk_widget_get_realized (widget)) { - GdkGCValues values; - - values.function = GDK_INVERT; - values.subwindow_mode = GDK_INCLUDE_INFERIORS; - dock->_priv->xor_gc = gdk_gc_new_with_values - (gtk_widget_get_window (widget), &values, GDK_GC_FUNCTION | GDK_GC_SUBWINDOW); - } else - return; - }; - - gdk_gc_set_line_attributes (dock->_priv->xor_gc, 1, - GDK_LINE_ON_OFF_DASH, - GDK_CAP_NOT_LAST, - GDK_JOIN_BEVEL); - - window = gtk_widget_get_window (widget); - - dash_list [0] = 1; - dash_list [1] = 1; - - gdk_gc_set_dashes (dock->_priv->xor_gc, 1, dash_list, 2); - - gdk_draw_rectangle (window, dock->_priv->xor_gc, FALSE, - rect->x, rect->y, - rect->width, rect->height); - - gdk_gc_set_dashes (dock->_priv->xor_gc, 0, dash_list, 2); - - gdk_draw_rectangle (window, dock->_priv->xor_gc, FALSE, - rect->x + 1, rect->y + 1, - rect->width - 2, rect->height - 2); -} diff --git a/src/libgdl/gdl-dock.h b/src/libgdl/gdl-dock.h deleted file mode 100644 index 2259d395d..000000000 --- a/src/libgdl/gdl-dock.h +++ /dev/null @@ -1,99 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This file is part of the GNOME Devtools Libraries. - * - * Copyright (C) 2002 Gustavo Giráldez <gustavo.giraldez@gmx.net> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef __GDL_DOCK_H__ -#define __GDL_DOCK_H__ - -#include <gtk/gtk.h> -#include "libgdl/gdl-dock-object.h" -#include "libgdl/gdl-dock-item.h" -#include "libgdl/gdl-dock-placeholder.h" - -G_BEGIN_DECLS - -/* standard macros */ -#define GDL_TYPE_DOCK (gdl_dock_get_type ()) -#define GDL_DOCK(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDL_TYPE_DOCK, GdlDock)) -#define GDL_DOCK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDL_TYPE_DOCK, GdlDockClass)) -#define GDL_IS_DOCK(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GDL_TYPE_DOCK)) -#define GDL_IS_DOCK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDL_TYPE_DOCK)) -#define GDL_DOCK_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_DOCK, GdlDockClass)) - -/* data types & structures */ -typedef struct _GdlDock GdlDock; -typedef struct _GdlDockClass GdlDockClass; -typedef struct _GdlDockPrivate GdlDockPrivate; - -struct _GdlDock { - GdlDockObject object; - - GdlDockObject *root; - - GdlDockPrivate *_priv; -}; - -struct _GdlDockClass { - GdlDockObjectClass parent_class; - - void (* layout_changed) (GdlDock *dock); /* proxy signal for the master */ -}; - -/* additional macros */ -#define GDL_DOCK_IS_CONTROLLER(dock) \ - (gdl_dock_master_get_controller (GDL_DOCK_OBJECT_GET_MASTER (dock)) == \ - GDL_DOCK_OBJECT (dock)) - -/* public interface */ - -GtkWidget *gdl_dock_new (void); - -GtkWidget *gdl_dock_new_from (GdlDock *original, - gboolean floating); - -GType gdl_dock_get_type (void); - -void gdl_dock_add_item (GdlDock *dock, - GdlDockItem *item, - GdlDockPlacement place); - -void gdl_dock_add_floating_item (GdlDock *dock, - GdlDockItem *item, - gint x, - gint y, - gint width, - gint height); - -GdlDockItem *gdl_dock_get_item_by_name (GdlDock *dock, - const gchar *name); - -GdlDockPlaceholder *gdl_dock_get_placeholder_by_name (GdlDock *dock, - const gchar *name); - -GList *gdl_dock_get_named_items (GdlDock *dock); - -GdlDock *gdl_dock_object_get_toplevel (GdlDockObject *object); - -void gdl_dock_xor_rect (GdlDock *dock, - GdkRectangle *rect); - -G_END_DECLS - -#endif diff --git a/src/libgdl/gdl-i18n.c b/src/libgdl/gdl-i18n.c deleted file mode 100644 index 5f92b66c7..000000000 --- a/src/libgdl/gdl-i18n.c +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation - * All rights reserved. - * - * This file is part of the Gnome Devtools Library. - * - * The Gnome Devtools Library is free software; you can redistribute - * it and/or modify it under the terms of the GNU Library General - * Public License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * The Gnome Devtools Library is distributed in the hope that it will - * be useful, but WITHOUT ANY WARRANTY; without even the implied - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * See the GNU Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with the Gnome Library; see the file COPYING.LIB. If not, - * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "gdl-i18n.h" - -char * -gdl_gettext (const char *msgid) -{ - static gboolean initialized = FALSE; - - if (!initialized) { -/* bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR); */ - bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); - initialized = TRUE; - } - - return dgettext (GETTEXT_PACKAGE, msgid); -} - - diff --git a/src/libgdl/gdl-i18n.h b/src/libgdl/gdl-i18n.h deleted file mode 100644 index 1582e957d..000000000 --- a/src/libgdl/gdl-i18n.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation - * All rights reserved. - * - * This file is part of the Gnome Devtools Library. - * - * The Gnome Devtools Library is free software; you can redistribute - * it and/or modify it under the terms of the GNU Library General - * Public License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * The Gnome Devtools Library is distributed in the hope that it will - * be useful, but WITHOUT ANY WARRANTY; without even the implied - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * See the GNU Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with the Gnome Library; see the file COPYING.LIB. If not, - * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ -/* - @NOTATION@ - */ - -/* - * Handles all of the internationalization configuration options. - * Author: Tom Tromey <tromey@creche.cygnus.com> - */ - -#ifndef __GDL_18N_H__ -#define __GDL_18N_H__ 1 - -#include <glib.h> - - -G_BEGIN_DECLS - -#ifdef ENABLE_NLS -# include <libintl.h> -# undef _ -# define _(String) gdl_gettext (String) -# ifdef gettext_noop -# define N_(String) gettext_noop (String) -# else -# define N_(String) (String) -# endif -#else -/* Stubs that do something close enough. */ -# undef textdomain -# define textdomain(String) (String) -# undef gettext -# define gettext(String) (String) -# undef dgettext -# define dgettext(Domain,Message) (Message) -# undef dcgettext -# define dcgettext(Domain,Message,Type) (Message) -# undef bindtextdomain -# define bindtextdomain(Domain,Directory) (Domain) -# undef bind_textdomain_codeset -# define bind_textdomain_codeset(Domain,CodeSet) (Domain) -# undef _ -# define _(String) (String) -# undef N_ -# define N_(String) (String) -#endif - -char *gdl_gettext (const char *msgid); - -G_END_DECLS - -#endif /* __GDL_I18N_H__ */ diff --git a/src/libgdl/gdl-switcher.c b/src/libgdl/gdl-switcher.c deleted file mode 100644 index 53a4b1989..000000000 --- a/src/libgdl/gdl-switcher.c +++ /dev/null @@ -1,1031 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4; tab-width: 8 -*- */ -/* gdl-switcher.c - * - * Copyright (C) 2003 Ettore Perazzoli, - * 2007 Naba Kumar - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * - * Copied and adapted from ESidebar.[ch] from evolution - * - * Authors: Ettore Perazzoli <ettore@ximian.com> - * Naba Kumar <naba@gnome.org> - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include "gdl-i18n.h" -#include "gdl-switcher.h" -#include "libgdlmarshal.h" -#include "libgdltypebuiltins.h" - -#include <gtk/gtk.h> - -static void gdl_switcher_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec); -static void gdl_switcher_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec); - -static void gdl_switcher_add_button (GdlSwitcher *switcher, - const gchar *label, - const gchar *tooltips, - const gchar *stock_id, - GdkPixbuf *pixbuf_icon, - gint switcher_id, - GtkWidget *page); -/* static void gdl_switcher_remove_button (GdlSwitcher *switcher, gint switcher_id); */ -static void gdl_switcher_select_page (GdlSwitcher *switcher, gint switcher_id); -static void gdl_switcher_select_button (GdlSwitcher *switcher, gint switcher_id); -static void gdl_switcher_set_show_buttons (GdlSwitcher *switcher, gboolean show); -static void gdl_switcher_set_style (GdlSwitcher *switcher, - GdlSwitcherStyle switcher_style); -static GdlSwitcherStyle gdl_switcher_get_style (GdlSwitcher *switcher); - -enum { - PROP_0, - PROP_SWITCHER_STYLE -}; - -typedef struct { - GtkWidget *button_widget; - GtkWidget *label; - GtkWidget *icon; - GtkWidget *arrow; - GtkWidget *hbox; - GtkWidget *page; - int id; -} Button; - -struct _GdlSwitcherPrivate { - GdlSwitcherStyle switcher_style; - GdlSwitcherStyle toolbar_style; - - gboolean show; - GSList *buttons; - - guint style_changed_id; - gint buttons_height_request; - gboolean in_toggle; -}; - -G_DEFINE_TYPE (GdlSwitcher, gdl_switcher, GTK_TYPE_NOTEBOOK) - -#define INTERNAL_MODE(switcher) (switcher->priv->switcher_style == \ - GDL_SWITCHER_STYLE_TOOLBAR ? switcher->priv->toolbar_style : \ - switcher->priv->switcher_style) - -#define H_PADDING 2 -#define V_PADDING 2 - -/* Utility functions. */ - -static void -gdl_switcher_long_name_changed (GObject* object, - GParamSpec* spec, - gpointer user_data) -{ - Button* button = user_data; - gchar* label; - - g_object_get (object, "long-name", &label, NULL); - gtk_label_set_text (GTK_LABEL (button->label), label); - g_free (label); -} - -static void -gdl_switcher_stock_id_changed (GObject* object, - GParamSpec* spec, - gpointer user_data) -{ - Button* button = user_data; - gchar* id; - - g_object_get (object, "stock-id", &id, NULL); - gtk_image_set_from_stock (GTK_IMAGE(button->icon), id, GTK_ICON_SIZE_MENU); - g_free (id); -} - - -static Button * -button_new (GtkWidget *button_widget, GtkWidget *label, GtkWidget *icon, - GtkWidget *arrow, GtkWidget *hbox, int id, GtkWidget *page) -{ - Button *button = g_new (Button, 1); - - button->button_widget = button_widget; - button->label = label; - button->icon = icon; - button->arrow = arrow; - button->hbox = hbox; - button->id = id; - button->page = page; - - g_signal_connect (page, "notify::long-name", G_CALLBACK (gdl_switcher_long_name_changed), - button); - g_signal_connect (page, "notify::stock-id", G_CALLBACK (gdl_switcher_stock_id_changed), - button); - - g_object_ref (button_widget); - g_object_ref (label); - g_object_ref (icon); - g_object_ref (arrow); - g_object_ref (hbox); - - return button; -} - -static void -button_free (Button *button) -{ - g_signal_handlers_disconnect_by_func (button->page, - gdl_switcher_long_name_changed, - button); - g_signal_handlers_disconnect_by_func (button->page, - gdl_switcher_stock_id_changed, - button); - - g_object_unref (button->button_widget); - g_object_unref (button->label); - g_object_unref (button->icon); - g_object_unref (button->hbox); - g_free (button); -} - -static gint -gdl_switcher_get_page_id (GtkWidget *widget) -{ - static gint switcher_id_count = 0; - gint switcher_id; - switcher_id = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (widget), - "__switcher_id")); - if (switcher_id <= 0) { - switcher_id = ++switcher_id_count; - g_object_set_data (G_OBJECT (widget), "__switcher_id", - GINT_TO_POINTER (switcher_id)); - } - return switcher_id; -} - -static void -update_buttons (GdlSwitcher *switcher, int new_selected_id) -{ - GSList *p; - - switcher->priv->in_toggle = TRUE; - - for (p = switcher->priv->buttons; p != NULL; p = p->next) { - Button *button = p->data; - - if (button->id == new_selected_id) { - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON - (button->button_widget), TRUE); - gtk_widget_set_sensitive (button->arrow, TRUE); - } else { - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON - (button->button_widget), FALSE); - gtk_widget_set_sensitive (button->arrow, FALSE); - } - } - - switcher->priv->in_toggle = FALSE; -} - -/* Callbacks. */ - -static void -button_toggled_callback (GtkToggleButton *toggle_button, - GdlSwitcher *switcher) -{ - int id = 0; - gboolean is_active = FALSE; - GSList *p; - - if (switcher->priv->in_toggle) - return; - - switcher->priv->in_toggle = TRUE; - - if (gtk_toggle_button_get_active (toggle_button)) - is_active = TRUE; - - for (p = switcher->priv->buttons; p != NULL; p = p->next) { - Button *button = p->data; - - if (button->button_widget != GTK_WIDGET (toggle_button)) { - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON - (button->button_widget), FALSE); - gtk_widget_set_sensitive (button->arrow, FALSE); - } else { - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON - (button->button_widget), TRUE); - gtk_widget_set_sensitive (button->arrow, TRUE); - id = button->id; - } - } - - switcher->priv->in_toggle = FALSE; - - if (is_active) - { - gdl_switcher_select_page (switcher, id); - } -} - -/* Returns -1 if layout didn't happen because a resize request was queued */ -static int -layout_buttons (GdlSwitcher *switcher) -{ - GtkRequisition client_requisition = {0,0}; - GtkAllocation allocation; - GdlSwitcherStyle switcher_style; - gboolean icons_only; - int num_btns = g_slist_length (switcher->priv->buttons); - unsigned int btns_per_row; - GSList **rows, *p; - Button *button; - int row_number; - int max_btn_width = 0, max_btn_height = 0; - int optimal_layout_width = 0; - int row_last; - int x, y; - int i; - int rows_count; - int last_buttons_height; - - gtk_widget_get_allocation (GTK_WIDGET (switcher), &allocation); - - last_buttons_height = switcher->priv->buttons_height_request; - - GTK_WIDGET_CLASS (gdl_switcher_parent_class)->size_request (GTK_WIDGET (switcher), &client_requisition); - - y = allocation.y + allocation.height - V_PADDING - 1; - - if (num_btns == 0) - return y; - - switcher_style = INTERNAL_MODE (switcher); - icons_only = (switcher_style == GDL_SWITCHER_STYLE_ICON); - - /* Figure out the max width and height */ - optimal_layout_width = H_PADDING; - for (p = switcher->priv->buttons; p != NULL; p = p->next) { - GtkRequisition requisition; - - button = p->data; - gtk_widget_size_request (GTK_WIDGET (button->button_widget), - &requisition); - optimal_layout_width += requisition.width + H_PADDING; - max_btn_height = MAX (max_btn_height, requisition.height); - max_btn_width = MAX (max_btn_width, requisition.width); - } - - /* Figure out how many rows and columns we'll use. */ - btns_per_row = allocation.width / (max_btn_width + H_PADDING); - /* Use at least one column */ - if (btns_per_row == 0) btns_per_row = 1; - - /* If all the buttons could fit in the single row, have it so */ - if (allocation.width >= optimal_layout_width) - { - btns_per_row = num_btns; - } - if (!icons_only) { - /* If using text buttons, we want to try to have a - * completely filled-in grid, but if we can't, we want - * the odd row to have just a single button. - */ - while (num_btns % btns_per_row > 1) - btns_per_row--; - } - - rows_count = num_btns / btns_per_row; - if (num_btns % btns_per_row != 0) - rows_count++; - - /* Assign buttons to rows */ - rows = g_new0 (GSList *, rows_count); - - if (!icons_only && num_btns % btns_per_row != 0) { - button = switcher->priv->buttons->data; - rows [0] = g_slist_append (rows [0], button->button_widget); - - p = switcher->priv->buttons->next; - row_number = p ? 1 : 0; - } else { - p = switcher->priv->buttons; - row_number = 0; - } - - for (; p != NULL; p = p->next) { - button = p->data; - - if (g_slist_length (rows [row_number]) == btns_per_row) - row_number ++; - - rows [row_number] = g_slist_append (rows [row_number], - button->button_widget); - } - - row_last = row_number; - - /* If there are more than 1 row of buttons, save the current height - * requirement for subsequent size requests. - */ - if (row_last > 0) - { - switcher->priv->buttons_height_request = - (row_last + 1) * (max_btn_height + V_PADDING) + 1; - } else { /* Otherwize clear it */ - if (last_buttons_height >= 0) { - - switcher->priv->buttons_height_request = -1; - } - } - - /* If it turns out that we now require smaller height for the buttons - * than it was last time, make a resize request to ensure our - * size requisition is properly communicated to the parent (otherwise - * parent tend to keep assuming the older size). - */ - if (last_buttons_height > switcher->priv->buttons_height_request) - { - gtk_widget_queue_resize (GTK_WIDGET (switcher)); - y = -1; // set return value - } - else - { - /* Layout the buttons. */ - for (i = row_last; i >= 0; i --) { - int len, extra_width; - - y -= max_btn_height; - - /* Check for possible size over flow (taking into account client - * requisition - */ - if (y < (allocation.y + client_requisition.height)) { - /* We have an overflow: Insufficient allocation */ - if (last_buttons_height < switcher->priv->buttons_height_request) { - /* Request for a new resize */ - gtk_widget_queue_resize (GTK_WIDGET (switcher)); - y = -1; // set return value - goto exit; - } - } - x = H_PADDING + allocation.x; - len = g_slist_length (rows[i]); - if (switcher_style == GDL_SWITCHER_STYLE_TEXT || - switcher_style == GDL_SWITCHER_STYLE_BOTH) - extra_width = (allocation.width - (len * max_btn_width ) - - (len * H_PADDING)) / len; - else - extra_width = 0; - for (p = rows [i]; p != NULL; p = p->next) { - GtkAllocation child_allocation; - - child_allocation.x = x; - child_allocation.y = y; - if (rows_count == 1 && row_number == 0) - { - GtkRequisition child_requisition; - gtk_widget_size_request (GTK_WIDGET (p->data), - &child_requisition); - child_allocation.width = child_requisition.width; - } - else - { - child_allocation.width = max_btn_width + extra_width; - } - child_allocation.height = max_btn_height; - - gtk_widget_size_allocate (GTK_WIDGET (p->data), &child_allocation); - - x += child_allocation.width + H_PADDING; - } - - y -= V_PADDING; - } - } - - exit: - for (i = 0; i <= row_last; i ++) { - g_slist_free (rows [i]); - } - g_free (rows); - - return y; -} - -static void -do_layout (GdlSwitcher *switcher) -{ - GtkAllocation allocation; - GtkAllocation child_allocation; - int y; - - gtk_widget_get_allocation (GTK_WIDGET (switcher), &allocation); - - if (switcher->priv->show) { - y = layout_buttons (switcher); - if (y < 0) /* Layout did not happen and a resize was requested */ - return; - } - else - y = allocation.y + allocation.height; - - /* Place the parent widget. */ - child_allocation.x = allocation.x; - child_allocation.y = allocation.y; - child_allocation.width = allocation.width; - child_allocation.height = y - allocation.y; - - GTK_WIDGET_CLASS (gdl_switcher_parent_class)->size_allocate (GTK_WIDGET (switcher), &child_allocation); -} - -/* GtkContainer methods. */ - -static void -gdl_switcher_forall (GtkContainer *container, gboolean include_internals, - GtkCallback callback, void *callback_data) -{ - GdlSwitcher *switcher = - GDL_SWITCHER (container); - GSList *p; - - GTK_CONTAINER_CLASS (gdl_switcher_parent_class)->forall (GTK_CONTAINER (switcher), - include_internals, - callback, callback_data); - if (include_internals) { - for (p = switcher->priv->buttons; p != NULL; p = p->next) { - GtkWidget *widget = ((Button *) p->data)->button_widget; - (* callback) (widget, callback_data); - } - } -} - -static void -gdl_switcher_remove (GtkContainer *container, GtkWidget *widget) -{ - gint switcher_id; - GdlSwitcher *switcher = - GDL_SWITCHER (container); - GSList *p; - - switcher_id = gdl_switcher_get_page_id (widget); - for (p = switcher->priv->buttons; p != NULL; p = p->next) { - Button *b = (Button *) p->data; - - if (b->id == switcher_id) { - gtk_widget_unparent (b->button_widget); - switcher->priv->buttons = - g_slist_remove_link (switcher->priv->buttons, p); - button_free (b); - gtk_widget_queue_resize (GTK_WIDGET (switcher)); - break; - } - } - GTK_CONTAINER_CLASS (gdl_switcher_parent_class)->remove (GTK_CONTAINER (switcher), widget); -} - -/* GtkWidget methods. */ - -static void -gdl_switcher_size_request (GtkWidget *widget, GtkRequisition *requisition) -{ - GdlSwitcher *switcher = GDL_SWITCHER (widget); - GSList *p; - gint button_height = 0; - - GTK_WIDGET_CLASS (gdl_switcher_parent_class)->size_request (GTK_WIDGET (switcher), requisition); - - if (!switcher->priv->show) - return; - - for (p = switcher->priv->buttons; p != NULL; p = p->next) { - gint button_width; - Button *button = p->data; - GtkRequisition button_requisition; - - gtk_widget_size_request (button->button_widget, &button_requisition); - button_width = button_requisition.width + 2 * H_PADDING; - requisition->width = MAX (requisition->width, button_width); - button_height = MAX (button_height, - button_requisition.height + 2 * V_PADDING); - } - - if (switcher->priv->buttons_height_request > 0) { - requisition->height += switcher->priv->buttons_height_request; - } else { - requisition->height += button_height + V_PADDING; - } -} - -static void -gdl_switcher_size_allocate (GtkWidget *widget, GtkAllocation *allocation) -{ - gtk_widget_set_allocation (widget, allocation); - do_layout (GDL_SWITCHER (widget)); -} - -static gint -gdl_switcher_expose (GtkWidget *widget, GdkEventExpose *event) -{ - GSList *p; - GdlSwitcher *switcher = GDL_SWITCHER (widget); - if (switcher->priv->show) { - for (p = switcher->priv->buttons; p != NULL; p = p->next) { - GtkWidget *button = ((Button *) p->data)->button_widget; - gtk_container_propagate_expose (GTK_CONTAINER (widget), - button, event); - } - } - return GTK_WIDGET_CLASS (gdl_switcher_parent_class)->expose_event (widget, event); -} - -static void -gdl_switcher_map (GtkWidget *widget) -{ - GSList *p; - GdlSwitcher *switcher = GDL_SWITCHER (widget); - - if (switcher->priv->show) { - for (p = switcher->priv->buttons; p != NULL; p = p->next) { - GtkWidget *button = ((Button *) p->data)->button_widget; - gtk_widget_map (button); - } - } - GTK_WIDGET_CLASS (gdl_switcher_parent_class)->map (widget); -} - -/* GObject methods. */ - -static void -gdl_switcher_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) -{ - GdlSwitcher *switcher = GDL_SWITCHER (object); - - switch (prop_id) { - case PROP_SWITCHER_STYLE: - gdl_switcher_set_style (switcher, g_value_get_enum (value)); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -gdl_switcher_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) -{ - GdlSwitcher *switcher = GDL_SWITCHER (object); - - switch (prop_id) { - case PROP_SWITCHER_STYLE: - g_value_set_enum (value, gdl_switcher_get_style (switcher)); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -gdl_switcher_dispose (GObject *object) -{ - GdlSwitcherPrivate *priv = GDL_SWITCHER (object)->priv; - -#if HAVE_GNOME - GConfClient *gconf_client = gconf_client_get_default (); - - if (priv->style_changed_id) { - gconf_client_notify_remove (gconf_client, priv->style_changed_id); - priv->style_changed_id = 0; - } - g_object_unref (gconf_client); -#endif - - g_slist_foreach (priv->buttons, (GFunc) button_free, NULL); - g_slist_free (priv->buttons); - priv->buttons = NULL; - - G_OBJECT_CLASS (gdl_switcher_parent_class)->dispose (object); -} - -static void -gdl_switcher_finalize (GObject *object) -{ - GdlSwitcherPrivate *priv = GDL_SWITCHER (object)->priv; - - g_free (priv); - - G_OBJECT_CLASS (gdl_switcher_parent_class)->finalize (object); -} - -/* Signal handlers */ - -static void -gdl_switcher_notify_cb (GObject *g_object, GParamSpec *pspec, - GdlSwitcher *switcher) -{ -} - -static void -gdl_switcher_switch_page_cb (GtkNotebook *nb, GtkWidget *page_widget, - gint page_num, GdlSwitcher *switcher) -{ - gint switcher_id; - - /* Change switcher button */ - switcher_id = gdl_switcher_get_page_id (page_widget); - gdl_switcher_select_button (GDL_SWITCHER (switcher), switcher_id); -} - -static void -gdl_switcher_page_added_cb (GtkNotebook *nb, GtkWidget *page, - gint page_num, GdlSwitcher *switcher) -{ - gint switcher_id; - - (void)nb; - (void)page_num; - switcher_id = gdl_switcher_get_page_id (page); - - gdl_switcher_add_button (GDL_SWITCHER (switcher), NULL, NULL, NULL, NULL, - switcher_id, page); - gdl_switcher_select_button (GDL_SWITCHER (switcher), switcher_id); -} - -static void -gdl_switcher_select_page (GdlSwitcher *switcher, gint id) -{ - GList *children, *node; - children = gtk_container_get_children (GTK_CONTAINER (switcher)); - node = children; - while (node) - { - gint switcher_id; - switcher_id = gdl_switcher_get_page_id (GTK_WIDGET (node->data)); - if (switcher_id == id) - { - gint page_num; - page_num = gtk_notebook_page_num (GTK_NOTEBOOK (switcher), - GTK_WIDGET (node->data)); - g_signal_handlers_block_by_func (switcher, - gdl_switcher_switch_page_cb, - switcher); - gtk_notebook_set_current_page (GTK_NOTEBOOK (switcher), page_num); - g_signal_handlers_unblock_by_func (switcher, - gdl_switcher_switch_page_cb, - switcher); - break; - } - node = g_list_next (node); - } - g_list_free (children); -} - -/* Initialization. */ - -static void -gdl_switcher_class_init (GdlSwitcherClass *klass) -{ - GtkContainerClass *container_class = GTK_CONTAINER_CLASS (klass); - GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - container_class->forall = gdl_switcher_forall; - container_class->remove = gdl_switcher_remove; - - widget_class->size_request = gdl_switcher_size_request; - widget_class->size_allocate = gdl_switcher_size_allocate; - widget_class->expose_event = gdl_switcher_expose; - widget_class->map = gdl_switcher_map; - - object_class->dispose = gdl_switcher_dispose; - object_class->finalize = gdl_switcher_finalize; - object_class->set_property = gdl_switcher_set_property; - object_class->get_property = gdl_switcher_get_property; - - g_object_class_install_property ( - object_class, PROP_SWITCHER_STYLE, - g_param_spec_enum ("switcher-style", _("Switcher Style"), - _("Switcher buttons style"), - GDL_TYPE_SWITCHER_STYLE, - GDL_SWITCHER_STYLE_BOTH, - G_PARAM_READWRITE)); - - gtk_rc_parse_string ("style \"gdl-button-style\"\n" - "{\n" - "GtkWidget::focus-padding = 1\n" - "GtkWidget::focus-line-width = 1\n" - "xthickness = 0\n" - "ythickness = 0\n" - "}\n" - "widget \"*.gdl-button\" style \"gdl-button-style\""); -} - -static void -gdl_switcher_init (GdlSwitcher *switcher) -{ - GdlSwitcherPrivate *priv; - - gtk_widget_set_has_window (GTK_WIDGET (switcher), FALSE); - - priv = g_new0 (GdlSwitcherPrivate, 1); - switcher->priv = priv; - - priv->show = TRUE; - priv->buttons_height_request = -1; - - gtk_notebook_set_tab_pos (GTK_NOTEBOOK (switcher), GTK_POS_BOTTOM); - gtk_notebook_set_show_tabs (GTK_NOTEBOOK (switcher), FALSE); - gtk_notebook_set_show_border (GTK_NOTEBOOK (switcher), FALSE); - gdl_switcher_set_style (switcher, GDL_SWITCHER_STYLE_BOTH); - - /* notebook signals */ - g_signal_connect (switcher, "switch-page", - G_CALLBACK (gdl_switcher_switch_page_cb), switcher); - g_signal_connect (switcher, "page-added", - G_CALLBACK (gdl_switcher_page_added_cb), switcher); - g_signal_connect (switcher, "notify::show-tabs", - G_CALLBACK (gdl_switcher_notify_cb), switcher); -} - -GtkWidget * -gdl_switcher_new (void) -{ - GdlSwitcher *switcher = g_object_new (gdl_switcher_get_type (), NULL); - return GTK_WIDGET (switcher); -} - -static void -gdl_switcher_add_button (GdlSwitcher *switcher, const gchar *label, - const gchar *tooltips, const gchar *stock_id, - GdkPixbuf *pixbuf_icon, - gint switcher_id, GtkWidget* page) -{ - GtkWidget *button_widget; - GtkWidget *hbox; - GtkWidget *icon_widget; - GtkWidget *label_widget; - GtkWidget *arrow; - - button_widget = gtk_toggle_button_new (); - gtk_widget_set_name (button_widget, "gdl-button"); - gtk_button_set_relief (GTK_BUTTON(button_widget), GTK_RELIEF_HALF); - if (switcher->priv->show) - gtk_widget_show (button_widget); - g_signal_connect (button_widget, "toggled", - G_CALLBACK (button_toggled_callback), - switcher); - hbox = gtk_hbox_new (FALSE, 3); - gtk_container_set_border_width (GTK_CONTAINER (hbox), 0); - gtk_container_add (GTK_CONTAINER (button_widget), hbox); - gtk_widget_show (hbox); - - if (stock_id) { - icon_widget = gtk_image_new_from_stock (stock_id, GTK_ICON_SIZE_MENU); - } else if (pixbuf_icon) { - icon_widget = gtk_image_new_from_pixbuf (pixbuf_icon); - } else { - icon_widget = gtk_image_new_from_stock (GTK_STOCK_NEW, GTK_ICON_SIZE_MENU); - } - - gtk_widget_show (icon_widget); - - if (!label) { - gchar *text = g_strdup_printf ("Item %d", switcher_id); - label_widget = gtk_label_new (text); - g_free (text); - } else { - label_widget = gtk_label_new (label); - } - gtk_misc_set_alignment (GTK_MISC (label_widget), 0.0, 0.5); - gtk_widget_show (label_widget); - - - gtk_widget_set_tooltip_text (button_widget, - tooltips); - - switch (INTERNAL_MODE (switcher)) { - case GDL_SWITCHER_STYLE_TEXT: - gtk_box_pack_start (GTK_BOX (hbox), label_widget, TRUE, TRUE, 0); - break; - case GDL_SWITCHER_STYLE_ICON: - gtk_box_pack_start (GTK_BOX (hbox), icon_widget, TRUE, TRUE, 0); - break; - case GDL_SWITCHER_STYLE_BOTH: - default: - gtk_box_pack_start (GTK_BOX (hbox), icon_widget, FALSE, TRUE, 0); - gtk_box_pack_start (GTK_BOX (hbox), label_widget, TRUE, TRUE, 0); - break; - } - arrow = gtk_arrow_new (GTK_ARROW_UP, GTK_SHADOW_NONE); - gtk_widget_show (arrow); - gtk_box_pack_start (GTK_BOX (hbox), arrow, FALSE, FALSE, 0); - - switcher->priv->buttons = - g_slist_append (switcher->priv->buttons, - button_new (button_widget, label_widget, - icon_widget, - arrow, hbox, switcher_id, page)); - - gtk_widget_set_parent (button_widget, GTK_WIDGET (switcher)); - gtk_widget_queue_resize (GTK_WIDGET (switcher)); -} - -#if 0 -static void -gdl_switcher_remove_button (GdlSwitcher *switcher, gint switcher_id) -{ - GSList *p; - - for (p = switcher->priv->buttons; p != NULL; p = p->next) { - Button *button = p->data; - - if (button->id == switcher_id) - { - gtk_container_remove (GTK_CONTAINER (switcher), - button->button_widget); - break; - } - } - gtk_widget_queue_resize (GTK_WIDGET (switcher)); -} -#endif - -static void -gdl_switcher_select_button (GdlSwitcher *switcher, gint switcher_id) -{ - update_buttons (switcher, switcher_id); - - /* Select the notebook page associated with this button */ - gdl_switcher_select_page (switcher, switcher_id); -} - - -gint -gdl_switcher_insert_page (GdlSwitcher *switcher, GtkWidget *page, - GtkWidget *tab_widget, const gchar *label, - const gchar *tooltips, const gchar *stock_id, - GdkPixbuf *pixbuf_icon, gint position) -{ - gint ret_position; - gint switcher_id; - g_signal_handlers_block_by_func (switcher, - gdl_switcher_page_added_cb, - switcher); - - if (!tab_widget) { - tab_widget = gtk_label_new (label); - gtk_widget_show (tab_widget); - } - switcher_id = gdl_switcher_get_page_id (page); - gdl_switcher_add_button (switcher, label, tooltips, stock_id, pixbuf_icon, switcher_id, page); - - ret_position = gtk_notebook_insert_page (GTK_NOTEBOOK (switcher), page, - tab_widget, position); - g_signal_handlers_unblock_by_func (switcher, - gdl_switcher_page_added_cb, - switcher); - - return ret_position; -} - -static void -set_switcher_style_toolbar (GdlSwitcher *switcher, - GdlSwitcherStyle switcher_style) -{ - GSList *p; - - if (switcher_style == GDL_SWITCHER_STYLE_NONE - || switcher_style == GDL_SWITCHER_STYLE_TABS) - return; - - if (switcher_style == GDL_SWITCHER_STYLE_TOOLBAR) - switcher_style = GDL_SWITCHER_STYLE_BOTH; - - if (switcher_style == INTERNAL_MODE (switcher)) - return; - - gtk_notebook_set_show_tabs (GTK_NOTEBOOK (switcher), FALSE); - - for (p = switcher->priv->buttons; p != NULL; p = p->next) { - Button *button = p->data; - - gtk_container_remove (GTK_CONTAINER (button->hbox), button->arrow); - - if (gtk_widget_get_parent (button->icon)) - gtk_container_remove (GTK_CONTAINER (button->hbox), button->icon); - if (gtk_widget_get_parent (button->label)) - gtk_container_remove (GTK_CONTAINER (button->hbox), button->label); - - switch (switcher_style) { - case GDL_SWITCHER_STYLE_TEXT: - gtk_box_pack_start (GTK_BOX (button->hbox), button->label, - TRUE, TRUE, 0); - gtk_widget_show (button->label); - break; - - case GDL_SWITCHER_STYLE_ICON: - gtk_box_pack_start (GTK_BOX (button->hbox), button->icon, - TRUE, TRUE, 0); - gtk_widget_show (button->icon); - break; - - case GDL_SWITCHER_STYLE_BOTH: - gtk_box_pack_start (GTK_BOX (button->hbox), button->icon, - FALSE, TRUE, 0); - gtk_box_pack_start (GTK_BOX (button->hbox), button->label, - TRUE, TRUE, 0); - gtk_widget_show (button->icon); - gtk_widget_show (button->label); - break; - - default: - break; - } - - gtk_box_pack_start (GTK_BOX (button->hbox), button->arrow, - FALSE, FALSE, 0); - } - - gdl_switcher_set_show_buttons (switcher, TRUE); -} - -static void -gdl_switcher_set_style (GdlSwitcher *switcher, GdlSwitcherStyle switcher_style) -{ - if (switcher->priv->switcher_style == switcher_style) - return; - - if (switcher_style == GDL_SWITCHER_STYLE_NONE) { - gdl_switcher_set_show_buttons (switcher, FALSE); - gtk_notebook_set_show_tabs (GTK_NOTEBOOK (switcher), FALSE); - } - else if (switcher_style == GDL_SWITCHER_STYLE_TABS) { - gdl_switcher_set_show_buttons (switcher, FALSE); - gtk_notebook_set_show_tabs (GTK_NOTEBOOK (switcher), TRUE); - } - else - set_switcher_style_toolbar (switcher, switcher_style); - - gtk_widget_queue_resize (GTK_WIDGET (switcher)); - switcher->priv->switcher_style = switcher_style; -} - -static void -gdl_switcher_set_show_buttons (GdlSwitcher *switcher, gboolean show) -{ - GSList *p; - - if (switcher->priv->show == show) - return; - - for (p = switcher->priv->buttons; p != NULL; p = p->next) { - Button *button = p->data; - - if (show) - gtk_widget_show (button->button_widget); - else - gtk_widget_hide (button->button_widget); - } - - switcher->priv->show = show; - - gtk_widget_queue_resize (GTK_WIDGET (switcher)); -} - -static GdlSwitcherStyle -gdl_switcher_get_style (GdlSwitcher *switcher) -{ - if (!switcher->priv->show) - return GDL_SWITCHER_STYLE_TABS; - return switcher->priv->switcher_style; -} diff --git a/src/libgdl/gdl-switcher.h b/src/libgdl/gdl-switcher.h deleted file mode 100644 index 0caf3a0aa..000000000 --- a/src/libgdl/gdl-switcher.h +++ /dev/null @@ -1,67 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4; tab-width: 8 -*- */ -/* gdl-switcher.h - * - * Copyright (C) 2003 Ettore Perazzoli - * 2007 Naba Kumar - * -* This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * - * Authors: Ettore Perazzoli <ettore@ximian.com> - * Naba Kumar <naba@gnome.org> - */ - -#ifndef _GDL_SWITCHER_H_ -#define _GDL_SWITCHER_H_ - -#include <gtk/gtk.h> - -G_BEGIN_DECLS - -#define GDL_TYPE_SWITCHER (gdl_switcher_get_type ()) -#define GDL_SWITCHER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GDL_TYPE_SWITCHER, GdlSwitcher)) -#define GDL_SWITCHER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDL_TYPE_SWITCHER, GdlSwitcherClass)) -#define GDL_IS_SWITCHER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GDL_TYPE_SWITCHER)) -#define GDL_IS_SWITCHER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), GDL_TYPE_SWITCHER)) - -typedef struct _GdlSwitcher GdlSwitcher; -typedef struct _GdlSwitcherPrivate GdlSwitcherPrivate; -typedef struct _GdlSwitcherClass GdlSwitcherClass; - -struct _GdlSwitcher { - GtkNotebook parent; - - GdlSwitcherPrivate *priv; -}; - -struct _GdlSwitcherClass { - GtkNotebookClass parent_class; -}; - -GType gdl_switcher_get_type (void); -GtkWidget *gdl_switcher_new (void); - -gint gdl_switcher_insert_page (GdlSwitcher *switcher, - GtkWidget *page, - GtkWidget *tab_widget, - const gchar *label, - const gchar *tooltips, - const gchar *stock_id, - GdkPixbuf *pixbuf_icon, - gint position); -G_END_DECLS - -#endif /* _GDL_SWITCHER_H_ */ diff --git a/src/libgdl/gdl-win32.c b/src/libgdl/gdl-win32.c deleted file mode 100644 index f23036ed6..000000000 --- a/src/libgdl/gdl-win32.c +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Windows stuff - * - * Author: - * Albin Sunnanbo - * Based on code by Lauris Kaplinski <lauris@kaplinski.com> (/src/extension/internal/win32.cpp) - * - * This code is in public domain - */ -#ifdef WIN32 - -#include "gdl-win32.h" -#include <windows.h> - -/* Platform detection */ -gboolean -is_os_vista() -{ - static gboolean initialized = FALSE; - static gboolean is_vista = FALSE; - static OSVERSIONINFOA osver; - - if ( !initialized ) - { - BOOL result; - - initialized = TRUE; - - memset (&osver, 0, sizeof(OSVERSIONINFOA)); - osver.dwOSVersionInfoSize = sizeof(OSVERSIONINFOA); - result = GetVersionExA (&osver); - if (result) - { - if (osver.dwMajorVersion == WIN32_MAJORVERSION_VISTA) - is_vista = TRUE; - } - } - - return is_vista; -} - -#endif diff --git a/src/libgdl/gdl-win32.h b/src/libgdl/gdl-win32.h deleted file mode 100644 index 90c0cbafa..000000000 --- a/src/libgdl/gdl-win32.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Windows stuff - * - * Author: - * Albin Sunnanbo - * - * This code is in public domain - */ -#ifndef __INKSCAPE_GDL_WIN32_H__ -#define __INKSCAPE_GDL_WIN32_H__ -#ifdef WIN32 - -#include <gdk/gdk.h> - -#define WIN32_MAJORVERSION_VISTA 0x0006 - -/* Platform detection */ -gboolean is_os_vista(); - -#endif // ifdef WIN32 -#endif /* __INKSCAPE_GDL_WIN32_H__ */ diff --git a/src/libgdl/gdl.h b/src/libgdl/gdl.h deleted file mode 100644 index 235c5e3eb..000000000 --- a/src/libgdl/gdl.h +++ /dev/null @@ -1,32 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This file is part of the GNOME Devtools Libraries. - * - * Copyright (C) 1999-2000 Dave Camp <dave@helixcode.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef __GDL_H__ -#define __GDL_H__ - -#include "libgdl/gdl-dock-object.h" -#include "libgdl/gdl-dock-master.h" -#include "libgdl/gdl-dock.h" -#include "libgdl/gdl-dock-item.h" -#include "libgdl/gdl-dock-item-grip.h" -#include "libgdl/gdl-dock-bar.h" - -#endif diff --git a/src/libgdl/libgdlmarshal.c b/src/libgdl/libgdlmarshal.c deleted file mode 100644 index a2a9fe220..000000000 --- a/src/libgdl/libgdlmarshal.c +++ /dev/null @@ -1,173 +0,0 @@ -#include "libgdlmarshal.h" - -#include <glib-object.h> - - -#ifdef G_ENABLE_DEBUG -#define g_marshal_value_peek_boolean(v) g_value_get_boolean (v) -#define g_marshal_value_peek_char(v) g_value_get_char (v) -#define g_marshal_value_peek_uchar(v) g_value_get_uchar (v) -#define g_marshal_value_peek_int(v) g_value_get_int (v) -#define g_marshal_value_peek_uint(v) g_value_get_uint (v) -#define g_marshal_value_peek_long(v) g_value_get_long (v) -#define g_marshal_value_peek_ulong(v) g_value_get_ulong (v) -#define g_marshal_value_peek_int64(v) g_value_get_int64 (v) -#define g_marshal_value_peek_uint64(v) g_value_get_uint64 (v) -#define g_marshal_value_peek_enum(v) g_value_get_enum (v) -#define g_marshal_value_peek_flags(v) g_value_get_flags (v) -#define g_marshal_value_peek_float(v) g_value_get_float (v) -#define g_marshal_value_peek_double(v) g_value_get_double (v) -#define g_marshal_value_peek_string(v) (char*) g_value_get_string (v) -#define g_marshal_value_peek_param(v) g_value_get_param (v) -#define g_marshal_value_peek_boxed(v) g_value_get_boxed (v) -#define g_marshal_value_peek_pointer(v) g_value_get_pointer (v) -#define g_marshal_value_peek_object(v) g_value_get_object (v) -#define g_marshal_value_peek_variant(v) g_value_get_variant (v) -#else /* !G_ENABLE_DEBUG */ -/* WARNING: This code accesses GValues directly, which is UNSUPPORTED API. - * Do not access GValues directly in your code. Instead, use the - * g_value_get_*() functions - */ -#define g_marshal_value_peek_boolean(v) (v)->data[0].v_int -#define g_marshal_value_peek_char(v) (v)->data[0].v_int -#define g_marshal_value_peek_uchar(v) (v)->data[0].v_uint -#define g_marshal_value_peek_int(v) (v)->data[0].v_int -#define g_marshal_value_peek_uint(v) (v)->data[0].v_uint -#define g_marshal_value_peek_long(v) (v)->data[0].v_long -#define g_marshal_value_peek_ulong(v) (v)->data[0].v_ulong -#define g_marshal_value_peek_int64(v) (v)->data[0].v_int64 -#define g_marshal_value_peek_uint64(v) (v)->data[0].v_uint64 -#define g_marshal_value_peek_enum(v) (v)->data[0].v_long -#define g_marshal_value_peek_flags(v) (v)->data[0].v_ulong -#define g_marshal_value_peek_float(v) (v)->data[0].v_float -#define g_marshal_value_peek_double(v) (v)->data[0].v_double -#define g_marshal_value_peek_string(v) (v)->data[0].v_pointer -#define g_marshal_value_peek_param(v) (v)->data[0].v_pointer -#define g_marshal_value_peek_boxed(v) (v)->data[0].v_pointer -#define g_marshal_value_peek_pointer(v) (v)->data[0].v_pointer -#define g_marshal_value_peek_object(v) (v)->data[0].v_pointer -#define g_marshal_value_peek_variant(v) (v)->data[0].v_pointer -#endif /* !G_ENABLE_DEBUG */ - - -/* VOID:VOID (./libgdlmarshal.list:1) */ - -/* VOID:ENUM (./libgdlmarshal.list:2) */ - -/* VOID:INT,INT (./libgdlmarshal.list:3) */ -void -gdl_marshal_VOID__INT_INT (GClosure *closure, - GValue *return_value G_GNUC_UNUSED, - guint n_param_values, - const GValue *param_values, - gpointer invocation_hint G_GNUC_UNUSED, - gpointer marshal_data) -{ - typedef void (*GMarshalFunc_VOID__INT_INT) (gpointer data1, - gint arg_1, - gint arg_2, - gpointer data2); - register GMarshalFunc_VOID__INT_INT callback; - register GCClosure *cc = (GCClosure*) closure; - register gpointer data1, data2; - - g_return_if_fail (n_param_values == 3); - - if (G_CCLOSURE_SWAP_DATA (closure)) - { - data1 = closure->data; - data2 = g_value_peek_pointer (param_values + 0); - } - else - { - data1 = g_value_peek_pointer (param_values + 0); - data2 = closure->data; - } - callback = (GMarshalFunc_VOID__INT_INT) (marshal_data ? marshal_data : cc->callback); - - callback (data1, - g_marshal_value_peek_int (param_values + 1), - g_marshal_value_peek_int (param_values + 2), - data2); -} - -/* VOID:UINT,UINT (./libgdlmarshal.list:4) */ -void -gdl_marshal_VOID__UINT_UINT (GClosure *closure, - GValue *return_value G_GNUC_UNUSED, - guint n_param_values, - const GValue *param_values, - gpointer invocation_hint G_GNUC_UNUSED, - gpointer marshal_data) -{ - typedef void (*GMarshalFunc_VOID__UINT_UINT) (gpointer data1, - guint arg_1, - guint arg_2, - gpointer data2); - register GMarshalFunc_VOID__UINT_UINT callback; - register GCClosure *cc = (GCClosure*) closure; - register gpointer data1, data2; - - g_return_if_fail (n_param_values == 3); - - if (G_CCLOSURE_SWAP_DATA (closure)) - { - data1 = closure->data; - data2 = g_value_peek_pointer (param_values + 0); - } - else - { - data1 = g_value_peek_pointer (param_values + 0); - data2 = closure->data; - } - callback = (GMarshalFunc_VOID__UINT_UINT) (marshal_data ? marshal_data : cc->callback); - - callback (data1, - g_marshal_value_peek_uint (param_values + 1), - g_marshal_value_peek_uint (param_values + 2), - data2); -} - -/* VOID:BOOLEAN (./libgdlmarshal.list:5) */ - -/* VOID:OBJECT,ENUM,BOXED (./libgdlmarshal.list:6) */ -void -gdl_marshal_VOID__OBJECT_ENUM_BOXED (GClosure *closure, - GValue *return_value G_GNUC_UNUSED, - guint n_param_values, - const GValue *param_values, - gpointer invocation_hint G_GNUC_UNUSED, - gpointer marshal_data) -{ - typedef void (*GMarshalFunc_VOID__OBJECT_ENUM_BOXED) (gpointer data1, - gpointer arg_1, - gint arg_2, - gpointer arg_3, - gpointer data2); - register GMarshalFunc_VOID__OBJECT_ENUM_BOXED callback; - register GCClosure *cc = (GCClosure*) closure; - register gpointer data1, data2; - - g_return_if_fail (n_param_values == 4); - - if (G_CCLOSURE_SWAP_DATA (closure)) - { - data1 = closure->data; - data2 = g_value_peek_pointer (param_values + 0); - } - else - { - data1 = g_value_peek_pointer (param_values + 0); - data2 = closure->data; - } - callback = (GMarshalFunc_VOID__OBJECT_ENUM_BOXED) (marshal_data ? marshal_data : cc->callback); - - callback (data1, - g_marshal_value_peek_object (param_values + 1), - g_marshal_value_peek_enum (param_values + 2), - g_marshal_value_peek_boxed (param_values + 3), - data2); -} - -/* VOID:BOXED (./libgdlmarshal.list:7) */ - diff --git a/src/libgdl/libgdlmarshal.h b/src/libgdl/libgdlmarshal.h deleted file mode 100644 index 2d6bc800f..000000000 --- a/src/libgdl/libgdlmarshal.h +++ /dev/null @@ -1,48 +0,0 @@ - -#ifndef __gdl_marshal_MARSHAL_H__ -#define __gdl_marshal_MARSHAL_H__ - -#include <glib-object.h> - -G_BEGIN_DECLS - -/* VOID:VOID (./libgdlmarshal.list:1) */ -#define gdl_marshal_VOID__VOID g_cclosure_marshal_VOID__VOID - -/* VOID:ENUM (./libgdlmarshal.list:2) */ -#define gdl_marshal_VOID__ENUM g_cclosure_marshal_VOID__ENUM - -/* VOID:INT,INT (./libgdlmarshal.list:3) */ -extern void gdl_marshal_VOID__INT_INT (GClosure *closure, - GValue *return_value, - guint n_param_values, - const GValue *param_values, - gpointer invocation_hint, - gpointer marshal_data); - -/* VOID:UINT,UINT (./libgdlmarshal.list:4) */ -extern void gdl_marshal_VOID__UINT_UINT (GClosure *closure, - GValue *return_value, - guint n_param_values, - const GValue *param_values, - gpointer invocation_hint, - gpointer marshal_data); - -/* VOID:BOOLEAN (./libgdlmarshal.list:5) */ -#define gdl_marshal_VOID__BOOLEAN g_cclosure_marshal_VOID__BOOLEAN - -/* VOID:OBJECT,ENUM,BOXED (./libgdlmarshal.list:6) */ -extern void gdl_marshal_VOID__OBJECT_ENUM_BOXED (GClosure *closure, - GValue *return_value, - guint n_param_values, - const GValue *param_values, - gpointer invocation_hint, - gpointer marshal_data); - -/* VOID:BOXED (./libgdlmarshal.list:7) */ -#define gdl_marshal_VOID__BOXED g_cclosure_marshal_VOID__BOXED - -G_END_DECLS - -#endif /* __gdl_marshal_MARSHAL_H__ */ - diff --git a/src/libgdl/libgdlmarshal.list b/src/libgdl/libgdlmarshal.list deleted file mode 100644 index 750989abc..000000000 --- a/src/libgdl/libgdlmarshal.list +++ /dev/null @@ -1,7 +0,0 @@ -VOID:VOID -VOID:ENUM -VOID:INT,INT -VOID:UINT,UINT -VOID:BOOLEAN -VOID:OBJECT,ENUM,BOXED -VOID:BOXED diff --git a/src/libgdl/libgdltypebuiltins.c b/src/libgdl/libgdltypebuiltins.c deleted file mode 100644 index b347fe6f5..000000000 --- a/src/libgdl/libgdltypebuiltins.c +++ /dev/null @@ -1,162 +0,0 @@ - - - -#include <glib-object.h> -#include "libgdltypebuiltins.h" - - -/* enumerations from "gdl-dock-object.h" */ -static const GFlagsValue _gdl_dock_param_flags_values[] = { - { GDL_DOCK_PARAM_EXPORT, "GDL_DOCK_PARAM_EXPORT", "export" }, - { GDL_DOCK_PARAM_AFTER, "GDL_DOCK_PARAM_AFTER", "after" }, - { 0, NULL, NULL } -}; - -GType -gdl_dock_param_flags_get_type (void) -{ - static GType type = 0; - - if (!type) - type = g_flags_register_static ("GdlDockParamFlags", _gdl_dock_param_flags_values); - - return type; -} - -static const GFlagsValue _gdl_dock_object_flags_values[] = { - { GDL_DOCK_AUTOMATIC, "GDL_DOCK_AUTOMATIC", "automatic" }, - { GDL_DOCK_ATTACHED, "GDL_DOCK_ATTACHED", "attached" }, - { GDL_DOCK_IN_REFLOW, "GDL_DOCK_IN_REFLOW", "in-reflow" }, - { GDL_DOCK_IN_DETACH, "GDL_DOCK_IN_DETACH", "in-detach" }, - { 0, NULL, NULL } -}; - -GType -gdl_dock_object_flags_get_type (void) -{ - static GType type = 0; - - if (!type) - type = g_flags_register_static ("GdlDockObjectFlags", _gdl_dock_object_flags_values); - - return type; -} - -static const GEnumValue _gdl_dock_placement_values[] = { - { GDL_DOCK_NONE, "GDL_DOCK_NONE", "none" }, - { GDL_DOCK_TOP, "GDL_DOCK_TOP", "top" }, - { GDL_DOCK_BOTTOM, "GDL_DOCK_BOTTOM", "bottom" }, - { GDL_DOCK_RIGHT, "GDL_DOCK_RIGHT", "right" }, - { GDL_DOCK_LEFT, "GDL_DOCK_LEFT", "left" }, - { GDL_DOCK_CENTER, "GDL_DOCK_CENTER", "center" }, - { GDL_DOCK_FLOATING, "GDL_DOCK_FLOATING", "floating" }, - { 0, NULL, NULL } -}; - -GType -gdl_dock_placement_get_type (void) -{ - static GType type = 0; - - if (!type) - type = g_enum_register_static ("GdlDockPlacement", _gdl_dock_placement_values); - - return type; -} - - -/* enumerations from "gdl-dock-master.h" */ -static const GEnumValue _gdl_switcher_style_values[] = { - { GDL_SWITCHER_STYLE_TEXT, "GDL_SWITCHER_STYLE_TEXT", "text" }, - { GDL_SWITCHER_STYLE_ICON, "GDL_SWITCHER_STYLE_ICON", "icon" }, - { GDL_SWITCHER_STYLE_BOTH, "GDL_SWITCHER_STYLE_BOTH", "both" }, - { GDL_SWITCHER_STYLE_TOOLBAR, "GDL_SWITCHER_STYLE_TOOLBAR", "toolbar" }, - { GDL_SWITCHER_STYLE_TABS, "GDL_SWITCHER_STYLE_TABS", "tabs" }, - { GDL_SWITCHER_STYLE_NONE, "GDL_SWITCHER_STYLE_NONE", "none" }, - { 0, NULL, NULL } -}; - -GType -gdl_switcher_style_get_type (void) -{ - static GType type = 0; - - if (!type) - type = g_enum_register_static ("GdlSwitcherStyle", _gdl_switcher_style_values); - - return type; -} - - -/* enumerations from "gdl-dock-item.h" */ -static const GFlagsValue _gdl_dock_item_behavior_values[] = { - { GDL_DOCK_ITEM_BEH_NORMAL, "GDL_DOCK_ITEM_BEH_NORMAL", "normal" }, - { GDL_DOCK_ITEM_BEH_NEVER_FLOATING, "GDL_DOCK_ITEM_BEH_NEVER_FLOATING", "never-floating" }, - { GDL_DOCK_ITEM_BEH_NEVER_VERTICAL, "GDL_DOCK_ITEM_BEH_NEVER_VERTICAL", "never-vertical" }, - { GDL_DOCK_ITEM_BEH_NEVER_HORIZONTAL, "GDL_DOCK_ITEM_BEH_NEVER_HORIZONTAL", "never-horizontal" }, - { GDL_DOCK_ITEM_BEH_LOCKED, "GDL_DOCK_ITEM_BEH_LOCKED", "locked" }, - { GDL_DOCK_ITEM_BEH_CANT_DOCK_TOP, "GDL_DOCK_ITEM_BEH_CANT_DOCK_TOP", "cant-dock-top" }, - { GDL_DOCK_ITEM_BEH_CANT_DOCK_BOTTOM, "GDL_DOCK_ITEM_BEH_CANT_DOCK_BOTTOM", "cant-dock-bottom" }, - { GDL_DOCK_ITEM_BEH_CANT_DOCK_LEFT, "GDL_DOCK_ITEM_BEH_CANT_DOCK_LEFT", "cant-dock-left" }, - { GDL_DOCK_ITEM_BEH_CANT_DOCK_RIGHT, "GDL_DOCK_ITEM_BEH_CANT_DOCK_RIGHT", "cant-dock-right" }, - { GDL_DOCK_ITEM_BEH_CANT_DOCK_CENTER, "GDL_DOCK_ITEM_BEH_CANT_DOCK_CENTER", "cant-dock-center" }, - { GDL_DOCK_ITEM_BEH_CANT_CLOSE, "GDL_DOCK_ITEM_BEH_CANT_CLOSE", "cant-close" }, - { GDL_DOCK_ITEM_BEH_CANT_ICONIFY, "GDL_DOCK_ITEM_BEH_CANT_ICONIFY", "cant-iconify" }, - { GDL_DOCK_ITEM_BEH_NO_GRIP, "GDL_DOCK_ITEM_BEH_NO_GRIP", "no-grip" }, - { 0, NULL, NULL } -}; - -GType -gdl_dock_item_behavior_get_type (void) -{ - static GType type = 0; - - if (!type) - type = g_flags_register_static ("GdlDockItemBehavior", _gdl_dock_item_behavior_values); - - return type; -} - -static const GFlagsValue _gdl_dock_item_flags_values[] = { - { GDL_DOCK_IN_DRAG, "GDL_DOCK_IN_DRAG", "in-drag" }, - { GDL_DOCK_IN_PREDRAG, "GDL_DOCK_IN_PREDRAG", "in-predrag" }, - { GDL_DOCK_ICONIFIED, "GDL_DOCK_ICONIFIED", "iconified" }, - { GDL_DOCK_USER_ACTION, "GDL_DOCK_USER_ACTION", "user-action" }, - { 0, NULL, NULL } -}; - -GType -gdl_dock_item_flags_get_type (void) -{ - static GType type = 0; - - if (!type) - type = g_flags_register_static ("GdlDockItemFlags", _gdl_dock_item_flags_values); - - return type; -} - - -/* enumerations from "gdl-dock-bar.h" */ -static const GEnumValue _gdl_dock_bar_style_values[] = { - { GDL_DOCK_BAR_ICONS, "GDL_DOCK_BAR_ICONS", "icons" }, - { GDL_DOCK_BAR_TEXT, "GDL_DOCK_BAR_TEXT", "text" }, - { GDL_DOCK_BAR_BOTH, "GDL_DOCK_BAR_BOTH", "both" }, - { GDL_DOCK_BAR_AUTO, "GDL_DOCK_BAR_AUTO", "auto" }, - { 0, NULL, NULL } -}; - -GType -gdl_dock_bar_style_get_type (void) -{ - static GType type = 0; - - if (!type) - type = g_enum_register_static ("GdlDockBarStyle", _gdl_dock_bar_style_values); - - return type; -} - - - - diff --git a/src/libgdl/libgdltypebuiltins.h b/src/libgdl/libgdltypebuiltins.h deleted file mode 100644 index 19eac4989..000000000 --- a/src/libgdl/libgdltypebuiltins.h +++ /dev/null @@ -1,38 +0,0 @@ - - - -#ifndef __LIBGDLTYPEBUILTINS_H__ -#define __LIBGDLTYPEBUILTINS_H__ 1 - -#include "libgdl/gdl.h" - -G_BEGIN_DECLS - - -/* --- gdl-dock-object.h --- */ -#define GDL_TYPE_DOCK_PARAM_FLAGS gdl_dock_param_flags_get_type() -GType gdl_dock_param_flags_get_type (void); -#define GDL_TYPE_DOCK_OBJECT_FLAGS gdl_dock_object_flags_get_type() -GType gdl_dock_object_flags_get_type (void); -#define GDL_TYPE_DOCK_PLACEMENT gdl_dock_placement_get_type() -GType gdl_dock_placement_get_type (void); - -/* --- gdl-dock-master.h --- */ -#define GDL_TYPE_SWITCHER_STYLE gdl_switcher_style_get_type() -GType gdl_switcher_style_get_type (void); - -/* --- gdl-dock-item.h --- */ -#define GDL_TYPE_DOCK_ITEM_BEHAVIOR gdl_dock_item_behavior_get_type() -GType gdl_dock_item_behavior_get_type (void); -#define GDL_TYPE_DOCK_ITEM_FLAGS gdl_dock_item_flags_get_type() -GType gdl_dock_item_flags_get_type (void); - -/* --- gdl-dock-bar.h --- */ -#define GDL_TYPE_DOCK_BAR_STYLE gdl_dock_bar_style_get_type() -GType gdl_dock_bar_style_get_type (void); -G_END_DECLS - -#endif /* __LIBGDLTYPEBUILTINS_H__ */ - - - diff --git a/src/libgdl/makefile.in b/src/libgdl/makefile.in deleted file mode 100644 index 9dc8cb2ca..000000000 --- a/src/libgdl/makefile.in +++ /dev/null @@ -1,17 +0,0 @@ -# Convenience stub makefile to call the real Makefile. - -@SET_MAKE@ - -OBJEXT = @OBJEXT@ - -# Explicit so that it's the default rule. -all: - cd .. && $(MAKE) libgdl/all - -clean %.a %.$(OBJEXT): - cd .. && $(MAKE) libgdl/$@ - -.PHONY: all clean - -.SUFFIXES: -.SUFFIXES: .a .$(OBJEXT) diff --git a/src/libnrtype/FontFactory.cpp b/src/libnrtype/FontFactory.cpp index 65eb62dda..6865e923e 100644 --- a/src/libnrtype/FontFactory.cpp +++ b/src/libnrtype/FontFactory.cpp @@ -24,6 +24,9 @@ #include "util/unordered-containers.h" #include <map> +#include <harfbuzz/hb-ft.h> +#include <harfbuzz/hb-ot.h> + typedef INK_UNORDERED_MAP<PangoFontDescription*, font_instance*, font_descr_hash, font_descr_equal> FaceMapType; // need to avoid using the size field @@ -99,7 +102,6 @@ font_factory::font_factory(void) : fontSize(512), loadedPtr(new FaceMapType()) { - // std::cout << pango_version_string() << std::endl; #ifdef USE_PANGO_WIN32 #else pango_ft2_font_map_set_resolution(PANGO_FT2_FONT_MAP(fontServer), @@ -293,6 +295,7 @@ void font_factory::GetUIFamilies(std::vector<PangoFontFamily *>& out) const char* displayName = pango_font_family_get_name(families[currentFamily]); if (displayName == 0 || *displayName == '\0') { + std::cerr << "font_factory::GetUIFamilies: Missing displayName! " << std::endl; continue; } sorted.push_back(std::make_pair(families[currentFamily], displayName)); @@ -311,6 +314,10 @@ GList* font_factory::GetUIStyles(PangoFontFamily * in) // Gather the styles for this family PangoFontFace** faces = NULL; int numFaces = 0; + if (in == NULL) { + std::cerr << "font_factory::GetUIStyles(): PangoFontFamily is NULL" << std::endl; + return ret; + } pango_font_family_list_faces(in, &faces, &numFaces); for (int currentFace = 0; currentFace < numFaces; currentFace++) { @@ -320,6 +327,7 @@ GList* font_factory::GetUIStyles(PangoFontFamily * in) const gchar* displayName = pango_font_face_get_face_name(faces[currentFace]); // std::cout << "Display Name: " << displayName << std::endl; if (displayName == NULL || *displayName == '\0') { + std::cerr << "font_factory::GetUIStyles: Missing displayName! " << std::endl; continue; } @@ -593,13 +601,15 @@ font_instance* font_factory::FaceFromFontSpecification(char const *fontSpecifica return font; } -void dump_tag( guint32 *tag, Glib::ustring prefix = "" ) { +void dump_tag( guint32 *tag, Glib::ustring prefix = "", bool lf=true ) { std::cout << prefix << ((char)((*tag & 0xff000000)>>24)) << ((char)((*tag & 0x00ff0000)>>16)) << ((char)((*tag & 0x0000ff00)>>8)) - << ((char)((*tag & 0x000000ff)>>0)) - << std::endl; + << ((char)((*tag & 0x000000ff)>>0)); + if( lf ) { + std::cout << std::endl; + } } Glib::ustring extract_tag( guint32 *tag ) { @@ -677,74 +687,61 @@ font_instance *font_factory::Face(PangoFontDescription *descr, bool canFail) } // Extract which OpenType tables are in the font. We'll make a list of all tables - // regardless of which script and langauge they are in. These functions are deprecated but - // will eventually be replaced by newer functions (according to Behdad). - PangoOTInfo* info = pango_ot_info_get( res->theFace ); - - PangoOTTag* scripts = pango_ot_info_list_scripts( info, PANGO_OT_TABLE_GSUB ); - // std::cout << " scripts: " << std::endl; - for( unsigned i = 0; scripts[i] != 0; ++i ) { - // dump_tag( &scripts[i], " " ); - - guint script_index = -1; - if( pango_ot_info_find_script( info, PANGO_OT_TABLE_GSUB, scripts[i], &script_index )) { - - PangoOTTag* languages = - pango_ot_info_list_languages( info, PANGO_OT_TABLE_GSUB, script_index, NULL); - // if( languages[0] != 0 ) - // std::cout << " languages: " << std::endl; - - for( unsigned j = 0; languages[j] != 0; ++j ) { - // dump_tag( &languages[j], " lang: "); - - guint language_index = -1; - if( pango_ot_info_find_language(info, PANGO_OT_TABLE_GSUB, script_index, languages[j], &language_index, NULL)) { - - PangoOTTag* features = - pango_ot_info_list_features( info, PANGO_OT_TABLE_GSUB, 0, i, j ); - if( features[0] != 0 ) - // std::cout << " features: " << std::endl; - - for( unsigned k = 0; features[k] != 0; ++k ) { - // dump_tag( &features[k], " feature: "); - ++(res->openTypeTables[ extract_tag(&features[k])]); - } - g_free( features ); - } else { - // std::cout << " No languages defined" << std::endl; - PangoOTTag* features = - pango_ot_info_list_features( info, PANGO_OT_TABLE_GSUB, 0, i, PANGO_OT_DEFAULT_LANGUAGE ); - // if( features[0] != 0 ) - // std::cout << " default features: " << std::endl; - - for( unsigned k = 0; features[k] != 0; ++k ) { - // dump_tag( &features[k], " feature: " ); - ++(res->openTypeTables[ extract_tag(&features[k])]); - } - g_free( features ); + // regardless of which script and langauge they are in. This Harfbuzz code replaces + // an earlier Pango version as the Pango functions are deprecated. + + // Empty map... bitmap fonts seem to be loaded multiple times. + res->openTypeTables.clear(); + + auto const hb_face = hb_ft_face_create(res->theFace, NULL); + + // First time to get size of array + auto script_count = hb_ot_layout_table_get_script_tags(hb_face, HB_OT_TAG_GSUB, 0, NULL, NULL); + auto const scripts_hb = g_new(hb_tag_t, script_count + 1); + + // Second time to fill array (this two step process was not necessary with Pango). + hb_ot_layout_table_get_script_tags(hb_face, HB_OT_TAG_GSUB, 0, &script_count, scripts_hb); + + for(unsigned int i = 0; i < script_count; ++i) { + auto language_count = hb_ot_layout_script_get_language_tags(hb_face, HB_OT_TAG_GSUB, i, 0, NULL, NULL); + + if(language_count > 0) { + auto const languages_hb = g_new(hb_tag_t, language_count + 1); + hb_ot_layout_script_get_language_tags(hb_face, HB_OT_TAG_GSUB, i, 0, &language_count, languages_hb); + + for(unsigned int j = 0; j < language_count; ++j) { + auto feature_count = hb_ot_layout_language_get_feature_tags(hb_face, HB_OT_TAG_GSUB, i, j, 0, NULL, NULL); + auto const features_hb = g_new(hb_tag_t, feature_count + 1); + hb_ot_layout_language_get_feature_tags(hb_face, HB_OT_TAG_GSUB, i, j, 0, &feature_count, features_hb); + + for(unsigned int k = 0; k < feature_count; ++k) { + ++(res->openTypeTables[ extract_tag(&features_hb[k])]); } + + g_free(features_hb); } - g_free( languages ); - } else { - // std::cout << " No scripts defined! " << std::endl; + + g_free(languages_hb); + } + else { + // Even if no languages are present there is still the default. + auto feature_count = hb_ot_layout_language_get_feature_tags(hb_face, HB_OT_TAG_GSUB, i, + HB_OT_LAYOUT_DEFAULT_LANGUAGE_INDEX, + 0, NULL, NULL); + auto const features_hb = g_new(hb_tag_t, feature_count + 1); + hb_ot_layout_language_get_feature_tags(hb_face, HB_OT_TAG_GSUB, i, + HB_OT_LAYOUT_DEFAULT_LANGUAGE_INDEX, + 0, &feature_count, features_hb); + + for(unsigned int k = 0; k < feature_count; ++k) { + ++(res->openTypeTables[ extract_tag(&features_hb[k])]); + } + + g_free(features_hb); } } - g_free( scripts ); - - PangoOTTag* features = - pango_ot_info_list_features( info, PANGO_OT_TABLE_GSUB, 0, 0, PANGO_OT_DEFAULT_LANGUAGE ); - // if( features[0] != 0 ) - // std::cout << " DFTL DFTL features: " << std::endl; - for( unsigned i = 0; features[i] != 0; ++i ) { - // dump_tag( &features[i], " feature: " ); - ++(res->openTypeTables[ extract_tag(&features[i])]); - } - // std::map<Glib::ustring,int>::iterator it; - // for( it = res->openTypeTables.begin(); it != res->openTypeTables.end(); ++it) { - // std::cout << "Table: " << it->first << " Occurances: " << it->second << std::endl; - // } - g_free( features ); + g_free(scripts_hb); } else { // already here res = loadedFaces[descr]; diff --git a/src/libnrtype/Layout-TNG-Output.cpp b/src/libnrtype/Layout-TNG-Output.cpp index 526319f35..df7adf5b4 100644 --- a/src/libnrtype/Layout-TNG-Output.cpp +++ b/src/libnrtype/Layout-TNG-Output.cpp @@ -742,8 +742,6 @@ void Layout::fitToPathAlign(SVGLength const &startOffset, Path const &path) if (endpoint != startpoint) { tangent = endpoint - startpoint; tangent.normalize(); - } else { - tangent = Geom::Point (0,0); } } g_free(end_otp); diff --git a/src/libnrtype/Makefile_insert b/src/libnrtype/Makefile_insert deleted file mode 100644 index ab9465daa..000000000 --- a/src/libnrtype/Makefile_insert +++ /dev/null @@ -1,28 +0,0 @@ -## Makefile.am fragment sourced by src/Makefile.am. - -ink_common_sources += \ - libnrtype/boundary-type.h \ - libnrtype/font-glyph.h \ - libnrtype/font-instance.h \ - libnrtype/font-style.h \ - libnrtype/nr-type-primitives.cpp \ - libnrtype/nr-type-primitives.h \ - libnrtype/FontFactory.cpp \ - libnrtype/FontFactory.h \ - libnrtype/FontInstance.cpp \ - libnrtype/font-lister.h \ - libnrtype/font-lister.cpp \ - libnrtype/one-box.h \ - libnrtype/one-glyph.h \ - libnrtype/one-para.h \ - libnrtype/text-boundary.h \ - libnrtype/TextWrapper.cpp \ - libnrtype/TextWrapper.h \ - libnrtype/Layout-TNG-Compute.cpp \ - libnrtype/Layout-TNG-Input.cpp \ - libnrtype/Layout-TNG-OutIter.cpp \ - libnrtype/Layout-TNG-Output.cpp \ - libnrtype/Layout-TNG-Scanline-Maker.h \ - libnrtype/Layout-TNG-Scanline-Makers.cpp \ - libnrtype/Layout-TNG.cpp \ - libnrtype/Layout-TNG.h diff --git a/src/libnrtype/font-lister.cpp b/src/libnrtype/font-lister.cpp index 568a7c8cc..48fcf2a22 100644 --- a/src/libnrtype/font-lister.cpp +++ b/src/libnrtype/font-lister.cpp @@ -135,6 +135,8 @@ void FontLister::ensureRowStyles(GtkTreeModel* model, GtkTreeIter const* iterato if (!row[FontList.styles]) { if (row[FontList.pango_family]) { row[FontList.styles] = font_factory::Default()->GetUIStyles(row[FontList.pango_family]); + } else { + row[FontList.styles] = default_styles; } } } @@ -177,6 +179,7 @@ void FontLister::insert_font_family(Glib::ustring new_family) (*treeModelIter)[FontList.family] = new_family; (*treeModelIter)[FontList.styles] = styles; (*treeModelIter)[FontList.onSystem] = false; + (*treeModelIter)[FontList.pango_family] = NULL; } void FontLister::update_font_list(SPDocument *document) @@ -256,7 +259,8 @@ void FontLister::update_font_list(SPDocument *document) Gtk::TreeModel::iterator treeModelIter = font_list_store->prepend(); (*treeModelIter)[FontList.family] = reinterpret_cast<const char *>(g_strdup((*i).c_str())); (*treeModelIter)[FontList.styles] = styles; - (*treeModelIter)[FontList.onSystem] = false; + (*treeModelIter)[FontList.onSystem] = false; // false if document font + (*treeModelIter)[FontList.pango_family] = NULL; // CHECK ME (set to pango_family if on system?) } @@ -298,8 +302,8 @@ void FontLister::update_font_list_recursive(SPObject *r, std::list<Glib::ustring l->push_back(Glib::ustring(font_family)); } - for (SPObject *child = r->firstChild(); child; child = child->getNext()) { - update_font_list_recursive(child, l); + for (auto& child: r->children) { + update_font_list_recursive(&child, l); } } @@ -993,7 +997,7 @@ Glib::ustring FontLister::get_best_style_match(Glib::ustring family, Glib::ustri } catch (...) { - //std::cout << " ERROR: can't find family: " << family << std::endl; + std::cerr << "FontLister::get_best_style_match(): can't find family: " << family << std::endl; return (target_style); } @@ -1002,10 +1006,12 @@ Glib::ustring FontLister::get_best_style_match(Glib::ustring family, Glib::ustri //font_description_dump( target ); - if (!row[FontList.styles]) { + GList *styles = default_styles; + if (row[FontList.onSystem] && !row[FontList.styles]) { row[FontList.styles] = font_factory::Default()->GetUIStyles(row[FontList.pango_family]); + styles = row[FontList.styles]; } - GList *styles = row[FontList.styles]; + for (GList *l = styles; l; l = l->next) { Glib::ustring fontspec = family + ", " + ((StyleNames *)l->data)->CssName; PangoFontDescription *candidate = pango_font_description_from_string(fontspec.c_str()); diff --git a/src/libuemf/Makefile_insert b/src/libuemf/Makefile_insert deleted file mode 100644 index 427a0e80e..000000000 --- a/src/libuemf/Makefile_insert +++ /dev/null @@ -1,30 +0,0 @@ -## Makefile.am fragment sourced by src/Makefile.am. - -libuemf/all: libuemf.a - -libuemf/clean: - rm -f libuemf/libuemf.a $(libuemf_libuemf_a_OBJECTS) - -libuemf_libuemf_a_SOURCES = \ - libuemf/uemf.c \ - libuemf/uemf.h \ - libuemf/uemf_endian.c \ - libuemf/uemf_endian.h \ - libuemf/uemf_print.c \ - libuemf/uemf_print.h \ - libuemf/uemf_safe.c \ - libuemf/uemf_safe.h \ - libuemf/uemf_utf.c \ - libuemf/uemf_utf.h \ - libuemf/uwmf.c \ - libuemf/uwmf.h \ - libuemf/uwmf_endian.c \ - libuemf/uwmf_endian.h \ - libuemf/uwmf_print.c \ - libuemf/uwmf_print.h \ - libuemf/upmf.c \ - libuemf/upmf.h \ - libuemf/upmf_print.c \ - libuemf/upmf_print.h \ - libuemf/symbol_convert.c \ - libuemf/symbol_convert.h diff --git a/src/libvpsc/Makefile_insert b/src/libvpsc/Makefile_insert deleted file mode 100644 index cb05be6c0..000000000 --- a/src/libvpsc/Makefile_insert +++ /dev/null @@ -1,23 +0,0 @@ -## Makefile.am fragment sourced by src/Makefile.am. -libvpsc/all: libvpsc/libvpsc.a - -libvpsc/clean: - rm -f libvpsc/libvpsc.a $(libvpsc_libvpsc_a_OBJECTS) - -libvpsc_libvpsc_a_SOURCES = libvpsc/block.cpp\ - libvpsc/blocks.cpp\ - libvpsc/constraint.cpp\ - libvpsc/generate-constraints.cpp\ - libvpsc/pairingheap/PairingHeap.cpp\ - libvpsc/remove_rectangle_overlap.cpp\ - libvpsc/solve_VPSC.cpp\ - libvpsc/variable.cpp\ - libvpsc/block.h\ - libvpsc/blocks.h\ - libvpsc/constraint.h\ - libvpsc/generate-constraints.h\ - libvpsc/pairingheap/PairingHeap.h\ - libvpsc/pairingheap/dsexceptions.h\ - libvpsc/remove_rectangle_overlap.h\ - libvpsc/solve_VPSC.h\ - libvpsc/variable.h diff --git a/src/line-geometry.cpp b/src/line-geometry.cpp index c5357e213..6e0f82d45 100644 --- a/src/line-geometry.cpp +++ b/src/line-geometry.cpp @@ -10,7 +10,6 @@ */ #include "line-geometry.h" -#include "inkscape.h" #include "desktop.h" #include "desktop-style.h" diff --git a/src/line-snapper.cpp b/src/line-snapper.cpp index 6122b133a..6be447a4f 100644 --- a/src/line-snapper.cpp +++ b/src/line-snapper.cpp @@ -11,10 +11,8 @@ */ #include <2geom/line.h> -#include <cassert> #include "line-snapper.h" -#include "snapped-line.h" #include "snap.h" Inkscape::LineSnapper::LineSnapper(SnapManager *sm, Geom::Coord const d) : Snapper(sm, d) diff --git a/src/livarot/Makefile_insert b/src/livarot/Makefile_insert deleted file mode 100644 index 69078d073..000000000 --- a/src/livarot/Makefile_insert +++ /dev/null @@ -1,41 +0,0 @@ -## Makefile.am fragment sourced by src/Makefile.am. - -livarot/all: livarot/libvarot.a - -livarot/clean: - rm -f livarot/libvarot.a $(livarot_libvarot_a_OBJECTS) - -livarot_libvarot_a_SOURCES = \ - livarot/AVL.cpp \ - livarot/AVL.h \ - livarot/AlphaLigne.cpp \ - livarot/AlphaLigne.h \ - livarot/BitLigne.cpp \ - livarot/BitLigne.h \ - livarot/float-line.cpp \ - livarot/float-line.h \ - livarot/int-line.cpp \ - livarot/int-line.h \ - livarot/LivarotDefs.h \ - livarot/Path.cpp \ - livarot/Path.h \ - livarot/PathConversion.cpp \ - livarot/PathCutting.cpp \ - livarot/PathOutline.cpp \ - livarot/PathSimplify.cpp \ - livarot/PathStroke.cpp \ - livarot/Shape.cpp \ - livarot/Shape.h \ - livarot/ShapeDraw.cpp \ - livarot/ShapeMisc.cpp \ - livarot/ShapeRaster.cpp \ - livarot/ShapeSweep.cpp \ - livarot/sweep-tree-list.cpp \ - livarot/sweep-tree-list.h \ - livarot/sweep-tree.cpp \ - livarot/sweep-tree.h \ - livarot/sweep-event.cpp \ - livarot/sweep-event.h \ - livarot/sweep-event-queue.h \ - livarot/path-description.h \ - livarot/path-description.cpp diff --git a/src/livarot/PathOutline.cpp b/src/livarot/PathOutline.cpp index 1c42301da..0683d8ae8 100644 --- a/src/livarot/PathOutline.cpp +++ b/src/livarot/PathOutline.cpp @@ -1195,7 +1195,7 @@ Path::OutlineJoin (Path * dest, Geom::Point pos, Geom::Point stNor, Geom::Point if ((dest->descr_cmd[dest->descr_cmd.size() - 1]->getType() == descr_lineto) && (nType == descr_lineto)) { Geom::Point const biss = unit_vector(Geom::rot90( stNor - enNor )); double c2 = Geom::dot (biss, enNor); - if (fabs(c2) > 0.707107) { // apply only to obtuse angles + if (fabs(c2) > M_SQRT1_2) { // apply only to obtuse angles double l = width / c2; PathDescrLineTo* nLine = dynamic_cast<PathDescrLineTo*>(dest->descr_cmd[dest->descr_cmd.size() - 1]); nLine->p = pos + l*biss; // relocate to bisector diff --git a/src/live_effects/Makefile_insert b/src/live_effects/Makefile_insert deleted file mode 100644 index d227d379d..000000000 --- a/src/live_effects/Makefile_insert +++ /dev/null @@ -1,117 +0,0 @@ -## Makefile.am fragment sourced by src/Makefile.am. - -ink_common_sources += \ - live_effects/effect.cpp \ - live_effects/effect.h \ - live_effects/effect-enum.h \ - live_effects/lpeobject.cpp \ - live_effects/lpeobject.h \ - live_effects/lpegroupbbox.cpp \ - live_effects/lpegroupbbox.h \ - live_effects/lpeobject-reference.cpp \ - live_effects/lpeobject-reference.h \ - live_effects/lpe-patternalongpath.cpp \ - live_effects/lpe-patternalongpath.h \ - live_effects/lpe-bendpath.cpp \ - live_effects/lpe-bendpath.h \ - live_effects/lpe-dynastroke.cpp \ - live_effects/lpe-dynastroke.h \ - live_effects/lpe-extrude.cpp \ - live_effects/lpe-extrude.h \ - live_effects/lpe-sketch.cpp \ - live_effects/lpe-sketch.h \ - live_effects/lpe-knot.cpp \ - live_effects/lpe-knot.h \ - live_effects/lpe-vonkoch.cpp \ - live_effects/lpe-vonkoch.h \ - live_effects/lpe-rough-hatches.cpp \ - live_effects/lpe-rough-hatches.h \ - live_effects/lpe-curvestitch.cpp \ - live_effects/lpe-curvestitch.h \ - live_effects/lpe-constructgrid.cpp \ - live_effects/lpe-constructgrid.h \ - live_effects/lpe-fillet-chamfer.cpp \ - live_effects/lpe-fillet-chamfer.h \ - live_effects/lpe-gears.cpp \ - live_effects/lpe-gears.h \ - live_effects/lpe-interpolate.cpp \ - live_effects/lpe-interpolate.h \ - live_effects/lpe-interpolate_points.cpp \ - live_effects/lpe-interpolate_points.h \ - live_effects/lpe-test-doEffect-stack.cpp \ - live_effects/lpe-test-doEffect-stack.h \ - live_effects/lpe-bspline.cpp \ - live_effects/lpe-bspline.h \ - live_effects/lpe-lattice.cpp \ - live_effects/lpe-lattice.h \ - live_effects/lpe-lattice2.cpp \ - live_effects/lpe-lattice2.h \ - live_effects/lpe-roughen.cpp \ - live_effects/lpe-roughen.h \ - live_effects/lpe-show_handles.cpp \ - live_effects/lpe-show_handles.h \ - live_effects/lpe-simplify.cpp \ - live_effects/lpe-simplify.h \ - live_effects/lpe-envelope.cpp \ - live_effects/lpe-envelope.h \ - live_effects/lpe-spiro.cpp \ - live_effects/lpe-spiro.h \ - live_effects/lpe-tangent_to_curve.cpp \ - live_effects/lpe-tangent_to_curve.h \ - live_effects/lpe-perp_bisector.cpp \ - live_effects/lpe-perp_bisector.h \ - live_effects/spiro.h \ - live_effects/spiro.cpp \ - live_effects/spiro-converters.h \ - live_effects/spiro-converters.cpp \ - live_effects/lpe-circle_with_radius.cpp \ - live_effects/lpe-circle_with_radius.h \ - live_effects/lpe-perspective_path.cpp \ - live_effects/lpe-perspective_path.h \ - live_effects/lpe-perspective-envelope.cpp \ - live_effects/lpe-perspective-envelope.h \ - live_effects/lpe-measure-line.cpp \ - live_effects/lpe-measure-line.h \ - live_effects/lpe-mirror_symmetry.cpp \ - live_effects/lpe-mirror_symmetry.h \ - live_effects/lpe-circle_3pts.cpp \ - live_effects/lpe-circle_3pts.h \ - live_effects/lpe-transform_2pts.cpp \ - live_effects/lpe-transform_2pts.h \ - live_effects/lpe-angle_bisector.cpp \ - live_effects/lpe-angle_bisector.h \ - live_effects/lpe-parallel.cpp \ - live_effects/lpe-parallel.h \ - live_effects/lpe-copy_rotate.cpp \ - live_effects/lpe-copy_rotate.h \ - live_effects/lpe-powerstroke.cpp \ - live_effects/lpe-powerstroke.h \ - live_effects/lpe-powerstroke-interpolators.h \ - live_effects/lpe-offset.cpp \ - live_effects/lpe-offset.h \ - live_effects/lpe-clone-original.cpp \ - live_effects/lpe-clone-original.h \ - live_effects/lpe-ruler.cpp \ - live_effects/lpe-ruler.h \ - live_effects/lpe-recursiveskeleton.cpp \ - live_effects/lpe-recursiveskeleton.h \ - live_effects/lpe-text_label.cpp \ - live_effects/lpe-text_label.h \ - live_effects/lpe-path_length.cpp \ - live_effects/lpe-path_length.h \ - live_effects/lpe-line_segment.cpp \ - live_effects/lpe-line_segment.h \ - live_effects/lpe-bounding-box.cpp \ - live_effects/lpe-bounding-box.h \ - live_effects/lpe-attach-path.cpp \ - live_effects/lpe-attach-path.h \ - live_effects/lpe-fill-between-strokes.cpp \ - live_effects/lpe-fill-between-strokes.h \ - live_effects/lpe-fill-between-many.cpp \ - live_effects/lpe-fill-between-many.h \ - live_effects/lpe-ellipse_5pts.cpp \ - live_effects/lpe-ellipse_5pts.h \ - live_effects/lpe-jointype.cpp \ - live_effects/lpe-jointype.h \ - live_effects/lpe-taperstroke.cpp \ - live_effects/lpe-taperstroke.h diff --git a/src/live_effects/effect.cpp b/src/live_effects/effect.cpp index 7efc1a711..792bb5d7a 100644 --- a/src/live_effects/effect.cpp +++ b/src/live_effects/effect.cpp @@ -8,12 +8,11 @@ //#define LPE_ENABLE_TEST_EFFECTS //uncomment for toy effects #ifdef HAVE_CONFIG_H -# include "config.h" +#include <config.h> #endif // include effects: #include "live_effects/lpe-patternalongpath.h" -#include "live_effects/effect.h" #include "live_effects/lpe-angle_bisector.h" #include "live_effects/lpe-attach-path.h" #include "live_effects/lpe-bendpath.h" @@ -65,30 +64,15 @@ #include "live_effects/lpe-vonkoch.h" #include "xml/node-event-vector.h" -#include "sp-object.h" -#include "attributes.h" #include "message-stack.h" -#include "desktop.h" -#include "inkscape.h" -#include "document.h" #include "document-private.h" -#include "xml/document.h" -#include <glibmm/i18n.h> #include "ui/tools/pen-tool.h" +#include "ui/tools/node-tool.h" #include "ui/tools-switch.h" #include "knotholder.h" -#include "sp-lpe-item.h" #include "live_effects/lpeobject.h" -#include "live_effects/parameter/parameter.h" -#include <glibmm/ustring.h> #include "display/curve.h" -#include <exception> - -#include <2geom/sbasis-to-bezier.h> -#include <2geom/affine.h> -#include <2geom/pathvector.h> - namespace Inkscape { @@ -480,6 +464,7 @@ void Effect::doBeforeEffect_impl(SPLPEItem const* lpeitem) sp_lpe_item->apply_to_clippath(sp_lpe_item); sp_lpe_item->apply_to_mask(sp_lpe_item); } + update_helperpath(); } /** @@ -669,6 +654,20 @@ Effect::addCanvasIndicators(SPLPEItem const*/*lpeitem*/, std::vector<Geom::PathV { } +/** + * Call to a method on nodetool to update the helper path from the effect + */ +void +Effect::update_helperpath() { + using namespace Inkscape::UI; + SPDesktop *desktop = SP_ACTIVE_DESKTOP; + if (desktop) { + if (tools_isactive(desktop, TOOLS_NODES)) { + Inkscape::UI::Tools::NodeTool *nt = static_cast<Inkscape::UI::Tools::NodeTool*>(desktop->event_context); + nt->update_helperpath(); + } + } +} /** * This *creates* a new widget, management of deletion should be done by the caller diff --git a/src/live_effects/effect.h b/src/live_effects/effect.h index f54624302..5ca53486c 100644 --- a/src/live_effects/effect.h +++ b/src/live_effects/effect.h @@ -102,6 +102,7 @@ public: virtual LPEPathFlashType pathFlashType() const { return DEFAULT; } void addHandles(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item); std::vector<Geom::PathVector> getCanvasIndicators(SPLPEItem const* lpeitem); + void update_helperpath(); inline bool providesOwnFlashPaths() const { return provides_own_flash_paths || show_orig_path; diff --git a/src/live_effects/lpe-angle_bisector.cpp b/src/live_effects/lpe-angle_bisector.cpp index 900d29e3a..9bfbf4ca8 100644 --- a/src/live_effects/lpe-angle_bisector.cpp +++ b/src/live_effects/lpe-angle_bisector.cpp @@ -12,7 +12,6 @@ #include "live_effects/lpe-angle_bisector.h" -#include <2geom/path.h> #include <2geom/sbasis-to-bezier.h> #include "sp-lpe-item.h" diff --git a/src/live_effects/lpe-attach-path.cpp b/src/live_effects/lpe-attach-path.cpp index 21459f322..d2b44dd4e 100644 --- a/src/live_effects/lpe-attach-path.cpp +++ b/src/live_effects/lpe-attach-path.cpp @@ -10,16 +10,9 @@ #include "live_effects/lpe-attach-path.h" #include "display/curve.h" -#include "sp-item.h" -#include "2geom/path.h" #include "sp-shape.h" #include "sp-text.h" -#include "2geom/bezier-curve.h" #include "2geom/path-sink.h" -#include "parameter/parameter.h" -#include "live_effects/parameter/point.h" -#include "parameter/originalpath.h" -#include "2geom/affine.h" namespace Inkscape { namespace LivePathEffect { diff --git a/src/live_effects/lpe-bendpath.cpp b/src/live_effects/lpe-bendpath.cpp index bc112285f..c24d38d7b 100644 --- a/src/live_effects/lpe-bendpath.cpp +++ b/src/live_effects/lpe-bendpath.cpp @@ -6,27 +6,11 @@ */ #include "live_effects/lpe-bendpath.h" -#include "sp-shape.h" -#include "sp-item.h" -#include "sp-path.h" #include "sp-item-group.h" -#include "svg/svg.h" -#include "ui/widget/scalar.h" - -#include <2geom/sbasis.h> -#include <2geom/sbasis-geometric.h> -#include <2geom/bezier-to-sbasis.h> -#include <2geom/sbasis-to-bezier.h> -#include <2geom/d2.h> -#include <2geom/piecewise.h> #include "knot-holder-entity.h" #include "knotholder.h" -#include <glibmm/i18n.h> - -#include <algorithm> - using std::vector; diff --git a/src/live_effects/lpe-bounding-box.cpp b/src/live_effects/lpe-bounding-box.cpp index 43a60d482..cfe1f5165 100644 --- a/src/live_effects/lpe-bounding-box.cpp +++ b/src/live_effects/lpe-bounding-box.cpp @@ -9,12 +9,8 @@ #include "live_effects/lpe-bounding-box.h" #include "display/curve.h" -#include "sp-item.h" -#include "2geom/path.h" #include "sp-shape.h" #include "sp-text.h" -#include "2geom/bezier-curve.h" -#include "lpe-bounding-box.h" namespace Inkscape { namespace LivePathEffect { diff --git a/src/live_effects/lpe-circle_3pts.cpp b/src/live_effects/lpe-circle_3pts.cpp index dbb1f4b6b..18252f6a0 100644 --- a/src/live_effects/lpe-circle_3pts.cpp +++ b/src/live_effects/lpe-circle_3pts.cpp @@ -15,7 +15,6 @@ #include "live_effects/lpe-circle_3pts.h" // You might need to include other 2geom files. You can add them here: -#include <2geom/path.h> #include <2geom/circle.h> #include <2geom/path-sink.h> diff --git a/src/live_effects/lpe-circle_with_radius.cpp b/src/live_effects/lpe-circle_with_radius.cpp index 8f2156044..6e03cb1ce 100644 --- a/src/live_effects/lpe-circle_with_radius.cpp +++ b/src/live_effects/lpe-circle_with_radius.cpp @@ -15,7 +15,6 @@ #include "display/curve.h" // You might need to include other 2geom files. You can add them here: -#include <2geom/pathvector.h> #include <2geom/circle.h> #include <2geom/path-sink.h> diff --git a/src/live_effects/lpe-constructgrid.cpp b/src/live_effects/lpe-constructgrid.cpp index b1e0edaac..4af8891e8 100644 --- a/src/live_effects/lpe-constructgrid.cpp +++ b/src/live_effects/lpe-constructgrid.cpp @@ -14,9 +14,6 @@ #include "live_effects/lpe-constructgrid.h" -#include <2geom/path.h> -#include <2geom/transforms.h> - namespace Inkscape { namespace LivePathEffect { diff --git a/src/live_effects/lpe-copy_rotate.cpp b/src/live_effects/lpe-copy_rotate.cpp index 80f5bdafd..f28ab4b31 100644 --- a/src/live_effects/lpe-copy_rotate.cpp +++ b/src/live_effects/lpe-copy_rotate.cpp @@ -15,11 +15,7 @@ #include <2geom/path-intersection.h> #include <2geom/sbasis-to-bezier.h> #include "live_effects/lpe-copy_rotate.h" -#include <2geom/path.h> -#include <2geom/transforms.h> -#include <2geom/angle.h> -#include "knot-holder-entity.h" #include "knotholder.h" // TODO due to internal breakage in glibmm headers, this must be last: #include <glibmm/i18n.h> diff --git a/src/live_effects/lpe-curvestitch.cpp b/src/live_effects/lpe-curvestitch.cpp index 609447f26..3beedaf57 100644 --- a/src/live_effects/lpe-curvestitch.cpp +++ b/src/live_effects/lpe-curvestitch.cpp @@ -17,19 +17,11 @@ #include "live_effects/lpe-curvestitch.h" -#include "sp-item.h" #include "sp-path.h" #include "svg/svg.h" #include "xml/repr.h" -#include <2geom/path.h> -#include <2geom/piecewise.h> -#include <2geom/sbasis.h> -#include <2geom/sbasis-geometric.h> #include <2geom/bezier-to-sbasis.h> -#include <2geom/sbasis-to-bezier.h> -#include <2geom/d2.h> -#include <2geom/affine.h> namespace Inkscape { namespace LivePathEffect { diff --git a/src/live_effects/lpe-dynastroke.cpp b/src/live_effects/lpe-dynastroke.cpp index aeecd5d5c..7e22f6e51 100644 --- a/src/live_effects/lpe-dynastroke.cpp +++ b/src/live_effects/lpe-dynastroke.cpp @@ -14,14 +14,8 @@ #include "display/curve.h" //# include <libnr/n-art-bpath.h> -#include <2geom/path.h> -#include <2geom/sbasis.h> -#include <2geom/sbasis-geometric.h> #include <2geom/bezier-to-sbasis.h> -#include <2geom/sbasis-to-bezier.h> -#include <2geom/d2.h> #include <2geom/sbasis-math.h> -#include <2geom/piecewise.h> namespace Inkscape { namespace LivePathEffect { diff --git a/src/live_effects/lpe-ellipse_5pts.cpp b/src/live_effects/lpe-ellipse_5pts.cpp index 088d24b9c..0371fc313 100644 --- a/src/live_effects/lpe-ellipse_5pts.cpp +++ b/src/live_effects/lpe-ellipse_5pts.cpp @@ -15,7 +15,6 @@ // You might need to include other 2geom files. You can add them here: #include <glibmm/i18n.h> -#include <2geom/path.h> #include <2geom/circle.h> #include <2geom/ellipse.h> #include <2geom/path-sink.h> diff --git a/src/live_effects/lpe-envelope.cpp b/src/live_effects/lpe-envelope.cpp index e873c0b15..0ce784877 100644 --- a/src/live_effects/lpe-envelope.cpp +++ b/src/live_effects/lpe-envelope.cpp @@ -5,22 +5,8 @@ */ #include "live_effects/lpe-envelope.h" -#include "sp-shape.h" -#include "sp-item.h" -#include "sp-path.h" -#include "sp-item-group.h" #include "display/curve.h" -#include "svg/svg.h" -#include "ui/widget/scalar.h" -#include <2geom/sbasis.h> -#include <2geom/sbasis-geometric.h> -#include <2geom/bezier-to-sbasis.h> -#include <2geom/sbasis-to-bezier.h> -#include <2geom/d2.h> -#include <2geom/piecewise.h> - -#include <algorithm> using std::vector; namespace Inkscape { diff --git a/src/live_effects/lpe-extrude.cpp b/src/live_effects/lpe-extrude.cpp index dd1a8c824..d22007f76 100644 --- a/src/live_effects/lpe-extrude.cpp +++ b/src/live_effects/lpe-extrude.cpp @@ -15,11 +15,6 @@ #include <glibmm/i18n.h> -#include <2geom/path.h> -#include <2geom/piecewise.h> -#include <2geom/transforms.h> -#include <algorithm> - #include "sp-item.h" namespace Inkscape { diff --git a/src/live_effects/lpe-fill-between-many.cpp b/src/live_effects/lpe-fill-between-many.cpp index 574ec3580..ccb9cf56d 100644 --- a/src/live_effects/lpe-fill-between-many.cpp +++ b/src/live_effects/lpe-fill-between-many.cpp @@ -9,11 +9,8 @@ #include "live_effects/lpe-fill-between-many.h" #include "display/curve.h" -#include "sp-item.h" -#include "2geom/path.h" #include "sp-shape.h" #include "sp-text.h" -#include "2geom/bezier-curve.h" #include <glibmm/i18n.h> diff --git a/src/live_effects/lpe-fill-between-strokes.cpp b/src/live_effects/lpe-fill-between-strokes.cpp index 89ea80545..b1e328d18 100644 --- a/src/live_effects/lpe-fill-between-strokes.cpp +++ b/src/live_effects/lpe-fill-between-strokes.cpp @@ -9,11 +9,8 @@ #include "live_effects/lpe-fill-between-strokes.h" #include "display/curve.h" -#include "sp-item.h" -#include "2geom/path.h" #include "sp-shape.h" #include "sp-text.h" -#include "2geom/bezier-curve.h" namespace Inkscape { namespace LivePathEffect { diff --git a/src/live_effects/lpe-fillet-chamfer.cpp b/src/live_effects/lpe-fillet-chamfer.cpp index 07760b172..24ee2ccc3 100644 --- a/src/live_effects/lpe-fillet-chamfer.cpp +++ b/src/live_effects/lpe-fillet-chamfer.cpp @@ -17,21 +17,16 @@ #include <2geom/sbasis-to-bezier.h> #include <2geom/elliptical-arc.h> -#include <2geom/line.h> -#include "desktop.h" #include "display/curve.h" #include "helper/geom-nodetype.h" #include "helper/geom-curves.h" #include "helper/geom.h" -#include "live_effects/parameter/filletchamferpointarray.h" - // for programmatically updating knots #include "ui/tools-switch.h" // TODO due to internal breakage in glibmm headers, this must be last: -#include <glibmm/i18n.h> using namespace Geom; namespace Inkscape { diff --git a/src/live_effects/lpe-gears.cpp b/src/live_effects/lpe-gears.cpp index d4d695542..1d5398aa5 100644 --- a/src/live_effects/lpe-gears.cpp +++ b/src/live_effects/lpe-gears.cpp @@ -8,14 +8,9 @@ #include "live_effects/lpe-gears.h" -#include <vector> - #include <glibmm/i18n.h> -#include <2geom/d2.h> -#include <2geom/sbasis.h> #include <2geom/bezier-to-sbasis.h> -#include <2geom/path.h> using std::vector; using namespace Geom; @@ -212,7 +207,8 @@ namespace LivePathEffect { LPEGears::LPEGears(LivePathEffectObject *lpeobject) : Effect(lpeobject), teeth(_("_Teeth:"), _("The number of teeth"), "teeth", &wr, this, 10), - phi(_("_Phi:"), _("Tooth pressure angle (typically 20-25 deg). The ratio of teeth not in contact."), "phi", &wr, this, 5) + phi(_("_Phi:"), _("Tooth pressure angle (typically 20-25 deg). The ratio of teeth not in contact."), "phi", &wr, this, 5), + min_radius(_("Min Radius:"), _("Minimun radius, low balues can slow"), "min_radius", &wr, this, 5.0) { /* Tooth pressure angle: The angle between the tooth profile and a perpendicular to the pitch * circle, usually at the point where the pitch circle meets the tooth profile. Standard angles @@ -223,8 +219,10 @@ LPEGears::LPEGears(LivePathEffectObject *lpeobject) : teeth.param_make_integer(); teeth.param_set_range(3, 1e10); - registerParameter( dynamic_cast<Parameter *>(&teeth) ); - registerParameter( dynamic_cast<Parameter *>(&phi) ); + min_radius.param_set_range(0.01, 9999.0); + registerParameter(&teeth); + registerParameter(&phi); + registerParameter(&min_radius); } LPEGears::~LPEGears() @@ -247,12 +245,17 @@ LPEGears::doEffect_path (Geom::PathVector const &path_in) gear->angle(atan2((*it).initialPoint() - gear_centre)); ++it; - if ( it == gearpath.end() ) return path_out; - gear->pitch_radius(Geom::distance(gear_centre, (*it).finalPoint())); + if ( it == gearpath.end() ) return path_out; + double radius = Geom::distance(gear_centre, (*it).finalPoint()); + radius = radius < min_radius?min_radius:radius; + gear->pitch_radius(radius); path_out.push_back( gear->path()); - + for (++it; it != gearpath.end() ; ++it) { + if (are_near((*it).initialPoint(), (*it).finalPoint())) { + continue; + } // iterate through Geom::Curve in path_in Gear* gearnew = new Gear(gear->spawn( (*it).finalPoint() )); path_out.push_back( gearnew->path() ); diff --git a/src/live_effects/lpe-gears.h b/src/live_effects/lpe-gears.h index 5dd6dd239..57b49d2b5 100644 --- a/src/live_effects/lpe-gears.h +++ b/src/live_effects/lpe-gears.h @@ -27,6 +27,7 @@ public: private: ScalarParam teeth; ScalarParam phi; + ScalarParam min_radius; LPEGears(const LPEGears&); LPEGears& operator=(const LPEGears&); diff --git a/src/live_effects/lpe-interpolate.cpp b/src/live_effects/lpe-interpolate.cpp index 74c7efd90..43da4d105 100644 --- a/src/live_effects/lpe-interpolate.cpp +++ b/src/live_effects/lpe-interpolate.cpp @@ -14,10 +14,7 @@ #include "live_effects/lpe-interpolate.h" -#include <2geom/path.h> #include <2geom/sbasis-to-bezier.h> -#include <2geom/piecewise.h> -#include <2geom/sbasis-geometric.h> #include "sp-path.h" #include "display/curve.h" diff --git a/src/live_effects/lpe-interpolate_points.cpp b/src/live_effects/lpe-interpolate_points.cpp index cf70832ee..ab0576174 100644 --- a/src/live_effects/lpe-interpolate_points.cpp +++ b/src/live_effects/lpe-interpolate_points.cpp @@ -13,8 +13,6 @@ #include "live_effects/lpe-interpolate_points.h" -#include <2geom/path.h> - #include "live_effects/lpe-powerstroke-interpolators.h" namespace Inkscape { diff --git a/src/live_effects/lpe-jointype.cpp b/src/live_effects/lpe-jointype.cpp index fe42932be..3bfbd6288 100644 --- a/src/live_effects/lpe-jointype.cpp +++ b/src/live_effects/lpe-jointype.cpp @@ -10,16 +10,12 @@ #include "live_effects/parameter/enum.h" #include "helper/geom-pathstroke.h" -#include "sp-shape.h" #include "style.h" -#include "xml/repr.h" -#include "sp-paint-server.h" #include "svg/svg-color.h" #include "desktop-style.h" #include "svg/css-ostringstream.h" #include "display/curve.h" -#include <2geom/path.h> #include <2geom/elliptical-arc.h> #include "lpe-jointype.h" diff --git a/src/live_effects/lpe-knot.cpp b/src/live_effects/lpe-knot.cpp index 09f35f05e..fbc32cf3e 100644 --- a/src/live_effects/lpe-knot.cpp +++ b/src/live_effects/lpe-knot.cpp @@ -16,7 +16,6 @@ #include "sp-path.h" #include "display/curve.h" #include "live_effects/lpe-knot.h" -#include "svg/svg.h" #include "style.h" #include "knot-holder-entity.h" #include "knotholder.h" @@ -25,20 +24,14 @@ #include <gdk/gdk.h> #include <2geom/sbasis-to-bezier.h> -#include <2geom/sbasis.h> -#include <2geom/d2.h> -#include <2geom/path.h> #include <2geom/bezier-to-sbasis.h> #include <2geom/basic-intersection.h> -#include <2geom/exception.h> // for change crossing undo #include "verbs.h" #include "document.h" #include "document-undo.h" -#include <exception> - namespace Inkscape { namespace LivePathEffect { diff --git a/src/live_effects/lpe-lattice.cpp b/src/live_effects/lpe-lattice.cpp index 3c23e349e..091b6ddca 100644 --- a/src/live_effects/lpe-lattice.cpp +++ b/src/live_effects/lpe-lattice.cpp @@ -6,7 +6,7 @@ * Authors: * Johan Engelen <j.b.c.engelen@utwente.nl> * Steren Giannini - * Noé Falzon + * No� Falzon * Victor Navez * * Copyright (C) 2007-2008 Authors @@ -16,22 +16,10 @@ #include "live_effects/lpe-lattice.h" -#include "sp-shape.h" -#include "sp-item.h" -#include "sp-path.h" #include "display/curve.h" -#include "svg/svg.h" -#include <2geom/sbasis.h> #include <2geom/sbasis-2d.h> -#include <2geom/sbasis-geometric.h> #include <2geom/bezier-to-sbasis.h> -#include <2geom/sbasis-to-bezier.h> -#include <2geom/d2.h> -#include <2geom/piecewise.h> -#include <2geom/transforms.h> - -#include "desktop.h" // TODO: should be factored out (see below) using namespace Geom; diff --git a/src/live_effects/lpe-lattice2.cpp b/src/live_effects/lpe-lattice2.cpp index bacbe5fa7..9e9fc153a 100644 --- a/src/live_effects/lpe-lattice2.cpp +++ b/src/live_effects/lpe-lattice2.cpp @@ -6,7 +6,7 @@ * Authors: * Johan Engelen <j.b.c.engelen@utwente.nl> * Steren Giannini - * Noé Falzon + * No� Falzon * Victor Navez * ~suv * Jabiertxo Arraiza @@ -17,24 +17,11 @@ */ #include "live_effects/lpe-lattice2.h" -#include "sp-shape.h" -#include "sp-item.h" -#include "sp-path.h" #include "display/curve.h" -#include "svg/svg.h" #include "helper/geom.h" -#include <2geom/path.h> -#include <2geom/sbasis.h> #include <2geom/sbasis-2d.h> -#include "helper/geom-curves.h" -#include <2geom/sbasis-geometric.h> #include <2geom/bezier-to-sbasis.h> -#include <2geom/sbasis-to-bezier.h> -#include <2geom/d2.h> -#include <2geom/piecewise.h> -#include <2geom/transforms.h> // TODO due to internal breakage in glibmm headers, this must be last: -#include <glibmm/i18n.h> using namespace Geom; diff --git a/src/live_effects/lpe-line_segment.cpp b/src/live_effects/lpe-line_segment.cpp index dfd8aea8f..4c9edabd4 100644 --- a/src/live_effects/lpe-line_segment.cpp +++ b/src/live_effects/lpe-line_segment.cpp @@ -14,10 +14,6 @@ #include "live_effects/lpe-line_segment.h" #include "ui/tools/lpe-tool.h" -#include <2geom/pathvector.h> -#include <2geom/geom.h> -#include <2geom/bezier-curve.h> - namespace Inkscape { namespace LivePathEffect { diff --git a/src/live_effects/lpe-mirror_symmetry.cpp b/src/live_effects/lpe-mirror_symmetry.cpp index cf866ad6a..4deb29d8f 100644 --- a/src/live_effects/lpe-mirror_symmetry.cpp +++ b/src/live_effects/lpe-mirror_symmetry.cpp @@ -14,29 +14,22 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ #include "live_effects/lpe-mirror_symmetry.h" -#include <sp-path.h> #include <display/curve.h> #include <svg/path-string.h> #include "helper/geom.h" -#include <2geom/path.h> #include <2geom/path-intersection.h> -#include <2geom/transforms.h> -#include <2geom/affine.h> -#include "knot-holder-entity.h" #include "knotholder.h" -#include "inkscape.h" // TODO due to internal breakage in glibmm headers, this must be last: -#include <glibmm/i18n.h> namespace Inkscape { namespace LivePathEffect { static const Util::EnumData<ModeType> ModeTypeData[MT_END] = { - { MT_V, N_("Vertical Page Center"), "Vertical Page Center, use select tool to move item instead line" }, - { MT_H, N_("Horizontal Page Center"), "Horizontal Page Center, use select tool to move item instead line" }, - { MT_FREE, N_("Free from reflection line"), "Free from path" }, - { MT_X, N_("X from middle knot"), "X from middle knot" }, - { MT_Y, N_("Y from middle knot"), "Y from middle knot" } + { MT_V, N_("Vertical Page Center"), "vertical" }, + { MT_H, N_("Horizontal Page Center"), "horizontal" }, + { MT_FREE, N_("Free from reflection line"), "free" }, + { MT_X, N_("X from middle knot"), "X" }, + { MT_Y, N_("Y from middle knot"), "Y" } }; static const Util::EnumDataConverter<ModeType> MTConverter(ModeTypeData, MT_END); @@ -94,7 +87,7 @@ void LPEMirrorSymmetry::doBeforeEffect (SPLPEItem const* lpeitem) { using namespace Geom; - + original_bbox(lpeitem); Point point_a(boundingbox_X.max(), boundingbox_Y.min()); Point point_b(boundingbox_X.max(), boundingbox_Y.max()); Point point_c(boundingbox_X.max(), boundingbox_Y.middle()); @@ -152,6 +145,18 @@ LPEMirrorSymmetry::doBeforeEffect (SPLPEItem const* lpeitem) } void +LPEMirrorSymmetry::transform_multiply(Geom::Affine const& postmul, bool set) +{ + center_point *= postmul; + previous_center = center_point; + // cycle through all parameters. Most parameters will not need transformation, but path and point params do. + for (std::vector<Parameter *>::iterator it = param_vector.begin(); it != param_vector.end(); ++it) { + Parameter * param = *it; + param->param_transform_multiply(postmul, set); + } +} + +void LPEMirrorSymmetry::doOnApply (SPLPEItem const* lpeitem) { using namespace Geom; @@ -185,10 +190,13 @@ LPEMirrorSymmetry::doEffect_path (Geom::PathVector const & path_in) Geom::Translate m1(point_a[0], point_a[1]); double hyp = Geom::distance(point_a, point_b); - double c = (point_b[0] - point_a[0]) / hyp; // cos(alpha) - double s = (point_b[1] - point_a[1]) / hyp; // sin(alpha) - - Geom::Affine m2(c, -s, s, c, 0.0, 0.0); + double cos = 0; + double sin = 0; + if (hyp > 0) { + cos = (point_b[0] - point_a[0]) / hyp; + sin = (point_b[1] - point_a[1]) / hyp; + } + Geom::Affine m2(cos, -sin, sin, cos, 0.0, 0.0); Geom::Scale sca(1.0, -1.0); Geom::Affine m = m1.inverse() * m2; @@ -299,8 +307,8 @@ LPEMirrorSymmetry::doEffect_path (Geom::PathVector const & path_in) } if (!fuse_paths || discard_orig_path) { - for (int i = 0; i < static_cast<int>(path_in.size()); ++i) { - path_out.push_back(path_in[i] * m); + for (size_t i = 0; i < original_pathv.size(); ++i) { + path_out.push_back(original_pathv[i] * m); } } diff --git a/src/live_effects/lpe-mirror_symmetry.h b/src/live_effects/lpe-mirror_symmetry.h index 9e5b4d628..7ec4029e0 100644 --- a/src/live_effects/lpe-mirror_symmetry.h +++ b/src/live_effects/lpe-mirror_symmetry.h @@ -46,6 +46,7 @@ public: virtual ~LPEMirrorSymmetry(); virtual void doOnApply (SPLPEItem const* lpeitem); virtual void doBeforeEffect (SPLPEItem const* lpeitem); + virtual void transform_multiply(Geom::Affine const& postmul, bool set); virtual Geom::PathVector doEffect_path (Geom::PathVector const & path_in); /* the knotholder entity classes must be declared friends */ friend class MS::KnotHolderEntityCenterMirrorSymmetry; diff --git a/src/live_effects/lpe-offset.cpp b/src/live_effects/lpe-offset.cpp index d611b88a1..a0fa46c3f 100644 --- a/src/live_effects/lpe-offset.cpp +++ b/src/live_effects/lpe-offset.cpp @@ -17,11 +17,7 @@ #include "sp-shape.h" #include "display/curve.h" -#include <2geom/path.h> -#include <2geom/piecewise.h> -#include <2geom/sbasis-geometric.h> #include <2geom/elliptical-arc.h> -#include <2geom/transforms.h> namespace Inkscape { namespace LivePathEffect { diff --git a/src/live_effects/lpe-parallel.cpp b/src/live_effects/lpe-parallel.cpp index 23cd5e2e7..9cd8ecf46 100644 --- a/src/live_effects/lpe-parallel.cpp +++ b/src/live_effects/lpe-parallel.cpp @@ -17,10 +17,6 @@ #include "sp-shape.h" #include "display/curve.h" -#include <2geom/path.h> -#include <2geom/transforms.h> - -#include "knot-holder-entity.h" #include "knotholder.h" namespace Inkscape { diff --git a/src/live_effects/lpe-path_length.cpp b/src/live_effects/lpe-path_length.cpp index 4ca380c15..8fbf9d420 100644 --- a/src/live_effects/lpe-path_length.cpp +++ b/src/live_effects/lpe-path_length.cpp @@ -16,8 +16,6 @@ #include "live_effects/lpe-path_length.h" #include "util/units.h" -#include "2geom/sbasis-geometric.h" - namespace Inkscape { namespace LivePathEffect { diff --git a/src/live_effects/lpe-patternalongpath.cpp b/src/live_effects/lpe-patternalongpath.cpp index 911c410f9..0785da235 100644 --- a/src/live_effects/lpe-patternalongpath.cpp +++ b/src/live_effects/lpe-patternalongpath.cpp @@ -6,22 +6,13 @@ #include "live_effects/lpe-patternalongpath.h" #include "live_effects/lpeobject.h" -#include "sp-shape.h" #include "display/curve.h" -#include "svg/svg.h" -#include "ui/widget/scalar.h" -#include <2geom/sbasis.h> -#include <2geom/sbasis-geometric.h> #include <2geom/bezier-to-sbasis.h> -#include <2geom/sbasis-to-bezier.h> -#include <2geom/d2.h> -#include <2geom/piecewise.h> -#include "knot-holder-entity.h" #include "knotholder.h" - #include <algorithm> + using std::vector; @@ -202,12 +193,12 @@ LPEPatternAlongPath::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > con case PAPCT_REPEATED_STRETCHED: // if uskeleton is closed: if(path_i.segs.front().at0() == path_i.segs.back().at1()){ - nbCopies = static_cast<int>(std::floor((uskeleton.domain().extent() - toffset)/(pattBndsX->extent()+xspace))); + nbCopies = std::max(1, static_cast<int>(std::floor((uskeleton.domain().extent() - toffset)/(pattBndsX->extent()+xspace)))); pattBndsX = Interval(pattBndsX->min(),pattBndsX->max()+xspace); scaling = (uskeleton.domain().extent() - toffset)/(((double)nbCopies)*pattBndsX->extent()); // if not closed: no space at the end }else{ - nbCopies = static_cast<int>(std::floor((uskeleton.domain().extent() - toffset + xspace)/(pattBndsX->extent()+xspace))); + nbCopies = std::max(1, static_cast<int>(std::floor((uskeleton.domain().extent() - toffset + xspace)/(pattBndsX->extent()+xspace)))); pattBndsX = Interval(pattBndsX->min(),pattBndsX->max()+xspace); scaling = (uskeleton.domain().extent() - toffset)/(((double)nbCopies)*pattBndsX->extent() - xspace); } @@ -264,9 +255,11 @@ LPEPatternAlongPath::transform_multiply(Geom::Affine const& postmul, bool set) bool transform_stroke = prefs ? prefs->getBool("/options/transform/stroke", true) : true; if (transform_stroke && !scale_y_rel) { prop_scale.param_set_value(prop_scale * ((postmul.expansionX() + postmul.expansionY()) / 2)); - } + prop_scale.write_to_SVG(); + } if (postmul.isTranslation()) { pattern.param_transform_multiply(postmul, set); + pattern.write_to_SVG(); } sp_lpe_item_update_patheffect (sp_lpe_item, false, true); } diff --git a/src/live_effects/lpe-perp_bisector.cpp b/src/live_effects/lpe-perp_bisector.cpp index 660318c57..f69dae6a1 100644 --- a/src/live_effects/lpe-perp_bisector.cpp +++ b/src/live_effects/lpe-perp_bisector.cpp @@ -18,10 +18,7 @@ #include "display/curve.h" #include "sp-path.h" #include "line-geometry.h" -#include "sp-lpe-item.h" -#include <2geom/path.h> -#include "knot-holder-entity.h" #include "knotholder.h" namespace Inkscape { diff --git a/src/live_effects/lpe-perspective-envelope.cpp b/src/live_effects/lpe-perspective-envelope.cpp index ae951dfc9..6a6b59519 100644 --- a/src/live_effects/lpe-perspective-envelope.cpp +++ b/src/live_effects/lpe-perspective-envelope.cpp @@ -18,7 +18,6 @@ #include "live_effects/lpe-perspective-envelope.h" #include "helper/geom.h" #include "display/curve.h" -#include "svg/svg.h" #include <gsl/gsl_linalg.h> using namespace Geom; @@ -32,8 +31,8 @@ enum DeformationType { }; static const Util::EnumData<unsigned> DeformationTypeData[] = { - {DEFORMATION_PERSPECTIVE , N_("Perspective"), "Perspective"}, - {DEFORMATION_ENVELOPE , N_("Envelope deformation"), "Envelope deformation"} + {DEFORMATION_PERSPECTIVE , N_("Perspective"), "perspective"}, + {DEFORMATION_ENVELOPE , N_("Envelope deformation"), "envelope_deformation"} }; static const Util::EnumDataConverter<unsigned> DeformationTypeConverter(DeformationTypeData, sizeof(DeformationTypeData)/sizeof(*DeformationTypeData)); diff --git a/src/live_effects/lpe-perspective_path.cpp b/src/live_effects/lpe-perspective_path.cpp index c8cdd7912..cb4e43d87 100644 --- a/src/live_effects/lpe-perspective_path.cpp +++ b/src/live_effects/lpe-perspective_path.cpp @@ -15,18 +15,13 @@ #include "persp3d.h" //#include "transf_mat_3x4.h" -#include "document.h" #include "document-private.h" #include "live_effects/lpe-perspective_path.h" #include "live_effects/lpeobject.h" -#include "sp-item-group.h" #include "knot-holder-entity.h" #include "knotholder.h" #include "desktop.h" #include <util/units.h> -#include "inkscape.h" - -#include <2geom/path.h> namespace Inkscape { namespace LivePathEffect { @@ -107,12 +102,12 @@ void LPEPerspectivePath::refresh(Gtk::Entry* perspective) { perspectiveID = perspective->get_text(); Persp3D *first = 0; Persp3D *persp = 0; - for ( SPObject *child = this->lpeobj->document->getDefs()->firstChild(); child && !persp; child = child->getNext() ) { - if (SP_IS_PERSP3D(child) && first == 0) { - first = SP_PERSP3D(child); + for (auto& child: lpeobj->document->getDefs()->children) { + if (SP_IS_PERSP3D(&child) && first == 0) { + first = SP_PERSP3D(&child); } - if (SP_IS_PERSP3D(child) && strcmp(child->getId(), const_cast<const gchar *>(perspectiveID.c_str())) == 0) { - persp = SP_PERSP3D(child); + if (SP_IS_PERSP3D(&child) && strcmp(child.getId(), const_cast<const gchar *>(perspectiveID.c_str())) == 0) { + persp = SP_PERSP3D(&child); break; } } diff --git a/src/live_effects/lpe-powerstroke.cpp b/src/live_effects/lpe-powerstroke.cpp index 66c8776b5..0de668847 100644 --- a/src/live_effects/lpe-powerstroke.cpp +++ b/src/live_effects/lpe-powerstroke.cpp @@ -13,32 +13,17 @@ #include "live_effects/lpe-powerstroke.h" #include "live_effects/lpe-powerstroke-interpolators.h" -#include "sp-shape.h" #include "style.h" -#include "xml/repr.h" -#include "sp-paint-server.h" #include "svg/svg-color.h" #include "desktop-style.h" #include "svg/css-ostringstream.h" #include "display/curve.h" -#include <2geom/path.h> -#include <2geom/piecewise.h> -#include <2geom/sbasis-geometric.h> -#include <2geom/transforms.h> -#include <2geom/bezier-utils.h> #include <2geom/elliptical-arc.h> -#include <2geom/sbasis-to-bezier.h> #include <2geom/path-sink.h> #include <2geom/path-intersection.h> -#include <2geom/crossing.h> -#include <2geom/ellipse.h> #include <2geom/circle.h> -#include <2geom/math-utils.h> #include "helper/geom.h" -#include <math.h> - -#include "spiro.h" namespace Geom { // should all be moved to 2geom at some point diff --git a/src/live_effects/lpe-recursiveskeleton.cpp b/src/live_effects/lpe-recursiveskeleton.cpp index ac571d963..ed0c915ce 100644 --- a/src/live_effects/lpe-recursiveskeleton.cpp +++ b/src/live_effects/lpe-recursiveskeleton.cpp @@ -14,13 +14,7 @@ #include "live_effects/lpe-recursiveskeleton.h" -#include <2geom/path.h> -#include <2geom/sbasis.h> -#include <2geom/sbasis-geometric.h> #include <2geom/bezier-to-sbasis.h> -#include <2geom/sbasis-to-bezier.h> -#include <2geom/d2.h> -#include <2geom/piecewise.h> namespace Inkscape { namespace LivePathEffect { diff --git a/src/live_effects/lpe-rough-hatches.cpp b/src/live_effects/lpe-rough-hatches.cpp index 76421e0f0..2fb65b349 100644 --- a/src/live_effects/lpe-rough-hatches.cpp +++ b/src/live_effects/lpe-rough-hatches.cpp @@ -18,18 +18,10 @@ #include "sp-item.h" #include "sp-path.h" -#include "svg/svg.h" #include "xml/repr.h" -#include <2geom/path.h> -#include <2geom/piecewise.h> -#include <2geom/sbasis.h> #include <2geom/sbasis-math.h> -#include <2geom/sbasis-geometric.h> #include <2geom/bezier-to-sbasis.h> -#include <2geom/sbasis-to-bezier.h> -#include <2geom/d2.h> -#include <2geom/affine.h> namespace Inkscape { diff --git a/src/live_effects/lpe-roughen.cpp b/src/live_effects/lpe-roughen.cpp index 13f2b7b51..3a486ff10 100644 --- a/src/live_effects/lpe-roughen.cpp +++ b/src/live_effects/lpe-roughen.cpp @@ -14,15 +14,10 @@ */ #include "live_effects/lpe-roughen.h" -#include "desktop.h" #include "display/curve.h" -#include "live_effects/parameter/parameter.h" #include <boost/functional/hash.hpp> #include "helper/geom.h" -#include "sp-item-group.h" -#include <cmath> // TODO due to internal breakage in glibmm headers, this must be last: -#include <glibmm/i18n.h> namespace Inkscape { namespace LivePathEffect { diff --git a/src/live_effects/lpe-ruler.cpp b/src/live_effects/lpe-ruler.cpp index 49b5faa2e..3a2d78b2c 100644 --- a/src/live_effects/lpe-ruler.cpp +++ b/src/live_effects/lpe-ruler.cpp @@ -12,10 +12,6 @@ */ #include "live_effects/lpe-ruler.h" -#include <2geom/piecewise.h> -#include <2geom/sbasis-geometric.h> -#include "inkscape.h" -#include "desktop.h" namespace Inkscape { diff --git a/src/live_effects/lpe-show_handles.cpp b/src/live_effects/lpe-show_handles.cpp index 2d4666fe4..388ea176f 100644 --- a/src/live_effects/lpe-show_handles.cpp +++ b/src/live_effects/lpe-show_handles.cpp @@ -7,7 +7,6 @@ */ #include "live_effects/lpe-show_handles.h" -#include "live_effects/parameter/parameter.h" #include <2geom/sbasis-to-bezier.h> #include <2geom/svg-path-parser.h> #include "helper/geom.h" diff --git a/src/live_effects/lpe-simplify.cpp b/src/live_effects/lpe-simplify.cpp index b0c1fbc23..ec21e10d2 100644 --- a/src/live_effects/lpe-simplify.cpp +++ b/src/live_effects/lpe-simplify.cpp @@ -4,20 +4,11 @@ #include "live_effects/lpe-simplify.h" #include "display/curve.h" -#include "live_effects/parameter/parameter.h" #include "helper/geom.h" -#include "livarot/Path.h" -#include "splivarot.h" #include <2geom/svg-path-parser.h> -#include "desktop.h" -#include "inkscape.h" #include "svg/svg.h" #include "ui/tools/node-tool.h" -#include <2geom/d2.h> -#include <2geom/generic-rect.h> -#include <2geom/interval.h> #include "ui/icon-names.h" -#include "util/units.h" // TODO due to internal breakage in glibmm headers, this must be last: #include <glibmm/i18n.h> diff --git a/src/live_effects/lpe-skeleton.cpp b/src/live_effects/lpe-skeleton.cpp index 6e4afbe9b..7d34db699 100644 --- a/src/live_effects/lpe-skeleton.cpp +++ b/src/live_effects/lpe-skeleton.cpp @@ -21,13 +21,9 @@ #include "live_effects/lpe-skeleton.h" // You might need to include other 2geom files. You can add them here: -#include <2geom/path.h> #include <glibmm/i18n.h> -//#include "knot-holder-entity.h" -//#include "knotholder.h" - namespace Inkscape { namespace LivePathEffect { diff --git a/src/live_effects/lpe-sketch.cpp b/src/live_effects/lpe-sketch.cpp index 82d343f6e..95e2f6f0d 100644 --- a/src/live_effects/lpe-sketch.cpp +++ b/src/live_effects/lpe-sketch.cpp @@ -16,16 +16,8 @@ #include <glibmm/i18n.h> // You might need to include other 2geom files. You can add them here: -#include <2geom/path.h> -#include <2geom/sbasis.h> -#include <2geom/sbasis-geometric.h> #include <2geom/sbasis-math.h> #include <2geom/bezier-to-sbasis.h> -#include <2geom/sbasis-to-bezier.h> -#include <2geom/d2.h> -#include <2geom/sbasis-math.h> -#include <2geom/piecewise.h> -#include <2geom/crossing.h> #include <2geom/path-intersection.h> namespace Inkscape { diff --git a/src/live_effects/lpe-spiro.cpp b/src/live_effects/lpe-spiro.cpp index 0d42596b2..4a41dc5a0 100644 --- a/src/live_effects/lpe-spiro.cpp +++ b/src/live_effects/lpe-spiro.cpp @@ -7,9 +7,6 @@ #include "live_effects/lpe-spiro.h" #include "display/curve.h" -#include <typeinfo> -#include <2geom/pathvector.h> -#include <2geom/affine.h> #include <2geom/curves.h> #include "helper/geom-nodetype.h" #include "helper/geom-curves.h" diff --git a/src/live_effects/lpe-tangent_to_curve.cpp b/src/live_effects/lpe-tangent_to_curve.cpp index 978ab57fb..b308ef8d7 100644 --- a/src/live_effects/lpe-tangent_to_curve.cpp +++ b/src/live_effects/lpe-tangent_to_curve.cpp @@ -19,10 +19,6 @@ #include "sp-path.h" #include "display/curve.h" -#include <2geom/path.h> -#include <2geom/transforms.h> - -#include "knot-holder-entity.h" #include "knotholder.h" namespace Inkscape { diff --git a/src/live_effects/lpe-taperstroke.cpp b/src/live_effects/lpe-taperstroke.cpp index f2ddd4929..f6f6b33dc 100644 --- a/src/live_effects/lpe-taperstroke.cpp +++ b/src/live_effects/lpe-taperstroke.cpp @@ -13,28 +13,20 @@ #include "live_effects/lpe-taperstroke.h" -#include <2geom/path.h> -#include <2geom/path.h> #include <2geom/circle.h> #include <2geom/sbasis-to-bezier.h> #include "helper/geom-nodetype.h" #include "helper/geom-pathstroke.h" #include "display/curve.h" -#include "sp-shape.h" #include "style.h" -#include "xml/repr.h" -#include "sp-paint-server.h" #include "svg/svg-color.h" #include "desktop-style.h" #include "svg/css-ostringstream.h" #include "svg/svg.h" -#include "knot-holder-entity.h" #include "knotholder.h" -#include <glibmm/i18n.h> - template<typename T> inline bool withinRange(T value, T low, T high) { return (value > low && value < high); diff --git a/src/live_effects/lpe-test-doEffect-stack.cpp b/src/live_effects/lpe-test-doEffect-stack.cpp index 2bcd4c136..c7ecf6481 100644 --- a/src/live_effects/lpe-test-doEffect-stack.cpp +++ b/src/live_effects/lpe-test-doEffect-stack.cpp @@ -8,9 +8,6 @@ #include "live_effects/lpe-test-doEffect-stack.h" -#include <2geom/piecewise.h> -#include <vector> -#include <cstring> using std::memcpy; namespace Inkscape { diff --git a/src/live_effects/lpe-transform_2pts.cpp b/src/live_effects/lpe-transform_2pts.cpp index d32cf42fc..78db622f2 100644 --- a/src/live_effects/lpe-transform_2pts.cpp +++ b/src/live_effects/lpe-transform_2pts.cpp @@ -14,9 +14,6 @@ #include "live_effects/lpe-transform_2pts.h" #include "display/curve.h" -#include <2geom/transforms.h> -#include <2geom/pathvector.h> -#include "sp-path.h" #include "ui/icon-names.h" #include "svg/svg.h" #include "verbs.h" diff --git a/src/live_effects/lpe-vonkoch.cpp b/src/live_effects/lpe-vonkoch.cpp index 7eda7446e..2486f3366 100644 --- a/src/live_effects/lpe-vonkoch.cpp +++ b/src/live_effects/lpe-vonkoch.cpp @@ -8,8 +8,6 @@ #include <glibmm/i18n.h> -#include <2geom/transforms.h> - //using std::vector; namespace Inkscape { namespace LivePathEffect { diff --git a/src/live_effects/lpegroupbbox.cpp b/src/live_effects/lpegroupbbox.cpp index 2a1b70a6a..3862ebcc8 100644 --- a/src/live_effects/lpegroupbbox.cpp +++ b/src/live_effects/lpegroupbbox.cpp @@ -7,8 +7,6 @@ #include "live_effects/lpegroupbbox.h" -#include "sp-item.h" - namespace Inkscape { namespace LivePathEffect { diff --git a/src/live_effects/lpeobject-reference.cpp b/src/live_effects/lpeobject-reference.cpp index d9de6e77f..1940806bd 100644 --- a/src/live_effects/lpeobject-reference.cpp +++ b/src/live_effects/lpeobject-reference.cpp @@ -8,7 +8,6 @@ #include <string.h> -#include "enums.h" #include "live_effects/lpeobject-reference.h" #include "live_effects/lpeobject.h" #include "uri.h" diff --git a/src/live_effects/lpeobject.cpp b/src/live_effects/lpeobject.cpp index 8e5ae568f..b5b27c984 100644 --- a/src/live_effects/lpeobject.cpp +++ b/src/live_effects/lpeobject.cpp @@ -11,13 +11,10 @@ #include "xml/repr.h" #include "xml/node-event-vector.h" -#include "sp-object.h" #include "attributes.h" #include "document.h" #include "document-private.h" -#include <glibmm/i18n.h> - //#define LIVEPATHEFFECT_VERBOSE static void livepatheffect_on_repr_attr_changed (Inkscape::XML::Node * repr, const gchar *key, const gchar *oldval, const gchar *newval, bool is_interactive, void * data); diff --git a/src/live_effects/parameter/Makefile_insert b/src/live_effects/parameter/Makefile_insert deleted file mode 100644 index d9cd5b3c1..000000000 --- a/src/live_effects/parameter/Makefile_insert +++ /dev/null @@ -1,38 +0,0 @@ -## Makefile.am fragment sourced by src/Makefile.am. - -ink_common_sources += \ - live_effects/parameter/parameter.cpp \ - live_effects/parameter/parameter.h \ - live_effects/parameter/array.cpp \ - live_effects/parameter/array.h \ - live_effects/parameter/bool.cpp \ - live_effects/parameter/bool.h \ - live_effects/parameter/random.cpp \ - live_effects/parameter/random.h \ - live_effects/parameter/point.cpp \ - live_effects/parameter/point.h \ - live_effects/parameter/fontbutton.cpp \ - live_effects/parameter/fontbutton.h \ - live_effects/parameter/enum.h \ - live_effects/parameter/path-reference.cpp \ - live_effects/parameter/path-reference.h \ - live_effects/parameter/path.cpp \ - live_effects/parameter/path.h \ - live_effects/parameter/originalpath.cpp \ - live_effects/parameter/originalpath.h \ - live_effects/parameter/originalpatharray.cpp \ - live_effects/parameter/originalpatharray.h \ - live_effects/parameter/powerstrokepointarray.cpp \ - live_effects/parameter/powerstrokepointarray.h \ - live_effects/parameter/filletchamferpointarray.cpp \ - live_effects/parameter/filletchamferpointarray.h \ - live_effects/parameter/text.cpp \ - live_effects/parameter/text.h \ - live_effects/parameter/transformedpoint.cpp \ - live_effects/parameter/transformedpoint.h \ - live_effects/parameter/togglebutton.cpp \ - live_effects/parameter/togglebutton.h \ - live_effects/parameter/unit.cpp \ - live_effects/parameter/unit.h \ - live_effects/parameter/vector.cpp \ - live_effects/parameter/vector.h diff --git a/src/live_effects/parameter/togglebutton.cpp b/src/live_effects/parameter/togglebutton.cpp index dd1717b40..b3f6442bb 100644 --- a/src/live_effects/parameter/togglebutton.cpp +++ b/src/live_effects/parameter/togglebutton.cpp @@ -75,12 +75,8 @@ ToggleButtonParam::param_newWidget() false, param_effect->getRepr(), param_effect->getSPDoc()) ); -#if GTK_CHECK_VERSION(3,0,0) - GtkWidget * box_button = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); + auto box_button = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); gtk_box_set_homogeneous(GTK_BOX(box_button), false); -#else - GtkWidget * box_button = gtk_hbox_new (false, 0); -#endif GtkWidget * label_button = gtk_label_new (""); if (!param_label.empty()) { if(value || inactive_label.empty()){ @@ -167,7 +163,7 @@ ToggleButtonParam::toggled() { param_effect->upd_params = true; if (SP_ACTIVE_DESKTOP) { Inkscape::Selection *selection = SP_ACTIVE_DESKTOP->getSelection(); - selection ->emitModified(); + selection->emitModified(); } _signal_toggled.emit(); } diff --git a/src/live_effects/spiro.cpp b/src/live_effects/spiro.cpp index 0ac2815bf..a2ff4813e 100644 --- a/src/live_effects/spiro.cpp +++ b/src/live_effects/spiro.cpp @@ -29,7 +29,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA #include <string.h> #include "display/curve.h" -#include <2geom/math-utils.h> #define SPIRO_SHOW_INFINITE_COORDINATE_CALLS diff --git a/src/main-cmdlineact.cpp b/src/main-cmdlineact.cpp index 496c16d5d..a23c036a0 100644 --- a/src/main-cmdlineact.cpp +++ b/src/main-cmdlineact.cpp @@ -10,7 +10,6 @@ #include <ui/view/view.h> #include <desktop.h> #include <helper/action.h> -#include <helper/action-context.h> #include <selection.h> #include <verbs.h> #include <inkscape.h> @@ -24,74 +23,81 @@ namespace Inkscape { std::list <CmdLineAction *> CmdLineAction::_list; -CmdLineAction::CmdLineAction (bool isVerb, gchar const * arg) : _isVerb(isVerb), _arg(NULL) { - if (arg != NULL) { - _arg = g_strdup(arg); - } +CmdLineAction::CmdLineAction(bool isVerb, gchar const *arg) : _isVerb(isVerb), _arg(NULL) +{ + if (arg != NULL) { + _arg = g_strdup(arg); + } - _list.insert(_list.end(), this); + _list.insert(_list.end(), this); - return; + return; } -CmdLineAction::~CmdLineAction () { - if (_arg != NULL) { - g_free(_arg); - } +CmdLineAction::~CmdLineAction() +{ + if (_arg != NULL) { + g_free(_arg); + } } void -CmdLineAction::doIt (ActionContext const & context) { - //printf("Doing: %s\n", _arg); - if (_isVerb) { - Inkscape::Verb * verb = Inkscape::Verb::getbyid(_arg); - if (verb == NULL) { - printf(_("Unable to find verb ID '%s' specified on the command line.\n"), _arg); - return; - } - SPAction * action = verb->get_action(context); - sp_action_perform(action, NULL); - } else { - if (context.getDocument() == NULL || context.getSelection() == NULL) { return; } - - SPDocument * doc = context.getDocument(); - SPObject * obj = doc->getObjectById(_arg); - if (obj == NULL) { - printf(_("Unable to find node ID: '%s'\n"), _arg); - return; - } - - Inkscape::Selection * selection = context.getSelection(); - selection->add(obj, false); - } - return; +CmdLineAction::doIt(ActionContext const &context) +{ + //printf("Doing: %s\n", _arg); + if (_isVerb) { + Inkscape::Verb *verb = Inkscape::Verb::getbyid(_arg); + if (verb == NULL) { + printf(_("Unable to find verb ID '%s' specified on the command line.\n"), _arg); + return; + } + SPAction *action = verb->get_action(context); + sp_action_perform(action, NULL); + } else { + if (context.getDocument() == NULL || context.getSelection() == NULL) { + return; + } + + SPDocument *doc = context.getDocument(); + SPObject *obj = doc->getObjectById(_arg); + if (obj == NULL) { + printf(_("Unable to find node ID: '%s'\n"), _arg); + return; + } + + Inkscape::Selection *selection = context.getSelection(); + selection->add(obj); + } + return; } bool -CmdLineAction::doList (ActionContext const & context) { - bool hasActions = !_list.empty(); - for (std::list<CmdLineAction *>::iterator i = _list.begin(); - i != _list.end(); ++i) { - CmdLineAction * entry = *i; - entry->doIt(context); - } - return hasActions; +CmdLineAction::doList(ActionContext const &context) +{ + bool hasActions = !_list.empty(); + for (std::list<CmdLineAction *>::iterator i = _list.begin(); + i != _list.end(); ++i) { + CmdLineAction *entry = *i; + entry->doIt(context); + } + return hasActions; } bool -CmdLineAction::idle (void) { - std::list<SPDesktop *> desktops; - INKSCAPE.get_all_desktops(desktops); - - // We're going to assume one desktop per document, because no one - // should have had time to make more at this point. - for (std::list<SPDesktop *>::iterator i = desktops.begin(); - i != desktops.end(); ++i) { - SPDesktop * desktop = *i; - //Inkscape::UI::View::View * view = dynamic_cast<Inkscape::UI::View::View *>(desktop); - doList(ActionContext(desktop)); - } - return false; +CmdLineAction::idle(void) +{ + std::list<SPDesktop *> desktops; + INKSCAPE.get_all_desktops(desktops); + + // We're going to assume one desktop per document, because no one + // should have had time to make more at this point. + for (std::list<SPDesktop *>::iterator i = desktops.begin(); + i != desktops.end(); ++i) { + SPDesktop *desktop = *i; + //Inkscape::UI::View::View * view = dynamic_cast<Inkscape::UI::View::View *>(desktop); + doList(ActionContext(desktop)); + } + return false; } } // Inkscape diff --git a/src/main-cmdlineact.h b/src/main-cmdlineact.h index b8ec4403b..171313401 100644 --- a/src/main-cmdlineact.h +++ b/src/main-cmdlineact.h @@ -21,18 +21,18 @@ class ActionContext; class CmdLineAction { bool _isVerb; - char * _arg; + char *_arg; static std::list <CmdLineAction *> _list; public: - CmdLineAction (bool isVerb, char const * arg); - virtual ~CmdLineAction (); + CmdLineAction(bool isVerb, char const *arg); + virtual ~CmdLineAction(); - void doIt (ActionContext const & context); + void doIt(ActionContext const &context); /** Return true if any actions were performed */ - static bool doList (ActionContext const & context); - static bool idle (void); + static bool doList(ActionContext const &context); + static bool idle(void); }; } // Inkscape diff --git a/src/main.cpp b/src/main.cpp index 8cf52127b..004d96191 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -38,9 +38,6 @@ #include <ieeefp.h> #endif #include <cstring> -#include <string> -#include <locale.h> -#include <stdlib.h> #include <popt.h> #ifndef POPT_TABLEEND @@ -48,14 +45,8 @@ #endif /* Not def: POPT_TABLEEND */ #include <libxml/tree.h> -#include <glib/gprintf.h> -#include <glib-object.h> -#include <gtk/gtk.h> -#if GTK_CHECK_VERSION(3,0,0) -#include <gtkmm/cssprovider.h> #include <gdkmm/screen.h> -#endif #include "inkgc/gc-core.h" @@ -63,16 +54,13 @@ #undef AND #endif -#include "macros.h" #include "file.h" #include "document.h" #include "layer-model.h" #include "selection.h" -#include "sp-object.h" #include "ui/interface.h" #include "print.h" #include "color.h" -#include "sp-item.h" #include "sp-root.h" #include "svg/svg.h" @@ -93,10 +81,8 @@ #include "helper/action-context.h" #include "helper/png-write.h" -#include "helper/geom.h" #include <extension/extension.h> -#include <extension/system.h> #include <extension/db.h> #include <extension/output.h> #include <extension/input.h> @@ -114,10 +100,12 @@ #endif // WITH_DBUS #include <glibmm/i18n.h> -#include <glibmm/main.h> +#include <glibmm/convert.h> +#include <glibmm/fileutils.h> #include <glibmm/miscutils.h> - +#include <glibmm/main.h> #include <gtkmm/main.h> +#include <gtkmm/window.h> #ifndef HAVE_BIND_TEXTDOMAIN_CODESET #define bind_textdomain_codeset(p,c) @@ -129,8 +117,6 @@ #include <errno.h> #include "verbs.h" -#include <gdk/gdkkeysyms.h> - #include "path-chemistry.h" #include "sp-text.h" #include "sp-flowtext.h" @@ -867,10 +853,10 @@ static int sp_common_main( int argc, char const **argv, GSList **flDest ) // temporarily switch gettext encoding to locale, so that help messages can be output properly - gchar const *charset; - g_get_charset(&charset); + std::string charset; + Glib::get_charset(charset); - bind_textdomain_codeset(GETTEXT_PACKAGE, charset); + bind_textdomain_codeset(GETTEXT_PACKAGE, charset.c_str()); poptContext ctx = poptGetContext(NULL, argc, argv, options, 0); poptSetOtherOptionHelp(ctx, _("[OPTIONS...] [FILE...]\n\nAvailable options:")); @@ -1014,16 +1000,6 @@ snooper(GdkEvent *event, gpointer /*data*/) { gtk_main_do_event (event); } -static std::vector<Glib::ustring> getDirectorySet(const gchar* userDir, const gchar* const * systemDirs) { - std::vector<Glib::ustring> listing; - listing.push_back(userDir); - for ( const char* const* cur = systemDirs; *cur; cur++ ) - { - listing.push_back(*cur); - } - return listing; -} - int sp_main_gui(int argc, char const **argv) { @@ -1033,106 +1009,23 @@ sp_main_gui(int argc, char const **argv) int retVal = sp_common_main( argc, argv, &fl ); g_return_val_if_fail(retVal == 0, 1); - // Add possible icon entry directories - std::vector<Glib::ustring> dataDirs = getDirectorySet( g_get_user_data_dir(), - g_get_system_data_dirs() ); - for (std::vector<Glib::ustring>::iterator it = dataDirs.begin(); it != dataDirs.end(); ++it) - { - std::vector<Glib::ustring> listing; - listing.push_back(*it); - listing.push_back("inkscape"); - listing.push_back("icons"); - Glib::ustring dir = Glib::build_filename(listing); - gtk_icon_theme_append_search_path(gtk_icon_theme_get_default(), dir.c_str()); - } - - // Add our icon directory to the search path for icon theme lookups. - gchar *usericondir = Inkscape::Application::profile_path("icons"); - gtk_icon_theme_append_search_path(gtk_icon_theme_get_default(), usericondir); - gtk_icon_theme_append_search_path(gtk_icon_theme_get_default(), INKSCAPE_PIXMAPDIR); -#ifdef INKSCAPE_THEMEDIR - gtk_icon_theme_append_search_path(gtk_icon_theme_get_default(), INKSCAPE_THEMEDIR); - gtk_icon_theme_rescan_if_needed (gtk_icon_theme_get_default()); -#endif - g_free(usericondir); - - -#if GTK_CHECK_VERSION(3,0,0) - // Add style sheet (GTK3) - Glib::RefPtr<Gdk::Screen> screen = Gdk::Screen::get_default(); - - Glib::ustring inkscape_style = INKSCAPE_UIDIR; - inkscape_style += "/style.css"; - // std::cout << "CSS Stylesheet Inkscape: " << inkscape_style << std::endl; - - if (g_file_test (inkscape_style.c_str(), G_FILE_TEST_EXISTS)) { - Glib::RefPtr<Gtk::CssProvider> provider = Gtk::CssProvider::create(); - - // From 3.16, throws an error which we must catch. - try { - provider->load_from_path (inkscape_style); - } -#if GTK_CHECK_VERSION(3,16,0) - // Gtk::CssProviderError not defined until 3.16. - catch (const Gtk::CssProviderError& ex) - { - std::cerr << "CSSProviderError::load_from_path(): failed to load: " << inkscape_style - << "\n (" << ex.what() << ")" << std::endl; - } -#else - catch (...) - {} -#endif - - Gtk::StyleContext::add_provider_for_screen (screen, provider, GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); - } else { - std::cerr << "sp_main_gui: Cannot find default style file:\n (" << inkscape_style - << ")" << std::endl; - } - - Glib::ustring user_style = Inkscape::Application::profile_path("ui/style.css"); - // std::cout << "CSS Stylesheet User: " << user_style << std::endl; - - if (g_file_test (user_style.c_str(), G_FILE_TEST_EXISTS)) { - Glib::RefPtr<Gtk::CssProvider> provider2 = Gtk::CssProvider::create(); - - // From 3.16, throws an error which we must catch. - try { - provider2->load_from_path (user_style); - } -#if GTK_CHECK_VERSION(3,16,0) - // Gtk::CssProviderError not defined until 3.16. - catch (const Gtk::CssProviderError& ex) - { - std::cerr << "CSSProviderError::load_from_path(): failed to load: " << user_style - << "\n (" << ex.what() << ")" << std::endl; - } -#else - catch (...) - {} -#endif - - Gtk::StyleContext::add_provider_for_screen (screen, provider2, GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); - } -#endif - gdk_event_handler_set((GdkEventFunc)snooper, NULL, NULL); Inkscape::Debug::log_display_config(); // Set default window icon. Obeys the theme. - gtk_window_set_default_icon_name("inkscape"); + Gtk::Window::set_default_icon_name("inkscape"); // Do things that were previously in inkscape_gtk_stock_init(). sp_icon_get_phys_size(GTK_ICON_SIZE_MENU); Inkscape::UI::Widget::Panel::prep(); - gboolean create_new = TRUE; + bool create_new = true; /// \todo FIXME BROKEN - non-UTF-8 sneaks in here. Inkscape::Application::create(argv[0], true); while (fl) { if (sp_file_open((gchar *)fl->data,NULL)) { - create_new=FALSE; + create_new=false; } fl = g_slist_remove(fl, fl->data); } @@ -1228,8 +1121,8 @@ static int sp_process_file_list(GSList *fl) std::vector<SPItem*> items; SPRoot *root = doc->getRoot(); doc->ensureUpToDate(); - for ( SPObject *iter = root->firstChild(); iter ; iter = iter->getNext()) { - SPItem* item = (SPItem*) iter; + for (auto& iter: root->children) { + SPItem* item = (SPItem*) &iter; if (! (SP_IS_TEXT(item) || SP_IS_FLOWTEXT(item) || SP_IS_GROUP(item))) { continue; } @@ -1483,10 +1376,8 @@ do_query_all_recurse (SPObject *o) } } - SPObject *child = o->children; - while (child) { - do_query_all_recurse (child); - child = child->next; + for(auto& child: o->children) { + do_query_all_recurse (&child); } } diff --git a/src/marker-test.h b/src/marker-test.h deleted file mode 100644 index bf7e1040a..000000000 --- a/src/marker-test.h +++ /dev/null @@ -1,39 +0,0 @@ -/** @file - * @brief Unit tests for SVG marker handling - */ -/* Authors: - * Johan Engelen <goejendaagh@zonnet.nl> - * - * This file is released into the public domain. - */ - -#include <cxxtest/TestSuite.h> - -#include "sp-marker-loc.h" - -class MarkerTest : public CxxTest::TestSuite -{ -public: - - void testMarkerLoc() - { - // code depends on these *exact* values, so check them here. - TS_ASSERT_EQUALS(SP_MARKER_LOC, 0); - TS_ASSERT_EQUALS(SP_MARKER_LOC_START, 1); - TS_ASSERT_EQUALS(SP_MARKER_LOC_MID, 2); - TS_ASSERT_EQUALS(SP_MARKER_LOC_END, 3); - TS_ASSERT_EQUALS(SP_MARKER_LOC_QTY, 4); - } - -}; - -/* - 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/message-stack.cpp b/src/message-stack.cpp index bc89520b7..70b2fb42d 100644 --- a/src/message-stack.cpp +++ b/src/message-stack.cpp @@ -12,7 +12,6 @@ #include <string.h> #include <glib.h> #include <cstring> -#include <string> #include "message-stack.h" namespace Inkscape { diff --git a/src/mod360-test.h b/src/mod360-test.h deleted file mode 100644 index 932361eb3..000000000 --- a/src/mod360-test.h +++ /dev/null @@ -1,56 +0,0 @@ - -#ifndef SEEN_MOD_360_TEST_H -#define SEEN_MOD_360_TEST_H - -#include <cxxtest/TestSuite.h> -#include <2geom/math-utils.h> -#include "mod360.h" - - -class Mod360Test : public CxxTest::TestSuite -{ -public: - static double inf() { return INFINITY; } - static double nan() { return ((double)INFINITY) - ((double)INFINITY); } - - void testMod360() - { - double cases[][2] = { - {0, 0}, - {10, 10}, - {360, 0}, - {361, 1}, - {-1, 359}, - {-359, 1}, - {-360, -0}, - {-361, 359}, - {inf(), 0}, - {-inf(), 0}, - {nan(), 0}, - {720, 0}, - {-721, 359}, - {-1000, 80} - }; - - for ( unsigned i = 0; i < G_N_ELEMENTS(cases); i++ ) { - double result = mod360( cases[i][0] ); - TS_ASSERT_EQUALS( cases[i][1], result ); - } - } - -}; - - -#endif // SEEN_MOD_360_TEST_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/object-hierarchy.cpp b/src/object-hierarchy.cpp index f241da83d..87b7ac570 100644 --- a/src/object-hierarchy.cpp +++ b/src/object-hierarchy.cpp @@ -10,13 +10,10 @@ */ #include <cstdio> -#include <cassert> #include "sp-object.h" #include "object-hierarchy.h" -#include <sigc++/functors/mem_fun.h> - namespace Inkscape { ObjectHierarchy::ObjectHierarchy(SPObject *top) { diff --git a/src/object-set.cpp b/src/object-set.cpp new file mode 100644 index 000000000..92bcf6b07 --- /dev/null +++ b/src/object-set.cpp @@ -0,0 +1,370 @@ +/* + * Multiindex container for selection + * + * Authors: + * Adrian Boguszewski + * + * Copyright (C) 2016 Adrian Boguszewski + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include <sigc++/sigc++.h> +#include <glib.h> +#include "object-set.h" +#include "box3d.h" +#include "persp3d.h" +#include "preferences.h" +#include <boost/range/adaptor/filtered.hpp> +#include <boost/range/adaptor/transformed.hpp> + +namespace Inkscape { + +bool ObjectSet::add(SPObject* object) { + g_return_val_if_fail(object != NULL, false); + g_return_val_if_fail(SP_IS_OBJECT(object), false); + + // any ancestor is in the set - do nothing + if (_anyAncestorIsInSet(object)) { + return false; + } + + // very nice function, but changes selection behavior (probably needs new selection option to deal with it) + // check if there is mutual ancestor for some elements, which can replace all of them in the set +// object = _getMutualAncestor(object); + + // remove all descendants from the set + _removeDescendantsFromSet(object); + + _add(object); + _emitSignals(); + return true; +} + +bool ObjectSet::remove(SPObject* object) { + g_return_val_if_fail(object != NULL, false); + g_return_val_if_fail(SP_IS_OBJECT(object), false); + + // object is the top of subtree + if (includes(object)) { + _remove(object); + _emitSignals(); + return true; + } + + // any ancestor of object is in the set + if (_anyAncestorIsInSet(object)) { + _removeAncestorsFromSet(object); + _emitSignals(); + return true; + } + + // no object nor any parent in the set + return false; +} + +bool ObjectSet::includes(SPObject *object) { + g_return_val_if_fail(object != NULL, false); + g_return_val_if_fail(SP_IS_OBJECT(object), false); + + return _container.get<hashed>().find(object) != _container.get<hashed>().end(); +} + +void ObjectSet::clear() { + _clear(); + _emitSignals(); +} + +int ObjectSet::size() { + return _container.size(); +} + +bool ObjectSet::_anyAncestorIsInSet(SPObject *object) { + SPObject* o = object; + while (o != nullptr) { + if (includes(o)) { + return true; + } + o = o->parent; + } + + return false; +} + +void ObjectSet::_removeDescendantsFromSet(SPObject *object) { + for (auto& child: object->children) { + if (includes(&child)) { + _remove(&child); + // there is certainly no children of this child in the set + continue; + } + + _removeDescendantsFromSet(&child); + } +} + +void ObjectSet::_remove(SPObject *object) { + _releaseConnections[object].disconnect(); + _releaseConnections.erase(object); + _container.get<hashed>().erase(object); + _remove3DBoxesRecursively(object); + _releaseSignals(object); +} + +void ObjectSet::_add(SPObject *object) { + _releaseConnections[object] = object->connectRelease(sigc::hide_return(sigc::mem_fun(*this, &ObjectSet::remove))); + _container.push_back(object); + _add3DBoxesRecursively(object); + _connectSignals(object); +} + +void ObjectSet::_clear() { + for (auto object: _container) { + _remove(object); + } +} + +SPObject *ObjectSet::_getMutualAncestor(SPObject *object) { + SPObject *o = object; + + bool flag = true; + while (o->parent != nullptr) { + for (auto &child: o->parent->children) { + if(&child != o && !includes(&child)) { + flag = false; + break; + } + } + if (!flag) { + break; + } + o = o->parent; + } + return o; +} + +void ObjectSet::_removeAncestorsFromSet(SPObject *object) { + SPObject* o = object; + while (o->parent != nullptr) { + for (auto &child: o->parent->children) { + if (&child != o) { + _add(&child); + } + } + if (includes(o->parent)) { + _remove(o->parent); + break; + } + o = o->parent; + } +} + +ObjectSet::~ObjectSet() { + _clear(); +} + +void ObjectSet::toggle(SPObject *obj) { + if (includes(obj)) { + remove(obj); + } else { + add(obj); + } +} + +bool ObjectSet::isEmpty() { + return _container.size() == 0; +} + +SPObject *ObjectSet::single() { + return _container.size() == 1 ? *_container.begin() : nullptr; +} + +SPItem *ObjectSet::singleItem() { + if (_container.size() == 1) { + SPObject* obj = *_container.begin(); + if (SP_IS_ITEM(obj)) { + return SP_ITEM(obj); + } + } + + return nullptr; +} + +SPItem *ObjectSet::smallestItem(CompareSize compare) { + return _sizeistItem(true, compare); +} + +SPItem *ObjectSet::largestItem(CompareSize compare) { + return _sizeistItem(false, compare); +} + +SPItem *ObjectSet::_sizeistItem(bool sml, CompareSize compare) { + auto items = this->items(); + gdouble max = sml ? 1e18 : 0; + SPItem *ist = NULL; + + for (auto i = items.begin(); i != items.end(); ++i) { + Geom::OptRect obox = SP_ITEM(*i)->desktopPreferredBounds(); + if (!obox || obox.empty()) { + continue; + } + + Geom::Rect bbox = *obox; + + gdouble size = compare == AREA ? bbox.area() : + (compare == VERTICAL ? bbox.width() : bbox.height()); + size = sml ? size : size * -1; + if (size < max) { + max = size; + ist = SP_ITEM(*i); + } + } + + return ist; +} + +SPObjectRange ObjectSet::objects() { + return SPObjectRange(_container.get<random_access>().begin(), _container.get<random_access>().end()); +} + +Inkscape::XML::Node *ObjectSet::singleRepr() { + SPObject *obj = single(); + return obj ? obj->getRepr() : nullptr; +} + +void ObjectSet::set(SPObject *object) { + _clear(); + _add(object); + // can't emit signal here due to boolean argument in Selection +// _emitSignals(); +} + +Geom::OptRect ObjectSet::bounds(SPItem::BBoxType type) const +{ + return (type == SPItem::GEOMETRIC_BBOX) ? + geometricBounds() : visualBounds(); +} + +Geom::OptRect ObjectSet::geometricBounds() const +{ + auto items = const_cast<ObjectSet *>(this)->items(); + + Geom::OptRect bbox; + for (auto iter = items.begin(); iter != items.end(); ++iter) { + bbox.unionWith(SP_ITEM(*iter)->desktopGeometricBounds()); + } + return bbox; +} + +Geom::OptRect ObjectSet::visualBounds() const +{ + auto items = const_cast<ObjectSet *>(this)->items(); + + Geom::OptRect bbox; + for (auto iter = items.begin(); iter != items.end(); ++iter) { + bbox.unionWith(SP_ITEM(*iter)->desktopVisualBounds()); + } + return bbox; +} + +Geom::OptRect ObjectSet::preferredBounds() const +{ + if (Inkscape::Preferences::get()->getInt("/tools/bounding_box") == 0) { + return bounds(SPItem::VISUAL_BBOX); + } else { + return bounds(SPItem::GEOMETRIC_BBOX); + } +} + +Geom::OptRect ObjectSet::documentBounds(SPItem::BBoxType type) const +{ + Geom::OptRect bbox; + auto items = const_cast<ObjectSet *>(this)->items(); + if (items.empty()) return bbox; + + for (auto iter = items.begin(); iter != items.end(); ++iter) { + SPItem *item = SP_ITEM(*iter); + bbox |= item->documentBounds(type); + } + + return bbox; +} + +// If we have a selection of multiple items, then the center of the first item +// will be returned; this is also the case in SelTrans::centerRequest() +boost::optional<Geom::Point> ObjectSet::center() const { + auto items = const_cast<ObjectSet *>(this)->items(); + if (!items.empty()) { + SPItem *first = items.back(); // from the first item in selection + if (first->isCenterSet()) { // only if set explicitly + return first->getCenter(); + } + } + Geom::OptRect bbox = preferredBounds(); + if (bbox) { + return bbox->midpoint(); + } else { + return boost::optional<Geom::Point>(); + } +} + +std::list<Persp3D *> const ObjectSet::perspList() { + std::list<Persp3D *> pl; + for (std::list<SPBox3D *>::iterator i = _3dboxes.begin(); i != _3dboxes.end(); ++i) { + Persp3D *persp = box3d_get_perspective(*i); + if (std::find(pl.begin(), pl.end(), persp) == pl.end()) + pl.push_back(persp); + } + return pl; +} + +std::list<SPBox3D *> const ObjectSet::box3DList(Persp3D *persp) { + std::list<SPBox3D *> boxes; + if (persp) { + for (std::list<SPBox3D *>::iterator i = _3dboxes.begin(); i != _3dboxes.end(); ++i) { + SPBox3D *box = *i; + if (persp == box3d_get_perspective(box)) { + boxes.push_back(box); + } + } + } else { + boxes = _3dboxes; + } + return boxes; +} + +void ObjectSet::_add3DBoxesRecursively(SPObject *obj) { + std::list<SPBox3D *> boxes = box3d_extract_boxes(obj); + + for (std::list<SPBox3D *>::iterator i = boxes.begin(); i != boxes.end(); ++i) { + SPBox3D *box = *i; + _3dboxes.push_back(box); + } +} + +void ObjectSet::_remove3DBoxesRecursively(SPObject *obj) { + std::list<SPBox3D *> boxes = box3d_extract_boxes(obj); + + for (std::list<SPBox3D *>::iterator i = boxes.begin(); i != boxes.end(); ++i) { + SPBox3D *box = *i; + std::list<SPBox3D *>::iterator b = std::find(_3dboxes.begin(), _3dboxes.end(), box); + if (b == _3dboxes.end()) { + g_print ("Warning! Trying to remove unselected box from selection.\n"); + return; + } + _3dboxes.erase(b); + } +} + +} // namespace Inkscape + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/object-set.h b/src/object-set.h new file mode 100644 index 000000000..fae365f70 --- /dev/null +++ b/src/object-set.h @@ -0,0 +1,329 @@ +/* + * Multiindex container for selection + * + * Authors: + * Adrian Boguszewski + * + * Copyright (C) 2016 Adrian Boguszewski + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#ifndef INKSCAPE_PROTOTYPE_OBJECTSET_H +#define INKSCAPE_PROTOTYPE_OBJECTSET_H + +#include <string> +#include <unordered_map> +#include <boost/multi_index_container.hpp> +#include <boost/multi_index/identity.hpp> +#include <boost/multi_index/sequenced_index.hpp> +#include <boost/multi_index/hashed_index.hpp> +#include <boost/multi_index/random_access_index.hpp> +#include <boost/range/adaptor/filtered.hpp> +#include <boost/range/adaptor/transformed.hpp> +#include <boost/range/sub_range.hpp> +#include <boost/range/any_range.hpp> +#include <boost/type_traits.hpp> +#include <boost/utility/enable_if.hpp> +#include <sigc++/connection.h> +#include <inkgc/gc-soft-ptr.h> +#include "sp-object.h" +#include "sp-item.h" +#include "sp-item-group.h" + +class SPBox3D; +class Persp3D; +class SPDesktop; + +namespace Inkscape { + +namespace XML { +class Node; +} + +struct hashed{}; +struct random_access{}; + +struct is_item { + bool operator()(SPObject* obj) { + return SP_IS_ITEM(obj); + } +}; + +struct is_group { + bool operator()(SPObject* obj) { + return SP_IS_GROUP(obj); + } +}; + +struct object_to_item { + typedef SPItem* result_type; + SPItem* operator()(SPObject* obj) const { + return SP_ITEM(obj); + } +}; + +struct object_to_node { + typedef XML::Node* result_type; + XML::Node* operator()(SPObject* obj) const { + return obj->getRepr(); + } +}; + +struct object_to_group { + typedef SPGroup* result_type; + SPGroup* operator()(SPObject* obj) const { + return SP_GROUP(obj); + } +}; + +typedef boost::multi_index_container< + SPObject*, + boost::multi_index::indexed_by< + boost::multi_index::sequenced<>, + boost::multi_index::random_access< + boost::multi_index::tag<random_access>>, + boost::multi_index::hashed_unique< + boost::multi_index::tag<hashed>, + boost::multi_index::identity<SPObject*>> + >> MultiIndexContainer; + +typedef boost::any_range< + SPObject*, + boost::random_access_traversal_tag, + SPObject* const&, + std::ptrdiff_t> SPObjectRange; + +class ObjectSet { +public: + enum CompareSize {HORIZONTAL, VERTICAL, AREA}; + typedef decltype(MultiIndexContainer().get<random_access>() | boost::adaptors::filtered(is_item()) | boost::adaptors::transformed(object_to_item())) SPItemRange; + typedef decltype(MultiIndexContainer().get<random_access>() | boost::adaptors::filtered(is_group()) | boost::adaptors::transformed(object_to_group())) SPGroupRange; + typedef decltype(MultiIndexContainer().get<random_access>() | boost::adaptors::filtered(is_item()) | boost::adaptors::transformed(object_to_node())) XMLNodeRange; + + ObjectSet(SPDesktop* desktop): _desktop(desktop) {}; + ObjectSet(): _desktop(nullptr) {}; + virtual ~ObjectSet(); + + /** + * Add an SPObject to the set of selected objects. + * + * @param obj the SPObject to add + */ + bool add(SPObject* object); + + /** Add items from an STL iterator range to the selection. + * \param from the begin iterator + * \param to the end iterator + */ + template <typename InputIterator> + void add(InputIterator from, InputIterator to) { + for(auto it = from; it != to; ++it) { + _add(*it); + } + _emitSignals(); + } + + /** + * Removes an item from the set of selected objects. + * + * It is ok to call this method for an unselected item. + * + * @param item the item to unselect + * + * @return is success + */ + bool remove(SPObject* object); + + /** + * Returns true if the given object is selected. + */ + bool includes(SPObject *object); + + /** + * Set the selection to a single specific object. + * + * @param obj the object to select + */ + void set(SPObject *object); + + /** + * Unselects all selected objects. + */ + void clear(); + + /** + * Returns size of the selection. + */ + int size(); + + /** + * Returns true if no items are selected. + */ + bool isEmpty(); + + /** + * Removes an item if selected, adds otherwise. + * + * @param item the item to unselect + */ + void toggle(SPObject *obj); + + /** + * Returns a single selected object. + * + * @return NULL unless exactly one object is selected + */ + SPObject *single(); + + /** + * Returns a single selected item. + * + * @return NULL unless exactly one object is selected + */ + SPItem *singleItem(); + + /** + * Returns the smallest item from this selection. + */ + SPItem *smallestItem(CompareSize compare); + + /** + * Returns the largest item from this selection. + */ + SPItem *largestItem(CompareSize compare); + + /** Returns the list of selected objects. */ + SPObjectRange objects(); + + /** Returns a range of selected SPItems. */ + SPItemRange items() { + return SPItemRange(_container.get<random_access>() + | boost::adaptors::filtered(is_item()) + | boost::adaptors::transformed(object_to_item())); + }; + + /** Returns a range of selected groups. */ + SPGroupRange groups() { + return SPGroupRange (_container.get<random_access>() + | boost::adaptors::filtered(is_group()) + | boost::adaptors::transformed(object_to_group())); + } + + /** Returns a range of the xml nodes of all selected objects. */ + XMLNodeRange xmlNodes() { + return XMLNodeRange(_container.get<random_access>() + | boost::adaptors::filtered(is_item()) + | boost::adaptors::transformed(object_to_node())); + } + + /** + * Returns a single selected object's xml node. + * + * @return NULL unless exactly one object is selected + */ + XML::Node *singleRepr(); + + /** + * Selects exactly the specified objects. + * + * @param objs the objects to select + */ + template <class T> + typename boost::enable_if<boost::is_base_of<SPObject, T>, void>::type + setList(const std::vector<T*> &objs) { + _clear(); + addList(objs); + } + + /** + * Adds the specified objects to selection, without deselecting first. + * + * @param objs the objects to select + */ + template <class T> + typename boost::enable_if<boost::is_base_of<SPObject, T>, void>::type + addList(const std::vector<T*> &objs) { + for (auto obj: objs) { + if (!includes(obj)) { + add(obj); + } + } + } + + /** Returns the bounding rectangle of the selection. */ + Geom::OptRect bounds(SPItem::BBoxType type) const; + Geom::OptRect visualBounds() const; + Geom::OptRect geometricBounds() const; + + /** + * Returns either the visual or geometric bounding rectangle of the selection, based on the + * preferences specified for the selector tool + */ + Geom::OptRect preferredBounds() const; + + /* Returns the bounding rectangle of the selectionin document coordinates.*/ + Geom::OptRect documentBounds(SPItem::BBoxType type) const; + + /** + * Returns the rotation/skew center of the selection. + */ + boost::optional<Geom::Point> center() const; + + /** Returns a list of all perspectives which have a 3D box in the current selection. + (these may also be nested in groups) */ + std::list<Persp3D *> const perspList(); + + /** + * Returns a list of all 3D boxes in the current selection which are associated to @c + * persp. If @c pers is @c NULL, return all selected boxes. + */ + std::list<SPBox3D *> const box3DList(Persp3D *persp = NULL); + + /** + * Returns the desktop the selection is bound to + * + * @return the desktop the selection is bound to, or NULL if in console mode + */ + SPDesktop *desktop() { return _desktop; } + +protected: + virtual void _connectSignals(SPObject* object) {}; + virtual void _releaseSignals(SPObject* object) {}; + virtual void _emitSignals() {}; + void _add(SPObject* object); + void _clear(); + void _remove(SPObject* object); + bool _anyAncestorIsInSet(SPObject *object); + void _removeDescendantsFromSet(SPObject *object); + void _removeAncestorsFromSet(SPObject *object); + SPItem *_sizeistItem(bool sml, CompareSize compare); + SPObject *_getMutualAncestor(SPObject *object); + virtual void _add3DBoxesRecursively(SPObject *obj); + virtual void _remove3DBoxesRecursively(SPObject *obj); + + MultiIndexContainer _container; + GC::soft_ptr<SPDesktop> _desktop; + std::list<SPBox3D *> _3dboxes; + std::unordered_map<SPObject*, sigc::connection> _releaseConnections; + +}; + +typedef ObjectSet::SPItemRange SPItemRange; +typedef ObjectSet::SPGroupRange SPGroupRange; +typedef ObjectSet::XMLNodeRange XMLNodeRange; + +} // namespace Inkscape + +#endif //INKSCAPE_PROTOTYPE_OBJECTSET_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/object-snapper.cpp b/src/object-snapper.cpp index 3e559ee7a..b4f4024cc 100644 --- a/src/object-snapper.cpp +++ b/src/object-snapper.cpp @@ -14,9 +14,6 @@ #include "svg/svg.h" #include <2geom/path-intersection.h> -#include <2geom/pathvector.h> -#include <2geom/point.h> -#include <2geom/rect.h> #include <2geom/line.h> #include <2geom/circle.h> #include <2geom/path-sink.h> @@ -24,9 +21,7 @@ #include "sp-namedview.h" #include "sp-image.h" #include "sp-item-group.h" -#include "sp-item.h" #include "sp-use.h" -#include "display/curve.h" #include "inkscape.h" #include "preferences.h" #include "sp-text.h" @@ -34,7 +29,6 @@ #include "text-editing.h" #include "sp-clippath.h" #include "sp-mask.h" -#include "helper/geom-curves.h" #include "desktop.h" #include "sp-root.h" @@ -90,9 +84,9 @@ void Inkscape::ObjectSnapper::_findCandidates(SPObject* parent, Geom::Rect bbox_to_snap_incl = bbox_to_snap; // _incl means: will include the snapper tolerance bbox_to_snap_incl.expandBy(getSnapperTolerance()); // see? - for ( SPObject *o = parent->firstChild(); o; o = o->getNext() ) { + for (auto& o: parent->children) { g_assert(dt != NULL); - SPItem *item = dynamic_cast<SPItem *>(o); + SPItem *item = dynamic_cast<SPItem *>(&o); if (item && !(dt->itemIsHidden(item) && !clip_or_mask)) { // Snapping to items in a locked layer is allowed // Don't snap to hidden objects, unless they're a clipped path or a mask @@ -100,7 +94,7 @@ void Inkscape::ObjectSnapper::_findCandidates(SPObject* parent, std::vector<SPItem const *>::const_iterator i; if (it != NULL) { i = it->begin(); - while (i != it->end() && *i != o) { + while (i != it->end() && *i != &o) { ++i; } } @@ -122,7 +116,7 @@ void Inkscape::ObjectSnapper::_findCandidates(SPObject* parent, } if (dynamic_cast<SPGroup *>(item)) { - _findCandidates(o, it, false, bbox_to_snap, clip_or_mask, additional_affine); + _findCandidates(&o, it, false, bbox_to_snap, clip_or_mask, additional_affine); } else { Geom::OptRect bbox_of_item; Preferences *prefs = Preferences::get(); diff --git a/src/object-test.h b/src/object-test.h deleted file mode 100644 index 4f0be3251..000000000 --- a/src/object-test.h +++ /dev/null @@ -1,235 +0,0 @@ -#ifndef SEEN_OBJECT_TEST_H -#define SEEN_OBJECT_TEST_H - -#include <cassert> -#include <ctime> -#include <cxxtest/TestSuite.h> -#include <string> -#include <vector> - -#include "document.h" -#include "sp-item-group.h" -#include "sp-object.h" -#include "sp-path.h" -#include "sp-root.h" -#include "xml/document.h" -#include "xml/node.h" - -class ObjectTest : public CxxTest::TestSuite -{ -public: - virtual ~ObjectTest() {} - - static ObjectTest *createSuite() { return new ObjectTest(); } - static void destroySuite(ObjectTest *suite) { delete suite; } - - void testObjects() - { - clock_t begin, end; - // Sample document - // svg:svg - // svg:defs - // svg:path - // svg:linearGradient - // svg:stop - // svg:filter - // svg:feGaussianBlur (feel free to implement for other filters) - // svg:clipPath - // svg:rect - // svg:g - // svg:use - // svg:circle - // svg:ellipse - // svg:text - // svg:polygon - // svg:polyline - // svg:image - // svg:line - - char const *docString = - "<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n" - "<!-- just a comment -->\n" - "<title id=\"title\">SVG test</title>\n" - "<defs>\n" - " <path id=\"P\" d=\"M -21,-4 -5,0 -18,12 -3,4 -4,21 0,5 12,17 4,2 21,3 5,-1 17,-12 2,-4 3,-21 -1,-5 -12,-18 -4,-3z\"/>\n" - " <linearGradient id=\"LG\" x1=\"0%\" y1=\"0%\" x2=\"100%\" y2=\"0%\">\n" - " <stop offset=\"0%\" style=\"stop-color:#ffff00;stop-opacity:1\"/>\n" - " <stop offset=\"100%\" style=\"stop-color:red;stop-opacity:1\"/>\n" - " </linearGradient>\n" - " <clipPath id=\"clip\" clipPathUnits=\"userSpaceOnUse\">\n" - " <rect x=\"10\" y=\"10\" width=\"100\" height=\"100\"/>\n" - " </clipPath>\n" - " <filter style=\"color-interpolation-filters:sRGB\" id=\"filter\" x=\"-0.15\" width=\"1.34\" y=\"0\" height=\"1\">\n" - " <feGaussianBlur stdDeviation=\"4.26\"/>\n" - " </filter>\n" - "</defs>\n" - - "<g id=\"G\" transform=\"skewX(10.5) translate(9,5)\">\n" - " <use id=\"U\" xlink:href=\"#P\" opacity=\"0.5\" fill=\"#1dace3\" transform=\"rotate(4)\"/>\n" - " <circle id=\"C\" cx=\"45.5\" cy=\"67\" r=\"23\" fill=\"#000\"/>\n" - " <ellipse id=\"E\" cx=\"200\" cy=\"70\" rx=\"85\" ry=\"55\" fill=\"url(#LG)\"/>\n" - " <text id=\"T\" fill=\"#fff\" style=\"font-size:45;font-family:Verdana\" x=\"150\" y=\"86\">TEST</text>\n" - " <polygon id=\"PG\" points=\"60,20 100,40 100,80 60,100 20,80 20,40\" clip-path=\"url(#clip)\" filter=\"url(#filter)\"/>\n" - " <polyline id=\"PL\" points=\"0,40 40,40 40,80 80,80 80,120 120,120 120,160\" style=\"fill:none;stroke:red;stroke-width:4\"/>\n" - " <image id=\"I\" xlink:href=\"data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9IjE4MCIgd2lkdGg9IjUwMCI+PHBhdGggZD0iTTAsNDAgNDAsNDAgNDAs" // this is one line - "ODAgODAsODAgODAsMTIwIDEyMCwxMjAgMTIwLDE2MCIgc3R5bGU9ImZpbGw6d2hpdGU7c3Ryb2tlOnJlZDtzdHJva2Utd2lkdGg6NCIvPjwvc3ZnPgo=\"/>\n" - " <line id=\"L\" x1=\"20\" y1=\"100\" x2=\"100\" y2=\"20\" stroke=\"black\" stroke-width=\"2\"/>\n" - "</g>\n" - "</svg>\n"; - - begin = clock(); - SPDocument *doc = SPDocument::createNewDocFromMem(docString, strlen(docString), false); - end = clock(); - - assert(doc != NULL); // cannot continue if doc is null, abort! - assert(doc->getRoot() != NULL); - - SPRoot *root = doc->getRoot(); - assert(root->getRepr() != NULL); - assert(root->hasChildren()); - - std::cout << "Took " << double(end - begin) / double(CLOCKS_PER_SEC) << " seconds to construct the test document\n"; - - SPPath *path = dynamic_cast<SPPath *>(doc->getObjectById("P")); - testClones(path); - - SPGroup *group = dynamic_cast<SPGroup *>(doc->getObjectById("G")); - testGrouping(group); - - // Test parent behavior - SPObject *child = root->firstChild(); - assert(child != NULL); - TS_ASSERT(child->parent == root); - TS_ASSERT(child->document == doc); - TS_ASSERT(root->isAncestorOf(child)); - - // Test list behavior - SPObject *next = child->getNext(); - SPObject *prev = next; - TS_ASSERT(next->getPrev() == child); - prev = next; - next = next->getNext(); - while (next != NULL) { - // Walk the list - TS_ASSERT(next->getPrev() == prev); - prev = next; - next = next->getNext(); - } - TS_ASSERT(child->lastChild() == next); - - // Test hrefcount - TS_ASSERT(path->isReferenced()); - } - - void testClones(SPPath *path) - { - clock_t begin, end; - - assert(path != NULL); - - // Since we don't yet have any clean way to do this (FIXME), we'll abuse the XML tree a bit. - Inkscape::XML::Node *node = path->getRepr(); - assert(node != NULL); - - Inkscape::XML::Document *xml_doc = node->document(); - - Inkscape::XML::Node *parent = node->parent(); - assert(parent != NULL); - - TS_TRACE("Benchmarking clones..."); - const size_t num_clones = 10000; - - std::string href(std::string("#") + std::string(path->getId())); - std::vector<Inkscape::XML::Node *> clones(num_clones, NULL); - - begin = clock(); - // Create num_clones clones of this path and stick them in the document - for (size_t i = 0; i < num_clones; ++i) { - Inkscape::XML::Node *clone = xml_doc->createElement("svg:use"); - Inkscape::GC::release(clone); - clone->setAttribute("xlink:href", href.c_str()); - parent->addChild(clone, node); - clones[i] = clone; - } - end = clock(); - - std::cout << "Took " << double(end - begin) / double(CLOCKS_PER_SEC) << " seconds to write " << num_clones << " clones of a path\n"; - - begin = clock(); - // Remove those clones - for (size_t i = num_clones - 1; i >= 1; --i) { - parent->removeChild(clones[i]); - } - end = clock(); - - std::cout << "Took " << double(end - begin) / double(CLOCKS_PER_SEC) << " seconds to remove " << num_clones << " clones of a path\n"; - } - - void testGrouping(SPGroup *group) - { - clock_t begin, end; - - assert(group != NULL); - - // Since we don't yet have any clean way to do this (FIXME), we'll abuse the XML tree a bit. - Inkscape::XML::Node *node = group->getRepr(); - assert(node != NULL); - - Inkscape::XML::Document *xml_doc = node->document(); - - TS_TRACE("Benchmarking groups..."); - const size_t num_elements = 10000; - - Inkscape::XML::Node *new_group = xml_doc->createElement("svg:g"); - Inkscape::GC::release(new_group); - node->addChild(new_group, NULL); - - std::vector<Inkscape::XML::Node *> elements(num_elements, NULL); - - begin = clock(); - for (size_t i = 0; i < num_elements; ++i) { - Inkscape::XML::Node *circle = xml_doc->createElement("svg:circle"); - Inkscape::GC::release(circle); - circle->setAttribute("cx", "2048"); - circle->setAttribute("cy", "1024"); - circle->setAttribute("r", "1.5"); - new_group->addChild(circle, NULL); - elements[i] = circle; - } - end = clock(); - - std::cout << "Took " << double(end - begin) / double(CLOCKS_PER_SEC) << " seconds to write " << num_elements << " elements into a group\n"; - - SPGroup *n_group = dynamic_cast<SPGroup *>(group->get_child_by_repr(new_group)); - assert(n_group != NULL); - - begin = clock(); - std::vector<SPItem*> ch; - sp_item_group_ungroup(n_group, ch, false); - end = clock(); - - std::cout << "Took " << double(end - begin) / double(CLOCKS_PER_SEC) << " seconds to ungroup a <g> with " << num_elements << " elements\n"; - std::cout << " Note: sp_item_group_ungroup_handle_clones() is responsible\n for most of the time as it is linear in number of elements\n which results in quadratic behavior for ungrouping." << std::endl; - - begin = clock(); - // Remove those elements - for (size_t i = num_elements - 1; i >= 1; --i) { - elements[i]->parent()->removeChild(elements[i]); - } - end = clock(); - - std::cout << "Took " << double(end - begin) / double(CLOCKS_PER_SEC) << " seconds to remove " << num_elements << " elements\n"; - } -}; -#endif // SEEN_OBJECT_TEST_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/path-chemistry.cpp b/src/path-chemistry.cpp index 1a345b565..5295b7a70 100644 --- a/src/path-chemistry.cpp +++ b/src/path-chemistry.cpp @@ -15,15 +15,13 @@ */ #ifdef HAVE_CONFIG_H -# include <config.h> +#include <config.h> #endif #include <cstring> #include <string> #include "xml/repr.h" #include "svg/svg.h" #include "display/curve.h" -#include "color.h" -#include <glib.h> #include <glibmm/i18n.h> #include "sp-path.h" #include "sp-text.h" @@ -37,7 +35,6 @@ #include "selection.h" #include "box3d.h" -#include <2geom/pathvector.h> #include "selection-chemistry.h" #include "path-chemistry.h" #include "verbs.h" @@ -57,7 +54,7 @@ sp_selected_path_combine(SPDesktop *desktop, bool skip_undo) Inkscape::Selection *selection = desktop->getSelection(); SPDocument *doc = desktop->getDocument(); - std::vector<SPItem*> items(selection->itemList()); + std::vector<SPItem*> items(selection->items().begin(), selection->items().end()); if (items.size() < 1) { desktop->getMessageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to combine.")); @@ -203,7 +200,7 @@ sp_selected_path_break_apart(SPDesktop *desktop, bool skip_undo) bool did = false; - std::vector<SPItem*> itemlist(selection->itemList()); + std::vector<SPItem*> itemlist(selection->items().begin(), selection->items().end()); for (std::vector<SPItem*>::const_iterator i = itemlist.begin(); i != itemlist.end(); ++i){ SPItem *item = *i; @@ -303,7 +300,7 @@ sp_selected_path_to_curves(Inkscape::Selection *selection, SPDesktop *desktop, b desktop->setWaitingCursor(); } - std::vector<SPItem*> selected(selection->itemList()); + std::vector<SPItem*> selected(selection->items().begin(), selection->items().end()); std::vector<Inkscape::XML::Node*> to_select; selection->clear(); std::vector<SPItem*> items(selected); @@ -334,7 +331,7 @@ void sp_selected_to_lpeitems(SPDesktop *desktop) return; } - std::vector<SPItem*> selected(selection->itemList()); + std::vector<SPItem*> selected(selection->items().begin(), selection->items().end()); std::vector<Inkscape::XML::Node*> to_select; selection->clear(); std::vector<SPItem*> items(selected); @@ -603,7 +600,7 @@ void sp_selected_path_reverse(SPDesktop *desktop) { Inkscape::Selection *selection = desktop->getSelection(); - std::vector<SPItem*> items = selection->itemList(); + auto items = selection->items(); if (items.empty()) { desktop->getMessageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>path(s)</b> to reverse.")); @@ -617,7 +614,7 @@ sp_selected_path_reverse(SPDesktop *desktop) bool did = false; desktop->messageStack()->flash(Inkscape::IMMEDIATE_MESSAGE, _("Reversing paths...")); - for (std::vector<SPItem*>::const_iterator i = items.begin(); i != items.end(); ++i){ + for (auto i = items.begin(); i != items.end(); ++i){ SPPath *path = dynamic_cast<SPPath *>(*i); if (!path) { diff --git a/src/path-prefix.h b/src/path-prefix.h index 7f9bcec51..8a39ede84 100644 --- a/src/path-prefix.h +++ b/src/path-prefix.h @@ -21,28 +21,33 @@ //#endif /* __cplusplus */ #ifdef ENABLE_BINRELOC -# define INKSCAPE_APPICONDIR BR_DATADIR( "/pixmaps" ) -# define INKSCAPE_ATTRRELDIR BR_DATADIR( "/inkscape/attributes" ) -# define INKSCAPE_BINDDIR BR_DATADIR( "/inkscape/bind" ) -# define INKSCAPE_EXAMPLESDIR BR_DATADIR( "/inkscape/examples" ) -# define INKSCAPE_EXTENSIONDIR BR_DATADIR( "/inkscape/extensions" ) -# define INKSCAPE_FILTERDIR BR_DATADIR( "/inkscape/filters" ) -# define INKSCAPE_GRADIENTSDIR BR_DATADIR( "/inkscape/gradients" ) -# define INKSCAPE_KEYSDIR BR_DATADIR( "/inkscape/keys" ) -# define INKSCAPE_PIXMAPDIR BR_DATADIR( "/inkscape/icons" ) -# define INKSCAPE_MARKERSDIR BR_DATADIR( "/inkscape/markers" ) -# 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_THEMEDIR BR_DATADIR( "/icons" ) -# define INKSCAPE_TUTORIALSDIR BR_DATADIR( "/inkscape/tutorials" ) -# define INKSCAPE_TEMPLATESDIR BR_DATADIR( "/inkscape/templates" ) -# define INKSCAPE_UIDIR BR_DATADIR( "/inkscape/ui" ) +/* The way that we're building now is with a shared library between Inkscape + and Inkview, and the code will find the path to the library then. But we + don't really want that. This prefix then pulls things out of the lib directory + and back into the root install dir. */ +# define INKSCAPE_LIBPREFIX "/../.." +# define INKSCAPE_APPICONDIR BR_DATADIR( INKSCAPE_LIBPREFIX "/share/pixmaps" ) +# define INKSCAPE_ATTRRELDIR BR_DATADIR( INKSCAPE_LIBPREFIX "/share/inkscape/attributes" ) +# define INKSCAPE_BINDDIR BR_DATADIR( INKSCAPE_LIBPREFIX "/share/inkscape/bind" ) +# define INKSCAPE_EXAMPLESDIR BR_DATADIR( INKSCAPE_LIBPREFIX "/share/inkscape/examples" ) +# define INKSCAPE_EXTENSIONDIR BR_DATADIR( INKSCAPE_LIBPREFIX "/share/inkscape/extensions" ) +# define INKSCAPE_FILTERDIR BR_DATADIR( INKSCAPE_LIBPREFIX "/share/inkscape/filters" ) +# define INKSCAPE_GRADIENTSDIR BR_DATADIR( INKSCAPE_LIBPREFIX "/share/inkscape/gradients" ) +# define INKSCAPE_KEYSDIR BR_DATADIR( INKSCAPE_LIBPREFIX "/share/inkscape/keys" ) +# define INKSCAPE_PIXMAPDIR BR_DATADIR( INKSCAPE_LIBPREFIX "/share/inkscape/icons" ) +# define INKSCAPE_MARKERSDIR BR_DATADIR( INKSCAPE_LIBPREFIX "/share/inkscape/markers" ) +# define INKSCAPE_PALETTESDIR BR_DATADIR( INKSCAPE_LIBPREFIX "/share/inkscape/palettes" ) +# define INKSCAPE_PATTERNSDIR BR_DATADIR( INKSCAPE_LIBPREFIX "/share/inkscape/patterns" ) +# define INKSCAPE_SCREENSDIR BR_DATADIR( INKSCAPE_LIBPREFIX "/share/inkscape/screens" ) +# define INKSCAPE_SYMBOLSDIR BR_DATADIR( INKSCAPE_LIBPREFIX "/share/inkscape/symbols" ) +# define INKSCAPE_THEMEDIR BR_DATADIR( INKSCAPE_LIBPREFIX "/share/icons" ) +# define INKSCAPE_TUTORIALSDIR BR_DATADIR( INKSCAPE_LIBPREFIX "/share/inkscape/tutorials" ) +# define INKSCAPE_TEMPLATESDIR BR_DATADIR( INKSCAPE_LIBPREFIX "/share/inkscape/templates" ) +# define INKSCAPE_UIDIR BR_DATADIR( INKSCAPE_LIBPREFIX "/share/inkscape/ui" ) //CREATE V0.1 support -# define CREATE_GRADIENTSDIR BR_DATADIR( "/create/gradients/gimp" ) -# define CREATE_PALETTESDIR BR_DATADIR( "/create/swatches" ) -# define CREATE_PATTERNSDIR BR_DATADIR( "/create/patterns/vector" ) +# define CREATE_GRADIENTSDIR BR_DATADIR( INKSCAPE_LIBPREFIX "/share/create/gradients/gimp" ) +# define CREATE_PALETTESDIR BR_DATADIR( INKSCAPE_LIBPREFIX "/share/create/swatches" ) +# define CREATE_PATTERNSDIR BR_DATADIR( INKSCAPE_LIBPREFIX "/share/create/patterns/vector" ) #else # ifdef WIN32 # define INKSCAPE_APPICONDIR WIN32_DATADIR("pixmaps") diff --git a/src/persp3d-reference.cpp b/src/persp3d-reference.cpp index 4526a8d8f..49510764e 100644 --- a/src/persp3d-reference.cpp +++ b/src/persp3d-reference.cpp @@ -8,7 +8,6 @@ */ #include "persp3d-reference.h" -#include "persp3d.h" #include "uri.h" static void persp3dreference_href_changed(SPObject *old_ref, SPObject *ref, Persp3DReference *persp3dref); diff --git a/src/persp3d.cpp b/src/persp3d.cpp index a48481145..ff00f9441 100644 --- a/src/persp3d.cpp +++ b/src/persp3d.cpp @@ -18,9 +18,7 @@ #include "document-undo.h" #include "vanishing-point.h" #include "ui/tools/box3d-tool.h" -#include "box3d.h" #include "svg/stringstream.h" -#include "xml/document.h" #include "xml/node-event-vector.h" #include "desktop.h" @@ -215,9 +213,10 @@ Persp3D *persp3d_create_xml_element(SPDocument *document, Persp3DImpl *dup) {// Persp3D *persp3d_document_first_persp(SPDocument *document) { Persp3D *first = 0; - for ( SPObject *child = document->getDefs()->firstChild(); child && !first; child = child->getNext() ) { - if (SP_IS_PERSP3D(child)) { - first = SP_PERSP3D(child); + for (auto& child: document->getDefs()->children) { + if (SP_IS_PERSP3D(&child)) { + first = SP_PERSP3D(&child); + break; } } return first; @@ -493,10 +492,10 @@ persp3d_on_repr_attr_changed ( Inkscape::XML::Node * /*repr*/, /* checks whether all boxes linked to this perspective are currently selected */ bool -persp3d_has_all_boxes_in_selection (Persp3D *persp, Inkscape::Selection *selection) { +persp3d_has_all_boxes_in_selection (Persp3D *persp, Inkscape::ObjectSet *set) { Persp3DImpl *persp_impl = persp->perspective_impl; - std::list<SPBox3D *> selboxes = selection->box3DList(); + std::list<SPBox3D *> selboxes = set->box3DList(); for (std::vector<SPBox3D *>::iterator i = persp_impl->boxes.begin(); i != persp_impl->boxes.end(); ++i) { if (std::find(selboxes.begin(), selboxes.end(), *i) == selboxes.end()) { @@ -533,9 +532,9 @@ persp3d_print_debugging_info (Persp3D *persp) { void persp3d_print_debugging_info_all(SPDocument *document) { - for ( SPObject *child = document->getDefs()->firstChild(); child; child = child->getNext() ) { - if (SP_IS_PERSP3D(child)) { - persp3d_print_debugging_info(SP_PERSP3D(child)); + for (auto& child: document->getDefs()->children) { + if (SP_IS_PERSP3D(&child)) { + persp3d_print_debugging_info(SP_PERSP3D(&child)); } } persp3d_print_all_selected(); diff --git a/src/persp3d.h b/src/persp3d.h index be5680bcb..ce0e3c120 100644 --- a/src/persp3d.h +++ b/src/persp3d.h @@ -107,7 +107,7 @@ void persp3d_absorb(Persp3D *persp1, Persp3D *persp2); Persp3D * persp3d_create_xml_element (SPDocument *document, Persp3DImpl *dup = NULL); Persp3D * persp3d_document_first_persp (SPDocument *document); -bool persp3d_has_all_boxes_in_selection (Persp3D *persp, Inkscape::Selection *selection); +bool persp3d_has_all_boxes_in_selection (Persp3D *persp, Inkscape::ObjectSet *set); void persp3d_print_debugging_info (Persp3D *persp); void persp3d_print_debugging_info_all(SPDocument *doc); diff --git a/src/perspective-line.cpp b/src/perspective-line.cpp index e6c78403b..cf40e4c60 100644 --- a/src/perspective-line.cpp +++ b/src/perspective-line.cpp @@ -10,7 +10,6 @@ */ #include "perspective-line.h" -#include "persp3d.h" namespace Box3D { diff --git a/src/preferences-test.h b/src/preferences-test.h deleted file mode 100644 index 92cb14247..000000000 --- a/src/preferences-test.h +++ /dev/null @@ -1,136 +0,0 @@ -/** @file - * @brief Unit tests for the Preferences object - */ -/* Authors: - * Krzysztof KosiÅ„ski <tweenk.pl@gmail.com> - * - * This file is released into the public domain. - */ - -#include <cxxtest/TestSuite.h> -#include "preferences.h" - -#include <glibmm/ustring.h> - -// test observer -class TestObserver : public Inkscape::Preferences::Observer { -public: - TestObserver(Glib::ustring const &path) : - Inkscape::Preferences::Observer(path), - value(0) {} - - virtual void notify(Inkscape::Preferences::Entry const &val) - { - value = val.getInt(); - } - int value; -}; - -class PreferencesTest : public CxxTest::TestSuite { -public: - void setUp() { - prefs = Inkscape::Preferences::get(); - } - void tearDown() { - prefs = NULL; - Inkscape::Preferences::unload(); - } - - void testStartingState() - { - TS_ASSERT_DIFFERS(prefs, static_cast<void*>(0)); - TS_ASSERT_EQUALS(prefs->isWritable(), true); - } - - void testOverwrite() - { - prefs->setInt("/test/intvalue", 123); - prefs->setInt("/test/intvalue", 321); - TS_ASSERT_EQUALS(prefs->getInt("/test/intvalue"), 321); - } - - void testDefaultReturn() - { - TS_ASSERT_EQUALS(prefs->getInt("/this/path/does/not/exist", 123), 123); - } - - void testLimitedReturn() - { - prefs->setInt("/test/intvalue", 1000); - - // simple case - TS_ASSERT_EQUALS(prefs->getIntLimited("/test/intvalue", 123, 0, 500), 123); - // the below may seem quirky but this behaviour is intended - TS_ASSERT_EQUALS(prefs->getIntLimited("/test/intvalue", 123, 1001, 5000), 123); - // corner cases - TS_ASSERT_EQUALS(prefs->getIntLimited("/test/intvalue", 123, 0, 1000), 1000); - TS_ASSERT_EQUALS(prefs->getIntLimited("/test/intvalue", 123, 1000, 5000), 1000); - } - - void testKeyObserverNotification() - { - Glib::ustring const path = "/some/random/path"; - TestObserver obs("/some/random"); - obs.value = 1; - prefs->setInt(path, 5); - TS_ASSERT_EQUALS(obs.value, 1); // no notifications sent before adding - - prefs->addObserver(obs); - prefs->setInt(path, 10); - TS_ASSERT_EQUALS(obs.value, 10); - prefs->setInt("/some/other/random/path", 10); - TS_ASSERT_EQUALS(obs.value, 10); // value should not change - - prefs->removeObserver(obs); - prefs->setInt(path, 15); - TS_ASSERT_EQUALS(obs.value, 10); // no notifications sent after removal - } - - void testEntryObserverNotification() - { - Glib::ustring const path = "/some/random/path"; - TestObserver obs(path); - obs.value = 1; - prefs->setInt(path, 5); - TS_ASSERT_EQUALS(obs.value, 1); // no notifications sent before adding - - prefs->addObserver(obs); - prefs->setInt(path, 10); - TS_ASSERT_EQUALS(obs.value, 10); - - // test that filtering works properly - prefs->setInt("/some/random/value", 1234); - TS_ASSERT_EQUALS(obs.value, 10); - prefs->setInt("/some/randomvalue", 1234); - TS_ASSERT_EQUALS(obs.value, 10); - prefs->setInt("/some/random/path2", 1234); - TS_ASSERT_EQUALS(obs.value, 10); - - prefs->removeObserver(obs); - prefs->setInt(path, 15); - TS_ASSERT_EQUALS(obs.value, 10); // no notifications sent after removal - } - - void testPreferencesEntryMethods() - { - prefs->setInt("/test/prefentry", 100); - Inkscape::Preferences::Entry val = prefs->getEntry("/test/prefentry"); - TS_ASSERT(val.isValid()); - TS_ASSERT_EQUALS(val.getPath(), "/test/prefentry"); - TS_ASSERT_EQUALS(val.getEntryName(), "prefentry"); - TS_ASSERT_EQUALS(val.getInt(), 100); - } -private: - Inkscape::Preferences *prefs; -}; - -/* - 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/preferences.cpp b/src/preferences.cpp index e5a5fe7f0..4d522a1d8 100644 --- a/src/preferences.cpp +++ b/src/preferences.cpp @@ -15,7 +15,6 @@ #include <glibmm/fileutils.h> #include <glibmm/convert.h> #include <glibmm/i18n.h> -#include <glib.h> #include <glib/gstdio.h> #include <gtk/gtk.h> #include "preferences.h" @@ -25,6 +24,7 @@ #include "xml/node-iterators.h" #include "xml/attribute-record.h" #include "util/units.h" +#include "attribute-rel-util.h" #define PREFERENCES_FILE_NAME "preferences.xml" @@ -496,6 +496,7 @@ void Preferences::mergeStyle(Glib::ustring const &pref_path, SPCSSAttr *style) { SPCSSAttr *current = getStyle(pref_path); sp_repr_css_merge(current, style); + sp_attribute_purge_default_style(current, SP_ATTR_CLEAN_DEFAULT_REMOVE); Glib::ustring css_str; sp_repr_css_write_string(current, css_str); _setRawValue(pref_path, css_str); diff --git a/src/prefix.cpp b/src/prefix.cpp index 6bf5cb2cf..4e2204cff 100644 --- a/src/prefix.cpp +++ b/src/prefix.cpp @@ -27,7 +27,7 @@ #define _PREFIX_C_ #ifdef HAVE_CONFIG_H -# include "config.h" +#include <config.h> #endif @@ -35,7 +35,6 @@ #include <cstdlib> #include <cstdio> #include <cstring> -#include <limits.h> #include "prefix.h" diff --git a/src/resource-manager.cpp b/src/resource-manager.cpp index 09b9364c6..188b7d9c8 100644 --- a/src/resource-manager.cpp +++ b/src/resource-manager.cpp @@ -11,10 +11,10 @@ #include <algorithm> #include <gtkmm/recentmanager.h> #include <glibmm/i18n.h> -#include <glibmm/convert.h> -#include <glibmm/fileutils.h> #include <glibmm/miscutils.h> +#include <glibmm/fileutils.h> #include <glibmm/uriutils.h> +#include <glibmm/convert.h> #include "resource-manager.h" @@ -24,8 +24,6 @@ #include "document-undo.h" #include "verbs.h" -#include <set> - namespace Inkscape { static std::vector<std::string> splitPath( std::string const &path ) diff --git a/src/round-test.h b/src/round-test.h deleted file mode 100644 index 8e9ca69e0..000000000 --- a/src/round-test.h +++ /dev/null @@ -1,91 +0,0 @@ - -#ifndef SEEN_ROUND_TEST_H -#define SEEN_ROUND_TEST_H - -#include <cxxtest/TestSuite.h> - -#include <vector> -#include <round.h> - -class RoundTest : public CxxTest::TestSuite -{ -public: - struct Case { - double arg0; - double ret; - }; - - std::vector<Case> nonneg_round_cases; - std::vector<Case> nonpos_round_cases; - - RoundTest() : - TestSuite() - { - Case cases[] = { - { 5.0, 5.0 }, - { 0.0, 0.0 }, - { 5.4, 5.0 }, - { 5.6, 6.0 }, - { 1e-7, 0.0 }, - { 1e7 + .49, 1e7 }, - { 1e7 + .51, 1e7 + 1 }, - { 1e12 + .49, 1e12 }, - { 1e12 + .51, 1e12 + 1 }, - { 1e40, 1e40 } - }; - - for ( size_t i = 0; i < G_N_ELEMENTS(cases); i++ ) - { - nonneg_round_cases.push_back( cases[i] ); - - Case tmp = {-nonneg_round_cases[i].arg0, -nonneg_round_cases[i].ret}; - nonpos_round_cases.push_back( tmp ); - } - } - - virtual ~RoundTest() - { - } - - static RoundTest *createSuite() { return new RoundTest(); } - static void destroySuite( RoundTest *suite ) { delete suite; } - -// ------------------------------------------------------------------------- -// ------------------------------------------------------------------------- - - - - void testNonNegRound() - { - for ( size_t i = 0; i < nonneg_round_cases.size(); i++ ) - { - double result = Inkscape::round( nonneg_round_cases[i].arg0 ); - TS_ASSERT_EQUALS( result, nonneg_round_cases[i].ret ); - } - } - - void testNonPosRoung() - { - for ( size_t i = 0; i < nonpos_round_cases.size(); i++ ) - { - double result = Inkscape::round( nonpos_round_cases[i].arg0 ); - TS_ASSERT_EQUALS( result, nonpos_round_cases[i].ret ); - } - } - -}; - - -#endif // SEEN_ROUND_TEST_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/rubberband.cpp b/src/rubberband.cpp index 4a171f4a1..47fdffb28 100644 --- a/src/rubberband.cpp +++ b/src/rubberband.cpp @@ -15,7 +15,6 @@ #include "rubberband.h" #include "display/sp-canvas.h" -#include "display/sp-canvas-item.h" #include "display/canvas-bpath.h" #include "display/curve.h" diff --git a/src/satisfied-guide-cns.cpp b/src/satisfied-guide-cns.cpp index a83417865..83b8b555c 100644 --- a/src/satisfied-guide-cns.cpp +++ b/src/satisfied-guide-cns.cpp @@ -1,7 +1,6 @@ #include <2geom/coord.h> #include "desktop.h" #include "sp-guide.h" -#include "sp-guide-constraint.h" #include "sp-namedview.h" #include "satisfied-guide-cns.h" diff --git a/src/selcue.cpp b/src/selcue.cpp index 297b9fffc..13600231a 100644 --- a/src/selcue.cpp +++ b/src/selcue.cpp @@ -11,8 +11,6 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include <string.h> - #include "desktop.h" #include "selection.h" @@ -23,7 +21,6 @@ #include "text-editing.h" #include "sp-text.h" #include "sp-flowtext.h" -#include "preferences.h" #include "selcue.h" Inkscape::SelCue::BoundingBoxPrefsObserver::BoundingBoxPrefsObserver(SelCue &sel_cue) : @@ -96,15 +93,15 @@ void Inkscape::SelCue::_updateItemBboxes(Inkscape::Preferences *prefs) void Inkscape::SelCue::_updateItemBboxes(gint mode, int prefs_bbox) { - const std::vector<SPItem*> items = _selection->itemList(); - if (_item_bboxes.size() != items.size()) { + auto items = _selection->items(); + if (_item_bboxes.size() != boost::distance(items)) { _newItemBboxes(); return; } int bcount = 0; - std::vector<SPItem*> ll=_selection->itemList(); - for (std::vector<SPItem*>::const_iterator l = ll.begin(); l != ll.end(); ++l) { + auto ll= _selection->items(); + for (auto l = ll.begin(); l != ll.end(); ++l) { SPItem *item = *l; SPCanvasItem* box = _item_bboxes[bcount ++]; @@ -146,8 +143,8 @@ void Inkscape::SelCue::_newItemBboxes() int prefs_bbox = prefs->getBool("/tools/bounding_box"); - std::vector<SPItem*> ll=_selection->itemList(); - for (std::vector<SPItem*>::const_iterator l = ll.begin(); l != ll.end(); ++l) { + auto ll= _selection->items(); + for (auto l = ll.begin(); l != ll.end(); ++l) { SPItem *item = *l; Geom::OptRect const b = (prefs_bbox == 0) ? @@ -201,8 +198,8 @@ void Inkscape::SelCue::_newTextBaselines() } _text_baselines.clear(); - std::vector<SPItem*> ll = _selection->itemList(); - for (std::vector<SPItem*>::const_iterator l=ll.begin();l!=ll.end();++l) { + auto ll = _selection->items(); + for (auto l=ll.begin();l!=ll.end();++l) { SPItem *item = *l; SPCanvasItem* baseline_point = NULL; diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index 7d32477a1..7bed0a71d 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -12,15 +12,16 @@ * Abhishek Sharma * Kris De Gussem <Kris.DeGussem@gmail.com> * Tavmjong Bah <tavmjong@free.fr> (Symbol additions) + * Adrian Boguszewski * - * Copyright (C) 1999-2010,2012 authors + * Copyright (C) 1999-2016 authors * Copyright (C) 2001-2002 Ximian, Inc. * * Released under GNU GPL, read the file 'COPYING' for more information */ #ifdef HAVE_CONFIG_H -# include "config.h" +#include <config.h> #endif #include <gtkmm/clipboard.h> @@ -34,7 +35,6 @@ SPCycleType SP_CYCLING = SP_CYCLE_FOCUS; #include "svg/svg.h" #include "desktop.h" #include "desktop-style.h" -#include "dir-util.h" #include "layer-model.h" #include "selection.h" #include "ui/tools-switch.h" @@ -42,7 +42,6 @@ SPCycleType SP_CYCLING = SP_CYCLE_FOCUS; #include "message-stack.h" #include "sp-item-transform.h" #include "sp-marker.h" -#include "sp-use.h" #include "sp-textpath.h" #include "sp-tspan.h" #include "sp-tref.h" @@ -53,7 +52,6 @@ SPCycleType SP_CYCLING = SP_CYCLE_FOCUS; #include "sp-ellipse.h" #include "sp-star.h" #include "sp-spiral.h" -#include "sp-switch.h" #include "sp-polyline.h" #include "sp-line.h" #include "text-editing.h" @@ -64,13 +62,10 @@ SPCycleType SP_CYCLING = SP_CYCLE_FOCUS; #include "sp-conn-end.h" #include "ui/tools/dropper-tool.h" #include <glibmm/i18n.h> -#include <2geom/transforms.h> -#include "xml/repr.h" #include "xml/rebase-hrefs.h" #include "style.h" #include "document-private.h" #include "document-undo.h" -#include "sp-gradient.h" #include "sp-gradient-reference.h" #include "sp-linear-gradient.h" #include "sp-pattern.h" @@ -78,7 +73,6 @@ SPCycleType SP_CYCLING = SP_CYCLE_FOCUS; #include "sp-radial-gradient.h" #include "ui/tools/gradient-tool.h" #include "sp-namedview.h" -#include "preferences.h" #include "sp-offset.h" #include "sp-clippath.h" #include "sp-mask.h" @@ -88,32 +82,22 @@ SPCycleType SP_CYCLING = SP_CYCLE_FOCUS; #include <map> #include <cstring> #include <string> +#include <boost/range/adaptor/reversed.hpp> #include "sp-item.h" #include "box3d.h" #include "persp3d.h" -#include "util/units.h" #include "xml/simple-document.h" -#include "sp-filter-reference.h" #include "gradient-drag.h" -#include "uri-references.h" -#include "display/curve.h" -#include "display/canvas-bpath.h" #include "display/cairo-utils.h" -#include "inkscape.h" #include "path-chemistry.h" #include "ui/tool/control-point-selection.h" #include "ui/tool/multi-path-manipulator.h" -#include "sp-lpe-item.h" #include "live_effects/effect.h" -#include "live_effects/effect-enum.h" #include "live_effects/parameter/originalpath.h" #include "layer-manager.h" - -#include "enums.h" -#include "sp-item-group.h" +#include "object-set.h" // For clippath editing -#include "ui/tools-switch.h" #include "ui/tools/node-tool.h" #include "ui/clipboard.h" @@ -123,6 +107,7 @@ using Inkscape::DocumentUndo; using Geom::X; using Geom::Y; using Inkscape::UI::Tools::NodeTool; +using namespace Inkscape; /* The clipboard handling is in ui/clipboard.cpp now. There are some legacy functions left here, because the layer manipulation code uses them. It should be rewritten specifically @@ -282,9 +267,9 @@ void SelectionHelper::fixSelection(SPDesktop *dt) std::vector<SPItem*> items ; - std::vector<SPItem*> const selList = selection->itemList(); + auto selList = selection->items(); - for( std::vector<SPItem*>::const_reverse_iterator i = selList.rbegin(); i != selList.rend(); ++i ) { + for(auto i = boost::rbegin(selList); i != boost::rend(selList); ++i) { SPItem *item = *i; if( item && !dt->isLayer(item) && @@ -409,7 +394,7 @@ void sp_selection_delete(SPDesktop *desktop) desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("<b>Nothing</b> was deleted.")); return; } - std::vector<SPItem*> selected(selection->itemList()); + std::vector<SPItem*> selected(selection->items().begin(), selection->items().end()); selection->clear(); sp_selection_delete_impl(selected); desktop->currentLayer()->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); @@ -432,8 +417,8 @@ static void add_ids_recursive(std::vector<const gchar *> &ids, SPObject *obj) ids.push_back(obj->getId()); if (dynamic_cast<SPGroup *>(obj)) { - for (SPObject *child = obj->firstChild() ; child; child = child->getNext() ) { - add_ids_recursive(ids, child); + for (auto& child: obj->children) { + add_ids_recursive(ids, &child); } } } @@ -454,7 +439,7 @@ void sp_selection_duplicate(SPDesktop *desktop, bool suppressDone, bool duplicat desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to duplicate.")); return; } - std::vector<Inkscape::XML::Node*> reprs(selection->reprList()); + std::vector<Inkscape::XML::Node*> reprs(selection->xmlNodes().begin(), selection->xmlNodes().end()); if(duplicateLayer){ reprs.clear(); @@ -512,6 +497,8 @@ void sp_selection_duplicate(SPDesktop *desktop, bool suppressDone, bool duplicat const gchar *id = old_ids[i]; SPObject *old_clone = doc->getObjectById(id); SPUse *use = dynamic_cast<SPUse *>(old_clone); + SPOffset *offset = dynamic_cast<SPOffset *>(old_clone); + SPText *text = dynamic_cast<SPText *>(old_clone); if (use) { SPItem *orig = use->get_original(); if (!orig) // orphaned @@ -525,14 +512,20 @@ void sp_selection_duplicate(SPDesktop *desktop, bool suppressDone, bool duplicat new_clone->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); } } - } else { - SPOffset *offset = dynamic_cast<SPOffset *>(old_clone); - if (offset) { - for (guint j = 0; j < old_ids.size(); j++) { - gchar *source_href = offset->sourceHref; - if (source_href && source_href[0]=='#' && !strcmp(source_href+1, old_ids[j])) { - doc->getObjectById(new_ids[i])->getRepr()->setAttribute("xlink:href", Glib::ustring("#") + new_ids[j]); - } + } else if (offset) { + gchar *source_href = offset->sourceHref; + for (guint j = 0; j < old_ids.size(); j++) { + if (source_href && source_href[0]=='#' && !strcmp(source_href+1, old_ids[j])) { + doc->getObjectById(new_ids[i])->getRepr()->setAttribute("xlink:href", Glib::ustring("#") + new_ids[j]); + } + } + } else if (text) { + SPTextPath *textpath = dynamic_cast<SPTextPath *>(text->firstChild()); + if (!textpath) continue; + const gchar *source_href = sp_textpath_get_path_item(textpath)->getId(); + for (guint j = 0; j < old_ids.size(); j++) { + if (!strcmp(source_href, old_ids[j])) { + doc->getObjectById(new_ids[i])->firstChild()->getRepr()->setAttribute("xlink:href", Glib::ustring("#") + new_ids[j]); } } } @@ -586,20 +579,20 @@ void sp_edit_clear_all(Inkscape::Selection *selection) */ std::vector<SPItem*> &get_all_items(std::vector<SPItem*> &list, SPObject *from, SPDesktop *desktop, bool onlyvisible, bool onlysensitive, bool ingroups, std::vector<SPItem*> const &exclude) { - for ( SPObject *child = from->firstChild() ; child; child = child->getNext() ) { - SPItem *item = dynamic_cast<SPItem *>(child); + for (auto& child: from->children) { + SPItem *item = dynamic_cast<SPItem *>(&child); if (item && !desktop->isLayer(item) && (!onlysensitive || !item->isLocked()) && (!onlyvisible || !desktop->itemIsHidden(item)) && - (exclude.empty() || exclude.end() == std::find(exclude.begin(),exclude.end(),child)) + (exclude.empty() || exclude.end() == std::find(exclude.begin(), exclude.end(), &child)) ) { list.insert(list.begin(),item); } if (ingroups || (item && desktop->isLayer(item))) { - list = get_all_items(list, child, desktop, onlyvisible, onlysensitive, ingroups, exclude); + list = get_all_items(list, &child, desktop, onlyvisible, onlysensitive, ingroups, exclude); } } @@ -624,7 +617,7 @@ static void sp_edit_select_all_full(SPDesktop *dt, bool force_all_layers, bool i std::vector<SPItem*> exclude; if (invert) { - exclude = selection->itemList(); + exclude.insert(exclude.end(), selection->items().begin(), selection->items().end()); } if (force_all_layers) @@ -690,9 +683,13 @@ void sp_edit_invert_in_all_layers(SPDesktop *desktop) sp_edit_select_all_full(desktop, true, true); } -static void sp_selection_group_impl(std::vector<Inkscape::XML::Node*> p, Inkscape::XML::Node *group, Inkscape::XML::Document *xml_doc, SPDocument *doc) { +static Inkscape::XML::Node* sp_object_set_group(ObjectSet *set) { + SPDocument *doc = set->desktop()->getDocument(); + Inkscape::XML::Document *xml_doc = doc->getReprDoc(); + Inkscape::XML::Node *group = xml_doc->createElement("svg:g"); - sort(p.begin(),p.end(),sp_repr_compare_position_bool); + std::vector<Inkscape::XML::Node*> p(set->xmlNodes().begin(), set->xmlNodes().end()); + std::sort(p.begin(), p.end(), sp_repr_compare_position_bool); // Remember the position and parent of the topmost object. gint topmost = p.back()->position(); @@ -750,31 +747,24 @@ static void sp_selection_group_impl(std::vector<Inkscape::XML::Node*> p, Inkscap // Move to the position of the topmost, reduced by the number of items deleted from topmost_parent group->setPosition(topmost + 1); + + set->set(doc->getObjectByRepr(group)); + + return group; } void sp_selection_group(Inkscape::Selection *selection, SPDesktop *desktop) { - SPDocument *doc = selection->layers()->getDocument(); - Inkscape::XML::Document *xml_doc = doc->getReprDoc(); - // Check if something is selected. if (selection->isEmpty()) { selection_display_message(desktop, Inkscape::WARNING_MESSAGE, _("Select <b>some objects</b> to group.")); return; } + Inkscape::XML::Node* group = sp_object_set_group(selection); - std::vector<Inkscape::XML::Node*> p (selection->reprList()); - - selection->clear(); - - Inkscape::XML::Node *group = xml_doc->createElement("svg:g"); - - sp_selection_group_impl(p, group, xml_doc, doc); - - DocumentUndo::done(doc, SP_VERB_SELECTION_GROUP, + DocumentUndo::done(selection->layers()->getDocument(), SP_VERB_SELECTION_GROUP, C_("Verb", "Group")); - selection->set(group); Inkscape::GC::release(group); } @@ -798,9 +788,8 @@ void sp_selection_ungroup_pop_selection(Inkscape::Selection *selection, SPDeskto selection_display_message(desktop, Inkscape::WARNING_MESSAGE, _("<b>No objects selected</b> to pop out of group.")); return; } - std::vector<SPItem*> selection_list = selection->itemList(); - std::vector<SPItem*>::const_iterator item = selection_list.begin(); // leaving this because it will be useful for + auto item = selection->items().begin(); // leaving this because it will be useful for // future implementation of complex pop ungrouping SPItem *obj = *item; SPItem *parent_group = static_cast<SPItem*>(obj->parent); @@ -823,32 +812,16 @@ void sp_selection_ungroup_pop_selection(Inkscape::Selection *selection, SPDeskto } - -void sp_selection_ungroup(Inkscape::Selection *selection, SPDesktop *desktop) +static void sp_object_set_ungroup(ObjectSet *set) { - if (selection->isEmpty()) { - selection_display_message(desktop, Inkscape::WARNING_MESSAGE, _("Select a <b>group</b> to ungroup.")); - } - - // first check whether there is anything to ungroup - std::vector<SPItem*> old_select = selection->itemList(); - std::vector<SPItem*> new_select; GSList *groups = NULL; - for (std::vector<SPItem*>::const_iterator item = old_select.begin(); item!=old_select.end(); ++item) { - SPItem *obj = *item; - if (dynamic_cast<SPGroup *>(obj)) { - groups = g_slist_prepend(groups, obj); - } + for (auto g: set->groups()) { + groups = g_slist_prepend(groups, g); } - if (groups == NULL) { - selection_display_message(desktop, Inkscape::ERROR_MESSAGE, _("<b>No groups</b> to ungroup in the selection.")); - g_slist_free(groups); - return; - } - - std::vector<SPItem*> items(old_select); - selection->clear(); + std::vector<SPItem*> new_select; + auto old_select = set->items(); + std::vector<SPItem*> items(old_select.begin(), old_select.end()); // If any of the clones refer to the groups, unlink them and replace them with successors // in the items list. @@ -895,7 +868,21 @@ void sp_selection_ungroup(Inkscape::Selection *selection, SPDesktop *desktop) } } - selection->addList(new_select); + set->setList(new_select); +} + +void sp_selection_ungroup(Inkscape::Selection *selection, SPDesktop *desktop) +{ + if (selection->isEmpty()) { + selection_display_message(desktop, Inkscape::WARNING_MESSAGE, _("Select a <b>group</b> to ungroup.")); + } + + if (boost::distance(selection->groups()) == 0) { + selection_display_message(desktop, Inkscape::ERROR_MESSAGE, _("<b>No groups</b> to ungroup in the selection.")); + return; + } + + sp_object_set_ungroup(selection); DocumentUndo::done(selection->layers()->getDocument(), SP_VERB_SELECTION_UNGROUP, _("Ungroup")); @@ -931,18 +918,18 @@ sp_degroup_list(std::vector<SPItem*> &items) /** If items in the list have a common parent, return it, otherwise return NULL */ static SPGroup * -sp_item_list_common_parent_group(std::vector<SPItem*> const &items) +sp_item_list_common_parent_group(const SPItemRange &items) { if (items.empty()) { return NULL; } - SPObject *parent = items[0]->parent; + SPObject *parent = items.front()->parent; // Strictly speaking this CAN happen, if user selects <svg> from Inkscape::XML editor if (!dynamic_cast<SPGroup *>(parent)) { return NULL; } - for (std::vector<SPItem*>::const_iterator item=items.begin();item!=items.end();++item) { - if((*item)==items[0])continue; + for (auto item=items.begin();item!=items.end();++item) { + if((*item)==items.front())continue; if ((*item)->parent != parent) { return NULL; } @@ -980,22 +967,9 @@ bool sp_item_repr_compare_position_bool(SPObject const *first, SPObject const *s ((SPItem*)second)->getRepr())<0; } -void -sp_selection_raise(Inkscape::Selection *selection, SPDesktop *desktop) -{ - std::vector<SPItem*> items= selection->itemList(); - if (items.empty()) { - selection_display_message(desktop, Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to raise.")); - return; - } - - SPGroup const *group = sp_item_list_common_parent_group(items); - if (!group) { - selection_display_message(desktop, Inkscape::ERROR_MESSAGE, _("You cannot raise/lower objects from <b>different groups</b> or <b>layers</b>.")); - return; - } - - Inkscape::XML::Node *grepr = const_cast<Inkscape::XML::Node *>(group->getRepr()); +void sp_object_set_raise(ObjectSet *set) { + std::vector<SPItem*> items(set->items().begin(), set->items().end()); + Inkscape::XML::Node *grepr = const_cast<Inkscape::XML::Node *>(items.front()->parent->getRepr()); /* Construct reverse-ordered list of selected children. */ std::vector<SPItem*> rev(items); @@ -1009,7 +983,7 @@ sp_selection_raise(Inkscape::Selection *selection, SPDesktop *desktop) for (std::vector<SPItem*>::const_iterator item=rev.begin();item!=rev.end();++item) { SPObject *child = *item; // for each selected object, find the next sibling - for (SPObject *newref = child->next; newref; newref = newref->next) { + for (SPObject *newref = child->getNext(); newref; newref = newref->getNext()) { // if the sibling is an item AND overlaps our selection, SPItem *newItem = dynamic_cast<SPItem *>(newref); if (newItem) { @@ -1026,55 +1000,64 @@ sp_selection_raise(Inkscape::Selection *selection, SPDesktop *desktop) } } } - DocumentUndo::done(selection->layers()->getDocument(), SP_VERB_SELECTION_RAISE, - //TRANSLATORS: "Raise" means "to raise an object" in the undo history - C_("Undo action", "Raise")); } -void sp_selection_raise_to_top(Inkscape::Selection *selection, SPDesktop *desktop) +void sp_selection_raise(Inkscape::Selection *selection, SPDesktop *desktop) { - SPDocument *document = selection->layers()->getDocument(); - - if (selection->isEmpty()) { - selection_display_message(desktop, Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to raise to top.")); + if (selection->items().empty()) { + selection_display_message(desktop, Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to raise.")); return; } - std::vector<SPItem*> items = selection->itemList(); - - SPGroup const *group = sp_item_list_common_parent_group(items); + SPGroup const *group = sp_item_list_common_parent_group(selection->items()); if (!group) { selection_display_message(desktop, Inkscape::ERROR_MESSAGE, _("You cannot raise/lower objects from <b>different groups</b> or <b>layers</b>.")); return; } + sp_object_set_raise(selection); + + DocumentUndo::done(selection->layers()->getDocument(), SP_VERB_SELECTION_RAISE, + //TRANSLATORS: "Raise" means "to raise an object" in the undo history + C_("Undo action", "Raise")); +} + - std::vector<Inkscape::XML::Node*> rl(selection->reprList()); +void sp_object_set_raise_to_top(ObjectSet *set) { + std::vector<Inkscape::XML::Node*> rl(set->xmlNodes().begin(), set->xmlNodes().end()); sort(rl.begin(),rl.end(),sp_repr_compare_position_bool); for (std::vector<Inkscape::XML::Node*>::const_iterator l=rl.begin(); l!=rl.end();++l) { Inkscape::XML::Node *repr =(*l); repr->setPosition(-1); } - - DocumentUndo::done(document, SP_VERB_SELECTION_TO_FRONT, - _("Raise to top")); } -void sp_selection_lower(Inkscape::Selection *selection, SPDesktop *desktop) +void sp_selection_raise_to_top(Inkscape::Selection *selection, SPDesktop *desktop, bool skip_undo) { - std::vector<SPItem*> items = selection->itemList(); - if (items.empty()) { - selection_display_message(desktop, Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to lower.")); + SPDocument *document = selection->layers()->getDocument(); + + if (selection->isEmpty()) { + selection_display_message(desktop, Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to raise to top.")); return; } - SPGroup const *group = sp_item_list_common_parent_group(items); + SPGroup const *group = sp_item_list_common_parent_group(selection->items()); if (!group) { selection_display_message(desktop, Inkscape::ERROR_MESSAGE, _("You cannot raise/lower objects from <b>different groups</b> or <b>layers</b>.")); return; } - Inkscape::XML::Node *grepr = const_cast<Inkscape::XML::Node *>(group->getRepr()); + sp_object_set_raise_to_top(selection); + + if (!skip_undo) { + DocumentUndo::done(document, SP_VERB_SELECTION_TO_FRONT, + _("Raise to top")); + } +} + +void sp_object_set_lower(ObjectSet *set) { + std::vector<SPItem*> items(set->items().begin(), set->items().end()); + Inkscape::XML::Node *grepr = const_cast<Inkscape::XML::Node *>(items.front()->parent->getRepr()); // Determine the common bbox of the selected items. Geom::OptRect selected = enclose_items(items); @@ -1109,49 +1092,68 @@ void sp_selection_lower(Inkscape::Selection *selection, SPDesktop *desktop) } } } - - DocumentUndo::done(selection->layers()->getDocument(), SP_VERB_SELECTION_LOWER, - //TRANSLATORS: "Lower" means "to lower an object" in the undo history - C_("Undo action", "Lower")); } -void sp_selection_lower_to_bottom(Inkscape::Selection *selection, SPDesktop *desktop) +void sp_selection_lower(Inkscape::Selection *selection, SPDesktop *desktop) { - SPDocument *document = selection->layers()->getDocument(); - - if (selection->isEmpty()) { - selection_display_message(desktop, Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to lower to bottom.")); + if (selection->items().empty()) { + selection_display_message(desktop, Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to lower.")); return; } - std::vector<SPItem*> items =selection->itemList(); - - SPGroup const *group = sp_item_list_common_parent_group(items); + SPGroup const *group = sp_item_list_common_parent_group(selection->items()); if (!group) { selection_display_message(desktop, Inkscape::ERROR_MESSAGE, _("You cannot raise/lower objects from <b>different groups</b> or <b>layers</b>.")); return; } - std::vector<Inkscape::XML::Node*> rl(selection->reprList()); + sp_object_set_lower(selection); + + DocumentUndo::done(selection->layers()->getDocument(), SP_VERB_SELECTION_LOWER, + //TRANSLATORS: "Lower" means "to lower an object" in the undo history + C_("Undo action", "Lower")); +} + + +void sp_object_set_lower_to_bottom(ObjectSet *set) { + std::vector<Inkscape::XML::Node*> rl(set->xmlNodes().begin(), set->xmlNodes().end()); sort(rl.begin(),rl.end(),sp_repr_compare_position_bool); for (std::vector<Inkscape::XML::Node*>::const_reverse_iterator l=rl.rbegin();l!=rl.rend();++l) { gint minpos; - SPObject *pp, *pc; + SPObject *pp; Inkscape::XML::Node *repr = (*l); - pp = document->getObjectByRepr(repr->parent()); + pp = set->desktop()->getDocument()->getObjectByRepr(repr->parent()); minpos = 0; g_assert(dynamic_cast<SPGroup *>(pp)); - pc = pp->firstChild(); - while (!dynamic_cast<SPItem *>(pc)) { + for (auto& pc: pp->children) { + if(dynamic_cast<SPItem *>(&pc)) { + break; + } minpos += 1; - pc = pc->next; } repr->setPosition(minpos); } +} + +void sp_selection_lower_to_bottom(Inkscape::Selection *selection, SPDesktop *desktop, bool skip_undo) +{ + if (selection->isEmpty()) { + selection_display_message(desktop, Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to lower to bottom.")); + return; + } + + SPGroup const *group = sp_item_list_common_parent_group(selection->items()); + if (!group) { + selection_display_message(desktop, Inkscape::ERROR_MESSAGE, _("You cannot raise/lower objects from <b>different groups</b> or <b>layers</b>.")); + return; + } - DocumentUndo::done(document, SP_VERB_SELECTION_TO_BACK, - _("Lower to bottom")); + sp_object_set_lower_to_bottom(selection); + if (!skip_undo) { + DocumentUndo::done(desktop->getDocument(), SP_VERB_SELECTION_TO_BACK, + _("Lower to bottom")); + } } void @@ -1196,13 +1198,14 @@ take_style_from_item(SPObject *object) if (css == NULL) return NULL; - if ((dynamic_cast<SPGroup *>(object) && object->children) || - (dynamic_cast<SPText *>(object) && object->children && object->children->next == NULL)) { + if ((dynamic_cast<SPGroup *>(object) && object->firstChild()) || + (dynamic_cast<SPText *>(object) && object->firstChild() && object->firstChild()->getNext() == NULL)) { // if this is a text with exactly one tspan child, merge the style of that tspan as well // If this is a group, merge the style of its topmost (last) child with style - for (SPObject *last_element = object->lastChild(); last_element != NULL; last_element = last_element->getPrev()) { - if ( last_element->style ) { - SPCSSAttr *temp = sp_css_attr_from_object(last_element, SP_STYLE_FLAG_IFSET); + auto list = object->children | boost::adaptors::reversed; + for (auto& element: list) { + if (element.style ) { + SPCSSAttr *temp = sp_css_attr_from_object(&element, SP_STYLE_FLAG_IFSET); if (temp) { sp_repr_css_merge(css, temp); sp_repr_css_attr_unref(temp); @@ -1287,8 +1290,8 @@ void sp_selection_remove_livepatheffect(SPDesktop *desktop) desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to remove live path effects from.")); return; } - std::vector<SPItem*> list=selection->itemList(); - for ( std::vector<SPItem*>::const_iterator itemlist=list.begin();itemlist!=list.end();++itemlist) { + auto list= selection->items(); + for (auto itemlist=list.begin();itemlist!=list.end();++itemlist) { SPItem *item = *itemlist; sp_selection_remove_livepatheffect_impl(item); @@ -1368,7 +1371,7 @@ void sp_selection_to_next_layer(SPDesktop *dt, bool suppressDone) return; } - std::vector<SPItem*> items(selection->itemList()); + std::vector<SPItem*> items(selection->items().begin(), selection->items().end()); bool no_more = false; // Set to true, if no more layers above SPObject *next=Inkscape::next_layer(dt->currentRoot(), dt->currentLayer()); @@ -1412,7 +1415,7 @@ void sp_selection_to_prev_layer(SPDesktop *dt, bool suppressDone) return; } - const std::vector<SPItem*> items(selection->itemList()); + std::vector<SPItem*> items(selection->items().begin(), selection->items().end()); bool no_more = false; // Set to true, if no more layers below SPObject *next=Inkscape::previous_layer(dt->currentRoot(), dt->currentLayer()); @@ -1455,7 +1458,7 @@ void sp_selection_to_layer(SPDesktop *dt, SPObject *moveto, bool suppressDone) return; } - std::vector<SPItem*> items(selection->itemList()); + std::vector<SPItem*> items(selection->items().begin(), selection->items().end()); if (moveto) { selection->clear(); @@ -1475,7 +1478,7 @@ void sp_selection_to_layer(SPDesktop *dt, SPObject *moveto, bool suppressDone) } static bool -selection_contains_original(SPItem *item, Inkscape::Selection *selection) +object_set_contains_original(SPItem *item, ObjectSet *set) { bool contains_original = false; @@ -1486,7 +1489,7 @@ selection_contains_original(SPItem *item, Inkscape::Selection *selection) { item_use = use->get_original(); use = dynamic_cast<SPUse *>(item_use); - contains_original |= selection->includes(item_use); + contains_original |= set->includes(item_use); if (item_use == item_use_first) break; } @@ -1495,7 +1498,7 @@ selection_contains_original(SPItem *item, Inkscape::Selection *selection) // data is part of the selection SPTRef *tref = dynamic_cast<SPTRef *>(item); if (!contains_original && tref) { - contains_original = selection->includes(tref->getObjectReferredTo()); + contains_original = set->includes(tref->getObjectReferredTo()); } return contains_original; @@ -1503,14 +1506,14 @@ selection_contains_original(SPItem *item, Inkscape::Selection *selection) static bool -selection_contains_both_clone_and_original(Inkscape::Selection *selection) +object_set_contains_both_clone_and_original(ObjectSet *set) { bool clone_with_original = false; - std::vector<SPItem*> items = selection->itemList(); - for (std::vector<SPItem*>::const_iterator l=items.begin();l!=items.end() ;++l) { + auto items = set->items(); + for (auto l=items.begin();l!=items.end() ;++l) { SPItem *item = *l; if (item) { - clone_with_original |= selection_contains_original(item, selection); + clone_with_original |= object_set_contains_original(item, set); if (clone_with_original) break; } @@ -1524,21 +1527,22 @@ value of set_i2d==false is only used by seltrans when it's dragging objects live that case, items are already in the new position, but the repr is in the old, and this function then simply updates the repr from item->transform. */ -void sp_selection_apply_affine(Inkscape::Selection *selection, Geom::Affine const &affine, bool set_i2d, bool compensate, bool adjust_transf_center) +void sp_object_set_apply_affine(ObjectSet *set, Geom::Affine const &affine, bool set_i2d, bool compensate, + bool adjust_transf_center) { - if (selection->isEmpty()) + if (set->isEmpty()) return; // For each perspective with a box in selection, check whether all boxes are selected and // unlink all non-selected boxes. Persp3D *persp; Persp3D *transf_persp; - std::list<Persp3D *> plist = selection->perspList(); + std::list<Persp3D *> plist = set->perspList(); for (std::list<Persp3D *>::iterator i = plist.begin(); i != plist.end(); ++i) { persp = (Persp3D *) (*i); - if (!persp3d_has_all_boxes_in_selection (persp, selection)) { - std::list<SPBox3D *> selboxes = selection->box3DList(persp); + if (!persp3d_has_all_boxes_in_selection (persp, set)) { + std::list<SPBox3D *> selboxes = set->box3DList(persp); // create a new perspective as a copy of the current one and link the selected boxes to it transf_persp = persp3d_create_xml_element (persp->document, persp->perspective_impl); @@ -1551,14 +1555,14 @@ void sp_selection_apply_affine(Inkscape::Selection *selection, Geom::Affine cons persp3d_apply_affine_transformation(transf_persp, affine); } - std::vector<SPItem*> items = selection->itemList(); - for (std::vector<SPItem*>::const_iterator l=items.begin();l!=items.end() ;++l) { + auto items = set->items(); + for (auto l=items.begin();l!=items.end() ;++l) { SPItem *item = *l; if( dynamic_cast<SPRoot *>(item) ) { // An SVG element cannot have a transform. We could change 'x' and 'y' in response // to a translation... but leave that for another day. - selection->desktop()->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Cannot transform an embedded SVG.")); + set->desktop()->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Cannot transform an embedded SVG.")); break; } @@ -1572,17 +1576,17 @@ void sp_selection_apply_affine(Inkscape::Selection *selection, Geom::Affine cons #endif // we're moving both a clone and its original or any ancestor in clone chain? - bool transform_clone_with_original = selection_contains_original(item, selection); + bool transform_clone_with_original = object_set_contains_original(item, set); // ...both a text-on-path and its path? bool transform_textpath_with_path = ((dynamic_cast<SPText *>(item) && item->firstChild() && dynamic_cast<SPTextPath *>(item->firstChild())) - && selection->includes( sp_textpath_get_path_item(dynamic_cast<SPTextPath *>(item->firstChild())) )); + && set->includes( sp_textpath_get_path_item(dynamic_cast<SPTextPath *>(item->firstChild())) )); // ...both a flowtext and its frame? - bool transform_flowtext_with_frame = (dynamic_cast<SPFlowtext *>(item) && selection->includes( dynamic_cast<SPFlowtext *>(item)->get_frame(NULL))); // (only the first frame is checked so far) + bool transform_flowtext_with_frame = (dynamic_cast<SPFlowtext *>(item) && set->includes( dynamic_cast<SPFlowtext *>(item)->get_frame(NULL))); // (only the first frame is checked so far) // ...both an offset and its source? - bool transform_offset_with_source = (dynamic_cast<SPOffset *>(item) && dynamic_cast<SPOffset *>(item)->sourceHref) && selection->includes( sp_offset_get_source(dynamic_cast<SPOffset *>(item)) ); + bool transform_offset_with_source = (dynamic_cast<SPOffset *>(item) && dynamic_cast<SPOffset *>(item)->sourceHref) && set->includes( sp_offset_get_source(dynamic_cast<SPOffset *>(item)) ); // If we're moving a connector, we want to detach it // from shapes that aren't part of the selection, but @@ -1593,7 +1597,7 @@ void sp_selection_apply_affine(Inkscape::Selection *selection, Geom::Affine cons SPItem *attItem[2] = {0, 0}; path->connEndPair.getAttachedItems(attItem); for (int n = 0; n < 2; ++n) { - if (!selection->includes(attItem[n])) { + if (!set->includes(attItem[n])) { sp_conn_end_detach(item, n); } } @@ -1621,10 +1625,10 @@ void sp_selection_apply_affine(Inkscape::Selection *selection, Geom::Affine cons } else if (transform_flowtext_with_frame) { // apply the inverse of the region's transform to the <use> so that the flow remains // the same (even though the output itself gets transformed) - for ( SPObject *region = item->firstChild() ; region ; region = region->getNext() ) { - if (dynamic_cast<SPFlowregion *>(region) || dynamic_cast<SPFlowregionExclude *>(region)) { - for ( SPObject *item = region->firstChild() ; item ; item = item->getNext() ) { - SPUse *use = dynamic_cast<SPUse *>(item); + for (auto& region: item->children) { + if (dynamic_cast<SPFlowregion *>(®ion) || dynamic_cast<SPFlowregionExclude *>(®ion)) { + for (auto& itm: region.children) { + SPUse *use = dynamic_cast<SPUse *>(&itm); if ( use ) { use->doWriteTransform(use->getRepr(), use->transform.inverse(), NULL, compensate); } @@ -1715,15 +1719,15 @@ void sp_selection_apply_affine(Inkscape::Selection *selection, Geom::Affine cons } } -void sp_selection_remove_transform(SPDesktop *desktop) +void sp_object_set_remove_transform(SPDesktop *desktop) { if (desktop == NULL) return; Inkscape::Selection *selection = desktop->getSelection(); - std::vector<Inkscape::XML::Node*> items = selection->reprList(); - for (std::vector<Inkscape::XML::Node*>::const_iterator l=items.begin();l!=items.end() ;++l) { + auto items = selection->xmlNodes(); + for (auto l=items.begin();l!=items.end() ;++l) { (*l)->setAttribute("transform", NULL, false); } @@ -1732,14 +1736,14 @@ void sp_selection_remove_transform(SPDesktop *desktop) } void -sp_selection_scale_absolute(Inkscape::Selection *selection, - double const x0, double const x1, - double const y0, double const y1) +sp_object_set_scale_absolute(ObjectSet *set, + double x0, double x1, + double y0, double y1) { - if (selection->isEmpty()) + if (set->isEmpty()) return; - Geom::OptRect bbox = selection->visualBounds(); + Geom::OptRect bbox = set->visualBounds(); if ( !bbox ) { return; } @@ -1752,16 +1756,16 @@ sp_selection_scale_absolute(Inkscape::Selection *selection, Geom::Translate const o2n(x0, y0); Geom::Affine const final( p2o * scale * o2n ); - sp_selection_apply_affine(selection, final); + sp_object_set_apply_affine(set, final); } -void sp_selection_scale_relative(Inkscape::Selection *selection, Geom::Point const &align, Geom::Scale const &scale) +void sp_object_set_scale_relative(ObjectSet *set, Geom::Point const &align, Geom::Scale const &scale) { - if (selection->isEmpty()) + if (set->isEmpty()) return; - Geom::OptRect bbox = selection->visualBounds(); + Geom::OptRect bbox = set->visualBounds(); if ( !bbox ) { return; @@ -1777,21 +1781,21 @@ void sp_selection_scale_relative(Inkscape::Selection *selection, Geom::Point con Geom::Translate const n2d(-align); Geom::Translate const d2n(align); Geom::Affine const final( n2d * scale * d2n ); - sp_selection_apply_affine(selection, final); + sp_object_set_apply_affine(set, final); } void -sp_selection_rotate_relative(Inkscape::Selection *selection, Geom::Point const ¢er, gdouble const angle_degrees) +sp_object_set_rotate_relative(ObjectSet *set, Geom::Point const ¢er, double angle_degrees) { Geom::Translate const d2n(center); Geom::Translate const n2d(-center); Geom::Rotate const rotate(Geom::Rotate::from_degrees(angle_degrees)); Geom::Affine const final( Geom::Affine(n2d) * rotate * d2n ); - sp_selection_apply_affine(selection, final); + sp_object_set_apply_affine(set, final); } void -sp_selection_skew_relative(Inkscape::Selection *selection, Geom::Point const &align, double dx, double dy) +sp_object_set_skew_relative(ObjectSet *set, Geom::Point const &align, double dx, double dy) { Geom::Translate const d2n(align); Geom::Translate const n2d(-align); @@ -1799,17 +1803,17 @@ sp_selection_skew_relative(Inkscape::Selection *selection, Geom::Point const &al dx, 1, 0, 0); Geom::Affine const final( n2d * skew * d2n ); - sp_selection_apply_affine(selection, final); + sp_object_set_apply_affine(set, final); } -void sp_selection_move_relative(Inkscape::Selection *selection, Geom::Point const &move, bool compensate) +void sp_object_set_move_relative(ObjectSet *set, Geom::Point const &move, bool compensate) { - sp_selection_apply_affine(selection, Geom::Affine(Geom::Translate(move)), true, compensate); + sp_object_set_apply_affine(set, Geom::Affine(Geom::Translate(move)), true, compensate); } -void sp_selection_move_relative(Inkscape::Selection *selection, double dx, double dy) +void sp_object_set_move_relative(ObjectSet *set, double dx, double dy) { - sp_selection_apply_affine(selection, Geom::Affine(Geom::Translate(dx, dy))); + sp_object_set_apply_affine(set, Geom::Affine(Geom::Translate(dx, dy))); } /** @@ -1822,9 +1826,9 @@ void sp_selection_rotate_90(SPDesktop *desktop, bool ccw) if (selection->isEmpty()) return; - std::vector<SPItem*> items = selection->itemList(); + auto items = selection->items(); Geom::Rotate const rot_90(Geom::Point(0, ccw ? 1 : -1)); // pos. or neg. rotation, depending on the value of ccw - for (std::vector<SPItem*>::const_iterator l=items.begin();l!=items.end() ;++l) { + for (auto l=items.begin();l!=items.end() ;++l) { SPItem *item = *l; if (item) { sp_item_rotate_rel(item, rot_90); @@ -1849,7 +1853,7 @@ sp_selection_rotate(Inkscape::Selection *selection, gdouble const angle_degrees) return; } - sp_selection_rotate_relative(selection, *center, angle_degrees); + sp_object_set_rotate_relative(selection, *center, angle_degrees); DocumentUndo::maybeDone(selection->desktop()->getDocument(), ( ( angle_degrees > 0 ) @@ -1886,7 +1890,7 @@ void sp_select_same_fill_stroke_style(SPDesktop *desktop, gboolean fill, gboolea std::vector<SPItem*> all_matches; Inkscape::Selection *selection = desktop->getSelection(); - std::vector<SPItem*> items = selection->itemList(); + auto items = selection->items(); std::vector<SPItem*> tmp; for (std::vector<SPItem*>::const_iterator iter=all_list.begin();iter!=all_list.end();++iter) { @@ -1896,7 +1900,7 @@ void sp_select_same_fill_stroke_style(SPDesktop *desktop, gboolean fill, gboolea } all_list=tmp; - for (std::vector<SPItem*>::const_iterator sel_iter=items.begin();sel_iter!=items.end();++sel_iter) { + for (auto sel_iter=items.begin();sel_iter!=items.end();++sel_iter) { SPItem *sel = *sel_iter; std::vector<SPItem*> matches = all_list; if (fill && stroke && style) { @@ -1943,8 +1947,8 @@ void sp_select_same_object_type(SPDesktop *desktop) Inkscape::Selection *selection = desktop->getSelection(); - std::vector<SPItem*> items=selection->itemList(); - for (std::vector<SPItem*>::const_iterator sel_iter=items.begin();sel_iter!=items.end();++sel_iter) { + auto items= selection->items(); + for (auto sel_iter=items.begin();sel_iter!=items.end();++sel_iter) { SPItem *sel = *sel_iter; if (sel) { matches = sp_get_same_object_type(sel, matches); @@ -2198,7 +2202,7 @@ sp_selection_rotate_screen(Inkscape::Selection *selection, gdouble angle) gdouble const zangle = 180 * atan2(zmove, r) / M_PI; - sp_selection_rotate_relative(selection, *center, zangle); + sp_object_set_rotate_relative(selection, *center, zangle); DocumentUndo::maybeDone(selection->desktop()->getDocument(), ( (angle > 0) @@ -2228,7 +2232,7 @@ sp_selection_scale(Inkscape::Selection *selection, gdouble grow) } double const times = 1.0 + grow / max_len; - sp_selection_scale_relative(selection, center, Geom::Scale(times, times)); + sp_object_set_scale_relative(selection, center, Geom::Scale(times, times)); DocumentUndo::maybeDone(selection->desktop()->getDocument(), ( (grow > 0) @@ -2241,8 +2245,7 @@ sp_selection_scale(Inkscape::Selection *selection, gdouble grow) void sp_selection_scale_screen(Inkscape::Selection *selection, gdouble grow_pixels) { - sp_selection_scale(selection, - grow_pixels / selection->desktop()->current_zoom()); + sp_selection_scale(selection, grow_pixels / selection->desktop()->current_zoom()); } void @@ -2258,7 +2261,7 @@ sp_selection_scale_times(Inkscape::Selection *selection, gdouble times) } Geom::Point const center(sel_bbox->midpoint()); - sp_selection_scale_relative(selection, center, Geom::Scale(times, times)); + sp_object_set_scale_relative(selection, center, Geom::Scale(times, times)); DocumentUndo::done(selection->desktop()->getDocument(), SP_VERB_CONTEXT_SELECT, _("Scale by whole factor")); } @@ -2270,7 +2273,7 @@ sp_selection_move(Inkscape::Selection *selection, gdouble dx, gdouble dy) return; } - sp_selection_move_relative(selection, dx, dy); + sp_object_set_move_relative(selection, dx, dy); SPDocument *doc = selection->layers()->getDocument(); if (dx == 0) { @@ -2296,7 +2299,7 @@ sp_selection_move_screen(Inkscape::Selection *selection, gdouble dx, gdouble dy) gdouble const zoom = selection->desktop()->current_zoom(); gdouble const zdx = dx / zoom; gdouble const zdy = dy / zoom; - sp_selection_move_relative(selection, zdx, zdy); + sp_object_set_move_relative(selection, zdx, zdy); SPDocument *doc = selection->layers()->getDocument(); if (dx == 0) { @@ -2328,10 +2331,10 @@ typedef struct ListReverse { typedef GSList *Iterator; static Iterator children(SPObject *o) { - return make_list(o->firstChild(), NULL); + return make_list(o, NULL); } static Iterator siblings_after(SPObject *o) { - return make_list(o->parent->firstChild(), o); + return make_list(o->parent, o); } static void dispose(Iterator i) { g_slist_free(i); @@ -2345,13 +2348,12 @@ typedef struct ListReverse { private: static GSList *make_list(SPObject *object, SPObject *limit) { GSList *list = NULL; - while ( object != limit ) { - if (!object) { // TODO check if this happens in practice - g_warning("Unexpected list overrun"); + for (auto &child: object->children) { + if (&child == limit) { break; } - list = g_slist_prepend(list, object); - object = object->getNext(); + list = g_slist_prepend(list, &child); + } return list; } @@ -2456,7 +2458,8 @@ sp_selection_item_next(SPDesktop *desktop) root = desktop->currentRoot(); } - SPItem *item=next_item_from_list<Forward>(desktop, selection->itemList(), root, SP_CYCLING == SP_CYCLE_VISIBLE, inlayer, onlyvisible, onlysensitive); + std::vector<SPItem *> vec(selection->items().begin(), selection->items().end()); + SPItem *item=next_item_from_list<Forward>(desktop, vec, root, SP_CYCLING == SP_CYCLE_VISIBLE, inlayer, onlyvisible, onlysensitive); if (item) { selection->set(item, PREFS_SELECTION_LAYER_RECURSIVE == inlayer); @@ -2486,7 +2489,8 @@ sp_selection_item_prev(SPDesktop *desktop) root = desktop->currentRoot(); } - SPItem *item=next_item_from_list<ListReverse>(desktop, selection->itemList(), root, SP_CYCLING == SP_CYCLE_VISIBLE, inlayer, onlyvisible, onlysensitive); + std::vector<SPItem *> vec(selection->items().begin(), selection->items().end()); + SPItem *item=next_item_from_list<ListReverse>(desktop, vec, root, SP_CYCLING == SP_CYCLE_VISIBLE, inlayer, onlyvisible, onlysensitive); if (item) { selection->set(item, PREFS_SELECTION_LAYER_RECURSIVE == inlayer); @@ -2603,7 +2607,7 @@ void sp_selection_clone(SPDesktop *desktop) return; } - std::vector<Inkscape::XML::Node*> reprs (selection->reprList()); + std::vector<Inkscape::XML::Node*> reprs(selection->xmlNodes().begin(), selection->xmlNodes().end()); selection->clear(); @@ -2662,8 +2666,8 @@ sp_selection_relink(SPDesktop *desktop) // Get a copy of current selection. bool relinked = false; - std::vector<SPItem*> items=selection->itemList(); - for (std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();++i){ + auto items= selection->items(); + for (auto i=items.begin();i!=items.end();++i){ SPItem *item = *i; if (dynamic_cast<SPUse *>(item)) { @@ -2700,8 +2704,9 @@ sp_selection_unlink(SPDesktop *desktop) // Get a copy of current selection. std::vector<SPItem*> new_select; bool unlinked = false; - std::vector<SPItem*> items=selection->itemList(); - for (std::vector<SPItem*>::const_reverse_iterator i=items.rbegin();i!=items.rend();++i){ + std::vector<SPItem *> items(selection->items().begin(), selection->items().end()); + + for (auto i=items.rbegin();i!=items.rend();++i){ SPItem *item = *i; if (dynamic_cast<SPText *>(item)) { @@ -2767,8 +2772,8 @@ sp_select_clone_original(SPDesktop *desktop) // Check if other than two objects are selected - std::vector<SPItem*> items=selection->itemList(); - if (items.size() != 1 || !item) { + auto items= selection->items(); + if (boost::distance(items) != 1 || !item) { desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, error); return; } @@ -2865,8 +2870,8 @@ void sp_selection_clone_original_path_lpe(SPDesktop *desktop) Inkscape::SVGOStringStream os; SPObject * firstItem = NULL; - std::vector<SPItem*> items=selection->itemList(); - for (std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();++i){ + auto items= selection->items(); + for (auto i=items.begin();i!=items.end();++i){ if (SP_IS_SHAPE(*i) || SP_IS_TEXT(*i)) { if (firstItem) { os << "|"; @@ -2950,12 +2955,12 @@ void sp_selection_to_marker(SPDesktop *desktop, bool apply) Geom::Point center( *c - corner ); // As defined by rotation center center[Geom::Y] = -center[Geom::Y]; - std::vector<SPItem*> items(selection->itemList()); + std::vector<SPItem*> items(selection->items().begin(), selection->items().end()); //items = g_slist_sort(items, (GCompareFunc) sp_object_compare_position); // Why needed? // bottommost object, after sorting - SPObject *parent = items[0]->parent; + SPObject *parent = items.front()->parent; Geom::Affine parent_transform; { @@ -3024,7 +3029,7 @@ void sp_selection_to_guides(SPDesktop *desktop) SPDocument *doc = desktop->getDocument(); Inkscape::Selection *selection = desktop->getSelection(); // we need to copy the list because it gets reset when objects are deleted - std::vector<SPItem*> items(selection->itemList()); + std::vector<SPItem*> items(selection->items().begin(), selection->items().end()); if (items.empty()) { desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to convert to guides.")); @@ -3090,7 +3095,7 @@ void sp_selection_symbol(SPDesktop *desktop, bool /*apply*/ ) doc->ensureUpToDate(); - std::vector<SPObject*> items(selection->list()); + std::vector<SPObject*> items(selection->objects().begin(), selection->objects().end()); sort(items.begin(),items.end(),sp_object_compare_position_bool); // Keep track of parent, this is where <use> will be inserted. @@ -3302,7 +3307,7 @@ sp_selection_tile(SPDesktop *desktop, bool apply) move_p[Geom::Y] = -move_p[Geom::Y]; Geom::Affine move = Geom::Affine(Geom::Translate(move_p)); - std::vector<SPItem*> items (selection->itemList()); + std::vector<SPItem*> items(selection->items().begin(), selection->items().end()); sort(items.begin(),items.end(),sp_object_compare_position_bool); @@ -3407,7 +3412,7 @@ void sp_selection_untile(SPDesktop *desktop) bool did = false; - std::vector<SPItem*> items(selection->itemList()); + std::vector<SPItem*> items(selection->items().begin(), selection->items().end()); for (std::vector<SPItem*>::const_reverse_iterator i=items.rbegin();i!=items.rend();++i){ SPItem *item = *i; @@ -3430,9 +3435,9 @@ void sp_selection_untile(SPDesktop *desktop) Geom::Affine pat_transform = basePat->getTransform(); pat_transform *= item->transform; - for (SPObject *child = pattern->firstChild() ; child != NULL; child = child->next ) { - if (dynamic_cast<SPItem *>(child)) { - Inkscape::XML::Node *copy = child->getRepr()->duplicate(xml_doc); + for (auto& child: pattern->children) { + if (dynamic_cast<SPItem *>(&child)) { + Inkscape::XML::Node *copy = child.getRepr()->duplicate(xml_doc); SPItem *i = dynamic_cast<SPItem *>(desktop->currentLayer()->appendChildRepr(copy)); // FIXME: relink clones to the new canvas objects @@ -3466,18 +3471,18 @@ void sp_selection_untile(SPDesktop *desktop) } } -void sp_selection_get_export_hints(Inkscape::Selection *selection, Glib::ustring &filename, float *xdpi, float *ydpi) +void sp_object_set_get_export_hints(ObjectSet *set, Glib::ustring &filename, float *xdpi, float *ydpi) { - if (selection->isEmpty()) { + if (set->isEmpty()) { return; } - std::vector<Inkscape::XML::Node*> const reprlst = selection->reprList(); + auto reprlst = set->xmlNodes(); bool filename_search = TRUE; bool xdpi_search = TRUE; bool ydpi_search = TRUE; - for (std::vector<Inkscape::XML::Node*>::const_iterator i=reprlst.begin();filename_search&&xdpi_search&&ydpi_search&&i!=reprlst.end();++i){ + for (auto i=reprlst.begin();filename_search&&xdpi_search&&ydpi_search&&i!=reprlst.end();++i){ gchar const *dpi_string; Inkscape::XML::Node *repr = *i; @@ -3564,7 +3569,7 @@ void sp_selection_create_bitmap_copy(SPDesktop *desktop) } // List of the items to show; all others will be hidden - std::vector<SPItem*> items(selection->itemList()); + std::vector<SPItem*> items(selection->items().begin(), selection->items().end()); // Sort items so that the topmost comes last sort(items.begin(),items.end(),sp_item_repr_compare_position_bool); @@ -3617,7 +3622,7 @@ void sp_selection_create_bitmap_copy(SPDesktop *desktop) float hint_xdpi = 0, hint_ydpi = 0; Glib::ustring hint_filename; // take resolution hint from the selected objects - sp_selection_get_export_hints(selection, hint_filename, &hint_xdpi, &hint_ydpi); + sp_object_set_get_export_hints(selection, hint_filename, &hint_xdpi, &hint_ydpi); if (hint_xdpi != 0) { res = hint_xdpi; } else { @@ -3765,7 +3770,7 @@ void sp_selection_set_clipgroup(SPDesktop *desktop) return; } - std::vector<Inkscape::XML::Node*> p(selection->reprList()); + std::vector<Inkscape::XML::Node*> p(selection->xmlNodes().begin(), selection->xmlNodes().end()); sort(p.begin(),p.end(),sp_repr_compare_position_bool); @@ -3859,7 +3864,7 @@ void sp_selection_set_clipgroup(SPDesktop *desktop) * If \a apply_clip_path parameter is true, clipPath is created, otherwise mask * */ -void sp_selection_set_mask(SPDesktop *desktop, bool apply_clip_path, bool apply_to_layer) +void sp_selection_set_mask(SPDesktop *desktop, bool apply_clip_path, bool apply_to_layer, bool skip_undo) { if (desktop == NULL) { return; @@ -3875,14 +3880,14 @@ void sp_selection_set_mask(SPDesktop *desktop, bool apply_clip_path, bool apply_ if ( apply_to_layer && is_empty) { desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to create clippath or mask from.")); return; - } else if (!apply_to_layer && ( is_empty || selection->itemList().size()==1 )) { + } else if (!apply_to_layer && ( is_empty || boost::distance(selection->items())==1 )) { desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select mask object and <b>object(s)</b> to apply clippath or mask to.")); return; } // FIXME: temporary patch to prevent crash! // Remove this when bboxes are fixed to not blow up on an item clipped/masked with its own clone - bool clone_with_original = selection_contains_both_clone_and_original(selection); + bool clone_with_original = object_set_contains_both_clone_and_original(selection); if (clone_with_original) { return; // in this version, you cannot clip/mask an object with its own clone } @@ -3890,7 +3895,7 @@ void sp_selection_set_mask(SPDesktop *desktop, bool apply_clip_path, bool apply_ doc->ensureUpToDate(); - std::vector<SPItem*> items(selection->itemList()); + std::vector<SPItem*> items(selection->items().begin(), selection->items().end()); sort(items.begin(),items.end(),sp_object_compare_position_bool); @@ -3942,18 +3947,13 @@ void sp_selection_set_mask(SPDesktop *desktop, bool apply_clip_path, bool apply_ if (grouping == PREFS_MASKOBJECT_GROUPING_ALL) { // group all those objects into one group // and apply mask to that - Inkscape::XML::Node *group = xml_doc->createElement("svg:g"); - - // make a note we should ungroup this when unsetting mask - group->setAttribute("inkscape:groupmode", "maskhelper"); + ObjectSet* set = new ObjectSet(selection->desktop()); + set->add(apply_to_items.begin(), apply_to_items.end()); - std::vector<Inkscape::XML::Node*> reprs_to_group; - for (std::vector<SPItem*>::const_iterator i = apply_to_items.begin(); i != apply_to_items.end(); ++i) { - reprs_to_group.push_back(static_cast<SPObject*>(*i)->getRepr()); - } items_to_select.clear(); - sp_selection_group_impl(reprs_to_group, group, xml_doc, doc); + Inkscape::XML::Node *group = sp_object_set_group(set); + group->setAttribute("inkscape:groupmode", "maskhelper"); // apply clip/mask only to newly created group apply_to_items.clear(); @@ -3961,6 +3961,7 @@ void sp_selection_set_mask(SPDesktop *desktop, bool apply_clip_path, bool apply_ items_to_select.push_back((SPItem*)(doc->getObjectByRepr(group))); + delete set; Inkscape::GC::release(group); } if (grouping == PREFS_MASKOBJECT_GROUPING_SEPARATE) { @@ -4021,11 +4022,12 @@ void sp_selection_set_mask(SPDesktop *desktop, bool apply_clip_path, bool apply_ } selection->addList(items_to_select); - - if (apply_clip_path) { - DocumentUndo::done(doc, SP_VERB_OBJECT_SET_CLIPPATH, _("Set clipping path")); - } else { - DocumentUndo::done(doc, SP_VERB_OBJECT_SET_MASK, _("Set mask")); + if (!skip_undo) { + if (apply_clip_path) { + DocumentUndo::done(doc, SP_VERB_OBJECT_SET_CLIPPATH, _("Set clipping path")); + } else { + DocumentUndo::done(doc, SP_VERB_OBJECT_SET_MASK, _("Set mask")); + } } } @@ -4052,7 +4054,7 @@ void sp_selection_unset_mask(SPDesktop *desktop, bool apply_clip_path) { gchar const *attributeName = apply_clip_path ? "clip-path" : "mask"; std::map<SPObject*,SPItem*> referenced_objects; - std::vector<SPItem*> items(selection->itemList()); + std::vector<SPItem*> items(selection->items().begin(), selection->items().end()); selection->clear(); GSList *items_to_ungroup = NULL; @@ -4098,9 +4100,9 @@ void sp_selection_unset_mask(SPDesktop *desktop, bool apply_clip_path) { for ( std::map<SPObject*,SPItem*>::iterator it = referenced_objects.begin() ; it != referenced_objects.end() ; ++it) { SPObject *obj = (*it).first; // Group containing the clipped paths or masks GSList *items_to_move = NULL; - for ( SPObject *child = obj->firstChild() ; child; child = child->getNext() ) { + for (auto& child: obj->children) { // Collect all clipped paths and masks within a single group - Inkscape::XML::Node *copy = child->getRepr()->duplicate(xml_doc); + Inkscape::XML::Node *copy = child.getRepr()->duplicate(xml_doc); if(copy->attribute("inkscape:original-d") && copy->attribute("inkscape:path-effect")) { copy->setAttribute("d", copy->attribute("inkscape:original-d")); @@ -4259,11 +4261,11 @@ static void itemtree_map(void (*f)(SPItem *, SPDesktop *), SPObject *root, SPDes f(item, desktop); } } - for ( SPObject::SiblingIterator iter = root->firstChild() ; iter ; ++iter ) { + for (auto& child: root->children) { //don't recurse into locked layers - SPItem *item = dynamic_cast<SPItem *>(&*iter); + SPItem *item = dynamic_cast<SPItem *>(&child); if (!(item && desktop->isLayer(item) && item->isLocked())) { - itemtree_map(f, iter, desktop); + itemtree_map(f, &child, desktop); } } } diff --git a/src/selection-chemistry.h b/src/selection-chemistry.h index 82b91c617..72e4acc66 100644 --- a/src/selection-chemistry.h +++ b/src/selection-chemistry.h @@ -26,6 +26,7 @@ class SPDesktop; namespace Inkscape { class Selection; +class ObjectSet; namespace LivePathEffect { class PathParam; @@ -78,10 +79,15 @@ void sp_selection_group(Inkscape::Selection *selection, SPDesktop *desktop); void sp_selection_ungroup(Inkscape::Selection *selection, SPDesktop *desktop); void sp_selection_ungroup_pop_selection(Inkscape::Selection *selection, SPDesktop *desktop); +void sp_object_set_raise(Inkscape::ObjectSet *set); +void sp_object_set_raise_to_top(Inkscape::ObjectSet *set); +void sp_object_set_lower(Inkscape::ObjectSet *set); +void sp_object_set_lower_to_bottom(Inkscape::ObjectSet *set); + void sp_selection_raise(Inkscape::Selection *selection, SPDesktop *desktop); -void sp_selection_raise_to_top(Inkscape::Selection *selection, SPDesktop *desktop); +void sp_selection_raise_to_top(Inkscape::Selection *selection, SPDesktop *desktop, bool skip_undo = false); void sp_selection_lower(Inkscape::Selection *selection, SPDesktop *desktop); -void sp_selection_lower_to_bottom(Inkscape::Selection *selection, SPDesktop *desktop); +void sp_selection_lower_to_bottom(Inkscape::Selection *selection, SPDesktop *desktop, bool skip_undo = false); SPCSSAttr *take_style_from_item (SPObject *object); @@ -103,14 +109,15 @@ 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, bool adjust_transf_center = true); -void sp_selection_remove_transform (SPDesktop *desktop); -void sp_selection_scale_absolute (Inkscape::Selection *selection, double x0, double x1, double y0, double y1); -void sp_selection_scale_relative(Inkscape::Selection *selection, Geom::Point const &align, Geom::Scale const &scale); -void sp_selection_rotate_relative (Inkscape::Selection *selection, Geom::Point const ¢er, double angle); -void sp_selection_skew_relative (Inkscape::Selection *selection, Geom::Point const &align, double dx, double dy); -void sp_selection_move_relative (Inkscape::Selection *selection, Geom::Point const &move, bool compensate = true); -void sp_selection_move_relative (Inkscape::Selection *selection, double dx, double dy); +void sp_object_set_apply_affine(Inkscape::ObjectSet *set, Geom::Affine const &affine, bool set_i2d = true, + bool compensate = true, bool adjust_transf_center = true); +void sp_object_set_remove_transform(SPDesktop *desktop); +void sp_object_set_scale_absolute(Inkscape::ObjectSet *set, double x0, double x1, double y0, double y1); +void sp_object_set_scale_relative(Inkscape::ObjectSet *set, Geom::Point const &align, Geom::Scale const &scale); +void sp_object_set_rotate_relative(Inkscape::ObjectSet *set, Geom::Point const ¢er, double angle); +void sp_object_set_skew_relative(Inkscape::ObjectSet *set, Geom::Point const &align, double dx, double dy); +void sp_object_set_move_relative(Inkscape::ObjectSet *set, Geom::Point const &move, bool compensate = true); +void sp_object_set_move_relative(Inkscape::ObjectSet *set, double dx, double dy); void sp_selection_rotate_90 (SPDesktop *desktop, bool ccw); void sp_selection_rotate (Inkscape::Selection *selection, double angle); @@ -151,13 +158,13 @@ void scroll_to_show_item(SPDesktop *desktop, SPItem *item); void sp_undo (SPDesktop *desktop, SPDocument *doc); void sp_redo (SPDesktop *desktop, SPDocument *doc); -void sp_selection_get_export_hints (Inkscape::Selection *selection, Glib::ustring &filename, float *xdpi, float *ydpi); +void sp_object_set_get_export_hints(Inkscape::ObjectSet *set, Glib::ustring &filename, float *xdpi, float *ydpi); void sp_document_get_export_hints (SPDocument * doc, Glib::ustring &filename, float *xdpi, float *ydpi); void sp_selection_create_bitmap_copy (SPDesktop *desktop); void sp_selection_set_clipgroup(SPDesktop *desktop); -void sp_selection_set_mask(SPDesktop *desktop, bool apply_clip_path, bool apply_to_layer); +void sp_selection_set_mask(SPDesktop *desktop, bool apply_clip_path, bool apply_to_layer, bool skip_undo = false); void sp_selection_unset_mask(SPDesktop *desktop, bool apply_clip_path); bool fit_canvas_to_selection(SPDesktop *, bool with_margins = false); diff --git a/src/selection-describer.cpp b/src/selection-describer.cpp index ddc7a0d10..43fe1311d 100644 --- a/src/selection-describer.cpp +++ b/src/selection-describer.cpp @@ -13,7 +13,7 @@ */ #ifdef HAVE_CONFIG_H -# include "config.h" +#include <config.h> #endif #include <glibmm/i18n.h> @@ -27,17 +27,8 @@ #include "sp-flowtext.h" #include "sp-use.h" #include "sp-symbol.h" -#include "sp-rect.h" -#include "box3d.h" -#include "sp-ellipse.h" -#include "sp-star.h" -#include "sp-anchor.h" #include "sp-image.h" #include "sp-path.h" -#include "sp-line.h" -#include "sp-use.h" -#include "sp-polyline.h" -#include "sp-spiral.h" // Returns a list of terms for the items to be used in the statusbar char* collect_terms (const std::vector<SPItem*> &items) @@ -122,7 +113,7 @@ void SelectionDescriber::_selectionModified(Inkscape::Selection *selection, guin } void SelectionDescriber::_updateMessageFromSelection(Inkscape::Selection *selection) { - std::vector<SPItem*> const items = selection->itemList(); + std::vector<SPItem*> items(selection->items().begin(), selection->items().end()); if (items.empty()) { // no items _context.set(Inkscape::NORMAL_MESSAGE, _when_nothing); diff --git a/src/selection.cpp b/src/selection.cpp index 91d6d2634..bdd4f0dc7 100644 --- a/src/selection.cpp +++ b/src/selection.cpp @@ -7,8 +7,10 @@ * bulia byak <buliabyak@users.sf.net> * Andrius R. <knutux@gmail.com> * Abhishek Sharma + * Adrian Boguszewski * - * Copyright (C) 2006 Andrius R. + * Copyright (C) 2016 Adrian Boguszewski + * Copyright (C) 2006 Andrius R. * Copyright (C) 2004-2005 MenTaLguY * Copyright (C) 1999-2002 Lauris Kaplinski * Copyright (C) 2001-2002 Ximian, Inc. @@ -17,38 +19,24 @@ */ #ifdef HAVE_CONFIG_H -# include <config.h> #endif -#include "macros.h" + #include "inkscape.h" -#include "document.h" -#include "layer-model.h" -#include "selection.h" -#include <2geom/rect.h> #include "xml/repr.h" #include "preferences.h" #include "sp-shape.h" #include "sp-path.h" -#include "sp-item-group.h" -#include "box3d.h" -#include "box3d.h" -#include "persp3d.h" - -#include <sigc++/functors/mem_fun.h> +#include "desktop.h" +#include "document.h" #define SP_SELECTION_UPDATE_PRIORITY (G_PRIORITY_HIGH_IDLE + 1) namespace Inkscape { -Selection::Selection(LayerModel *layers, SPDesktop *desktop) : - _objs(std::list<SPObject*>()), - _objs_vector(std::vector<SPObject*>()), - _objs_set(std::set<SPObject*>()), - _reprs(std::vector<XML::Node*>()), - _items(std::vector<SPItem*>()), +Selection::Selection(LayerModel *layers, SPDesktop *desktop): + ObjectSet(desktop), _layers(layers), - _desktop(desktop), _selection_context(NULL), _flags(0), _idle(0) @@ -56,7 +44,6 @@ Selection::Selection(LayerModel *layers, SPDesktop *desktop) : } Selection::~Selection() { - _clear(); _layers = NULL; if (_idle) { g_source_remove(_idle); @@ -76,8 +63,7 @@ void Selection::_schedule_modified(SPObject */*obj*/, guint flags) { this->_flags |= flags; } -gboolean -Selection::_emit_modified(Selection *selection) +gboolean Selection::_emit_modified(Selection *selection) { /* force new handler to be created if requested before we return */ selection->_idle = 0; @@ -110,8 +96,7 @@ void Selection::_emitChanged(bool persist_selection_context/* = false */) { _changed_signal.emit(this); } -void -Selection::_releaseContext(SPObject *obj) +void Selection::_releaseContext(SPObject *obj) { if (NULL == _selection_context || _selection_context != obj) return; @@ -122,359 +107,38 @@ Selection::_releaseContext(SPObject *obj) _selection_context = NULL; } -void Selection::_invalidateCachedLists() { - _items.clear(); - _reprs.clear(); - _objs_vector.clear(); -} - -void Selection::_clear() { - _invalidateCachedLists(); - while (!_objs.empty()) { - SPObject *obj=_objs.front(); - _remove(obj); - } -} - SPObject *Selection::activeContext() { if (NULL != _selection_context) return _selection_context; return _layers->currentLayer(); - } - -bool Selection::includes(SPObject *obj) const { - if (obj == NULL) - return FALSE; - - g_return_val_if_fail(SP_IS_OBJECT(obj), FALSE); - - return ( _objs_set.find(obj)!=_objs_set.end() ); -} - -void Selection::add(SPObject *obj, bool persist_selection_context/* = false */) { - g_return_if_fail(obj != NULL); - g_return_if_fail(SP_IS_OBJECT(obj)); - g_return_if_fail(obj->document != NULL); - - if (includes(obj)) { - return; - } - - _invalidateCachedLists(); - _add(obj); - _emitChanged(persist_selection_context); -} - -void Selection::add_3D_boxes_recursively(SPObject *obj) { - std::list<SPBox3D *> boxes = box3d_extract_boxes(obj); - - for (std::list<SPBox3D *>::iterator i = boxes.begin(); i != boxes.end(); ++i) { - SPBox3D *box = *i; - _3dboxes.push_back(box); - } -} - -void Selection::_add(SPObject *obj) { - // unselect any of the item's ancestors and descendants which may be selected - // (to prevent double-selection) - _removeObjectDescendants(obj); - _removeObjectAncestors(obj); - g_return_if_fail(SP_IS_OBJECT(obj)); - - _objs.push_front(obj); - _objs_set.insert(obj); - - add_3D_boxes_recursively(obj); - - _release_connections[obj] = obj->connectRelease(sigc::mem_fun(*this, (void (Selection::*)(SPObject *))&Selection::remove)); - _modified_connections[obj] = obj->connectModified(sigc::mem_fun(*this, &Selection::_schedule_modified)); } void Selection::set(SPObject *object, bool persist_selection_context) { - _clear(); - add(object, persist_selection_context); -} - -void Selection::toggle(SPObject *obj) { - if (includes (obj)) { - remove (obj); - } else { - add(obj); - } -} - -void Selection::remove(SPObject *obj) { - g_return_if_fail(obj != NULL); - g_return_if_fail(SP_IS_OBJECT(obj)); - g_return_if_fail(includes(obj)); - - _invalidateCachedLists(); - _remove(obj); - _emitChanged(); -} - -void Selection::remove_3D_boxes_recursively(SPObject *obj) { - std::list<SPBox3D *> boxes = box3d_extract_boxes(obj); - - for (std::list<SPBox3D *>::iterator i = boxes.begin(); i != boxes.end(); ++i) { - SPBox3D *box = *i; - std::list<SPBox3D *>::iterator b = std::find(_3dboxes.begin(), _3dboxes.end(), box); - if (b == _3dboxes.end()) { - g_print ("Warning! Trying to remove unselected box from selection.\n"); - return; - } - _3dboxes.erase(b); - } -} - -void Selection::_remove(SPObject *obj) { - _modified_connections[obj].disconnect(); - _modified_connections.erase(obj); - - _release_connections[obj].disconnect(); - _release_connections.erase(obj); - - remove_3D_boxes_recursively(obj); - - _objs.remove(obj); - _objs_set.erase(obj); -} - -void Selection::setList(std::vector<SPItem*> const &list) { - // Clear and add, or just clear with emit. - if (!list.empty()) { - _clear(); - addList(list); - } else clear(); -} - -void Selection::addList(std::vector<SPItem*> const &list) { - - if (list.empty()) - return; - - _invalidateCachedLists(); - - for ( std::vector<SPItem*>::const_iterator iter=list.begin();iter!=list.end(); ++iter) { - SPObject *obj = *iter; - if (includes(obj)) continue; - _add (obj); - } - - _emitChanged(); + ObjectSet::set(object); + _emitChanged(persist_selection_context); } void Selection::setReprList(std::vector<XML::Node*> const &list) { - _clear(); + clear(); - for ( std::vector<XML::Node*>::const_reverse_iterator iter=list.rbegin();iter!=list.rend(); ++iter) { - SPObject *obj=_objectForXMLNode(*iter); + for (std::vector<XML::Node*>::const_reverse_iterator iter = list.rbegin(); iter != list.rend(); ++iter) { + SPObject *obj = _objectForXMLNode(*iter); if (obj) { - _add(obj); + add(obj); } } _emitChanged(); } -void Selection::clear() { - _clear(); - _emitChanged(); -} - -void Selection::emitModified() -{ - _emitChanged(); -} - -std::vector<SPObject*> const &Selection::list() { - if(!_objs_vector.empty()) - return _objs_vector; - - for ( std::list<SPObject*>::const_iterator iter=_objs.begin();iter!=_objs.end(); ++iter) { - _objs_vector.push_back(*iter); - } - return _objs_vector; - -} - -std::vector<SPItem*> const &Selection::itemList() { - if (!_items.empty()) { - return _items; - } - - for ( std::list<SPObject*>::const_iterator iter=_objs.begin();iter!=_objs.end(); ++iter) { - SPObject *obj=*iter; - if (SP_IS_ITEM(obj)) { - _items.push_back(SP_ITEM(obj)); - } - } - return _items; -} - -std::vector<XML::Node*> const &Selection::reprList() { - if (!_reprs.empty()) { return _reprs; } - std::vector<SPItem*> list = itemList(); - for ( std::vector<SPItem*>::const_iterator iter=list.begin();iter!=list.end(); ++iter) { - SPObject *obj = *iter; - _reprs.push_back(obj->getRepr()); - } - return _reprs; -} - -std::list<Persp3D *> const Selection::perspList() { - std::list<Persp3D *> pl; - for (std::list<SPBox3D *>::iterator i = _3dboxes.begin(); i != _3dboxes.end(); ++i) { - Persp3D *persp = box3d_get_perspective(*i); - if (std::find(pl.begin(), pl.end(), persp) == pl.end()) - pl.push_back(persp); - } - return pl; -} - -std::list<SPBox3D *> const Selection::box3DList(Persp3D *persp) { - std::list<SPBox3D *> boxes; - if (persp) { - for (std::list<SPBox3D *>::iterator i = _3dboxes.begin(); i != _3dboxes.end(); ++i) { - SPBox3D *box = *i; - if (persp == box3d_get_perspective(box)) { - boxes.push_back(box); - } - } - } else { - boxes = _3dboxes; - } - return boxes; -} - -SPObject *Selection::single() { - if ( _objs.size() == 1 ) { - return _objs.front(); - } else { - return NULL; - } -} - -SPItem *Selection::singleItem() { - std::vector<SPItem*> const items=itemList(); - if ( items.size()==1) { - return items[0]; - } else { - return NULL; - } -} - -SPItem *Selection::smallestItem(Selection::CompareSize compare) { - return _sizeistItem(true, compare); -} - -SPItem *Selection::largestItem(Selection::CompareSize compare) { - return _sizeistItem(false, compare); -} - -SPItem *Selection::_sizeistItem(bool sml, Selection::CompareSize compare) { - std::vector<SPItem*> const items = const_cast<Selection *>(this)->itemList(); - gdouble max = sml ? 1e18 : 0; - SPItem *ist = NULL; - - for ( std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end(); ++i) { - Geom::OptRect obox = SP_ITEM(*i)->desktopPreferredBounds(); - if (!obox || obox.empty()) continue; - Geom::Rect bbox = *obox; - - gdouble size = compare == 2 ? bbox.area() : - (compare == 1 ? bbox.width() : bbox.height()); - size = sml ? size : size * -1; - if (size < max) { - max = size; - ist = SP_ITEM(*i); - } - } - return ist; -} - -Inkscape::XML::Node *Selection::singleRepr() { - SPObject *obj=single(); - return obj ? obj->getRepr() : NULL; -} - -Geom::OptRect Selection::bounds(SPItem::BBoxType type) const -{ - return (type == SPItem::GEOMETRIC_BBOX) ? - geometricBounds() : visualBounds(); -} - -Geom::OptRect Selection::geometricBounds() const -{ - std::vector<SPItem*> const items = const_cast<Selection *>(this)->itemList(); - - Geom::OptRect bbox; - for ( std::vector<SPItem*>::const_iterator iter=items.begin();iter!=items.end(); ++iter) { - bbox.unionWith(SP_ITEM(*iter)->desktopGeometricBounds()); - } - return bbox; -} - -Geom::OptRect Selection::visualBounds() const -{ - std::vector<SPItem*> const items = const_cast<Selection *>(this)->itemList(); - - Geom::OptRect bbox; - for ( std::vector<SPItem*>::const_iterator iter=items.begin();iter!=items.end(); ++iter) { - bbox.unionWith(SP_ITEM(*iter)->desktopVisualBounds()); - } - return bbox; -} - -Geom::OptRect Selection::preferredBounds() const -{ - if (Inkscape::Preferences::get()->getInt("/tools/bounding_box") == 0) { - return bounds(SPItem::VISUAL_BBOX); - } else { - return bounds(SPItem::GEOMETRIC_BBOX); - } -} - -Geom::OptRect Selection::documentBounds(SPItem::BBoxType type) const -{ - Geom::OptRect bbox; - std::vector<SPItem*> const items = const_cast<Selection *>(this)->itemList(); - if (items.empty()) return bbox; - - for ( std::vector<SPItem*>::const_iterator iter=items.begin();iter!=items.end(); ++iter) { - SPItem *item = SP_ITEM(*iter); - bbox |= item->documentBounds(type); - } - - return bbox; -} - -// If we have a selection of multiple items, then the center of the first item -// will be returned; this is also the case in SelTrans::centerRequest() -boost::optional<Geom::Point> Selection::center() const { - std::vector<SPItem*> const items = const_cast<Selection *>(this)->itemList(); - if (!items.empty()) { - SPItem *first = items.back(); // from the first item in selection - if (first->isCenterSet()) { // only if set explicitly - return first->getCenter(); - } - } - Geom::OptRect bbox = preferredBounds(); - if (bbox) { - return bbox->midpoint(); - } else { - return boost::optional<Geom::Point>(); - } -} - std::vector<Inkscape::SnapCandidatePoint> Selection::getSnapPoints(SnapPreferences const *snapprefs) const { std::vector<Inkscape::SnapCandidatePoint> p; if (snapprefs != NULL){ 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 - std::vector<SPItem*> const items = const_cast<Selection *>(this)->itemList(); - for ( std::vector<SPItem*>::const_iterator iter=items.begin();iter!=items.end(); ++iter) { + auto items = const_cast<Selection *>(this)->items(); + for (auto iter = items.begin(); iter != items.end(); ++iter) { SPItem *this_item = *iter; this_item->getSnappoints(p, &snapprefs_dummy); @@ -489,34 +153,6 @@ std::vector<Inkscape::SnapCandidatePoint> Selection::getSnapPoints(SnapPreferenc return p; } -void Selection::_removeObjectDescendants(SPObject *obj) { - std::vector<SPObject*> toremove; - for ( std::list<SPObject*>::const_iterator iter=_objs.begin();iter!=_objs.end(); ++iter) { - SPObject *sel_obj= dynamic_cast<SPObject*>(*iter); - SPObject *parent = sel_obj->parent; - while (parent) { - if ( parent == obj ) { - toremove.push_back(sel_obj); - break; - } - parent = parent->parent; - } - } - for ( std::vector<SPObject*>::const_iterator iter=toremove.begin();iter!=toremove.end(); ++iter) { - _remove(*iter); - } -} - -void Selection::_removeObjectAncestors(SPObject *obj) { - SPObject *parent = obj->parent; - while (parent) { - if (includes(parent)) { - _remove(parent); - } - parent = parent->parent; - } -} - SPObject *Selection::_objectForXMLNode(Inkscape::XML::Node *repr) const { g_return_val_if_fail(repr != NULL, NULL); gchar const *id = repr->attribute("id"); @@ -527,25 +163,39 @@ SPObject *Selection::_objectForXMLNode(Inkscape::XML::Node *repr) const { } size_t Selection::numberOfLayers() { - std::vector<SPItem*> const items = const_cast<Selection *>(this)->itemList(); + auto items = this->items(); std::set<SPObject*> layers; - for ( std::vector<SPItem*>::const_iterator iter=items.begin();iter!=items.end(); ++iter) { + for (auto iter = items.begin(); iter != items.end(); ++iter) { SPObject *layer = _layers->layerForObject(*iter); layers.insert(layer); } + return layers.size(); } size_t Selection::numberOfParents() { - std::vector<SPItem*> const items = const_cast<Selection *>(this)->itemList(); + auto items = this->items(); std::set<SPObject*> parents; - for ( std::vector<SPItem*>::const_iterator iter=items.begin();iter!=items.end(); ++iter) { + for (auto iter = items.begin(); iter != items.end(); ++iter) { SPObject *parent = (*iter)->parent; parents.insert(parent); } return parents.size(); } +void Selection::_emitSignals() { + _emitChanged(); +} + +void Selection::_connectSignals(SPObject *object) { + _modified_connections[object] = object->connectModified(sigc::mem_fun(*this, &Selection::_schedule_modified)); +} + +void Selection::_releaseSignals(SPObject *object) { + _modified_connections[object].disconnect(); + _modified_connections.erase(object); +} + } /* diff --git a/src/selection.h b/src/selection.h index bf6acb015..cf00ba1f4 100644 --- a/src/selection.h +++ b/src/selection.h @@ -5,7 +5,9 @@ * Lauris Kaplinski <lauris@kaplinski.com> * MenTaLguY <mental@rydia.net> * bulia byak <buliabyak@users.sf.net> + * Adrian Boguszewski * + * Copyright (C) 2016 Adrian Boguszewski * Copyright (C) 2004-2005 MenTaLguY * Copyright (C) 1999-2002 Lauris Kaplinski * Copyright (C) 2001-2002 Ximian, Inc. @@ -15,23 +17,16 @@ #include <vector> #include <map> -#include <list> -#include <set> #include <stddef.h> #include <sigc++/sigc++.h> #include "inkgc/gc-managed.h" #include "gc-finalized.h" #include "gc-anchored.h" -#include "inkgc/gc-soft-ptr.h" #include "sp-item.h" +#include "object-set.h" - - -class SPDesktop; class SPItem; -class SPBox3D; -class Persp3D; namespace Inkscape { class LayerModel; @@ -40,7 +35,6 @@ class Node; } } - namespace Inkscape { /** @@ -62,10 +56,10 @@ namespace Inkscape { */ class Selection : public Inkscape::GC::Managed<>, public Inkscape::GC::Finalized, - public Inkscape::GC::Anchored + public Inkscape::GC::Anchored, + public ObjectSet { public: - enum CompareSize { HORIZONTAL, VERTICAL, AREA }; /** * Constructs an selection object, bound to a particular * layer model @@ -84,12 +78,7 @@ public: */ LayerModel *layers() { return _layers; } - /** - * Returns the desktop the selection is bound to - * - * @return the desktop the selection is bound to, or NULL if in console mode - */ - SPDesktop *desktop() { return _desktop; } + /** * Returns active layer for selection (currentLayer or its parent). @@ -98,19 +87,16 @@ public: */ SPObject *activeContext(); - /** - * Add an SPObject to the set of selected objects. - * - * @param obj the SPObject to add - */ - void add(SPObject *obj, bool persist_selection_context = false); + using ObjectSet::add; /** * Add an XML node's SPObject to the set of selected objects. * * @param the xml node of the item to add */ - void add(XML::Node *repr) { add(_objectForXMLNode(repr)); } + void add(XML::Node *repr) { + add(_objectForXMLNode(repr)); + } /** * Set the selection to a single specific object. @@ -124,23 +110,11 @@ public: * * @param repr the xml node of the item to select */ - void set(XML::Node *repr) { set(_objectForXMLNode(repr)); } - - /** - * Removes an item from the set of selected objects. - * - * It is ok to call this method for an unselected item. - * - * @param item the item to unselect - */ - void remove(SPObject *obj); + void set(XML::Node *repr) { + set(_objectForXMLNode(repr)); + } - /** - * Removes an item if selected, adds otherwise. - * - * @param item the item to unselect - */ - void toggle(SPObject *obj); + using ObjectSet::remove; /** * Removes an item from the set of selected objects. @@ -149,21 +123,9 @@ public: * * @param repr the xml node of the item to remove */ - void remove(XML::Node *repr) { remove(_objectForXMLNode(repr)); } - - /** - * Selects exactly the specified objects. - * - * @param objs the objects to select - */ - void setList(std::vector<SPItem*> const &objs); - - /** - * Adds the specified objects to selection, without deselecting first. - * - * @param objs the objects to select - */ - void addList(std::vector<SPItem*> const &objs); + void remove(XML::Node *repr) { + remove(_objectForXMLNode(repr)); + } /** * Clears the selection and selects the specified objects. @@ -172,122 +134,22 @@ public: */ void setReprList(std::vector<XML::Node*> const &reprs); - /** Add items from an STL iterator range to the selection. - * \param from the begin iterator - * \param to the end iterator - */ - template <typename InputIterator> - void add(InputIterator from, InputIterator to) { - _invalidateCachedLists(); - while ( from != to ) { - _add(*from); - ++from; - } - _emitChanged(); - } - - /** - * Unselects all selected objects.. - */ - void clear(); - - /** - * Emmit modified signal - */ - void emitModified(); - - /** - * Returns true if no items are selected. - */ - bool isEmpty() const { return _objs.empty(); } - /** - * Returns true if the given object is selected. - */ - bool includes(SPObject *obj) const; + using ObjectSet::includes; /** * Returns true if the given item is selected. */ - bool includes(XML::Node *repr) const { + bool includes(XML::Node *repr) { return includes(_objectForXMLNode(repr)); } - /** - * Returns a single selected object. - * - * @return NULL unless exactly one object is selected - */ - SPObject *single(); - - /** - * Returns a single selected item. - * - * @return NULL unless exactly one object is selected - */ - SPItem *singleItem(); - - /** - * Returns the smallest item from this selection. - */ - SPItem *smallestItem(CompareSize compare); - - /** - * Returns the largest item from this selection. - */ - SPItem *largestItem(CompareSize compare); - - /** - * Returns a single selected object's xml node. - * - * @return NULL unless exactly one object is selected - */ - XML::Node *singleRepr(); - - /** Returns the list of selected objects. */ - std::vector<SPObject*> const &list(); - /** Returns the list of selected SPItems. */ - std::vector<SPItem*> const &itemList(); - /** Returns a list of the xml nodes of all selected objects. */ - /// \todo only returns reprs of SPItems currently; need a separate - /// method for that - std::vector<XML::Node*> const &reprList(); - - /** Returns a list of all perspectives which have a 3D box in the current selection. - (these may also be nested in groups) */ - std::list<Persp3D *> const perspList(); - - /** - * Returns a list of all 3D boxes in the current selection which are associated to @c - * persp. If @c pers is @c NULL, return all selected boxes. - */ - std::list<SPBox3D *> const box3DList(Persp3D *persp = NULL); - /** Returns the number of layers in which there are selected objects. */ size_t numberOfLayers(); /** Returns the number of parents to which the selected objects belong. */ size_t numberOfParents(); - /** Returns the bounding rectangle of the selection. */ - Geom::OptRect bounds(SPItem::BBoxType type) const; - Geom::OptRect visualBounds() const; - Geom::OptRect geometricBounds() const; - - /** - * Returns either the visual or geometric bounding rectangle of the selection, based on the - * preferences specified for the selector tool - */ - Geom::OptRect preferredBounds() const; - - /// Returns the bounding rectangle of the selectionin document coordinates. - Geom::OptRect documentBounds(SPItem::BBoxType type) const; - - /** - * Returns the rotation/skew center of the selection. - */ - boost::optional<Geom::Point> center() const; - /** * Compute the list of points in the selection that are to be considered for snapping from. * @@ -305,6 +167,7 @@ public: * * @return the resulting connection */ + void emitModified(){ _emitModified(this->_flags); }; sigc::connection connectChanged(sigc::slot<void, Selection *> const &slot) { return _changed_signal.connect(slot); } @@ -334,6 +197,11 @@ public: return _modified_signal.slots().insert(_modified_signal.slots().begin(), slot); } +protected: + void _emitSignals(); + void _connectSignals(SPObject* object); + void _releaseSignals(SPObject* object); + private: /** no copy. */ Selection(Selection const &); @@ -349,46 +217,17 @@ private: void _emitModified(unsigned int flags); /** Issues changed selection signal. */ void _emitChanged(bool persist_selection_context = false); - - void _invalidateCachedLists(); - - /** unselect all descendants of the given item. */ - void _removeObjectDescendants(SPObject *obj); - /** unselect all ancestors of the given item. */ - void _removeObjectAncestors(SPObject *obj); - /** clears the selection (without issuing a notification). */ - void _clear(); - /** adds an object (without issuing a notification). */ - void _add(SPObject *obj); - /** removes an object (without issuing a notification). */ - void _remove(SPObject *obj); /** returns the SPObject corresponding to an xml node (if any). */ SPObject *_objectForXMLNode(XML::Node *repr) const; /** Releases an active layer object that is being removed. */ void _releaseContext(SPObject *obj); - mutable std::list<SPObject*> _objs; //to more efficiently remove arbitrary elements - mutable std::vector<SPObject*> _objs_vector; // to be returned by list(); - mutable std::set<SPObject*> _objs_set; //to efficiently test if object is selected - mutable std::vector<XML::Node*> _reprs; - mutable std::vector<SPItem*> _items; - - void add_box_perspective(SPBox3D *box); - void add_3D_boxes_recursively(SPObject *obj); - void remove_box_perspective(SPBox3D *box); - void remove_3D_boxes_recursively(SPObject *obj); - SPItem *_sizeistItem(bool sml, CompareSize compare); - - std::list<SPBox3D *> _3dboxes; - LayerModel *_layers; - GC::soft_ptr<SPDesktop> _desktop; SPObject* _selection_context; unsigned int _flags; unsigned int _idle; std::map<SPObject *, sigc::connection> _modified_connections; - std::map<SPObject *, sigc::connection> _release_connections; sigc::connection _context_release_connection; sigc::signal<void, Selection *> _changed_signal; diff --git a/src/seltrans.cpp b/src/seltrans.cpp index b54525610..7b17a294a 100644 --- a/src/seltrans.cpp +++ b/src/seltrans.cpp @@ -15,7 +15,7 @@ */ #ifdef HAVE_CONFIG_H -# include <config.h> +#include <config.h> #endif #include <cstring> #include <string> @@ -30,11 +30,9 @@ #include "desktop-style.h" #include "knot.h" #include "message-stack.h" -#include "snap.h" #include "pure-transform.h" #include "selection.h" #include "ui/tools/select-tool.h" -#include "sp-item.h" #include "sp-item-transform.h" #include "sp-root.h" #include "seltrans-handles.h" @@ -44,13 +42,9 @@ #include <glibmm/i18n.h> #include "display/sp-ctrlline.h" #include "display/sodipodi-ctrl.h" -#include "preferences.h" -#include "xml/repr.h" #include "mod360.h" -#include <2geom/angle.h> #include "display/snap-indicator.h" #include "ui/control-manager.h" -#include "seltrans-handles.h" using Inkscape::ControlManager; using Inkscape::DocumentUndo; @@ -240,8 +234,8 @@ void Inkscape::SelTrans::setCenter(Geom::Point const &p) _center_is_set = true; // Write the new center position into all selected items - std::vector<SPItem*> items=_desktop->selection->itemList(); - for ( std::vector<SPItem*>::const_iterator iter=items.begin();iter!=items.end(); ++iter) { + auto items= _desktop->selection->items(); + for (auto iter=items.begin();iter!=items.end(); ++iter) { SPItem *it = SP_ITEM(*iter); it->setCenter(p); // only set the value; updating repr and document_done will be done once, on ungrab @@ -270,8 +264,8 @@ void Inkscape::SelTrans::grab(Geom::Point const &p, gdouble x, gdouble y, bool s return; } - std::vector<SPItem*> items=_desktop->selection->itemList(); - for ( std::vector<SPItem*>::const_iterator iter=items.begin();iter!=items.end(); ++iter) { + auto items= _desktop->selection->items(); + for (auto iter=items.begin();iter!=items.end(); ++iter) { SPItem *it = static_cast<SPItem*>(sp_object_ref(*iter, NULL)); _items.push_back(it); _items_const.push_back(it); @@ -445,7 +439,7 @@ void Inkscape::SelTrans::ungrab() if (!_current_relative_affine.isIdentity()) { // we can have a identity affine // when trying to stretch a perfectly vertical line in horizontal direction, which will not be allowed by the handles; - sp_selection_apply_affine(selection, _current_relative_affine, (_show == SHOW_OUTLINE)? true : false); + sp_object_set_apply_affine(selection, _current_relative_affine, (_show == SHOW_OUTLINE) ? true : false); if (_center) { *_center *= _current_relative_affine; _center_is_set = true; @@ -492,8 +486,8 @@ void Inkscape::SelTrans::ungrab() if (_center_is_set) { // we were dragging center; update reprs and commit undoable action - std::vector<SPItem*> items=_desktop->selection->itemList(); - for ( std::vector<SPItem*>::const_iterator iter=items.begin();iter!=items.end(); ++iter) { + auto items= _desktop->selection->items(); + for (auto iter=items.begin();iter!=items.end(); ++iter) { SPItem *it = *iter; it->updateRepr(); } @@ -529,8 +523,8 @@ void Inkscape::SelTrans::stamp() l = _stamp_cache; } else { /* Build cache */ - l = selection->itemList(); - sort(l.begin(),l.end(),sp_object_compare_position_bool); + l.insert(l.end(), selection->items().begin(), selection->items().end()); + sort(l.begin(), l.end(), sp_object_compare_position_bool); _stamp_cache = l; } @@ -621,7 +615,8 @@ void Inkscape::SelTrans::_updateVolatileState() return; } - _strokewidth = stroke_average_width (selection->itemList()); + std::vector<SPItem *> vec(selection->items().begin(), selection->items().end()); + _strokewidth = stroke_average_width(vec); } void Inkscape::SelTrans::_showHandles(SPSelTransType type) @@ -711,8 +706,8 @@ void Inkscape::SelTrans::handleClick(SPKnot */*knot*/, guint state, SPSelTransHa case HANDLE_CENTER: if (state & GDK_SHIFT_MASK) { // Unset the center position for all selected items - std::vector<SPItem*> items=_desktop->selection->itemList(); - for ( std::vector<SPItem*>::const_iterator iter=items.begin();iter!=items.end(); ++iter) { + auto items = _desktop->selection->items(); + for (auto iter=items.begin();iter!=items.end(); ++iter) { SPItem *it = *iter; it->unsetCenter(); it->updateRepr(); @@ -1287,7 +1282,7 @@ gboolean Inkscape::SelTrans::centerRequest(Geom::Point &pt, guint state) // items will share a single center. While dragging that single center, it should never snap to the // centers of any of the selected objects. Therefore we will have to pass the list of selected items // to the snapper, to avoid self-snapping of the rotation center - std::vector<SPItem*> items = const_cast<Selection *>(_selection)->itemList(); + std::vector<SPItem *> items(_selection->items().begin(), _selection->items().end()); SnapManager &m = _desktop->namedview->snap_manager; m.setup(_desktop); m.setRotationCenterSource(items); diff --git a/src/shortcuts.cpp b/src/shortcuts.cpp index 194d4d2a4..e74d60abc 100644 --- a/src/shortcuts.cpp +++ b/src/shortcuts.cpp @@ -26,16 +26,14 @@ #include <map> #include "shortcuts.h" -#include <gdk/gdk.h> #include <gdk/gdkkeysyms.h> #include <gtk/gtk.h> -#include <glibmm/convert.h> #include <glibmm/i18n.h> +#include <glibmm/convert.h> #include <glibmm/miscutils.h> #include "helper/action.h" -#include "helper/action-context.h" #include "io/sys.h" #include "io/resource.h" #include "verbs.h" diff --git a/src/snap-preferences.cpp b/src/snap-preferences.cpp index 79e47ca83..9985b0185 100644 --- a/src/snap-preferences.cpp +++ b/src/snap-preferences.cpp @@ -10,8 +10,6 @@ */ #include "inkscape.h" -#include "snap-preferences.h" -#include <glib.h> // g_assert() Inkscape::SnapPreferences::SnapPreferences() : _snap_enabled_globally(true), diff --git a/src/snap.cpp b/src/snap.cpp index 7f0e8d9dc..c84da0491 100644 --- a/src/snap.cpp +++ b/src/snap.cpp @@ -19,10 +19,6 @@ #include <2geom/transforms.h> #include "sp-namedview.h" -#include "snap.h" -#include "snap-enums.h" -#include "snapped-line.h" -#include "snapped-curve.h" #include "pure-transform.h" #include "display/canvas-grid.h" @@ -30,9 +26,7 @@ #include "inkscape.h" #include "desktop.h" -#include "selection.h" #include "sp-guide.h" -#include "preferences.h" #include "ui/tools/tool-base.h" #include "helper/mathfns.h" using std::vector; @@ -708,8 +702,8 @@ void SnapManager::setupIgnoreSelection(SPDesktop const *desktop, _items_to_ignore.clear(); Inkscape::Selection *sel = _desktop->selection; - std::vector<SPItem*> const items = sel->itemList(); - for (std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();++i) { + auto items = sel->items(); + for (auto i=items.begin();i!=items.end();++i) { _items_to_ignore.push_back(*i); } } diff --git a/src/snap.h b/src/snap.h index 41d21b1b2..12fba05ff 100644 --- a/src/snap.h +++ b/src/snap.h @@ -21,7 +21,6 @@ #include "guide-snapper.h" #include "object-snapper.h" #include "snap-preferences.h" -//#include "pure-transform.h" // Guides diff --git a/src/snapped-curve.cpp b/src/snapped-curve.cpp index b332fa8c1..1f6165813 100644 --- a/src/snapped-curve.cpp +++ b/src/snapped-curve.cpp @@ -9,7 +9,6 @@ */ #include "snapped-curve.h" -#include <2geom/crossing.h> #include <2geom/path-intersection.h> Inkscape::SnappedCurve::SnappedCurve(Geom::Point const &snapped_point, Geom::Point const &tangent, int num_path, int num_segm, Geom::Coord const &snapped_distance, Geom::Coord const &snapped_tolerance, bool const &always_snap, bool const &fully_constrained, Geom::Curve const *curve, SnapSourceType source, long source_num, SnapTargetType target, Geom::OptRect target_bbox) diff --git a/src/snapped-line.cpp b/src/snapped-line.cpp index fa333d6f1..8a307783a 100644 --- a/src/snapped-line.cpp +++ b/src/snapped-line.cpp @@ -1,4 +1,4 @@ -/** +/**#include <config.h> * \file src/snapped-line.cpp * SnappedLine class. * @@ -9,7 +9,6 @@ */ #include "snapped-line.h" -#include <2geom/line.h> Inkscape::SnappedLineSegment::SnappedLineSegment(Geom::Point const &snapped_point, Geom::Coord const &snapped_distance, SnapSourceType const &source, long source_num, SnapTargetType const &target, Geom::Coord const &snapped_tolerance, bool const &always_snap, Geom::Point const &start_point_of_line, Geom::Point const &end_point_of_line) : _start_point_of_line(start_point_of_line), _end_point_of_line(end_point_of_line) diff --git a/src/snapper.cpp b/src/snapper.cpp index 8c985b732..78493746f 100644 --- a/src/snapper.cpp +++ b/src/snapper.cpp @@ -10,7 +10,6 @@ */ #include "sp-namedview.h" -#include "inkscape.h" #include "desktop.h" /** diff --git a/src/sp-clippath.cpp b/src/sp-clippath.cpp index 0c07d1b3d..b371e15b2 100644 --- a/src/sp-clippath.cpp +++ b/src/sp-clippath.cpp @@ -23,7 +23,6 @@ #include "attributes.h" #include "document.h" #include "document-private.h" -#include "sp-item.h" #include "style.h" #include <2geom/transforms.h> @@ -128,9 +127,9 @@ void SPClipPath::update(SPCtx* ctx, unsigned int flags) { flags &= SP_OBJECT_MODIFIED_CASCADE; GSList *l = NULL; - for ( SPObject *child = this->firstChild(); child; child = child->getNext()) { - sp_object_ref(child); - l = g_slist_prepend(l, child); + for (auto& child: children) { + sp_object_ref(&child); + l = g_slist_prepend(l, &child); } l = g_slist_reverse(l); @@ -167,9 +166,9 @@ void SPClipPath::modified(unsigned int flags) { flags &= SP_OBJECT_MODIFIED_CASCADE; GSList *l = NULL; - for (SPObject *child = this->firstChild(); child; child = child->getNext()) { - sp_object_ref(child); - l = g_slist_prepend(l, child); + for (auto& child: children) { + sp_object_ref(&child); + l = g_slist_prepend(l, &child); } l = g_slist_reverse(l); @@ -200,9 +199,9 @@ Inkscape::DrawingItem *SPClipPath::show(Inkscape::Drawing &drawing, unsigned int Inkscape::DrawingGroup *ai = new Inkscape::DrawingGroup(drawing); display = sp_clippath_view_new_prepend(display, key, ai); - for ( SPObject *child = firstChild() ; child ; child = child->getNext() ) { - if (SP_IS_ITEM(child)) { - Inkscape::DrawingItem *ac = SP_ITEM(child)->invoke_show(drawing, key, SP_ITEM_REFERENCE_FLAGS); + for (auto& child: children) { + if (SP_IS_ITEM(&child)) { + Inkscape::DrawingItem *ac = SP_ITEM(&child)->invoke_show(drawing, key, SP_ITEM_REFERENCE_FLAGS); if (ac) { /* The order is not important in clippath */ @@ -223,9 +222,9 @@ Inkscape::DrawingItem *SPClipPath::show(Inkscape::Drawing &drawing, unsigned int } void SPClipPath::hide(unsigned int key) { - for ( SPObject *child = firstChild() ; child; child = child->getNext() ) { - if (SP_IS_ITEM(child)) { - SP_ITEM(child)->invoke_hide(key); + for (auto& child: children) { + if (SP_IS_ITEM(&child)) { + SP_ITEM(&child)->invoke_hide(key); } } @@ -252,9 +251,9 @@ void SPClipPath::setBBox(unsigned int key, Geom::OptRect const &bbox) { Geom::OptRect SPClipPath::geometricBounds(Geom::Affine const &transform) { Geom::OptRect bbox; - for (SPObject *i = firstChild(); i; i = i->getNext()) { - if (SP_IS_ITEM(i)) { - Geom::OptRect tmp = SP_ITEM(i)->geometricBounds(Geom::Affine(SP_ITEM(i)->transform) * transform); + for (auto& i: children) { + if (SP_IS_ITEM(&i)) { + Geom::OptRect tmp = SP_ITEM(&i)->geometricBounds(Geom::Affine(SP_ITEM(&i)->transform) * transform); bbox.unionWith(tmp); } } diff --git a/src/sp-conn-end-pair.cpp b/src/sp-conn-end-pair.cpp index dbd4f2e94..937163f45 100644 --- a/src/sp-conn-end-pair.cpp +++ b/src/sp-conn-end-pair.cpp @@ -13,7 +13,6 @@ #include <cstring> #include <string> -#include <iostream> #include <glibmm/stringutils.h> #include "attributes.h" @@ -22,7 +21,6 @@ #include "display/curve.h" #include "xml/repr.h" #include "sp-path.h" -#include "libavoid/vertices.h" #include "libavoid/router.h" #include "document.h" #include "sp-item-group.h" diff --git a/src/sp-conn-end.cpp b/src/sp-conn-end.cpp index 75cce4374..9ce1a3b56 100644 --- a/src/sp-conn-end.cpp +++ b/src/sp-conn-end.cpp @@ -10,8 +10,6 @@ #include "uri.h" #include "document.h" #include "sp-item-group.h" -#include "2geom/path.h" -#include "2geom/pathvector.h" #include "2geom/path-intersection.h" diff --git a/src/sp-defs.cpp b/src/sp-defs.cpp index dd779c0da..865c6891e 100644 --- a/src/sp-defs.cpp +++ b/src/sp-defs.cpp @@ -54,9 +54,9 @@ void SPDefs::modified(unsigned int flags) { flags &= SP_OBJECT_MODIFIED_CASCADE; GSList *l = NULL; - for ( SPObject *child = this->firstChild() ; child; child = child->getNext() ) { - sp_object_ref(child); - l = g_slist_prepend(l, child); + for (auto& child: children) { + sp_object_ref(&child); + l = g_slist_prepend(l, &child); } l = g_slist_reverse(l); @@ -79,8 +79,8 @@ Inkscape::XML::Node* SPDefs::write(Inkscape::XML::Document *xml_doc, Inkscape::X } GSList *l = NULL; - for ( SPObject *child = this->firstChild() ; child; child = child->getNext() ) { - Inkscape::XML::Node *crepr = child->updateRepr(xml_doc, NULL, flags); + for (auto& child: children) { + Inkscape::XML::Node *crepr = child.updateRepr(xml_doc, NULL, flags); if (crepr) { l = g_slist_prepend(l, crepr); } @@ -93,8 +93,8 @@ Inkscape::XML::Node* SPDefs::write(Inkscape::XML::Document *xml_doc, Inkscape::X } } else { - for ( SPObject *child = this->firstChild() ; child; child = child->getNext() ) { - child->updateRepr(flags); + for (auto& child: children) { + child.updateRepr(flags); } } diff --git a/src/sp-ellipse.cpp b/src/sp-ellipse.cpp index 0675b7781..0d60aa5d8 100644 --- a/src/sp-ellipse.cpp +++ b/src/sp-ellipse.cpp @@ -21,8 +21,6 @@ #include <2geom/circle.h> #include <2geom/ellipse.h> #include <2geom/path-sink.h> -#include <2geom/pathvector.h> -#include <2geom/transforms.h> #include "attributes.h" #include "display/curve.h" @@ -33,19 +31,12 @@ #include "style.h" #include "svg/svg.h" #include "svg/path-string.h" -#include "xml/repr.h" -#ifndef M_PI -#define M_PI 3.14159265358979323846 -#endif - -#define SP_2PI (2 * M_PI) - SPGenericEllipse::SPGenericEllipse() : SPShape() , start(0) - , end(SP_2PI) + , end(M_2_PI) , type(SP_GENERIC_ELLIPSE_UNDEFINED) , _closed(true) { @@ -536,7 +527,7 @@ void SPGenericEllipse::snappoints(std::vector<Inkscape::SnapCandidatePoint> &p, // Snap to the 4 quadrant points of the ellipse, but only if the arc // spans far enough to include them if (snapprefs->isTargetSnappable(Inkscape::SNAPTARGET_ELLIPSE_QUADRANT_POINT)) { - for (double angle = 0; angle < SP_2PI; angle += M_PI_2) { + for (double angle = 0; angle < M_2_PI; angle += M_PI_2) { if (Geom::AngleInterval(this->start, this->end, true).contains(angle)) { Geom::Point pt = this->getPointAtAngle(angle) * i2dt; p.push_back(Inkscape::SnapCandidatePoint(pt, Inkscape::SNAPSOURCE_ELLIPSE_QUADRANT_POINT, Inkscape::SNAPTARGET_ELLIPSE_QUADRANT_POINT)); @@ -671,7 +662,7 @@ bool SPGenericEllipse::_isSlice() const { Geom::AngleInterval a(this->start, this->end, true); - return !(Geom::are_near(a.extent(), 0) || Geom::are_near(a.extent(), SP_2PI)); + return !(Geom::are_near(a.extent(), 0) || Geom::are_near(a.extent(), M_2_PI)); } /* diff --git a/src/sp-factory.cpp b/src/sp-factory.cpp index 20472d425..f98291378 100644 --- a/src/sp-factory.cpp +++ b/src/sp-factory.cpp @@ -32,22 +32,18 @@ #include "sp-hatch.h" #include "sp-hatch-path.h" #include "sp-image.h" -#include "sp-item-group.h" #include "sp-line.h" #include "sp-linear-gradient.h" #include "sp-marker.h" #include "sp-mask.h" -#include "sp-mesh.h" +#include "sp-mesh-gradient.h" #include "sp-mesh-patch.h" #include "sp-mesh-row.h" #include "sp-metadata.h" #include "sp-missing-glyph.h" #include "sp-namedview.h" -#include "sp-object.h" #include "sp-offset.h" -#include "sp-path.h" #include "sp-pattern.h" -#include "sp-polygon.h" #include "sp-polyline.h" #include "sp-radial-gradient.h" #include "sp-rect.h" @@ -68,7 +64,6 @@ #include "sp-title.h" #include "sp-tref.h" #include "sp-tspan.h" -#include "sp-use.h" #include "live_effects/lpeobject.h" // filters @@ -159,8 +154,12 @@ SPObject *SPFactory::createObject(std::string const& id) ret = new SPGuide; else if (id == "svg:hatch") ret = new SPHatch; - else if (id == "svg:hatchPath") + else if (id == "svg:hatchpath") ret = new SPHatchPath; + else if (id == "svg:hatchPath") { + std::cerr << "Warning: <hatchPath> has been renamed <hatchpath>" << std::endl; + ret = new SPHatchPath; + } else if (id == "svg:image") ret = new SPImage; else if (id == "svg:g") @@ -173,8 +172,17 @@ SPObject *SPFactory::createObject(std::string const& id) ret = new SPMarker; else if (id == "svg:mask") ret = new SPMask; - else if (id == "svg:mesh") - ret = new SPMesh; + else if (id == "svg:mesh") { // SVG 2 old + ret = new SPMeshGradient; + std::cerr << "Warning: <mesh> has been renamed <meshgradient>." << std::endl; + std::cerr << "Warning: <mesh> has been repurposed as a shape that tightly wraps a <meshgradient>." << std::endl; + } + else if (id == "svg:meshGradient") { // SVG 2 old + ret = new SPMeshGradient; + std::cerr << "Warning: <meshGradient> has been renamed <meshgradient>" << std::endl; + } + else if (id == "svg:meshgradient") // SVG 2 + ret = new SPMeshGradient; else if (id == "svg:meshpatch") ret = new SPMeshpatch; else if (id == "svg:meshrow") @@ -203,7 +211,11 @@ SPObject *SPFactory::createObject(std::string const& id) ret = new SPRoot; else if (id == "svg:script") ret = new SPScript; - else if (id == "svg:solidColor") + else if (id == "svg:solidColor") { + ret = new SPSolidColor; + std::cerr << "Warning: <solidColor> has been renamed <solidcolor>" << std::endl; + } + else if (id == "svg:solidcolor") ret = new SPSolidColor; else if (id == "spiral") ret = new SPSpiral; diff --git a/src/sp-filter-primitive.cpp b/src/sp-filter-primitive.cpp index b18850914..0fbeed15b 100644 --- a/src/sp-filter-primitive.cpp +++ b/src/sp-filter-primitive.cpp @@ -14,20 +14,16 @@ */ #ifdef HAVE_CONFIG_H -# include "config.h" +#include <config.h> #endif #include <string.h> #include "display/nr-filter-primitive.h" -#include "display/nr-filter-types.h" #include "attributes.h" #include "style.h" #include "sp-filter-primitive.h" -#include "xml/repr.h" -#include "sp-filter.h" -#include "sp-item.h" // CPPIFY: Make pure virtual. @@ -246,8 +242,10 @@ int sp_filter_primitive_read_result(SPFilterPrimitive *prim, gchar const *name) */ int sp_filter_primitive_name_previous_out(SPFilterPrimitive *prim) { SPFilter *parent = SP_FILTER(prim->parent); - SPObject *i = parent->children; - while (i && i->next != prim) i = i->next; + SPObject *i = parent->firstChild(); + while (i && i->getNext() != prim) { + i = i->getNext(); + } if (i) { SPFilterPrimitive *i_prim = SP_FILTER_PRIMITIVE(i); if (i_prim->image_out < 0) { diff --git a/src/sp-filter.cpp b/src/sp-filter.cpp index c17c67fc5..26ea03c6c 100644 --- a/src/sp-filter.cpp +++ b/src/sp-filter.cpp @@ -14,7 +14,7 @@ */ #ifdef HAVE_CONFIG_H -# include "config.h" +#include <config.h> #endif #include <map> @@ -29,14 +29,10 @@ using std::pair; #include "sp-filter.h" #include "sp-filter-reference.h" #include "sp-filter-primitive.h" -#include "sp-item.h" #include "uri.h" #include "xml/repr.h" -#include <cstring> -#include <string> #define SP_MACROS_SILENT -#include "macros.h" static void filter_ref_changed(SPObject *old_ref, SPObject *ref, SPFilter *filter); static void filter_ref_modified(SPObject *href, guint flags, SPFilter *filter); @@ -268,8 +264,8 @@ Inkscape::XML::Node* SPFilter::write(Inkscape::XML::Document *doc, Inkscape::XML } GSList *l = NULL; - for ( SPObject *child = this->firstChild(); child; child = child->getNext() ) { - Inkscape::XML::Node *crepr = child->updateRepr(doc, NULL, flags); + for (auto& child: children) { + Inkscape::XML::Node *crepr = child.updateRepr(doc, NULL, flags); if (crepr) { l = g_slist_prepend (l, crepr); @@ -282,8 +278,8 @@ Inkscape::XML::Node* SPFilter::write(Inkscape::XML::Document *doc, Inkscape::XML l = g_slist_remove (l, l->data); } } else { - for ( SPObject *child = this->firstChild() ; child; child = child->getNext() ) { - child->updateRepr(flags); + for (auto& child: children) { + child.updateRepr(flags); } } @@ -420,10 +416,9 @@ void sp_filter_build_renderer(SPFilter *sp_filter, Inkscape::Filters::Filter *nr } nr_filter->clear_primitives(); - SPObject *primitive_obj = sp_filter->children; - while (primitive_obj) { - if (SP_IS_FILTER_PRIMITIVE(primitive_obj)) { - SPFilterPrimitive *primitive = SP_FILTER_PRIMITIVE(primitive_obj); + for(auto& primitive_obj: sp_filter->children) { + if (SP_IS_FILTER_PRIMITIVE(&primitive_obj)) { + SPFilterPrimitive *primitive = SP_FILTER_PRIMITIVE(&primitive_obj); g_assert(primitive != NULL); // if (((SPFilterPrimitiveClass*) G_OBJECT_GET_CLASS(primitive))->build_renderer) { @@ -433,7 +428,6 @@ void sp_filter_build_renderer(SPFilter *sp_filter, Inkscape::Filters::Filter *nr // } // CPPIFY: => FilterPrimitive should be abstract. primitive->build_renderer(nr_filter); } - primitive_obj = primitive_obj->next; } } @@ -441,11 +435,12 @@ int sp_filter_primitive_count(SPFilter *filter) { g_assert(filter != NULL); int count = 0; - SPObject *primitive_obj = filter->children; - while (primitive_obj) { - if (SP_IS_FILTER_PRIMITIVE(primitive_obj)) count++; - primitive_obj = primitive_obj->next; + for(auto& primitive_obj: filter->children) { + if (SP_IS_FILTER_PRIMITIVE(&primitive_obj)) { + count++; + } } + return count; } @@ -513,10 +508,9 @@ Glib::ustring sp_filter_get_new_result_name(SPFilter *filter) { g_assert(filter != NULL); int largest = 0; - SPObject *primitive_obj = filter->children; - while (primitive_obj) { - if (SP_IS_FILTER_PRIMITIVE(primitive_obj)) { - Inkscape::XML::Node *repr = primitive_obj->getRepr(); + for(auto& primitive_obj: filter->children) { + if (SP_IS_FILTER_PRIMITIVE(&primitive_obj)) { + Inkscape::XML::Node *repr = primitive_obj.getRepr(); char const *result = repr->attribute("result"); int index; if (result) @@ -530,7 +524,6 @@ Glib::ustring sp_filter_get_new_result_name(SPFilter *filter) { } } } - primitive_obj = primitive_obj->next; } return "result" + Glib::Ascii::dtostr(largest + 1); diff --git a/src/sp-flowdiv.cpp b/src/sp-flowdiv.cpp index 8d9c51ab8..17b841e37 100644 --- a/src/sp-flowdiv.cpp +++ b/src/sp-flowdiv.cpp @@ -27,9 +27,9 @@ void SPFlowdiv::update(SPCtx *ctx, unsigned int flags) { childflags &= SP_OBJECT_MODIFIED_CASCADE; GSList* l = NULL; - for (SPObject *child = this->firstChild() ; child ; child = child->getNext() ) { - sp_object_ref(child); - l = g_slist_prepend(l, child); + for (auto& child: children) { + sp_object_ref(&child); + l = g_slist_prepend(l, &child); } l = g_slist_reverse(l); @@ -65,9 +65,9 @@ void SPFlowdiv::modified(unsigned int flags) { flags &= SP_OBJECT_MODIFIED_CASCADE; GSList *l = NULL; - for ( SPObject *child = this->firstChild() ; child ; child = child->getNext() ) { - sp_object_ref(child); - l = g_slist_prepend(l, child); + for (auto& child: children) { + sp_object_ref(&child); + l = g_slist_prepend(l, &child); } l = g_slist_reverse (l); @@ -104,15 +104,15 @@ Inkscape::XML::Node* SPFlowdiv::write(Inkscape::XML::Document *xml_doc, Inkscape GSList *l = NULL; - for (SPObject* child = this->firstChild() ; child ; child = child->getNext() ) { + for (auto& child: children) { Inkscape::XML::Node* c_repr = NULL; - if ( SP_IS_FLOWTSPAN (child) ) { - c_repr = child->updateRepr(xml_doc, NULL, flags); - } else if ( SP_IS_FLOWPARA(child) ) { - c_repr = child->updateRepr(xml_doc, NULL, flags); - } else if ( SP_IS_STRING(child) ) { - c_repr = xml_doc->createTextNode(SP_STRING(child)->string.c_str()); + if ( SP_IS_FLOWTSPAN (&child) ) { + c_repr = child.updateRepr(xml_doc, NULL, flags); + } else if ( SP_IS_FLOWPARA(&child) ) { + c_repr = child.updateRepr(xml_doc, NULL, flags); + } else if ( SP_IS_STRING(&child) ) { + c_repr = xml_doc->createTextNode(SP_STRING(&child)->string.c_str()); } if ( c_repr ) { @@ -126,13 +126,13 @@ Inkscape::XML::Node* SPFlowdiv::write(Inkscape::XML::Document *xml_doc, Inkscape l = g_slist_remove(l, l->data); } } else { - for ( SPObject* child = this->firstChild() ; child ; child = child->getNext() ) { - if ( SP_IS_FLOWTSPAN (child) ) { - child->updateRepr(flags); - } else if ( SP_IS_FLOWPARA(child) ) { - child->updateRepr(flags); - } else if ( SP_IS_STRING(child) ) { - child->getRepr()->setContent(SP_STRING(child)->string.c_str()); + for (auto& child: children) { + if ( SP_IS_FLOWTSPAN (&child) ) { + child.updateRepr(flags); + } else if ( SP_IS_FLOWPARA(&child) ) { + child.updateRepr(flags); + } else if ( SP_IS_STRING(&child) ) { + child.getRepr()->setContent(SP_STRING(&child)->string.c_str()); } } } @@ -168,9 +168,9 @@ void SPFlowtspan::update(SPCtx *ctx, unsigned int flags) { childflags &= SP_OBJECT_MODIFIED_CASCADE; GSList* l = NULL; - for ( SPObject *child = this->firstChild() ; child ; child = child->getNext() ) { - sp_object_ref(child); - l = g_slist_prepend(l, child); + for (auto& child: children) { + sp_object_ref(&child); + l = g_slist_prepend(l, &child); } l = g_slist_reverse (l); @@ -206,9 +206,9 @@ void SPFlowtspan::modified(unsigned int flags) { flags &= SP_OBJECT_MODIFIED_CASCADE; GSList *l = NULL; - for ( SPObject *child = this->firstChild() ; child ; child = child->getNext() ) { - sp_object_ref(child); - l = g_slist_prepend(l, child); + for (auto& child: children) { + sp_object_ref(&child); + l = g_slist_prepend(l, &child); } l = g_slist_reverse (l); @@ -242,15 +242,15 @@ Inkscape::XML::Node *SPFlowtspan::write(Inkscape::XML::Document *xml_doc, Inksca GSList *l = NULL; - for ( SPObject* child = this->firstChild() ; child ; child = child->getNext() ) { + for (auto& child: children) { Inkscape::XML::Node* c_repr = NULL; - if ( SP_IS_FLOWTSPAN(child) ) { - c_repr = child->updateRepr(xml_doc, NULL, flags); - } else if ( SP_IS_FLOWPARA(child) ) { - c_repr = child->updateRepr(xml_doc, NULL, flags); - } else if ( SP_IS_STRING(child) ) { - c_repr = xml_doc->createTextNode(SP_STRING(child)->string.c_str()); + if ( SP_IS_FLOWTSPAN(&child) ) { + c_repr = child.updateRepr(xml_doc, NULL, flags); + } else if ( SP_IS_FLOWPARA(&child) ) { + c_repr = child.updateRepr(xml_doc, NULL, flags); + } else if ( SP_IS_STRING(&child) ) { + c_repr = xml_doc->createTextNode(SP_STRING(&child)->string.c_str()); } if ( c_repr ) { @@ -264,13 +264,13 @@ Inkscape::XML::Node *SPFlowtspan::write(Inkscape::XML::Document *xml_doc, Inksca l = g_slist_remove(l, l->data); } } else { - for ( SPObject* child = this->firstChild() ; child ; child = child->getNext() ) { - if ( SP_IS_FLOWTSPAN(child) ) { - child->updateRepr(flags); - } else if ( SP_IS_FLOWPARA(child) ) { - child->updateRepr(flags); - } else if ( SP_IS_STRING(child) ) { - child->getRepr()->setContent(SP_STRING(child)->string.c_str()); + for (auto& child: children) { + if ( SP_IS_FLOWTSPAN(&child) ) { + child.updateRepr(flags); + } else if ( SP_IS_FLOWPARA(&child) ) { + child.updateRepr(flags); + } else if ( SP_IS_STRING(&child) ) { + child.getRepr()->setContent(SP_STRING(&child)->string.c_str()); } } } @@ -307,9 +307,9 @@ void SPFlowpara::update(SPCtx *ctx, unsigned int flags) { flags &= SP_OBJECT_MODIFIED_CASCADE; GSList* l = NULL; - for ( SPObject *child = this->firstChild() ; child ; child = child->getNext() ) { - sp_object_ref(child); - l = g_slist_prepend(l, child); + for (auto& child: children) { + sp_object_ref(&child); + l = g_slist_prepend(l, &child); } l = g_slist_reverse (l); @@ -343,9 +343,9 @@ void SPFlowpara::modified(unsigned int flags) { flags &= SP_OBJECT_MODIFIED_CASCADE; GSList *l = NULL; - for ( SPObject *child = this->firstChild() ; child ; child = child->getNext() ) { - sp_object_ref(child); - l = g_slist_prepend(l, child); + for (auto& child: children) { + sp_object_ref(&child); + l = g_slist_prepend(l, &child); } l = g_slist_reverse (l); @@ -379,15 +379,15 @@ Inkscape::XML::Node *SPFlowpara::write(Inkscape::XML::Document *xml_doc, Inkscap GSList *l = NULL; - for ( SPObject* child = this->firstChild() ; child ; child = child->getNext() ) { + for (auto& child: children) { Inkscape::XML::Node* c_repr = NULL; - if ( SP_IS_FLOWTSPAN(child) ) { - c_repr = child->updateRepr(xml_doc, NULL, flags); - } else if ( SP_IS_FLOWPARA(child) ) { - c_repr = child->updateRepr(xml_doc, NULL, flags); - } else if ( SP_IS_STRING(child) ) { - c_repr = xml_doc->createTextNode(SP_STRING(child)->string.c_str()); + if ( SP_IS_FLOWTSPAN(&child) ) { + c_repr = child.updateRepr(xml_doc, NULL, flags); + } else if ( SP_IS_FLOWPARA(&child) ) { + c_repr = child.updateRepr(xml_doc, NULL, flags); + } else if ( SP_IS_STRING(&child) ) { + c_repr = xml_doc->createTextNode(SP_STRING(&child)->string.c_str()); } if ( c_repr ) { @@ -401,13 +401,13 @@ Inkscape::XML::Node *SPFlowpara::write(Inkscape::XML::Document *xml_doc, Inkscap l = g_slist_remove(l, l->data); } } else { - for ( SPObject* child = this->firstChild() ; child ; child = child->getNext() ) { - if ( SP_IS_FLOWTSPAN(child) ) { - child->updateRepr(flags); - } else if ( SP_IS_FLOWPARA(child) ) { - child->updateRepr(flags); - } else if ( SP_IS_STRING(child) ) { - child->getRepr()->setContent(SP_STRING(child)->string.c_str()); + for (auto& child: children) { + if ( SP_IS_FLOWTSPAN(&child) ) { + child.updateRepr(flags); + } else if ( SP_IS_FLOWPARA(&child) ) { + child.updateRepr(flags); + } else if ( SP_IS_STRING(&child) ) { + child.getRepr()->setContent(SP_STRING(&child)->string.c_str()); } } } diff --git a/src/sp-flowregion.cpp b/src/sp-flowregion.cpp index 5715e5eb1..4064c12f1 100644 --- a/src/sp-flowregion.cpp +++ b/src/sp-flowregion.cpp @@ -2,7 +2,7 @@ */ #ifdef HAVE_CONFIG_H -# include "config.h" +#include <config.h> #endif #include <glibmm/i18n.h> @@ -18,8 +18,6 @@ #include "sp-flowregion.h" -#include "display/canvas-bpath.h" - #include "livarot/Path.h" #include "livarot/Shape.h" @@ -63,9 +61,9 @@ void SPFlowregion::update(SPCtx *ctx, unsigned int flags) { GSList *l = NULL; - for ( SPObject *child = this->firstChild() ; child ; child = child->getNext() ) { - sp_object_ref(child); - l = g_slist_prepend(l, child); + for (auto& child: children) { + sp_object_ref(&child); + l = g_slist_prepend(l, &child); } l = g_slist_reverse(l); @@ -102,9 +100,9 @@ void SPFlowregion::UpdateComputed(void) } computed.clear(); - for (SPObject* child = firstChild() ; child ; child = child->getNext() ) { + for (auto& child: children) { Shape *shape = 0; - GetDest(child, &shape); + GetDest(&child, &shape); computed.push_back(shape); } } @@ -118,9 +116,9 @@ void SPFlowregion::modified(guint flags) { GSList *l = NULL; - for ( SPObject *child = this->firstChild() ; child ; child = child->getNext() ) { - sp_object_ref(child); - l = g_slist_prepend(l, child); + for (auto& child: children) { + sp_object_ref(&child); + l = g_slist_prepend(l, &child); } l = g_slist_reverse(l); @@ -145,9 +143,9 @@ Inkscape::XML::Node *SPFlowregion::write(Inkscape::XML::Document *xml_doc, Inksc } GSList *l = NULL; - for ( SPObject *child = this->firstChild() ; child; child = child->getNext() ) { - if ( !dynamic_cast<SPTitle *>(child) && !dynamic_cast<SPDesc *>(child) ) { - Inkscape::XML::Node *crepr = child->updateRepr(xml_doc, NULL, flags); + for (auto& child: children) { + if ( !dynamic_cast<SPTitle *>(&child) && !dynamic_cast<SPDesc *>(&child) ) { + Inkscape::XML::Node *crepr = child.updateRepr(xml_doc, NULL, flags); if (crepr) { l = g_slist_prepend(l, crepr); @@ -161,10 +159,9 @@ Inkscape::XML::Node *SPFlowregion::write(Inkscape::XML::Document *xml_doc, Inksc l = g_slist_remove(l, l->data); } - } else { - for ( SPObject *child = this->firstChild() ; child; child = child->getNext() ) { - if ( !dynamic_cast<SPTitle *>(child) && !dynamic_cast<SPDesc *>(child) ) { - child->updateRepr(flags); + for (auto& child: children) { + if ( !dynamic_cast<SPTitle *>(&child) && !dynamic_cast<SPDesc *>(&child) ) { + child.updateRepr(flags); } } } @@ -221,9 +218,9 @@ void SPFlowregionExclude::update(SPCtx *ctx, unsigned int flags) { GSList *l = NULL; - for ( SPObject *child = this->firstChild() ; child ; child = child->getNext() ) { - sp_object_ref(child); - l = g_slist_prepend(l, child); + for (auto& child: children) { + sp_object_ref(&child); + l = g_slist_prepend(l, &child); } l = g_slist_reverse (l); @@ -259,8 +256,8 @@ void SPFlowregionExclude::UpdateComputed(void) computed = NULL; } - for ( SPObject* child = firstChild() ; child ; child = child->getNext() ) { - GetDest(child, &computed); + for (auto& child: children) { + GetDest(&child, &computed); } } @@ -273,9 +270,9 @@ void SPFlowregionExclude::modified(guint flags) { GSList *l = NULL; - for ( SPObject *child = this->firstChild() ; child ; child = child->getNext() ) { - sp_object_ref(child); - l = g_slist_prepend(l, child); + for (auto& child: children) { + sp_object_ref(&child); + l = g_slist_prepend(l, &child); } l = g_slist_reverse (l); @@ -301,8 +298,8 @@ Inkscape::XML::Node *SPFlowregionExclude::write(Inkscape::XML::Document *xml_doc GSList *l = NULL; - for ( SPObject *child = this->firstChild() ; child; child = child->getNext() ) { - Inkscape::XML::Node *crepr = child->updateRepr(xml_doc, NULL, flags); + for (auto& child: children) { + Inkscape::XML::Node *crepr = child.updateRepr(xml_doc, NULL, flags); if (crepr) { l = g_slist_prepend(l, crepr); @@ -316,8 +313,8 @@ Inkscape::XML::Node *SPFlowregionExclude::write(Inkscape::XML::Document *xml_doc } } else { - for ( SPObject *child = this->firstChild() ; child; child = child->getNext() ) { - child->updateRepr(flags); + for (auto& child: children) { + child.updateRepr(flags); } } diff --git a/src/sp-flowtext.cpp b/src/sp-flowtext.cpp index 51fb3ae89..264558014 100644 --- a/src/sp-flowtext.cpp +++ b/src/sp-flowtext.cpp @@ -2,7 +2,7 @@ */ #ifdef HAVE_CONFIG_H -# include "config.h" +#include <config.h> #endif #include <glibmm/i18n.h> #include <cstring> @@ -13,20 +13,15 @@ #include "style.h" #include "inkscape.h" #include "document.h" -#include "selection.h" #include "desktop.h" -#include "xml/repr.h" - #include "sp-flowdiv.h" #include "sp-flowregion.h" #include "sp-flowtext.h" #include "sp-string.h" -#include "sp-use.h" #include "sp-rect.h" #include "text-tag-attributes.h" -#include "text-chemistry.h" #include "text-editing.h" #include "sp-text.h" @@ -72,9 +67,9 @@ void SPFlowtext::update(SPCtx* ctx, unsigned int flags) { GSList *l = NULL; - for (SPObject *child = this->firstChild() ; child ; child = child->getNext() ) { - sp_object_ref(child); - l = g_slist_prepend(l, child); + for (auto& child: children) { + sp_object_ref(&child); + l = g_slist_prepend(l, &child); } l = g_slist_reverse(l); @@ -135,9 +130,9 @@ void SPFlowtext::modified(unsigned int flags) { } } - for ( SPObject *o = this->firstChild() ; o ; o = o->getNext() ) { - if (dynamic_cast<SPFlowregion *>(o)) { - region = o; + for (auto& o: children) { + if (dynamic_cast<SPFlowregion *>(&o)) { + region = &o; break; } } @@ -223,11 +218,11 @@ Inkscape::XML::Node* SPFlowtext::write(Inkscape::XML::Document* doc, Inkscape::X GSList *l = NULL; - for (SPObject *child = this->firstChild() ; child ; child = child->getNext() ) { + for (auto& child: children) { Inkscape::XML::Node *c_repr = NULL; - if ( dynamic_cast<SPFlowdiv *>(child) || dynamic_cast<SPFlowpara *>(child) || dynamic_cast<SPFlowregion *>(child) || dynamic_cast<SPFlowregionExclude *>(child)) { - c_repr = child->updateRepr(doc, NULL, flags); + if ( dynamic_cast<SPFlowdiv *>(&child) || dynamic_cast<SPFlowpara *>(&child) || dynamic_cast<SPFlowregion *>(&child) || dynamic_cast<SPFlowregionExclude *>(&child)) { + c_repr = child.updateRepr(doc, NULL, flags); } if ( c_repr ) { @@ -241,9 +236,9 @@ Inkscape::XML::Node* SPFlowtext::write(Inkscape::XML::Document* doc, Inkscape::X l = g_slist_remove(l, l->data); } } else { - for (SPObject *child = this->firstChild() ; child ; child = child->getNext() ) { - if ( dynamic_cast<SPFlowdiv *>(child) || dynamic_cast<SPFlowpara *>(child) || dynamic_cast<SPFlowregion *>(child) || dynamic_cast<SPFlowregionExclude *>(child)) { - child->updateRepr(flags); + for (auto& child: children) { + if ( dynamic_cast<SPFlowdiv *>(&child) || dynamic_cast<SPFlowpara *>(&child) || dynamic_cast<SPFlowregion *>(&child) || dynamic_cast<SPFlowregionExclude *>(&child)) { + child.updateRepr(flags); } } } @@ -390,8 +385,8 @@ void SPFlowtext::_buildLayoutInput(SPObject *root, Shape const *exclusion_shape, *pending_line_break_object = NULL; } - for (SPObject *child = root->firstChild() ; child ; child = child->getNext() ) { - SPString *str = dynamic_cast<SPString *>(child); + for (auto& child: root->children) { + SPString *str = dynamic_cast<SPString *>(&child); if (str) { if (*pending_line_break_object) { if (dynamic_cast<SPFlowregionbreak *>(*pending_line_break_object)) @@ -402,12 +397,12 @@ void SPFlowtext::_buildLayoutInput(SPObject *root, Shape const *exclusion_shape, *pending_line_break_object = NULL; } if (with_indent) { - layout.appendText(str->string, root->style, child, &pi); + layout.appendText(str->string, root->style, &child, &pi); } else { - layout.appendText(str->string, root->style, child); + layout.appendText(str->string, root->style, &child); } } else { - SPFlowregion *region = dynamic_cast<SPFlowregion *>(child); + SPFlowregion *region = dynamic_cast<SPFlowregion *>(&child); if (region) { std::vector<Shape*> const &computed = region->computed; for (std::vector<Shape*>::const_iterator it = computed.begin() ; it != computed.end() ; ++it) { @@ -421,8 +416,8 @@ void SPFlowtext::_buildLayoutInput(SPObject *root, Shape const *exclusion_shape, } } //Xml Tree is being directly used while it shouldn't be. - else if (!dynamic_cast<SPFlowregionExclude *>(child) && !sp_repr_is_meta_element(child->getRepr())) { - _buildLayoutInput(child, exclusion_shape, shapes, pending_line_break_object); + else if (!dynamic_cast<SPFlowregionExclude *>(&child) && !sp_repr_is_meta_element(child.getRepr())) { + _buildLayoutInput(&child, exclusion_shape, shapes, pending_line_break_object); } } } @@ -440,9 +435,9 @@ Shape* SPFlowtext::_buildExclusionShape() const Shape *shape = new Shape(); Shape *shape_temp = new Shape(); - for (SPObject *child = children ; child ; child = child->getNext() ) { + for (auto& child: children) { // RH: is it right that this shouldn't be recursive? - SPFlowregionExclude *c_child = dynamic_cast<SPFlowregionExclude *>(child); + SPFlowregionExclude *c_child = dynamic_cast<SPFlowregionExclude *>(const_cast<SPObject*>(&child)); if ( c_child && c_child->computed && c_child->computed->hasEdges() ) { if (shape->hasEdges()) { shape_temp->Booleen(shape, c_child->computed, bool_op_union); @@ -593,9 +588,9 @@ SPItem *SPFlowtext::get_frame(SPItem const *after) SPItem *frame = 0; SPObject *region = 0; - for (SPObject *o = firstChild() ; o ; o = o->getNext() ) { - if (dynamic_cast<SPFlowregion *>(o)) { - region = o; + for (auto& o: children) { + if (dynamic_cast<SPFlowregion *>(&o)) { + region = &o; break; } } @@ -603,8 +598,8 @@ SPItem *SPFlowtext::get_frame(SPItem const *after) if (region) { bool past = false; - for (SPObject *o = region->firstChild() ; o ; o = o->getNext() ) { - SPItem *item = dynamic_cast<SPItem *>(o); + for (auto& o: region->children) { + SPItem *item = dynamic_cast<SPItem *>(&o); if (item) { if ( (after == NULL) || past ) { frame = item; @@ -707,9 +702,9 @@ Geom::Affine SPFlowtext::set_transform (Geom::Affine const &xform) } SPObject *region = NULL; - for ( SPObject *o = this->firstChild() ; o ; o = o->getNext() ) { - if (dynamic_cast<SPFlowregion *>(o)) { - region = o; + for (auto& o: children) { + if (dynamic_cast<SPFlowregion *>(&o)) { + region = &o; break; } } diff --git a/src/sp-flowtext.h b/src/sp-flowtext.h index 9ee676893..d0b0a19a4 100644 --- a/src/sp-flowtext.h +++ b/src/sp-flowtext.h @@ -8,6 +8,7 @@ #include "libnrtype/Layout-TNG.h" #include "sp-item.h" +#include "desktop.h" #define SP_FLOWTEXT(obj) (dynamic_cast<SPFlowtext*>((SPObject*)obj)) #define SP_IS_FLOWTEXT(obj) (dynamic_cast<const SPFlowtext*>((SPObject*)obj) != NULL) diff --git a/src/sp-font-face.cpp b/src/sp-font-face.cpp index afd2a9dee..52fc09ddd 100644 --- a/src/sp-font-face.cpp +++ b/src/sp-font-face.cpp @@ -1,5 +1,5 @@ #ifdef HAVE_CONFIG_H -# include <config.h> +#include <config.h> #endif /* diff --git a/src/sp-font.cpp b/src/sp-font.cpp index 341a6159f..0d97463df 100644 --- a/src/sp-font.cpp +++ b/src/sp-font.cpp @@ -1,5 +1,5 @@ #ifdef HAVE_CONFIG_H -# include <config.h> +#include <config.h> #endif /* @@ -17,8 +17,6 @@ #include "xml/repr.h" #include "attributes.h" #include "sp-font.h" -#include "sp-glyph.h" -#include "sp-missing-glyph.h" #include "document.h" #include "display/nr-svgfonts.h" @@ -27,9 +25,9 @@ //I think we should have extra stuff here and in the set method in order to set default value as specified at http://www.w3.org/TR/SVG/fonts.html // TODO determine better values and/or make these dynamic: -double FNT_DEFAULT_ADV = 90; // TODO determine proper default -double FNT_DEFAULT_ASCENT = 90; // TODO determine proper default -double FNT_UNITS_PER_EM = 90; // TODO determine proper default +double FNT_DEFAULT_ADV = 1024; // TODO determine proper default +double FNT_DEFAULT_ASCENT = 768; // TODO determine proper default +double FNT_UNITS_PER_EM = 1024; // TODO determine proper default SPFont::SPFont() : SPObject() { this->horiz_origin_x = 0; diff --git a/src/sp-glyph-kerning.cpp b/src/sp-glyph-kerning.cpp index f33d3c509..66de5aed9 100644 --- a/src/sp-glyph-kerning.cpp +++ b/src/sp-glyph-kerning.cpp @@ -16,7 +16,6 @@ #include "sp-glyph-kerning.h" #include "document.h" -#include <string> #include <cstring> diff --git a/src/sp-glyph.cpp b/src/sp-glyph.cpp index 4829aae51..6284cbfa1 100644 --- a/src/sp-glyph.cpp +++ b/src/sp-glyph.cpp @@ -1,5 +1,4 @@ #ifdef HAVE_CONFIG_H -# include <config.h> #endif /* @@ -18,7 +17,6 @@ #include "attributes.h" #include "sp-glyph.h" #include "document.h" -#include <cstring> SPGlyph::SPGlyph() : SPObject() diff --git a/src/sp-gradient-test.h b/src/sp-gradient-test.h deleted file mode 100644 index 578d0c5c0..000000000 --- a/src/sp-gradient-test.h +++ /dev/null @@ -1,161 +0,0 @@ -#ifndef SEEN_SP_GRADIENT_TEST_H -#define SEEN_SP_GRADIENT_TEST_H - -#include "document-using-test.h" - - -#include "sp-gradient.h" -#include "svg/svg.h" -#include "xml/repr.h" -#include <2geom/transforms.h> -#include "helper/geom.h" - -class SPGradientTest : public DocumentUsingTest -{ -public: - SPDocument* _doc; - - SPGradientTest() : - _doc(0) - { - } - - virtual ~SPGradientTest() - { - if ( _doc ) - { - _doc->doUnref(); - } - } - - static void createSuiteSubclass( SPGradientTest *& dst ) - { - SPGradient *gr = static_cast<SPGradient *>(g_object_new(SP_TYPE_GRADIENT, NULL)); - if ( gr ) { - UTEST_ASSERT(gr->gradientTransform.isIdentity()); - UTEST_ASSERT(gr->gradientTransform == Geom::identity()); - g_object_unref(gr); - - dst = new SPGradientTest(); - } - } - - static SPGradientTest *createSuite() - { - return Inkscape::createSuiteAndDocument<SPGradientTest>( createSuiteSubclass ); - } - - static void destroySuite( SPGradientTest *suite ) { delete suite; } - -// ------------------------------------------------------------------------- -// ------------------------------------------------------------------------- - - void testSetGradientTransform() - { - SPGradient *gr = static_cast<SPGradient *>(g_object_new(SP_TYPE_GRADIENT, NULL)); - SP_OBJECT(gr)->document = _doc; - - SP_OBJECT(gr)->setKeyValue( SP_ATTR_GRADIENTTRANSFORM, "translate(5, 8)"); - TS_ASSERT_EQUALS( gr->gradientTransform, Geom::Affine(Geom::Translate(5, 8)) ); - - SP_OBJECT(gr)->setKeyValue( SP_ATTR_GRADIENTTRANSFORM, ""); - TS_ASSERT_EQUALS( gr->gradientTransform, Geom::identity() ); - - SP_OBJECT(gr)->setKeyValue( SP_ATTR_GRADIENTTRANSFORM, "rotate(90)"); - TS_ASSERT_EQUALS( gr->gradientTransform, Geom::Affine(rotate_degrees(90)) ); - - g_object_unref(gr); - } - - - void testWrite() - { - SPGradient *gr = static_cast<SPGradient *>(g_object_new(SP_TYPE_GRADIENT, NULL)); - SP_OBJECT(gr)->document = _doc; - - SP_OBJECT(gr)->setKeyValue( SP_ATTR_GRADIENTTRANSFORM, "matrix(0, 1, -1, 0, 0, 0)"); - Inkscape::XML::Document *xml_doc = _doc->getReprDoc(); - Inkscape::XML::Node *repr = xml_doc->createElement("svg:radialGradient"); - SP_OBJECT(gr)->updateRepr(repr, SP_OBJECT_WRITE_ALL); - { - gchar const *tr = repr->attribute("gradientTransform"); - Geom::Affine svd; - bool const valid = sp_svg_transform_read(tr, &svd); - TS_ASSERT( valid ); - TS_ASSERT_EQUALS( svd, Geom::Affine(rotate_degrees(90)) ); - } - - g_object_unref(gr); - } - - - void testGetG2dGetGs2dSetGs2d() - { - SPGradient *gr = static_cast<SPGradient *>(g_object_new(SP_TYPE_GRADIENT, NULL)); - SP_OBJECT(gr)->document = _doc; - Geom::Affine const grXform(2, 1, - 1, 3, - 4, 6); - gr->gradientTransform = grXform; - Geom::Rect const unit_rect(Geom::Point(0, 0), Geom::Point(1, 1)); - { - Geom::Affine const g2d(sp_gradient_get_g2d_matrix(gr, Geom::identity(), unit_rect)); - Geom::Affine const gs2d(sp_gradient_get_gs2d_matrix(gr, Geom::identity(), unit_rect)); - TS_ASSERT_EQUALS( g2d, Geom::identity() ); - TS_ASSERT( Geom::are_near(gs2d, gr->gradientTransform * g2d, 1e-12) ); - - sp_gradient_set_gs2d_matrix(gr, Geom::identity(), unit_rect, gs2d); - TS_ASSERT( Geom::are_near(gr->gradientTransform, grXform, 1e-12) ); - } - - gr->gradientTransform = grXform; - Geom::Affine const funny(2, 3, - 4, 5, - 6, 7); - { - Geom::Affine const g2d(sp_gradient_get_g2d_matrix(gr, funny, unit_rect)); - Geom::Affine const gs2d(sp_gradient_get_gs2d_matrix(gr, funny, unit_rect)); - TS_ASSERT_EQUALS( g2d, funny ); - TS_ASSERT( Geom::are_near(gs2d, gr->gradientTransform * g2d, 1e-12) ); - - sp_gradient_set_gs2d_matrix(gr, funny, unit_rect, gs2d); - TS_ASSERT( Geom::are_near(gr->gradientTransform, grXform, 1e-12) ); - } - - gr->gradientTransform = grXform; - Geom::Rect const larger_rect(Geom::Point(5, 6), Geom::Point(8, 10)); - { - Geom::Affine const g2d(sp_gradient_get_g2d_matrix(gr, funny, larger_rect)); - Geom::Affine const gs2d(sp_gradient_get_gs2d_matrix(gr, funny, larger_rect)); - TS_ASSERT_EQUALS( g2d, Geom::Affine(3, 0, - 0, 4, - 5, 6) * funny ); - TS_ASSERT( Geom::are_near(gs2d, gr->gradientTransform * g2d, 1e-12) ); - - sp_gradient_set_gs2d_matrix(gr, funny, larger_rect, gs2d); - TS_ASSERT( Geom::are_near(gr->gradientTransform, grXform, 1e-12) ); - - SP_OBJECT(gr)->setKeyValue( SP_ATTR_GRADIENTUNITS, "userSpaceOnUse"); - Geom::Affine const user_g2d(sp_gradient_get_g2d_matrix(gr, funny, larger_rect)); - Geom::Affine const user_gs2d(sp_gradient_get_gs2d_matrix(gr, funny, larger_rect)); - TS_ASSERT_EQUALS( user_g2d, funny ); - TS_ASSERT( Geom::are_near(user_gs2d, gr->gradientTransform * user_g2d, 1e-12) ); - } - g_object_unref(gr); - } - -}; - - -#endif // SEEN_SP_GRADIENT_TEST_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/sp-gradient.cpp b/src/sp-gradient.cpp index 854d53dc4..d3e38485b 100644 --- a/src/sp-gradient.cpp +++ b/src/sp-gradient.cpp @@ -1,6 +1,6 @@ /** \file * SPGradient, SPStop, SPLinearGradient, SPRadialGradient, - * SPMesh, SPMeshRow, SPMeshPatch + * SPMeshGradient, SPMeshRow, SPMeshPatch */ /* * Authors: @@ -22,6 +22,7 @@ */ #define noSP_GRADIENT_VERBOSE +//#define OBJECT_TRACE #include <cstring> #include <string> @@ -35,7 +36,6 @@ #include "display/cairo-utils.h" #include "svg/svg.h" -#include "svg/svg-color.h" #include "svg/css-ostringstream.h" #include "attributes.h" #include "document-private.h" @@ -44,15 +44,9 @@ #include "sp-gradient-reference.h" #include "sp-linear-gradient.h" #include "sp-radial-gradient.h" -#include "sp-mesh.h" +#include "sp-mesh-gradient.h" #include "sp-mesh-row.h" -#include "sp-mesh-patch.h" #include "sp-stop.h" -#include "streq.h" -#include "uri.h" -#include "xml/repr.h" -#include "style.h" -#include "display/grayscale.h" /// Has to be power of 2 Seems to be unused. //#define NCOLORS NR_GRADIENT_VECTOR_LENGTH @@ -121,7 +115,7 @@ bool SPGradient::isEquivalent(SPGradient *that) else if ( (SP_IS_LINEARGRADIENT(this) && SP_IS_LINEARGRADIENT(that)) || (SP_IS_RADIALGRADIENT(this) && SP_IS_RADIALGRADIENT(that)) || - (SP_IS_MESH(this) && SP_IS_MESH(that))) { + (SP_IS_MESHGRADIENT(this) && SP_IS_MESHGRADIENT(that))) { if(!this->isAligned(that))break; } else { break; } // this should never happen, some unhandled type of gradient @@ -206,9 +200,9 @@ bool SPGradient::isAligned(SPGradient *that) (sg->fy.computed != tg->fy.computed) ) { break; } } else if( sg->cx._set || sg->cy._set || sg->fx._set || sg->fy._set || sg->r._set ) { break; } // some mix of set and not set // none set? assume aligned and fall through - } else if (SP_IS_MESH(this) && SP_IS_MESH(that)) { - SPMesh *sg=SP_MESH(this); - SPMesh *tg=SP_MESH(that); + } else if (SP_IS_MESHGRADIENT(this) && SP_IS_MESHGRADIENT(that)) { + SPMeshGradient *sg=SP_MESHGRADIENT(this); + SPMeshGradient *tg=SP_MESHGRADIENT(that); if( sg->x._set != !tg->x._set) { break; } if( sg->y._set != !tg->y._set) { break; } @@ -235,7 +229,7 @@ SPGradient::SPGradient() : SPPaintServer(), units(), state(2), vector() { - this->has_patches = 0; + this->has_patches = 0; this->ref = new SPGradientReference(this); this->ref->changedSignal().connect(sigc::bind(sigc::ptr_fun(SPGradient::gradientRefChanged), this)); @@ -276,8 +270,8 @@ void SPGradient::build(SPDocument *document, Inkscape::XML::Node *repr) SPPaintServer::build(document, repr); - for ( SPObject *ochild = this->firstChild() ; ochild ; ochild = ochild->getNext() ) { - if (SP_IS_STOP(ochild)) { + for (auto& ochild: children) { + if (SP_IS_STOP(&ochild)) { this->has_stops = TRUE; break; } @@ -325,6 +319,12 @@ void SPGradient::release() */ void SPGradient::set(unsigned key, gchar const *value) { +#ifdef OBJECT_TRACE + std::stringstream temp; + temp << "SPGradient::set: " << key << " " << (value?value:"null"); + objectTrace( temp.str() ); +#endif + switch (key) { case SP_ATTR_GRADIENTUNITS: if (value) { @@ -416,6 +416,10 @@ void SPGradient::set(unsigned key, gchar const *value) SPPaintServer::set(key, value); break; } + +#ifdef OBJECT_TRACE + objectTrace( "SPGradient::set", false ); +#endif } /** @@ -481,8 +485,8 @@ void SPGradient::remove_child(Inkscape::XML::Node *child) SPPaintServer::remove_child(child); this->has_stops = FALSE; - for ( SPObject *ochild = this->firstChild() ; ochild ; ochild = ochild->getNext() ) { - if (SP_IS_STOP(ochild)) { + for (auto& ochild: children) { + if (SP_IS_STOP(&ochild)) { this->has_stops = TRUE; break; } @@ -505,29 +509,24 @@ void SPGradient::remove_child(Inkscape::XML::Node *child) */ void SPGradient::modified(guint flags) { +#ifdef OBJECT_TRACE + objectTrace( "SPGradient::modified" ); +#endif + if (flags & SP_OBJECT_CHILD_MODIFIED_FLAG) { - // CPPIFY - // This comparison has never worked (i. e. always evaluated to false), - // the right value would have been SP_TYPE_MESH - //if( this->get_type() != SP_GRADIENT_TYPE_MESH ) { -// if (!SP_IS_MESH(this)) { -// this->invalidateVector(); -// } else { -// this->invalidateArray(); -// } - this->invalidateVector(); + if (SP_IS_MESHGRADIENT(this)) { + this->invalidateArray(); + } else { + this->invalidateVector(); + } } if (flags & SP_OBJECT_STYLE_MODIFIED_FLAG) { - // CPPIFY - // see above - //if( this->get_type() != SP_GRADIENT_TYPE_MESH ) { -// if (!SP_IS_MESH(this)) { -// this->ensureVector(); -// } else { -// this->ensureArray(); -// } - this->ensureVector(); + if (SP_IS_MESHGRADIENT(this)) { + this->ensureArray(); + } else { + this->ensureVector(); + } } if (flags & SP_OBJECT_MODIFIED_FLAG) flags |= SP_OBJECT_PARENT_MODIFIED_FLAG; @@ -536,9 +535,9 @@ void SPGradient::modified(guint flags) // FIXME: climb up the ladder of hrefs GSList *l = NULL; - for (SPObject *child = this->firstChild() ; child; child = child->getNext() ) { - sp_object_ref(child); - l = g_slist_prepend(l, child); + for (auto& child: children) { + sp_object_ref(&child); + l = g_slist_prepend(l, &child); } l = g_slist_reverse(l); @@ -553,14 +552,19 @@ void SPGradient::modified(guint flags) sp_object_unref(child); } + +#ifdef OBJECT_TRACE + objectTrace( "SPGradient::modified", false ); +#endif } SPStop* SPGradient::getFirstStop() { - SPStop* first = 0; - for (SPObject *ochild = firstChild(); ochild && !first; ochild = ochild->getNext()) { - if (SP_IS_STOP(ochild)) { - first = SP_STOP(ochild); + SPStop* first = nullptr; + for (auto& ochild: children) { + if (SP_IS_STOP(&ochild)) { + first = SP_STOP(&ochild); + break; } } return first; @@ -582,13 +586,17 @@ int SPGradient::getStopCount() const */ Inkscape::XML::Node *SPGradient::write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { +#ifdef OBJECT_TRACE + objectTrace( "SPGradient::write" ); +#endif + SPPaintServer::write(xml_doc, repr, flags); if (flags & SP_OBJECT_WRITE_BUILD) { GSList *l = NULL; - for (SPObject *child = this->firstChild(); child; child = child->getNext()) { - Inkscape::XML::Node *crepr = child->updateRepr(xml_doc, NULL, flags); + for (auto& child: children) { + Inkscape::XML::Node *crepr = child.updateRepr(xml_doc, NULL, flags); if (crepr) { l = g_slist_prepend(l, crepr); @@ -652,6 +660,9 @@ Inkscape::XML::Node *SPGradient::write(Inkscape::XML::Document *xml_doc, Inkscap repr->setAttribute( "osb:paint", 0 ); } +#ifdef OBJECT_TRACE + objectTrace( "SPGradient::write", false ); +#endif return repr; } @@ -904,7 +915,7 @@ bool SPGradient::invalidateArray() if (array.built) { array.built = false; - array.clear(); + // array.clear(); ret = true; } @@ -915,8 +926,8 @@ bool SPGradient::invalidateArray() void SPGradient::rebuildVector() { gint len = 0; - for ( SPObject *child = firstChild() ; child ; child = child->getNext() ) { - if (SP_IS_STOP(child)) { + for (auto& child: children) { + if (SP_IS_STOP(&child)) { len ++; } } @@ -937,9 +948,9 @@ void SPGradient::rebuildVector() } } - for ( SPObject *child = firstChild(); child; child = child->getNext() ) { - if (SP_IS_STOP(child)) { - SPStop *stop = SP_STOP(child); + for (auto& child: children) { + if (SP_IS_STOP(&child)) { + SPStop *stop = SP_STOP(&child); SPGradientStop gstop; if (!vector.stops.empty()) { @@ -1014,39 +1025,12 @@ void SPGradient::rebuildArray() { // std::cout << "SPGradient::rebuildArray()" << std::endl; - if( !SP_IS_MESH(this) ) { + if( !SP_IS_MESHGRADIENT(this) ) { g_warning( "SPGradient::rebuildArray() called for non-mesh gradient" ); return; } - array.read( SP_MESH( this ) ); - - has_patches = false; - for ( SPObject *ro = firstChild() ; ro ; ro = ro->getNext() ) { - if (SP_IS_MESHROW(ro)) { - has_patches = true; - // std::cout << " Has Patches" << std::endl; - break; - } - } - - // MESH_FIXME: TO PROPERLY COPY - SPGradient *reffed = ref->getObject(); - if ( !hasPatches() && reffed ) { - std::cout << "SPGradient::rebuildArray(): reffed array NOT IMPLEMENTED!!!" << std::endl; - /* Copy array from referenced gradient */ - array.built = true; // Prevent infinite recursion. - reffed->ensureArray(); - // if (!reffed->array.nodes.empty()) { - // array.built = reffed->array.built; - // for( uint i = 0; i < reffed->array.nodes.size(); ++i ) { - // array.nodes[i].assign(reffed->array.nodes[i].begin(), reffed->array.nodes[i].end()); - - // // FILL ME - // } - // return; - // } - } + array.read( SP_MESHGRADIENT( this ) ); } Geom::Affine @@ -1137,9 +1121,7 @@ sp_gradient_create_preview_pattern(SPGradient *gr, double width) { cairo_pattern_t *pat = NULL; - // CPPIFY - //if( gr->get_type() != SP_GRADIENT_TYPE_MESH ) { - if (!SP_IS_MESH(gr)) { + if (!SP_IS_MESHGRADIENT(gr)) { gr->ensureVector(); pat = cairo_pattern_create_linear(0, 0, width, 0); diff --git a/src/sp-gradient.h b/src/sp-gradient.h index ab45d6f08..7348bb5ca 100644 --- a/src/sp-gradient.h +++ b/src/sp-gradient.h @@ -210,8 +210,6 @@ sp_gradient_pattern_common_setup(cairo_pattern_t *cp, void sp_gradient_repr_write_vector(SPGradient *gr); void sp_gradient_repr_clear_vector(SPGradient *gr); -void sp_mesh_repr_write(SPMesh *mg); - cairo_pattern_t *sp_gradient_create_preview_pattern(SPGradient *gradient, double width); /** Transforms to/from gradient position space in given environment */ diff --git a/src/sp-guide.cpp b/src/sp-guide.cpp index 58a1a746e..ff0f6cadb 100644 --- a/src/sp-guide.cpp +++ b/src/sp-guide.cpp @@ -16,7 +16,7 @@ */ #ifdef HAVE_CONFIG_H -# include <config.h> +#include <config.h> #endif #include <algorithm> @@ -31,8 +31,6 @@ #include "attributes.h" #include "sp-guide.h" #include <sp-item-notify-moveto.h> -#include <sp-item.h> -#include <sp-guide-constraint.h> #include <glibmm/i18n.h> #include <xml/repr.h> #include <remove-last.h> @@ -40,8 +38,6 @@ #include "desktop.h" #include "sp-root.h" #include "sp-namedview.h" -#include <2geom/angle.h> -#include "document.h" #include "document-undo.h" #include "helper-fns.h" #include "verbs.h" diff --git a/src/sp-hatch-path.cpp b/src/sp-hatch-path.cpp index 32a514dcb..b40f66064 100644 --- a/src/sp-hatch-path.cpp +++ b/src/sp-hatch-path.cpp @@ -12,10 +12,8 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include <cstring> #include <string> #include <2geom/path.h> -#include <2geom/transforms.h> #include "svg/svg.h" #include "display/cairo-utils.h" @@ -27,11 +25,8 @@ #include "helper/geom.h" #include "attributes.h" #include "document-private.h" -#include "uri.h" -#include "style.h" #include "sp-hatch-path.h" #include "svg/css-ostringstream.h" -#include "xml/repr.h" SPHatchPath::SPHatchPath() : offset(), diff --git a/src/sp-hatch.cpp b/src/sp-hatch.cpp index 2d938618c..02d95c75c 100644 --- a/src/sp-hatch.cpp +++ b/src/sp-hatch.cpp @@ -25,11 +25,8 @@ #include "display/drawing-pattern.h" #include "attributes.h" #include "document-private.h" -#include "uri.h" -#include "style.h" #include "sp-hatch.h" #include "sp-hatch-path.h" -#include "xml/repr.h" SPHatch::SPHatch() : SPPaintServer(), @@ -233,14 +230,13 @@ void SPHatch::set(unsigned int key, const gchar* value) bool SPHatch::_hasHatchPatchChildren(SPHatch const *hatch) { - bool matched = false; - for (SPObject const *child = hatch->firstChild(); child && !matched; child = child->getNext() ) { - SPHatchPath const *hatchPath = dynamic_cast<SPHatchPath const *>(child); + for (auto& child: hatch->children) { + SPHatchPath const *hatchPath = dynamic_cast<SPHatchPath const *>(&child); if (hatchPath) { - matched = true; + return true; } } - return matched; + return false; } std::vector<SPHatchPath*> SPHatch::hatchPaths() @@ -249,8 +245,8 @@ std::vector<SPHatchPath*> SPHatch::hatchPaths() SPHatch *src = chase_hrefs<SPHatch>(this, sigc::ptr_fun(&_hasHatchPatchChildren)); if (src) { - for (SPObject *child = src->firstChild(); child; child = child->getNext()) { - SPHatchPath *hatchPath = dynamic_cast<SPHatchPath *>(child); + for (auto& child: src->children) { + SPHatchPath *hatchPath = dynamic_cast<SPHatchPath *>(&child); if (hatchPath) { list.push_back(hatchPath); } @@ -265,8 +261,8 @@ std::vector<SPHatchPath const*> SPHatch::hatchPaths() const SPHatch const *src = chase_hrefs<SPHatch const>(this, sigc::ptr_fun(&_hasHatchPatchChildren)); if (src) { - for (SPObject const *child = src->firstChild(); child; child = child->getNext()) { - SPHatchPath const *hatchPath = dynamic_cast<SPHatchPath const*>(child); + for (auto& child: src->children) { + SPHatchPath const *hatchPath = dynamic_cast<SPHatchPath const*>(&child); if (hatchPath) { list.push_back(hatchPath); } diff --git a/src/sp-image.cpp b/src/sp-image.cpp index bf5b9ebcd..aa1dbfe20 100644 --- a/src/sp-image.cpp +++ b/src/sp-image.cpp @@ -30,7 +30,6 @@ #include "display/cairo-utils.h" #include "display/curve.h" //Added for preserveAspectRatio support -- EAF -#include "enums.h" #include "attributes.h" #include "print.h" #include "brokenimage.xpm" @@ -38,8 +37,6 @@ #include "sp-image.h" #include "sp-clippath.h" #include "xml/quote.h" -#include "xml/repr.h" -#include "snap-candidate.h" #include "preferences.h" #include "io/sys.h" diff --git a/src/sp-item-group.cpp b/src/sp-item-group.cpp index 70d2bc732..96dcdbe30 100644 --- a/src/sp-item-group.cpp +++ b/src/sp-item-group.cpp @@ -15,7 +15,7 @@ */ #ifdef HAVE_CONFIG_H -# include "config.h" +#include <config.h> #endif #include <glibmm/i18n.h> @@ -32,16 +32,13 @@ #include "attributes.h" #include "sp-item-transform.h" #include "sp-root.h" -#include "sp-use.h" #include "sp-offset.h" #include "sp-clippath.h" #include "sp-mask.h" #include "sp-path.h" #include "box3d.h" #include "persp3d.h" -#include "inkscape.h" -#include "selection.h" #include "live_effects/effect.h" #include "live_effects/lpeobject.h" #include "live_effects/lpeobject-reference.h" @@ -50,10 +47,8 @@ #include "sp-switch.h" #include "sp-defs.h" #include "verbs.h" -#include "layer-model.h" #include "sp-textpath.h" #include "sp-flowtext.h" -#include "sp-tspan.h" #include "selection-chemistry.h" #include "xml/sp-css-attr.h" #include "svg/css-ostringstream.h" @@ -137,7 +132,7 @@ void SPGroup::remove_child(Inkscape::XML::Node *child) { void SPGroup::order_changed (Inkscape::XML::Node *child, Inkscape::XML::Node *old_ref, Inkscape::XML::Node *new_ref) { - SPLPEItem::order_changed(child, old_ref, new_ref); + SPLPEItem::order_changed(child, old_ref, new_ref); SPItem *item = dynamic_cast<SPItem *>(get_child_by_repr(child)); if ( item ) { @@ -204,11 +199,18 @@ void SPGroup::modified(guint flags) { // std::cout << "SPGroup::modified(): " << (getId()?getId():"null") << std::endl; SPLPEItem::modified(flags); if (flags & SP_OBJECT_MODIFIED_FLAG) { - flags |= SP_OBJECT_PARENT_MODIFIED_FLAG; + flags |= SP_OBJECT_PARENT_MODIFIED_FLAG; } flags &= SP_OBJECT_MODIFIED_CASCADE; + if (flags & SP_OBJECT_STYLE_MODIFIED_FLAG) { + for (SPItemView *v = this->display; v != NULL; v = v->next) { + Inkscape::DrawingGroup *group = dynamic_cast<Inkscape::DrawingGroup *>(v->arenaitem); + group->setStyle(this->style); + } + } + std::vector<SPObject*> l=this->childList(true); for(std::vector<SPObject*>::const_iterator i=l.begin();i!=l.end();++i){ SPObject *child = *i; @@ -235,9 +237,9 @@ Inkscape::XML::Node* SPGroup::write(Inkscape::XML::Document *xml_doc, Inkscape:: l = NULL; - for (SPObject *child = firstChild(); child; child = child->getNext() ) { - if ( !dynamic_cast<SPTitle *>(child) && !dynamic_cast<SPDesc *>(child) ) { - Inkscape::XML::Node *crepr = child->updateRepr(xml_doc, NULL, flags); + for (auto& child: children) { + if ( !dynamic_cast<SPTitle *>(&child) && !dynamic_cast<SPDesc *>(&child) ) { + Inkscape::XML::Node *crepr = child.updateRepr(xml_doc, NULL, flags); if (crepr) { l = g_slist_prepend (l, crepr); @@ -251,9 +253,9 @@ Inkscape::XML::Node* SPGroup::write(Inkscape::XML::Document *xml_doc, Inkscape:: l = g_slist_remove (l, l->data); } } else { - for (SPObject *child = firstChild() ; child ; child = child->getNext() ) { - if ( !dynamic_cast<SPTitle *>(child) && !dynamic_cast<SPDesc *>(child) ) { - child->updateRepr(flags); + for (auto& child: children) { + if ( !dynamic_cast<SPTitle *>(&child) && !dynamic_cast<SPDesc *>(&child) ) { + child.updateRepr(flags); } } } @@ -297,9 +299,8 @@ Geom::OptRect SPGroup::bbox(Geom::Affine const &transform, SPItem::BBoxType bbox } void SPGroup::print(SPPrintContext *ctx) { - std::vector<SPObject*> l=this->childList(false); - for(std::vector<SPObject*>::const_iterator i=l.begin();i!=l.end();++i){ - SPObject *o = *i; + for(auto& child: children){ + SPObject *o = &child; SPItem *item = dynamic_cast<SPItem *>(o); if (item) { item->invoke_print(ctx); @@ -351,7 +352,7 @@ Inkscape::DrawingItem *SPGroup::show (Inkscape::Drawing &drawing, unsigned int k } void SPGroup::hide (unsigned int key) { - std::vector<SPObject*> l=this->childList(false, SPObject::ActionShow); + std::vector<SPObject*> l=this->childList(false, SPObject::ActionShow); for(std::vector<SPObject*>::const_iterator i=l.begin();i!=l.end();++i){ SPObject *o = *i; @@ -366,9 +367,9 @@ void SPGroup::hide (unsigned int key) { void SPGroup::snappoints(std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs) const { - for ( SPObject const *o = this->firstChild(); o; o = o->getNext() ) + for (auto& o: children) { - SPItem const *item = dynamic_cast<SPItem const *>(o); + SPItem const *item = dynamic_cast<SPItem const *>(&o); if (item) { item->getSnappoints(p, snapprefs); } @@ -401,7 +402,7 @@ sp_recursive_scale_text_size(Inkscape::XML::Node *repr, double scale){ } SPCSSAttr * css = sp_repr_css_attr(repr,"style"); Glib::ustring element = g_quark_to_string(repr->code()); - if (css && element == "svg:text" || element == "svg:tspan") { + if ((css && element == "svg:text") || element == "svg:tspan") { gchar const *w = sp_repr_css_property(css, "font-size", NULL); if (w) { gchar *units = NULL; @@ -512,20 +513,21 @@ sp_item_group_ungroup (SPGroup *group, std::vector<SPItem*> &children, bool do_d GSList *objects = NULL; Geom::Affine const g(group->transform); - for (SPObject *child = group->firstChild() ; child; child = child->getNext() ) - if (SPItem *citem = dynamic_cast<SPItem *>(child)) - sp_item_group_ungroup_handle_clones(citem,g); - + for (auto& child: group->children) { + if (SPItem *citem = dynamic_cast<SPItem *>(&child)) { + sp_item_group_ungroup_handle_clones(citem, g); + } + } - for (SPObject *child = group->firstChild() ; child; child = child->getNext() ) { - SPItem *citem = dynamic_cast<SPItem *>(child); + for (auto& child: group->children) { + SPItem *citem = dynamic_cast<SPItem *>(&child); if (citem) { /* Merging of style */ // this converts the gradient/pattern fill/stroke, if any, to userSpaceOnUse; we need to do // it here _before_ the new transform is set, so as to use the pre-transform bbox citem->adjust_paint_recursive (Geom::identity(), Geom::identity(), false); - child->style->merge( group->style ); + child.style->merge( group->style ); /* * fixme: We currently make no allowance for the case where child is cloned * and the group has any style settings. @@ -547,9 +549,9 @@ sp_item_group_ungroup (SPGroup *group, std::vector<SPItem*> &children, bool do_d * extra complication & maintenance burden and this case is rare. */ - child->updateRepr(); + child.updateRepr(); - Inkscape::XML::Node *nrepr = child->getRepr()->duplicate(prepr->document()); + Inkscape::XML::Node *nrepr = child.getRepr()->duplicate(prepr->document()); // Merging transform Geom::Affine ctrans = citem->transform * g; @@ -583,7 +585,7 @@ sp_item_group_ungroup (SPGroup *group, std::vector<SPItem*> &children, bool do_d if (text) { //this causes a change in text-on-path appearance when there is a non-conformal transform, see bug #1594565 double scale = (ctrans.expansionX() + ctrans.expansionY()) / 2.0; - SPTextPath * text_path = dynamic_cast<SPTextPath *>(text->children); + SPTextPath * text_path = dynamic_cast<SPTextPath *>(text->firstChild()); if (!text_path) { nrepr->setAttribute("transform", affinestr); } else { @@ -600,7 +602,7 @@ sp_item_group_ungroup (SPGroup *group, std::vector<SPItem*> &children, bool do_d items = g_slist_prepend (items, nrepr); } else { - Inkscape::XML::Node *nrepr = child->getRepr()->duplicate(prepr->document()); + Inkscape::XML::Node *nrepr = child.getRepr()->duplicate(prepr->document()); objects = g_slist_prepend (objects, nrepr); } } @@ -662,9 +664,9 @@ std::vector<SPItem*> sp_item_group_item_list(SPGroup * group) std::vector<SPItem*> s; g_return_val_if_fail(group != NULL, s); - for (SPObject *o = group->firstChild() ; o ; o = o->getNext() ) { - if ( dynamic_cast<SPItem *>(o) ) { - s.push_back((SPItem*)o); + for (auto& o: group->children) { + if ( dynamic_cast<SPItem *>(&o) ) { + s.push_back((SPItem*)&o); } } return s; @@ -735,8 +737,8 @@ void SPGroup::_updateLayerMode(unsigned int display_key) { void SPGroup::translateChildItems(Geom::Translate const &tr) { if ( hasChildren() ) { - for (SPObject *o = firstChild() ; o ; o = o->getNext() ) { - SPItem *item = dynamic_cast<SPItem *>(o); + for (auto& o: children) { + SPItem *item = dynamic_cast<SPItem *>(&o); if ( item ) { sp_item_move_rel(item, tr); } @@ -748,14 +750,14 @@ void SPGroup::translateChildItems(Geom::Translate const &tr) void SPGroup::scaleChildItemsRec(Geom::Scale const &sc, Geom::Point const &p, bool noRecurse) { if ( hasChildren() ) { - for (SPObject *o = firstChild() ; o ; o = o->getNext() ) { - if ( SPDefs *defs = dynamic_cast<SPDefs *>(o) ) { // select symbols from defs, ignore clips, masks, patterns - for (SPObject *defschild = defs->firstChild() ; defschild ; defschild = defschild->getNext() ) { - SPGroup *defsgroup = dynamic_cast<SPGroup *>(defschild); + for (auto& o: children) { + if ( SPDefs *defs = dynamic_cast<SPDefs *>(&o) ) { // select symbols from defs, ignore clips, masks, patterns + for (auto& defschild: defs->children) { + SPGroup *defsgroup = dynamic_cast<SPGroup *>(&defschild); if (defsgroup) defsgroup->scaleChildItemsRec(sc, p, false); } - } else if ( SPItem *item = dynamic_cast<SPItem *>(o) ) { + } else if ( SPItem *item = dynamic_cast<SPItem *>(&o) ) { SPGroup *group = dynamic_cast<SPGroup *>(item); if (group && !dynamic_cast<SPBox3D *>(item)) { /* Using recursion breaks clipping because transforms are applied @@ -871,8 +873,8 @@ void SPGroup::scaleChildItemsRec(Geom::Scale const &sc, Geom::Point const &p, bo gint SPGroup::getItemCount() const { gint len = 0; - for (SPObject const *o = this->firstChild() ; o ; o = o->getNext() ) { - if (dynamic_cast<SPItem const *>(o)) { + for (auto& child: children) { + if (dynamic_cast<SPItem const *>(&child)) { len++; } } diff --git a/src/sp-item-rm-unsatisfied-cns.cpp b/src/sp-item-rm-unsatisfied-cns.cpp index 7a712b083..516c88672 100644 --- a/src/sp-item-rm-unsatisfied-cns.cpp +++ b/src/sp-item-rm-unsatisfied-cns.cpp @@ -4,8 +4,6 @@ #include "remove-last.h" #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-update-cns.cpp b/src/sp-item-update-cns.cpp index 750f0d94f..9aef336c5 100644 --- a/src/sp-item-update-cns.cpp +++ b/src/sp-item-update-cns.cpp @@ -1,10 +1,8 @@ #include "satisfied-guide-cns.h" -#include "sp-guide-constraint.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 9fd6e8ecc..d161562fd 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -13,7 +13,7 @@ */ #ifdef HAVE_CONFIG_H -# include "config.h" +#include <config.h> #endif #include "sp-item.h" @@ -33,19 +33,14 @@ #include "sp-clippath.h" #include "sp-mask.h" #include "sp-rect.h" -#include "sp-use.h" #include "sp-text.h" #include "sp-textpath.h" #include "sp-item-rm-unsatisfied-cns.h" #include "sp-pattern.h" -#include "sp-paint-server.h" #include "sp-switch.h" -#include "sp-guide-constraint.h" #include "gradient-chemistry.h" -#include "preferences.h" #include "conn-avoid-ref.h" #include "conditions.h" -#include "sp-filter-reference.h" #include "filter-chemistry.h" #include "sp-guide.h" #include "sp-title.h" @@ -53,13 +48,8 @@ #include "util/find-last-if.h" #include "util/reverse-list.h" -#include <2geom/rect.h> -#include <2geom/affine.h> -#include <2geom/transforms.h> -#include "xml/repr.h" #include "extract-uri.h" -#include "helper/geom.h" #include "live_effects/lpeobject.h" #include "live_effects/effect.h" @@ -69,6 +59,7 @@ #define noSP_ITEM_DEBUG_IDLE +//#define OBJECT_TRACE static SPItemView* sp_item_view_list_remove(SPItemView *list, SPItemView *view); @@ -308,51 +299,42 @@ bool is_item(SPObject const &object) { void SPItem::raiseToTop() { using Inkscape::Algorithms::find_last_if; - SPObject *topmost=find_last_if<SPObject::SiblingIterator>( - next, NULL, &is_item - ); - if (topmost) { + auto topmost = find_last_if(++parent->children.iterator_to(*this), parent->children.end(), &is_item); + if (topmost != parent->children.end()) { getRepr()->parent()->changeOrder( getRepr(), topmost->getRepr() ); } } void SPItem::raiseOne() { - SPObject *next_higher=std::find_if<SPObject::SiblingIterator>( - next, NULL, &is_item - ); - if (next_higher) { + auto next_higher = std::find_if(++parent->children.iterator_to(*this), parent->children.end(), &is_item); + if (next_higher != parent->children.end()) { Inkscape::XML::Node *ref = next_higher->getRepr(); getRepr()->parent()->changeOrder(getRepr(), ref); } } void SPItem::lowerOne() { - using Inkscape::Util::MutableList; - using Inkscape::Util::reverse_list; - - MutableList<SPObject &> next_lower=std::find_if( - reverse_list<SPObject::SiblingIterator>( - parent->firstChild(), this - ), - MutableList<SPObject &>(), - &is_item - ); - if (next_lower) { - ++next_lower; - Inkscape::XML::Node *ref = ( next_lower ? next_lower->getRepr() : NULL ); + using Inkscape::Algorithms::find_last_if; + + auto next_lower = find_last_if(parent->children.begin(), parent->children.iterator_to(*this), &is_item); + if (next_lower != parent->children.iterator_to(*this)) { + Inkscape::XML::Node *ref = nullptr; + if (next_lower != parent->children.begin()) { + next_lower--; + ref = next_lower->getRepr(); + } getRepr()->parent()->changeOrder(getRepr(), ref); } } void SPItem::lowerToBottom() { - using Inkscape::Algorithms::find_last_if; - using Inkscape::Util::MutableList; - using Inkscape::Util::reverse_list; - - SPObject * bottom=parent->firstChild(); - while(dynamic_cast<SPObject*>(bottom) && dynamic_cast<SPObject*>(bottom->next) && bottom!=this && !is_item(*(bottom->next))) bottom=bottom->next; - if (bottom && bottom != this) { - Inkscape::XML::Node *ref = bottom->getRepr() ; + auto bottom = std::find_if(parent->children.begin(), parent->children.iterator_to(*this), &is_item); + if (bottom != parent->children.iterator_to(*this)) { + Inkscape::XML::Node *ref = nullptr; + if (bottom != parent->children.begin()) { + bottom--; + ref = bottom->getRepr(); + } parent->getRepr()->changeOrder(getRepr(), ref); } } @@ -366,8 +348,8 @@ void SPItem::moveTo(SPItem *target, bool intoafter) { // Assume move to the "first" in the top node, find the top node intoafter = false; SPObject* bottom = this->document->getObjectByRepr(our_ref->root())->firstChild(); - while(!dynamic_cast<SPItem*>(bottom->next)){ - bottom=bottom->next; + while(!dynamic_cast<SPItem*>(bottom->getNext())){ + bottom = bottom->getNext(); } target_ref = bottom->getRepr(); } @@ -710,6 +692,10 @@ void SPItem::update(SPCtx* ctx, guint flags) { void SPItem::modified(unsigned int /*flags*/) { +#ifdef OBJECT_TRACE + objectTrace( "SPItem::modified" ); + objectTrace( "SPItem::modified", false ); +#endif } Inkscape::XML::Node* SPItem::write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { @@ -720,9 +706,9 @@ Inkscape::XML::Node* SPItem::write(Inkscape::XML::Document *xml_doc, Inkscape::X // so we need to add any children from the underlying object to the new repr if (flags & SP_OBJECT_WRITE_BUILD) { GSList *l = NULL; - for (SPObject *child = object->firstChild(); child != NULL; child = child->next ) { - if (dynamic_cast<SPTitle *>(child) || dynamic_cast<SPDesc *>(child)) { - Inkscape::XML::Node *crepr = child->updateRepr(xml_doc, NULL, flags); + for (auto& child: object->children) { + if (dynamic_cast<SPTitle *>(&child) || dynamic_cast<SPDesc *>(&child)) { + Inkscape::XML::Node *crepr = child.updateRepr(xml_doc, NULL, flags); if (crepr) { l = g_slist_prepend (l, crepr); } @@ -734,9 +720,9 @@ Inkscape::XML::Node* SPItem::write(Inkscape::XML::Document *xml_doc, Inkscape::X l = g_slist_remove (l, l->data); } } else { - for (SPObject *child = object->firstChild() ; child != NULL; child = child->next ) { - if (dynamic_cast<SPTitle *>(child) || dynamic_cast<SPDesc *>(child)) { - child->updateRepr(flags); + for (auto& child: object->children) { + if (dynamic_cast<SPTitle *>(&child) || dynamic_cast<SPDesc *>(&child)) { + child.updateRepr(flags); } } } @@ -943,12 +929,12 @@ unsigned int SPItem::pos_in_parent() const { unsigned int pos = 0; - for ( SPObject *iter = parent->firstChild() ; iter ; iter = iter->next) { - if (iter == this) { + for (auto& iter: parent->children) { + if (&iter == this) { return pos; } - if (dynamic_cast<SPItem *>(iter)) { + if (dynamic_cast<SPItem *>(&iter)) { pos++; } } @@ -989,8 +975,8 @@ void SPItem::getSnappoints(std::vector<Inkscape::SnapCandidatePoint> &p, Inkscap for (std::list<SPObject const *>::const_iterator o = clips_and_masks.begin(); o != clips_and_masks.end(); ++o) { if (*o) { // obj is a group object, the children are the actual clippers - for (SPObject *child = (*o)->children ; child ; child = child->next) { - SPItem *item = dynamic_cast<SPItem *>(child); + for(auto& child: (*o)->children) { + SPItem *item = dynamic_cast<SPItem *>(const_cast<SPObject*>(&child)); if (item) { std::vector<Inkscape::SnapCandidatePoint> p_clip_or_mask; // Please note the recursive call here! @@ -1317,8 +1303,8 @@ void SPItem::adjust_stroke_width_recursive(double expansion) // A clone's child is the ghost of its original - we must not touch it, skip recursion if ( !dynamic_cast<SPUse *>(this) ) { - for ( SPObject *o = children; o; o = o->getNext() ) { - SPItem *item = dynamic_cast<SPItem *>(o); + for (auto& o: children) { + SPItem *item = dynamic_cast<SPItem *>(&o); if (item) { item->adjust_stroke_width_recursive(expansion); } @@ -1332,8 +1318,8 @@ void SPItem::freeze_stroke_width_recursive(bool freeze) // A clone's child is the ghost of its original - we must not touch it, skip recursion if ( !dynamic_cast<SPUse *>(this) ) { - for ( SPObject *o = children; o; o = o->getNext() ) { - SPItem *item = dynamic_cast<SPItem *>(o); + for (auto& o: children) { + SPItem *item = dynamic_cast<SPItem *>(&o); if (item) { item->freeze_stroke_width_recursive(freeze); } @@ -1352,10 +1338,10 @@ sp_item_adjust_rects_recursive(SPItem *item, Geom::Affine advertized_transform) rect->compensateRxRy(advertized_transform); } - for (SPObject *o = item->children; o != NULL; o = o->next) { - SPItem *item = dynamic_cast<SPItem *>(o); - if (item) { - sp_item_adjust_rects_recursive(item, advertized_transform); + for(auto& o: item->children) { + SPItem *itm = dynamic_cast<SPItem *>(&o); + if (itm) { + sp_item_adjust_rects_recursive(itm, advertized_transform); } } } @@ -1372,8 +1358,8 @@ void SPItem::adjust_paint_recursive (Geom::Affine advertized_transform, Geom::Af // also we do not recurse into clones, because a clone's child is the ghost of its original - // we must not touch it if (!(this && (dynamic_cast<SPText *>(this) || dynamic_cast<SPUse *>(this)))) { - for (SPObject *o = children; o != NULL; o = o->next) { - SPItem *item = dynamic_cast<SPItem *>(o); + for (auto& o: children) { + SPItem *item = dynamic_cast<SPItem *>(&o); if (item) { // At the level of the transformed item, t_ancestors is identity; // below it, it is the accmmulated chain of transforms from this level to the top level @@ -1681,8 +1667,8 @@ SPItem const *sp_item_first_item_child(SPObject const *obj) SPItem *sp_item_first_item_child(SPObject *obj) { SPItem *child = 0; - for ( SPObject *iter = obj->firstChild() ; iter ; iter = iter->next ) { - SPItem *tmp = dynamic_cast<SPItem *>(iter); + for (auto& iter: obj->children) { + SPItem *tmp = dynamic_cast<SPItem *>(&iter); if ( tmp ) { child = tmp; break; diff --git a/src/sp-line.cpp b/src/sp-line.cpp index cf21be912..09ffd1f17 100644 --- a/src/sp-line.cpp +++ b/src/sp-line.cpp @@ -17,7 +17,6 @@ #include "sp-guide.h" #include "display/curve.h" #include <glibmm/i18n.h> -#include "xml/repr.h" #include "document.h" #include "inkscape.h" diff --git a/src/sp-line.h b/src/sp-line.h index d6a075659..6c720d403 100644 --- a/src/sp-line.h +++ b/src/sp-line.h @@ -1,4 +1,4 @@ -#ifndef SEEN_SP_LINE_H +#ifndef SEEN_SP_LINE_H #define SEEN_SP_LINE_H /* diff --git a/src/sp-lpe-item.cpp b/src/sp-lpe-item.cpp index fdc2949d5..d83593b31 100644 --- a/src/sp-lpe-item.cpp +++ b/src/sp-lpe-item.cpp @@ -13,7 +13,6 @@ */ #ifdef HAVE_CONFIG_H -# include "config.h" #endif #include "ui/tool/multi-path-manipulator.h" @@ -27,11 +26,7 @@ #include "sp-path.h" #include "sp-item-group.h" -#include "streq.h" -#include "macros.h" #include "attributes.h" -#include "sp-lpe-item.h" -#include "xml/repr.h" #include "uri.h" #include "message-stack.h" #include "inkscape.h" @@ -40,14 +35,10 @@ #include "sp-ellipse.h" #include "display/curve.h" #include "svg/svg.h" -#include <2geom/pathvector.h> #include "sp-clippath.h" #include "sp-mask.h" #include "ui/tools-switch.h" #include "ui/tools/node-tool.h" -#include "ui/tools/tool-base.h" - -#include <algorithm> /* LPEItem base class */ static void sp_lpe_item_enable_path_effects(SPLPEItem *lpeitem, bool enable); @@ -210,9 +201,6 @@ Inkscape::XML::Node* SPLPEItem::write(Inkscape::XML::Document *xml_doc, Inkscape * returns true when LPE was successful. */ bool SPLPEItem::performPathEffect(SPCurve *curve, bool is_clip_or_mask) { - if (!this) { - return false; - } if (!curve) { return false; @@ -349,10 +337,10 @@ sp_lpe_item_create_original_path_recursive(SPLPEItem *lpeitem) { sp_lpe_item_create_original_path_recursive(SP_LPE_ITEM(mask->firstChild())); } - SPClipPath * clipPath = lpeitem->clip_ref->getObject(); - if(clipPath) + SPClipPath * clip_path = lpeitem->clip_ref->getObject(); + if(clip_path) { - sp_lpe_item_create_original_path_recursive(SP_LPE_ITEM(clipPath->firstChild())); + sp_lpe_item_create_original_path_recursive(SP_LPE_ITEM(clip_path->firstChild())); } if (SP_IS_GROUP(lpeitem)) { std::vector<SPItem*> item_list = sp_item_group_item_list(SP_GROUP(lpeitem)); @@ -383,10 +371,10 @@ sp_lpe_item_cleanup_original_path_recursive(SPLPEItem *lpeitem) { sp_lpe_item_cleanup_original_path_recursive(SP_LPE_ITEM(mask->firstChild())); } - SPClipPath * clipPath = lpeitem->clip_ref->getObject(); - if(clipPath) + SPClipPath * clip_path = lpeitem->clip_ref->getObject(); + if(clip_path) { - sp_lpe_item_cleanup_original_path_recursive(SP_LPE_ITEM(clipPath->firstChild())); + sp_lpe_item_cleanup_original_path_recursive(SP_LPE_ITEM(clip_path->firstChild())); } } std::vector<SPItem*> item_list = sp_item_group_item_list(SP_GROUP(lpeitem)); @@ -405,10 +393,10 @@ sp_lpe_item_cleanup_original_path_recursive(SPLPEItem *lpeitem) { sp_lpe_item_cleanup_original_path_recursive(SP_LPE_ITEM(mask->firstChild())); } - SPClipPath * clipPath = lpeitem->clip_ref->getObject(); - if(clipPath) + SPClipPath * clip_path = lpeitem->clip_ref->getObject(); + if(clip_path) { - sp_lpe_item_cleanup_original_path_recursive(SP_LPE_ITEM(clipPath->firstChild())); + sp_lpe_item_cleanup_original_path_recursive(SP_LPE_ITEM(clip_path->firstChild())); } repr->setAttribute("d", repr->attribute("inkscape:original-d")); repr->setAttribute("inkscape:original-d", NULL); @@ -472,7 +460,7 @@ void SPLPEItem::addPathEffect(std::string value, bool reset) if (SP_ACTIVE_DESKTOP ) { Inkscape::UI::Tools::ToolBase *ec = SP_ACTIVE_DESKTOP->event_context; if (INK_IS_NODE_TOOL(ec)) { - tools_switch(SP_ACTIVE_DESKTOP, TOOLS_LPETOOL); //mhh + tools_switch(SP_ACTIVE_DESKTOP, TOOLS_SELECT); //mhh tools_switch(SP_ACTIVE_DESKTOP, TOOLS_NODES); } } @@ -640,10 +628,13 @@ bool SPLPEItem::hasPathEffectRecursive() const void SPLPEItem::apply_to_clippath(SPItem *item) { - SPClipPath *clipPath = item->clip_ref->getObject(); - if(clipPath) { - SPObject * clip_data = clipPath->firstChild(); - apply_to_clip_or_mask(SP_ITEM(clip_data), item); + SPClipPath *clip_path = item->clip_ref->getObject(); + if(clip_path) { + std::vector<SPObject*> clip_path_list = clip_path->childList(true); + for ( std::vector<SPObject*>::const_iterator iter=clip_path_list.begin();iter!=clip_path_list.end();++iter) { + SPObject * clip_data = *iter; + apply_to_clip_or_mask(SP_ITEM(clip_data), item); + } } if(SP_IS_GROUP(item)){ std::vector<SPItem*> item_list = sp_item_group_item_list(SP_GROUP(item)); @@ -659,8 +650,11 @@ SPLPEItem::apply_to_mask(SPItem *item) { SPMask *mask = item->mask_ref->getObject(); if(mask) { - SPObject *mask_data = mask->firstChild(); - apply_to_clip_or_mask(SP_ITEM(mask_data), item); + std::vector<SPObject*> mask_list = mask->childList(true); + for ( std::vector<SPObject*>::const_iterator iter=mask_list.begin();iter!=mask_list.end();++iter) { + SPObject * mask_data = *iter; + apply_to_clip_or_mask(SP_ITEM(mask_data), item); + } } if(SP_IS_GROUP(item)){ std::vector<SPItem*> item_list = sp_item_group_item_list(SP_GROUP(item)); @@ -715,7 +709,7 @@ SPLPEItem::apply_to_clip_or_mask(SPItem *clip_mask, SPItem *item) // LPE was unsuccesfull. Read the old 'd'-attribute. if (gchar const * value = repr->attribute("d")) { Geom::PathVector pv = sp_svg_read_pathv(value); - SPCurve *oldcurve = new SPCurve(pv); + SPCurve *oldcurve = new (std::nothrow) SPCurve(pv); if (oldcurve) { SP_SHAPE(clip_mask)->setCurve(oldcurve, TRUE); oldcurve->unref(); diff --git a/src/sp-marker.cpp b/src/sp-marker.cpp index 3505e2fe8..43df8525d 100644 --- a/src/sp-marker.cpp +++ b/src/sp-marker.cpp @@ -16,7 +16,6 @@ #include <cstring> #include <string> -#include "config.h" #include <2geom/affine.h> #include <2geom/transforms.h> diff --git a/src/sp-mask.cpp b/src/sp-mask.cpp index 3537c7bac..4690ffda2 100644 --- a/src/sp-mask.cpp +++ b/src/sp-mask.cpp @@ -23,7 +23,6 @@ #include "attributes.h" #include "document.h" #include "document-private.h" -#include "sp-item.h" #include "sp-mask.h" @@ -138,12 +137,8 @@ void SPMask::update(SPCtx* ctx, unsigned int flags) { flags &= SP_OBJECT_MODIFIED_CASCADE; - std::vector<SPObject *> children = this->childList(false); - for (std::vector<SPObject *>::const_iterator child = children.begin();child != children.end();++child) { - sp_object_ref(*child); - } - - + std::vector<SPObject *> children = this->childList(true); + for (std::vector<SPObject *>::const_iterator child = children.begin();child != children.end();++child) { if (flags || ((*child)->uflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) { (*child)->updateDisplay(ctx, flags); @@ -172,11 +167,8 @@ void SPMask::modified(unsigned int flags) { flags &= SP_OBJECT_MODIFIED_CASCADE; - std::vector<SPObject *> children = this->childList(false); - for (std::vector<SPObject *>::const_iterator child = children.begin();child != children.end();++child) { - sp_object_ref(*child); - } - + std::vector<SPObject *> children = this->childList(true); + for (std::vector<SPObject *>::const_iterator child = children.begin();child != children.end();++child) { if (flags || ((*child)->mflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) { (*child)->emitModified(flags); @@ -234,9 +226,9 @@ Inkscape::DrawingItem *SPMask::sp_mask_show(Inkscape::Drawing &drawing, unsigned Inkscape::DrawingGroup *ai = new Inkscape::DrawingGroup(drawing); this->display = sp_mask_view_new_prepend (this->display, key, ai); - for ( SPObject *child = this->firstChild() ; child; child = child->getNext() ) { - if (SP_IS_ITEM (child)) { - Inkscape::DrawingItem *ac = SP_ITEM (child)->invoke_show (drawing, key, SP_ITEM_REFERENCE_FLAGS); + for (auto& child: children) { + if (SP_IS_ITEM (&child)) { + Inkscape::DrawingItem *ac = SP_ITEM (&child)->invoke_show (drawing, key, SP_ITEM_REFERENCE_FLAGS); if (ac) { ai->prependChild(ac); @@ -257,9 +249,9 @@ void SPMask::sp_mask_hide(unsigned int key) { g_return_if_fail (this != NULL); g_return_if_fail (SP_IS_MASK (this)); - for ( SPObject *child = this->firstChild(); child; child = child->getNext()) { - if (SP_IS_ITEM (child)) { - SP_ITEM(child)->invoke_hide (key); + for (auto& child: children) { + if (SP_IS_ITEM (&child)) { + SP_ITEM(&child)->invoke_hide (key); } } diff --git a/src/sp-mesh-array.cpp b/src/sp-mesh-array.cpp index 355150893..c47c338de 100644 --- a/src/sp-mesh-array.cpp +++ b/src/sp-mesh-array.cpp @@ -46,7 +46,7 @@ #include "document.h" #include "sp-root.h" -#include "sp-mesh.h" +#include "sp-mesh-gradient.h" #include "sp-mesh-array.h" #include "sp-mesh-row.h" #include "sp-mesh-patch.h" @@ -574,7 +574,60 @@ void SPMeshPatchI::setOpacity( guint i, gdouble opacity ) { }; -SPMeshNodeArray::SPMeshNodeArray( SPMesh *mg ) { +/** + Return stop pointer for corner of patch. +*/ +SPStop* SPMeshPatchI::getStopPtr( guint i ) { + + assert( i < 4 ); + + SPStop* stop = nullptr; + switch ( i ) { + case 0: + stop = (*nodes)[ row ][ col ]->stop; + break; + case 1: + stop = (*nodes)[ row ][ col+3 ]->stop; + break; + case 2: + stop = (*nodes)[ row+3 ][ col+3 ]->stop; + break; + case 3: + stop = (*nodes)[ row+3 ][ col ]->stop; + break; + } + + return stop; +}; + + +/** + Set stop pointer for corner of patch. +*/ +void SPMeshPatchI::setStopPtr( guint i, SPStop* stop ) { + + assert( i < 4 ); + + switch ( i ) { + case 0: + (*nodes)[ row ][ col ]->stop = stop; + break; + case 1: + (*nodes)[ row ][ col+3 ]->stop = stop; + break; + case 2: + (*nodes)[ row+3 ][ col+3 ]->stop = stop; + break; + case 3: + (*nodes)[ row+3 ][ col ]->stop = stop; + break; + + } + +}; + + +SPMeshNodeArray::SPMeshNodeArray( SPMeshGradient *mg ) { read( mg ); @@ -586,7 +639,7 @@ SPMeshNodeArray::SPMeshNodeArray( const SPMeshNodeArray& rhs ) { built = false; mg = NULL; - drag_valid = false; + draggers_valid = false; nodes = rhs.nodes; // This only copies the pointers but it does size the vector of vectors. @@ -607,7 +660,7 @@ SPMeshNodeArray& SPMeshNodeArray::operator=( const SPMeshNodeArray& rhs ) { built = false; mg = NULL; - drag_valid = false; + draggers_valid = false; nodes = rhs.nodes; // This only copies the pointers but it does size the vector of vectors. @@ -620,28 +673,50 @@ SPMeshNodeArray& SPMeshNodeArray::operator=( const SPMeshNodeArray& rhs ) { return *this; }; - -void SPMeshNodeArray::read( SPMesh *mg_in ) { +// Fill array with data from mesh objects. +// Returns true of array's dimensions unchanged. +bool SPMeshNodeArray::read( SPMeshGradient *mg_in ) { mg = mg_in; - clear(); + // Count rows and columns, if unchanged reuse array to keep draggers valid. + unsigned cols = 0; + unsigned rows = 0; + for (auto& ro: mg->children) { + if (SP_IS_MESHROW(&ro)) { + ++rows; + if (rows == 1 ) { + for (auto& po: ro.children) { + if (SP_IS_MESHPATCH(&po)) { + ++cols; + } + } + } + } + } + bool same_size = true; + if (cols != patch_columns() || rows != patch_rows() ) { + // Draggers will be invalidated. + same_size = false; + clear(); + draggers_valid = false; + } Geom::Point current_p( mg->x.computed, mg->y.computed ); // std::cout << "SPMeshNodeArray::read: p: " << current_p << std::endl; guint max_column = 0; guint irow = 0; // Corresponds to top of patch being read in. - for ( SPObject *ro = mg->firstChild() ; ro ; ro = ro->getNext() ) { + for (auto& ro: mg->children) { - if (SP_IS_MESHROW(ro)) { + if (SP_IS_MESHROW(&ro)) { guint icolumn = 0; // Corresponds to left of patch being read in. - for ( SPObject *po = ro->firstChild() ; po ; po = po->getNext() ) { + for (auto& po: ro.children) { - if (SP_IS_MESHPATCH(po)) { + if (SP_IS_MESHPATCH(&po)) { - SPMeshpatch *patch = SP_MESHPATCH(po); + SPMeshpatch *patch = SP_MESHPATCH(&po); // std::cout << "SPMeshNodeArray::read: row size: " << nodes.size() << std::endl; SPMeshPatchI new_patch( &nodes, irow, icolumn ); // Adds new nodes. @@ -652,15 +727,15 @@ void SPMeshNodeArray::read( SPMesh *mg_in ) { // Only 'top' side defined for first row. if( irow != 0 ) ++istop; - for ( SPObject *so = po->firstChild() ; so ; so = so->getNext() ) { - if (SP_IS_STOP(so)) { + for (auto& so: po.children) { + if (SP_IS_STOP(&so)) { if( istop > 3 ) { // std::cout << " Mesh Gradient: Too many stops: " << istop << std::endl; break; } - SPStop *stop = SP_STOP(so); + SPStop *stop = SP_STOP(&so); // Handle top of first row. if( istop == 0 && icolumn == 0 ) { @@ -701,7 +776,7 @@ void SPMeshNodeArray::read( SPMesh *mg_in ) { dp = Geom::Point( x, y ); new_patch.setPoint( istop, 3, current_p + dp ); } else { - std::cout << "Failed to read l" << std::endl; + std::cerr << "Failed to read l" << std::endl; } } // To facilitate some side operations, set handles to 1/3 and @@ -723,7 +798,7 @@ void SPMeshNodeArray::read( SPMesh *mg_in ) { p = Geom::Point( x, y ); new_patch.setPoint( istop, 3, p ); } else { - std::cout << "Failed to read L" << std::endl; + std::cerr << "Failed to read L" << std::endl; } } // To facilitate some side operations, set handles to 1/3 and @@ -743,7 +818,7 @@ void SPMeshNodeArray::read( SPMesh *mg_in ) { p += current_p; new_patch.setPoint( istop, i, p ); } else { - std::cout << "Failed to read c: " << i << std::endl; + std::cerr << "Failed to read c: " << i << std::endl; } } break; @@ -756,13 +831,13 @@ void SPMeshNodeArray::read( SPMesh *mg_in ) { p = Geom::Point( x, y ); new_patch.setPoint( istop, i, p ); } else { - std::cout << "Failed to read C: " << i << std::endl; + std::cerr << "Failed to read C: " << i << std::endl; } } break; default: // should not reach - std::cout << "Path Error: unhandled path type: " << path_type << std::endl; + std::cerr << "Path Error: unhandled path type: " << path_type << std::endl; } current_p = new_patch.getPoint( istop, 3 ); @@ -774,6 +849,7 @@ void SPMeshNodeArray::read( SPMesh *mg_in ) { double opacity = stop->opacity; new_patch.setColor( istop, color ); new_patch.setOpacity( istop, opacity ); + new_patch.setStopPtr( istop, stop ); } } @@ -797,7 +873,7 @@ void SPMeshNodeArray::read( SPMesh *mg_in ) { if( !os.fail() ) { new_patch.setTensorPoint( i, new_patch.getPoint( i, 0 ) + Geom::Point( x, y ) ); } else { - std::cout << "Failed to read p: " << i << std::endl; + std::cerr << "Failed to read p: " << i << std::endl; break; } } @@ -830,15 +906,15 @@ void SPMeshNodeArray::read( SPMesh *mg_in ) { // std::cout << "SPMeshNodeArray::Read: result:" << std::endl; // print(); - drag_valid = false; built = true; + return same_size; }; /** Write repr using our array. */ -void SPMeshNodeArray::write( SPMesh *mg ) { +void SPMeshNodeArray::write( SPMeshGradient *mg ) { // std::cout << "SPMeshNodeArray::write: entrance:" << std::endl; // print(); @@ -848,15 +924,15 @@ void SPMeshNodeArray::write( SPMesh *mg ) { // First we must delete reprs for old mesh rows and patches. GSList *descendant_reprs = NULL; GSList *descendant_objects = NULL; - for ( SPObject *row = mg->firstChild(); row; row = row->getNext() ) { - descendant_reprs = g_slist_prepend (descendant_reprs, row->getRepr()); - descendant_objects = g_slist_prepend (descendant_objects, row ); - for ( SPObject *patch = row->firstChild(); patch; patch = patch->getNext() ) { - descendant_reprs = g_slist_prepend (descendant_reprs, patch->getRepr()); - descendant_objects = g_slist_prepend (descendant_objects, patch ); - for ( SPObject *stop = patch->firstChild(); stop; stop = stop->getNext() ) { - descendant_reprs = g_slist_prepend (descendant_reprs, stop->getRepr()); - descendant_objects = g_slist_prepend (descendant_objects, stop ); + for (auto& row: mg->children) { + descendant_reprs = g_slist_prepend (descendant_reprs, row.getRepr()); + descendant_objects = g_slist_prepend (descendant_objects, &row); + for (auto& patch: row.children) { + descendant_reprs = g_slist_prepend (descendant_reprs, patch.getRepr()); + descendant_objects = g_slist_prepend (descendant_objects, &patch); + for (auto& stop: patch.children) { + descendant_reprs = g_slist_prepend (descendant_reprs, stop.getRepr()); + descendant_objects = g_slist_prepend (descendant_objects, &stop); } } } @@ -967,10 +1043,10 @@ void SPMeshNodeArray::write( SPMesh *mg ) { break; case 'z': case 'Z': - std::cout << "sp_mesh_repr_write: bad path type" << path_type << std::endl; + std::cout << "SPMeshNodeArray::write(): bad path type" << path_type << std::endl; break; default: - std::cout << "sp_mesh_repr_write: unhandled path type" << path_type << std::endl; + std::cout << "SPMeshNodeArray::write(): unhandled path type" << path_type << std::endl; } stop->setAttribute("path", is.str().c_str()); // std::cout << "SPMeshNodeArray::write: path: " << is.str().c_str() << std::endl; @@ -1039,18 +1115,19 @@ static SPColor default_color( SPItem *item ) { /** Create a default mesh. */ -void SPMeshNodeArray::create( SPMesh *mg, SPItem *item, Geom::OptRect bbox ) { +void SPMeshNodeArray::create( SPMeshGradient *mg, SPItem *item, Geom::OptRect bbox ) { // std::cout << "SPMeshNodeArray::create: Entrance" << std::endl; if( !bbox ) { // Set default size to bounding box if size not given. std::cout << "SPMeshNodeArray::create(): bbox empty" << std::endl; - Geom::OptRect bbox = item->geometricBounds(); - } - if( !bbox ) { - std::cout << "SPMeshNodeArray::create: ERROR: No bounding box!" << std::endl; - return; + bbox = item->geometricBounds(); + + if( !bbox ) { + std::cout << "SPMeshNodeArray::create: ERROR: No bounding box!" << std::endl; + return; + } } Geom::Coord const width = bbox->dimensions()[Geom::X]; @@ -1414,6 +1491,7 @@ void SPMeshNodeArray::print() { << " Node edge: " << nodes[i][j]->node_edge << " Set: " << nodes[i][j]->set << " Path type: " << nodes[i][j]->path_type + << " Stop: " << nodes[i][j]->stop << std::endl; } else { std::cout << "Error: missing mesh node." << std::endl; @@ -1775,7 +1853,9 @@ guint SPMeshNodeArray::patch_rows() { Number of patch columns. */ guint SPMeshNodeArray::patch_columns() { - + if (nodes.empty()) { + return 0; + } return nodes[0].size()/3; } @@ -2344,7 +2424,11 @@ guint SPMeshNodeArray::color_pick( std::vector<guint> icorners, SPItem* item ) { */ void SPMeshNodeArray::update_handles( guint corner, std::vector< guint > /*selected*/, Geom::Point p_old, MeshNodeOperation /*op*/ ) { - assert( drag_valid ); + if (!draggers_valid) { + std::cerr << "SPMeshNodeArray::update_handles: Draggers not valid!" << std::endl; + return; + } + // assert( draggers_valid ); // std::cout << "SPMeshNodeArray::update_handles: " // << " corner: " << corner diff --git a/src/sp-mesh-array.h b/src/sp-mesh-array.h index b078b221e..49ee88e53 100644 --- a/src/sp-mesh-array.h +++ b/src/sp-mesh-array.h @@ -85,6 +85,7 @@ enum MeshNodeOperation { MG_NODE_SCALE_HANDLE }; +class SPStop; class SPMeshNode { public: @@ -95,6 +96,7 @@ public: draggable = -1; path_type = 'u'; opacity = 0.0; + stop = nullptr; } NodeType node_type; unsigned int node_edge; @@ -104,6 +106,7 @@ public: char path_type; SPColor color; double opacity; + SPStop *stop; // Stop corresponding to node. }; @@ -133,21 +136,23 @@ public: void setColor( unsigned int i, SPColor c ); double getOpacity( unsigned int i ); void setOpacity( unsigned int i, double o ); + SPStop* getStopPtr( unsigned int i ); + void setStopPtr( unsigned int i, SPStop* ); }; -class SPMesh; +class SPMeshGradient; // An array of mesh nodes. class SPMeshNodeArray { // Should be private public: - SPMesh *mg; + SPMeshGradient *mg; std::vector< std::vector< SPMeshNode* > > nodes; public: // Draggables to nodes - bool drag_valid; + bool draggers_valid; std::vector< SPMeshNode* > corners; std::vector< SPMeshNode* > handles; std::vector< SPMeshNode* > tensors; @@ -156,17 +161,17 @@ public: friend class SPMeshPatchI; - SPMeshNodeArray() { built = false; mg = NULL; drag_valid = false; }; - SPMeshNodeArray( SPMesh *mg ); + SPMeshNodeArray() { built = false; mg = NULL; draggers_valid = false; }; + SPMeshNodeArray( SPMeshGradient *mg ); SPMeshNodeArray( const SPMeshNodeArray& rhs ); SPMeshNodeArray& operator=(const SPMeshNodeArray& rhs); ~SPMeshNodeArray() { clear(); }; bool built; - void read( SPMesh *mg ); - void write( SPMesh *mg ); - void create( SPMesh *mg, SPItem *item, Geom::OptRect bbox ); + bool read( SPMeshGradient *mg ); + void write( SPMeshGradient *mg ); + void create( SPMeshGradient *mg, SPItem *item, Geom::OptRect bbox ); void clear(); void print(); diff --git a/src/sp-mesh.cpp b/src/sp-mesh-gradient.cpp index e04c29e8e..572131c60 100644 --- a/src/sp-mesh.cpp +++ b/src/sp-mesh-gradient.cpp @@ -2,35 +2,60 @@ #include "attributes.h" #include "display/cairo-utils.h" -#include "xml/repr.h" -#include "sp-mesh.h" +#include "sp-mesh-gradient.h" /* * Mesh Gradient */ //#define MESH_DEBUG -SPMesh::SPMesh() : SPGradient(), type( SP_MESH_TYPE_COONS ), type_set(false) { +//#define OBJECT_TRACE + +SPMeshGradient::SPMeshGradient() : SPGradient(), type( SP_MESH_TYPE_COONS ), type_set(false) { +#ifdef OBJECT_TRACE + objectTrace( "SPMeshGradient::SPMeshGradient" ); +#endif + // Start coordinate of mesh this->x.unset(SVGLength::NONE, 0.0, 0.0); this->y.unset(SVGLength::NONE, 0.0, 0.0); + +#ifdef OBJECT_TRACE + objectTrace( "SPMeshGradient::SPMeshGradient", false ); +#endif } -SPMesh::~SPMesh() { +SPMeshGradient::~SPMeshGradient() { +#ifdef OBJECT_TRACE + objectTrace( "SPMeshGradient::~SPMeshGradient (empty function)" ); + objectTrace( "SPMeshGradient::~SPMeshGradient", false ); +#endif } -void SPMesh::build(SPDocument *document, Inkscape::XML::Node *repr) { +void SPMeshGradient::build(SPDocument *document, Inkscape::XML::Node *repr) { +#ifdef OBJECT_TRACE + objectTrace( "SPMeshGradient::build" ); +#endif + SPGradient::build(document, repr); - // Start coordinate of mesh + // Start coordinate of meshgradient this->readAttr( "x" ); this->readAttr( "y" ); this->readAttr( "type" ); + +#ifdef OBJECT_TRACE + objectTrace( "SPMeshGradient::build", false ); +#endif } -void SPMesh::set(unsigned key, gchar const *value) { +void SPMeshGradient::set(unsigned key, gchar const *value) { +#ifdef OBJECT_TRACE + objectTrace( "SPMeshGradient::set" ); +#endif + switch (key) { case SP_ATTR_X: if (!this->x.read(value)) { @@ -55,11 +80,11 @@ void SPMesh::set(unsigned key, gchar const *value) { } else if (!strcmp(value, "bicubic")) { this->type = SP_MESH_TYPE_BICUBIC; } else { - std::cerr << "SPMesh::set(): invalid value " << value << std::endl; + std::cerr << "SPMeshGradient::set(): invalid value " << value << std::endl; } this->type_set = TRUE; } else { - // std::cout << "SPMesh::set() No value " << std::endl; + // std::cout << "SPMeshGradient::set() No value " << std::endl; this->type = SP_MESH_TYPE_COONS; this->type_set = FALSE; } @@ -71,18 +96,22 @@ void SPMesh::set(unsigned key, gchar const *value) { SPGradient::set(key, value); break; } + +#ifdef OBJECT_TRACE + objectTrace( "SPMeshGradient::set", false ); +#endif } /** * Write mesh gradient attributes to associated repr. */ -Inkscape::XML::Node* SPMesh::write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { -#ifdef MESH_DEBUG - std::cout << "sp_mesh_write() ***************************" << std::endl; +Inkscape::XML::Node* SPMeshGradient::write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { +#ifdef OBJECT_TRACE + objectTrace( "SPMeshGradient::write", false ); #endif if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) { - repr = xml_doc->createElement("svg:mesh"); + repr = xml_doc->createElement("svg:meshgradient"); } if ((flags & SP_OBJECT_WRITE_ALL) || this->x._set) { @@ -109,17 +138,13 @@ Inkscape::XML::Node* SPMesh::write(Inkscape::XML::Document *xml_doc, Inkscape::X SPGradient::write(xml_doc, repr, flags); +#ifdef OBJECT_TRACE + objectTrace( "SPMeshGradient::write", false ); +#endif return repr; } -void -sp_mesh_repr_write(SPMesh *mg) -{ - mg->array.write( mg ); -} - - -cairo_pattern_t* SPMesh::pattern_new(cairo_t * /*ct*/, +cairo_pattern_t* SPMeshGradient::pattern_new(cairo_t * /*ct*/, #if defined(MESH_DEBUG) || (CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 11, 4)) Geom::OptRect const &bbox, double opacity @@ -133,7 +158,7 @@ cairo_pattern_t* SPMesh::pattern_new(cairo_t * /*ct*/, using Geom::Y; #ifdef MESH_DEBUG - std::cout << "sp_mesh_create_pattern: (" << bbox->x0 << "," << bbox->y0 << ") (" << bbox->x1 << "," << bbox->y1 << ") " << opacity << std::endl; + std::cout << "sp_meshgradient_create_pattern: " << (*bbox) << " " << opacity << std::endl; #endif this->ensureArray(); @@ -146,7 +171,7 @@ cairo_pattern_t* SPMesh::pattern_new(cairo_t * /*ct*/, if( type_set ) { switch (type) { case SP_MESH_TYPE_COONS: - // std::cout << "SPMesh::pattern_new: Coons" << std::endl; + // std::cout << "SPMeshGradient::pattern_new: Coons" << std::endl; break; case SP_MESH_TYPE_BICUBIC: array.bicubic( &array_smoothed, type ); diff --git a/src/sp-mesh-gradient.h b/src/sp-mesh-gradient.h new file mode 100644 index 000000000..a221554a3 --- /dev/null +++ b/src/sp-mesh-gradient.h @@ -0,0 +1,43 @@ +#ifndef SP_MESH_GRADIENT_H +#define SP_MESH_GRADIENT_H + +/** \file + * SPMeshGradient: SVG <meshgradient> implementation. + */ + +#include "svg/svg-length.h" +#include "sp-gradient.h" + +#define SP_MESHGRADIENT(obj) (dynamic_cast<SPMeshGradient*>((SPObject*)obj)) +#define SP_IS_MESHGRADIENT(obj) (dynamic_cast<const SPMeshGradient*>((SPObject*)obj) != NULL) + +/** Mesh gradient. */ +class SPMeshGradient : public SPGradient { +public: + SPMeshGradient(); + virtual ~SPMeshGradient(); + + SVGLength x; // Upper left corner of meshgradient + SVGLength y; // Upper right corner of mesh + SPMeshType type; + bool type_set; + virtual cairo_pattern_t* pattern_new(cairo_t *ct, Geom::OptRect const &bbox, double opacity); + +protected: + virtual void build(SPDocument *document, Inkscape::XML::Node *repr); + virtual void set(unsigned key, char const *value); + virtual Inkscape::XML::Node* write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, unsigned int flags); +}; + +#endif /* !SP_MESH_GRADIENT_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/sp-mesh-patch.cpp b/src/sp-mesh-patch.cpp index 834c09935..9a173a8db 100644 --- a/src/sp-mesh-patch.cpp +++ b/src/sp-mesh-patch.cpp @@ -18,7 +18,6 @@ #include "style.h" #include "attributes.h" -#include "xml/repr.h" SPMeshpatch* SPMeshpatch::getNextMeshpatch() { @@ -58,7 +57,6 @@ SPMeshpatch* SPMeshpatch::getPrevMeshpatch() /* * Mesh Patch */ - SPMeshpatch::SPMeshpatch() : SPObject() { this->tensor_string = NULL; } @@ -75,7 +73,6 @@ void SPMeshpatch::build(SPDocument* doc, Inkscape::XML::Node* repr) { /** * Virtual build: set meshpatch attributes from its associated XML node. */ - void SPMeshpatch::set(unsigned int key, const gchar* value) { switch (key) { case SP_ATTR_TENSOR: { @@ -92,9 +89,36 @@ void SPMeshpatch::set(unsigned int key, const gchar* value) { } /** - * Virtual set: set attribute to value. + * modified */ +void SPMeshpatch::modified(unsigned int flags) { + flags &= SP_OBJECT_MODIFIED_CASCADE; + GSList *l = NULL; + + for (auto& child: children) { + sp_object_ref(&child); + l = g_slist_prepend(l, &child); + } + + l = g_slist_reverse(l); + + while (l) { + SPObject *child = SP_OBJECT(l->data); + l = g_slist_remove(l, child); + + if (flags || (child->mflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) { + child->emitModified(flags); + } + + sp_object_unref(child); + } +} + + +/** + * Virtual set: set attribute to value. + */ Inkscape::XML::Node* SPMeshpatch::write(Inkscape::XML::Document* xml_doc, Inkscape::XML::Node* repr, guint flags) { if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) { repr = xml_doc->createElement("svg:meshpatch"); diff --git a/src/sp-mesh-patch.h b/src/sp-mesh-patch.h index 88d6325c3..e018b81ea 100644 --- a/src/sp-mesh-patch.h +++ b/src/sp-mesh-patch.h @@ -21,8 +21,8 @@ /** Gradient Meshpatch. */ class SPMeshpatch : public SPObject { public: - SPMeshpatch(); - virtual ~SPMeshpatch(); + SPMeshpatch(); + virtual ~SPMeshpatch(); SPMeshpatch* getNextMeshpatch(); SPMeshpatch* getPrevMeshpatch(); @@ -31,9 +31,10 @@ public: //SVGLength ty[4]; // Tensor points protected: - virtual void build(SPDocument* doc, Inkscape::XML::Node* repr); - virtual void set(unsigned int key, const char* value); - virtual Inkscape::XML::Node* write(Inkscape::XML::Document* doc, Inkscape::XML::Node* repr, unsigned int flags); + virtual void build(SPDocument* doc, Inkscape::XML::Node* repr); + virtual void set(unsigned int key, const char* value); + virtual void modified(unsigned int flags); + virtual Inkscape::XML::Node* write(Inkscape::XML::Document* doc, Inkscape::XML::Node* repr, unsigned int flags); }; #endif /* !SEEN_SP_MESHPATCH_H */ diff --git a/src/sp-mesh-row.cpp b/src/sp-mesh-row.cpp index dd7948bdf..5ac349c27 100644 --- a/src/sp-mesh-row.cpp +++ b/src/sp-mesh-row.cpp @@ -17,8 +17,6 @@ #include "sp-mesh-row.h" #include "style.h" -#include "xml/repr.h" - SPMeshrow* SPMeshrow::getNextMeshrow() { SPMeshrow *result = 0; @@ -67,17 +65,44 @@ void SPMeshrow::build(SPDocument* doc, Inkscape::XML::Node* repr) { SPObject::build(doc, repr); } + /** * Virtual build: set meshrow attributes from its associated XML node. */ - void SPMeshrow::set(unsigned int /*key*/, const gchar* /*value*/) { } /** - * Virtual set: set attribute to value. + * modified */ +void SPMeshrow::modified(unsigned int flags) { + + flags &= SP_OBJECT_MODIFIED_CASCADE; + GSList *l = NULL; + + for (auto& child: children) { + sp_object_ref(&child); + l = g_slist_prepend(l, &child); + } + + l = g_slist_reverse(l); + + while (l) { + SPObject *child = SP_OBJECT(l->data); + l = g_slist_remove(l, child); + if (flags || (child->mflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) { + child->emitModified(flags); + } + + sp_object_unref(child); + } +} + + +/** + * Virtual set: set attribute to value. + */ Inkscape::XML::Node* SPMeshrow::write(Inkscape::XML::Document* xml_doc, Inkscape::XML::Node* repr, guint flags) { if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) { repr = xml_doc->createElement("svg:meshrow"); diff --git a/src/sp-mesh-row.h b/src/sp-mesh-row.h index ffb3efa6b..40335e2b9 100644 --- a/src/sp-mesh-row.h +++ b/src/sp-mesh-row.h @@ -19,16 +19,17 @@ /** Gradient Meshrow. */ class SPMeshrow : public SPObject { public: - SPMeshrow(); - virtual ~SPMeshrow(); + SPMeshrow(); + virtual ~SPMeshrow(); SPMeshrow* getNextMeshrow(); SPMeshrow* getPrevMeshrow(); protected: - virtual void build(SPDocument* doc, Inkscape::XML::Node* repr); - virtual void set(unsigned int key, const char* value); - virtual Inkscape::XML::Node* write(Inkscape::XML::Document* doc, Inkscape::XML::Node* repr, unsigned int flags); + virtual void build(SPDocument* doc, Inkscape::XML::Node* repr); + virtual void set(unsigned int key, const char* value); + virtual void modified(unsigned int flags); + virtual Inkscape::XML::Node* write(Inkscape::XML::Document* doc, Inkscape::XML::Node* repr, unsigned int flags); }; #endif /* !SEEN_SP_MESHROW_H */ diff --git a/src/sp-mesh.h b/src/sp-mesh.h deleted file mode 100644 index 6f992d034..000000000 --- a/src/sp-mesh.h +++ /dev/null @@ -1,43 +0,0 @@ -#ifndef SP_MESH_H -#define SP_MESH_H - -/** \file - * SPMesh: SVG <mesh> implementation. - */ - -#include "svg/svg-length.h" -#include "sp-gradient.h" - -#define SP_MESH(obj) (dynamic_cast<SPMesh*>((SPObject*)obj)) -#define SP_IS_MESH(obj) (dynamic_cast<const SPMesh*>((SPObject*)obj) != NULL) - -/** Mesh gradient. */ -class SPMesh : public SPGradient { -public: - SPMesh(); - virtual ~SPMesh(); - - SVGLength x; // Upper left corner of mesh - SVGLength y; // Upper right corner of mesh - SPMeshType type; - bool type_set; - virtual cairo_pattern_t* pattern_new(cairo_t *ct, Geom::OptRect const &bbox, double opacity); - -protected: - virtual void build(SPDocument *document, Inkscape::XML::Node *repr); - virtual void set(unsigned key, char const *value); - virtual Inkscape::XML::Node* write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, unsigned int flags); -}; - -#endif /* !SP_MESH_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/sp-metadata.cpp b/src/sp-metadata.cpp index 6bdc2f0b9..e7907e4f0 100644 --- a/src/sp-metadata.cpp +++ b/src/sp-metadata.cpp @@ -10,7 +10,7 @@ */ #ifdef HAVE_CONFIG_H -# include "config.h" +#include <config.h> #endif #include "sp-metadata.h" diff --git a/src/sp-missing-glyph.cpp b/src/sp-missing-glyph.cpp index 75de55693..f441b66d2 100644 --- a/src/sp-missing-glyph.cpp +++ b/src/sp-missing-glyph.cpp @@ -1,5 +1,5 @@ #ifdef HAVE_CONFIG_H -# include <config.h> +#include <config.h> #endif /* diff --git a/src/sp-namedview.cpp b/src/sp-namedview.cpp index 616ec3921..b9526433f 100644 --- a/src/sp-namedview.cpp +++ b/src/sp-namedview.cpp @@ -14,14 +14,12 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include "config.h" #include <cstring> #include <string> #include "event-log.h" #include <2geom/transforms.h> #include "display/canvas-grid.h" -#include "display/guideline.h" #include "util/units.h" #include "svg/svg-color.h" #include "xml/repr.h" @@ -248,9 +246,9 @@ void SPNamedView::build(SPDocument *document, Inkscape::XML::Node *repr) { this->readAttr( "inkscape:lockguides" ); /* Construct guideline list */ - for (SPObject *o = this->firstChild() ; o; o = o->getNext() ) { - if (SP_IS_GUIDE(o)) { - SPGuide * g = SP_GUIDE(o); + for (auto& o: children) { + if (SP_IS_GUIDE(&o)) { + SPGuide * g = SP_GUIDE(&o); this->guides.push_back(g); //g_object_set(G_OBJECT(g), "color", nv->guidecolor, "hicolor", nv->guidehicolor, NULL); g->setColor(this->guidecolor); @@ -858,9 +856,9 @@ void sp_namedview_update_layers_from_document (SPDesktop *desktop) } // if that didn't work out, look for the topmost layer if (!layer) { - for ( SPObject *iter = document->getRoot()->firstChild(); iter ; iter = iter->getNext() ) { - if (desktop->isLayer(iter)) { - layer = iter; + for (auto& iter: document->getRoot()->children) { + if (desktop->isLayer(&iter)) { + layer = &iter; } } } diff --git a/src/sp-object-group.cpp b/src/sp-object-group.cpp index c3967461e..62c6f7a87 100644 --- a/src/sp-object-group.cpp +++ b/src/sp-object-group.cpp @@ -50,8 +50,8 @@ Inkscape::XML::Node *SPObjectGroup::write(Inkscape::XML::Document *xml_doc, Inks } GSList *l = 0; - for ( SPObject *child = this->firstChild() ; child ; child = child->getNext() ) { - Inkscape::XML::Node *crepr = child->updateRepr(xml_doc, NULL, flags); + for (auto& child: children) { + Inkscape::XML::Node *crepr = child.updateRepr(xml_doc, NULL, flags); if (crepr) { l = g_slist_prepend(l, crepr); @@ -64,8 +64,8 @@ Inkscape::XML::Node *SPObjectGroup::write(Inkscape::XML::Document *xml_doc, Inks l = g_slist_remove(l, l->data); } } else { - for ( SPObject *child = this->firstChild() ; child ; child = child->getNext() ) { - child->updateRepr(flags); + for (auto& child: children) { + child.updateRepr(flags); } } diff --git a/src/sp-object.cpp b/src/sp-object.cpp index d1659eedc..da4367d5b 100644 --- a/src/sp-object.cpp +++ b/src/sp-object.cpp @@ -7,8 +7,9 @@ * Stephen Silver <sasilver@users.sourceforge.net> * Jon A. Cruz <jon@joncruz.org> * Abhishek Sharma + * Adrian Boguszewski * - * Copyright (C) 1999-2008 authors + * Copyright (C) 1999-2016 authors * Copyright (C) 2001-2002 Ximian, Inc. * * Released under GNU GPL, read the file 'COPYING' for more information @@ -16,6 +17,7 @@ #include <cstring> #include <string> +#include <boost/range/adaptor/transformed.hpp> #include "helper/sp-marshal.h" #include "xml/node-event-vector.h" @@ -32,12 +34,10 @@ #include "sp-script.h" #include "streq.h" #include "strneq.h" -#include "xml/repr.h" #include "xml/node-fns.h" #include "debug/event-tracker.h" #include "debug/simple-event.h" #include "debug/demangle.h" -#include "util/share.h" #include "util/format.h" #include "util/longest-common-suffix.h" @@ -61,6 +61,10 @@ using std::strstr; # define debug(f, a...) /* */ #endif +// Define to enable indented tracing of SPObject. +//#define OBJECT_TRACE +unsigned SPObject::indent_level = 0; + guint update_in_progress = 0; // guard against update-during-update Inkscape::XML::NodeEventVector object_event_vector = { @@ -116,8 +120,7 @@ static gchar *sp_object_get_unique_id(SPObject *object, */ SPObject::SPObject() : cloned(0), uflags(0), mflags(0), hrefcount(0), _total_hrefcount(0), - document(NULL), parent(NULL), children(NULL), _last_child(NULL), - next(NULL), id(NULL), repr(NULL), refCount(1),hrefList(std::list<SPObject*>()), + document(NULL), parent(NULL), id(NULL), repr(NULL), refCount(1), hrefList(std::list<SPObject*>()), _successor(NULL), _collection_policy(SPObject::COLLECT_WITH_PARENT), _label(NULL), _default_label(NULL) { @@ -150,6 +153,9 @@ SPObject::~SPObject() { sp_object_unref(this->_successor, NULL); this->_successor = NULL; } + if (parent) { + parent->children.erase(parent->children.iterator_to(*this)); + } if( style == NULL ) { // style pointer could be NULL if unreffed too many times. @@ -180,6 +186,10 @@ void SPObject::update(SPCtx* /*ctx*/, unsigned int /*flags*/) { } void SPObject::modified(unsigned int /*flags*/) { +#ifdef OBJECT_TRACE + objectTrace( "SPObject::modified (default) (empty function)" ); + objectTrace( "SPObject::modified (default)", false ); +#endif //throw; } @@ -398,13 +408,12 @@ void SPObject::changeCSS(SPCSSAttr *css, gchar const *attr) } std::vector<SPObject*> SPObject::childList(bool add_ref, Action) { - std::vector<SPObject*> l; - for ( SPObject *child = firstChild() ; child; child = child->getNext() ) { + std::vector<SPObject*> l; + for (auto& child: children) { if (add_ref) { - sp_object_ref (child); + sp_object_ref(&child); } - - l.push_back(child); + l.push_back(&child); } return l; @@ -467,9 +476,9 @@ void SPObject::requestOrphanCollection() { } void SPObject::_sendDeleteSignalRecursive() { - for (SPObject *child = firstChild(); child; child = child->getNext()) { - child->_delete_signal.emit(child); - child->_sendDeleteSignalRecursive(); + for (auto& child: children) { + child._delete_signal.emit(&child); + child._sendDeleteSignalRecursive(); } } @@ -497,12 +506,12 @@ void SPObject::deleteObject(bool propagate, bool propagate_descendants) void SPObject::cropToObject(SPObject *except) { std::vector<SPObject*> toDelete; - for ( SPObject *child = this->firstChild(); child; child = child->getNext() ) { - if (SP_IS_ITEM(child)) { - if (child->isAncestorOf(except)) { - child->cropToObject(except); - } else if(child != except) { - toDelete.push_back(child); + for (auto& child: children) { + if (SP_IS_ITEM(&child)) { + if (child.isAncestorOf(except)) { + child.cropToObject(except); + } else if(&child != except) { + toDelete.push_back(&child); } } } @@ -525,60 +534,29 @@ void SPObject::attach(SPObject *object, SPObject *prev) object->parent = this; this->_updateTotalHRefCount(object->_total_hrefcount); - SPObject *next; - if (prev) { - next = prev->next; - prev->next = object; - } else { - next = this->children; - this->children = object; - } - object->next = next; - if (!next) { - this->_last_child = object; + auto it = children.begin(); + if (prev != nullptr) { + it = ++children.iterator_to(*prev); } + children.insert(it, *object); + if (!object->xml_space.set) object->xml_space.value = this->xml_space.value; } -void SPObject::reorder(SPObject *prev) -{ - //g_return_if_fail(object != NULL); - //g_return_if_fail(SP_IS_OBJECT(object)); - g_return_if_fail(this->parent != NULL); - g_return_if_fail(this != prev); - g_return_if_fail(!prev || SP_IS_OBJECT(prev)); - g_return_if_fail(!prev || prev->parent == this->parent); +void SPObject::reorder(SPObject* obj, SPObject* prev) { + g_return_if_fail(obj != nullptr); + g_return_if_fail(obj->parent); + g_return_if_fail(obj->parent == this); + g_return_if_fail(obj != prev); + g_return_if_fail(!prev || prev->parent == obj->parent); - SPObject *const parent=this->parent; - - SPObject *old_prev=NULL; - for ( SPObject *child = parent->children ; child && child != this ; - child = child->next ) - { - old_prev = child; + auto it = children.begin(); + if (prev != nullptr) { + it = ++children.iterator_to(*prev); } - SPObject *next=this->next; - if (old_prev) { - old_prev->next = next; - } else { - parent->children = next; - } - if (!next) { - parent->_last_child = old_prev; - } - if (prev) { - next = prev->next; - prev->next = this; - } else { - next = parent->children; - parent->children = this; - } - this->next = next; - if (!next) { - parent->_last_child = this; - } + children.splice(it, children, children.iterator_to(*obj)); } void SPObject::detach(SPObject *object) @@ -589,26 +567,9 @@ void SPObject::detach(SPObject *object) g_return_if_fail(SP_IS_OBJECT(object)); g_return_if_fail(object->parent == this); + children.erase(children.iterator_to(*object)); object->releaseReferences(); - SPObject *prev=NULL; - for ( SPObject *child = this->children ; child && child != object ; - child = child->next ) - { - prev = child; - } - - SPObject *next=object->next; - if (prev) { - prev->next = next; - } else { - this->children = next; - } - if (!next) { - this->_last_child = prev; - } - - object->next = NULL; object->parent = NULL; this->_updateTotalHRefCount(-object->_total_hrefcount); @@ -618,14 +579,14 @@ void SPObject::detach(SPObject *object) SPObject *SPObject::get_child_by_repr(Inkscape::XML::Node *repr) { g_return_val_if_fail(repr != NULL, NULL); - SPObject *result = 0; + SPObject *result = nullptr; - if ( _last_child && (_last_child->getRepr() == repr) ) { - result = _last_child; // optimization for common scenario + if (children.size() > 0 && children.back().getRepr() == repr) { + result = &children.back(); // optimization for common scenario } else { - for ( SPObject *child = children ; child ; child = child->next ) { - if ( child->getRepr() == repr ) { - result = child; + for (auto& child: children) { + if (child.getRepr() == repr) { + result = &child; break; } } @@ -656,10 +617,12 @@ void SPObject::child_added(Inkscape::XML::Node *child, Inkscape::XML::Node *ref) void SPObject::release() { SPObject* object = this; - debug("id=%p, typename=%s", object, g_type_name_from_instance((GTypeInstance*)object)); - while (object->children) { - object->detach(object->children); + auto tmp = children | boost::adaptors::transformed([](SPObject& obj){return &obj;}); + std::vector<SPObject *> toRelease(tmp.begin(), tmp.end()); + + for (auto& p: toRelease) { + object->detach(p); } } @@ -680,11 +643,15 @@ void SPObject::order_changed(Inkscape::XML::Node *child, Inkscape::XML::Node * / SPObject *ochild = object->get_child_by_repr(child); g_return_if_fail(ochild != NULL); SPObject *prev = new_ref ? object->get_child_by_repr(new_ref) : NULL; - ochild->reorder(prev); + object->reorder(ochild, prev); ochild->_position_changed_signal.emit(ochild); } void SPObject::build(SPDocument *document, Inkscape::XML::Node *repr) { + +#ifdef OBJECT_TRACE + objectTrace( "SPObject::build" ); +#endif SPObject* object = this; /* Nothing specific here */ @@ -710,10 +677,17 @@ void SPObject::build(SPDocument *document, Inkscape::XML::Node *repr) { sp_object_unref(child, NULL); child->invoke_build(document, rchild, object->cloned); } + +#ifdef OBJECT_TRACE + objectTrace( "SPObject::build", false ); +#endif } void SPObject::invoke_build(SPDocument *document, Inkscape::XML::Node *repr, unsigned int cloned) { +#ifdef OBJECT_TRACE + objectTrace( "SPObject::invoke_build" ); +#endif debug("id=%p, typename=%s", this, g_type_name_from_instance((GTypeInstance*)this)); //g_assert(object != NULL); @@ -773,6 +747,10 @@ void SPObject::invoke_build(SPDocument *document, Inkscape::XML::Node *repr, uns /* Signalling (should be connected AFTER processing derived methods */ sp_repr_add_listener(repr, &object_event_vector, this); + +#ifdef OBJECT_TRACE + objectTrace( "SPObject::invoke_build", false ); +#endif } int SPObject::getIntAttribute(char const *key, int def) @@ -842,15 +820,22 @@ void SPObject::releaseReferences() { SPObject *SPObject::getPrev() { - SPObject *prev = 0; - for ( SPObject *obj = parent->firstChild(); obj && !prev; obj = obj->getNext() ) { - if (obj->getNext() == this) { - prev = obj; - } + SPObject *prev = nullptr; + if (parent && !parent->children.empty() && &parent->children.front() != this) { + prev = &*(--parent->children.iterator_to(*this)); } return prev; } +SPObject* SPObject::getNext() +{ + SPObject *next = nullptr; + if (parent && !parent->children.empty() && &parent->children.back() != this) { + next = &*(++parent->children.iterator_to(*this)); + } + return next; +} + void SPObject::repr_child_added(Inkscape::XML::Node * /*repr*/, Inkscape::XML::Node *child, Inkscape::XML::Node *ref, gpointer data) { SPObject *object = SP_OBJECT(data); @@ -873,6 +858,13 @@ void SPObject::repr_order_changed(Inkscape::XML::Node * /*repr*/, Inkscape::XML: } void SPObject::set(unsigned int key, gchar const* value) { + +#ifdef OBJECT_TRACE + std::stringstream temp; + temp << "SPObject::set: " << key << " " << (value?value:"null"); + objectTrace( temp.str() ); +#endif + g_assert(key != SP_ATTR_INVALID); SPObject* object = this; @@ -956,6 +948,9 @@ void SPObject::set(unsigned int key, gchar const* value) { default: break; } +#ifdef OBJECT_TRACE + objectTrace( "SPObject::set", false ); +#endif } void SPObject::setKeyValue(unsigned int key, gchar const *value) @@ -1020,6 +1015,10 @@ static gchar const *sp_xml_get_space_string(unsigned int space) } Inkscape::XML::Node* SPObject::write(Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags) { +#ifdef OBJECT_TRACE + objectTrace( "SPObject::write" ); +#endif + if (!repr && (flags & SP_OBJECT_WRITE_BUILD)) { repr = this->getRepr()->duplicate(doc); if (!( flags & SP_OBJECT_WRITE_EXT )) { @@ -1088,38 +1087,68 @@ Inkscape::XML::Node* SPObject::write(Inkscape::XML::Document *doc, Inkscape::XML sp_style_unset_property_attrs (this); } +#ifdef OBJECT_TRACE + objectTrace( "SPObject::write", false ); +#endif return repr; } Inkscape::XML::Node * SPObject::updateRepr(unsigned int flags) { +#ifdef OBJECT_TRACE + objectTrace( "SPObject::updateRepr 1" ); +#endif + if ( !cloned ) { Inkscape::XML::Node *repr = getRepr(); if (repr) { +#ifdef OBJECT_TRACE + objectTrace( "SPObject::updateRepr 1", false ); +#endif return updateRepr(repr->document(), repr, flags); } else { g_critical("Attempt to update non-existent repr"); +#ifdef OBJECT_TRACE + objectTrace( "SPObject::updateRepr 1", false ); +#endif return NULL; } } else { /* cloned objects have no repr */ +#ifdef OBJECT_TRACE + objectTrace( "SPObject::updateRepr 1", false ); +#endif return NULL; } } Inkscape::XML::Node * SPObject::updateRepr(Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, unsigned int flags) { +#ifdef OBJECT_TRACE + objectTrace( "SPObject::updateRepr 2" ); +#endif + g_assert(doc != NULL); if (cloned) { /* cloned objects have no repr */ +#ifdef OBJECT_TRACE + objectTrace( "SPObject::updateRepr 2", false ); +#endif return NULL; } if (!(flags & SP_OBJECT_WRITE_BUILD) && !repr) { repr = getRepr(); } + +#ifdef OBJECT_TRACE + Inkscape::XML::Node *node = write(doc, repr, flags); + objectTrace( "SPObject::updateRepr 2", false ); + return node; +#else return this->write(doc, repr, flags); +#endif } @@ -1139,6 +1168,10 @@ void SPObject::requestDisplayUpdate(unsigned int flags) g_return_if_fail((flags & SP_OBJECT_MODIFIED_FLAG) || (flags & SP_OBJECT_CHILD_MODIFIED_FLAG)); g_return_if_fail(!((flags & SP_OBJECT_MODIFIED_FLAG) && (flags & SP_OBJECT_CHILD_MODIFIED_FLAG))); +#ifdef OBJECT_TRACE + objectTrace( "SPObject::requestDisplayUpdate" ); +#endif + bool already_propagated = (!(this->uflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))); this->uflags |= flags; @@ -1153,12 +1186,21 @@ void SPObject::requestDisplayUpdate(unsigned int flags) document->requestModified(); } } + +#ifdef OBJECT_TRACE + objectTrace( "SPObject::requestDisplayUpdate", false ); +#endif + } void SPObject::updateDisplay(SPCtx *ctx, unsigned int flags) { g_return_if_fail(!(flags & ~SP_OBJECT_MODIFIED_CASCADE)); +#ifdef OBJECT_TRACE + objectTrace( "SPObject::updateDisplay" ); +#endif + update_in_progress ++; #ifdef SP_OBJECT_DEBUG_CASCADE @@ -1199,6 +1241,10 @@ void SPObject::updateDisplay(SPCtx *ctx, unsigned int flags) } update_in_progress --; + +#ifdef OBJECT_TRACE + objectTrace( "SPObject::updateDisplay", false ); +#endif } void SPObject::requestModified(unsigned int flags) @@ -1211,6 +1257,10 @@ void SPObject::requestModified(unsigned int flags) g_return_if_fail((flags & SP_OBJECT_MODIFIED_FLAG) || (flags & SP_OBJECT_CHILD_MODIFIED_FLAG)); g_return_if_fail(!((flags & SP_OBJECT_MODIFIED_FLAG) && (flags & SP_OBJECT_CHILD_MODIFIED_FLAG))); +#ifdef OBJECT_TRACE + objectTrace( "SPObject::requestModified" ); +#endif + bool already_propagated = (!(this->mflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))); this->mflags |= flags; @@ -1225,6 +1275,9 @@ void SPObject::requestModified(unsigned int flags) document->requestModified(); } } +#ifdef OBJECT_TRACE + objectTrace( "SPObject::requestModified", false ); +#endif } void SPObject::emitModified(unsigned int flags) @@ -1232,6 +1285,10 @@ void SPObject::emitModified(unsigned int flags) /* only the MODIFIED_CASCADE flag is legal here */ g_return_if_fail(!(flags & ~SP_OBJECT_MODIFIED_CASCADE)); +#ifdef OBJECT_TRACE + objectTrace( "SPObject::emitModified", true, flags ); +#endif + #ifdef SP_OBJECT_DEBUG_CASCADE g_print("Modified %s:%s %x %x %x\n", g_type_name_from_instance((GTypeInstance *) this), getId(), flags, this->uflags, this->mflags); #endif @@ -1248,6 +1305,10 @@ void SPObject::emitModified(unsigned int flags) _modified_signal.emit(this, flags); sp_object_unref(this); + +#ifdef OBJECT_TRACE + objectTrace( "SPObject::emitModified", false ); +#endif } gchar const *SPObject::getTagName(SPException *ex) const @@ -1286,10 +1347,12 @@ void SPObject::setAttribute(gchar const *key, gchar const *value, SPException *e //XML Tree being used here. getRepr()->setAttribute(key, value, false); } + void SPObject::setAttribute(char const *key, Glib::ustring const &value, SPException *ex) { setAttribute(key, value.empty() ? NULL : value.c_str(), ex); } + void SPObject::setAttribute(Glib::ustring const &key, Glib::ustring const &value, SPException *ex) { setAttribute( key.empty() ? NULL : key.c_str(), @@ -1514,8 +1577,11 @@ bool SPObject::setTitleOrDesc(gchar const *value, gchar const *svg_tagname, bool } else { // remove the current content of the 'text' or 'desc' element - SPObject *child; - while (NULL != (child = elem->firstChild())) child->deleteObject(); + auto tmp = elem->children | boost::adaptors::transformed([](SPObject& obj) { return &obj; }); + std::vector<SPObject*> vec(tmp.begin(), tmp.end()); + for (auto &child: vec) { + child->deleteObject(); + } } // add the new content @@ -1523,33 +1589,33 @@ bool SPObject::setTitleOrDesc(gchar const *value, gchar const *svg_tagname, bool return true; } -SPObject * SPObject::findFirstChild(gchar const *tagname) const +SPObject* SPObject::findFirstChild(gchar const *tagname) const { - for (SPObject *child = children; child; child = child->next) + for (auto& child: const_cast<SPObject*>(this)->children) { - if (child->repr->type() == Inkscape::XML::ELEMENT_NODE && - !strcmp(child->repr->name(), tagname)) { - return child; + if (child.repr->type() == Inkscape::XML::ELEMENT_NODE && + !strcmp(child.repr->name(), tagname)) { + return &child; } } - return NULL; + return nullptr; } char* SPObject::textualContent() const { GString* text = g_string_new(""); - for (const SPObject *child = firstChild(); child; child = child->next) + for (auto& child: children) { - Inkscape::XML::NodeType child_type = child->repr->type(); + Inkscape::XML::NodeType child_type = child.repr->type(); if (child_type == Inkscape::XML::ELEMENT_NODE) { - char* new_string = child->textualContent(); + char* new_string = child.textualContent(); g_string_append(text, new_string); g_free(new_string); } else if (child_type == Inkscape::XML::TEXT_NODE) { - g_string_append(text, child->repr->content()); + g_string_append(text, child.repr->content()); } } return g_string_free(text, FALSE); @@ -1566,8 +1632,36 @@ void SPObject::recursivePrintTree( unsigned level ) std::cout << " "; } std::cout << (getId()?getId():"No object id") << std::endl; - for (SPObject *child = children; child; child = child->next) { - child->recursivePrintTree( level+1 ); + for (auto& child: children) { + child.recursivePrintTree(level + 1); + } +} + +// Function to allow tracing of program flow through SPObject and derived classes. +// To trace function, add at entrance ('in' = true) and exit of function ('in' = false). +void SPObject::objectTrace( std::string text, bool in, unsigned flags ) { + if( in ) { + for (unsigned i = 0; i < indent_level; ++i) { + std::cout << " "; + } + std::cout << text << ":" + << " entrance: " + << (id?id:"null") + << " uflags: " << uflags + << " mflags: " << mflags + << " flags: " << flags << std::endl; + ++indent_level; + } else { + --indent_level; + for (unsigned i = 0; i < indent_level; ++i) { + std::cout << " "; + } + std::cout << text << ":" + << " exit: " + << (id?id:"null") + << " uflags: " << uflags + << " mflags: " << mflags + << " flags: " << flags << std::endl; } } diff --git a/src/sp-object.h b/src/sp-object.h index 70d3e5df5..ac3d0c851 100644 --- a/src/sp-object.h +++ b/src/sp-object.h @@ -6,8 +6,9 @@ * Lauris Kaplinski <lauris@kaplinski.com> * Jon A. Cruz <jon@joncruz.org> * Abhishek Sharma + * Adrian Boguszewski * - * Copyright (C) 1999-2002 authors + * Copyright (C) 1999-2016 authors * Copyright (C) 2001-2002 Ximian, Inc. * * Released under GNU GPL, read the file 'COPYING' for more information @@ -53,6 +54,7 @@ class SPObject; #include <sigc++/functors/slot.h> #include <sigc++/signal.h> #include <vector> +#include <boost/intrusive/list.hpp> #include "version.h" #include "util/forward-pointer-iterator.h" @@ -206,9 +208,6 @@ public: unsigned int _total_hrefcount; /* our hrefcount + total descendants */ SPDocument *document; /* Document we are part of */ SPObject *parent; /* Our parent (only one allowed) */ - SPObject *children; /* Our children */ - SPObject *_last_child; /* Remembered last child */ - SPObject *next; /* Next object in linked list */ private: SPObject(const SPObject&); @@ -216,6 +215,7 @@ private: char *id; /* Our very own unique id */ Inkscape::XML::Node *repr; /* Our xml representation */ + public: int refCount; std::list<SPObject*> hrefList; @@ -279,17 +279,9 @@ public: return object->parent; } }; - /// Switch containing next() method. - struct SiblingIteratorStrategy { - static SPObject const *next(SPObject const *object) { - return object->next; - } - }; typedef Inkscape::Util::ForwardPointerIterator<SPObject, ParentIteratorStrategy> ParentIterator; typedef Inkscape::Util::ForwardPointerIterator<SPObject const, ParentIteratorStrategy> ConstParentIterator; - typedef Inkscape::Util::ForwardPointerIterator<SPObject, SiblingIteratorStrategy> SiblingIterator; - typedef Inkscape::Util::ForwardPointerIterator<SPObject const, SiblingIteratorStrategy> ConstSiblingIterator; bool isSiblingOf(SPObject const *object) const { if (object == NULL) return false; @@ -306,24 +298,21 @@ public: */ SPObject const *nearestCommonAncestor(SPObject const *object) const; - /* A non-const version can be similarly constructed if you want one. - * (Don't just cast away the constness, which would be ill-formed.) */ - SPObject *getNext() {return next;} - - SPObject const *getNext() const {return next;} + /* Returns next object in sibling list or NULL. */ + SPObject *getNext(); /** * Returns previous object in sibling list or NULL. */ SPObject *getPrev(); - bool hasChildren() const { return ( children != NULL ); } + bool hasChildren() const { return ( children.size() > 0 ); } - SPObject *firstChild() { return children; } - SPObject const *firstChild() const { return children; } + SPObject *firstChild() { return children.empty() ? nullptr : &children.front(); } + SPObject const *firstChild() const { return children.empty() ? nullptr : &children.front(); } - SPObject *lastChild() { return _last_child; } - SPObject const *lastChild() const { return _last_child; } + SPObject *lastChild() { return children.empty() ? nullptr : &children.back(); } + SPObject const *lastChild() const { return children.empty() ? nullptr : &children.back(); } enum Action { ActionGeneral, ActionBBox, ActionUpdate, ActionShow }; @@ -681,9 +670,9 @@ public: void attach(SPObject *object, SPObject *prev); /** - * In list of object's siblings, move object behind prev. + * In list of object's children, move object behind prev. */ - void reorder(SPObject *prev); + void reorder(SPObject* obj, SPObject *prev); /** * Remove object from parent's children, release and unref it. @@ -858,10 +847,22 @@ protected: virtual Inkscape::XML::Node* write(Inkscape::XML::Document* doc, Inkscape::XML::Node* repr, unsigned int flags); + typedef boost::intrusive::list_member_hook<> ListHook; + ListHook _child_hook; public: + typedef boost::intrusive::list< + SPObject, + boost::intrusive::member_hook< + SPObject, + ListHook, + &SPObject::_child_hook + >> ChildrenList; + ChildrenList children; virtual void read_content(); void recursivePrintTree(unsigned level = 0); // For debugging + static unsigned indent_level; + void objectTrace( std::string, bool in=true, unsigned flags=0 ); }; diff --git a/src/sp-offset.cpp b/src/sp-offset.cpp index d84bdbdd3..9e2264d76 100644 --- a/src/sp-offset.cpp +++ b/src/sp-offset.cpp @@ -15,7 +15,7 @@ */ #ifdef HAVE_CONFIG_H -# include "config.h" +#include <config.h> #endif #include <cstring> @@ -36,11 +36,6 @@ #include "sp-use-reference.h" #include "uri.h" -#include <2geom/affine.h> -#include <2geom/pathvector.h> - -#include "xml/repr.h" - class SPDocument; #define noOFFSET_VERBOSE diff --git a/src/sp-paint-server.cpp b/src/sp-paint-server.cpp index d445ca0a7..958078012 100644 --- a/src/sp-paint-server.cpp +++ b/src/sp-paint-server.cpp @@ -13,7 +13,6 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include <string.h> #include "sp-paint-server-reference.h" #include "sp-paint-server.h" diff --git a/src/sp-path.cpp b/src/sp-path.cpp index c4d24c503..a7119dd31 100644 --- a/src/sp-path.cpp +++ b/src/sp-path.cpp @@ -16,7 +16,7 @@ */ #ifdef HAVE_CONFIG_H -# include <config.h> +#include <config.h> #endif #include <glibmm/i18n.h> @@ -27,7 +27,6 @@ #include "sp-lpe-item.h" #include "display/curve.h" -#include <2geom/pathvector.h> #include <2geom/curves.h> #include "helper/geom-curves.h" @@ -46,7 +45,6 @@ #include "inkscape.h" #include "style.h" #include "message-stack.h" -#include "selection.h" #define noPATH_VERBOSE diff --git a/src/sp-pattern.cpp b/src/sp-pattern.cpp index 55110f3c5..9d6296a0d 100644 --- a/src/sp-pattern.cpp +++ b/src/sp-pattern.cpp @@ -13,14 +13,13 @@ */ #ifdef HAVE_CONFIG_H -#include "config.h" +#include <config.h> #endif #include <cstring> #include <string> #include <glibmm.h> #include <2geom/transforms.h> -#include <sigc++/functors/mem_fun.h> #include "svg/svg.h" #include "display/cairo-utils.h" @@ -30,10 +29,7 @@ #include "display/drawing-group.h" #include "attributes.h" #include "document-private.h" -#include "uri.h" -#include "style.h" #include "sp-pattern.h" -#include "xml/repr.h" #include "sp-factory.h" @@ -223,8 +219,8 @@ void SPPattern::_getChildren(std::list<SPObject *> &l) { for (SPPattern *pat_i = this; pat_i != NULL; pat_i = pat_i->ref ? pat_i->ref->getObject() : NULL) { if (pat_i->firstChild()) { // find the first one with children - for (SPObject *child = pat_i->firstChild(); child; child = child->getNext()) { - l.push_back(child); + for (auto& child: pat_i->children) { + l.push_back(&child); } break; // do not go further up the chain if children are found } @@ -319,8 +315,8 @@ guint SPPattern::_countHrefs(SPObject *o) const i++; } - for (SPObject *child = o->firstChild(); child != NULL; child = child->next) { - i += _countHrefs(child); + for (auto& child: o->children) { + i += _countHrefs(&child); } return i; @@ -508,13 +504,13 @@ Geom::OptRect SPPattern::viewbox() const bool SPPattern::_hasItemChildren() const { - bool hasChildren = false; - for (SPObject const *child = firstChild(); child && !hasChildren; child = child->getNext()) { - if (SP_IS_ITEM(child)) { - hasChildren = true; + for (auto& child: children) { + if (SP_IS_ITEM(&child)) { + return true; } } - return hasChildren; + + return false; } bool SPPattern::isValid() const @@ -558,12 +554,12 @@ cairo_pattern_t *SPPattern::pattern_new(cairo_t *base_ct, Geom::OptRect const &b Inkscape::DrawingGroup *root = new Inkscape::DrawingGroup(drawing); drawing.setRoot(root); - for (SPObject *child = shown->firstChild(); child != NULL; child = child->getNext()) { - if (SP_IS_ITEM(child)) { + for (auto& child: shown->children) { + if (SP_IS_ITEM(&child)) { // for each item in pattern, show it on our drawing, add to the group, // and connect to the release signal in case the item gets deleted Inkscape::DrawingItem *cai; - cai = SP_ITEM(child)->invoke_show(drawing, dkey, SP_ITEM_SHOW_DISPLAY); + cai = SP_ITEM(&child)->invoke_show(drawing, dkey, SP_ITEM_SHOW_DISPLAY); root->appendChild(cai); } } @@ -654,9 +650,9 @@ cairo_pattern_t *SPPattern::pattern_new(cairo_t *base_ct, Geom::OptRect const &b // Render drawing to pattern_surface via drawing context, this calls root->render // which is really DrawingItem->render(). drawing.render(dc, one_tile); - for (SPObject *child = shown->firstChild(); child != NULL; child = child->getNext()) { - if (SP_IS_ITEM(child)) { - SP_ITEM(child)->invoke_hide(dkey); + for (auto& child: shown->children) { + if (SP_IS_ITEM(&child)) { + SP_ITEM(&child)->invoke_hide(dkey); } } @@ -674,10 +670,20 @@ cairo_pattern_t *SPPattern::pattern_new(cairo_t *base_ct, Geom::OptRect const &b dc.paint(opacity); // apply opacity } - 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() * pattern_surface.drawingTransform()); + Geom::Affine raw_transform = ps2user.inverse() * pattern_surface.drawingTransform(); + // Cairo doesn't like large values of x0 and y0. We can replace x0 and y0 by equivalent + // values close to zero (since one tile on a grid is the same as another it doesn't + // matter which tile is used as the base tile). + int w = one_tile[Geom::X].extent(); + int h = one_tile[Geom::Y].extent(); + int m = raw_transform[4] / w; + int n = raw_transform[5] / h; + raw_transform *= Geom::Translate( -m*w, -n*h ); + + cairo_pattern_t *cp = cairo_pattern_create_for_surface(pattern_surface.raw()); + ink_cairo_pattern_set_matrix(cp, raw_transform); cairo_pattern_set_extend(cp, CAIRO_EXTEND_REPEAT); return cp; diff --git a/src/sp-polygon.cpp b/src/sp-polygon.cpp index ced485f12..14fd104b3 100644 --- a/src/sp-polygon.cpp +++ b/src/sp-polygon.cpp @@ -15,7 +15,6 @@ #include "sp-polygon.h" #include "display/curve.h" #include <glibmm/i18n.h> -#include <2geom/pathvector.h> #include <2geom/curves.h> #include "helper/geom-curves.h" #include "svg/stringstream.h" diff --git a/src/sp-polyline.cpp b/src/sp-polyline.cpp index a12f927b5..29054f934 100644 --- a/src/sp-polyline.cpp +++ b/src/sp-polyline.cpp @@ -11,8 +11,6 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include "config.h" - #include "attributes.h" #include "sp-polyline.h" #include "display/curve.h" diff --git a/src/sp-rect.cpp b/src/sp-rect.cpp index 2ba9a7023..88dad5354 100644 --- a/src/sp-rect.cpp +++ b/src/sp-rect.cpp @@ -12,12 +12,10 @@ */ #ifdef HAVE_CONFIG_H -# include "config.h" +#include <config.h> #endif - #include "display/curve.h" -#include <2geom/rect.h> #include "inkscape.h" #include "document.h" @@ -25,12 +23,12 @@ #include "style.h" #include "sp-rect.h" #include <glibmm/i18n.h> -#include "xml/repr.h" #include "sp-guide.h" #include "preferences.h" #define noRECT_VERBOSE +//#define OBJECT_TRACE SPRect::SPRect() : SPShape() { } @@ -39,6 +37,10 @@ SPRect::~SPRect() { } void SPRect::build(SPDocument* doc, Inkscape::XML::Node* repr) { +#ifdef OBJECT_TRACE + objectTrace( "SPRect::build" ); +#endif + SPShape::build(doc, repr); this->readAttr("x"); @@ -47,9 +49,20 @@ void SPRect::build(SPDocument* doc, Inkscape::XML::Node* repr) { this->readAttr("height"); this->readAttr("rx"); this->readAttr("ry"); + +#ifdef OBJECT_TRACE + objectTrace( "SPRect::build", false ); +#endif } void SPRect::set(unsigned key, gchar const *value) { + +#ifdef OBJECT_TRACE + std::stringstream temp; + temp << "SPRect::set: " << key << " " << (value?value:"null"); + objectTrace( temp.str() ); +#endif + /* fixme: We need real error processing some time */ // We must update the SVGLengths immediately or nodes may be misplaced after they are moved. @@ -107,9 +120,17 @@ void SPRect::set(unsigned key, gchar const *value) { SPShape::set(key, value); break; } +#ifdef OBJECT_TRACE + objectTrace( "SPRect::set", false ); +#endif } void SPRect::update(SPCtx* ctx, unsigned int flags) { + +#ifdef OBJECT_TRACE + objectTrace( "SPRect::update", true, flags ); +#endif + if (flags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) { SPItemCtx const *ictx = reinterpret_cast<SPItemCtx const *>(ctx); @@ -130,9 +151,17 @@ void SPRect::update(SPCtx* ctx, unsigned int flags) { } SPShape::update(ctx, flags); +#ifdef OBJECT_TRACE + objectTrace( "SPRect::update", false, flags ); +#endif } Inkscape::XML::Node * SPRect::write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) { + +#ifdef OBJECT_TRACE + objectTrace( "SPRect::write", true, flags ); +#endif + if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) { repr = xml_doc->createElement("svg:rect"); } @@ -154,6 +183,10 @@ Inkscape::XML::Node * SPRect::write(Inkscape::XML::Document *xml_doc, Inkscape:: this->set_shape(); // evaluate SPCurve SPShape::write(xml_doc, repr, flags); +#ifdef OBJECT_TRACE + objectTrace( "SPRect::write", false, flags ); +#endif + return repr; } diff --git a/src/sp-root.cpp b/src/sp-root.cpp index 98eae2159..34047054a 100644 --- a/src/sp-root.cpp +++ b/src/sp-root.cpp @@ -73,9 +73,9 @@ void SPRoot::build(SPDocument *document, Inkscape::XML::Node *repr) SPGroup::build(document, repr); // Search for first <defs> node - for (SPObject *o = this->firstChild() ; o ; o = o->getNext()) { - if (SP_IS_DEFS(o)) { - this->defs = SP_DEFS(o); + for (auto& o: children) { + if (SP_IS_DEFS(&o)) { + this->defs = SP_DEFS(&o); break; } } @@ -174,9 +174,9 @@ void SPRoot::child_added(Inkscape::XML::Node *child, Inkscape::XML::Node *ref) if (co && SP_IS_DEFS(co)) { // We search for first <defs> node - it is not beautiful, but works - for (SPObject *c = this->firstChild() ; c ; c = c->getNext()) { - if (SP_IS_DEFS(c)) { - this->defs = SP_DEFS(c); + for (auto& c: children) { + if (SP_IS_DEFS(&c)) { + this->defs = SP_DEFS(&c); break; } } @@ -189,7 +189,8 @@ void SPRoot::remove_child(Inkscape::XML::Node *child) SPObject *iter = 0; // We search for first remaining <defs> node - it is not beautiful, but works - for (iter = this->firstChild() ; iter ; iter = iter->getNext()) { + for (auto& child: children) { + iter = &child; if (SP_IS_DEFS(iter) && (SPDefs *)iter != this->defs) { this->defs = (SPDefs *)iter; break; diff --git a/src/sp-script.cpp b/src/sp-script.cpp index f1ea9c9bd..bd1ab512b 100644 --- a/src/sp-script.cpp +++ b/src/sp-script.cpp @@ -13,8 +13,6 @@ #include "sp-script.h" #include "attributes.h" -#include <cstring> -#include "document.h" SPScript::SPScript() : SPObject() { this->xlinkhref = NULL; diff --git a/src/sp-shape.cpp b/src/sp-shape.cpp index 78135d459..acec00024 100644 --- a/src/sp-shape.cpp +++ b/src/sp-shape.cpp @@ -15,21 +15,19 @@ */ #ifdef HAVE_CONFIG_H -# include "config.h" +#include <config.h> #endif #include <2geom/rect.h> #include <2geom/transforms.h> #include <2geom/pathvector.h> #include <2geom/path-intersection.h> -#include <2geom/exception.h> #include "helper/geom.h" #include "helper/geom-nodetype.h" #include <sigc++/functors/ptr_fun.h> #include <sigc++/adaptors/bind.h> -#include "macros.h" #include "display/drawing-shape.h" #include "display/curve.h" #include "print.h" @@ -41,11 +39,6 @@ #include "attributes.h" #include "live_effects/lpeobject.h" -#include "uri.h" -#include "extract-uri.h" -#include "uri-references.h" -#include "bad-uri-exception.h" -#include "xml/repr.h" #include "helper/mathfns.h" // for triangle_area() diff --git a/src/sp-solid-color.cpp b/src/sp-solid-color.cpp index f319410b0..89858c18c 100644 --- a/src/sp-solid-color.cpp +++ b/src/sp-solid-color.cpp @@ -14,10 +14,6 @@ #include "attributes.h" #include "style.h" -#include "xml/repr.h" - -#include "sp-item.h" -#include "style-internal.h" /* diff --git a/src/sp-spiral.cpp b/src/sp-spiral.cpp index 5dbd7dfa0..57eb918fe 100644 --- a/src/sp-spiral.cpp +++ b/src/sp-spiral.cpp @@ -14,8 +14,6 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include "config.h" - #include "svg/svg.h" #include "attributes.h" diff --git a/src/sp-star.cpp b/src/sp-star.cpp index 8a1956e3b..d112962a2 100644 --- a/src/sp-star.cpp +++ b/src/sp-star.cpp @@ -14,7 +14,7 @@ */ #ifdef HAVE_CONFIG_H -# include "config.h" +#include <config.h> #endif #include <cstring> @@ -28,8 +28,6 @@ #include "xml/repr.h" #include "document.h" -#include <2geom/pathvector.h> - #include "sp-star.h" SPStar::SPStar() : SPPolygon() , diff --git a/src/sp-stop.cpp b/src/sp-stop.cpp index 5e8fed86c..58746c951 100644 --- a/src/sp-stop.cpp +++ b/src/sp-stop.cpp @@ -22,7 +22,6 @@ #include "svg/svg.h" #include "svg/svg-color.h" #include "svg/css-ostringstream.h" -#include "xml/repr.h" SPStop::SPStop() : SPObject() { this->path_string = NULL; @@ -115,6 +114,7 @@ void SPStop::set(unsigned int key, const gchar* value) { // std::cout << "Got Curve" << std::endl; //curve->unref(); //} + this->requestModified(SP_OBJECT_MODIFIED_FLAG); } break; } diff --git a/src/sp-string.cpp b/src/sp-string.cpp index 26bb44006..0a959abea 100644 --- a/src/sp-string.cpp +++ b/src/sp-string.cpp @@ -25,10 +25,6 @@ #include "sp-string.h" #include "style.h" -#include "xml/repr.h" - -#include <iostream> - /*##################################################### # SPSTRING #####################################################*/ diff --git a/src/sp-style-elem-test.h b/src/sp-style-elem-test.h deleted file mode 100644 index 6f65a48ea..000000000 --- a/src/sp-style-elem-test.h +++ /dev/null @@ -1,166 +0,0 @@ -#ifndef SEEN_SP_STYLE_ELEM_TEST_H -#define SEEN_SP_STYLE_ELEM_TEST_H - -#include <cxxtest/TestSuite.h> - -#include "test-helpers.h" - -#include "sp-style-elem.h" -#include "xml/repr.h" - -class SPStyleElemTest : public CxxTest::TestSuite -{ -public: - SPDocument* _doc; - - SPStyleElemTest() : - _doc(0) - { - } - - virtual ~SPStyleElemTest() - { - if ( _doc ) - { - _doc->doUnref(); - } - } - - static void createSuiteSubclass( SPStyleElemTest *& dst ) - { - SPStyleElem *style_elem = new SPStyleElem(); - - if ( style_elem ) { - TS_ASSERT(!style_elem->is_css); - TS_ASSERT(style_elem->media.print); - TS_ASSERT(style_elem->media.screen); - delete style_elem; - - dst = new SPStyleElemTest(); - } - } - - static SPStyleElemTest *createSuite() - { - return Inkscape::createSuiteAndDocument<SPStyleElemTest>( createSuiteSubclass ); - } - - static void destroySuite( SPStyleElemTest *suite ) { delete suite; } - -// ------------------------------------------------------------------------- -// ------------------------------------------------------------------------- - - - void testSetType() - { - SPStyleElem *style_elem = new SPStyleElem(); - SP_OBJECT(style_elem)->document = _doc; - - SP_OBJECT(style_elem)->setKeyValue( SP_ATTR_TYPE, "something unrecognized"); - TS_ASSERT( !style_elem->is_css ); - - SP_OBJECT(style_elem)->setKeyValue( SP_ATTR_TYPE, "text/css"); - TS_ASSERT( style_elem->is_css ); - - SP_OBJECT(style_elem)->setKeyValue( SP_ATTR_TYPE, "atext/css"); - TS_ASSERT( !style_elem->is_css ); - - SP_OBJECT(style_elem)->setKeyValue( SP_ATTR_TYPE, "text/cssx"); - TS_ASSERT( !style_elem->is_css ); - - delete style_elem; - } - - void testWrite() - { - TS_ASSERT( _doc ); - TS_ASSERT( _doc->getReprDoc() ); - if ( !_doc->getReprDoc() ) { - return; // evil early return - } - - SPStyleElem *style_elem = new SPStyleElem(); - SP_OBJECT(style_elem)->document = _doc; - - SP_OBJECT(style_elem)->setKeyValue( SP_ATTR_TYPE, "text/css"); - Inkscape::XML::Node *repr = _doc->getReprDoc()->createElement("svg:style"); - SP_OBJECT(style_elem)->updateRepr(_doc->getReprDoc(), repr, SP_OBJECT_WRITE_ALL); - { - gchar const *typ = repr->attribute("type"); - TS_ASSERT( typ != NULL ); - if ( typ ) - { - TS_ASSERT_EQUALS( std::string(typ), std::string("text/css") ); - } - } - - delete style_elem; - } - - void testBuild() - { - TS_ASSERT( _doc ); - TS_ASSERT( _doc->getReprDoc() ); - if ( !_doc->getReprDoc() ) { - return; // evil early return - } - - SPStyleElem *style_elem = new SPStyleElem(); - Inkscape::XML::Node *const repr = _doc->getReprDoc()->createElement("svg:style"); - repr->setAttribute("type", "text/css"); - style_elem->invoke_build( _doc, repr, false); - TS_ASSERT( style_elem->is_css ); - TS_ASSERT( style_elem->media.print ); - TS_ASSERT( style_elem->media.screen ); - - /* Some checks relevant to the read_content test below. */ - { - g_assert(_doc->style_cascade); - CRStyleSheet const *const stylesheet = cr_cascade_get_sheet(_doc->style_cascade, ORIGIN_AUTHOR); - g_assert(stylesheet); - g_assert(stylesheet->statements == NULL); - } - - delete style_elem; - Inkscape::GC::release(repr); - } - - void testReadContent() - { - TS_ASSERT( _doc ); - TS_ASSERT( _doc->getReprDoc() ); - if ( !_doc->getReprDoc() ) { - return; // evil early return - } - - SPStyleElem *style_elem = new SPStyleElem(); - Inkscape::XML::Node *const repr = _doc->getReprDoc()->createElement("svg:style"); - repr->setAttribute("type", "text/css"); - Inkscape::XML::Node *const content_repr = _doc->getReprDoc()->createTextNode(".myclass { }"); - repr->addChild(content_repr, NULL); - style_elem->invoke_build(_doc, repr, false); - TS_ASSERT( style_elem->is_css ); - TS_ASSERT( _doc->style_cascade ); - CRStyleSheet const *const stylesheet = cr_cascade_get_sheet(_doc->style_cascade, ORIGIN_AUTHOR); - TS_ASSERT(stylesheet != NULL); - TS_ASSERT(stylesheet->statements != NULL); - - delete style_elem; - Inkscape::GC::release(repr); - } - -}; - - -#endif // SEEN_SP_STYLE_ELEM_TEST_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/sp-switch.cpp b/src/sp-switch.cpp index d2dcde15d..d6ab1e904 100644 --- a/src/sp-switch.cpp +++ b/src/sp-switch.cpp @@ -18,7 +18,6 @@ #include "display/drawing-group.h" #include "conditions.h" -#include <sigc++/functors/ptr_fun.h> #include <sigc++/adaptors/bind.h> SPSwitch::SPSwitch() : SPGroup() { @@ -32,9 +31,10 @@ SPSwitch::~SPSwitch() { SPObject *SPSwitch::_evaluateFirst() { SPObject *first = 0; - for (SPObject *child = this->firstChild() ; child && !first ; child = child->getNext() ) { - if (SP_IS_ITEM(child) && sp_item_evaluate(SP_ITEM(child))) { - first = child; + for (auto& child: children) { + if (SP_IS_ITEM(&child) && sp_item_evaluate(SP_ITEM(&child))) { + first = &child; + break; } } diff --git a/src/sp-symbol.cpp b/src/sp-symbol.cpp index 62fb232a3..55b5101af 100644 --- a/src/sp-symbol.cpp +++ b/src/sp-symbol.cpp @@ -12,10 +12,9 @@ */ #ifdef HAVE_CONFIG_H -# include "config.h" +#include <config.h> #endif -#include <cstring> #include <string> #include <2geom/transforms.h> diff --git a/src/sp-tag-use-reference.cpp b/src/sp-tag-use-reference.cpp index 9fcb31fd1..cca24ed85 100644 --- a/src/sp-tag-use-reference.cpp +++ b/src/sp-tag-use-reference.cpp @@ -8,12 +8,9 @@ #include <cstring> #include <string> -#include <string.h> -#include "enums.h" #include "sp-tag-use-reference.h" -#include "display/curve.h" #include "livarot/Path.h" #include "preferences.h" #include "sp-shape.h" diff --git a/src/sp-text.cpp b/src/sp-text.cpp index 4afc38524..b066ca3de 100644 --- a/src/sp-text.cpp +++ b/src/sp-text.cpp @@ -29,17 +29,14 @@ #include <glibmm/i18n.h> #include "svg/svg.h" -#include "svg/stringstream.h" #include "display/drawing-text.h" #include "attributes.h" #include "document.h" #include "preferences.h" #include "desktop.h" #include "sp-namedview.h" -#include "style.h" #include "inkscape.h" #include "xml/quote.h" -#include "xml/repr.h" #include "mod360.h" #include "sp-title.h" #include "sp-desc.h" @@ -52,9 +49,7 @@ #include "text-editing.h" // For SVG 2 text flow -#include "livarot/Path.h" #include "livarot/Shape.h" -#include "sp-shape.h" #include "display/curve.h" /*##################################################### @@ -98,14 +93,16 @@ void SPText::set(unsigned int key, const gchar* value) { } else { switch (key) { case SP_ATTR_SODIPODI_LINESPACING: - // convert deprecated tag to css - if (value) { + // convert deprecated tag to css... but only if 'line-height' missing. + if (value && !this->style->line_height.set) { this->style->line_height.set = TRUE; this->style->line_height.inherit = FALSE; this->style->line_height.normal = FALSE; this->style->line_height.unit = SP_CSS_UNIT_PERCENT; this->style->line_height.value = this->style->line_height.computed = sp_svg_read_percentage (value, 1.0); } + // Remove deprecated attribute + this->getRepr()->setAttribute("sodipodi:linespacing", NULL); this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_TEXT_LAYOUT_MODIFIED_FLAG); break; @@ -155,9 +152,9 @@ void SPText::update(SPCtx *ctx, guint flags) { // Create temporary list of children GSList *l = NULL; - for (SPObject *child = this->firstChild() ; child ; child = child->getNext() ) { - sp_object_ref(child, this); - l = g_slist_prepend (l, child); + for (auto& child: children) { + sp_object_ref(&child, this); + l = g_slist_prepend (l, &child); } l = g_slist_reverse (l); @@ -235,9 +232,9 @@ void SPText::modified(guint flags) { // Create temporary list of children GSList *l = NULL; - for (SPObject *child = this->firstChild() ; child ; child = child->getNext() ) { - sp_object_ref(child, this); - l = g_slist_prepend (l, child); + for (auto& child: children) { + sp_object_ref(&child, this); + l = g_slist_prepend (l, &child); } l = g_slist_reverse (l); @@ -262,17 +259,17 @@ Inkscape::XML::Node *SPText::write(Inkscape::XML::Document *xml_doc, Inkscape::X GSList *l = NULL; - for (SPObject *child = this->firstChild() ; child ; child = child->getNext() ) { - if (SP_IS_TITLE(child) || SP_IS_DESC(child)) { + for (auto& child: children) { + if (SP_IS_TITLE(&child) || SP_IS_DESC(&child)) { continue; } Inkscape::XML::Node *crepr = NULL; - if (SP_IS_STRING(child)) { - crepr = xml_doc->createTextNode(SP_STRING(child)->string.c_str()); + if (SP_IS_STRING(&child)) { + crepr = xml_doc->createTextNode(SP_STRING(&child)->string.c_str()); } else { - crepr = child->updateRepr(xml_doc, NULL, flags); + crepr = child.updateRepr(xml_doc, NULL, flags); } if (crepr) { @@ -286,15 +283,15 @@ Inkscape::XML::Node *SPText::write(Inkscape::XML::Document *xml_doc, Inkscape::X l = g_slist_remove (l, l->data); } } else { - for (SPObject *child = this->firstChild() ; child ; child = child->getNext() ) { - if (SP_IS_TITLE(child) || SP_IS_DESC(child)) { + for (auto& child: children) { + if (SP_IS_TITLE(&child) || SP_IS_DESC(&child)) { continue; } - if (SP_IS_STRING(child)) { - child->getRepr()->setContent(SP_STRING(child)->string.c_str()); + if (SP_IS_STRING(&child)) { + child.getRepr()->setContent(SP_STRING(&child)->string.c_str()); } else { - child->updateRepr(flags); + child.updateRepr(flags); } } } @@ -302,15 +299,6 @@ Inkscape::XML::Node *SPText::write(Inkscape::XML::Document *xml_doc, Inkscape::X this->attributes.writeTo(repr); this->rebuildLayout(); // copied from update(), see LP Bug 1339305 - // deprecated attribute, but keep it around for backwards compatibility - if (this->style->line_height.set && !this->style->line_height.inherit && !this->style->line_height.normal && this->style->line_height.unit == SP_CSS_UNIT_PERCENT) { - Inkscape::SVGOStringStream os; - os << (this->style->line_height.value * 100.0) << "%"; - this->getRepr()->setAttribute("sodipodi:linespacing", os.str().c_str()); - } else { - this->getRepr()->setAttribute("sodipodi:linespacing", NULL); - } - // SVG 2 Auto-wrapped text if( this->width.computed > 0.0 ) { sp_repr_set_svg_double(repr, "width", this->width.computed); @@ -606,16 +594,16 @@ unsigned SPText::_buildLayoutInput(SPObject *root, Inkscape::Text::Layout::Optio } } - for (SPObject *child = root->firstChild() ; child ; child = child->getNext() ) { - SPString *str = dynamic_cast<SPString *>(child); + for (auto& child: root->children) { + SPString *str = dynamic_cast<SPString *>(&child); if (str) { Glib::ustring const &string = str->string; // std::cout << " Appending: >" << string << "<" << std::endl; - layout.appendText(string, root->style, child, &optional_attrs, child_attrs_offset + length); + layout.appendText(string, root->style, &child, &optional_attrs, child_attrs_offset + length); length += string.length(); - } else if (!sp_repr_is_meta_element(child->getRepr())) { + } else if (!sp_repr_is_meta_element(child.getRepr())) { /* ^^^^ XML Tree being directly used here while it shouldn't be.*/ - length += _buildLayoutInput(child, optional_attrs, child_attrs_offset + length, in_textpath); + length += _buildLayoutInput(&child, optional_attrs, child_attrs_offset + length, in_textpath); } } @@ -628,9 +616,9 @@ void SPText::rebuildLayout() Inkscape::Text::Layout::OptionalTextTagAttrs optional_attrs; _buildLayoutInput(this, optional_attrs, 0, false); layout.calculateFlow(); - for (SPObject *child = firstChild() ; child ; child = child->getNext() ) { - if (SP_IS_TEXTPATH(child)) { - SPTextPath const *textpath = SP_TEXTPATH(child); + for (auto& child: children) { + if (SP_IS_TEXTPATH(&child)) { + SPTextPath const *textpath = SP_TEXTPATH(&child); if (textpath->originalPath != NULL) { //g_print("%s", layout.dumpAsText().c_str()); layout.fitToPathAlign(textpath->startOffset, *textpath->originalPath); @@ -640,9 +628,9 @@ void SPText::rebuildLayout() //g_print("%s", layout.dumpAsText().c_str()); // set the x,y attributes on role:line spans - for (SPObject *child = firstChild() ; child ; child = child->getNext() ) { - if (SP_IS_TSPAN(child)) { - SPTSpan *tspan = SP_TSPAN(child); + for (auto& child: children) { + if (SP_IS_TSPAN(&child)) { + SPTSpan *tspan = SP_TSPAN(&child); if ( (tspan->role != SP_TSPAN_ROLE_UNSPECIFIED) && tspan->attributes.singleXYCoordinates() ) { Inkscape::Text::Layout::iterator iter = layout.sourceToIterator(tspan); @@ -676,9 +664,9 @@ void SPText::_adjustFontsizeRecursive(SPItem *item, double ex, bool is_root) item->updateRepr(); } - for (SPObject *o = item->children; o != NULL; o = o->next) { - if (SP_IS_ITEM(o)) - _adjustFontsizeRecursive(SP_ITEM(o), ex, false); + for(auto& o: item->children) { + if (SP_IS_ITEM(&o)) + _adjustFontsizeRecursive(SP_ITEM(&o), ex, false); } } @@ -695,9 +683,9 @@ void SPText::_adjustCoordsRecursive(SPItem *item, Geom::Affine const &m, double SP_TREF(item)->attributes.transform(m, ex, ex, is_root); } - for (SPObject *o = item->children; o != NULL; o = o->next) { - if (SP_IS_ITEM(o)) - _adjustCoordsRecursive(SP_ITEM(o), m, ex, false); + for(auto& o: item->children) { + if (SP_IS_ITEM(&o)) + _adjustCoordsRecursive(SP_ITEM(&o), m, ex, false); } } diff --git a/src/sp-tref-reference.cpp b/src/sp-tref-reference.cpp index 7c6ff00e7..dfb8dd60b 100644 --- a/src/sp-tref-reference.cpp +++ b/src/sp-tref-reference.cpp @@ -13,8 +13,6 @@ #include "sp-text.h" #include "sp-tref.h" -#include "sp-tspan.h" - bool SPTRefReference::_acceptObject(SPObject * const obj) const diff --git a/src/sp-tref.cpp b/src/sp-tref.cpp index ba592058b..e25ddb5a4 100644 --- a/src/sp-tref.cpp +++ b/src/sp-tref.cpp @@ -22,14 +22,9 @@ #include "document.h" #include "sp-factory.h" #include "sp-text.h" -#include "sp-tspan.h" #include "sp-tref.h" #include "style.h" #include "text-editing.h" -#include "uri.h" - -#include "xml/node.h" -#include "xml/repr.h" //#define DEBUG_TREF #ifdef DEBUG_TREF @@ -506,9 +501,9 @@ sp_tref_convert_to_tspan(SPObject *obj) //////////////////// else { GSList *l = NULL; - for (SPObject *child = obj->firstChild() ; child != NULL ; child = child->getNext() ) { - sp_object_ref(child, obj); - l = g_slist_prepend (l, child); + for (auto& child: obj->children) { + sp_object_ref(&child, obj); + l = g_slist_prepend (l, &child); } l = g_slist_reverse (l); while (l) { diff --git a/src/sp-tspan.cpp b/src/sp-tspan.cpp index 05f8430ba..2e169ad77 100644 --- a/src/sp-tspan.cpp +++ b/src/sp-tspan.cpp @@ -24,7 +24,7 @@ */ #ifdef HAVE_CONFIG_H -# include "config.h" +#include <config.h> #endif #include <cstring> @@ -40,9 +40,7 @@ #include "sp-textpath.h" #include "text-editing.h" #include "style.h" -#include "xml/repr.h" #include "document.h" -#include "2geom/transforms.h" /*##################################################### # SPTSPAN @@ -96,9 +94,9 @@ void SPTSpan::update(SPCtx *ctx, guint flags) { } childflags &= SP_OBJECT_MODIFIED_CASCADE; - for ( SPObject *ochild = this->firstChild() ; ochild ; ochild = ochild->getNext() ) { - if ( flags || ( ochild->uflags & SP_OBJECT_MODIFIED_FLAG )) { - ochild->updateDisplay(ctx, childflags); + for (auto& ochild: children) { + if ( flags || ( ochild.uflags & SP_OBJECT_MODIFIED_FLAG )) { + ochild.updateDisplay(ctx, childflags); } } @@ -128,9 +126,9 @@ void SPTSpan::modified(unsigned int flags) { flags &= SP_OBJECT_MODIFIED_CASCADE; - for ( SPObject *ochild = this->firstChild() ; ochild ; ochild = ochild->getNext() ) { - if (flags || (ochild->mflags & SP_OBJECT_MODIFIED_FLAG)) { - ochild->emitModified(flags); + for (auto& ochild: children) { + if (flags || (ochild.mflags & SP_OBJECT_MODIFIED_FLAG)) { + ochild.emitModified(flags); } } } @@ -175,15 +173,15 @@ Inkscape::XML::Node* SPTSpan::write(Inkscape::XML::Document *xml_doc, Inkscape:: if ( flags&SP_OBJECT_WRITE_BUILD ) { GSList *l = NULL; - for (SPObject* child = this->firstChild() ; child ; child = child->getNext() ) { + for (auto& child: children) { Inkscape::XML::Node* c_repr=NULL; - if ( SP_IS_TSPAN(child) || SP_IS_TREF(child) ) { - c_repr = child->updateRepr(xml_doc, NULL, flags); - } else if ( SP_IS_TEXTPATH(child) ) { - //c_repr = child->updateRepr(xml_doc, NULL, flags); // shouldn't happen - } else if ( SP_IS_STRING(child) ) { - c_repr = xml_doc->createTextNode(SP_STRING(child)->string.c_str()); + if ( SP_IS_TSPAN(&child) || SP_IS_TREF(&child) ) { + c_repr = child.updateRepr(xml_doc, NULL, flags); + } else if ( SP_IS_TEXTPATH(&child) ) { + //c_repr = child.updateRepr(xml_doc, NULL, flags); // shouldn't happen + } else if ( SP_IS_STRING(&child) ) { + c_repr = xml_doc->createTextNode(SP_STRING(&child)->string.c_str()); } if ( c_repr ) { @@ -197,13 +195,13 @@ Inkscape::XML::Node* SPTSpan::write(Inkscape::XML::Document *xml_doc, Inkscape:: l = g_slist_remove(l, l->data); } } else { - for (SPObject* child = this->firstChild() ; child ; child = child->getNext() ) { - if ( SP_IS_TSPAN(child) || SP_IS_TREF(child) ) { - child->updateRepr(flags); - } else if ( SP_IS_TEXTPATH(child) ) { + for (auto& child: children) { + if ( SP_IS_TSPAN(&child) || SP_IS_TREF(&child) ) { + child.updateRepr(flags); + } else if ( SP_IS_TEXTPATH(&child) ) { //c_repr = child->updateRepr(xml_doc, NULL, flags); // shouldn't happen - } else if ( SP_IS_STRING(child) ) { - child->getRepr()->setContent(SP_STRING(child)->string.c_str()); + } else if ( SP_IS_STRING(&child) ) { + child.getRepr()->setContent(SP_STRING(&child)->string.c_str()); } } } @@ -313,9 +311,9 @@ void SPTextPath::update(SPCtx *ctx, guint flags) { flags &= SP_OBJECT_MODIFIED_CASCADE; - for ( SPObject *ochild = this->firstChild() ; ochild ; ochild = ochild->getNext() ) { - if ( flags || ( ochild->uflags & SP_OBJECT_MODIFIED_FLAG )) { - ochild->updateDisplay(ctx, flags); + for (auto& ochild: children) { + if ( flags || ( ochild.uflags & SP_OBJECT_MODIFIED_FLAG )) { + ochild.updateDisplay(ctx, flags); } } @@ -367,9 +365,9 @@ void SPTextPath::modified(unsigned int flags) { flags &= SP_OBJECT_MODIFIED_CASCADE; - for ( SPObject *ochild = this->firstChild() ; ochild ; ochild = ochild->getNext() ) { - if (flags || (ochild->mflags & SP_OBJECT_MODIFIED_FLAG)) { - ochild->emitModified(flags); + for (auto& ochild: children) { + if (flags || (ochild.mflags & SP_OBJECT_MODIFIED_FLAG)) { + ochild.emitModified(flags); } } } @@ -399,15 +397,15 @@ Inkscape::XML::Node* SPTextPath::write(Inkscape::XML::Document *xml_doc, Inkscap if ( flags & SP_OBJECT_WRITE_BUILD ) { GSList *l = NULL; - for (SPObject* child = this->firstChild() ; child ; child = child->getNext() ) { + for (auto& child: children) { Inkscape::XML::Node* c_repr=NULL; - if ( SP_IS_TSPAN(child) || SP_IS_TREF(child) ) { - c_repr = child->updateRepr(xml_doc, NULL, flags); - } else if ( SP_IS_TEXTPATH(child) ) { + if ( SP_IS_TSPAN(&child) || SP_IS_TREF(&child) ) { + c_repr = child.updateRepr(xml_doc, NULL, flags); + } else if ( SP_IS_TEXTPATH(&child) ) { //c_repr = child->updateRepr(xml_doc, NULL, flags); // shouldn't happen - } else if ( SP_IS_STRING(child) ) { - c_repr = xml_doc->createTextNode(SP_STRING(child)->string.c_str()); + } else if ( SP_IS_STRING(&child) ) { + c_repr = xml_doc->createTextNode(SP_STRING(&child)->string.c_str()); } if ( c_repr ) { @@ -421,13 +419,13 @@ Inkscape::XML::Node* SPTextPath::write(Inkscape::XML::Document *xml_doc, Inkscap l = g_slist_remove(l, l->data); } } else { - for (SPObject* child = this->firstChild() ; child ; child = child->getNext() ) { - if ( SP_IS_TSPAN(child) || SP_IS_TREF(child) ) { - child->updateRepr(flags); - } else if ( SP_IS_TEXTPATH(child) ) { - //c_repr = child->updateRepr(xml_doc, NULL, flags); // shouldn't happen - } else if ( SP_IS_STRING(child) ) { - child->getRepr()->setContent(SP_STRING(child)->string.c_str()); + for (auto& child: children) { + if ( SP_IS_TSPAN(&child) || SP_IS_TREF(&child) ) { + child.updateRepr(flags); + } else if ( SP_IS_TEXTPATH(&child) ) { + //c_repr = child.updateRepr(xml_doc, NULL, flags); // shouldn't happen + } else if ( SP_IS_STRING(&child) ) { + child.getRepr()->setContent(SP_STRING(&child)->string.c_str()); } } } @@ -466,8 +464,8 @@ void sp_textpath_to_text(SPObject *tp) // make a list of textpath children GSList *tp_reprs = NULL; - for (SPObject *o = tp->firstChild() ; o != NULL; o = o->next) { - tp_reprs = g_slist_prepend(tp_reprs, o->getRepr()); + for (auto& o: tp->children) { + tp_reprs = g_slist_prepend(tp_reprs, o.getRepr()); } for ( GSList *i = tp_reprs ; i ; i = i->next ) { diff --git a/src/sp-use-reference.cpp b/src/sp-use-reference.cpp index f0b2985d2..3dd63df40 100644 --- a/src/sp-use-reference.cpp +++ b/src/sp-use-reference.cpp @@ -9,7 +9,6 @@ #include <cstring> #include <string> -#include <string.h> #include "enums.h" #include "sp-use-reference.h" @@ -21,8 +20,6 @@ #include "sp-text.h" #include "uri.h" - - bool SPUseReference::_acceptObject(SPObject * const obj) const { return URIReference::_acceptObject(obj); diff --git a/src/sp-use.cpp b/src/sp-use.cpp index c8a0830c1..6ba03dad9 100644 --- a/src/sp-use.cpp +++ b/src/sp-use.cpp @@ -34,7 +34,6 @@ #include "style.h" #include "sp-symbol.h" #include "sp-root.h" -#include "sp-use.h" #include "sp-use-reference.h" #include "sp-shape.h" #include "sp-text.h" @@ -436,27 +435,23 @@ void SPUse::move_compensate(Geom::Affine const *mp) { //BUT move clippaths accordingly. //if clone has a clippath, move it accordingly if(clip_ref->getObject()){ - SPObject *clip = clip_ref->getObject()->firstChild() ; - while(clip){ - SPItem *item = (SPItem*) clip; + for(auto& clip: clip_ref->getObject()->children){ + SPItem *item = (SPItem*) &clip; if(item){ item->transform *= m; Geom::Affine identity; - item->doWriteTransform(clip->getRepr(),item->transform, &identity); + item->doWriteTransform(clip.getRepr(),item->transform, &identity); } - clip = clip->getNext(); } } if(mask_ref->getObject()){ - SPObject *mask = mask_ref->getObject()->firstChild() ; - while(mask){ - SPItem *item = (SPItem*) mask; + for(auto& mask: mask_ref->getObject()->children){ + SPItem *item = (SPItem*) &mask; if(item){ item->transform *= m; Geom::Affine identity; - item->doWriteTransform(mask->getRepr(),item->transform, &identity); + item->doWriteTransform(mask.getRepr(),item->transform, &identity); } - mask = mask->getNext(); } } return; @@ -480,27 +475,23 @@ void SPUse::move_compensate(Geom::Affine const *mp) { //if clone has a clippath, move it accordingly if(clip_ref->getObject()){ - SPObject *clip = clip_ref->getObject()->firstChild() ; - while(clip){ - SPItem *item = (SPItem*) clip; + for(auto& clip: clip_ref->getObject()->children){ + SPItem *item = (SPItem*) &clip; if(item){ item->transform *= clone_move.inverse(); Geom::Affine identity; - item->doWriteTransform(clip->getRepr(),item->transform, &identity); + item->doWriteTransform(clip.getRepr(),item->transform, &identity); } - clip = clip->getNext(); } } if(mask_ref->getObject()){ - SPObject *mask = mask_ref->getObject()->firstChild() ; - while(mask){ - SPItem *item = (SPItem*) mask; + for(auto& mask: mask_ref->getObject()->children){ + SPItem *item = (SPItem*) &mask; if(item){ item->transform *= clone_move.inverse(); Geom::Affine identity; - item->doWriteTransform(mask->getRepr(),item->transform, &identity); + item->doWriteTransform(mask.getRepr(),item->transform, &identity); } - mask = mask->getNext(); } } diff --git a/src/splivarot.cpp b/src/splivarot.cpp index a8018f6c2..6b9fd5f83 100644 --- a/src/splivarot.cpp +++ b/src/splivarot.cpp @@ -13,7 +13,6 @@ */ #ifdef HAVE_CONFIG_H -# include <config.h> #endif #include <cstring> @@ -23,14 +22,11 @@ #include "xml/repr.h" #include "svg/svg.h" #include "sp-path.h" -#include "sp-shape.h" #include "sp-image.h" #include "sp-marker.h" -#include "enums.h" #include "sp-text.h" #include "sp-flowtext.h" #include "text-editing.h" -#include "sp-item-group.h" #include "style.h" #include "document.h" #include "document-undo.h" @@ -38,15 +34,9 @@ #include "message-stack.h" #include "selection.h" -#include "desktop.h" -#include "display/canvas-bpath.h" -#include "display/curve.h" #include <glibmm/i18n.h> -#include "preferences.h" -#include "xml/repr.h" #include "xml/repr-sorting.h" -#include <2geom/pathvector.h> #include <2geom/svg-path-writer.h> #include "helper/geom.h" @@ -57,65 +47,96 @@ #include "verbs.h" #include "2geom/svg-path-parser.h" // to get from SVG on boolean to Geom::Path +enum BoolOpErrors { + DONE, + DONE_NO_PATH, + DONE_NO_ACTION, + ERR_TOO_LESS_PATHS_1, + ERR_TOO_LESS_PATHS_2, + ERR_NO_PATHS, + ERR_Z_ORDER +}; + using Inkscape::DocumentUndo; bool Ancetre(Inkscape::XML::Node *a, Inkscape::XML::Node *who); -void sp_selected_path_boolop(Inkscape::Selection *selection, SPDesktop *desktop, bool_op bop, const unsigned int verb=SP_VERB_NONE, const Glib::ustring description=""); +void sp_selected_path_boolop_ui(Inkscape::Selection *selection, SPDesktop *desktop, bool_op bop, + const unsigned int verb = SP_VERB_NONE, const Glib::ustring description = ""); +BoolOpErrors sp_selected_path_boolop(Inkscape::ObjectSet *set, bool_op bop); void sp_selected_path_do_offset(SPDesktop *desktop, bool expand, double prefOffset); void sp_selected_path_create_offset_object(SPDesktop *desktop, int expand, bool updating); void sp_selected_path_union(Inkscape::Selection *selection, SPDesktop *desktop) { - sp_selected_path_boolop(selection, desktop, bool_op_union, SP_VERB_SELECTION_UNION, _("Union")); + sp_selected_path_boolop_ui(selection, desktop, bool_op_union, SP_VERB_SELECTION_UNION, _("Union")); } void -sp_selected_path_union_skip_undo(Inkscape::Selection *selection, SPDesktop *desktop) +sp_selected_path_union_skip_undo(Inkscape::ObjectSet *set) { - sp_selected_path_boolop(selection, desktop, bool_op_union, SP_VERB_NONE, _("Union")); + sp_selected_path_boolop(set, bool_op_union); } void sp_selected_path_intersect(Inkscape::Selection *selection, SPDesktop *desktop) { - sp_selected_path_boolop(selection, desktop, bool_op_inters, SP_VERB_SELECTION_INTERSECT, _("Intersection")); + sp_selected_path_boolop_ui(selection, desktop, bool_op_inters, SP_VERB_SELECTION_INTERSECT, _("Intersection")); +} + +void +sp_selected_path_intersect_skip_undo(Inkscape::ObjectSet *set) +{ + sp_selected_path_boolop(set, bool_op_inters); } void sp_selected_path_diff(Inkscape::Selection *selection, SPDesktop *desktop) { - sp_selected_path_boolop(selection, desktop, bool_op_diff, SP_VERB_SELECTION_DIFF, _("Difference")); + sp_selected_path_boolop_ui(selection, desktop, bool_op_diff, SP_VERB_SELECTION_DIFF, _("Difference")); } void -sp_selected_path_diff_skip_undo(Inkscape::Selection *selection, SPDesktop *desktop) +sp_selected_path_diff_skip_undo(Inkscape::ObjectSet *set) { - sp_selected_path_boolop(selection, desktop, bool_op_diff, SP_VERB_NONE, _("Difference")); + sp_selected_path_boolop(set, bool_op_diff); } void sp_selected_path_symdiff(Inkscape::Selection *selection, SPDesktop *desktop) { - sp_selected_path_boolop(selection, desktop, bool_op_symdiff, SP_VERB_SELECTION_SYMDIFF, _("Exclusion")); + sp_selected_path_boolop_ui(selection, desktop, bool_op_symdiff, SP_VERB_SELECTION_SYMDIFF, _("Exclusion")); +} + +void +sp_selected_path_symdiff_skip_undo(Inkscape::ObjectSet *set) +{ + sp_selected_path_boolop(set, bool_op_symdiff); } + void sp_selected_path_cut(Inkscape::Selection *selection, SPDesktop *desktop) { - sp_selected_path_boolop(selection, desktop, bool_op_cut, SP_VERB_SELECTION_CUT, _("Division")); + sp_selected_path_boolop_ui(selection, desktop, bool_op_cut, SP_VERB_SELECTION_CUT, _("Division")); } void -sp_selected_path_cut_skip_undo(Inkscape::Selection *selection, SPDesktop *desktop) +sp_selected_path_cut_skip_undo(Inkscape::ObjectSet *set) { - sp_selected_path_boolop(selection, desktop, bool_op_cut, SP_VERB_NONE, _("Division")); + sp_selected_path_boolop(set, bool_op_cut); } void sp_selected_path_slice(Inkscape::Selection *selection, SPDesktop *desktop) { - sp_selected_path_boolop(selection, desktop, bool_op_slice, SP_VERB_SELECTION_SLICE, _("Cut path")); + sp_selected_path_boolop_ui(selection, desktop, bool_op_slice, SP_VERB_SELECTION_SLICE, _("Cut path")); +} + +void +sp_selected_path_slice_skip_undo(Inkscape::ObjectSet *set) +{ + sp_selected_path_boolop(set, bool_op_slice); } // helper for printing error messages, regardless of whether we have a GUI or not @@ -331,20 +352,17 @@ Geom::PathVector pathliv_to_pathvector(Path *pathliv){ // boolean operations on the desktop // take the source paths from the file, do the operation, delete the originals and add the results -void -sp_selected_path_boolop(Inkscape::Selection *selection, SPDesktop *desktop, bool_op bop, const unsigned int verb, const Glib::ustring description) +BoolOpErrors sp_selected_path_boolop(Inkscape::ObjectSet * set, bool_op bop) { - SPDocument *doc = selection->layers()->getDocument(); - std::vector<SPItem*> il= selection->itemList(); - + SPDocument *doc = set->desktop()->getDocument(); + std::vector<SPItem*> il(set->items().begin(), set->items().end()); + // allow union on a single object for the purpose of removing self overlapse (svn log, revision 13334) - if ( (il.size() < 2) && (bop != bool_op_union)) { - boolop_display_error_message(desktop, _("Select <b>at least 2 paths</b> to perform a boolean operation.")); - return; + if (il.size() < 2 && bop != bool_op_union) { + return ERR_TOO_LESS_PATHS_2; } - else if ( il.size() < 1 ) { - boolop_display_error_message(desktop, _("Select <b>at least 1 path</b> to perform a boolean union.")); - return; + else if (il.size() < 1) { + return ERR_TOO_LESS_PATHS_1; } g_assert(!il.empty()); @@ -360,8 +378,7 @@ sp_selected_path_boolop(Inkscape::Selection *selection, SPDesktop *desktop, bool Inkscape::XML::Node *b = il.back()->getRepr(); if (a == NULL || b == NULL) { - boolop_display_error_message(desktop, _("Unable to determine the <b>z-order</b> of the objects selected for difference, XOR, division, or path cut.")); - return; + return ERR_Z_ORDER; } if (Ancetre(a, b)) { @@ -375,8 +392,7 @@ sp_selected_path_boolop(Inkscape::Selection *selection, SPDesktop *desktop, bool // find their lowest common ancestor Inkscape::XML::Node *parent = LCA(a, b); if (parent == NULL) { - boolop_display_error_message(desktop, _("Unable to determine the <b>z-order</b> of the objects selected for difference, XOR, division, or path cut.")); - return; + return ERR_Z_ORDER; } // find the children of the LCA that lead from it to the a and b @@ -405,8 +421,7 @@ sp_selected_path_boolop(Inkscape::Selection *selection, SPDesktop *desktop, bool SPItem *item = *l; if (!SP_IS_SHAPE(item) && !SP_IS_TEXT(item) && !SP_IS_FLOWTEXT(item)) { - boolop_display_error_message(desktop, _("One of the objects is <b>not a path</b>, cannot perform boolean operation.")); - return; + return ERR_NO_PATHS; } } @@ -439,7 +454,7 @@ sp_selected_path_boolop(Inkscape::Selection *selection, SPDesktop *desktop, bool if (originaux[curOrig] == NULL || originaux[curOrig]->descr_cmd.size() <= 1) { for (int i = curOrig; i >= 0; i--) delete originaux[i]; - return; + return DONE_NO_ACTION; } curOrig++; } @@ -500,18 +515,18 @@ sp_selected_path_boolop(Inkscape::Selection *selection, SPDesktop *desktop, bool bool zeroA = theShapeA->numberOfEdges() == 0; bool zeroB = theShapeB->numberOfEdges() == 0; if (zeroA || zeroB) { - // We might need to do a swap. Apply the above rules depending on operation type. - bool resultIsB = ((bop == bool_op_union || bop == bool_op_symdiff) && zeroA) - || ((bop == bool_op_inters) && zeroB) - || (bop == bool_op_diff); + // We might need to do a swap. Apply the above rules depending on operation type. + bool resultIsB = ((bop == bool_op_union || bop == bool_op_symdiff) && zeroA) + || ((bop == bool_op_inters) && zeroB) + || (bop == bool_op_diff); if (resultIsB) { - // Swap A and B to use B as the result + // Swap A and B to use B as the result Shape *swap = theShapeB; theShapeB = theShapeA; theShapeA = swap; } } else { - // Just do the Boolean operation as usual + // Just do the Boolean operation as usual // les elements arrivent en ordre inverse dans la liste theShape->Booleen(theShapeB, theShapeA, bop); Shape *swap = theShape; @@ -672,24 +687,23 @@ sp_selected_path_boolop(Inkscape::Selection *selection, SPDesktop *desktop, bool for (std::vector<SPItem*>::const_iterator l = il.begin(); l != il.end(); l++){ (*l)->deleteObject(); } - DocumentUndo::done(doc, SP_VERB_NONE, description); - selection->clear(); + set->clear(); delete res; - return; + return DONE_NO_PATH; } // get the source path object SPObject *source; if ( bop == bool_op_diff || bop == bool_op_cut || bop == bool_op_slice ) { if (reverseOrderForOp) { - source = il[0]; + source = il[0]; } else { - source = il.back(); + source = il.back(); } } else { // find out the bottom object - std::vector<Inkscape::XML::Node*> sorted(selection->reprList()); + std::vector<Inkscape::XML::Node*> sorted(set->xmlNodes().begin(), set->xmlNodes().end()); sort(sorted.begin(),sorted.end(),sp_repr_compare_position_bool); @@ -717,7 +731,7 @@ sp_selected_path_boolop(Inkscape::Selection *selection, SPDesktop *desktop, bool gchar *title = source->title(); gchar *desc = source->desc(); // remove source paths - selection->clear(); + set->clear(); for (std::vector<SPItem*>::const_iterator l = il.begin(); l != il.end(); l++){ // if this is the bottommost object, if (!strcmp(reinterpret_cast<SPObject *>(*l)->getRepr()->attribute("id"), id)) { @@ -796,7 +810,7 @@ sp_selected_path_boolop(Inkscape::Selection *selection, SPDesktop *desktop, bool // move to the saved position repr->setPosition(pos > 0 ? pos : 0); - selection->add(repr); + set->add(doc->getObjectByRepr(repr)); Inkscape::GC::release(repr); delete resPath[i]; @@ -824,14 +838,14 @@ sp_selected_path_boolop(Inkscape::Selection *selection, SPDesktop *desktop, bool repr->setAttribute("id", id); parent->appendChild(repr); if (title) { - doc->getObjectByRepr(repr)->setTitle(title); - } + doc->getObjectByRepr(repr)->setTitle(title); + } if (desc) { - doc->getObjectByRepr(repr)->setDesc(desc); + doc->getObjectByRepr(repr)->setDesc(desc); } - repr->setPosition(pos > 0 ? pos : 0); + repr->setPosition(pos > 0 ? pos : 0); - selection->add(repr); + set->add(doc->getObjectByRepr(repr)); Inkscape::GC::release(repr); } @@ -839,18 +853,46 @@ sp_selected_path_boolop(Inkscape::Selection *selection, SPDesktop *desktop, bool if (title) g_free(title); if (desc) g_free(desc); - if (verb != SP_VERB_NONE) { - DocumentUndo::done(doc, verb, description); - } - delete res; + + return DONE; +} + +void sp_selected_path_boolop_ui(Inkscape::Selection *selection, SPDesktop *desktop, bool_op bop, const unsigned int verb, + const Glib::ustring description) +{ + SPDocument *doc = selection->desktop()->getDocument(); + BoolOpErrors returnCode = sp_selected_path_boolop(selection, bop); + switch(returnCode) { + case ERR_TOO_LESS_PATHS_1: + boolop_display_error_message(desktop, _("Select <b>at least 1 path</b> to perform a boolean union.")); + return; + case ERR_TOO_LESS_PATHS_2: + boolop_display_error_message(desktop, _("Select <b>at least 2 paths</b> to perform a boolean operation.")); + return; + case ERR_NO_PATHS: + boolop_display_error_message(desktop, _("One of the objects is <b>not a path</b>, cannot perform boolean operation.")); + return; + case ERR_Z_ORDER: + boolop_display_error_message(desktop, _("Unable to determine the <b>z-order</b> of the objects selected for difference, XOR, division, or path cut.")); + return; + case DONE_NO_PATH: + DocumentUndo::done(doc, SP_VERB_NONE, description); + return; + case DONE: + DocumentUndo::done(doc, verb, description); + return; + case DONE_NO_ACTION: + default: + return; + } } static void sp_selected_path_outline_add_marker( SPObject *marker_object, Geom::Affine marker_transform, Geom::Scale stroke_scale, Geom::Affine transform, Inkscape::XML::Node *g_repr, Inkscape::XML::Document *xml_doc, SPDocument * doc, - SPDesktop *desktop ) + SPDesktop *desktop , bool legacy) { SPMarker* marker = SP_MARKER (marker_object); SPItem* marker_item = sp_item_first_item_child(marker_object); @@ -874,7 +916,9 @@ void sp_selected_path_outline_add_marker( SPObject *marker_object, Geom::Affine m_repr->setPosition(0); SPItem *marker_item = (SPItem *) doc->getObjectByRepr(m_repr); marker_item->doWriteTransform(m_repr, tr); - sp_item_path_outline(marker_item, desktop); + if (!legacy) { + sp_item_path_outline(marker_item, desktop, legacy); + } } } @@ -887,9 +931,9 @@ void item_outline_add_marker_child( SPItem const *item, Geom::Affine marker_tran // note: a marker child item can be an item group! if (SP_IS_GROUP(item)) { // recurse through all childs: - for (SPObject const *o = item->firstChild() ; o ; o = o->getNext() ) { - if ( SP_IS_ITEM(o) ) { - item_outline_add_marker_child(SP_ITEM(o), tr, pathv_in); + for (auto& o: item->children) { + if ( SP_IS_ITEM(&o) ) { + item_outline_add_marker_child(SP_ITEM(&o), tr, pathv_in); } } } else { @@ -1149,20 +1193,26 @@ Geom::PathVector* item_outline(SPItem const *item, bool bbox_only) } bool -sp_item_path_outline(SPItem *item, SPDesktop *desktop) +sp_item_path_outline(SPItem *item, SPDesktop *desktop, bool legacy) { bool did = false; Inkscape::Selection *selection = desktop->getSelection(); + SPDocument * doc = desktop->getDocument(); + Inkscape::XML::Document *xml_doc = doc->getReprDoc(); SPLPEItem *lpeitem = SP_LPE_ITEM(item); if (lpeitem) { lpeitem->removeAllPathEffects(true); } + SPGroup *group = dynamic_cast<SPGroup *>(item); if (group) { + if (legacy) { + return false; + } std::vector<SPItem*> const item_list = sp_item_group_item_list(group); for ( std::vector<SPItem*>::const_iterator iter=item_list.begin();iter!=item_list.end();++iter) { SPItem *subitem = *iter; - sp_item_path_outline(subitem, desktop); + sp_item_path_outline(subitem, desktop, legacy); } } else { if (!SP_IS_SHAPE(item) && !SP_IS_TEXT(item)) @@ -1374,8 +1424,6 @@ sp_item_path_outline(SPItem *item, SPDesktop *desktop) } if (SP_IS_SHAPE(item)) { - SPDocument * doc = desktop->getDocument(); - Inkscape::XML::Document *xml_doc = doc->getReprDoc(); Inkscape::XML::Node *g_repr = xml_doc->createElement("svg:g"); // add the group to the parent @@ -1384,23 +1432,24 @@ sp_item_path_outline(SPItem *item, SPDesktop *desktop) g_repr->setPosition(pos > 0 ? pos : 0); //The fill - Inkscape::XML::Node *fill = NULL; - gchar const *f_val = sp_repr_css_property(ncsf, "fill", NULL); - if (f_val) { - fill = xml_doc->createElement("svg:path"); - sp_repr_css_change(fill, ncsf, "style"); - - sp_repr_css_attr_unref(ncsf); - - gchar *str = sp_svg_write_path( pathv ); - fill->setAttribute("d", str); - g_free(str); - - if (mask) - fill->setAttribute("mask", mask); - if (clip_path) - fill->setAttribute("clip-path", clip_path); + if (!legacy) { + gchar const *f_val = sp_repr_css_property(ncsf, "fill", NULL); + if( !item->style->fill.noneSet ){ + fill = xml_doc->createElement("svg:path"); + sp_repr_css_change(fill, ncsf, "style"); + + sp_repr_css_attr_unref(ncsf); + + gchar *str = sp_svg_write_path( pathv ); + fill->setAttribute("d", str); + g_free(str); + + if (mask) + fill->setAttribute("mask", mask); + if (clip_path) + fill->setAttribute("clip-path", clip_path); + } } // restore title, description, id, transform g_repr->setAttribute("id", id); @@ -1412,22 +1461,25 @@ sp_item_path_outline(SPItem *item, SPDesktop *desktop) if (desc) { newitem->setDesc(desc); } - SPShape *shape = SP_SHAPE(item); Geom::PathVector const & pathv = curve->get_pathvector(); Inkscape::XML::Node *markers = NULL; if(SP_SHAPE(item)->hasMarkers ()) { - markers = xml_doc->createElement("svg:g"); - g_repr->appendChild(markers); - markers->setPosition(pos > 0 ? pos : 0); + if (!legacy) { + markers = xml_doc->createElement("svg:g"); + g_repr->appendChild(markers); + markers->setPosition(pos > 0 ? pos : 0); + } else { + markers = g_repr; + } // START marker for (int i = 0; i < 2; i++) { // SP_MARKER_LOC and SP_MARKER_LOC_START if ( SPObject *marker_obj = shape->_marker[i] ) { Geom::Affine const m (sp_shape_marker_get_transform_at_start(pathv.front().front())); sp_selected_path_outline_add_marker( marker_obj, m, Geom::Scale(i_style->stroke_width.computed), transform, - markers, xml_doc, doc, desktop ); + markers, xml_doc, doc, desktop, legacy); } } // MID marker @@ -1442,7 +1494,7 @@ sp_item_path_outline(SPItem *item, SPDesktop *desktop) Geom::Affine const m (sp_shape_marker_get_transform_at_start(path_it->front())); sp_selected_path_outline_add_marker( midmarker_obj, m, Geom::Scale(i_style->stroke_width.computed), transform, - markers, xml_doc, doc, desktop ); + markers, xml_doc, doc, desktop, legacy); } // MID position if (path_it->size_default() > 1) { @@ -1457,7 +1509,7 @@ sp_item_path_outline(SPItem *item, SPDesktop *desktop) Geom::Affine const m (sp_shape_marker_get_transform(*curve_it1, *curve_it2)); sp_selected_path_outline_add_marker( midmarker_obj, m, Geom::Scale(i_style->stroke_width.computed), transform, - markers, xml_doc, doc, desktop ); + markers, xml_doc, doc, desktop, legacy); ++curve_it1; ++curve_it2; @@ -1469,7 +1521,7 @@ sp_item_path_outline(SPItem *item, SPDesktop *desktop) Geom::Affine const m = sp_shape_marker_get_transform_at_end(lastcurve); sp_selected_path_outline_add_marker( midmarker_obj, m, Geom::Scale(i_style->stroke_width.computed), transform, - markers, xml_doc, doc, desktop ); + markers, xml_doc, doc, desktop, legacy); } } } @@ -1488,18 +1540,20 @@ sp_item_path_outline(SPItem *item, SPDesktop *desktop) Geom::Affine const m = sp_shape_marker_get_transform_at_end(lastcurve); sp_selected_path_outline_add_marker( marker_obj, m, Geom::Scale(i_style->stroke_width.computed), transform, - markers, xml_doc, doc, desktop ); + markers, xml_doc, doc, desktop, legacy); } } - if (mask) - markers->setAttribute("mask", mask); - if (clip_path) - markers->setAttribute("clip-path", clip_path); + if (!legacy) { + if (mask) + markers->setAttribute("mask", mask); + if (clip_path) + markers->setAttribute("clip-path", clip_path); + } } gchar const *paint_order = sp_repr_css_property(ncss, "paint-order", NULL); SPIPaintOrder temp; temp.read( paint_order ); - if (temp.layer[0] != SP_CSS_PAINT_ORDER_NORMAL) { + if (temp.layer[0] != SP_CSS_PAINT_ORDER_NORMAL && !legacy) { if (temp.layer[0] == SP_CSS_PAINT_ORDER_FILL) { if (temp.layer[1] == SP_CSS_PAINT_ORDER_STROKE) { @@ -1583,14 +1637,21 @@ sp_item_path_outline(SPItem *item, SPDesktop *desktop) if( fill || stroke || markers ) { did = true; } + Inkscape::XML::Node *out = NULL; if (!fill && !markers) { - g_repr = stroke; - } - if (!fill && !stroke) { - g_repr = markers; - } - if (!markers && !stroke) { - g_repr = fill; + out = stroke; + parent->mergeFrom(g_repr, ""); + parent->removeChild(g_repr); + } else if (!fill && !stroke) { + out = markers; + parent->mergeFrom(g_repr, ""); + parent->removeChild(g_repr); + } else if (!markers && !stroke) { + out = fill; + parent->mergeFrom(g_repr, ""); + parent->removeChild(g_repr); + } else { + out = g_repr; } //bug lp:1290573 : completely destroy the old object first @@ -1599,7 +1660,7 @@ sp_item_path_outline(SPItem *item, SPDesktop *desktop) if( selection->includes(item) ){ selection->remove(item); item->deleteObject(false); - selection->add(g_repr); + selection->add(out); } else { item->deleteObject(false); } @@ -1624,7 +1685,7 @@ sp_item_path_outline(SPItem *item, SPDesktop *desktop) } void -sp_selected_path_outline(SPDesktop *desktop) +sp_selected_path_outline(SPDesktop *desktop, bool legacy) { Inkscape::Selection *selection = desktop->getSelection(); @@ -1636,10 +1697,10 @@ sp_selected_path_outline(SPDesktop *desktop) bool scale_stroke = prefs->getBool("/options/transform/stroke", true); prefs->setBool("/options/transform/stroke", true); bool did = false; - std::vector<SPItem*> il(selection->itemList()); + std::vector<SPItem*> il(selection->items().begin(), selection->items().end()); for (std::vector<SPItem*>::const_iterator l = il.begin(); l != il.end(); l++){ SPItem *item = *l; - did = sp_item_path_outline(item, desktop); + did = sp_item_path_outline(item, desktop, legacy); } prefs->setBool("/options/transform/stroke", scale_stroke); @@ -1908,7 +1969,7 @@ sp_selected_path_do_offset(SPDesktop *desktop, bool expand, double prefOffset) } bool did = false; - std::vector<SPItem*> il(selection->itemList()); + std::vector<SPItem*> il(selection->items().begin(), selection->items().end()); for (std::vector<SPItem*>::const_iterator l = il.begin(); l != il.end(); l++){ SPItem *item = *l; SPCurve *curve = NULL; @@ -2333,7 +2394,7 @@ sp_selected_path_simplify_selection(SPDesktop *desktop, float threshold, bool ju return; } - std::vector<SPItem*> items(selection->itemList()); + std::vector<SPItem*> items(selection->items().begin(), selection->items().end()); bool didSomething = sp_selected_path_simplify_items(desktop, selection, items, threshold, diff --git a/src/splivarot.h b/src/splivarot.h index 3278956bf..6adc05946 100644 --- a/src/splivarot.h +++ b/src/splivarot.h @@ -17,6 +17,7 @@ class SPItem; namespace Inkscape { class Selection; + class ObjectSet; } // boolean operations @@ -27,14 +28,17 @@ namespace Inkscape { // command-line mode, i.e. without a desktop. If a desktop is not // provided (desktop == NULL), error messages will be shown on stderr. void sp_selected_path_union (Inkscape::Selection *selection, SPDesktop *desktop); -void sp_selected_path_union_skip_undo (Inkscape::Selection *selection, SPDesktop *desktop); +void sp_selected_path_union_skip_undo (Inkscape::ObjectSet *set); void sp_selected_path_intersect (Inkscape::Selection *selection, SPDesktop *desktop); +void sp_selected_path_intersect_skip_undo (Inkscape::ObjectSet *set); void sp_selected_path_diff (Inkscape::Selection *selection, SPDesktop *desktop); -void sp_selected_path_diff_skip_undo (Inkscape::Selection *selection, SPDesktop *desktop); +void sp_selected_path_diff_skip_undo (Inkscape::ObjectSet *set); void sp_selected_path_symdiff (Inkscape::Selection *selection, SPDesktop *desktop); +void sp_selected_path_symdiff_skip_undo (Inkscape::ObjectSet *set); void sp_selected_path_cut (Inkscape::Selection *selection, SPDesktop *desktop); -void sp_selected_path_cut_skip_undo (Inkscape::Selection *selection, SPDesktop *desktop); +void sp_selected_path_cut_skip_undo (Inkscape::ObjectSet *set); void sp_selected_path_slice (Inkscape::Selection *selection, SPDesktop *desktop); +void sp_selected_path_slice_skip_undo (Inkscape::ObjectSet *set); // offset/inset of a curve // takes the fill-rule in consideration @@ -53,8 +57,8 @@ void sp_selected_path_create_updating_offset_object_zero (SPDesktop *desktop); // outline of a curve // uses the stroke-width -void sp_selected_path_outline (SPDesktop *desktop); -bool sp_item_path_outline(SPItem *item, SPDesktop *desktop); +void sp_selected_path_outline (SPDesktop *desktop, bool legacy = false); +bool sp_item_path_outline(SPItem *item, SPDesktop *desktop, bool legacy); Geom::PathVector* item_outline(SPItem const *item, bool bbox_only = false); // simplifies a path (removes small segments and the like) diff --git a/src/style-internal.cpp b/src/style-internal.cpp index 62b0de52d..136a522f8 100644 --- a/src/style-internal.cpp +++ b/src/style-internal.cpp @@ -23,16 +23,14 @@ */ #ifdef HAVE_CONFIG_H -# include "config.h" +#include <config.h> #endif #include "style-internal.h" -#include "style-enums.h" #include "style.h" #include "svg/svg.h" #include "svg/svg-color.h" -#include "svg/svg-icc-color.h" #include "streq.h" #include "strneq.h" @@ -42,9 +40,6 @@ #include "svg/css-ostringstream.h" #include "util/units.h" -#include <sigc++/functors/ptr_fun.h> -#include <sigc++/adaptors/bind.h> - #include <glibmm/regex.h> // TODO REMOVE OR MAKE MEMBER FUNCTIONS diff --git a/src/style-test.h b/src/style-test.h deleted file mode 100644 index c6bb665e0..000000000 --- a/src/style-test.h +++ /dev/null @@ -1,537 +0,0 @@ -#ifndef SEEN_STYLE_TEST_H -#define SEEN_STYLE_TEST_H - -#include <cxxtest/TestSuite.h> - -#include "test-helpers.h" - -#include "style.h" - -class StyleTest : public CxxTest::TestSuite -{ -public: - SPDocument* _doc; - - StyleTest() : - _doc(0) - { - } - - virtual ~StyleTest() - { - if ( _doc ) - { - _doc->doUnref(); - _doc = 0; - } - } - - static void createSuiteSubclass( StyleTest*& dst ) - { - dst = new StyleTest(); - } - -// createSuite and destroySuite get us per-suite setup and teardown -// without us having to worry about static initialization order, etc. - static StyleTest *createSuite() - { - StyleTest* suite = Inkscape::createSuiteAndDocument<StyleTest>( createSuiteSubclass ); - return suite; - } - - static void destroySuite( StyleTest *suite ) - { - delete suite; - } - - // --------------------------------------------------------------- - // --------------------------------------------------------------- - // --------------------------------------------------------------- - - // Reading and writing style string - void testOne() - { - struct TestCase { - TestCase(gchar const* src, gchar const* dst = 0, gchar const* uri = 0) : src(src), dst(dst), uri(uri) {} - gchar const* src; - gchar const* dst; - gchar const* uri; - }; - - TestCase cases[] = { - TestCase("fill:none"), - TestCase("fill:currentColor"), - TestCase("fill:#ff00ff"), - - TestCase("fill:rgb(100%, 0%, 100%)", "fill:#ff00ff"), - // TODO - fix this to preserve the string - TestCase("fill:url(#painter) rgb(100%, 0%, 100%)", - "fill:url(#painter) #ff00ff", "#painter"), - - TestCase("fill:rgb(255, 0, 255)", "fill:#ff00ff"), - // TODO - fix this to preserve the string - TestCase("fill:url(#painter) rgb(255, 0, 255)", - "fill:url(#painter) #ff00ff", "#painter"), - - -// TestCase("fill:#ff00ff icc-color(colorChange, 0.1, 0.5, 0.1)"), - - TestCase("fill:url(#painter)", 0, "#painter"), - TestCase("fill:url(#painter) none", 0, "#painter"), - TestCase("fill:url(#painter) currentColor", 0, "#painter"), - TestCase("fill:url(#painter) #ff00ff", 0, "#painter"), -// TestCase("fill:url(#painter) rgb(100%, 0%, 100%)", 0, "#painter"), -// TestCase("fill:url(#painter) rgb(255, 0, 255)", 0, "#painter"), - - TestCase("fill:url(#painter) #ff00ff icc-color(colorChange, 0.1, 0.5, 0.1)", 0, "#painter"), - -// TestCase("fill:url(#painter) inherit", 0, "#painter"), - TestCase("fill:inherit"), - -// General tests (in general order of appearance in sp_style_read), SPIPaint tested above - TestCase("visibility:hidden"), // SPIEnum - TestCase("visibility:collapse"), - TestCase("visibility:visible"), - TestCase("display:none"), // SPIEnum - TestCase("overflow:visible"), // SPIEnum - TestCase("overflow:auto"), // SPIEnum - - TestCase("color:#ff0000"), - TestCase("color:blue", "color:#0000ff"), - // TestCase("color:currentColor"), SVG 1.1 does not allow color value 'currentColor' - - // Font shorthand - TestCase("font:bold 12px Arial", - "font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:12px;line-height:normal;font-family:Arial"), - TestCase("font:bold 12px/24px 'Times New Roman'", - "font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:12px;line-height:24px;font-family:\'Times New Roman\'"), - // From CSS 3 Fonts (examples): - TestCase("font: 12pt/15pt sans-serif", - "font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:16px;line-height:15pt;font-family:sans-serif"), - TestCase("font: 80% sans-serif", - "font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:80%;line-height:normal;font-family:sans-serif"), - TestCase("font: x-large/110% 'new century schoolbook', serif", - "font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:x-large;line-height:110%;font-family:\'new century schoolbook\', serif"), - TestCase("font: bold italic large Palatino, serif", - "font-style:italic;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:large;line-height:normal;font-family:Palatino, serif"), - TestCase("font: normal small-caps 120%/120% fantasy", - "font-style:normal;font-variant:small-caps;font-weight:normal;font-stretch:normal;font-size:120%;line-height:120%;font-family:fantasy"), - TestCase("font: condensed oblique 12pt 'Helvetica Neue', serif;", - "font-style:oblique;font-variant:normal;font-weight:normal;font-stretch:condensed;font-size:16px;line-height:normal;font-family:\'Helvetica Neue\', serif"), - - TestCase("font-family:sans-serif"), // SPIString, text_private - TestCase("font-family:Arial"), - // TestCase("font-variant:normal;font-stretch:normal;-inkscape-font-specification:Nimbus Roman No9 L Bold Italic"), - - // Needs to be fixed (quotes should be around each font-family): - TestCase("font-family:Georgia, 'Minion Web'","font-family:Georgia, \'Minion Web\'"), - TestCase("font-size:12", "font-size:12px"), // SPIFontSize - TestCase("font-size:12px"), - TestCase("font-size:12pt", "font-size:16px"), - TestCase("font-size:medium"), - TestCase("font-size:smaller"), - TestCase("font-style:italic"), // SPIEnum - TestCase("font-variant:small-caps"), // SPIEnum - TestCase("font-weight:100"), // SPIEnum - TestCase("font-weight:normal"), - TestCase("font-weight:bolder"), - TestCase("font-stretch:condensed"), // SPIEnum - - TestCase("font-variant-ligatures:none"), // SPILigatures - TestCase("font-variant-ligatures:normal"), - TestCase("font-variant-ligatures:no-common-ligatures"), - TestCase("font-variant-ligatures:discretionary-ligatures"), - TestCase("font-variant-ligatures:historical-ligatures"), - TestCase("font-variant-ligatures:no-contextual"), - TestCase("font-variant-ligatures:common-ligatures", "font-variant-ligatures:normal"), - TestCase("font-variant-ligatures:contextual", "font-variant-ligatures:normal"), - TestCase("font-variant-ligatures:no-common-ligatures historical-ligatures"), - TestCase("font-variant-ligatures:historical-ligatures no-contextual"), - TestCase("font-variant-position:normal"), - TestCase("font-variant-position:sub"), - TestCase("font-variant-position:super"), - TestCase("font-variant-caps:normal"), - TestCase("font-variant-caps:small-caps"), - TestCase("font-variant-caps:all-small-caps"), - TestCase("font-variant-numeric:normal"), - TestCase("font-variant-numeric:lining-nums"), - TestCase("font-variant-numeric:oldstyle-nums"), - TestCase("font-variant-numeric:proportional-nums"), - TestCase("font-variant-numeric:tabular-nums"), - TestCase("font-variant-numeric:diagonal-fractions"), - TestCase("font-variant-numeric:stacked-fractions"), - TestCase("font-variant-numeric:ordinal"), - TestCase("font-variant-numeric:slashed-zero"), - TestCase("font-variant-numeric:tabular-nums slashed-zero"), - TestCase("font-variant-numeric:tabular-nums proportional-nums", "font-variant-numeric:proportional-nums"), - - // Should be moved down - TestCase("text-indent:12em"), // SPILength? - TestCase("text-align:center"), // SPIEnum - - // SPITextDecoration - // The default value for 'text-decoration-color' is 'currentColor', but - // we cannot set the default to that value yet. (We need to switch - // SPIPaint to SPIColor and then add the ability to set default.) - // TestCase("text-decoration: underline", - // "text-decoration: underline;text-decoration-line: underline;text-decoration-color:currentColor"), - // TestCase("text-decoration: overline underline", - // "text-decoration: underline overline;text-decoration-line: underline overline;text-decoration-color:currentColor"), - - TestCase("text-decoration: underline wavy #0000ff", - "text-decoration: underline;text-decoration-line: underline;text-decoration-style:wavy;text-decoration-color:#0000ff"), - TestCase("text-decoration: double overline underline #ff0000", - "text-decoration: underline overline;text-decoration-line: underline overline;text-decoration-style:double;text-decoration-color:#ff0000"), - - // SPITextDecorationLine - TestCase("text-decoration-line: underline", - "text-decoration: underline;text-decoration-line: underline"), - - // SPITextDecorationStyle - TestCase("text-decoration-style:solid"), - TestCase("text-decoration-style:dotted"), - - // SPITextDecorationColor - TestCase("text-decoration-color:#ff00ff"), - - // Should be moved up - TestCase("line-height:24px"), // SPILengthOrNormal - TestCase("line-height:1.5"), - TestCase("letter-spacing:2px"), // SPILengthOrNormal - TestCase("word-spacing:2px"), // SPILengthOrNormal - TestCase("word-spacing:normal"), - TestCase("text-transform:lowercase"), // SPIEnum - // ... - TestCase("baseline-shift:baseline"), // SPIBaselineShift - TestCase("baseline-shift:sub"), - TestCase("baseline-shift:12.5%"), - TestCase("baseline-shift:2px"), - - TestCase("opacity:0.1"), // SPIScale24 - // ... - TestCase("stroke-width:2px"), // SPILength - TestCase("stroke-linecap:round"), // SPIEnum - TestCase("stroke-linejoin:round"), // SPIEnum - TestCase("stroke-miterlimit:4"), // SPIFloat - TestCase("marker:url(#Arrow)"), // SPIString - TestCase("marker-start:url(#Arrow)"), - TestCase("marker-mid:url(#Arrow)"), - TestCase("marker-end:url(#Arrow)"), - TestCase("stroke-opacity:0.5"), // SPIScale24 - TestCase("stroke-dasharray:0, 1, 0, 1"), // SPIDashArray - TestCase("stroke-dasharray:0 1 0 1","stroke-dasharray:0, 1, 0, 1"), - TestCase("stroke-dasharray:0 1 2 3","stroke-dasharray:0, 1, 2, 3"), - TestCase("stroke-dashoffset:13"), // SPILength - TestCase("stroke-dashoffset:10px"), - // ... - //TestCase("filter:url(#myfilter)"), // SPIFilter segfault in read - TestCase("filter:inherit"), - - TestCase("opacity:0.1;fill:#ff0000;stroke:#0000ff;stroke-width:2px"), - TestCase("opacity:0.1;fill:#ff0000;stroke:#0000ff;stroke-width:2px;stroke-dasharray:1, 2, 3, 4;stroke-dashoffset:15"), - - -#ifdef WITH_SVG2 - TestCase("paint-order:stroke"), // SPIPaintOrder - TestCase("paint-order:normal"), - TestCase("paint-order: markers stroke fill", "paint-order:markers stroke fill"), - -#endif - TestCase(0) - }; - - for ( gint i = 0; cases[i].src; i++ ) { - // std::cout << "Test one: " << i << std::endl; - SPStyle style(_doc); - style.mergeString( cases[i].src ); - if ( cases[i].uri ) { - TSM_ASSERT( cases[i].src, style.fill.value.href ); - if ( style.fill.value.href ) { - TS_ASSERT_EQUALS( style.fill.value.href->getURI()->toString(), std::string(cases[i].uri) ); - } - } else { - TS_ASSERT( !style.fill.value.href || !style.fill.value.href->getObject() ); - } - - std::string str0_set = style.write(SP_STYLE_FLAG_IFSET ); - - if ( cases[i].dst ) { - // std::cout << " " << str0_set << " " << std::string(cases[i].dst) << std::endl; - TS_ASSERT_EQUALS( str0_set, std::string(cases[i].dst) ); - } else { - // std::cout << " " << str0_set << " " << std::string(cases[i].src) << std::endl; - TS_ASSERT_EQUALS( str0_set, std::string(cases[i].src) ); - } - } - } - - // Testing operator== - void testTwo() - { - struct TestCase { - TestCase(gchar const* src, gchar const* dst, bool match) : - src(src), dst(dst), match(match) {} - gchar const* src; - gchar const* dst; - bool match; - }; - - TestCase cases[] = { - - // SPIFloat - TestCase("stroke-miterlimit:4", "stroke-miterlimit:4", true ), - TestCase("stroke-miterlimit:4", "stroke-miterlimit:2", false), - TestCase("stroke-miterlimit:4", "", true ), // Default - - // SPIScale24 - TestCase("opacity:0.3", "opacity:0.3", true ), - TestCase("opacity:0.3", "opacity:0.6", false), - TestCase("opacity:1.0", "", true ), // Default - - // SPILength - TestCase("text-indent:3", "text-indent:3", true ), - TestCase("text-indent:6", "text-indent:3", false), - TestCase("text-indent:6px", "text-indent:3", false), - TestCase("text-indent:1px", "text-indent:12pc", false), - TestCase("text-indent:2ex", "text-indent:2ex", false), - - // SPILengthOrNormal - TestCase("letter-spacing:normal", "letter-spacing:normal", true ), - TestCase("letter-spacing:2", "letter-spacing:normal", false), - TestCase("letter-spacing:normal", "letter-spacing:2", false), - TestCase("letter-spacing:5px", "letter-spacing:5px", true ), - TestCase("letter-spacing:10px", "letter-spacing:5px", false), - TestCase("letter-spacing:10em", "letter-spacing:10em", false), - - // SPIEnum - TestCase("text-anchor:start", "text-anchor:start", true ), - TestCase("text-anchor:start", "text-anchor:middle", false), - TestCase("text-anchor:start", "", true ), // Default - TestCase("text-anchor:start", "text-anchor:junk", true ), // Bad value - - TestCase("font-weight:normal", "font-weight:400", true ), - TestCase("font-weight:bold", "font-weight:700", true ), - - - // SPIString and SPIFontString - TestCase("font-family:Arial", "font-family:Arial", true ), - TestCase("font-family:A B", "font-family:A B", true ), - TestCase("font-family:A B", "font-family:A C", false), - // Default is not set by class... value is NULL which cannot be compared - // TestCase("font-family:sans-serif", "", true ), // Default - - // SPIColor - TestCase("color:blue", "color:blue", true ), - TestCase("color:blue", "color:red", false), - TestCase("color:red", "color:#ff0000", true ), - - // SPIPaint - TestCase("fill:blue", "fill:blue", true ), - TestCase("fill:blue", "fill:red", false), - TestCase("fill:currentColor", "fill:currentColor", true ), - TestCase("fill:url(#xxx)", "fill:url(#xxx)", true ), - // Needs URL defined as in test 1 - //TestCase("fill:url(#xxx)", "fill:url(#yyy)", false), - - // SPIPaintOrder - TestCase("paint-order:markers", "paint-order:markers", true ), - TestCase("paint-order:markers", "paint-order:stroke", false), - //TestCase("paint-order:fill stroke markers", "", true ), // Default - TestCase("paint-order:normal", "paint-order:normal", true ), - //TestCase("paint-order:fill stroke markers", "paint-order:normal", true ), - - // SPIDashArray - TestCase("stroke-dasharray:0 1 2 3","stroke-dasharray:0 1 2 3",true ), - TestCase("stroke-dasharray:0 1", "stroke-dasharray:0 2", false), - - // SPIFilter - - // SPIFontSize - TestCase("font-size:12px", "font-size:12px", true ), - TestCase("font-size:12px", "font-size:24px", false), - TestCase("font-size:12ex", "font-size:24ex", false), - TestCase("font-size:medium", "font-size:medium", true ), - TestCase("font-size:medium", "font-size:large", false), - - // SPIBaselineShift - TestCase("baseline-shift:baseline", "baseline-shift:baseline", true ), - TestCase("baseline-shift:sub", "baseline-shift:sub", true ), - TestCase("baseline-shift:sub", "baseline-shift:super", false), - TestCase("baseline-shift:baseline", "baseline-shift:sub", false), - TestCase("baseline-shift:10px", "baseline-shift:10px", true ), - TestCase("baseline-shift:10px", "baseline-shift:12px", false), - - - // SPITextDecorationLine - TestCase("text-decoration-line:underline", "text-decoration-line:underline", true ), - TestCase("text-decoration-line:underline", "text-decoration-line:overline", false), - TestCase("text-decoration-line:underline overline", "text-decoration-line:underline overline", true ), - TestCase("text-decoration-line:none", "", true ), // Default - - - // SPITextDecorationStyle - TestCase("text-decoration-style:solid", "text-decoration-style:solid", true ), - TestCase("text-decoration-style:dotted", "text-decoration-style:solid", false), - TestCase("text-decoration-style:solid", "", true ), // Default - - // SPITextDecoration - TestCase("text-decoration:underline", "text-decoration:underline", true ), - TestCase("text-decoration:underline", "text-decoration:overline", false), - TestCase("text-decoration:underline overline","text-decoration:underline overline",true ), - TestCase("text-decoration:overline underline","text-decoration:underline overline",true ), - // TestCase("text-decoration:none", "text-decoration-color:currentColor", true ), // Default - - - // Terminate - TestCase(0,0,0) - }; - for ( gint i = 0; cases[i].src; i++ ) { - // std::cout << "Test two: " << i << std::endl; - SPStyle style_src(_doc); - SPStyle style_dst(_doc); - - style_src.mergeString( cases[i].src ); - style_dst.mergeString( cases[i].dst ); - - // std::cout << "Test:" << std::endl; - // std::cout << " C: |" << cases[i].src << "| |" << cases[i].dst << "|" << std::endl; - // std::cout << " S: |" << style_src.write( SP_STYLE_FLAG_IFSET, NULL ) << "| |" - // << style_dst.write( SP_STYLE_FLAG_IFSET, NULL ) << "|" <<std::endl; - TS_ASSERT( (style_src == style_dst) == cases[i].match ); - // std::cout << "End Test\n" << std::endl; - } - } - - - // Test of cascade - void testThree() - { - struct TestCase { - TestCase(gchar const* parent, gchar const* child, gchar const* result) : - parent(parent), child(child), result(result) {} - gchar const* parent; - gchar const* child; - gchar const* result; - }; - - TestCase cases[] = { - - // SPIFloat - TestCase("stroke-miterlimit:6", "stroke-miterlimit:2", "stroke-miterlimit:2" ), - TestCase("stroke-miterlimit:6", "", "stroke-miterlimit:6" ), - TestCase("", "stroke-miterlimit:2", "stroke-miterlimit:2" ), - - // SPIScale24 - TestCase("opacity:0.3", "opacity:0.3", "opacity:0.3" ), - TestCase("opacity:0.3", "opacity:0.6", "opacity:0.6" ), - // 'opacity' does not inherit - TestCase("opacity:0.3", "", "opacity:1.0" ), - TestCase("", "opacity:0.3", "opacity:0.3" ), - TestCase("opacity:0.5", "opacity:inherit", "opacity:0.5" ), - TestCase("", "", "opacity:1.0" ), - - // SPILength - TestCase("text-indent:3", "text-indent:3", "text-indent:3" ), - TestCase("text-indent:6", "text-indent:3", "text-indent:3" ), - TestCase("text-indent:6px", "text-indent:3", "text-indent:3" ), - TestCase("text-indent:1px", "text-indent:12pc", "text-indent:12pc" ), - // ex, em cannot be equal - //TestCase("text-indent:2ex", "text-indent:2ex", "text-indent:2ex" ), - TestCase("text-indent:3", "", "text-indent:3" ), - TestCase("text-indent:3", "text-indent:inherit", "text-indent:3" ), - - // SPILengthOrNormal - TestCase("letter-spacing:normal", "letter-spacing:normal", "letter-spacing:normal" ), - TestCase("letter-spacing:2", "letter-spacing:normal", "letter-spacing:normal" ), - TestCase("letter-spacing:normal", "letter-spacing:2", "letter-spacing:2" ), - TestCase("letter-spacing:5px", "letter-spacing:5px", "letter-spacing:5px" ), - TestCase("letter-spacing:10px", "letter-spacing:5px", "letter-spacing:5px" ), - // ex, em cannot be equal - // TestCase("letter-spacing:10em", "letter-spacing:10em", "letter-spacing:10em" ), - - // SPIEnum - TestCase("text-anchor:start", "text-anchor:start", "text-anchor:start" ), - TestCase("text-anchor:start", "text-anchor:middle", "text-anchor:middle" ), - TestCase("text-anchor:start", "", "text-anchor:start" ), - TestCase("text-anchor:start", "text-anchor:junk", "text-anchor:start" ), - TestCase("text-anchor:end", "text-anchor:inherit", "text-anchor:end" ), - - TestCase("font-weight:400", "font-weight:400", "font-weight:400" ), - TestCase("font-weight:400", "font-weight:700", "font-weight:700" ), - TestCase("font-weight:400", "font-weight:bolder", "font-weight:700" ), - TestCase("font-weight:700", "font-weight:bolder", "font-weight:900" ), - TestCase("font-weight:400", "font-weight:lighter", "font-weight:100" ), - TestCase("font-weight:200", "font-weight:lighter", "font-weight:100" ), - - TestCase("font-stretch:condensed","font-stretch:expanded", "font-stretch:expanded" ), - TestCase("font-stretch:condensed","font-stretch:wider", "font-stretch:semi-condensed" ), - - // SPIString and SPIFontString - - // SPIPaint - - // SPIPaintOrder - - // SPIDashArray - - // SPIFilter - - // SPIFontSize - - // SPIBaselineShift - - - // SPITextDecorationLine - TestCase("text-decoration-line:overline", "text-decoration-line:underline", - "text-decoration-line:underline" ), - - // SPITextDecorationStyle - - // SPITextDecoration - - // Terminate - TestCase(0,0,0) - }; - for ( gint i = 0; cases[i].parent; i++ ) { - // std::cout << "Test three: " << i << std::endl; - SPStyle style_parent(_doc); - SPStyle style_child( _doc); - SPStyle style_result(_doc); - - style_parent.mergeString( cases[i].parent ); - style_child.mergeString( cases[i].child ); - style_result.mergeString( cases[i].result ); - - // std::cout << "Test:" << std::endl; - // std::cout << " Input: "; - // std::cout << " Parent: " << cases[i].parent - // << " Child: " << cases[i].child - // << " Result: " << cases[i].result << std::endl; - // std::cout << " Write: "; - // std::cout << " Parent: " << style_parent.write( SP_STYLE_FLAG_IFSET ) - // << " Child: " << style_child.write( SP_STYLE_FLAG_IFSET ) - // << " Result: " << style_result.write( SP_STYLE_FLAG_IFSET ) << std::endl; - - style_child.cascade( &style_parent ); - - TS_ASSERT(style_child == style_result ); - - // std::cout << "End Test: *************\n" << std::endl; - } - } - -}; - - -#endif // SEEN_STYLE_TEST_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/style.cpp b/src/style.cpp index c24818f2a..930e271ad 100644 --- a/src/style.cpp +++ b/src/style.cpp @@ -20,7 +20,7 @@ */ #ifdef HAVE_CONFIG_H -# include "config.h" +#include <config.h> #endif #include <cstring> @@ -31,33 +31,19 @@ #include "xml/croco-node-iface.h" #include "svg/svg.h" -#include "svg/svg-color.h" -#include "svg/svg-icc-color.h" #include "display/canvas-bpath.h" #include "attributes.h" #include "document.h" -#include "extract-uri.h" #include "uri-references.h" #include "uri.h" #include "sp-paint-server.h" -#include "streq.h" -#include "strneq.h" #include "style.h" #include "svg/css-ostringstream.h" -#include "xml/repr.h" #include "xml/simple-document.h" #include "util/units.h" -#include "macros.h" #include "preferences.h" -#include "sp-filter-reference.h" - -#include <sigc++/functors/ptr_fun.h> -#include <sigc++/adaptors/bind.h> - -#include <2geom/math-utils.h> - #include <glibmm/regex.h> using Inkscape::CSSOStringStream; @@ -124,7 +110,7 @@ SPStyle::SPStyle(SPDocument *document_in, SPObject *object_in) : font_variant_caps( "font-variant-caps", enum_font_variant_caps, SP_CSS_FONT_VARIANT_CAPS_NORMAL ), font_variant_numeric( "font-variant-numeric", enum_font_variant_numeric ), font_variant_alternates("font-variant-alternates", enum_font_variant_alternates, SP_CSS_FONT_VARIANT_ALTERNATES_NORMAL ), - font_variant_east_asian("font-variant-east_asian", enum_font_variant_east_asian, SP_CSS_FONT_VARIANT_EAST_ASIAN_NORMAL ), + font_variant_east_asian("font-variant-east-asian", enum_font_variant_east_asian, SP_CSS_FONT_VARIANT_EAST_ASIAN_NORMAL ), font_feature_settings( "font-feature-settings", "normal" ), // Text related properties diff --git a/src/svg-view-widget.cpp b/src/svg-view-widget.cpp index b1fddd7e6..7c72686b4 100644 --- a/src/svg-view-widget.cpp +++ b/src/svg-view-widget.cpp @@ -27,7 +27,6 @@ static void sp_svg_view_widget_dispose(GObject *object); static void sp_svg_view_widget_size_allocate (GtkWidget *widget, GtkAllocation *allocation); static void sp_svg_view_widget_size_request (GtkWidget *widget, GtkRequisition *req); -#if GTK_CHECK_VERSION(3,0,0) static void sp_svg_view_widget_get_preferred_width(GtkWidget *widget, gint *minimal_width, gint *natural_width); @@ -35,7 +34,6 @@ static void sp_svg_view_widget_get_preferred_width(GtkWidget *widget, static void sp_svg_view_widget_get_preferred_height(GtkWidget *widget, gint *minimal_height, gint *natural_height); -#endif static void sp_svg_view_widget_view_resized (SPViewWidget *vw, Inkscape::UI::View::View *view, gdouble width, gdouble height); @@ -53,12 +51,8 @@ static void sp_svg_view_widget_class_init(SPSVGSPViewWidgetClass *klass) object_class->dispose = sp_svg_view_widget_dispose; widget_class->size_allocate = sp_svg_view_widget_size_allocate; -#if GTK_CHECK_VERSION(3,0,0) widget_class->get_preferred_width = sp_svg_view_widget_get_preferred_width; widget_class->get_preferred_height = sp_svg_view_widget_get_preferred_height; -#else - widget_class->size_request = sp_svg_view_widget_size_request; -#endif vw_class->view_resized = sp_svg_view_widget_view_resized; } @@ -83,16 +77,10 @@ static void sp_svg_view_widget_init(SPSVGSPViewWidget *vw) gtk_widget_show (vw->sw); /* Canvas */ -#if !GTK_CHECK_VERSION(3,0,0) - GdkColormap *cmap = gdk_colormap_get_system(); - gtk_widget_push_colormap(cmap); -#endif - vw->canvas = SPCanvas::createAA(); -#if GTK_CHECK_VERSION(3,0,0) - GtkCssProvider *css_provider = gtk_css_provider_new(); - GtkStyleContext *style_context = gtk_widget_get_style_context(GTK_WIDGET(vw->canvas)); + auto css_provider = gtk_css_provider_new(); + auto style_context = gtk_widget_get_style_context(GTK_WIDGET(vw->canvas)); gtk_css_provider_load_from_data(css_provider, "SPCanvas {\n" @@ -103,19 +91,8 @@ static void sp_svg_view_widget_init(SPSVGSPViewWidget *vw) gtk_style_context_add_provider(style_context, GTK_STYLE_PROVIDER(css_provider), GTK_STYLE_PROVIDER_PRIORITY_USER); -#else - gtk_widget_pop_colormap (); - GtkStyle *style = gtk_style_copy (gtk_widget_get_style (vw->canvas)); - style->bg[GTK_STATE_NORMAL] = style->white; - gtk_widget_set_style (vw->canvas, style); -#endif - -#if GTK_CHECK_VERSION(3,0,0) - gtk_container_add (GTK_CONTAINER (vw->sw), vw->canvas); -#else - gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (vw->sw), vw->canvas); -#endif + gtk_container_add (GTK_CONTAINER (vw->sw), vw->canvas); gtk_widget_show (vw->canvas); /* View */ @@ -146,7 +123,6 @@ static void sp_svg_view_widget_size_request(GtkWidget *widget, GtkRequisition *r SPSVGSPViewWidget *vw = SP_SVG_VIEW_WIDGET (widget); Inkscape::UI::View::View *v = SP_VIEW_WIDGET_VIEW (widget); -#if GTK_CHECK_VERSION(3,0,0) if (GTK_WIDGET_CLASS(sp_svg_view_widget_parent_class)->get_preferred_width && GTK_WIDGET_CLASS(sp_svg_view_widget_parent_class)->get_preferred_height) { gint width_min, height_min, width_nat, height_nat; @@ -156,11 +132,6 @@ static void sp_svg_view_widget_size_request(GtkWidget *widget, GtkRequisition *r req->width=width_min; req->height=height_min; } -#else - if (GTK_WIDGET_CLASS(sp_svg_view_widget_parent_class)->size_request) { - GTK_WIDGET_CLASS(sp_svg_view_widget_parent_class)->size_request(widget, req); - } -#endif if (v->doc()) { SPSVGView *svgv; @@ -189,7 +160,6 @@ static void sp_svg_view_widget_size_request(GtkWidget *widget, GtkRequisition *r } } -#if GTK_CHECK_VERSION(3,0,0) static void sp_svg_view_widget_get_preferred_width(GtkWidget *widget, gint *minimal_width, gint *natural_width) { GtkRequisition requisition; @@ -203,7 +173,6 @@ static void sp_svg_view_widget_get_preferred_height(GtkWidget *widget, gint *min sp_svg_view_widget_size_request(widget, &requisition); *minimal_height = *natural_height = requisition.height; } -#endif /** * Callback connected with size_allocate signal. diff --git a/src/svg-view.cpp b/src/svg-view.cpp index 53fa8633f..00ea0d381 100644 --- a/src/svg-view.cpp +++ b/src/svg-view.cpp @@ -107,11 +107,7 @@ void SPSVGView::mouseover() GdkCursor *cursor = gdk_cursor_new_for_display(display, GDK_HAND2); GdkWindow *window = gtk_widget_get_window (GTK_WIDGET(SP_CANVAS_ITEM(_drawing)->canvas)); gdk_window_set_cursor(window, cursor); -#if GTK_CHECK_VERSION(3,0,0) g_object_unref(cursor); -#else - gdk_cursor_unref(cursor); -#endif } void SPSVGView::mouseout() diff --git a/src/svg/Makefile_insert b/src/svg/Makefile_insert deleted file mode 100644 index 4f82bdd76..000000000 --- a/src/svg/Makefile_insert +++ /dev/null @@ -1,32 +0,0 @@ -## Makefile.am fragment sourced by src/Makefile.am. - -ink_common_sources += \ - svg/css-ostringstream.h \ - svg/css-ostringstream.cpp \ - svg/path-string.h \ - svg/path-string.cpp \ - svg/stringstream.h \ - svg/stringstream.cpp \ - svg/strip-trailing-zeros.h \ - svg/strip-trailing-zeros.cpp \ - svg/svg-affine.cpp \ - svg/svg-color.cpp \ - svg/svg-color.h \ - svg/svg-icc-color.h \ - svg/svg-angle.cpp \ - svg/svg-angle.h \ - svg/svg-length.cpp \ - svg/svg-length.h \ - svg/svg-path.cpp \ - svg/svg.h - -# ###################### -# ### CxxTest stuff #### -# ###################### -CXXTEST_TESTSUITES += \ - $(srcdir)/svg/css-ostringstream-test.h \ - $(srcdir)/svg/stringstream-test.h \ - $(srcdir)/svg/svg-affine-test.h \ - $(srcdir)/svg/svg-color-test.h \ - $(srcdir)/svg/svg-length-test.h \ - $(srcdir)/svg/svg-path-geom-test.h diff --git a/src/svg/css-ostringstream.cpp b/src/svg/css-ostringstream.cpp index 33985443e..ef0413372 100644 --- a/src/svg/css-ostringstream.cpp +++ b/src/svg/css-ostringstream.cpp @@ -1,7 +1,6 @@ #include "svg/css-ostringstream.h" #include "svg/strip-trailing-zeros.h" #include "preferences.h" -#include <glib.h> Inkscape::CSSOStringStream::CSSOStringStream() { diff --git a/src/svg/path-string.cpp b/src/svg/path-string.cpp index 6dddeadff..7d0092dfa 100644 --- a/src/svg/path-string.cpp +++ b/src/svg/path-string.cpp @@ -17,7 +17,6 @@ #include "svg/stringstream.h" #include "svg/svg.h" #include "preferences.h" -#include <algorithm> // 1<=numericprecision<=16, doubles are only accurate upto (slightly less than) 16 digits (and less than one digit doesn't make sense) // Please note that these constants are used to allocate sufficient space to hold serialized numbers diff --git a/src/svg/svg-affine.cpp b/src/svg/svg-affine.cpp index d9d79bba5..76d89579d 100644 --- a/src/svg/svg-affine.cpp +++ b/src/svg/svg-affine.cpp @@ -12,7 +12,7 @@ */ #ifdef HAVE_CONFIG_H -# include "config.h" +#include "config.h" #endif #include <cstring> @@ -21,14 +21,9 @@ #include <cstdio> #include <glib.h> #include <2geom/transforms.h> -#include <2geom/angle.h> #include "svg.h" #include "preferences.h" -#ifndef M_PI -# define M_PI 3.14159265358979323846 -#endif - bool sp_svg_transform_read(gchar const *str, Geom::Affine *transform) { diff --git a/src/svg/svg-angle.cpp b/src/svg/svg-angle.cpp index ed5ccd45e..9d4435a18 100644 --- a/src/svg/svg-angle.cpp +++ b/src/svg/svg-angle.cpp @@ -13,16 +13,13 @@ */ #ifdef HAVE_CONFIG_H -# include "config.h" +#include "config.h" #endif #include <cstring> #include <string> -#include <math.h> #include <glib.h> -#include "svg.h" -#include "stringstream.h" #include "svg/svg-angle.h" #include "util/units.h" diff --git a/src/svg/svg-color.cpp b/src/svg/svg-color.cpp index 693094048..89a5636a8 100644 --- a/src/svg/svg-color.cpp +++ b/src/svg/svg-color.cpp @@ -19,7 +19,6 @@ #include <cstdio> // sprintf #include <cstring> #include <string> -#include <cassert> #include <math.h> #include <glib.h> // g_assert #include <errno.h> diff --git a/src/svg/svg-path.cpp b/src/svg/svg-path.cpp index 7bb58fc9c..13795f2a3 100644 --- a/src/svg/svg-path.cpp +++ b/src/svg/svg-path.cpp @@ -17,17 +17,13 @@ #include <cstring> #include <string> -#include <cassert> #include <glib.h> // g_assert() #include <2geom/pathvector.h> -#include <2geom/path.h> #include <2geom/curves.h> #include <2geom/sbasis-to-bezier.h> #include <2geom/path-sink.h> #include <2geom/svg-path-parser.h> -#include <2geom/exception.h> -#include <2geom/angle.h> #include "svg/svg.h" #include "svg/path-string.h" diff --git a/src/test-helpers.h b/src/test-helpers.h deleted file mode 100644 index d30449ebb..000000000 --- a/src/test-helpers.h +++ /dev/null @@ -1,66 +0,0 @@ -#ifndef SEEN_TEST_HELPERS_H -#define SEEN_TEST_HELPERS_H - - -#include <cxxtest/TestSuite.h> - -#include "document.h" -#include "inkscape.h" - - -// Dummy functions to keep linker happy -#if !defined(DUMMY_MAIN_TEST_CALLS_SEEN) -#define DUMMY_MAIN_TEST_CALLS_SEEN -int sp_main_gui (int, char const**) { return 0; } -int sp_main_console (int, char const**) { return 0; } -#endif // DUMMY_MAIN_TEST_CALLS_SEEN - -namespace Inkscape -{ - -template <class T> -T* createSuiteAndDocument( void (*fun)(T*&) ) -{ - T* suite = 0; - -#if !GLIB_CHECK_VERSION(2,36,0) - g_type_init(); -#endif - - Inkscape::GC::init(); - if ( !Inkscape::Application::exists() ) - { - // Create the global inkscape object. - Inkscape::Application::create("", false); - } - - SPDocument* tmp = SPDocument::createNewDoc( NULL, TRUE, true ); - if ( tmp ) { - fun( suite ); - if ( suite ) - { - suite->_doc = tmp; - } - else - { - tmp->doUnref(); - } - } - - return suite; -} - -} // namespace Inkscape - -#endif // SEEN_TEST_HELPERS_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/text-chemistry.cpp b/src/text-chemistry.cpp index fbbbe5807..2b731c75d 100644 --- a/src/text-chemistry.cpp +++ b/src/text-chemistry.cpp @@ -12,7 +12,7 @@ */ #ifdef HAVE_CONFIG_H -# include <config.h> +#include <config.h> #endif #include <cstring> @@ -27,7 +27,6 @@ #include "document.h" #include "document-undo.h" #include "message-stack.h" -#include "selection.h" #include "style.h" #include "text-editing.h" @@ -43,8 +42,8 @@ using Inkscape::DocumentUndo; static SPItem * flowtext_in_selection(Inkscape::Selection *selection) { - std::vector<SPItem*> items = selection->itemList(); - for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();++i){ + auto items = selection->items(); + for(auto i=items.begin();i!=items.end();++i){ if (SP_IS_FLOWTEXT(*i)) return *i; } @@ -54,8 +53,8 @@ flowtext_in_selection(Inkscape::Selection *selection) static SPItem * text_or_flowtext_in_selection(Inkscape::Selection *selection) { - std::vector<SPItem*> items = selection->itemList(); - for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();++i){ + auto items = selection->items(); + for(auto i=items.begin();i!=items.end();++i){ if (SP_IS_TEXT(*i) || SP_IS_FLOWTEXT(*i)) return *i; } @@ -65,8 +64,8 @@ text_or_flowtext_in_selection(Inkscape::Selection *selection) static SPItem * shape_in_selection(Inkscape::Selection *selection) { - std::vector<SPItem*> items = selection->itemList(); - for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();++i){ + auto items = selection->items(); + for(auto i=items.begin();i!=items.end();++i){ if (SP_IS_SHAPE(*i)) return *i; } @@ -87,7 +86,7 @@ text_put_on_path() Inkscape::XML::Document *xml_doc = desktop->doc()->getReprDoc(); - if (!text || !shape || selection->itemList().size() != 2) { + if (!text || !shape || boost::distance(selection->items()) != 2) { desktop->getMessageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>a text and a path</b> to put text on path.")); return; } @@ -142,8 +141,8 @@ text_put_on_path() // make a list of text children GSList *text_reprs = NULL; - for (SPObject *o = text->children; o != NULL; o = o->next) { - text_reprs = g_slist_prepend(text_reprs, o->getRepr()); + for(auto& o: text->children) { + text_reprs = g_slist_prepend(text_reprs, o.getRepr()); } // create textPath and put it into the text @@ -196,8 +195,8 @@ text_remove_from_path() } bool did = false; - std::vector<SPItem*> items(selection->itemList()); - for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();++i){ + auto items = selection->items(); + for(auto i=items.begin();i!=items.end();++i){ SPObject *obj = *i; if (SP_IS_TEXT_TEXTPATH(obj)) { @@ -214,7 +213,8 @@ text_remove_from_path() } else { DocumentUndo::done(desktop->getDocument(), SP_VERB_CONTEXT_TEXT, _("Remove text from path")); - selection->setList(selection->itemList()); // reselect to update statusbar description + std::vector<SPItem *> vec(selection->items().begin(), selection->items().end()); + selection->setList(vec); // reselect to update statusbar description } } @@ -239,9 +239,9 @@ text_remove_all_kerns_recursively(SPObject *o) g_strfreev(xa_comma); } - for (SPObject *i = o->firstChild(); i != NULL; i = i->getNext()) { - text_remove_all_kerns_recursively(i); - i->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_TEXT_LAYOUT_MODIFIED_FLAG); + for (auto& i: o->children) { + text_remove_all_kerns_recursively(&i); + i.requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_TEXT_LAYOUT_MODIFIED_FLAG); } } @@ -260,8 +260,8 @@ text_remove_all_kerns() bool did = false; - std::vector<SPItem*> items = selection->itemList(); - for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();++i){ + auto items = selection->items(); + for(auto i=items.begin();i!=items.end();++i){ SPObject *obj = *i; if (!SP_IS_TEXT(obj) && !SP_IS_TSPAN(obj) && !SP_IS_FLOWTEXT(obj)) { @@ -296,7 +296,7 @@ text_flow_into_shape() SPItem *text = text_or_flowtext_in_selection(selection); SPItem *shape = shape_in_selection(selection); - if (!text || !shape || selection->itemList().size() < 2) { + if (!text || !shape || boost::distance(selection->items()) < 2) { desktop->getMessageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>a text</b> and one or more <b>paths or shapes</b> to flow text into frame.")); return; } @@ -320,8 +320,8 @@ text_flow_into_shape() g_return_if_fail(SP_IS_FLOWREGION(object)); /* Add clones */ - std::vector<SPItem*> items = selection->itemList(); - for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();++i){ + auto items = selection->items(); + for(auto i=items.begin();i!=items.end();++i){ SPItem *item = *i; if (SP_IS_SHAPE(item)){ Inkscape::XML::Node *clone = xml_doc->createElement("svg:use"); @@ -352,9 +352,9 @@ text_flow_into_shape() Inkscape::GC::release(text_repr); } else { // reflow an already flowed text, preserving paras - for (SPObject *o = text->children; o != NULL; o = o->next) { - if (SP_IS_FLOWPARA(o)) { - Inkscape::XML::Node *para_repr = o->getRepr()->duplicate(xml_doc); + for(auto& o: text->children) { + if (SP_IS_FLOWPARA(&o)) { + Inkscape::XML::Node *para_repr = o.getRepr()->duplicate(xml_doc); root_repr->appendChild(para_repr); object = doc->getObjectByRepr(para_repr); g_return_if_fail(SP_IS_FLOWPARA(object)); @@ -387,7 +387,7 @@ text_unflow () Inkscape::Selection *selection = desktop->getSelection(); - if (!flowtext_in_selection(selection) || selection->itemList().size() < 1) { + if (!flowtext_in_selection(selection) || boost::distance(selection->items()) < 1) { desktop->getMessageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>a flowed text</b> to unflow it.")); return; } @@ -395,8 +395,8 @@ text_unflow () std::vector<SPItem*> new_objs; GSList *old_objs = NULL; - std::vector<SPItem*> items = selection->itemList(); - for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();++i){ + auto items = selection->items(); + for(auto i=items.begin();i!=items.end();++i){ if (!SP_IS_FLOWTEXT(*i)) { continue; @@ -480,7 +480,7 @@ flowtext_to_text() bool did = false; std::vector<Inkscape::XML::Node*> reprs; - std::vector<SPItem*> items(selection->itemList()); + std::vector<SPItem*> items(selection->items().begin(), selection->items().end()); for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();++i){ SPItem *item = *i; diff --git a/src/text-editing.cpp b/src/text-editing.cpp index 057523b1e..6809a4bc5 100644 --- a/src/text-editing.cpp +++ b/src/text-editing.cpp @@ -13,7 +13,6 @@ */ #ifdef HAVE_CONFIG_H -# include "config.h" #endif #include <cstring> @@ -27,7 +26,6 @@ #include "util/units.h" #include "document.h" -#include "xml/repr.h" #include "xml/attribute-record.h" #include "xml/sp-css-attr.h" @@ -91,8 +89,8 @@ bool sp_te_input_is_empty(SPObject const *item) if (SP_IS_STRING(item)) { empty = SP_STRING(item)->string.empty(); } else { - for (SPObject const *child = item->firstChild() ; child ; child = child->getNext()) { - if (!sp_te_input_is_empty(child)) { + for (auto& child: item->children) { + if (!sp_te_input_is_empty(&child)) { empty = false; break; } @@ -237,11 +235,11 @@ unsigned sp_text_get_length(SPObject const *item) length++; } - for (SPObject const *child = item->firstChild() ; child ; child = child->getNext()) { - if (SP_IS_STRING(child)) { - length += SP_STRING(child)->string.length(); + for (auto& child: item->children) { + if (SP_IS_STRING(&child)) { + length += SP_STRING(&child)->string.length(); } else { - length += sp_text_get_length(child); + length += sp_text_get_length(&child); } } } @@ -267,22 +265,22 @@ unsigned sp_text_get_length_upto(SPObject const *item, SPObject const *upto) } // Count the length of the children - for (SPObject const *child = item->firstChild() ; child ; child = child->getNext()) { - if (upto && child == upto) { + for (auto& child: item->children) { + if (upto && &child == upto) { // hit upto, return immediately return length; } - if (SP_IS_STRING(child)) { - length += SP_STRING(child)->string.length(); + if (SP_IS_STRING(&child)) { + length += SP_STRING(&child)->string.length(); } else { - if (upto && child->isAncestorOf(upto)) { + if (upto && child.isAncestorOf(upto)) { // upto is below us, recurse and break loop - length += sp_text_get_length_upto(child, upto); + length += sp_text_get_length_upto(&child, upto); return length; } else { // recurse and go to the next sibling - length += sp_text_get_length_upto(child, upto); + length += sp_text_get_length_upto(&child, upto); } } } @@ -323,8 +321,11 @@ to \a item at the same level. */ static unsigned sum_sibling_text_lengths_before(SPObject const *item) { unsigned char_index = 0; - for (SPObject *sibling = item->parent->firstChild() ; sibling && sibling != item ; sibling = sibling->getNext()) { - char_index += sp_text_get_length(sibling); + for (auto& sibling: item->parent->children) { + if (&sibling == item) { + break; + } + char_index += sp_text_get_length(&sibling); } return char_index; } @@ -857,11 +858,11 @@ static void sp_te_get_ustring_multiline(SPObject const *root, Glib::ustring *str if (*pending_line_break) { *string += '\n'; } - for (SPObject const *child = root->firstChild() ; child ; child = child->getNext()) { - if (SP_IS_STRING(child)) { - *string += SP_STRING(child)->string; + for (auto& child: root->children) { + if (SP_IS_STRING(&child)) { + *string += SP_STRING(&child)->string; } else { - sp_te_get_ustring_multiline(child, string, pending_line_break); + sp_te_get_ustring_multiline(&child, string, pending_line_break); } } if (!SP_IS_TEXT(root) && !SP_IS_TEXTPATH(root) && is_line_break_object(root)) { @@ -941,13 +942,10 @@ sp_te_set_repr_text_multiline(SPItem *text, gchar const *str) gchar *content = g_strdup (str); repr->setContent(""); - SPObject *child = object->firstChild(); - while (child) { - SPObject *next = child->getNext(); - if (!SP_IS_FLOWREGION(child) && !SP_IS_FLOWREGIONEXCLUDE(child)) { - repr->removeChild(child->getRepr()); + for (auto& child: object->children) { + if (!SP_IS_FLOWREGION(&child) && !SP_IS_FLOWREGIONEXCLUDE(&child)) { + repr->removeChild(child.getRepr()); } - child = next; } gchar *p = content; @@ -1405,17 +1403,17 @@ static void apply_css_recursive(SPObject *o, SPCSSAttr const *css) { sp_repr_css_change(o->getRepr(), const_cast<SPCSSAttr*>(css), "style"); - for (SPObject *child = o->firstChild() ; child ; child = child->getNext() ) { + for (auto& child: o->children) { if (sp_repr_css_property(const_cast<SPCSSAttr*>(css), "opacity", NULL) != NULL) { // Unset properties which are accumulating and thus should not be set recursively. // For example, setting opacity 0.5 on a group recursively would result in the visible opacity of 0.25 for an item in the group. SPCSSAttr *css_recurse = sp_repr_css_attr_new(); sp_repr_css_merge(css_recurse, const_cast<SPCSSAttr*>(css)); sp_repr_css_set_property(css_recurse, "opacity", NULL); - apply_css_recursive(child, css_recurse); + apply_css_recursive(&child, css_recurse); sp_repr_css_attr_unref(css_recurse); } else { - apply_css_recursive(child, const_cast<SPCSSAttr*>(css)); + apply_css_recursive(&child, const_cast<SPCSSAttr*>(css)); } } } @@ -1429,7 +1427,7 @@ static void recursively_apply_style(SPObject *common_ancestor, SPCSSAttr const * { bool passed_start = start_item == NULL ? true : false; Inkscape::XML::Document *xml_doc = common_ancestor->document->getReprDoc(); - + for (SPObject *child = common_ancestor->firstChild() ; child ; child = child->getNext()) { if (start_item == child) { passed_start = true; @@ -2073,8 +2071,8 @@ bool has_visible_text(SPObject *obj) if (SP_IS_STRING(obj) && !SP_STRING(obj)->string.empty()) { hasVisible = true; // maybe we should also check that it's not all whitespace? } else { - for (SPObject const *child = obj->firstChild() ; child ; child = child->getNext()) { - if (has_visible_text(const_cast<SPObject *>(child))) { + for (auto& child: obj->children) { + if (has_visible_text(const_cast<SPObject *>(&child))) { hasVisible = true; break; } diff --git a/src/trace/Makefile_insert b/src/trace/Makefile_insert deleted file mode 100644 index 27353df15..000000000 --- a/src/trace/Makefile_insert +++ /dev/null @@ -1,23 +0,0 @@ -## Makefile.am fragment sourced by src/Makefile.am. - -if HAVE_POTRACE - -ink_common_sources += \ - trace/pool.h \ - trace/trace.h \ - trace/trace.cpp \ - trace/imagemap-gdk.cpp \ - trace/imagemap-gdk.h \ - trace/imagemap.cpp \ - trace/imagemap.h \ - trace/quantize.h \ - trace/quantize.cpp \ - trace/filterset.h \ - trace/filterset.cpp \ - trace/siox.h \ - trace/siox.cpp \ - trace/potrace/bitmap.h \ - trace/potrace/inkscape-potrace.cpp \ - trace/potrace/inkscape-potrace.h - -endif diff --git a/src/trace/trace.cpp b/src/trace/trace.cpp index 379682668..52e99886a 100644 --- a/src/trace/trace.cpp +++ b/src/trace/trace.cpp @@ -65,7 +65,7 @@ SPImage *Tracer::getSelectedSPImage() if (sioxEnabled) { SPImage *img = NULL; - std::vector<SPItem*> const list = sel->itemList(); + auto list = sel->items(); std::vector<SPItem *> items; sioxShapes.clear(); @@ -74,7 +74,7 @@ SPImage *Tracer::getSelectedSPImage() them as bottom-to-top so that we can discover the image and any SPItems above it */ - for (std::vector<SPItem*>::const_iterator i=list.begin() ; list.end()!=i ; ++i) + for (auto i=list.begin() ; list.end()!=i ; ++i) { if (!SP_IS_ITEM(*i)) { diff --git a/src/ui/CMakeLists.txt b/src/ui/CMakeLists.txt index af375f1f9..f2a256698 100644 --- a/src/ui/CMakeLists.txt +++ b/src/ui/CMakeLists.txt @@ -131,8 +131,6 @@ set(ui_SRC widget/font-button.cpp widget/font-variants.cpp widget/frame.cpp - widget/gimpcolorwheel.c - widget/gimpspinscale.c widget/highlight-picker.cpp widget/imageicon.cpp widget/imagetoggler.cpp @@ -249,6 +247,7 @@ set(ui_SRC dialog/template-widget.h dialog/text-edit.h dialog/tile.h + dialog/tracedialog.h dialog/transformation.h dialog/undo-history.h dialog/xml-tree.h @@ -276,14 +275,15 @@ set(ui_SRC tools/dropper-tool.h tools/dynamic-base.h tools/eraser-tool.h + tools/flood-tool.h tools/freehand-base.h tools/gradient-tool.h tools/lpe-tool.h tools/measure-tool.h tools/mesh-tool.h tools/node-tool.h - tools/pencil-tool.h tools/pen-tool.h + tools/pencil-tool.h tools/rect-tool.h tools/select-tool.h tools/spiral-tool.h @@ -316,8 +316,6 @@ set(ui_SRC widget/font-button.h widget/font-variants.h widget/frame.h - widget/gimpspinscale.h - widget/gimpcolorwheel.h widget/highlight-picker.h widget/insertordericon.h widget/imageicon.h diff --git a/src/ui/Makefile_insert b/src/ui/Makefile_insert deleted file mode 100644 index bbfdb532c..000000000 --- a/src/ui/Makefile_insert +++ /dev/null @@ -1,31 +0,0 @@ -## Makefile.am fragment sourced by src/Makefile.am. - -ink_common_sources += \ - ui/clipboard.cpp \ - ui/clipboard.h \ - ui/control-manager.cpp \ - ui/control-manager.h \ - ui/control-types.h \ - ui/dialog-events.cpp \ - ui/dialog-events.h \ - ui/draw-anchor.cpp \ - ui/draw-anchor.h \ - ui/icon-names.h \ - ui/interface.cpp \ - ui/interface.h \ - ui/object-edit.cpp \ - ui/object-edit.h \ - ui/previewable.h \ - ui/previewfillable.h \ - ui/previewholder.cpp \ - ui/previewholder.h \ - ui/selected-color.h \ - ui/selected-color.cpp \ - ui/shape-editor.cpp \ - ui/shape-editor.h \ - ui/tool-factory.cpp \ - ui/tool-factory.h \ - ui/tools-switch.cpp \ - ui/tools-switch.h \ - ui/uxmanager.cpp \ - ui/uxmanager.h diff --git a/src/ui/cache/Makefile_insert b/src/ui/cache/Makefile_insert deleted file mode 100644 index c648777f8..000000000 --- a/src/ui/cache/Makefile_insert +++ /dev/null @@ -1,6 +0,0 @@ -## Makefile.am fragment sourced by src/Makefile.am. - -ink_common_sources += \ - ui/cache/svg_preview_cache.h \ - ui/cache/svg_preview_cache.cpp - diff --git a/src/ui/clipboard.cpp b/src/ui/clipboard.cpp index d581dbf7e..66b13ed9d 100644 --- a/src/ui/clipboard.cpp +++ b/src/ui/clipboard.cpp @@ -27,9 +27,6 @@ // TODO: reduce header bloat if possible #include "file.h" // for file_import, used in _pasteImage -#include <list> -#include <algorithm> -#include <glibmm/ustring.h> #include <glibmm/i18n.h> #include <glib/gstdio.h> // for g_file_set_contents etc., used in _onGet and paste #include "inkgc/gc-core.h" @@ -41,7 +38,6 @@ #include "desktop-style.h" // for sp_desktop_set_style, used in _pasteStyle #include "document.h" #include "document-private.h" -#include "selection.h" #include "message-stack.h" #include "context-fns.h" #include "ui/tools/dropper-tool.h" // used in copy() @@ -50,17 +46,13 @@ #include "extension/input.h" #include "extension/output.h" #include "selection-chemistry.h" -#include <2geom/rect.h> #include <2geom/transforms.h> #include "box3d.h" #include "gradient-drag.h" #include "sp-marker.h" -#include "sp-item.h" #include "sp-item-transform.h" // for sp_item_scale_rel, used in _pasteSize #include "sp-path.h" #include "sp-pattern.h" -#include "sp-shape.h" -#include "sp-gradient.h" #include "sp-gradient-reference.h" #include "sp-linear-gradient.h" #include "sp-radial-gradient.h" @@ -68,8 +60,6 @@ #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" @@ -83,9 +73,7 @@ #include "helper/png-write.h" #include "svg/svg-color.h" #include "sp-namedview.h" -#include "snap.h" #include "persp3d.h" -#include "preferences.h" /// Made up mimetype to represent Gdk::Pixbuf clipboard contents. #define CLIPBOARD_GDK_PIXBUF_TARGET "image/x-gdk-pixbuf" @@ -522,8 +510,8 @@ bool ClipboardManagerImpl::pasteSize(SPDesktop *desktop, bool separately, bool a // resize each object in the selection if (separately) { - std::vector<SPItem*> itemlist=selection->itemList(); - for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();++i){ + auto itemlist= selection->items(); + for(auto i=itemlist.begin();i!=itemlist.end();++i){ SPItem *item = *i; if (item) { Geom::OptRect obj_size = item->desktopVisualBounds(); @@ -539,8 +527,8 @@ bool ClipboardManagerImpl::pasteSize(SPDesktop *desktop, bool separately, bool a else { Geom::OptRect sel_size = selection->visualBounds(); if ( sel_size ) { - sp_selection_scale_relative(selection, sel_size->midpoint(), - _getScale(desktop, min, max, *sel_size, apply_x, apply_y)); + sp_object_set_scale_relative(selection, sel_size->midpoint(), + _getScale(desktop, min, max, *sel_size, apply_x, apply_y)); } } pasted = true; @@ -578,8 +566,8 @@ bool ClipboardManagerImpl::pastePathEffect(SPDesktop *desktop) desktop->doc()->importDefs(tempdoc); // make sure all selected items are converted to paths first (i.e. rectangles) sp_selected_to_lpeitems(desktop); - std::vector<SPItem*> itemlist=selection->itemList(); - for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();++i){ + auto itemlist= selection->items(); + for(auto i=itemlist.begin();i!=itemlist.end();++i){ SPItem *item = *i; _applyPathEffect(item, effectstack); } @@ -661,9 +649,9 @@ Glib::ustring ClipboardManagerImpl::getShapeOrTextObjectId(SPDesktop *desktop) void ClipboardManagerImpl::_copySelection(Inkscape::Selection *selection) { // copy the defs used by all items - std::vector<SPItem*> itemlist=selection->itemList(); + auto itemlist= selection->items(); cloned_elements.clear(); - for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();++i){ + for(auto i=itemlist.begin();i!=itemlist.end();++i){ SPItem *item = *i; if (item) { _copyUsedDefs(item); @@ -674,7 +662,7 @@ void ClipboardManagerImpl::_copySelection(Inkscape::Selection *selection) // copy the representation of the items std::vector<SPObject*> sorted_items; - for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();++i) + for(auto i=itemlist.begin();i!=itemlist.end();++i) sorted_items.push_back(*i); sort(sorted_items.begin(),sorted_items.end(),sp_object_compare_position_bool); @@ -839,8 +827,8 @@ void ClipboardManagerImpl::_copyUsedDefs(SPItem *item) SPObject *mask = item->mask_ref->getObject(); _copyNode(mask->getRepr(), _doc, _defs); // recurse into the mask for its gradients etc. - for (SPObject *o = mask->children ; o != NULL ; o = o->next) { - SPItem *childItem = dynamic_cast<SPItem *>(o); + for(auto& o: mask->children) { + SPItem *childItem = dynamic_cast<SPItem *>(&o); if (childItem) { _copyUsedDefs(childItem); } @@ -857,8 +845,8 @@ void ClipboardManagerImpl::_copyUsedDefs(SPItem *item) } // recurse - for (SPObject *o = item->children ; o != NULL ; o = o->next) { - SPItem *childItem = dynamic_cast<SPItem *>(o); + for(auto& o: item->children) { + SPItem *childItem = dynamic_cast<SPItem *>(&o); if (childItem) { _copyUsedDefs(childItem); } @@ -894,8 +882,8 @@ void ClipboardManagerImpl::_copyPattern(SPPattern *pattern) _copyNode(pattern->getRepr(), _doc, _defs); // items in the pattern may also use gradients and other patterns, so recurse - for ( SPObject *child = pattern->firstChild() ; child ; child = child->getNext() ) { - SPItem *childItem = dynamic_cast<SPItem *>(child); + for (auto& child: pattern->children) { + SPItem *childItem = dynamic_cast<SPItem *>(&child); if (childItem) { _copyUsedDefs(childItem); } @@ -1300,11 +1288,7 @@ Geom::Scale ClipboardManagerImpl::_getScale(SPDesktop *desktop, Geom::Point cons */ Glib::ustring ClipboardManagerImpl::_getBestTarget() { -#if WITH_GTKMM_3_0 - std::vector<Glib::ustring> targets = _clipboard->wait_for_targets(); -#else - std::list<Glib::ustring> targets = _clipboard->wait_for_targets(); -#endif + auto targets = _clipboard->wait_for_targets(); // clipboard target debugging snippet /* @@ -1363,12 +1347,7 @@ void ClipboardManagerImpl::_setClipboardTargets() { Inkscape::Extension::DB::OutputList outlist; Inkscape::Extension::db.get_output_list(outlist); - -#if WITH_GTKMM_3_0 std::vector<Gtk::TargetEntry> target_list; -#else - std::list<Gtk::TargetEntry> target_list; -#endif bool plaintextSet = false; for (Inkscape::Extension::DB::OutputList::const_iterator out = outlist.begin() ; out != outlist.end() ; ++out) { diff --git a/src/ui/control-manager.cpp b/src/ui/control-manager.cpp index a2c977533..d0285e467 100644 --- a/src/ui/control-manager.cpp +++ b/src/ui/control-manager.cpp @@ -17,7 +17,6 @@ #include <glib-object.h> #include "display/sodipodi-ctrl.h" // for SP_TYPE_CTRL -#include "display/sp-canvas-item.h" #include "display/sp-ctrlline.h" #include "display/sp-ctrlcurve.h" #include "preferences.h" @@ -149,7 +148,7 @@ ControlManagerImpl::ControlManagerImpl(ControlManager &manager) : _ctrlToShape[CTRL_TYPE_NODE_AUTO] = SP_CTRL_SHAPE_CIRCLE; _ctrlToShape[CTRL_TYPE_NODE_SYMETRICAL] = SP_CTRL_SHAPE_SQUARE; - _ctrlToShape[CTRL_TYPE_ADJ_HANDLE] = SP_CTRL_SHAPE_CIRCLE; + _ctrlToShape[CTRL_TYPE_ADJ_HANDLE] =SP_CTRL_SHAPE_CIRCLE; _ctrlToShape[CTRL_TYPE_INVISIPOINT] = SP_CTRL_SHAPE_SQUARE; // ------- @@ -223,10 +222,10 @@ SPCanvasItem *ControlManagerImpl::createControl(SPCanvasGroup *parent, ControlTy { case CTRL_TYPE_ADJ_HANDLE: item = sp_canvas_item_new(parent, SP_TYPE_CTRL, - "shape", SP_CTRL_SHAPE_CIRCLE, + "shape",SP_CTRL_SHAPE_CIRCLE, "size", targetSize, - "filled", 0, - "fill_color", 0xff00007f, + "filled", 1, + "fill_color", 0xffffff7f, "stroked", 1, "stroke_color", 0x0000ff7f, NULL); diff --git a/src/ui/dialog-events.cpp b/src/ui/dialog-events.cpp index 8856631c0..d7d56fa50 100644 --- a/src/ui/dialog-events.cpp +++ b/src/ui/dialog-events.cpp @@ -12,17 +12,14 @@ */ #ifdef HAVE_CONFIG_H -# include "config.h" +#include <config.h> #endif #include <gtkmm/entry.h> #include <gtkmm/window.h> -#include <gdk/gdkkeysyms.h> #include "macros.h" -#include <gtk/gtk.h> #include "desktop.h" #include "inkscape.h" -#include "preferences.h" #include "ui/tools/tool-base.h" #include "ui/dialog-events.h" diff --git a/src/ui/dialog-events.h b/src/ui/dialog-events.h index b4a5d7c35..547cfb95d 100644 --- a/src/ui/dialog-events.h +++ b/src/ui/dialog-events.h @@ -12,6 +12,7 @@ #ifndef SEEN_DIALOG_EVENTS_H #define SEEN_DIALOG_EVENTS_H +#include <gtk/gtk.h> /* * event callback can only accept one argument, but we need two, diff --git a/src/ui/dialog/Makefile_insert b/src/ui/dialog/Makefile_insert deleted file mode 100644 index 71628973e..000000000 --- a/src/ui/dialog/Makefile_insert +++ /dev/null @@ -1,133 +0,0 @@ -## Makefile.am fragment sourced by src/Makefile.am. - -ink_common_sources += \ - ui/dialog/aboutbox.cpp \ - ui/dialog/aboutbox.h \ - ui/dialog/align-and-distribute.cpp \ - ui/dialog/align-and-distribute.h \ - ui/dialog/arrange-tab.h \ - ui/dialog/behavior.h \ - ui/dialog/calligraphic-profile-rename.h \ - ui/dialog/calligraphic-profile-rename.cpp \ - ui/dialog/clonetiler.cpp \ - ui/dialog/clonetiler.h \ - ui/dialog/color-item.cpp \ - ui/dialog/color-item.h \ - ui/dialog/debug.cpp \ - ui/dialog/debug.h \ - ui/dialog/desktop-tracker.cpp \ - ui/dialog/desktop-tracker.h \ - ui/dialog/dialog.cpp \ - ui/dialog/dialog.h \ - ui/dialog/dialog-manager.cpp \ - ui/dialog/dialog-manager.h \ - ui/dialog/dock-behavior.cpp \ - ui/dialog/dock-behavior.h \ - ui/dialog/document-metadata.cpp \ - ui/dialog/document-metadata.h \ - ui/dialog/document-properties.cpp \ - ui/dialog/document-properties.h \ - ui/dialog/export.cpp \ - ui/dialog/export.h \ - ui/dialog/extension-editor.cpp \ - ui/dialog/extension-editor.h \ - ui/dialog/extensions.cpp \ - ui/dialog/extensions.h \ - ui/dialog/filedialog.cpp \ - ui/dialog/filedialog.h \ - ui/dialog/filedialogimpl-gtkmm.cpp \ - ui/dialog/filedialogimpl-gtkmm.h \ - ui/dialog/filedialogimpl-win32.cpp \ - ui/dialog/filedialogimpl-win32.h \ - ui/dialog/fill-and-stroke.cpp \ - ui/dialog/fill-and-stroke.h \ - ui/dialog/filter-effects-dialog.cpp \ - ui/dialog/filter-effects-dialog.h \ - ui/dialog/find.cpp \ - ui/dialog/find.h \ - ui/dialog/font-substitution.cpp \ - ui/dialog/font-substitution.h \ - ui/dialog/floating-behavior.cpp \ - ui/dialog/floating-behavior.h \ - ui/dialog/glyphs.cpp \ - ui/dialog/glyphs.h \ - ui/dialog/grid-arrange-tab.h \ - ui/dialog/grid-arrange-tab.cpp \ - ui/dialog/guides.cpp \ - ui/dialog/guides.h \ - ui/dialog/icon-preview.cpp \ - ui/dialog/icon-preview.h \ - ui/dialog/inkscape-preferences.cpp \ - ui/dialog/inkscape-preferences.h \ - ui/dialog/input.cpp \ - ui/dialog/input.h \ - ui/dialog/knot-properties.cpp \ - ui/dialog/knot-properties.h \ - ui/dialog/layer-properties.cpp \ - ui/dialog/layer-properties.h \ - ui/dialog/layers.cpp \ - ui/dialog/layers.h \ - ui/dialog/livepatheffect-add.cpp \ - ui/dialog/livepatheffect-add.h \ - ui/dialog/livepatheffect-editor.cpp \ - ui/dialog/livepatheffect-editor.h \ - ui/dialog/memory.cpp \ - ui/dialog/memory.h \ - ui/dialog/messages.cpp \ - ui/dialog/messages.h \ - ui/dialog/new-from-template.cpp \ - ui/dialog/new-from-template.h \ - ui/dialog/ocaldialogs.cpp \ - ui/dialog/ocaldialogs.h \ - ui/dialog/object-attributes.cpp \ - ui/dialog/object-attributes.h \ - ui/dialog/object-properties.cpp \ - ui/dialog/object-properties.h \ - ui/dialog/panel-dialog.h \ - ui/dialog/polar-arrange-tab.cpp \ - ui/dialog/polar-arrange-tab.h \ - ui/dialog/print.cpp \ - ui/dialog/print.h \ - ui/dialog/print-colors-preview-dialog.cpp \ - ui/dialog/print-colors-preview-dialog.h \ - ui/dialog/spellcheck.cpp \ - ui/dialog/spellcheck.h \ - ui/dialog/svg-fonts-dialog.cpp \ - ui/dialog/svg-fonts-dialog.h \ - ui/dialog/swatches.cpp \ - ui/dialog/swatches.h \ - ui/dialog/symbols.cpp \ - ui/dialog/symbols.h \ - ui/dialog/template-load-tab.cpp \ - ui/dialog/template-load-tab.h \ - ui/dialog/template-widget.cpp \ - ui/dialog/template-widget.h \ - ui/dialog/tags.cpp \ - ui/dialog/tags.h \ - ui/dialog/text-edit.cpp \ - ui/dialog/text-edit.h \ - ui/dialog/tile.cpp \ - ui/dialog/tile.h \ - ui/dialog/pixelartdialog.cpp \ - ui/dialog/pixelartdialog.h \ - ui/dialog/transformation.cpp \ - ui/dialog/transformation.h \ - ui/dialog/undo-history.cpp \ - ui/dialog/undo-history.h \ - ui/dialog/xml-tree.cpp \ - ui/dialog/xml-tree.h \ - ui/dialog/lpe-powerstroke-properties.cpp \ - ui/dialog/lpe-powerstroke-properties.h \ - ui/dialog/objects.cpp \ - ui/dialog/objects.h \ - ui/dialog/lpe-fillet-chamfer-properties.cpp \ - ui/dialog/lpe-fillet-chamfer-properties.h \ - $(inkboard_dialogs) - -if HAVE_POTRACE - -ink_common_sources += \ - ui/dialog/tracedialog.cpp \ - ui/dialog/tracedialog.h - -endif diff --git a/src/ui/dialog/aboutbox.cpp b/src/ui/dialog/aboutbox.cpp index 6276d3391..04cf9d02a 100644 --- a/src/ui/dialog/aboutbox.cpp +++ b/src/ui/dialog/aboutbox.cpp @@ -98,11 +98,7 @@ AboutBox::AboutBox() : Gtk::Dialog(_("About Inkscape")) { tabs->append_page(*manage( make_scrolled_text(license_text)), _("_License"), true); -#if WITH_GTKMM_3_0 get_content_area()->pack_end(*manage(tabs), true, true); -#else - get_vbox()->pack_end(*manage(tabs), true, true); -#endif tabs->show_all(); @@ -130,23 +126,16 @@ AboutBox::AboutBox() : Gtk::Dialog(_("About Inkscape")) { link->set_selectable(true); link->show(); -#if WITH_GTKMM_3_0 get_content_area()->pack_start(*manage(label), false, false); get_content_area()->pack_start(*manage(link), false, false); -#else - get_vbox()->pack_start(*manage(label), false, false); - get_vbox()->pack_start(*manage(link), false, false); -#endif - Gtk::Requisition requisition; -#if GTK_CHECK_VERSION(3,0,0) - gtk_widget_get_preferred_size(reinterpret_cast<GtkWidget*>(gobj()), &requisition, NULL); -#else - gtk_widget_size_request (reinterpret_cast<GtkWidget*>(gobj()), &requisition); -#endif + Gtk::Requisition minimum_size; + Gtk::Requisition natural_size; + get_preferred_size(minimum_size, natural_size); + // allow window to shrink set_size_request(0, 0); - set_default_size(requisition.width, requisition.height); + set_default_size(minimum_size.width, minimum_size.height); } diff --git a/src/ui/dialog/align-and-distribute.cpp b/src/ui/dialog/align-and-distribute.cpp index 8f87932b8..7ba6df978 100644 --- a/src/ui/dialog/align-and-distribute.cpp +++ b/src/ui/dialog/align-and-distribute.cpp @@ -18,7 +18,7 @@ #ifdef HAVE_CONFIG_H -# include <config.h> +#include "config.h" #endif #include "align-and-distribute.h" @@ -27,13 +27,10 @@ #include "unclump.h" #include "document.h" -#include "enums.h" #include "graphlayout.h" #include "inkscape.h" -#include "macros.h" #include "preferences.h" #include "removeoverlap.h" -#include "selection.h" #include "sp-flowtext.h" #include "sp-item-transform.h" #include "sp-text.h" @@ -61,11 +58,7 @@ namespace Dialog { Action::Action(const Glib::ustring &id, const Glib::ustring &tiptext, guint row, guint column, -#if WITH_GTKMM_3_0 - Gtk::Grid &parent, -#else - Gtk::Table &parent, -#endif + Gtk::Grid &parent, AlignAndDistribute &dialog): _dialog(dialog), _id(id), @@ -81,11 +74,7 @@ Action::Action(const Glib::ustring &id, pButton->signal_clicked() .connect(sigc::mem_fun(*this, &Action::on_button_click)); pButton->set_tooltip_text(tiptext); -#if WITH_GTKMM_3_0 parent.attach(*pButton, column, row, 1, 1); -#else - parent.attach(*pButton, column, column+1, row, row+1, Gtk::FILL, Gtk::FILL); -#endif } @@ -133,7 +122,7 @@ void ActionAlign::do_action(SPDesktop *desktop, int index) Inkscape::Preferences *prefs = Inkscape::Preferences::get(); bool sel_as_group = prefs->getBool("/dialogs/align/sel-as-groups"); - std::vector<SPItem*> selected(selection->itemList()); + std::vector<SPItem*> selected(selection->items().begin(), selection->items().end()); if (selected.empty()) return; const Coeffs &a = _allCoeffs[index]; @@ -145,10 +134,10 @@ void ActionAlign::do_action(SPDesktop *desktop, int index) switch (AlignTarget(prefs->getInt("/dialogs/align/align-to", 6))) { case LAST: - focus = SP_ITEM(*selected.begin()); + focus = SP_ITEM(*--(selected.end())); break; case FIRST: - focus = SP_ITEM(*--(selected.end())); + focus = SP_ITEM(*selected.begin()); break; case BIGGEST: focus = selection->largestItem(horiz); @@ -293,7 +282,7 @@ private : Inkscape::Selection *selection = desktop->getSelection(); if (!selection) return; - std::vector<SPItem*> selected(selection->itemList()); + std::vector<SPItem*> selected(selection->items().begin(), selection->items().end()); if (selected.empty()) return; //Check 2 or more selected objects @@ -447,11 +436,7 @@ public: Action(id, tiptext, row, column + 4, dialog.removeOverlap_table(), dialog) { -#if WITH_GTKMM_3_0 dialog.removeOverlap_table().set_column_spacing(3); -#else - dialog.removeOverlap_table().set_col_spacings(3); -#endif removeOverlapXGap.set_digits(1); removeOverlapXGap.set_size_request(60, -1); @@ -473,17 +458,10 @@ public: removeOverlapYGapLabel.set_text_with_mnemonic(C_("Gap", "_V:")); removeOverlapYGapLabel.set_mnemonic_widget(removeOverlapYGap); -#if WITH_GTKMM_3_0 dialog.removeOverlap_table().attach(removeOverlapXGapLabel, column, row, 1, 1); dialog.removeOverlap_table().attach(removeOverlapXGap, column+1, row, 1, 1); dialog.removeOverlap_table().attach(removeOverlapYGapLabel, column+2, row, 1, 1); dialog.removeOverlap_table().attach(removeOverlapYGap, column+3, row, 1, 1); -#else - dialog.removeOverlap_table().attach(removeOverlapXGapLabel, column, column+1, row, row+1, Gtk::FILL, Gtk::FILL); - dialog.removeOverlap_table().attach(removeOverlapXGap, column+1, column+2, row, row+1, Gtk::FILL, Gtk::FILL); - dialog.removeOverlap_table().attach(removeOverlapYGapLabel, column+2, column+3, row, row+1, Gtk::FILL, Gtk::FILL); - dialog.removeOverlap_table().attach(removeOverlapYGap, column+3, column+4, row, row+1, Gtk::FILL, Gtk::FILL); -#endif } private : @@ -499,7 +477,9 @@ private : // xGap and yGap are the minimum space required between bounding rectangles. double const xGap = removeOverlapXGap.get_value(); double const yGap = removeOverlapYGap.get_value(); - removeoverlap(_dialog.getDesktop()->getSelection()->itemList(), xGap, yGap); + auto tmp = _dialog.getDesktop()->getSelection()->items(); + std::vector<SPItem *> vec(tmp.begin(), tmp.end()); + removeoverlap(vec, xGap, yGap); // restore compensation setting prefs->setInt("/options/clonecompensation/value", saved_compensation); @@ -530,8 +510,9 @@ private : int saved_compensation = prefs->getInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED); prefs->setInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED); - graphlayout(_dialog.getDesktop()->getSelection()->itemList()); - + auto tmp = _dialog.getDesktop()->getSelection()->items(); + std::vector<SPItem *> vec(tmp.begin(), tmp.end()); + graphlayout(vec); // restore compensation setting prefs->setInt("/options/clonecompensation/value", saved_compensation); @@ -590,7 +571,7 @@ private : Inkscape::Selection *selection = desktop->getSelection(); if (!selection) return; - std::vector<SPItem*> selected(selection->itemList()); + std::vector<SPItem*> selected(selection->items().begin(), selection->items().end()); if (selected.empty()) return; //Check 2 or more selected objects @@ -656,7 +637,8 @@ private : Inkscape::Preferences *prefs = Inkscape::Preferences::get(); int saved_compensation = prefs->getInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED); prefs->setInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED); - std::vector<SPItem*> x(_dialog.getDesktop()->getSelection()->itemList()); + auto tmp = _dialog.getDesktop()->getSelection()->items(); + std::vector<SPItem*> x(tmp.begin(), tmp.end()); unclump (x); // restore compensation setting @@ -687,7 +669,7 @@ private : Inkscape::Selection *selection = desktop->getSelection(); if (!selection) return; - std::vector<SPItem*> selected(selection->itemList()); + std::vector<SPItem*> selected(selection->items().begin(), selection->items().end()); if (selected.empty()) return; //Check 2 or more selected objects @@ -762,11 +744,7 @@ public : guint row, guint column, AlignAndDistribute &dialog, -#if WITH_GTKMM_3_0 Gtk::Grid &table, -#else - Gtk::Table &table, -#endif Geom::Dim2 orientation, bool distribute): Action(id, tiptext, row, column, table, dialog), @@ -785,7 +763,7 @@ private : Inkscape::Selection *selection = desktop->getSelection(); if (!selection) return; - std::vector<SPItem*> selected(selection->itemList()); + std::vector<SPItem*> selected(selection->items().begin(), selection->items().end()); //Check 2 or more selected objects if (selected.size() < 2) return; @@ -939,19 +917,11 @@ AlignAndDistribute::AlignAndDistribute() _rearrangeFrame(_("Rearrange")), _removeOverlapFrame(_("Remove overlaps")), _nodesFrame(_("Nodes")), -#if WITH_GTKMM_3_0 _alignTable(), _distributeTable(), _rearrangeTable(), _removeOverlapTable(), _nodesTable(), -#else - _alignTable(2, 6, true), - _distributeTable(2, 6, true), - _rearrangeTable(1, 5, false), - _removeOverlapTable(1, 5, false), - _nodesTable(1, 4, true), -#endif _anchorLabel(_("Relative to: ")), _anchorLabelNode(_("Relative to: ")), _selgrpLabel(_("_Treat selection as group: "), 1) @@ -1316,13 +1286,8 @@ void AlignAndDistribute::addRandomizeButton(const Glib::ustring &id, const Glib: ); } -#if WITH_GTKMM_3_0 void AlignAndDistribute::addBaselineButton(const Glib::ustring &id, const Glib::ustring tiptext, guint row, guint col, Gtk::Grid &table, Geom::Dim2 orientation, bool distribute) -#else -void AlignAndDistribute::addBaselineButton(const Glib::ustring &id, const Glib::ustring tiptext, - guint row, guint col, Gtk::Table &table, Geom::Dim2 orientation, bool distribute) -#endif { _actionList.push_back( new ActionBaseline( diff --git a/src/ui/dialog/align-and-distribute.h b/src/ui/dialog/align-and-distribute.h index f8cc61af2..acb3d02ed 100644 --- a/src/ui/dialog/align-and-distribute.h +++ b/src/ui/dialog/align-and-distribute.h @@ -22,15 +22,11 @@ #include <gtkmm/frame.h> #include <gtkmm/comboboxtext.h> #include <gtkmm/label.h> -#include "2geom/rect.h" -#include "ui/dialog/desktop-tracker.h" - -#if WITH_GTKMM_3_0 #include <gtkmm/checkbutton.h> #include <gtkmm/grid.h> -#else -#include <gtkmm/table.h> -#endif + +#include "2geom/rect.h" +#include "ui/dialog/desktop-tracker.h" class SPItem; @@ -51,19 +47,11 @@ public: static AlignAndDistribute &getInstance() { return *new AlignAndDistribute(); } -#if WITH_GTKMM_3_0 Gtk::Grid &align_table(){return _alignTable;} Gtk::Grid &distribute_table(){return _distributeTable;} Gtk::Grid &rearrange_table(){return _rearrangeTable;} Gtk::Grid &removeOverlap_table(){return _removeOverlapTable;} Gtk::Grid &nodes_table(){return _nodesTable;} -#else - Gtk::Table &align_table(){return _alignTable;} - Gtk::Table &distribute_table(){return _distributeTable;} - Gtk::Table &rearrange_table(){return _rearrangeTable;} - Gtk::Table &removeOverlap_table(){return _removeOverlapTable;} - Gtk::Table &nodes_table(){return _nodesTable;} -#endif void setMode(bool nodeEdit); @@ -100,22 +88,13 @@ protected: guint row, guint col); void addRandomizeButton(const Glib::ustring &id, const Glib::ustring tiptext, guint row, guint col); -#if WITH_GTKMM_3_0 void addBaselineButton(const Glib::ustring &id, const Glib::ustring tiptext, guint row, guint col, Gtk::Grid &table, Geom::Dim2 orientation, bool distribute); -#else - void addBaselineButton(const Glib::ustring &id, const Glib::ustring tiptext, - guint row, guint col, Gtk::Table &table, Geom::Dim2 orientation, bool distribute); -#endif void setTargetDesktop(SPDesktop *desktop); std::list<Action *> _actionList; UI::Widget::Frame _alignFrame, _distributeFrame, _rearrangeFrame, _removeOverlapFrame, _nodesFrame; -#if WITH_GTKMM_3_0 Gtk::Grid _alignTable, _distributeTable, _rearrangeTable, _removeOverlapTable, _nodesTable; -#else - Gtk::Table _alignTable, _distributeTable, _rearrangeTable, _removeOverlapTable, _nodesTable; -#endif Gtk::HBox _anchorBox; Gtk::HBox _selgrpBox; Gtk::VBox _alignBox; @@ -163,11 +142,7 @@ public : Action(const Glib::ustring &id, const Glib::ustring &tiptext, guint row, guint column, - #if WITH_GTKMM_3_0 - Gtk::Grid &parent, - #else - Gtk::Table &parent, - #endif + Gtk::Grid &parent, AlignAndDistribute &dialog); virtual ~Action(){} @@ -178,12 +153,7 @@ private : virtual void on_button_click(){} Glib::ustring _id; - -#if WITH_GTKMM_3_0 Gtk::Grid &_parent; -#else - Gtk::Table &_parent; -#endif }; diff --git a/src/ui/dialog/calligraphic-profile-rename.cpp b/src/ui/dialog/calligraphic-profile-rename.cpp index 9ae22db2d..50dae0fd8 100644 --- a/src/ui/dialog/calligraphic-profile-rename.cpp +++ b/src/ui/dialog/calligraphic-profile-rename.cpp @@ -16,12 +16,7 @@ #include "calligraphic-profile-rename.h" #include <glibmm/i18n.h> #include <gtkmm/stock.h> - -#if WITH_GTKMM_3_0 -# include <gtkmm/grid.h> -#else -# include <gtkmm/table.h> -#endif +#include <gtkmm/grid.h> #include "desktop.h" @@ -30,40 +25,24 @@ namespace UI { namespace Dialog { CalligraphicProfileRename::CalligraphicProfileRename() : -#if WITH_GTKMM_3_0 _layout_table(Gtk::manage(new Gtk::Grid())), -#else - _layout_table(Gtk::manage(new Gtk::Table(1, 2))), -#endif _applied(false) { set_title(_("Edit profile")); -#if WITH_GTKMM_3_0 - Gtk::Box *mainVBox = get_content_area(); + auto mainVBox = get_content_area(); _layout_table->set_column_spacing(4); _layout_table->set_row_spacing(4); -#else - Gtk::Box *mainVBox = get_vbox(); - _layout_table->set_spacings(4); -#endif _profile_name_entry.set_activates_default(true); _profile_name_label.set_label(_("Profile name:")); _profile_name_label.set_alignment(1.0, 0.5); -#if WITH_GTKMM_3_0 _layout_table->attach(_profile_name_label, 0, 0, 1, 1); _profile_name_entry.set_hexpand(); _layout_table->attach(_profile_name_entry, 1, 0, 1, 1); -#else - _layout_table->attach(_profile_name_label, - 0, 1, 0, 1, Gtk::FILL, Gtk::FILL); - _layout_table->attach(_profile_name_entry, - 1, 2, 0, 1, Gtk::FILL | Gtk::EXPAND, Gtk::FILL); -#endif mainVBox->pack_start(*_layout_table, false, false, 4); // Buttons diff --git a/src/ui/dialog/calligraphic-profile-rename.h b/src/ui/dialog/calligraphic-profile-rename.h index 4ef71900b..b7a97a1e7 100644 --- a/src/ui/dialog/calligraphic-profile-rename.h +++ b/src/ui/dialog/calligraphic-profile-rename.h @@ -20,11 +20,7 @@ #include <gtkmm/label.h> namespace Gtk { -#if WITH_GTKMM_3_0 class Grid; -#else -class Table; -#endif } class SPDesktop; @@ -59,12 +55,7 @@ protected: Gtk::Label _profile_name_label; Gtk::Entry _profile_name_entry; - -#if WITH_GTKMM_3_0 Gtk::Grid* _layout_table; -#else - Gtk::Table* _layout_table; -#endif Gtk::Button _close_button; Gtk::Button _delete_button; diff --git a/src/ui/dialog/clonetiler.cpp b/src/ui/dialog/clonetiler.cpp index b727c87ee..8e9d3dbbf 100644 --- a/src/ui/dialog/clonetiler.cpp +++ b/src/ui/dialog/clonetiler.cpp @@ -15,39 +15,34 @@ */ #ifdef HAVE_CONFIG_H -# include "config.h" +#include "config.h" #endif #include "clonetiler.h" -#include <climits> - #include <glibmm/i18n.h> #include <2geom/transforms.h> + #include <gtkmm/adjustment.h> +#include <gtkmm/checkbutton.h> +#include <gtkmm/combobox.h> +#include <gtkmm/liststore.h> +#include <gtkmm/radiobutton.h> #include "desktop.h" #include "display/cairo-utils.h" #include "display/drawing.h" #include "display/drawing-context.h" -#include "display/drawing-item.h" #include "document.h" #include "document-undo.h" #include "filter-chemistry.h" #include "ui/widget/unit-menu.h" -#include "util/units.h" #include "helper/window.h" #include "inkscape.h" #include "ui/interface.h" -#include "macros.h" #include "message-stack.h" -#include "preferences.h" -#include "selection.h" -#include "sp-filter.h" #include "sp-namedview.h" -#include "sp-use.h" -#include "style.h" #include "svg/svg-color.h" #include "svg/svg.h" #include "ui/icon-names.h" @@ -55,8 +50,6 @@ #include "unclump.h" #include "verbs.h" #include "widgets/icon.h" -#include "xml/repr.h" -#include "sp-root.h" using Inkscape::DocumentUndo; using Inkscape::Util::unit_table; @@ -75,10 +68,8 @@ static unsigned trace_visionkey; static gdouble trace_zoom; static SPDocument *trace_doc = NULL; - CloneTiler::CloneTiler () : UI::Widget::Panel ("", "/dialogs/clonetiler/", SP_VERB_DIALOG_CLONETILER), - dlg(NULL), desktop(NULL), deskTrack(), table_row_labels(NULL) @@ -87,16 +78,10 @@ CloneTiler::CloneTiler () : contents->set_spacing(0); { - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - - dlg = GTK_WIDGET(gobj()); + auto prefs = Inkscape::Preferences::get(); -#if GTK_CHECK_VERSION(3,0,0) - GtkWidget *mainbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 4); + auto mainbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 4); gtk_box_set_homogeneous(GTK_BOX(mainbox), FALSE); -#else - GtkWidget *mainbox = gtk_vbox_new(FALSE, 4); -#endif gtk_container_set_border_width (GTK_CONTAINER (mainbox), 6); contents->pack_start (*Gtk::manage(Glib::wrap(mainbox)), true, true, 0); @@ -107,7 +92,7 @@ CloneTiler::CloneTiler () : // Symmetry { - GtkWidget *vb = clonetiler_new_tab (nb, _("_Symmetry")); + GtkWidget *vb = new_tab (nb, _("_Symmetry")); /* TRANSLATORS: For the following 17 symmetry groups, see * http://www.bib.ulb.ac.be/coursmath/doc/17.htm (visual examples); @@ -116,7 +101,7 @@ CloneTiler::CloneTiler () : */ struct SymGroups { gint group; - gchar const *label; + Glib::ustring label; } const sym_groups[] = { // TRANSLATORS: "translation" means "shift" / "displacement" here. {TILE_P1, _("<b>P1</b>: simple translation")}, @@ -142,42 +127,36 @@ CloneTiler::CloneTiler () : gint current = prefs->getInt(prefs_path + "symmetrygroup", 0); - // Create a list structure containing all the data to be displayed in - // the symmetry group combo box. - GtkListStore *store = gtk_list_store_new (1, G_TYPE_STRING); - GtkTreeIter iter; - - for (unsigned j = 0; j < G_N_ELEMENTS(sym_groups); ++j) { - SymGroups const &sg = sym_groups[j]; + // Add a new combo box widget with the list of symmetry groups to the vbox + auto combo = Gtk::manage(new Gtk::ComboBoxText()); + combo->set_tooltip_text(_("Select one of the 17 symmetry groups for the tiling")); - // Add the description of the symgroup to a new row - gtk_list_store_append(store, &iter); - gtk_list_store_set(store, &iter, 0, sg.label, -1); - } + // Hack to add markup support + auto cell_list = gtk_cell_layout_get_cells(GTK_CELL_LAYOUT(combo->gobj())); + gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combo->gobj()), + GTK_CELL_RENDERER(cell_list->data), + "markup", 0, NULL); - // Add a new combo box widget with the list of symmetry groups to the vbox - GtkWidget *combo = gtk_combo_box_new_with_model (GTK_TREE_MODEL (store)); - gtk_widget_set_tooltip_text (combo, _("Select one of the 17 symmetry groups for the tiling")); - gtk_box_pack_start (GTK_BOX (vb), combo, FALSE, FALSE, SB_MARGIN); + for (unsigned j = 0; j < G_N_ELEMENTS(sym_groups); ++j) { + SymGroups const &sg = sym_groups[j]; - // Specify the rendering of data from the list in a combo box cell - GtkCellRenderer *renderer = gtk_cell_renderer_text_new (); - gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), renderer, FALSE); - gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combo), renderer, "markup", 0, NULL); + // Add the description of the symgroup to a new row + combo->append(sg.label); + } - gtk_combo_box_set_active (GTK_COMBO_BOX (combo), current); + gtk_box_pack_start (GTK_BOX (vb), GTK_WIDGET(combo->gobj()), FALSE, FALSE, SB_MARGIN); - g_signal_connect(G_OBJECT(combo), "changed", - G_CALLBACK(clonetiler_symgroup_changed), NULL); + combo->set_active(current); + combo->signal_changed().connect(sigc::bind(sigc::mem_fun(*this, &CloneTiler::symgroup_changed), combo)); } table_row_labels = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); // Shift { - GtkWidget *vb = clonetiler_new_tab (nb, _("S_hift")); + GtkWidget *vb = new_tab (nb, _("S_hift")); - GtkWidget *table = clonetiler_table_x_y_rand (3); + GtkWidget *table = table_x_y_rand (3); gtk_box_pack_start (GTK_BOX (vb), table, FALSE, FALSE, 0); // X @@ -187,29 +166,29 @@ CloneTiler::CloneTiler () : // xgettext:no-c-format gtk_label_set_markup (GTK_LABEL(l), _("<b>Shift X:</b>")); gtk_size_group_add_widget(table_row_labels, l); - clonetiler_table_attach (table, l, 1, 2, 1); + table_attach (table, l, 1, 2, 1); } { - GtkWidget *l = clonetiler_spinbox ( + auto l = spinbox ( // xgettext:no-c-format _("Horizontal shift per row (in % of tile width)"), "shiftx_per_j", -10000, 10000, "%"); - clonetiler_table_attach (table, l, 0, 2, 2); + table_attach (table, l, 0, 2, 2); } { - GtkWidget *l = clonetiler_spinbox ( + auto l = spinbox ( // xgettext:no-c-format _("Horizontal shift per column (in % of tile width)"), "shiftx_per_i", -10000, 10000, "%"); - clonetiler_table_attach (table, l, 0, 2, 3); + table_attach (table, l, 0, 2, 3); } { - GtkWidget *l = clonetiler_spinbox (_("Randomize the horizontal shift by this percentage"), "shiftx_rand", + auto l = spinbox (_("Randomize the horizontal shift by this percentage"), "shiftx_rand", 0, 1000, "%"); - clonetiler_table_attach (table, l, 0, 2, 4); + table_attach (table, l, 0, 2, 4); } // Y @@ -219,30 +198,30 @@ CloneTiler::CloneTiler () : // xgettext:no-c-format gtk_label_set_markup (GTK_LABEL(l), _("<b>Shift Y:</b>")); gtk_size_group_add_widget(table_row_labels, l); - clonetiler_table_attach (table, l, 1, 3, 1); + table_attach (table, l, 1, 3, 1); } { - GtkWidget *l = clonetiler_spinbox ( + auto l = spinbox ( // xgettext:no-c-format _("Vertical shift per row (in % of tile height)"), "shifty_per_j", -10000, 10000, "%"); - clonetiler_table_attach (table, l, 0, 3, 2); + table_attach (table, l, 0, 3, 2); } { - GtkWidget *l = clonetiler_spinbox ( + auto l = spinbox ( // xgettext:no-c-format _("Vertical shift per column (in % of tile height)"), "shifty_per_i", -10000, 10000, "%"); - clonetiler_table_attach (table, l, 0, 3, 3); + table_attach (table, l, 0, 3, 3); } { - GtkWidget *l = clonetiler_spinbox ( + auto l = spinbox ( _("Randomize the vertical shift by this percentage"), "shifty_rand", 0, 1000, "%"); - clonetiler_table_attach (table, l, 0, 3, 4); + table_attach (table, l, 0, 3, 4); } // Exponent @@ -250,21 +229,21 @@ CloneTiler::CloneTiler () : GtkWidget *l = gtk_label_new (""); gtk_label_set_markup (GTK_LABEL(l), _("<b>Exponent:</b>")); gtk_size_group_add_widget(table_row_labels, l); - clonetiler_table_attach (table, l, 1, 4, 1); + table_attach (table, l, 1, 4, 1); } { - GtkWidget *l = clonetiler_spinbox ( + auto l = spinbox ( _("Whether rows are spaced evenly (1), converge (<1) or diverge (>1)"), "shifty_exp", 0, 10, "", true); - clonetiler_table_attach (table, l, 0, 4, 2); + table_attach (table, l, 0, 4, 2); } { - GtkWidget *l = clonetiler_spinbox ( + auto l = spinbox ( _("Whether columns are spaced evenly (1), converge (<1) or diverge (>1)"), "shiftx_exp", 0, 10, "", true); - clonetiler_table_attach (table, l, 0, 4, 3); + table_attach (table, l, 0, 4, 3); } { // alternates @@ -272,17 +251,17 @@ CloneTiler::CloneTiler () : // TRANSLATORS: "Alternate" is a verb here gtk_label_set_markup (GTK_LABEL(l), _("<small>Alternate:</small>")); gtk_size_group_add_widget(table_row_labels, l); - clonetiler_table_attach (table, l, 1, 5, 1); + table_attach (table, l, 1, 5, 1); } { - GtkWidget *l = clonetiler_checkbox (_("Alternate the sign of shifts for each row"), "shifty_alternate"); - clonetiler_table_attach (table, l, 0, 5, 2); + auto l = checkbox (_("Alternate the sign of shifts for each row"), "shifty_alternate"); + table_attach (table, l, 0, 5, 2); } { - GtkWidget *l = clonetiler_checkbox (_("Alternate the sign of shifts for each column"), "shiftx_alternate"); - clonetiler_table_attach (table, l, 0, 5, 3); + auto l = checkbox (_("Alternate the sign of shifts for each column"), "shiftx_alternate"); + table_attach (table, l, 0, 5, 3); } { // Cumulate @@ -290,17 +269,17 @@ CloneTiler::CloneTiler () : // TRANSLATORS: "Cumulate" is a verb here gtk_label_set_markup (GTK_LABEL(l), _("<small>Cumulate:</small>")); gtk_size_group_add_widget(table_row_labels, l); - clonetiler_table_attach (table, l, 1, 6, 1); + table_attach (table, l, 1, 6, 1); } { - GtkWidget *l = clonetiler_checkbox (_("Cumulate the shifts for each row"), "shifty_cumulate"); - clonetiler_table_attach (table, l, 0, 6, 2); + auto l = checkbox (_("Cumulate the shifts for each row"), "shifty_cumulate"); + table_attach (table, l, 0, 6, 2); } { - GtkWidget *l = clonetiler_checkbox (_("Cumulate the shifts for each column"), "shiftx_cumulate"); - clonetiler_table_attach (table, l, 0, 6, 3); + auto l = checkbox (_("Cumulate the shifts for each column"), "shiftx_cumulate"); + table_attach (table, l, 0, 6, 3); } { // Exclude tile width and height in shift @@ -308,17 +287,17 @@ CloneTiler::CloneTiler () : // TRANSLATORS: "Cumulate" is a verb here gtk_label_set_markup (GTK_LABEL(l), _("<small>Exclude tile:</small>")); gtk_size_group_add_widget(table_row_labels, l); - clonetiler_table_attach (table, l, 1, 7, 1); + table_attach (table, l, 1, 7, 1); } { - GtkWidget *l = clonetiler_checkbox (_("Exclude tile height in shift"), "shifty_excludeh"); - clonetiler_table_attach (table, l, 0, 7, 2); + auto l = checkbox (_("Exclude tile height in shift"), "shifty_excludeh"); + table_attach (table, l, 0, 7, 2); } { - GtkWidget *l = clonetiler_checkbox (_("Exclude tile width in shift"), "shiftx_excludew"); - clonetiler_table_attach (table, l, 0, 7, 3); + auto l = checkbox (_("Exclude tile width in shift"), "shiftx_excludew"); + table_attach (table, l, 0, 7, 3); } } @@ -326,9 +305,9 @@ CloneTiler::CloneTiler () : // Scale { - GtkWidget *vb = clonetiler_new_tab (nb, _("Sc_ale")); + GtkWidget *vb = new_tab (nb, _("Sc_ale")); - GtkWidget *table = clonetiler_table_x_y_rand (2); + GtkWidget *table = table_x_y_rand (2); gtk_box_pack_start (GTK_BOX (vb), table, FALSE, FALSE, 0); // X @@ -336,29 +315,29 @@ CloneTiler::CloneTiler () : GtkWidget *l = gtk_label_new (""); gtk_label_set_markup (GTK_LABEL(l), _("<b>Scale X:</b>")); gtk_size_group_add_widget(table_row_labels, l); - clonetiler_table_attach (table, l, 1, 2, 1); + table_attach (table, l, 1, 2, 1); } { - GtkWidget *l = clonetiler_spinbox ( + auto l = spinbox ( // xgettext:no-c-format _("Horizontal scale per row (in % of tile width)"), "scalex_per_j", -100, 1000, "%"); - clonetiler_table_attach (table, l, 0, 2, 2); + table_attach (table, l, 0, 2, 2); } { - GtkWidget *l = clonetiler_spinbox ( + auto l = spinbox ( // xgettext:no-c-format _("Horizontal scale per column (in % of tile width)"), "scalex_per_i", -100, 1000, "%"); - clonetiler_table_attach (table, l, 0, 2, 3); + table_attach (table, l, 0, 2, 3); } { - GtkWidget *l = clonetiler_spinbox (_("Randomize the horizontal scale by this percentage"), "scalex_rand", + auto l = spinbox (_("Randomize the horizontal scale by this percentage"), "scalex_rand", 0, 1000, "%"); - clonetiler_table_attach (table, l, 0, 2, 4); + table_attach (table, l, 0, 2, 4); } // Y @@ -366,29 +345,29 @@ CloneTiler::CloneTiler () : GtkWidget *l = gtk_label_new (""); gtk_label_set_markup (GTK_LABEL(l), _("<b>Scale Y:</b>")); gtk_size_group_add_widget(table_row_labels, l); - clonetiler_table_attach (table, l, 1, 3, 1); + table_attach (table, l, 1, 3, 1); } { - GtkWidget *l = clonetiler_spinbox ( + auto l = spinbox ( // xgettext:no-c-format _("Vertical scale per row (in % of tile height)"), "scaley_per_j", -100, 1000, "%"); - clonetiler_table_attach (table, l, 0, 3, 2); + table_attach (table, l, 0, 3, 2); } { - GtkWidget *l = clonetiler_spinbox ( + auto l = spinbox ( // xgettext:no-c-format _("Vertical scale per column (in % of tile height)"), "scaley_per_i", -100, 1000, "%"); - clonetiler_table_attach (table, l, 0, 3, 3); + table_attach (table, l, 0, 3, 3); } { - GtkWidget *l = clonetiler_spinbox (_("Randomize the vertical scale by this percentage"), "scaley_rand", + auto l = spinbox (_("Randomize the vertical scale by this percentage"), "scaley_rand", 0, 1000, "%"); - clonetiler_table_attach (table, l, 0, 3, 4); + table_attach (table, l, 0, 3, 4); } // Exponent @@ -396,19 +375,19 @@ CloneTiler::CloneTiler () : GtkWidget *l = gtk_label_new (""); gtk_label_set_markup (GTK_LABEL(l), _("<b>Exponent:</b>")); gtk_size_group_add_widget(table_row_labels, l); - clonetiler_table_attach (table, l, 1, 4, 1); + table_attach (table, l, 1, 4, 1); } { - GtkWidget *l = clonetiler_spinbox (_("Whether row scaling is uniform (1), converge (<1) or diverge (>1)"), "scaley_exp", + auto l = spinbox (_("Whether row scaling is uniform (1), converge (<1) or diverge (>1)"), "scaley_exp", 0, 10, "", true); - clonetiler_table_attach (table, l, 0, 4, 2); + table_attach (table, l, 0, 4, 2); } { - GtkWidget *l = clonetiler_spinbox (_("Whether column scaling is uniform (1), converge (<1) or diverge (>1)"), "scalex_exp", + auto l = spinbox (_("Whether column scaling is uniform (1), converge (<1) or diverge (>1)"), "scalex_exp", 0, 10, "", true); - clonetiler_table_attach (table, l, 0, 4, 3); + table_attach (table, l, 0, 4, 3); } // Logarithmic (as in logarithmic spiral) @@ -416,19 +395,19 @@ CloneTiler::CloneTiler () : GtkWidget *l = gtk_label_new (""); gtk_label_set_markup (GTK_LABEL(l), _("<b>Base:</b>")); gtk_size_group_add_widget(table_row_labels, l); - clonetiler_table_attach (table, l, 1, 5, 1); + table_attach (table, l, 1, 5, 1); } { - GtkWidget *l = clonetiler_spinbox (_("Base for a logarithmic spiral: not used (0), converge (<1), or diverge (>1)"), "scaley_log", + auto l = spinbox (_("Base for a logarithmic spiral: not used (0), converge (<1), or diverge (>1)"), "scaley_log", 0, 10, "", false); - clonetiler_table_attach (table, l, 0, 5, 2); + table_attach (table, l, 0, 5, 2); } { - GtkWidget *l = clonetiler_spinbox (_("Base for a logarithmic spiral: not used (0), converge (<1), or diverge (>1)"), "scalex_log", + auto l = spinbox (_("Base for a logarithmic spiral: not used (0), converge (<1), or diverge (>1)"), "scalex_log", 0, 10, "", false); - clonetiler_table_attach (table, l, 0, 5, 3); + table_attach (table, l, 0, 5, 3); } { // alternates @@ -436,17 +415,17 @@ CloneTiler::CloneTiler () : // TRANSLATORS: "Alternate" is a verb here gtk_label_set_markup (GTK_LABEL(l), _("<small>Alternate:</small>")); gtk_size_group_add_widget(table_row_labels, l); - clonetiler_table_attach (table, l, 1, 6, 1); + table_attach (table, l, 1, 6, 1); } { - GtkWidget *l = clonetiler_checkbox (_("Alternate the sign of scales for each row"), "scaley_alternate"); - clonetiler_table_attach (table, l, 0, 6, 2); + auto l = checkbox (_("Alternate the sign of scales for each row"), "scaley_alternate"); + table_attach (table, l, 0, 6, 2); } { - GtkWidget *l = clonetiler_checkbox (_("Alternate the sign of scales for each column"), "scalex_alternate"); - clonetiler_table_attach (table, l, 0, 6, 3); + auto l = checkbox (_("Alternate the sign of scales for each column"), "scalex_alternate"); + table_attach (table, l, 0, 6, 3); } { // Cumulate @@ -454,17 +433,17 @@ CloneTiler::CloneTiler () : // TRANSLATORS: "Cumulate" is a verb here gtk_label_set_markup (GTK_LABEL(l), _("<small>Cumulate:</small>")); gtk_size_group_add_widget(table_row_labels, l); - clonetiler_table_attach (table, l, 1, 7, 1); + table_attach (table, l, 1, 7, 1); } { - GtkWidget *l = clonetiler_checkbox (_("Cumulate the scales for each row"), "scaley_cumulate"); - clonetiler_table_attach (table, l, 0, 7, 2); + auto l = checkbox (_("Cumulate the scales for each row"), "scaley_cumulate"); + table_attach (table, l, 0, 7, 2); } { - GtkWidget *l = clonetiler_checkbox (_("Cumulate the scales for each column"), "scalex_cumulate"); - clonetiler_table_attach (table, l, 0, 7, 3); + auto l = checkbox (_("Cumulate the scales for each column"), "scalex_cumulate"); + table_attach (table, l, 0, 7, 3); } } @@ -472,9 +451,9 @@ CloneTiler::CloneTiler () : // Rotation { - GtkWidget *vb = clonetiler_new_tab (nb, _("_Rotation")); + GtkWidget *vb = new_tab (nb, _("_Rotation")); - GtkWidget *table = clonetiler_table_x_y_rand (1); + GtkWidget *table = table_x_y_rand (1); gtk_box_pack_start (GTK_BOX (vb), table, FALSE, FALSE, 0); // Angle @@ -482,29 +461,29 @@ CloneTiler::CloneTiler () : GtkWidget *l = gtk_label_new (""); gtk_label_set_markup (GTK_LABEL(l), _("<b>Angle:</b>")); gtk_size_group_add_widget(table_row_labels, l); - clonetiler_table_attach (table, l, 1, 2, 1); + table_attach (table, l, 1, 2, 1); } { - GtkWidget *l = clonetiler_spinbox ( + auto l = spinbox ( // xgettext:no-c-format _("Rotate tiles by this angle for each row"), "rotate_per_j", -180, 180, "°"); - clonetiler_table_attach (table, l, 0, 2, 2); + table_attach (table, l, 0, 2, 2); } { - GtkWidget *l = clonetiler_spinbox ( + auto l = spinbox ( // xgettext:no-c-format _("Rotate tiles by this angle for each column"), "rotate_per_i", -180, 180, "°"); - clonetiler_table_attach (table, l, 0, 2, 3); + table_attach (table, l, 0, 2, 3); } { - GtkWidget *l = clonetiler_spinbox (_("Randomize the rotation angle by this percentage"), "rotate_rand", + auto l = spinbox (_("Randomize the rotation angle by this percentage"), "rotate_rand", 0, 100, "%"); - clonetiler_table_attach (table, l, 0, 2, 4); + table_attach (table, l, 0, 2, 4); } { // alternates @@ -512,17 +491,17 @@ CloneTiler::CloneTiler () : // TRANSLATORS: "Alternate" is a verb here gtk_label_set_markup (GTK_LABEL(l), _("<small>Alternate:</small>")); gtk_size_group_add_widget(table_row_labels, l); - clonetiler_table_attach (table, l, 1, 3, 1); + table_attach (table, l, 1, 3, 1); } { - GtkWidget *l = clonetiler_checkbox (_("Alternate the rotation direction for each row"), "rotate_alternatej"); - clonetiler_table_attach (table, l, 0, 3, 2); + auto l = checkbox (_("Alternate the rotation direction for each row"), "rotate_alternatej"); + table_attach (table, l, 0, 3, 2); } { - GtkWidget *l = clonetiler_checkbox (_("Alternate the rotation direction for each column"), "rotate_alternatei"); - clonetiler_table_attach (table, l, 0, 3, 3); + auto l = checkbox (_("Alternate the rotation direction for each column"), "rotate_alternatei"); + table_attach (table, l, 0, 3, 3); } { // Cumulate @@ -530,17 +509,17 @@ CloneTiler::CloneTiler () : // TRANSLATORS: "Cumulate" is a verb here gtk_label_set_markup (GTK_LABEL(l), _("<small>Cumulate:</small>")); gtk_size_group_add_widget(table_row_labels, l); - clonetiler_table_attach (table, l, 1, 4, 1); + table_attach (table, l, 1, 4, 1); } { - GtkWidget *l = clonetiler_checkbox (_("Cumulate the rotation for each row"), "rotate_cumulatej"); - clonetiler_table_attach (table, l, 0, 4, 2); + auto l = checkbox (_("Cumulate the rotation for each row"), "rotate_cumulatej"); + table_attach (table, l, 0, 4, 2); } { - GtkWidget *l = clonetiler_checkbox (_("Cumulate the rotation for each column"), "rotate_cumulatei"); - clonetiler_table_attach (table, l, 0, 4, 3); + auto l = checkbox (_("Cumulate the rotation for each column"), "rotate_cumulatei"); + table_attach (table, l, 0, 4, 3); } } @@ -548,9 +527,9 @@ CloneTiler::CloneTiler () : // Blur and opacity { - GtkWidget *vb = clonetiler_new_tab (nb, _("_Blur & opacity")); + GtkWidget *vb = new_tab (nb, _("_Blur & opacity")); - GtkWidget *table = clonetiler_table_x_y_rand (1); + GtkWidget *table = table_x_y_rand (1); gtk_box_pack_start (GTK_BOX (vb), table, FALSE, FALSE, 0); @@ -559,25 +538,25 @@ CloneTiler::CloneTiler () : GtkWidget *l = gtk_label_new (""); gtk_label_set_markup (GTK_LABEL(l), _("<b>Blur:</b>")); gtk_size_group_add_widget(table_row_labels, l); - clonetiler_table_attach (table, l, 1, 2, 1); + table_attach (table, l, 1, 2, 1); } { - GtkWidget *l = clonetiler_spinbox (_("Blur tiles by this percentage for each row"), "blur_per_j", + auto l = spinbox (_("Blur tiles by this percentage for each row"), "blur_per_j", 0, 100, "%"); - clonetiler_table_attach (table, l, 0, 2, 2); + table_attach (table, l, 0, 2, 2); } { - GtkWidget *l = clonetiler_spinbox (_("Blur tiles by this percentage for each column"), "blur_per_i", + auto l = spinbox (_("Blur tiles by this percentage for each column"), "blur_per_i", 0, 100, "%"); - clonetiler_table_attach (table, l, 0, 2, 3); + table_attach (table, l, 0, 2, 3); } { - GtkWidget *l = clonetiler_spinbox (_("Randomize the tile blur by this percentage"), "blur_rand", + auto l = spinbox (_("Randomize the tile blur by this percentage"), "blur_rand", 0, 100, "%"); - clonetiler_table_attach (table, l, 0, 2, 4); + table_attach (table, l, 0, 2, 4); } { // alternates @@ -585,17 +564,17 @@ CloneTiler::CloneTiler () : // TRANSLATORS: "Alternate" is a verb here gtk_label_set_markup (GTK_LABEL(l), _("<small>Alternate:</small>")); gtk_size_group_add_widget(table_row_labels, l); - clonetiler_table_attach (table, l, 1, 3, 1); + table_attach (table, l, 1, 3, 1); } { - GtkWidget *l = clonetiler_checkbox (_("Alternate the sign of blur change for each row"), "blur_alternatej"); - clonetiler_table_attach (table, l, 0, 3, 2); + auto l = checkbox (_("Alternate the sign of blur change for each row"), "blur_alternatej"); + table_attach (table, l, 0, 3, 2); } { - GtkWidget *l = clonetiler_checkbox (_("Alternate the sign of blur change for each column"), "blur_alternatei"); - clonetiler_table_attach (table, l, 0, 3, 3); + auto l = checkbox (_("Alternate the sign of blur change for each column"), "blur_alternatei"); + table_attach (table, l, 0, 3, 3); } @@ -605,25 +584,25 @@ CloneTiler::CloneTiler () : GtkWidget *l = gtk_label_new (""); gtk_label_set_markup (GTK_LABEL(l), _("<b>Opacity:</b>")); gtk_size_group_add_widget(table_row_labels, l); - clonetiler_table_attach (table, l, 1, 4, 1); + table_attach (table, l, 1, 4, 1); } { - GtkWidget *l = clonetiler_spinbox (_("Decrease tile opacity by this percentage for each row"), "opacity_per_j", + auto l = spinbox (_("Decrease tile opacity by this percentage for each row"), "opacity_per_j", 0, 100, "%"); - clonetiler_table_attach (table, l, 0, 4, 2); + table_attach (table, l, 0, 4, 2); } { - GtkWidget *l = clonetiler_spinbox (_("Decrease tile opacity by this percentage for each column"), "opacity_per_i", + auto l = spinbox (_("Decrease tile opacity by this percentage for each column"), "opacity_per_i", 0, 100, "%"); - clonetiler_table_attach (table, l, 0, 4, 3); + table_attach (table, l, 0, 4, 3); } { - GtkWidget *l = clonetiler_spinbox (_("Randomize the tile opacity by this percentage"), "opacity_rand", + auto l = spinbox (_("Randomize the tile opacity by this percentage"), "opacity_rand", 0, 100, "%"); - clonetiler_table_attach (table, l, 0, 4, 4); + table_attach (table, l, 0, 4, 4); } { // alternates @@ -631,39 +610,35 @@ CloneTiler::CloneTiler () : // TRANSLATORS: "Alternate" is a verb here gtk_label_set_markup (GTK_LABEL(l), _("<small>Alternate:</small>")); gtk_size_group_add_widget(table_row_labels, l); - clonetiler_table_attach (table, l, 1, 5, 1); + table_attach (table, l, 1, 5, 1); } { - GtkWidget *l = clonetiler_checkbox (_("Alternate the sign of opacity change for each row"), "opacity_alternatej"); - clonetiler_table_attach (table, l, 0, 5, 2); + auto l = checkbox (_("Alternate the sign of opacity change for each row"), "opacity_alternatej"); + table_attach (table, l, 0, 5, 2); } { - GtkWidget *l = clonetiler_checkbox (_("Alternate the sign of opacity change for each column"), "opacity_alternatei"); - clonetiler_table_attach (table, l, 0, 5, 3); + auto l = checkbox (_("Alternate the sign of opacity change for each column"), "opacity_alternatei"); + table_attach (table, l, 0, 5, 3); } } // Color { - GtkWidget *vb = clonetiler_new_tab (nb, _("Co_lor")); + GtkWidget *vb = new_tab (nb, _("Co_lor")); { -#if GTK_CHECK_VERSION(3,0,0) - GtkWidget *hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); + auto hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); gtk_box_set_homogeneous(GTK_BOX(hb), FALSE); -#else - GtkWidget *hb = gtk_hbox_new (FALSE, 0); -#endif GtkWidget *l = gtk_label_new (_("Initial color: ")); gtk_box_pack_start (GTK_BOX (hb), l, FALSE, FALSE, 0); guint32 rgba = 0x000000ff | sp_svg_read_color (prefs->getString(prefs_path + "initial_color").data(), 0x000000ff); color_picker = new Inkscape::UI::Widget::ColorPicker (*new Glib::ustring(_("Initial color of tiled clones")), *new Glib::ustring(_("Initial color for clones (works only if the original has unset fill or stroke or on spray tool in copy mode)")), rgba, false); - color_changed_connection = color_picker->connectChanged (sigc::ptr_fun(on_picker_color_changed)); + color_changed_connection = color_picker->connectChanged(sigc::mem_fun(*this, &CloneTiler::on_picker_color_changed)); gtk_box_pack_start (GTK_BOX (hb), reinterpret_cast<GtkWidget*>(color_picker->gobj()), FALSE, FALSE, 0); @@ -671,7 +646,7 @@ CloneTiler::CloneTiler () : } - GtkWidget *table = clonetiler_table_x_y_rand (3); + GtkWidget *table = table_x_y_rand (3); gtk_box_pack_start (GTK_BOX (vb), table, FALSE, FALSE, 0); // Hue @@ -679,25 +654,25 @@ CloneTiler::CloneTiler () : GtkWidget *l = gtk_label_new (""); gtk_label_set_markup (GTK_LABEL(l), _("<b>H:</b>")); gtk_size_group_add_widget(table_row_labels, l); - clonetiler_table_attach (table, l, 1, 2, 1); + table_attach (table, l, 1, 2, 1); } { - GtkWidget *l = clonetiler_spinbox (_("Change the tile hue by this percentage for each row"), "hue_per_j", + auto l = spinbox (_("Change the tile hue by this percentage for each row"), "hue_per_j", -100, 100, "%"); - clonetiler_table_attach (table, l, 0, 2, 2); + table_attach (table, l, 0, 2, 2); } { - GtkWidget *l = clonetiler_spinbox (_("Change the tile hue by this percentage for each column"), "hue_per_i", + auto l = spinbox (_("Change the tile hue by this percentage for each column"), "hue_per_i", -100, 100, "%"); - clonetiler_table_attach (table, l, 0, 2, 3); + table_attach (table, l, 0, 2, 3); } { - GtkWidget *l = clonetiler_spinbox (_("Randomize the tile hue by this percentage"), "hue_rand", + auto l = spinbox (_("Randomize the tile hue by this percentage"), "hue_rand", 0, 100, "%"); - clonetiler_table_attach (table, l, 0, 2, 4); + table_attach (table, l, 0, 2, 4); } @@ -706,25 +681,25 @@ CloneTiler::CloneTiler () : GtkWidget *l = gtk_label_new (""); gtk_label_set_markup (GTK_LABEL(l), _("<b>S:</b>")); gtk_size_group_add_widget(table_row_labels, l); - clonetiler_table_attach (table, l, 1, 3, 1); + table_attach (table, l, 1, 3, 1); } { - GtkWidget *l = clonetiler_spinbox (_("Change the color saturation by this percentage for each row"), "saturation_per_j", + auto l = spinbox (_("Change the color saturation by this percentage for each row"), "saturation_per_j", -100, 100, "%"); - clonetiler_table_attach (table, l, 0, 3, 2); + table_attach (table, l, 0, 3, 2); } { - GtkWidget *l = clonetiler_spinbox (_("Change the color saturation by this percentage for each column"), "saturation_per_i", + auto l = spinbox (_("Change the color saturation by this percentage for each column"), "saturation_per_i", -100, 100, "%"); - clonetiler_table_attach (table, l, 0, 3, 3); + table_attach (table, l, 0, 3, 3); } { - GtkWidget *l = clonetiler_spinbox (_("Randomize the color saturation by this percentage"), "saturation_rand", + auto l = spinbox (_("Randomize the color saturation by this percentage"), "saturation_rand", 0, 100, "%"); - clonetiler_table_attach (table, l, 0, 3, 4); + table_attach (table, l, 0, 3, 4); } // Lightness @@ -732,25 +707,25 @@ CloneTiler::CloneTiler () : GtkWidget *l = gtk_label_new (""); gtk_label_set_markup (GTK_LABEL(l), _("<b>L:</b>")); gtk_size_group_add_widget(table_row_labels, l); - clonetiler_table_attach (table, l, 1, 4, 1); + table_attach (table, l, 1, 4, 1); } { - GtkWidget *l = clonetiler_spinbox (_("Change the color lightness by this percentage for each row"), "lightness_per_j", + auto l = spinbox (_("Change the color lightness by this percentage for each row"), "lightness_per_j", -100, 100, "%"); - clonetiler_table_attach (table, l, 0, 4, 2); + table_attach (table, l, 0, 4, 2); } { - GtkWidget *l = clonetiler_spinbox (_("Change the color lightness by this percentage for each column"), "lightness_per_i", + auto l = spinbox (_("Change the color lightness by this percentage for each column"), "lightness_per_i", -100, 100, "%"); - clonetiler_table_attach (table, l, 0, 4, 3); + table_attach (table, l, 0, 4, 3); } { - GtkWidget *l = clonetiler_spinbox (_("Randomize the color lightness by this percentage"), "lightness_rand", + auto l = spinbox (_("Randomize the color lightness by this percentage"), "lightness_rand", 0, 100, "%"); - clonetiler_table_attach (table, l, 0, 4, 4); + table_attach (table, l, 0, 4, 4); } @@ -758,135 +733,109 @@ CloneTiler::CloneTiler () : GtkWidget *l = gtk_label_new (""); gtk_label_set_markup (GTK_LABEL(l), _("<small>Alternate:</small>")); gtk_size_group_add_widget(table_row_labels, l); - clonetiler_table_attach (table, l, 1, 5, 1); + table_attach (table, l, 1, 5, 1); } { - GtkWidget *l = clonetiler_checkbox (_("Alternate the sign of color changes for each row"), "color_alternatej"); - clonetiler_table_attach (table, l, 0, 5, 2); + auto l = checkbox (_("Alternate the sign of color changes for each row"), "color_alternatej"); + table_attach (table, l, 0, 5, 2); } { - GtkWidget *l = clonetiler_checkbox (_("Alternate the sign of color changes for each column"), "color_alternatei"); - clonetiler_table_attach (table, l, 0, 5, 3); + auto l = checkbox (_("Alternate the sign of color changes for each column"), "color_alternatei"); + table_attach (table, l, 0, 5, 3); } } // Trace { - GtkWidget *vb = clonetiler_new_tab (nb, _("_Trace")); + GtkWidget *vb = new_tab (nb, _("_Trace")); { -#if GTK_CHECK_VERSION(3,0,0) - GtkWidget *hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, VB_MARGIN); + auto hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, VB_MARGIN); gtk_box_set_homogeneous(GTK_BOX(hb), FALSE); -#else - GtkWidget *hb = gtk_hbox_new(FALSE, VB_MARGIN); -#endif gtk_box_pack_start (GTK_BOX (vb), hb, FALSE, FALSE, 0); - b = gtk_check_button_new_with_label (_("Trace the drawing under the clones/sprayed items")); - g_object_set_data (G_OBJECT(b), "uncheckable", GINT_TO_POINTER(TRUE)); + _b = Gtk::manage(new Gtk::CheckButton(_("Trace the drawing under the clones/sprayed items"))); + _b->set_data("uncheckable", GINT_TO_POINTER(TRUE)); bool old = prefs->getBool(prefs_path + "dotrace"); - gtk_toggle_button_set_active ((GtkToggleButton *) b, old); - gtk_widget_set_tooltip_text (b, _("For each clone/sprayed item, pick a value from the drawing in its location and apply it")); - gtk_box_pack_start (GTK_BOX (hb), b, FALSE, FALSE, 0); - - g_signal_connect(G_OBJECT(b), "toggled", - G_CALLBACK(clonetiler_do_pick_toggled), (gpointer)dlg); + _b->set_active(old); + _b->set_tooltip_text(_("For each clone/sprayed item, pick a value from the drawing in its location and apply it")); + gtk_box_pack_start (GTK_BOX (hb), GTK_WIDGET(_b->gobj()), FALSE, FALSE, 0); + _b->signal_toggled().connect(sigc::mem_fun(*this, &CloneTiler::do_pick_toggled)); } { -#if GTK_CHECK_VERSION(3,0,0) - GtkWidget *vvb = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); + auto vvb = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); gtk_box_set_homogeneous(GTK_BOX(vvb), FALSE); -#else - GtkWidget *vvb = gtk_vbox_new (FALSE, 0); -#endif gtk_box_pack_start (GTK_BOX (vb), vvb, FALSE, FALSE, 0); - g_object_set_data (G_OBJECT(dlg), "dotrace", (gpointer) vvb); - + _dotrace = vvb; { GtkWidget *frame = gtk_frame_new (_("1. Pick from the drawing:")); gtk_box_pack_start (GTK_BOX (vvb), frame, FALSE, FALSE, 0); -#if GTK_CHECK_VERSION(3,0,0) - GtkWidget *table = gtk_grid_new(); + auto table = gtk_grid_new(); gtk_grid_set_row_spacing(GTK_GRID(table), 4); gtk_grid_set_column_spacing(GTK_GRID(table), 6); -#else - GtkWidget *table = gtk_table_new (3, 3, FALSE); - gtk_table_set_row_spacings (GTK_TABLE (table), 4); - gtk_table_set_col_spacings (GTK_TABLE (table), 6); -#endif gtk_container_add(GTK_CONTAINER(frame), table); - - GtkWidget* radio; + Gtk::RadioButtonGroup rb_group; { - radio = gtk_radio_button_new_with_label (NULL, _("Color")); - gtk_widget_set_tooltip_text (radio, _("Pick the visible color and opacity")); - clonetiler_table_attach (table, radio, 0.0, 1, 1); - g_signal_connect (G_OBJECT (radio), "toggled", - G_CALLBACK (clonetiler_pick_switched), GINT_TO_POINTER(PICK_COLOR)); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path + "pick", 0) == PICK_COLOR); + auto radio = Gtk::manage(new Gtk::RadioButton(rb_group, _("Color"))); + radio->set_tooltip_text(_("Pick the visible color and opacity")); + table_attach(table, radio, 0.0, 1, 1); + radio->signal_toggled().connect(sigc::bind(sigc::mem_fun(*this, &CloneTiler::pick_switched), PICK_COLOR)); + radio->set_active(prefs->getInt(prefs_path + "pick", 0) == PICK_COLOR); } { - radio = gtk_radio_button_new_with_label (gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio)), _("Opacity")); - gtk_widget_set_tooltip_text (radio, _("Pick the total accumulated opacity")); - clonetiler_table_attach (table, radio, 0.0, 2, 1); - g_signal_connect (G_OBJECT (radio), "toggled", - G_CALLBACK (clonetiler_pick_switched), GINT_TO_POINTER(PICK_OPACITY)); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path + "pick", 0) == PICK_OPACITY); + auto radio = Gtk::manage(new Gtk::RadioButton(rb_group, _("Opacity"))); + radio->set_tooltip_text(_("Pick the total accumulated opacity")); + table_attach (table, radio, 0.0, 2, 1); + radio->signal_toggled().connect(sigc::bind(sigc::mem_fun(*this, &CloneTiler::pick_switched), PICK_OPACITY)); + radio->set_active(prefs->getInt(prefs_path + "pick", 0) == PICK_OPACITY); } { - radio = gtk_radio_button_new_with_label (gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio)), _("R")); - gtk_widget_set_tooltip_text (radio, _("Pick the Red component of the color")); - clonetiler_table_attach (table, radio, 0.0, 1, 2); - g_signal_connect (G_OBJECT (radio), "toggled", - G_CALLBACK (clonetiler_pick_switched), GINT_TO_POINTER(PICK_R)); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path + "pick", 0) == PICK_R); + auto radio = Gtk::manage(new Gtk::RadioButton(rb_group, _("R"))); + radio->set_tooltip_text(_("Pick the Red component of the color")); + table_attach (table, radio, 0.0, 1, 2); + radio->signal_toggled().connect(sigc::bind(sigc::mem_fun(*this, &CloneTiler::pick_switched), PICK_R)); + radio->set_active(prefs->getInt(prefs_path + "pick", 0) == PICK_R); } { - radio = gtk_radio_button_new_with_label (gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio)), _("G")); - gtk_widget_set_tooltip_text (radio, _("Pick the Green component of the color")); - clonetiler_table_attach (table, radio, 0.0, 2, 2); - g_signal_connect (G_OBJECT (radio), "toggled", - G_CALLBACK (clonetiler_pick_switched), GINT_TO_POINTER(PICK_G)); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path + "pick", 0) == PICK_G); + auto radio = Gtk::manage(new Gtk::RadioButton(rb_group, _("G"))); + radio->set_tooltip_text(_("Pick the Green component of the color")); + table_attach (table, radio, 0.0, 2, 2); + radio->signal_toggled().connect(sigc::bind(sigc::mem_fun(*this, &CloneTiler::pick_switched), PICK_G)); + radio->set_active(prefs->getInt(prefs_path + "pick", 0) == PICK_G); } { - radio = gtk_radio_button_new_with_label (gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio)), _("B")); - gtk_widget_set_tooltip_text (radio, _("Pick the Blue component of the color")); - clonetiler_table_attach (table, radio, 0.0, 3, 2); - g_signal_connect (G_OBJECT (radio), "toggled", - G_CALLBACK (clonetiler_pick_switched), GINT_TO_POINTER(PICK_B)); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path + "pick", 0) == PICK_B); + auto radio = Gtk::manage(new Gtk::RadioButton(rb_group, _("B"))); + radio->set_tooltip_text(_("Pick the Blue component of the color")); + table_attach (table, radio, 0.0, 3, 2); + radio->signal_toggled().connect(sigc::bind(sigc::mem_fun(*this, &CloneTiler::pick_switched), PICK_B)); + radio->set_active(prefs->getInt(prefs_path + "pick", 0) == PICK_B); } { - radio = gtk_radio_button_new_with_label (gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio)), C_("Clonetiler color hue", "H")); - gtk_widget_set_tooltip_text (radio, _("Pick the hue of the color")); - clonetiler_table_attach (table, radio, 0.0, 1, 3); - g_signal_connect (G_OBJECT (radio), "toggled", - G_CALLBACK (clonetiler_pick_switched), GINT_TO_POINTER(PICK_H)); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path + "pick", 0) == PICK_H); + auto radio = Gtk::manage(new Gtk::RadioButton(rb_group, C_("Clonetiler color hue", "H"))); + radio->set_tooltip_text(_("Pick the hue of the color")); + table_attach (table, radio, 0.0, 1, 3); + radio->signal_toggled().connect(sigc::bind(sigc::mem_fun(*this, &CloneTiler::pick_switched), PICK_H)); + radio->set_active(prefs->getInt(prefs_path + "pick", 0) == PICK_H); } { - radio = gtk_radio_button_new_with_label (gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio)), C_("Clonetiler color saturation", "S")); - gtk_widget_set_tooltip_text (radio, _("Pick the saturation of the color")); - clonetiler_table_attach (table, radio, 0.0, 2, 3); - g_signal_connect (G_OBJECT (radio), "toggled", - G_CALLBACK (clonetiler_pick_switched), GINT_TO_POINTER(PICK_S)); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path + "pick", 0) == PICK_S); + auto radio = Gtk::manage(new Gtk::RadioButton(rb_group, C_("Clonetiler color saturation", "S"))); + radio->set_tooltip_text(_("Pick the saturation of the color")); + table_attach (table, radio, 0.0, 2, 3); + radio->signal_toggled().connect(sigc::bind(sigc::mem_fun(*this, &CloneTiler::pick_switched), PICK_S)); + radio->set_active(prefs->getInt(prefs_path + "pick", 0) == PICK_S); } { - radio = gtk_radio_button_new_with_label (gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio)), C_("Clonetiler color lightness", "L")); - gtk_widget_set_tooltip_text (radio, _("Pick the lightness of the color")); - clonetiler_table_attach (table, radio, 0.0, 3, 3); - g_signal_connect (G_OBJECT (radio), "toggled", - G_CALLBACK (clonetiler_pick_switched), GINT_TO_POINTER(PICK_L)); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), prefs->getInt(prefs_path + "pick", 0) == PICK_L); + auto radio = Gtk::manage(new Gtk::RadioButton(rb_group, C_("Clonetiler color lightness", "L"))); + radio->set_tooltip_text(_("Pick the lightness of the color")); + table_attach (table, radio, 0.0, 3, 3); + radio->signal_toggled().connect(sigc::bind(sigc::mem_fun(*this, &CloneTiler::pick_switched), PICK_L)); + radio->set_active(prefs->getInt(prefs_path + "pick", 0) == PICK_L); } } @@ -895,48 +844,42 @@ CloneTiler::CloneTiler () : GtkWidget *frame = gtk_frame_new (_("2. Tweak the picked value:")); gtk_box_pack_start (GTK_BOX (vvb), frame, FALSE, FALSE, VB_MARGIN); -#if GTK_CHECK_VERSION(3,0,0) - GtkWidget *table = gtk_grid_new(); + auto table = gtk_grid_new(); gtk_grid_set_row_spacing(GTK_GRID(table), 4); gtk_grid_set_column_spacing(GTK_GRID(table), 6); -#else - GtkWidget *table = gtk_table_new (4, 2, FALSE); - gtk_table_set_row_spacings (GTK_TABLE (table), 4); - gtk_table_set_col_spacings (GTK_TABLE (table), 6); -#endif gtk_container_add(GTK_CONTAINER(frame), table); { GtkWidget *l = gtk_label_new (""); gtk_label_set_markup (GTK_LABEL(l), _("Gamma-correct:")); - clonetiler_table_attach (table, l, 1.0, 1, 1); + table_attach (table, l, 1.0, 1, 1); } { - GtkWidget *l = clonetiler_spinbox (_("Shift the mid-range of the picked value upwards (>0) or downwards (<0)"), "gamma_picked", + auto l = spinbox (_("Shift the mid-range of the picked value upwards (>0) or downwards (<0)"), "gamma_picked", -10, 10, ""); - clonetiler_table_attach (table, l, 0.0, 1, 2); + table_attach (table, l, 0.0, 1, 2); } { GtkWidget *l = gtk_label_new (""); gtk_label_set_markup (GTK_LABEL(l), _("Randomize:")); - clonetiler_table_attach (table, l, 1.0, 1, 3); + table_attach (table, l, 1.0, 1, 3); } { - GtkWidget *l = clonetiler_spinbox (_("Randomize the picked value by this percentage"), "rand_picked", + auto l = spinbox (_("Randomize the picked value by this percentage"), "rand_picked", 0, 100, "%"); - clonetiler_table_attach (table, l, 0.0, 1, 4); + table_attach (table, l, 0.0, 1, 4); } { GtkWidget *l = gtk_label_new (""); gtk_label_set_markup (GTK_LABEL(l), _("Invert:")); - clonetiler_table_attach (table, l, 1.0, 2, 1); + table_attach (table, l, 1.0, 2, 1); } { - GtkWidget *l = clonetiler_checkbox (_("Invert the picked value"), "invert_picked"); - clonetiler_table_attach (table, l, 0.0, 2, 2); + auto l = checkbox (_("Invert the picked value"), "invert_picked"); + table_attach (table, l, 0.0, 2, 2); } } @@ -944,55 +887,45 @@ CloneTiler::CloneTiler () : GtkWidget *frame = gtk_frame_new (_("3. Apply the value to the clones':")); gtk_box_pack_start (GTK_BOX (vvb), frame, FALSE, FALSE, 0); -#if GTK_CHECK_VERSION(3,0,0) - GtkWidget *table = gtk_grid_new(); + auto table = gtk_grid_new(); gtk_grid_set_row_spacing(GTK_GRID(table), 4); gtk_grid_set_column_spacing(GTK_GRID(table), 6); -#else - GtkWidget *table = gtk_table_new (2, 2, FALSE); - gtk_table_set_row_spacings (GTK_TABLE (table), 4); - gtk_table_set_col_spacings (GTK_TABLE (table), 6); -#endif gtk_container_add(GTK_CONTAINER(frame), table); { - GtkWidget *b = gtk_check_button_new_with_label (_("Presence")); + auto b = Gtk::manage(new Gtk::CheckButton(_("Presence"))); bool old = prefs->getBool(prefs_path + "pick_to_presence", true); - gtk_toggle_button_set_active ((GtkToggleButton *) b, old); - gtk_widget_set_tooltip_text (b, _("Each clone is created with the probability determined by the picked value in that point")); - clonetiler_table_attach (table, b, 0.0, 1, 1); - g_signal_connect(G_OBJECT(b), "toggled", - G_CALLBACK(clonetiler_pick_to), (gpointer) "pick_to_presence"); + b->set_active(old); + b->set_tooltip_text(_("Each clone is created with the probability determined by the picked value in that point")); + table_attach (table, b, 0.0, 1, 1); + b->signal_toggled().connect(sigc::bind(sigc::mem_fun(*this, &CloneTiler::pick_to), b, "pick_to_presence")); } { - GtkWidget *b = gtk_check_button_new_with_label (_("Size")); + auto b = Gtk::manage(new Gtk::CheckButton(_("Size"))); bool old = prefs->getBool(prefs_path + "pick_to_size"); - gtk_toggle_button_set_active ((GtkToggleButton *) b, old); - gtk_widget_set_tooltip_text (b, _("Each clone's size is determined by the picked value in that point")); - clonetiler_table_attach (table, b, 0.0, 2, 1); - g_signal_connect(G_OBJECT(b), "toggled", - G_CALLBACK(clonetiler_pick_to), (gpointer) "pick_to_size"); + b->set_active(old); + b->set_tooltip_text(_("Each clone's size is determined by the picked value in that point")); + table_attach (table, b, 0.0, 2, 1); + b->signal_toggled().connect(sigc::bind(sigc::mem_fun(*this, &CloneTiler::pick_to), b, "pick_to_size")); } { - GtkWidget *b = gtk_check_button_new_with_label (_("Color")); + auto b = Gtk::manage(new Gtk::CheckButton(_("Color"))); bool old = prefs->getBool(prefs_path + "pick_to_color", 0); - gtk_toggle_button_set_active ((GtkToggleButton *) b, old); - gtk_widget_set_tooltip_text (b, _("Each clone is painted by the picked color (the original must have unset fill or stroke)")); - clonetiler_table_attach (table, b, 0.0, 1, 2); - g_signal_connect(G_OBJECT(b), "toggled", - G_CALLBACK(clonetiler_pick_to), (gpointer) "pick_to_color"); + b->set_active(old); + b->set_tooltip_text(_("Each clone is painted by the picked color (the original must have unset fill or stroke)")); + table_attach (table, b, 0.0, 1, 2); + b->signal_toggled().connect(sigc::bind(sigc::mem_fun(*this, &CloneTiler::pick_to), b, "pick_to_color")); } { - GtkWidget *b = gtk_check_button_new_with_label (_("Opacity")); + auto b = Gtk::manage(new Gtk::CheckButton(_("Opacity"))); bool old = prefs->getBool(prefs_path + "pick_to_opacity", 0); - gtk_toggle_button_set_active ((GtkToggleButton *) b, old); - gtk_widget_set_tooltip_text (b, _("Each clone's opacity is determined by the picked value in that point")); - clonetiler_table_attach (table, b, 0.0, 2, 2); - g_signal_connect(G_OBJECT(b), "toggled", - G_CALLBACK(clonetiler_pick_to), (gpointer) "pick_to_opacity"); + b->set_active(old); + b->set_tooltip_text(_("Each clone's opacity is determined by the picked value in that point")); + table_attach (table, b, 0.0, 2, 2); + b->signal_toggled().connect(sigc::bind(sigc::mem_fun(*this, &CloneTiler::pick_to), b, "pick_to_opacity")); } } gtk_widget_set_sensitive (vvb, prefs->getBool(prefs_path + "dotrace")); @@ -1000,12 +933,8 @@ CloneTiler::CloneTiler () : } { -#if GTK_CHECK_VERSION(3,0,0) - GtkWidget *hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, VB_MARGIN); + auto hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, VB_MARGIN); gtk_box_set_homogeneous(GTK_BOX(hb), FALSE); -#else - GtkWidget *hb = gtk_hbox_new(FALSE, VB_MARGIN); -#endif gtk_box_pack_start (GTK_BOX (mainbox), hb, FALSE, FALSE, 0); GtkWidget *l = gtk_label_new(_("")); gtk_label_set_markup (GTK_LABEL(l), _("Apply to tiled clones:")); @@ -1013,296 +942,211 @@ CloneTiler::CloneTiler () : } // Rows/columns, width/height { -#if GTK_CHECK_VERSION(3,0,0) - GtkWidget *table = gtk_grid_new(); + auto table = gtk_grid_new(); gtk_grid_set_row_spacing(GTK_GRID(table), 4); gtk_grid_set_column_spacing(GTK_GRID(table), 6); -#else - GtkWidget *table = gtk_table_new (2, 2, FALSE); - gtk_table_set_row_spacings (GTK_TABLE (table), 4); - gtk_table_set_col_spacings (GTK_TABLE (table), 6); -#endif gtk_container_set_border_width (GTK_CONTAINER (table), VB_MARGIN); gtk_box_pack_start (GTK_BOX (mainbox), table, FALSE, FALSE, 0); { -#if GTK_CHECK_VERSION(3,0,0) - GtkWidget *hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, VB_MARGIN); - gtk_box_set_homogeneous(GTK_BOX(hb), FALSE); -#else - GtkWidget *hb = gtk_hbox_new(FALSE, VB_MARGIN); -#endif - g_object_set_data (G_OBJECT(dlg), "rowscols", (gpointer) hb); + _rowscols = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL, VB_MARGIN)); { -#if WITH_GTKMM_3_0 - Glib::RefPtr<Gtk::Adjustment>a = Gtk::Adjustment::create(0.0, 1, 500, 1, 10, 0); -#else - Gtk::Adjustment *a = new Gtk::Adjustment (0.0, 1, 500, 1, 10, 0); -#endif + auto a = Gtk::Adjustment::create(0.0, 1, 500, 1, 10, 0); int value = prefs->getInt(prefs_path + "jmax", 2); a->set_value (value); -#if WITH_GTKMM_3_0 - Inkscape::UI::Widget::SpinButton *sb = new Inkscape::UI::Widget::SpinButton(a, 1.0, 0); -#else - Inkscape::UI::Widget::SpinButton *sb = new Inkscape::UI::Widget::SpinButton (*a, 1.0, 0); -#endif + auto sb = new Inkscape::UI::Widget::SpinButton(a, 1.0, 0); sb->set_tooltip_text (_("How many rows in the tiling")); sb->set_width_chars (7); - gtk_box_pack_start (GTK_BOX (hb), GTK_WIDGET(sb->gobj()), TRUE, TRUE, 0); + _rowscols->pack_start(*sb, true, true, 0); - // TODO: C++ification - g_signal_connect(G_OBJECT(a->gobj()), "value_changed", - G_CALLBACK(clonetiler_xy_changed), (gpointer) "jmax"); + a->signal_value_changed().connect(sigc::bind(sigc::mem_fun(*this, &CloneTiler::xy_changed), a, "jmax")); } { - GtkWidget *l = gtk_label_new (""); - gtk_label_set_markup (GTK_LABEL(l), "×"); -#if GTK_CHECK_VERSION(3,0,0) - gtk_widget_set_halign(l, GTK_ALIGN_END); -#else - gtk_misc_set_alignment (GTK_MISC (l), 1.0, 0.5); -#endif - gtk_box_pack_start (GTK_BOX (hb), l, TRUE, TRUE, 0); + auto l = Gtk::manage(new Gtk::Label("")); + l->set_markup("×"); + l->set_halign(Gtk::ALIGN_END); + _rowscols->pack_start(*l, true, true, 0); } { -#if WITH_GTKMM_3_0 - Glib::RefPtr<Gtk::Adjustment> a = Gtk::Adjustment::create(0.0, 1, 500, 1, 10, 0); -#else - Gtk::Adjustment *a = new Gtk::Adjustment (0.0, 1, 500, 1, 10, 0); -#endif + auto a = Gtk::Adjustment::create(0.0, 1, 500, 1, 10, 0); int value = prefs->getInt(prefs_path + "imax", 2); a->set_value (value); -#if WITH_GTKMM_3_0 - Inkscape::UI::Widget::SpinButton *sb = new Inkscape::UI::Widget::SpinButton(a, 1.0, 0); -#else - Inkscape::UI::Widget::SpinButton *sb = new Inkscape::UI::Widget::SpinButton (*a, 1.0, 0); -#endif + auto sb = new Inkscape::UI::Widget::SpinButton(a, 1.0, 0); sb->set_tooltip_text (_("How many columns in the tiling")); sb->set_width_chars (7); - gtk_box_pack_start (GTK_BOX (hb), GTK_WIDGET(sb->gobj()), TRUE, TRUE, 0); + _rowscols->pack_start(*sb, true, true, 0); - // TODO: C++ification - g_signal_connect(G_OBJECT(a->gobj()), "value_changed", - G_CALLBACK(clonetiler_xy_changed), (gpointer) "imax"); + a->signal_value_changed().connect(sigc::bind(sigc::mem_fun(*this, &CloneTiler::xy_changed), a, "imax")); } - clonetiler_table_attach (table, hb, 0.0, 1, 2); + table_attach (table, GTK_WIDGET(_rowscols->gobj()), 0.0, 1, 2); } { -#if GTK_CHECK_VERSION(3,0,0) - GtkWidget *hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, VB_MARGIN); - gtk_box_set_homogeneous(GTK_BOX(hb), FALSE); -#else - GtkWidget *hb = gtk_hbox_new(FALSE, VB_MARGIN); -#endif - g_object_set_data (G_OBJECT(dlg), "widthheight", (gpointer) hb); + _widthheight = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL, VB_MARGIN)); // unitmenu unit_menu = new Inkscape::UI::Widget::UnitMenu(); unit_menu->setUnitType(Inkscape::Util::UNIT_TYPE_LINEAR); unit_menu->setUnit(SP_ACTIVE_DESKTOP->getNamedView()->display_units->abbr); - unitChangedConn = unit_menu->signal_changed().connect(sigc::mem_fun(*this, &CloneTiler::clonetiler_unit_changed)); + unitChangedConn = unit_menu->signal_changed().connect(sigc::mem_fun(*this, &CloneTiler::unit_changed)); { // Width spinbutton -#if WITH_GTKMM_3_0 fill_width = Gtk::Adjustment::create(0.0, -1e6, 1e6, 1.0, 10.0, 0); -#else - fill_width = new Gtk::Adjustment (0.0, -1e6, 1e6, 1.0, 10.0, 0); -#endif double value = prefs->getDouble(prefs_path + "fillwidth", 50.0); Inkscape::Util::Unit const *unit = unit_menu->getUnit(); gdouble const units = Inkscape::Util::Quantity::convert(value, "px", unit); fill_width->set_value (units); -#if WITH_GTKMM_3_0 - Inkscape::UI::Widget::SpinButton *e = new Inkscape::UI::Widget::SpinButton(fill_width, 1.0, 2); -#else - Inkscape::UI::Widget::SpinButton *e = new Inkscape::UI::Widget::SpinButton (*fill_width, 1.0, 2); -#endif + auto e = new Inkscape::UI::Widget::SpinButton(fill_width, 1.0, 2); e->set_tooltip_text (_("Width of the rectangle to be filled")); e->set_width_chars (7); e->set_digits (4); - gtk_box_pack_start (GTK_BOX (hb), GTK_WIDGET(e->gobj()), TRUE, TRUE, 0); - // TODO: C++ification - g_signal_connect(G_OBJECT(fill_width->gobj()), "value_changed", - G_CALLBACK(clonetiler_fill_width_changed), unit_menu); + _widthheight->pack_start(*e, true, true, 0); + fill_width->signal_value_changed().connect(sigc::mem_fun(*this, &CloneTiler::fill_width_changed)); } { - GtkWidget *l = gtk_label_new (""); - gtk_label_set_markup (GTK_LABEL(l), "×"); -#if GTK_CHECK_VERSION(3,0,0) - gtk_widget_set_halign(l, GTK_ALIGN_END); -#else - gtk_misc_set_alignment (GTK_MISC (l), 1.0, 0.5); -#endif - gtk_box_pack_start (GTK_BOX (hb), l, TRUE, TRUE, 0); + auto l = Gtk::manage(new Gtk::Label("")); + l->set_markup("×"); + l->set_halign(Gtk::ALIGN_END); + _widthheight->pack_start(*l, true, true, 0); } { // Height spinbutton -#if WITH_GTKMM_3_0 fill_height = Gtk::Adjustment::create(0.0, -1e6, 1e6, 1.0, 10.0, 0); -#else - fill_height = new Gtk::Adjustment (0.0, -1e6, 1e6, 1.0, 10.0, 0); -#endif double value = prefs->getDouble(prefs_path + "fillheight", 50.0); Inkscape::Util::Unit const *unit = unit_menu->getUnit(); gdouble const units = Inkscape::Util::Quantity::convert(value, "px", unit); fill_height->set_value (units); -#if WITH_GTKMM_3_0 - Inkscape::UI::Widget::SpinButton *e = new Inkscape::UI::Widget::SpinButton(fill_height, 1.0, 2); -#else - Inkscape::UI::Widget::SpinButton *e = new Inkscape::UI::Widget::SpinButton (*fill_height, 1.0, 2); -#endif + auto e = new Inkscape::UI::Widget::SpinButton(fill_height, 1.0, 2); e->set_tooltip_text (_("Height of the rectangle to be filled")); e->set_width_chars (7); e->set_digits (4); - gtk_box_pack_start (GTK_BOX (hb), GTK_WIDGET(e->gobj()), TRUE, TRUE, 0); - // TODO: C++ification - g_signal_connect(G_OBJECT(fill_height->gobj()), "value_changed", - G_CALLBACK(clonetiler_fill_height_changed), unit_menu); + _widthheight->pack_start(*e, true, true, 0); + fill_height->signal_value_changed().connect(sigc::mem_fun(*this, &CloneTiler::fill_height_changed)); } - gtk_box_pack_start (GTK_BOX (hb), (GtkWidget*) unit_menu->gobj(), TRUE, TRUE, 0); - clonetiler_table_attach (table, hb, 0.0, 2, 2); + _widthheight->pack_start(*unit_menu, true, true, 0); + table_attach (table, GTK_WIDGET(_widthheight->gobj()), 0.0, 2, 2); } // Switch - GtkWidget* radio; + Gtk::RadioButtonGroup rb_group; { - radio = gtk_radio_button_new_with_label (NULL, _("Rows, columns: ")); - gtk_widget_set_tooltip_text (radio, _("Create the specified number of rows and columns")); - clonetiler_table_attach (table, radio, 0.0, 1, 1); - g_signal_connect (G_OBJECT (radio), "toggled", G_CALLBACK (clonetiler_switch_to_create), (gpointer) dlg); - } - if (!prefs->getBool(prefs_path + "fillrect")) { - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), TRUE); - gtk_toggle_button_toggled (GTK_TOGGLE_BUTTON (radio)); + auto radio = Gtk::manage(new Gtk::RadioButton(rb_group, _("Rows, columns: "))); + radio->set_tooltip_text(_("Create the specified number of rows and columns")); + table_attach (table, GTK_WIDGET(radio->gobj()), 0.0, 1, 1); + radio->signal_toggled().connect(sigc::mem_fun(*this, &CloneTiler::switch_to_create)); + + if (!prefs->getBool(prefs_path + "fillrect")) { + radio->set_active(true); + } } { - radio = gtk_radio_button_new_with_label (gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio)), _("Width, height: ")); - gtk_widget_set_tooltip_text (radio, _("Fill the specified width and height with the tiling")); - clonetiler_table_attach (table, radio, 0.0, 2, 1); - g_signal_connect (G_OBJECT (radio), "toggled", G_CALLBACK (clonetiler_switch_to_fill), (gpointer) dlg); - } - if (prefs->getBool(prefs_path + "fillrect")) { - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), TRUE); - gtk_toggle_button_toggled (GTK_TOGGLE_BUTTON (radio)); + auto radio = Gtk::manage(new Gtk::RadioButton(rb_group, _("Width, height: "))); + radio->set_tooltip_text(_("Fill the specified width and height with the tiling")); + table_attach (table, GTK_WIDGET(radio->gobj()), 0.0, 2, 1); + radio->signal_toggled().connect(sigc::mem_fun(*this, &CloneTiler::switch_to_fill)); + + if (prefs->getBool(prefs_path + "fillrect")) { + radio->set_active(true); + } } } // Use saved pos { -#if GTK_CHECK_VERSION(3,0,0) - GtkWidget *hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, VB_MARGIN); - gtk_box_set_homogeneous(GTK_BOX(hb), FALSE); -#else - GtkWidget *hb = gtk_hbox_new(FALSE, VB_MARGIN); -#endif - gtk_box_pack_start (GTK_BOX (mainbox), hb, FALSE, FALSE, 0); - - GtkWidget *b = gtk_check_button_new_with_label (_("Use saved size and position of the tile")); - bool keepbbox = prefs->getBool(prefs_path + "keepbbox", true); - gtk_toggle_button_set_active ((GtkToggleButton *) b, keepbbox); - gtk_widget_set_tooltip_text (b, _("Pretend that the size and position of the tile are the same as the last time you tiled it (if any), instead of using the current size")); - gtk_box_pack_start (GTK_BOX (hb), b, FALSE, FALSE, 0); - - g_signal_connect(G_OBJECT(b), "toggled", - G_CALLBACK(clonetiler_keep_bbox_toggled), NULL); + auto hb = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL, VB_MARGIN)); + gtk_box_pack_start (GTK_BOX (mainbox), GTK_WIDGET(hb->gobj()), FALSE, FALSE, 0); + + _cb_keep_bbox = Gtk::manage(new Gtk::CheckButton(_("Use saved size and position of the tile"))); + auto keepbbox = prefs->getBool(prefs_path + "keepbbox", true); + _cb_keep_bbox->set_active(keepbbox); + _cb_keep_bbox->set_tooltip_text(_("Pretend that the size and position of the tile are the same " + "as the last time you tiled it (if any), instead of using the " + "current size")); + hb->pack_start(*_cb_keep_bbox, false, false, 0); + _cb_keep_bbox->signal_toggled().connect(sigc::mem_fun(*this, &CloneTiler::keep_bbox_toggled)); } // Statusbar { -#if GTK_CHECK_VERSION(3,0,0) - GtkWidget *hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, VB_MARGIN); + auto hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, VB_MARGIN); gtk_box_set_homogeneous(GTK_BOX(hb), FALSE); -#else - GtkWidget *hb = gtk_hbox_new(FALSE, VB_MARGIN); -#endif gtk_box_pack_end (GTK_BOX (mainbox), hb, FALSE, FALSE, 0); GtkWidget *l = gtk_label_new(""); - g_object_set_data (G_OBJECT(dlg), "status", (gpointer) l); + _status = l; gtk_box_pack_start (GTK_BOX (hb), l, FALSE, FALSE, 0); } // Buttons { -#if GTK_CHECK_VERSION(3,0,0) - GtkWidget *hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, VB_MARGIN); + auto hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, VB_MARGIN); gtk_box_set_homogeneous(GTK_BOX(hb), FALSE); -#else - GtkWidget *hb = gtk_hbox_new(FALSE, VB_MARGIN); -#endif gtk_box_pack_start (GTK_BOX (mainbox), hb, FALSE, FALSE, 0); { - GtkWidget *b = gtk_button_new (); - GtkWidget *l = gtk_label_new (""); - gtk_label_set_markup_with_mnemonic (GTK_LABEL(l), _(" <b>_Create</b> ")); - gtk_container_add (GTK_CONTAINER(b), l); - gtk_widget_set_tooltip_text (b, _("Create and tile the clones of the selection")); - g_signal_connect (G_OBJECT (b), "clicked", G_CALLBACK (clonetiler_apply), dlg); - gtk_box_pack_end (GTK_BOX (hb), b, FALSE, FALSE, 0); + auto b = Gtk::manage(new Gtk::Button()); + auto l = Gtk::manage(new Gtk::Label("")); + l->set_markup_with_mnemonic(_(" <b>_Create</b> ")); + b->add(*l); + b->set_tooltip_text(_("Create and tile the clones of the selection")); + b->signal_clicked().connect(sigc::mem_fun(*this, &CloneTiler::apply)); + gtk_box_pack_end (GTK_BOX (hb), GTK_WIDGET(b->gobj()), FALSE, FALSE, 0); } { // buttons which are enabled only when there are tiled clones -#if GTK_CHECK_VERSION(3,0,0) - GtkWidget *sb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); + auto sb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); gtk_box_set_homogeneous(GTK_BOX(sb), FALSE); -#else - GtkWidget *sb = gtk_hbox_new(FALSE, 0); -#endif gtk_box_pack_end (GTK_BOX (hb), sb, FALSE, FALSE, 0); - g_object_set_data (G_OBJECT(dlg), "buttons_on_tiles", (gpointer) sb); + _buttons_on_tiles = sb; { // TRANSLATORS: if a group of objects are "clumped" together, then they // are unevenly spread in the given amount of space - as shown in the // diagrams on the left in the following screenshot: // http://www.inkscape.org/screenshots/gallery/inkscape-0.42-CVS-tiles-unclump.png // So unclumping is the process of spreading a number of objects out more evenly. - GtkWidget *b = gtk_button_new_with_mnemonic (_(" _Unclump ")); - gtk_widget_set_tooltip_text (b, _("Spread out clones to reduce clumping; can be applied repeatedly")); - g_signal_connect (G_OBJECT (b), "clicked", G_CALLBACK (clonetiler_unclump), NULL); - gtk_box_pack_end (GTK_BOX (sb), b, FALSE, FALSE, 0); + auto b = Gtk::manage(new Gtk::Button(_(" _Unclump "), true)); + b->set_tooltip_text(_("Spread out clones to reduce clumping; can be applied repeatedly")); + b->signal_clicked().connect(sigc::mem_fun(*this, &CloneTiler::unclump)); + gtk_box_pack_end (GTK_BOX (sb), GTK_WIDGET(b->gobj()), FALSE, FALSE, 0); } { - GtkWidget *b = gtk_button_new_with_mnemonic (_(" Re_move ")); - gtk_widget_set_tooltip_text (b, _("Remove existing tiled clones of the selected object (siblings only)")); - g_signal_connect (G_OBJECT (b), "clicked", G_CALLBACK (clonetiler_remove), gpointer(dlg)); - gtk_box_pack_end (GTK_BOX (sb), b, FALSE, FALSE, 0); + auto b = Gtk::manage(new Gtk::Button(_(" Re_move "), true)); + b->set_tooltip_text(_("Remove existing tiled clones of the selected object (siblings only)")); + b->signal_clicked().connect(sigc::mem_fun(*this, &CloneTiler::on_remove_button_clicked)); + gtk_box_pack_end (GTK_BOX (sb), GTK_WIDGET(b->gobj()), FALSE, FALSE, 0); } // connect to global selection changed signal (so we can change desktops) and // external_change (so we're not fooled by undo) - selectChangedConn = INKSCAPE.signal_selection_changed.connect(sigc::bind(sigc::ptr_fun(&CloneTiler::clonetiler_change_selection), dlg)); - externChangedConn = INKSCAPE.signal_external_change.connect (sigc::bind(sigc::ptr_fun(&CloneTiler::clonetiler_external_change), dlg)); - - g_signal_connect(G_OBJECT(dlg), "destroy", G_CALLBACK(clonetiler_disconnect_gsignal), this); + selectChangedConn = INKSCAPE.signal_selection_changed.connect(sigc::mem_fun(*this, &CloneTiler::change_selection)); + externChangedConn = INKSCAPE.signal_external_change.connect(sigc::mem_fun(*this, &CloneTiler::external_change)); // update now - clonetiler_change_selection (SP_ACTIVE_DESKTOP->getSelection(), dlg); + change_selection(SP_ACTIVE_DESKTOP->getSelection()); } { - GtkWidget *b = gtk_button_new_with_mnemonic (_(" R_eset ")); + auto b = Gtk::manage(new Gtk::Button(_(" R_eset "), true)); // TRANSLATORS: "change" is a noun here - gtk_widget_set_tooltip_text (b, _("Reset all shifts, scales, rotates, opacity and color changes in the dialog to zero")); - g_signal_connect (G_OBJECT (b), "clicked", G_CALLBACK (clonetiler_reset), dlg); - gtk_box_pack_start (GTK_BOX (hb), b, FALSE, FALSE, 0); + b->set_tooltip_text(_("Reset all shifts, scales, rotates, opacity and color changes in the dialog to zero")); + b->signal_clicked().connect(sigc::mem_fun(*this, &CloneTiler::reset)); + gtk_box_pack_start (GTK_BOX (hb), GTK_WIDGET(b->gobj()), FALSE, FALSE, 0); } } @@ -1319,8 +1163,9 @@ CloneTiler::CloneTiler () : CloneTiler::~CloneTiler (void) { //subselChangedConn.disconnect(); - //selectChangedConn.disconnect(); //selectModifiedConn.disconnect(); + selectChangedConn.disconnect(); + externChangedConn.disconnect(); desktopChangeConn.disconnect(); deskTrack.disconnect(); color_changed_connection.disconnect(); @@ -1335,17 +1180,7 @@ void CloneTiler::setDesktop(SPDesktop *desktop) void CloneTiler::setTargetDesktop(SPDesktop *desktop) { if (this->desktop != desktop) { - if (this->desktop) { - //selectModifiedConn.disconnect(); - //subselChangedConn.disconnect(); - //selectChangedConn.disconnect(); - } this->desktop = desktop; - if (desktop && desktop->selection) { - //selectChangedConn = desktop->selection->connectChanged(sigc::hide(sigc::mem_fun(*this, &CloneTiler::clonetiler_change_selection))); - //subselChangedConn = desktop->connectToolSubselectionChanged(sigc::hide(sigc::mem_fun(*this, &CloneTiler::clonetiler_change_selection))); - //selectModifiedConn = desktop->selection->connectModified(sigc::hide<0>(sigc::mem_fun(*this, &CloneTiler::clonetiler_change_selection))); - } } } @@ -1365,50 +1200,38 @@ void CloneTiler::on_picker_color_changed(guint rgba) is_updating = false; } -void CloneTiler::clonetiler_change_selection(Inkscape::Selection *selection, GtkWidget *dlg) +void CloneTiler::change_selection(Inkscape::Selection *selection) { - GtkWidget *buttons = GTK_WIDGET(g_object_get_data (G_OBJECT(dlg), "buttons_on_tiles")); - GtkWidget *status = GTK_WIDGET(g_object_get_data (G_OBJECT(dlg), "status")); - if (selection->isEmpty()) { - gtk_widget_set_sensitive (buttons, FALSE); - gtk_label_set_markup (GTK_LABEL(status), _("<small>Nothing selected.</small>")); + gtk_widget_set_sensitive (_buttons_on_tiles, FALSE); + gtk_label_set_markup (GTK_LABEL(_status), _("<small>Nothing selected.</small>")); return; } - if (selection->itemList().size() > 1) { - gtk_widget_set_sensitive (buttons, FALSE); - gtk_label_set_markup (GTK_LABEL(status), _("<small>More than one object selected.</small>")); + if (boost::distance(selection->items()) > 1) { + gtk_widget_set_sensitive (_buttons_on_tiles, FALSE); + gtk_label_set_markup (GTK_LABEL(_status), _("<small>More than one object selected.</small>")); return; } - guint n = clonetiler_number_of_clones(selection->singleItem()); + guint n = number_of_clones(selection->singleItem()); if (n > 0) { - gtk_widget_set_sensitive (buttons, TRUE); + gtk_widget_set_sensitive (_buttons_on_tiles, TRUE); gchar *sta = g_strdup_printf (_("<small>Object has <b>%d</b> tiled clones.</small>"), n); - gtk_label_set_markup (GTK_LABEL(status), sta); + gtk_label_set_markup (GTK_LABEL(_status), sta); g_free (sta); } else { - gtk_widget_set_sensitive (buttons, FALSE); - gtk_label_set_markup (GTK_LABEL(status), _("<small>Object has no tiled clones.</small>")); + gtk_widget_set_sensitive (_buttons_on_tiles, FALSE); + gtk_label_set_markup (GTK_LABEL(_status), _("<small>Object has no tiled clones.</small>")); } } -void CloneTiler::clonetiler_external_change(GtkWidget *dlg) +void CloneTiler::external_change() { - clonetiler_change_selection (SP_ACTIVE_DESKTOP->getSelection(), dlg); + change_selection(SP_ACTIVE_DESKTOP->getSelection()); } -void CloneTiler::clonetiler_disconnect_gsignal(GObject *, gpointer source) -{ - g_return_if_fail(source != NULL); - - CloneTiler* dlg = reinterpret_cast<CloneTiler*>(source); - dlg->selectChangedConn.disconnect(); - dlg->externChangedConn.disconnect(); -} - -Geom::Affine CloneTiler::clonetiler_get_transform( +Geom::Affine CloneTiler::get_transform( // symmetry group int type, @@ -2010,7 +1833,7 @@ Geom::Affine CloneTiler::clonetiler_get_transform( return Geom::identity(); } -bool CloneTiler::clonetiler_is_a_clone_of(SPObject *tile, SPObject *obj) +bool CloneTiler::is_a_clone_of(SPObject *tile, SPObject *obj) { bool result = false; char *id_href = NULL; @@ -2037,21 +1860,21 @@ bool CloneTiler::clonetiler_is_a_clone_of(SPObject *tile, SPObject *obj) return result; } -void CloneTiler::clonetiler_trace_hide_tiled_clones_recursively(SPObject *from) +void CloneTiler::trace_hide_tiled_clones_recursively(SPObject *from) { if (!trace_drawing) return; - for (SPObject *o = from->firstChild(); o != NULL; o = o->next) { - SPItem *item = dynamic_cast<SPItem *>(o); - if (item && clonetiler_is_a_clone_of(o, NULL)) { + for (auto& o: from->children) { + SPItem *item = dynamic_cast<SPItem *>(&o); + if (item && is_a_clone_of(&o, NULL)) { item->invoke_hide(trace_visionkey); // FIXME: hide each tiled clone's original too! } - clonetiler_trace_hide_tiled_clones_recursively (o); + trace_hide_tiled_clones_recursively (&o); } } -void CloneTiler::clonetiler_trace_setup(SPDocument *doc, gdouble zoom, SPItem *original) +void CloneTiler::trace_setup(SPDocument *doc, gdouble zoom, SPItem *original) { trace_drawing = new Inkscape::Drawing(); /* Create ArenaItem and set transform */ @@ -2061,7 +1884,7 @@ void CloneTiler::clonetiler_trace_setup(SPDocument *doc, gdouble zoom, SPItem *o // hide the (current) original and any tiled clones, we only want to pick the background original->invoke_hide(trace_visionkey); - clonetiler_trace_hide_tiled_clones_recursively(trace_doc->getRoot()); + trace_hide_tiled_clones_recursively(trace_doc->getRoot()); trace_doc->getRoot()->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); trace_doc->ensureUpToDate(); @@ -2069,7 +1892,7 @@ void CloneTiler::clonetiler_trace_setup(SPDocument *doc, gdouble zoom, SPItem *o trace_zoom = zoom; } -guint32 CloneTiler::clonetiler_trace_pick(Geom::Rect box) +guint32 CloneTiler::trace_pick(Geom::Rect box) { if (!trace_drawing) { return 0; @@ -2093,7 +1916,7 @@ guint32 CloneTiler::clonetiler_trace_pick(Geom::Rect box) return SP_RGBA32_F_COMPOSE (R, G, B, A); } -void CloneTiler::clonetiler_trace_finish() +void CloneTiler::trace_finish() { if (trace_doc) { trace_doc->getRoot()->invoke_hide(trace_visionkey); @@ -2103,48 +1926,48 @@ void CloneTiler::clonetiler_trace_finish() } } -void CloneTiler::clonetiler_unclump(GtkWidget */*widget*/, void *) +void CloneTiler::unclump() { - SPDesktop *desktop = SP_ACTIVE_DESKTOP; + auto desktop = SP_ACTIVE_DESKTOP; if (desktop == NULL) { return; } - Inkscape::Selection *selection = desktop->getSelection(); + auto selection = desktop->getSelection(); // check if something is selected - if (selection->isEmpty() || selection->itemList().size() > 1) { + if (selection->isEmpty() || boost::distance(selection->items()) > 1) { desktop->getMessageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>one object</b> whose tiled clones to unclump.")); return; } - SPObject *obj = selection->singleItem(); - SPObject *parent = obj->parent; + auto obj = selection->singleItem(); + auto parent = obj->parent; std::vector<SPItem*> to_unclump; // not including the original - for (SPObject *child = parent->firstChild(); child != NULL; child = child->next) { - if (clonetiler_is_a_clone_of (child, obj)) { - to_unclump.push_back((SPItem*)child); + for (auto& child: parent->children) { + if (is_a_clone_of (&child, obj)) { + to_unclump.push_back((SPItem*)&child); } } desktop->getDocument()->ensureUpToDate(); reverse(to_unclump.begin(),to_unclump.end()); - unclump (to_unclump); + ::unclump (to_unclump); DocumentUndo::done(desktop->getDocument(), SP_VERB_DIALOG_CLONETILER, _("Unclump tiled clones")); } -guint CloneTiler::clonetiler_number_of_clones(SPObject *obj) +guint CloneTiler::number_of_clones(SPObject *obj) { SPObject *parent = obj->parent; guint n = 0; - for (SPObject *child = parent->firstChild(); child != NULL; child = child->next) { - if (clonetiler_is_a_clone_of (child, obj)) { + for (auto& child: parent->children) { + if (is_a_clone_of (&child, obj)) { n ++; } } @@ -2152,7 +1975,7 @@ guint CloneTiler::clonetiler_number_of_clones(SPObject *obj) return n; } -void CloneTiler::clonetiler_remove(GtkWidget */*widget*/, GtkWidget *dlg, bool do_undo/* = true*/) +void CloneTiler::remove(bool do_undo/* = true*/) { SPDesktop *desktop = SP_ACTIVE_DESKTOP; if (desktop == NULL) { @@ -2162,7 +1985,7 @@ void CloneTiler::clonetiler_remove(GtkWidget */*widget*/, GtkWidget *dlg, bool d Inkscape::Selection *selection = desktop->getSelection(); // check if something is selected - if (selection->isEmpty() || selection->itemList().size() > 1) { + if (selection->isEmpty() || boost::distance(selection->items()) > 1) { desktop->getMessageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>one object</b> whose tiled clones to remove.")); return; } @@ -2172,9 +1995,9 @@ void CloneTiler::clonetiler_remove(GtkWidget */*widget*/, GtkWidget *dlg, bool d // remove old tiling GSList *to_delete = NULL; - for (SPObject *child = parent->firstChild(); child != NULL; child = child->next) { - if (clonetiler_is_a_clone_of (child, obj)) { - to_delete = g_slist_prepend (to_delete, child); + for (auto& child: parent->children) { + if (is_a_clone_of (&child, obj)) { + to_delete = g_slist_prepend (to_delete, &child); } } for (GSList *i = to_delete; i; i = i->next) { @@ -2184,7 +2007,7 @@ void CloneTiler::clonetiler_remove(GtkWidget */*widget*/, GtkWidget *dlg, bool d } g_slist_free (to_delete); - clonetiler_change_selection (selection, dlg); + change_selection (selection); if (do_undo) { DocumentUndo::done(desktop->getDocument(), SP_VERB_DIALOG_CLONETILER, @@ -2224,7 +2047,7 @@ double CloneTiler::randomize01(double val, double rand) } -void CloneTiler::clonetiler_apply(GtkWidget */*widget*/, GtkWidget *dlg) +void CloneTiler::apply() { SPDesktop *desktop = SP_ACTIVE_DESKTOP; if (desktop == NULL) { @@ -2240,7 +2063,7 @@ void CloneTiler::clonetiler_apply(GtkWidget */*widget*/, GtkWidget *dlg) } // Check if more than one object is selected. - if (selection->itemList().size() > 1) { + if (boost::distance(selection->items()) > 1) { desktop->getMessageStack()->flash(Inkscape::ERROR_MESSAGE, _("If you want to clone several objects, <b>group</b> them and <b>clone the group</b>.")); return; } @@ -2249,9 +2072,8 @@ void CloneTiler::clonetiler_apply(GtkWidget */*widget*/, GtkWidget *dlg) desktop->setWaitingCursor(); // set statusbar text - GtkWidget *status = GTK_WIDGET(g_object_get_data (G_OBJECT(dlg), "status")); - gtk_label_set_markup (GTK_LABEL(status), _("<small>Creating tiled clones...</small>")); - gtk_widget_queue_draw(GTK_WIDGET(status)); + gtk_label_set_markup (GTK_LABEL(_status), _("<small>Creating tiled clones...</small>")); + gtk_widget_queue_draw(GTK_WIDGET(_status)); gdk_window_process_all_updates(); SPObject *obj = selection->singleItem(); @@ -2264,7 +2086,7 @@ void CloneTiler::clonetiler_apply(GtkWidget */*widget*/, GtkWidget *dlg) const char *id_href = g_strdup_printf("#%s", obj_repr->attribute("id")); SPObject *parent = obj->parent; - clonetiler_remove (NULL, dlg, false); + remove(false); Geom::Scale scale = desktop->getDocument()->getDocumentScale().inverse(); double scale_units = scale[Geom::X]; // Use just x direction.... @@ -2353,7 +2175,7 @@ void CloneTiler::clonetiler_apply(GtkWidget */*widget*/, GtkWidget *dlg) SPItem *item = dynamic_cast<SPItem *>(obj); if (dotrace) { - clonetiler_trace_setup (desktop->getDocument(), 1.0, item); + trace_setup(desktop->getDocument(), 1.0, item); } Geom::Point center; @@ -2425,7 +2247,7 @@ void CloneTiler::clonetiler_apply(GtkWidget */*widget*/, GtkWidget *dlg) // Note: We create a clone at 0,0 too, right over the original, in case our clones are colored // Get transform from symmetry, shift, scale, rotation - Geom::Affine orig_t = clonetiler_get_transform (type, i, j, center[Geom::X], center[Geom::Y], w, h, + Geom::Affine orig_t = get_transform (type, i, j, center[Geom::X], center[Geom::Y], w, h, shiftx_per_i, shifty_per_i, shiftx_per_j, shifty_per_j, shiftx_rand, shifty_rand, @@ -2499,7 +2321,7 @@ void CloneTiler::clonetiler_apply(GtkWidget */*widget*/, GtkWidget *dlg) if (dotrace) { Geom::Rect bbox_t = transform_rect (bbox_original, t*Geom::Scale(1.0/scale_units)); - guint32 rgba = clonetiler_trace_pick (bbox_t); + guint32 rgba = trace_pick (bbox_t); float r = SP_RGBA32_R_F(rgba); float g = SP_RGBA32_G_F(rgba); float b = SP_RGBA32_B_F(rgba); @@ -2659,10 +2481,10 @@ void CloneTiler::clonetiler_apply(GtkWidget */*widget*/, GtkWidget *dlg) } if (dotrace) { - clonetiler_trace_finish (); + trace_finish (); } - clonetiler_change_selection (selection, dlg); + change_selection(selection); desktop->clearWaitingCursor(); @@ -2670,111 +2492,84 @@ void CloneTiler::clonetiler_apply(GtkWidget */*widget*/, GtkWidget *dlg) _("Create tiled clones")); } -GtkWidget * CloneTiler::clonetiler_new_tab(GtkWidget *nb, const gchar *label) +GtkWidget * CloneTiler::new_tab(GtkWidget *nb, const gchar *label) { GtkWidget *l = gtk_label_new_with_mnemonic (label); -#if GTK_CHECK_VERSION(3,0,0) - GtkWidget *vb = gtk_box_new(GTK_ORIENTATION_VERTICAL, VB_MARGIN); + auto vb = gtk_box_new(GTK_ORIENTATION_VERTICAL, VB_MARGIN); gtk_box_set_homogeneous(GTK_BOX(vb), FALSE); -#else - GtkWidget *vb = gtk_vbox_new (FALSE, VB_MARGIN); -#endif gtk_container_set_border_width (GTK_CONTAINER (vb), VB_MARGIN); gtk_notebook_append_page (GTK_NOTEBOOK (nb), vb, l); return vb; } -void CloneTiler::clonetiler_checkbox_toggled(GtkToggleButton *tb, gpointer *data) +void CloneTiler::checkbox_toggled(Gtk::ToggleButton *tb, + const Glib::ustring &attr) { - const gchar *attr = (const gchar *) data; - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - prefs->setBool(prefs_path + attr, gtk_toggle_button_get_active(tb)); + auto prefs = Inkscape::Preferences::get(); + prefs->setBool(prefs_path + attr, tb->get_active()); } -GtkWidget * CloneTiler::clonetiler_checkbox(const char *tip, const char *attr) +Gtk::Widget * CloneTiler::checkbox(const char *tip, + const Glib::ustring &attr) { -#if GTK_CHECK_VERSION(3,0,0) - GtkWidget *hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, VB_MARGIN); - gtk_box_set_homogeneous(GTK_BOX(hb), FALSE); -#else - GtkWidget *hb = gtk_hbox_new(FALSE, VB_MARGIN); -#endif - - GtkWidget *b = gtk_check_button_new (); - gtk_widget_set_tooltip_text (b, tip); + auto hb = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL, VB_MARGIN)); + auto b = Gtk::manage(new Gtk::CheckButton()); + b->set_tooltip_text(tip); - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - bool value = prefs->getBool(prefs_path + attr); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(b), value); + auto const prefs = Inkscape::Preferences::get(); + auto const value = prefs->getBool(prefs_path + attr); + b->set_active(value); - gtk_box_pack_end (GTK_BOX (hb), b, FALSE, TRUE, 0); - g_signal_connect ( G_OBJECT (b), "clicked", - G_CALLBACK (clonetiler_checkbox_toggled), (gpointer) attr); + hb->pack_end(*b, false, true); + b->signal_clicked().connect(sigc::bind(sigc::mem_fun(*this, &CloneTiler::checkbox_toggled), b, attr)); - g_object_set_data (G_OBJECT(b), "uncheckable", GINT_TO_POINTER(TRUE)); + b->set_data("uncheckable", GINT_TO_POINTER(true)); return hb; } -void CloneTiler::clonetiler_value_changed(GtkAdjustment *adj, gpointer data) +void CloneTiler::value_changed(Glib::RefPtr<Gtk::Adjustment> &adj, + Glib::ustring const &pref) { - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - const gchar *pref = (const gchar *) data; - prefs->setDouble(prefs_path + pref, gtk_adjustment_get_value (adj)); + auto prefs = Inkscape::Preferences::get(); + prefs->setDouble(prefs_path + pref, adj->get_value()); } -GtkWidget * CloneTiler::clonetiler_spinbox(const char *tip, const char *attr, double lower, double upper, const gchar *suffix, bool exponent/* = false*/) +Gtk::Widget * CloneTiler::spinbox(const char *tip, + const Glib::ustring &attr, + double lower, + double upper, + const gchar *suffix, + bool exponent/* = false*/) { -#if GTK_CHECK_VERSION(3,0,0) - GtkWidget *hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); - gtk_box_set_homogeneous(GTK_BOX(hb), FALSE); -#else - GtkWidget *hb = gtk_hbox_new(FALSE, 0); -#endif + auto hb = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL, 0)); { -#if WITH_GTKMM_3_0 - Glib::RefPtr<Gtk::Adjustment> a; - if (exponent) { - a = Gtk::Adjustment::create(1.0, lower, upper, 0.01, 0.05, 0); - } else { - a = Gtk::Adjustment::create(0.0, lower, upper, 0.1, 0.5, 0); - } -#else - Gtk::Adjustment *a; - if (exponent) { - a = new Gtk::Adjustment (1.0, lower, upper, 0.01, 0.05, 0); - } else { - a = new Gtk::Adjustment (0.0, lower, upper, 0.1, 0.5, 0); - } -#endif + // Parameters for adjustment + auto const initial_value = (exponent ? 1.0 : 0.0); + auto const step_increment = (exponent ? 0.01 : 0.1); + auto const page_increment = (exponent ? 0.05 : 0.4); - Inkscape::UI::Widget::SpinButton *sb; -#if WITH_GTKMM_3_0 - if (exponent) { - sb = new Inkscape::UI::Widget::SpinButton(a, 0.01, 2); - } else { - sb = new Inkscape::UI::Widget::SpinButton(a, 0.1, 1); - } -#else - if (exponent) { - sb = new Inkscape::UI::Widget::SpinButton (*a, 0.01, 2); - } else { - sb = new Inkscape::UI::Widget::SpinButton (*a, 0.1, 1); - } -#endif + auto a = Gtk::Adjustment::create(initial_value, + lower, + upper, + step_increment, + page_increment); + + auto const climb_rate = (exponent ? 0.01 : 0.1); + auto const digits = (exponent ? 2 : 1); + + auto sb = new Inkscape::UI::Widget::SpinButton(a, climb_rate, digits); sb->set_tooltip_text (tip); sb->set_width_chars (5); sb->set_digits(3); - gtk_box_pack_start (GTK_BOX (hb), GTK_WIDGET(sb->gobj()), FALSE, FALSE, SB_MARGIN); + hb->pack_start(*sb, false, false, SB_MARGIN); - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - double value = prefs->getDoubleLimited(prefs_path + attr, exponent? 1.0 : 0.0, lower, upper); + auto prefs = Inkscape::Preferences::get(); + auto value = prefs->getDoubleLimited(prefs_path + attr, exponent? 1.0 : 0.0, lower, upper); a->set_value (value); - // TODO: C++ification - g_signal_connect(G_OBJECT(a->gobj()), "value_changed", - G_CALLBACK(clonetiler_value_changed), (gpointer) attr); + a->signal_value_changed().connect(sigc::bind(sigc::mem_fun(*this, &CloneTiler::value_changed), a, attr)); if (exponent) { sb->set_data ("oneable", GINT_TO_POINTER(TRUE)); @@ -2784,49 +2579,43 @@ GtkWidget * CloneTiler::clonetiler_spinbox(const char *tip, const char *attr, do } { - GtkWidget *l = gtk_label_new (""); - gtk_label_set_markup (GTK_LABEL(l), suffix); -#if GTK_CHECK_VERSION(3,0,0) - gtk_widget_set_halign(l, GTK_ALIGN_END); - gtk_widget_set_valign(l, GTK_ALIGN_START); -#else - gtk_misc_set_alignment (GTK_MISC (l), 1.0, 0); -#endif - gtk_box_pack_start (GTK_BOX (hb), l, FALSE, FALSE, 0); + auto l = Gtk::manage(new Gtk::Label("")); + l->set_markup(suffix); + l->set_halign(Gtk::ALIGN_END); + l->set_valign(Gtk::ALIGN_START); + hb->pack_start(*l); } return hb; } -void CloneTiler::clonetiler_symgroup_changed(GtkComboBox *cb, gpointer /*data*/) +void CloneTiler::symgroup_changed(Gtk::ComboBox *cb) { - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - gint group_new = gtk_combo_box_get_active (cb); + auto prefs = Inkscape::Preferences::get(); + auto group_new = cb->get_active_row_number(); prefs->setInt(prefs_path + "symmetrygroup", group_new); } -void CloneTiler::clonetiler_xy_changed(GtkAdjustment *adj, gpointer data) +void CloneTiler::xy_changed(Glib::RefPtr<Gtk::Adjustment> &adj, Glib::ustring const &pref) { - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - const gchar *pref = (const gchar *) data; - prefs->setInt(prefs_path + pref, (int) floor(gtk_adjustment_get_value (adj) + 0.5)); + auto prefs = Inkscape::Preferences::get(); + prefs->setInt(prefs_path + pref, (int) floor(adj->get_value() + 0.5)); } -void CloneTiler::clonetiler_keep_bbox_toggled(GtkToggleButton *tb, gpointer /*data*/) +void CloneTiler::keep_bbox_toggled() { - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - prefs->setBool(prefs_path + "keepbbox", gtk_toggle_button_get_active(tb)); + auto prefs = Inkscape::Preferences::get(); + prefs->setBool(prefs_path + "keepbbox", _cb_keep_bbox->get_active()); } -void CloneTiler::clonetiler_pick_to(GtkToggleButton *tb, gpointer data) +void CloneTiler::pick_to(Gtk::ToggleButton *tb, Glib::ustring const &pref) { - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - const gchar *pref = (const gchar *) data; - prefs->setBool(prefs_path + pref, gtk_toggle_button_get_active(tb)); + auto prefs = Inkscape::Preferences::get(); + prefs->setBool(prefs_path + pref, tb->get_active()); } -void CloneTiler::clonetiler_reset_recursive(GtkWidget *w) +void CloneTiler::reset_recursive(GtkWidget *w) { if (w && G_IS_OBJECT(w)) { { @@ -2854,51 +2643,40 @@ void CloneTiler::clonetiler_reset_recursive(GtkWidget *w) if (GTK_IS_CONTAINER(w)) { GList *ch = gtk_container_get_children (GTK_CONTAINER(w)); for (GList *i = ch; i != NULL; i = i->next) { - clonetiler_reset_recursive (GTK_WIDGET(i->data)); + reset_recursive (GTK_WIDGET(i->data)); } g_list_free (ch); } } -void CloneTiler::clonetiler_reset(GtkWidget */*widget*/, GtkWidget *dlg) +void CloneTiler::reset() { - clonetiler_reset_recursive (dlg); + reset_recursive(GTK_WIDGET(this->gobj())); } -void CloneTiler::clonetiler_table_attach(GtkWidget *table, GtkWidget *widget, float align, int row, int col) +void CloneTiler::table_attach(GtkWidget *table, Gtk::Widget *widget, float align, int row, int col) +{ + table_attach(table, GTK_WIDGET(widget->gobj()), align, row, col); +} + +void CloneTiler::table_attach(GtkWidget *table, GtkWidget *widget, float align, int row, int col) { -#if GTK_CHECK_VERSION(3,0,0) gtk_widget_set_halign(widget, GTK_ALIGN_FILL); gtk_widget_set_valign(widget, GTK_ALIGN_START); gtk_grid_attach(GTK_GRID(table), widget, col, row, 1, 1); -#else - GtkWidget *a = gtk_alignment_new (align, 0, 0, 0); - gtk_container_add(GTK_CONTAINER(a), widget); - gtk_table_attach ( GTK_TABLE (table), a, col, col + 1, row, row + 1, GTK_FILL, (GtkAttachOptions)0, 0, 0 ); -#endif } -GtkWidget * CloneTiler::clonetiler_table_x_y_rand(int values) +GtkWidget * CloneTiler::table_x_y_rand(int values) { -#if GTK_CHECK_VERSION(3,0,0) - GtkWidget *table = gtk_grid_new(); + auto table = gtk_grid_new(); gtk_grid_set_row_spacing(GTK_GRID(table), 6); gtk_grid_set_column_spacing(GTK_GRID(table), 8); -#else - GtkWidget *table = gtk_table_new (values + 2, 5, FALSE); - gtk_table_set_row_spacings (GTK_TABLE (table), 6); - gtk_table_set_col_spacings (GTK_TABLE (table), 8); -#endif gtk_container_set_border_width (GTK_CONTAINER (table), VB_MARGIN); { -#if GTK_CHECK_VERSION(3,0,0) - GtkWidget *hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); + auto hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); gtk_box_set_homogeneous(GTK_BOX(hb), FALSE); -#else - GtkWidget *hb = gtk_hbox_new (FALSE, 0); -#endif GtkWidget *i = sp_icon_new (Inkscape::ICON_SIZE_DECORATION, INKSCAPE_ICON("object-rows")); gtk_box_pack_start (GTK_BOX (hb), i, FALSE, FALSE, 2); @@ -2907,16 +2685,12 @@ GtkWidget * CloneTiler::clonetiler_table_x_y_rand(int values) gtk_label_set_markup (GTK_LABEL(l), _("<small>Per row:</small>")); gtk_box_pack_start (GTK_BOX (hb), l, FALSE, FALSE, 2); - clonetiler_table_attach (table, hb, 0, 1, 2); + table_attach (table, hb, 0, 1, 2); } { -#if GTK_CHECK_VERSION(3,0,0) - GtkWidget *hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); + auto hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); gtk_box_set_homogeneous(GTK_BOX(hb), FALSE); -#else - GtkWidget *hb = gtk_hbox_new (FALSE, 0); -#endif GtkWidget *i = sp_icon_new (Inkscape::ICON_SIZE_DECORATION, INKSCAPE_ICON("object-columns")); gtk_box_pack_start (GTK_BOX (hb), i, FALSE, FALSE, 2); @@ -2925,83 +2699,72 @@ GtkWidget * CloneTiler::clonetiler_table_x_y_rand(int values) gtk_label_set_markup (GTK_LABEL(l), _("<small>Per column:</small>")); gtk_box_pack_start (GTK_BOX (hb), l, FALSE, FALSE, 2); - clonetiler_table_attach (table, hb, 0, 1, 3); + table_attach (table, hb, 0, 1, 3); } { GtkWidget *l = gtk_label_new (""); gtk_label_set_markup (GTK_LABEL(l), _("<small>Randomize:</small>")); - clonetiler_table_attach (table, l, 0, 1, 4); + table_attach (table, l, 0, 1, 4); } return table; } -void CloneTiler::clonetiler_pick_switched(GtkToggleButton */*tb*/, gpointer data) +void CloneTiler::pick_switched(PickType v) { - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - guint v = GPOINTER_TO_INT (data); + auto prefs = Inkscape::Preferences::get(); prefs->setInt(prefs_path + "pick", v); } - -void CloneTiler::clonetiler_switch_to_create(GtkToggleButton * /*tb*/, GtkWidget *dlg) +void CloneTiler::switch_to_create() { - GtkWidget *rowscols = GTK_WIDGET(g_object_get_data (G_OBJECT(dlg), "rowscols")); - GtkWidget *widthheight = GTK_WIDGET(g_object_get_data (G_OBJECT(dlg), "widthheight")); - - if (rowscols) { - gtk_widget_set_sensitive (rowscols, TRUE); + if (_rowscols) { + _rowscols->set_sensitive(true); } - if (widthheight) { - gtk_widget_set_sensitive (widthheight, FALSE); + if (_widthheight) { + _widthheight->set_sensitive(false); } - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + auto prefs = Inkscape::Preferences::get(); prefs->setBool(prefs_path + "fillrect", false); } -void CloneTiler::clonetiler_switch_to_fill(GtkToggleButton * /*tb*/, GtkWidget *dlg) +void CloneTiler::switch_to_fill() { - GtkWidget *rowscols = GTK_WIDGET(g_object_get_data (G_OBJECT(dlg), "rowscols")); - GtkWidget *widthheight = GTK_WIDGET(g_object_get_data (G_OBJECT(dlg), "widthheight")); - - if (rowscols) { - gtk_widget_set_sensitive (rowscols, FALSE); + if (_rowscols) { + _rowscols->set_sensitive(false); } - if (widthheight) { - gtk_widget_set_sensitive (widthheight, TRUE); + if (_widthheight) { + _widthheight->set_sensitive(true); } - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + auto prefs = Inkscape::Preferences::get(); prefs->setBool(prefs_path + "fillrect", true); } - - - -void CloneTiler::clonetiler_fill_width_changed(GtkAdjustment *adj, Inkscape::UI::Widget::UnitMenu *u) +void CloneTiler::fill_width_changed() { - gdouble const raw_dist = gtk_adjustment_get_value (adj); - Inkscape::Util::Unit const *unit = u->getUnit(); - gdouble const pixels = Inkscape::Util::Quantity::convert(raw_dist, unit, "px"); + auto const raw_dist = fill_width->get_value(); + auto const unit = unit_menu->getUnit(); + auto const pixels = Inkscape::Util::Quantity::convert(raw_dist, unit, "px"); - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + auto prefs = Inkscape::Preferences::get(); prefs->setDouble(prefs_path + "fillwidth", pixels); } -void CloneTiler::clonetiler_fill_height_changed(GtkAdjustment *adj, Inkscape::UI::Widget::UnitMenu *u) +void CloneTiler::fill_height_changed() { - gdouble const raw_dist = gtk_adjustment_get_value (adj); - Inkscape::Util::Unit const *unit = u->getUnit(); - gdouble const pixels = Inkscape::Util::Quantity::convert(raw_dist, unit, "px"); + auto const raw_dist = fill_height->get_value(); + auto const unit = unit_menu->getUnit(); + auto const pixels = Inkscape::Util::Quantity::convert(raw_dist, unit, "px"); - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + auto prefs = Inkscape::Preferences::get(); prefs->setDouble(prefs_path + "fillheight", pixels); } -void CloneTiler::clonetiler_unit_changed() +void CloneTiler::unit_changed() { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); gdouble width_pixels = prefs->getDouble(prefs_path + "fillwidth"); @@ -3015,22 +2778,21 @@ void CloneTiler::clonetiler_unit_changed() gtk_adjustment_set_value(fill_height->gobj(), height_value); } -void CloneTiler::clonetiler_do_pick_toggled(GtkToggleButton *tb, GtkWidget *dlg) +void CloneTiler::do_pick_toggled() { - GtkWidget *vvb = GTK_WIDGET(g_object_get_data (G_OBJECT(dlg), "dotrace")); - - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - prefs->setBool(prefs_path + "dotrace", gtk_toggle_button_get_active (tb)); + auto prefs = Inkscape::Preferences::get(); + auto active = _b->get_active(); + prefs->setBool(prefs_path + "dotrace", active); - if (vvb) { - gtk_widget_set_sensitive (vvb, gtk_toggle_button_get_active (tb)); + if (_dotrace) { + gtk_widget_set_sensitive (_dotrace, active); } } void CloneTiler::show_page_trace() { gtk_notebook_set_current_page(GTK_NOTEBOOK(nb),6); - gtk_toggle_button_set_active ((GtkToggleButton *) b, false); + _b->set_active(false); } diff --git a/src/ui/dialog/clonetiler.h b/src/ui/dialog/clonetiler.h index a8f1df0a0..db3049ef1 100644 --- a/src/ui/dialog/clonetiler.h +++ b/src/ui/dialog/clonetiler.h @@ -16,6 +16,12 @@ #include "ui/widget/color-picker.h" #include "sp-root.h" +namespace Gtk { + class CheckButton; + class ComboBox; + class ToggleButton; +} + namespace Inkscape { namespace UI { @@ -33,45 +39,66 @@ public: static CloneTiler &getInstance() { return *new CloneTiler(); } void show_page_trace(); protected: - - GtkWidget * clonetiler_new_tab(GtkWidget *nb, const gchar *label); - GtkWidget * clonetiler_table_x_y_rand(int values); - GtkWidget * clonetiler_spinbox(const char *tip, const char *attr, double lower, double upper, const gchar *suffix, bool exponent = false); - GtkWidget * clonetiler_checkbox(const char *tip, const char *attr); - void clonetiler_table_attach(GtkWidget *table, GtkWidget *widget, float align, int row, int col); - - static void clonetiler_symgroup_changed(GtkComboBox *cb, gpointer /*data*/); - static void clonetiler_remove(GtkWidget */*widget*/, GtkWidget *dlg, bool do_undo = true); - static void on_picker_color_changed(guint rgba); - static void clonetiler_trace_hide_tiled_clones_recursively(SPObject *from); - static void clonetiler_checkbox_toggled(GtkToggleButton *tb, gpointer *data); - static void clonetiler_pick_switched(GtkToggleButton */*tb*/, gpointer data); - static void clonetiler_do_pick_toggled(GtkToggleButton *tb, GtkWidget *dlg); - static void clonetiler_pick_to(GtkToggleButton *tb, gpointer data); - static void clonetiler_xy_changed(GtkAdjustment *adj, gpointer data); - static void clonetiler_fill_width_changed(GtkAdjustment *adj, Inkscape::UI::Widget::UnitMenu *u); - static void clonetiler_fill_height_changed(GtkAdjustment *adj, Inkscape::UI::Widget::UnitMenu *u); - void clonetiler_unit_changed(); - static void clonetiler_switch_to_create(GtkToggleButton */*tb*/, GtkWidget *dlg); - static void clonetiler_switch_to_fill(GtkToggleButton */*tb*/, GtkWidget *dlg); - static void clonetiler_keep_bbox_toggled(GtkToggleButton *tb, gpointer /*data*/); - static void clonetiler_apply(GtkWidget */*widget*/, GtkWidget *dlg); - static void clonetiler_unclump(GtkWidget */*widget*/, void *); - static void clonetiler_change_selection(Inkscape::Selection *selection, GtkWidget *dlg); - static void clonetiler_external_change(GtkWidget *dlg); - static void clonetiler_disconnect_gsignal(GObject *widget, gpointer source); - static void clonetiler_reset(GtkWidget */*widget*/, GtkWidget *dlg); - static guint clonetiler_number_of_clones(SPObject *obj); - static void clonetiler_trace_setup(SPDocument *doc, gdouble zoom, SPItem *original); - static guint32 clonetiler_trace_pick(Geom::Rect box); - static void clonetiler_trace_finish(); - static bool clonetiler_is_a_clone_of(SPObject *tile, SPObject *obj); - static Geom::Rect transform_rect(Geom::Rect const &r, Geom::Affine const &m); - static double randomize01(double val, double rand); - static void clonetiler_value_changed(GtkAdjustment *adj, gpointer data); - static void clonetiler_reset_recursive(GtkWidget *w); - - static Geom::Affine clonetiler_get_transform( // symmetry group + enum PickType { + PICK_COLOR, + PICK_OPACITY, + PICK_R, + PICK_G, + PICK_B, + PICK_H, + PICK_S, + PICK_L + }; + + GtkWidget * new_tab(GtkWidget *nb, const gchar *label); + GtkWidget * table_x_y_rand(int values); + Gtk::Widget * spinbox(const char *tip, + const Glib::ustring &attr, + double lower, + double upper, + const gchar *suffix, + bool exponent = false); + Gtk::Widget * checkbox(const char *tip, + const Glib::ustring &attr); + void table_attach(GtkWidget *table, GtkWidget *widget, float align, int row, int col); + void table_attach(GtkWidget *table, Gtk::Widget *widget, float align, int row, int col); + + void symgroup_changed(Gtk::ComboBox *cb); + void on_picker_color_changed(guint rgba); + void trace_hide_tiled_clones_recursively(SPObject *from); + guint number_of_clones(SPObject *obj); + void trace_setup(SPDocument *doc, gdouble zoom, SPItem *original); + guint32 trace_pick(Geom::Rect box); + void trace_finish(); + bool is_a_clone_of(SPObject *tile, SPObject *obj); + Geom::Rect transform_rect(Geom::Rect const &r, Geom::Affine const &m); + double randomize01(double val, double rand); + + void apply(); + void change_selection(Inkscape::Selection *selection); + void checkbox_toggled(Gtk::ToggleButton *tb, + Glib::ustring const &attr); + void do_pick_toggled(); + void external_change(); + void fill_width_changed(); + void fill_height_changed(); + void keep_bbox_toggled(); + void on_remove_button_clicked() {remove();} + void pick_switched(PickType); + void pick_to(Gtk::ToggleButton *tb, + Glib::ustring const &pref); + void remove(bool do_undo = true); + void reset(); + void reset_recursive(GtkWidget *w); + void switch_to_create(); + void switch_to_fill(); + void unclump(); + void unit_changed(); + void value_changed(Glib::RefPtr<Gtk::Adjustment> &adj, Glib::ustring const &pref); + void xy_changed(Glib::RefPtr<Gtk::Adjustment> &adj, Glib::ustring const &pref); + + Geom::Affine get_transform( + // symmetry group int type, // row, column @@ -112,22 +139,17 @@ private: CloneTiler(CloneTiler const &d); CloneTiler& operator=(CloneTiler const &d); - GtkWidget *dlg; + Gtk::CheckButton *_b; + Gtk::CheckButton *_cb_keep_bbox; GtkWidget *nb; - GtkWidget *b; SPDesktop *desktop; DesktopTracker deskTrack; Inkscape::UI::Widget::ColorPicker *color_picker; GtkSizeGroup* table_row_labels; Inkscape::UI::Widget::UnitMenu *unit_menu; -#if WITH_GTKMM_3_0 Glib::RefPtr<Gtk::Adjustment> fill_width; Glib::RefPtr<Gtk::Adjustment> fill_height; -#else - Gtk::Adjustment *fill_width; - Gtk::Adjustment *fill_height; -#endif sigc::connection desktopChangeConn; sigc::connection selectChangedConn; @@ -147,21 +169,17 @@ private: */ void setTargetDesktop(SPDesktop *desktop); + // Variables that used to be set using GObject + GtkWidget *_buttons_on_tiles; + GtkWidget *_dotrace; + GtkWidget *_status; + Gtk::Box *_rowscols; + Gtk::Box *_widthheight; + }; enum { - PICK_COLOR, - PICK_OPACITY, - PICK_R, - PICK_G, - PICK_B, - PICK_H, - PICK_S, - PICK_L -}; - -enum { TILE_P1, TILE_P2, TILE_PM, diff --git a/src/ui/dialog/color-item.cpp b/src/ui/dialog/color-item.cpp index 34cdb92e3..df4ab6485 100644 --- a/src/ui/dialog/color-item.cpp +++ b/src/ui/dialog/color-item.cpp @@ -12,15 +12,13 @@ */ #ifdef HAVE_CONFIG_H -# include "config.h" +#include "config.h" #endif #include <errno.h> #include <gtkmm/label.h> #include <glibmm/i18n.h> -#include <cairo.h> -#include <gtk/gtk.h> #include "color-item.h" @@ -34,16 +32,10 @@ #include "io/resource.h" #include "io/sys.h" #include "message-context.h" -#include "sp-gradient.h" -#include "sp-item.h" #include "svg/svg-color.h" -#include "xml/node.h" -#include "xml/repr.h" #include "verbs.h" #include "widgets/gradient-vector.h" -#include "color.h" // for SP_RGBA32_U_COMPOSE - namespace Inkscape { namespace UI { diff --git a/src/ui/dialog/debug.cpp b/src/ui/dialog/debug.cpp index d127261c0..d062bf863 100644 --- a/src/ui/dialog/debug.cpp +++ b/src/ui/dialog/debug.cpp @@ -10,13 +10,12 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ #ifdef HAVE_CONFIG_H -# include <config.h> +#include "config.h" #endif #include <gtkmm/box.h> #include <gtkmm/dialog.h> #include <gtkmm/textview.h> -#include <gtkmm/button.h> #include <gtkmm/menubar.h> #include <gtkmm/scrolledwindow.h> #include <glibmm/i18n.h> @@ -68,12 +67,7 @@ DebugDialogImpl::DebugDialogImpl() { set_title(_("Messages")); set_size_request(300, 400); - -#if WITH_GTKMM_3_0 - Gtk::Box *mainVBox = get_content_area(); -#else - Gtk::Box *mainVBox = get_vbox(); -#endif + auto mainVBox = get_content_area(); //## Add a menu for clear() Gtk::MenuItem* item = Gtk::manage(new Gtk::MenuItem(_("_File"), true)); diff --git a/src/ui/dialog/desktop-tracker.cpp b/src/ui/dialog/desktop-tracker.cpp index 0659de67b..c18711a55 100644 --- a/src/ui/dialog/desktop-tracker.cpp +++ b/src/ui/dialog/desktop-tracker.cpp @@ -6,7 +6,6 @@ */ #include "widgets/desktop-widget.h" -#include <glib-object.h> #include "desktop-tracker.h" diff --git a/src/ui/dialog/dialog-manager.cpp b/src/ui/dialog/dialog-manager.cpp index 49853277c..c53112656 100644 --- a/src/ui/dialog/dialog-manager.cpp +++ b/src/ui/dialog/dialog-manager.cpp @@ -14,7 +14,7 @@ */ #ifdef HAVE_CONFIG_H -# include <config.h> +#include "config.h" #endif #include "ui/dialog/dialog-manager.h" @@ -45,11 +45,8 @@ #include "ui/dialog/panel-dialog.h" #include "ui/dialog/layers.h" #include "ui/dialog/icon-preview.h" -#include "ui/dialog/floating-behavior.h" -#include "ui/dialog/dock-behavior.h" //#include "ui/dialog/print-colors-preview-dialog.h" #include "util/ege-appear-time-tracker.h" -#include "preferences.h" #include "ui/dialog/object-attributes.h" #include "ui/dialog/object-properties.h" #include "ui/dialog/text-edit.h" diff --git a/src/ui/dialog/dialog.cpp b/src/ui/dialog/dialog.cpp index 27d88bae7..d0b618c65 100644 --- a/src/ui/dialog/dialog.cpp +++ b/src/ui/dialog/dialog.cpp @@ -14,7 +14,7 @@ */ #ifdef HAVE_CONFIG_H -# include <config.h> +#include "config.h" #endif #include "dialog-manager.h" @@ -27,13 +27,10 @@ #include "desktop.h" #include "shortcuts.h" -#include "preferences.h" #include "ui/interface.h" #include "verbs.h" #include "ui/tool/event-utils.h" -#include <gtk/gtk.h> - #define MIN_ONSCREEN_DISTANCE 50 diff --git a/src/ui/dialog/dock-behavior.cpp b/src/ui/dialog/dock-behavior.cpp index 50a6db208..ec630c08f 100644 --- a/src/ui/dialog/dock-behavior.cpp +++ b/src/ui/dialog/dock-behavior.cpp @@ -12,7 +12,7 @@ #ifdef HAVE_CONFIG_H -# include <config.h> +#include "config.h" #endif #include "dock-behavior.h" @@ -23,15 +23,11 @@ #include "ui/widget/dock.h" #include "verbs.h" #include "dialog.h" -#include "preferences.h" #include "ui/dialog-events.h" #include <gtkmm/invisible.h> -#include <gtkmm/label.h> #include <gtkmm/stock.h> -#include <gtk/gtk.h> - namespace Inkscape { namespace UI { namespace Dialog { diff --git a/src/ui/dialog/document-metadata.cpp b/src/ui/dialog/document-metadata.cpp index da1facc08..dc1958434 100644 --- a/src/ui/dialog/document-metadata.cpp +++ b/src/ui/dialog/document-metadata.cpp @@ -15,13 +15,12 @@ */ #ifdef HAVE_CONFIG_H -# include <config.h> +#include "config.h" #endif #include "document-metadata.h" #include "desktop.h" -#include "inkscape.h" #include "rdf.h" #include "sp-namedview.h" #include "ui/widget/entity-entry.h" @@ -61,12 +60,7 @@ DocumentMetadata::getInstance() DocumentMetadata::DocumentMetadata() -#if WITH_GTKMM_3_0 : UI::Widget::Panel ("", "/dialogs/documentmetadata", SP_VERB_DIALOG_METADATA) -#else - : UI::Widget::Panel ("", "/dialogs/documentmetadata", SP_VERB_DIALOG_METADATA), - _page_metadata1(1, 1), _page_metadata2(1, 1) -#endif { hide(); _getContents()->set_spacing (4); @@ -75,15 +69,10 @@ DocumentMetadata::DocumentMetadata() _page_metadata1.set_border_width(2); _page_metadata2.set_border_width(2); -#if WITH_GTKMM_3_0 _page_metadata1.set_column_spacing(2); _page_metadata2.set_column_spacing(2); _page_metadata1.set_row_spacing(2); _page_metadata2.set_row_spacing(2); -#else - _page_metadata1.set_spacings(2); - _page_metadata2.set_spacings(2); -#endif _notebook.append_page(_page_metadata1, _("Metadata")); _notebook.append_page(_page_metadata2, _("License")); @@ -126,12 +115,8 @@ DocumentMetadata::build_metadata() label->set_markup (_("<b>Dublin Core Entities</b>")); label->set_alignment (0.0); -#if WITH_GTKMM_3_0 label->set_valign(Gtk::ALIGN_CENTER); _page_metadata1.attach(*label, 0, 0, 3, 1); -#else - _page_metadata1.attach(*label, 0,3,0,1, Gtk::FILL, (Gtk::AttachOptions)0,0,0); -#endif /* add generic metadata entry areas */ struct rdf_work_entity_t * entity; @@ -143,7 +128,6 @@ DocumentMetadata::build_metadata() Gtk::HBox *space = Gtk::manage (new Gtk::HBox); space->set_size_request (SPACE_SIZE_X, SPACE_SIZE_Y); -#if WITH_GTKMM_3_0 space->set_valign(Gtk::ALIGN_CENTER); _page_metadata1.attach(*space, 0, row, 1, 1); @@ -153,11 +137,6 @@ DocumentMetadata::build_metadata() w->_packable->set_hexpand(); w->_packable->set_valign(Gtk::ALIGN_CENTER); _page_metadata1.attach(*w->_packable, 2, row, 1, 1); -#else - _page_metadata1.attach(*space, 0,1, row, row+1, Gtk::FILL, (Gtk::AttachOptions)0,0,0); - _page_metadata1.attach(w->_label, 1,2, row, row+1, Gtk::FILL, (Gtk::AttachOptions)0,0,0); - _page_metadata1.attach(*w->_packable, 2,3, row, row+1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0,0,0); -#endif } } @@ -167,31 +146,20 @@ DocumentMetadata::build_metadata() Gtk::Label *llabel = Gtk::manage (new Gtk::Label); llabel->set_markup (_("<b>License</b>")); llabel->set_alignment (0.0); - -#if WITH_GTKMM_3_0 llabel->set_valign(Gtk::ALIGN_CENTER); _page_metadata2.attach(*llabel, 0, row, 3, 1); -#else - _page_metadata2.attach(*llabel, 0,3, row, row+1, Gtk::FILL, (Gtk::AttachOptions)0,0,0); -#endif /* add license selector pull-down and URI */ ++row; _licensor.init (_wr); Gtk::HBox *space = Gtk::manage (new Gtk::HBox); space->set_size_request (SPACE_SIZE_X, SPACE_SIZE_Y); - -#if WITH_GTKMM_3_0 space->set_valign(Gtk::ALIGN_CENTER); _page_metadata2.attach(*space, 0, row, 1, 1); _licensor.set_hexpand(); _licensor.set_valign(Gtk::ALIGN_CENTER); _page_metadata2.attach(_licensor, 1, row, 2, 1); -#else - _page_metadata2.attach(*space, 0,1, row, row+1, Gtk::FILL, (Gtk::AttachOptions)0,0,0); - _page_metadata2.attach(_licensor, 1,3, row, row+1, Gtk::EXPAND|Gtk::FILL, (Gtk::AttachOptions)0,0,0); -#endif } /** diff --git a/src/ui/dialog/document-metadata.h b/src/ui/dialog/document-metadata.h index cde5d92fd..2c56e9317 100644 --- a/src/ui/dialog/document-metadata.h +++ b/src/ui/dialog/document-metadata.h @@ -21,12 +21,7 @@ #include <stddef.h> #include "ui/widget/panel.h" #include <gtkmm/notebook.h> - -#if WITH_GTKMM_3_0 -# include <gtkmm/grid.h> -#else -# include <gtkmm/table.h> -#endif +#include <gtkmm/grid.h> #include "inkscape.h" #include "ui/widget/licensor.h" @@ -62,13 +57,8 @@ protected: Gtk::Notebook _notebook; -#if WITH_GTKMM_3_0 Gtk::Grid _page_metadata1; Gtk::Grid _page_metadata2; -#else - Gtk::Table _page_metadata1; - Gtk::Table _page_metadata2; -#endif //--------------------------------------------------------------- RDElist _rdflist; diff --git a/src/ui/dialog/document-properties.cpp b/src/ui/dialog/document-properties.cpp index 589973162..053549b73 100644 --- a/src/ui/dialog/document-properties.cpp +++ b/src/ui/dialog/document-properties.cpp @@ -25,27 +25,17 @@ #include "ui/widget/notebook-page.h" #include "document-properties.h" #include "display/canvas-grid.h" -#include "document.h" -#include "desktop.h" -#include "inkscape.h" #include "io/sys.h" -#include "preferences.h" #include "ui/shape-editor.h" -#include "sp-namedview.h" #include "sp-root.h" #include "sp-script.h" #include "style.h" -#include "svg/stringstream.h" #include "ui/tools-switch.h" -#include "ui/widget/color-picker.h" -#include "ui/widget/scalar-unit.h" #include "ui/dialog/filedialog.h" #include "verbs.h" #include "widgets/icon.h" #include "xml/node-event-vector.h" -#include "xml/repr.h" -#include <algorithm> // std::min #include "rdf.h" #include "ui/widget/entity-entry.h" @@ -54,11 +44,9 @@ #include "color-profile.h" #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) -#include <gtkmm/imagemenuitem.h> #include <gtkmm/stock.h> -#include <gtkmm/table.h> +#include <gtkmm/imagemenuitem.h> -#include <2geom/transforms.h> #include "ui/icon-names.h" using std::pair; @@ -223,25 +211,16 @@ DocumentProperties::~DocumentProperties() * widget in columns 2-3; (non-0, 0) means label in columns 1-3; and * (non-0, non-0) means two widgets in columns 2 and 3. */ -#if WITH_GTKMM_3_0 inline void attach_all(Gtk::Grid &table, Gtk::Widget *const arr[], unsigned const n, int start = 0, int docum_prop_flag = 0) -#else -inline void attach_all(Gtk::Table &table, Gtk::Widget *const arr[], unsigned const n, int start = 0, int docum_prop_flag = 0) -#endif { for (unsigned i = 0, r = start; i < n; i += 2) { if (arr[i] && arr[i+1]) { -#if WITH_GTKMM_3_0 arr[i]->set_hexpand(); arr[i+1]->set_hexpand(); arr[i]->set_valign(Gtk::ALIGN_CENTER); arr[i+1]->set_valign(Gtk::ALIGN_CENTER); table.attach(*arr[i], 1, r, 1, 1); table.attach(*arr[i+1], 2, r, 1, 1); -#else - table.attach(*arr[i], 1, 2, r, r+1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0,0,0); - table.attach(*arr[i+1], 2, 3, r, r+1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0,0,0); -#endif } else { if (arr[i+1]) { Gtk::AttachOptions yoptions = (Gtk::AttachOptions)0; @@ -252,7 +231,6 @@ inline void attach_all(Gtk::Table &table, Gtk::Widget *const arr[], unsigned con if (docum_prop_flag) { // this sets the padding for subordinate widgets on the "Page" page if( i==(n-8) || i==(n-10) ) { -#if WITH_GTKMM_3_0 arr[i+1]->set_hexpand(); arr[i+1]->set_margin_left(20); arr[i+1]->set_margin_right(20); @@ -263,11 +241,7 @@ inline void attach_all(Gtk::Table &table, Gtk::Widget *const arr[], unsigned con arr[i+1]->set_valign(Gtk::ALIGN_CENTER); table.attach(*arr[i+1], 1, r, 2, 1); -#else - table.attach(*arr[i+1], 1, 3, r, r+1, Gtk::FILL|Gtk::EXPAND, yoptions, 20,0); -#endif } else { -#if WITH_GTKMM_3_0 arr[i+1]->set_hexpand(); if (yoptions & Gtk::EXPAND) @@ -276,12 +250,8 @@ inline void attach_all(Gtk::Table &table, Gtk::Widget *const arr[], unsigned con arr[i+1]->set_valign(Gtk::ALIGN_CENTER); table.attach(*arr[i+1], 1, r, 2, 1); -#else - table.attach(*arr[i+1], 1, 3, r, r+1, Gtk::FILL|Gtk::EXPAND, yoptions, 0,0); -#endif } } else { -#if WITH_GTKMM_3_0 arr[i+1]->set_hexpand(); if (yoptions & Gtk::EXPAND) @@ -290,32 +260,21 @@ inline void attach_all(Gtk::Table &table, Gtk::Widget *const arr[], unsigned con arr[i+1]->set_valign(Gtk::ALIGN_CENTER); table.attach(*arr[i+1], 1, r, 2, 1); -#else - table.attach(*arr[i+1], 1, 3, r, r+1, Gtk::FILL|Gtk::EXPAND, yoptions, 0,0); -#endif } } else if (arr[i]) { Gtk::Label& label = reinterpret_cast<Gtk::Label&>(*arr[i]); label.set_alignment (0.0); -#if WITH_GTKMM_3_0 label.set_hexpand(); label.set_valign(Gtk::ALIGN_CENTER); table.attach(label, 0, r, 3, 1); -#else - table.attach (label, 0, 3, r, r+1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0,0,0); -#endif } else { Gtk::HBox *space = Gtk::manage (new Gtk::HBox); space->set_size_request (SPACE_SIZE_X, SPACE_SIZE_Y); -#if WITH_GTKMM_3_0 space->set_halign(Gtk::ALIGN_CENTER); space->set_valign(Gtk::ALIGN_CENTER); table.attach(*space, 0, r, 1, 1); -#else - table.attach (*space, 0, 1, r, r+1, (Gtk::AttachOptions)0, (Gtk::AttachOptions)0,0,0); -#endif } } ++r; @@ -685,52 +644,35 @@ void DocumentProperties::build_cms() label_link->set_alignment(0.0); -#if WITH_GTKMM_3_0 label_link->set_hexpand(); label_link->set_valign(Gtk::ALIGN_CENTER); _page_cms->table().attach(*label_link, 0, row, 3, 1); -#else - _page_cms->table().attach(*label_link, 0, 3, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0); -#endif row++; -#if WITH_GTKMM_3_0 _LinkedProfilesListScroller.set_hexpand(); _LinkedProfilesListScroller.set_valign(Gtk::ALIGN_CENTER); _page_cms->table().attach(_LinkedProfilesListScroller, 0, row, 3, 1); -#else - _page_cms->table().attach(_LinkedProfilesListScroller, 0, 3, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0); -#endif row++; Gtk::HBox* spacer = Gtk::manage(new Gtk::HBox()); spacer->set_size_request(SPACE_SIZE_X, SPACE_SIZE_Y); -#if WITH_GTKMM_3_0 spacer->set_hexpand(); spacer->set_valign(Gtk::ALIGN_CENTER); _page_cms->table().attach(*spacer, 0, row, 3, 1); -#else - _page_cms->table().attach(*spacer, 0, 3, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0); -#endif row++; label_avail->set_alignment(0.0); -#if WITH_GTKMM_3_0 label_avail->set_hexpand(); label_avail->set_valign(Gtk::ALIGN_CENTER); _page_cms->table().attach(*label_avail, 0, row, 3, 1); -#else - _page_cms->table().attach(*label_avail, 0, 3, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0); -#endif row++; -#if WITH_GTKMM_3_0 _AvailableProfilesList.set_hexpand(); _AvailableProfilesList.set_valign(Gtk::ALIGN_CENTER); _page_cms->table().attach(_AvailableProfilesList, 0, row, 1, 1); @@ -744,11 +686,6 @@ void DocumentProperties::build_cms() _unlink_btn.set_halign(Gtk::ALIGN_CENTER); _unlink_btn.set_valign(Gtk::ALIGN_CENTER); _page_cms->table().attach(_unlink_btn, 2, row, 1, 1); -#else - _page_cms->table().attach(_AvailableProfilesList, 0, 1, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0); - _page_cms->table().attach(_link_btn, 1, 2, row, row + 1, (Gtk::AttachOptions)0, (Gtk::AttachOptions)0, 2, 0); - _page_cms->table().attach(_unlink_btn, 2, 3, row, row + 1, (Gtk::AttachOptions)0, (Gtk::AttachOptions)0, 0, 0); -#endif // Set up the Avialable Profiles combo box _AvailableProfilesListStore = Gtk::ListStore::create(_AvailableProfilesListColumns); @@ -815,41 +752,27 @@ void DocumentProperties::build_scripting() gint row = 0; label_external->set_alignment(0.0); - -#if WITH_GTKMM_3_0 label_external->set_hexpand(); label_external->set_valign(Gtk::ALIGN_CENTER); _page_external_scripts->table().attach(*label_external, 0, row, 3, 1); -#else - _page_external_scripts->table().attach(*label_external, 0, 3, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0); -#endif row++; -#if WITH_GTKMM_3_0 _ExternalScriptsListScroller.set_hexpand(); _ExternalScriptsListScroller.set_valign(Gtk::ALIGN_CENTER); _page_external_scripts->table().attach(_ExternalScriptsListScroller, 0, row, 3, 1); -#else - _page_external_scripts->table().attach(_ExternalScriptsListScroller, 0, 3, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0); -#endif row++; Gtk::HBox* spacer_external = Gtk::manage(new Gtk::HBox()); spacer_external->set_size_request(SPACE_SIZE_X, SPACE_SIZE_Y); -#if WITH_GTKMM_3_0 spacer_external->set_hexpand(); spacer_external->set_valign(Gtk::ALIGN_CENTER); _page_external_scripts->table().attach(*spacer_external, 0, row, 3, 1); -#else - _page_external_scripts->table().attach(*spacer_external, 0, 3, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0); -#endif row++; -#if WITH_GTKMM_3_0 _script_entry.set_hexpand(); _script_entry.set_valign(Gtk::ALIGN_CENTER); _page_external_scripts->table().attach(_script_entry, 0, row, 1, 1); @@ -863,11 +786,6 @@ void DocumentProperties::build_scripting() _external_remove_btn.set_halign(Gtk::ALIGN_CENTER); _external_remove_btn.set_valign(Gtk::ALIGN_CENTER); _page_external_scripts->table().attach(_external_remove_btn, 2, row, 1, 1); -#else - _page_external_scripts->table().attach(_script_entry, 0, 1, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0); - _page_external_scripts->table().attach(_external_add_btn, 1, 2, row, row + 1, (Gtk::AttachOptions)0, (Gtk::AttachOptions)0, 2, 0); - _page_external_scripts->table().attach(_external_remove_btn, 2, 3, row, row + 1, (Gtk::AttachOptions)0, (Gtk::AttachOptions)0, 0, 0); -#endif //# Set up the External Scripts box _ExternalScriptsListStore = Gtk::ListStore::create(_ExternalScriptsListColumns); @@ -888,12 +806,6 @@ void DocumentProperties::build_scripting() _embed_remove_btn.set_tooltip_text(_("Remove")); docprops_style_button(_embed_remove_btn, INKSCAPE_ICON("list-remove")); -#if !WITH_GTKMM_3_0 - // TODO: This has been removed from Gtkmm 3.0. Check that - // everything still looks OK! - _embed_button_box.set_child_min_width( 16 ); - _embed_button_box.set_spacing( 4 ); -#endif _embed_button_box.set_layout (Gtk::BUTTONBOX_START); _embed_button_box.add(_embed_new_btn); _embed_button_box.add(_embed_remove_btn); @@ -902,47 +814,29 @@ void DocumentProperties::build_scripting() row = 0; label_embedded->set_alignment(0.0); - -#if WITH_GTKMM_3_0 label_embedded->set_hexpand(); label_embedded->set_valign(Gtk::ALIGN_CENTER); _page_embedded_scripts->table().attach(*label_embedded, 0, row, 3, 1); -#else - _page_embedded_scripts->table().attach(*label_embedded, 0, 3, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0); -#endif row++; -#if WITH_GTKMM_3_0 _EmbeddedScriptsListScroller.set_hexpand(); _EmbeddedScriptsListScroller.set_valign(Gtk::ALIGN_CENTER); _page_embedded_scripts->table().attach(_EmbeddedScriptsListScroller, 0, row, 3, 1); -#else - _page_embedded_scripts->table().attach(_EmbeddedScriptsListScroller, 0, 3, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0); -#endif row++; -#if WITH_GTKMM_3_0 _embed_button_box.set_hexpand(); _embed_button_box.set_valign(Gtk::ALIGN_CENTER); _page_embedded_scripts->table().attach(_embed_button_box, 0, row, 1, 1); -#else - _page_embedded_scripts->table().attach(_embed_button_box, 0, 1, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0); -#endif row++; Gtk::HBox* spacer_embedded = Gtk::manage(new Gtk::HBox()); spacer_embedded->set_size_request(SPACE_SIZE_X, SPACE_SIZE_Y); - -#if WITH_GTKMM_3_0 spacer_embedded->set_hexpand(); spacer_embedded->set_valign(Gtk::ALIGN_CENTER); _page_embedded_scripts->table().attach(*spacer_embedded, 0, row, 3, 1); -#else - _page_embedded_scripts->table().attach(*spacer_embedded, 0, 3, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0); -#endif row++; @@ -958,24 +852,15 @@ void DocumentProperties::build_scripting() label_embedded_content->set_markup (_("<b>Content:</b>")); label_embedded_content->set_alignment(0.0); - -#if WITH_GTKMM_3_0 label_embedded_content->set_hexpand(); label_embedded_content->set_valign(Gtk::ALIGN_CENTER); _page_embedded_scripts->table().attach(*label_embedded_content, 0, row, 3, 1); -#else - _page_embedded_scripts->table().attach(*label_embedded_content, 0, 3, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0); -#endif row++; -#if WITH_GTKMM_3_0 _EmbeddedContentScroller.set_hexpand(); _EmbeddedContentScroller.set_valign(Gtk::ALIGN_CENTER); _page_embedded_scripts->table().attach(_EmbeddedContentScroller, 0, row, 3, 1); -#else - _page_embedded_scripts->table().attach(_EmbeddedContentScroller, 0, 3, row, row + 1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 0, 0); -#endif _EmbeddedContentScroller.add(_EmbeddedContent); _EmbeddedContentScroller.set_shadow_type(Gtk::SHADOW_IN); @@ -1037,12 +922,8 @@ void DocumentProperties::build_metadata() label->set_markup (_("<b>Dublin Core Entities</b>")); label->set_alignment (0.0); -#if WITH_GTKMM_3_0 label->set_valign(Gtk::ALIGN_CENTER); _page_metadata1->table().attach (*label, 0,0,3,1); -#else - _page_metadata1->table().attach (*label, 0,3,0,1, Gtk::FILL, (Gtk::AttachOptions)0,0,0); -#endif /* add generic metadata entry areas */ struct rdf_work_entity_t * entity; @@ -1053,8 +934,6 @@ void DocumentProperties::build_metadata() _rdflist.push_back (w); Gtk::HBox *space = Gtk::manage (new Gtk::HBox); space->set_size_request (SPACE_SIZE_X, SPACE_SIZE_Y); - -#if WITH_GTKMM_3_0 space->set_valign(Gtk::ALIGN_CENTER); _page_metadata1->table().attach(*space, 0, row, 1, 1); @@ -1064,11 +943,6 @@ void DocumentProperties::build_metadata() w->_packable->set_hexpand(); w->_packable->set_valign(Gtk::ALIGN_CENTER); _page_metadata1->table().attach(*w->_packable, 2, row, 1, 1); -#else - _page_metadata1->table().attach (*space, 0,1, row, row+1, Gtk::FILL, (Gtk::AttachOptions)0,0,0); - _page_metadata1->table().attach (w->_label, 1,2, row, row+1, Gtk::FILL, (Gtk::AttachOptions)0,0,0); - _page_metadata1->table().attach (*w->_packable, 2,3, row, row+1, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0,0,0); -#endif } } @@ -1077,11 +951,7 @@ void DocumentProperties::build_metadata() Gtk::Button *button_load = Gtk::manage (new Gtk::Button(_("Use _default"),1)); button_load->set_tooltip_text(_("Use the previously saved default metadata here")); -#if WITH_GTKMM_3_0 - Gtk::ButtonBox *box_buttons = Gtk::manage (new Gtk::ButtonBox); -#else - Gtk::HButtonBox *box_buttons = Gtk::manage (new Gtk::HButtonBox); -#endif + auto box_buttons = Gtk::manage (new Gtk::ButtonBox); box_buttons->set_layout(Gtk::BUTTONBOX_END); box_buttons->set_spacing(4); @@ -1099,12 +969,8 @@ void DocumentProperties::build_metadata() llabel->set_markup (_("<b>License</b>")); llabel->set_alignment (0.0); -#if WITH_GTKMM_3_0 llabel->set_valign(Gtk::ALIGN_CENTER); _page_metadata2->table().attach(*llabel, 0, row, 3, 1); -#else - _page_metadata2->table().attach (*llabel, 0,3, row, row+1, Gtk::FILL, (Gtk::AttachOptions)0,0,0); -#endif /* add license selector pull-down and URI */ ++row; @@ -1112,17 +978,12 @@ void DocumentProperties::build_metadata() Gtk::HBox *space = Gtk::manage (new Gtk::HBox); space->set_size_request (SPACE_SIZE_X, SPACE_SIZE_Y); -#if WITH_GTKMM_3_0 space->set_valign(Gtk::ALIGN_CENTER); _page_metadata2->table().attach(*space, 0, row, 1, 1); _licensor.set_hexpand(); _licensor.set_valign(Gtk::ALIGN_CENTER); _page_metadata2->table().attach(_licensor, 1, row, 3, 1); -#else - _page_metadata2->table().attach (*space, 0,1, row, row+1, Gtk::FILL, (Gtk::AttachOptions)0,0,0); - _page_metadata2->table().attach (_licensor, 1,3, row, row+1, Gtk::EXPAND|Gtk::FILL, (Gtk::AttachOptions)0,0,0); -#endif } void DocumentProperties::addExternalScript(){ @@ -1315,12 +1176,7 @@ void DocumentProperties::changeEmbeddedScript(){ for (std::vector<SPObject *>::const_iterator it = current.begin(); it != current.end(); ++it) { SPObject* obj = *it; if (id == obj->getId()){ - - int count=0; - for ( SPObject *child = obj->children ; child; child = child->next ) - { - count++; - } + int count = (int) obj->children.size(); if (count>1) g_warning("TODO: Found a script element with multiple (%d) child nodes! We must implement support for that!", count); @@ -1364,8 +1220,11 @@ void DocumentProperties::editEmbeddedScript(){ //XML Tree being used directly here while it shouldn't be. Inkscape::XML::Node *repr = obj->getRepr(); if (repr){ - SPObject *child; - while (NULL != (child = obj->firstChild())) child->deleteObject(); + auto tmp = obj->children | boost::adaptors::transformed([](SPObject& o) { return &o; }); + std::vector<SPObject*> vec(tmp.begin(), tmp.end()); + for (auto &child: vec) { + child->deleteObject(); + } obj->appendChildRepr(xml_doc->createTextNode(_EmbeddedContent.get_buffer()->get_text().c_str())); //TODO repr->set_content(_EmbeddedContent.get_buffer()->get_text()); diff --git a/src/ui/dialog/document-properties.h b/src/ui/dialog/document-properties.h index 7f91d9ea0..8d1c6b38a 100644 --- a/src/ui/dialog/document-properties.h +++ b/src/ui/dialog/document-properties.h @@ -173,11 +173,7 @@ protected: Gtk::Button _external_remove_btn; Gtk::Button _embed_new_btn; Gtk::Button _embed_remove_btn; -#if WITH_GTKMM_3_0 - Gtk::ButtonBox _embed_button_box; -#else - Gtk::HButtonBox _embed_button_box; -#endif + Gtk::ButtonBox _embed_button_box; class ExternalScriptsColumns : public Gtk::TreeModel::ColumnRecord { diff --git a/src/ui/dialog/export.cpp b/src/ui/dialog/export.cpp index 2fb5f9e3b..64a5d9866 100644 --- a/src/ui/dialog/export.cpp +++ b/src/ui/dialog/export.cpp @@ -24,18 +24,9 @@ #include <gtkmm/buttonbox.h> #include <gtkmm/dialog.h> #include <gtkmm/entry.h> -#include <gtkmm/image.h> -#include <gtkmm/label.h> +#include <gtkmm/grid.h> #include <gtkmm/spinbutton.h> #include <gtkmm/stock.h> -#include <gtkmm/stockid.h> -#if WITH_GTKMM_3_0 -# include <gtkmm/grid.h> -#else -# include <gtkmm/table.h> -#endif -#include <gtkmm/togglebutton.h> -#include <gtkmm/widget.h> #ifdef WITH_GNOME_VFS # include <libgnomevfs/gnome-vfs-init.h> // gnome_vfs_initialized @@ -45,16 +36,12 @@ #include <glibmm/miscutils.h> #include "ui/widget/unit-menu.h" -#include "util/units.h" #include "helper/window.h" #include "inkscape.h" #include "document.h" #include "document-undo.h" -#include "sp-item.h" -#include "selection.h" #include "file.h" -#include "macros.h" #include "sp-namedview.h" #include "selection-chemistry.h" @@ -71,12 +58,7 @@ #include "helper/png-write.h" -#if WITH_EXT_GDL #include <gdl/gdl-dock-item.h> -#else -#include "libgdl/gdl-dock-item.h" -#endif - // required to set status message after export #include "desktop.h" @@ -89,17 +71,12 @@ #include <glibmm/fileutils.h> #endif -#include <gtk/gtk.h> - #define SP_EXPORT_MIN_SIZE 1.0 #define DPI_BASE Inkscape::Util::Quantity::convert(1, "in", "px") #define EXPORT_COORD_PRECISION 3 -#include "../../document.h" -#include "../../document-undo.h" -#include "verbs.h" #include "export.h" using Inkscape::Util::unit_table; @@ -168,6 +145,13 @@ Export::Export (void) : browse_image(Gtk::StockID(Gtk::Stock::INDEX), Gtk::ICON_SIZE_BUTTON), batch_box(false, 5), batch_export(_("B_atch export all selected objects"), _("Export each selected object into its own PNG file, using export hints if any (caution, overwrites without asking!)")), + interlacing(_("Use interlacing"),_("Enables ADAM7 interlacing for PNG output. This results in slightly heavier images, but big images will look better sooner when loading the file")), + bitdepth_label(_("Bit depth")), + bitdepth_cb(), + zlib_label(_("Compression")), + zlib_compression(), + pHYs_label(_("pHYs dpi")), + pHYs_sb(pHYs_adj, 1.0, 2), hide_box(false, 5), hide_export(_("Hide a_ll except selected"), _("In the exported image, hide all objects except those that are selected")), closeWhenDone(_("Close when complete"), _("Once the export completes, close this dialog")), @@ -218,15 +202,9 @@ Export::Export (void) : selectiontype_buttons[i]->signal_clicked().connect(sigc::mem_fun(*this, &Export::onAreaToggled)); } -#if WITH_GTKMM_3_0 - Gtk::Grid* t = new Gtk::Grid(); + auto t = new Gtk::Grid(); t->set_row_spacing(4); t->set_column_spacing(4); -#else - Gtk::Table* t = new Gtk::Table(3, 4, false); - t->set_row_spacings (4); - t->set_col_spacings (4); -#endif x0_adj = createSpinbutton ( "x0", 0.0, -1000000.0, 1000000.0, 0.1, 1.0, t, 0, 0, _("_x0:"), "", EXPORT_COORD_PRECISION, 1, @@ -268,15 +246,9 @@ Export::Export (void) : bm_label->set_use_markup(true); size_box.pack_start(*bm_label, false, false, 0); -#if WITH_GTKMM_3_0 - Gtk::Grid *t = new Gtk::Grid(); + auto t = new Gtk::Grid(); t->set_row_spacing(4); t->set_column_spacing(4); -#else - Gtk::Table *t = new Gtk::Table(2, 5, false); - t->set_row_spacings (4); - t->set_col_spacings (4); -#endif size_box.pack_start(*t); @@ -356,6 +328,34 @@ Export::Export (void) : button_box.pack_start(closeWhenDone, true, true, 0 ); button_box.pack_end(export_button, false, false, 0); + /*Advanced*/ + Gtk::Label *label_advanced = Gtk::manage(new Gtk::Label(_("Advanced"),1)); + expander.set_label_widget(*label_advanced); + const char* const modes_list[]={"Gray_1", "Gray_2","Gray_4","Gray_8","Gray_16","RGB_8","RGB_16","GrayAlpha_8","GrayAlpha_16","RGBA_8","RGBA_16"}; + for(int i=0; i<11; ++i) + bitdepth_cb.append(modes_list[i]); + bitdepth_cb.set_active_text("RGBA_8"); + bitdepth_cb.set_hexpand(); + const char* const zlist[]={"Z_NO_COMPRESSION","Z_BEST_SPEED","2","3","4","5","Z_DEFAULT_COMPRESSION","7","8","Z_BEST_COMPRESSION"}; + for(int i=0; i<10; ++i) + zlib_compression.append(zlist[i]); + zlib_compression.set_active_text("Z_DEFAULT_COMPRESSION"); + pHYs_adj = Gtk::Adjustment::create(0, 0, 100000, 0.1, 1.0, 0); + pHYs_sb.set_adjustment(pHYs_adj); + pHYs_sb.set_width_chars(7); + pHYs_sb.set_tooltip_text( _("Will force-set the physical dpi for the png file. Set this to 72 if you're planning to work on your png with Photoshop") ); + zlib_compression.set_hexpand(); + auto table = new Gtk::Grid(); + gtk_container_add(GTK_CONTAINER(expander.gobj()), (GtkWidget*)(table->gobj())); + table->attach(interlacing,0,0,1,1); + table->attach(bitdepth_label,0,1,1,1); + table->attach(bitdepth_cb,1,1,1,1); + table->attach(zlib_label,0,2,1,1); + table->attach(zlib_compression,1,2,1,1); + table->attach(pHYs_label,0,3,1,1); + table->attach(pHYs_sb,1,3,1,1); + table->show(); + /* Main dialog */ Gtk::Box *contents = _getContents(); contents->set_spacing(0); @@ -364,6 +364,7 @@ Export::Export (void) : contents->pack_start(hide_box); contents->pack_end(button_box, false, 0); contents->pack_end(_prog, Gtk::PACK_EXPAND_WIDGET); + contents->pack_end(expander, FALSE, FALSE,0); /* Signal handlers */ filename_entry.signal_changed().connect( sigc::mem_fun(*this, &Export::onFilenameModified) ); @@ -484,27 +485,14 @@ void Export::set_default_filename () { } } -#if WITH_GTKMM_3_0 Glib::RefPtr<Gtk::Adjustment> Export::createSpinbutton( gchar const * /*key*/, float val, float min, float max, float step, float page, Gtk::Grid *t, int x, int y, const Glib::ustring& ll, const Glib::ustring& lr, int digits, unsigned int sensitive, void (Export::*cb)() ) -#else -Gtk::Adjustment * Export::createSpinbutton( gchar const * /*key*/, float val, float min, float max, - float step, float page, - Gtk::Table *t, int x, int y, - const Glib::ustring& ll, const Glib::ustring& lr, - int digits, unsigned int sensitive, - void (Export::*cb)() ) -#endif { -#if WITH_GTKMM_3_0 - Glib::RefPtr<Gtk::Adjustment> adj = Gtk::Adjustment::create(val, min, max, step, page, 0); -#else - Gtk::Adjustment *adj = new Gtk::Adjustment ( val, min, max, step, page, 0 ); -#endif + auto adj = Gtk::Adjustment::create(val, min, max, step, page, 0); int pos = 0; Gtk::Label *l = NULL; @@ -512,28 +500,17 @@ Gtk::Adjustment * Export::createSpinbutton( gchar const * /*key*/, float val, fl if (!ll.empty()) { l = new Gtk::Label(ll,true); l->set_alignment (1.0, 0.5); - -#if WITH_GTKMM_3_0 l->set_hexpand(); l->set_vexpand(); t->attach(*l, x + pos, y, 1, 1); -#else - t->attach (*l, x + pos, x + pos + 1, y, y + 1, Gtk::EXPAND, Gtk::EXPAND, 0, 0 ); -#endif - l->set_sensitive(sensitive); pos++; } -#if WITH_GTKMM_3_0 - Gtk::SpinButton *sb = new Gtk::SpinButton(adj, 1.0, digits); + auto sb = new Gtk::SpinButton(adj, 1.0, digits); sb->set_hexpand(); sb->set_vexpand(); t->attach(*sb, x + pos, y, 1, 1); -#else - Gtk::SpinButton *sb = new Gtk::SpinButton(*adj, 1.0, digits); - t->attach (*sb, x + pos, x + pos + 1, y, y + 1, Gtk::EXPAND, Gtk::EXPAND, 0, 0 ); -#endif sb->set_width_chars(7); sb->set_sensitive (sensitive); @@ -546,15 +523,9 @@ Gtk::Adjustment * Export::createSpinbutton( gchar const * /*key*/, float val, fl if (!lr.empty()) { l = new Gtk::Label(lr,true); l->set_alignment (0.0, 0.5); - -#if WITH_GTKMM_3_0 l->set_hexpand(); l->set_vexpand(); t->attach(*l, x + pos, y, 1, 1); -#else - t->attach (*l, x + pos, x + pos + 1, y, y + 1, Gtk::EXPAND, Gtk::EXPAND, 0, 0 ); -#endif - l->set_sensitive (sensitive); pos++; l->set_mnemonic_widget (*sb); @@ -608,7 +579,7 @@ void Export::onBatchClicked () void Export::updateCheckbuttons () { - gint num = SP_ACTIVE_DESKTOP->getSelection()->itemList().size(); + gint num = (gint) boost::distance(SP_ACTIVE_DESKTOP->getSelection()->items()); if (num >= 2) { batch_export.set_sensitive(true); batch_export.set_label(g_strdup_printf (ngettext("B_atch export %d selected object","B_atch export %d selected objects",num), num)); @@ -814,14 +785,14 @@ void Export::onAreaToggled () case SELECTION_SELECTION: if ((SP_ACTIVE_DESKTOP->getSelection())->isEmpty() == false) { - sp_selection_get_export_hints (SP_ACTIVE_DESKTOP->getSelection(), filename, &xdpi, &ydpi); + sp_object_set_get_export_hints(SP_ACTIVE_DESKTOP->getSelection(), filename, &xdpi, &ydpi); /* If we still don't have a filename -- let's build one that's nice */ if (filename.empty()) { const gchar * id = "object"; - const std::vector<XML::Node*> reprlst = SP_ACTIVE_DESKTOP->getSelection()->reprList(); - for(std::vector<XML::Node*>::const_iterator i=reprlst.begin(); reprlst.end() != i; ++i) { + auto reprlst = SP_ACTIVE_DESKTOP->getSelection()->xmlNodes(); + for(auto i=reprlst.begin(); reprlst.end() != i; ++i) { Inkscape::XML::Node * repr = *i; if (repr->attribute("id")) { id = repr->attribute("id"); @@ -932,11 +903,7 @@ Gtk::Dialog * Export::create_progress_dialog (Glib::ustring progress_text) { Gtk::ProgressBar *prg = new Gtk::ProgressBar (); prg->set_text(progress_text); dlg->set_data ("progress", prg); -#if GTK_CHECK_VERSION(3,0,0) - Gtk::Box* CA = dlg->get_content_area(); -#else - Gtk::Box* CA = dlg->get_vbox(); -#endif + auto CA = dlg->get_content_area(); CA->pack_start(*prg, FALSE, FALSE, 4); Gtk::Button* btn = dlg->add_button (Gtk::Stock::CANCEL,Gtk::RESPONSE_CANCEL ); @@ -1012,10 +979,22 @@ void Export::onExport () bool exportSuccessful = false; bool hide = hide_export.get_active (); + + // Advanced parameters + bool do_interlace = (interlacing.get_active()); + float pHYs = 0; + int zlib = zlib_compression.get_active_row_number() ; + const char* const modes_list[]={"Gray_1", "Gray_2","Gray_4","Gray_8","Gray_16","RGB_8","RGB_16","GrayAlpha_8","GrayAlpha_16","RGBA_8","RGBA_16"}; + int colortypes[] = {0,0,0,0,0,2,2,4,4,6,6}; //keep in sync with modes_list in Export constructor. values are from libpng doc. + int bitdepths[] = {1,2,4,8,16,8,16,8,16,8,16}; + int color_type = colortypes[bitdepth_cb.get_active_row_number()] ; + int bit_depth = bitdepths[bitdepth_cb.get_active_row_number()] ; + + if (batch_export.get_active ()) { // Batch export of selected objects - gint num = (desktop->getSelection()->itemList()).size(); + gint num = (gint) boost::distance(desktop->getSelection()->items()); gint n = 0; if (num < 1) { @@ -1029,8 +1008,8 @@ void Export::onExport () gint export_count = 0; - std::vector<SPItem*> itemlist=desktop->getSelection()->itemList(); - for(std::vector<SPItem*>::const_iterator i = itemlist.begin();i!=itemlist.end() && !interrupted ;++i){ + auto itemlist= desktop->getSelection()->items(); + for(auto i = itemlist.begin();i!=itemlist.end() && !interrupted ;++i){ SPItem *item = *i; prog_dlg->set_data("current", GINT_TO_POINTER(n)); @@ -1056,6 +1035,7 @@ void Export::onExport () if (dpi == 0.0) { dpi = getValue(xdpi_adj); } + pHYs = (pHYs_adj->get_value() > 0.01) ? pHYs_adj->get_value() : dpi; Geom::OptRect area = item->desktopVisualBounds(); if (area) { @@ -1070,12 +1050,14 @@ void Export::onExport () MessageCleaner msgFlashCleanup(desktop->messageStack()->flashF(Inkscape::IMMEDIATE_MESSAGE, _("Exporting file <b>%s</b>..."), safeFile), desktop); std::vector<SPItem*> x; + std::vector<SPItem*> selected(desktop->getSelection()->items().begin(), desktop->getSelection()->items().end()); if (!sp_export_png_file (doc, path.c_str(), - *area, width, height, dpi, dpi, + *area, width, height, pHYs, pHYs, nv->pagecolor, onProgressCallback, (void*)prog_dlg, TRUE, // overwrite without asking - hide ? (desktop->getSelection()->itemList()) : x + hide ? selected : x, + do_interlace, color_type, bit_depth, zlib )) { gchar * error = g_strdup_printf(_("Could not export to filename %s.\n"), safeFile); @@ -1117,6 +1099,7 @@ void Export::onExport () float const y1 = getValuePx(y1_adj); float const xdpi = getValue(xdpi_adj); float const ydpi = getValue(ydpi_adj); + pHYs = (pHYs_adj->get_value() > 0.01) ? pHYs_adj->get_value() : xdpi; unsigned long int const width = int(getValue(bmwidth_adj) + 0.5); unsigned long int const height = int(getValue(bmheight_adj) + 0.5); @@ -1160,13 +1143,15 @@ void Export::onExport () /* Do export */ std::vector<SPItem*> x; + std::vector<SPItem*> selected(desktop->getSelection()->items().begin(), desktop->getSelection()->items().end()); ExportResult status = sp_export_png_file(desktop->getDocument(), path.c_str(), - Geom::Rect(Geom::Point(x0, y0), Geom::Point(x1, y1)), width, height, xdpi, ydpi, + Geom::Rect(Geom::Point(x0, y0), Geom::Point(x1, y1)), width, height, pHYs, pHYs, //previously xdpi, ydpi. nv->pagecolor, onProgressCallback, (void*)prog_dlg, FALSE, - hide ? (desktop->getSelection()->itemList()) : x - ); + hide ? selected : x, + do_interlace, color_type, bit_depth, zlib + ); if (status == EXPORT_ERROR) { gchar * safeFile = Inkscape::IO::sanitizeString(path.c_str()); gchar * error = g_strdup_printf(_("Could not export to filename %s.\n"), safeFile); @@ -1231,15 +1216,14 @@ void Export::onExport () break; } case SELECTION_SELECTION: { - std::vector<XML::Node*> reprlst; SPDocument * doc = SP_ACTIVE_DOCUMENT; bool modified = false; bool saved = DocumentUndo::getUndoSensitive(doc); DocumentUndo::setUndoSensitive(doc, false); - reprlst = desktop->getSelection()->reprList(); + auto reprlst = desktop->getSelection()->xmlNodes(); - for(std::vector<Inkscape::XML::Node*>::const_iterator i=reprlst.begin(); reprlst.end() != i; ++i) { + for(auto i=reprlst.begin(); reprlst.end() != i; ++i) { Inkscape::XML::Node * repr = *i; const gchar * temp_string; Glib::ustring dir = Glib::path_get_dirname(filename.c_str()); @@ -1357,11 +1341,7 @@ void Export::onBrowse () Glib::RefPtr<const Gdk::Window> parentWindow = desktop->getToplevel()->get_window(); g_assert(parentWindow->gobj() != NULL); -#if WITH_GTKMM_3_0 opf.hwndOwner = (HWND)gdk_win32_window_get_handle((GdkWindow*)parentWindow->gobj()); -#else - opf.hwndOwner = (HWND)gdk_win32_drawable_get_handle((GdkDrawable*)parentWindow->gobj()); -#endif opf.lpstrFilter = filter_string; opf.lpstrCustomFilter = 0; opf.nMaxCustFilter = 0L; @@ -1521,11 +1501,7 @@ void Export::detectSize() { } /* sp_export_detect_size */ /// Called when area x0 value is changed -#if WITH_GTKMM_3_0 void Export::areaXChange(Glib::RefPtr<Gtk::Adjustment>& adj) -#else -void Export::areaXChange (Gtk::Adjustment *adj) -#endif { float x0, x1, xdpi, width; @@ -1564,11 +1540,7 @@ void Export::areaXChange (Gtk::Adjustment *adj) } // end of sp_export_area_x_value_changed() /// Called when area y0 value is changed. -#if WITH_GTKMM_3_0 void Export::areaYChange(Glib::RefPtr<Gtk::Adjustment>& adj) -#else -void Export::areaYChange (Gtk::Adjustment *adj) -#endif { float y0, y1, ydpi, height; @@ -1875,11 +1847,7 @@ void Export::setArea( double x0, double y0, double x1, double y1 ) * @param adj The adjustment widget * @param val What value to set it to. */ -#if WITH_GTKMM_3_0 void Export::setValue(Glib::RefPtr<Gtk::Adjustment>& adj, double val ) -#else -void Export::setValue( Gtk::Adjustment *adj, double val ) -#endif { if (adj) { adj->set_value(val); @@ -1897,11 +1865,7 @@ void Export::setValue( Gtk::Adjustment *adj, double val ) * @param adj The adjustment widget * @param val What the value should be in points. */ -#if WITH_GTKMM_3_0 void Export::setValuePx(Glib::RefPtr<Gtk::Adjustment>& adj, double val) -#else -void Export::setValuePx( Gtk::Adjustment *adj, double val) -#endif { Unit const *unit = unit_selector.getUnit(); @@ -1920,11 +1884,7 @@ void Export::setValuePx( Gtk::Adjustment *adj, double val) * * @return The value in the specified adjustment. */ -#if WITH_GTKMM_3_0 float Export::getValue(Glib::RefPtr<Gtk::Adjustment>& adj) -#else -float Export::getValue( Gtk::Adjustment *adj ) -#endif { if (!adj) { g_message("sp_export_value_get : adj is NULL"); @@ -1946,11 +1906,7 @@ float Export::getValue( Gtk::Adjustment *adj ) * * @return The value in the adjustment in points. */ -#if WITH_GTKMM_3_0 float Export::getValuePx(Glib::RefPtr<Gtk::Adjustment>& adj) -#else -float Export::getValuePx( Gtk::Adjustment *adj ) -#endif { float value = getValue( adj); Unit const *unit = unit_selector.getUnit(); diff --git a/src/ui/dialog/export.h b/src/ui/dialog/export.h index 23af0109b..112f42312 100644 --- a/src/ui/dialog/export.h +++ b/src/ui/dialog/export.h @@ -13,6 +13,9 @@ #define SP_EXPORT_H #include <gtkmm/progressbar.h> +#include <gtkmm/expander.h> +#include <gtkmm/grid.h> +#include <gtkmm/comboboxtext.h> #include "ui/dialog/desktop-tracker.h" #include "ui/widget/panel.h" @@ -79,17 +82,10 @@ private: /* * Getter/setter style functions for the spinbuttons */ -#if WITH_GTKMM_3_0 void setValue(Glib::RefPtr<Gtk::Adjustment>& adj, double val); void setValuePx(Glib::RefPtr<Gtk::Adjustment>& adj, double val); float getValue(Glib::RefPtr<Gtk::Adjustment>& adj); float getValuePx(Glib::RefPtr<Gtk::Adjustment>& adj); -#else - void setValue (Gtk::Adjustment *adj, double val); - void setValuePx (Gtk::Adjustment *adj, double val); - float getValue (Gtk::Adjustment *adj); - float getValuePx (Gtk::Adjustment *adj); -#endif /** * Helper function to create, style and pack spinbuttons for the export dialog. @@ -112,21 +108,12 @@ private: * * No unit_selector is stored in the created spinbutton, relies on external unit management */ -#if WITH_GTKMM_3_0 Glib::RefPtr<Gtk::Adjustment> createSpinbutton( gchar const *key, float val, float min, float max, float step, float page, Gtk::Grid *t, int x, int y, const Glib::ustring& ll, const Glib::ustring& lr, int digits, unsigned int sensitive, void (Export::*cb)() ); -#else - Gtk::Adjustment * createSpinbutton( gchar const *key, float val, float min, float max, - float step, float page, - Gtk::Table *t, int x, int y, - const Glib::ustring& ll, const Glib::ustring& lr, - int digits, unsigned int sensitive, - void (Export::*cb)() ); -#endif /** * One of the area select radio buttons was pressed @@ -152,11 +139,7 @@ private: void onAreaX1Change() { areaXChange(x1_adj); } ; -#if WITH_GTKMM_3_0 void areaXChange(Glib::RefPtr<Gtk::Adjustment>& adj); -#else - void areaXChange ( Gtk::Adjustment *adj); -#endif /** * Area Y value changed callback @@ -167,11 +150,7 @@ private: void onAreaY1Change() { areaYChange(y1_adj); } ; -#if WITH_GTKMM_3_0 void areaYChange(Glib::RefPtr<Gtk::Adjustment>& adj); -#else - void areaYChange ( Gtk::Adjustment *adj); -#endif /** * Unit changed callback @@ -298,7 +277,6 @@ private: Gtk::VBox area_box; Gtk::VBox singleexport_box; -#if WITH_GTKMM_3_0 /* Custom size widgets */ Glib::RefPtr<Gtk::Adjustment> x0_adj; Glib::RefPtr<Gtk::Adjustment> x1_adj; @@ -312,21 +290,6 @@ private: Glib::RefPtr<Gtk::Adjustment> bmheight_adj; Glib::RefPtr<Gtk::Adjustment> xdpi_adj; Glib::RefPtr<Gtk::Adjustment> ydpi_adj; -#else - /* Custom size widgets */ - Gtk::Adjustment *x0_adj; - Gtk::Adjustment *x1_adj; - Gtk::Adjustment *y0_adj; - Gtk::Adjustment *y1_adj; - Gtk::Adjustment *width_adj; - Gtk::Adjustment *height_adj; - - /* Bitmap size widgets */ - Gtk::Adjustment *bmwidth_adj; - Gtk::Adjustment *bmheight_adj; - Gtk::Adjustment *xdpi_adj; - Gtk::Adjustment *ydpi_adj; -#endif Gtk::VBox size_box; Gtk::Label* bm_label; @@ -354,6 +317,17 @@ private: Inkscape::UI::Widget::CheckButton closeWhenDone; + /* Advanced */ + Gtk::Expander expander; + Inkscape::UI::Widget::CheckButton interlacing; + Gtk::Label bitdepth_label; + Gtk::ComboBoxText bitdepth_cb; + Gtk::Label zlib_label; + Gtk::ComboBoxText zlib_compression; + Gtk::Label pHYs_label; + Glib::RefPtr<Gtk::Adjustment> pHYs_adj; + Gtk::SpinButton pHYs_sb; + /* Export Button widgets */ Gtk::HBox button_box; Gtk::Button export_button; diff --git a/src/ui/dialog/extension-editor.cpp b/src/ui/dialog/extension-editor.cpp index 9bdddc0e0..84840f22d 100644 --- a/src/ui/dialog/extension-editor.cpp +++ b/src/ui/dialog/extension-editor.cpp @@ -12,14 +12,13 @@ */ #ifdef HAVE_CONFIG_H -# include <config.h> +#include "config.h" #endif #include "extension-editor.h" #include <glibmm/i18n.h> #include <gtkmm/frame.h> -#include <gtkmm/scrolledwindow.h> #include <gtkmm/alignment.h> #include <gtkmm/notebook.h> @@ -27,7 +26,6 @@ #include "preferences.h" #include "ui/interface.h" -#include "extension/extension.h" #include "extension/db.h" namespace Inkscape { diff --git a/src/ui/dialog/filedialog.cpp b/src/ui/dialog/filedialog.cpp index 4e4b0278a..df3c4a307 100644 --- a/src/ui/dialog/filedialog.cpp +++ b/src/ui/dialog/filedialog.cpp @@ -15,14 +15,15 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include "filedialogimpl-win32.h" +#ifdef WIN32 +# include "filedialogimpl-win32.h" +# include "preferences.h" +#endif + #include "filedialogimpl-gtkmm.h" -#include "filedialog.h" -#include "inkgc/gc-core.h" #include "ui/dialog-events.h" #include "extension/output.h" -#include "preferences.h" #include <glibmm/convert.h> diff --git a/src/ui/dialog/filedialogimpl-gtkmm.cpp b/src/ui/dialog/filedialogimpl-gtkmm.cpp index 042637d22..e8c1bf723 100644 --- a/src/ui/dialog/filedialogimpl-gtkmm.cpp +++ b/src/ui/dialog/filedialogimpl-gtkmm.cpp @@ -754,16 +754,9 @@ FileOpenDialogImplGtk::~FileOpenDialogImplGtk() void FileOpenDialogImplGtk::addFilterMenu(Glib::ustring name, Glib::ustring pattern) { - -#if WITH_GTKMM_3_0 - Glib::RefPtr<Gtk::FileFilter> allFilter = Gtk::FileFilter::create(); + auto allFilter = Gtk::FileFilter::create(); allFilter->set_name(_(name.c_str())); allFilter->add_pattern(pattern); -#else - Gtk::FileFilter allFilter; - allFilter.set_name(_(name.c_str())); - allFilter.add_pattern(pattern); -#endif extensionMap[Glib::ustring(_("All Files"))] = NULL; add_filter(allFilter); } @@ -775,51 +768,27 @@ void FileOpenDialogImplGtk::createFilterMenu() } if (_dialogType == EXE_TYPES) { -#if WITH_GTKMM_3_0 - Glib::RefPtr<Gtk::FileFilter> allFilter = Gtk::FileFilter::create(); + auto allFilter = Gtk::FileFilter::create(); allFilter->set_name(_("All Files")); allFilter->add_pattern("*"); -#else - Gtk::FileFilter allFilter; - allFilter.set_name(_("All Files")); - allFilter.add_pattern("*"); -#endif extensionMap[Glib::ustring(_("All Files"))] = NULL; add_filter(allFilter); } else { -#if WITH_GTKMM_3_0 - Glib::RefPtr<Gtk::FileFilter> allInkscapeFilter = Gtk::FileFilter::create(); + auto allInkscapeFilter = Gtk::FileFilter::create(); allInkscapeFilter->set_name(_("All Inkscape Files")); - Glib::RefPtr<Gtk::FileFilter> allFilter = Gtk::FileFilter::create(); + auto allFilter = Gtk::FileFilter::create(); allFilter->set_name(_("All Files")); allFilter->add_pattern("*"); - Glib::RefPtr<Gtk::FileFilter> allImageFilter = Gtk::FileFilter::create(); + auto allImageFilter = Gtk::FileFilter::create(); allImageFilter->set_name(_("All Images")); - Glib::RefPtr<Gtk::FileFilter> allVectorFilter = Gtk::FileFilter::create(); + auto allVectorFilter = Gtk::FileFilter::create(); allVectorFilter->set_name(_("All Vectors")); - Glib::RefPtr<Gtk::FileFilter> allBitmapFilter = Gtk::FileFilter::create(); + auto allBitmapFilter = Gtk::FileFilter::create(); allBitmapFilter->set_name(_("All Bitmaps")); -#else - Gtk::FileFilter allInkscapeFilter; - allInkscapeFilter.set_name(_("All Inkscape Files")); - - Gtk::FileFilter allFilter; - allFilter.set_name(_("All Files")); - allFilter.add_pattern("*"); - - Gtk::FileFilter allImageFilter; - allImageFilter.set_name(_("All Images")); - - Gtk::FileFilter allVectorFilter; - allVectorFilter.set_name(_("All Vectors")); - - Gtk::FileFilter allBitmapFilter; - allBitmapFilter.set_name(_("All Bitmaps")); -#endif extensionMap[Glib::ustring(_("All Inkscape Files"))] = NULL; add_filter(allInkscapeFilter); @@ -854,29 +823,16 @@ void FileOpenDialogImplGtk::createFilterMenu() Glib::ustring uname(_(imod->get_filetypename())); -#if WITH_GTKMM_3_0 - Glib::RefPtr<Gtk::FileFilter> filter = Gtk::FileFilter::create(); + auto filter = Gtk::FileFilter::create(); filter->set_name(uname); filter->add_pattern(upattern); -#else - Gtk::FileFilter filter; - filter.set_name(uname); - filter.add_pattern(upattern); -#endif - add_filter(filter); extensionMap[uname] = imod; // g_message("ext %s:%s '%s'\n", ioext->name, ioext->mimetype, upattern.c_str()); -#if WITH_GTKMM_3_0 allInkscapeFilter->add_pattern(upattern); if (strncmp("image", imod->get_mimetype(), 5) == 0) allImageFilter->add_pattern(upattern); -#else - allInkscapeFilter.add_pattern(upattern); - if (strncmp("image", imod->get_mimetype(), 5) == 0) - allImageFilter.add_pattern(upattern); -#endif // uncomment this to find out all mime types supported by Inkscape import/open // g_print ("%s\n", imod->get_mimetype()); @@ -896,17 +852,9 @@ void FileOpenDialogImplGtk::createFilterMenu() strncmp("image/x-tga", imod->get_mimetype(), 11) == 0 || strncmp("image/x-pcx", imod->get_mimetype(), 11) == 0) { -#if WITH_GTKMM_3_0 allBitmapFilter->add_pattern(upattern); -#else - allBitmapFilter.add_pattern(upattern); -#endif } else { -#if WITH_GTKMM_3_0 allVectorFilter->add_pattern(upattern); -#else - allVectorFilter.add_pattern(upattern); -#endif } } } @@ -972,18 +920,13 @@ Glib::ustring FileOpenDialogImplGtk::getFilename(void) */ std::vector<Glib::ustring> FileOpenDialogImplGtk::getFilenames() { -#if WITH_GTKMM_3_0 - std::vector<std::string> result_tmp = get_filenames(); + auto result_tmp = get_filenames(); // Copy filenames to a vector of type Glib::ustring std::vector<Glib::ustring> result; - for (std::vector<std::string>::iterator it = result_tmp.begin(); it != result_tmp.end(); ++it) - result.push_back(*it); - -#else - std::vector<Glib::ustring> result = get_filenames(); -#endif + for (auto it : result_tmp) + result.push_back(it); #ifdef WITH_GNOME_VFS if (result.empty() && gnome_vfs_initialized()) @@ -1170,13 +1113,8 @@ void FileSaveDialogImplGtk::fileTypeChangedCallback() // g_message("selected: %s\n", type.name.c_str()); extension = type.extension; -#if WITH_GTKMM_3_0 - Glib::RefPtr<Gtk::FileFilter> filter = Gtk::FileFilter::create(); + auto filter = Gtk::FileFilter::create(); filter->add_pattern(type.pattern); -#else - Gtk::FileFilter filter; - filter.add_pattern(type.pattern); -#endif set_filter(filter); updateNameAndExtension(); diff --git a/src/ui/dialog/filedialogimpl-win32.cpp b/src/ui/dialog/filedialogimpl-win32.cpp index cafc3be4f..02d77cba1 100644 --- a/src/ui/dialog/filedialogimpl-win32.cpp +++ b/src/ui/dialog/filedialogimpl-win32.cpp @@ -128,11 +128,7 @@ FileDialogBaseWin32::FileDialogBaseWin32(Gtk::Window &parent, Glib::RefPtr<const Gdk::Window> parentWindow = parent.get_window(); g_assert(parentWindow->gobj() != NULL); -#if WITH_GTKMM_3_0 _ownerHwnd = (HWND)gdk_win32_window_get_handle((GdkWindow*)parentWindow->gobj()); -#else - _ownerHwnd = (HWND)gdk_win32_drawable_get_handle((GdkDrawable*)parentWindow->gobj()); -#endif } FileDialogBaseWin32::~FileDialogBaseWin32() diff --git a/src/ui/dialog/fill-and-stroke.cpp b/src/ui/dialog/fill-and-stroke.cpp index 8141f7696..0b3b468e9 100644 --- a/src/ui/dialog/fill-and-stroke.cpp +++ b/src/ui/dialog/fill-and-stroke.cpp @@ -22,7 +22,6 @@ #include "fill-and-stroke.h" #include "filter-chemistry.h" #include "inkscape.h" -#include "selection.h" #include "preferences.h" #include "style.h" #include "svg/css-ostringstream.h" @@ -32,12 +31,9 @@ #include "widgets/icon.h" #include "widgets/paint-selector.h" #include "widgets/stroke-style.h" -#include "xml/repr.h" #include "ui/view/view-widget.h" -#include <gtkmm/table.h> - namespace Inkscape { namespace UI { namespace Dialog { @@ -111,11 +107,7 @@ void FillAndStroke::setTargetDesktop(SPDesktop *desktop) } } -#if WITH_GTKMM_3_0 void FillAndStroke::_onSwitchPage(Gtk::Widget * /*page*/, guint pagenum) -#else -void FillAndStroke::_onSwitchPage(GtkNotebookPage * /*page*/, guint pagenum) -#endif { _savePagePref(pagenum); } @@ -132,24 +124,14 @@ void FillAndStroke::_layoutPageFill() { fillWdgt = Gtk::manage(sp_fill_style_widget_new()); - -#if WITH_GTKMM_3_0 _page_fill->table().attach(*fillWdgt, 0, 0, 1, 1); -#else - _page_fill->table().attach(*fillWdgt, 0, 1, 0, 1); -#endif } void FillAndStroke::_layoutPageStrokePaint() { strokeWdgt = Gtk::manage(sp_stroke_style_paint_widget_new()); - -#if WITH_GTKMM_3_0 _page_stroke_paint->table().attach(*strokeWdgt, 0, 0, 1, 1); -#else - _page_stroke_paint->table().attach(*strokeWdgt, 0, 1, 0, 1); -#endif } void @@ -158,12 +140,7 @@ FillAndStroke::_layoutPageStrokeStyle() //Gtk::Widget *strokeStyleWdgt = manage(Glib::wrap(sp_stroke_style_line_widget_new())); //Gtk::Widget *strokeStyleWdgt = static_cast<Gtk::Widget *>(sp_stroke_style_line_widget_new()); strokeStyleWdgt = sp_stroke_style_line_widget_new(); - -#if WITH_GTKMM_3_0 _page_stroke_style->table().attach(*strokeStyleWdgt, 0, 0, 1, 1); -#else - _page_stroke_style->table().attach(*strokeStyleWdgt, 0, 1, 0, 1); -#endif } void diff --git a/src/ui/dialog/fill-and-stroke.h b/src/ui/dialog/fill-and-stroke.h index f2a6bf39d..67e9d60ed 100644 --- a/src/ui/dialog/fill-and-stroke.h +++ b/src/ui/dialog/fill-and-stroke.h @@ -64,11 +64,7 @@ protected: void _layoutPageStrokePaint(); void _layoutPageStrokeStyle(); void _savePagePref(guint page_num); -#if WITH_GTKMM_3_0 void _onSwitchPage(Gtk::Widget *page, guint pagenum); -#else - void _onSwitchPage(GtkNotebookPage *page, guint pagenum); -#endif private: FillAndStroke(FillAndStroke const &d); diff --git a/src/ui/dialog/filter-effects-dialog.cpp b/src/ui/dialog/filter-effects-dialog.cpp index d3ad5d1da..a0cd786dc 100644 --- a/src/ui/dialog/filter-effects-dialog.cpp +++ b/src/ui/dialog/filter-effects-dialog.cpp @@ -16,71 +16,57 @@ */ #ifdef HAVE_CONFIG_H -# include <config.h> +#include "config.h" #endif #include "dialog-manager.h" #include <gtkmm/imagemenuitem.h> -#if GTK_CHECK_VERSION(3,0,0) +#include <gdkmm/display.h> +#if GTK_CHECK_VERSION(3, 20, 0) +# include <gdkmm/seat.h> +#else # include <gdkmm/devicemanager.h> #endif #include "ui/widget/spinbutton.h" -#include <glibmm/convert.h> #include <glibmm/i18n.h> -#include <glibmm/main.h> #include <glibmm/stringutils.h> +#include <glibmm/main.h> +#include <glibmm/convert.h> #include "desktop.h" -#include "dir-util.h" #include "document.h" #include "document-undo.h" #include "filter-chemistry.h" #include "filter-effects-dialog.h" #include "filter-enums.h" #include "inkscape.h" -#include "path-prefix.h" -#include "preferences.h" -#include "selection.h" #include "filters/blend.h" #include "filters/colormatrix.h" #include "filters/componenttransfer.h" #include "filters/componenttransfer-funcnode.h" -#include "filters/composite.h" #include "filters/convolvematrix.h" -#include "filters/displacementmap.h" #include "filters/distantlight.h" -#include "filters/gaussian-blur.h" #include "filters/merge.h" #include "filters/mergenode.h" -#include "filters/offset.h" #include "filters/pointlight.h" #include "filters/spotlight.h" -#include "sp-filter-primitive.h" #include "style.h" #include "svg/svg-color.h" -#include "svg/stringstream.h" #include "ui/dialog/filedialog.h" #include "verbs.h" -#include "xml/node.h" -#include "xml/node-observer.h" -#include "xml/repr.h" -#include <sstream> #include "io/sys.h" -#include <iostream> #include "selection-chemistry.h" -#include <gtkmm/checkbutton.h> #include <gtkmm/colorbutton.h> -#include <gtkmm/paned.h> -#include <gtkmm/scrolledwindow.h> #include <gtkmm/stock.h> #include <gdkmm/general.h> +#include <gtkmm/checkbutton.h> using namespace Inkscape::Filters; @@ -103,9 +89,7 @@ static int input_count(const SPFilterPrimitive* prim) return 2; else if(SP_IS_FEMERGE(prim)) { // Return the number of feMergeNode connections plus an extra - int count = 1; - for(const SPObject* o = prim->firstChild(); o; o = o->next, ++count){}; - return count; + return (int) (prim->children.size() + 1); } else return 1; @@ -319,15 +303,9 @@ public: set_tooltip_text(tip_text); } -#if WITH_GTKMM_3_0 Gdk::RGBA col; col.set_rgba_u(65535, 65535, 65535); set_rgba(col); -#else - Gdk::Color col; - col.set_rgb(65535, 65535, 65535); - set_color(col); -#endif } // Returns the color in 'rgb(r,g,b)' form. @@ -336,13 +314,8 @@ public: // no doubles here, so we can use the standard string stream. std::ostringstream os; -#if WITH_GTKMM_3_0 - const Gdk::RGBA c = get_rgba(); - const int r = c.get_red_u() / 257, g = c.get_green_u() / 257, b = c.get_blue_u() / 257;//TO-DO: verify this. This sounds a lot strange! shouldn't it be 256? -#else - const Gdk::Color c = get_color(); - const int r = c.get_red() / 257, g = c.get_green() / 257, b = c.get_blue() / 257;//TO-DO: verify this. This sounds a lot strange! shouldn't it be 256? -#endif + const auto c = get_rgba(); + const int r = c.get_red_u() / 257, g = c.get_green_u() / 257, b = c.get_blue_u() / 257;//TO-DO: verify this. This sounds a lot strange! shouldn't it be 256? os << "rgb(" << r << "," << g << "," << b << ")"; return os.str(); } @@ -359,15 +332,9 @@ public: } const int r = SP_RGBA32_R_U(i), g = SP_RGBA32_G_U(i), b = SP_RGBA32_B_U(i); -#if WITH_GTKMM_3_0 Gdk::RGBA col; col.set_rgba_u(r * 256, g * 256, b * 256); set_rgba(col); -#else - Gdk::Color col; - col.set_rgb(r * 256, g * 256, b * 256); - set_color(col); -#endif } }; @@ -691,7 +658,7 @@ private: void select_svg_element(){ Inkscape::Selection* sel = _desktop->getSelection(); if (sel->isEmpty()) return; - Inkscape::XML::Node* node = sel->reprList()[0]; + Inkscape::XML::Node* node = sel->xmlNodes().front(); if (!node || !node->matchAttributeName("id")) return; std::ostringstream xlikhref; @@ -1060,11 +1027,10 @@ public: // FuncNode can be in any order so we must search to find correct one. SPFeFuncNode* find_node(SPFeComponentTransfer* ct) { - SPObject* node = ct->children; SPFeFuncNode* funcNode = NULL; bool found = false; - for(;node;node=node->next){ - funcNode = SP_FEFUNCNODE(node); + for(auto& node: ct->children) { + funcNode = SP_FEFUNCNODE(&node); if( funcNode->channel == _channel ) { found = true; break; @@ -1228,7 +1194,7 @@ protected: _locked = true; - SPObject* child = o->children; + SPObject* child = o->firstChild(); if(SP_IS_FEDISTANTLIGHT(child)) _light_source.set_active(0); @@ -1253,7 +1219,7 @@ private: if(prim) { _locked = true; - SPObject* child = prim->children; + SPObject* child = prim->firstChild(); const int ls = _light_source.get_active_row_number(); // Check if the light source type has changed if(!(ls == -1 && !child) && @@ -1287,8 +1253,8 @@ private: _light_box.show_all(); SPFilterPrimitive* prim = _dialog._primitive_list.get_selected(); - if(prim && prim->children) - _settings.show_and_update(_light_source.get_active_data()->id, prim->children); + if(prim && prim->firstChild()) + _settings.show_and_update(_light_source.get_active_data()->id, prim->firstChild()); } FilterEffectsDialog& _dialog; @@ -1474,8 +1440,8 @@ void FilterEffectsDialog::FilterModifier::update_selection(Selection *sel) } std::set<SPObject*> used; - std::vector<SPItem*> itemlist=sel->itemList(); - for(std::vector<SPItem*>::const_iterator i=itemlist.begin(); itemlist.end() != i; ++i) { + auto itemlist= sel->items(); + for(auto i=itemlist.begin(); itemlist.end() != i; ++i) { SPObject *obj = *i; SPStyle *style = obj->style; if (!style || !SP_IS_ITEM(obj)) { @@ -1555,8 +1521,8 @@ void FilterEffectsDialog::FilterModifier::on_selection_toggled(const Glib::ustri if((*iter)[_columns.sel] == 1) filter = 0; - std::vector<SPItem*> itemlist=sel->itemList(); - for(std::vector<SPItem*>::const_iterator i=itemlist.begin(); itemlist.end() != i; ++i) { + auto itemlist= sel->items(); + for(auto i=itemlist.begin(); itemlist.end() != i; ++i) { SPItem * item = *i; SPStyle *style = item->style; g_assert(style != NULL); @@ -1730,7 +1696,6 @@ Glib::PropertyProxy<void*> FilterEffectsDialog::CellRendererConnection::property return _primitive.get_proxy(); } -#if WITH_GTKMM_3_0 void FilterEffectsDialog::CellRendererConnection::get_preferred_width_vfunc(Gtk::Widget& widget, int& minimum_width, int& natural_width) const @@ -1764,27 +1729,6 @@ void FilterEffectsDialog::CellRendererConnection::get_preferred_height_for_width { get_preferred_height(widget, minimum_height, natural_height); } -#else -void FilterEffectsDialog::CellRendererConnection::get_size_vfunc( - Gtk::Widget& widget, const Gdk::Rectangle* /*cell_area*/, - int* x_offset, int* y_offset, int* width, int* height) const -{ - PrimitiveList& primlist = dynamic_cast<PrimitiveList&>(widget); - - if(x_offset) - (*x_offset) = 0; - if(y_offset) - (*y_offset) = 0; - if(width) - (*width) = size * primlist.primitive_count() + (primlist.get_input_type_width()) * 6; - if(height) { - // Scale the height depending on the number of inputs, unless it's - // the first primitive, in which case there are no connections - SPFilterPrimitive* prim = SP_FILTER_PRIMITIVE(_primitive.get_value()); - (*height) = size * input_count(prim); - } -} -#endif /*** PrimitiveList ***/ FilterEffectsDialog::PrimitiveList::PrimitiveList(FilterEffectsDialog& d) @@ -1792,13 +1736,8 @@ FilterEffectsDialog::PrimitiveList::PrimitiveList(FilterEffectsDialog& d) _in_drag(0), _observer(new Inkscape::XML::SignalObserver) { -#if WITH_GTKMM_3_0 d.signal_draw().connect(sigc::mem_fun(*this, &PrimitiveList::on_draw_signal)); signal_draw().connect(sigc::mem_fun(*this, &PrimitiveList::on_draw_signal)); -#else - d.signal_expose_event().connect(sigc::mem_fun(*this, &PrimitiveList::on_expose_signal)); - signal_expose_event().connect(sigc::mem_fun(*this, &PrimitiveList::on_expose_signal)); -#endif add_events(Gdk::POINTER_MOTION_MASK | Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK); @@ -1871,26 +1810,25 @@ void FilterEffectsDialog::PrimitiveList::update() bool active_found = false; _dialog._primitive_box->set_sensitive(true); _dialog.update_filter_general_settings_view(); - for(SPObject *prim_obj = f->children; - prim_obj && SP_IS_FILTER_PRIMITIVE(prim_obj); - prim_obj = prim_obj->next) { - SPFilterPrimitive *prim = SP_FILTER_PRIMITIVE(prim_obj); - if(prim) { - Gtk::TreeModel::Row row = *_model->append(); - row[_columns.primitive] = prim; - - //XML Tree being used directly here while it shouldn't be. - row[_columns.type_id] = FPConverter.get_id_from_key(prim->getRepr()->name()); - row[_columns.type] = _(FPConverter.get_label(row[_columns.type_id]).c_str()); - - if (prim->getId()) { - row[_columns.id] = Glib::ustring(prim->getId()); - } - - if(prim == active_prim) { - get_selection()->select(row); - active_found = true; - } + for(auto& prim_obj: f->children) { + SPFilterPrimitive *prim = SP_FILTER_PRIMITIVE(&prim_obj); + if(!prim) { + break; + } + Gtk::TreeModel::Row row = *_model->append(); + row[_columns.primitive] = prim; + + //XML Tree being used directly here while it shouldn't be. + row[_columns.type_id] = FPConverter.get_id_from_key(prim->getRepr()->name()); + row[_columns.type] = _(FPConverter.get_label(row[_columns.type_id]).c_str()); + + if (prim->getId()) { + row[_columns.id] = Glib::ustring(prim->getId()); + } + + if(prim == active_prim) { + get_selection()->select(row); + active_found = true; } } @@ -1961,25 +1899,9 @@ void FilterEffectsDialog::PrimitiveList::remove_selected() } } -#if !WITH_GTKMM_3_0 -bool FilterEffectsDialog::PrimitiveList::on_expose_signal(GdkEventExpose * /*evt*/) -{ - bool result = false; - - if (get_is_drawable()) - { - Cairo::RefPtr<Cairo::Context> cr = get_bin_window()->create_cairo_context(); - result = on_draw_signal(cr); - } - - return result; -} -#endif - bool FilterEffectsDialog::PrimitiveList::on_draw_signal(const Cairo::RefPtr<Cairo::Context> & cr) { cr->set_line_width(1.0); -#if GTK_CHECK_VERSION(3,0,0) // In GTK+ 3, the draw function receives the widget window, not the // bin_window (i.e., just the area under the column headers). We // therefore translate the origin of our coordinate system to account for this @@ -1987,7 +1909,7 @@ bool FilterEffectsDialog::PrimitiveList::on_draw_signal(const Cairo::RefPtr<Cair convert_bin_window_to_widget_coords(0,0,x_origin,y_origin); cr->translate(x_origin, y_origin); - GtkStyleContext *sc = gtk_widget_get_style_context(GTK_WIDGET(gobj())); + auto sc = gtk_widget_get_style_context(GTK_WIDGET(gobj())); GdkRGBA bg_color, fg_color; gtk_style_context_get_background_color(sc, GTK_STATE_FLAG_NORMAL, &bg_color); gtk_style_context_get_color(sc, GTK_STATE_FLAG_NORMAL, &fg_color); @@ -2005,9 +1927,6 @@ bool FilterEffectsDialog::PrimitiveList::on_draw_signal(const Cairo::RefPtr<Cair (bg_color_active.green + fg_color_active.green)/2.0, (bg_color_active.blue + fg_color_active.blue)/2.0, (bg_color_active.alpha + fg_color_active.alpha)/2.0}; -#else - GtkStyle *style = gtk_widget_get_style(GTK_WIDGET(gobj())); -#endif SPFilterPrimitive* prim = get_selected(); int row_count = get_model()->children().size(); @@ -2026,25 +1945,15 @@ bool FilterEffectsDialog::PrimitiveList::on_draw_signal(const Cairo::RefPtr<Cair const int x = text_start_x + get_input_type_width() * i; cr->save(); cr->rectangle(x, 0, get_input_type_width(), vis.get_height()); -#if GTK_CHECK_VERSION(3,0,0) gdk_cairo_set_source_rgba(cr->cobj(), &bg_color); cr->fill_preserve(); gdk_cairo_set_source_rgba(cr->cobj(), &fg_color); -#else - gdk_cairo_set_source_color(cr->cobj(), &(style->bg[GTK_STATE_NORMAL])); - cr->fill_preserve(); - gdk_cairo_set_source_color(cr->cobj(), &(style->text[GTK_STATE_NORMAL])); -#endif cr->move_to(x+get_input_type_width(), 0); cr->rotate_degrees(90); _vertical_layout->show_in_cairo_context(cr); -#if GTK_CHECK_VERSION(3,0,0) gdk_cairo_set_source_rgba(cr->cobj(), &mid_color); -#else - gdk_cairo_set_source_color(cr->cobj(), &(style->dark[GTK_STATE_NORMAL])); -#endif cr->move_to(x, 0); cr->line_to(x, vis.get_height()); cr->stroke(); @@ -2061,24 +1970,21 @@ bool FilterEffectsDialog::PrimitiveList::on_draw_signal(const Cairo::RefPtr<Cair int mx, my; Gdk::ModifierType mask; -#if GTK_CHECK_VERSION(3,0,0) - Glib::RefPtr<Gdk::Display> display = get_bin_window()->get_display(); - Glib::RefPtr<Gdk::DeviceManager> dm = display->get_device_manager(); - Glib::RefPtr<const Gdk::Device> device = dm->get_client_pointer(); - get_bin_window()->get_device_position(device, mx, my, mask); + auto display = get_bin_window()->get_display(); +#if GTK_CHECK_VERSION(3, 20, 0) + auto seat = display->get_default_seat(); + auto device = seat->get_pointer(); #else - get_bin_window()->get_pointer(mx, my, mask); + auto dm = display->get_device_manager(); + auto device = dm->get_client_pointer(); #endif + get_bin_window()->get_device_position(device, mx, my, mask); // Outline the bottom of the connection area const int outline_x = x + fheight * (row_count - row_index); cr->save(); -#if GTK_CHECK_VERSION(3,0,0) gdk_cairo_set_source_rgba(cr->cobj(), &mid_color); -#else - gdk_cairo_set_source_color(cr->cobj(), &(style->dark[GTK_STATE_NORMAL])); -#endif cr->move_to(x, y + h); cr->line_to(outline_x, y + h); @@ -2101,17 +2007,10 @@ bool FilterEffectsDialog::PrimitiveList::on_draw_signal(const Cairo::RefPtr<Cair cr->save(); -#if GTK_CHECK_VERSION(3,0,0) gdk_cairo_set_source_rgba(cr->cobj(), inside && mask & GDK_BUTTON1_MASK ? &mid_color : &mid_color_active); -#else - gdk_cairo_set_source_color(cr->cobj(), - inside && mask & GDK_BUTTON1_MASK ? - &(style->dark[GTK_STATE_NORMAL]) : - &(style->dark[GTK_STATE_ACTIVE])); -#endif draw_connection_node(cr, con_poly, inside); @@ -2137,17 +2036,10 @@ bool FilterEffectsDialog::PrimitiveList::on_draw_signal(const Cairo::RefPtr<Cair cr->save(); -#if GTK_CHECK_VERSION(3,0,0) gdk_cairo_set_source_rgba(cr->cobj(), inside && mask & GDK_BUTTON1_MASK ? &mid_color : &mid_color_active); -#else - gdk_cairo_set_source_color(cr->cobj(), - inside && mask & GDK_BUTTON1_MASK ? - &(style->dark[GTK_STATE_NORMAL]) : - &(style->dark[GTK_STATE_ACTIVE])); -#endif draw_connection_node(cr, con_poly, inside); @@ -2170,17 +2062,10 @@ bool FilterEffectsDialog::PrimitiveList::on_draw_signal(const Cairo::RefPtr<Cair cr->save(); -#if GTK_CHECK_VERSION(3,0,0) gdk_cairo_set_source_rgba(cr->cobj(), inside && mask & GDK_BUTTON1_MASK ? &mid_color : &mid_color_active); -#else - gdk_cairo_set_source_color(cr->cobj(), - inside && mask & GDK_BUTTON1_MASK ? - &(style->dark[GTK_STATE_NORMAL]) : - &(style->dark[GTK_STATE_ACTIVE])); -#endif draw_connection_node(cr, con_poly, inside); @@ -2216,8 +2101,7 @@ void FilterEffectsDialog::PrimitiveList::draw_connection(const Cairo::RefPtr<Cai { cr->save(); -#if GTK_CHECK_VERSION(3,0,0) - GtkStyleContext *sc = gtk_widget_get_style_context(GTK_WIDGET(gobj())); + auto sc = gtk_widget_get_style_context(GTK_WIDGET(gobj())); GdkRGBA bg_color, fg_color; gtk_style_context_get_background_color(sc, GTK_STATE_FLAG_NORMAL, &bg_color); @@ -2227,9 +2111,6 @@ void FilterEffectsDialog::PrimitiveList::draw_connection(const Cairo::RefPtr<Cai (bg_color.green + fg_color.green)/2.0, (bg_color.blue + fg_color.blue)/2.0, (bg_color.alpha + fg_color.alpha)/2.0}; -#else - GtkStyle *style = gtk_widget_get_style(GTK_WIDGET(gobj())); -#endif int src_id = 0; Gtk::TreeIter res = find_result(input, attr, src_id); @@ -2245,11 +2126,7 @@ void FilterEffectsDialog::PrimitiveList::draw_connection(const Cairo::RefPtr<Cai gint end_x = text_start_x + tw * src_id + (int)(tw * 0.5f) + 1; if(use_default && is_first) -#if GTK_CHECK_VERSION(3,0,0) gdk_cairo_set_source_rgba(cr->cobj(), &mid_color); -#else - gdk_cairo_set_source_color(cr->cobj(), &(style->dark[GTK_STATE_NORMAL])); -#endif else cr->set_source_rgb(0.0, 0.0, 0.0); @@ -2343,11 +2220,12 @@ const Gtk::TreeIter FilterEffectsDialog::PrimitiveList::find_result(const Gtk::T if(SP_IS_FEMERGE(prim)) { int c = 0; bool found = false; - for(const SPObject* o = prim->firstChild(); o; o = o->next, ++c) { - if(c == attr && SP_IS_FEMERGENODE(o)) { - image = SP_FEMERGENODE(o)->input; + for (auto& o: prim->children) { + if(c == attr && SP_IS_FEMERGENODE(&o)) { + image = SP_FEMERGENODE(&o)->input; found = true; } + ++c; } if(!found) return target; @@ -2534,21 +2412,23 @@ bool FilterEffectsDialog::PrimitiveList::on_button_release_event(GdkEventButton* if(SP_IS_FEMERGE(prim)) { int c = 1; bool handled = false; - for(SPObject* o = prim->firstChild(); o && !handled; o = o->next, ++c) { - if(c == _in_drag && SP_IS_FEMERGENODE(o)) { + for (auto& o: prim->children) { + if(c == _in_drag && SP_IS_FEMERGENODE(&o)) { // If input is null, delete it if(!in_val) { //XML Tree being used directly here while it shouldn't be. - sp_repr_unparent(o->getRepr()); + sp_repr_unparent(o.getRepr()); DocumentUndo::done(prim->document, SP_VERB_DIALOG_FILTER_EFFECTS, _("Remove merge node")); (*get_selection()->get_selected())[_columns.primitive] = prim; + } else { + _dialog.set_attr(&o, SP_ATTR_IN, in_val); } - else - _dialog.set_attr(o, SP_ATTR_IN, in_val); handled = true; + break; } + ++c; } // Add new input? if(!handled && c == _in_drag && in_val) { @@ -2669,8 +2549,7 @@ void FilterEffectsDialog::PrimitiveList::on_drag_end(const Glib::RefPtr<Gdk::Dra bool FilterEffectsDialog::PrimitiveList::on_scroll_timeout() { if(_autoscroll_y) { -#if WITH_GTKMM_3_0 - Glib::RefPtr<Gtk::Adjustment> a = dynamic_cast<Gtk::ScrolledWindow*>(get_parent())->get_vadjustment(); + auto a = dynamic_cast<Gtk::ScrolledWindow*>(get_parent())->get_vadjustment(); double v = a->get_value() + _autoscroll_y; if(v < 0) @@ -2679,25 +2558,13 @@ bool FilterEffectsDialog::PrimitiveList::on_scroll_timeout() v = a->get_upper() - a->get_page_size(); a->set_value(v); -#else - Gtk::Adjustment& a = *dynamic_cast<Gtk::ScrolledWindow*>(get_parent())->get_vadjustment(); - double v = a.get_value() + _autoscroll_y; - - if(v < 0) - v = 0; - if(v > a.get_upper() - a.get_page_size()) - v = a.get_upper() - a.get_page_size(); - - a.set_value(v); -#endif queue_draw(); } if(_autoscroll_x) { -#if WITH_GTKMM_3_0 - Glib::RefPtr<Gtk::Adjustment> a_h = dynamic_cast<Gtk::ScrolledWindow*>(get_parent())->get_hadjustment(); + auto a_h = dynamic_cast<Gtk::ScrolledWindow*>(get_parent())->get_hadjustment(); double h = a_h->get_value() + _autoscroll_x; if(h < 0) @@ -2706,18 +2573,6 @@ bool FilterEffectsDialog::PrimitiveList::on_scroll_timeout() h = a_h->get_upper() - a_h->get_page_size(); a_h->set_value(h); -#else - Gtk::Adjustment& a_h = *dynamic_cast<Gtk::ScrolledWindow*>(get_parent())->get_hadjustment(); - double h = a_h.get_value() + _autoscroll_x; - - if(h < 0) - h = 0; - if(h > a_h.get_upper() - a_h.get_page_size()) - h = a_h.get_upper() - a_h.get_page_size(); - - a_h.set_value(h); - -#endif queue_draw(); } @@ -2759,13 +2614,8 @@ FilterEffectsDialog::FilterEffectsDialog() _sizegroup->set_ignore_hidden(); // Initialize widget hierarchy -#if WITH_GTKMM_3_0 - Gtk::Paned* hpaned = Gtk::manage(new Gtk::Paned); + auto hpaned = Gtk::manage(new Gtk::Paned); _primitive_box = Gtk::manage(new Gtk::Paned); -#else - Gtk::HPaned* hpaned = Gtk::manage(new Gtk::HPaned); - _primitive_box = Gtk::manage(new Gtk::VPaned); -#endif _sw_infobox = Gtk::manage(new Gtk::ScrolledWindow); Gtk::ScrolledWindow* sw_prims = Gtk::manage(new Gtk::ScrolledWindow); @@ -3097,7 +2947,7 @@ void FilterEffectsDialog::set_filternode_attr(const AttrWidget* input) void FilterEffectsDialog::set_child_attr_direct(const AttrWidget* input) { - set_attr(_primitive_list.get_selected()->children, input->get_attribute(), input->get_as_attribute().c_str()); + set_attr(_primitive_list.get_selected()->firstChild(), input->get_attribute(), input->get_as_attribute().c_str()); } void FilterEffectsDialog::set_attr(SPObject* o, const SPAttributeEnum attr, const gchar* val) diff --git a/src/ui/dialog/filter-effects-dialog.h b/src/ui/dialog/filter-effects-dialog.h index 7c715327e..eae0fc317 100644 --- a/src/ui/dialog/filter-effects-dialog.h +++ b/src/ui/dialog/filter-effects-dialog.h @@ -163,7 +163,6 @@ private: static const int size = 24; protected: -#if WITH_GTKMM_3_0 virtual void get_preferred_width_vfunc(Gtk::Widget& widget, int& minimum_width, int& natural_width) const; @@ -181,10 +180,6 @@ private: int width, int& minimum_height, int& natural_height) const; -#else - virtual void get_size_vfunc(Gtk::Widget& widget, const Gdk::Rectangle* cell_area, - int* x_offset, int* y_offset, int* width, int* height) const; -#endif private: // void* should be SPFilterPrimitive*, some weirdness with properties prevents this Glib::Property<void*> _primitive; @@ -211,9 +206,6 @@ private: protected: bool on_draw_signal(const Cairo::RefPtr<Cairo::Context> &cr); -#if !WITH_GTKMM_3_0 - bool on_expose_signal(GdkEventExpose*); -#endif bool on_button_press_event(GdkEventButton*); bool on_motion_notify_event(GdkEventMotion*); @@ -283,11 +275,7 @@ private: Gtk::ScrolledWindow* _sw_infobox; // View/add primitives -#if WITH_GTKMM_3_0 Gtk::Paned* _primitive_box; -#else - Gtk::VPaned* _primitive_box; -#endif UI::Widget::ComboBoxEnum<Inkscape::Filters::FilterPrimitiveType> _add_primitive_type; Gtk::Button _add_primitive; diff --git a/src/ui/dialog/find.cpp b/src/ui/dialog/find.cpp index 0f368c5ac..b4f7902f5 100644 --- a/src/ui/dialog/find.cpp +++ b/src/ui/dialog/find.cpp @@ -11,30 +11,25 @@ */ #ifdef HAVE_CONFIG_H -# include <config.h> +#include "config.h" #endif #include "find.h" #include <gtkmm/entry.h> -#include <gtkmm/widget.h> #include "verbs.h" #include "message-stack.h" #include "helper/window.h" -#include "macros.h" #include "inkscape.h" #include "desktop.h" #include "document.h" #include "document-undo.h" -#include "selection.h" #include "ui/dialog-events.h" -#include "verbs.h" #include "ui/interface.h" -#include "preferences.h" #include "sp-text.h" #include "sp-flowtext.h" #include "sp-flowdiv.h" @@ -51,11 +46,9 @@ #include "sp-line.h" #include "sp-polyline.h" #include "sp-item-group.h" -#include "sp-use.h" #include "sp-image.h" #include "sp-offset.h" #include "sp-root.h" -#include "xml/repr.h" #include "xml/node-iterators.h" #include "xml/attribute-record.h" @@ -747,22 +740,22 @@ std::vector<SPItem*> &Find::all_items (SPObject *r, std::vector<SPItem*> &l, boo return l; // we're not interested in metadata } - for (SPObject *child = r->firstChild(); child; child = child->getNext()) { - SPItem *item = dynamic_cast<SPItem *>(child); - if (item && !child->cloned && !desktop->isLayer(item)) { + for (auto& child: r->children) { + SPItem *item = dynamic_cast<SPItem *>(&child); + if (item && !child.cloned && !desktop->isLayer(item)) { if ((hidden || !desktop->itemIsHidden(item)) && (locked || !item->isLocked())) { - l.insert(l.begin(),(SPItem*)child); + l.insert(l.begin(),(SPItem*)&child); } } - l = all_items (child, l, hidden, locked); + l = all_items (&child, l, hidden, locked); } return l; } std::vector<SPItem*> &Find::all_selection_items (Inkscape::Selection *s, std::vector<SPItem*> &l, SPObject *ancestor, bool hidden, bool locked) { - std::vector<SPItem*> itemlist=s->itemList(); - for(std::vector<SPItem*>::const_reverse_iterator i=itemlist.rbegin(); itemlist.rend() != i; ++i) { + auto itemlist= s->items(); + for(auto i=boost::rbegin(itemlist); boost::rend(itemlist) != i; ++i) { SPObject *obj = *i; SPItem *item = dynamic_cast<SPItem *>(obj); g_assert(item != NULL); diff --git a/src/ui/dialog/find.h b/src/ui/dialog/find.h index 4bcb900b6..94d635037 100644 --- a/src/ui/dialog/find.h +++ b/src/ui/dialog/find.h @@ -286,13 +286,7 @@ private: Gtk::Label status; UI::Widget::Button button_find; UI::Widget::Button button_replace; - -#if WITH_GTKMM_3_0 Gtk::ButtonBox box_buttons; -#else - Gtk::HButtonBox box_buttons; -#endif - Gtk::HBox hboxbutton_row; /** diff --git a/src/ui/dialog/floating-behavior.cpp b/src/ui/dialog/floating-behavior.cpp index 55ef0c5bb..fa8e11dfd 100644 --- a/src/ui/dialog/floating-behavior.cpp +++ b/src/ui/dialog/floating-behavior.cpp @@ -11,13 +11,12 @@ */ #ifdef HAVE_CONFIG_H -# include "config.h" +#include "config.h" #endif #include <gtkmm/dialog.h> #include <gtkmm/stock.h> #include <glibmm/main.h> -#include <gtk/gtk.h> #include "floating-behavior.h" #include "dialog.h" @@ -26,7 +25,6 @@ #include "desktop.h" #include "ui/dialog-events.h" #include "ui/interface.h" -#include "preferences.h" #include "verbs.h" namespace Inkscape { @@ -140,11 +138,7 @@ FloatingBehavior::create(Dialog &dialog) inline FloatingBehavior::operator Gtk::Widget &() { return *_d; } inline GtkWidget *FloatingBehavior::gobj() { return GTK_WIDGET(_d->gobj()); } inline Gtk::Box* FloatingBehavior::get_vbox() { -#if WITH_GTKMM_3_0 return _d->get_content_area(); -#else - return _d->get_vbox(); -#endif } inline void FloatingBehavior::present() { _d->present(); } inline void FloatingBehavior::hide() { _d->hide(); } @@ -155,12 +149,8 @@ inline void FloatingBehavior::move(int x, int y) { _d-> inline void FloatingBehavior::set_position(Gtk::WindowPosition position) { _d->set_position(position); } inline void FloatingBehavior::set_size_request(int width, int height) { _d->set_size_request(width, height); } inline void FloatingBehavior::size_request(Gtk::Requisition &requisition) { -#if WITH_GTKMM_3_0 Gtk::Requisition requisition_natural; _d->get_preferred_size(requisition, requisition_natural); -#else - requisition = _d->size_request(); -#endif } inline void FloatingBehavior::get_position(int &x, int &y) { _d->get_position(x, y); } inline void FloatingBehavior::get_size(int &width, int &height) { _d->get_size(width, height); } diff --git a/src/ui/dialog/font-substitution.cpp b/src/ui/dialog/font-substitution.cpp index f219f3db6..abae8ea70 100644 --- a/src/ui/dialog/font-substitution.cpp +++ b/src/ui/dialog/font-substitution.cpp @@ -7,7 +7,7 @@ */ #ifdef HAVE_CONFIG_H -# include <config.h> +#include "config.h" #endif #include <gtkmm/messagedialog.h> @@ -21,16 +21,11 @@ #include "inkscape.h" #include "desktop.h" #include "document.h" -#include "selection.h" #include "ui/dialog-events.h" #include "selection-chemistry.h" -#include "preferences.h" -#include "xml/repr.h" - -#include "sp-defs.h" #include "sp-root.h" #include "sp-text.h" #include "sp-textpath.h" @@ -106,11 +101,7 @@ FontSubstitution::show(Glib::ustring out, std::vector<SPItem*> &l) cbWarning->set_label(_("Don't show this warning again")); cbWarning->show(); -#if GTK_CHECK_VERSION(3,0,0) - Gtk::Box * box = warning.get_content_area(); -#else - Gtk::Box * box = warning.get_vbox(); -#endif + auto box = warning.get_content_area(); box->set_spacing(2); box->pack_start(*scrollwindow, true, true, 4); box->pack_start(*cbSelect, false, false, 0); @@ -182,7 +173,7 @@ std::vector<SPItem*> FontSubstitution::getFontReplacedItems(SPDocument* doc, Gli family = SP_TEXT(parent_text)->layout.getFontFamily(0); // Add all the spans fonts to the set gint ii = 0; - for (SPObject *child = parent_text->firstChild() ; child ; child = child->getNext() ) { + for (auto& child: parent_text->children) { family = SP_TEXT(parent_text)->layout.getFontFamily(ii); setFontSpans.insert(family); ii++; diff --git a/src/ui/dialog/glyphs.cpp b/src/ui/dialog/glyphs.cpp index 56b001291..9c1236ca9 100644 --- a/src/ui/dialog/glyphs.cpp +++ b/src/ui/dialog/glyphs.cpp @@ -14,21 +14,11 @@ #include <glibmm/i18n.h> #include <gtkmm/alignment.h> #include <gtkmm/comboboxtext.h> -#include <gtkmm/entry.h> +#include <gtkmm/grid.h> #include <gtkmm/iconview.h> -#include <gtkmm/label.h> #include <gtkmm/liststore.h> #include <gtkmm/scrolledwindow.h> -#if WITH_GTKMM_3_0 -# include <gtkmm/grid.h> -#else -# include <gtkmm/table.h> -#endif - -#include <gtkmm/treemodelcolumn.h> -#include <gtkmm/widget.h> - #include "desktop.h" #include "document.h" // for SPDocumentUndo::done() #include "document-undo.h" @@ -342,12 +332,7 @@ GlyphsPanel::GlyphsPanel(gchar const *prefsPath) : instanceConns(), desktopConns() { -#if WITH_GTKMM_3_0 - Gtk::Grid *table = new Gtk::Grid(); -#else - Gtk::Table *table = new Gtk::Table(3, 1, false); -#endif - + auto table = new Gtk::Grid(); _getContents()->pack_start(*Gtk::manage(table), Gtk::PACK_EXPAND_WIDGET); guint row = 0; @@ -360,29 +345,16 @@ GlyphsPanel::GlyphsPanel(gchar const *prefsPath) : gtk_widget_set_size_request (fontsel, 0, 150); g_signal_connect( G_OBJECT(fontsel), "font_set", G_CALLBACK(fontChangeCB), this ); -#if WITH_GTKMM_3_0 table->attach(*Gtk::manage(Glib::wrap(fontsel)), 0, row, 3, 1); -#else - table->attach(*Gtk::manage(Glib::wrap(fontsel)), - 0, 3, row, row + 1, - Gtk::SHRINK|Gtk::FILL, Gtk::SHRINK|Gtk::FILL); -#endif - row++; // ------------------------------- { - Gtk::Label *label = new Gtk::Label(_("Script: ")); + auto label = new Gtk::Label(_("Script: ")); -#if WITH_GTKMM_3_0 table->attach( *Gtk::manage(label), 0, row, 1, 1); -#else - table->attach( *Gtk::manage(label), - 0, 1, row, row + 1, - Gtk::SHRINK, Gtk::SHRINK); -#endif scriptCombo = new Gtk::ComboBoxText(); for (std::map<GUnicodeScript, Glib::ustring>::iterator it = getScriptToName().begin(); it != getScriptToName().end(); ++it) @@ -396,14 +368,8 @@ GlyphsPanel::GlyphsPanel(gchar const *prefsPath) : Gtk::Alignment *align = Gtk::manage(new Gtk::Alignment(Gtk::ALIGN_START, Gtk::ALIGN_START, 0.0, 0.0)); align->add(*Gtk::manage(scriptCombo)); -#if WITH_GTKMM_3_0 align->set_hexpand(); table->attach( *align, 1, row, 1, 1); -#else - table->attach( *align, - 1, 2, row, row + 1, - Gtk::FILL|Gtk::EXPAND, Gtk::SHRINK); -#endif } row++; @@ -411,15 +377,8 @@ GlyphsPanel::GlyphsPanel(gchar const *prefsPath) : // ------------------------------- { - Gtk::Label *label = new Gtk::Label(_("Range: ")); - -#if WITH_GTKMM_3_0 + auto label = new Gtk::Label(_("Range: ")); table->attach( *Gtk::manage(label), 0, row, 1, 1); -#else - table->attach( *Gtk::manage(label), - 0, 1, row, row + 1, - Gtk::SHRINK, Gtk::SHRINK); -#endif rangeCombo = new Gtk::ComboBoxText(); for ( std::vector<NamedRange>::iterator it = getRanges().begin(); it != getRanges().end(); ++it ) { @@ -431,15 +390,8 @@ GlyphsPanel::GlyphsPanel(gchar const *prefsPath) : instanceConns.push_back(conn); Gtk::Alignment *align = new Gtk::Alignment(Gtk::ALIGN_START, Gtk::ALIGN_START, 0.0, 0.0); align->add(*Gtk::manage(rangeCombo)); - -#if WITH_GTKMM_3_0 align->set_hexpand(); table->attach( *Gtk::manage(align), 1, row, 1, 1); -#else - table->attach( *Gtk::manage(align), - 1, 2, row, row + 1, - Gtk::FILL|Gtk::EXPAND, Gtk::SHRINK); -#endif } row++; @@ -462,16 +414,9 @@ GlyphsPanel::GlyphsPanel(gchar const *prefsPath) : Gtk::ScrolledWindow *scroller = new Gtk::ScrolledWindow(); scroller->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_ALWAYS); scroller->add(*Gtk::manage(iconView)); - -#if WITH_GTKMM_3_0 scroller->set_hexpand(); scroller->set_vexpand(); table->attach(*Gtk::manage(scroller), 0, row, 3, 1); -#else - table->attach(*Gtk::manage(scroller), - 0, 3, row, row + 1, - Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL); -#endif row++; @@ -501,15 +446,8 @@ GlyphsPanel::GlyphsPanel(gchar const *prefsPath) : insertBtn->set_sensitive(false); box->pack_end(*Gtk::manage(insertBtn), Gtk::PACK_SHRINK); - -#if WITH_GTKMM_3_0 box->set_hexpand(); table->attach( *Gtk::manage(box), 0, row, 3, 1); -#else - table->attach( *Gtk::manage(box), - 0, 3, row, row + 1, - Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK); -#endif row++; @@ -578,8 +516,8 @@ void GlyphsPanel::setTargetDesktop(SPDesktop *desktop) void GlyphsPanel::insertText() { SPItem *textItem = 0; - std::vector<SPItem*> itemlist=targetDesktop->selection->itemList(); - for(std::vector<SPItem*>::const_iterator i=itemlist.begin(); itemlist.end() != i; ++i) { + auto itemlist= targetDesktop->selection->items(); + for(auto i=itemlist.begin(); itemlist.end() != i; ++i) { if (SP_IS_TEXT(*i) || SP_IS_FLOWTEXT(*i)) { textItem = *i; break; @@ -591,12 +529,7 @@ void GlyphsPanel::insertText() if (entry->get_text_length() > 0) { glyphs = entry->get_text(); } else { - -#if WITH_GTKMM_3_0 - std::vector<Gtk::TreePath> itemArray = iconView->get_selected_items(); -#else - Gtk::IconView::ArrayHandle_TreePaths itemArray = iconView->get_selected_items(); -#endif + auto itemArray = iconView->get_selected_items(); if (!itemArray.empty()) { Gtk::TreeModel::Path const & path = *itemArray.begin(); @@ -641,11 +574,7 @@ void GlyphsPanel::glyphActivated(Gtk::TreeModel::Path const & path) void GlyphsPanel::glyphSelectionChanged() { -#if WITH_GTKMM_3_0 - std::vector<Gtk::TreePath> itemArray = iconView->get_selected_items(); -#else - Gtk::IconView::ArrayHandle_TreePaths itemArray = iconView->get_selected_items(); -#endif + auto itemArray = iconView->get_selected_items(); if (itemArray.empty()) { label->set_text(" "); @@ -688,8 +617,8 @@ void GlyphsPanel::selectionModifiedCB(guint flags) void GlyphsPanel::calcCanInsert() { int items = 0; - std::vector<SPItem*> itemlist=targetDesktop->selection->itemList(); - for(std::vector<SPItem*>::const_iterator i=itemlist.begin(); itemlist.end() != i; ++i) { + auto itemlist= targetDesktop->selection->items(); + for(auto i=itemlist.begin(); itemlist.end() != i; ++i) { if (SP_IS_TEXT(*i) || SP_IS_FLOWTEXT(*i)) { ++items; } diff --git a/src/ui/dialog/grid-arrange-tab.cpp b/src/ui/dialog/grid-arrange-tab.cpp index 639e463ea..5872393ae 100644 --- a/src/ui/dialog/grid-arrange-tab.cpp +++ b/src/ui/dialog/grid-arrange-tab.cpp @@ -16,15 +16,10 @@ //#define DEBUG_GRID_ARRANGE 1 #include "ui/dialog/grid-arrange-tab.h" -#include <gtk/gtk.h> //for GTK_RESPONSE* types #include <glibmm/i18n.h> -#include <gtkmm/stock.h> -#if WITH_GTKMM_3_0 -# include <gtkmm/grid.h> -#else -# include <gtkmm/table.h> -#endif +#include <gtkmm/grid.h> +#include <gtkmm/stock.h> #include <2geom/transforms.h> @@ -32,10 +27,8 @@ #include "preferences.h" #include "inkscape.h" -#include "selection.h" #include "document.h" #include "document-undo.h" -#include "sp-item.h" #include "widgets/icon.h" #include "desktop.h" //#include "sp-item-transform.h" FIXME @@ -163,7 +156,11 @@ void GridArrangeTab::arrange() desktop->getDocument()->ensureUpToDate(); Inkscape::Selection *selection = desktop->getSelection(); - const std::vector<SPItem*> items = selection ? selection->itemList() : std::vector<SPItem*>(); + std::vector<SPItem*> items; + if (selection) { + items.insert(items.end(), selection->items().begin(), selection->items().end()); + } + for(std::vector<SPItem*>::const_iterator i = items.begin();i!=items.end(); ++i){ SPItem *item = *i; Geom::OptRect b = item->documentVisualBounds(); @@ -192,7 +189,7 @@ void GridArrangeTab::arrange() // require the sorting done before we can calculate row heights etc. g_return_if_fail(selection); - std::vector<SPItem*> sorted(selection->itemList()); + std::vector<SPItem*> sorted(selection->items().begin(), selection->items().end()); sort(sorted.begin(),sorted.end(),sp_compare_y_position); sort(sorted.begin(),sorted.end(),sp_compare_x_position); @@ -368,8 +365,7 @@ void GridArrangeTab::on_row_spinbutton_changed() Inkscape::Selection *selection = desktop ? desktop->selection : 0; g_return_if_fail( selection ); - std::vector<SPItem*> const items = selection->itemList(); - int selcount = items.size(); + int selcount = (int) boost::distance(selection->items()); double PerCol = ceil(selcount / NoOfColsSpinner.get_value()); NoOfRowsSpinner.set_value(PerCol); @@ -394,7 +390,7 @@ void GridArrangeTab::on_col_spinbutton_changed() Inkscape::Selection *selection = desktop ? desktop->selection : 0; g_return_if_fail(selection); - int selcount = selection->itemList().size(); + int selcount = (int) boost::distance(selection->items()); double PerRow = ceil(selcount / NoOfRowsSpinner.get_value()); NoOfColsSpinner.set_value(PerRow); @@ -531,7 +527,10 @@ void GridArrangeTab::updateSelection() updating = true; SPDesktop *desktop = Parent->getDesktop(); Inkscape::Selection *selection = desktop ? desktop->selection : 0; - std::vector<SPItem*> const items = selection ? selection->itemList() : std::vector<SPItem*>(); + std::vector<SPItem*> items; + if (selection) { + items.insert(items.end(), selection->items().begin(), selection->items().end()); + } if (!items.empty()) { int selcount = items.size(); @@ -570,11 +569,7 @@ GridArrangeTab::GridArrangeTab(ArrangeDialog *parent) : Parent(parent), XPadding(_("X:"), _("Horizontal spacing between columns."), UNIT_TYPE_LINEAR, "", "object-columns", &PaddingUnitMenu), YPadding(_("Y:"), _("Vertical spacing between rows."), XPadding, "", "object-rows", &PaddingUnitMenu), -#if WITH_GTKMM_3_0 PaddingTable(Gtk::manage(new Gtk::Grid())) -#else - PaddingTable(Gtk::manage(new Gtk::Table(2, 2, false))) -#endif { // bool used by spin button callbacks to stop loops where they change each other. updating = false; @@ -602,7 +597,7 @@ GridArrangeTab::GridArrangeTab(ArrangeDialog *parent) g_return_if_fail( selection ); int selcount = 1; if (!selection->isEmpty()) { - selcount = selection->itemList().size(); + selcount = (int) boost::distance(selection->items()); } @@ -736,20 +731,11 @@ GridArrangeTab::GridArrangeTab(ArrangeDialog *parent) } PaddingTable->set_border_width(MARGIN); - -#if WITH_GTKMM_3_0 PaddingTable->set_row_spacing(MARGIN); PaddingTable->set_column_spacing(MARGIN); PaddingTable->attach(XPadding, 0, 0, 1, 1); PaddingTable->attach(PaddingUnitMenu, 1, 0, 1, 1); PaddingTable->attach(YPadding, 0, 1, 1, 1); -#else - PaddingTable->set_row_spacings(MARGIN); - PaddingTable->set_col_spacings(MARGIN); - PaddingTable->attach(XPadding, 0, 1, 0, 1, Gtk::SHRINK, Gtk::SHRINK); - PaddingTable->attach(PaddingUnitMenu, 1, 2, 0, 1, Gtk::SHRINK, Gtk::SHRINK); - PaddingTable->attach(YPadding, 0, 1, 1, 2, Gtk::SHRINK, Gtk::SHRINK); -#endif TileBox.pack_start(*PaddingTable, false, false, MARGIN); diff --git a/src/ui/dialog/grid-arrange-tab.h b/src/ui/dialog/grid-arrange-tab.h index a137d1694..891849f1a 100644 --- a/src/ui/dialog/grid-arrange-tab.h +++ b/src/ui/dialog/grid-arrange-tab.h @@ -111,12 +111,7 @@ private: Inkscape::UI::Widget::UnitMenu PaddingUnitMenu; Inkscape::UI::Widget::ScalarUnit XPadding; Inkscape::UI::Widget::ScalarUnit YPadding; - -#if WITH_GTKMM_3_0 Gtk::Grid *PaddingTable; -#else - Gtk::Table *PaddingTable; -#endif // BBox or manual spacing Gtk::VBox SpacingVBox; diff --git a/src/ui/dialog/guides.cpp b/src/ui/dialog/guides.cpp index 556d77a28..8d6ca4143 100644 --- a/src/ui/dialog/guides.cpp +++ b/src/ui/dialog/guides.cpp @@ -14,7 +14,7 @@ */ #ifdef HAVE_CONFIG_H -# include <config.h> +#include "config.h" #endif #include "guides.h" @@ -30,12 +30,8 @@ #include <glibmm/i18n.h> #include "ui/dialog-events.h" #include "message-context.h" -#include "xml/repr.h" #include "verbs.h" -#include <2geom/point.h> -#include <2geom/angle.h> - #include <gtkmm/stock.h> namespace Inkscape { @@ -124,13 +120,8 @@ void GuidelinePropertiesDialog::_onOK() g_free((gpointer) name); -#if WITH_GTKMM_3_0 - const Gdk::RGBA c = _color.get_rgba(); + const auto c = _color.get_rgba(); unsigned r = c.get_red_u()/257, g = c.get_green_u()/257, b = c.get_blue_u()/257; -#else - const Gdk::Color c = _color.get_color(); - unsigned r = c.get_red()/257, g = c.get_green()/257, b = c.get_blue()/257; -#endif //TODO: why 257? verify this! _guide->set_color(r, g, b, true); @@ -171,15 +162,9 @@ void GuidelinePropertiesDialog::_setup() { add_button(Gtk::Stock::DELETE, -12); add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); -#if WITH_GTKMM_3_0 - Gtk::Box *mainVBox = get_content_area(); + auto mainVBox = get_content_area(); _layout_table.set_row_spacing(4); _layout_table.set_column_spacing(4); -#else - Gtk::Box *mainVBox = get_vbox(); - _layout_table.set_spacings(4); - _layout_table.resize (3, 4); -#endif mainVBox->pack_start(_layout_table, false, false, 0); @@ -189,7 +174,6 @@ void GuidelinePropertiesDialog::_setup() { _label_descr.set_label("foo1"); _label_descr.set_alignment(0, 0.5); -#if WITH_GTKMM_3_0 _label_name.set_halign(Gtk::ALIGN_FILL); _label_name.set_valign(Gtk::ALIGN_FILL); _layout_table.attach(_label_name, 0, 0, 3, 1); @@ -207,19 +191,6 @@ void GuidelinePropertiesDialog::_setup() { _color.set_valign(Gtk::ALIGN_FILL); _color.set_hexpand(); _layout_table.attach(_color, 1, 3, 2, 1); -#else - _layout_table.attach(_label_name, - 0, 3, 0, 1, Gtk::FILL, Gtk::FILL); - - _layout_table.attach(_label_descr, - 0, 3, 1, 2, Gtk::FILL, Gtk::FILL); - - _layout_table.attach(_label_entry, - 1, 3, 2, 3, Gtk::EXPAND | Gtk::FILL, Gtk::FILL); - - _layout_table.attach(_color, - 1, 3, 3, 4, Gtk::EXPAND | Gtk::FILL, Gtk::FILL); -#endif // unitmenus /* fixme: We should allow percents here too, as percents of the canvas size */ @@ -238,7 +209,6 @@ void GuidelinePropertiesDialog::_setup() { _spin_button_y.setIncrements(1.0, 10.0); _spin_button_y.setRange(-1e6, 1e6); -#if WITH_GTKMM_3_0 _spin_button_x.set_halign(Gtk::ALIGN_FILL); _spin_button_x.set_valign(Gtk::ALIGN_FILL); _spin_button_x.set_hexpand(); @@ -252,22 +222,12 @@ void GuidelinePropertiesDialog::_setup() { _unit_menu.set_halign(Gtk::ALIGN_FILL); _unit_menu.set_valign(Gtk::ALIGN_FILL); _layout_table.attach(_unit_menu, 2, 4, 1, 1); -#else - _layout_table.attach(_spin_button_x, - 1, 2, 4, 5, Gtk::EXPAND | Gtk::FILL, Gtk::FILL); - _layout_table.attach(_spin_button_y, - 1, 2, 5, 6, Gtk::EXPAND | Gtk::FILL, Gtk::FILL); - - _layout_table.attach(_unit_menu, - 2, 3, 4, 5, Gtk::FILL, Gtk::FILL); -#endif // angle spinbutton _spin_angle.setDigits(3); _spin_angle.setIncrements(1.0, 10.0); _spin_angle.setRange(-3600., 3600.); -#if WITH_GTKMM_3_0 _spin_angle.set_halign(Gtk::ALIGN_FILL); _spin_angle.set_valign(Gtk::ALIGN_FILL); _spin_angle.set_hexpand(); @@ -284,18 +244,6 @@ void GuidelinePropertiesDialog::_setup() { _locked_toggle.set_valign(Gtk::ALIGN_FILL); _locked_toggle.set_hexpand(); _layout_table.attach(_locked_toggle, 1, 8, 2, 1); -#else - _layout_table.attach(_spin_angle, - 1, 3, 6, 7, Gtk::EXPAND | Gtk::FILL, Gtk::FILL); - - // mode radio button - _layout_table.attach(_relative_toggle, - 1, 3, 7, 8, Gtk::EXPAND | Gtk::FILL, Gtk::FILL); - - // locked radio button - _layout_table.attach(_locked_toggle, - 1, 3, 8, 9, Gtk::EXPAND | Gtk::FILL, Gtk::FILL); -#endif _relative_toggle.signal_toggled().connect(sigc::mem_fun(*this, &GuidelinePropertiesDialog::_modeChanged)); _relative_toggle.set_active(_relative_toggle_status); @@ -348,15 +296,9 @@ void GuidelinePropertiesDialog::_setup() { // init name entry _label_entry.getEntry()->set_text(_guide->getLabel() ? _guide->getLabel() : ""); -#if WITH_GTKMM_3_0 Gdk::RGBA c; c.set_rgba(((_guide->getColor()>>24)&0xff) / 255.0, ((_guide->getColor()>>16)&0xff) / 255.0, ((_guide->getColor()>>8)&0xff) / 255.0); _color.set_rgba(c); -#else - Gdk::Color c; - c.set_rgb_p(((_guide->getColor()>>24)&0xff) / 255.0, ((_guide->getColor()>>16)&0xff) / 255.0, ((_guide->getColor()>>8)&0xff) / 255.0); - _color.set_color(c); -#endif _modeChanged(); // sets values of spinboxes. diff --git a/src/ui/dialog/guides.h b/src/ui/dialog/guides.h index 5dce0d6ed..25d32015c 100644 --- a/src/ui/dialog/guides.h +++ b/src/ui/dialog/guides.h @@ -16,12 +16,7 @@ #endif #include <gtkmm/dialog.h> - -#if WITH_GTKMM_3_0 #include <gtkmm/grid.h> -#else -#include <gtkmm/table.h> -#endif #include <gtkmm/label.h> #include <gtkmm/colorbutton.h> @@ -71,12 +66,7 @@ private: SPDesktop *_desktop; SPGuide *_guide; -#if WITH_GTKMM_3_0 - Gtk::Grid _layout_table; -#else - Gtk::Table _layout_table; -#endif - + Gtk::Grid _layout_table; Gtk::Label _label_name; Gtk::Label _label_descr; Inkscape::UI::Widget::CheckButton _locked_toggle; diff --git a/src/ui/dialog/icon-preview.cpp b/src/ui/dialog/icon-preview.cpp index 83656a1f2..a4fcc9947 100644 --- a/src/ui/dialog/icon-preview.cpp +++ b/src/ui/dialog/icon-preview.cpp @@ -14,15 +14,15 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ #ifdef HAVE_CONFIG_H -# include <config.h> +#include "config.h" #endif #include <gtkmm/buttonbox.h> #include <boost/scoped_ptr.hpp> #include <glibmm/i18n.h> -#include <glibmm/main.h> #include <glibmm/timer.h> +#include <glibmm/main.h> #include <gtkmm/alignment.h> #include <gtkmm/checkbutton.h> @@ -35,10 +35,7 @@ #include "display/drawing.h" #include "document.h" #include "inkscape.h" -#include "preferences.h" -#include "selection.h" #include "sp-root.h" -#include "xml/repr.h" #include "verbs.h" #include "icon-preview.h" @@ -362,8 +359,8 @@ void IconPreviewPanel::refreshPreview() if ( sel ) { //g_message("found a selection to play with"); - std::vector<SPItem*> const items = sel->itemList(); - for(std::vector<SPItem*>::const_iterator i=items.begin();!target && i!=items.end();++i){ + auto items = sel->items(); + for(auto i=items.begin();!target && i!=items.end();++i){ SPItem* item = *i; gchar const *id = item->getId(); if ( id ) { diff --git a/src/ui/dialog/icon-preview.h b/src/ui/dialog/icon-preview.h index 8a6e19a25..caec7e3b5 100644 --- a/src/ui/dialog/icon-preview.h +++ b/src/ui/dialog/icon-preview.h @@ -66,13 +66,7 @@ private: gdouble minDelay; Gtk::VBox iconBox; - -#if WITH_GTKMM_3_0 Gtk::Paned splitter; -#else - Gtk::HPaned splitter; -#endif - Glib::ustring targetId; int hot; int numEntries; diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp index 6dd62d3bb..9a95c3d8c 100644 --- a/src/ui/dialog/inkscape-preferences.cpp +++ b/src/ui/dialog/inkscape-preferences.cpp @@ -19,30 +19,22 @@ #include "inkscape-preferences.h" #include <glibmm/i18n.h> -#include <glibmm/markup.h> #include <glibmm/miscutils.h> +#include <glibmm/markup.h> #include <gtkmm/main.h> -#include <gtkmm/frame.h> -#include <gtkmm/scrolledwindow.h> #include <gtkmm/alignment.h> #include "preferences.h" #include "verbs.h" #include "selcue.h" -#include "util/units.h" -#include <iostream> -#include "enums.h" #include "extension/internal/gdkpixbuf-input.h" #include "message-stack.h" #include "style.h" #include "selection.h" #include "selection-chemistry.h" -#include "xml/repr.h" #include "ui/widget/style-swatch.h" -#include "ui/widget/spinbutton.h" #include "display/nr-filter-gaussian.h" -#include "display/nr-filter-types.h" #include "cms-system.h" #include "color-profile.h" #include "display/canvas-grid.h" @@ -86,12 +78,8 @@ InkscapePreferences::InkscapePreferences() _getContents()->add(*sb); show_all_children(); Gtk::Requisition sreq; -#if WITH_GTKMM_3_0 Gtk::Requisition sreq_natural; sb->get_preferred_size(sreq_natural, sreq); -#else - sreq = sb->size_request(); -#endif _sb_width = sreq.width; _getContents()->remove(*sb); delete sb; @@ -863,17 +851,10 @@ static void proofComboChanged( Gtk::ComboBoxText* combo ) } static void gamutColorChanged( Gtk::ColorButton* btn ) { -#if WITH_GTKMM_3_0 - Gdk::RGBA rgba = btn->get_rgba(); - gushort r = rgba.get_red_u(); - gushort g = rgba.get_green_u(); - gushort b = rgba.get_blue_u(); -#else - Gdk::Color color = btn->get_color(); - gushort r = color.get_red(); - gushort g = color.get_green(); - gushort b = color.get_blue(); -#endif + auto rgba = btn->get_rgba(); + auto r = rgba.get_red_u(); + auto g = rgba.get_green_u(); + auto b = rgba.get_blue_u(); gchar* tmp = g_strdup_printf("#%02x%02x%02x", (r >> 8), (g >> 8), (b >> 8) ); @@ -1043,13 +1024,8 @@ void InkscapePreferences::initPageIO() Glib::ustring colorStr = prefs->getString("/options/softproof/gamutcolor"); -#if WITH_GTKMM_3_0 Gdk::RGBA tmpColor( colorStr.empty() ? "#00ff00" : colorStr); _cms_gamutcolor.set_rgba( tmpColor ); -#else - Gdk::Color tmpColor( colorStr.empty() ? "#00ff00" : colorStr); - _cms_gamutcolor.set_color( tmpColor ); -#endif _page_cms.add_line( true, _("Out of gamut warning color:"), _cms_gamutcolor, "", _("Selects the color used for out of gamut warning"), false); @@ -1331,7 +1307,7 @@ void InkscapePreferences::initPageBehavior() _steps_rot_relative.init ( _("Relative snapping of guideline angles"), "/options/relativeguiderotationsnap/value", false); _page_steps.add_line( false, "", _steps_rot_relative, "", _("When on, the snap angles when rotating a guideline will be relative to the original angle")); - _steps_zoom.init ( "/options/zoomincrement/value", 101.0, 500.0, 1.0, 1.0, 1.414213562, true, true); + _steps_zoom.init ( "/options/zoomincrement/value", 101.0, 500.0, 1.0, 1.0, M_SQRT2, true, true); _page_steps.add_line( false, _("_Zoom in/out by:"), _steps_zoom, _("%"), _("Zoom tool click, +/- keys, and middle click zoom in and out by this multiplier"), false); this->AddPage(_page_steps, _("Steps"), iter_behavior, PREFS_PAGE_BEHAVIOR_STEPS); @@ -1594,31 +1570,19 @@ void InkscapePreferences::initKeyboardShortcuts(Gtk::TreeModel::iterator iter_ui int row = 3; -#if WITH_GTKMM_3_0 scroller->set_hexpand(); scroller->set_vexpand(); _page_keyshortcuts.attach(*scroller, 0, row, 2, 1); -#else - _page_keyshortcuts.attach(*scroller, 0, 2, row, row+1, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL); -#endif row++; -#if WITH_GTKMM_3_0 - Gtk::ButtonBox *box_buttons = Gtk::manage(new Gtk::ButtonBox); -#else - Gtk::HButtonBox *box_buttons = Gtk::manage (new Gtk::HButtonBox); -#endif + auto box_buttons = Gtk::manage(new Gtk::ButtonBox); box_buttons->set_layout(Gtk::BUTTONBOX_END); box_buttons->set_spacing(4); -#if WITH_GTKMM_3_0 box_buttons->set_hexpand(); _page_keyshortcuts.attach(*box_buttons, 0, row, 3, 1); -#else - _page_keyshortcuts.attach(*box_buttons, 0, 3, row, row+1, Gtk::EXPAND | Gtk::FILL, Gtk::SHRINK); -#endif UI::Widget::Button *kb_reset = Gtk::manage(new UI::Widget::Button(_("Reset"), _("Remove all your customized keyboard shortcuts, and revert to the shortcuts in the shortcut file listed above"))); box_buttons->pack_start(*kb_reset, true, true, 6); @@ -2051,12 +2015,8 @@ bool InkscapePreferences::SetMaxDialogSize(const Gtk::TreeModel::iterator& iter) _page_frame.add(*page); this->show_all_children(); Gtk::Requisition sreq; -#if WITH_GTKMM_3_0 Gtk::Requisition sreq_natural; this->get_preferred_size(sreq_natural, sreq); -#else - sreq = this->size_request(); -#endif _max_dialog_width=std::max(_max_dialog_width, sreq.width); _max_dialog_height=std::max(_max_dialog_height, sreq.height); _page_frame.remove(); diff --git a/src/ui/dialog/inkscape-preferences.h b/src/ui/dialog/inkscape-preferences.h index d1abcfc58..781b5e48e 100644 --- a/src/ui/dialog/inkscape-preferences.h +++ b/src/ui/dialog/inkscape-preferences.h @@ -97,11 +97,7 @@ enum { }; namespace Gtk { -#if WITH_GTKMM_3_0 class Scale; -#else -class HScale; -#endif } namespace Inkscape { @@ -206,11 +202,7 @@ protected: UI::Widget::PrefCheckButton _scroll_space; UI::Widget::PrefCheckButton _wheel_zoom; -#if WITH_GTKMM_3_0 Gtk::Scale *_slider_snapping_delay; -#else - Gtk::HScale *_slider_snapping_delay; -#endif UI::Widget::PrefCheckButton _snap_indicator; UI::Widget::PrefCheckButton _snap_closest_only; diff --git a/src/ui/dialog/input.cpp b/src/ui/dialog/input.cpp index 8343cd6fe..9fd2288e7 100644 --- a/src/ui/dialog/input.cpp +++ b/src/ui/dialog/input.cpp @@ -15,35 +15,20 @@ #include "ui/widget/panel.h" #include "ui/widget/frame.h" -#include <glib/gprintf.h> #include <glibmm/i18n.h> -#include <gtkmm/alignment.h> #include <gtkmm/buttonbox.h> #include <gtkmm/cellrenderercombo.h> #include <gtkmm/checkbutton.h> #include <gtkmm/comboboxtext.h> -#include <gtkmm/enums.h> -#include <gtkmm/eventbox.h> -#include <gtkmm/frame.h> -#include <gtkmm/image.h> +#include <gtkmm/grid.h> #include <gtkmm/liststore.h> #include <gtkmm/menubar.h> #include <gtkmm/notebook.h> #include <gtkmm/paned.h> #include <gtkmm/progressbar.h> #include <gtkmm/scrolledwindow.h> - -#if WITH_GTKMM_3_0 -# include <gtkmm/grid.h> -#else -# include <gtkmm/table.h> -#endif - -#include <gtkmm/treemodel.h> -#include <gtkmm/treemodelcolumn.h> #include <gtkmm/treestore.h> -#include <gtkmm/treeview.h> #include "device-manager.h" #include "preferences.h" @@ -431,13 +416,7 @@ private: Blink watcher; Gtk::CheckButton useExt; Gtk::Button save; - -#if WITH_GTKMM_3_0 Gtk::Paned pane; -#else - Gtk::HPaned pane; -#endif - Gtk::VBox detailsBox; Gtk::HBox titleFrame; Gtk::Label titleLabel; @@ -498,27 +477,14 @@ private: Inkscape::UI::Widget::Frame axisFrame; Gtk::ScrolledWindow treeScroller; Gtk::ScrolledWindow detailScroller; - -#if WITH_GTKMM_3_0 Gtk::Paned splitter; Gtk::Paned split2; -#else - Gtk::HPaned splitter; - Gtk::VPaned split2; -#endif - Gtk::Label devName; Gtk::Label devKeyCount; Gtk::Label devAxesCount; Gtk::ComboBoxText axesCombo; Gtk::ProgressBar axesValues[6]; - -#if WITH_GTKMM_3_0 Gtk::Grid axisTable; -#else - Gtk::Table axisTable; -#endif - Gtk::ComboBoxText buttonCombo; Gtk::ComboBoxText linkCombo; sigc::connection linkConnection; @@ -528,13 +494,7 @@ private: Gtk::Image testThumb; Gtk::Image testButtons[24]; Gtk::Image testAxes[8]; - -#if WITH_GTKMM_3_0 Gtk::Grid imageTable; -#else - Gtk::Table imageTable; -#endif - Gtk::EventBox testDetector; ConfPanel cfgPanel; @@ -620,20 +580,11 @@ InputDialogImpl::InputDialogImpl() : treeScroller(), detailScroller(), splitter(), -#if WITH_GTKMM_3_0 split2(Gtk::ORIENTATION_VERTICAL), axisTable(), -#else - split2(), - axisTable(11, 2), -#endif linkCombo(), topHolder(), -#if WITH_GTKMM_3_0 imageTable(), -#else - imageTable(8, 7), -#endif testDetector(), cfgPanel() { @@ -655,27 +606,16 @@ InputDialogImpl::InputDialogImpl() : testFrame.add(testDetector); testThumb.set(getPix(PIX_TABLET)); testThumb.set_padding(24, 24); - -#if WITH_GTKMM_3_0 testThumb.set_hexpand(); testThumb.set_vexpand(); imageTable.attach(testThumb, 0, 0, 8, 1); -#else - imageTable.attach(testThumb, 0, 8, 0, 1, ::Gtk::EXPAND, ::Gtk::EXPAND); -#endif { guint col = 0; guint row = 1; for ( guint num = 0; num < G_N_ELEMENTS(testButtons); num++ ) { testButtons[num].set(getPix(PIX_BUTTONS_NONE)); - -#if WITH_GTKMM_3_0 imageTable.attach(testButtons[num], col, row, 1, 1); -#else - imageTable.attach(testButtons[num], col, col + 1, row, row + 1, ::Gtk::FILL, ::Gtk::FILL); -#endif - col++; if (col > 7) { col = 0; @@ -686,13 +626,7 @@ InputDialogImpl::InputDialogImpl() : col = 0; for ( guint num = 0; num < G_N_ELEMENTS(testAxes); num++ ) { testAxes[num].set(getPix(PIX_AXIS_NONE)); - -#if WITH_GTKMM_3_0 imageTable.attach(testAxes[num], col * 2, row, 2, 1); -#else - imageTable.attach(testAxes[num], col * 2, (col + 1) * 2, row, row + 1, ::Gtk::FILL, ::Gtk::FILL); -#endif - col++; if (col > 3) { col = 0; @@ -730,45 +664,17 @@ InputDialogImpl::InputDialogImpl() : axisFrame.add(axisTable); Gtk::Label *lbl = Gtk::manage(new Gtk::Label(_("Link:"))); - -#if WITH_GTKMM_3_0 axisTable.attach(*lbl, 0, rowNum, 1, 1); -#else - axisTable.attach(*lbl, 0, 1, rowNum, rowNum+ 1, - ::Gtk::FILL, - ::Gtk::SHRINK); -#endif - linkCombo.append(_("None")); linkCombo.set_active_text(_("None")); linkCombo.set_sensitive(false); linkConnection = linkCombo.signal_changed().connect(sigc::mem_fun(*this, &InputDialogImpl::linkComboChanged)); - -#if WITH_GTKMM_3_0 axisTable.attach(linkCombo, 1, rowNum, 1, 1); -#else - axisTable.attach(linkCombo, 1, 2, rowNum, rowNum + 1, - ::Gtk::FILL, - ::Gtk::SHRINK); -#endif - rowNum++; - lbl = Gtk::manage(new Gtk::Label(_("Axes count:"))); - -#if WITH_GTKMM_3_0 axisTable.attach(*lbl, 0, rowNum, 1, 1); axisTable.attach(devAxesCount, 1, rowNum, 1, 1); -#else - axisTable.attach(*lbl, 0, 1, rowNum, rowNum+ 1, - ::Gtk::FILL, - ::Gtk::SHRINK); - axisTable.attach(devAxesCount, 1, 2, rowNum, rowNum + 1, - ::Gtk::SHRINK, - ::Gtk::SHRINK); -#endif - rowNum++; @@ -786,22 +692,11 @@ InputDialogImpl::InputDialogImpl() : for ( guint barNum = 0; barNum < static_cast<guint>(G_N_ELEMENTS(axesValues)); barNum++ ) { lbl = Gtk::manage(new Gtk::Label(_("axis:"))); - -#if WITH_GTKMM_3_0 lbl->set_hexpand(); axisTable.attach(*lbl, 0, rowNum, 1, 1); axesValues[barNum].set_hexpand(); axisTable.attach(axesValues[barNum], 1, rowNum, 1, 1); -#else - axisTable.attach(*lbl, 0, 1, rowNum, rowNum+ 1, - ::Gtk::EXPAND, - ::Gtk::SHRINK); - axisTable.attach(axesValues[barNum], 1, 2, rowNum, rowNum + 1, - ::Gtk::EXPAND, - ::Gtk::SHRINK); -#endif - axesValues[barNum].set_sensitive(false); rowNum++; @@ -811,17 +706,8 @@ InputDialogImpl::InputDialogImpl() : lbl = Gtk::manage(new Gtk::Label(_("Button count:"))); -#if WITH_GTKMM_3_0 axisTable.attach(*lbl, 0, rowNum, 1, 1); axisTable.attach(devKeyCount, 1, rowNum, 1, 1); -#else - axisTable.attach(*lbl, 0, 1, rowNum, rowNum+ 1, - ::Gtk::FILL, - ::Gtk::SHRINK); - axisTable.attach(devKeyCount, 1, 2, rowNum, rowNum + 1, - ::Gtk::SHRINK, - ::Gtk::SHRINK); -#endif rowNum++; @@ -837,13 +723,7 @@ InputDialogImpl::InputDialogImpl() : rowNum++; */ -#if WITH_GTKMM_3_0 axisTable.attach(keyVal, 0, rowNum, 2, 1); -#else - axisTable.attach(keyVal, 0, 2, rowNum, rowNum + 1, - ::Gtk::FILL, - ::Gtk::SHRINK); -#endif rowNum++; @@ -857,18 +737,9 @@ InputDialogImpl::InputDialogImpl() : // TODO: Extension event stuff has been removed from public API in GTK+ 3 // Need to check that this hasn't broken anything -#if !GTK_CHECK_VERSION(3,0,0) - gtk_widget_set_extension_events( GTK_WIDGET(testDetector.gobj()), GDK_EXTENSION_EVENTS_ALL ); -#endif testDetector.add_events(Gdk::POINTER_MOTION_MASK|Gdk::KEY_PRESS_MASK|Gdk::KEY_RELEASE_MASK |Gdk::PROXIMITY_IN_MASK|Gdk::PROXIMITY_OUT_MASK|Gdk::SCROLL_MASK); -#if WITH_GTKMM_3_0 axisTable.attach(keyEntry, 0, rowNum, 2, 1); -#else - axisTable.attach(keyEntry, 0, 2, rowNum, rowNum + 1, - ::Gtk::FILL, - ::Gtk::SHRINK); -#endif rowNum++; @@ -1150,12 +1021,7 @@ InputDialogImpl::ConfPanel::ConfPanel() : useExt.set_active(Preferences::get()->getBool("/options/useextinput/value")); useExt.signal_toggled().connect(sigc::mem_fun(*this, &InputDialogImpl::ConfPanel::useExtToggled)); -#if WITH_GTKMM_3_0 - Gtk::ButtonBox *buttonBox = Gtk::manage(new Gtk::ButtonBox); -#else - Gtk::HButtonBox *buttonBox = Gtk::manage (new Gtk::HButtonBox); -#endif - + auto buttonBox = Gtk::manage(new Gtk::ButtonBox); buttonBox->set_layout (Gtk::BUTTONBOX_END); //Gtk::Alignment *align = new Gtk::Alignment(Gtk::ALIGN_END, Gtk::ALIGN_START, 0, 0); buttonBox->add(save); @@ -1939,7 +1805,6 @@ bool InputDialogImpl::eventSnoop(GdkEvent* event) testThumb.set(getPix(PIX_ERASER)); break; } -#if WITH_GTKMM_3_0 /// \fixme GTK3 added new GDK_SOURCEs that should be handled here! case GDK_SOURCE_KEYBOARD: case GDK_SOURCE_TOUCHSCREEN: @@ -1947,7 +1812,6 @@ bool InputDialogImpl::eventSnoop(GdkEvent* event) g_warning("InputDialogImpl::eventSnoop : unhandled GDK_SOURCE type!"); break; } -#endif } updateTestButtons(key, hotButton); diff --git a/src/ui/dialog/knot-properties.cpp b/src/ui/dialog/knot-properties.cpp index a91a09a4f..133ed6f4c 100644 --- a/src/ui/dialog/knot-properties.cpp +++ b/src/ui/dialog/knot-properties.cpp @@ -14,12 +14,10 @@ */ #ifdef HAVE_CONFIG_H -# include <config.h> +#include "config.h" #endif #include "ui/dialog/knot-properties.h" #include <boost/lexical_cast.hpp> -#include <gtkmm/stock.h> -#include <glibmm/main.h> #include <glibmm/i18n.h> #include "inkscape.h" #include "util/units.h" @@ -27,15 +25,8 @@ #include "document.h" #include "document-undo.h" #include "layer-manager.h" -#include "message-stack.h" -#include "sp-object.h" -#include "sp-item.h" -#include "verbs.h" -#include "selection.h" #include "selection-chemistry.h" -#include "ui/icon-names.h" -#include "ui/widget/imagetoggler.h" //#include "event-context.h" diff --git a/src/ui/dialog/layer-properties.cpp b/src/ui/dialog/layer-properties.cpp index 5d550ed48..4aa86cc48 100644 --- a/src/ui/dialog/layer-properties.cpp +++ b/src/ui/dialog/layer-properties.cpp @@ -15,8 +15,9 @@ #include "layer-properties.h" #include <gtkmm/stock.h> -#include <glibmm/main.h> #include <glibmm/i18n.h> +#include <glibmm/main.h> + #include "inkscape.h" #include "desktop.h" #include "document.h" @@ -24,10 +25,7 @@ #include "layer-manager.h" #include "message-stack.h" -#include "sp-object.h" -#include "sp-item.h" #include "verbs.h" -#include "selection.h" #include "selection-chemistry.h" #include "ui/icon-names.h" #include "ui/widget/imagetoggler.h" @@ -40,22 +38,15 @@ namespace Dialogs { LayerPropertiesDialog::LayerPropertiesDialog() : _strategy(NULL), _desktop(NULL), _layer(NULL), _position_visible(false) { -#if WITH_GTKMM_3_0 - Gtk::Box *mainVBox = get_content_area(); + auto mainVBox = get_content_area(); _layout_table.set_row_spacing(4); _layout_table.set_column_spacing(4); -#else - Gtk::Box *mainVBox = get_vbox(); - _layout_table.set_spacings(4); - _layout_table.resize (1, 2); -#endif // Layer name widgets _layer_name_entry.set_activates_default(true); _layer_name_label.set_label(_("Layer name:")); _layer_name_label.set_alignment(1.0, 0.5); -#if WITH_GTKMM_3_0 _layer_name_label.set_halign(Gtk::ALIGN_FILL); _layer_name_label.set_valign(Gtk::ALIGN_FILL); _layout_table.attach(_layer_name_label, 0, 0, 1, 1); @@ -64,12 +55,6 @@ LayerPropertiesDialog::LayerPropertiesDialog() _layer_name_entry.set_valign(Gtk::ALIGN_FILL); _layer_name_entry.set_hexpand(); _layout_table.attach(_layer_name_entry, 1, 0, 1, 1); -#else - _layout_table.attach(_layer_name_label, - 0, 1, 0, 1, Gtk::FILL, Gtk::FILL); - _layout_table.attach(_layer_name_entry, - 1, 2, 0, 1, Gtk::FILL | Gtk::EXPAND, Gtk::FILL); -#endif mainVBox->pack_start(_layout_table, true, true, 4); @@ -166,10 +151,6 @@ LayerPropertiesDialog::_setup_position_controls() { _layer_position_combo.set_cell_data_func(_label_renderer, sigc::mem_fun(*this, &LayerPropertiesDialog::_prepareLabelRenderer)); -#if !WITH_GTKMM_3_0 - _layout_table.resize (2, 2); -#endif - Gtk::ListStore::iterator row; row = _dropdown_list->append(); row->set_value(_dropdown_columns.position, LPOS_ABOVE); @@ -185,7 +166,6 @@ LayerPropertiesDialog::_setup_position_controls() { _layer_position_label.set_label(_("Position:")); _layer_position_label.set_alignment(1.0, 0.5); -#if WITH_GTKMM_3_0 _layer_position_combo.set_halign(Gtk::ALIGN_FILL); _layer_position_combo.set_valign(Gtk::ALIGN_FILL); _layer_position_combo.set_hexpand(); @@ -194,12 +174,6 @@ LayerPropertiesDialog::_setup_position_controls() { _layer_position_label.set_halign(Gtk::ALIGN_FILL); _layer_position_label.set_valign(Gtk::ALIGN_FILL); _layout_table.attach(_layer_position_label, 0, 1, 1, 1); -#else - _layout_table.attach(_layer_position_combo, - 1, 2, 1, 2, Gtk::FILL | Gtk::EXPAND, Gtk::FILL); - _layout_table.attach(_layer_position_label, - 0, 1, 1, 2, Gtk::FILL, Gtk::FILL); -#endif show_all_children(); } @@ -254,16 +228,11 @@ LayerPropertiesDialog::_setup_layers_controls() { _layout_table.remove(_layer_name_entry); _layout_table.remove(_layer_name_label); -#if WITH_GTKMM_3_0 _scroller.set_halign(Gtk::ALIGN_FILL); _scroller.set_valign(Gtk::ALIGN_FILL); _scroller.set_hexpand(); _scroller.set_vexpand(); _layout_table.attach(_scroller, 0, 1, 2, 1); -#else - _layout_table.attach(_scroller, - 0, 2, 1, 2, Gtk::FILL | Gtk::EXPAND, Gtk::FILL | Gtk::EXPAND); -#endif show_all_children(); } diff --git a/src/ui/dialog/layer-properties.h b/src/ui/dialog/layer-properties.h index c75a7f190..f62f22782 100644 --- a/src/ui/dialog/layer-properties.h +++ b/src/ui/dialog/layer-properties.h @@ -19,12 +19,7 @@ #include <gtkmm/dialog.h> #include <gtkmm/entry.h> #include <gtkmm/label.h> - -#if WITH_GTKMM_3_0 #include <gtkmm/grid.h> -#else -#include <gtkmm/table.h> -#endif #include <gtkmm/combobox.h> #include <gtkmm/liststore.h> @@ -102,12 +97,7 @@ protected: Gtk::Entry _layer_name_entry; Gtk::Label _layer_position_label; Gtk::ComboBox _layer_position_combo; - -#if WITH_GTKMM_3_0 Gtk::Grid _layout_table; -#else - Gtk::Table _layout_table; -#endif bool _position_visible; diff --git a/src/ui/dialog/layers.cpp b/src/ui/dialog/layers.cpp index 1c022ecad..dd9d7ec25 100644 --- a/src/ui/dialog/layers.cpp +++ b/src/ui/dialog/layers.cpp @@ -10,16 +10,13 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ #ifdef HAVE_CONFIG_H -# include <config.h> +#include "config.h" #endif #include "layers.h" -#include <gtkmm/widget.h> #include <gtkmm/icontheme.h> #include <gtkmm/imagemenuitem.h> #include <gtkmm/separatormenuitem.h> - -#include <glibmm/i18n.h> #include <glibmm/main.h> #include "desktop.h" @@ -27,19 +24,14 @@ #include "document.h" #include "document-undo.h" #include "helper/action.h" -#include "helper/action-context.h" #include "inkscape.h" #include "layer-fns.h" #include "layer-manager.h" -#include "preferences.h" -#include "sp-item.h" -#include "sp-object.h" #include "svg/css-ostringstream.h" #include "ui/icon-names.h" #include "ui/widget/imagetoggler.h" #include "verbs.h" #include "widgets/icon.h" -#include "xml/repr.h" #include "sp-root.h" #include "ui/tools/tool-base.h" #include "selection-chemistry.h" @@ -866,12 +858,8 @@ LayersPanel::LayersPanel() : _scroller.set_policy( Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC ); _scroller.set_shadow_type(Gtk::SHADOW_IN); Gtk::Requisition sreq; -#if WITH_GTKMM_3_0 Gtk::Requisition sreq_natural; _scroller.get_preferred_size(sreq_natural, sreq); -#else - sreq = _scroller.size_request(); -#endif int minHeight = 70; if (sreq.height < minHeight) { // Set a min height to see the layers when used with Ubuntu liboverlay-scrollbar diff --git a/src/ui/dialog/layers.h b/src/ui/dialog/layers.h index 9cd2c3b92..893b31557 100644 --- a/src/ui/dialog/layers.h +++ b/src/ui/dialog/layers.h @@ -124,15 +124,9 @@ private: Gtk::TreeView _tree; Gtk::CellRendererText *_text_renderer; Gtk::TreeView::Column *_name_column; -#if WITH_GTKMM_3_0 Gtk::Box _buttonsRow; Gtk::Box _buttonsPrimary; Gtk::Box _buttonsSecondary; -#else - Gtk::HBox _buttonsRow; - Gtk::HBox _buttonsPrimary; - Gtk::HBox _buttonsSecondary; -#endif Gtk::ScrolledWindow _scroller; Gtk::Menu _popupMenu; Inkscape::UI::Widget::SpinButton _spinBtn; diff --git a/src/ui/dialog/livepatheffect-add.cpp b/src/ui/dialog/livepatheffect-add.cpp index c558eddaf..917e48ac6 100644 --- a/src/ui/dialog/livepatheffect-add.cpp +++ b/src/ui/dialog/livepatheffect-add.cpp @@ -9,7 +9,7 @@ */ #ifdef HAVE_CONFIG_H -# include <config.h> +#include "config.h" #endif #include "livepatheffect-add.h" @@ -17,7 +17,6 @@ #include <gtkmm/stock.h> #include "desktop.h" -#include "live_effects/effect-enum.h" namespace Inkscape { namespace UI { @@ -74,11 +73,7 @@ LivePathEffectAdd::LivePathEffectAdd() : add_button.set_use_underline(true); add_button.set_can_default(); -#if WITH_GTKMM_3_0 - Gtk::Box *mainVBox = get_content_area(); -#else - Gtk::Box *mainVBox = get_vbox(); -#endif + auto mainVBox = get_content_area(); mainVBox->pack_start(scrolled_window, true, true); add_action_widget(close_button, Gtk::RESPONSE_CLOSE); diff --git a/src/ui/dialog/livepatheffect-editor.cpp b/src/ui/dialog/livepatheffect-editor.cpp index e177ae01e..73f8debd6 100644 --- a/src/ui/dialog/livepatheffect-editor.cpp +++ b/src/ui/dialog/livepatheffect-editor.cpp @@ -13,20 +13,16 @@ */ #ifdef HAVE_CONFIG_H -# include <config.h> +#include "config.h" #endif #include "livepatheffect-editor.h" -#include <glibmm/i18n.h> #include <gtkmm/stock.h> -#include <gtkmm/toolbar.h> -#include <vector> #include "desktop.h" #include "document.h" #include "document-undo.h" -#include "gtkmm/widget.h" #include "helper/action.h" #include "inkscape.h" #include "live_effects/effect.h" @@ -34,19 +30,14 @@ #include "live_effects/lpeobject-reference.h" #include "path-chemistry.h" #include "selection-chemistry.h" -#include "selection.h" #include "sp-item-group.h" -#include "sp-lpe-item.h" #include "sp-path.h" #include "sp-rect.h" -#include "sp-use.h" #include "sp-text.h" -#include "sp-shape.h" #include "ui/icon-names.h" #include "ui/widget/imagetoggler.h" #include "verbs.h" #include "widgets/icon.h" -#include "xml/node.h" #include "livepatheffect-add.h" namespace Inkscape { @@ -135,13 +126,6 @@ LivePathEffectEditor::LivePathEffectEditor() // Add toolbar items to toolbar toolbar_hbox.set_layout (Gtk::BUTTONBOX_END); - -#if !WITH_GTKMM_3_0 - // TODO: This has been removed from Gtkmm 3.0. Check that - // everything still looks OK! - toolbar_hbox.set_child_min_width( 16 ); -#endif - toolbar_hbox.add( button_add ); toolbar_hbox.set_child_secondary( button_add , true); toolbar_hbox.add( button_remove ); diff --git a/src/ui/dialog/livepatheffect-editor.h b/src/ui/dialog/livepatheffect-editor.h index b7ec1eeec..489e9564d 100644 --- a/src/ui/dialog/livepatheffect-editor.h +++ b/src/ui/dialog/livepatheffect-editor.h @@ -113,11 +113,7 @@ private: void on_visibility_toggled( Glib::ustring const& str ); -#if WITH_GTKMM_3_0 Gtk::ButtonBox toolbar_hbox; -#else - Gtk::HButtonBox toolbar_hbox; -#endif Gtk::Button button_add; Gtk::Button button_remove; Gtk::Button button_up; diff --git a/src/ui/dialog/lpe-fillet-chamfer-properties.cpp b/src/ui/dialog/lpe-fillet-chamfer-properties.cpp index b0cc91868..d33ee758d 100644 --- a/src/ui/dialog/lpe-fillet-chamfer-properties.cpp +++ b/src/ui/dialog/lpe-fillet-chamfer-properties.cpp @@ -5,30 +5,20 @@ */ #ifdef HAVE_CONFIG_H -#include <config.h> +#include "config.h" #endif #include <gtkmm.h> #include "lpe-fillet-chamfer-properties.h" #include <boost/lexical_cast.hpp> -#include <glibmm/main.h> #include <glibmm/i18n.h> #include "inkscape.h" #include "desktop.h" -#include "document.h" #include "document-undo.h" #include "layer-manager.h" #include "message-stack.h" -#include "sp-object.h" -#include "sp-item.h" -#include "verbs.h" -#include "selection.h" #include "selection-chemistry.h" -#include "ui/icon-names.h" -#include "ui/widget/imagetoggler.h" -#include "live_effects/parameter/parameter.h" -#include <cmath> //#include "event-context.h" diff --git a/src/ui/dialog/lpe-powerstroke-properties.cpp b/src/ui/dialog/lpe-powerstroke-properties.cpp index a6dcce907..d5b3bb30d 100644 --- a/src/ui/dialog/lpe-powerstroke-properties.cpp +++ b/src/ui/dialog/lpe-powerstroke-properties.cpp @@ -14,29 +14,18 @@ */ #ifdef HAVE_CONFIG_H -# include <config.h> +#include "config.h" #endif #include "lpe-powerstroke-properties.h" #include <boost/lexical_cast.hpp> -#include <gtkmm/stock.h> -#include <glibmm/main.h> #include <glibmm/i18n.h> #include "inkscape.h" #include "desktop.h" -#include "document.h" #include "document-undo.h" #include "layer-manager.h" -#include "message-stack.h" -#include "sp-object.h" -#include "sp-item.h" -#include "verbs.h" -#include "selection.h" #include "selection-chemistry.h" -#include "ui/icon-names.h" -#include "ui/widget/imagetoggler.h" -#include "live_effects/parameter/parameter.h" //#include "event-context.h" namespace Inkscape { diff --git a/src/ui/dialog/memory.cpp b/src/ui/dialog/memory.cpp index c0bc884fa..f08089774 100644 --- a/src/ui/dialog/memory.cpp +++ b/src/ui/dialog/memory.cpp @@ -11,12 +11,13 @@ */ #ifdef HAVE_CONFIG_H -# include <config.h> +#include "config.h" #endif #include "ui/dialog/memory.h" -#include <glibmm/main.h> #include <glibmm/i18n.h> +#include <glibmm/main.h> + #include <gtkmm/liststore.h> #include <gtkmm/treeview.h> diff --git a/src/ui/dialog/messages.cpp b/src/ui/dialog/messages.cpp index df02215fe..3a8e7338d 100644 --- a/src/ui/dialog/messages.cpp +++ b/src/ui/dialog/messages.cpp @@ -11,7 +11,7 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ #ifdef HAVE_CONFIG_H -# include <config.h> +#include "config.h" #endif #include "messages.h" diff --git a/src/ui/dialog/new-from-template.cpp b/src/ui/dialog/new-from-template.cpp index 74ec7111e..2b33fd54d 100644 --- a/src/ui/dialog/new-from-template.cpp +++ b/src/ui/dialog/new-from-template.cpp @@ -9,14 +9,13 @@ */ #if HAVE_CONFIG_H - #include "config.h" +#include "config.h" #endif #include "new-from-template.h" #include "file.h" #include <gtkmm/alignment.h> -#include <glibmm/i18n.h> namespace Inkscape { @@ -31,20 +30,12 @@ NewFromTemplate::NewFromTemplate() _main_widget = new TemplateLoadTab(this); -#if WITH_GTKMM_3_0 get_content_area()->pack_start(*_main_widget); -#else - get_vbox()->pack_start(*_main_widget); -#endif Gtk::Alignment *align; align = Gtk::manage(new Gtk::Alignment(Gtk::ALIGN_END, Gtk::ALIGN_CENTER, 0.0, 0.0)); -#if WITH_GTKMM_3_0 get_content_area()->pack_end(*align, Gtk::PACK_SHRINK); -#else - get_vbox()->pack_end(*align, Gtk::PACK_SHRINK); -#endif align->set_padding(0, 0, 0, 15); align->add(_create_template_button); diff --git a/src/ui/dialog/object-attributes.cpp b/src/ui/dialog/object-attributes.cpp index 1bc570f43..72520d3d0 100644 --- a/src/ui/dialog/object-attributes.cpp +++ b/src/ui/dialog/object-attributes.cpp @@ -23,15 +23,12 @@ #include "ui/dialog/dialog-manager.h" #include "desktop.h" -#include "macros.h" #include "sp-anchor.h" #include "sp-image.h" #include "verbs.h" -#include "xml/repr.h" #include "ui/dialog/object-attributes.h" #include "widgets/sp-attribute-widget.h" #include "inkscape.h" -#include "selection.h" #include <glibmm/i18n.h> namespace Inkscape { diff --git a/src/ui/dialog/object-properties.cpp b/src/ui/dialog/object-properties.cpp index be46129c4..191216eea 100644 --- a/src/ui/dialog/object-properties.cpp +++ b/src/ui/dialog/object-properties.cpp @@ -33,19 +33,11 @@ #include "document-undo.h" #include "verbs.h" #include "inkscape.h" -#include "selection.h" #include "desktop.h" -#include "sp-item.h" #include "sp-image.h" -#include "xml/repr.h" #include <glibmm/i18n.h> -#if WITH_GTKMM_3_0 -# include <gtkmm/grid.h> -#else -# include <gtkmm/table.h> -#endif - +#include <gtkmm/grid.h> namespace Inkscape { namespace UI { @@ -106,16 +98,9 @@ void ObjectProperties::_init() Gtk::Box *contents = _getContents(); contents->set_spacing(0); -#if WITH_GTKMM_3_0 - Gtk::Grid *grid_top = Gtk::manage(new Gtk::Grid()); + auto grid_top = Gtk::manage(new Gtk::Grid()); grid_top->set_row_spacing(4); grid_top->set_column_spacing(0); -#else - Gtk::Table *grid_top = Gtk::manage(new Gtk::Table(4, 4)); - grid_top->set_row_spacings(4); - grid_top->set_col_spacings(0); -#endif - grid_top->set_border_width(4); contents->pack_start(*grid_top, false, false, 0); @@ -124,29 +109,14 @@ void ObjectProperties::_init() /* Create the label for the object id */ _label_id.set_label(_label_id.get_label() + " "); _label_id.set_alignment(1, 0.5); - -#if WITH_GTKMM_3_0 _label_id.set_valign(Gtk::ALIGN_CENTER); grid_top->attach(_label_id, 0, 0, 1, 1); -#else - grid_top->attach(_label_id, 0, 1, 0, 1, - Gtk::SHRINK | Gtk::FILL, - Gtk::AttachOptions(), 0, 0 ); -#endif - /* Create the entry box for the object id */ _entry_id.set_tooltip_text(_("The id= attribute (only letters, digits, and the characters .-_: allowed)")); _entry_id.set_max_length(64); - -#if WITH_GTKMM_3_0 _entry_id.set_valign(Gtk::ALIGN_CENTER); grid_top->attach(_entry_id, 1, 0, 1, 1); -#else - grid_top->attach(_entry_id, 1, 2, 0, 1, - Gtk::EXPAND | Gtk::FILL, - Gtk::AttachOptions(), 0, 0 ); -#endif _label_id.set_mnemonic_widget(_entry_id); @@ -160,29 +130,16 @@ void ObjectProperties::_init() _label_label.set_label(_label_label.get_label() + " "); _label_label.set_alignment(1, 0.5); -#if WITH_GTKMM_3_0 _label_label.set_valign(Gtk::ALIGN_CENTER); grid_top->attach(_label_label, 0, 1, 1, 1); -#else - grid_top->attach(_label_label, 0, 1, 1, 2, - Gtk::SHRINK | Gtk::FILL, - Gtk::AttachOptions(), 0, 0 ); -#endif - /* Create the entry box for the object label */ _entry_label.set_tooltip_text(_("A freeform label for the object")); _entry_label.set_max_length(256); -#if WITH_GTKMM_3_0 _entry_label.set_hexpand(); _entry_label.set_valign(Gtk::ALIGN_CENTER); grid_top->attach(_entry_label, 1, 1, 1, 1); -#else - grid_top->attach(_entry_label, 1, 2, 1, 2, - Gtk::EXPAND | Gtk::FILL, - Gtk::AttachOptions(), 0, 0 ); -#endif _label_label.set_mnemonic_widget(_entry_label); @@ -194,28 +151,16 @@ void ObjectProperties::_init() _label_title.set_label(_label_title.get_label() + " "); _label_title.set_alignment (1, 0.5); -#if WITH_GTKMM_3_0 _label_title.set_valign(Gtk::ALIGN_CENTER); grid_top->attach(_label_title, 0, 2, 1, 1); -#else - grid_top->attach(_label_title, 0, 1, 2, 3, - Gtk::SHRINK | Gtk::FILL, - Gtk::AttachOptions(), 0, 0 ); -#endif /* Create the entry box for the object title */ _entry_title.set_sensitive (FALSE); _entry_title.set_max_length (256); -#if WITH_GTKMM_3_0 _entry_title.set_hexpand(); _entry_title.set_valign(Gtk::ALIGN_CENTER); grid_top->attach(_entry_title, 1, 2, 1, 1); -#else - grid_top->attach(_entry_title, 1, 2, 2, 3, - Gtk::EXPAND | Gtk::FILL, - Gtk::AttachOptions(), 0, 0 ); -#endif _label_title.set_mnemonic_widget(_entry_title); // pressing enter in the label field is the same as clicking Set: @@ -244,14 +189,8 @@ void ObjectProperties::_init() _label_image_rendering.set_label(_label_image_rendering.get_label() + " "); _label_image_rendering.set_alignment(1, 0.5); -#if WITH_GTKMM_3_0 _label_image_rendering.set_valign(Gtk::ALIGN_CENTER); grid_top->attach(_label_image_rendering, 0, 3, 1, 1); -#else - grid_top->attach(_label_image_rendering, 0, 1, 3, 4, - Gtk::SHRINK | Gtk::FILL, - Gtk::AttachOptions(), 0, 0 ); -#endif /* Create the combo box text for the 'image-rendering' property */ _combo_image_rendering.append( "auto" ); @@ -259,14 +198,8 @@ void ObjectProperties::_init() _combo_image_rendering.append( "optimizeSpeed" ); _combo_image_rendering.set_tooltip_text(_("The 'image-rendering' property can influence how a bitmap is up-scaled:\n\t'auto' no preference;\n\t'optimizeQuality' smooth;\n\t'optimizeSpeed' blocky.\nNote that this behaviour is not defined in the SVG 1.1 specification and not all browsers follow this interpretation.")); -#if WITH_GTKMM_3_0 _combo_image_rendering.set_valign(Gtk::ALIGN_CENTER); grid_top->attach(_combo_image_rendering, 1, 3, 1, 1); -#else - grid_top->attach(_combo_image_rendering, 1, 2, 3, 4, - Gtk::EXPAND | Gtk::FILL, - Gtk::AttachOptions(), 0, 0 ); -#endif _label_image_rendering.set_mnemonic_widget(_combo_image_rendering); @@ -278,60 +211,36 @@ void ObjectProperties::_init() Gtk::HBox *hb_checkboxes = Gtk::manage(new Gtk::HBox()); contents->pack_start(*hb_checkboxes, FALSE, FALSE, 0); -#if WITH_GTKMM_3_0 - Gtk::Grid *grid_cb = Gtk::manage(new Gtk::Grid()); + auto grid_cb = Gtk::manage(new Gtk::Grid()); grid_cb->set_row_homogeneous(); grid_cb->set_column_homogeneous(true); -#else - Gtk::Table *grid_cb = Gtk::manage(new Gtk::Table(1, 2, true)); -#endif grid_cb->set_border_width(4); hb_checkboxes->pack_start(*grid_cb, true, true, 0); /* Hide */ _cb_hide.set_tooltip_text (_("Check to make the object invisible")); - -#if WITH_GTKMM_3_0 _cb_hide.set_hexpand(); _cb_hide.set_valign(Gtk::ALIGN_CENTER); grid_cb->attach(_cb_hide, 0, 0, 1, 1); -#else - grid_cb->attach(_cb_hide, 0, 1, 0, 1, - Gtk::EXPAND | Gtk::FILL, - Gtk::AttachOptions(), 0, 0 ); -#endif _cb_hide.signal_toggled().connect(sigc::mem_fun(this, &ObjectProperties::_hiddenToggled)); /* Lock */ // TRANSLATORS: "Lock" is a verb here _cb_lock.set_tooltip_text(_("Check to make the object insensitive (not selectable by mouse)")); - -#if WITH_GTKMM_3_0 _cb_lock.set_hexpand(); _cb_lock.set_valign(Gtk::ALIGN_CENTER); grid_cb->attach(_cb_lock, 1, 0, 1, 1); -#else - grid_cb->attach(_cb_lock, 1, 2, 0, 1, - Gtk::EXPAND | Gtk::FILL, - Gtk::AttachOptions(), 0, 0 ); -#endif _cb_lock.signal_toggled().connect(sigc::mem_fun(this, &ObjectProperties::_sensitivityToggled)); /* Button for setting the object's id, label, title and description. */ Gtk::Button *btn_set = Gtk::manage(new Gtk::Button(_("_Set"), 1)); -#if WITH_GTKMM_3_0 btn_set->set_hexpand(); btn_set->set_valign(Gtk::ALIGN_CENTER); grid_cb->attach(*btn_set, 2, 0, 1, 1); -#else - grid_cb->attach(*btn_set, 2, 3, 0, 1, - Gtk::EXPAND | Gtk::FILL, - Gtk::AttachOptions(), 0, 0 ); -#endif btn_set->signal_clicked().connect(sigc::mem_fun(this, &ObjectProperties::_labelChanged)); diff --git a/src/ui/dialog/object-properties.h b/src/ui/dialog/object-properties.h index dc28c0bad..8551d5fca 100644 --- a/src/ui/dialog/object-properties.h +++ b/src/ui/dialog/object-properties.h @@ -50,11 +50,7 @@ class SPDesktop; class SPItem; namespace Gtk { -#if WITH_GTKMM_3_0 class Grid; -#else -class Table; -#endif } namespace Inkscape { diff --git a/src/ui/dialog/objects.cpp b/src/ui/dialog/objects.cpp index 27694a9ac..09ffc9c4c 100644 --- a/src/ui/dialog/objects.cpp +++ b/src/ui/dialog/objects.cpp @@ -10,17 +10,14 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ #ifdef HAVE_CONFIG_H -# include <config.h> +#include "config.h" #endif #include "objects.h" -#include <gtkmm/widget.h> #include <gtkmm/icontheme.h> +#include <gtkmm/stock.h> #include <gtkmm/imagemenuitem.h> #include <gtkmm/separatormenuitem.h> -#include <gtkmm/stock.h> - -#include <glibmm/i18n.h> #include <glibmm/main.h> #include "desktop.h" @@ -34,12 +31,8 @@ #include "helper/action.h" #include "inkscape.h" #include "layer-manager.h" -#include "preferences.h" -#include "selection.h" #include "sp-clippath.h" #include "sp-mask.h" -#include "sp-item.h" -#include "sp-object.h" #include "sp-root.h" #include "sp-shape.h" #include "style.h" @@ -52,13 +45,10 @@ #include "ui/widget/clipmaskicon.h" #include "ui/widget/highlight-picker.h" #include "ui/tools/node-tool.h" -#include "ui/tools/tool-base.h" #include "verbs.h" #include "ui/widget/color-notebook.h" #include "widgets/icon.h" -#include "xml/node.h" #include "xml/node-observer.h" -#include "xml/repr.h" //#define DUMP_LAYERS 1 @@ -340,12 +330,11 @@ void ObjectsPanel::_objectsChanged(SPObject */*obj*/) void ObjectsPanel::_addObject(SPObject* obj, Gtk::TreeModel::Row* parentRow) { if ( _desktop && obj ) { - for ( SPObject *child = obj->children; child != NULL; child = child->next) { - - if (SP_IS_ITEM(child)) + for(auto& child: obj->children) { + if (SP_IS_ITEM(&child)) { - SPItem * item = SP_ITEM(child); - SPGroup * group = SP_IS_GROUP(child) ? SP_GROUP(child) : 0; + SPItem * item = SP_ITEM(&child); + SPGroup * group = SP_IS_GROUP(&child) ? SP_GROUP(&child) : 0; //Add the item to the tree and set the column information Gtk::TreeModel::iterator iter = parentRow ? _store->prepend(parentRow->children()) : _store->prepend(); @@ -372,14 +361,14 @@ void ObjectsPanel::_addObject(SPObject* obj, Gtk::TreeModel::Row* parentRow) } //Add an object watcher to the item - ObjectsPanel::ObjectWatcher *w = new ObjectsPanel::ObjectWatcher(this, child); - child->getRepr()->addObserver(*w); + ObjectsPanel::ObjectWatcher *w = new ObjectsPanel::ObjectWatcher(this, &child); + child.getRepr()->addObserver(*w); _objectWatchers.push_back(w); //If the item is a group, recursively add its children if (group) { - _addObject( child, &row ); + _addObject( &child, &row ); } } } @@ -399,9 +388,8 @@ void ObjectsPanel::_updateObject( SPObject *obj, bool recurse ) { //end mark if (recurse) { - for (SPObject * iter = obj->children; iter != NULL; iter = iter->next) - { - _updateObject(iter, recurse); + for (auto& iter: obj->children) { + _updateObject(&iter, recurse); } } } @@ -478,8 +466,8 @@ void ObjectsPanel::_objectsSelected( Selection *sel ) { _selectedConnection.block(); _tree.get_selection()->unselect_all(); SPItem *item = NULL; - std::vector<SPItem*> const items = sel->itemList(); - for(std::vector<SPItem*>::const_iterator i=items.begin(); i!=items.end(); ++i){ + auto items = sel->items(); + for(auto i=items.begin(); i!=items.end(); ++i){ item = *i; if (setOpacity) { @@ -511,28 +499,27 @@ void ObjectsPanel::_setCompositingValues(SPItem *item) _blurConnection.block(); //Set the opacity -#if WITH_GTKMM_3_0 _opacity_adjustment->set_value((item->style->opacity.set ? SP_SCALE24_TO_FLOAT(item->style->opacity.value) : 1) * _opacity_adjustment->get_upper()); -#else - _opacity_adjustment.set_value((item->style->opacity.set ? SP_SCALE24_TO_FLOAT(item->style->opacity.value) : 1) * _opacity_adjustment.get_upper()); -#endif SPFeBlend *spblend = NULL; SPGaussianBlur *spblur = NULL; if (item->style->getFilter()) { - for(SPObject *primitive_obj = item->style->getFilter()->children; primitive_obj && SP_IS_FILTER_PRIMITIVE(primitive_obj); primitive_obj = primitive_obj->next) { - if(SP_IS_FEBLEND(primitive_obj) && !spblend) { - //Get the blend mode - spblend = SP_FEBLEND(primitive_obj); - } - - if(SP_IS_GAUSSIANBLUR(primitive_obj) && !spblur) { - //Get the blur value - spblur = SP_GAUSSIANBLUR(primitive_obj); - } + for (auto& primitive_obj: item->style->getFilter()->children) { + if (!SP_IS_FILTER_PRIMITIVE(&primitive_obj)) { + break; } + if(SP_IS_FEBLEND(&primitive_obj) && !spblend) { + //Get the blend mode + spblend = SP_FEBLEND(&primitive_obj); + } + + if(SP_IS_GAUSSIANBLUR(&primitive_obj) && !spblur) { + //Get the blur value + spblur = SP_GAUSSIANBLUR(&primitive_obj); + } + } } - + //Set the blend mode _fe_cb.set_blend_mode(spblend ? spblend->blend_mode : Inkscape::Filters::BLEND_NORMAL); @@ -1292,9 +1279,9 @@ bool ObjectsPanel::_executeAction() break; case BUTTON_COLLAPSE_ALL: { - for (SPObject* obj = _document->getRoot()->firstChild(); obj != NULL; obj = obj->next) { - if (SP_IS_GROUP(obj)) { - _setCollapsed(SP_GROUP(obj)); + for (auto& obj: _document->getRoot()->children) { + if (SP_IS_GROUP(&obj)) { + _setCollapsed(SP_GROUP(&obj)); } } _objectsChanged(_document->getRoot()); @@ -1404,9 +1391,10 @@ void ObjectsPanel::_setCollapsed(SPGroup * group) { group->setExpanded(false); group->updateRepr(SP_OBJECT_WRITE_NO_CHILDREN | SP_OBJECT_WRITE_EXT); - for (SPObject *iter = group->children; iter != NULL; iter = iter->next) - { - if (SP_IS_GROUP(iter)) _setCollapsed(SP_GROUP(iter)); + for (auto& iter: group->children) { + if (SP_IS_GROUP(&iter)) { + _setCollapsed(SP_GROUP(&iter)); + } } } @@ -1481,11 +1469,7 @@ void ObjectsPanel::_opacityChangedIter(const Gtk::TreeIter& iter) if (item) { item->style->opacity.set = TRUE; -#if WITH_GTKMM_3_0 item->style->opacity.value = SP_SCALE24_FROM_FLOAT(_opacity_adjustment->get_value() / _opacity_adjustment->get_upper()); -#else - item->style->opacity.value = SP_SCALE24_FROM_FLOAT(_opacity_adjustment.get_value() / _opacity_adjustment.get_upper()); -#endif item->updateRepr(SP_OBJECT_WRITE_NO_CHILDREN | SP_OBJECT_WRITE_EXT); } } @@ -1521,11 +1505,14 @@ void ObjectsPanel::_blendChangedIter(const Gtk::TreeIter& iter, Glib::ustring bl if (blendmode != "normal") { gdouble radius = 0; if (item->style->getFilter()) { - for (SPObject *primitive = item->style->getFilter()->children; primitive && SP_IS_FILTER_PRIMITIVE(primitive); primitive = primitive->next) { - if (SP_IS_GAUSSIANBLUR(primitive)) { + for (auto& primitive: item->style->getFilter()->children) { + if (!SP_IS_FILTER_PRIMITIVE(&primitive)) { + break; + } + if (SP_IS_GAUSSIANBLUR(&primitive)) { Geom::OptRect bbox = item->bounds(SPItem::GEOMETRIC_BBOX); if (bbox) { - radius = SP_GAUSSIANBLUR(primitive)->stdDeviation.getNumber(); + radius = SP_GAUSSIANBLUR(&primitive)->stdDeviation.getNumber(); } } } @@ -1533,13 +1520,16 @@ void ObjectsPanel::_blendChangedIter(const Gtk::TreeIter& iter, Glib::ustring bl SPFilter *filter = new_filter_simple_from_item(_document, item, blendmode.c_str(), radius); sp_style_set_property_url(item, "filter", filter, false); } else { - for (SPObject *primitive = item->style->getFilter()->children; primitive && SP_IS_FILTER_PRIMITIVE(primitive); primitive = primitive->next) { - if (SP_IS_FEBLEND(primitive)) { - primitive->deleteObject(); + for (auto& primitive: item->style->getFilter()->children) { + if (!SP_IS_FILTER_PRIMITIVE(&primitive)) { + break; + } + if (SP_IS_FEBLEND(&primitive)) { + primitive.deleteObject(); break; } } - if (!item->style->getFilter()->children) { + if (!item->style->getFilter()->firstChild()) { remove_filter(item, false); } } @@ -1590,13 +1580,16 @@ void ObjectsPanel::_blurChangedIter(const Gtk::TreeIter& iter, double blur) SPFilter *filter = modify_filter_gaussian_blur_from_item(_document, item, radius); sp_style_set_property_url(item, "filter", filter, false); } else if (item->style->filter.set && item->style->getFilter()) { - for (SPObject *primitive = item->style->getFilter()->children; primitive && SP_IS_FILTER_PRIMITIVE(primitive); primitive = primitive->next) { - if (SP_IS_GAUSSIANBLUR(primitive)) { - primitive->deleteObject(); + for (auto& primitive: item->style->getFilter()->children) { + if (!SP_IS_FILTER_PRIMITIVE(&primitive)) { + break; + } + if (SP_IS_GAUSSIANBLUR(&primitive)) { + primitive.deleteObject(); break; } } - if (!item->style->getFilter()->children) { + if (!item->style->getFilter()->firstChild()) { remove_filter(item, false); } } @@ -1628,11 +1621,7 @@ ObjectsPanel::ObjectsPanel() : _opacity_vbox(false, 0), _opacity_label(_("Opacity:")), _opacity_label_unit(_("%")), -#if WITH_GTKMM_3_0 _opacity_adjustment(Gtk::Adjustment::create(100.0, 0.0, 100.0, 1.0, 1.0, 0.0)), -#else - _opacity_adjustment(100.0, 0.0, 100.0, 1.0, 1.0, 0.0), -#endif _opacity_hscale(_opacity_adjustment), _opacity_spin_button(_opacity_adjustment, 0.01, 1), _fe_cb(UI::Widget::SimpleFilterModifier::BLEND), @@ -1762,12 +1751,8 @@ ObjectsPanel::ObjectsPanel() : _scroller.set_policy( Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC ); _scroller.set_shadow_type(Gtk::SHADOW_IN); Gtk::Requisition sreq; -#if WITH_GTKMM_3_0 Gtk::Requisition sreq_natural; _scroller.get_preferred_size(sreq_natural, sreq); -#else - sreq = _scroller.size_request(); -#endif int minHeight = 70; if (sreq.height < minHeight) { // Set a min height to see the layers when used with Ubuntu liboverlay-scrollbar @@ -1800,13 +1785,8 @@ ObjectsPanel::ObjectsPanel() : _opacity_hbox.pack_start(_opacity_spin_button, false, false, 0); _opacity_hbox.pack_start(_opacity_label_unit, false, false, 3); _opacity_hscale.set_draw_value(false); -#if WITH_GTKMM_3_0 _opacityConnection = _opacity_adjustment->signal_value_changed().connect(sigc::mem_fun(*this, &ObjectsPanel::_opacityValueChanged)); _opacity_label.set_mnemonic_widget(_opacity_hscale); -#else - _opacityConnection = _opacity_adjustment.signal_value_changed().connect(sigc::mem_fun(*this, &ObjectsPanel::_opacityValueChanged)); - _opacity_label.set_mnemonic_widget(_opacity_hscale); -#endif //Keep the labels aligned GtkSizeGroup *labels = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); diff --git a/src/ui/dialog/objects.h b/src/ui/dialog/objects.h index 9b9a6025a..018f9191f 100644 --- a/src/ui/dialog/objects.h +++ b/src/ui/dialog/objects.h @@ -134,15 +134,9 @@ private: Gtk::TreeView _tree; Gtk::CellRendererText *_text_renderer; Gtk::TreeView::Column *_name_column; -#if WITH_GTKMM_3_0 Gtk::Box _buttonsRow; Gtk::Box _buttonsPrimary; Gtk::Box _buttonsSecondary; -#else - Gtk::HBox _buttonsRow; - Gtk::HBox _buttonsPrimary; - Gtk::HBox _buttonsSecondary; -#endif Gtk::ScrolledWindow _scroller; Gtk::Menu _popupMenu; Inkscape::UI::Widget::SpinButton _spinBtn; @@ -161,11 +155,7 @@ private: Gtk::HBox _opacity_hbox; Gtk::Label _opacity_label; Gtk::Label _opacity_label_unit; -#if WITH_GTKMM_3_0 Glib::RefPtr<Gtk::Adjustment> _opacity_adjustment; -#else - Gtk::Adjustment _opacity_adjustment; -#endif Gtk::HScale _opacity_hscale; Inkscape::UI::Widget::SpinButton _opacity_spin_button; diff --git a/src/ui/dialog/ocaldialogs.cpp b/src/ui/dialog/ocaldialogs.cpp index f2ee79d06..878b68d55 100644 --- a/src/ui/dialog/ocaldialogs.cpp +++ b/src/ui/dialog/ocaldialogs.cpp @@ -18,16 +18,10 @@ #include "ocaldialogs.h" -#include <stdio.h> // rename() -#include <unistd.h> // close() -#include <errno.h> // errno -#include <string.h> // strerror() - #include "path-prefix.h" #include "filedialogimpl-gtkmm.h" #include "ui/interface.h" #include "inkgc/gc-core.h" -#include "ui/dialog-events.h" #include "io/sys.h" #include "preferences.h" @@ -37,12 +31,13 @@ #include <gdkmm/general.h> #include <libxml/tree.h> +#include <glibmm/i18n.h> +#include <glibmm/miscutils.h> +#include <glibmm/markup.h> #include <glibmm/convert.h> #include <glibmm/fileutils.h> -#include <glibmm/i18n.h> #include <glibmm/main.h> -#include <glibmm/markup.h> -#include <glibmm/miscutils.h> + #include "ui/icon-names.h" namespace Inkscape @@ -316,27 +311,10 @@ LoadingBox::LoadingBox() : Gtk::EventBox() draw_spinner = false; spinner_step = 0; -#if WITH_GTKMM_3_0 signal_draw().connect(sigc::mem_fun(*this, &LoadingBox::_on_draw), false); -#else - signal_expose_event().connect(sigc::mem_fun(*this, &LoadingBox::_on_expose_event), false); -#endif } -#if !WITH_GTKMM_3_0 -bool LoadingBox::_on_expose_event(GdkEventExpose* /*event*/) -{ - Cairo::RefPtr<Cairo::Context> cr = get_window()->create_cairo_context(); - - return _on_draw(cr); -} -#endif - -bool LoadingBox::_on_draw(const Cairo::RefPtr<Cairo::Context> & -#if WITH_GTKMM_3_0 -cr -#endif -) +bool LoadingBox::_on_draw(const Cairo::RefPtr<Cairo::Context> &cr) { // Draw shadow int x = get_allocation().get_x(); @@ -344,27 +322,14 @@ cr int width = get_allocation().get_width(); int height = get_allocation().get_height(); -#if WITH_GTKMM_3_0 get_style_context()->render_frame(cr, x, y, width, height); -#else - get_style()->paint_shadow(get_window(), get_state(), Gtk::SHADOW_IN, - Gdk::Rectangle(x, y, width, height), - *this, Glib::ustring("viewport"), x, y, width, height); -#endif if (draw_spinner) { int spinner_size = 16; int spinner_x = x + (width - spinner_size) / 2; int spinner_y = y + (height - spinner_size) / 2; -#if WITH_GTKMM_3_0 get_style_context()->render_activity(cr, spinner_x, spinner_y, spinner_size, spinner_size); -#else - gtk_paint_spinner(gtk_widget_get_style(GTK_WIDGET(gobj())), - gtk_widget_get_window(GTK_WIDGET(gobj())), - gtk_widget_get_state(GTK_WIDGET(gobj())), NULL, GTK_WIDGET(gobj()), - NULL, spinner_step, spinner_x, spinner_y, spinner_size, spinner_size); -#endif } return false; @@ -434,11 +399,7 @@ PreviewWidget::PreviewWidget() : Gtk::VBox(false, 12) box_loading->set_size_request(90, 90); set_border_width(12); -#if WITH_GTKMM_3_0 signal_draw().connect(sigc::mem_fun(*this, &PreviewWidget::_on_draw), false); -#else - signal_expose_event().connect(sigc::mem_fun(*this, &PreviewWidget::_on_expose_event), false); -#endif clear(); } @@ -482,15 +443,6 @@ void PreviewWidget::clear() image->hide(); } -#if !WITH_GTKMM_3_0 -bool PreviewWidget::_on_expose_event(GdkEventExpose* /*event*/) -{ - Cairo::RefPtr<Cairo::Context> cr = get_window()->create_cairo_context(); - - return _on_draw(cr); -} -#endif - bool PreviewWidget::_on_draw(const Cairo::RefPtr<Cairo::Context>& cr) { // Draw background @@ -499,16 +451,10 @@ bool PreviewWidget::_on_draw(const Cairo::RefPtr<Cairo::Context>& cr) int width = get_allocation().get_width(); int height = get_allocation().get_height(); -#if WITH_GTKMM_3_0 Gdk::RGBA background_fill; get_style_context()->lookup_color("base_color", background_fill); cr->rectangle(x, y, width, height); Gdk::Cairo::set_source_rgba(cr, background_fill); -#else - Gdk::Color background_fill = get_style()->get_base(get_state()); - cr->rectangle(x, y, width, height); - Gdk::Cairo::set_source_color(cr, background_fill); -#endif cr->fill(); @@ -573,57 +519,12 @@ void StatusWidget::end_process() clear(); } -#if !GTK_CHECK_VERSION(3,0,0) -SearchEntry::SearchEntry() : Gtk::Entry() -{ - signal_changed().connect(sigc::mem_fun(*this, &SearchEntry::_on_changed)); - signal_icon_press().connect(sigc::mem_fun(*this, &SearchEntry::_on_icon_pressed)); - - set_icon_from_icon_name(INKSCAPE_ICON("edit-find"), Gtk::ENTRY_ICON_PRIMARY); - gtk_entry_set_icon_from_icon_name(gobj(), GTK_ENTRY_ICON_SECONDARY, NULL); -} - -void SearchEntry::_on_icon_pressed(Gtk::EntryIconPosition icon_position, const GdkEventButton* /*event*/) -{ - if (icon_position == Gtk::ENTRY_ICON_SECONDARY) { - grab_focus(); - delete_text(0, -1); - } else if (icon_position == Gtk::ENTRY_ICON_PRIMARY) { - select_region(0, -1); - grab_focus(); - } -} - -void SearchEntry::_on_changed() -{ - if (get_text().empty()) { - gtk_entry_set_icon_from_icon_name(gobj(), GTK_ENTRY_ICON_SECONDARY, NULL); - } else { - set_icon_from_icon_name(INKSCAPE_ICON("edit-clear"), Gtk::ENTRY_ICON_SECONDARY); - } -} -#endif - - BaseBox::BaseBox() : Gtk::EventBox() { -#if WITH_GTKMM_3_0 signal_draw().connect(sigc::mem_fun(*this, &BaseBox::_on_draw), false); -#else - signal_expose_event().connect(sigc::mem_fun(*this, &BaseBox::_on_expose_event), false); -#endif set_visible_window(false); } -#if !WITH_GTKMM_3_0 -bool BaseBox::_on_expose_event(GdkEventExpose* /*event*/) -{ - Cairo::RefPtr<Cairo::Context> cr = get_window()->create_cairo_context(); - - return _on_draw(cr); -} -#endif - bool BaseBox::_on_draw(const Cairo::RefPtr<Cairo::Context>& cr) { // Draw background and shadow @@ -632,23 +533,12 @@ bool BaseBox::_on_draw(const Cairo::RefPtr<Cairo::Context>& cr) int width = get_allocation().get_width(); int height = get_allocation().get_height(); -#if WITH_GTKMM_3_0 Gdk::RGBA background_fill; get_style_context()->lookup_color("base_color", background_fill); cr->rectangle(x, y, width, height); Gdk::Cairo::set_source_rgba(cr, background_fill); cr->fill(); get_style_context()->render_frame(cr, x, y, width, height); -#else - Gdk::Color background_fill = get_style()->get_base(get_state()); - cr->rectangle(x, y, width, height); - Gdk::Cairo::set_source_color(cr, background_fill); - cr->fill(); - - get_style()->paint_shadow(get_window(), get_state(), Gtk::SHADOW_IN, - Gdk::Rectangle(x, y, width, height), - *this, Glib::ustring("viewport"), x, y, width, height); -#endif return false; } @@ -665,23 +555,10 @@ LogoArea::LogoArea() : Gtk::EventBox() draw_logo = false; } -#if WITH_GTKMM_3_0 signal_draw().connect(sigc::mem_fun(*this, &LogoArea::_on_draw)); -#else - signal_expose_event().connect(sigc::mem_fun(*this, &LogoArea::_on_expose_event)); -#endif set_visible_window(false); } -#if !WITH_GTKMM_3_0 -bool LogoArea::_on_expose_event(GdkEventExpose* /*event*/) -{ - Cairo::RefPtr<Cairo::Context> cr = get_window()->create_cairo_context(); - - return _on_draw(cr); -} -#endif - bool LogoArea::_on_draw(const Cairo::RefPtr<Cairo::Context>& cr) { if (draw_logo) { @@ -692,16 +569,9 @@ bool LogoArea::_on_draw(const Cairo::RefPtr<Cairo::Context>& cr) int x_logo = x + (width - 220) / 2; int y_logo = y + (height - 76) / 2; - // Draw logo, we mask [read fill] it with the mid colour from the - // user's GTK theme -#if WITH_GTKMM_3_0 - // For GTK+ 3, use grey + // Draw logo, we mask [read fill] it with grey Gdk::RGBA logo_fill("grey"); Gdk::Cairo::set_source_rgba(cr, logo_fill); -#else - Gdk::Color logo_fill = get_style()->get_mid(get_state()); - Gdk::Cairo::set_source_color(cr, logo_fill); -#endif cr->mask(logo_mask, x_logo, y_logo); } @@ -1179,16 +1049,9 @@ void ImportDialog::update_label_no_search_results() Glib::ustring msg_two = _("Please make sure all keywords are spelled correctly," " or try again with different keywords."); -#if WITH_GTKMM_3_0 - Glib::ustring markup = Glib::ustring::compose( + auto markup = Glib::ustring::compose( "<span size=\"large\">%1</span>\n<span>%2</span>", msg_one, msg_two); -#else - Gdk::Color grey = entry_search->get_style()->get_text_aa(entry_search->get_state()); - Glib::ustring markup = Glib::ustring::compose( - "<span size=\"large\">%1</span>\n<span color=\"%2\">%3</span>", - msg_one, grey.to_string(), msg_two); -#endif label_not_found->set_markup(markup); } @@ -1208,33 +1071,17 @@ ImportDialog::ImportDialog(Gtk::Window& parent_window, FileDialogType file_types dialogType = file_types; // Creation - Gtk::VBox *vbox = new Gtk::VBox(false, 0); - -#if WITH_GTKMM_3_0 - Gtk::ButtonBox *hbuttonbox_bottom = new Gtk::ButtonBox(); -#else - Gtk::HButtonBox *hbuttonbox_bottom = new Gtk::HButtonBox(); -#endif - - Gtk::HBox *hbox_bottom = new Gtk::HBox(false, 12); + auto vbox = new Gtk::VBox(false, 0); + auto hbuttonbox_bottom = new Gtk::ButtonBox(); + auto hbox_bottom = new Gtk::HBox(false, 12); BaseBox *basebox_logo = new BaseBox(); BaseBox *basebox_no_search_results = new BaseBox(); label_not_found = new Gtk::Label(); label_description = new Gtk::Label(); - -#if GTK_CHECK_VERSION(3,0,0) entry_search = new Gtk::SearchEntry(); -#else - entry_search = new SearchEntry(); -#endif - button_search = new Gtk::Button(_("Search")); -#if WITH_GTKMM_3_0 - Gtk::ButtonBox* hbuttonbox_search = new Gtk::ButtonBox(); -#else - Gtk::HButtonBox* hbuttonbox_search = new Gtk::HButtonBox(); -#endif + auto hbuttonbox_search = new Gtk::ButtonBox(); Gtk::ScrolledWindow* scrolledwindow_preview = new Gtk::ScrolledWindow(); preview_files = new PreviewWidget(); diff --git a/src/ui/dialog/ocaldialogs.h b/src/ui/dialog/ocaldialogs.h index 9de24d821..db3c60786 100644 --- a/src/ui/dialog/ocaldialogs.h +++ b/src/ui/dialog/ocaldialogs.h @@ -17,19 +17,16 @@ # include <config.h> #endif -//Gtk includes +// Gtkmm includes #include <gtkmm/box.h> #include <gtkmm/eventbox.h> #include <gtkmm/listviewtext.h> #include <gtkmm/scrolledwindow.h> +#include <gtkmm/searchentry.h> #include <gtkmm/window.h> #include <cairomm/refptr.h> -#if GTK_CHECK_VERSION(3,0,0) -# include <gtkmm/searchentry.h> -#endif - #include <giomm/file.h> //Inkscape includes @@ -283,10 +280,6 @@ private: sigc::connection timeout; bool draw_spinner; -#if !WITH_GTKMM_3_0 - bool _on_expose_event(GdkEventExpose* event); -#endif - bool _on_draw(const Cairo::RefPtr<Cairo::Context>& cr); bool on_timeout(); }; @@ -310,10 +303,6 @@ private: WrapLabel* label_description; WrapLabel* label_time; -#if !WITH_GTKMM_3_0 - bool _on_expose_event(GdkEventExpose* event); -#endif - bool _on_draw(const Cairo::RefPtr<Cairo::Context>& cr); }; @@ -336,21 +325,6 @@ public: Gtk::Label* label; }; -#if !GTK_CHECK_VERSION(3,0,0) -/** - * A Gtk::Entry with search & clear icons - */ -class SearchEntry : public Gtk::Entry -{ -public: - SearchEntry(); - -private: - void _on_icon_pressed(Gtk::EntryIconPosition icon_position, const GdkEventButton* event); - void _on_changed(); -}; -#endif - /** * A box which paints an overlay of the OCAL logo */ @@ -359,9 +333,6 @@ class LogoArea : public Gtk::EventBox public: LogoArea(); private: -#if !WITH_GTKMM_3_0 - bool _on_expose_event(GdkEventExpose* event); -#endif bool _on_draw(const Cairo::RefPtr<Cairo::Context>& cr); bool draw_logo; Cairo::RefPtr<Cairo::ImageSurface> logo_mask; @@ -375,9 +346,6 @@ class BaseBox : public Gtk::EventBox public: BaseBox(); private: -#if !WITH_GTKMM_3_0 - bool _on_expose_event(GdkEventExpose* event); -#endif bool _on_draw(const Cairo::RefPtr<Cairo::Context>& cr); }; @@ -459,12 +427,7 @@ protected: private: Glib::ustring filename_image; Glib::ustring filename_thumbnail; - -#if GTK_CHECK_VERSION(3,0,0) Gtk::SearchEntry *entry_search; -#else - SearchEntry *entry_search; -#endif LogoArea *drawingarea_logo; SearchResultList *list_results; diff --git a/src/ui/dialog/pixelartdialog.cpp b/src/ui/dialog/pixelartdialog.cpp index f557ff0fc..b838b0842 100644 --- a/src/ui/dialog/pixelartdialog.cpp +++ b/src/ui/dialog/pixelartdialog.cpp @@ -31,7 +31,6 @@ #include <gtkmm/stock.h> #include <gtkmm/messagedialog.h> -#include <gtk/gtk.h> //for GTK_RESPONSE* types #include <glibmm/i18n.h> #include "ui/widget/spinbutton.h" @@ -41,18 +40,13 @@ #include "desktop-tracker.h" #include "message-stack.h" #include "selection.h" -#include "preferences.h" #include "sp-image.h" #include "display/cairo-utils.h" #include "libdepixelize/kopftracer2011.h" -#include <algorithm> #include "document.h" -#include "xml/repr.h" -#include "xml/document.h" #include "svg/svg.h" #include "svg/svg-color.h" -#include "color.h" #include "svg/css-ostringstream.h" #include "document-undo.h" @@ -372,8 +366,8 @@ void PixelArtDialogImpl::vectorize() return; } - std::vector<SPItem*> const items = desktop->selection->itemList(); - for(std::vector<SPItem*>::const_iterator i=items.begin(); i!=items.end();++i){ + auto items = desktop->selection->items(); + for(auto i=items.begin(); i!=items.end();++i){ if ( !SP_IS_IMAGE(*i) ) continue; diff --git a/src/ui/dialog/polar-arrange-tab.cpp b/src/ui/dialog/polar-arrange-tab.cpp index 5ec1285c1..c51881a96 100644 --- a/src/ui/dialog/polar-arrange-tab.cpp +++ b/src/ui/dialog/polar-arrange-tab.cpp @@ -17,10 +17,8 @@ #include "preferences.h" #include "inkscape.h" -#include "selection.h" #include "document.h" #include "document-undo.h" -#include "sp-item.h" #include "widgets/icon.h" #include "desktop.h" #include "sp-ellipse.h" @@ -33,11 +31,7 @@ namespace Dialog { PolarArrangeTab::PolarArrangeTab(ArrangeDialog *parent_) : parent(parent_), -#if WITH_GTKMM_3_0 parametersTable(), -#else - parametersTable(3, 3, false), -#endif centerY("", C_("Polar arrange tab", "Y coordinate of the center"), UNIT_TYPE_LINEAR), centerX("", C_("Polar arrange tab", "X coordinate of the center"), centerY), radiusY("", C_("Polar arrange tab", "Y coordinate of the radius"), UNIT_TYPE_LINEAR), @@ -81,11 +75,7 @@ PolarArrangeTab::PolarArrangeTab(ArrangeDialog *parent_) pack_start(arrangeOnParametersRadio, false, false); centerLabel.set_text(C_("Polar arrange tab", "Center X/Y:")); -#if WITH_GTKMM_3_0 parametersTable.attach(centerLabel, 0, 0, 1, 1); -#else - parametersTable.attach(centerLabel, 0, 1, 0, 1, Gtk::FILL); -#endif centerX.setDigits(2); centerX.setIncrements(0.2, 0); centerX.setRange(-10000, 10000); @@ -94,20 +84,11 @@ PolarArrangeTab::PolarArrangeTab(ArrangeDialog *parent_) centerY.setIncrements(0.2, 0); centerY.setRange(-10000, 10000); centerY.setValue(0, "px"); -#if WITH_GTKMM_3_0 parametersTable.attach(centerX, 1, 0, 1, 1); parametersTable.attach(centerY, 2, 0, 1, 1); -#else - parametersTable.attach(centerX, 1, 2, 0, 1, Gtk::FILL); - parametersTable.attach(centerY, 2, 3, 0, 1, Gtk::FILL); -#endif radiusLabel.set_text(C_("Polar arrange tab", "Radius X/Y:")); -#if WITH_GTKMM_3_0 parametersTable.attach(radiusLabel, 0, 1, 1, 1); -#else - parametersTable.attach(radiusLabel, 0, 1, 1, 2, Gtk::FILL); -#endif radiusX.setDigits(2); radiusX.setIncrements(0.2, 0); radiusX.setRange(0.001, 10000); @@ -116,20 +97,11 @@ PolarArrangeTab::PolarArrangeTab(ArrangeDialog *parent_) radiusY.setIncrements(0.2, 0); radiusY.setRange(0.001, 10000); radiusY.setValue(100, "px"); -#if WITH_GTKMM_3_0 parametersTable.attach(radiusX, 1, 1, 1, 1); parametersTable.attach(radiusY, 2, 1, 1, 1); -#else - parametersTable.attach(radiusX, 1, 2, 1, 2, Gtk::FILL); - parametersTable.attach(radiusY, 2, 3, 1, 2, Gtk::FILL); -#endif angleLabel.set_text(_("Angle X/Y:")); -#if WITH_GTKMM_3_0 parametersTable.attach(angleLabel, 0, 2, 1, 1); -#else - parametersTable.attach(angleLabel, 0, 1, 2, 3, Gtk::FILL); -#endif angleX.setDigits(2); angleX.setIncrements(0.2, 0); angleX.setRange(-10000, 10000); @@ -138,13 +110,8 @@ PolarArrangeTab::PolarArrangeTab(ArrangeDialog *parent_) angleY.setIncrements(0.2, 0); angleY.setRange(-10000, 10000); angleY.setValue(180, "°"); -#if WITH_GTKMM_3_0 parametersTable.attach(angleX, 1, 2, 1, 1); parametersTable.attach(angleY, 2, 2, 1, 1); -#else - parametersTable.attach(angleX, 1, 2, 2, 3, Gtk::FILL); - parametersTable.attach(angleY, 2, 3, 2, 3, Gtk::FILL); -#endif pack_start(parametersTable, false, false); rotateObjectsCheckBox.set_label(_("Rotate objects")); @@ -297,7 +264,7 @@ static void moveToPoint(int anchor, SPItem *item, Geom::Point p) void PolarArrangeTab::arrange() { Inkscape::Selection *selection = parent->getDesktop()->getSelection(); - const std::vector<SPItem*> tmp(selection->itemList()); + const std::vector<SPItem*> tmp(selection->items().begin(), selection->items().end()); SPGenericEllipse *referenceEllipse = NULL; // Last ellipse in selection bool arrangeOnEllipse = !arrangeOnParametersRadio.get_active(); diff --git a/src/ui/dialog/polar-arrange-tab.h b/src/ui/dialog/polar-arrange-tab.h index f7d7bf11f..1a4e04eda 100644 --- a/src/ui/dialog/polar-arrange-tab.h +++ b/src/ui/dialog/polar-arrange-tab.h @@ -20,12 +20,7 @@ #include <gtkmm/radiobutton.h> #include <gtkmm/radiobuttongroup.h> - -#if WITH_GTKMM_3_0 - #include <gtkmm/grid.h> -#else - #include <gtkmm/table.h> -#endif +#include <gtkmm/grid.h> namespace Inkscape { namespace UI { @@ -75,11 +70,7 @@ private: Gtk::RadioButton arrangeOnLastCircleRadio; Gtk::RadioButton arrangeOnParametersRadio; -#if WITH_GTKMM_3_0 Gtk::Grid parametersTable; -#else - Gtk::Table parametersTable; -#endif Gtk::Label centerLabel; Inkscape::UI::Widget::ScalarUnit centerY; diff --git a/src/ui/dialog/print.cpp b/src/ui/dialog/print.cpp index c44d645a5..9ebbf040c 100644 --- a/src/ui/dialog/print.cpp +++ b/src/ui/dialog/print.cpp @@ -11,7 +11,7 @@ */ #ifdef HAVE_CONFIG_H -# include <config.h> +#include "config.h" #endif #include <gtkmm.h> @@ -26,7 +26,6 @@ #include "extension/internal/cairo-render-context.h" #include "extension/internal/cairo-renderer.h" -#include "ui/widget/rendering-options.h" #include "document.h" #include "util/units.h" diff --git a/src/ui/dialog/spellcheck.cpp b/src/ui/dialog/spellcheck.cpp index 6da8acb20..045ce3459 100644 --- a/src/ui/dialog/spellcheck.cpp +++ b/src/ui/dialog/spellcheck.cpp @@ -17,25 +17,18 @@ #include "message-stack.h" #include "helper/window.h" -#include "macros.h" #include "inkscape.h" #include "document.h" -#include "selection.h" #include "desktop.h" #include "ui/tools-switch.h" #include "ui/tools/text-tool.h" #include "ui/interface.h" -#include "preferences.h" -#include "sp-text.h" #include "sp-flowtext.h" #include "text-editing.h" -#include "sp-tspan.h" #include "sp-tref.h" #include "sp-defs.h" #include "selection-chemistry.h" -#include <xml/repr.h> -#include "display/canvas-bpath.h" #include "display/curve.h" #include "document-undo.h" #include "sp-root.h" @@ -47,7 +40,7 @@ #endif #ifdef HAVE_CONFIG_H -# include "config.h" +#include "config.h" #endif @@ -234,14 +227,14 @@ GSList *SpellCheck::allTextItems (SPObject *r, GSList *l, bool hidden, bool lock return l; // we're not interested in metadata } - for (SPObject *child = r->firstChild(); child; child = child->next) { - if (SP_IS_ITEM (child) && !child->cloned && !desktop->isLayer(SP_ITEM(child))) { - if ((hidden || !desktop->itemIsHidden(SP_ITEM(child))) && (locked || !SP_ITEM(child)->isLocked())) { - if (SP_IS_TEXT(child) || SP_IS_FLOWTEXT(child)) - l = g_slist_prepend (l, child); + for (auto& child: r->children) { + if (SP_IS_ITEM (&child) && !child.cloned && !desktop->isLayer(SP_ITEM(&child))) { + if ((hidden || !desktop->itemIsHidden(SP_ITEM(&child))) && (locked || !SP_ITEM(&child)->isLocked())) { + if (SP_IS_TEXT(&child) || SP_IS_FLOWTEXT(&child)) + l = g_slist_prepend (l, &child); } } - l = allTextItems (child, l, hidden, locked); + l = allTextItems (&child, l, hidden, locked); } return l; } diff --git a/src/ui/dialog/spellcheck.h b/src/ui/dialog/spellcheck.h index e98a9d80e..834f23c24 100644 --- a/src/ui/dialog/spellcheck.h +++ b/src/ui/dialog/spellcheck.h @@ -225,11 +225,7 @@ private: * Dialogs widgets */ Gtk::Label banner_label; -#if WITH_GTKMM_3_0 Gtk::ButtonBox banner_hbox; -#else - Gtk::HButtonBox banner_hbox; -#endif Gtk::ScrolledWindow scrolled_window; Gtk::TreeView tree_view; Glib::RefPtr<Gtk::ListStore> model; @@ -243,21 +239,10 @@ private: Gtk::Button add_button; GtkWidget * dictionary_combo; Gtk::HBox dictionary_hbox; - -#if WITH_GTKMM_3_0 Gtk::Separator action_sep; -#else - Gtk::HSeparator action_sep; -#endif - Gtk::Button stop_button; Gtk::Button start_button; - -#if WITH_GTKMM_3_0 Gtk::ButtonBox actionbutton_hbox; -#else - Gtk::HButtonBox actionbutton_hbox; -#endif SPDesktop * desktop; DesktopTracker deskTrack; diff --git a/src/ui/dialog/svg-fonts-dialog.cpp b/src/ui/dialog/svg-fonts-dialog.cpp index 08ebbcf14..e55a32bd5 100644 --- a/src/ui/dialog/svg-fonts-dialog.cpp +++ b/src/ui/dialog/svg-fonts-dialog.cpp @@ -12,25 +12,24 @@ */ #ifdef HAVE_CONFIG_H -# include <config.h> +#include "config.h" #endif #include "svg-fonts-dialog.h" #include "document-private.h" #include "document-undo.h" #include <gtkmm/notebook.h> -#include <gtkmm/imagemenuitem.h> #include <gtkmm/scale.h> #include <gtkmm/stock.h> +#include <gtkmm/imagemenuitem.h> #include <message-stack.h> #include "selection.h" -#include <string.h> #include "svg/svg.h" -#include "xml/node.h" #include "xml/repr.h" #include "sp-font-face.h" #include "desktop.h" +#include <sstream> #include "display/nr-svgfonts.h" #include "verbs.h" #include "sp-glyph.h" @@ -76,6 +75,15 @@ bool SvgFontDrawingArea::on_expose_event (GdkEventExpose */*event*/){ cr->set_font_size (_y-20); cr->move_to (10, 10); cr->show_text (_text.c_str()); + + // Draw some lines to show line area. + cr->set_source_rgb( 0.5, 0.5, 0.5 ); + cr->move_to ( 0, 10); + cr->line_to (_x, 10); + cr->stroke(); + cr->move_to ( 0, _y-10); + cr->line_to (_x, _y-10); + cr->stroke(); } return TRUE; } @@ -112,14 +120,15 @@ void SvgFontsDialog::AttrEntry::set_text(char* t){ entry.set_text(t); } +// 'font-family' has a problem as it is also a presentation attribute for <text> void SvgFontsDialog::AttrEntry::on_attr_changed(){ SPObject* o = NULL; - for(SPObject* node = this->dialog->get_selected_spfont()->children; node; node=node->next){ + for (auto& node: dialog->get_selected_spfont()->children) { switch(this->attr){ case SP_PROP_FONT_FAMILY: - if (SP_IS_FONTFACE(node)){ - o = node; + if (SP_IS_FONTFACE(&node)){ + o = &node; continue; } break; @@ -141,6 +150,74 @@ void SvgFontsDialog::AttrEntry::on_attr_changed(){ } +SvgFontsDialog::AttrSpin::AttrSpin(SvgFontsDialog* d, gchar* lbl, const SPAttributeEnum attr) { + + this->dialog = d; + this->attr = attr; + this->add(* Gtk::manage(new Gtk::Label(lbl)) ); + this->add(spin); + this->show_all(); + spin.set_range(0, 4096); + spin.set_increments(16, 0); + spin.signal_value_changed().connect(sigc::mem_fun(*this, &SvgFontsDialog::AttrSpin::on_attr_changed)); +} + +void SvgFontsDialog::AttrSpin::set_range(double low, double high){ + spin.set_range(low, high); +} + +void SvgFontsDialog::AttrSpin::set_value(double v){ + spin.set_value(v); +} + +void SvgFontsDialog::AttrSpin::on_attr_changed(){ + + SPObject* o = NULL; + switch (this->attr) { + + // <font> attributes + case SP_ATTR_HORIZ_ORIGIN_X: + case SP_ATTR_HORIZ_ORIGIN_Y: + case SP_ATTR_HORIZ_ADV_X: + case SP_ATTR_VERT_ORIGIN_X: + case SP_ATTR_VERT_ORIGIN_Y: + case SP_ATTR_VERT_ADV_Y: + o = this->dialog->get_selected_spfont(); + break; + + // <font-face> attributes + case SP_ATTR_UNITS_PER_EM: + case SP_ATTR_ASCENT: + case SP_ATTR_DESCENT: + case SP_ATTR_CAP_HEIGHT: + case SP_ATTR_X_HEIGHT: + for (auto& node: dialog->get_selected_spfont()->children){ + if (SP_IS_FONTFACE(&node)){ + o = &node; + continue; + } + } + break; + + default: + o = NULL; + } + + const gchar* name = (const gchar*)sp_attribute_name(this->attr); + if(name && o) { + std::ostringstream temp; + temp << this->spin.get_value(); + o->getRepr()->setAttribute((const gchar*) name, temp.str().c_str() ); + o->parent->requestModified(SP_OBJECT_MODIFIED_FLAG); + + Glib::ustring undokey = "svgfonts:"; + undokey += name; + DocumentUndo::maybeDone(o->document, undokey.c_str(), SP_VERB_DIALOG_SVG_FONTS, + _("Set SVG Font attribute")); + } + +} + Gtk::HBox* SvgFontsDialog::AttrCombo(gchar* lbl, const SPAttributeEnum /*attr*/){ Gtk::HBox* hbox = Gtk::manage(new Gtk::HBox()); hbox->add(* Gtk::manage(new Gtk::Label(lbl)) ); @@ -164,15 +241,13 @@ GlyphComboBox::GlyphComboBox(){ } void GlyphComboBox::update(SPFont* spfont){ - if (!spfont) return -//TODO: figure out why do we need to append("") before clearing items properly... + if (!spfont) return; - this->append(""); //Gtk is refusing to clear the combobox when I comment out this line this->remove_all(); - for(SPObject* node = spfont->children; node; node=node->next){ - if (SP_IS_GLYPH(node)){ - this->append((static_cast<SPGlyph*>(node))->unicode); + for (auto& node: spfont->children) { + if (SP_IS_GLYPH(&node)){ + this->append((static_cast<SPGlyph*>(&node))->unicode); } } } @@ -283,7 +358,6 @@ void SvgFontsDialog::update_fonts() } void SvgFontsDialog::on_preview_text_changed(){ - _font_da.set_text((gchar*) _preview_entry.get_text().c_str()); _font_da.set_text(_preview_entry.get_text()); } @@ -308,10 +382,18 @@ void SvgFontsDialog::update_global_settings_tab(){ SPFont* font = get_selected_spfont(); if (!font) return; - SPObject* obj; - for (obj=font->children; obj; obj=obj->next){ - if (SP_IS_FONTFACE(obj)){ - _familyname_entry->set_text((SP_FONTFACE(obj))->font_family); + _horiz_adv_x_spin->set_value(font->horiz_adv_x); + _horiz_origin_x_spin->set_value(font->horiz_origin_x); + _horiz_origin_y_spin->set_value(font->horiz_origin_y); + + for (auto& obj: font->children) { + if (SP_IS_FONTFACE(&obj)){ + _familyname_entry->set_text((SP_FONTFACE(&obj))->font_family); + _units_per_em_spin->set_value((SP_FONTFACE(&obj))->units_per_em); + _ascent_spin->set_value((SP_FONTFACE(&obj))->ascent); + _descent_spin->set_value((SP_FONTFACE(&obj))->descent); + _x_height_spin->set_value((SP_FONTFACE(&obj))->x_height); + _cap_height_spin->set_value((SP_FONTFACE(&obj))->cap_height); } } } @@ -326,11 +408,8 @@ void SvgFontsDialog::on_font_selection_changed(){ kerning_preview.set_svgfont(svgfont); _font_da.set_svgfont(svgfont); _font_da.redraw(); - - double set_width = spfont->horiz_adv_x; - setwidth_spin.set_value(set_width); - - kerning_slider->set_range(0, set_width); + + kerning_slider->set_range(0, spfont->horiz_adv_x); kerning_slider->set_draw_value(false); kerning_slider->set_value(0); @@ -340,17 +419,6 @@ void SvgFontsDialog::on_font_selection_changed(){ update_sensitiveness(); } -void SvgFontsDialog::on_setfontdata_changed(){ - SPFont* spfont = this->get_selected_spfont(); - if (spfont){ - spfont->horiz_adv_x = setwidth_spin.get_value(); - //TODO: tell cairo that the glyphs cache has to be invalidated - // The current solution is to recreate the whole cairo svgfont. - // This is not a good solution to the issue because big fonts will result in poor performance. - update_glyphs(); - } -} - SPGlyphKerning* SvgFontsDialog::get_selected_kerning_pair() { Gtk::TreeModel::iterator i = _KerningPairsList.get_selection()->get_selected(); @@ -384,24 +452,37 @@ SPGlyph* SvgFontsDialog::get_selected_glyph() } Gtk::VBox* SvgFontsDialog::global_settings_tab(){ - _familyname_entry = new AttrEntry(this, (gchar*) _("Family Name:"), SP_PROP_FONT_FAMILY); + _font_label = new Gtk::Label( _("Font Attributes") ); + _horiz_adv_x_spin = new AttrSpin( this, (gchar*) _("Horiz. Advance X"), SP_ATTR_HORIZ_ADV_X); + _horiz_origin_x_spin = new AttrSpin( this, (gchar*) _("Horiz. Origin X "), SP_ATTR_HORIZ_ORIGIN_X); + _horiz_origin_y_spin = new AttrSpin( this, (gchar*) _("Horiz. Origin Y "), SP_ATTR_HORIZ_ORIGIN_Y); + _font_face_label = new Gtk::Label( _("Font Face Attributes") ); + _familyname_entry = new AttrEntry(this, (gchar*) _("Family Name:"), SP_PROP_FONT_FAMILY); + _units_per_em_spin = new AttrSpin( this, (gchar*) _("Units per em"), SP_ATTR_UNITS_PER_EM); + _ascent_spin = new AttrSpin( this, (gchar*) _("Ascent:"), SP_ATTR_ASCENT); + _descent_spin = new AttrSpin( this, (gchar*) _("Descent:"), SP_ATTR_DESCENT); + _cap_height_spin = new AttrSpin( this, (gchar*) _("Cap Height:"), SP_ATTR_CAP_HEIGHT); + _x_height_spin = new AttrSpin( this, (gchar*) _("x Height:"), SP_ATTR_X_HEIGHT); + + //_descent_spin->set_range(-4096,0); + + global_vbox.pack_start(*_font_label, false, false); + global_vbox.pack_start(*_horiz_adv_x_spin, false, false); + global_vbox.pack_start(*_horiz_origin_x_spin, false, false); + global_vbox.pack_start(*_horiz_origin_y_spin, false, false); + global_vbox.pack_start(*_font_face_label, false, false); + global_vbox.pack_start(*_familyname_entry, false, false); + global_vbox.pack_start(*_units_per_em_spin, false, false); + global_vbox.pack_start(*_ascent_spin, false, false); + global_vbox.pack_start(*_descent_spin, false, false); + global_vbox.pack_start(*_cap_height_spin, false, false); + global_vbox.pack_start(*_x_height_spin, false, false); - global_vbox.pack_start(*_familyname_entry, false, false); /* global_vbox->add(*AttrCombo((gchar*) _("Style:"), SP_PROP_FONT_STYLE)); global_vbox->add(*AttrCombo((gchar*) _("Variant:"), SP_PROP_FONT_VARIANT)); global_vbox->add(*AttrCombo((gchar*) _("Weight:"), SP_PROP_FONT_WEIGHT)); */ -//Set Width (horiz_adv_x): - Gtk::HBox* setwidth_hbox = Gtk::manage(new Gtk::HBox()); - setwidth_hbox->add(*Gtk::manage(new Gtk::Label(_("Set width:")))); - setwidth_hbox->add(setwidth_spin); - - setwidth_spin.signal_changed().connect(sigc::mem_fun(*this, &SvgFontsDialog::on_setfontdata_changed)); - setwidth_spin.set_range(0, 4096); - setwidth_spin.set_increments(10, 0); - global_vbox.pack_start(*setwidth_hbox, false, false); - return &global_vbox; } @@ -414,12 +495,13 @@ SvgFontsDialog::populate_glyphs_box() SPFont* spfont = this->get_selected_spfont(); _glyphs_observer.set(spfont); - for(SPObject* node = spfont->children; node; node=node->next){ - if (SP_IS_GLYPH(node)){ + for (auto& node: spfont->children) { + if (SP_IS_GLYPH(&node)){ Gtk::TreeModel::Row row = *(_GlyphsListStore->append()); - row[_GlyphsListColumns.glyph_node] = static_cast<SPGlyph*>(node); - row[_GlyphsListColumns.glyph_name] = (static_cast<SPGlyph*>(node))->glyph_name; - row[_GlyphsListColumns.unicode] = (static_cast<SPGlyph*>(node))->unicode; + row[_GlyphsListColumns.glyph_node] = static_cast<SPGlyph*>(&node); + row[_GlyphsListColumns.glyph_name] = (static_cast<SPGlyph*>(&node))->glyph_name; + row[_GlyphsListColumns.unicode] = (static_cast<SPGlyph*>(&node))->unicode; + row[_GlyphsListColumns.advance] = (static_cast<SPGlyph*>(&node))->horiz_adv_x; } } } @@ -432,13 +514,13 @@ SvgFontsDialog::populate_kerning_pairs_box() SPFont* spfont = this->get_selected_spfont(); - for(SPObject* node = spfont->children; node; node=node->next){ - if (SP_IS_HKERN(node)){ + for (auto& node: spfont->children) { + if (SP_IS_HKERN(&node)){ Gtk::TreeModel::Row row = *(_KerningPairsListStore->append()); - row[_KerningPairsListColumns.first_glyph] = (static_cast<SPGlyphKerning*>(node))->u1->attribute_string().c_str(); - row[_KerningPairsListColumns.second_glyph] = (static_cast<SPGlyphKerning*>(node))->u2->attribute_string().c_str(); - row[_KerningPairsListColumns.kerning_value] = (static_cast<SPGlyphKerning*>(node))->k; - row[_KerningPairsListColumns.spnode] = static_cast<SPGlyphKerning*>(node); + row[_KerningPairsListColumns.first_glyph] = (static_cast<SPGlyphKerning*>(&node))->u1->attribute_string().c_str(); + row[_KerningPairsListColumns.second_glyph] = (static_cast<SPGlyphKerning*>(&node))->u2->attribute_string().c_str(); + row[_KerningPairsListColumns.kerning_value] = (static_cast<SPGlyphKerning*>(&node))->k; + row[_KerningPairsListColumns.spnode] = static_cast<SPGlyphKerning*>(&node); } } } @@ -492,17 +574,14 @@ void SvgFontsDialog::add_glyph(){ Geom::PathVector SvgFontsDialog::flip_coordinate_system(Geom::PathVector pathv){ - double units_per_em = 1000; - SPObject* obj; - for (obj = get_selected_spfont()->children; obj; obj=obj->next){ - if (SP_IS_FONTFACE(obj)){ + double units_per_em = 1024; + for (auto& obj: get_selected_spfont()->children) { + if (SP_IS_FONTFACE(&obj)){ //XML Tree being directly used here while it shouldn't be. - sp_repr_get_double(obj->getRepr(), "units-per-em", &units_per_em); + sp_repr_get_double(obj.getRepr(), "units-per-em", &units_per_em); } } - double baseline_offset = units_per_em - get_selected_spfont()->horiz_origin_y; - //This matrix flips y-axis and places the origin at baseline Geom::Affine m(Geom::Coord(1),Geom::Coord(0),Geom::Coord(0),Geom::Coord(-1),Geom::Coord(0),Geom::Coord(baseline_offset)); return pathv*m; @@ -524,7 +603,7 @@ void SvgFontsDialog::set_glyph_description_from_selected_path(){ return; } - Inkscape::XML::Node* node = sel->reprList().front(); + Inkscape::XML::Node* node = sel->xmlNodes().front(); if (!node) return;//TODO: should this be an assert? if (!node->matchAttributeName("d") || !node->attribute("d")){ char *msg = _("The selected object does not have a <b>path</b> description."); @@ -566,7 +645,7 @@ void SvgFontsDialog::missing_glyph_description_from_selected_path(){ return; } - Inkscape::XML::Node* node = sel->reprList().front(); + Inkscape::XML::Node* node = sel->xmlNodes().front(); if (!node) return;//TODO: should this be an assert? if (!node->matchAttributeName("d") || !node->attribute("d")){ char *msg = _("The selected object does not have a <b>path</b> description."); @@ -576,13 +655,12 @@ void SvgFontsDialog::missing_glyph_description_from_selected_path(){ Geom::PathVector pathv = sp_svg_read_pathv(node->attribute("d")); - SPObject* obj; - for (obj = get_selected_spfont()->children; obj; obj=obj->next){ - if (SP_IS_MISSING_GLYPH(obj)){ + for (auto& obj: get_selected_spfont()->children) { + if (SP_IS_MISSING_GLYPH(&obj)){ //XML Tree being directly used here while it shouldn't be. gchar *str = sp_svg_write_path (flip_coordinate_system(pathv)); - obj->getRepr()->setAttribute("d", str); + obj.getRepr()->setAttribute("d", str); g_free(str); DocumentUndo::done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Set glyph curves")); } @@ -599,11 +677,10 @@ void SvgFontsDialog::reset_missing_glyph_description(){ } SPDocument* doc = desktop->getDocument(); - SPObject* obj; - for (obj = get_selected_spfont()->children; obj; obj=obj->next){ - if (SP_IS_MISSING_GLYPH(obj)){ + for (auto& obj: get_selected_spfont()->children) { + if (SP_IS_MISSING_GLYPH(&obj)){ //XML Tree being directly used here while it shouldn't be. - obj->getRepr()->setAttribute("d", (char*) "M0,0h1000v1024h-1000z"); + obj.getRepr()->setAttribute("d", (char*) "M0,0h1000v1024h-1000z"); DocumentUndo::done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Reset missing-glyph")); } } @@ -639,6 +716,26 @@ void SvgFontsDialog::glyph_unicode_edit(const Glib::ustring&, const Glib::ustrin update_glyphs(); } +void SvgFontsDialog::glyph_advance_edit(const Glib::ustring&, const Glib::ustring& str){ + Gtk::TreeModel::iterator i = _GlyphsList.get_selection()->get_selected(); + if (!i) return; + + SPGlyph* glyph = (*i)[_GlyphsListColumns.glyph_node]; + //XML Tree being directly used here while it shouldn't be. + std::istringstream is(str); + double value; + // Check if input valid + if ((is >> value)) { + glyph->getRepr()->setAttribute("horiz-adv-x", str.c_str()); + SPDocument* doc = this->getDesktop()->getDocument(); + DocumentUndo::done(doc, SP_VERB_DIALOG_SVG_FONTS, _("Set glyph advance")); + + update_glyphs(); + } else { + std::cerr << "SvgFontDialog::glyph_advance_edit: Error in input: " << str << std::endl; + } +} + void SvgFontsDialog::remove_selected_font(){ SPFont* font = get_selected_spfont(); if (!font) return; @@ -707,9 +804,9 @@ Gtk::VBox* SvgFontsDialog::glyphs_tab(){ _GlyphsListScroller.add(_GlyphsList); _GlyphsListStore = Gtk::ListStore::create(_GlyphsListColumns); _GlyphsList.set_model(_GlyphsListStore); - _GlyphsList.append_column_editable(_("Glyph name"), _GlyphsListColumns.glyph_name); + _GlyphsList.append_column_editable(_("Glyph name"), _GlyphsListColumns.glyph_name); _GlyphsList.append_column_editable(_("Matching string"), _GlyphsListColumns.unicode); - + _GlyphsList.append_column_numeric_editable(_("Advance"), _GlyphsListColumns.advance, "%.2f"); Gtk::HBox* hb = Gtk::manage(new Gtk::HBox()); add_glyph_button.set_label(_("Add Glyph")); add_glyph_button.signal_clicked().connect(sigc::mem_fun(*this, &SvgFontsDialog::add_glyph)); @@ -727,6 +824,9 @@ Gtk::VBox* SvgFontsDialog::glyphs_tab(){ dynamic_cast<Gtk::CellRendererText*>( _GlyphsList.get_column_cell_renderer(1))->signal_edited().connect( sigc::mem_fun(*this, &SvgFontsDialog::glyph_unicode_edit)); + dynamic_cast<Gtk::CellRendererText*>( _GlyphsList.get_column_cell_renderer(2))->signal_edited().connect( + sigc::mem_fun(*this, &SvgFontsDialog::glyph_advance_edit)); + _glyphs_observer.signal_changed().connect(sigc::mem_fun(*this, &SvgFontsDialog::update_glyphs)); return &glyphs_vbox; @@ -738,12 +838,12 @@ void SvgFontsDialog::add_kerning_pair(){ //look for this kerning pair on the currently selected font this->kerning_pair = NULL; - for(SPObject* node = this->get_selected_spfont()->children; node; node=node->next){ + for (auto& node: get_selected_spfont()->children) { //TODO: It is not really correct to get only the first byte of each string. //TODO: We should also support vertical kerning - if (SP_IS_HKERN(node) && (static_cast<SPGlyphKerning*>(node))->u1->contains((gchar) first_glyph.get_active_text().c_str()[0]) - && (static_cast<SPGlyphKerning*>(node))->u2->contains((gchar) second_glyph.get_active_text().c_str()[0]) ){ - this->kerning_pair = static_cast<SPGlyphKerning*>(node); + if (SP_IS_HKERN(&node) && (static_cast<SPGlyphKerning*>(&node))->u1->contains((gchar) first_glyph.get_active_text().c_str()[0]) + && (static_cast<SPGlyphKerning*>(&node))->u2->contains((gchar) second_glyph.get_active_text().c_str()[0]) ){ + this->kerning_pair = static_cast<SPGlyphKerning*>(&node); continue; } } @@ -806,7 +906,7 @@ Gtk::VBox* SvgFontsDialog::kerning_tab(){ kerning_amount_hbox->add(*kerning_slider); kerning_preview.set_size(300 + 20, 150 + 20); - _font_da.set_size(150 + 20, 50 + 20); + _font_da.set_size(300 + 50 + 20, 60 + 20); return &kerning_vbox; } @@ -852,11 +952,10 @@ SPFont *new_font(SPDocument *document) void set_font_family(SPFont* font, char* str){ if (!font) return; - SPObject* obj; - for (obj=font->children; obj; obj=obj->next){ - if (SP_IS_FONTFACE(obj)){ + for (auto& obj: font->children) { + if (SP_IS_FONTFACE(&obj)){ //XML Tree being directly used here while it shouldn't be. - obj->getRepr()->setAttribute("font-family", str); + obj.getRepr()->setAttribute("font-family", str); } } @@ -873,11 +972,10 @@ void SvgFontsDialog::add_font(){ font->setLabel(os.str().c_str()); os2 << "SVGFont " << count; - SPObject* obj; - for (obj=font->children; obj; obj=obj->next){ - if (SP_IS_FONTFACE(obj)){ + for (auto& obj: font->children) { + if (SP_IS_FONTFACE(&obj)){ //XML Tree being directly used here while it shouldn't be. - obj->getRepr()->setAttribute("font-family", os2.str().c_str()); + obj.getRepr()->setAttribute("font-family", os2.str().c_str()); } } @@ -890,12 +988,7 @@ void SvgFontsDialog::add_font(){ SvgFontsDialog::SvgFontsDialog() : UI::Widget::Panel("", "/dialogs/svgfonts", SP_VERB_DIALOG_SVG_FONTS), _add(Gtk::Stock::NEW) { -#if WITH_GTKMM_3_0 kerning_slider = Gtk::manage(new Gtk::Scale(Gtk::ORIENTATION_HORIZONTAL)); -#else - kerning_slider = Gtk::manage(new Gtk::HScale); -#endif - _add.signal_clicked().connect(sigc::mem_fun(*this, &SvgFontsDialog::add_font)); Gtk::HBox* hbox = Gtk::manage(new Gtk::HBox()); diff --git a/src/ui/dialog/svg-fonts-dialog.h b/src/ui/dialog/svg-fonts-dialog.h index e80bbfd39..a0f1586d8 100644 --- a/src/ui/dialog/svg-fonts-dialog.h +++ b/src/ui/dialog/svg-fonts-dialog.h @@ -27,11 +27,7 @@ #include "xml/helper-observer.h" namespace Gtk { -#if WITH_GTKMM_3_0 class Scale; -#else -class HScale; -#endif } class SPGlyph; @@ -86,8 +82,9 @@ public: void on_setfontdata_changed(); void add_font(); Geom::PathVector flip_coordinate_system(Geom::PathVector pathv); + bool updating; - //TODO: AttrEntry is currently unused. Should we remove it? + // Used for font-family class AttrEntry : public Gtk::HBox { public: @@ -100,6 +97,20 @@ public: SPAttributeEnum attr; }; + class AttrSpin : public Gtk::HBox + { + public: + AttrSpin(SvgFontsDialog* d, gchar* lbl, const SPAttributeEnum attr); + void set_value(double v); + void set_range(double low, double high); + Inkscape::UI::Widget::SpinButton* getSpin() { return &spin; } + private: + SvgFontsDialog* dialog; + void on_attr_changed(); + Inkscape::UI::Widget::SpinButton spin; + SPAttributeEnum attr; + }; + private: void update_glyphs(); void update_sensitiveness(); @@ -111,7 +122,8 @@ private: void reset_missing_glyph_description(); void add_glyph(); void glyph_unicode_edit(const Glib::ustring&, const Glib::ustring&); - void glyph_name_edit(const Glib::ustring&, const Glib::ustring&); + void glyph_name_edit( const Glib::ustring&, const Glib::ustring&); + void glyph_advance_edit(const Glib::ustring&, const Glib::ustring&); void remove_selected_glyph(); void remove_selected_font(); void remove_selected_kerning_pair(); @@ -133,7 +145,21 @@ private: Gtk::HBox* AttrCombo(gchar* lbl, const SPAttributeEnum attr); // Gtk::HBox* AttrSpin(gchar* lbl, const SPAttributeEnum attr); Gtk::VBox* global_settings_tab(); + + // <font> + Gtk::Label* _font_label; + AttrSpin* _horiz_adv_x_spin; + AttrSpin* _horiz_origin_x_spin; + AttrSpin* _horiz_origin_y_spin; + + // <font-face> + Gtk::Label* _font_face_label; AttrEntry* _familyname_entry; + AttrSpin* _units_per_em_spin; + AttrSpin* _ascent_spin; + AttrSpin* _descent_spin; + AttrSpin* _cap_height_spin; + AttrSpin* _x_height_spin; Gtk::VBox* kerning_tab(); Gtk::VBox* glyphs_tab(); @@ -169,11 +195,13 @@ private: add(glyph_node); add(glyph_name); add(unicode); + add(advance); } Gtk::TreeModelColumn<SPGlyph*> glyph_node; Gtk::TreeModelColumn<Glib::ustring> glyph_name; Gtk::TreeModelColumn<Glib::ustring> unicode; + Gtk::TreeModelColumn<double> advance; }; GlyphsColumns _GlyphsListColumns; Glib::RefPtr<Gtk::ListStore> _GlyphsListStore; @@ -216,12 +244,7 @@ private: GlyphComboBox first_glyph, second_glyph; SPGlyphKerning* kerning_pair; Inkscape::UI::Widget::SpinButton setwidth_spin; - -#if WITH_GTKMM_3_0 Gtk::Scale* kerning_slider; -#else - Gtk::HScale* kerning_slider; -#endif class EntryWidget : public Gtk::HBox { diff --git a/src/ui/dialog/swatches.cpp b/src/ui/dialog/swatches.cpp index 6577c8d4e..87bfa9252 100644 --- a/src/ui/dialog/swatches.cpp +++ b/src/ui/dialog/swatches.cpp @@ -24,7 +24,6 @@ #include <glibmm/i18n.h> #include <glibmm/main.h> #include <glibmm/timer.h> -#include <gdkmm/pixbuf.h> #include "color-item.h" #include "desktop.h" @@ -35,28 +34,20 @@ #include "document-undo.h" #include "extension/db.h" #include "inkscape.h" -#include "inkscape.h" #include "io/sys.h" #include "io/resource.h" #include "message-context.h" #include "path-prefix.h" -#include "preferences.h" -#include "sp-item.h" -#include "sp-gradient.h" -#include "sp-gradient-vector.h" #include "style.h" #include "ui/previewholder.h" #include "widgets/desktop-widget.h" #include "widgets/gradient-vector.h" -#include "widgets/eek-preview.h" #include "display/cairo-utils.h" #include "sp-gradient-reference.h" #include "dialog-manager.h" -#include "selection.h" #include "verbs.h" #include "gradient-chemistry.h" #include "helper/action.h" -#include "helper/action-context.h" namespace Inkscape { namespace UI { @@ -123,7 +114,7 @@ static void editGradientImpl( SPDesktop* desktop, SPGradient* gr ) bool shown = false; if ( desktop && desktop->doc() ) { Inkscape::Selection *selection = desktop->getSelection(); - std::vector<SPItem*> const items = selection->itemList(); + std::vector<SPItem*> const items(selection->items().begin(), selection->items().end()); if (!items.empty()) { SPStyle query( desktop->doc() ); int result = objects_query_fillstroke((items), &query, true); @@ -607,7 +598,7 @@ SwatchesPanel::SwatchesPanel(gchar const* prefsPath) : } loadEmUp(); - if ( !systemSwatchPages.empty() ) { + if ( !systemSwatchPages.empty() || !userSwatchPages.empty()) { SwatchPage* first = 0; int index = 0; Glib::ustring targetName; @@ -658,12 +649,8 @@ SwatchesPanel::SwatchesPanel(gchar const* prefsPath) : if (Glib::ustring(prefsPath) == "/dialogs/swatches") { Gtk::Requisition sreq; -#if WITH_GTKMM_3_0 Gtk::Requisition sreq_natural; get_preferred_size(sreq_natural, sreq); -#else - sreq = size_request(); -#endif int minHeight = 60; if (sreq.height < minHeight) { set_size_request(70, minHeight); diff --git a/src/ui/dialog/symbols.cpp b/src/ui/dialog/symbols.cpp index 06c17611f..4840b897b 100644 --- a/src/ui/dialog/symbols.cpp +++ b/src/ui/dialog/symbols.cpp @@ -15,25 +15,16 @@ #include <iostream> #include <algorithm> #include <locale> -#include <functional> #include <sstream> #include <gtkmm/buttonbox.h> #include <gtkmm/label.h> - -#if WITH_GTKMM_3_0 -# include <gtkmm/togglebutton.h> -# include <gtkmm/grid.h> -#else -# include <gtkmm/table.h> -#endif - +#include <gtkmm/togglebutton.h> +#include <gtkmm/grid.h> #include <gtkmm/scrolledwindow.h> #include <gtkmm/comboboxtext.h> #include <gtkmm/iconview.h> #include <gtkmm/liststore.h> -#include <gtkmm/treemodelcolumn.h> -#include <gtkmm/clipboard.h> #include <glibmm/stringutils.h> #include <glibmm/markup.h> #include <glibmm/i18n.h> @@ -76,8 +67,6 @@ #include "verbs.h" #include "helper/action.h" -#include "helper/action-context.h" -#include "xml/repr.h" namespace Inkscape { namespace UI { @@ -121,11 +110,7 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : { /******************** Table *************************/ -#if WITH_GTKMM_3_0 - Gtk::Grid *table = new Gtk::Grid(); -#else - Gtk::Table *table = new Gtk::Table(2, 4, false); -#endif + auto table = new Gtk::Grid(); // panel is a cloked Gtk::VBox _getContents()->pack_start(*Gtk::manage(table), Gtk::PACK_EXPAND_WIDGET); @@ -133,24 +118,12 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : /******************** Symbol Sets *************************/ Gtk::Label* labelSet = new Gtk::Label(_("Symbol set: ")); - -#if WITH_GTKMM_3_0 table->attach(*Gtk::manage(labelSet),0,row,1,1); -#else - table->attach(*Gtk::manage(labelSet),0,1,row,row+1,Gtk::SHRINK,Gtk::SHRINK); -#endif - symbolSet = new Gtk::ComboBoxText(); // Fill in later symbolSet->append(_("Current Document")); symbolSet->set_active_text(_("Current Document")); - -#if WITH_GTKMM_3_0 symbolSet->set_hexpand(); table->attach(*Gtk::manage(symbolSet),1,row,1,1); -#else - table->attach(*Gtk::manage(symbolSet),1,2,row,row+1,Gtk::FILL|Gtk::EXPAND,Gtk::SHRINK); -#endif - sigc::connection connSet = symbolSet->signal_changed().connect( sigc::mem_fun(*this, &SymbolsDialog::rebuild)); instanceConns.push_back(connSet); @@ -183,14 +156,9 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : Gtk::ScrolledWindow *scroller = new Gtk::ScrolledWindow(); scroller->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_ALWAYS); scroller->add(*Gtk::manage(iconView)); - -#if WITH_GTKMM_3_0 scroller->set_hexpand(); scroller->set_vexpand(); table->attach(*Gtk::manage(scroller),0,row,2,1); -#else - table->attach(*Gtk::manage(scroller),0,2,row,row+1,Gtk::EXPAND|Gtk::FILL,Gtk::EXPAND|Gtk::FILL); -#endif ++row; @@ -199,12 +167,8 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : Gtk::HBox* tools = new Gtk::HBox(); //tools->set_layout( Gtk::BUTTONBOX_END ); -#if WITH_GTKMM_3_0 scroller->set_hexpand(); table->attach(*Gtk::manage(tools),0,row,2,1); -#else - table->attach(*Gtk::manage(tools),0,2,row,row+1,Gtk::EXPAND|Gtk::FILL,Gtk::FILL); -#endif addSymbol = Gtk::manage(new Gtk::Button()); addSymbol->add(*Gtk::manage(Glib::wrap( @@ -398,11 +362,7 @@ void SymbolsDialog::revertSymbol() { void SymbolsDialog::iconDragDataGet(const Glib::RefPtr<Gdk::DragContext>& /*context*/, Gtk::SelectionData& data, guint /*info*/, guint /*time*/) { -#if WITH_GTKMM_3_0 - std::vector<Gtk::TreePath> iconArray = iconView->get_selected_items(); -#else - Gtk::IconView::ArrayHandle_TreePaths iconArray = iconView->get_selected_items(); -#endif + auto iconArray = iconView->get_selected_items(); if( iconArray.empty() ) { //std::cout << " iconArray empty: huh? " << std::endl; @@ -455,11 +415,7 @@ SPDocument* SymbolsDialog::selectedSymbols() { Glib::ustring SymbolsDialog::selectedSymbolId() { -#if WITH_GTKMM_3_0 - std::vector<Gtk::TreePath> iconArray = iconView->get_selected_items(); -#else - Gtk::IconView::ArrayHandle_TreePaths iconArray = iconView->get_selected_items(); -#endif + auto iconArray = iconView->get_selected_items(); if( !iconArray.empty() ) { Gtk::TreeModel::Path const & path = *iconArray.begin(); @@ -476,11 +432,6 @@ void SymbolsDialog::iconChanged() { SPObject* symbol = symbolDocument->getObjectById(symbol_id); if( symbol ) { - if( symbolDocument == currentDocument ) { - // Select the symbol on the canvas so it can be manipulated - currentDesktop->selection->set( symbol, false ); - } - // Find style for use in <use> // First look for default style stored in <symbol> gchar const* style = symbol->getAttribute("inkscape:symbol-style"); @@ -663,8 +614,8 @@ GSList* SymbolsDialog::symbols_in_doc_recursive (SPObject *r, GSList *l) l = g_slist_prepend (l, r); } - for (SPObject *child = r->firstChild(); child; child = child->getNext()) { - l = symbols_in_doc_recursive( child, l ); + for (auto& child: r->children) { + l = symbols_in_doc_recursive( &child, l ); } return l; @@ -685,8 +636,8 @@ GSList* SymbolsDialog::use_in_doc_recursive (SPObject *r, GSList *l) l = g_slist_prepend (l, r); } - for (SPObject *child = r->firstChild(); child; child = child->getNext()) { - l = use_in_doc_recursive( child, l ); + for (auto& child: r->children) { + l = use_in_doc_recursive( &child, l ); } return l; diff --git a/src/ui/dialog/tags.cpp b/src/ui/dialog/tags.cpp index c99c1bff3..dfe71bddb 100644 --- a/src/ui/dialog/tags.cpp +++ b/src/ui/dialog/tags.cpp @@ -10,17 +10,13 @@ */ #ifdef HAVE_CONFIG_H -# include <config.h> +#include "config.h" #endif #include "tags.h" -#include <gtkmm/widget.h> #include <gtkmm/icontheme.h> #include <gtkmm/imagemenuitem.h> -#include <gtkmm/separatormenuitem.h> - #include <glibmm/main.h> -#include <glibmm/i18n.h> #include "desktop.h" #include "desktop-style.h" @@ -30,28 +26,19 @@ #include "inkscape.h" #include "layer-fns.h" #include "layer-manager.h" -#include "preferences.h" -#include "sp-item.h" -#include "sp-object.h" #include "sp-shape.h" #include "svg/css-ostringstream.h" -#include "ui/icon-names.h" #include "ui/widget/layertypeicon.h" #include "ui/widget/addtoicon.h" #include "verbs.h" #include "widgets/icon.h" -#include "xml/node.h" #include "xml/node-observer.h" -#include "xml/repr.h" #include "sp-root.h" #include "ui/tools/tool-base.h" //"event-context.h" -#include "selection.h" //#include "dialogs/dialog-events.h" #include "ui/widget/color-notebook.h" #include "style.h" #include "filter-chemistry.h" -#include "filters/blend.h" -#include "filters/gaussian-blur.h" #include "sp-clippath.h" #include "sp-mask.h" #include "sp-tag.h" @@ -348,8 +335,8 @@ void TagsPanel::_objectsSelected( Selection *sel ) { _selectedConnection.block(); _tree.get_selection()->unselect_all(); - std::vector<SPObject*> tmp=sel->list(); - for(std::vector<SPObject*>::const_iterator i=tmp.begin();i!=tmp.end();++i) + auto tmp = sel->objects(); + for(auto i = tmp.begin(); i != tmp.end(); ++i) { SPObject *obj = *i; _store->foreach(sigc::bind<SPObject *>( sigc::mem_fun(*this, &TagsPanel::_checkForSelected), obj)); @@ -399,26 +386,26 @@ void TagsPanel::_objectsChanged(SPObject* root) void TagsPanel::_addObject( SPDocument* doc, SPObject* obj, Gtk::TreeModel::Row* parentRow ) { if ( _desktop && obj ) { - for ( SPObject *child = obj->children; child != NULL; child = child->next) { - if (SP_IS_TAG(child)) + for (auto& child: obj->children) { + if (SP_IS_TAG(&child)) { Gtk::TreeModel::iterator iter = parentRow ? _store->prepend(parentRow->children()) : _store->prepend(); Gtk::TreeModel::Row row = *iter; - row[_model->_colObject] = child; + row[_model->_colObject] = &child; row[_model->_colParentObject] = NULL; - row[_model->_colLabel] = child->label() ? child->label() : child->getId(); + row[_model->_colLabel] = child.label() ? child.label() : child.getId(); row[_model->_colAddRemove] = true; row[_model->_colAllowAddRemove] = true; _tree.expand_to_path( _store->get_path(iter) ); - TagsPanel::ObjectWatcher *w = new TagsPanel::ObjectWatcher(this, child); - child->getRepr()->addObserver(*w); + TagsPanel::ObjectWatcher *w = new TagsPanel::ObjectWatcher(this, &child); + child.getRepr()->addObserver(*w); _objectWatchers.push_back(w); - _addObject( doc, child, &row ); + _addObject( doc, &child, &row ); } } - if (SP_IS_TAG(obj) && obj->children) + if (SP_IS_TAG(obj) && obj->firstChild()) { Gtk::TreeModel::iterator iteritems = parentRow ? _store->append(parentRow->children()) : _store->prepend(); Gtk::TreeModel::Row rowitems = *iteritems; @@ -429,16 +416,16 @@ void TagsPanel::_addObject( SPDocument* doc, SPObject* obj, Gtk::TreeModel::Row* rowitems[_model->_colAllowAddRemove] = false; _tree.expand_to_path( _store->get_path(iteritems) ); - - for ( SPObject *child = obj->children; child != NULL; child = child->next) { - if (SP_IS_TAG_USE(child)) + + for (auto& child: obj->children) { + if (SP_IS_TAG_USE(&child)) { - SPItem *item = SP_TAG_USE(child)->ref->getObject(); + SPItem *item = SP_TAG_USE(&child)->ref->getObject(); Gtk::TreeModel::iterator iter = _store->prepend(rowitems->children()); Gtk::TreeModel::Row row = *iter; - row[_model->_colObject] = child; + row[_model->_colObject] = &child; row[_model->_colParentObject] = NULL; - row[_model->_colLabel] = item ? (item->label() ? item->label() : item->getId()) : SP_TAG_USE(child)->href; + row[_model->_colLabel] = item ? (item->label() ? item->label() : item->getId()) : SP_TAG_USE(&child)->href; row[_model->_colAddRemove] = false; row[_model->_colAllowAddRemove] = true; @@ -447,7 +434,7 @@ void TagsPanel::_addObject( SPDocument* doc, SPObject* obj, Gtk::TreeModel::Row* } if (item) { - TagsPanel::ObjectWatcher *w = new TagsPanel::ObjectWatcher(this, child, item->getRepr()); + TagsPanel::ObjectWatcher *w = new TagsPanel::ObjectWatcher(this, &child, item->getRepr()); item->getRepr()->addObserver(*w); _objectWatchers.push_back(w); } @@ -459,12 +446,11 @@ void TagsPanel::_addObject( SPDocument* doc, SPObject* obj, Gtk::TreeModel::Row* void TagsPanel::_select_tag( SPTag * tag ) { - for (SPObject * child = tag->children; child != NULL; child = child->next) - { - if (SP_IS_TAG(child)) { - _select_tag(SP_TAG(child)); - } else if (SP_IS_TAG_USE(child)) { - SPObject * obj = SP_TAG_USE(child)->ref->getObject(); + for (auto& child: tag->children) { + if (SP_IS_TAG(&child)) { + _select_tag(SP_TAG(&child)); + } else if (SP_IS_TAG_USE(&child)) { + SPObject * obj = SP_TAG_USE(&child)->ref->getObject(); if (obj) { if (_desktop->selection->isEmpty()) _desktop->setCurrentLayer(obj->parent); _desktop->selection->add(obj); @@ -646,12 +632,12 @@ bool TagsPanel::_handleButtonEvent(GdkEventButton* event) if (col == _tree.get_column(COL_ADD - 1) && down_at_add) { if (SP_IS_TAG(obj)) { bool wasadded = false; - std::vector<SPItem*> items=_desktop->selection->itemList(); - for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();++i){ + auto items= _desktop->selection->items(); + for(auto i=items.begin();i!=items.end();++i){ SPObject *newobj = *i; bool addchild = true; - for ( SPObject *child = obj->children; child != NULL; child = child->next) { - if (SP_IS_TAG_USE(child) && SP_TAG_USE(child)->ref->getObject() == newobj) { + for (auto& child: obj->children) { + if (SP_IS_TAG_USE(&child) && SP_TAG_USE(&child)->ref->getObject() == newobj) { addchild = false; } } @@ -980,12 +966,8 @@ TagsPanel::TagsPanel() : _scroller.set_policy( Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC ); _scroller.set_shadow_type(Gtk::SHADOW_IN); Gtk::Requisition sreq; -#if WITH_GTKMM_3_0 Gtk::Requisition sreq_natural; _scroller.get_preferred_size(sreq_natural, sreq); -#else - sreq = _scroller.size_request(); -#endif int minHeight = 70; if (sreq.height < minHeight) { // Set a min height to see the layers when used with Ubuntu liboverlay-scrollbar diff --git a/src/ui/dialog/tags.h b/src/ui/dialog/tags.h index 3576bd111..bdda22dd4 100644 --- a/src/ui/dialog/tags.h +++ b/src/ui/dialog/tags.h @@ -141,15 +141,9 @@ private: Gtk::TreeView _tree; Gtk::CellRendererText *_text_renderer; Gtk::TreeView::Column *_name_column; -#if WITH_GTKMM_3_0 Gtk::Box _buttonsRow; Gtk::Box _buttonsPrimary; Gtk::Box _buttonsSecondary; -#else - Gtk::HBox _buttonsRow; - Gtk::HBox _buttonsPrimary; - Gtk::HBox _buttonsSecondary; -#endif Gtk::ScrolledWindow _scroller; Gtk::Menu _popupMenu; Inkscape::UI::Widget::SpinButton _spinBtn; diff --git a/src/ui/dialog/template-load-tab.cpp b/src/ui/dialog/template-load-tab.cpp index 7eb04ff79..7b96c2b97 100644 --- a/src/ui/dialog/template-load-tab.cpp +++ b/src/ui/dialog/template-load-tab.cpp @@ -9,28 +9,20 @@ */ #include "template-widget.h" -#include "template-load-tab.h" #include "new-from-template.h" -#include <gtkmm/messagedialog.h> -#include <gtkmm/scrolledwindow.h> -#include <glibmm/i18n.h> -#include <glibmm/fileutils.h> #include <glibmm/miscutils.h> #include <glibmm/stringutils.h> +#include <glibmm/fileutils.h> +#include <gtkmm/messagedialog.h> +#include <gtkmm/scrolledwindow.h> #include <iostream> -#include <list> #include "extension/db.h" -#include "extension/effect.h" #include "inkscape.h" #include "ui/interface.h" #include "file.h" #include "path-prefix.h" -#include "preferences.h" -#include "xml/repr.h" -#include "xml/document.h" -#include "xml/node.h" namespace Inkscape { namespace UI { diff --git a/src/ui/dialog/template-widget.cpp b/src/ui/dialog/template-widget.cpp index 0d110d853..3b7fbe88c 100644 --- a/src/ui/dialog/template-widget.cpp +++ b/src/ui/dialog/template-widget.cpp @@ -10,15 +10,10 @@ #include "template-widget.h" +#include <glibmm/miscutils.h> #include <gtkmm/alignment.h> -#include <gtkmm/button.h> -#include <gtkmm/label.h> #include <gtkmm/messagedialog.h> -#include <glibmm/i18n.h> -#include <glibmm/miscutils.h> - -#include "template-load-tab.h" #include "desktop.h" #include "document.h" diff --git a/src/ui/dialog/text-edit.cpp b/src/ui/dialog/text-edit.cpp index c01da8864..a38085c85 100644 --- a/src/ui/dialog/text-edit.cpp +++ b/src/ui/dialog/text-edit.cpp @@ -22,7 +22,6 @@ #include "text-edit.h" #include <libnrtype/font-instance.h> -#include <gtk/gtk.h> #ifdef WITH_GTKSPELL extern "C" { @@ -31,11 +30,8 @@ extern "C" { #endif #include <gtkmm/stock.h> -#include <libnrtype/font-instance.h> #include <libnrtype/font-lister.h> -#include <xml/repr.h> -#include "macros.h" #include "helper/window.h" #include "inkscape.h" #include "document.h" @@ -43,13 +39,10 @@ extern "C" { #include "desktop-style.h" #include "document-undo.h" -#include "selection.h" -#include "style.h" #include "sp-text.h" #include "sp-flowtext.h" #include "text-editing.h" #include "ui/icon-names.h" -#include "preferences.h" #include "verbs.h" #include "ui/interface.h" #include "svg/css-ostringstream.h" @@ -99,9 +92,7 @@ TextEdit::TextEdit() styleButton(&align_right, _("Align right"), INKSCAPE_ICON("format-justify-right"), &align_left); styleButton(&align_justify, _("Justify (only flowed text)"), INKSCAPE_ICON("format-justify-fill"), &align_left); -#if WITH_GTKMM_3_0 align_sep.set_orientation(Gtk::ORIENTATION_VERTICAL); -#endif layout_hbox.pack_start(align_sep, false, false, 10); @@ -109,13 +100,12 @@ TextEdit::TextEdit() styleButton(&text_horizontal, _("Horizontal text"), INKSCAPE_ICON("format-text-direction-horizontal"), NULL); styleButton(&text_vertical, _("Vertical text"), INKSCAPE_ICON("format-text-direction-vertical"), &text_horizontal); -#if WITH_GTKMM_3_0 text_sep.set_orientation(Gtk::ORIENTATION_VERTICAL); -#endif layout_hbox.pack_start(text_sep, false, false, 10); /* Line Spacing */ + /* Commented out as this does not handle non-percentage values GtkWidget *px = sp_icon_new( Inkscape::ICON_SIZE_SMALL_TOOLBAR, INKSCAPE_ICON("text_line_spacing") ); layout_hbox.pack_start(*Gtk::manage(Glib::wrap(px)), false, false); @@ -132,6 +122,7 @@ TextEdit::TextEdit() layout_hbox.pack_start(*Gtk::manage(Glib::wrap(spacing_combo)), false, false); layout_frame.set_padding(4,4,4,4); layout_frame.add(layout_hbox); + */ // Text start Offset { @@ -146,12 +137,8 @@ TextEdit::TextEdit() gtk_widget_set_tooltip_text(startOffset, _("Text path offset")); -#if WITH_GTKMM_3_0 - Gtk::Separator *sep = Gtk::manage(new Gtk::Separator()); + auto sep = Gtk::manage(new Gtk::Separator()); sep->set_orientation(Gtk::ORIENTATION_VERTICAL); -#else - Gtk::VSeparator *sep = Gtk::manage(new Gtk::VSeparator); -#endif layout_hbox.pack_start(*sep, false, false, 10); layout_hbox.pack_start(*Gtk::manage(Glib::wrap(startOffset)), false, false); @@ -175,7 +162,6 @@ TextEdit::TextEdit() gtk_text_view_set_wrap_mode ((GtkTextView *) text_view, GTK_WRAP_WORD); #ifdef WITH_GTKSPELL -#ifdef WITH_GTKMM_3_0 /* TODO: Use computed xml:lang attribute of relevant element, if present, to specify the language (either as 2nd arg of gtkspell_new_attach, or with explicit @@ -187,20 +173,6 @@ TextEdit::TextEdit() if (! gtk_spell_checker_attach(speller, GTK_TEXT_VIEW(text_view))) { g_print("gtkspell error:\n"); } -#else - GError *error = NULL; - -/* - TODO: Use computed xml:lang attribute of relevant element, if present, to specify the - language (either as 2nd arg of gtkspell_new_attach, or with explicit - gtkspell_set_language call in; see advanced.c example in gtkspell docs). - onReadSelection looks like a suitable place. -*/ - if (gtkspell_new_attach(GTK_TEXT_VIEW(text_view), NULL, &error) == NULL) { - g_print("gtkspell error: %s\n", error->message); - g_error_free(error); - } -#endif #endif gtk_widget_set_size_request (text_view, -1, 64); @@ -226,7 +198,7 @@ TextEdit::TextEdit() /* Signal handlers */ g_signal_connect ( G_OBJECT (fontsel), "font_set", G_CALLBACK (onFontChange), this ); - g_signal_connect ( G_OBJECT (spacing_combo), "changed", G_CALLBACK (onLineSpacingChange), this ); + // g_signal_connect ( G_OBJECT (spacing_combo), "changed", G_CALLBACK (onLineSpacingChange), this ); g_signal_connect ( G_OBJECT (text_buffer), "changed", G_CALLBACK (onTextChange), this ); g_signal_connect(startOffset, "changed", G_CALLBACK(onStartOffsetChange), this); setasdefault_button.signal_clicked().connect(sigc::mem_fun(*this, &TextEdit::onSetDefault)); @@ -392,6 +364,7 @@ void TextEdit::onReadSelection ( gboolean dostyle, gboolean /*docontent*/ ) text_vertical.set_active(); } + /* double height; if (query.line_height.normal) height = Inkscape::Text::Layout::LINE_HEIGHT_NORMAL; else if (query.line_height.unit == SP_CSS_UNIT_PERCENT) @@ -401,6 +374,7 @@ void TextEdit::onReadSelection ( gboolean dostyle, gboolean /*docontent*/ ) gtk_entry_set_text ((GtkEntry *) gtk_bin_get_child ((GtkBin *) spacing_combo), sstr); g_free(sstr); + */ // Update font variant widget //int result_variants = @@ -443,8 +417,8 @@ SPItem *TextEdit::getSelectedTextItem (void) if (!SP_ACTIVE_DESKTOP) return NULL; - std::vector<SPItem*> tmp=SP_ACTIVE_DESKTOP->getSelection()->itemList(); - for(std::vector<SPItem*>::const_iterator i=tmp.begin();i!=tmp.end();++i) + auto tmp= SP_ACTIVE_DESKTOP->getSelection()->items(); + for(auto i=tmp.begin();i!=tmp.end();++i) { if (SP_IS_TEXT(*i) || SP_IS_FLOWTEXT(*i)) return *i; @@ -461,8 +435,8 @@ unsigned TextEdit::getSelectedTextCount (void) unsigned int items = 0; - std::vector<SPItem*> tmp=SP_ACTIVE_DESKTOP->getSelection()->itemList(); - for(std::vector<SPItem*>::const_iterator i=tmp.begin();i!=tmp.end();++i) + auto tmp= SP_ACTIVE_DESKTOP->getSelection()->items(); + for(auto i=tmp.begin();i!=tmp.end();++i) { if (SP_IS_TEXT(*i) || SP_IS_FLOWTEXT(*i)) ++items; @@ -535,11 +509,9 @@ SPCSSAttr *TextEdit::fillTextStyle () sp_repr_css_set_property (css, "writing-mode", "tb"); } - // Note that SVG 1.1 does not support line-height; we set it for consistency, but also set - // sodipodi:linespacing for backwards compatibility; in 1.2 we use line-height for flowtext - - const gchar *sstr = gtk_combo_box_text_get_active_text ((GtkComboBoxText *) spacing_combo); - sp_repr_css_set_property (css, "line-height", sstr); + // Note that SVG 1.1 does not support line-height but we use it. + // const gchar *sstr = gtk_combo_box_text_get_active_text ((GtkComboBoxText *) spacing_combo); + // sp_repr_css_set_property (css, "line-height", sstr); // Font variants vari_vbox.fill_css( css ); @@ -568,22 +540,15 @@ void TextEdit::onApply() SPDesktop *desktop = SP_ACTIVE_DESKTOP; unsigned items = 0; - const std::vector<SPItem*> item_list = desktop->getSelection()->itemList(); + auto item_list = desktop->getSelection()->items(); SPCSSAttr *css = fillTextStyle (); sp_desktop_set_style(desktop, css, true); - for(std::vector<SPItem*>::const_iterator i=item_list.begin();i!=item_list.end();++i){ + for(auto i=item_list.begin();i!=item_list.end();++i){ // apply style to the reprs of all text objects in the selection - if (SP_IS_TEXT (*i)) { - - // backwards compatibility: - (*i)->getRepr()->setAttribute("sodipodi:linespacing", sp_repr_css_property (css, "line-height", NULL)); - + if (SP_IS_TEXT (*i) || (SP_IS_FLOWTEXT (*i)) ) { ++items; } - else if (SP_IS_FLOWTEXT (*i)) - // no need to set sodipodi:linespacing, because Inkscape never supported it on flowtext - ++items; } if (items == 0) { diff --git a/src/ui/dialog/text-edit.h b/src/ui/dialog/text-edit.h index cfe612268..e974874d2 100644 --- a/src/ui/dialog/text-edit.h +++ b/src/ui/dialog/text-edit.h @@ -198,21 +198,10 @@ private: Gtk::RadioButton align_center; Gtk::RadioButton align_right; Gtk::RadioButton align_justify; - -#if WITH_GTKMM_3_0 Gtk::Separator align_sep; -#else - Gtk::VSeparator align_sep; -#endif - Gtk::RadioButton text_vertical; Gtk::RadioButton text_horizontal; - -#if WITH_GTKMM_3_0 Gtk::Separator text_sep; -#else - Gtk::VSeparator text_sep; -#endif GtkWidget *spacing_combo; diff --git a/src/ui/dialog/tile.h b/src/ui/dialog/tile.h index de1d3028b..2c29f85b8 100644 --- a/src/ui/dialog/tile.h +++ b/src/ui/dialog/tile.h @@ -29,12 +29,7 @@ namespace Gtk { class Button; - -#if WITH_GTKMM_3_0 class Grid; -#else -class Table; -#endif } namespace Inkscape { diff --git a/src/ui/dialog/tracedialog.cpp b/src/ui/dialog/tracedialog.cpp index 11e75391b..1c0cb5708 100644 --- a/src/ui/dialog/tracedialog.cpp +++ b/src/ui/dialog/tracedialog.cpp @@ -12,18 +12,17 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ #ifdef HAVE_CONFIG_H -# include <config.h> +#include "config.h" #endif #include "tracedialog.h" #include <gtkmm/notebook.h> #include <gtkmm/frame.h> +#include <gtkmm/radiobutton.h> #include "ui/widget/spinbutton.h" #include "ui/widget/frame.h" -#include <gtkmm/radiobutton.h> #include <gtkmm/stock.h> -#include <gtk/gtk.h> //for GTK_RESPONSE* types #include <glibmm/i18n.h> #include "desktop.h" diff --git a/src/ui/dialog/transformation.cpp b/src/ui/dialog/transformation.cpp index b7638e8c1..7f1492cd7 100644 --- a/src/ui/dialog/transformation.cpp +++ b/src/ui/dialog/transformation.cpp @@ -12,7 +12,7 @@ */ #ifdef HAVE_CONFIG_H -# include <config.h> +#include "config.h" #endif #include <gtkmm/dialog.h> @@ -26,15 +26,11 @@ #include "transformation.h" #include "align-and-distribute.h" #include "inkscape.h" -#include "selection.h" #include "selection-chemistry.h" #include "message-stack.h" #include "verbs.h" -#include "preferences.h" #include "sp-namedview.h" #include "sp-item-transform.h" -#include "macros.h" -#include "sp-item.h" #include "ui/icon-names.h" #include "widgets/icon.h" @@ -216,38 +212,20 @@ void Transformation::layoutPageMove() //_scalar_move_vertical.set_label_image( INKSCAPE_STOCK_ARROWS_HOR ); -#if WITH_GTKMM_3_0 _page_move.table().attach(_scalar_move_horizontal, 0, 0, 2, 1); _page_move.table().attach(_units_move, 2, 0, 1, 1); -#else - _page_move.table() - .attach(_scalar_move_horizontal, 0, 2, 0, 1, Gtk::FILL, Gtk::SHRINK); - - _page_move.table() - .attach(_units_move, 2, 3, 0, 1, Gtk::SHRINK, Gtk::SHRINK); -#endif _scalar_move_horizontal.signal_value_changed() .connect(sigc::mem_fun(*this, &Transformation::onMoveValueChanged)); //_scalar_move_vertical.set_label_image( INKSCAPE_STOCK_ARROWS_VER ); -#if WITH_GTKMM_3_0 _page_move.table().attach(_scalar_move_vertical, 0, 1, 2, 1); -#else - _page_move.table() - .attach(_scalar_move_vertical, 0, 2, 1, 2, Gtk::FILL, Gtk::SHRINK); -#endif _scalar_move_vertical.signal_value_changed() .connect(sigc::mem_fun(*this, &Transformation::onMoveValueChanged)); // Relative moves -#if WITH_GTKMM_3_0 _page_move.table().attach(_check_move_relative, 0, 2, 2, 1); -#else - _page_move.table() - .attach(_check_move_relative, 0, 2, 2, 3, Gtk::FILL, Gtk::SHRINK); -#endif _check_move_relative.set_active(true); _check_move_relative.signal_toggled() @@ -273,36 +251,18 @@ void Transformation::layoutPageScale() _scalar_scale_vertical.setAbsoluteIsIncrement(true); _scalar_scale_vertical.setPercentageIsIncrement(true); -#if WITH_GTKMM_3_0 _page_scale.table().attach(_scalar_scale_horizontal, 0, 0, 2, 1); -#else - _page_scale.table() - .attach(_scalar_scale_horizontal, 0, 2, 0, 1, Gtk::FILL, Gtk::SHRINK); -#endif _scalar_scale_horizontal.signal_value_changed() .connect(sigc::mem_fun(*this, &Transformation::onScaleXValueChanged)); -#if WITH_GTKMM_3_0 _page_scale.table().attach(_units_scale, 2, 0, 1, 1); _page_scale.table().attach(_scalar_scale_vertical, 0, 1, 2, 1); -#else - _page_scale.table() - .attach(_units_scale, 2, 3, 0, 1, Gtk::SHRINK, Gtk::SHRINK); - - _page_scale.table() - .attach(_scalar_scale_vertical, 0, 2, 1, 2, Gtk::FILL, Gtk::SHRINK); -#endif _scalar_scale_vertical.signal_value_changed() .connect(sigc::mem_fun(*this, &Transformation::onScaleYValueChanged)); -#if WITH_GTKMM_3_0 _page_scale.table().attach(_check_scale_proportional, 0, 2, 2, 1); -#else - _page_scale.table() - .attach(_check_scale_proportional, 0, 2, 2, 3, Gtk::FILL, Gtk::SHRINK); -#endif _check_scale_proportional.set_active(false); _check_scale_proportional.signal_toggled() @@ -334,24 +294,10 @@ void Transformation::layoutPageRotate() Gtk::RadioButton::Group group = _counterclockwise_rotate.get_group(); _clockwise_rotate.set_group(group); -#if WITH_GTKMM_3_0 _page_rotate.table().attach(_scalar_rotate, 0, 0, 2, 1); _page_rotate.table().attach(_units_rotate, 2, 0, 1, 1); _page_rotate.table().attach(_counterclockwise_rotate, 3, 0, 1, 1); _page_rotate.table().attach(_clockwise_rotate, 4, 0, 1, 1); -#else - _page_rotate.table() - .attach(_scalar_rotate, 0, 2, 0, 1, Gtk::FILL, Gtk::SHRINK); - - _page_rotate.table() - .attach(_units_rotate, 2, 3, 0, 1, Gtk::SHRINK, Gtk::SHRINK); - - _page_rotate.table() - .attach(_counterclockwise_rotate, 3, 4, 0, 1, Gtk::SHRINK, Gtk::SHRINK); - - _page_rotate.table() - .attach(_clockwise_rotate, 4, 5, 0, 1, Gtk::SHRINK, Gtk::SHRINK); -#endif Inkscape::Preferences *prefs = Inkscape::Preferences::get(); if (prefs->getBool("/dialogs/transformation/rotateCounterClockwise", TRUE)) { @@ -385,26 +331,13 @@ void Transformation::layoutPageSkew() _scalar_skew_vertical.setDigits(3); _scalar_skew_vertical.setIncrements(0.1, 1.0); -#if WITH_GTKMM_3_0 _page_skew.table().attach(_scalar_skew_horizontal, 0, 0, 2, 1); -#else - _page_skew.table() - .attach(_scalar_skew_horizontal, 0, 2, 0, 1, Gtk::FILL, Gtk::SHRINK); -#endif _scalar_skew_horizontal.signal_value_changed() .connect(sigc::mem_fun(*this, &Transformation::onSkewValueChanged)); -#if WITH_GTKMM_3_0 _page_skew.table().attach(_units_skew, 2, 0, 1, 1); _page_skew.table().attach(_scalar_skew_vertical, 0, 1, 2, 1); -#else - _page_skew.table() - .attach(_units_skew, 2, 3, 0, 1, Gtk::SHRINK, Gtk::SHRINK); - - _page_skew.table() - .attach(_scalar_skew_vertical, 0, 2, 1, 2, Gtk::FILL, Gtk::SHRINK); -#endif _scalar_skew_vertical.signal_value_changed() .connect(sigc::mem_fun(*this, &Transformation::onSkewValueChanged)); @@ -422,12 +355,7 @@ void Transformation::layoutPageTransform() _scalar_transform_a.setIncrements(0.1, 1.0); _scalar_transform_a.setValue(1.0); -#if WITH_GTKMM_3_0 _page_transform.table().attach(_scalar_transform_a, 0, 0, 1, 1); -#else - _page_transform.table() - .attach(_scalar_transform_a, 0, 1, 0, 1, Gtk::SHRINK, Gtk::SHRINK); -#endif _scalar_transform_a.signal_value_changed() .connect(sigc::mem_fun(*this, &Transformation::onTransformValueChanged)); @@ -438,12 +366,7 @@ void Transformation::layoutPageTransform() _scalar_transform_b.setIncrements(0.1, 1.0); _scalar_transform_b.setValue(0.0); -#if WITH_GTKMM_3_0 _page_transform.table().attach(_scalar_transform_b, 0, 1, 1, 1); -#else - _page_transform.table() - .attach(_scalar_transform_b, 0, 1, 1, 2, Gtk::SHRINK, Gtk::SHRINK); -#endif _scalar_transform_b.signal_value_changed() .connect(sigc::mem_fun(*this, &Transformation::onTransformValueChanged)); @@ -454,12 +377,7 @@ void Transformation::layoutPageTransform() _scalar_transform_c.setIncrements(0.1, 1.0); _scalar_transform_c.setValue(0.0); -#if WITH_GTKMM_3_0 _page_transform.table().attach(_scalar_transform_c, 1, 0, 1, 1); -#else - _page_transform.table() - .attach(_scalar_transform_c, 1, 2, 0, 1, Gtk::SHRINK, Gtk::SHRINK); -#endif _scalar_transform_c.signal_value_changed() .connect(sigc::mem_fun(*this, &Transformation::onTransformValueChanged)); @@ -471,12 +389,7 @@ void Transformation::layoutPageTransform() _scalar_transform_d.setIncrements(0.1, 1.0); _scalar_transform_d.setValue(1.0); -#if WITH_GTKMM_3_0 _page_transform.table().attach(_scalar_transform_d, 1, 1, 1, 1); -#else - _page_transform.table() - .attach(_scalar_transform_d, 1, 2, 1, 2, Gtk::SHRINK, Gtk::SHRINK); -#endif _scalar_transform_d.signal_value_changed() .connect(sigc::mem_fun(*this, &Transformation::onTransformValueChanged)); @@ -488,12 +401,7 @@ void Transformation::layoutPageTransform() _scalar_transform_e.setIncrements(0.1, 1.0); _scalar_transform_e.setValue(0.0); -#if WITH_GTKMM_3_0 _page_transform.table().attach(_scalar_transform_e, 2, 0, 1, 1); -#else - _page_transform.table() - .attach(_scalar_transform_e, 2, 3, 0, 1, Gtk::SHRINK, Gtk::SHRINK); -#endif _scalar_transform_e.signal_value_changed() .connect(sigc::mem_fun(*this, &Transformation::onTransformValueChanged)); @@ -505,23 +413,13 @@ void Transformation::layoutPageTransform() _scalar_transform_f.setIncrements(0.1, 1.0); _scalar_transform_f.setValue(0.0); -#if WITH_GTKMM_3_0 _page_transform.table().attach(_scalar_transform_f, 2, 1, 1, 1); -#else - _page_transform.table() - .attach(_scalar_transform_f, 2, 3, 1, 2, Gtk::SHRINK, Gtk::SHRINK); -#endif _scalar_transform_f.signal_value_changed() .connect(sigc::mem_fun(*this, &Transformation::onTransformValueChanged)); // Edit existing matrix -#if WITH_GTKMM_3_0 _page_transform.table().attach(_check_replace_matrix, 0, 2, 2, 1); -#else - _page_transform.table() - .attach(_check_replace_matrix, 0, 2, 2, 3, Gtk::FILL, Gtk::SHRINK); -#endif _check_replace_matrix.set_active(false); _check_replace_matrix.signal_toggled() @@ -568,11 +466,7 @@ void Transformation::updateSelection(PageType page, Inkscape::Selection *selecti selection && !selection->isEmpty()); } -#if WITH_GTKMM_3_0 void Transformation::onSwitchPage(Gtk::Widget * /*page*/, guint pagenum) -#else -void Transformation::onSwitchPage(GtkNotebookPage * /*page*/, guint pagenum) -#endif { updateSelection((PageType)pagenum, getDesktop()->getSelection()); } @@ -650,7 +544,7 @@ void Transformation::updatePageTransform(Inkscape::Selection *selection) { if (selection && !selection->isEmpty()) { if (_check_replace_matrix.get_active()) { - Geom::Affine current (selection->itemList()[0]->transform); // take from the first item in selection + Geom::Affine current (selection->items().front()->transform); // take from the first item in selection Geom::Affine new_displayed = current; @@ -723,19 +617,19 @@ void Transformation::applyPageMove(Inkscape::Selection *selection) if (!prefs->getBool("/dialogs/transformation/applyseparately")) { // move selection as a whole if (_check_move_relative.get_active()) { - sp_selection_move_relative(selection, x, y); + sp_object_set_move_relative(selection, x, y); } else { Geom::OptRect bbox = selection->preferredBounds(); if (bbox) { - sp_selection_move_relative(selection, - x - bbox->min()[Geom::X], y - bbox->min()[Geom::Y]); + sp_object_set_move_relative(selection, + x - bbox->min()[Geom::X], y - bbox->min()[Geom::Y]); } } } else { if (_check_move_relative.get_active()) { // shift each object relatively to the previous one - std::vector<SPItem*> selected(selection->itemList()); + std::vector<SPItem*> selected(selection->items().begin(), selection->items().end()); if (selected.empty()) return; if (fabs(x) > 1e-6) { @@ -791,8 +685,8 @@ void Transformation::applyPageMove(Inkscape::Selection *selection) } else { Geom::OptRect bbox = selection->preferredBounds(); if (bbox) { - sp_selection_move_relative(selection, - x - bbox->min()[Geom::X], y - bbox->min()[Geom::Y]); + sp_object_set_move_relative(selection, + x - bbox->min()[Geom::X], y - bbox->min()[Geom::Y]); } } } @@ -810,8 +704,8 @@ void Transformation::applyPageScale(Inkscape::Selection *selection) bool transform_stroke = prefs->getBool("/options/transform/stroke", true); bool preserve = prefs->getBool("/options/preservetransform/value", false); if (prefs->getBool("/dialogs/transformation/applyseparately")) { - std::vector<SPItem*> tmp=selection->itemList(); - for(std::vector<SPItem*>::const_iterator i=tmp.begin();i!=tmp.end();++i){ + auto tmp= selection->items(); + for(auto i=tmp.begin();i!=tmp.end();++i){ SPItem *item = *i; Geom::OptRect bbox_pref = item->desktopPreferredBounds(); Geom::OptRect bbox_geom = item->desktopGeometricBounds(); @@ -856,7 +750,7 @@ void Transformation::applyPageScale(Inkscape::Selection *selection) double y1 = bbox_pref->midpoint()[Geom::Y] + new_height/2; Geom::Affine scaler = get_scale_transform_for_variable_stroke (*bbox_pref, *bbox_geom, transform_stroke, preserve, x0, y0, x1, y1); - sp_selection_apply_affine(selection, scaler); + sp_object_set_apply_affine(selection, scaler); } } @@ -874,15 +768,15 @@ void Transformation::applyPageRotate(Inkscape::Selection *selection) } if (prefs->getBool("/dialogs/transformation/applyseparately")) { - std::vector<SPItem*> tmp=selection->itemList(); - for(std::vector<SPItem*>::const_iterator i=tmp.begin();i!=tmp.end();++i){ + auto tmp= selection->items(); + for(auto i=tmp.begin();i!=tmp.end();++i){ SPItem *item = *i; sp_item_rotate_rel(item, Geom::Rotate (angle*M_PI/180.0)); } } else { boost::optional<Geom::Point> center = selection->center(); if (center) { - sp_selection_rotate_relative(selection, *center, angle); + sp_object_set_rotate_relative(selection, *center, angle); } } @@ -894,8 +788,8 @@ void Transformation::applyPageSkew(Inkscape::Selection *selection) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); if (prefs->getBool("/dialogs/transformation/applyseparately")) { - std::vector<SPItem*> items=selection->itemList(); - for(std::vector<SPItem*>::const_iterator i = items.begin();i!=items.end();++i){ + auto items = selection->items(); + for(auto i = items.begin();i!=items.end();++i){ SPItem *item = *i; if (!_units_skew.isAbsolute()) { // percentage @@ -949,7 +843,7 @@ void Transformation::applyPageSkew(Inkscape::Selection *selection) getDesktop()->getMessageStack()->flash(Inkscape::WARNING_MESSAGE, _("Transform matrix is singular, <b>not used</b>.")); return; } - sp_selection_skew_relative(selection, *center, 0.01*skewX, 0.01*skewY); + sp_object_set_skew_relative(selection, *center, 0.01 * skewX, 0.01 * skewY); } else if (_units_skew.isRadial()) { //deg or rad double angleX = _scalar_skew_horizontal.getValue("rad"); double angleY = _scalar_skew_vertical.getValue("rad"); @@ -962,7 +856,7 @@ void Transformation::applyPageSkew(Inkscape::Selection *selection) } double skewX = tan(-angleX); double skewY = tan(angleY); - sp_selection_skew_relative(selection, *center, skewX, skewY); + sp_object_set_skew_relative(selection, *center, skewX, skewY); } else { // absolute displacement double skewX = _scalar_skew_horizontal.getValue("px"); double skewY = _scalar_skew_vertical.getValue("px"); @@ -970,7 +864,7 @@ void Transformation::applyPageSkew(Inkscape::Selection *selection) getDesktop()->getMessageStack()->flash(Inkscape::WARNING_MESSAGE, _("Transform matrix is singular, <b>not used</b>.")); return; } - sp_selection_skew_relative(selection, *center, skewX/height, skewY/width); + sp_object_set_skew_relative(selection, *center, skewX / height, skewY / width); } } } @@ -996,14 +890,14 @@ void Transformation::applyPageTransform(Inkscape::Selection *selection) } if (_check_replace_matrix.get_active()) { - std::vector<SPItem*> tmp=selection->itemList(); - for(std::vector<SPItem*>::const_iterator i=tmp.begin();i!=tmp.end();++i){ + auto tmp = selection->items(); + for(auto i=tmp.begin();i!=tmp.end();++i){ SPItem *item = *i; item->set_item_transform(displayed); item->updateRepr(); } } else { - sp_selection_apply_affine(selection, displayed); // post-multiply each object's transform + sp_object_set_apply_affine(selection, displayed); // post-multiply each object's transform } DocumentUndo::done(selection->desktop()->getDocument(), SP_VERB_DIALOG_TRANSFORM, @@ -1149,7 +1043,7 @@ void Transformation::onReplaceMatrixToggled() double f = _scalar_transform_f.getValue(); Geom::Affine displayed (a, b, c, d, e, f); - Geom::Affine current = selection->itemList()[0]->transform; // take from the first item in selection + Geom::Affine current = selection->items().front()->transform; // take from the first item in selection Geom::Affine new_displayed; if (_check_replace_matrix.get_active()) { diff --git a/src/ui/dialog/transformation.h b/src/ui/dialog/transformation.h index 89aa95d90..9595e87bc 100644 --- a/src/ui/dialog/transformation.h +++ b/src/ui/dialog/transformation.h @@ -169,11 +169,7 @@ protected: virtual void _apply(); void presentPage(PageType page); -#if WITH_GTKMM_3_0 void onSwitchPage(Gtk::Widget *page, guint pagenum); -#else - void onSwitchPage(GtkNotebookPage *page, guint pagenum); -#endif /** * Callbacks for when a user changes values on the panels diff --git a/src/ui/dialog/undo-history.cpp b/src/ui/dialog/undo-history.cpp index a50a169eb..53aa7e6ff 100644 --- a/src/ui/dialog/undo-history.cpp +++ b/src/ui/dialog/undo-history.cpp @@ -12,18 +12,14 @@ */ #ifdef HAVE_CONFIG_H -# include <config.h> +#include "config.h" #endif #include "undo-history.h" -#include <glibmm/i18n.h> -#include <stddef.h> -#include <sigc++/sigc++.h> #include "document.h" #include "document-undo.h" #include "inkscape.h" -#include "verbs.h" #include "util/signal-blocker.h" @@ -35,20 +31,11 @@ namespace UI { namespace Dialog { /* Rendering functions for custom cell renderers */ -#if WITH_GTKMM_3_0 void CellRendererSPIcon::render_vfunc(const Cairo::RefPtr<Cairo::Context>& cr, Gtk::Widget& widget, const Gdk::Rectangle& background_area, const Gdk::Rectangle& cell_area, Gtk::CellRendererState flags) -#else -void CellRendererSPIcon::render_vfunc(const Glib::RefPtr<Gdk::Drawable>& window, - Gtk::Widget& widget, - const Gdk::Rectangle& background_area, - const Gdk::Rectangle& cell_area, - const Gdk::Rectangle& expose_area, - Gtk::CellRendererState flags) -#endif { // if this event type doesn't have an icon... if ( !Inkscape::Verb::get(_property_event_type)->get_image() ) return; @@ -67,13 +54,8 @@ void CellRendererSPIcon::render_vfunc(const Glib::RefPtr<Gdk::Drawable>& window, sp_icon_fetch_pixbuf(sp_icon); _property_icon = Glib::wrap(sp_icon->pb, true); } else if ( GTK_IS_IMAGE(icon->gobj()) ) { -#if WITH_GTKMM_3_0 _property_icon = Gtk::Invisible().render_icon_pixbuf(Gtk::StockID(image), Gtk::ICON_SIZE_MENU); -#else - _property_icon = Gtk::Invisible().render_icon(Gtk::StockID(image), - Gtk::ICON_SIZE_MENU); -#endif } else { delete icon; return; @@ -87,42 +69,23 @@ void CellRendererSPIcon::render_vfunc(const Glib::RefPtr<Gdk::Drawable>& window, property_pixbuf() = _icon_cache[_property_event_type]; } -#if WITH_GTKMM_3_0 Gtk::CellRendererPixbuf::render_vfunc(cr, widget, background_area, cell_area, flags); -#else - Gtk::CellRendererPixbuf::render_vfunc(window, widget, background_area, - cell_area, expose_area, flags); -#endif } -#if WITH_GTKMM_3_0 void CellRendererInt::render_vfunc(const Cairo::RefPtr<Cairo::Context>& cr, Gtk::Widget& widget, const Gdk::Rectangle& background_area, const Gdk::Rectangle& cell_area, Gtk::CellRendererState flags) -#else -void CellRendererInt::render_vfunc(const Glib::RefPtr<Gdk::Drawable>& window, - Gtk::Widget& widget, - const Gdk::Rectangle& background_area, - const Gdk::Rectangle& cell_area, - const Gdk::Rectangle& expose_area, - Gtk::CellRendererState flags) -#endif { if( _filter(_property_number) ) { std::ostringstream s; s << _property_number << std::flush; property_text() = s.str(); -#if WITH_GTKMM_3_0 Gtk::CellRendererText::render_vfunc(cr, widget, background_area, cell_area, flags); -#else - Gtk::CellRendererText::render_vfunc(window, widget, background_area, - cell_area, expose_area, flags); -#endif } } diff --git a/src/ui/dialog/undo-history.h b/src/ui/dialog/undo-history.h index b0cc283cf..48929a0d0 100644 --- a/src/ui/dialog/undo-history.h +++ b/src/ui/dialog/undo-history.h @@ -50,20 +50,11 @@ public: property_event_type() { return _property_event_type.get_proxy(); } protected: -#if WITH_GTKMM_3_0 virtual void render_vfunc(const Cairo::RefPtr<Cairo::Context>& cr, Gtk::Widget& widget, const Gdk::Rectangle& background_area, const Gdk::Rectangle& cell_area, Gtk::CellRendererState flags); -#else - virtual void render_vfunc(const Glib::RefPtr<Gdk::Drawable>& window, - Gtk::Widget& widget, - const Gdk::Rectangle& background_area, - const Gdk::Rectangle& cell_area, - const Gdk::Rectangle& expose_area, - Gtk::CellRendererState flags); -#endif private: Glib::Property<Glib::RefPtr<Gdk::Pixbuf> > _property_icon; @@ -95,20 +86,11 @@ public: static const Filter& no_filter; protected: -#if WITH_GTKMM_3_0 virtual void render_vfunc(const Cairo::RefPtr<Cairo::Context>& cr, Gtk::Widget& widget, const Gdk::Rectangle& background_area, const Gdk::Rectangle& cell_area, Gtk::CellRendererState flags); -#else - virtual void render_vfunc(const Glib::RefPtr<Gdk::Drawable>& window, - Gtk::Widget& widget, - const Gdk::Rectangle& background_area, - const Gdk::Rectangle& cell_area, - const Gdk::Rectangle& expose_area, - Gtk::CellRendererState flags); -#endif private: diff --git a/src/ui/dialog/xml-tree.cpp b/src/ui/dialog/xml-tree.cpp index 99a4acc69..d05c52531 100644 --- a/src/ui/dialog/xml-tree.cpp +++ b/src/ui/dialog/xml-tree.cpp @@ -18,7 +18,6 @@ #include "xml-tree.h" #include "widgets/icon.h" -#include <gdk/gdkkeysyms.h> #include <glibmm/i18n.h> #include <gtkmm/stock.h> @@ -31,18 +30,14 @@ #include "helper/window.h" #include "inkscape.h" #include "ui/interface.h" -#include "macros.h" #include "message-context.h" #include "message-stack.h" -#include "preferences.h" -#include "selection.h" #include "shortcuts.h" #include "sp-root.h" #include "sp-string.h" #include "sp-tspan.h" #include "ui/icon-names.h" #include "verbs.h" -#include "widgets/icon.h" #include "widgets/sp-xmlview-attr-list.h" #include "widgets/sp-xmlview-content.h" @@ -79,11 +74,7 @@ XmlTree::XmlTree (void) : xml_attribute_delete_button (_("Delete attribute")), text_container (), attr_container (), -#if WITH_GTKMM_3_0 attr_subpaned_container(Gtk::ORIENTATION_VERTICAL), -#else - attr_subpaned_container(), -#endif set_attr (_("Set")), new_window(NULL) { @@ -100,9 +91,7 @@ XmlTree::XmlTree (void) : status.set_alignment( 0.0, 0.5); status.set_size_request(1, -1); status.set_markup(""); -#if WITH_GTKMM_3_0 status.set_line_wrap(true); -#endif status_box.pack_start( status, TRUE, TRUE, 0); contents->pack_end(status_box, false, false, 2); @@ -801,7 +790,8 @@ void XmlTree::on_attr_row_changed(SPXMLViewAttrList *attributes, const gchar * n void XmlTree::on_attr_unselect_row_clear_text() { attr_name.set_text(""); - attr_value.get_buffer()->set_text("", 0); + // Set text with empty Glib::ustring + attr_value.get_buffer()->set_text( Glib::ustring() ); } void XmlTree::onNameChanged() @@ -881,31 +871,19 @@ void XmlTree::cmd_new_element_node() g_signal_connect(G_OBJECT(new_window), "destroy", gtk_main_quit, NULL); g_signal_connect(G_OBJECT(new_window), "key-press-event", G_CALLBACK(quit_on_esc), new_window); -#if GTK_CHECK_VERSION(3,0,0) vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 4); gtk_box_set_homogeneous(GTK_BOX(vbox), FALSE); -#else - vbox = gtk_vbox_new(FALSE, 4); -#endif gtk_container_add(GTK_CONTAINER(new_window), vbox); name_entry = new Gtk::Entry(); gtk_box_pack_start(GTK_BOX(vbox), GTK_WIDGET(name_entry->gobj()), FALSE, TRUE, 0); -#if GTK_CHECK_VERSION(3,0,0) sep = gtk_separator_new(GTK_ORIENTATION_HORIZONTAL); -#else - sep = gtk_hseparator_new(); -#endif gtk_box_pack_start(GTK_BOX(vbox), sep, FALSE, TRUE, 0); -#if GTK_CHECK_VERSION(3,0,0) bbox = gtk_button_box_new(GTK_ORIENTATION_HORIZONTAL); -#else - bbox = gtk_hbutton_box_new(); -#endif gtk_container_set_border_width(GTK_CONTAINER(bbox), 4); gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END); diff --git a/src/ui/dialog/xml-tree.h b/src/ui/dialog/xml-tree.h index 58ef3aef8..a4c3fffcb 100644 --- a/src/ui/dialog/xml-tree.h +++ b/src/ui/dialog/xml-tree.h @@ -218,13 +218,7 @@ private: Gtk::Button *create_button; Gtk::Entry *name_entry; - -#if WITH_GTKMM_3_0 Gtk::Paned paned; -#else - Gtk::HPaned paned; -#endif - Gtk::VBox left_box; Gtk::VBox right_box; Gtk::HBox status_box; @@ -248,12 +242,7 @@ private: Gtk::ScrolledWindow text_container; Gtk::HBox attr_hbox; Gtk::VBox attr_container; - -#if WITH_GTKMM_3_0 Gtk::Paned attr_subpaned_container; -#else - Gtk::VPaned attr_subpaned_container; -#endif Gtk::Button set_attr; diff --git a/src/ui/interface.cpp b/src/ui/interface.cpp index ab29471ed..b47e66451 100644 --- a/src/ui/interface.cpp +++ b/src/ui/interface.cpp @@ -20,12 +20,13 @@ */ #ifdef HAVE_CONFIG_H -# include "config.h" +#include <config.h> #endif #include "ui/dialog/dialog-manager.h" #include <gtkmm/icontheme.h> #include "file.h" +#include <glibmm/miscutils.h> #include <gtkmm/imagemenuitem.h> #include <gtkmm/separatormenuitem.h> @@ -35,25 +36,20 @@ #include "extension/input.h" #include "widgets/icon.h" #include "preferences.h" -#include "path-prefix.h" #include "shortcuts.h" #include "document.h" #include "ui/interface.h" #include "desktop.h" -#include "selection.h" #include "selection-chemistry.h" #include "svg-view-widget.h" #include "widgets/desktop-widget.h" #include "sp-item-group.h" #include "sp-text.h" -#include "sp-gradient.h" #include "sp-flowtext.h" #include "sp-namedview.h" #include "sp-root.h" -#include "ui/view/view.h" #include "helper/action.h" -#include "helper/action-context.h" #include "helper/gnome-utils.h" #include "helper/window.h" #include "io/sys.h" @@ -63,7 +59,6 @@ #include "ui/clipboard.h" #include "display/sp-canvas.h" -#include "color.h" #include "svg/svg-color.h" #include "desktop-style.h" #include "style.h" @@ -74,18 +69,11 @@ #include "sp-anchor.h" #include "sp-clippath.h" #include "sp-image.h" -#include "sp-item.h" #include "sp-mask.h" #include "message-stack.h" #include "ui/dialog/layer-properties.h" -#if GTK_CHECK_VERSION(3,0,0) - #include "widgets/image-menu-item.h" -#endif - -#include <gdk/gdkkeysyms.h> - -#include <glibmm/miscutils.h> +#include "widgets/image-menu-item.h" using Inkscape::DocumentUndo; @@ -417,11 +405,7 @@ sp_ui_menuitem_add_icon( GtkWidget *item, gchar *icon_name ) icon = sp_icon_new( Inkscape::ICON_SIZE_MENU, icon_name ); gtk_widget_show(icon); -#if GTK_CHECK_VERSION(3,0,0) image_menu_item_set_image((ImageMenuItem *) item, icon); -#else - gtk_image_menu_item_set_image((GtkImageMenuItem *) item, icon); -#endif } // end of sp_ui_menu_add_icon void @@ -475,11 +459,7 @@ static GtkWidget *sp_ui_menu_append_item_from_verb(GtkMenu *menu, Inkscape::Verb if (radio) { item = gtk_radio_menu_item_new_with_mnemonic(group, action->name); } else { -#if GTK_CHECK_VERSION(3,0,0) item = image_menu_item_new_with_mnemonic(action->name); -#else - item = gtk_image_menu_item_new_with_mnemonic(action->name); -#endif } gtk_label_set_markup_with_mnemonic( GTK_LABEL(gtk_bin_get_child(GTK_BIN (item))), action->name); @@ -570,11 +550,7 @@ static bool getViewStateFromPref(Inkscape::UI::View::View *view, gchar const *pr return prefs->getBool(pref_path, true); } -#if GTK_CHECK_VERSION(3,0,0) static gboolean checkitem_update(GtkWidget *widget, cairo_t * /*cr*/, gpointer user_data) -#else -static gboolean checkitem_update(GtkWidget *widget, GdkEventExpose * /*event*/, gpointer user_data) -#endif { GtkCheckMenuItem *menuitem=GTK_CHECK_MENU_ITEM(widget); @@ -631,11 +607,7 @@ static void taskToggled(GtkCheckMenuItem *menuitem, gpointer userData) /** * Callback function to update the status of the radio buttons in the View -> Display mode menu (Normal, No Filters, Outline) and Color display mode. */ -#if GTK_CHECK_VERSION(3,0,0) static gboolean update_view_menu(GtkWidget *widget, cairo_t * /*cr*/, gpointer user_data) -#else -static gboolean update_view_menu(GtkWidget *widget, GdkEventExpose * /*event*/, gpointer user_data) -#endif { SPAction *action = (SPAction *) user_data; g_assert(action->id != NULL); @@ -679,11 +651,7 @@ static gboolean update_view_menu(GtkWidget *widget, GdkEventExpose * /*event*/, static void sp_ui_menu_append_check_item_from_verb(GtkMenu *menu, Inkscape::UI::View::View *view, gchar const *label, gchar const *tip, gchar const *pref, void (*callback_toggle)(GtkCheckMenuItem *, gpointer user_data), -#if GTK_CHECK_VERSION(3,0,0) gboolean (*callback_update)(GtkWidget *widget, cairo_t *cr, gpointer user_data), -#else - gboolean (*callback_update)(GtkWidget *widget, GdkEventExpose *event, gpointer user_data), -#endif Inkscape::Verb *verb) { unsigned int shortcut = (verb) ? sp_shortcut_get_primary(verb) : 0; @@ -707,11 +675,7 @@ sp_ui_menu_append_check_item_from_verb(GtkMenu *menu, Inkscape::UI::View::View * g_signal_connect( G_OBJECT(item), "toggled", (GCallback) callback_toggle, (void *) pref); -#if GTK_CHECK_VERSION(3,0,0) g_signal_connect( G_OBJECT(item), "draw", (GCallback) callback_update, (void *) pref); -#else - g_signal_connect( G_OBJECT(item), "expose_event", (GCallback) callback_update, (void *) pref); -#endif (*callback_update)(item, NULL, (void *)pref); @@ -854,11 +818,7 @@ static void sp_ui_build_dyn_menus(Inkscape::XML::Node *menus, GtkWidget *menu, I } if (verb->get_code() != SP_VERB_NONE) { SPAction *action = verb->get_action(Inkscape::ActionContext(view)); -#if GTK_CHECK_VERSION(3,0,0) g_signal_connect( G_OBJECT(item), "draw", (GCallback) update_view_menu, (void *) action); -#else - g_signal_connect( G_OBJECT(item), "expose_event", (GCallback) update_view_menu, (void *) action); -#endif } } else if (menu_pntr->attribute("check") != NULL) { if (verb->get_code() != SP_VERB_NONE) { @@ -1250,7 +1210,7 @@ sp_ui_drag_data_received(GtkWidget *widget, Geom::OptRect sel_bbox = selection->visualBounds(); if (sel_bbox) { Geom::Point m( desktop->point() - sel_bbox->midpoint() ); - sp_selection_move_relative(selection, m, false); + sp_object_set_move_relative(selection, m, false); } } @@ -2096,8 +2056,8 @@ void ContextMenu::ImageEdit(void) } #endif - std::vector<SPItem*> itemlist=_desktop->selection->itemList(); - for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();++i){ + auto itemlist= _desktop->selection->items(); + for(auto i=itemlist.begin();i!=itemlist.end();++i){ Inkscape::XML::Node *ir = (*i)->getRepr(); const gchar *href = ir->attribute("xlink:href"); diff --git a/src/ui/object-edit.cpp b/src/ui/object-edit.cpp index 459acf002..2763e6c4b 100644 --- a/src/ui/object-edit.cpp +++ b/src/ui/object-edit.cpp @@ -12,11 +12,9 @@ */ #ifdef HAVE_CONFIG_H -# include "config.h" +#include <config.h> #endif - - #include "sp-item.h" #include "sp-rect.h" #include "box3d.h" @@ -32,11 +30,8 @@ #include "sp-namedview.h" #include "live_effects/effect.h" #include "sp-pattern.h" -#include "sp-path.h" #include <glibmm/i18n.h> #include "ui/object-edit.h" -#include "xml/repr.h" -#include <2geom/math-utils.h> #include "knot-holder-entity.h" #define sp_round(v,m) (((v) < 0.0) ? ((ceil((v) / (m) - 0.5)) * (m)) : ((floor((v) / (m) + 0.5)) * (m))) @@ -800,8 +795,11 @@ sp_genericellipse_side(SPGenericEllipse *ellipse, Geom::Point const &p) gdouble dy = (p[Geom::Y] - ellipse->cy.computed) / ellipse->ry.computed; gdouble s = dx * dx + dy * dy; - if (s < 1.0) return 1; - if (s > 1.0) return -1; + // We add a bit of a buffer, so there's a decent chance the user will + // be able to adjust the arc without the closed status flipping between + // open and closed during micro mouse movements. + if (s < 0.75) return 1; + if (s > 1.25) return -1; return 0; } @@ -813,16 +811,21 @@ ArcKnotHolderEntityStart::knot_set(Geom::Point const &p, Geom::Point const &/*or SPGenericEllipse *arc = dynamic_cast<SPGenericEllipse *>(item); g_assert(arc != NULL); - arc->setClosed(sp_genericellipse_side(arc, p) == -1); + gint side = sp_genericellipse_side(arc, p); + if(side != 0) { arc->setClosed(side == -1); } Geom::Point delta = p - Geom::Point(arc->cx.computed, arc->cy.computed); Geom::Scale sc(arc->rx.computed, arc->ry.computed); - arc->start = atan2(delta * sc.inverse()); + double offset = arc->start - atan2(delta * sc.inverse()); + arc->start -= offset; if ((state & GDK_CONTROL_MASK) && snaps) { arc->start = sp_round(arc->start, M_PI / snaps); } + if (state & GDK_SHIFT_MASK) { + arc->end -= offset; + } arc->normalize(); arc->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); @@ -857,16 +860,21 @@ ArcKnotHolderEntityEnd::knot_set(Geom::Point const &p, Geom::Point const &/*orig SPGenericEllipse *arc = dynamic_cast<SPGenericEllipse *>(item); g_assert(arc != NULL); - arc->setClosed(sp_genericellipse_side(arc, p) == -1); + gint side = sp_genericellipse_side(arc, p); + if(side != 0) { arc->setClosed(side == -1); } Geom::Point delta = p - Geom::Point(arc->cx.computed, arc->cy.computed); Geom::Scale sc(arc->rx.computed, arc->ry.computed); - arc->end = atan2(delta * sc.inverse()); + double offset = arc->end - atan2(delta * sc.inverse()); + arc->end -= offset; if ((state & GDK_CONTROL_MASK) && snaps) { arc->end = sp_round(arc->end, M_PI/snaps); } + if (state & GDK_SHIFT_MASK) { + arc->start -= offset; + } arc->normalize(); arc->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); @@ -988,13 +996,15 @@ ArcKnotHolder::ArcKnotHolder(SPDesktop *desktop, SPItem *item, SPKnotHolderRelea SP_KNOT_SHAPE_SQUARE, SP_KNOT_MODE_XOR); entity_start->create(desktop, item, this, Inkscape::CTRL_TYPE_ROTATE, - _("Position the <b>start point</b> of the arc or segment; with <b>Ctrl</b> " - "to snap angle; drag <b>inside</b> the ellipse for arc, <b>outside</b> for segment"), + _("Position the <b>start point</b> of the arc or segment; with <b>Shift</b> to move " + "with <b>end point</b>; with <b>Ctrl</b> to snap angle; drag <b>inside</b> the " + "ellipse for arc, <b>outside</b> for segment"), SP_KNOT_SHAPE_CIRCLE, SP_KNOT_MODE_XOR); entity_end->create(desktop, item, this, Inkscape::CTRL_TYPE_ROTATE, - _("Position the <b>end point</b> of the arc or segment; with <b>Ctrl</b> to snap angle; " - "drag <b>inside</b> the ellipse for arc, <b>outside</b> for segment"), + _("Position the <b>end point</b> of the arc or segment; with <b>Shift</b> to move " + "with <b>start point</b>; with <b>Ctrl</b> to snap angle; drag <b>inside</b> the " + "ellipse for arc, <b>outside</b> for segment"), SP_KNOT_SHAPE_CIRCLE, SP_KNOT_MODE_XOR); entity.push_back(entity_rx); diff --git a/src/ui/previewholder.cpp b/src/ui/previewholder.cpp index 5e75179a3..ef11daa3b 100644 --- a/src/ui/previewholder.cpp +++ b/src/ui/previewholder.cpp @@ -12,18 +12,12 @@ #include "previewholder.h" -#include "preferences.h" #include <gtkmm/scrolledwindow.h> #include <gtkmm/sizegroup.h> #include <gtkmm/scrollbar.h> #include <gtkmm/adjustment.h> - -#if WITH_GTKMM_3_0 -# include <gtkmm/grid.h> -#else -# include <gtkmm/table.h> -#endif +#include <gtkmm/grid.h> #define COLUMNS_FOR_SMALL 16 #define COLUMNS_FOR_LARGE 8 @@ -55,7 +49,6 @@ PreviewHolder::PreviewHolder() : ((Gtk::ScrolledWindow *)_scroller)->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); -#if WITH_GTKMM_3_0 _insides = Gtk::manage(new Gtk::Grid()); _insides->set_name( "PreviewHolderGrid" ); _insides->set_column_spacing(8); @@ -66,21 +59,9 @@ PreviewHolder::PreviewHolder() : _scroller->set_hexpand(); _scroller->set_vexpand(); -#else - _insides = Gtk::manage(new Gtk::Table( 1, 2 )); - _insides->set_col_spacings( 8 ); - - // Add a container with the scroller and a spacer - Gtk::Table* spaceHolder = Gtk::manage( new Gtk::Table(1, 2) ); -#endif - _scroller->add( *_insides ); -#if WITH_GTKMM_3_0 spaceHolder->attach( *_scroller, 0, 0, 1, 1); -#else - spaceHolder->attach( *_scroller, 0, 1, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND ); -#endif pack_start(*spaceHolder, Gtk::PACK_EXPAND_WIDGET); } @@ -93,11 +74,7 @@ PreviewHolder::~PreviewHolder() bool PreviewHolder::on_scroll_event(GdkEventScroll *event) { // Scroll horizontally by page on mouse wheel -#if WITH_GTKMM_3_0 - Glib::RefPtr<Gtk::Adjustment> adj = dynamic_cast<Gtk::ScrolledWindow*>(_scroller)->get_hadjustment(); -#else - Gtk::Adjustment *adj = dynamic_cast<Gtk::ScrolledWindow*>(_scroller)->get_hadjustment(); -#endif + auto adj = dynamic_cast<Gtk::ScrolledWindow*>(_scroller)->get_hadjustment(); if (!adj) { return FALSE; @@ -141,7 +118,6 @@ void PreviewHolder::addPreview( Previewable* preview ) Gtk::Widget* label = Gtk::manage(preview->getPreview(PREVIEW_STYLE_BLURB, VIEW_TYPE_LIST, _baseSize, _ratio, _border)); Gtk::Widget* thing = Gtk::manage(preview->getPreview(PREVIEW_STYLE_PREVIEW, VIEW_TYPE_LIST, _baseSize, _ratio, _border)); -#if WITH_GTKMM_3_0 thing->set_hexpand(); thing->set_vexpand(); _insides->attach(*thing, 0, i, 1, 1); @@ -149,10 +125,6 @@ void PreviewHolder::addPreview( Previewable* preview ) label->set_hexpand(); label->set_valign(Gtk::ALIGN_CENTER); _insides->attach(*label, 1, i, 1, 1); -#else - _insides->attach( *thing, 0, 1, i, i+1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND ); - _insides->attach( *label, 1, 2, i, i+1, Gtk::FILL|Gtk::EXPAND, Gtk::SHRINK ); -#endif } break; @@ -168,44 +140,25 @@ void PreviewHolder::addPreview( Previewable* preview ) int col = i % width; int row = i / width; -#if !WITH_GTKMM_3_0 - // If the existing grid isn't wide enough, we need to resize - // it and re-pack the existing widgets - if ( _insides && width > (int)_insides->property_n_columns() ) { - _insides->resize( height, width ); -#endif - std::vector<Gtk::Widget*>kids = _insides->get_children(); - int childCount = (int)kids.size(); - // g_message(" %3d resize from %d to %d (r:%d, c:%d) with %d children", i, oldWidth, width, row, col, childCount ); - - // Loop through the existing widgets and move them to new location - for ( int j = 1; j < childCount; j++ ) { - Gtk::Widget* target = kids[childCount - (j + 1)]; - int col2 = j % width; - int row2 = j / width; - Glib::RefPtr<Gtk::Widget> handle(target); - _insides->remove( *target ); - -#if WITH_GTKMM_3_0 - target->set_hexpand(); - target->set_vexpand(); - _insides->attach( *target, col2, row2, 1, 1); -#else - _insides->attach( *target, col2, col2+1, row2, row2+1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND ); -#endif - } -#if WITH_GTKMM_3_0 - thing->set_hexpand(); - thing->set_vexpand(); - _insides->attach(*thing, col, row, 1, 1); -#else - } else if ( col == 0 ) { - // we just started a new row - _insides->resize( row + 1, width ); - } - - _insides->attach( *thing, col, col+1, row, row+1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND ); -#endif + auto kids = _insides->get_children(); + int childCount = (int)kids.size(); + // g_message(" %3d resize from %d to %d (r:%d, c:%d) with %d children", i, oldWidth, width, row, col, childCount ); + + // Loop through the existing widgets and move them to new location + for ( int j = 1; j < childCount; j++ ) { + auto target = kids[childCount - (j + 1)]; + int col2 = j % width; + int row2 = j / width; + Glib::RefPtr<Gtk::Widget> handle(target); + _insides->remove( *target ); + + target->set_hexpand(); + target->set_vexpand(); + _insides->attach( *target, col2, row2, 1, 1); + } + thing->set_hexpand(); + thing->set_vexpand(); + _insides->attach(*thing, col, row, 1, 1); } } @@ -305,12 +258,8 @@ void PreviewHolder::on_size_allocate( Gtk::Allocation& allocation ) if ( _insides && !_wrap && (_view != VIEW_TYPE_LIST) && (_anchor == SP_ANCHOR_NORTH || _anchor == SP_ANCHOR_SOUTH) ) { Gtk::Requisition req; -#if GTK_CHECK_VERSION(3,0,0) Gtk::Requisition req_natural; _insides->get_preferred_size(req, req_natural); -#else - req = _insides->size_request(); -#endif gint delta = allocation.get_width() - req.width; if ( (delta > 4) && req.height < allocation.get_height() ) { @@ -352,43 +301,27 @@ void PreviewHolder::calcGridSize( const Gtk::Widget* thing, int itemCount, int& if ( _anchor == SP_ANCHOR_SOUTH || _anchor == SP_ANCHOR_NORTH ) { Gtk::Requisition req; -#if GTK_CHECK_VERSION(3,0,0) Gtk::Requisition req_natural; _scroller->get_preferred_size(req, req_natural); -#else - req = _scroller->size_request(); -#endif int currW = _scroller->get_width(); if ( currW > req.width ) { req.width = currW; } -#if GTK_CHECK_VERSION(3,0,0) - Gtk::Scrollbar* hs = dynamic_cast<Gtk::ScrolledWindow*>(_scroller)->get_hscrollbar(); -#else - Gtk::HScrollbar* hs = dynamic_cast<Gtk::ScrolledWindow*>(_scroller)->get_hscrollbar(); -#endif + auto hs = dynamic_cast<Gtk::ScrolledWindow*>(_scroller)->get_hscrollbar(); if ( hs ) { Gtk::Requisition scrollReq; -#if GTK_CHECK_VERSION(3,0,0) Gtk::Requisition scrollReq_natural; hs->get_preferred_size(scrollReq, scrollReq_natural); -#else - scrollReq = hs->size_request(); -#endif // the +8 is a temporary hack req.height -= scrollReq.height + 8; } Gtk::Requisition req2; -#if GTK_CHECK_VERSION(3,0,0) Gtk::Requisition req2_natural; const_cast<Gtk::Widget*>(thing)->get_preferred_size(req2, req2_natural); -#else - req2 = const_cast<Gtk::Widget*>(thing)->size_request(); -#endif int h2 = ((req2.height > 0) && (req.height > req2.height)) ? (req.height / req2.height) : 1; int w2 = ((req2.width > 0) && (req.width > req2.width)) ? (req.width / req2.width) : 1; @@ -416,21 +349,11 @@ void PreviewHolder::rebuildUI() switch(_view) { case VIEW_TYPE_LIST: { - -#if WITH_GTKMM_3_0 _insides = Gtk::manage(new Gtk::Grid()); _insides->set_column_spacing(8); -#else - _insides = Gtk::manage(new Gtk::Table( 1, 2 )); - _insides->set_col_spacings( 8 ); -#endif if (_border == BORDER_WIDE) { -#if WITH_GTKMM_3_0 _insides->set_row_spacing(1); -#else - _insides->set_row_spacings( 1 ); -#endif } for ( unsigned int i = 0; i < items.size(); i++ ) { @@ -439,7 +362,6 @@ void PreviewHolder::rebuildUI() Gtk::Widget* thing = Gtk::manage(items[i]->getPreview(PREVIEW_STYLE_PREVIEW, _view, _baseSize, _ratio, _border)); -#if WITH_GTKMM_3_0 thing->set_hexpand(); thing->set_vexpand(); _insides->attach(*thing, 0, i, 1, 1); @@ -447,10 +369,6 @@ void PreviewHolder::rebuildUI() label->set_hexpand(); label->set_valign(Gtk::ALIGN_CENTER); _insides->attach(*label, 1, i, 1, 1); -#else - _insides->attach( *thing, 0, 1, i, i+1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND ); - _insides->attach( *label, 1, 2, i, i+1, Gtk::FILL|Gtk::EXPAND, Gtk::SHRINK ); -#endif } _scroller->add( *_insides ); @@ -473,28 +391,16 @@ void PreviewHolder::rebuildUI() if ( !_insides ) { calcGridSize( thing, items.size(), width, height ); -#if WITH_GTKMM_3_0 _insides = Gtk::manage(new Gtk::Grid()); if (_border == BORDER_WIDE) { _insides->set_column_spacing(1); _insides->set_row_spacing(1); } -#else - _insides = Gtk::manage(new Gtk::Table( height, width )); - if (_border == BORDER_WIDE) { - _insides->set_col_spacings( 1 ); - _insides->set_row_spacings( 1 ); - } -#endif } -#if WITH_GTKMM_3_0 thing->set_hexpand(); thing->set_vexpand(); _insides->attach( *thing, col, row, 1, 1); -#else - _insides->attach( *thing, col, col+1, row, row+1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND ); -#endif if ( ++col >= width ) { col = 0; @@ -502,11 +408,7 @@ void PreviewHolder::rebuildUI() } } if ( !_insides ) { -#if WITH_GTKMM_3_0 _insides = Gtk::manage(new Gtk::Grid()); -#else - _insides = Gtk::manage(new Gtk::Table( 1, 2 )); -#endif } _scroller->add( *_insides ); diff --git a/src/ui/previewholder.h b/src/ui/previewholder.h index 28c0fd865..d370e8fc8 100644 --- a/src/ui/previewholder.h +++ b/src/ui/previewholder.h @@ -21,11 +21,7 @@ #include <gtkmm/bin.h> namespace Gtk { -#if WITH_GTKMM_3_0 class Grid; -#else -class Table; -#endif } #include "previewfillable.h" @@ -68,12 +64,7 @@ private: std::vector<Previewable*> items; Gtk::Bin *_scroller; - -#if WITH_GTKMM_3_0 Gtk::Grid *_insides; -#else - Gtk::Table *_insides; -#endif int _prefCols; bool _updatesFrozen; diff --git a/src/ui/selected-color.cpp b/src/ui/selected-color.cpp index 846d50a5b..08f4bd979 100644 --- a/src/ui/selected-color.cpp +++ b/src/ui/selected-color.cpp @@ -11,7 +11,7 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ #ifdef HAVE_CONFIG_H -# include "config.h" +#include <config.h> #endif #include <glibmm/ustring.h> diff --git a/src/ui/shape-editor.cpp b/src/ui/shape-editor.cpp index aec5cde27..98320ed8c 100644 --- a/src/ui/shape-editor.cpp +++ b/src/ui/shape-editor.cpp @@ -8,7 +8,7 @@ */ #ifdef HAVE_CONFIG_H -#include "config.h" +#include <config.h> #endif #include <string.h> @@ -16,11 +16,8 @@ #include "desktop.h" #include "document.h" -#include "gc-anchored.h" #include "knotholder.h" #include "ui/object-edit.h" -#include "sp-item.h" -#include "sp-object.h" #include "ui/shape-editor.h" #include "xml/node-event-vector.h" diff --git a/src/ui/tool-factory.cpp b/src/ui/tool-factory.cpp index c6c579c9e..f101e5a24 100644 --- a/src/ui/tool-factory.cpp +++ b/src/ui/tool-factory.cpp @@ -27,14 +27,12 @@ #include "ui/tools/mesh-tool.h" #include "ui/tools/node-tool.h" #include "ui/tools/pencil-tool.h" -#include "ui/tools/pen-tool.h" #include "ui/tools/rect-tool.h" #include "ui/tools/select-tool.h" #include "ui/tools/spiral-tool.h" #include "ui/tools/spray-tool.h" #include "ui/tools/star-tool.h" #include "ui/tools/text-tool.h" -#include "ui/tools/tool-base.h" #include "ui/tools/tweak-tool.h" #include "ui/tools/zoom-tool.h" diff --git a/src/ui/tool/Makefile_insert b/src/ui/tool/Makefile_insert deleted file mode 100644 index f46f48b72..000000000 --- a/src/ui/tool/Makefile_insert +++ /dev/null @@ -1,30 +0,0 @@ -## Makefile.am fragment sourced by src/Makefile.am. - -ink_common_sources += \ - ui/tool/control-point.cpp \ - ui/tool/control-point.h \ - ui/tool/control-point-selection.cpp \ - ui/tool/control-point-selection.h \ - ui/tool/commit-events.h \ - ui/tool/curve-drag-point.cpp \ - ui/tool/curve-drag-point.h \ - ui/tool/event-utils.cpp \ - ui/tool/event-utils.h \ - ui/tool/manipulator.cpp \ - ui/tool/manipulator.h \ - ui/tool/modifier-tracker.cpp \ - ui/tool/modifier-tracker.h \ - ui/tool/multi-path-manipulator.cpp \ - ui/tool/multi-path-manipulator.h \ - ui/tool/node.cpp \ - ui/tool/node.h \ - ui/tool/node-types.h \ - ui/tool/path-manipulator.cpp \ - ui/tool/path-manipulator.h \ - ui/tool/selectable-control-point.cpp \ - ui/tool/selectable-control-point.h \ - ui/tool/selector.cpp \ - ui/tool/selector.h \ - ui/tool/shape-record.h \ - ui/tool/transform-handle-set.cpp \ - ui/tool/transform-handle-set.h diff --git a/src/ui/tool/control-point-selection.cpp b/src/ui/tool/control-point-selection.cpp index f36ad7374..a5611addc 100644 --- a/src/ui/tool/control-point-selection.cpp +++ b/src/ui/tool/control-point-selection.cpp @@ -13,7 +13,6 @@ #include "ui/tool/selectable-control-point.h" #include <2geom/transforms.h> #include "desktop.h" -#include "preferences.h" #include "ui/tool/control-point-selection.h" #include "ui/tool/event-utils.h" #include "ui/tool/transform-handle-set.h" diff --git a/src/ui/tool/control-point.cpp b/src/ui/tool/control-point.cpp index 636595016..d9374c790 100644 --- a/src/ui/tool/control-point.cpp +++ b/src/ui/tool/control-point.cpp @@ -16,8 +16,6 @@ #include "display/snap-indicator.h" #include "ui/tools/tool-base.h" #include "message-context.h" -#include "preferences.h" -#include "snap-preferences.h" #include "sp-namedview.h" #include "ui/control-manager.h" #include "ui/tool/control-point.h" diff --git a/src/ui/tool/curve-drag-point.cpp b/src/ui/tool/curve-drag-point.cpp index e460b0fb7..908e18474 100644 --- a/src/ui/tool/curve-drag-point.cpp +++ b/src/ui/tool/curve-drag-point.cpp @@ -8,15 +8,12 @@ #include "ui/tool/curve-drag-point.h" #include <glib/gi18n.h> -#include <2geom/bezier-curve.h> #include "desktop.h" #include "ui/tool/control-point-selection.h" #include "ui/tool/event-utils.h" #include "ui/tool/multi-path-manipulator.h" #include "ui/tool/path-manipulator.h" -#include "ui/tool/node.h" #include "sp-namedview.h" -#include "snap.h" namespace Inkscape { namespace UI { diff --git a/src/ui/tool/manipulator.cpp b/src/ui/tool/manipulator.cpp index 11dd220f4..82ff014e4 100644 --- a/src/ui/tool/manipulator.cpp +++ b/src/ui/tool/manipulator.cpp @@ -8,8 +8,8 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include "ui/tool/node.h" -#include "ui/tool/manipulator.h" +//#include "ui/tool/node.h" +//#include "ui/tool/manipulator.h" namespace Inkscape { namespace UI { diff --git a/src/ui/tool/modifier-tracker.cpp b/src/ui/tool/modifier-tracker.cpp index cc4e4d0b2..f502acab2 100644 --- a/src/ui/tool/modifier-tracker.cpp +++ b/src/ui/tool/modifier-tracker.cpp @@ -12,7 +12,6 @@ #include <gdk/gdkkeysyms.h> #include "ui/tool/event-utils.h" #include "ui/tool/modifier-tracker.h" -#include <gtk/gtk.h> namespace Inkscape { namespace UI { diff --git a/src/ui/tool/multi-path-manipulator.cpp b/src/ui/tool/multi-path-manipulator.cpp index 9ec6f733f..f30c7e349 100644 --- a/src/ui/tool/multi-path-manipulator.cpp +++ b/src/ui/tool/multi-path-manipulator.cpp @@ -19,13 +19,11 @@ #include "document-undo.h" #include "live_effects/lpeobject.h" #include "message-stack.h" -#include "preferences.h" #include "sp-path.h" #include "ui/tool/control-point-selection.h" #include "ui/tool/event-utils.h" #include "ui/tool/multi-path-manipulator.h" #include "ui/tool/path-manipulator.h" -#include "util/unordered-containers.h" #include "verbs.h" #include <gdk/gdkkeysyms.h> diff --git a/src/ui/tool/node.cpp b/src/ui/tool/node.cpp index 9268d9730..0e5a9279d 100644 --- a/src/ui/tool/node.cpp +++ b/src/ui/tool/node.cpp @@ -12,25 +12,20 @@ #include "multi-path-manipulator.h" #include <glib/gi18n.h> #include <2geom/bezier-utils.h> -#include <2geom/transforms.h> #include "display/sp-ctrlline.h" #include "display/sp-canvas.h" #include "display/sp-canvas-util.h" #include "desktop.h" -#include "preferences.h" #include "snap.h" -#include "snap-preferences.h" #include "sp-namedview.h" #include "ui/control-manager.h" #include "ui/tool/control-point-selection.h" #include "ui/tool/event-utils.h" -#include "ui/tool/node.h" #include "ui/tool/path-manipulator.h" #include "ui/tools/node-tool.h" #include "ui/tools-switch.h" #include <gdk/gdkkeysyms.h> -#include <cmath> namespace { diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp index de071dad3..f316bea38 100644 --- a/src/ui/tool/path-manipulator.cpp +++ b/src/ui/tool/path-manipulator.cpp @@ -13,36 +13,23 @@ #include "live_effects/lpe-powerstroke.h" #include "live_effects/lpe-bspline.h" #include "live_effects/lpe-fillet-chamfer.h" -#include <string> -#include <sstream> -#include <deque> -#include <stdexcept> -#include <boost/shared_ptr.hpp> -#include <2geom/bezier-curve.h> #include <2geom/bezier-utils.h> #include <2geom/path-sink.h> -#include <glibmm/i18n.h> #include "ui/tool/path-manipulator.h" -#include "desktop.h" #include "display/sp-canvas.h" #include "display/sp-canvas-util.h" #include "display/curve.h" #include "display/canvas-bpath.h" -#include "document.h" -#include "live_effects/effect.h" #include "live_effects/lpeobject.h" #include "live_effects/lpeobject-reference.h" #include "live_effects/parameter/path.h" -#include "sp-path.h" #include "helper/geom.h" -#include "preferences.h" #include "style.h" #include "ui/tool/control-point-selection.h" #include "ui/tool/curve-drag-point.h" #include "ui/tool/event-utils.h" #include "ui/tool/multi-path-manipulator.h" -#include "xml/node.h" #include "xml/node-observer.h" namespace Inkscape { diff --git a/src/ui/tool/selector.cpp b/src/ui/tool/selector.cpp index 9acf7de88..84e96173d 100644 --- a/src/ui/tool/selector.cpp +++ b/src/ui/tool/selector.cpp @@ -14,7 +14,6 @@ #include "display/sodipodi-ctrlrect.h" #include "ui/tools/tool-base.h" -#include "preferences.h" #include "ui/tool/event-utils.h" #include "ui/tool/selector.h" diff --git a/src/ui/tool/transform-handle-set.cpp b/src/ui/tool/transform-handle-set.cpp index 748b9d4cc..33015fe11 100644 --- a/src/ui/tool/transform-handle-set.cpp +++ b/src/ui/tool/transform-handle-set.cpp @@ -18,11 +18,7 @@ #include "sp-namedview.h" #include "display/sodipodi-ctrlrect.h" -#include "preferences.h" #include "pure-transform.h" -#include "snap.h" -#include "snap-candidate.h" -#include "sp-namedview.h" #include "ui/tool/commit-events.h" #include "ui/tool/control-point-selection.h" #include "ui/tool/selectable-control-point.h" diff --git a/src/ui/tools-switch.cpp b/src/ui/tools-switch.cpp index ea0431b0a..d87bcc51d 100644 --- a/src/ui/tools-switch.cpp +++ b/src/ui/tools-switch.cpp @@ -13,16 +13,11 @@ #include <gtkmm.h> // prevents deprecation warnings -#include <cstring> -#include <string> - #include "inkscape.h" #include "desktop.h" #include <glibmm/i18n.h> -#include <xml/repr.h> - #include "ui/tools-switch.h" #include "box3d.h" @@ -52,7 +47,6 @@ #include "ui/tools/measure-tool.h" #include "ui/tools/mesh-tool.h" #include "ui/tools/node-tool.h" -#include "ui/tools/pen-tool.h" #include "ui/tools/pencil-tool.h" #include "ui/tools/rect-tool.h" #include "ui/tools/select-tool.h" diff --git a/src/ui/tools/Makefile_insert b/src/ui/tools/Makefile_insert deleted file mode 100644 index 686dfedd8..000000000 --- a/src/ui/tools/Makefile_insert +++ /dev/null @@ -1,34 +0,0 @@ -## Makefile.am fragment sourced by src/Makefile.am. - -ink_common_sources += \ - ui/tools/arc-tool.cpp ui/tools/arc-tool.h \ - ui/tools/box3d-tool.cpp ui/tools/box3d-tool.h \ - ui/tools/calligraphic-tool.cpp ui/tools/calligraphic-tool.h \ - ui/tools/connector-tool.cpp ui/tools/connector-tool.h \ - ui/tools/dropper-tool.cpp ui/tools/dropper-tool.h \ - ui/tools/dynamic-base.cpp ui/tools/dynamic-base.h \ - ui/tools/eraser-tool.cpp ui/tools/eraser-tool.h \ - ui/tools/freehand-base.cpp ui/tools/freehand-base.h \ - ui/tools/gradient-tool.cpp ui/tools/gradient-tool.h \ - ui/tools/lpe-tool.cpp ui/tools/lpe-tool.h \ - ui/tools/measure-tool.cpp ui/tools/measure-tool.h \ - ui/tools/mesh-tool.cpp ui/tools/mesh-tool.h \ - ui/tools/node-tool.cpp ui/tools/node-tool.h \ - ui/tools/pen-tool.cpp ui/tools/pen-tool.h \ - ui/tools/pencil-tool.cpp ui/tools/pencil-tool.h \ - ui/tools/rect-tool.cpp ui/tools/rect-tool.h \ - ui/tools/select-tool.cpp ui/tools/select-tool.h \ - ui/tools/spiral-tool.cpp ui/tools/spiral-tool.h \ - ui/tools/spray-tool.cpp ui/tools/spray-tool.h \ - ui/tools/star-tool.cpp ui/tools/star-tool.h \ - ui/tools/text-tool.cpp ui/tools/text-tool.h \ - ui/tools/tool-base.cpp ui/tools/tool-base.h \ - ui/tools/tweak-tool.cpp ui/tools/tweak-tool.h \ - ui/tools/zoom-tool.cpp ui/tools/zoom-tool.h - -if HAVE_POTRACE - -ink_common_sources += \ - ui/tools/flood-tool.cpp ui/tools/flood-tool.h - -endif diff --git a/src/ui/tools/arc-tool.cpp b/src/ui/tools/arc-tool.cpp index c6a9bb23a..6652f7ab5 100644 --- a/src/ui/tools/arc-tool.cpp +++ b/src/ui/tools/arc-tool.cpp @@ -17,7 +17,7 @@ */ #ifdef HAVE_CONFIG_H -# include <config.h> +#include <config.h> #endif #include <gdk/gdkkeysyms.h> @@ -30,7 +30,6 @@ #include "sp-namedview.h" #include "selection.h" -#include "snap.h" #include "pixmaps/cursor-ellipse.xpm" #include "xml/repr.h" #include "xml/node-event-vector.h" diff --git a/src/ui/tools/box3d-tool.cpp b/src/ui/tools/box3d-tool.cpp index 27e755add..94488a700 100644 --- a/src/ui/tools/box3d-tool.cpp +++ b/src/ui/tools/box3d-tool.cpp @@ -15,8 +15,6 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include "config.h" - #include <gdk/gdkkeysyms.h> #include "macros.h" @@ -27,8 +25,6 @@ #include "selection.h" #include "selection-chemistry.h" -#include "snap.h" -#include "display/curve.h" #include "display/sp-canvas-item.h" #include "desktop.h" #include "message-context.h" @@ -36,17 +32,12 @@ #include "box3d.h" #include "ui/tools/box3d-tool.h" #include <glibmm/i18n.h> -#include "xml/repr.h" #include "xml/node-event-vector.h" -#include "preferences.h" #include "context-fns.h" #include "desktop-style.h" -#include "transf_mat_3x4.h" #include "perspective-line.h" -#include "persp3d.h" #include "box3d-side.h" #include "document-private.h" -#include "line-geometry.h" #include "ui/shape-editor.h" #include "verbs.h" @@ -118,8 +109,8 @@ static void sp_box3d_context_ensure_persp_in_defs(SPDocument *document) { SPDefs *defs = document->getDefs(); bool has_persp = false; - for ( SPObject *child = defs->firstChild(); child; child = child->getNext() ) { - if (SP_IS_PERSP3D(child)) { + for (auto& child: defs->children) { + if (SP_IS_PERSP3D(&child)) { has_persp = true; break; } diff --git a/src/ui/tools/calligraphic-tool.cpp b/src/ui/tools/calligraphic-tool.cpp index 28195eb75..9b4dbb1a2 100644 --- a/src/ui/tools/calligraphic-tool.cpp +++ b/src/ui/tools/calligraphic-tool.cpp @@ -23,8 +23,6 @@ #define noDYNA_DRAW_VERBOSE -#include "config.h" - #include <gtk/gtk.h> #include <gdk/gdkkeysyms.h> #include <glibmm/i18n.h> @@ -35,12 +33,10 @@ #include "svg/svg.h" #include "display/canvas-bpath.h" #include "display/cairo-utils.h" -#include <2geom/math-utils.h> #include <2geom/pathvector.h> #include <2geom/bezier-utils.h> #include <2geom/circle.h> #include "display/curve.h" -#include <glib.h> #include "macros.h" #include "document.h" #include "document-undo.h" @@ -50,20 +46,15 @@ #include "desktop-style.h" #include "message-context.h" -#include "preferences.h" #include "pixmaps/cursor-calligraphy.xpm" -#include "xml/repr.h" #include "context-fns.h" -#include "sp-item.h" #include "inkscape.h" -#include "color.h" #include "splivarot.h" #include "sp-item-group.h" #include "sp-shape.h" #include "sp-path.h" #include "sp-text.h" #include "display/sp-canvas.h" -#include "display/canvas-bpath.h" #include "display/canvas-arena.h" #include "livarot/Shape.h" #include "verbs.h" @@ -144,7 +135,7 @@ void CalligraphicTool::setup() { SPCurve *c = new SPCurve(path); - this->hatch_area = sp_canvas_bpath_new(this->desktop->getControls(), c); + this->hatch_area = sp_canvas_bpath_new(this->desktop->getControls(), c, true); c->unref(); @@ -930,10 +921,10 @@ void CalligraphicTool::set_to_accumulated(bool unionize, bool subtract) { if (unionize) { desktop->getSelection()->add(this->repr); - sp_selected_path_union_skip_undo(desktop->getSelection(), desktop); + sp_selected_path_union_skip_undo(desktop->getSelection()); } else if (subtract) { desktop->getSelection()->add(this->repr); - sp_selected_path_diff_skip_undo(desktop->getSelection(), desktop); + sp_selected_path_diff_skip_undo(desktop->getSelection()); } else { if (this->keep_selected) { desktop->getSelection()->set(this->repr); @@ -1099,7 +1090,7 @@ void CalligraphicTool::fit_and_split(bool release) { add_cap(this->currentcurve, b2[0], b1[0], this->cap_rounding); } this->currentcurve->closepath(); - sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(this->currentshape), this->currentcurve); + sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(this->currentshape), this->currentcurve, true); } /* Current calligraphic */ @@ -1135,7 +1126,7 @@ void CalligraphicTool::fit_and_split(bool release) { SP_TYPE_CANVAS_BPATH, NULL); SPCurve *curve = this->currentcurve->copy(); - sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH (cbp), curve); + sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH (cbp), curve, true); curve->unref(); guint32 fillColor = sp_desktop_get_color_tool (desktop, "/tools/calligraphic", true); @@ -1179,7 +1170,7 @@ void CalligraphicTool::draw_temporary_box() { } this->currentcurve->closepath(); - sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(this->currentshape), this->currentcurve); + sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(this->currentshape), this->currentcurve, true); } } diff --git a/src/ui/tools/connector-tool.cpp b/src/ui/tools/connector-tool.cpp index 74f2664fe..7e6fb4b72 100644 --- a/src/ui/tools/connector-tool.cpp +++ b/src/ui/tools/connector-tool.cpp @@ -75,7 +75,6 @@ #include "ui/tools/connector-tool.h" #include "pixmaps/cursor-connector.xpm" #include "xml/node-event-vector.h" -#include "xml/repr.h" #include "svg/svg.h" #include "desktop.h" #include "desktop-style.h" @@ -86,19 +85,13 @@ #include "message-stack.h" #include "selection.h" #include "inkscape.h" -#include "preferences.h" #include "sp-path.h" #include "display/sp-canvas.h" #include "display/canvas-bpath.h" -#include "display/sodipodi-ctrl.h" #include <glibmm/i18n.h> #include <glibmm/stringutils.h> #include "snap.h" -#include "knot.h" #include "sp-conn-end.h" -#include "sp-conn-end-pair.h" -#include "conn-avoid-ref.h" -#include "libavoid/vertices.h" #include "libavoid/router.h" #include "context-fns.h" #include "sp-namedview.h" @@ -627,7 +620,7 @@ bool ConnectorTool::_handleMotionNotify(GdkEventMotion const &mevent) { this->red_curve = path->get_curve_for_edit(); this->red_curve->transform(i2d); - sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(this->red_bpath), this->red_curve); + sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(this->red_bpath), this->red_curve, true); ret = true; break; } @@ -818,7 +811,7 @@ void ConnectorTool::_setSubsequentPoint(Geom::Point const p) { // Recreate curve from libavoid route. recreateCurve( this->red_curve, this->newConnRef, this->curvature ); this->red_curve->transform(desktop->doc2dt()); - sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(this->red_bpath), this->red_curve); + sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(this->red_bpath), this->red_curve, true); } @@ -1042,7 +1035,7 @@ endpt_handler(SPKnot */*knot*/, GdkEvent *event, ConnectorTool *cc) cc->red_curve = SP_PATH(cc->clickeditem)->get_curve_for_edit(); Geom::Affine i2d = (cc->clickeditem)->i2dt_affine(); cc->red_curve->transform(i2d); - sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(cc->red_bpath), cc->red_curve); + sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(cc->red_bpath), cc->red_curve, true); cc->clickeditem->setHidden(true); @@ -1114,9 +1107,9 @@ void ConnectorTool::_setActiveShape(SPItem *item) { // The idea here is to try and add a group's children to solidify // connection handling. We react to path objects with only one node. - for (SPObject *child = item->firstChild() ; child ; child = child->getNext() ) { - if (SP_IS_PATH(child) && SP_PATH(child)->nodesInPath() == 1) { - this->_activeShapeAddKnot((SPItem *) child); + for (auto& child: item->children) { + if (SP_IS_PATH(&child) && SP_PATH(&child)->nodesInPath() == 1) { + this->_activeShapeAddKnot((SPItem *) &child); } } this->_activeShapeAddKnot(item); @@ -1306,8 +1299,8 @@ void cc_selection_set_avoid(bool const set_avoid) int changes = 0; - std::vector<SPItem*> l = selection->itemList(); - for(std::vector<SPItem*>::const_iterator i=l.begin();i!=l.end(); ++i) { + auto l = selection->items(); + for(auto i=l.begin();i!=l.end(); ++i) { SPItem *item = *i; char const *value = (set_avoid) ? "true" : NULL; diff --git a/src/ui/tools/dropper-tool.cpp b/src/ui/tools/dropper-tool.cpp index c838c27d5..99177dc75 100644 --- a/src/ui/tools/dropper-tool.cpp +++ b/src/ui/tools/dropper-tool.cpp @@ -12,7 +12,7 @@ */ #ifdef HAVE_CONFIG_H -# include <config.h> +#include <config.h> #endif #include <glibmm/i18n.h> @@ -27,7 +27,6 @@ #include "display/curve.h" #include "display/cairo-utils.h" #include "svg/svg-color.h" -#include "color.h" #include "color-rgba.h" #include "desktop-style.h" #include "preferences.h" @@ -36,7 +35,6 @@ #include "desktop.h" #include "selection.h" -#include "document.h" #include "document-undo.h" #include "pixmaps/cursor-dropper-f.xpm" @@ -45,7 +43,6 @@ #include "ui/tools/dropper-tool.h" #include "message-context.h" #include "verbs.h" -#include "ui/tools/tool-base.h" using Inkscape::DocumentUndo; @@ -121,20 +118,12 @@ void DropperTool::finish() { } if (cursor_dropper_fill) { -#if GTK_CHECK_VERSION(3,0,0) g_object_unref(cursor_dropper_fill); -#else - gdk_cursor_unref (cursor_dropper_fill); -#endif cursor_dropper_fill = NULL; } if (cursor_dropper_stroke) { -#if GTK_CHECK_VERSION(3,0,0) g_object_unref(cursor_dropper_stroke); -#else - gdk_cursor_unref (cursor_dropper_stroke); -#endif cursor_dropper_fill = NULL; } diff --git a/src/ui/tools/dynamic-base.cpp b/src/ui/tools/dynamic-base.cpp index eb789d850..6627a470e 100644 --- a/src/ui/tools/dynamic-base.cpp +++ b/src/ui/tools/dynamic-base.cpp @@ -1,13 +1,7 @@ #include "ui/tools/dynamic-base.h" -#include <gtk/gtk.h> - -#include "config.h" - #include "message-context.h" -#include "streq.h" -#include "preferences.h" #include "display/sp-canvas-item.h" #include "desktop.h" #include "display/curve.h" diff --git a/src/ui/tools/eraser-tool.cpp b/src/ui/tools/eraser-tool.cpp index 6b32b5901..12686160b 100644 --- a/src/ui/tools/eraser-tool.cpp +++ b/src/ui/tools/eraser-tool.cpp @@ -24,8 +24,6 @@ #define noERASER_VERBOSE -#include "config.h" - #include <gtk/gtk.h> #include <gdk/gdkkeysyms.h> #include <glibmm/i18n.h> @@ -38,7 +36,6 @@ #include "display/canvas-bpath.h" #include <2geom/bezier-utils.h> -#include <glib.h> #include "macros.h" #include "document.h" #include "selection.h" @@ -47,30 +44,28 @@ #include "desktop-style.h" #include "message-context.h" -#include "preferences.h" #include "pixmaps/cursor-eraser.xpm" -#include "xml/repr.h" #include "context-fns.h" -#include "sp-item.h" -#include "color.h" #include "rubberband.h" #include "splivarot.h" #include "sp-item-group.h" #include "sp-shape.h" #include "sp-path.h" +#include "sp-clippath.h" +#include "sp-rect.h" #include "sp-text.h" +#include "sp-root.h" #include "display/canvas-bpath.h" #include "display/canvas-arena.h" -#include "livarot/Shape.h" #include "document-undo.h" #include "verbs.h" #include "style.h" -#include "style-enums.h" -#include <2geom/math-utils.h> #include <2geom/pathvector.h> #include "path-chemistry.h" +#include "selection-chemistry.h" #include "display/curve.h" - +#include "layer-model.h" +#include "layer-manager.h" #include "ui/tools/eraser-tool.h" using Inkscape::DocumentUndo; @@ -380,7 +375,7 @@ void EraserTool::cancel() { bool EraserTool::root_handler(GdkEvent* event) { gint ret = FALSE; Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - gint eraserMode = prefs->getBool("/tools/eraser/mode") ? 1 : 0; + gint eraser_mode = prefs->getInt("/tools/eraser/mode", 2); switch (event->type) { case GDK_BUTTON_PRESS: if (event->button.button == 1 && !this->space_panning) { @@ -400,7 +395,7 @@ bool EraserTool::root_handler(GdkEvent* event) { if (this->repr) { this->repr = NULL; } - if ( ! eraserMode ) { + if ( eraser_mode == ERASER_MODE_DELETE ) { Inkscape::Rubberband::get(desktop)->start(desktop, button_dt); Inkscape::Rubberband::get(desktop)->setMode(RUBBERBAND_MODE_TOUCHPATH); } @@ -448,7 +443,7 @@ bool EraserTool::root_handler(GdkEvent* event) { ret = TRUE; } - if ( !eraserMode ) { + if ( eraser_mode == ERASER_MODE_DELETE ) { this->accumulated->reset(); Inkscape::Rubberband::get(desktop)->move(motion_dt); } @@ -491,7 +486,7 @@ bool EraserTool::root_handler(GdkEvent* event) { ret = TRUE; } - if (!eraserMode && Inkscape::Rubberband::get(desktop)->is_started()) { + if (eraser_mode == ERASER_MODE_DELETE && Inkscape::Rubberband::get(desktop)->is_started()) { Inkscape::Rubberband::get(desktop)->stop(); } @@ -578,7 +573,7 @@ bool EraserTool::root_handler(GdkEvent* event) { break; case GDK_KEY_Escape: - if ( !eraserMode ) { + if ( eraser_mode == ERASER_MODE_DELETE ) { Inkscape::Rubberband::get(desktop)->stop(); } if (this->is_drawing) { @@ -640,65 +635,66 @@ void EraserTool::clear_current() { void EraserTool::set_to_accumulated() { bool workDone = false; - + SPDocument *document = this->desktop->doc(); if (!this->accumulated->is_empty()) { if (!this->repr) { /* Create object */ - Inkscape::XML::Document *xml_doc = desktop->doc()->getReprDoc(); + Inkscape::XML::Document *xml_doc = this->desktop->doc()->getReprDoc(); Inkscape::XML::Node *repr = xml_doc->createElement("svg:path"); /* Set style */ - sp_desktop_apply_style_tool (desktop, repr, "/tools/eraser", false); + sp_desktop_apply_style_tool (this->desktop, repr, "/tools/eraser", false); this->repr = repr; } - SPItem *item = SP_ITEM(desktop->currentLayer()->appendChildRepr(this->repr)); + SPObject * top_layer = desktop->layer_manager->nthChildOf(desktop->layers->currentRoot(), 0); + SPItem *item_repr = SP_ITEM(top_layer->appendChildRepr(this->repr)); Inkscape::GC::release(this->repr); - item->updateRepr(); - Geom::PathVector pathv = this->accumulated->get_pathvector() * desktop->dt2doc(); - pathv *= item->i2doc_affine().inverse(); + item_repr->updateRepr(); + Geom::PathVector pathv = this->accumulated->get_pathvector() * this->desktop->dt2doc(); + pathv *= item_repr->i2doc_affine().inverse(); gchar *str = sp_svg_write_path(pathv); g_assert( str != NULL ); this->repr->setAttribute("d", str); g_free(str); - + Geom::OptRect eraserBbox; if ( this->repr ) { bool wasSelection = false; - Inkscape::Selection *selection = desktop->getSelection(); + Inkscape::Selection *selection = this->desktop->getSelection(); Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - gint eraserMode = prefs->getBool("/tools/eraser/mode") ? 1 : 0; - Inkscape::XML::Document *xml_doc = desktop->doc()->getReprDoc(); + gint eraser_mode = prefs->getInt("/tools/eraser/mode", ERASER_MODE_CLIP); + Inkscape::XML::Document *xml_doc = this->desktop->doc()->getReprDoc(); - SPItem* acid = SP_ITEM(desktop->doc()->getObjectByRepr(this->repr)); - Geom::OptRect eraserBbox = acid->desktopVisualBounds(); + SPItem* acid = SP_ITEM(this->desktop->doc()->getObjectByRepr(this->repr)); + eraserBbox = acid->desktopVisualBounds(); std::vector<SPItem*> remainingItems; std::vector<SPItem*> toWorkOn; if (selection->isEmpty()) { - if ( eraserMode ) { - toWorkOn = desktop->getDocument()->getItemsPartiallyInBox(desktop->dkey, *eraserBbox); + if (eraser_mode == ERASER_MODE_CUT || eraser_mode == ERASER_MODE_CLIP) { + toWorkOn = document->getItemsPartiallyInBox(this->desktop->dkey, *eraserBbox); } else { - Inkscape::Rubberband *r = Inkscape::Rubberband::get(desktop); - toWorkOn = desktop->getDocument()->getItemsAtPoints(desktop->dkey, r->getPoints()); + Inkscape::Rubberband *r = Inkscape::Rubberband::get(this->desktop); + toWorkOn = document->getItemsAtPoints(this->desktop->dkey, r->getPoints()); } toWorkOn.erase(std::remove(toWorkOn.begin(), toWorkOn.end(), acid), toWorkOn.end()); } else { - if ( !eraserMode ) { - Inkscape::Rubberband *r = Inkscape::Rubberband::get(desktop); + if (eraser_mode == ERASER_MODE_DELETE) { + Inkscape::Rubberband *r = Inkscape::Rubberband::get(this->desktop); std::vector<SPItem*> touched; - touched = desktop->getDocument()->getItemsAtPoints(desktop->dkey, r->getPoints()); + touched = document->getItemsAtPoints(this->desktop->dkey, r->getPoints()); for (std::vector<SPItem*>::const_iterator i = touched.begin();i!=touched.end();++i) { if(selection->includes(*i)){ toWorkOn.push_back((*i)); } } } else { - toWorkOn = selection->itemList(); + toWorkOn.insert(toWorkOn.end(), selection->items().begin(), selection->items().end()); } wasSelection = true; } if ( !toWorkOn.empty() ) { - if ( eraserMode ) { + if (eraser_mode == ERASER_MODE_CUT) { for (std::vector<SPItem*>::const_iterator i = toWorkOn.begin(); i != toWorkOn.end(); ++i){ SPItem *item = *i; SPUse *use = dynamic_cast<SPUse *>(item); @@ -708,7 +704,6 @@ void EraserTool::set_to_accumulated() { item->deleteObject(true); sp_object_unref(item); workDone = true; - workDone = true; } else if (SP_IS_GROUP(item) || use ) { /*Do nothing*/ } else { @@ -719,33 +714,33 @@ void EraserTool::set_to_accumulated() { Inkscape::GC::release(dup); // parent takes over selection->set(dup); if (!this->nowidth) { - sp_selected_path_union_skip_undo(selection, desktop); + sp_selected_path_union_skip_undo(selection); } selection->add(item); if(item->style->fill_rule.value == SP_WIND_RULE_EVENODD){ SPCSSAttr *css = sp_repr_css_attr_new(); sp_repr_css_set_property(css, "fill-rule", "evenodd"); - sp_desktop_set_style(desktop, css); + sp_desktop_set_style(this->desktop, css); sp_repr_css_attr_unref(css); css = 0; } if (this->nowidth) { - sp_selected_path_cut_skip_undo(selection, desktop); + sp_selected_path_cut_skip_undo(selection); } else { - sp_selected_path_diff_skip_undo(selection, desktop); + sp_selected_path_diff_skip_undo(selection); } workDone = true; // TODO set this only if something was cut. bool break_apart = prefs->getBool("/tools/eraser/break_apart", false); if(!break_apart){ - sp_selected_path_combine(desktop, true); + sp_selected_path_combine(this->desktop, true); } else { if(!this->nowidth){ - sp_selected_path_break_apart(desktop, true); + sp_selected_path_break_apart(this->desktop, true); } } if ( !selection->isEmpty() ) { // If the item was not completely erased, track the new remainder. - std::vector<SPItem*> nowSel(selection->itemList()); + std::vector<SPItem*> nowSel(selection->items().begin(), selection->items().end()); for (std::vector<SPItem*>::const_iterator i2 = nowSel.begin();i2!=nowSel.end();++i2) { remainingItems.push_back(*i2); } @@ -755,6 +750,78 @@ void EraserTool::set_to_accumulated() { } } } + } else if (eraser_mode == ERASER_MODE_CLIP) { + if (!this->nowidth) { + remainingItems.clear(); + for (std::vector<SPItem*>::const_iterator i = toWorkOn.begin(); i != toWorkOn.end(); ++i){ + selection->clear(); + SPItem *item = *i; + Geom::OptRect bbox = item->desktopVisualBounds(); + Inkscape::XML::Document *xml_doc = this->desktop->doc()->getReprDoc(); + Inkscape::XML::Node* dup = this->repr->duplicate(xml_doc); + this->repr->parent()->appendChild(dup); + Inkscape::GC::release(dup); // parent takes over + selection->set(dup); + sp_selected_path_union_skip_undo(selection); + if (bbox && bbox->intersects(*eraserBbox)) { + SPClipPath *clip_path = item->clip_ref->getObject(); + if (clip_path) { + std::vector<SPItem*> selected; + selected.push_back(SP_ITEM(clip_path->firstChild())); + std::vector<Inkscape::XML::Node*> to_select; + std::vector<SPItem*> items(selected); + sp_item_list_to_curves(items, selected, to_select); + Inkscape::XML::Node * clip_data = SP_ITEM(clip_path->firstChild())->getRepr(); + if (!clip_data && !to_select.empty()) { + clip_data = *(to_select.begin()); + } + if (clip_data) { + Inkscape::XML::Node *dup_clip = clip_data->duplicate(xml_doc); + if (dup_clip) { + SPItem * dup_clip_obj = SP_ITEM(item_repr->parent->appendChildRepr(dup_clip)); + if (dup_clip_obj) { + dup_clip_obj->doWriteTransform(dup_clip, item->transform); + sp_object_ref(clip_path, 0); + clip_path->deleteObject(true); + sp_object_unref(clip_path); + sp_selection_raise_to_top(selection, this->desktop, true); + selection->add(dup_clip); + sp_selected_path_diff_skip_undo(selection); + SPItem * clip = SP_ITEM(*(selection->items().begin())); + } + } + } + } else { + Inkscape::XML::Node *rect_repr = xml_doc->createElement("svg:rect"); + sp_desktop_apply_style_tool (this->desktop, rect_repr, "/tools/eraser", false); + SPRect * rect = SP_RECT(item_repr->parent->appendChildRepr(rect_repr)); + Inkscape::GC::release(rect_repr); + rect->setPosition (bbox->left(), bbox->top(), bbox->width(), bbox->height()); + rect->transform = SP_ITEM(rect->parent)->i2dt_affine().inverse(); + rect->updateRepr(); + rect->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); + sp_selection_raise_to_top(selection, this->desktop, true); + selection->add(rect); + sp_selected_path_diff_skip_undo(selection); + } + sp_selection_raise_to_top(selection, this->desktop, true); + selection->add(item); + sp_selection_set_mask(this->desktop, true, false, true); + } else { + SPItem *erase_clip = selection->singleItem(); + if (erase_clip) { + sp_object_ref(erase_clip, 0); + erase_clip->deleteObject(true); + sp_object_unref(erase_clip); + } + } + workDone = true; + selection->clear(); + if (wasSelection) { + remainingItems.push_back(item); + } + } + } } else { for (std::vector<SPItem*> ::const_iterator i = toWorkOn.begin();i!=toWorkOn.end();++i) { sp_object_ref( *i, 0 ); @@ -768,8 +835,8 @@ void EraserTool::set_to_accumulated() { } } - if ( !eraserMode ) { - //sp_selection_delete(desktop); + if (eraser_mode == ERASER_MODE_DELETE) { + sp_selection_delete(this->desktop); remainingItems.clear(); } @@ -791,12 +858,10 @@ void EraserTool::set_to_accumulated() { this->repr = 0; } } - - if ( workDone ) { - DocumentUndo::done(desktop->getDocument(), SP_VERB_CONTEXT_ERASER, _("Draw eraser stroke")); + DocumentUndo::done(document, SP_VERB_CONTEXT_ERASER, _("Draw eraser stroke")); } else { - DocumentUndo::cancel(desktop->getDocument()); + DocumentUndo::cancel(document); } } @@ -955,7 +1020,7 @@ void EraserTool::fit_and_split(bool release) { } this->currentcurve->closepath(); - sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(this->currentshape), this->currentcurve); + sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(this->currentshape), this->currentcurve, true); } /* Current eraser */ @@ -987,12 +1052,12 @@ void EraserTool::fit_and_split(bool release) { g_print("[%d]Yup\n", this->npoints); #endif if (!release) { - gint eraserMode = prefs->getBool("/tools/eraser/mode") ? 1 : 0; + gint eraser_mode = prefs->getInt("/tools/eraser/mode",2); g_assert(!this->currentcurve->is_empty()); SPCanvasItem *cbp = sp_canvas_item_new(desktop->getSketch(), SP_TYPE_CANVAS_BPATH, NULL); SPCurve *curve = this->currentcurve->copy(); - sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH (cbp), curve); + sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH (cbp), curve, true); curve->unref(); guint32 fillColor = sp_desktop_get_color_tool (desktop, "/tools/eraser", true); @@ -1009,7 +1074,7 @@ void EraserTool::fit_and_split(bool release) { this->segments = g_slist_prepend(this->segments, cbp); - if ( !eraserMode ) { + if (eraser_mode == ERASER_MODE_DELETE) { sp_canvas_item_hide(cbp); sp_canvas_item_hide(this->currentshape); } @@ -1041,7 +1106,7 @@ void EraserTool::draw_temporary_box() { } this->currentcurve->closepath(); - sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(this->currentshape), this->currentcurve); + sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(this->currentshape), this->currentcurve, true); } } diff --git a/src/ui/tools/eraser-tool.h b/src/ui/tools/eraser-tool.h index 50ce6b6e3..bd0e98057 100644 --- a/src/ui/tools/eraser-tool.h +++ b/src/ui/tools/eraser-tool.h @@ -31,6 +31,10 @@ #define ERC_MAX_TILT 1.0 #define ERC_DEFAULT_TILT 0.0 +#define ERASER_MODE_DELETE 0 +#define ERASER_MODE_CUT 1 +#define ERASER_MODE_CLIP 2 + namespace Inkscape { namespace UI { namespace Tools { diff --git a/src/ui/tools/flood-tool.cpp b/src/ui/tools/flood-tool.cpp index 748c82717..0b893a7ba 100644 --- a/src/ui/tools/flood-tool.cpp +++ b/src/ui/tools/flood-tool.cpp @@ -18,14 +18,13 @@ */ #ifdef HAVE_CONFIG_H -#include "config.h" +#include <config.h> #endif #include "trace/potrace/inkscape-potrace.h" #include <2geom/pathvector.h> #include <gdk/gdkkeysyms.h> #include <queue> -#include <deque> #include <glibmm/i18n.h> #include "color.h" @@ -36,7 +35,6 @@ #include "display/cairo-utils.h" #include "display/drawing-context.h" #include "display/drawing-image.h" -#include "display/drawing-item.h" #include "display/drawing.h" #include "display/sp-canvas.h" #include "document.h" @@ -47,23 +45,15 @@ #include "macros.h" #include "message-context.h" #include "message-stack.h" -#include "preferences.h" #include "rubberband.h" #include "selection.h" #include "ui/shape-editor.h" -#include "sp-defs.h" -#include "sp-item.h" #include "splivarot.h" #include "sp-namedview.h" -#include "sp-object.h" -#include "sp-path.h" -#include "sp-rect.h" #include "sp-root.h" #include "svg/svg.h" #include "trace/imagemap.h" -#include "trace/trace.h" #include "xml/node-event-vector.h" -#include "xml/repr.h" #include "verbs.h" #include "pixmaps/cursor-paintbucket.xpm" @@ -456,7 +446,7 @@ static void do_trace(bitmap_coords_info bci, guchar *trace_px, SPDesktop *deskto ngettext("Area filled, path with <b>%d</b> node created and unioned with selection.","Area filled, path with <b>%d</b> nodes created and unioned with selection.", SP_PATH(reprobj)->nodesInPath()), SP_PATH(reprobj)->nodesInPath() ); selection->add(reprobj); - sp_selected_path_union_skip_undo(desktop->getSelection(), desktop); + sp_selected_path_union_skip_undo(desktop->getSelection()); } else { desktop->messageStack()->flashF( Inkscape::WARNING_MESSAGE, ngettext("Area filled, path with <b>%d</b> node created.","Area filled, path with <b>%d</b> nodes created.", diff --git a/src/ui/tools/freehand-base.cpp b/src/ui/tools/freehand-base.cpp index 7697cd59c..067035b97 100644 --- a/src/ui/tools/freehand-base.cpp +++ b/src/ui/tools/freehand-base.cpp @@ -17,43 +17,29 @@ #define DRAW_VERBOSE #ifdef HAVE_CONFIG_H -# include "config.h" +#include <config.h> #endif #include "live_effects/lpe-bendpath.h" #include "live_effects/lpe-patternalongpath.h" #include "live_effects/lpe-simplify.h" #include "display/canvas-bpath.h" -#include "xml/repr.h" #include "svg/svg.h" -#include <glibmm/i18n.h> #include "display/curve.h" -#include "desktop.h" #include "desktop-style.h" -#include "document.h" #include "ui/draw-anchor.h" #include "macros.h" #include "message-stack.h" #include "ui/tools/pen-tool.h" #include "ui/tools/lpe-tool.h" -#include "preferences.h" -#include "selection.h" #include "selection-chemistry.h" -#include "snap.h" -#include "sp-path.h" -#include "sp-use.h" #include "sp-item-group.h" -#include "sp-namedview.h" #include "live_effects/lpe-powerstroke.h" #include "style.h" #include "ui/control-manager.h" -#include "util/units.h" // clipboard support #include "ui/clipboard.h" -#include "ui/tools/freehand-base.h" - -#include <gdk/gdkkeysyms.h> using Inkscape::DocumentUndo; @@ -226,6 +212,10 @@ static void spdc_paste_curve_as_freehand_shape(Geom::PathVector const &newpath, Effect::createAndApply(PATTERN_ALONG_PATH, dc->desktop->doc(), item); Effect* lpe = SP_LPE_ITEM(item)->getCurrentLPE(); static_cast<LPEPatternAlongPath*>(lpe)->pattern.set_new_value(newpath,true); + double scale_doc = 1 / dc->desktop->doc()->getDocumentScale()[0]; + Inkscape::SVGOStringStream os; + os << scale_doc; + lpe->getRepr()->setAttribute("prop_scale", os.str().c_str()); } static void spdc_apply_powerstroke_shape(const std::vector<Geom::Point> & points, FreehandBase *dc, SPItem *item) @@ -342,7 +332,7 @@ static void spdc_check_for_and_apply_waiting_LPE(FreehandBase *dc, SPItem *item, // "triangle in" std::vector<Geom::Point> points(1); points[0] = Geom::Point(0., swidth/2); - points[0] *= i2anc_affine(static_cast<SPItem *>(item->parent), NULL).inverse(); + //points[0] *= i2anc_affine(static_cast<SPItem *>(item->parent), NULL).inverse(); spdc_apply_powerstroke_shape(points, dc, item); shape_applied = true; @@ -354,7 +344,7 @@ static void spdc_check_for_and_apply_waiting_LPE(FreehandBase *dc, SPItem *item, guint curve_length = curve->get_segment_count(); std::vector<Geom::Point> points(1); points[0] = Geom::Point(0, swidth/2); - points[0] *= i2anc_affine(static_cast<SPItem *>(item->parent), NULL).inverse(); + //points[0] *= i2anc_affine(static_cast<SPItem *>(item->parent), NULL).inverse(); points[0][Geom::X] = (double)curve_length; spdc_apply_powerstroke_shape(points, dc, item); @@ -792,16 +782,26 @@ static void spdc_flush_white(FreehandBase *dc, SPCurve *gc) if (!dc->white_item) { // Attach repr + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + shapeType shape_selected = (shapeType)prefs->getInt(tool_name(dc) + "/shape", 0); SPItem *item = SP_ITEM(desktop->currentLayer()->appendChildRepr(repr)); - - spdc_check_for_and_apply_waiting_LPE(dc, item, c); - if(previous_shape_type != BEND_CLIPBOARD){ - dc->selection->set(repr); + //Bend needs the transforms applied after, Other effects best before + if((previous_shape_type == BEND_CLIPBOARD && shape_selected == LAST_APPLIED) || + shape_selected == BEND_CLIPBOARD) + { + spdc_check_for_and_apply_waiting_LPE(dc, item, c); + previous_shape_type = BEND_CLIPBOARD; } Inkscape::GC::release(repr); item->transform = SP_ITEM(desktop->currentLayer())->i2doc_affine().inverse(); item->updateRepr(); item->doWriteTransform(item->getRepr(), item->transform, NULL, true); + if((previous_shape_type != BEND_CLIPBOARD || shape_selected != LAST_APPLIED) && + shape_selected != BEND_CLIPBOARD) + { + spdc_check_for_and_apply_waiting_LPE(dc, item, c); + dc->selection->set(repr); + } if(previous_shape_type == BEND_CLIPBOARD){ repr->parent()->removeChild(repr); } diff --git a/src/ui/tools/gradient-tool.cpp b/src/ui/tools/gradient-tool.cpp index 9d8101cc4..16df225e0 100644 --- a/src/ui/tools/gradient-tool.cpp +++ b/src/ui/tools/gradient-tool.cpp @@ -13,7 +13,7 @@ */ #ifdef HAVE_CONFIG_H -# include "config.h" +#include <config.h> #endif @@ -31,17 +31,10 @@ #include "ui/tools/gradient-tool.h" #include "gradient-chemistry.h" #include <glibmm/i18n.h> -#include "preferences.h" #include "gradient-drag.h" -#include "gradient-chemistry.h" -#include "xml/repr.h" -#include "sp-item.h" #include "display/sp-ctrlline.h" -#include "sp-linear-gradient.h" -#include "sp-radial-gradient.h" #include "sp-stop.h" #include "svg/css-ostringstream.h" -#include "svg/svg-color.h" #include "snap.h" #include "sp-namedview.h" #include "rubberband.h" @@ -106,7 +99,7 @@ void GradientTool::selection_changed(Inkscape::Selection*) { if (selection == NULL) { return; } - guint n_obj = selection->itemList().size(); + guint n_obj = (guint) boost::distance(selection->items()); if (!drag->isNonEmpty() || selection->isEmpty()) return; @@ -492,10 +485,10 @@ bool GradientTool::root_handler(GdkEvent* event) { if (over_line) { // we take the first item in selection, because with doubleclick, the first click // always resets selection to the single object under cursor - sp_gradient_context_add_stop_near_point(this, SP_ITEM(selection->itemList().front()), this->mousepoint_doc, event->button.time); + sp_gradient_context_add_stop_near_point(this, SP_ITEM(selection->items().front()), this->mousepoint_doc, event->button.time); } else { - std::vector<SPItem*> items=selection->itemList(); - for (std::vector<SPItem*>::const_iterator i = items.begin();i!=items.end();++i) { + auto items= selection->items(); + for (auto i = items.begin();i!=items.end();++i) { SPItem *item = *i; SPGradientType new_type = (SPGradientType) prefs->getInt("/tools/gradient/newgradient", SP_GRADIENT_TYPE_LINEAR); Inkscape::PaintTarget fsmode = (prefs->getInt("/tools/gradient/newfillorstroke", 1) != 0) ? Inkscape::FOR_FILL : Inkscape::FOR_STROKE; @@ -878,6 +871,7 @@ bool GradientTool::root_handler(GdkEvent* event) { return ret; } +// Creates a new linear or radial gradient. static void sp_gradient_drag(GradientTool &rc, Geom::Point const pt, guint /*state*/, guint32 etime) { SPDesktop *desktop = SP_EVENT_CONTEXT(&rc)->desktop; @@ -897,7 +891,7 @@ static void sp_gradient_drag(GradientTool &rc, Geom::Point const pt, guint /*sta } else { // Starting from empty space: // Sort items so that the topmost comes last - std::vector<SPItem*> items(selection->itemList()); + std::vector<SPItem*> items(selection->items().begin(), selection->items().end()); sort(items.begin(),items.end(),sp_item_repr_compare_position); // take topmost vector = sp_gradient_vector_for_object(document, desktop, SP_ITEM(items.back()), fill_or_stroke); @@ -907,8 +901,8 @@ static void sp_gradient_drag(GradientTool &rc, Geom::Point const pt, guint /*sta SPCSSAttr *css = sp_repr_css_attr_new(); sp_repr_css_set_property(css, "fill-opacity", "1.0"); - std::vector<SPItem*> itemlist = selection->itemList(); - for (std::vector<SPItem*>::const_iterator i = itemlist.begin();i!=itemlist.end();++i) { + auto itemlist = selection->items(); + for (auto i = itemlist.begin();i!=itemlist.end();++i) { //FIXME: see above sp_repr_css_change_recursive((*i)->getRepr(), css, "style"); @@ -931,7 +925,7 @@ static void sp_gradient_drag(GradientTool &rc, Geom::Point const pt, guint /*sta ec->_grdrag->local_change = true; // give the grab out-of-bounds values of xp/yp because we're already dragging // and therefore are already out of tolerance - ec->_grdrag->grabKnot (selection->itemList()[0], + ec->_grdrag->grabKnot (selection->items().front(), type == SP_GRADIENT_TYPE_LINEAR? POINT_LG_END : POINT_RG_R1, -1, // ignore number (though it is always 1) fill_or_stroke, 99999, 99999, etime); @@ -940,7 +934,7 @@ static void sp_gradient_drag(GradientTool &rc, Geom::Point const pt, guint /*sta // status text; we do not track coords because this branch is run once, not all the time // during drag - int n_objects = selection->itemList().size(); + int n_objects = (int) boost::distance(selection->items()); rc.message_context->setF(Inkscape::NORMAL_MESSAGE, ngettext("<b>Gradient</b> for %d object; with <b>Ctrl</b> to snap angle", "<b>Gradient</b> for %d objects; with <b>Ctrl</b> to snap angle", n_objects), diff --git a/src/ui/tools/lpe-tool.cpp b/src/ui/tools/lpe-tool.cpp index 9bbc1ac20..29e4c9e74 100644 --- a/src/ui/tools/lpe-tool.cpp +++ b/src/ui/tools/lpe-tool.cpp @@ -15,19 +15,16 @@ */ #ifdef HAVE_CONFIG_H -#include "config.h" +#include <config.h> #endif #include <2geom/sbasis-geometric.h> -#include <gdk/gdkkeysyms.h> #include <glibmm/i18n.h> -#include "macros.h" #include "pixmaps/cursor-crosshairs.xpm" #include <gtk/gtk.h> #include "desktop.h" #include "message-context.h" -#include "preferences.h" #include "ui/shape-editor.h" #include "selection.h" @@ -396,8 +393,8 @@ lpetool_create_measuring_items(LpeTool *lc, Inkscape::Selection *selection) SPCanvasGroup *tmpgrp = lc->desktop->getTempGroup(); gchar *arc_length; double lengthval; - std::vector<SPItem*> items=selection->itemList(); - for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();++i){ + auto items= selection->items(); + for(auto i=items.begin();i!=items.end();++i){ if (SP_IS_PATH(*i)) { path = SP_PATH(*i); curve = path->getCurve(); diff --git a/src/ui/tools/measure-tool.cpp b/src/ui/tools/measure-tool.cpp index 63e2460ec..f3185649b 100644 --- a/src/ui/tools/measure-tool.cpp +++ b/src/ui/tools/measure-tool.cpp @@ -11,11 +11,10 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ #ifdef HAVE_CONFIG_H -# include <config.h> +#include <config.h> #endif #include <gtkmm.h> -#include <gdk/gdkkeysyms.h> #include <boost/none_t.hpp> #include "util/units.h" #include "display/curve.h" @@ -23,7 +22,6 @@ #include "display/sp-ctrlline.h" #include "display/sp-ctrlcurve.h" #include "display/sp-canvas.h" -#include "display/sp-canvas-item.h" #include "display/sp-canvas-util.h" #include "svg/svg.h" #include "svg/svg-color.h" @@ -31,34 +29,20 @@ #include "ui/tools/freehand-base.h" #include <2geom/line.h> #include <2geom/path-intersection.h> -#include <2geom/pathvector.h> -#include <2geom/crossing.h> -#include <2geom/angle.h> -#include <2geom/transforms.h> #include "ui/dialog/knot-properties.h" #include "sp-namedview.h" -#include "sp-shape.h" #include "sp-text.h" #include "sp-flowtext.h" #include "sp-defs.h" -#include "sp-item.h" #include "sp-root.h" -#include "macros.h" #include "svg/stringstream.h" #include "rubberband.h" #include "path-chemistry.h" #include "desktop.h" -#include "document.h" #include "document-undo.h" -#include "viewbox.h" -#include "snap.h" -#include "knot.h" #include "text-editing.h" #include "pixmaps/cursor-measure.xpm" -#include "preferences.h" #include "inkscape.h" -#include "enums.h" -#include "knot-enums.h" #include "desktop-style.h" #include "verbs.h" #include <glibmm/i18n.h> @@ -394,6 +378,10 @@ MeasureTool::~MeasureTool() sp_canvas_item_destroy(measure_tmp_items[idx]); } measure_tmp_items.clear(); + for (size_t idx = 0; idx < measure_item.size(); ++idx) { + sp_canvas_item_destroy(measure_item[idx]); + } + measure_item.clear(); for (size_t idx = 0; idx < measure_phantom_items.size(); ++idx) { sp_canvas_item_destroy(measure_phantom_items[idx]); } @@ -607,6 +595,12 @@ bool MeasureTool::root_handler(GdkEvent* event) snap_manager.preSnap(scp); snap_manager.unSetup(); } + Geom::Point const motion_w(event->motion.x, event->motion.y); + if(event->motion.state & GDK_SHIFT_MASK) { + showInfoBox(motion_w, true); + } else { + showInfoBox(motion_w, false); + } } else { ret = TRUE; Inkscape::Preferences *prefs = Inkscape::Preferences::get(); @@ -1127,6 +1121,108 @@ void MeasureTool::setMeasureCanvasControlLine(Geom::Point start, Geom::Point end } } +void MeasureTool::showItemInfoText(Geom::Point pos, gchar *measure_str, double fontsize) +{ + SPCanvasText *canvas_tooltip = sp_canvastext_new(desktop->getTempGroup(), + desktop, + pos, + measure_str); + sp_canvastext_set_fontsize(canvas_tooltip, fontsize); + canvas_tooltip->rgba = 0xffffffff; + canvas_tooltip->outline = false; + canvas_tooltip->background = true; + canvas_tooltip->anchor_position = TEXT_ANCHOR_LEFT; + canvas_tooltip->rgba_background = 0x00000099; + measure_item.push_back(SP_CANVAS_ITEM(canvas_tooltip)); + sp_canvas_item_show(SP_CANVAS_ITEM(canvas_tooltip)); +} + +void MeasureTool::showInfoBox(Geom::Point cursor, bool into_groups) +{ + SPDesktop *desktop = SP_ACTIVE_DESKTOP; + Inkscape::Util::Unit const * unit = desktop->getNamedView()->getDisplayUnit(); + for (size_t idx = 0; idx < measure_item.size(); ++idx) { + sp_canvas_item_destroy(measure_item[idx]); + } + measure_item.clear(); + + SPItem *newover = desktop->getItemAtPoint(cursor, into_groups); + if (newover) { + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + double fontsize = prefs->getDouble("/tools/measure/fontsize", 10.0); + double scale = prefs->getDouble("/tools/measure/scale", 100.0) / 100.0; + int precision = prefs->getInt("/tools/measure/precision", 2); + Glib::ustring unit_name = prefs->getString("/tools/measure/unit"); + if (!unit_name.compare("")) { + unit_name = "px"; + } + Geom::Scale zoom = Geom::Scale(Inkscape::Util::Quantity::convert(desktop->current_zoom(), "px", unit->abbr)).inverse(); + if(newover != over){ + over = newover; + Preferences *prefs = Preferences::get(); + int prefs_bbox = prefs->getBool("/tools/bounding_box", 0); + SPItem::BBoxType bbox_type = !prefs_bbox ? SPItem::VISUAL_BBOX : SPItem::GEOMETRIC_BBOX; + Geom::OptRect bbox = over->bounds(bbox_type); + if (bbox) { + + item_width = Inkscape::Util::Quantity::convert((*bbox).width() * scale, unit->abbr, unit_name); + item_height = Inkscape::Util::Quantity::convert((*bbox).height() * scale, unit->abbr, unit_name); + item_x = Inkscape::Util::Quantity::convert((*bbox).left(), unit->abbr, unit_name); + Geom::Point y_point(0,Inkscape::Util::Quantity::convert((*bbox).bottom() * scale, unit->abbr, "px")); + y_point *= desktop->doc2dt(); + item_y = Inkscape::Util::Quantity::convert(y_point[Geom::Y] * scale, "px", unit_name); + if (SP_IS_SHAPE(over)) { + Geom::PathVector shape = SP_SHAPE(over)->getCurve()->get_pathvector(); + item_length = Geom::length(paths_to_pw(shape)); + item_length = Inkscape::Util::Quantity::convert(item_length * scale, unit->abbr, unit_name); + } + } + } + gchar *measure_str = NULL; + std::stringstream precision_str; + precision_str.imbue(std::locale::classic()); + double origin = Inkscape::Util::Quantity::convert(14, "px", unit->abbr); + Geom::Point rel_position = Geom::Point(origin, origin); + Geom::Point pos = desktop->w2d(cursor); + double gap = Inkscape::Util::Quantity::convert(7 + fontsize, "px", unit->abbr); + if (SP_IS_SHAPE(over)) { + precision_str << _("Length") << ": %." << precision << "f %s"; + measure_str = g_strdup_printf(precision_str.str().c_str(), item_length, unit_name.c_str()); + precision_str.str(""); + showItemInfoText(pos + (rel_position * zoom),measure_str,fontsize); + rel_position = Geom::Point(rel_position[Geom::X], rel_position[Geom::Y] + gap); + } else if (SP_IS_GROUP(over)) { + measure_str = _("Shift to measure into group"); + showItemInfoText(pos + (rel_position * zoom),measure_str,fontsize); + rel_position = Geom::Point(rel_position[Geom::X], rel_position[Geom::Y] + gap); + } + + precision_str << "Y: %." << precision << "f %s"; + measure_str = g_strdup_printf(precision_str.str().c_str(), item_y, unit_name.c_str()); + precision_str.str(""); + showItemInfoText(pos + (rel_position * zoom),measure_str,fontsize); + rel_position = Geom::Point(rel_position[Geom::X], rel_position[Geom::Y] + gap); + + precision_str << "X: %." << precision << "f %s"; + measure_str = g_strdup_printf(precision_str.str().c_str(), item_x, unit_name.c_str()); + precision_str.str(""); + showItemInfoText(pos + (rel_position * zoom),measure_str,fontsize); + rel_position = Geom::Point(rel_position[Geom::X], rel_position[Geom::Y] + gap); + + precision_str << _("Height") << ": %." << precision << "f %s"; + measure_str = g_strdup_printf(precision_str.str().c_str(), item_height, unit_name.c_str()); + precision_str.str(""); + showItemInfoText(pos + (rel_position * zoom),measure_str,fontsize); + rel_position = Geom::Point(rel_position[Geom::X], rel_position[Geom::Y] + gap); + + precision_str << _("Width") << ": %." << precision << "f %s"; + measure_str = g_strdup_printf(precision_str.str().c_str(), item_width, unit_name.c_str()); + precision_str.str(""); + showItemInfoText(pos + (rel_position * zoom),measure_str,fontsize); + g_free(measure_str); + } +} + void MeasureTool::showCanvasItems(bool to_guides, bool to_item, bool to_phantom, Inkscape::XML::Node *measure_repr) { SPDesktop *desktop = SP_ACTIVE_DESKTOP; diff --git a/src/ui/tools/measure-tool.h b/src/ui/tools/measure-tool.h index 14fc9f81a..42122dca1 100644 --- a/src/ui/tools/measure-tool.h +++ b/src/ui/tools/measure-tool.h @@ -54,6 +54,8 @@ public: virtual void setMarker(bool isStart); virtual const std::string& getPrefsPath(); Geom::Point readMeasurePoint(bool is_start); + void showInfoBox(Geom::Point cursor, bool into_groups); + void showItemInfoText(Geom::Point pos, gchar *measure_str, double fontsize); void writeMeasurePoint(Geom::Point point, bool is_start); void setGuide(Geom::Point origin, double angle, const char *label); void setPoint(Geom::Point origin, Inkscape::XML::Node *measure_repr); @@ -77,6 +79,13 @@ private: Geom::Point end_p; std::vector<SPCanvasItem *> measure_tmp_items; std::vector<SPCanvasItem *> measure_phantom_items; + std::vector<SPCanvasItem *> measure_item; + double item_width; + double item_height; + double item_x; + double item_y; + double item_length; + SPItem *over; sigc::connection _knot_start_moved_connection; sigc::connection _knot_start_ungrabbed_connection; sigc::connection _knot_start_click_connection; diff --git a/src/ui/tools/mesh-tool.cpp b/src/ui/tools/mesh-tool.cpp index 47927667c..aac8239f3 100644 --- a/src/ui/tools/mesh-tool.cpp +++ b/src/ui/tools/mesh-tool.cpp @@ -15,7 +15,7 @@ */ #ifdef HAVE_CONFIG_H -# include "config.h" +#include <config.h> #endif //#define DEBUG_MESH @@ -33,7 +33,6 @@ #include "macros.h" #include "message-context.h" #include "message-stack.h" -#include "preferences.h" #include "rubberband.h" #include "selection.h" #include "snap.h" @@ -48,7 +47,7 @@ // Mesh specific #include "ui/tools/mesh-tool.h" -#include "sp-mesh.h" +#include "sp-mesh-gradient.h" #include "display/sp-ctrlcurve.h" using Inkscape::DocumentUndo; @@ -103,7 +102,7 @@ void MeshTool::selection_changed(Inkscape::Selection* /*sel*/) { return; } - guint n_obj = selection->itemList().size(); + guint n_obj = (guint) boost::distance(selection->items()); if (!drag->isNonEmpty() || selection->isEmpty()) { return; @@ -162,9 +161,9 @@ void MeshTool::selection_changed(Inkscape::Selection* /*sel*/) { // if (style && (style->fill.isPaintserver())) { // SPPaintServer *server = item->style->getFillPaintServer(); - // if ( SP_IS_MESH(server) ) { + // if ( SP_IS_MESHGRADIENT(server) ) { - // SPMesh *mg = SP_MESH(server); + // SPMeshGradient *mg = SP_MESHGRADIENT(server); // guint rows = 0;//mg->array.patches.size(); // for ( guint i = 0; i < rows; ++i ) { @@ -266,14 +265,18 @@ sp_mesh_context_select_prev (ToolBase *event_context) Returns true if mouse cursor over mesh edge. */ static bool -sp_mesh_context_is_over_line (MeshTool *rc, SPItem *item, Geom::Point event_p) +sp_mesh_context_is_over_line (MeshTool *rc, SPCtrlLine *line, Geom::Point event_p) { + if (!SP_IS_CTRLCURVE(line) ) { + return false; + } + SPDesktop *desktop = SP_EVENT_CONTEXT (rc)->desktop; //Translate mouse point into proper coord system rc->mousepoint_doc = desktop->w2d(event_p); - SPCtrlCurve *curve = SP_CTRLCURVE(item); + SPCtrlCurve *curve = SP_CTRLCURVE(line); Geom::BezierCurveN<3> b( curve->p0, curve->p1, curve->p2, curve->p3 ); Geom::Coord coord = b.nearestTime( rc->mousepoint_doc ); // Coord == double Geom::Point nearest = b( coord ); @@ -327,8 +330,8 @@ sp_mesh_context_corner_operation (MeshTool *rc, MeshCornerOperation operation ) SPDocument *doc = NULL; GrDrag *drag = rc->_grdrag; - std::map<SPMesh*, std::vector<guint> > points; - std::map<SPMesh*, SPItem*> items; + std::map<SPMeshGradient*, std::vector<guint> > points; + std::map<SPMeshGradient*, SPItem*> items; // Get list of selected draggers for each mesh. // For all selected draggers @@ -342,7 +345,7 @@ sp_mesh_context_corner_operation (MeshTool *rc, MeshCornerOperation operation ) if( d->point_type != POINT_MG_CORNER ) continue; // Find the gradient - SPMesh *gradient = SP_MESH( getGradient (d->item, d->fill_or_stroke) ); + SPMeshGradient *gradient = SP_MESHGRADIENT( getGradient (d->item, d->fill_or_stroke) ); // Collect points together for same gradient points[gradient].push_back( d->point_i ); @@ -351,8 +354,8 @@ sp_mesh_context_corner_operation (MeshTool *rc, MeshCornerOperation operation ) } // Loop over meshes. - for( std::map<SPMesh*, std::vector<guint> >::const_iterator iter = points.begin(); iter != points.end(); ++iter) { - SPMesh *mg = SP_MESH( iter->first ); + for( std::map<SPMeshGradient*, std::vector<guint> >::const_iterator iter = points.begin(); iter != points.end(); ++iter) { + SPMeshGradient *mg = SP_MESHGRADIENT( iter->first ); if( iter->second.size() > 0 ) { guint noperation = 0; switch (operation) { @@ -426,6 +429,7 @@ sp_mesh_context_corner_operation (MeshTool *rc, MeshCornerOperation operation ) /** Handles all keyboard and mouse input for meshs. +Note: node/handle events are take care of elsewhere. */ bool MeshTool::root_handler(GdkEvent* event) { static bool dragging; @@ -455,23 +459,21 @@ bool MeshTool::root_handler(GdkEvent* event) { if ( event->button.button == 1 ) { // Are we over a mesh line? bool over_line = false; - SPCtrlCurve *line = NULL; if (! drag->lines.empty()) { for (std::vector<SPCtrlLine *>::const_iterator l = drag->lines.begin(); l != drag->lines.end() && (!over_line); ++l) { - line = (SPCtrlCurve*) (*l); - over_line |= sp_mesh_context_is_over_line (this, (SPItem*) line, Geom::Point(event->motion.x, event->motion.y)); + over_line |= sp_mesh_context_is_over_line (this, *l, Geom::Point(event->motion.x, event->motion.y)); } } if (over_line) { // We take the first item in selection, because with doubleclick, the first click // always resets selection to the single object under cursor - sp_mesh_context_split_near_point(this, selection->itemList()[0], this->mousepoint_doc, event->button.time); + sp_mesh_context_split_near_point(this, selection->items().front(), this->mousepoint_doc, event->button.time); } else { // Create a new gradient with default coordinates. - std::vector<SPItem*> items=selection->itemList(); - for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();++i){ + auto items= selection->items(); + for(auto i=items.begin();i!=items.end();++i){ SPItem *item = *i; SPGradientType new_type = SP_GRADIENT_TYPE_MESH; Inkscape::PaintTarget fsmode = (prefs->getInt("/tools/gradient/newfillorstroke", 1) != 0) ? Inkscape::FOR_FILL : Inkscape::FOR_STROKE; @@ -595,7 +597,7 @@ bool MeshTool::root_handler(GdkEvent* event) { if (!drag->lines.empty()) { for (std::vector<SPCtrlLine *>::const_iterator l = drag->lines.begin(); l != drag->lines.end() ; ++l) { - over_line |= sp_mesh_context_is_over_line (this, (SPItem*)(*l), Geom::Point(event->motion.x, event->motion.y)); + over_line |= sp_mesh_context_is_over_line (this, *l, Geom::Point(event->motion.x, event->motion.y)); } } @@ -626,8 +628,7 @@ bool MeshTool::root_handler(GdkEvent* event) { if (!drag->lines.empty()) { for (std::vector<SPCtrlLine *>::const_iterator l = drag->lines.begin(); l != drag->lines.end() && (!over_line); ++l) { - line = (SPCtrlLine*)(*l); - over_line = sp_mesh_context_is_over_line (this, (SPItem*) line, Geom::Point(event->motion.x, event->motion.y)); + over_line = sp_mesh_context_is_over_line (this, *l, Geom::Point(event->motion.x, event->motion.y)); if (over_line) { break; @@ -926,6 +927,7 @@ bool MeshTool::root_handler(GdkEvent* event) { return ret; } +// Creates a new mesh gradient. static void sp_mesh_end_drag(MeshTool &rc) { SPDesktop *desktop = SP_EVENT_CONTEXT(&rc)->desktop; Inkscape::Selection *selection = desktop->getSelection(); @@ -945,7 +947,7 @@ static void sp_mesh_end_drag(MeshTool &rc) { } else { // Starting from empty space: // Sort items so that the topmost comes last - std::vector<SPItem*> items(selection->itemList()); + std::vector<SPItem*> items(selection->items().begin(), selection->items().end()); sort(items.begin(),items.end(),sp_item_repr_compare_position); // take topmost vector = sp_gradient_vector_for_object(document, desktop, SP_ITEM(items.back()), fill_or_stroke); @@ -955,8 +957,8 @@ static void sp_mesh_end_drag(MeshTool &rc) { SPCSSAttr *css = sp_repr_css_attr_new(); sp_repr_css_set_property(css, "fill-opacity", "1.0"); - std::vector<SPItem*> items=selection->itemList(); - for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();++i){ + auto items= selection->items(); + for(auto i=items.begin();i!=items.end();++i){ //FIXME: see above sp_repr_css_change_recursive((*i)->getRepr(), css, "style"); @@ -972,7 +974,7 @@ static void sp_mesh_end_drag(MeshTool &rc) { // status text; we do not track coords because this branch is run once, not all the time // during drag - int n_objects = selection->itemList().size(); + int n_objects = (int) boost::distance(selection->items()); rc.message_context->setF(Inkscape::NORMAL_MESSAGE, ngettext("<b>Gradient</b> for %d object; with <b>Ctrl</b> to snap angle", "<b>Gradient</b> for %d objects; with <b>Ctrl</b> to snap angle", n_objects), diff --git a/src/ui/tools/node-tool.cpp b/src/ui/tools/node-tool.cpp index 23aaf6bb1..2bd4fdea3 100644 --- a/src/ui/tools/node-tool.cpp +++ b/src/ui/tools/node-tool.cpp @@ -24,25 +24,19 @@ #include "message-context.h" #include "selection.h" #include "ui/shape-editor.h" // temporary! -#include "live_effects/effect.h" -#include "display/curve.h" #include "snap.h" #include "sp-namedview.h" #include "sp-clippath.h" #include "sp-item-group.h" #include "sp-mask.h" -#include "sp-object-group.h" -#include "sp-path.h" #include "sp-text.h" #include "ui/control-manager.h" #include "ui/tools/node-tool.h" #include "ui/tool/control-point-selection.h" #include "ui/tool/event-utils.h" -#include "ui/tool/manipulator.h" #include "ui/tool/multi-path-manipulator.h" #include "ui/tool/path-manipulator.h" #include "ui/tool/selector.h" -#include "ui/tool/shape-record.h" #include "pixmaps/cursor-node.xpm" #include "pixmaps/cursor-node-d.xpm" @@ -250,7 +244,6 @@ void NodeTool::setup() { this->flash_tempitem = NULL; this->flashed_item = NULL; this->_last_over = NULL; - this->helperpath_tmpitem = NULL; // read prefs before adding items to selection to prevent momentarily showing the outline sp_event_context_read(this, "show_handles"); @@ -311,7 +304,7 @@ void NodeTool::update_helperpath () { cc->reset(); } if (!c->is_empty()) { - SPCanvasItem *helperpath = sp_canvas_bpath_new(this->desktop->getTempGroup(), c); + SPCanvasItem *helperpath = sp_canvas_bpath_new(this->desktop->getTempGroup(), c, true); sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(helperpath), 0x0000ff9A, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT); sp_canvas_bpath_set_fill(SP_CANVAS_BPATH(helperpath), 0, SP_WIND_RULE_NONZERO); sp_canvas_item_affine_absolute(helperpath, selection->singleItem()->i2dt_affine()); @@ -378,8 +371,8 @@ void gather_items(NodeTool *nt, SPItem *base, SPObject *obj, Inkscape::UI::Shape r.role = role; s.insert(r); } else if (role != SHAPE_ROLE_NORMAL && (SP_IS_GROUP(obj) || SP_IS_OBJECTGROUP(obj))) { - for (SPObject *c = obj->children; c; c = c->next) { - gather_items(nt, base, c, role, s); + for (auto& c: obj->children) { + gather_items(nt, base, &c, role, s); } } else if (SP_IS_ITEM(obj)) { SPItem *item = static_cast<SPItem*>(obj); @@ -407,8 +400,8 @@ void NodeTool::selection_changed(Inkscape::Selection *sel) { std::set<ShapeRecord> shapes; - std::vector<SPItem*> items=sel->itemList(); - for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();++i){ + auto items= sel->items(); + for(auto i=items.begin();i!=items.end();++i){ SPObject *obj = *i; if (SP_IS_ITEM(obj)) { @@ -443,8 +436,9 @@ void NodeTool::selection_changed(Inkscape::Selection *sel) { } } + std::vector<SPItem *> vec(sel->items().begin(), sel->items().end()); _previous_selection = _current_selection; - _current_selection = sel->itemList(); + _current_selection = vec; this->_multipath->setItems(shapes); this->update_tip(NULL); @@ -473,13 +467,10 @@ bool NodeTool::root_handler(GdkEvent* event) { if (this->_selected_nodes->event(this, event)) { return true; } - switch (event->type) { case GDK_MOTION_NOTIFY: { - this->update_helperpath(); combine_motion_events(desktop->canvas, event->motion, 0); - this->update_helperpath(); SPItem *over_item = sp_event_context_find_item (desktop, event_point(event->button), FALSE, TRUE); @@ -532,7 +523,7 @@ bool NodeTool::root_handler(GdkEvent* event) { } c->transform(over_item->i2dt_affine()); - SPCanvasItem *flash = sp_canvas_bpath_new(desktop->getTempGroup(), c); + SPCanvasItem *flash = sp_canvas_bpath_new(desktop->getTempGroup(), c, true); sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(flash), //prefs->getInt("/tools/nodes/highlight_color", 0xff0000ff), 1.0, @@ -634,7 +625,6 @@ bool NodeTool::root_handler(GdkEvent* event) { void NodeTool::update_tip(GdkEvent *event) { using namespace Inkscape::UI; - if (event && (event->type == GDK_KEY_PRESS || event->type == GDK_KEY_RELEASE)) { unsigned new_state = state_after_event(event); diff --git a/src/ui/tools/pen-tool.cpp b/src/ui/tools/pen-tool.cpp index 18af8e105..b7579b1fb 100644 --- a/src/ui/tools/pen-tool.cpp +++ b/src/ui/tools/pen-tool.cpp @@ -32,8 +32,6 @@ #include "ui/draw-anchor.h" #include "message-stack.h" #include "message-context.h" -#include "preferences.h" -#include "sp-path.h" #include "display/sp-canvas.h" #include "display/curve.h" #include "pixmaps/cursor-pen.xpm" @@ -46,7 +44,6 @@ #include "ui/tools-switch.h" #include "ui/control-manager.h" // we include the necessary files for BSpline & Spiro -#include "live_effects/effect.h" #include "live_effects/lpeobject.h" #include "live_effects/lpeobject-reference.h" #include "live_effects/parameter/path.h" @@ -54,25 +51,16 @@ #include "live_effects/lpe-spiro.h" -#include <typeinfo> -#include <2geom/pathvector.h> -#include <2geom/affine.h> #include <2geom/curves.h> #include "helper/geom-nodetype.h" -#include "helper/geom-curves.h" // For handling un-continuous paths: -#include "message-stack.h" #include "inkscape.h" -#include "desktop.h" #include "live_effects/spiro.h" #define INKSCAPE_LPE_BSPLINE_C #include "live_effects/lpe-bspline.h" -#include <2geom/nearest-time.h> - -#include "live_effects/effect.h" using Inkscape::ControlManager; @@ -877,7 +865,7 @@ void PenTool::_redrawAll() { this->green_bpaths = g_slist_remove(this->green_bpaths, this->green_bpaths->data); } // one canvas bpath for all of green_curve - SPCanvasItem *canvas_shape = sp_canvas_bpath_new(this->desktop->getSketch(), this->green_curve); + SPCanvasItem *canvas_shape = sp_canvas_bpath_new(this->desktop->getSketch(), this->green_curve, true); sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(canvas_shape), this->green_color, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT); sp_canvas_bpath_set_fill(SP_CANVAS_BPATH(canvas_shape), 0, SP_WIND_RULE_NONZERO); @@ -889,7 +877,7 @@ void PenTool::_redrawAll() { this->red_curve->reset(); this->red_curve->moveto(this->p[0]); this->red_curve->curveto(this->p[1], this->p[2], this->p[3]); - sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(this->red_bpath), this->red_curve); + sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(this->red_bpath), this->red_curve, true); // handles // hide the handlers in bspline and spiro modes @@ -1263,10 +1251,10 @@ bool PenTool::_handleKeyPress(GdkEvent *event) { void PenTool::_resetColors() { // Red this->red_curve->reset(); - sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(this->red_bpath), NULL); + sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(this->red_bpath), NULL, true); // Blue this->blue_curve->reset(); - sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(this->blue_bpath), NULL); + sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(this->blue_bpath), NULL, true); // Green while (this->green_bpaths) { sp_canvas_item_destroy(SP_CANVAS_ITEM(this->green_bpaths->data)); @@ -1289,7 +1277,7 @@ void PenTool::_setInitialPoint(Geom::Point const p) { this->p[0] = p; this->p[1] = p; this->npoints = 2; - sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(this->red_bpath), NULL); + sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(this->red_bpath), NULL, true); this->desktop->canvas->forceFullRedrawAfterInterruptions(5); } @@ -1355,7 +1343,7 @@ void PenTool::_bsplineSpiroColor() this->green_bpaths = g_slist_remove(this->green_bpaths, this->green_bpaths->data); } // one canvas bpath for all of green_curve - SPCanvasItem *canvas_shape = sp_canvas_bpath_new(this->desktop->getSketch(), this->green_curve); + SPCanvasItem *canvas_shape = sp_canvas_bpath_new(this->desktop->getSketch(), this->green_curve, true); sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(canvas_shape), this->green_color, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT); sp_canvas_bpath_set_fill(SP_CANVAS_BPATH(canvas_shape), 0, SP_WIND_RULE_NONZERO); this->green_bpaths = g_slist_prepend(this->green_bpaths, canvas_shape); @@ -1713,7 +1701,7 @@ void PenTool::_bsplineSpiroBuild() }else{ this->red_curve->curveto(this->p[1],this->p[2],this->p[3]); } - sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(this->red_bpath), this->red_curve); + sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(this->red_bpath), this->red_curve, true); curve->append_continuous(this->red_curve, 0.0625); } @@ -1734,7 +1722,7 @@ void PenTool::_bsplineSpiroBuild() LivePathEffect::sp_spiro_do_effect(curve); } - sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(this->blue_bpath), curve); + sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(this->blue_bpath), curve, true); sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(this->blue_bpath), this->blue_color, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT); sp_canvas_item_show(this->blue_bpath); curve->unref(); @@ -1790,7 +1778,7 @@ void PenTool::_setSubsequentPoint(Geom::Point const p, bool statusbar, guint sta } } - sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(this->red_bpath), this->red_curve); + sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(this->red_bpath), this->red_curve, true); if (statusbar) { gchar *message = is_curve ? @@ -1830,7 +1818,7 @@ void PenTool::_setCtrl(Geom::Point const p, guint const state) { this->red_curve->reset(); this->red_curve->moveto(this->p[0]); this->red_curve->curveto(this->p[1], this->p[2], this->p[3]); - sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(this->red_bpath), this->red_curve); + sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(this->red_bpath), this->red_curve, true); } SP_CTRL(this->c0)->moveto(this->p[2]); this->cl0 ->setCoords(this->p[3], this->p[2]); @@ -1862,7 +1850,7 @@ void PenTool::_finishSegment(Geom::Point const p, guint const state) { SPCurve *curve = this->red_curve->copy(); /// \todo fixme: - SPCanvasItem *canvas_shape = sp_canvas_bpath_new(this->desktop->getSketch(), curve); + SPCanvasItem *canvas_shape = sp_canvas_bpath_new(this->desktop->getSketch(), curve, true); curve->unref(); sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(canvas_shape), this->green_color, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT); diff --git a/src/ui/tools/pencil-tool.cpp b/src/ui/tools/pencil-tool.cpp index b029ca613..9e8005be8 100644 --- a/src/ui/tools/pencil-tool.cpp +++ b/src/ui/tools/pencil-tool.cpp @@ -27,7 +27,6 @@ #include "message-stack.h" #include "message-context.h" #include "sp-path.h" -#include "preferences.h" #include "snap.h" #include "pixmaps/cursor-pencil.xpm" #include <2geom/sbasis-to-bezier.h> @@ -36,13 +35,9 @@ #include <glibmm/i18n.h> #include "context-fns.h" #include "sp-namedview.h" -#include "xml/repr.h" -#include "document.h" #include "desktop-style.h" -#include "macros.h" #include "display/sp-canvas.h" #include "display/curve.h" -#include "livarot/Path.h" #include "ui/tool/event-utils.h" namespace Inkscape { @@ -852,7 +847,7 @@ void PencilTool::_fitAndSplit() { SPCurve *curve = this->red_curve->copy(); /// \todo fixme: - SPCanvasItem *cshape = sp_canvas_bpath_new(this->desktop->getSketch(), curve); + SPCanvasItem *cshape = sp_canvas_bpath_new(this->desktop->getSketch(), curve, true); curve->unref(); this->highlight_color = SP_ITEM(this->desktop->currentLayer())->highlight_color(); diff --git a/src/ui/tools/rect-tool.cpp b/src/ui/tools/rect-tool.cpp index 844965c4d..00330ef57 100644 --- a/src/ui/tools/rect-tool.cpp +++ b/src/ui/tools/rect-tool.cpp @@ -14,8 +14,6 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include "config.h" - #include <gdk/gdkkeysyms.h> #include <cstring> #include <string> @@ -29,16 +27,13 @@ #include "selection.h" #include "selection-chemistry.h" -#include "snap.h" #include "desktop.h" #include "desktop-style.h" #include "message-context.h" #include "pixmaps/cursor-rect.xpm" #include "ui/tools/rect-tool.h" #include <glibmm/i18n.h> -#include "xml/repr.h" #include "xml/node-event-vector.h" -#include "preferences.h" #include "context-fns.h" #include "ui/shape-editor.h" #include "verbs.h" diff --git a/src/ui/tools/select-tool.cpp b/src/ui/tools/select-tool.cpp index b5ec3d88e..86a2dbed3 100644 --- a/src/ui/tools/select-tool.cpp +++ b/src/ui/tools/select-tool.cpp @@ -15,7 +15,7 @@ */ #ifdef HAVE_CONFIG_H -# include "config.h" +#include <config.h> #endif #include <cstring> #include <string> @@ -40,14 +40,12 @@ #include "desktop.h" #include "sp-root.h" -#include "preferences.h" #include "ui/tools-switch.h" #include "message-stack.h" #include "selection-describer.h" #include "seltrans.h" #include "box3d.h" #include "display/sp-canvas.h" -#include "display/sp-canvas-item.h" #include "display/drawing-item.h" using Inkscape::DocumentUndo; @@ -128,20 +126,12 @@ SelectTool::~SelectTool() { this->_describer = NULL; if (CursorSelectDragging) { -#if GTK_CHECK_VERSION(3,0,0) g_object_unref(CursorSelectDragging); -#else - gdk_cursor_unref (CursorSelectDragging); -#endif CursorSelectDragging = NULL; } if (CursorSelectMouseover) { -#if GTK_CHECK_VERSION(3,0,0) g_object_unref(CursorSelectMouseover); -#else - gdk_cursor_unref (CursorSelectMouseover); -#endif CursorSelectMouseover = NULL; } } @@ -477,7 +467,7 @@ bool SelectTool::root_handler(GdkEvent* event) { case GDK_2BUTTON_PRESS: if (event->button.button == 1) { if (!selection->isEmpty()) { - SPItem *clicked_item = selection->itemList()[0]; + SPItem *clicked_item = selection->items().front(); if (dynamic_cast<SPGroup *>(clicked_item) && !dynamic_cast<SPBox3D *>(clicked_item)) { // enter group if it's not a 3D box desktop->setCurrentLayer(clicked_item); diff --git a/src/ui/tools/spiral-tool.cpp b/src/ui/tools/spiral-tool.cpp index 833fef18d..0ba08853e 100644 --- a/src/ui/tools/spiral-tool.cpp +++ b/src/ui/tools/spiral-tool.cpp @@ -14,8 +14,6 @@ * Released under GNU GPL */ -#include "config.h" - #include <gdk/gdkkeysyms.h> #include <cstring> #include <string> @@ -28,16 +26,13 @@ #include "sp-namedview.h" #include "selection.h" -#include "snap.h" #include "desktop.h" #include "desktop-style.h" #include "message-context.h" #include "pixmaps/cursor-spiral.xpm" #include "ui/tools/spiral-tool.h" #include <glibmm/i18n.h> -#include "xml/repr.h" #include "xml/node-event-vector.h" -#include "preferences.h" #include "context-fns.h" #include "ui/shape-editor.h" #include "verbs.h" diff --git a/src/ui/tools/spray-tool.cpp b/src/ui/tools/spray-tool.cpp index 9adaf3879..3649008ff 100644 --- a/src/ui/tools/spray-tool.cpp +++ b/src/ui/tools/spray-tool.cpp @@ -13,21 +13,19 @@ * Jon A. Cruz <jon@joncruz.org> * Abhishek Sharma * Jabiertxo Arraiza <jabier.arraiza@marker.es> + * Adrian Boguszewski * * Copyright (C) 2009 authors * * Released under GNU GPL, read the file 'COPYING' for more information */ -#include "config.h" - #include <numeric> #include "ui/dialog/dialog-manager.h" #include "svg/svg.h" -#include <glib.h> #include "macros.h" #include "document.h" #include "document-undo.h" @@ -37,10 +35,7 @@ #include "message-context.h" #include "pixmaps/cursor-spray.xpm" -#include <boost/optional.hpp> -#include "xml/repr.h" #include "context-fns.h" -#include "sp-item.h" #include "inkscape.h" #include "splivarot.h" @@ -57,17 +52,12 @@ #include "svg/svg-color.h" #include "sp-text.h" -#include "sp-root.h" #include "sp-flowtext.h" #include "display/sp-canvas.h" -#include "display/canvas-bpath.h" #include "display/canvas-arena.h" #include "display/curve.h" #include "livarot/Shape.h" #include <2geom/circle.h> -#include <2geom/transforms.h> -#include "preferences.h" -#include "style.h" #include "box3d.h" #include "sp-item-transform.h" #include "filter-chemistry.h" @@ -76,9 +66,6 @@ #include "helper/action.h" #include "verbs.h" -#include <iostream> - -#include <gtk/gtk.h> #include <gdk/gdkkeysyms.h> #include <glibmm/i18n.h> @@ -196,6 +183,7 @@ SprayTool::SprayTool() } SprayTool::~SprayTool() { + object_set.clear(); this->enableGrDrag(false); this->style_set_connection.disconnect(); @@ -210,7 +198,7 @@ void SprayTool::update_cursor(bool /*with_shift*/) { gchar *sel_message = NULL; if (!desktop->selection->isEmpty()) { - num = desktop->selection->itemList().size(); + num = (guint) boost::distance(desktop->selection->items()); sel_message = g_strdup_printf(ngettext("<b>%i</b> object selected","<b>%i</b> objects selected",num), num); } else { sel_message = g_strdup_printf("%s", _("<b>Nothing</b> selected")); @@ -591,7 +579,7 @@ static bool fit_item(SPDesktop *desktop, if (selection->isEmpty()) { return false; } - std::vector<SPItem*> const items_selected(selection->itemList()); + std::vector<SPItem*> const items_selected(selection->items().begin(), selection->items().end()); std::vector<SPItem*> items_down_erased; for (std::vector<SPItem*>::const_iterator i=items_down.begin(); i!=items_down.end(); ++i) { SPItem *item_down = *i; @@ -862,7 +850,7 @@ static bool fit_item(SPDesktop *desktop, } static bool sp_spray_recursive(SPDesktop *desktop, - Inkscape::Selection *selection, + Inkscape::ObjectSet *set, SPItem *item, Geom::Point p, Geom::Point /*vector*/, @@ -907,7 +895,7 @@ static bool sp_spray_recursive(SPDesktop *desktop, if (box) { // convert 3D boxes to ordinary groups before spraying their shapes item = box3d_convert_to_group(box); - selection->add(item); + set->add(item); } } @@ -996,23 +984,11 @@ static bool sp_spray_recursive(SPDesktop *desktop, } #ifdef ENABLE_SPRAY_MODE_SINGLE_PATH } else if (mode == SPRAY_MODE_SINGLE_PATH) { + long setSize = boost::distance(set->items()); + SPItem *parent_item = setSize > 0 ? set->items().front() : nullptr; // Initial object + SPItem *unionResult = setSize > 1 ? *(++set->items().begin()) : nullptr; // Previous union + SPItem *item_copied = nullptr; // Projected object - SPItem *parent_item = NULL; // Initial object - SPItem *item_copied = NULL; // Projected object - SPItem *unionResult = NULL; // Previous union - - int i=1; - std::vector<SPItem*> items=selection->itemList(); - for(std::vector<SPItem*>::const_iterator it=items.begin();it!=items.end(); ++it){ - SPItem *item1 = *it; - if (i == 1) { - parent_item = item1; - } - if (i == 2) { - unionResult = item1; - } - i++; - } if (parent_item) { SPDocument *doc = parent_item->document; Inkscape::XML::Document* xml_doc = doc->getReprDoc(); @@ -1045,13 +1021,13 @@ static bool sp_spray_recursive(SPDesktop *desktop, sp_item_move_rel(item_copied, Geom::Translate(move[Geom::X], -move[Geom::Y])); // Union and duplication - selection->clear(); - selection->add(item_copied); + set->clear(); + set->add(item_copied); if (unionResult) { // No need to add the very first item (initialized with NULL). - selection->add(unionResult); + set->add(unionResult); } - sp_selected_path_union_skip_undo(selection, selection->desktop()); - selection->add(parent_item); + sp_selected_path_union_skip_undo(set); + set->add(parent_item); Inkscape::GC::release(copy); did = true; } @@ -1146,9 +1122,8 @@ static bool sp_spray_recursive(SPDesktop *desktop, static bool sp_spray_dilate(SprayTool *tc, Geom::Point /*event_p*/, Geom::Point p, Geom::Point vector, bool reverse) { SPDesktop *desktop = tc->desktop; - Inkscape::Selection *selection = desktop->getSelection(); - - if (selection->isEmpty()) { + Inkscape::ObjectSet *set = tc->objectSet(); + if (set->isEmpty()) { return false; } @@ -1170,7 +1145,7 @@ static bool sp_spray_dilate(SprayTool *tc, Geom::Point /*event_p*/, Geom::Point double move_standard_deviation = get_move_standard_deviation(tc); { - std::vector<SPItem*> const items(selection->itemList()); + std::vector<SPItem*> const items(set->items().begin(), set->items().end()); for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end(); ++i){ SPItem *item = *i; @@ -1182,7 +1157,7 @@ static bool sp_spray_dilate(SprayTool *tc, Geom::Point /*event_p*/, Geom::Point SPItem *item = *i; g_assert(item != NULL); if (sp_spray_recursive(desktop - , selection + , set , item , p, vector , tc->mode @@ -1276,6 +1251,11 @@ bool SprayTool::root_handler(GdkEvent* event) { this->is_dilating = true; this->has_dilated = false; + object_set = *desktop->getSelection(); + if (mode == SPRAY_MODE_SINGLE_PATH) { + desktop->getSelection()->clear(); + } + if(this->is_dilating && event->button.button == 1 && !this->space_panning) { sp_spray_dilate(this, motion_w, desktop->dt2doc(motion_dt), Geom::Point(0,0), MOD__SHIFT(event)); } @@ -1299,7 +1279,7 @@ bool SprayTool::root_handler(GdkEvent* event) { guint num = 0; if (!desktop->selection->isEmpty()) { - num = desktop->selection->itemList().size(); + num = (guint) boost::distance(desktop->selection->items()); } if (num == 0) { this->message_context->flash(Inkscape::ERROR_MESSAGE, _("<b>Nothing selected!</b> Select objects to spray.")); @@ -1384,6 +1364,8 @@ bool SprayTool::root_handler(GdkEvent* event) { SP_VERB_CONTEXT_SPRAY, _("Spray with clones")); break; case SPRAY_MODE_SINGLE_PATH: + sp_selected_path_union_skip_undo(objectSet()); + desktop->getSelection()->add(object_set.objects().begin(), object_set.objects().end()); DocumentUndo::done(this->desktop->getDocument(), SP_VERB_CONTEXT_SPRAY, _("Spray in single path")); break; diff --git a/src/ui/tools/spray-tool.h b/src/ui/tools/spray-tool.h index c81110b37..d5504d565 100644 --- a/src/ui/tools/spray-tool.h +++ b/src/ui/tools/spray-tool.h @@ -13,6 +13,7 @@ * Vincent MONTAGNE * Pierre BARBRY-BLOT * Jabiertxo ARRAIZA + * Adrian Boguszewski * * Copyright (C) 2009 authors * @@ -120,8 +121,14 @@ public: virtual const std::string& getPrefsPath(); - void update_cursor(bool /*with_shift*/); + + ObjectSet* objectSet() { + return &object_set; + } + +private: + ObjectSet object_set; }; } diff --git a/src/ui/tools/star-tool.cpp b/src/ui/tools/star-tool.cpp index 9190ae57b..ddee08189 100644 --- a/src/ui/tools/star-tool.cpp +++ b/src/ui/tools/star-tool.cpp @@ -15,7 +15,7 @@ */ #ifdef HAVE_CONFIG_H -# include "config.h" +#include <config.h> #endif #include <cstring> @@ -31,14 +31,11 @@ #include "sp-namedview.h" #include "selection.h" -#include "snap.h" #include "desktop.h" #include "desktop-style.h" #include "message-context.h" #include "pixmaps/cursor-star.xpm" #include <glibmm/i18n.h> -#include "preferences.h" -#include "xml/repr.h" #include "xml/node-event-vector.h" #include "context-fns.h" #include "ui/shape-editor.h" diff --git a/src/ui/tools/text-tool.cpp b/src/ui/tools/text-tool.cpp index 1888551cf..559187764 100644 --- a/src/ui/tools/text-tool.cpp +++ b/src/ui/tools/text-tool.cpp @@ -14,7 +14,7 @@ */ #ifdef HAVE_CONFIG_H -# include <config.h> +#include <config.h> #endif #include <gtkmm/clipboard.h> @@ -23,7 +23,6 @@ #include <display/sp-ctrlquadr.h> #include <gdk/gdkkeysyms.h> #include <glibmm/i18n.h> -#include <sstream> #include "context-fns.h" @@ -36,7 +35,6 @@ #include "message-stack.h" #include "pixmaps/cursor-text-insert.xpm" #include "pixmaps/cursor-text.xpm" -#include "preferences.h" #include "rubberband.h" #include "selection-chemistry.h" #include "selection.h" @@ -50,8 +48,6 @@ #include "ui/control-manager.h" #include "verbs.h" #include "xml/node-event-vector.h" -#include "xml/repr.h" -#include <gtk/gtk.h> using Inkscape::ControlManager; using Inkscape::DocumentUndo; diff --git a/src/ui/tools/tool-base.cpp b/src/ui/tools/tool-base.cpp index 72ba499de..8a35882b9 100644 --- a/src/ui/tools/tool-base.cpp +++ b/src/ui/tools/tool-base.cpp @@ -15,7 +15,7 @@ */ #ifdef HAVE_CONFIG_H -# include "config.h" +#include <config.h> #endif #include "widgets/desktop-widget.h" @@ -24,12 +24,8 @@ #include "file.h" #include "ui/tools/tool-base.h" -#include <string.h> #include <gdk/gdkkeysyms.h> -#include <gtk/gtk.h> #include <glibmm/i18n.h> -#include <cstring> -#include <string> #include "display/sp-canvas.h" #include "xml/node-event-vector.h" @@ -43,18 +39,14 @@ #include "ui/interface.h" #include "macros.h" #include "ui/tools-switch.h" -#include "preferences.h" #include "message-context.h" #include "gradient-drag.h" -#include "attributes.h" #include "rubberband.h" #include "selcue.h" #include "ui/tools/lpe-tool.h" #include "ui/tool/control-point.h" #include "ui/shape-editor.h" #include "sp-guide.h" -#include "color.h" -#include "knot.h" #include "knot-ptr.h" // globals for temporary switching to selector by space @@ -118,11 +110,7 @@ ToolBase::~ToolBase() { } if (this->cursor != NULL) { -#if GTK_CHECK_VERSION(3,0,0) g_object_unref(this->cursor); -#else - gdk_cursor_unref(this->cursor); -#endif this->cursor = NULL; } @@ -149,16 +137,10 @@ void ToolBase::sp_event_context_set_cursor(GdkCursorType cursor_type) { GdkDisplay *display = gdk_display_get_default(); GdkCursor *cursor = gdk_cursor_new_for_display(display, cursor_type); -#if WITH_GTKMM_3_0 if (cursor) { gdk_window_set_cursor (gtk_widget_get_window (w), cursor); g_object_unref (cursor); } -#else - gdk_window_set_cursor (gtk_widget_get_window (w), cursor); - gdk_cursor_unref (cursor); -#endif - } /** @@ -188,11 +170,7 @@ void ToolBase::sp_event_context_update_cursor() { ); if (pixbuf != NULL) { if (this->cursor) { -#if GTK_CHECK_VERSION(3,0,0) g_object_unref(this->cursor); -#else - gdk_cursor_unref(this->cursor); -#endif } this->cursor = gdk_cursor_new_from_pixbuf(display, pixbuf, this->hot_x, this->hot_y); g_object_unref(pixbuf); @@ -202,11 +180,7 @@ void ToolBase::sp_event_context_update_cursor() { if (pixbuf) { if (this->cursor) { -#if GTK_CHECK_VERSION(3,0,0) g_object_unref(this->cursor); -#else - gdk_cursor_unref(this->cursor); -#endif } this->cursor = gdk_cursor_new_from_pixbuf(display, pixbuf, this->hot_x, this->hot_y); @@ -777,11 +751,9 @@ bool ToolBase::root_handler(GdkEvent* event) { int const wheel_scroll = prefs->getIntLimited( "/options/wheelscroll/value", 40, 0, 1000); -#if GTK_CHECK_VERSION(3,0,0) // Size of smooth-scrolls (only used in GTK+ 3) gdouble delta_x = 0; gdouble delta_y = 0; -#endif /* shift + wheel, pan left--right */ if (event->scroll.state & GDK_SHIFT_MASK) { @@ -842,12 +814,10 @@ bool ToolBase::root_handler(GdkEvent* event) { desktop->scroll_world(-wheel_scroll, 0); break; -#if GTK_CHECK_VERSION(3,0,0) case GDK_SCROLL_SMOOTH: gdk_event_get_scroll_deltas(event, &delta_x, &delta_y); desktop->scroll_world(delta_x, delta_y); break; -#endif } } break; @@ -1081,9 +1051,8 @@ void sp_event_root_menu_popup(SPDesktop *desktop, SPItem *item, GdkEvent *event) item = sp_event_context_find_item (desktop, Geom::Point(event->button.x, event->button.y), FALSE, FALSE); - /* fixme: This is not what I want but works for now (Lauris) */ - if (event->type == GDK_KEY_PRESS) { - item = desktop->getSelection()->itemList().front(); + if (event->type == GDK_KEY_PRESS && !desktop->getSelection()->isEmpty()) { + item = desktop->getSelection()->items().front(); } ContextMenu* CM = new ContextMenu(desktop, item); @@ -1157,8 +1126,9 @@ SPItem *sp_event_context_find_item(SPDesktop *desktop, Geom::Point const &p, SPItem *item = 0; if (select_under) { - SPItem *selected_at_point = desktop->getItemFromListAtPointBottom( - desktop->selection->itemList(), p); + auto tmp = desktop->selection->items(); + std::vector<SPItem *> vec(tmp.begin(), tmp.end()); + SPItem *selected_at_point = desktop->getItemFromListAtPointBottom(vec, p); item = desktop->getItemAtPoint(p, into_groups, selected_at_point); if (item == NULL) { // we may have reached bottom, flip over to the top item = desktop->getItemAtPoint(p, into_groups, NULL); diff --git a/src/ui/tools/tweak-tool.cpp b/src/ui/tools/tweak-tool.cpp index 39a7a3f0b..a0394ecd4 100644 --- a/src/ui/tools/tweak-tool.cpp +++ b/src/ui/tools/tweak-tool.cpp @@ -11,8 +11,6 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include "config.h" - #include <gtk/gtk.h> #include <gdk/gdkkeysyms.h> #include <glibmm/i18n.h> @@ -21,7 +19,6 @@ #include "svg/svg.h" -#include <glib.h> #include "macros.h" #include "document.h" #include "document-undo.h" @@ -48,19 +45,13 @@ #include "pixmaps/cursor-push.xpm" #include "pixmaps/cursor-roughen.xpm" #include "pixmaps/cursor-color.xpm" -#include <boost/optional.hpp> -#include "xml/repr.h" #include "context-fns.h" -#include "sp-item.h" #include "inkscape.h" -#include "color.h" -#include "svg/svg-color.h" #include "splivarot.h" #include "sp-item-group.h" #include "sp-shape.h" #include "sp-path.h" #include "path-chemistry.h" -#include "sp-gradient.h" #include "sp-stop.h" #include "sp-gradient-reference.h" #include "sp-linear-gradient.h" @@ -69,13 +60,10 @@ #include "sp-text.h" #include "sp-flowtext.h" #include "display/sp-canvas.h" -#include "display/canvas-bpath.h" #include "display/canvas-arena.h" #include "display/curve.h" #include "livarot/Shape.h" -#include <2geom/transforms.h> #include <2geom/circle.h> -#include "preferences.h" #include "style.h" #include "box3d.h" #include "sp-item-transform.h" @@ -153,7 +141,7 @@ void TweakTool::update_cursor (bool with_shift) { gchar *sel_message = NULL; if (!desktop->selection->isEmpty()) { - num = desktop->selection->itemList().size(); + num = (guint) boost::distance(desktop->selection->items()); sel_message = g_strdup_printf(ngettext("<b>%i</b> object selected","<b>%i</b> objects selected",num), num); } else { sel_message = g_strdup_printf("%s", _("<b>Nothing</b> selected")); @@ -385,9 +373,9 @@ sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, Geom::P if (dynamic_cast<SPGroup *>(item) && !dynamic_cast<SPBox3D *>(item)) { GSList *children = NULL; - for (SPObject *child = item->firstChild() ; child; child = child->getNext() ) { - if (dynamic_cast<SPItem *>(static_cast<SPObject *>(child))) { - children = g_slist_prepend(children, child); + for (auto& child: item->children) { + if (dynamic_cast<SPItem *>(static_cast<SPObject *>(&child))) { + children = g_slist_prepend(children, &child); } } @@ -832,8 +820,8 @@ static void tweak_colors_in_gradient(SPItem *item, Inkscape::PaintTarget fill_or double offset_l = 0; double offset_h = 0; SPObject *child_prev = NULL; - for (SPObject *child = vector->firstChild(); child; child = child->getNext()) { - SPStop *stop = dynamic_cast<SPStop *>(child); + for (auto& child: vector->children) { + SPStop *stop = dynamic_cast<SPStop *>(&child); if (!stop) { continue; } @@ -878,7 +866,7 @@ static void tweak_colors_in_gradient(SPItem *item, Inkscape::PaintTarget fill_or } offset_l = offset_h; - child_prev = child; + child_prev = &child; } } @@ -894,8 +882,8 @@ sp_tweak_color_recursive (guint mode, SPItem *item, SPItem *item_at_point, bool did = false; if (dynamic_cast<SPGroup *>(item)) { - for (SPObject *child = item->firstChild() ; child; child = child->getNext() ) { - SPItem *childItem = dynamic_cast<SPItem *>(child); + for (auto& child: item->children) { + SPItem *childItem = dynamic_cast<SPItem *>(&child); if (childItem) { if (sp_tweak_color_recursive (mode, childItem, item_at_point, fill_goal, do_fill, @@ -951,9 +939,8 @@ sp_tweak_color_recursive (guint mode, SPItem *item, SPItem *item_at_point, Geom::Affine i2dt = item->i2dt_affine (); if (style->filter.set && style->getFilter()) { //cycle through filter primitives - SPObject *primitive_obj = style->getFilter()->children; - while (primitive_obj) { - SPFilterPrimitive *primitive = dynamic_cast<SPFilterPrimitive *>(primitive_obj); + for (auto& primitive_obj: style->getFilter()->children) { + SPFilterPrimitive *primitive = dynamic_cast<SPFilterPrimitive *>(&primitive_obj); if (primitive) { //if primitive is gaussianblur SPGaussianBlur * spblur = dynamic_cast<SPGaussianBlur *>(primitive); @@ -962,7 +949,6 @@ sp_tweak_color_recursive (guint mode, SPItem *item, SPItem *item_at_point, blur_now += num * i2dt.descrim(); // sum all blurs in the filter } } - primitive_obj = primitive_obj->next; } } double perimeter = bbox->dimensions()[Geom::X] + bbox->dimensions()[Geom::Y]; @@ -1076,8 +1062,8 @@ sp_tweak_dilate (TweakTool *tc, Geom::Point event_p, Geom::Point p, Geom::Point double move_force = get_move_force(tc); double color_force = MIN(sqrt(path_force)/20.0, 1); - std::vector<SPItem*> items=selection->itemList(); - for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end(); ++i){ + auto items= selection->items(); + for(auto i=items.begin();i!=items.end(); ++i){ SPItem *item = *i; if (is_color_mode (tc->mode)) { @@ -1185,7 +1171,7 @@ bool TweakTool::root_handler(GdkEvent* event) { guint num = 0; if (!desktop->selection->isEmpty()) { - num = desktop->selection->itemList().size(); + num = (guint) boost::distance(desktop->selection->items()); } if (num == 0) { this->message_context->flash(Inkscape::ERROR_MESSAGE, _("<b>Nothing selected!</b> Select objects to tweak.")); diff --git a/src/ui/tools/zoom-tool.cpp b/src/ui/tools/zoom-tool.cpp index 13e097c18..ca42d2d6f 100644 --- a/src/ui/tools/zoom-tool.cpp +++ b/src/ui/tools/zoom-tool.cpp @@ -21,7 +21,6 @@ #include "desktop.h" #include "pixmaps/cursor-zoom.xpm" #include "pixmaps/cursor-zoom-out.xpm" -#include "preferences.h" #include "selection-chemistry.h" #include "ui/tools/zoom-tool.h" diff --git a/src/ui/uxmanager.cpp b/src/ui/uxmanager.cpp index 036659661..cbce86cdb 100644 --- a/src/ui/uxmanager.cpp +++ b/src/ui/uxmanager.cpp @@ -10,18 +10,15 @@ */ #ifdef HAVE_CONFIG_H -# include "config.h" +#include <config.h> #endif #include "widgets/desktop-widget.h" -#include <algorithm> #include "uxmanager.h" #include "desktop.h" #include "util/ege-tags.h" #include "widgets/toolbox.h" -#include "preferences.h" -#include "gdkmm/screen.h" #ifdef GDK_WINDOWING_X11 #include <gdk/gdkx.h> diff --git a/src/ui/view/Makefile_insert b/src/ui/view/Makefile_insert deleted file mode 100644 index b3ab598d4..000000000 --- a/src/ui/view/Makefile_insert +++ /dev/null @@ -1,9 +0,0 @@ -## Makefile.am fragment sourced by src/Makefile.am. - -ink_common_sources += \ - ui/view/edit-widget-interface.h \ - ui/view/view.h \ - ui/view/view.cpp \ - ui/view/view-widget.cpp \ - ui/view/view-widget.h - diff --git a/src/ui/widget/Makefile_insert b/src/ui/widget/Makefile_insert deleted file mode 100644 index b5d8a74f6..000000000 --- a/src/ui/widget/Makefile_insert +++ /dev/null @@ -1,112 +0,0 @@ -## Makefile.am fragment sourced by src/Makefile.am. - -ink_common_sources += \ - ui/widget/anchor-selector.h \ - ui/widget/anchor-selector.cpp \ - ui/widget/attr-widget.h \ - ui/widget/button.h \ - ui/widget/button.cpp \ - ui/widget/color-entry.cpp \ - ui/widget/color-entry.h \ - ui/widget/color-icc-selector.cpp \ - ui/widget/color-icc-selector.h \ - ui/widget/color-notebook.cpp \ - ui/widget/color-notebook.h \ - ui/widget/color-wheel-selector.cpp \ - ui/widget/color-wheel-selector.h \ - ui/widget/color-picker.cpp \ - ui/widget/color-picker.h \ - ui/widget/color-preview.cpp \ - ui/widget/color-preview.h \ - ui/widget/color-slider.cpp \ - ui/widget/color-slider.h \ - ui/widget/color-scales.cpp \ - ui/widget/color-scales.h \ - ui/widget/combo-enums.h \ - ui/widget/dock.h \ - ui/widget/dock.cpp \ - ui/widget/dock-item.h \ - ui/widget/dock-item.cpp \ - ui/widget/entity-entry.cpp \ - ui/widget/entity-entry.h \ - ui/widget/entry.cpp \ - ui/widget/entry.h \ - ui/widget/filter-effect-chooser.h \ - ui/widget/filter-effect-chooser.cpp \ - ui/widget/font-button.h \ - ui/widget/font-button.cpp \ - ui/widget/font-variants.h \ - ui/widget/font-variants.cpp \ - ui/widget/gimpspinscale.c \ - ui/widget/gimpspinscale.h \ - ui/widget/gimpcolorwheel.c \ - ui/widget/gimpcolorwheel.h \ - ui/widget/frame.cpp \ - ui/widget/frame.h \ - ui/widget/imageicon.cpp \ - ui/widget/imageicon.h \ - ui/widget/imagetoggler.cpp \ - ui/widget/imagetoggler.h \ - ui/widget/labelled.cpp \ - ui/widget/labelled.h \ - ui/widget/layer-selector.cpp \ - ui/widget/layer-selector.h \ - ui/widget/licensor.cpp \ - ui/widget/licensor.h \ - ui/widget/notebook-page.cpp \ - ui/widget/notebook-page.h \ - ui/widget/object-composite-settings.cpp \ - ui/widget/object-composite-settings.h \ - ui/widget/page-sizer.cpp \ - ui/widget/page-sizer.h \ - ui/widget/panel.cpp \ - ui/widget/panel.h \ - ui/widget/point.cpp \ - ui/widget/point.h \ - ui/widget/preferences-widget.cpp \ - ui/widget/preferences-widget.h \ - ui/widget/random.cpp \ - ui/widget/random.h \ - ui/widget/registered-widget.cpp \ - ui/widget/registered-widget.h \ - ui/widget/registered-enums.h \ - ui/widget/registry.cpp \ - ui/widget/registry.h \ - ui/widget/rendering-options.cpp \ - ui/widget/rendering-options.h \ - ui/widget/rotateable.h \ - ui/widget/rotateable.cpp \ - ui/widget/scalar-unit.cpp \ - ui/widget/scalar-unit.h \ - ui/widget/scalar.cpp \ - ui/widget/scalar.h \ - ui/widget/selected-style.h \ - ui/widget/selected-style.cpp \ - ui/widget/spinbutton.h \ - ui/widget/spinbutton.cpp \ - ui/widget/spin-scale.h \ - ui/widget/spin-scale.cpp \ - ui/widget/spin-slider.h \ - ui/widget/spin-slider.cpp \ - ui/widget/style-subject.h \ - ui/widget/style-subject.cpp \ - ui/widget/style-swatch.h \ - ui/widget/style-swatch.cpp \ - ui/widget/text.cpp \ - ui/widget/text.h \ - ui/widget/tolerance-slider.cpp \ - ui/widget/tolerance-slider.h \ - ui/widget/unit-menu.cpp \ - ui/widget/unit-menu.h \ - ui/widget/unit-tracker.h \ - ui/widget/unit-tracker.cpp \ - ui/widget/clipmaskicon.cpp \ - ui/widget/clipmaskicon.h \ - ui/widget/highlight-picker.cpp \ - ui/widget/highlight-picker.h \ - ui/widget/layertypeicon.cpp \ - ui/widget/layertypeicon.h \ - ui/widget/insertordericon.cpp \ - ui/widget/insertordericon.h \ - ui/widget/addtoicon.cpp \ - ui/widget/addtoicon.h diff --git a/src/ui/widget/addtoicon.cpp b/src/ui/widget/addtoicon.cpp index 10294125d..70516ed00 100644 --- a/src/ui/widget/addtoicon.cpp +++ b/src/ui/widget/addtoicon.cpp @@ -9,7 +9,7 @@ #ifdef HAVE_CONFIG_H -# include <config.h> +#include <config.h> #endif #include "ui/widget/addtoicon.h" @@ -19,9 +19,7 @@ #include "widgets/icon.h" #include "widgets/toolbox.h" #include "ui/icon-names.h" -#include "preferences.h" #include "layertypeicon.h" -#include "addtoicon.h" namespace Inkscape { namespace UI { @@ -51,8 +49,6 @@ AddToIcon::AddToIcon() : set_pixbuf(); } - -#if WITH_GTKMM_3_0 void AddToIcon::get_preferred_height_vfunc(Gtk::Widget& widget, int& min_h, int& nat_h) const @@ -82,47 +78,16 @@ void AddToIcon::get_preferred_width_vfunc(Gtk::Widget& widget, nat_w += (nat_w) >> 1; } } -#else -void AddToIcon::get_size_vfunc(Gtk::Widget& widget, - const Gdk::Rectangle* cell_area, - int* x_offset, - int* y_offset, - int* width, - int* height ) const -{ - Gtk::CellRendererPixbuf::get_size_vfunc( widget, cell_area, x_offset, y_offset, width, height ); - - if ( width ) { - *width = phys;//+= (*width) >> 1; - } - if ( height ) { - *height =phys;//+= (*height) >> 1; - } -} -#endif -#if WITH_GTKMM_3_0 void AddToIcon::render_vfunc( const Cairo::RefPtr<Cairo::Context>& cr, Gtk::Widget& widget, const Gdk::Rectangle& background_area, const Gdk::Rectangle& cell_area, Gtk::CellRendererState flags ) -#else -void AddToIcon::render_vfunc( const Glib::RefPtr<Gdk::Drawable>& window, - Gtk::Widget& widget, - const Gdk::Rectangle& background_area, - const Gdk::Rectangle& cell_area, - const Gdk::Rectangle& expose_area, - Gtk::CellRendererState flags ) -#endif { set_pixbuf(); -#if WITH_GTKMM_3_0 Gtk::CellRendererPixbuf::render_vfunc( cr, widget, background_area, cell_area, flags ); -#else - Gtk::CellRendererPixbuf::render_vfunc( window, widget, background_area, cell_area, expose_area, flags ); -#endif } bool AddToIcon::activate_vfunc(GdkEvent* /*event*/, diff --git a/src/ui/widget/addtoicon.h b/src/ui/widget/addtoicon.h index a8d900d1f..3b2228754 100644 --- a/src/ui/widget/addtoicon.h +++ b/src/ui/widget/addtoicon.h @@ -31,8 +31,6 @@ public: Glib::PropertyProxy< Glib::RefPtr<Gdk::Pixbuf> > property_pixbuf_off(); protected: - -#if WITH_GTKMM_3_0 virtual void render_vfunc( const Cairo::RefPtr<Cairo::Context>& cr, Gtk::Widget& widget, const Gdk::Rectangle& background_area, @@ -46,18 +44,6 @@ protected: virtual void get_preferred_height_vfunc(Gtk::Widget& widget, int& min_h, int& nat_h) const; -#else - virtual void render_vfunc( const Glib::RefPtr<Gdk::Drawable>& window, - Gtk::Widget& widget, - const Gdk::Rectangle& background_area, - const Gdk::Rectangle& cell_area, - const Gdk::Rectangle& expose_area, - Gtk::CellRendererState flags ); - - virtual void get_size_vfunc( Gtk::Widget &widget, - Gdk::Rectangle const *cell_area, - int *x_offset, int *y_offset, int *width, int *height ) const; -#endif virtual bool activate_vfunc(GdkEvent *event, Gtk::Widget &widget, diff --git a/src/ui/widget/anchor-selector.cpp b/src/ui/widget/anchor-selector.cpp index df00b786a..087e7375e 100644 --- a/src/ui/widget/anchor-selector.cpp +++ b/src/ui/widget/anchor-selector.cpp @@ -8,7 +8,6 @@ */ #include "ui/widget/anchor-selector.h" -#include <iostream> #include "widgets/icon.h" #include "ui/icon-names.h" @@ -28,11 +27,7 @@ void AnchorSelector::setupButton(const Glib::ustring& icon, Gtk::ToggleButton& b AnchorSelector::AnchorSelector() : Gtk::Alignment(0.5, 0, 0, 0), -#if WITH_GTKMM_3_0 _container() -#else - _container(3, 3, true) -#endif { setupButton(INKSCAPE_ICON("boundingbox_top_left"), _buttons[0]); setupButton(INKSCAPE_ICON("boundingbox_top"), _buttons[1]); @@ -44,20 +39,14 @@ AnchorSelector::AnchorSelector() setupButton(INKSCAPE_ICON("boundingbox_bottom"), _buttons[7]); setupButton(INKSCAPE_ICON("boundingbox_bottom_right"), _buttons[8]); -#if WITH_GTKMM_3_0 _container.set_row_homogeneous(); _container.set_column_homogeneous(true); -#endif for(int i = 0; i < 9; ++i) { _buttons[i].signal_clicked().connect( sigc::bind(sigc::mem_fun(*this, &AnchorSelector::btn_activated), i)); -#if WITH_GTKMM_3_0 _container.attach(_buttons[i], i % 3, i / 3, 1, 1); -#else - _container.attach(_buttons[i], i % 3, i % 3+1, i / 3, i / 3+1, Gtk::FILL, Gtk::FILL); -#endif } _selection = 4; _buttons[4].set_active(); diff --git a/src/ui/widget/anchor-selector.h b/src/ui/widget/anchor-selector.h index 0a702d296..96331fae3 100644 --- a/src/ui/widget/anchor-selector.h +++ b/src/ui/widget/anchor-selector.h @@ -16,12 +16,7 @@ #include <gtkmm/alignment.h> #include <gtkmm/togglebutton.h> - -#if WITH_GTKMM_3_0 - #include <gtkmm/grid.h> -#else - #include <gtkmm/table.h> -#endif +#include <gtkmm/grid.h> namespace Inkscape { namespace UI { @@ -32,12 +27,7 @@ class AnchorSelector : public Gtk::Alignment private: Gtk::ToggleButton _buttons[9]; int _selection; - -#if WITH_GTKMM_3_0 Gtk::Grid _container; -#else - Gtk::Table _container; -#endif sigc::signal<void> _selectionChanged; diff --git a/src/ui/widget/clipmaskicon.cpp b/src/ui/widget/clipmaskicon.cpp index 421f1df1e..4f791042a 100644 --- a/src/ui/widget/clipmaskicon.cpp +++ b/src/ui/widget/clipmaskicon.cpp @@ -8,7 +8,7 @@ */ #ifdef HAVE_CONFIG_H -# include <config.h> +#include <config.h> #endif #include "ui/widget/clipmaskicon.h" @@ -63,8 +63,6 @@ ClipMaskIcon::ClipMaskIcon() : property_pixbuf() = Glib::RefPtr<Gdk::Pixbuf>(0); } - -#if WITH_GTKMM_3_0 void ClipMaskIcon::get_preferred_height_vfunc(Gtk::Widget& widget, int& min_h, int& nat_h) const @@ -94,39 +92,12 @@ void ClipMaskIcon::get_preferred_width_vfunc(Gtk::Widget& widget, nat_w += (nat_w) >> 1; } } -#else -void ClipMaskIcon::get_size_vfunc(Gtk::Widget& widget, - const Gdk::Rectangle* cell_area, - int* x_offset, - int* y_offset, - int* width, - int* height ) const -{ - Gtk::CellRendererPixbuf::get_size_vfunc( widget, cell_area, x_offset, y_offset, width, height ); - - if ( width ) { - *width = phys;//+= (*width) >> 1; - } - if ( height ) { - *height =phys;//+= (*height) >> 1; - } -} -#endif -#if WITH_GTKMM_3_0 void ClipMaskIcon::render_vfunc( const Cairo::RefPtr<Cairo::Context>& cr, Gtk::Widget& widget, const Gdk::Rectangle& background_area, const Gdk::Rectangle& cell_area, Gtk::CellRendererState flags ) -#else -void ClipMaskIcon::render_vfunc( const Glib::RefPtr<Gdk::Drawable>& window, - Gtk::Widget& widget, - const Gdk::Rectangle& background_area, - const Gdk::Rectangle& cell_area, - const Gdk::Rectangle& expose_area, - Gtk::CellRendererState flags ) -#endif { switch (_property_active.get_value()) { @@ -143,11 +114,7 @@ void ClipMaskIcon::render_vfunc( const Glib::RefPtr<Gdk::Drawable>& window, property_pixbuf() = Glib::RefPtr<Gdk::Pixbuf>(0); break; } -#if WITH_GTKMM_3_0 Gtk::CellRendererPixbuf::render_vfunc( cr, widget, background_area, cell_area, flags ); -#else - Gtk::CellRendererPixbuf::render_vfunc( window, widget, background_area, cell_area, expose_area, flags ); -#endif } bool ClipMaskIcon::activate_vfunc(GdkEvent* /*event*/, diff --git a/src/ui/widget/clipmaskicon.h b/src/ui/widget/clipmaskicon.h index eca852a83..0d149edb8 100644 --- a/src/ui/widget/clipmaskicon.h +++ b/src/ui/widget/clipmaskicon.h @@ -32,7 +32,6 @@ public: protected: -#if WITH_GTKMM_3_0 virtual void render_vfunc( const Cairo::RefPtr<Cairo::Context>& cr, Gtk::Widget& widget, const Gdk::Rectangle& background_area, @@ -46,18 +45,6 @@ protected: virtual void get_preferred_height_vfunc(Gtk::Widget& widget, int& min_h, int& nat_h) const; -#else - virtual void render_vfunc( const Glib::RefPtr<Gdk::Drawable>& window, - Gtk::Widget& widget, - const Gdk::Rectangle& background_area, - const Gdk::Rectangle& cell_area, - const Gdk::Rectangle& expose_area, - Gtk::CellRendererState flags ); - - virtual void get_size_vfunc( Gtk::Widget &widget, - Gdk::Rectangle const *cell_area, - int *x_offset, int *y_offset, int *width, int *height ) const; -#endif virtual bool activate_vfunc(GdkEvent *event, Gtk::Widget &widget, diff --git a/src/ui/widget/color-icc-selector.cpp b/src/ui/widget/color-icc-selector.cpp index e4f58fe8a..616e9afa8 100644 --- a/src/ui/widget/color-icc-selector.cpp +++ b/src/ui/widget/color-icc-selector.cpp @@ -2,14 +2,10 @@ #include "config.h" #endif -#include <math.h> #include <gtkmm/adjustment.h> #include <glibmm/i18n.h> -#include <gtk/gtk.h> -#include <map> #include <set> -#include <vector> #include "ui/dialog-events.h" #include "ui/widget/color-icc-selector.h" @@ -87,7 +83,6 @@ GtkAttachOptions operator|(GtkAttachOptions lhs, GtkAttachOptions rhs) void attachToGridOrTable(GtkWidget *parent, GtkWidget *child, guint left, guint top, guint width, guint height, bool hexpand = false, bool centered = false, guint xpadding = XPAD, guint ypadding = YPAD) { -#if GTK_CHECK_VERSION(3, 0, 0) #if GTK_CHECK_VERSION(3, 12, 0) gtk_widget_set_margin_start(child, xpadding); gtk_widget_set_margin_end(child, xpadding); @@ -106,14 +101,6 @@ void attachToGridOrTable(GtkWidget *parent, GtkWidget *child, guint left, guint gtk_widget_set_valign(child, GTK_ALIGN_CENTER); } gtk_grid_attach(GTK_GRID(parent), child, left, top, width, height); -#else - GtkAttachOptions xoptions = - centered ? static_cast<GtkAttachOptions>(0) : hexpand ? (GTK_EXPAND | GTK_FILL) : GTK_FILL; - GtkAttachOptions yoptions = centered ? static_cast<GtkAttachOptions>(0) : GTK_FILL; - - gtk_table_attach(GTK_TABLE(parent), child, left, left + width, top, top + height, xoptions, yoptions, xpadding, - ypadding); -#endif } } // namespace @@ -431,12 +418,7 @@ void ColorICCSelector::init() _impl->_compUI[i]._label = gtk_label_new_with_mnemonic(labelStr.c_str()); -#if GTK_CHECK_VERSION(3,0,0) gtk_widget_set_halign(_impl->_compUI[i]._label, GTK_ALIGN_END); -#else - gtk_misc_set_alignment(GTK_MISC(_impl->_compUI[i]._label), 1.0, 0.5); -#endif - gtk_widget_show(_impl->_compUI[i]._label); gtk_widget_set_no_show_all(_impl->_compUI[i]._label, TRUE); @@ -495,12 +477,7 @@ void ColorICCSelector::init() // Label _impl->_label = gtk_label_new_with_mnemonic(_("_A:")); -#if GTK_CHECK_VERSION(3,0,0) gtk_widget_set_halign(_impl->_label, GTK_ALIGN_END); -#else - gtk_misc_set_alignment(GTK_MISC(_impl->_label), 1.0, 0.5); -#endif - gtk_widget_show(_impl->_label); attachToGridOrTable(t, _impl->_label, 0, row, 1, 1); @@ -727,11 +704,7 @@ void ColorICCSelectorImpl::_profilesChanged(std::string const & /*name*/) {} void ColorICCSelector::on_show() { -#if GTK_CHECK_VERSION(3, 0, 0) Gtk::Grid::on_show(); -#else - Gtk::Table::on_show(); -#endif _colorChanged(); } diff --git a/src/ui/widget/color-icc-selector.h b/src/ui/widget/color-icc-selector.h index 1bcb0a540..aaa8372b8 100644 --- a/src/ui/widget/color-icc-selector.h +++ b/src/ui/widget/color-icc-selector.h @@ -6,11 +6,7 @@ #endif #include <gtkmm/widget.h> -#if WITH_GTKMM_3_0 #include <gtkmm/grid.h> -#else -#include <gtkmm/table.h> -#endif #include "ui/selected-color.h" @@ -24,11 +20,7 @@ namespace Widget { class ColorICCSelectorImpl; class ColorICCSelector -#if GTK_CHECK_VERSION(3, 0, 0) : public Gtk::Grid -#else - : public Gtk::Table -#endif { public: static const gchar *MODE_NAME; diff --git a/src/ui/widget/color-notebook.cpp b/src/ui/widget/color-notebook.cpp index 6d7ada734..33e22b59d 100644 --- a/src/ui/widget/color-notebook.cpp +++ b/src/ui/widget/color-notebook.cpp @@ -20,10 +20,6 @@ #endif #include "widgets/icon.h" -#include <cstring> -#include <string> -#include <cstdlib> -#include <cstddef> #include <glibmm/i18n.h> #include <gtkmm/label.h> #include <gtkmm/notebook.h> @@ -56,13 +52,8 @@ namespace Widget { ColorNotebook::ColorNotebook(SelectedColor &color) -#if GTK_CHECK_VERSION(3, 0, 0) : Gtk::Grid() -#else - : Gtk::Table(2, 3, false) -#endif , _selected_color(color) - { Page *page; @@ -110,12 +101,8 @@ void ColorNotebook::_initUI() notebook->set_show_tabs(false); _book = GTK_WIDGET(notebook->gobj()); -#if GTK_CHECK_VERSION(3, 0, 0) _buttonbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 2); gtk_box_set_homogeneous(GTK_BOX(_buttonbox), TRUE); -#else - _buttonbox = gtk_hbox_new(TRUE, 2); -#endif gtk_widget_show(_buttonbox); _buttons = new GtkWidget *[_available_pages.size()]; @@ -126,7 +113,6 @@ void ColorNotebook::_initUI() sp_set_font_size_smaller(_buttonbox); -#if GTK_CHECK_VERSION(3, 0, 0) #if GTK_CHECK_VERSION(3, 12, 0) gtk_widget_set_margin_start(_buttonbox, XPAD); gtk_widget_set_margin_end(_buttonbox, XPAD); @@ -139,14 +125,9 @@ void ColorNotebook::_initUI() gtk_widget_set_hexpand(_buttonbox, TRUE); gtk_widget_set_valign(_buttonbox, GTK_ALIGN_CENTER); attach(*Glib::wrap(_buttonbox), 0, row, 2, 1); -#else - attach(*Glib::wrap(_buttonbox), 0, 2, row, row + 1, Gtk::EXPAND | Gtk::FILL, static_cast<Gtk::AttachOptions>(0), - XPAD, YPAD); -#endif row++; -#if GTK_CHECK_VERSION(3, 0, 0) #if GTK_CHECK_VERSION(3, 12, 0) gtk_widget_set_margin_start(_book, XPAD * 2); gtk_widget_set_margin_end(_book, XPAD * 2); @@ -159,20 +140,13 @@ void ColorNotebook::_initUI() gtk_widget_set_hexpand(_book, TRUE); gtk_widget_set_vexpand(_book, TRUE); attach(*notebook, 0, row, 2, 1); -#else - attach(*notebook, 0, 2, row, row + 1, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL, XPAD * 2, YPAD); -#endif // restore the last active page Inkscape::Preferences *prefs = Inkscape::Preferences::get(); _setCurrentPage(prefs->getInt("/colorselector/page", 0)); row++; -#if GTK_CHECK_VERSION(3, 0, 0) GtkWidget *rgbabox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); -#else - GtkWidget *rgbabox = gtk_hbox_new(FALSE, 0); -#endif #if defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) /* Create color management icons */ @@ -210,11 +184,7 @@ void ColorNotebook::_initUI() /* Create RGBA entry and color preview */ _rgbal = gtk_label_new_with_mnemonic(_("RGBA_:")); -#if GTK_CHECK_VERSION(3,0,0) gtk_widget_set_halign(_rgbal, GTK_ALIGN_END); -#else - gtk_misc_set_alignment(GTK_MISC(_rgbal), 1.0, 0.5); -#endif gtk_box_pack_start(GTK_BOX(rgbabox), _rgbal, TRUE, TRUE, 2); ColorEntry *rgba_entry = Gtk::manage(new ColorEntry(_selected_color)); @@ -230,7 +200,6 @@ void ColorNotebook::_initUI() gtk_widget_hide(GTK_WIDGET(_box_toomuchink)); #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) -#if GTK_CHECK_VERSION(3, 0, 0) #if GTK_CHECK_VERSION(3, 12, 0) gtk_widget_set_margin_start(rgbabox, XPAD); gtk_widget_set_margin_end(rgbabox, XPAD); @@ -241,9 +210,6 @@ void ColorNotebook::_initUI() gtk_widget_set_margin_top(rgbabox, YPAD); gtk_widget_set_margin_bottom(rgbabox, YPAD); attach(*Glib::wrap(rgbabox), 0, row, 2, 1); -#else - attach(*Glib::wrap(rgbabox), 0, 2, row, row + 1, Gtk::FILL, Gtk::SHRINK, XPAD, YPAD); -#endif #ifdef SPCS_PREVIEW _p = sp_color_preview_new(0xffffffff); diff --git a/src/ui/widget/color-notebook.h b/src/ui/widget/color-notebook.h index d28028c72..0948e3d46 100644 --- a/src/ui/widget/color-notebook.h +++ b/src/ui/widget/color-notebook.h @@ -19,12 +19,7 @@ #endif #include <boost/ptr_container/ptr_vector.hpp> -#if WITH_GTKMM_3_0 #include <gtkmm/grid.h> -#else -#include <gtkmm/table.h> -#endif -#include <gtk/gtk.h> #include <glib.h> #include "color.h" @@ -35,11 +30,7 @@ namespace UI { namespace Widget { class ColorNotebook -#if GTK_CHECK_VERSION(3, 0, 0) : public Gtk::Grid -#else - : public Gtk::Table -#endif { public: ColorNotebook(SelectedColor &color); diff --git a/src/ui/widget/color-picker.cpp b/src/ui/widget/color-picker.cpp index a66fbfc9c..5a62c3c98 100644 --- a/src/ui/widget/color-picker.cpp +++ b/src/ui/widget/color-picker.cpp @@ -59,13 +59,8 @@ void ColorPicker::setupDialog(const Glib::ustring &title) _color_selector = Gtk::manage(new ColorNotebook(_selected_color)); -#if WITH_GTKMM_3_0 _colorSelectorDialog.get_content_area()->pack_start ( *_color_selector, true, true, 0); -#else - _colorSelectorDialog.get_vbox()->pack_start ( - *_color_selector, true, true, 0); -#endif _color_selector->show(); } diff --git a/src/ui/widget/color-preview.cpp b/src/ui/widget/color-preview.cpp index 62c7cca1d..c9b6e56d2 100644 --- a/src/ui/widget/color-preview.cpp +++ b/src/ui/widget/color-preview.cpp @@ -34,7 +34,6 @@ ColorPreview::on_size_allocate (Gtk::Allocation &all) queue_draw(); } -#if WITH_GTKMM_3_0 void ColorPreview::get_preferred_height_vfunc(int& minimum_height, int& natural_height) const { @@ -58,31 +57,6 @@ ColorPreview::get_preferred_width_for_height_vfunc(int /* height */, int& minimu { minimum_width = natural_width = SPCP_DEFAULT_WIDTH; } -#else -void -ColorPreview::on_size_request (Gtk::Requisition *req) -{ - req->width = SPCP_DEFAULT_WIDTH; - req->height = SPCP_DEFAULT_HEIGHT; -} - -bool -ColorPreview::on_expose_event (GdkEventExpose *event) -{ - bool result = true; - - if (get_is_drawable()) - { - Cairo::RefPtr<Cairo::Context> cr = get_window()->create_cairo_context(); - cr->rectangle(event->area.x, event->area.y, - event->area.width, event->area.height); - cr->clip(); - result = on_draw(cr); - } - - return result; -} -#endif void ColorPreview::setRgba32 (guint32 rgba) diff --git a/src/ui/widget/color-preview.h b/src/ui/widget/color-preview.h index caddfb9a2..1276cf42b 100644 --- a/src/ui/widget/color-preview.h +++ b/src/ui/widget/color-preview.h @@ -33,16 +33,10 @@ public: protected: virtual void on_size_allocate (Gtk::Allocation &all); -#if WITH_GTKMM_3_0 virtual void get_preferred_height_vfunc(int& minimum_height, int& natural_height) const; virtual void get_preferred_height_for_width_vfunc(int width, int& minimum_height, int& natural_height) const; virtual void get_preferred_width_vfunc(int& minimum_width, int& natural_width) const; virtual void get_preferred_width_for_height_vfunc(int height, int& minimum_width, int& natural_width) const; -#else - virtual void on_size_request (Gtk::Requisition *req); - virtual bool on_expose_event(GdkEventExpose *event); -#endif - virtual bool on_draw(const Cairo::RefPtr<Cairo::Context>& cr); guint32 _rgba; diff --git a/src/ui/widget/color-scales.cpp b/src/ui/widget/color-scales.cpp index 48a2693bc..89913b01b 100644 --- a/src/ui/widget/color-scales.cpp +++ b/src/ui/widget/color-scales.cpp @@ -3,15 +3,12 @@ */ #ifdef HAVE_CONFIG_H -#include "config.h" +#include <config.h> #endif -#include <math.h> #include <gtkmm/adjustment.h> #include <glibmm/i18n.h> -#include <gtk/gtk.h> -#include "svg/svg-icc-color.h" #include "ui/dialog-events.h" #include "ui/widget/color-scales.h" #include "ui/widget/color-slider.h" @@ -46,11 +43,7 @@ static const gchar *sp_color_scales_hue_map(); const gchar *ColorScales::SUBMODE_NAMES[] = { N_("None"), N_("RGB"), N_("HSL"), N_("CMYK") }; ColorScales::ColorScales(SelectedColor &color, SPColorScalesMode mode) -#if GTK_CHECK_VERSION(3, 0, 0) : Gtk::Grid() -#else - : Gtk::Table(5, 3, false) -#endif , _color(color) , _rangeLimit(255.0) , _updating(FALSE) @@ -93,15 +86,9 @@ void ColorScales::_initUI(SPColorScalesMode mode) /* Label */ _l[i] = gtk_label_new(""); -#if GTK_CHECK_VERSION(3,0,0) gtk_widget_set_halign(_l[i], GTK_ALIGN_END); -#else - gtk_misc_set_alignment(GTK_MISC(_l[i]), 1.0, 0.5); -#endif - gtk_widget_show(_l[i]); -#if GTK_CHECK_VERSION(3, 0, 0) #if GTK_CHECK_VERSION(3, 12, 0) gtk_widget_set_margin_start(_l[i], XPAD); gtk_widget_set_margin_end(_l[i], XPAD); @@ -112,9 +99,6 @@ void ColorScales::_initUI(SPColorScalesMode mode) gtk_widget_set_margin_top(_l[i], YPAD); gtk_widget_set_margin_bottom(_l[i], YPAD); gtk_grid_attach(GTK_GRID(t), _l[i], 0, i, 1, 1); -#else - gtk_table_attach(GTK_TABLE(t), _l[i], 0, 1, i, i + 1, GTK_FILL, GTK_FILL, XPAD, YPAD); -#endif /* Adjustment */ _a[i] = GTK_ADJUSTMENT(gtk_adjustment_new(0.0, 0.0, _rangeLimit, 1.0, 10.0, 10.0)); @@ -122,7 +106,6 @@ void ColorScales::_initUI(SPColorScalesMode mode) _s[i] = Gtk::manage(new Inkscape::UI::Widget::ColorSlider(Glib::wrap(_a[i], true))); _s[i]->show(); -#if GTK_CHECK_VERSION(3, 0, 0) #if GTK_CHECK_VERSION(3, 12, 0) _s[i]->set_margin_start(XPAD); _s[i]->set_margin_end(XPAD); @@ -134,10 +117,6 @@ void ColorScales::_initUI(SPColorScalesMode mode) _s[i]->set_margin_bottom(YPAD); _s[i]->set_hexpand(true); gtk_grid_attach(GTK_GRID(t), _s[i]->gobj(), 1, i, 1, 1); -#else - gtk_table_attach(GTK_TABLE(t), _s[i]->gobj(), 1, 2, i, i + 1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), - GTK_FILL, XPAD, YPAD); -#endif /* Spinbutton */ _b[i] = gtk_spin_button_new(GTK_ADJUSTMENT(_a[i]), 1.0, 0); @@ -145,7 +124,6 @@ void ColorScales::_initUI(SPColorScalesMode mode) gtk_label_set_mnemonic_widget(GTK_LABEL(_l[i]), _b[i]); gtk_widget_show(_b[i]); -#if GTK_CHECK_VERSION(3, 0, 0) #if GTK_CHECK_VERSION(3, 12, 0) gtk_widget_set_margin_start(_b[i], XPAD); gtk_widget_set_margin_end(_b[i], XPAD); @@ -158,9 +136,6 @@ void ColorScales::_initUI(SPColorScalesMode mode) gtk_widget_set_halign(_b[i], GTK_ALIGN_CENTER); gtk_widget_set_valign(_b[i], GTK_ALIGN_CENTER); gtk_grid_attach(GTK_GRID(t), _b[i], 2, i, 1, 1); -#else - gtk_table_attach(GTK_TABLE(t), _b[i], 2, 3, i, i + 1, (GtkAttachOptions)0, (GtkAttachOptions)0, XPAD, YPAD); -#endif /* Attach channel value to adjustment */ g_object_set_data(G_OBJECT(_a[i]), "channel", GINT_TO_POINTER(i)); @@ -272,7 +247,6 @@ void ColorScales::_setRangeLimit(gdouble upper) _rangeLimit = upper; for (gint i = 0; i < static_cast<gint>(G_N_ELEMENTS(_a)); i++) { gtk_adjustment_set_upper(_a[i], upper); - gtk_adjustment_changed(_a[i]); } } @@ -286,11 +260,7 @@ void ColorScales::_onColorChanged() void ColorScales::on_show() { -#if GTK_CHECK_VERSION(3, 0, 0) Gtk::Grid::on_show(); -#else - Gtk::Table::on_show(); -#endif _updateDisplay(); } diff --git a/src/ui/widget/color-scales.h b/src/ui/widget/color-scales.h index aeacfbcc1..1e86d762d 100644 --- a/src/ui/widget/color-scales.h +++ b/src/ui/widget/color-scales.h @@ -5,11 +5,7 @@ #include <config.h> #endif -#if WITH_GTKMM_3_0 #include <gtkmm/grid.h> -#else -#include <gtkmm/table.h> -#endif #include "ui/selected-color.h" @@ -27,11 +23,7 @@ typedef enum { } SPColorScalesMode; class ColorScales -#if GTK_CHECK_VERSION(3, 0, 0) : public Gtk::Grid -#else - : public Gtk::Table -#endif { public: static const gchar *SUBMODE_NAMES[]; diff --git a/src/ui/widget/color-slider.cpp b/src/ui/widget/color-slider.cpp index 0c9586a67..2e665dbec 100644 --- a/src/ui/widget/color-slider.cpp +++ b/src/ui/widget/color-slider.cpp @@ -12,19 +12,13 @@ */ #ifdef HAVE_CONFIG_H -#include "config.h" +#include <config.h> #endif #include <gdkmm/cursor.h> -#include <gdkmm/screen.h> #include <gdkmm/general.h> #include <gtkmm/adjustment.h> -#if WITH_GTKMM_3_0 #include <gtkmm/stylecontext.h> -#else -#include <gtkmm/style.h> -#endif -#include <gtk/gtk.h> #include "ui/widget/color-scales.h" #include "ui/widget/color-slider.h" @@ -43,14 +37,8 @@ namespace Inkscape { namespace UI { namespace Widget { -#if GTK_CHECK_VERSION(3, 0, 0) ColorSlider::ColorSlider(Glib::RefPtr<Gtk::Adjustment> adjustment) : _dragging(false) -#else -ColorSlider::ColorSlider(Gtk::Adjustment *adjustment) - : _dragging(false) - , _adjustment(NULL) -#endif , _value(0.0) , _oldvalue(0.0) , _mapsize(0) @@ -83,12 +71,7 @@ ColorSlider::~ColorSlider() if (_adjustment) { _adjustment_changed_connection.disconnect(); _adjustment_value_changed_connection.disconnect(); -#if GTK_CHECK_VERSION(3, 0, 0) _adjustment.reset(); -#else - _adjustment->unreference(); - _adjustment = NULL; -#endif } } @@ -109,26 +92,15 @@ void ColorSlider::on_realize() attributes.window_type = GDK_WINDOW_CHILD; attributes.wclass = GDK_INPUT_OUTPUT; attributes.visual = gdk_screen_get_system_visual(gdk_screen_get_default()); -#if !GTK_CHECK_VERSION(3, 0, 0) - attributes.colormap = gdk_screen_get_system_colormap(gdk_screen_get_default()); -#endif attributes.event_mask = get_events(); attributes.event_mask |= (Gdk::EXPOSURE_MASK | Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK | Gdk::POINTER_MOTION_MASK | Gdk::ENTER_NOTIFY_MASK | Gdk::LEAVE_NOTIFY_MASK); -#if GTK_CHECK_VERSION(3, 0, 0) attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL; -#else - attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; -#endif _gdk_window = Gdk::Window::create(get_parent_window(), &attributes, attributes_mask); set_window(_gdk_window); _gdk_window->set_user_data(gobj()); - -#if !GTK_CHECK_VERSION(3, 0, 0) - style_attach(); -#endif } } @@ -149,8 +121,6 @@ void ColorSlider::on_size_allocate(Gtk::Allocation &allocation) } } -#if GTK_CHECK_VERSION(3, 0, 0) - void ColorSlider::get_preferred_width_vfunc(int &minimum_width, int &natural_width) const { Glib::RefPtr<Gtk::StyleContext> style_context = get_style_context(); @@ -177,38 +147,12 @@ void ColorSlider::get_preferred_height_for_width_vfunc(int /*width*/, int &minim get_preferred_height(minimum_height, natural_height); } -#else - -void ColorSlider::on_size_request(Gtk::Requisition *requisition) -{ - GtkStyle *style = gtk_widget_get_style(gobj()); - requisition->width = SLIDER_WIDTH + style->xthickness * 2; - requisition->height = SLIDER_HEIGHT + style->ythickness * 2; -} - -bool ColorSlider::on_expose_event(GdkEventExpose *event) -{ - bool result = false; - - if (get_is_drawable()) { - Cairo::RefPtr<Cairo::Context> cr = _gdk_window->create_cairo_context(); - result = on_draw(cr); - } - return result; -} - -#endif - bool ColorSlider::on_button_press_event(GdkEventButton *event) { if (event->button == 1) { Gtk::Allocation allocation = get_allocation(); gint cx, cw; -#if GTK_CHECK_VERSION(3, 0, 0) cx = get_style_context()->get_padding(get_state_flags()).get_left(); -#else - cx = get_style()->get_xthickness(); -#endif cw = allocation.get_width() - 2 * cx; signal_grabbed.emit(); _dragging = true; @@ -216,15 +160,9 @@ bool ColorSlider::on_button_press_event(GdkEventButton *event) ColorScales::setScaled(_adjustment->gobj(), CLAMP((gfloat)(event->x - cx) / cw, 0.0, 1.0)); signal_dragged.emit(); -#if GTK_CHECK_VERSION(3, 0, 0) gdk_device_grab( gdk_event_get_device(reinterpret_cast<GdkEvent *>(event)), _gdk_window->gobj(), GDK_OWNERSHIP_NONE, FALSE, static_cast<GdkEventMask>(GDK_POINTER_MOTION_MASK | GDK_BUTTON_RELEASE_MASK), NULL, event->time); -#else - gdk_pointer_grab(get_window()->gobj(), FALSE, - static_cast<GdkEventMask>(GDK_POINTER_MOTION_MASK | GDK_BUTTON_RELEASE_MASK), NULL, NULL, - event->time); -#endif } return false; @@ -233,13 +171,8 @@ bool ColorSlider::on_button_press_event(GdkEventButton *event) bool ColorSlider::on_button_release_event(GdkEventButton *event) { if (event->button == 1) { - -#if GTK_CHECK_VERSION(3, 0, 0) gdk_device_ungrab(gdk_event_get_device(reinterpret_cast<GdkEvent *>(event)), gdk_event_get_time(reinterpret_cast<GdkEvent *>(event))); -#else - get_window()->pointer_ungrab(event->time); -#endif _dragging = false; signal_released.emit(); @@ -256,11 +189,7 @@ bool ColorSlider::on_motion_notify_event(GdkEventMotion *event) if (_dragging) { gint cx, cw; Gtk::Allocation allocation = get_allocation(); -#if GTK_CHECK_VERSION(3, 0, 0) cx = get_style_context()->get_padding(get_state_flags()).get_left(); -#else - cx = get_style()->get_xthickness(); -#endif cw = allocation.get_width() - 2 * cx; ColorScales::setScaled(_adjustment->gobj(), CLAMP((gfloat)(event->x - cx) / cw, 0.0, 1.0)); signal_dragged.emit(); @@ -269,19 +198,10 @@ bool ColorSlider::on_motion_notify_event(GdkEventMotion *event) return false; } -#if GTK_CHECK_VERSION(3, 0, 0) void ColorSlider::setAdjustment(Glib::RefPtr<Gtk::Adjustment> adjustment) { -#else -void ColorSlider::setAdjustment(Gtk::Adjustment *adjustment) -{ -#endif if (!adjustment) { -#if GTK_CHECK_VERSION(3, 0, 0) _adjustment = Gtk::Adjustment::create(0.0, 0.0, 1.0, 0.01, 0.0, 0.0); -#else - _adjustment = Gtk::manage(new Gtk::Adjustment(0.0, 0.0, 1.0, 0.01, 0.0, 0.0)); -#endif } else { adjustment->set_page_increment(0.0); @@ -292,9 +212,6 @@ void ColorSlider::setAdjustment(Gtk::Adjustment *adjustment) if (_adjustment) { _adjustment_changed_connection.disconnect(); _adjustment_value_changed_connection.disconnect(); -#if !GTK_CHECK_VERSION(3, 0, 0) - _adjustment->unreference(); -#endif } _adjustment = adjustment; @@ -315,18 +232,11 @@ void ColorSlider::_onAdjustmentValueChanged() { if (_value != ColorScales::getScaled(_adjustment->gobj())) { gint cx, cy, cw, ch; -#if GTK_CHECK_VERSION(3, 0, 0) - Glib::RefPtr<Gtk::StyleContext> style_context = get_style_context(); - Gtk::Allocation allocation = get_allocation(); - Gtk::Border padding = style_context->get_padding(get_state_flags()); + auto style_context = get_style_context(); + auto allocation = get_allocation(); + auto padding = style_context->get_padding(get_state_flags()); cx = padding.get_left(); cy = padding.get_top(); -#else - Glib::RefPtr<Gtk::Style> style = get_style(); - Gtk::Allocation allocation = get_allocation(); - cx = style->get_xthickness(); - cy = style->get_ythickness(); -#endif cw = allocation.get_width() - 2 * cx; ch = allocation.get_height() - 2 * cy; if ((gint)(ColorScales::getScaled(_adjustment->gobj()) * cw) != (gint)(_value * cw)) { @@ -390,40 +300,22 @@ bool ColorSlider::on_draw(const Cairo::RefPtr<Cairo::Context> &cr) { gboolean colorsOnTop = Inkscape::Preferences::get()->getBool("/options/workarounds/colorsontop", false); - Gtk::Allocation allocation = get_allocation(); - -#if GTK_CHECK_VERSION(3, 0, 0) - Glib::RefPtr<Gtk::StyleContext> style_context = get_style_context(); -#else - Glib::RefPtr<Gdk::Window> window = get_window(); - Glib::RefPtr<Gtk::Style> style = get_style(); -#endif + auto allocation = get_allocation(); + auto style_context = get_style_context(); // Draw shadow if (colorsOnTop) { -#if GTK_CHECK_VERSION(3, 0, 0) style_context->render_frame(cr, 0, 0, allocation.get_width(), allocation.get_height()); -#else - gtk_paint_shadow(style->gobj(), window->gobj(), gtk_widget_get_state(gobj()), GTK_SHADOW_IN, NULL, gobj(), - "colorslider", 0, 0, allocation.get_width(), allocation.get_height()); -#endif } /* Paintable part of color gradient area */ Gdk::Rectangle carea; - -#if GTK_CHECK_VERSION(3, 0, 0) Gtk::Border padding; padding = style_context->get_padding(get_state_flags()); carea.set_x(padding.get_left()); carea.set_y(padding.get_top()); - ; -#else - carea.set_x(style->get_xthickness()); - carea.set_y(style->get_ythickness()); -#endif carea.set_width(allocation.get_width() - 2 * carea.get_x()); carea.set_height(allocation.get_height() - 2 * carea.get_y()); @@ -491,12 +383,7 @@ bool ColorSlider::on_draw(const Cairo::RefPtr<Cairo::Context> &cr) /* Draw shadow */ if (!colorsOnTop) { -#if GTK_CHECK_VERSION(3, 0, 0) style_context->render_frame(cr, 0, 0, allocation.get_width(), allocation.get_height()); -#else - gtk_paint_shadow(style->gobj(), window->gobj(), gtk_widget_get_state(gobj()), GTK_SHADOW_IN, NULL, gobj(), - "colorslider", 0, 0, allocation.get_width(), allocation.get_height()); -#endif } /* Draw arrow */ diff --git a/src/ui/widget/color-slider.h b/src/ui/widget/color-slider.h index 253f3123c..9be6c356a 100644 --- a/src/ui/widget/color-slider.h +++ b/src/ui/widget/color-slider.h @@ -24,18 +24,10 @@ namespace Widget { */ class ColorSlider : public Gtk::Widget { public: -#if GTK_CHECK_VERSION(3, 0, 0) ColorSlider(Glib::RefPtr<Gtk::Adjustment> adjustment); -#else - ColorSlider(Gtk::Adjustment *adjustment); -#endif ~ColorSlider(); -#if GTK_CHECK_VERSION(3, 0, 0) void setAdjustment(Glib::RefPtr<Gtk::Adjustment> adjustment); -#else - void setAdjustment(Gtk::Adjustment *adjustment); -#endif void setColors(guint32 start, guint32 mid, guint32 end); @@ -56,16 +48,10 @@ protected: bool on_button_release_event(GdkEventButton *event); bool on_motion_notify_event(GdkEventMotion *event); bool on_draw(const Cairo::RefPtr<Cairo::Context> &cr); - -#if GTK_CHECK_VERSION(3, 0, 0) void get_preferred_width_vfunc(int &minimum_width, int &natural_width) const; void get_preferred_width_for_height_vfunc(int height, int &minimum_width, int &natural_width) const; void get_preferred_height_vfunc(int &minimum_height, int &natural_height) const; void get_preferred_height_for_width_vfunc(int width, int &minimum_height, int &natural_height) const; -#else - void on_size_request(Gtk::Requisition *requisition); - bool on_expose_event(GdkEventExpose *event); -#endif private: void _onAdjustmentChanged(); @@ -73,11 +59,7 @@ private: bool _dragging; -#if GTK_CHECK_VERSION(3, 0, 0) Glib::RefPtr<Gtk::Adjustment> _adjustment; -#else - Gtk::Adjustment *_adjustment; -#endif sigc::connection _adjustment_changed_connection; sigc::connection _adjustment_value_changed_connection; diff --git a/src/ui/widget/color-wheel-selector.cpp b/src/ui/widget/color-wheel-selector.cpp index 22c616325..4f011c6c3 100644 --- a/src/ui/widget/color-wheel-selector.cpp +++ b/src/ui/widget/color-wheel-selector.cpp @@ -1,21 +1,17 @@ #ifdef HAVE_CONFIG_H -#include "config.h" +#include <config.h> #endif #include "color-wheel-selector.h" -#include <math.h> -#include <gtk/gtk.h> #include <glibmm/i18n.h> #include <gtkmm/adjustment.h> #include <gtkmm/label.h> #include <gtkmm/spinbutton.h> -#include "svg/svg-icc-color.h" #include "ui/dialog-events.h" -#include "ui/selected-color.h" #include "ui/widget/color-scales.h" #include "ui/widget/color-slider.h" -#include "ui/widget/gimpcolorwheel.h" +#include "widgets/gimp/gimpcolorwheel.h" namespace Inkscape { namespace UI { @@ -29,16 +25,9 @@ namespace Widget { const gchar *ColorWheelSelector::MODE_NAME = N_("Wheel"); ColorWheelSelector::ColorWheelSelector(SelectedColor &color) -#if GTK_CHECK_VERSION(3, 0, 0) : Gtk::Grid() -#else - : Gtk::Table(5, 3, false) -#endif , _color(color) , _updating(false) -#if !GTK_CHECK_VERSION(3, 0, 0) - , _alpha_adjustment(NULL) -#endif , _wheel(0) , _slider(0) { @@ -50,9 +39,6 @@ ColorWheelSelector::ColorWheelSelector(SelectedColor &color) ColorWheelSelector::~ColorWheelSelector() { _wheel = 0; -#if !GTK_CHECK_VERSION(3, 0, 0) - delete _alpha_adjustment; -#endif _color_changed_connection.disconnect(); _color_dragged_connection.disconnect(); @@ -66,16 +52,11 @@ void ColorWheelSelector::_initUI() _wheel = gimp_color_wheel_new(); gtk_widget_show(_wheel); -#if GTK_CHECK_VERSION(3, 0, 0) gtk_widget_set_halign(_wheel, GTK_ALIGN_FILL); gtk_widget_set_valign(_wheel, GTK_ALIGN_FILL); gtk_widget_set_hexpand(_wheel, TRUE); gtk_widget_set_vexpand(_wheel, TRUE); gtk_grid_attach(GTK_GRID(gobj()), _wheel, 0, row, 3, 1); -#else - gtk_table_attach(GTK_TABLE(gobj()), _wheel, 0, 3, row, row + 1, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), - (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), 0, 0); -#endif row++; @@ -84,7 +65,6 @@ void ColorWheelSelector::_initUI() label->set_alignment(1.0, 0.5); label->show(); -#if GTK_CHECK_VERSION(3, 0, 0) #if GTK_CHECK_VERSION(3, 12, 0) label->set_margin_start(XPAD); label->set_margin_end(XPAD); @@ -97,22 +77,15 @@ void ColorWheelSelector::_initUI() label->set_halign(Gtk::ALIGN_FILL); label->set_valign(Gtk::ALIGN_FILL); attach(*label, 0, row, 1, 1); -#else - attach(*label, 0, 1, row, row + 1, Gtk::FILL, Gtk::FILL, XPAD, YPAD); -#endif -/* Adjustment */ -#if GTK_CHECK_VERSION(3, 0, 0) + /* Adjustment */ _alpha_adjustment = Gtk::Adjustment::create(0.0, 0.0, 255.0, 1.0, 10.0, 10.0); -#else - _alpha_adjustment = new Gtk::Adjustment(0.0, 0.0, 255.0, 1.0, 10.0, 10.0); -#endif + /* Slider */ _slider = Gtk::manage(new Inkscape::UI::Widget::ColorSlider(_alpha_adjustment)); _slider->set_tooltip_text(_("Alpha (opacity)")); _slider->show(); -#if GTK_CHECK_VERSION(3, 0, 0) #if GTK_CHECK_VERSION(3, 12, 0) _slider->set_margin_start(XPAD); _slider->set_margin_end(XPAD); @@ -126,25 +99,17 @@ void ColorWheelSelector::_initUI() _slider->set_halign(Gtk::ALIGN_FILL); _slider->set_valign(Gtk::ALIGN_FILL); attach(*_slider, 1, row, 1, 1); -#else - attach(*_slider, 1, 2, row, row + 1, Gtk::EXPAND | Gtk::FILL, Gtk::FILL, XPAD, YPAD); -#endif _slider->setColors(SP_RGBA32_F_COMPOSE(1.0, 1.0, 1.0, 0.0), SP_RGBA32_F_COMPOSE(1.0, 1.0, 1.0, 0.5), SP_RGBA32_F_COMPOSE(1.0, 1.0, 1.0, 1.0)); -/* Spinbutton */ -#if GTK_CHECK_VERSION(3, 0, 0) - Gtk::SpinButton *spin_button = Gtk::manage(new Gtk::SpinButton(_alpha_adjustment, 1.0, 0)); -#else - Gtk::SpinButton *spin_button = Gtk::manage(new Gtk::SpinButton(*_alpha_adjustment, 1.0, 0)); -#endif + /* Spinbutton */ + auto spin_button = Gtk::manage(new Gtk::SpinButton(_alpha_adjustment, 1.0, 0)); spin_button->set_tooltip_text(_("Alpha (opacity)")); sp_dialog_defocus_on_enter(GTK_WIDGET(spin_button->gobj())); label->set_mnemonic_widget(*spin_button); spin_button->show(); -#if GTK_CHECK_VERSION(3, 0, 0) #if GTK_CHECK_VERSION(3, 12, 0) spin_button->set_margin_start(XPAD); spin_button->set_margin_end(XPAD); @@ -157,9 +122,6 @@ void ColorWheelSelector::_initUI() spin_button->set_halign(Gtk::ALIGN_CENTER); spin_button->set_valign(Gtk::ALIGN_CENTER); attach(*spin_button, 2, row, 1, 1); -#else - attach(*spin_button, 2, 3, row, row + 1, (Gtk::AttachOptions)0, (Gtk::AttachOptions)0, XPAD, YPAD); -#endif /* Signals */ _alpha_adjustment->signal_value_changed().connect(sigc::mem_fun(this, &ColorWheelSelector::_adjustmentChanged)); @@ -172,11 +134,7 @@ void ColorWheelSelector::_initUI() void ColorWheelSelector::on_show() { -#if GTK_CHECK_VERSION(3, 0, 0) Gtk::Grid::on_show(); -#else - Gtk::Table::on_show(); -#endif _updateDisplay(); } diff --git a/src/ui/widget/color-wheel-selector.h b/src/ui/widget/color-wheel-selector.h index 5711d417c..ee7bd9b83 100644 --- a/src/ui/widget/color-wheel-selector.h +++ b/src/ui/widget/color-wheel-selector.h @@ -16,11 +16,7 @@ #include <config.h> #endif -#if WITH_GTKMM_3_0 #include <gtkmm/grid.h> -#else -#include <gtkmm/table.h> -#endif #include "ui/selected-color.h" @@ -33,11 +29,7 @@ namespace Widget { class ColorSlider; class ColorWheelSelector -#if GTK_CHECK_VERSION(3, 0, 0) : public Gtk::Grid -#else - : public Gtk::Table -#endif { public: static const gchar *MODE_NAME; @@ -61,11 +53,7 @@ protected: SelectedColor &_color; bool _updating; -#if GTK_CHECK_VERSION(3, 0, 0) Glib::RefPtr<Gtk::Adjustment> _alpha_adjustment; -#else - Gtk::Adjustment *_alpha_adjustment; -#endif GtkWidget *_wheel; Inkscape::UI::Widget::ColorSlider *_slider; diff --git a/src/ui/widget/dock-item.cpp b/src/ui/widget/dock-item.cpp index 8d960ddc3..979c09d2f 100644 --- a/src/ui/widget/dock-item.cpp +++ b/src/ui/widget/dock-item.cpp @@ -9,10 +9,8 @@ #include "ui/widget/dock.h" -#include "dock-item.h" #include "desktop.h" #include "inkscape.h" -#include "preferences.h" #include "ui/icon-names.h" #include "widgets/icon.h" @@ -59,11 +57,7 @@ DockItem::DockItem(Dock& dock, const Glib::ustring& name, const Glib::ustring& l Gtk::StockItem item; Gtk::StockID stockId(icon_name); if ( Gtk::StockItem::lookup(stockId, item) ) { -#if WITH_GTKMM_3_0 _icon_pixbuf = _dock.getWidget().render_icon_pixbuf( stockId, Gtk::ICON_SIZE_MENU ); -#else - _icon_pixbuf = _dock.getWidget().render_icon( stockId, Gtk::ICON_SIZE_MENU ); -#endif } } } @@ -175,12 +169,8 @@ DockItem::set_size_request(int width, int height) void DockItem::size_request(Gtk::Requisition& requisition) { -#if WITH_GTKMM_3_0 Gtk::Requisition req_natural; getWidget().get_preferred_size(req_natural, requisition); -#else - requisition = getWidget().size_request(); -#endif } void diff --git a/src/ui/widget/dock-item.h b/src/ui/widget/dock-item.h index 25a69d94c..2df45b207 100644 --- a/src/ui/widget/dock-item.h +++ b/src/ui/widget/dock-item.h @@ -19,11 +19,7 @@ #include <gtkmm/frame.h> #include <gtkmm/window.h> -#if WITH_EXT_GDL #include <gdl/gdl.h> -#else -#include "libgdl/gdl.h" -#endif namespace Gtk { class HButtonBox; diff --git a/src/ui/widget/dock.cpp b/src/ui/widget/dock.cpp index fda647182..7744cb695 100644 --- a/src/ui/widget/dock.cpp +++ b/src/ui/widget/dock.cpp @@ -65,7 +65,6 @@ Dock::Dock(Gtk::Orientation orientation) static_cast<GtkOrientation>(orientation)); #endif -#if WITH_GTKMM_3_0 switch(orientation) { case Gtk::ORIENTATION_VERTICAL: _dock_box = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL)); @@ -75,17 +74,6 @@ Dock::Dock(Gtk::Orientation orientation) } _paned = Gtk::manage(new Gtk::Paned(orientation)); -#else - switch (orientation) { - case Gtk::ORIENTATION_VERTICAL: - _dock_box = Gtk::manage(new Gtk::HBox()); - _paned = Gtk::manage(new Gtk::VPaned()); - break; - case Gtk::ORIENTATION_HORIZONTAL: - _dock_box = Gtk::manage(new Gtk::VBox()); - _paned = Gtk::manage(new Gtk::HPaned()); - } -#endif _scrolled_window->add(*_dock_box); _scrolled_window->set_policy(Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC); diff --git a/src/ui/widget/entity-entry.cpp b/src/ui/widget/entity-entry.cpp index a8de2f384..381f0a2e1 100644 --- a/src/ui/widget/entity-entry.cpp +++ b/src/ui/widget/entity-entry.cpp @@ -14,14 +14,13 @@ */ #ifdef HAVE_CONFIG_H -# include <config.h> +#include <config.h> #endif #include <gtkmm/scrolledwindow.h> #include <gtkmm/entry.h> #include "inkscape.h" -#include "sp-object.h" #include "rdf.h" #include "ui/widget/registry.h" #include "sp-root.h" diff --git a/src/ui/widget/entry.cpp b/src/ui/widget/entry.cpp index 64d28119a..b1dd9ae8e 100644 --- a/src/ui/widget/entry.cpp +++ b/src/ui/widget/entry.cpp @@ -8,7 +8,7 @@ */ #ifdef HAVE_CONFIG_H -# include <config.h> +#include <config.h> #endif #include "entry.h" diff --git a/src/ui/widget/filter-effect-chooser.cpp b/src/ui/widget/filter-effect-chooser.cpp index 242a99073..ae2f3e7c2 100644 --- a/src/ui/widget/filter-effect-chooser.cpp +++ b/src/ui/widget/filter-effect-chooser.cpp @@ -10,12 +10,8 @@ */ #include "filter-effect-chooser.h" -#include <glibmm/i18n.h> - -#include "desktop.h" #include "document.h" -#include "inkscape.h" namespace Inkscape { namespace UI { diff --git a/src/ui/widget/font-variants.cpp b/src/ui/widget/font-variants.cpp index 62598dead..b386051a6 100644 --- a/src/ui/widget/font-variants.cpp +++ b/src/ui/widget/font-variants.cpp @@ -8,26 +8,18 @@ */ #ifdef HAVE_CONFIG_H -# include <config.h> +#include <config.h> #endif #include <gtkmm.h> #include <glibmm/i18n.h> #include <libnrtype/font-instance.h> -#include <iostream> #include "font-variants.h" // For updating from selection #include "desktop.h" -#include "selection.h" -#include "style.h" #include "sp-text.h" -#include "sp-tspan.h" -#include "sp-tref.h" -#include "sp-textpath.h" -#include "sp-item-group.h" -#include "xml/repr.h" namespace Inkscape { namespace UI { @@ -637,7 +629,7 @@ namespace Widget { } else if( _caps_all_small.get_active() ) { css_string = "all-small-caps"; caps_new = SP_CSS_FONT_VARIANT_CAPS_ALL_SMALL; - } else if( _caps_all_petite.get_active() ) { + } else if( _caps_petite.get_active() ) { css_string = "petite"; caps_new = SP_CSS_FONT_VARIANT_CAPS_PETITE; } else if( _caps_all_petite.get_active() ) { diff --git a/src/ui/widget/frame.cpp b/src/ui/widget/frame.cpp index eaa4336bb..65d10dcc4 100644 --- a/src/ui/widget/frame.cpp +++ b/src/ui/widget/frame.cpp @@ -8,7 +8,7 @@ */ #ifdef HAVE_CONFIG_H -# include <config.h> +#include <config.h> #endif #include "frame.h" diff --git a/src/ui/widget/highlight-picker.cpp b/src/ui/widget/highlight-picker.cpp index 09999b52d..561c1332a 100644 --- a/src/ui/widget/highlight-picker.cpp +++ b/src/ui/widget/highlight-picker.cpp @@ -14,9 +14,6 @@ #include "highlight-picker.h" #include "widgets/icon.h" -#include "widgets/toolbox.h" -#include "ui/icon-names.h" -#include <glibmm/i18n.h> namespace Inkscape { namespace UI { @@ -35,8 +32,6 @@ HighlightPicker::~HighlightPicker() { } - -#if WITH_GTKMM_3_0 void HighlightPicker::get_preferred_height_vfunc(Gtk::Widget& widget, int& min_h, int& nat_h) const @@ -66,39 +61,12 @@ void HighlightPicker::get_preferred_width_vfunc(Gtk::Widget& widget, nat_w += (nat_w) >> 1; } } -#else -void HighlightPicker::get_size_vfunc(Gtk::Widget& widget, - const Gdk::Rectangle* cell_area, - int* x_offset, - int* y_offset, - int* width, - int* height ) const -{ - Gtk::CellRendererPixbuf::get_size_vfunc( widget, cell_area, x_offset, y_offset, width, height ); - - if ( width ) { - *width = 10;//+= (*width) >> 1; - } - if ( height ) { - *height = 20; //cell_area ? cell_area->get_height() / 2 : 50; //+= (*height) >> 1; - } -} -#endif -#if WITH_GTKMM_3_0 void HighlightPicker::render_vfunc( const Cairo::RefPtr<Cairo::Context>& cr, Gtk::Widget& widget, const Gdk::Rectangle& background_area, const Gdk::Rectangle& cell_area, Gtk::CellRendererState flags ) -#else -void HighlightPicker::render_vfunc( const Glib::RefPtr<Gdk::Drawable>& window, - Gtk::Widget& widget, - const Gdk::Rectangle& background_area, - const Gdk::Rectangle& cell_area, - const Gdk::Rectangle& expose_area, - Gtk::CellRendererState flags ) -#endif { GdkRectangle carea; @@ -140,11 +108,7 @@ void HighlightPicker::render_vfunc( const Glib::RefPtr<Gdk::Drawable>& window, convert_pixbuf_argb32_to_normal(pixbuf); property_pixbuf() = Glib::wrap(pixbuf); -#if WITH_GTKMM_3_0 Gtk::CellRendererPixbuf::render_vfunc( cr, widget, background_area, cell_area, flags ); -#else - Gtk::CellRendererPixbuf::render_vfunc( window, widget, background_area, cell_area, expose_area, flags ); -#endif } bool HighlightPicker::activate_vfunc(GdkEvent* /*event*/, diff --git a/src/ui/widget/highlight-picker.h b/src/ui/widget/highlight-picker.h index c5fe4c02c..c459b0dcd 100644 --- a/src/ui/widget/highlight-picker.h +++ b/src/ui/widget/highlight-picker.h @@ -29,8 +29,6 @@ public: Glib::PropertyProxy<guint32> property_active() { return _property_active.get_proxy(); } protected: - -#if WITH_GTKMM_3_0 virtual void render_vfunc( const Cairo::RefPtr<Cairo::Context>& cr, Gtk::Widget& widget, const Gdk::Rectangle& background_area, @@ -44,18 +42,6 @@ protected: virtual void get_preferred_height_vfunc(Gtk::Widget& widget, int& min_h, int& nat_h) const; -#else - virtual void render_vfunc( const Glib::RefPtr<Gdk::Drawable>& window, - Gtk::Widget& widget, - const Gdk::Rectangle& background_area, - const Gdk::Rectangle& cell_area, - const Gdk::Rectangle& expose_area, - Gtk::CellRendererState flags ); - - virtual void get_size_vfunc( Gtk::Widget &widget, - Gdk::Rectangle const *cell_area, - int *x_offset, int *y_offset, int *width, int *height ) const; -#endif virtual bool activate_vfunc(GdkEvent *event, Gtk::Widget &widget, diff --git a/src/ui/widget/imageicon.cpp b/src/ui/widget/imageicon.cpp index df261b69a..8e7df7a68 100644 --- a/src/ui/widget/imageicon.cpp +++ b/src/ui/widget/imageicon.cpp @@ -11,17 +11,12 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ - - - #include "imageicon.h" -#include <sys/stat.h> #include "svg-view-widget.h" #include "document.h" #include "inkscape.h" -#include <glibmm/convert.h> #include <glibmm/fileutils.h> - +#include <glibmm/convert.h> namespace Inkscape { diff --git a/src/ui/widget/imagetoggler.cpp b/src/ui/widget/imagetoggler.cpp index 29907f4c9..987cc67bb 100644 --- a/src/ui/widget/imagetoggler.cpp +++ b/src/ui/widget/imagetoggler.cpp @@ -53,8 +53,6 @@ ImageToggler::ImageToggler( char const* on, char const* off) : property_pixbuf() = _property_pixbuf_off.get_value(); } - -#if WITH_GTKMM_3_0 void ImageToggler::get_preferred_height_vfunc(Gtk::Widget& widget, int& min_h, int& nat_h) const @@ -84,46 +82,15 @@ void ImageToggler::get_preferred_width_vfunc(Gtk::Widget& widget, nat_w += (nat_w) >> 1; } } -#else -void ImageToggler::get_size_vfunc(Gtk::Widget& widget, - const Gdk::Rectangle* cell_area, - int* x_offset, - int* y_offset, - int* width, - int* height ) const -{ - Gtk::CellRendererPixbuf::get_size_vfunc( widget, cell_area, x_offset, y_offset, width, height ); - - if ( width ) { - *width += (*width) >> 1; - } - if ( height ) { - *height += (*height) >> 1; - } -} -#endif -#if WITH_GTKMM_3_0 void ImageToggler::render_vfunc( const Cairo::RefPtr<Cairo::Context>& cr, Gtk::Widget& widget, const Gdk::Rectangle& background_area, const Gdk::Rectangle& cell_area, Gtk::CellRendererState flags ) -#else -void ImageToggler::render_vfunc( const Glib::RefPtr<Gdk::Drawable>& window, - Gtk::Widget& widget, - const Gdk::Rectangle& background_area, - const Gdk::Rectangle& cell_area, - const Gdk::Rectangle& expose_area, - Gtk::CellRendererState flags ) -#endif { property_pixbuf() = _property_active.get_value() ? _property_pixbuf_on : _property_pixbuf_off; -#if WITH_GTKMM_3_0 Gtk::CellRendererPixbuf::render_vfunc( cr, widget, background_area, cell_area, flags ); -#else - Gtk::CellRendererPixbuf::render_vfunc( window, widget, background_area, cell_area, expose_area, flags ); -#endif } bool diff --git a/src/ui/widget/imagetoggler.h b/src/ui/widget/imagetoggler.h index 7b02fa4dc..d4f27cf11 100644 --- a/src/ui/widget/imagetoggler.h +++ b/src/ui/widget/imagetoggler.h @@ -36,8 +36,6 @@ public: Glib::PropertyProxy< Glib::RefPtr<Gdk::Pixbuf> > property_pixbuf_off(); protected: - -#if WITH_GTKMM_3_0 virtual void render_vfunc( const Cairo::RefPtr<Cairo::Context>& cr, Gtk::Widget& widget, const Gdk::Rectangle& background_area, @@ -51,18 +49,6 @@ protected: virtual void get_preferred_height_vfunc(Gtk::Widget& widget, int& min_h, int& nat_h) const; -#else - virtual void render_vfunc( const Glib::RefPtr<Gdk::Drawable>& window, - Gtk::Widget& widget, - const Gdk::Rectangle& background_area, - const Gdk::Rectangle& cell_area, - const Gdk::Rectangle& expose_area, - Gtk::CellRendererState flags ); - - virtual void get_size_vfunc( Gtk::Widget &widget, - Gdk::Rectangle const *cell_area, - int *x_offset, int *y_offset, int *width, int *height ) const; -#endif virtual bool activate_vfunc(GdkEvent *event, Gtk::Widget &widget, diff --git a/src/ui/widget/insertordericon.cpp b/src/ui/widget/insertordericon.cpp index 9aec7d135..7ed1ed2e2 100644 --- a/src/ui/widget/insertordericon.cpp +++ b/src/ui/widget/insertordericon.cpp @@ -52,7 +52,6 @@ InsertOrderIcon::InsertOrderIcon() : } -#if WITH_GTKMM_3_0 void InsertOrderIcon::get_preferred_height_vfunc(Gtk::Widget& widget, int& min_h, int& nat_h) const @@ -82,39 +81,12 @@ void InsertOrderIcon::get_preferred_width_vfunc(Gtk::Widget& widget, nat_w += (nat_w) >> 1; } } -#else -void InsertOrderIcon::get_size_vfunc(Gtk::Widget& widget, - const Gdk::Rectangle* cell_area, - int* x_offset, - int* y_offset, - int* width, - int* height ) const -{ - Gtk::CellRendererPixbuf::get_size_vfunc( widget, cell_area, x_offset, y_offset, width, height ); - - if ( width ) { - *width = phys;//+= (*width) >> 1; - } - if ( height ) { - *height =phys;//+= (*height) >> 1; - } -} -#endif -#if WITH_GTKMM_3_0 void InsertOrderIcon::render_vfunc( const Cairo::RefPtr<Cairo::Context>& cr, Gtk::Widget& widget, const Gdk::Rectangle& background_area, const Gdk::Rectangle& cell_area, Gtk::CellRendererState flags ) -#else -void InsertOrderIcon::render_vfunc( const Glib::RefPtr<Gdk::Drawable>& window, - Gtk::Widget& widget, - const Gdk::Rectangle& background_area, - const Gdk::Rectangle& cell_area, - const Gdk::Rectangle& expose_area, - Gtk::CellRendererState flags ) -#endif { switch (_property_active.get_value()) { @@ -128,11 +100,7 @@ void InsertOrderIcon::render_vfunc( const Glib::RefPtr<Gdk::Drawable>& window, property_pixbuf() = Glib::RefPtr<Gdk::Pixbuf>(0); break; } -#if WITH_GTKMM_3_0 Gtk::CellRendererPixbuf::render_vfunc( cr, widget, background_area, cell_area, flags ); -#else - Gtk::CellRendererPixbuf::render_vfunc( window, widget, background_area, cell_area, expose_area, flags ); -#endif } bool InsertOrderIcon::activate_vfunc(GdkEvent* /*event*/, diff --git a/src/ui/widget/insertordericon.h b/src/ui/widget/insertordericon.h index bf8ac4fa7..43188fa5b 100644 --- a/src/ui/widget/insertordericon.h +++ b/src/ui/widget/insertordericon.h @@ -33,7 +33,6 @@ public: protected: -#if WITH_GTKMM_3_0 virtual void render_vfunc( const Cairo::RefPtr<Cairo::Context>& cr, Gtk::Widget& widget, const Gdk::Rectangle& background_area, @@ -47,18 +46,6 @@ protected: virtual void get_preferred_height_vfunc(Gtk::Widget& widget, int& min_h, int& nat_h) const; -#else - virtual void render_vfunc( const Glib::RefPtr<Gdk::Drawable>& window, - Gtk::Widget& widget, - const Gdk::Rectangle& background_area, - const Gdk::Rectangle& cell_area, - const Gdk::Rectangle& expose_area, - Gtk::CellRendererState flags ); - - virtual void get_size_vfunc( Gtk::Widget &widget, - Gdk::Rectangle const *cell_area, - int *x_offset, int *y_offset, int *width, int *height ) const; -#endif virtual bool activate_vfunc(GdkEvent *event, Gtk::Widget &widget, diff --git a/src/ui/widget/layer-selector.cpp b/src/ui/widget/layer-selector.cpp index 1a9ce617f..4432a6e09 100644 --- a/src/ui/widget/layer-selector.cpp +++ b/src/ui/widget/layer-selector.cpp @@ -11,7 +11,7 @@ */ #ifdef HAVE_CONFIG_H -# include "config.h" +#include <config.h> #endif #include <cstring> @@ -19,15 +19,15 @@ #include "ui/dialog/layer-properties.h" #include <glibmm/i18n.h> +#include <boost/range/adaptor/filtered.hpp> +#include <boost/range/adaptor/reversed.hpp> #include "desktop.h" #include "document.h" #include "document-undo.h" #include "layer-manager.h" -#include "sp-item.h" #include "ui/icon-names.h" -#include "ui/widget/layer-selector.h" #include "util/filter-list.h" #include "util/reverse-list.h" #include "verbs.h" @@ -348,27 +348,17 @@ void LayerSelector::_buildSiblingEntries( unsigned depth, SPObject &parent, Inkscape::Util::List<SPObject &> hierarchy ) { - using Inkscape::Util::List; using Inkscape::Util::rest; - using Inkscape::Util::reverse_list_in_place; - using Inkscape::Util::filter_list; - Inkscape::Util::List<SPObject &> siblings( - reverse_list_in_place( - filter_list<SPObject::SiblingIterator>( - is_layer(_desktop), parent.firstChild(), NULL - ) - ) - ); + auto siblings = parent.children | boost::adaptors::filtered(is_layer(_desktop)) | boost::adaptors::reversed; SPObject *layer( hierarchy ? &*hierarchy : NULL ); - while (siblings) { - _buildEntry(depth, *siblings); - if ( &*siblings == layer ) { + for (auto& sib: siblings) { + _buildEntry(depth, sib); + if ( &sib == layer ) { _buildSiblingEntries(depth+1, *layer, rest(hierarchy)); } - ++siblings; } } diff --git a/src/ui/widget/layertypeicon.cpp b/src/ui/widget/layertypeicon.cpp index 672c607e5..df85f271a 100644 --- a/src/ui/widget/layertypeicon.cpp +++ b/src/ui/widget/layertypeicon.cpp @@ -8,7 +8,7 @@ */ #ifdef HAVE_CONFIG_H -# include <config.h> +#include <config.h> #endif #include "ui/widget/layertypeicon.h" @@ -18,7 +18,6 @@ #include "widgets/icon.h" #include "widgets/toolbox.h" #include "ui/icon-names.h" -#include "layertypeicon.h" namespace Inkscape { namespace UI { @@ -64,8 +63,6 @@ LayerTypeIcon::LayerTypeIcon() : property_pixbuf() = _property_pixbuf_path.get_value(); } - -#if WITH_GTKMM_3_0 void LayerTypeIcon::get_preferred_height_vfunc(Gtk::Widget& widget, int& min_h, int& nat_h) const @@ -95,46 +92,15 @@ void LayerTypeIcon::get_preferred_width_vfunc(Gtk::Widget& widget, nat_w += (nat_w) >> 1; } } -#else -void LayerTypeIcon::get_size_vfunc(Gtk::Widget& widget, - const Gdk::Rectangle* cell_area, - int* x_offset, - int* y_offset, - int* width, - int* height ) const -{ - Gtk::CellRendererPixbuf::get_size_vfunc( widget, cell_area, x_offset, y_offset, width, height ); - - if ( width ) { - *width += (*width) >> 1; - } - if ( height ) { - *height += (*height) >> 1; - } -} -#endif -#if WITH_GTKMM_3_0 void LayerTypeIcon::render_vfunc( const Cairo::RefPtr<Cairo::Context>& cr, Gtk::Widget& widget, const Gdk::Rectangle& background_area, const Gdk::Rectangle& cell_area, Gtk::CellRendererState flags ) -#else -void LayerTypeIcon::render_vfunc( const Glib::RefPtr<Gdk::Drawable>& window, - Gtk::Widget& widget, - const Gdk::Rectangle& background_area, - const Gdk::Rectangle& cell_area, - const Gdk::Rectangle& expose_area, - Gtk::CellRendererState flags ) -#endif { property_pixbuf() = _property_active.get_value() == 1 ? _property_pixbuf_group : (_property_active.get_value() == 2 ? _property_pixbuf_layer : _property_pixbuf_path); -#if WITH_GTKMM_3_0 Gtk::CellRendererPixbuf::render_vfunc( cr, widget, background_area, cell_area, flags ); -#else - Gtk::CellRendererPixbuf::render_vfunc( window, widget, background_area, cell_area, expose_area, flags ); -#endif } bool diff --git a/src/ui/widget/layertypeicon.h b/src/ui/widget/layertypeicon.h index 6c71ce361..f12029c12 100644 --- a/src/ui/widget/layertypeicon.h +++ b/src/ui/widget/layertypeicon.h @@ -35,8 +35,6 @@ public: Glib::PropertyProxy< Glib::RefPtr<Gdk::Pixbuf> > property_pixbuf_off(); protected: - -#if WITH_GTKMM_3_0 virtual void render_vfunc( const Cairo::RefPtr<Cairo::Context>& cr, Gtk::Widget& widget, const Gdk::Rectangle& background_area, @@ -50,18 +48,6 @@ protected: virtual void get_preferred_height_vfunc(Gtk::Widget& widget, int& min_h, int& nat_h) const; -#else - virtual void render_vfunc( const Glib::RefPtr<Gdk::Drawable>& window, - Gtk::Widget& widget, - const Gdk::Rectangle& background_area, - const Gdk::Rectangle& cell_area, - const Gdk::Rectangle& expose_area, - Gtk::CellRendererState flags ); - - virtual void get_size_vfunc( Gtk::Widget &widget, - Gdk::Rectangle const *cell_area, - int *x_offset, int *y_offset, int *width, int *height ) const; -#endif virtual bool activate_vfunc(GdkEvent *event, Gtk::Widget &widget, diff --git a/src/ui/widget/licensor.cpp b/src/ui/widget/licensor.cpp index d21e848f2..1e9ee361d 100644 --- a/src/ui/widget/licensor.cpp +++ b/src/ui/widget/licensor.cpp @@ -13,12 +13,13 @@ */ #ifdef HAVE_CONFIG_H -# include <config.h> +#include <config.h> #endif #include "licensor.h" #include <gtkmm/entry.h> +#include <gtkmm/radiobutton.h> #include "ui/widget/entity-entry.h" #include "ui/widget/registry.h" @@ -27,7 +28,6 @@ #include "document-undo.h" #include "document-private.h" #include "verbs.h" -#include <gtkmm/radiobutton.h> namespace Inkscape { @@ -134,18 +134,10 @@ void Licensor::update (SPDocument *doc) for (i=0; rdf_licenses[i].name; i++) if (license == &rdf_licenses[i]) break; -#if WITH_GTKMM_3_0 static_cast<LicenseItem*>(get_children()[i+1])->set_active(); -#else - static_cast<LicenseItem*>(children()[i+1].get_widget())->set_active(); -#endif } else { -#if WITH_GTKMM_3_0 static_cast<LicenseItem*>(get_children()[0])->set_active(); -#else - static_cast<LicenseItem*>(children()[0].get_widget())->set_active(); -#endif } /* update the URI */ diff --git a/src/ui/widget/notebook-page.cpp b/src/ui/widget/notebook-page.cpp index 2f03ed23b..6d8ff1d75 100644 --- a/src/ui/widget/notebook-page.cpp +++ b/src/ui/widget/notebook-page.cpp @@ -11,31 +11,19 @@ #include "notebook-page.h" -#if WITH_GTKMM_3_0 # include <gtkmm/grid.h> -#else -# include <gtkmm/table.h> -#endif namespace Inkscape { namespace UI { namespace Widget { NotebookPage::NotebookPage(int n_rows, int n_columns, bool expand, bool fill, guint padding) -#if WITH_GTKMM_3_0 :_table(Gtk::manage(new Gtk::Grid())) -#else - :_table(Gtk::manage(new Gtk::Table(n_rows, n_columns))) -#endif { set_border_width(2); -#if WITH_GTKMM_3_0 _table->set_row_spacing(2); _table->set_column_spacing(2); -#else - _table->set_spacings(2); -#endif pack_start(*_table, expand, fill, padding); } diff --git a/src/ui/widget/notebook-page.h b/src/ui/widget/notebook-page.h index c11de1b5b..6eb23907c 100644 --- a/src/ui/widget/notebook-page.h +++ b/src/ui/widget/notebook-page.h @@ -17,11 +17,7 @@ #include <gtkmm/box.h> namespace Gtk { -#if WITH_GTKMM_3_0 class Grid; -#else -class Table; -#endif } namespace Inkscape { @@ -42,19 +38,10 @@ public: */ NotebookPage(int n_rows, int n_columns, bool expand=false, bool fill=false, guint padding=0); -#if WITH_GTKMM_3_0 Gtk::Grid& table() { return *_table; } -#else - Gtk::Table& table() { return *_table; } -#endif protected: - -#if WITH_GTKMM_3_0 Gtk::Grid *_table; -#else - Gtk::Table *_table; -#endif }; } // namespace Widget diff --git a/src/ui/widget/object-composite-settings.cpp b/src/ui/widget/object-composite-settings.cpp index 8acf083d0..1727660c8 100644 --- a/src/ui/widget/object-composite-settings.cpp +++ b/src/ui/widget/object-composite-settings.cpp @@ -14,8 +14,6 @@ #include "ui/widget/object-composite-settings.h" -#include <glibmm/i18n.h> - #include "desktop.h" #include "desktop-style.h" @@ -23,17 +21,12 @@ #include "document-undo.h" #include "filter-chemistry.h" #include "inkscape.h" -#include "selection.h" #include "style.h" -#include "sp-item.h" #include "svg/css-ostringstream.h" #include "verbs.h" -#include "xml/repr.h" #include "widgets/icon.h" -#include "ui/icon-names.h" #include "display/sp-canvas.h" #include "ui/widget/style-subject.h" -#include "ui/widget/gimpspinscale.h" namespace Inkscape { namespace UI { @@ -125,7 +118,7 @@ ObjectCompositeSettings::_blendBlurValueChanged() const Glib::ustring blendmode = _fe_cb.get_blend_mode(); //apply created filter to every selected item - std::vector<SPObject*> sel=_subject->list(); + std::vector<SPObject*> sel = _subject->list(); for (std::vector<SPObject*>::const_iterator i = sel.begin() ; i != sel.end() ; ++i ) { if (!SP_IS_ITEM(*i)) { continue; diff --git a/src/ui/widget/page-sizer.cpp b/src/ui/widget/page-sizer.cpp index 19ab1a280..081300b9e 100644 --- a/src/ui/widget/page-sizer.cpp +++ b/src/ui/widget/page-sizer.cpp @@ -18,35 +18,18 @@ */ #ifdef HAVE_CONFIG_H -# include <config.h> +#include <config.h> #endif #include "page-sizer.h" -#include <cmath> -#include <string> -#include <string.h> -#include <sstream> -#include <vector> - #include <glibmm/i18n.h> -#include <2geom/transforms.h> - -#include "document.h" -#include "desktop.h" #include "helper/action.h" -#include "helper/action-context.h" -#include "util/units.h" -#include "inkscape.h" -#include "sp-namedview.h" #include "sp-root.h" #include "ui/widget/button.h" -#include "ui/widget/scalar-unit.h" #include "verbs.h" -#include "xml/node.h" -#include "xml/repr.h" using std::pair; using Inkscape::Util::unit_table; @@ -353,7 +336,6 @@ PageSizer::PageSizer(Registry & _wr) _customDimTable.set_border_width(4); -#if WITH_GTKMM_3_0 _customDimTable.set_row_spacing(4); _customDimTable.set_column_spacing(4); @@ -372,15 +354,6 @@ PageSizer::PageSizer(Registry & _wr) _fitPageMarginExpander.set_hexpand(); _fitPageMarginExpander.set_vexpand(); _customDimTable.attach(_fitPageMarginExpander, 0, 2, 2, 1); -#else - _customDimTable.resize(3, 2); - _customDimTable.set_row_spacings(4); - _customDimTable.set_col_spacings(4); - _customDimTable.attach(_dimensionWidth, 0,1, 0,1); - _customDimTable.attach(_dimensionUnits, 1,2, 0,1); - _customDimTable.attach(_dimensionHeight, 0,1, 1,2); - _customDimTable.attach(_fitPageMarginExpander, 0,2, 2,3); -#endif _dimTabOrderGList = NULL; _dimTabOrderGList = g_list_append(_dimTabOrderGList, _dimensionWidth.gobj()); @@ -398,7 +371,6 @@ PageSizer::PageSizer(Registry & _wr) //## Set up margin settings _marginTable.set_border_width(4); -#if WITH_GTKMM_3_0 _marginTable.set_row_spacing(4); _marginTable.set_column_spacing(4); @@ -421,16 +393,6 @@ PageSizer::PageSizer(Registry & _wr) _fitPageButtonAlign.set_hexpand(); _fitPageButtonAlign.set_vexpand(); _marginTable.attach(_fitPageButtonAlign, 0, 3, 2, 1); -#else - _marginTable.set_border_width(4); - _marginTable.set_row_spacings(4); - _marginTable.set_col_spacings(4); - _marginTable.attach(_marginTopAlign, 0,2, 0,1); - _marginTable.attach(_marginLeftAlign, 0,1, 1,2); - _marginTable.attach(_marginRightAlign, 1,2, 1,2); - _marginTable.attach(_marginBottomAlign, 0,2, 2,3); - _marginTable.attach(_fitPageButtonAlign, 0,2, 3,4); -#endif _marginTopAlign.set(0.5, 0.5, 0.0, 1.0); _marginTopAlign.add(_marginTop); @@ -444,7 +406,7 @@ PageSizer::PageSizer(Registry & _wr) _fitPageButtonAlign.set(0.5, 0.5, 0.0, 1.0); _fitPageButtonAlign.add(_fitPageButton); _fitPageButton.set_use_underline(); - _fitPageButton.set_label(_("_Resize page to drawing or selection")); + _fitPageButton.set_label(_("_Resize page to drawing or selection (Ctrl+Shift+R)")); _fitPageButton.set_tooltip_text(_("Resize the page to fit the current selection, or the entire drawing if there is no selection")); _scaleFrame.set_label(_("Scale")); @@ -453,7 +415,6 @@ PageSizer::PageSizer(Registry & _wr) _scaleTable.set_border_width(4); -#if WITH_GTKMM_3_0 _scaleTable.set_row_spacing(4); _scaleTable.set_column_spacing(4); @@ -465,16 +426,6 @@ PageSizer::PageSizer(Registry & _wr) _viewboxExpander.set_hexpand(); _viewboxExpander.set_vexpand(); _scaleTable.attach(_viewboxExpander, 0, 2, 2, 1); -#else - _scaleTable.resize(3, 2); - _scaleTable.set_row_spacings(4); - _scaleTable.set_col_spacings(4); - _scaleTable.attach(_scaleX, 0,1, 0,1); - _scaleTable.attach(_scaleY, 1,2, 0,1); - _scaleTable.attach(_scaleLabel, 2,3, 0,1); - _scaleTable.attach(_scaleWarning, 0,3, 1,2, Gtk::FILL); - _scaleTable.attach(_viewboxExpander, 0,3, 2,3); -#endif _scaleWarning.set_label(_("While SVG allows non-uniform scaling it is recommended to use only uniform scaling in Inkscape. To set a non-uniform scaling, set the 'viewBox' directly.")); _scaleWarning.set_line_wrap( true ); @@ -483,7 +434,6 @@ PageSizer::PageSizer(Registry & _wr) _viewboxExpander.set_label(_("_Viewbox...")); _viewboxExpander.add(_viewboxTable); -#if WITH_GTKMM_3_0 _viewboxTable.set_row_spacing(2); _viewboxTable.set_column_spacing(2); @@ -503,16 +453,6 @@ PageSizer::PageSizer(Registry & _wr) _viewboxH.set_vexpand(); _viewboxTable.attach(_viewboxH, 1, 1, 1, 1); -#else - _viewboxTable.set_border_width(4); - _viewboxTable.set_row_spacings(2); - _viewboxTable.set_col_spacings(2); - _viewboxTable.attach(_viewboxX, 0,1, 0,1); - _viewboxTable.attach(_viewboxY, 1,2, 0,1); - _viewboxTable.attach(_viewboxW, 0,1, 1,2); - _viewboxTable.attach(_viewboxH, 1,2, 1,2); -#endif - _wr.setUpdating (true); updateScaleUI(); _wr.setUpdating (false); diff --git a/src/ui/widget/page-sizer.h b/src/ui/widget/page-sizer.h index 0eea28e61..f1966f848 100644 --- a/src/ui/widget/page-sizer.h +++ b/src/ui/widget/page-sizer.h @@ -23,15 +23,9 @@ #include <gtkmm/alignment.h> #include <gtkmm/expander.h> #include <gtkmm/frame.h> +#include <gtkmm/grid.h> #include <gtkmm/liststore.h> #include <gtkmm/scrolledwindow.h> - -#if WITH_GTKMM_3_0 -# include <gtkmm/grid.h> -#else -# include <gtkmm/table.h> -#endif - #include <gtkmm/radiobutton.h> namespace Inkscape { @@ -222,12 +216,7 @@ protected: //### Custom size frame Gtk::Frame _customFrame; - -#if WITH_GTKMM_3_0 Gtk::Grid _customDimTable; -#else - Gtk::Table _customDimTable; -#endif RegisteredUnitMenu _dimensionUnits; RegisteredScalarUnit _dimensionWidth; @@ -237,12 +226,7 @@ protected: //### Fit Page options Gtk::Expander _fitPageMarginExpander; -#if WITH_GTKMM_3_0 Gtk::Grid _marginTable; -#else - Gtk::Table _marginTable; -#endif - Gtk::Alignment _marginTopAlign; Gtk::Alignment _marginLeftAlign; Gtk::Alignment _marginRightAlign; @@ -257,11 +241,7 @@ protected: // Document scale Gtk::Frame _scaleFrame; -#if WITH_GTKMM_3_0 Gtk::Grid _scaleTable; -#else - Gtk::Table _scaleTable; -#endif Gtk::Label _scaleLabel; Gtk::Label _scaleWarning; @@ -271,11 +251,7 @@ protected: // Viewbox Gtk::Expander _viewboxExpander; -#if WITH_GTKMM_3_0 Gtk::Grid _viewboxTable; -#else - Gtk::Table _viewboxTable; -#endif RegisteredScalar _viewboxX; RegisteredScalar _viewboxY; diff --git a/src/ui/widget/panel.cpp b/src/ui/widget/panel.cpp index ab13577d7..6e6e6c527 100644 --- a/src/ui/widget/panel.cpp +++ b/src/ui/widget/panel.cpp @@ -12,20 +12,18 @@ */ #ifdef HAVE_CONFIG_H -# include <config.h> +#include <config.h> #endif #include <gtkmm/dialog.h> // for Gtk::RESPONSE_* #include <gtkmm/menu.h> #include <gtkmm/stock.h> -#include <gtkmm/radiobutton.h> +#include <gtkmm/checkmenuitem.h> #include <gtkmm/radiomenuitem.h> #include <gtkmm/separatormenuitem.h> #include <glibmm/i18n.h> -#include <gtk/gtk.h> - #include "panel.h" #include "icon-size.h" #include "preferences.h" @@ -74,9 +72,7 @@ Panel::Panel(Glib::ustring const &label, gchar const *prefs_path, _fillable(0) { set_name( "InkscapePanel" ); -#if WITH_GTKMM_3_0 set_orientation( Gtk::ORIENTATION_VERTICAL ); -#endif _init(); } @@ -598,13 +594,9 @@ void Panel::_addResponseButton(Gtk::Button *button, int response_id, bool pack_s { // Create a button box for the response buttons if it's the first button to be added if (!_action_area) { -#if WITH_GTKMM_3_0 _action_area = new Gtk::ButtonBox(); _action_area->set_layout(Gtk::BUTTONBOX_END); _action_area->set_spacing(6); -#else - _action_area = new Gtk::HButtonBox(Gtk::BUTTONBOX_END, 6); -#endif _action_area->set_border_width(4); pack_end(*_action_area, Gtk::PACK_SHRINK, 0); } diff --git a/src/ui/widget/panel.h b/src/ui/widget/panel.h index 7b2836fe8..370779586 100644 --- a/src/ui/widget/panel.h +++ b/src/ui/widget/panel.h @@ -31,13 +31,7 @@ class SPDocument; namespace Gtk { class CheckMenuItem; - -#if WITH_GTKMM_3_0 class ButtonBox; -#else - class HButtonBox; -#endif - class MenuItem; } @@ -64,12 +58,7 @@ namespace Widget { * @see UI::Dialog::DesktopTracker to handle desktop change, selection change and selected object modifications. * @see UI::Dialog::DialogManager manages the dialogs within inkscape. */ -#if WITH_GTKMM_3_0 class Panel : public Gtk::Box { -#else -class Panel : public Gtk::VBox { -#endif - public: static void prep(); @@ -172,12 +161,7 @@ private: Gtk::EventBox _menu_popper; Gtk::Button _close_button; Gtk::Menu *_menu; - -#if WITH_GTKMM_3_0 - Gtk::ButtonBox *_action_area; //< stores response buttons -#else - Gtk::HButtonBox *_action_area; //< stores response buttons -#endif + Gtk::ButtonBox *_action_area; //< stores response buttons std::vector<Gtk::Widget *> _non_horizontal; std::vector<Gtk::Widget *> _non_vertical; diff --git a/src/ui/widget/point.cpp b/src/ui/widget/point.cpp index 6aa6196bb..6b31b1856 100644 --- a/src/ui/widget/point.cpp +++ b/src/ui/widget/point.cpp @@ -12,14 +12,11 @@ */ #ifdef HAVE_CONFIG_H -# include <config.h> +#include <config.h> #endif #include "ui/widget/point.h" -#include "ui/widget/labelled.h" -#include "ui/widget/scalar.h" -#include <gtkmm/box.h> namespace Inkscape { namespace UI { @@ -53,11 +50,7 @@ Point::Point(Glib::ustring const &label, Glib::ustring const &tooltip, } Point::Point(Glib::ustring const &label, Glib::ustring const &tooltip, -#if WITH_GTKMM_3_0 Glib::RefPtr<Gtk::Adjustment> &adjust, -#else - Gtk::Adjustment &adjust, -#endif unsigned digits, Glib::ustring const &suffix, Glib::ustring const &icon, diff --git a/src/ui/widget/point.h b/src/ui/widget/point.h index 17078df8f..71bfd8473 100644 --- a/src/ui/widget/point.h +++ b/src/ui/widget/point.h @@ -82,11 +82,7 @@ public: */ Point( Glib::ustring const &label, Glib::ustring const &tooltip, -#if WITH_GTKMM_3_0 Glib::RefPtr<Gtk::Adjustment> &adjust, -#else - Gtk::Adjustment &adjust, -#endif unsigned digits = 0, Glib::ustring const &suffix = "", Glib::ustring const &icon = "", diff --git a/src/ui/widget/preferences-widget.cpp b/src/ui/widget/preferences-widget.cpp index d56506d62..1205cd012 100644 --- a/src/ui/widget/preferences-widget.cpp +++ b/src/ui/widget/preferences-widget.cpp @@ -11,7 +11,7 @@ */ #ifdef HAVE_CONFIG_H -# include <config.h> +#include <config.h> #endif #include <gtkmm/box.h> @@ -26,20 +26,16 @@ #include "verbs.h" #include "selcue.h" #include "io/sys.h" -#include <iostream> #include "desktop.h" -#include "enums.h" #include "inkscape.h" #include "message-stack.h" #include "style.h" -#include "selection.h" #include "selection-chemistry.h" #include "ui/dialog/filedialog.h" -#include "xml/repr.h" -#include <glibmm/convert.h> #include <glibmm/i18n.h> +#include <glibmm/convert.h> #ifdef WIN32 #include <windows.h> @@ -55,14 +51,9 @@ DialogPage::DialogPage() { set_border_width(12); -#if WITH_GTKMM_3_0 set_orientation(Gtk::ORIENTATION_VERTICAL); set_column_spacing(12); set_row_spacing(6); -#else - set_col_spacings(12); - set_row_spacings(6); -#endif } /** @@ -101,12 +92,7 @@ void DialogPage::add_line(bool indent, // be indented if desired Gtk::Alignment* w_alignment = Gtk::manage(new Gtk::Alignment()); w_alignment->add(*hb); - -#if WITH_GTKMM_3_0 w_alignment->set_valign(Gtk::ALIGN_CENTER); -#else - guint row = property_n_rows(); -#endif // Add a label in the first column if provided if (label != "") @@ -122,17 +108,12 @@ void DialogPage::add_line(bool indent, if (indent) label_alignment->set_padding(0, 0, 12, 0); -#if WITH_GTKMM_3_0 label_alignment->set_valign(Gtk::ALIGN_CENTER); add(*label_alignment); attach_next_to(*w_alignment, *label_alignment, Gtk::POS_RIGHT, 1, 1); -#else - attach(*label_alignment, 0, 1, row, row + 1, Gtk::FILL, Gtk::AttachOptions(), 0, 0); -#endif } // Now add the widget to the bottom of the dialog -#if WITH_GTKMM_3_0 if (label == "") { if (indent) @@ -145,17 +126,6 @@ void DialogPage::add_line(bool indent, g_value_set_int(&width, 2); gtk_container_child_set_property(GTK_CONTAINER(gobj()), GTK_WIDGET(w_alignment->gobj()), "width", &width); } -#else - // The widget should span two columns if there is no label - int w_col_span = 1; - if (label == "") - w_col_span = 2; - - attach(*w_alignment, 2 - w_col_span, 2, row, row + 1, - Gtk::FILL | Gtk::EXPAND, - Gtk::AttachOptions(), - 0, 0); -#endif // Add a label on the right of the widget if desired if (suffix != "") @@ -174,18 +144,8 @@ void DialogPage::add_group_header(Glib::ustring name) Glib::ustring("</b>"/*</span>"*/) , Gtk::ALIGN_START , Gtk::ALIGN_CENTER, true)); label_widget->set_use_markup(true); - -#if WITH_GTKMM_3_0 label_widget->set_valign(Gtk::ALIGN_CENTER); add(*label_widget); -// if (row != 1) - // set_row_spacing(row - 1, 18); -#else - int row = property_n_rows(); - attach(*label_widget , 0, 4, row, row + 1, Gtk::FILL, Gtk::AttachOptions(), 0, 0); - if (row != 1) - set_row_spacing(row - 1, 18); -#endif } } @@ -427,24 +387,6 @@ ZoomCorrRuler::draw_marks(Cairo::RefPtr<Cairo::Context> cr, double dist, int maj } } -#if !WITH_GTKMM_3_0 -bool -ZoomCorrRuler::on_expose_event(GdkEventExpose *event) { - bool result = false; - - if(get_is_drawable()) - { - Cairo::RefPtr<Cairo::Context> cr = get_window()->create_cairo_context(); - cr->rectangle(event->area.x, event->area.y, - event->area.width, event->area.height); - cr->clip(); - result = on_draw(cr); - } - - return result; -} -#endif - bool ZoomCorrRuler::on_draw(const Cairo::RefPtr<Cairo::Context>& cr) { Glib::RefPtr<Gdk::Window> window = get_window(); @@ -548,11 +490,7 @@ ZoomCorrRulerSlider::init(int ruler_width, int ruler_height, double lower, doubl _ruler.set_size(ruler_width, ruler_height); -#if WITH_GTKMM_3_0 _slider = Gtk::manage(new Gtk::Scale(Gtk::ORIENTATION_HORIZONTAL)); -#else - _slider = Gtk::manage(new Gtk::HScale()); -#endif _slider->set_size_request(_ruler.width(), -1); _slider->set_range (lower, upper); @@ -579,21 +517,13 @@ ZoomCorrRulerSlider::init(int ruler_width, int ruler_height, double lower, doubl alignment1->add(_sb); alignment2->add(_unit); -#if WITH_GTKMM_3_0 - Gtk::Grid *table = Gtk::manage(new Gtk::Grid()); + auto table = Gtk::manage(new Gtk::Grid()); table->attach(*_slider, 0, 0, 1, 1); alignment1->set_halign(Gtk::ALIGN_CENTER); table->attach(*alignment1, 1, 0, 1, 1); table->attach(_ruler, 0, 1, 1, 1); alignment2->set_halign(Gtk::ALIGN_CENTER); table->attach(*alignment2, 1, 1, 1, 1); -#else - Gtk::Table *table = Gtk::manage(new Gtk::Table()); - table->attach(*_slider, 0, 1, 0, 1); - table->attach(*alignment1, 1, 2, 0, 1, static_cast<Gtk::AttachOptions>(0)); - table->attach(_ruler, 0, 1, 1, 2); - table->attach(*alignment2, 1, 2, 1, 2, static_cast<Gtk::AttachOptions>(0)); -#endif pack_start(*table, Gtk::PACK_SHRINK); } @@ -640,11 +570,7 @@ PrefSlider::init(Glib::ustring const &prefs_path, freeze = false; -#if WITH_GTKMM_3_0 _slider = Gtk::manage(new Gtk::Scale(Gtk::ORIENTATION_HORIZONTAL)); -#else - _slider = Gtk::manage(new Gtk::HScale()); -#endif _slider->set_range (lower, upper); _slider->set_increments (step_increment, page_increment); @@ -661,17 +587,11 @@ PrefSlider::init(Glib::ustring const &prefs_path, Gtk::Alignment *alignment1 = Gtk::manage(new Gtk::Alignment(0.5,1,0,0)); alignment1->add(_sb); -#if WITH_GTKMM_3_0 - Gtk::Grid *table = Gtk::manage(new Gtk::Grid()); + auto table = Gtk::manage(new Gtk::Grid()); _slider->set_hexpand(); table->attach(*_slider, 0, 0, 1, 1); alignment1->set_halign(Gtk::ALIGN_CENTER); table->attach(*alignment1, 1, 0, 1, 1); -#else - Gtk::Table *table = Gtk::manage(new Gtk::Table()); - table->attach(*_slider, 0, 1, 0, 1); - table->attach(*alignment1, 1, 2, 0, 1, static_cast<Gtk::AttachOptions>(0)); -#endif this->pack_start(*table, Gtk::PACK_EXPAND_WIDGET); } diff --git a/src/ui/widget/preferences-widget.h b/src/ui/widget/preferences-widget.h index 1d2d77699..142793509 100644 --- a/src/ui/widget/preferences-widget.h +++ b/src/ui/widget/preferences-widget.h @@ -30,12 +30,7 @@ #include <gtkmm/radiobutton.h> #include <gtkmm/comboboxtext.h> #include <gtkmm/drawingarea.h> - -#if WITH_GTKMM_3_0 #include <gtkmm/grid.h> -#else -#include <gtkmm/table.h> -#endif #include "ui/widget/color-picker.h" #include "ui/widget/unit-menu.h" @@ -43,11 +38,7 @@ #include "ui/widget/scalar-unit.h" namespace Gtk { -#if WITH_GTKMM_3_0 class Scale; -#else -class HScale; -#endif } namespace Inkscape { @@ -126,10 +117,6 @@ public: static const double textpadding; private: -#if !WITH_GTKMM_3_0 - bool on_expose_event(GdkEventExpose *event); -#endif - bool on_draw(const Cairo::RefPtr<Cairo::Context>& cr); void draw_marks(Cairo::RefPtr<Cairo::Context> cr, double dist, int major_interval); @@ -155,11 +142,7 @@ private: Inkscape::UI::Widget::SpinButton _sb; UnitMenu _unit; -#if WITH_GTKMM_3_0 Gtk::Scale* _slider; -#else - Gtk::HScale* _slider; -#endif ZoomCorrRuler _ruler; bool freeze; // used to block recursive updates of slider and spinbutton }; @@ -178,11 +161,7 @@ private: Glib::ustring _prefs_path; Inkscape::UI::Widget::SpinButton _sb; -#if WITH_GTKMM_3_0 Gtk::Scale* _slider; -#else - Gtk::HScale* _slider; -#endif bool freeze; // used to block recursive updates of slider and spinbutton }; @@ -279,11 +258,7 @@ protected: void on_changed(); }; -#if WITH_GTKMM_3_0 class DialogPage : public Gtk::Grid -#else -class DialogPage : public Gtk::Table -#endif { public: DialogPage(); diff --git a/src/ui/widget/random.cpp b/src/ui/widget/random.cpp index 0a646b6fb..ba3b025ba 100644 --- a/src/ui/widget/random.cpp +++ b/src/ui/widget/random.cpp @@ -10,7 +10,7 @@ */ #ifdef HAVE_CONFIG_H -# include <config.h> +#include <config.h> #endif @@ -47,11 +47,7 @@ Random::Random(Glib::ustring const &label, Glib::ustring const &tooltip, } Random::Random(Glib::ustring const &label, Glib::ustring const &tooltip, -#if WITH_GTKMM_3_0 Glib::RefPtr<Gtk::Adjustment> &adjust, -#else - Gtk::Adjustment &adjust, -#endif unsigned digits, Glib::ustring const &suffix, Glib::ustring const &icon, diff --git a/src/ui/widget/random.h b/src/ui/widget/random.h index dc2b457c2..d86ab6246 100644 --- a/src/ui/widget/random.h +++ b/src/ui/widget/random.h @@ -75,11 +75,7 @@ public: */ Random(Glib::ustring const &label, Glib::ustring const &tooltip, -#if WITH_GTKMM_3_0 Glib::RefPtr<Gtk::Adjustment> &adjust, -#else - Gtk::Adjustment &adjust, -#endif unsigned digits = 0, Glib::ustring const &suffix = "", Glib::ustring const &icon = "", diff --git a/src/ui/widget/registered-widget.cpp b/src/ui/widget/registered-widget.cpp index dc2e4e14a..be677a434 100644 --- a/src/ui/widget/registered-widget.cpp +++ b/src/ui/widget/registered-widget.cpp @@ -14,34 +14,21 @@ */ #ifdef HAVE_CONFIG_H -# include <config.h> +#include <config.h> #endif #include "registered-widget.h" -#include <gtkmm/radiobutton.h> -#include "ui/widget/color-picker.h" -#include "ui/widget/registry.h" -#include "ui/widget/scalar-unit.h" -#include "ui/widget/point.h" -#include "ui/widget/random.h" -#include "ui/widget/font-button.h" #include "widgets/spinbutton-events.h" -#include "xml/repr.h" #include "svg/svg-color.h" #include "svg/stringstream.h" #include "verbs.h" - -// for interruptability bug: -#include "display/sp-canvas.h" - -#include "desktop.h" - - #include "sp-root.h" +#include <gtkmm/radiobutton.h> + namespace Inkscape { namespace UI { namespace Widget { diff --git a/src/ui/widget/rendering-options.cpp b/src/ui/widget/rendering-options.cpp index 837387f7b..220731b7e 100644 --- a/src/ui/widget/rendering-options.cpp +++ b/src/ui/widget/rendering-options.cpp @@ -9,7 +9,7 @@ */ #ifdef HAVE_CONFIG_H -# include <config.h> +#include <config.h> #endif #include <gtkmm.h> diff --git a/src/ui/widget/rotateable.cpp b/src/ui/widget/rotateable.cpp index 5e938dee6..e0de22335 100644 --- a/src/ui/widget/rotateable.cpp +++ b/src/ui/widget/rotateable.cpp @@ -8,12 +8,11 @@ */ #ifdef HAVE_CONFIG_H -# include "config.h" +#include <config.h> #endif #include <gtkmm/box.h> #include <gtkmm/eventbox.h> -#include <glibmm/i18n.h> #include <2geom/point.h> #include "ui/tools/tool-base.h" #include "rotateable.h" diff --git a/src/ui/widget/scalar.cpp b/src/ui/widget/scalar.cpp index 80a2454b0..f8543a371 100644 --- a/src/ui/widget/scalar.cpp +++ b/src/ui/widget/scalar.cpp @@ -43,11 +43,7 @@ Scalar::Scalar(Glib::ustring const &label, Glib::ustring const &tooltip, } Scalar::Scalar(Glib::ustring const &label, Glib::ustring const &tooltip, -#if WITH_GTKMM_3_0 Glib::RefPtr<Gtk::Adjustment> &adjust, -#else - Gtk::Adjustment &adjust, -#endif unsigned digits, Glib::ustring const &suffix, Glib::ustring const &icon, @@ -143,11 +139,7 @@ void Scalar::update() void Scalar::addSlider() { -#if WITH_GTKMM_3_0 - Gtk::Scale *scale = new Gtk::Scale(static_cast<SpinButton*>(_widget)->get_adjustment()); -#else - Gtk::HScale *scale = new Gtk::HScale( * static_cast<SpinButton*>(_widget)->get_adjustment() ); -#endif + auto scale = new Gtk::Scale(static_cast<SpinButton*>(_widget)->get_adjustment()); scale->set_draw_value(false); add (*manage (scale)); } diff --git a/src/ui/widget/scalar.h b/src/ui/widget/scalar.h index 9cceeaa1f..f186f46ac 100644 --- a/src/ui/widget/scalar.h +++ b/src/ui/widget/scalar.h @@ -73,11 +73,7 @@ public: */ Scalar(Glib::ustring const &label, Glib::ustring const &tooltip, -#if WITH_GTKMM_3_0 Glib::RefPtr<Gtk::Adjustment> &adjust, -#else - Gtk::Adjustment &adjust, -#endif unsigned digits = 0, Glib::ustring const &suffix = "", Glib::ustring const &icon = "", diff --git a/src/ui/widget/selected-style.cpp b/src/ui/widget/selected-style.cpp index f7fd63f51..301a3b2e0 100644 --- a/src/ui/widget/selected-style.cpp +++ b/src/ui/widget/selected-style.cpp @@ -10,11 +10,10 @@ */ #ifdef HAVE_CONFIG_H -# include <config.h> +#include <config.h> #endif #include "selected-style.h" -#include <gtkmm/separatormenuitem.h> #include "widgets/spw-utilities.h" #include "ui/widget/color-preview.h" @@ -26,24 +25,19 @@ #include "sp-namedview.h" #include "sp-linear-gradient.h" #include "sp-radial-gradient.h" -#include "sp-mesh.h" +#include "sp-mesh-gradient.h" #include "sp-pattern.h" #include "ui/dialog/dialog-manager.h" #include "ui/dialog/fill-and-stroke.h" #include "ui/dialog/panel-dialog.h" -#include "xml/repr.h" -#include "document.h" #include "document-undo.h" #include "widgets/widget-sizes.h" #include "widgets/spinbutton-events.h" #include "widgets/gradient-image.h" -#include "sp-gradient.h" #include "svg/svg-color.h" #include "svg/css-ostringstream.h" #include "ui/tools/tool-base.h" #include "message-context.h" -#include "verbs.h" -#include "color.h" #include <display/sp-canvas.h> #include "pixmaps/cursor-adj-h.xpm" #include "pixmaps/cursor-adj-s.xpm" @@ -51,7 +45,8 @@ #include "pixmaps/cursor-adj-a.xpm" #include "sp-cursor.h" #include "gradient-chemistry.h" -#include "util/units.h" + +#include <gtkmm/separatormenuitem.h> using Inkscape::Util::unit_table; @@ -123,11 +118,7 @@ SelectedStyle::SelectedStyle(bool /*layout*/) current_stroke_width(0), _desktop (NULL), -#if WITH_GTKMM_3_0 _table(), -#else - _table(2, 6), -#endif _fill_label (_("Fill:")), _stroke_label (_("Stroke:")), _opacity_label (_("O:")), @@ -139,11 +130,7 @@ SelectedStyle::SelectedStyle(bool /*layout*/) _stroke_flag_place (), _opacity_place (), -#if WITH_GTKMM_3_0 _opacity_adjustment(Gtk::Adjustment::create(100, 0.0, 100, 1.0, 10.0)), -#else - _opacity_adjustment (100, 0.0, 100, 1.0, 10.0), -#endif _opacity_sb (0.02, 0), _stroke (), @@ -166,13 +153,8 @@ SelectedStyle::SelectedStyle(bool /*layout*/) _opacity_label.set_alignment(0.0, 0.5); _opacity_label.set_padding(0, 0); -#if WITH_GTKMM_3_0 _table.set_column_spacing(2); _table.set_row_spacing(0); -#else - _table.set_col_spacings (2); - _table.set_row_spacings (0); -#endif for (int i = SS_FILL; i <= SS_STROKE; i++) { @@ -379,7 +361,6 @@ SelectedStyle::SelectedStyle(bool /*layout*/) _opacity_sb.set_size_request (SELECTED_STYLE_SB_WIDTH, -1); _opacity_sb.set_sensitive (false); -#if WITH_GTKMM_3_0 _table.attach(_fill_label, 0, 0, 1, 1); _table.attach(_stroke_label, 0, 1, 1, 1); @@ -388,26 +369,11 @@ SelectedStyle::SelectedStyle(bool /*layout*/) _table.attach(_fill_place, 2, 0, 1, 1); _table.attach(_stroke, 2, 1, 1, 1); -#else - _table.attach(_fill_label, 0,1, 0,1, Gtk::FILL, Gtk::SHRINK); - _table.attach(_stroke_label, 0,1, 1,2, Gtk::FILL, Gtk::SHRINK); - - _table.attach(_fill_flag_place, 1,2, 0,1, Gtk::SHRINK, Gtk::SHRINK); - _table.attach(_stroke_flag_place, 1,2, 1,2, Gtk::SHRINK, Gtk::SHRINK); - - _table.attach(_fill_place, 2,3, 0,1); - _table.attach(_stroke, 2,3, 1,2); -#endif _opacity_place.add(_opacity_label); -#if WITH_GTKMM_3_0 _table.attach(_opacity_place, 4, 0, 1, 2); _table.attach(_opacity_sb, 5, 0, 1, 2); -#else - _table.attach(_opacity_place, 4,5, 0,2, Gtk::SHRINK, Gtk::SHRINK); - _table.attach(_opacity_sb, 5,6, 0,2, Gtk::SHRINK, Gtk::SHRINK); -#endif pack_start(_table, true, true, 2); @@ -1044,7 +1010,7 @@ SelectedStyle::update() place->set_tooltip_text(__rgradient[i]); _mode[i] = SS_RGRADIENT; #ifdef WITH_MESH - } else if (SP_IS_MESH(server)) { + } else if (SP_IS_MESHGRADIENT(server)) { SPGradient *vector = SP_GRADIENT(server)->getVector(); sp_gradient_image_set_gradient(SP_GRADIENT_IMAGE(_gradient_preview_m[i]), vector); place->add(_gradient_box_m[i]); @@ -1120,11 +1086,7 @@ SelectedStyle::update() if (_opacity_blocked) break; _opacity_blocked = true; _opacity_sb.set_sensitive(true); -#if WITH_GTKMM_3_0 _opacity_adjustment->set_value(SP_SCALE24_TO_FLOAT(query.opacity.value) * 100); -#else - _opacity_adjustment.set_value(SP_SCALE24_TO_FLOAT(query.opacity.value) * 100); -#endif _opacity_blocked = false; break; } @@ -1224,11 +1186,7 @@ void SelectedStyle::on_opacity_changed () _opacity_blocked = true; SPCSSAttr *css = sp_repr_css_attr_new (); Inkscape::CSSOStringStream os; -#if WITH_GTKMM_3_0 os << CLAMP ((_opacity_adjustment->get_value() / 100), 0.0, 1.0); -#else - os << CLAMP ((_opacity_adjustment.get_value() / 100), 0.0, 1.0); -#endif sp_repr_css_set_property (css, "opacity", os.str().c_str()); // FIXME: workaround for GTK breakage: display interruptibility sometimes results in GTK // sending multiple value-changed events. As if when Inkscape interrupts redraw for main loop @@ -1357,11 +1315,7 @@ RotateableSwatch::do_motion(double by, guint modifier) { g_object_unref(pixbuf); gdk_window_set_cursor(gtk_widget_get_window(w), cr); -#if GTK_CHECK_VERSION(3,0,0) g_object_unref(cr); -#else - gdk_cursor_unref(cr); -#endif cr = NULL; cr_set = true; } @@ -1425,11 +1379,7 @@ RotateableSwatch::do_release(double by, guint modifier) { GtkWidget *w = GTK_WIDGET(gobj()); gdk_window_set_cursor(gtk_widget_get_window(w), NULL); if (cr) { -#if GTK_CHECK_VERSION(3,0,0) g_object_unref(cr); -#else - gdk_cursor_unref (cr); -#endif cr = NULL; } cr_set = false; diff --git a/src/ui/widget/selected-style.h b/src/ui/widget/selected-style.h index 804a6fef6..efac29f73 100644 --- a/src/ui/widget/selected-style.h +++ b/src/ui/widget/selected-style.h @@ -16,12 +16,7 @@ #endif #include <gtkmm/box.h> - -#if WITH_GTKMM_3_0 -# include <gtkmm/grid.h> -#else -# include <gtkmm/table.h> -#endif +#include <gtkmm/grid.h> #include <gtkmm/label.h> #include <gtkmm/eventbox.h> @@ -140,11 +135,7 @@ public: protected: SPDesktop *_desktop; -#if WITH_GTKMM_3_0 Gtk::Grid _table; -#else - Gtk::Table _table; -#endif Gtk::Label _fill_label; Gtk::Label _stroke_label; @@ -157,11 +148,7 @@ protected: Gtk::EventBox _stroke_flag_place; Gtk::EventBox _opacity_place; -#if WITH_GTKMM_3_0 Glib::RefPtr<Gtk::Adjustment> _opacity_adjustment; -#else - Gtk::Adjustment _opacity_adjustment; -#endif Inkscape::UI::Widget::SpinButton _opacity_sb; Gtk::Label _na[2]; diff --git a/src/ui/widget/spin-scale.cpp b/src/ui/widget/spin-scale.cpp index bb08d67df..f74626d9b 100644 --- a/src/ui/widget/spin-scale.cpp +++ b/src/ui/widget/spin-scale.cpp @@ -8,11 +8,10 @@ #include "spin-scale.h" -#include <gtkmm/adjustment.h> #include <glibmm/i18n.h> #include <glibmm/stringutils.h> -#include "ui/widget/gimpspinscale.h" +#include "widgets/gimp/gimpspinscale.h" namespace Inkscape { namespace UI { @@ -22,13 +21,8 @@ SpinScale::SpinScale(const char* label, double value, double lower, double upper double /*climb_rate*/, int digits, const SPAttributeEnum a, const char* tip_text) : AttrWidget(a, value) { -#if WITH_GTKMM_3_0 _adjustment = Gtk::Adjustment::create(value, lower, upper, step_inc); _spinscale = gimp_spin_scale_new (_adjustment->gobj(), label, digits); -#else - _adjustment = new Gtk::Adjustment(value, lower, upper, step_inc); - _spinscale = gimp_spin_scale_new (_adjustment->gobj(), label, digits); -#endif signal_value_changed().connect(signal_attr_changed().make_slot()); @@ -42,12 +36,10 @@ SpinScale::SpinScale(const char* label, double value, double lower, double upper } SpinScale::SpinScale(const char* label, -#if WITH_GTKMM_3_0 - Glib::RefPtr<Gtk::Adjustment> adj, -#else - Gtk::Adjustment *adj, -#endif - int digits, const SPAttributeEnum a, const char* tip_text) + Glib::RefPtr<Gtk::Adjustment> adj, + int digits, + const SPAttributeEnum a, + const char* tip_text) : AttrWidget(a, 0.0), _adjustment(adj) @@ -111,19 +103,12 @@ void SpinScale::set_appearance(const gchar* appearance) gimp_spin_scale_set_appearance(_spinscale, appearance); } -#if WITH_GTKMM_3_0 -const Glib::RefPtr<Gtk::Adjustment> SpinScale::get_adjustment() const -#else -const Gtk::Adjustment *SpinScale::get_adjustment() const -#endif +const decltype(SpinScale::_adjustment) SpinScale::get_adjustment() const { return _adjustment; } -#if WITH_GTKMM_3_0 -Glib::RefPtr<Gtk::Adjustment> SpinScale::get_adjustment() -#else -Gtk::Adjustment *SpinScale::get_adjustment() -#endif + +decltype(SpinScale::_adjustment) SpinScale::get_adjustment() { return _adjustment; } diff --git a/src/ui/widget/spin-scale.h b/src/ui/widget/spin-scale.h index 50e4fc953..d7030bed3 100644 --- a/src/ui/widget/spin-scale.h +++ b/src/ui/widget/spin-scale.h @@ -36,12 +36,8 @@ public: int digits, const SPAttributeEnum a = SP_ATTR_INVALID, const char* tip_text = NULL); SpinScale(const char* label, -#if WITH_GTKMM_3_0 - Glib::RefPtr<Gtk::Adjustment> adj, -#else - Gtk::Adjustment *adj, -#endif - int digits, const SPAttributeEnum a = SP_ATTR_INVALID, const char* tip_text = NULL); + Glib::RefPtr<Gtk::Adjustment> adj, + int digits, const SPAttributeEnum a = SP_ATTR_INVALID, const char* tip_text = NULL); virtual Glib::ustring get_as_attribute() const; virtual void set_from_attribute(SPObject*); @@ -52,23 +48,14 @@ public: void set_value(const double); void set_focuswidget(GtkWidget *widget); void set_appearance(const gchar* appearance); - -#if WITH_GTKMM_3_0 - const Glib::RefPtr<Gtk::Adjustment> get_adjustment() const; - Glib::RefPtr<Gtk::Adjustment> get_adjustment(); -#else - const Gtk::Adjustment *get_adjustment() const; - Gtk::Adjustment *get_adjustment(); -#endif private: -#if WITH_GTKMM_3_0 Glib::RefPtr<Gtk::Adjustment> _adjustment; -#else - Gtk::Adjustment *_adjustment; -#endif - GtkWidget *_spinscale; + +public: + const decltype(_adjustment) get_adjustment() const; + decltype(_adjustment) get_adjustment(); }; diff --git a/src/ui/widget/spin-slider.cpp b/src/ui/widget/spin-slider.cpp index 9b361ae78..f17b9b26c 100644 --- a/src/ui/widget/spin-slider.cpp +++ b/src/ui/widget/spin-slider.cpp @@ -20,11 +20,7 @@ namespace Widget { SpinSlider::SpinSlider(double value, double lower, double upper, double step_inc, double climb_rate, int digits, const SPAttributeEnum a, const char* tip_text) : AttrWidget(a, value), -#if WITH_GTKMM_3_0 _adjustment(Gtk::Adjustment::create(value, lower, upper, step_inc)), -#else - _adjustment(value, lower, upper, step_inc), -#endif _scale(_adjustment), _spin(_adjustment, climb_rate, digits) { signal_value_changed().connect(signal_attr_changed().make_slot()); @@ -43,11 +39,7 @@ SpinSlider::SpinSlider(double value, double lower, double upper, double step_inc Glib::ustring SpinSlider::get_as_attribute() const { -#if WITH_GTKMM_3_0 - const double val = _adjustment->get_value(); -#else - const double val = _adjustment.get_value(); -#endif + const auto val = _adjustment->get_value(); if(_spin.get_digits() == 0) return Glib::Ascii::dtostr((int)val); @@ -58,77 +50,43 @@ Glib::ustring SpinSlider::get_as_attribute() const void SpinSlider::set_from_attribute(SPObject* o) { const gchar* val = attribute_value(o); -#if WITH_GTKMM_3_0 if(val) _adjustment->set_value(Glib::Ascii::strtod(val)); else _adjustment->set_value(get_default()->as_double()); -#else - if(val) - _adjustment.set_value(Glib::Ascii::strtod(val)); - else - _adjustment.set_value(get_default()->as_double()); -#endif } Glib::SignalProxy0<void> SpinSlider::signal_value_changed() { -#if WITH_GTKMM_3_0 return _adjustment->signal_value_changed(); -#else - return _adjustment.signal_value_changed(); -#endif } double SpinSlider::get_value() const { -#if WITH_GTKMM_3_0 return _adjustment->get_value(); -#else - return _adjustment.get_value(); -#endif } void SpinSlider::set_value(const double val) { -#if WITH_GTKMM_3_0 _adjustment->set_value(val); -#else - _adjustment.set_value(val); -#endif } -#if WITH_GTKMM_3_0 -const Glib::RefPtr<Gtk::Adjustment> SpinSlider::get_adjustment() const -#else -const Gtk::Adjustment& SpinSlider::get_adjustment() const -#endif +const decltype(SpinSlider::_adjustment) SpinSlider::get_adjustment() const { return _adjustment; } -#if WITH_GTKMM_3_0 -Glib::RefPtr<Gtk::Adjustment> SpinSlider::get_adjustment() -#else -Gtk::Adjustment& SpinSlider::get_adjustment() -#endif + +decltype(SpinSlider::_adjustment) SpinSlider::get_adjustment() { return _adjustment; } -#if WITH_GTKMM_3_0 const Gtk::Scale& SpinSlider::get_scale() const -#else -const Gtk::HScale& SpinSlider::get_scale() const -#endif { return _scale; } -#if WITH_GTKMM_3_0 Gtk::Scale& SpinSlider::get_scale() -#else -Gtk::HScale& SpinSlider::get_scale() -#endif { return _scale; } @@ -157,15 +115,9 @@ DualSpinSlider::DualSpinSlider(double value, double lower, double upper, double { signal_value_changed().connect(signal_attr_changed().make_slot()); -#if WITH_GTKMM_3_0 _s1.get_adjustment()->signal_value_changed().connect(_signal_value_changed.make_slot()); _s2.get_adjustment()->signal_value_changed().connect(_signal_value_changed.make_slot()); _s1.get_adjustment()->signal_value_changed().connect(sigc::mem_fun(*this, &DualSpinSlider::update_linked)); -#else - _s1.get_adjustment().signal_value_changed().connect(_signal_value_changed.make_slot()); - _s2.get_adjustment().signal_value_changed().connect(_signal_value_changed.make_slot()); - _s1.get_adjustment().signal_value_changed().connect(sigc::mem_fun(*this, &DualSpinSlider::update_linked)); -#endif _link.signal_toggled().connect(sigc::mem_fun(*this, &DualSpinSlider::link_toggled)); Gtk::VBox* vb = Gtk::manage(new Gtk::VBox); @@ -202,13 +154,8 @@ void DualSpinSlider::set_from_attribute(SPObject* o) _link.set_active(toks[1] == 0); -#if WITH_GTKMM_3_0 _s1.get_adjustment()->set_value(v1); _s2.get_adjustment()->set_value(v2); -#else - _s1.get_adjustment().set_value(v1); - _s2.get_adjustment().set_value(v2); -#endif g_strfreev(toks); } diff --git a/src/ui/widget/spin-slider.h b/src/ui/widget/spin-slider.h index a5999f14f..5a29c1b67 100644 --- a/src/ui/widget/spin-slider.h +++ b/src/ui/widget/spin-slider.h @@ -42,17 +42,8 @@ public: double get_value() const; void set_value(const double); -#if WITH_GTKMM_3_0 - const Glib::RefPtr<Gtk::Adjustment> get_adjustment() const; - Glib::RefPtr<Gtk::Adjustment> get_adjustment(); const Gtk::Scale& get_scale() const; Gtk::Scale& get_scale(); -#else - const Gtk::Adjustment& get_adjustment() const; - Gtk::Adjustment& get_adjustment(); - const Gtk::HScale& get_scale() const; - Gtk::HScale& get_scale(); -#endif const Inkscape::UI::Widget::SpinButton& get_spin_button() const; Inkscape::UI::Widget::SpinButton& get_spin_button(); @@ -60,14 +51,13 @@ public: // Change the SpinSlider into a SpinButton with AttrWidget support) void remove_scale(); private: -#if WITH_GTKMM_3_0 Glib::RefPtr<Gtk::Adjustment> _adjustment; Gtk::Scale _scale; -#else - Gtk::Adjustment _adjustment; - Gtk::HScale _scale; -#endif Inkscape::UI::Widget::SpinButton _spin; + +public: + const decltype(_adjustment) get_adjustment() const; + decltype(_adjustment) get_adjustment(); }; /** diff --git a/src/ui/widget/spinbutton.cpp b/src/ui/widget/spinbutton.cpp index d7669d4e5..d1776e630 100644 --- a/src/ui/widget/spinbutton.cpp +++ b/src/ui/widget/spinbutton.cpp @@ -8,7 +8,7 @@ */ #ifdef HAVE_CONFIG_H -# include <config.h> +#include <config.h> #endif #include "spinbutton.h" diff --git a/src/ui/widget/spinbutton.h b/src/ui/widget/spinbutton.h index 30ffc7d77..ae571994b 100644 --- a/src/ui/widget/spinbutton.h +++ b/src/ui/widget/spinbutton.h @@ -36,11 +36,7 @@ public: { connect_signals(); }; -#if GTK_CHECK_VERSION(3,0,0) explicit SpinButton(Glib::RefPtr<Gtk::Adjustment>& adjustment, double climb_rate = 0.0, guint digits = 0) -#else - explicit SpinButton(Gtk::Adjustment& adjustment, double climb_rate = 0.0, guint digits = 0) -#endif : Gtk::SpinButton(adjustment, climb_rate, digits), _unit_menu(NULL), _unit_tracker(NULL), diff --git a/src/ui/widget/style-subject.cpp b/src/ui/widget/style-subject.cpp index da3bbcd20..a779e6feb 100644 --- a/src/ui/widget/style-subject.cpp +++ b/src/ui/widget/style-subject.cpp @@ -8,7 +8,6 @@ #include "ui/widget/style-subject.h" #include "desktop.h" -#include "sp-object.h" #include "xml/sp-css-attr.h" #include "desktop-style.h" @@ -55,11 +54,13 @@ Inkscape::Selection *StyleSubject::Selection::_getSelection() const { } } -std::vector<SPObject*> StyleSubject::Selection::list(){ +std::vector<SPObject*> StyleSubject::Selection::list() { Inkscape::Selection *selection = _getSelection(); - if(selection) - return selection->list(); - else return std::vector<SPObject*>(); + if(selection) { + return std::vector<SPObject *>(selection->objects().begin(), selection->objects().end()); + } + + return std::vector<SPObject*>(); } Geom::OptRect StyleSubject::Selection::getBounds(SPItem::BBoxType type) { diff --git a/src/ui/widget/style-swatch.cpp b/src/ui/widget/style-swatch.cpp index 188be705d..f8eac1c78 100644 --- a/src/ui/widget/style-swatch.cpp +++ b/src/ui/widget/style-swatch.cpp @@ -13,9 +13,6 @@ #include "style-swatch.h" -#include <cstring> -#include <string> - #include "widgets/spw-utilities.h" #include "ui/widget/color-preview.h" @@ -23,22 +20,15 @@ #include "sp-linear-gradient.h" #include "sp-radial-gradient.h" #include "sp-pattern.h" -#include "xml/repr.h" #include "xml/sp-css-attr.h" #include "widgets/widget-sizes.h" #include "util/units.h" #include "helper/action.h" -#include "helper/action-context.h" -#include "preferences.h" #include "inkscape.h" #include "verbs.h" #include <glibmm/i18n.h> -#if WITH_GTKMM_3_0 -# include <gtkmm/grid.h> -#else -# include <gtkmm/table.h> -#endif +#include <gtkmm/grid.h> enum { SS_FILL, @@ -117,11 +107,7 @@ StyleSwatch::StyleSwatch(SPCSSAttr *css, gchar const *main_tip) _css(NULL), _tool_obs(NULL), _style_obs(NULL), -#if WITH_GTKMM_3_0 _table(Gtk::manage(new Gtk::Grid())), -#else - _table(Gtk::manage(new Gtk::Table(2, 6))), -#endif _sw_unit(NULL) { set_name("StyleSwatch"); @@ -139,13 +125,8 @@ StyleSwatch::StyleSwatch(SPCSSAttr *css, gchar const *main_tip) _opacity_value.set_alignment(0.0, 0.5); _opacity_value.set_padding(0, 0); -#if WITH_GTKMM_3_0 _table->set_column_spacing(2); _table->set_row_spacing(0); -#else - _table->set_col_spacings(2); - _table->set_row_spacings(0); -#endif _stroke.pack_start(_place[SS_STROKE]); _stroke_width_place.add(_stroke_width); @@ -153,19 +134,11 @@ StyleSwatch::StyleSwatch(SPCSSAttr *css, gchar const *main_tip) _opacity_place.add(_opacity_value); -#if WITH_GTKMM_3_0 _table->attach(_label[SS_FILL], 0, 0, 1, 1); _table->attach(_label[SS_STROKE], 0, 1, 1, 1); _table->attach(_place[SS_FILL], 1, 0, 1, 1); _table->attach(_stroke, 1, 1, 1, 1); _table->attach(_opacity_place, 2, 0, 1, 2); -#else - _table->attach(_label[SS_FILL], 0,1, 0,1, Gtk::FILL, Gtk::SHRINK); - _table->attach(_label[SS_STROKE], 0,1, 1,2, Gtk::FILL, Gtk::SHRINK); - _table->attach(_place[SS_FILL], 1,2, 0,1); - _table->attach(_stroke, 1,2, 1,2); - _table->attach(_opacity_place, 2,3, 0,2, Gtk::SHRINK, Gtk::SHRINK); -#endif _swatch.add(*_table); pack_start(_swatch, true, true, 0); diff --git a/src/ui/widget/style-swatch.h b/src/ui/widget/style-swatch.h index 0016e0256..81a907d16 100644 --- a/src/ui/widget/style-swatch.h +++ b/src/ui/widget/style-swatch.h @@ -29,11 +29,7 @@ class SPStyle; class SPCSSAttr; namespace Gtk { -#if WITH_GTKMM_3_0 class Grid; -#else -class Table; -#endif } namespace Inkscape { @@ -75,11 +71,7 @@ private: Gtk::EventBox _swatch; -#if WITH_GTKMM_3_0 Gtk::Grid *_table; -#else - Gtk::Table *_table; -#endif Gtk::Label _label[2]; Gtk::EventBox _place[2]; diff --git a/src/ui/widget/tolerance-slider.cpp b/src/ui/widget/tolerance-slider.cpp index ced811c57..dea14585d 100644 --- a/src/ui/widget/tolerance-slider.cpp +++ b/src/ui/widget/tolerance-slider.cpp @@ -9,7 +9,7 @@ */ #ifdef HAVE_CONFIG_H -# include <config.h> +#include <config.h> #endif #include <gtkmm/adjustment.h> @@ -76,12 +76,8 @@ void ToleranceSlider::init (const Glib::ustring& label1, const Glib::ustring& la // align the label with the checkbox text above by indenting 22 px. _hbox->pack_start(*theLabel1, Gtk::PACK_EXPAND_WIDGET, 22); -#if WITH_GTKMM_3_0 _hscale = Gtk::manage(new Gtk::Scale(Gtk::ORIENTATION_HORIZONTAL)); _hscale->set_range(1.0, 51.0); -#else - _hscale = Gtk::manage (new Gtk::HScale (1.0, 51, 1.0)); -#endif theLabel1->set_mnemonic_widget (*_hscale); _hscale->set_draw_value (true); @@ -121,11 +117,7 @@ void ToleranceSlider::init (const Glib::ustring& label1, const Glib::ustring& la void ToleranceSlider::setValue (double val) { -#if WITH_GTKMM_3_0 - Glib::RefPtr<Gtk::Adjustment> adj = _hscale->get_adjustment(); -#else - Gtk::Adjustment *adj = _hscale->get_adjustment(); -#endif + auto adj = _hscale->get_adjustment(); adj->set_lower (1.0); adj->set_upper (51.0); diff --git a/src/ui/widget/tolerance-slider.h b/src/ui/widget/tolerance-slider.h index 7ae8e4712..3d2548ebe 100644 --- a/src/ui/widget/tolerance-slider.h +++ b/src/ui/widget/tolerance-slider.h @@ -14,11 +14,7 @@ namespace Gtk { class RadioButton; -#if WITH_GTKMM_3_0 class Scale; -#else -class HScale; -#endif } namespace Inkscape { @@ -60,13 +56,7 @@ protected: void on_toggled(); void update (double val); Gtk::HBox *_hbox; - -#if WITH_GTKMM_3_0 Gtk::Scale *_hscale; -#else - Gtk::HScale *_hscale; -#endif - Gtk::RadioButtonGroup _radio_button_group; Gtk::RadioButton *_button1; Gtk::RadioButton *_button2; diff --git a/src/uri-references.cpp b/src/uri-references.cpp index db46a156f..07f2d168b 100644 --- a/src/uri-references.cpp +++ b/src/uri-references.cpp @@ -12,7 +12,6 @@ #include <iostream> #include <cstring> -#include <string> #include "document.h" #include "sp-object.h" @@ -21,7 +20,6 @@ #include "extract-uri.h" #include "sp-tag-use.h" #include <glibmm/miscutils.h> -#include <sigc++/functors/mem_fun.h> namespace Inkscape { @@ -76,10 +74,11 @@ bool URIReference::_acceptObject(SPObject *obj) const std::vector<int> positions; while (owner->cloned) { int position = 0; - SPObject *c = owner->parent->firstChild(); - while (c != owner && dynamic_cast<SPObject *>(c)) { + for (auto &child: owner->parent->children) { + if(&child == owner) { + break; + } position++; - c = c->next; } positions.push_back(position); owner = owner->parent; @@ -92,7 +91,7 @@ bool URIReference::_acceptObject(SPObject *obj) const g_warning("cloned object with no known type\n"); return false; } - for (int i = positions.size() - 2; i >= 0; i--) + for (int i = (int) (positions.size() - 2); i >= 0; i--) owner = owner->childList(false)[positions[i]]; } // once we have the "original" object (hopefully) we look at who is referencing it diff --git a/src/uri-test.h b/src/uri-test.h deleted file mode 100644 index 2a4cdab46..000000000 --- a/src/uri-test.h +++ /dev/null @@ -1,90 +0,0 @@ - -#ifndef SEEN_URI_TEST_H -#define SEEN_URI_TEST_H -/* - * Test uri.h - * - * Written to aid with refactoring the uri handling to support fullPath - * and data URIs and also cover code which wasn't before tested. - * - * Copyright 2014 (c) BasisTech Boston - * - */ -#include <cxxtest/TestSuite.h> - -#include "uri.h" - -using Inkscape::URI; - -class URITest : public CxxTest::TestSuite -{ -public: - void stringTest( std::string result, std::string expected ) - { - if ( !result.empty() && !expected.empty() ) { - TS_ASSERT_EQUALS( result, expected ); - } else if ( result.empty() && !expected.empty() ) { - TS_FAIL( std::string("Expected (") + expected + "), found null" ); - } else if ( !result.empty() && expected.empty() ) { - TS_FAIL( std::string("Expected null, found (") + result + ")" ); - } - } - - std::string ValueOrEmpty(const char* s) { - return s == NULL ? std::string() : s; - } - - void toStringTest( std::string uri, std::string expected ) { - stringTest( URI(uri.c_str()).toString(), expected ); - } - void pathTest( std::string uri, std::string expected ) { - stringTest( ValueOrEmpty(URI(uri.c_str()).getPath()), expected ); - } - - void testToString() - { - char const* cases[][2] = { - { "foo", "foo" }, - { "#foo", "#foo" }, - { "blah.svg#h", "blah.svg#h" }, - //{ "data:data", "data:data" }, - }; - - for ( size_t i = 0; i < G_N_ELEMENTS(cases); i++ ) { - toStringTest( std::string(cases[i][0]), std::string(cases[i][1]) ); - } - } - - void testPath() - { - char const* cases[][2] = { - { "foo.svg", "foo.svg" }, - { "foo.svg#bar", "foo.svg" }, - { "#bar", NULL }, - { "data:data", NULL }, - }; - - for ( size_t i = 0; i < G_N_ELEMENTS(cases); i++ ) { - pathTest( ValueOrEmpty(cases[i][0]), ValueOrEmpty(cases[i][1]) ); - } - } - void testFullPath() { - std::ofstream fhl("/tmp/cxxtest-uri.svg", std::ofstream::out); - stringTest( URI("cxxtest-uri.svg").getFullPath("/tmp"), std::string("/tmp/cxxtest-uri.svg") ); - stringTest( URI("cxxtest-uri.svg").getFullPath("/usr/../tmp"), std::string("/tmp/cxxtest-uri.svg") ); - } - -}; - -#endif // SEEN_URI_TEST_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/uri.cpp b/src/uri.cpp index 49bdab63c..f2578b989 100644 --- a/src/uri.cpp +++ b/src/uri.cpp @@ -10,7 +10,6 @@ #include <glib.h> #include "uri.h" -#include <string> #include <glibmm/ustring.h> #include <glibmm/miscutils.h> diff --git a/src/util/Makefile_insert b/src/util/Makefile_insert deleted file mode 100644 index 2a778e660..000000000 --- a/src/util/Makefile_insert +++ /dev/null @@ -1,49 +0,0 @@ -## Makefile.am fragment sourced by src/Makefile.am. - -util/all: util/libutil.a - -util/clean: - rm -f util/libutil.a $(util_libutil_a_OBJECTS) - -util_libutil_a_SOURCES = \ - util/ziptool.h \ - util/ziptool.cpp \ - util/accumulators.h \ - util/compose.hpp \ - util/copy.h \ - util/enums.h \ - util/ege-appear-time-tracker.cpp \ - util/ege-appear-time-tracker.h \ - util/ege-tags.h \ - util/ege-tags.cpp \ - util/expression-evaluator.h \ - util/expression-evaluator.cpp \ - util/filter-list.h \ - util/find-if-before.h \ - util/find-last-if.h \ - util/fixed_point.h \ - util/format.h \ - util/forward-pointer-iterator.h \ - util/function.h \ - util/list.h \ - util/list-container.h \ - util/list-copy.h \ - util/longest-common-suffix.h \ - util/map-list.h \ - util/reference.h \ - util/reverse-list.h \ - util/share.h \ - util/share.cpp \ - util/signal-blocker.h \ - util/tuple.h \ - util/ucompose.hpp \ - util/units.cpp \ - util/units.h \ - util/unordered-containers.h - -# ###################### -# ### CxxTest stuff #### -# ###################### - -CXXTEST_TESTSUITES += \ - $(srcdir)/util/list-container-test.h diff --git a/src/util/unordered-containers.h b/src/util/unordered-containers.h index b92f2e7ea..0bda8191f 100644 --- a/src/util/unordered-containers.h +++ b/src/util/unordered-containers.h @@ -20,12 +20,11 @@ #ifndef DOXYGEN_SHOULD_SKIP_THIS -#if defined(HAVE_NATIVE_UNORDERED_SET) -# include <unordered_set> -# include <unordered_map> -# define INK_UNORDERED_SET std::unordered_set -# define INK_UNORDERED_MAP std::unordered_map -# define INK_HASH std::hash +#include <unordered_set> +#include <unordered_map> +#define INK_UNORDERED_SET std::unordered_set +#define INK_UNORDERED_MAP std::unordered_map +#define INK_HASH std::hash namespace std { template <> @@ -36,41 +35,6 @@ struct hash<Glib::ustring> : public std::unary_function<Glib::ustring, std::size }; } // namespace std -#elif defined(HAVE_TR1_UNORDERED_SET) -# include <tr1/unordered_set> -# include <tr1/unordered_map> -# define INK_UNORDERED_SET std::tr1::unordered_set -# define INK_UNORDERED_MAP std::tr1::unordered_map -# define INK_HASH std::tr1::hash - -namespace std { -namespace tr1 { -template <> -struct hash<Glib::ustring> : public std::unary_function<Glib::ustring, std::size_t> { - std::size_t operator()(Glib::ustring const &s) const { - return hash<std::string>()(s.raw()); - } -}; -} // namespace tr1 -} // namespace std - -#elif defined(HAVE_BOOST_UNORDERED_SET) -# include <boost/unordered_set.hpp> -# include <boost/unordered_map.hpp> -# define INK_UNORDERED_SET boost::unordered_set -# define INK_UNORDERED_MAP boost::unordered_map -# define INK_HASH boost::hash - -namespace boost { -template <> -struct hash<Glib::ustring> : public std::unary_function<Glib::ustring, std::size_t> { - std::size_t operator()(Glib::ustring const &s) const { - return hash<std::string>()(s.raw()); - } -}; -} // namespace boost -#endif - #else /// Name (with namespace) of the unordered set template. #define INK_UNORDERED_SET diff --git a/src/vanishing-point.cpp b/src/vanishing-point.cpp index 32ccbad93..d849b35d9 100644 --- a/src/vanishing-point.cpp +++ b/src/vanishing-point.cpp @@ -21,12 +21,10 @@ #include "display/sp-canvas-item.h" #include "display/sp-ctrlline.h" #include "ui/tools/tool-base.h" -#include "xml/repr.h" #include "perspective-line.h" #include "ui/shape-editor.h" #include "snap.h" #include "sp-namedview.h" -#include "ui/control-manager.h" #include "document-undo.h" #include "verbs.h" @@ -258,8 +256,8 @@ VanishingPoint::set_pos(Proj::Pt2 const &pt) { std::list<SPBox3D *> VanishingPoint::selectedBoxes(Inkscape::Selection *sel) { std::list<SPBox3D *> sel_boxes; - std::vector<SPItem*> itemlist=sel->itemList(); - for (std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();++i) { + auto itemlist= sel->items(); + for (auto i=itemlist.begin();i!=itemlist.end();++i) { SPItem *item = *i; SPBox3D *box = dynamic_cast<SPBox3D *>(item); if (box && this->hasBox(box)) { @@ -397,8 +395,8 @@ VPDragger::VPsOfSelectedBoxes() { VanishingPoint *vp; // FIXME: Should we take the selection from the parent VPDrag? I guess it shouldn't make a difference. Inkscape::Selection *sel = SP_ACTIVE_DESKTOP->getSelection(); - std::vector<SPItem*> itemlist=sel->itemList(); - for (std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();++i) { + auto itemlist= sel->items(); + for (auto i=itemlist.begin();i!=itemlist.end();++i) { SPItem *item = *i; SPBox3D *box = dynamic_cast<SPBox3D *>(item); if (box) { @@ -575,8 +573,8 @@ VPDrag::updateDraggers () g_return_if_fail (this->selection != NULL); - std::vector<SPItem*> itemlist=this->selection->itemList(); - for (std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();++i) { + auto itemlist= this->selection->items(); + for (auto i=itemlist.begin();i!=itemlist.end();++i) { SPItem *item = *i; SPBox3D *box = dynamic_cast<SPBox3D *>(item); if (box) { @@ -607,8 +605,8 @@ VPDrag::updateLines () g_return_if_fail (this->selection != NULL); - std::vector<SPItem*> itemlist=this->selection->itemList(); - for (std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();++i) { + auto itemlist= this->selection->items(); + for (auto i=itemlist.begin();i!=itemlist.end();++i) { SPItem *item = *i; SPBox3D *box = dynamic_cast<SPBox3D *>(item); if (box) { @@ -625,11 +623,11 @@ VPDrag::updateBoxHandles () // FIXME: Is there a way to update the knots without accessing the // (previously) statically linked function KnotHolder::update_knots? - std::vector<SPItem*> sel = selection->itemList(); + auto sel = selection->items(); if (sel.empty()) return; // no selection - if (sel.size() > 1) { + if (boost::distance(sel) > 1) { // Currently we only show handles if a single box is selected return; } diff --git a/src/verbs-test.h b/src/verbs-test.h deleted file mode 100644 index 04a0b80c0..000000000 --- a/src/verbs-test.h +++ /dev/null @@ -1,86 +0,0 @@ - - -#include <cxxtest/TestSuite.h> - -#include "verbs.h" - -class VerbsTest : public CxxTest::TestSuite -{ -public: - - class TestHook : public Inkscape::Verb { - public: - static int getInternalTableSize() { return _getBaseListSize(); } - - private: - TestHook(); - }; - - void testEnumLength() - { - TS_ASSERT_DIFFERS( 0, static_cast<int>(SP_VERB_LAST) ); - TS_ASSERT_EQUALS( static_cast<int>(SP_VERB_LAST) + 1, TestHook::getInternalTableSize() ); - } - - void testEnumFixed() - { - TS_ASSERT_EQUALS( 0, static_cast<int>(SP_VERB_INVALID) ); - TS_ASSERT_EQUALS( 1, static_cast<int>(SP_VERB_NONE) ); - - TS_ASSERT_DIFFERS( 0, static_cast<int>(SP_VERB_LAST) ); - TS_ASSERT_DIFFERS( 1, static_cast<int>(SP_VERB_LAST) ); - } - - void testFetch() - { - for ( int i = 0; i < static_cast<int>(SP_VERB_LAST); i++ ) - { - char tmp[16]; - snprintf( tmp, sizeof(tmp), "Verb# %d", i ); - tmp[sizeof(tmp)-1] = 0; - std::string descr(tmp); - - Inkscape::Verb* verb = Inkscape::Verb::get(i); - TSM_ASSERT( descr, verb ); - if ( verb ) - { - TSM_ASSERT_EQUALS( descr, verb->get_code(), static_cast<unsigned int>(i) ); - - if ( i != static_cast<int>(SP_VERB_INVALID) ) - { - TSM_ASSERT( descr, verb->get_id() ); - TSM_ASSERT( descr, verb->get_name() ); - - Inkscape::Verb* bounced = verb->getbyid( verb->get_id() ); - // TODO - put this back once verbs are fixed - //TSM_ASSERT( descr, bounced ); - if ( bounced ) - { - TSM_ASSERT_EQUALS( descr, bounced->get_code(), static_cast<unsigned int>(i) ); - } - else - { - TS_FAIL( std::string("Unable to getbyid() for ") + descr + std::string(" ID: '") + std::string(verb->get_id()) + std::string("'") ); - } - } - else - { - TSM_ASSERT( std::string("SP_VERB_INVALID"), !verb->get_id() ); - TSM_ASSERT( std::string("SP_VERB_INVALID"), !verb->get_name() ); - } - } - } - } - -}; - -/* - 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/verbs.cpp b/src/verbs.cpp index 299cfe8e7..5130f1701 100644 --- a/src/verbs.cpp +++ b/src/verbs.cpp @@ -26,7 +26,7 @@ #ifdef HAVE_CONFIG_H -# include "config.h" +#include <config.h> #endif #include <cstring> @@ -45,11 +45,9 @@ #include "document.h" #include "ui/tools/freehand-base.h" #include "extension/effect.h" -#include "ui/tools/tool-base.h" #include "file.h" #include "gradient-drag.h" #include "helper/action.h" -#include "helper/action-context.h" #include "help.h" #include "inkscape.h" #include "ui/interface.h" @@ -57,7 +55,6 @@ #include "layer-manager.h" #include "message-stack.h" #include "path-chemistry.h" -#include "preferences.h" #include "ui/tools/select-tool.h" #include "selection-chemistry.h" #include "seltrans.h" @@ -87,9 +84,6 @@ #include "ui/dialog/spellcheck.h" #include "ui/icon-names.h" #include "ui/tools/node-tool.h" -#include "selection.h" - -#include <gtk/gtk.h> using Inkscape::DocumentUndo; using Inkscape::UI::Dialog::ActionAlign; @@ -1207,6 +1201,9 @@ void SelectionVerb::perform(SPAction *action, void *data) case SP_VERB_SELECTION_OUTLINE: sp_selected_path_outline(dt); break; + case SP_VERB_SELECTION_OUTLINE_LEGACY: + sp_selected_path_outline(dt, true); + break; case SP_VERB_SELECTION_SIMPLIFY: sp_selected_path_simplify(dt); break; @@ -1520,7 +1517,7 @@ void ObjectVerb::perform( SPAction *action, void *data) sp_selection_rotate_90(dt, true); break; case SP_VERB_OBJECT_FLATTEN: - sp_selection_remove_transform(dt); + sp_object_set_remove_transform(dt); break; case SP_VERB_OBJECT_FLOW_TEXT: text_flow_into_shape(); @@ -1532,12 +1529,12 @@ void ObjectVerb::perform( SPAction *action, void *data) flowtext_to_text(); break; case SP_VERB_OBJECT_FLIP_HORIZONTAL: - sp_selection_scale_relative(sel, center, Geom::Scale(-1.0, 1.0)); + sp_object_set_scale_relative(sel, center, Geom::Scale(-1.0, 1.0)); DocumentUndo::done(dt->getDocument(), SP_VERB_OBJECT_FLIP_HORIZONTAL, _("Flip horizontally")); break; case SP_VERB_OBJECT_FLIP_VERTICAL: - sp_selection_scale_relative(sel, center, Geom::Scale(1.0, -1.0)); + sp_object_set_scale_relative(sel, center, Geom::Scale(1.0, -1.0)); DocumentUndo::done(dt->getDocument(), SP_VERB_OBJECT_FLIP_VERTICAL, _("Flip vertically")); break; @@ -1845,7 +1842,7 @@ void ZoomVerb::perform(SPAction *action, void *data) Inkscape::Preferences *prefs = Inkscape::Preferences::get(); gdouble zoom_inc = - prefs->getDoubleLimited( "/options/zoomincrement/value", 1.414213562, 1.01, 10 ); + prefs->getDoubleLimited( "/options/zoomincrement/value", M_SQRT2, 1.01, 10 ); double zcorr = 1.0; Glib::ustring abbr = prefs->getString("/options/zoomcorrection/unit"); @@ -2618,6 +2615,8 @@ Verb *Verb::_base_verbs[] = { INKSCAPE_ICON("path-offset-linked")), new SelectionVerb(SP_VERB_SELECTION_OUTLINE, "StrokeToPath", N_("_Stroke to Path"), N_("Convert selected object's stroke to paths"), INKSCAPE_ICON("stroke-to-path")), + new SelectionVerb(SP_VERB_SELECTION_OUTLINE_LEGACY, "StrokeToPathLegacy", N_("_Stroke to Path Legacy"), + N_("Convert selected object's stroke to paths legacy mode"), INKSCAPE_ICON("stroke-to-path")), new SelectionVerb(SP_VERB_SELECTION_SIMPLIFY, "SelectionSimplify", N_("Si_mplify"), N_("Simplify selected paths (remove extra nodes)"), INKSCAPE_ICON("path-simplify")), new SelectionVerb(SP_VERB_SELECTION_REVERSE, "SelectionReverse", N_("_Reverse"), diff --git a/src/verbs.h b/src/verbs.h index ffb9b23d8..16f88c408 100644 --- a/src/verbs.h +++ b/src/verbs.h @@ -135,6 +135,7 @@ enum { SP_VERB_SELECTION_DYNAMIC_OFFSET, SP_VERB_SELECTION_LINKED_OFFSET, SP_VERB_SELECTION_OUTLINE, + SP_VERB_SELECTION_OUTLINE_LEGACY, SP_VERB_SELECTION_SIMPLIFY, SP_VERB_SELECTION_REVERSE, diff --git a/src/viewbox.cpp b/src/viewbox.cpp index e1da23efa..1b50fe71c 100644 --- a/src/viewbox.cpp +++ b/src/viewbox.cpp @@ -15,7 +15,6 @@ #include <2geom/transforms.h> #include "viewbox.h" -#include "attributes.h" #include "enums.h" #include "sp-item.h" diff --git a/src/widgets/CMakeLists.txt b/src/widgets/CMakeLists.txt index 225afe317..c87fa1500 100644 --- a/src/widgets/CMakeLists.txt +++ b/src/widgets/CMakeLists.txt @@ -1,31 +1,20 @@ +add_subdirectory(gimp) set(widgets_SRC + arc-toolbar.cpp + box3d-toolbar.cpp button.cpp - arc-toolbar.cpp - box3d-toolbar.cpp - calligraphy-toolbar.cpp - connector-toolbar.cpp - dropper-toolbar.cpp - eraser-toolbar.cpp - lpe-toolbar.cpp - measure-toolbar.cpp - mesh-toolbar.cpp - node-toolbar.cpp - pencil-toolbar.cpp - rect-toolbar.cpp - spiral-toolbar.cpp - spray-toolbar.cpp - star-toolbar.cpp - text-toolbar.cpp - tweak-toolbar.cpp - zoom-toolbar.cpp + calligraphy-toolbar.cpp + connector-toolbar.cpp dash-selector.cpp desktop-widget.cpp + dropper-toolbar.cpp eek-preview.cpp + ege-adjustment-action.cpp + ege-output-action.cpp ege-paint-def.cpp - ege-adjustment-action.cpp - ege-output-action.cpp - ege-select-one-action.cpp + ege-select-one-action.cpp + eraser-toolbar.cpp fill-style.cpp font-selector.cpp gradient-image.cpp @@ -33,10 +22,19 @@ set(widgets_SRC gradient-toolbar.cpp gradient-vector.cpp icon.cpp + image-menu-item.c ink-action.cpp ink-comboboxentry-action.cpp + ink-radio-action.cpp + ink-toggle-action.cpp + ink-tool-menu-action.cpp + lpe-toolbar.cpp + measure-toolbar.cpp + mesh-toolbar.cpp + node-toolbar.cpp paint-selector.cpp - ruler.cpp + pencil-toolbar.cpp + rect-toolbar.cpp select-toolbar.cpp sp-attribute-widget.cpp sp-color-selector.cpp @@ -45,41 +43,35 @@ set(widgets_SRC sp-xmlview-content.cpp sp-xmlview-tree.cpp spinbutton-events.cpp + spiral-toolbar.cpp + spray-toolbar.cpp spw-utilities.cpp + star-toolbar.cpp stroke-marker-selector.cpp stroke-style.cpp swatch-selector.cpp + text-toolbar.cpp toolbox.cpp + tweak-toolbar.cpp + zoom-toolbar.cpp # ------- # Headers + arc-toolbar.h + box3d-toolbar.h button.h - arc-toolbar.h - box3d-toolbar.h - calligraphy-toolbar.h - connector-toolbar.h - dropper-toolbar.h - eraser-toolbar.h - lpe-toolbar.h - measure-toolbar.h - mesh-toolbar.h - node-toolbar.h - pencil-toolbar.h - rect-toolbar.h - spiral-toolbar.h - spray-toolbar.h - star-toolbar.h - text-toolbar.h - tweak-toolbar.h - zoom-toolbar.h + calligraphy-toolbar.h + connector-toolbar.h dash-selector.h desktop-widget.h + dropper-toolbar.h eek-preview.h + ege-adjustment-action.h + ege-output-action.h ege-paint-def.h - ege-adjustment-action.h - ege-output-action.h - ege-select-one-action.h + ege-select-one-action.h + eraser-toolbar.h fill-n-stroke-factory.h fill-style.h font-selector.h @@ -88,10 +80,19 @@ set(widgets_SRC gradient-toolbar.h gradient-vector.h icon.h - ink-action.h - ink-comboboxentry-action.h + image-menu-item.h + ink-action.h + ink-comboboxentry-action.h + ink-radio-action.h + ink-toggle-action.h + ink-tool-menu-action.h + lpe-toolbar.h + measure-toolbar.h + mesh-toolbar.h + node-toolbar.h paint-selector.h - ruler.h + pencil-toolbar.h + rect-toolbar.h select-toolbar.h sp-attribute-widget.h sp-color-selector.h @@ -100,30 +101,29 @@ set(widgets_SRC sp-xmlview-content.h sp-xmlview-tree.h spinbutton-events.h + spiral-toolbar.h + spray-toolbar.h spw-utilities.h + star-toolbar.h stroke-marker-selector.h stroke-style.h swatch-selector.h + text-toolbar.h toolbox.h + tweak-toolbar.h widget-sizes.h + zoom-toolbar.h ) -if(${WITH_GTK3_EXPERIMENTAL}) - set(image_menu_item_SRC image-menu-item.h image-menu-item.c) - add_inkscape_source("${image_menu_item_SRC}") -endif() - # add_inkscape_lib(widgets_LIB "${widgets_SRC}") add_inkscape_source("${widgets_SRC}") -set ( widgets_paintbucket_SRC - paintbucket-toolbar.cpp - paintbucket-toolbar.h +set(widgets_paintbucket_SRC + paintbucket-toolbar.cpp + paintbucket-toolbar.h ) if ("${HAVE_POTRACE}") add_inkscape_source("${widgets_paintbucket_SRC}") endif() - - diff --git a/src/widgets/Makefile_insert b/src/widgets/Makefile_insert deleted file mode 100644 index c9f04de14..000000000 --- a/src/widgets/Makefile_insert +++ /dev/null @@ -1,123 +0,0 @@ -## Makefile.am fragment sourced by src/Makefile.am. - -if WITH_GTKMM_3_0 -ink_common_sources += \ - widgets/image-menu-item.c \ - widgets/image-menu-item.h -endif - -ink_common_sources += \ - widgets/arc-toolbar.cpp \ - widgets/arc-toolbar.h \ - widgets/box3d-toolbar.cpp \ - widgets/box3d-toolbar.h \ - widgets/button.cpp \ - widgets/button.h \ - widgets/calligraphy-toolbar.cpp \ - widgets/calligraphy-toolbar.h \ - widgets/connector-toolbar.cpp \ - widgets/connector-toolbar.h \ - widgets/dash-selector.cpp \ - widgets/dash-selector.h \ - widgets/desktop-widget.cpp \ - widgets/desktop-widget.h \ - widgets/dropper-toolbar.cpp \ - widgets/dropper-toolbar.h \ - widgets/eek-preview.cpp \ - widgets/eek-preview.h \ - widgets/ege-adjustment-action.cpp \ - widgets/ege-adjustment-action.h \ - widgets/ege-paint-def.cpp \ - widgets/ege-paint-def.h \ - widgets/ege-output-action.cpp \ - widgets/ege-output-action.h \ - widgets/ege-select-one-action.cpp \ - widgets/ege-select-one-action.h \ - widgets/eraser-toolbar.cpp \ - widgets/eraser-toolbar.h \ - widgets/fill-style.cpp \ - widgets/fill-style.h \ - widgets/fill-n-stroke-factory.h \ - widgets/font-selector.cpp \ - widgets/font-selector.h \ - widgets/gradient-image.cpp \ - widgets/gradient-image.h \ - widgets/gradient-selector.cpp \ - widgets/gradient-selector.h \ - widgets/gradient-toolbar.cpp \ - widgets/gradient-toolbar.h \ - widgets/gradient-vector.cpp \ - widgets/gradient-vector.h \ - widgets/icon.cpp \ - widgets/icon.h \ - widgets/ink-action.cpp \ - widgets/ink-action.h \ - widgets/ink-comboboxentry-action.cpp \ - widgets/ink-comboboxentry-action.h \ - widgets/lpe-toolbar.cpp \ - widgets/lpe-toolbar.h \ - widgets/measure-toolbar.cpp \ - widgets/measure-toolbar.h \ - widgets/mesh-toolbar.cpp \ - widgets/mesh-toolbar.h \ - widgets/node-toolbar.cpp \ - widgets/node-toolbar.h \ - widgets/paint-selector.cpp \ - widgets/paint-selector.h \ - widgets/pencil-toolbar.cpp \ - widgets/pencil-toolbar.h \ - widgets/rect-toolbar.cpp \ - widgets/rect-toolbar.h \ - widgets/ruler.cpp \ - widgets/ruler.h \ - widgets/select-toolbar.cpp \ - widgets/select-toolbar.h \ - widgets/spray-toolbar.cpp \ - widgets/spray-toolbar.h \ - widgets/spiral-toolbar.cpp \ - widgets/spiral-toolbar.h \ - widgets/sp-attribute-widget.cpp \ - widgets/sp-attribute-widget.h \ - widgets/sp-color-selector.cpp \ - widgets/sp-color-selector.h \ - widgets/spinbutton-events.cpp \ - widgets/spinbutton-events.h \ - widgets/sp-widget.cpp \ - widgets/sp-widget.h \ - widgets/spw-utilities.cpp \ - widgets/spw-utilities.h \ - widgets/sp-xmlview-attr-list.cpp \ - widgets/sp-xmlview-attr-list.h \ - widgets/sp-xmlview-content.cpp \ - widgets/sp-xmlview-content.h \ - widgets/sp-xmlview-tree.cpp \ - widgets/sp-xmlview-tree.h \ - widgets/star-toolbar.cpp \ - widgets/star-toolbar.h \ - widgets/stroke-marker-selector.cpp \ - widgets/stroke-marker-selector.h \ - widgets/stroke-style.cpp \ - widgets/stroke-style.h \ - widgets/swatch-selector.cpp \ - widgets/swatch-selector.h \ - widgets/text-toolbar.cpp \ - widgets/text-toolbar.h \ - widgets/toolbox.cpp \ - widgets/toolbox.h \ - widgets/tweak-toolbar.cpp \ - widgets/tweak-toolbar.h \ - widgets/widget-sizes.h \ - widgets/zoom-toolbar.cpp \ - widgets/zoom-toolbar.h \ - widgets/widget-sizes.h - -if HAVE_POTRACE - -ink_common_sources += \ - widgets/paintbucket-toolbar.cpp \ - widgets/paintbucket-toolbar.h - -endif - -widgets/button.$(OBJEXT): helper/sp-marshal.h -widgets/menu.$(OBJEXT): helper/sp-marshal.h diff --git a/src/widgets/arc-toolbar.cpp b/src/widgets/arc-toolbar.cpp index 7b872e8b1..9b408a7b2 100644 --- a/src/widgets/arc-toolbar.cpp +++ b/src/widgets/arc-toolbar.cpp @@ -25,7 +25,7 @@ */ #ifdef HAVE_CONFIG_H -# include "config.h" +#include <config.h> #endif #include <glibmm/i18n.h> @@ -37,9 +37,9 @@ #include "widgets/ege-adjustment-action.h" #include "widgets/ege-output-action.h" #include "widgets/ege-select-one-action.h" -#include "widgets/ink-action.h" +#include "ink-action.h" +#include "ink-radio-action.h" #include "mod360.h" -#include "preferences.h" #include "selection.h" #include "sp-ellipse.h" #include "toolbox.h" @@ -49,7 +49,6 @@ #include "verbs.h" #include "widgets/spinbutton-events.h" #include "xml/node-event-vector.h" -#include "xml/repr.h" using Inkscape::UI::UXManager; using Inkscape::DocumentUndo; @@ -97,8 +96,8 @@ sp_arctb_startend_value_changed(GtkAdjustment *adj, GObject *tbl, gchar const *v gchar* namespaced_name = g_strconcat("sodipodi:", value_name, NULL); bool modmade = false; - std::vector<SPItem*> itemlist=desktop->getSelection()->itemList(); - for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();++i){ + auto itemlist= desktop->getSelection()->items(); + for(auto i=itemlist.begin();i!=itemlist.end();++i){ SPItem *item = *i; if (SP_IS_GENERICELLIPSE(item)) { @@ -163,8 +162,8 @@ static void sp_arctb_open_state_changed( EgeSelectOneAction *act, GObject *tbl ) bool modmade = false; if ( ege_select_one_action_get_active(act) != 0 ) { - std::vector<SPItem*> itemlist=desktop->getSelection()->itemList(); - for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();++i){ + auto itemlist= desktop->getSelection()->items(); + for(auto i=itemlist.begin();i!=itemlist.end();++i){ SPItem *item = *i; if (SP_IS_GENERICELLIPSE(item)) { Inkscape::XML::Node *repr = item->getRepr(); @@ -174,8 +173,8 @@ static void sp_arctb_open_state_changed( EgeSelectOneAction *act, GObject *tbl ) } } } else { - std::vector<SPItem*> itemlist=desktop->getSelection()->itemList(); - for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();++i){ + auto itemlist= desktop->getSelection()->items(); + for(auto i=itemlist.begin();i!=itemlist.end();++i){ SPItem *item = *i; if (SP_IS_GENERICELLIPSE(item)) { Inkscape::XML::Node *repr = item->getRepr(); @@ -264,8 +263,8 @@ static void sp_arc_toolbox_selection_changed(Inkscape::Selection *selection, GOb purge_repr_listener( tbl, tbl ); - std::vector<SPItem*> itemlist=selection->itemList(); - for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();++i){ + auto itemlist= selection->items(); + for(auto i=itemlist.begin();i!=itemlist.end();++i){ SPItem *item = *i; if (SP_IS_GENERICELLIPSE(item)) { n_selected++; diff --git a/src/widgets/box3d-toolbar.cpp b/src/widgets/box3d-toolbar.cpp index 31b897ced..95de28cf2 100644 --- a/src/widgets/box3d-toolbar.cpp +++ b/src/widgets/box3d-toolbar.cpp @@ -25,7 +25,7 @@ */ #ifdef HAVE_CONFIG_H -# include "config.h" +#include <config.h> #endif #include <glibmm/i18n.h> @@ -37,10 +37,9 @@ #include "document-undo.h" #include "document.h" #include "widgets/ege-adjustment-action.h" -#include "widgets/ink-action.h" +#include "widgets/ink-toggle-action.h" #include "inkscape.h" #include "persp3d.h" -#include "selection.h" #include "toolbox.h" #include "ui/icon-names.h" #include "ui/tools/box3d-tool.h" diff --git a/src/widgets/button.cpp b/src/widgets/button.cpp index 6ea8c1360..3f4f1207a 100644 --- a/src/widgets/button.cpp +++ b/src/widgets/button.cpp @@ -20,18 +20,9 @@ #include "shortcuts.h" #include "helper/action.h" -#include <gdk/gdkkeysyms.h> - static void sp_button_dispose(GObject *object); - -#if GTK_CHECK_VERSION(3, 0, 0) static void sp_button_get_preferred_width(GtkWidget *widget, gint *minimal_width, gint *natural_width); - static void sp_button_get_preferred_height(GtkWidget *widget, gint *minimal_height, gint *natural_height); -#else -static void sp_button_size_request(GtkWidget *widget, GtkRequisition *requisition); -#endif - static void sp_button_clicked(GtkButton *button); static void sp_button_perform_action(SPButton *button, gpointer data); static gint sp_button_process_event(SPButton *button, GdkEvent *event); @@ -50,12 +41,8 @@ static void sp_button_class_init(SPButtonClass *klass) GtkButtonClass *button_class = GTK_BUTTON_CLASS(klass); object_class->dispose = sp_button_dispose; -#if GTK_CHECK_VERSION(3, 0, 0) widget_class->get_preferred_width = sp_button_get_preferred_width; widget_class->get_preferred_height = sp_button_get_preferred_height; -#else - widget_class->size_request = sp_button_size_request; -#endif button_class->clicked = sp_button_clicked; } @@ -92,7 +79,6 @@ static void sp_button_dispose(GObject *object) (G_OBJECT_CLASS(sp_button_parent_class))->dispose(object); } -#if GTK_CHECK_VERSION(3, 0, 0) static void sp_button_get_preferred_width(GtkWidget *widget, gint *minimal_width, gint *natural_width) { GtkWidget *child = gtk_bin_get_child(GTK_BIN(widget)); @@ -136,23 +122,6 @@ static void sp_button_get_preferred_height(GtkWidget *widget, gint *minimal_heig *minimal_height += MAX(2, padding.top + padding.bottom + border.top + border.bottom); *natural_height += MAX(2, padding.top + padding.bottom + border.top + border.bottom); } -#else -static void sp_button_size_request(GtkWidget *widget, GtkRequisition *requisition) -{ - GtkWidget *child = gtk_bin_get_child(GTK_BIN(widget)); - GtkStyle *style = gtk_widget_get_style(widget); - - if (child) { - gtk_widget_size_request(GTK_WIDGET(child), requisition); - } else { - requisition->width = 0; - requisition->height = 0; - } - - requisition->width += 2 + 2 * MAX(2, style->xthickness); - requisition->height += 2 + 2 * MAX(2, style->ythickness); -} -#endif static void sp_button_clicked(GtkButton *button) { diff --git a/src/widgets/calligraphy-toolbar.cpp b/src/widgets/calligraphy-toolbar.cpp index 4ae6427ad..031295ccd 100644 --- a/src/widgets/calligraphy-toolbar.cpp +++ b/src/widgets/calligraphy-toolbar.cpp @@ -25,7 +25,7 @@ */ #ifdef HAVE_CONFIG_H -# include "config.h" +#include <config.h> #endif #include "ui/dialog/calligraphic-profile-rename.h" @@ -37,7 +37,7 @@ #include "widgets/ege-adjustment-action.h" #include "widgets/ege-select-one-action.h" #include "widgets/ink-action.h" -#include "preferences.h" +#include "widgets/ink-toggle-action.h" #include "toolbox.h" #include "ui/icon-names.h" #include "ui/uxmanager.h" diff --git a/src/widgets/connector-toolbar.cpp b/src/widgets/connector-toolbar.cpp index 733fb34e8..a078ecec4 100644 --- a/src/widgets/connector-toolbar.cpp +++ b/src/widgets/connector-toolbar.cpp @@ -25,7 +25,7 @@ */ #ifdef HAVE_CONFIG_H -# include "config.h" +#include <config.h> #endif #include <glibmm/i18n.h> @@ -38,12 +38,10 @@ #include "widgets/ege-adjustment-action.h" #include "enums.h" #include "graphlayout.h" -#include "widgets/ink-action.h" +#include "ink-action.h" +#include "ink-toggle-action.h" #include "inkscape.h" -#include "preferences.h" -#include "selection.h" #include "sp-namedview.h" -#include "sp-path.h" #include "toolbox.h" #include "ui/icon-names.h" #include "ui/tools/connector-tool.h" @@ -51,7 +49,6 @@ #include "verbs.h" #include "widgets/spinbutton-events.h" #include "xml/node-event-vector.h" -#include "xml/repr.h" using Inkscape::UI::UXManager; using Inkscape::DocumentUndo; @@ -97,8 +94,8 @@ static void sp_connector_orthogonal_toggled( GtkToggleAction* act, GObject *tbl gchar *value = is_orthog ? orthog_str : polyline_str ; bool modmade = false; - std::vector<SPItem*> itemlist=desktop->getSelection()->itemList(); - for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();++i){ + auto itemlist= desktop->getSelection()->items(); + for(auto i=itemlist.begin();i!=itemlist.end();++i){ SPItem *item = *i; if (Inkscape::UI::Tools::cc_item_is_connector(item)) { @@ -144,8 +141,8 @@ static void connector_curvature_changed(GtkAdjustment *adj, GObject* tbl) g_ascii_dtostr(value, G_ASCII_DTOSTR_BUF_SIZE, newValue); bool modmade = false; - std::vector<SPItem*> itemlist=desktop->getSelection()->itemList(); - for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();++i){ + auto itemlist= desktop->getSelection()->items(); + for(auto i=itemlist.begin();i!=itemlist.end();++i){ SPItem *item = *i; if (Inkscape::UI::Tools::cc_item_is_connector(item)) { @@ -227,7 +224,9 @@ static void sp_connector_graph_layout(void) int saved_compensation = prefs->getInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED); prefs->setInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED); - graphlayout(SP_ACTIVE_DESKTOP->getSelection()->itemList()); + auto tmp = SP_ACTIVE_DESKTOP->getSelection()->items(); + std::vector<SPItem *> vec(tmp.begin(), tmp.end()); + graphlayout(vec); prefs->setInt("/options/clonecompensation/value", saved_compensation); diff --git a/src/widgets/dash-selector.cpp b/src/widgets/dash-selector.cpp index 9d591d33d..522705cec 100644 --- a/src/widgets/dash-selector.cpp +++ b/src/widgets/dash-selector.cpp @@ -13,15 +13,13 @@ */ #ifdef HAVE_CONFIG_H -# include "config.h" +#include <config.h> #endif #include "dash-selector.h" #include <cstring> -#include <string> #include <glibmm/i18n.h> -#include <gtkmm/adjustment.h> #include <2geom/coord.h> #include "style.h" @@ -61,18 +59,9 @@ SPDashSelector::SPDashSelector() dash_combo.signal_changed().connect( sigc::mem_fun(*this, &SPDashSelector::on_selection) ); this->pack_start(dash_combo, false, false, 0); - -#if WITH_GTKMM_3_0 offset = Gtk::Adjustment::create(0.0, 0.0, 10.0, 0.1, 1.0, 0.0); -#else - offset = new Gtk::Adjustment(0.0, 0.0, 10.0, 0.1, 1.0, 0.0); -#endif offset->signal_value_changed().connect(sigc::mem_fun(*this, &SPDashSelector::offset_value_changed)); -#if WITH_GTKMM_3_0 - Inkscape::UI::Widget::SpinButton *sb = new Inkscape::UI::Widget::SpinButton(offset, 0.1, 2); -#else - Inkscape::UI::Widget::SpinButton *sb = new Inkscape::UI::Widget::SpinButton(*offset, 0.1, 2); -#endif + auto sb = new Inkscape::UI::Widget::SpinButton(offset, 0.1, 2); sb->set_tooltip_text(_("Pattern offset")); sp_dialog_defocus_on_enter_cpp(sb); sb->show(); @@ -99,9 +88,6 @@ SPDashSelector::SPDashSelector() SPDashSelector::~SPDashSelector() { // FIXME: for some reason this doesn't get called; does the call to manage() in // sp_stroke_style_line_widget_new() not processed correctly? -#if !WITH_GTKMM_3_0 - delete offset; -#endif } void SPDashSelector::prepareImageRenderer( Gtk::TreeModel::const_iterator const &row ) { diff --git a/src/widgets/dash-selector.h b/src/widgets/dash-selector.h index ec5a1cbd5..f176acf04 100644 --- a/src/widgets/dash-selector.h +++ b/src/widgets/dash-selector.h @@ -85,12 +85,7 @@ private: Glib::RefPtr<Gtk::ListStore> dash_store; Gtk::ComboBox dash_combo; Gtk::CellRendererPixbuf image_renderer; - -#if WITH_GTKMM_3_0 Glib::RefPtr<Gtk::Adjustment> offset; -#else - Gtk::Adjustment *offset; -#endif static gchar const *const _prefs_path; int preview_width; diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp index 164a06910..55dc82dc0 100644 --- a/src/widgets/desktop-widget.cpp +++ b/src/widgets/desktop-widget.cpp @@ -36,21 +36,15 @@ #include "desktop-widget.h" #include "display/sp-canvas.h" #include "display/canvas-arena.h" -#include "document.h" #include "ege-color-prof-tracker.h" #include "widgets/ege-select-one-action.h" #include <extension/db.h> #include "file.h" #include "helper/action.h" -#include "helper/action-context.h" #include "util/units.h" #include "ui/widget/unit-tracker.h" -#include "inkscape.h" #include "ui/interface.h" -#include "macros.h" -#include "preferences.h" #include "sp-image.h" -#include "sp-item.h" #include "sp-namedview.h" #include "ui/dialog/swatches.h" #include "ui/icon-names.h" @@ -63,21 +57,17 @@ // We're in the "widgets" directory, so no need to explicitly prefix these: #include "button.h" -#include "ruler.h" +#include "gimp/ruler.h" #include "spinbutton-events.h" #include "spw-utilities.h" #include "toolbox.h" #include "widget-sizes.h" #include "verbs.h" -#if GTK_CHECK_VERSION(3,0,0) -# include <gtkmm/cssprovider.h> -#endif +#include <gtkmm/cssprovider.h> #include <gtkmm/paned.h> #include <gtkmm/messagedialog.h> -#include <gtk/gtk.h> - #if defined (SOLARIS) && (SOLARIS == 8) #include "round.h" using Inkscape::round; @@ -256,16 +246,11 @@ Geom::Point SPDesktopWidget::window_get_pointer() { gint x,y; - GdkWindow *window = gtk_widget_get_window(GTK_WIDGET(canvas)); - -#if GTK_CHECK_VERSION(3,0,0) - GdkDisplay *display = gdk_window_get_display(window); - GdkDeviceManager *dm = gdk_display_get_device_manager(display); - GdkDevice *device = gdk_device_manager_get_client_pointer(dm); + auto window = gtk_widget_get_window(GTK_WIDGET(canvas)); + auto display = gdk_window_get_display(window); + auto dm = gdk_display_get_device_manager(display); + auto device = gdk_device_manager_get_client_pointer(dm); gdk_window_get_device_position(window, device, &x, &y, NULL); -#else - gdk_window_get_pointer(window, &x, &y, NULL); -#endif return Geom::Point(x,y); } @@ -322,12 +307,19 @@ sp_desktop_widget_class_init (SPDesktopWidgetClass *klass) * This adjusts the range of the rulers when the dock container is adjusted * (fixes lp:950552) */ -static void canvas_tbl_size_allocate(GtkWidget * /*widget*/, +static void canvas_tbl_size_allocate(GtkWidget * widget, GdkRectangle * /*allocation*/, gpointer data) { SPDesktopWidget *dtw = SP_DESKTOP_WIDGET(data); sp_desktop_widget_update_rulers(dtw); + + GtkWidget* parent = gtk_widget_get_parent(widget); + if(GTK_IS_PANED(parent)) { + GtkPaned *paned = GTK_PANED(parent); + // Could use gtk paned property 'max-position' here + gtk_paned_set_position(paned, 10000); + } } /** @@ -344,21 +336,11 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw ) dtw->_interaction_disabled_counter = 0; /* Main table */ -#if GTK_CHECK_VERSION(3,0,0) dtw->vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); gtk_widget_set_name(dtw->vbox, "DesktopMainTable"); -#else - dtw->vbox = gtk_vbox_new (FALSE, 0); -#endif gtk_container_add( GTK_CONTAINER(dtw), GTK_WIDGET(dtw->vbox) ); - -#if GTK_CHECK_VERSION(3,0,0) dtw->statusbar = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); gtk_widget_set_name(dtw->statusbar, "DesktopStatusBar"); -#else - dtw->statusbar = gtk_hbox_new (FALSE, 0); -#endif - //gtk_widget_set_usize (dtw->statusbar, -1, BOTTOM_BAR_HEIGHT); gtk_box_pack_end (GTK_BOX (dtw->vbox), dtw->statusbar, FALSE, TRUE, 0); { @@ -366,19 +348,12 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw ) dtw->panels = new SwatchesPanel("/embedded/swatches" /*false*/); dtw->panels->setOrientation(SP_ANCHOR_SOUTH); -#if GTK_CHECK_VERSION(3,0,0) dtw->panels->set_vexpand(false); -#endif - gtk_box_pack_end( GTK_BOX( dtw->vbox ), GTK_WIDGET(dtw->panels->gobj()), FALSE, TRUE, 0 ); } -#if GTK_CHECK_VERSION(3,0,0) dtw->hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); gtk_widget_set_name(dtw->hbox, "DesktopHbox"); -#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); @@ -402,14 +377,12 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw ) NULL, INKSCAPE_ICON("object-locked"), _("Toggle lock of all guides in the document")); -#if GTK_CHECK_VERSION(3,0,0) - Glib::RefPtr<Gtk::CssProvider> guides_lock_style_provider = Gtk::CssProvider::create(); + auto guides_lock_style_provider = Gtk::CssProvider::create(); guides_lock_style_provider->load_from_data("GtkWidget { padding-left: 0; padding-right: 0; padding-top: 0; padding-bottom: 0; }"); - Gtk::Widget * wnd = Glib::wrap(dtw->guides_lock); + auto wnd = Glib::wrap(dtw->guides_lock); wnd->set_name("LockGuides"); - Glib::RefPtr<Gtk::StyleContext> context = wnd->get_style_context(); + auto context = wnd->get_style_context(); context->add_provider(guides_lock_style_provider, GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); -#endif /* Horizontal ruler */ GtkWidget *eventbox = gtk_event_box_new (); @@ -424,29 +397,13 @@ void SPDesktopWidget::init( SPDesktopWidget *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_wrapper = gtk_grid_new(); // Is this widget really needed? + auto tbl_wrapper = gtk_grid_new(); // Is this widget really needed? gtk_widget_set_name(tbl_wrapper, "CanvasTableWrapper"); dtw->canvas_tbl = gtk_grid_new(); gtk_widget_set_name(dtw->canvas_tbl, "CanvasTable"); gtk_grid_attach(GTK_GRID(dtw->canvas_tbl), dtw->guides_lock, 0, 0, 1, 1); gtk_grid_attach(GTK_GRID(dtw->canvas_tbl), eventbox, 1, 0, 1, 1); -#else - GtkWidget *tbl_wrapper = gtk_table_new(2, 3, FALSE); - dtw->canvas_tbl = gtk_table_new(3, 3, FALSE); - - gtk_table_attach(GTK_TABLE(dtw->canvas_tbl), - dtw->guides_lock, - 0, 1, 0, 1, - GTK_FILL, GTK_FILL, - 0, 0); - gtk_table_attach(GTK_TABLE(dtw->canvas_tbl), - eventbox, - 1, 2, 0, 1, - GTK_FILL, GTK_FILL, - 0, 0); -#endif g_signal_connect (G_OBJECT (dtw->guides_lock), "toggled", G_CALLBACK (sp_update_guides_lock), dtw); gtk_box_pack_start( GTK_BOX(dtw->hbox), tbl_wrapper, TRUE, TRUE, 1 ); @@ -460,16 +417,7 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw ) sp_ruler_set_unit (SP_RULER (dtw->vruler), pt); gtk_widget_set_tooltip_text (dtw->vruler_box, gettext(pt->name_plural.c_str())); gtk_container_add (GTK_CONTAINER (eventbox), GTK_WIDGET (dtw->vruler)); - -#if GTK_CHECK_VERSION(3,0,0) gtk_grid_attach(GTK_GRID(dtw->canvas_tbl), eventbox, 0, 1, 1, 1); -#else - gtk_table_attach(GTK_TABLE (dtw->canvas_tbl), - eventbox, - 0, 1, 1, 2, - GTK_FILL, GTK_FILL, - 0, 0); -#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); @@ -477,19 +425,10 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw ) // Horizontal scrollbar dtw->hadj = GTK_ADJUSTMENT(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)); gtk_widget_set_name(dtw->hscrollbar, "HorizontalScrollbar"); gtk_grid_attach(GTK_GRID(dtw->canvas_tbl), dtw->hscrollbar, 1, 2, 1, 1); dtw->vscrollbar_box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); -#else - dtw->hscrollbar = gtk_hscrollbar_new (GTK_ADJUSTMENT (dtw->hadj)); - gtk_table_attach(GTK_TABLE (dtw->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, @@ -504,23 +443,10 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw ) // Vertical scrollbar dtw->vadj = GTK_ADJUSTMENT(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)); gtk_widget_set_name(dtw->vscrollbar, "VerticalScrollbar"); -#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); - -#if GTK_CHECK_VERSION(3,0,0) gtk_grid_attach(GTK_GRID(dtw->canvas_tbl), dtw->vscrollbar_box, 2, 0, 1, 2); -#else - gtk_table_attach(GTK_TABLE(dtw->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 ); @@ -554,15 +480,7 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw ) cms_adjust_set_sensitive(dtw, FALSE); #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) -#if GTK_CHECK_VERSION(3,0,0) gtk_grid_attach( GTK_GRID(dtw->canvas_tbl), dtw->cms_adjust, 2, 2, 1, 1); -#else - gtk_table_attach( GTK_TABLE(dtw->canvas_tbl), dtw->cms_adjust, 2, 3, 2, 3, - (GtkAttachOptions)(GTK_SHRINK), - (GtkAttachOptions)(GTK_SHRINK), - 0, 0); -#endif - { if (!watcher) { watcher = new CMSPrefWatcher(); @@ -579,10 +497,8 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw ) sp_ruler_add_track_widget (SP_RULER(dtw->hruler), GTK_WIDGET(dtw->canvas)); sp_ruler_add_track_widget (SP_RULER(dtw->vruler), GTK_WIDGET(dtw->canvas)); - -#if GTK_CHECK_VERSION(3,0,0) - GtkCssProvider *css_provider = gtk_css_provider_new(); - GtkStyleContext *style_context = gtk_widget_get_style_context(GTK_WIDGET(dtw->canvas)); + auto css_provider = gtk_css_provider_new(); + auto style_context = gtk_widget_get_style_context(GTK_WIDGET(dtw->canvas)); gtk_css_provider_load_from_data(css_provider, "SPCanvas {\n" @@ -593,21 +509,11 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw ) gtk_style_context_add_provider(style_context, GTK_STYLE_PROVIDER(css_provider), GTK_STYLE_PROVIDER_PRIORITY_USER); -#else - 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 - 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_hexpand(GTK_WIDGET(dtw->canvas), TRUE); gtk_widget_set_vexpand(GTK_WIDGET(dtw->canvas), TRUE); gtk_grid_attach(GTK_GRID(dtw->canvas_tbl), GTK_WIDGET(dtw->canvas), 1, 1, 1, 1); -#else - gtk_table_attach (GTK_TABLE (dtw->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 = @@ -616,12 +522,8 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw ) if (create_dock) { dtw->dock = new Inkscape::UI::Widget::Dock(); -#if WITH_GTKMM_3_0 - Gtk::Paned *paned = new Gtk::Paned(); + auto paned = new Gtk::Paned(); paned->set_name("Canvas_and_Dock"); -#else - Gtk::HPaned *paned = new Gtk::HPaned(); -#endif paned->pack1(*Glib::wrap(dtw->canvas_tbl)); paned->pack2(dtw->dock->getWidget(), Gtk::FILL); @@ -632,24 +534,13 @@ 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); + paned->set_hexpand(true); + paned->set_vexpand(true); gtk_grid_attach(GTK_GRID(tbl_wrapper), GTK_WIDGET (paned->gobj()), 1, 1, 1, 1); -#else - gtk_table_attach (GTK_TABLE (tbl_wrapper), 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(dtw->canvas_tbl), TRUE); gtk_widget_set_vexpand(GTK_WIDGET(dtw->canvas_tbl), TRUE); gtk_grid_attach(GTK_GRID(tbl_wrapper), GTK_WIDGET (dtw->canvas_tbl), 1, 1, 1, 1); -#else - gtk_table_attach (GTK_TABLE (tbl_wrapper), GTK_WIDGET (dtw->canvas_tbl), 1, 2, 1, 2, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), - (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), 0, 0); -#endif } // connect scrollbar signals @@ -666,11 +557,7 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw ) // Separator gtk_box_pack_start(GTK_BOX(dtw->statusbar), -#if GTK_CHECK_VERSION(3,0,0) gtk_separator_new(GTK_ORIENTATION_VERTICAL), -#else - gtk_vseparator_new(), -#endif FALSE, FALSE, 0); // Layer Selector @@ -689,12 +576,7 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw ) gtk_label_set_lines (GTK_LABEL(dtw->select_status), 2); #endif -#if GTK_CHECK_VERSION(3,0,0) gtk_widget_set_halign(dtw->select_status, GTK_ALIGN_START); -#else - gtk_misc_set_alignment (GTK_MISC (dtw->select_status), 0.0, 0.5); -#endif - gtk_widget_set_size_request (dtw->select_status, 1, -1); // Display the initial welcome message in the statusbar @@ -720,65 +602,36 @@ 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 -#if GTK_CHECK_VERSION(3,0,0) dtw->coord_status = gtk_grid_new(); gtk_widget_set_name(dtw->coord_status, "CoordinateAndZStatus"); 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); + auto sep = gtk_separator_new(GTK_ORIENTATION_VERTICAL); gtk_widget_set_name(sep, "CoordinateSeparator"); 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), - gtk_vseparator_new(), - 0, 1, 0, 2, - GTK_FILL, GTK_FILL, 0, 0); -#endif gtk_widget_set_tooltip_text (dtw->coord_status, _("Cursor coordinates")); - GtkWidget *label_x = gtk_label_new(_("X:")); - GtkWidget *label_y = gtk_label_new(_("Y:")); - -#if GTK_CHECK_VERSION(3,0,0) + auto label_x = gtk_label_new(_("X:")); + auto label_y = gtk_label_new(_("Y:")); gtk_widget_set_halign(label_x, GTK_ALIGN_START); gtk_widget_set_halign(label_y, GTK_ALIGN_START); gtk_grid_attach(GTK_GRID(dtw->coord_status), label_x, 1, 0, 1, 1); gtk_grid_attach(GTK_GRID(dtw->coord_status), label_y, 1, 1, 1, 1); -#else - gtk_misc_set_alignment (GTK_MISC(label_x), 0.0, 0.5); - gtk_misc_set_alignment (GTK_MISC(label_y), 0.0, 0.5); - gtk_table_attach(GTK_TABLE(dtw->coord_status), label_x, 1,2, 0,1, GTK_FILL, GTK_FILL, 0, 0); - 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); dtw->coord_status_y = gtk_label_new(NULL); gtk_label_set_markup( GTK_LABEL(dtw->coord_status_x), "<tt> 0.00 </tt>" ); gtk_label_set_markup( GTK_LABEL(dtw->coord_status_y), "<tt> 0.00 </tt>" ); - GtkWidget* label_z = gtk_label_new(_("Z:")); + auto label_z = gtk_label_new(_("Z:")); gtk_widget_set_name(label_z, "ZLabel"); - -#if GTK_CHECK_VERSION(3,0,0) gtk_widget_set_halign(dtw->coord_status_x, GTK_ALIGN_END); gtk_widget_set_halign(dtw->coord_status_y, GTK_ALIGN_END); 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_misc_set_alignment (GTK_MISC(dtw->coord_status_x), 1.0, 0.5); - gtk_misc_set_alignment (GTK_MISC(dtw->coord_status_y), 1.0, 0.5); - 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), 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); @@ -2211,7 +2064,6 @@ set_adjustment (GtkAdjustment *adj, double l, double u, double ps, double si, do gtk_adjustment_set_page_size(adj, ps); gtk_adjustment_set_step_increment(adj, si); gtk_adjustment_set_page_increment(adj, pi); - gtk_adjustment_changed (adj); } } diff --git a/src/widgets/dropper-toolbar.cpp b/src/widgets/dropper-toolbar.cpp index 45ed9ead4..4e26a99a0 100644 --- a/src/widgets/dropper-toolbar.cpp +++ b/src/widgets/dropper-toolbar.cpp @@ -25,7 +25,7 @@ */ #ifdef HAVE_CONFIG_H -# include "config.h" +#include <config.h> #endif #include <glibmm/i18n.h> @@ -33,7 +33,7 @@ #include "dropper-toolbar.h" #include "document-undo.h" #include "widgets/ege-output-action.h" -#include "widgets/ink-action.h" +#include "ink-toggle-action.h" #include "preferences.h" #include "widgets/spinbutton-events.h" diff --git a/src/widgets/eek-preview.cpp b/src/widgets/eek-preview.cpp index 9951a8957..5f1997672 100644 --- a/src/widgets/eek-preview.cpp +++ b/src/widgets/eek-preview.cpp @@ -194,7 +194,6 @@ static void eek_preview_size_request( GtkWidget* widget, GtkRequisition* req ) req->height = height; } -#if GTK_CHECK_VERSION(3,0,0) static void eek_preview_get_preferred_width(GtkWidget *widget, gint *minimal_width, gint *natural_width) { GtkRequisition requisition; @@ -208,7 +207,6 @@ static void eek_preview_get_preferred_height(GtkWidget *widget, gint *minimal_he eek_preview_size_request(widget, &requisition); *minimal_height = *natural_height = requisition.height; } -#endif enum { CLICKED_SIGNAL, @@ -219,22 +217,6 @@ enum { static guint eek_preview_signals[LAST_SIGNAL] = { 0 }; -#if !GTK_CHECK_VERSION(3,0,0) -static gboolean eek_preview_expose_event( GtkWidget* widget, GdkEventExpose* /* event */ ) -{ - gboolean result = FALSE; - - if (gtk_widget_is_drawable(widget)) { - GdkWindow* window = gtk_widget_get_window(widget); - cairo_t* cr = gdk_cairo_create(window); - result = eek_preview_draw(widget, cr); - cairo_destroy(cr); - } - - return result; -} -#endif - static gboolean eek_preview_draw(GtkWidget *widget, cairo_t *cr) @@ -246,14 +228,6 @@ gboolean eek_preview_draw(GtkWidget *widget, GtkAllocation allocation; gtk_widget_get_allocation(widget, &allocation); -#if !GTK_CHECK_VERSION(3,0,0) - GdkColor fg = { 0, - static_cast<guint16>(priv->r), - static_cast<guint16>(priv->g), - static_cast<guint16>(priv->b) - }; -#endif - gint insetTop = 0, insetBottom = 0; gint insetLeft = 0, insetRight = 0; @@ -270,9 +244,7 @@ gboolean eek_preview_draw(GtkWidget *widget, insetLeft = insetRight = 1; } - -#if GTK_CHECK_VERSION(3,0,0) - GtkStyleContext *context = gtk_widget_get_style_context(widget); + auto context = gtk_widget_get_style_context(widget); gtk_render_frame(context, cr, @@ -283,22 +255,6 @@ gboolean eek_preview_draw(GtkWidget *widget, cr, 0, 0, allocation.width, allocation.height); -#else - GtkStyle *style = gtk_widget_get_style(widget); - 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); - - gdk_colormap_alloc_color( gdk_colormap_get_system(), &fg, FALSE, TRUE ); -#endif // Border if (priv->border != BORDER_NONE) { @@ -377,27 +333,12 @@ gboolean eek_preview_draw(GtkWidget *widget, if (priv->linked & PREVIEW_LINK_IN) { -#if GTK_CHECK_VERSION(3,0,0) gtk_render_arrow(context, cr, G_PI, // Down-pointing arrow area.x, area.y, min(area.width, area.height) ); -#else - gtk_paint_arrow( style, - window, - gtk_widget_get_state (widget), - GTK_SHADOW_ETCHED_IN, - NULL, /* clip area. &area, */ - widget, /* may be NULL */ - NULL, /* detail */ - GTK_ARROW_DOWN, - FALSE, - area.x, area.y, - area.width, area.height - ); -#endif } if (priv->linked & PREVIEW_LINK_OUT) @@ -407,27 +348,12 @@ gboolean eek_preview_draw(GtkWidget *widget, otherArea.y = possible.y + (possible.height - otherArea.height); } -#if GTK_CHECK_VERSION(3,0,0) gtk_render_arrow(context, cr, G_PI, // Down-pointing arrow otherArea.x, otherArea.y, min(otherArea.width, otherArea.height) ); -#else - gtk_paint_arrow( style, - window, - gtk_widget_get_state (widget), - GTK_SHADOW_ETCHED_OUT, - NULL, /* clip area. &area, */ - widget, /* may be NULL */ - NULL, /* detail */ - GTK_ARROW_DOWN, - FALSE, - otherArea.x, otherArea.y, - otherArea.width, otherArea.height - ); -#endif } if (priv->linked & PREVIEW_LINK_OTHER) @@ -437,27 +363,12 @@ gboolean eek_preview_draw(GtkWidget *widget, otherArea.y = possible.y + (possible.height - otherArea.height) / 2; } -#if GTK_CHECK_VERSION(3,0,0) gtk_render_arrow(context, cr, 1.5*G_PI, // Left-pointing arrow otherArea.x, otherArea.y, min(otherArea.width, otherArea.height) ); -#else - gtk_paint_arrow( style, - window, - gtk_widget_get_state (widget), - GTK_SHADOW_ETCHED_OUT, - NULL, /* clip area. &area, */ - widget, /* may be NULL */ - NULL, /* detail */ - GTK_ARROW_LEFT, - FALSE, - otherArea.x, otherArea.y, - otherArea.width, otherArea.height - ); -#endif } @@ -469,22 +380,10 @@ gboolean eek_preview_draw(GtkWidget *widget, if ( otherArea.height < possible.height ) { otherArea.y = possible.y + (possible.height - otherArea.height) / 2; } -#if GTK_CHECK_VERSION(3,0,0) gtk_render_check(context, cr, otherArea.x, otherArea.y, otherArea.width, otherArea.height ); -#else - gtk_paint_check( style, - window, - gtk_widget_get_state (widget), - GTK_SHADOW_ETCHED_OUT, - NULL, - widget, - NULL, - otherArea.x, otherArea.y, - otherArea.width, otherArea.height ); -#endif } if (priv->linked & PREVIEW_STROKE) @@ -495,23 +394,11 @@ gboolean eek_preview_draw(GtkWidget *widget, if ( otherArea.height < possible.height ) { otherArea.y = possible.y + (possible.height - otherArea.height) / 2; } -#if GTK_CHECK_VERSION(3,0,0) // This should be a diamond too? gtk_render_check(context, cr, otherArea.x, otherArea.y, otherArea.width, otherArea.height ); -#else - gtk_paint_diamond( style, - window, - gtk_widget_get_state (widget), - GTK_SHADOW_ETCHED_OUT, - NULL, - widget, - NULL, - otherArea.x, otherArea.y, - otherArea.width, otherArea.height ); -#endif } } @@ -519,21 +406,10 @@ gboolean eek_preview_draw(GtkWidget *widget, if ( gtk_widget_has_focus(widget) ) { gtk_widget_get_allocation (widget, &allocation); -#if GTK_CHECK_VERSION(3,0,0) gtk_render_focus(context, cr, 0 + 1, 0 + 1, allocation.width - 2, allocation.height - 2 ); -#else - gtk_paint_focus( style, - window, - GTK_STATE_NORMAL, - NULL, /* GdkRectangle *area, */ - widget, - NULL, - 0 + 1, 0 + 1, - allocation.width - 2, allocation.height - 2 ); -#endif } return FALSE; @@ -547,11 +423,7 @@ static gboolean eek_preview_enter_cb( GtkWidget* widget, GdkEventCrossing* event EekPreviewPrivate *priv = EEK_PREVIEW_GET_PRIVATE(preview); priv->within = TRUE; -#if GTK_CHECK_VERSION(3,0,0) gtk_widget_set_state_flags( widget, priv->hot ? GTK_STATE_FLAG_ACTIVE : GTK_STATE_FLAG_PRELIGHT, false ); -#else - gtk_widget_set_state( widget, priv->hot ? GTK_STATE_ACTIVE : GTK_STATE_PRELIGHT ); -#endif } return FALSE; @@ -564,11 +436,7 @@ static gboolean eek_preview_leave_cb( GtkWidget* widget, GdkEventCrossing* event EekPreviewPrivate *priv = EEK_PREVIEW_GET_PRIVATE(preview); priv->within = FALSE; -#if GTK_CHECK_VERSION(3,0,0) gtk_widget_set_state_flags( widget, GTK_STATE_FLAG_NORMAL, false ); -#else - gtk_widget_set_state( widget, GTK_STATE_NORMAL ); -#endif } return FALSE; @@ -593,11 +461,7 @@ static gboolean eek_preview_button_press_cb( GtkWidget* widget, GdkEventButton* if ( priv->within ) { -#if GTK_CHECK_VERSION(3,0,0) gtk_widget_set_state_flags( widget, GTK_STATE_FLAG_ACTIVE, false ); -#else - gtk_widget_set_state( widget, GTK_STATE_ACTIVE ); -#endif } } } @@ -612,11 +476,7 @@ static gboolean eek_preview_button_release_cb( GtkWidget* widget, GdkEventButton EekPreviewPrivate *priv = EEK_PREVIEW_GET_PRIVATE(preview); priv->hot = FALSE; -#if GTK_CHECK_VERSION(3,0,0) gtk_widget_set_state_flags( widget, GTK_STATE_FLAG_NORMAL, false ); -#else - gtk_widget_set_state( widget, GTK_STATE_NORMAL ); -#endif if ( priv->within && (event->button == PRIME_BUTTON_MAGIC_NUMBER || @@ -697,15 +557,9 @@ static void eek_preview_class_init( EekPreviewClass *klass ) parent_class = (GtkWidgetClass*)g_type_class_peek_parent( klass ); -#if GTK_CHECK_VERSION(3,0,0) widgetClass->get_preferred_width = eek_preview_get_preferred_width; widgetClass->get_preferred_height = eek_preview_get_preferred_height; widgetClass->draw = eek_preview_draw; -#else - widgetClass->size_request = eek_preview_size_request; - widgetClass->expose_event = eek_preview_expose_event; -#endif - widgetClass->button_press_event = eek_preview_button_press_cb; widgetClass->button_release_event = eek_preview_button_release_cb; widgetClass->enter_notify_event = eek_preview_enter_cb; diff --git a/src/widgets/ege-adjustment-action.cpp b/src/widgets/ege-adjustment-action.cpp index 272217aa4..6678d1e5a 100644 --- a/src/widgets/ege-adjustment-action.cpp +++ b/src/widgets/ege-adjustment-action.cpp @@ -47,7 +47,7 @@ #include "icon-size.h" #include "widgets/ege-adjustment-action.h" -#include "ui/widget/gimpspinscale.h" +#include "gimp/gimpspinscale.h" #include "ui/icon-names.h" @@ -813,12 +813,8 @@ static GtkWidget* create_tool_item( GtkAction* action ) if ( IS_EGE_ADJUSTMENT_ACTION(action) ) { EgeAdjustmentAction* act = EGE_ADJUSTMENT_ACTION( action ); GtkWidget* spinbutton = 0; -#if GTK_CHECK_VERSION(3,0,0) - GtkWidget* hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 5); + auto hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 5); gtk_box_set_homogeneous(GTK_BOX(hb), FALSE); -#else - GtkWidget* hb = gtk_hbox_new( FALSE, 5 ); -#endif GValue value; memset( &value, 0, sizeof(value) ); g_value_init( &value, G_TYPE_STRING ); @@ -865,13 +861,7 @@ static GtkWidget* create_tool_item( GtkAction* action ) gtk_box_pack_start( GTK_BOX(hb), icon, FALSE, FALSE, 0 ); } else { GtkWidget* lbl = gtk_label_new( g_value_get_string( &value ) ? g_value_get_string( &value ) : "wwww" ); - -#if GTK_CHECK_VERSION(3,0,0) gtk_widget_set_halign(lbl, GTK_ALIGN_END); -#else - gtk_misc_set_alignment( GTK_MISC(lbl), 1.0, 0.5 ); -#endif - gtk_box_pack_start( GTK_BOX(hb), lbl, FALSE, FALSE, 0 ); } } diff --git a/src/widgets/ege-output-action.cpp b/src/widgets/ege-output-action.cpp index 5dece8e91..da29524a5 100644 --- a/src/widgets/ege-output-action.cpp +++ b/src/widgets/ege-output-action.cpp @@ -166,12 +166,8 @@ GtkWidget* create_tool_item( GtkAction* action ) if ( IS_EGE_OUTPUT_ACTION(action) ) { GValue value; -#if GTK_CHECK_VERSION(3,0,0) - GtkWidget* hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 5); + auto hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 5); gtk_box_set_homogeneous(GTK_BOX(hb), FALSE); -#else - GtkWidget* hb = gtk_hbox_new( FALSE, 5 ); -#endif GtkWidget* lbl = 0; memset( &value, 0, sizeof(value) ); diff --git a/src/widgets/ege-select-one-action.cpp b/src/widgets/ege-select-one-action.cpp index 2e106154e..5555663e4 100644 --- a/src/widgets/ege-select-one-action.cpp +++ b/src/widgets/ege-select-one-action.cpp @@ -632,12 +632,8 @@ GtkWidget* create_tool_item( GtkAction* action ) item = GTK_WIDGET( gtk_tool_item_new() ); if ( act->private_data->appearanceMode == APPEARANCE_FULL ) { -#if GTK_CHECK_VERSION(3,0,0) - GtkWidget* holder = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); + auto holder = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); gtk_box_set_homogeneous(GTK_BOX(holder), FALSE); -#else - GtkWidget* holder = gtk_hbox_new( FALSE, 0 ); -#endif GtkRadioAction* ract = 0; GSList* group = 0; @@ -744,12 +740,8 @@ GtkWidget* create_tool_item( GtkAction* action ) gtk_container_add( GTK_CONTAINER(item), holder ); } else { -#if GTK_CHECK_VERSION(3,0,0) - GtkWidget* holder = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 4); + auto holder = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 4); gtk_box_set_homogeneous(GTK_BOX(holder), FALSE); -#else - GtkWidget *holder = gtk_hbox_new( FALSE, 4 ); -#endif GtkEntry *entry = 0; GtkWidget *normal; @@ -818,14 +810,8 @@ GtkWidget* create_tool_item( GtkAction* action ) gtk_box_pack_start( GTK_BOX(holder), normal, FALSE, FALSE, 0 ); { -#if GTK_CHECK_VERSION(3,0,0) gtk_widget_set_halign(holder, GTK_ALIGN_START); gtk_container_add(GTK_CONTAINER(item), holder); -#else - GtkWidget *align = gtk_alignment_new(0, 0.5, 0, 0); - gtk_container_add( GTK_CONTAINER(align), holder); - gtk_container_add( GTK_CONTAINER(item), align ); -#endif } } @@ -861,13 +847,6 @@ void resync_active( EgeSelectOneAction* act, gint active, gboolean override ) if ( children && children->data ) { gpointer combodata = g_object_get_data( G_OBJECT(children->data), "ege-combo-box" ); -#if !GTK_CHECK_VERSION(3,0,0) - if (!combodata && GTK_IS_ALIGNMENT(children->data)) { - GList *other = gtk_container_get_children( GTK_CONTAINER(children->data) ); - combodata = g_object_get_data( G_OBJECT(other->data), "ege-combo-box" ); - } -#endif - if ( GTK_IS_COMBO_BOX(combodata) ) { GtkComboBox* combo = GTK_COMBO_BOX(combodata); if ((active == -1) && (gtk_combo_box_get_has_entry(combo))) { @@ -925,13 +904,6 @@ void resync_sensitive( EgeSelectOneAction* act ) if ( children && children->data ) { gpointer combodata = g_object_get_data( G_OBJECT(children->data), "ege-combo-box" ); -#if !GTK_CHECK_VERSION(3,0,0) - if (!combodata && GTK_IS_ALIGNMENT(children->data)) { - GList *other = gtk_container_get_children( GTK_CONTAINER(children->data) ); - combodata = g_object_get_data( G_OBJECT(other->data), "ege-combo-box" ); - } -#endif - if ( GTK_IS_COMBO_BOX(combodata) ) { /* Not implemented */ } else if ( GTK_IS_BOX(children->data) ) { diff --git a/src/widgets/eraser-toolbar.cpp b/src/widgets/eraser-toolbar.cpp index bb553f4e6..bcfa662a2 100644 --- a/src/widgets/eraser-toolbar.cpp +++ b/src/widgets/eraser-toolbar.cpp @@ -25,7 +25,7 @@ */ #ifdef HAVE_CONFIG_H -# include "config.h" +#include <config.h> #endif #include <glibmm/i18n.h> @@ -37,10 +37,12 @@ #include "document-undo.h" #include "widgets/ege-adjustment-action.h" #include "widgets/ege-select-one-action.h" -#include "widgets/ink-action.h" -#include "preferences.h" +#include "ink-action.h" +#include "ink-radio-action.h" +#include "ink-toggle-action.h" #include "toolbox.h" #include "ui/icon-names.h" +#include "ui/tools/eraser-tool.h" using Inkscape::DocumentUndo; using Inkscape::UI::ToolboxFactory; @@ -64,22 +66,60 @@ static void sp_erc_mass_value_changed( GtkAdjustment *adj, GObject* tbl ) update_presets_list(tbl); } +static void sp_erc_velthin_value_changed( GtkAdjustment *adj, GObject* tbl ) +{ + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + prefs->setDouble("/tools/eraser/thinning", gtk_adjustment_get_value(adj) ); + update_presets_list(tbl); +} + +static void sp_erc_cap_rounding_value_changed( GtkAdjustment *adj, GObject* tbl ) +{ + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + prefs->setDouble( "/tools/eraser/cap_rounding", gtk_adjustment_get_value(adj) ); + update_presets_list(tbl); +} + +static void sp_erc_tremor_value_changed( GtkAdjustment *adj, GObject* tbl ) +{ + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + prefs->setDouble( "/tools/eraser/tremor", gtk_adjustment_get_value(adj) ); + update_presets_list(tbl); +} + + static void sp_erasertb_mode_changed( EgeSelectOneAction *act, GObject *tbl ) { SPDesktop *desktop = static_cast<SPDesktop *>(g_object_get_data( tbl, "desktop" )); - bool eraserMode = ege_select_one_action_get_active( act ) != 0; + guint eraser_mode = ege_select_one_action_get_active( act ); if (DocumentUndo::getUndoSensitive(desktop->getDocument())) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - prefs->setBool( "/tools/eraser/mode", eraserMode ); + prefs->setInt( "/tools/eraser/mode", eraser_mode ); } GtkAction *split = GTK_ACTION( g_object_get_data(tbl, "split") ); GtkAction *mass = GTK_ACTION( g_object_get_data(tbl, "mass") ); GtkAction *width = GTK_ACTION( g_object_get_data(tbl, "width") ); - if(eraserMode == TRUE){ - gtk_action_set_visible( split, TRUE ); + GtkAction *usepressure = GTK_ACTION( g_object_get_data(tbl, "usepressure") ); + GtkAction *cap_rounding = GTK_ACTION( g_object_get_data(tbl, "cap_rounding") ); + GtkAction *thinning = GTK_ACTION( g_object_get_data(tbl, "thinning") ); + GtkAction *tremor = GTK_ACTION( g_object_get_data(tbl, "tremor") ); + if (eraser_mode != ERASER_MODE_DELETE) { + if(eraser_mode == ERASER_MODE_CUT) { + gtk_action_set_visible( split, TRUE ); + } else { + gtk_action_set_visible( split, FALSE ); + } + gtk_action_set_visible(usepressure, TRUE ); + gtk_action_set_visible(tremor, TRUE ); + gtk_action_set_visible(cap_rounding, TRUE ); + gtk_action_set_visible(thinning, TRUE ); gtk_action_set_visible( mass, TRUE ); gtk_action_set_visible( width, TRUE ); } else { + gtk_action_set_visible(usepressure, FALSE ); + gtk_action_set_visible(tremor, FALSE ); + gtk_action_set_visible(cap_rounding, FALSE ); + gtk_action_set_visible(thinning, FALSE ); gtk_action_set_visible( split, FALSE ); gtk_action_set_visible( mass, FALSE ); gtk_action_set_visible( width, FALSE ); @@ -90,7 +130,7 @@ static void sp_erasertb_mode_changed( EgeSelectOneAction *act, GObject *tbl ) g_object_set_data( tbl, "freeze", GINT_TO_POINTER(TRUE) ); /* - if ( eraserMode != 0 ) { + if ( eraser_mode != ERASER_MODE_DELETE ) { } else { } */ @@ -111,7 +151,7 @@ void sp_eraser_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GOb { Inkscape::IconSize secondarySize = ToolboxFactory::prefToSize("/toolbox/secondary", 1); Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - gint eraserMode = FALSE; + gint eraser_mode = FALSE; { GtkListStore* model = gtk_list_store_new( 3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING ); GtkTreeIter iter; @@ -125,10 +165,17 @@ void sp_eraser_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GOb gtk_list_store_append( model, &iter ); gtk_list_store_set( model, &iter, 0, _("Cut"), - 1, _("Cut out from objects"), + 1, _("Cut out from paths and shapes"), 2, INKSCAPE_ICON("path-difference"), -1 ); + gtk_list_store_append( model, &iter ); + gtk_list_store_set( model, &iter, + 0, _("Clip"), + 1, _("Clip from objects"), + 2, INKSCAPE_ICON("path-intersection"), + -1 ); + EgeSelectOneAction* act = ege_select_one_action_new( "EraserModeAction", (""), (""), NULL, GTK_TREE_MODEL(model) ); g_object_set( act, "short_label", _("Mode:"), NULL ); gtk_action_group_add_action( mainActions, GTK_ACTION(act) ); @@ -137,12 +184,13 @@ void sp_eraser_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GOb ege_select_one_action_set_appearance( act, "full" ); ege_select_one_action_set_radio_action_type( act, INK_RADIO_ACTION_TYPE ); g_object_set( G_OBJECT(act), "icon-property", "iconId", NULL ); - ege_select_one_action_set_icon_column( act, 2 ); - ege_select_one_action_set_tooltip_column( act, 1 ); + ege_select_one_action_set_icon_column( act, 2); + ege_select_one_action_set_icon_size( act, secondarySize ); + ege_select_one_action_set_tooltip_column( act, 1); Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - eraserMode = prefs->getBool("/tools/eraser/mode") ? TRUE : FALSE; - ege_select_one_action_set_active( act, eraserMode ); + eraser_mode = prefs->getInt("/tools/eraser/mode", ERASER_MODE_CLIP); + ege_select_one_action_set_active( act, eraser_mode ); g_signal_connect_after( G_OBJECT(act), "changed", G_CALLBACK(sp_erasertb_mode_changed), holder ); } @@ -163,6 +211,71 @@ void sp_eraser_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GOb g_object_set_data( holder, "width", eact ); gtk_action_set_sensitive( GTK_ACTION(eact), TRUE ); } + /* Use Pressure button */ + { + InkToggleAction* act = ink_toggle_action_new( "EraserPressureAction", + _("Eraser Pressure"), + _("Use the pressure of the input device to alter the width of the pen"), + INKSCAPE_ICON("draw-use-pressure"), + Inkscape::ICON_SIZE_DECORATION ); + gtk_action_group_add_action( mainActions, GTK_ACTION( act ) ); + PrefPusher *pusher = new PrefPusher(GTK_TOGGLE_ACTION(act), "/tools/eraser/usepressure", update_presets_list, holder); + g_signal_connect( holder, "destroy", G_CALLBACK(delete_prefspusher), pusher); + g_object_set_data( holder, "usepressure", act ); + } + { + + /* Thinning */ + gchar const* labels[] = {_("(speed blows up stroke)"), 0, 0, _("(slight widening)"), _("(constant width)"), _("(slight thinning, default)"), 0, 0, _("(speed deflates stroke)")}; + gdouble values[] = {-100, -40, -20, -10, 0, 10, 20, 40, 100}; + EgeAdjustmentAction* eact = create_adjustment_action( "EraserThinningAction", + _("Eraser Stroke Thinning"), _("Thinning:"), + _("How much velocity thins the stroke (> 0 makes fast strokes thinner, < 0 makes them broader, 0 makes width independent of velocity)"), + "/tools/eraser/thinning", 10, + GTK_WIDGET(desktop->canvas), holder, FALSE, NULL, + -100, 100, 1, 10.0, + labels, values, G_N_ELEMENTS(labels), + sp_erc_velthin_value_changed, NULL /*unit tracker*/, 1, 0); + gtk_action_group_add_action( mainActions, GTK_ACTION(eact) ); + g_object_set_data( holder, "thinning", eact ); + gtk_action_set_sensitive( GTK_ACTION(eact), TRUE ); + } + { + /* Cap Rounding */ + gchar const* labels[] = {_("(blunt caps, default)"), _("(slightly bulging)"), 0, 0, _("(approximately round)"), _("(long protruding caps)")}; + gdouble values[] = {0, 0.3, 0.5, 1.0, 1.4, 5.0}; + // TRANSLATORS: "cap" means "end" (both start and finish) here + EgeAdjustmentAction* eact = create_adjustment_action( "EraserCapRoundingAction", + _("Eraser Cap rounding"), _("Caps:"), + _("Increase to make caps at the ends of strokes protrude more (0 = no caps, 1 = round caps)"), + "/tools/eraser/cap_rounding", 0.0, + GTK_WIDGET(desktop->canvas), holder, FALSE, NULL, + 0.0, 5.0, 0.01, 0.1, + labels, values, G_N_ELEMENTS(labels), + sp_erc_cap_rounding_value_changed, NULL /*unit tracker*/, 0.01, 2 ); + gtk_action_group_add_action( mainActions, GTK_ACTION(eact) ); + g_object_set_data( holder, "cap_rounding", eact ); + gtk_action_set_sensitive( GTK_ACTION(eact), TRUE ); + } + + { + /* Tremor */ + gchar const* labels[] = {_("(smooth line)"), _("(slight tremor)"), _("(noticeable tremor)"), 0, 0, _("(maximum tremor)")}; + gdouble values[] = {0, 10, 20, 40, 60, 100}; + EgeAdjustmentAction* eact = create_adjustment_action( "EraserTremorAction", + _("EraserStroke Tremor"), _("Tremor:"), + _("Increase to make strokes rugged and trembling"), + "/tools/eraser/tremor", 0.0, + GTK_WIDGET(desktop->canvas), holder, FALSE, NULL, + 0.0, 100, 1, 10.0, + labels, values, G_N_ELEMENTS(labels), + sp_erc_tremor_value_changed, NULL /*unit tracker*/, 1, 0); + + ege_adjustment_action_set_appearance( eact, TOOLBAR_SLIDER_HINT ); + g_object_set_data( holder, "tremor", eact ); + gtk_action_group_add_action( mainActions, GTK_ACTION(eact) ); + gtk_action_set_sensitive( GTK_ACTION(eact), TRUE ); + } { /* Mass */ gchar const* labels[] = {_("(no inertia)"), _("(slight smoothing, default)"), _("(noticeable lagging)"), 0, 0, _("(maximum inertia)")}; @@ -195,11 +308,27 @@ void sp_eraser_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GOb GtkAction *split = GTK_ACTION( g_object_get_data(holder, "split") ); GtkAction *mass = GTK_ACTION( g_object_get_data(holder, "mass") ); GtkAction *width = GTK_ACTION( g_object_get_data(holder, "width") ); - if(eraserMode == TRUE){ - gtk_action_set_visible( split, TRUE ); + GtkAction *usepressure = GTK_ACTION( g_object_get_data(holder, "usepressure") ); + GtkAction *cap_rounding = GTK_ACTION( g_object_get_data(holder, "cap_rounding") ); + GtkAction *thinning = GTK_ACTION( g_object_get_data(holder, "thinning") ); + GtkAction *tremor = GTK_ACTION( g_object_get_data(holder, "tremor") ); + if (eraser_mode != ERASER_MODE_DELETE) { + if(eraser_mode == ERASER_MODE_CUT) { + gtk_action_set_visible( split, TRUE ); + } else { + gtk_action_set_visible( split, FALSE ); + } + gtk_action_set_visible(usepressure, TRUE ); + gtk_action_set_visible(tremor, TRUE ); + gtk_action_set_visible(cap_rounding, TRUE ); + gtk_action_set_visible(thinning, TRUE ); gtk_action_set_visible( mass, TRUE ); gtk_action_set_visible( width, TRUE ); } else { + gtk_action_set_visible(usepressure, FALSE ); + gtk_action_set_visible(tremor, FALSE ); + gtk_action_set_visible(cap_rounding, FALSE ); + gtk_action_set_visible(thinning, FALSE ); gtk_action_set_visible( split, FALSE ); gtk_action_set_visible( mass, FALSE ); gtk_action_set_visible( width, FALSE ); diff --git a/src/widgets/fill-style.cpp b/src/widgets/fill-style.cpp index a96776894..c35519b68 100644 --- a/src/widgets/fill-style.cpp +++ b/src/widgets/fill-style.cpp @@ -19,7 +19,7 @@ #define noSP_FS_VERBOSE #ifdef HAVE_CONFIG_H -# include "config.h" +#include <config.h> #endif #include <gtkmm/box.h> @@ -27,8 +27,6 @@ #include "verbs.h" -#include <gtk/gtk.h> - #include "desktop.h" #include "selection.h" @@ -38,13 +36,11 @@ #include "document-undo.h" #include "gradient-chemistry.h" #include "inkscape.h" -#include "selection.h" #include "sp-linear-gradient.h" #include "sp-pattern.h" #include "sp-radial-gradient.h" #include "style.h" #include "widgets/paint-selector.h" -#include "xml/repr.h" #include "fill-style.h" #include "fill-n-stroke-factory.h" @@ -476,7 +472,7 @@ void FillNStroke::updateFromPaint() SPDocument *document = desktop->getDocument(); Inkscape::Selection *selection = desktop->getSelection(); - std::vector<SPItem*> const items = selection->itemList(); + std::vector<SPItem*> const items(selection->items().begin(), selection->items().end()); switch (psel->mode) { case SPPaintSelector::MODE_EMPTY: diff --git a/src/widgets/font-selector.cpp b/src/widgets/font-selector.cpp index eeb80ab28..e9cf66621 100644 --- a/src/widgets/font-selector.cpp +++ b/src/widgets/font-selector.cpp @@ -16,31 +16,49 @@ */ #ifdef HAVE_CONFIG_H -# include "config.h" +#include <config.h> #endif #include <2geom/transforms.h> #include <gtk/gtk.h> +#include <libnrtype/font-lister.h> +#include <libnrtype/font-instance.h> + #include <glibmm/i18n.h> #include "desktop.h" #include "widgets/font-selector.h" -#include "preferences.h" /* SPFontSelector */ +struct SPFontSelector +{ + GtkBox hbox; + + unsigned int block_emit : 1; + + GtkWidget *family; + GtkWidget *style; + GtkWidget *size; + + GtkWidget *family_treeview; + GtkWidget *style_treeview; + + NRNameList families; + NRStyleList styles; + gfloat fontsize; + bool fontsize_dirty; + Glib::ustring *fontspec; +}; + struct SPFontSelectorClass { -#if GTK_CHECK_VERSION(3,0,0) GtkBoxClass parent_class; -#else - GtkHBoxClass parent_class; -#endif void (* font_set) (SPFontSelector *fsel, gchar *fontspec); }; @@ -66,11 +84,7 @@ static void sp_font_selector_set_sizes( SPFontSelector *fsel ); static guint fs_signals[LAST_SIGNAL] = { 0 }; -#if GTK_CHECK_VERSION(3,0,0) G_DEFINE_TYPE(SPFontSelector, sp_font_selector, GTK_TYPE_BOX); -#else -G_DEFINE_TYPE(SPFontSelector, sp_font_selector, GTK_TYPE_HBOX); -#endif static void sp_font_selector_class_init(SPFontSelectorClass *c) { @@ -102,8 +116,8 @@ static void sp_font_selector_set_size_tooltip(SPFontSelector *fsel) */ static void sp_font_selector_init(SPFontSelector *fsel) { - gtk_box_set_homogeneous(GTK_BOX(fsel), TRUE); - gtk_box_set_spacing(GTK_BOX(fsel), 4); + //gtk_box_set_homogeneous(GTK_BOX(fsel), TRUE); + //gtk_box_set_spacing(GTK_BOX(fsel), 4); /* Family frame */ GtkWidget *f = gtk_frame_new(_("Font family")); @@ -125,6 +139,7 @@ static void sp_font_selector_init(SPFontSelector *fsel) GtkTreeViewColumn *column = gtk_tree_view_column_new (); GtkCellRenderer *cell = gtk_cell_renderer_text_new (); gtk_tree_view_column_pack_start (column, cell, FALSE); + gtk_tree_view_column_set_fixed_width (column, 200); gtk_tree_view_column_set_attributes (column, cell, "text", 0, NULL); gtk_tree_view_column_set_cell_data_func (column, cell, GtkTreeCellDataFunc (font_lister_cell_data_func), @@ -135,8 +150,7 @@ static void sp_font_selector_init(SPFontSelector *fsel) /* Muck with style, see text-toolbar.cpp */ gtk_widget_set_name( GTK_WIDGET(fsel->family_treeview), "font_selector_family" ); -#if GTK_CHECK_VERSION(3,0,0) - GtkCssProvider *css_provider = gtk_css_provider_new(); + auto css_provider = gtk_css_provider_new(); gtk_css_provider_load_from_data(css_provider, "#font_selector_family {\n" " -GtkWidget-wide-separators: true;\n" @@ -144,14 +158,10 @@ static void sp_font_selector_init(SPFontSelector *fsel) "}\n", -1, NULL); - GdkScreen *screen = gdk_screen_get_default(); + auto screen = gdk_screen_get_default(); gtk_style_context_add_provider_for_screen(screen, GTK_STYLE_PROVIDER(css_provider), GTK_STYLE_PROVIDER_PRIORITY_USER); -#else - gtk_rc_parse_string ( - "widget \"*font_selector_family\" style \"fontfamily-separator-style\""); -#endif Inkscape::FontLister* fontlister = Inkscape::FontLister::get_instance(); Glib::RefPtr<Gtk::ListStore> store = fontlister->get_font_list(); @@ -168,14 +178,10 @@ static void sp_font_selector_init(SPFontSelector *fsel) /* Style frame */ f = gtk_frame_new(C_("Font selector", "Style")); gtk_widget_show(f); - gtk_box_pack_start(GTK_BOX (fsel), f, TRUE, TRUE, 0); + gtk_box_pack_start(GTK_BOX (fsel), f, FALSE, TRUE, 0); -#if GTK_CHECK_VERSION(3,0,0) - GtkWidget *vb = gtk_box_new(GTK_ORIENTATION_VERTICAL, 4); + auto vb = gtk_box_new(GTK_ORIENTATION_VERTICAL, 4); gtk_box_set_homogeneous(GTK_BOX(vb), FALSE); -#else - GtkWidget *vb = gtk_vbox_new(FALSE, 4); -#endif gtk_widget_show(vb); gtk_container_set_border_width(GTK_CONTAINER (vb), 4); gtk_container_add(GTK_CONTAINER(f), vb); @@ -210,12 +216,8 @@ static void sp_font_selector_init(SPFontSelector *fsel) selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(fsel->style_treeview)); g_signal_connect (G_OBJECT(selection), "changed", G_CALLBACK (sp_font_selector_style_select_row), fsel); -#if GTK_CHECK_VERSION(3,0,0) - GtkWidget *hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 4); + auto hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 4); gtk_box_set_homogeneous(GTK_BOX(hb), FALSE); -#else - GtkWidget *hb = gtk_hbox_new(FALSE, 4); -#endif gtk_widget_show(hb); gtk_box_pack_start(GTK_BOX(vb), hb, FALSE, FALSE, 0); diff --git a/src/widgets/font-selector.h b/src/widgets/font-selector.h index 2d55a87ab..e8e0af079 100644 --- a/src/widgets/font-selector.h +++ b/src/widgets/font-selector.h @@ -15,8 +15,7 @@ * * Released under GNU GPL, read the file 'COPYING' for more information */ -#include <libnrtype/font-lister.h> -#include <libnrtype/font-instance.h> + #include <glib.h> struct SPFontSelector diff --git a/src/widgets/gimp/CMakeLists.txt b/src/widgets/gimp/CMakeLists.txt new file mode 100644 index 000000000..7b3e834e3 --- /dev/null +++ b/src/widgets/gimp/CMakeLists.txt @@ -0,0 +1,13 @@ +set(gimpwidgets_SRC + gimpcolorwheel.c + gimpspinscale.c + ruler.cpp + + # ------- + # Headers + gimpcolorwheel.h + gimpspinscale.h + ruler.h +) + +add_inkscape_source("${gimpwidgets_SRC}") diff --git a/src/ui/widget/gimpcolorwheel.c b/src/widgets/gimp/gimpcolorwheel.c index d54486505..212391497 100644 --- a/src/ui/widget/gimpcolorwheel.c +++ b/src/widgets/gimp/gimpcolorwheel.c @@ -110,7 +110,6 @@ static gboolean gimp_color_wheel_button_release (GtkWidget *widget, GdkEventButton *event); static gboolean gimp_color_wheel_motion (GtkWidget *widget, GdkEventMotion *event); -#if GTK_CHECK_VERSION(3,0,0) static gboolean gimp_color_wheel_draw (GtkWidget *widget, cairo_t *cr); static void gimp_color_wheel_get_preferred_width (GtkWidget *widget, @@ -119,13 +118,6 @@ static void gimp_color_wheel_get_preferred_width (GtkWidget *widget, static void gimp_color_wheel_get_preferred_height (GtkWidget *widget, gint *minimum_height, gint *natural_height); -#else -static gboolean gimp_color_wheel_expose (GtkWidget *widget, - GdkEventExpose *event); -static void gimp_color_wheel_size_request (GtkWidget *widget, - GtkRequisition *requisition); -#endif - static gboolean gimp_color_wheel_grab_broken (GtkWidget *widget, GdkEventGrabBroken *event); static gboolean gimp_color_wheel_focus (GtkWidget *widget, @@ -157,16 +149,9 @@ gimp_color_wheel_class_init (GimpColorWheelClass *class) widget_class->button_press_event = gimp_color_wheel_button_press; widget_class->button_release_event = gimp_color_wheel_button_release; widget_class->motion_notify_event = gimp_color_wheel_motion; - -#if GTK_CHECK_VERSION(3,0,0) widget_class->get_preferred_width = gimp_color_wheel_get_preferred_width; widget_class->get_preferred_height = gimp_color_wheel_get_preferred_height; widget_class->draw = gimp_color_wheel_draw; -#else - widget_class->size_request = gimp_color_wheel_size_request; - widget_class->expose_event = gimp_color_wheel_expose; -#endif - widget_class->focus = gimp_color_wheel_focus; widget_class->grab_broken_event = gimp_color_wheel_grab_broken; @@ -302,10 +287,6 @@ gimp_color_wheel_realize (GtkWidget *widget) priv->window = gdk_window_new (parent_window, &attr, attr_mask); gdk_window_set_user_data (priv->window, wheel); - -#if !GTK_CHECK_VERSION(3,0,0) - gtk_widget_style_attach (widget); -#endif } static void @@ -321,7 +302,6 @@ gimp_color_wheel_unrealize (GtkWidget *widget) GTK_WIDGET_CLASS (parent_class)->unrealize (widget); } -#if GTK_CHECK_VERSION(3,0,0) static void gimp_color_wheel_get_preferred_width (GtkWidget *widget, gint *minimum_width, @@ -353,23 +333,6 @@ gimp_color_wheel_get_preferred_height (GtkWidget *widget, *minimum_height = *natural_height = DEFAULT_SIZE + 2 * (focus_width + focus_pad); } -#else -static void -gimp_color_wheel_size_request (GtkWidget *widget, - GtkRequisition *requisition) -{ - gint focus_width; - gint focus_pad; - - gtk_widget_style_get (widget, - "focus-line-width", &focus_width, - "focus-padding", &focus_pad, - NULL); - - requisition->width = DEFAULT_SIZE + 2 * (focus_width + focus_pad); - requisition->height = DEFAULT_SIZE + 2 * (focus_width + focus_pad); -} -#endif static void gimp_color_wheel_size_allocate (GtkWidget *widget, @@ -688,7 +651,6 @@ set_cross_grab (GimpColorWheel *wheel, gdk_cursor_new_for_display (gtk_widget_get_display (GTK_WIDGET (wheel)), GDK_CROSSHAIR); -#if GTK_CHECK_VERSION(3,0,0) gdk_device_grab (gtk_get_current_event_device(), priv->window, GDK_OWNERSHIP_NONE, @@ -698,14 +660,6 @@ set_cross_grab (GimpColorWheel *wheel, GDK_BUTTON_RELEASE_MASK, cursor, time); g_object_unref (cursor); -#else - gdk_pointer_grab (priv->window, FALSE, - GDK_POINTER_MOTION_MASK | - GDK_POINTER_MOTION_HINT_MASK | - GDK_BUTTON_RELEASE_MASK, - NULL, cursor, time); - gdk_cursor_unref (cursor); -#endif } static gboolean gimp_color_wheel_grab_broken(GtkWidget *widget, GdkEventGrabBroken *event) @@ -805,13 +759,8 @@ gimp_color_wheel_button_release (GtkWidget *widget, else g_assert_not_reached (); -#if GTK_CHECK_VERSION(3,0,0) gdk_device_ungrab (gtk_get_current_event_device(), event->time); -#else - gdk_display_pointer_ungrab (gdk_window_get_display (event->window), - event->time); -#endif return TRUE; } @@ -859,11 +808,7 @@ static void paint_ring (GimpColorWheel *wheel, cairo_t *cr) { -#if GTK_CHECK_VERSION(3,0,0) GtkWidget *widget = GTK_WIDGET (wheel); -#else - GtkAllocation allocation; -#endif GimpColorWheelPrivate *priv = wheel->priv; gint width, height; gint xx, yy; @@ -879,14 +824,8 @@ paint_ring (GimpColorWheel *wheel, cairo_t *source_cr; gint stride; -#if GTK_CHECK_VERSION(3,0,0) width = gtk_widget_get_allocated_width (widget); height = gtk_widget_get_allocated_height (widget); -#else - gtk_widget_get_allocation (GTK_WIDGET (wheel), &allocation); - width = allocation.width; - height = allocation.height; -#endif center_x = width / 2.0; center_y = height / 2.0; @@ -1027,19 +966,10 @@ paint_triangle (GimpColorWheel *wheel, gdouble r, g, b; gint stride; gint width, height; -#if GTK_CHECK_VERSION(3,0,0) GtkStyleContext *context; width = gtk_widget_get_allocated_width (widget); height = gtk_widget_get_allocated_height (widget); -#else - gchar *detail; - - GtkAllocation allocation; - gtk_widget_get_allocation (widget, &allocation); - width = allocation.width; - height = allocation.height; -#endif /* Compute triangle's vertices */ @@ -1180,28 +1110,18 @@ paint_triangle (GimpColorWheel *wheel, b = priv->v; hsv_to_rgb (&r, &g, &b); -#if GTK_CHECK_VERSION(3,0,0) context = gtk_widget_get_style_context (widget); gtk_style_context_save (context); -#endif if (INTENSITY (r, g, b) > 0.5) { -#if GTK_CHECK_VERSION(3,0,0) gtk_style_context_add_class (context, "light-area-focus"); -#else - detail = "colorwheel_light"; -#endif cairo_set_source_rgb (cr, 0.0, 0.0, 0.0); } else { -#if GTK_CHECK_VERSION(3,0,0) gtk_style_context_add_class (context, "dark-area-focus"); -#else - detail = "colorwheel_dark"; -#endif cairo_set_source_rgb (cr, 1.0, 1.0, 1.0); } @@ -1224,31 +1144,16 @@ paint_triangle (GimpColorWheel *wheel, "focus-padding", &focus_pad, NULL); -#if GTK_CHECK_VERSION(3,0,0) gtk_render_focus (context, cr, xx - FOCUS_RADIUS - focus_width - focus_pad, yy - FOCUS_RADIUS - focus_width - focus_pad, 2 * (FOCUS_RADIUS + focus_width + focus_pad), 2 * (FOCUS_RADIUS + focus_width + focus_pad)); -#else - gtk_widget_get_allocation (widget, &allocation); - gtk_paint_focus (gtk_widget_get_style (widget), - gtk_widget_get_window (widget), - gtk_widget_get_state (widget), - NULL, widget, detail, - allocation.x + xx - FOCUS_RADIUS - focus_width - focus_pad, - allocation.y + yy - FOCUS_RADIUS - focus_width - focus_pad, - 2 * (FOCUS_RADIUS + focus_width + focus_pad), - 2 * (FOCUS_RADIUS + focus_width + focus_pad)); -#endif } -#if GTK_CHECK_VERSION(3,0,0) gtk_style_context_restore (context); -#endif } -#if GTK_CHECK_VERSION(3,0,0) static gboolean gimp_color_wheel_draw (GtkWidget *widget, cairo_t *cr) @@ -1273,48 +1178,6 @@ gimp_color_wheel_draw (GtkWidget *widget, return FALSE; } -#else -static gint -gimp_color_wheel_expose (GtkWidget *widget, - GdkEventExpose *event) -{ - cairo_t *cr = gdk_cairo_create (gtk_widget_get_window (widget)); - - GimpColorWheel *wheel = GIMP_COLOR_WHEEL (widget); - GimpColorWheelPrivate *priv = wheel->priv; - gboolean draw_focus; - GtkAllocation allocation; - - if (! (event->window == gtk_widget_get_window (widget) && - gtk_widget_is_drawable (widget))) - return FALSE; - - gdk_cairo_region (cr, event->region); - cairo_clip (cr); - - gtk_widget_get_allocation (widget, &allocation); - cairo_translate (cr, allocation.x, allocation.y); - - draw_focus = gtk_widget_has_focus (widget); - - paint_ring (wheel, cr); - paint_triangle (wheel, cr, draw_focus); - - cairo_destroy (cr); - - if (draw_focus && priv->focus_on_ring) - gtk_paint_focus (gtk_widget_get_style (widget), - gtk_widget_get_window (widget), - gtk_widget_get_state (widget), - &event->area, widget, NULL, - allocation.x, - allocation.y, - allocation.width, - allocation.height); - - return FALSE; -} -#endif static gboolean gimp_color_wheel_focus (GtkWidget *widget, diff --git a/src/ui/widget/gimpcolorwheel.h b/src/widgets/gimp/gimpcolorwheel.h index 016fb593f..016fb593f 100644 --- a/src/ui/widget/gimpcolorwheel.h +++ b/src/widgets/gimp/gimpcolorwheel.h diff --git a/src/ui/widget/gimpspinscale.c b/src/widgets/gimp/gimpspinscale.c index d99646a64..8d8c6c935 100644 --- a/src/ui/widget/gimpspinscale.c +++ b/src/widgets/gimp/gimpspinscale.c @@ -41,10 +41,8 @@ typedef enum { TARGET_NUMBER, TARGET_UPPER, - TARGET_LOWER -#if WITH_GTKMM_3_0 - ,TARGET_NONE -#endif + TARGET_LOWER, + TARGET_NONE } SpinScaleTarget; typedef enum @@ -94,7 +92,6 @@ static void gimp_spin_scale_get_property (GObject *object, 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); @@ -103,13 +100,6 @@ static void gimp_spin_scale_get_preferred_height (GtkWidget *widget 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); @@ -145,14 +135,9 @@ gimp_spin_scale_class_init (GimpSpinScaleClass *klass) 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; @@ -294,7 +279,6 @@ gimp_spin_scale_set_appearance( GtkWidget *widget, const gchar *appearance) } } -#if GTK_CHECK_VERSION(3,0,0) static void gimp_spin_scale_get_preferred_width (GtkWidget *widget, gint *minimum_width, @@ -355,48 +339,6 @@ gimp_spin_scale_get_preferred_height (GtkWidget *widget, pango_font_metrics_unref (metrics); } -#else -static void -gimp_spin_scale_size_request (GtkWidget *widget, - GtkRequisition *requisition) -{ - GimpSpinScalePrivate *private = GET_PRIVATE (widget); - GtkStyle *style = gtk_widget_get_style (widget); - PangoContext *context = gtk_widget_get_pango_context (widget); - PangoFontMetrics *metrics; - gint height; - - GTK_WIDGET_CLASS (parent_class)->size_request (widget, requisition); - - metrics = pango_context_get_metrics (context, style->font_desc, - pango_context_get_language (context)); - - height = PANGO_PIXELS (pango_font_metrics_get_ascent (metrics) + - pango_font_metrics_get_descent (metrics)); - - if (private->appearanceMode == APPEARANCE_COMPACT) { - requisition->height += 1; - } else { - requisition->height += height; - } - - if (private->label) - { - gint char_width; - gint digit_width; - gint char_pixels; - - char_width = pango_font_metrics_get_approximate_char_width (metrics); - digit_width = pango_font_metrics_get_approximate_digit_width (metrics); - char_pixels = PANGO_PIXELS (MAX (char_width, digit_width)); - - /* ~3 chars for the ellipses */ - requisition->width += char_pixels * 3; - } - - pango_font_metrics_unref (metrics); -} -#endif static void gimp_spin_scale_style_set (GtkWidget *widget, @@ -415,16 +357,10 @@ gimp_spin_scale_style_set (GtkWidget *widget, static gboolean -#if GTK_CHECK_VERSION(3,0,0) gimp_spin_scale_draw (GtkWidget *widget, cairo_t *cr) -#else - gimp_spin_scale_expose (GtkWidget *widget, - GdkEventExpose *event) -#endif { GimpSpinScalePrivate *private = GET_PRIVATE (widget); -#if GTK_CHECK_VERSION(3,0,0) GtkStyleContext *style = gtk_widget_get_style_context(widget); GtkAllocation allocation; GdkRGBA color; @@ -434,66 +370,31 @@ static gboolean cairo_restore (cr); gtk_widget_get_allocation (widget, &allocation); -#else - GtkStyle *style = gtk_widget_get_style (widget); - cairo_t *cr; - gint w; - - GTK_WIDGET_CLASS (parent_class)->expose_event (widget, event); - - cr = gdk_cairo_create (event->window); - gdk_cairo_region (cr, event->region); - cairo_clip (cr); - - w = gdk_window_get_width (event->window); -#endif cairo_set_line_width (cr, 1.0); -#if GTK_CHECK_VERSION(3,0,0) if (private->label) { GdkRectangle text_area; gint minimum_width; gint natural_width; -#else - if (private->label && - gtk_widget_is_drawable (widget) && - event->window == gtk_entry_get_text_window (GTK_ENTRY (widget))) - { - GtkRequisition requisition; - GtkAllocation allocation; -#endif PangoRectangle logical; gint layout_offset_x; gint layout_offset_y; -#if GTK_CHECK_VERSION(3,0,0) GtkStateFlags state; GdkRGBA text_color; GdkRGBA bar_text_color; -#else - GtkStateType state; - GdkColor text_color; - GdkColor bar_text_color; - gint window_width; - gint window_height; -#endif gdouble progress_fraction; gint progress_x; gint progress_y; gint progress_width; gint progress_height; -#if GTK_CHECK_VERSION(3,0,0) gtk_entry_get_text_area (GTK_ENTRY (widget), &text_area); GTK_WIDGET_CLASS (parent_class)->get_preferred_width (widget, &minimum_width, &natural_width); -#else - GTK_WIDGET_CLASS (parent_class)->size_request (widget, &requisition); - gtk_widget_get_allocation (widget, &allocation); -#endif if (! private->layout) { @@ -504,27 +405,18 @@ static gboolean pango_layout_set_width (private->layout, PANGO_SCALE * -#if GTK_CHECK_VERSION(3,0,0) (allocation.width - minimum_width)); -#else - (allocation.width - requisition.width)); -#endif pango_layout_get_pixel_extents (private->layout, NULL, &logical); gtk_entry_get_layout_offsets (GTK_ENTRY (widget), NULL, &layout_offset_y); if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) -#if GTK_CHECK_VERSION(3,0,0) layout_offset_x = text_area.x + text_area.width - logical.width - 4; -#else - layout_offset_x = w - logical.width - 4; -#endif else layout_offset_x = 4; layout_offset_x -= logical.x; -#if GTK_CHECK_VERSION(3,0,0) state = gtk_widget_get_state_flags (widget); gtk_style_context_get_color (style, state, &text_color); @@ -533,16 +425,6 @@ static gboolean gtk_style_context_add_class (style, GTK_STYLE_CLASS_PROGRESSBAR); gtk_style_context_get_color (style, state, &bar_text_color); gtk_style_context_restore (style); -#else - state = GTK_STATE_SELECTED; - if (! gtk_widget_get_sensitive (widget)) - state = GTK_STATE_INSENSITIVE; - text_color = style->text[gtk_widget_get_state (widget)]; - bar_text_color = style->fg[state]; - - window_width = gdk_window_get_width (event->window); - window_height = gdk_window_get_height (event->window); -#endif progress_fraction = gtk_entry_get_progress_fraction (GTK_ENTRY (widget)); @@ -550,53 +432,30 @@ static gboolean { progress_fraction = 1.0 - progress_fraction; -#if GTK_CHECK_VERSION(3,0,0) progress_x = text_area.width * progress_fraction; -#else - progress_x = window_width * progress_fraction; -#endif progress_y = 0; -#if GTK_CHECK_VERSION(3,0,0) progress_width = text_area.width - progress_x; progress_height = text_area.height; -#else - progress_width = window_width - progress_x; - progress_height = window_height; -#endif } else { progress_x = 0; progress_y = 0; -#if GTK_CHECK_VERSION(3,0,0) progress_width = text_area.width * progress_fraction; progress_height = text_area.height; -#else - progress_width = window_width * progress_fraction; - progress_height = window_height; -#endif } cairo_save (cr); cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD); -#if GTK_CHECK_VERSION(3,0,0) cairo_rectangle (cr, 0, 0, text_area.width, text_area.height); -#else - cairo_rectangle (cr, 0, 0, window_width, window_height); -#endif cairo_rectangle (cr, progress_x, progress_y, progress_width, progress_height); cairo_clip (cr); cairo_set_fill_rule (cr, CAIRO_FILL_RULE_WINDING); -#if GTK_CHECK_VERSION(3,0,0) cairo_move_to (cr, layout_offset_x, text_area.y + layout_offset_y-3); gdk_cairo_set_source_rgba (cr, &text_color); -#else - cairo_move_to (cr, layout_offset_x, layout_offset_y-3); - gdk_cairo_set_source_color (cr, &text_color); -#endif pango_cairo_show_layout (cr, private->layout); cairo_restore (cr); @@ -604,24 +463,14 @@ static gboolean progress_width, progress_height); cairo_clip (cr); -#if GTK_CHECK_VERSION(3,0,0) cairo_move_to (cr, layout_offset_x, text_area.y + layout_offset_y-3); gdk_cairo_set_source_rgba (cr, &bar_text_color); -#else - cairo_move_to (cr, layout_offset_x, layout_offset_y-3); - gdk_cairo_set_source_color (cr, &bar_text_color); -#endif pango_cairo_show_layout (cr, private->layout); } -#if !GTK_CHECK_VERSION(3,0,0) - cairo_destroy (cr); -#endif - return FALSE; } -#if WITH_GTKMM_3_0 /* Returns TRUE if a translation should be done */ static gboolean gtk_widget_get_translation_to_window (GtkWidget *widget, @@ -685,7 +534,6 @@ gimp_spin_scale_event_to_widget_coords (GtkWidget *widget, *widget_x = event_x; *widget_y = event_y; } -#endif static SpinScaleTarget gimp_spin_scale_get_target (GtkWidget *widget, @@ -702,7 +550,6 @@ gimp_spin_scale_get_target (GtkWidget *widget, 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); @@ -726,19 +573,6 @@ gimp_spin_scale_get_target (GtkWidget *widget, } 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 @@ -773,49 +607,21 @@ gimp_spin_scale_change_value (GtkWidget *widget, 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; @@ -825,12 +631,7 @@ gimp_spin_scale_change_value (GtkWidget *widget, { 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); @@ -849,7 +650,6 @@ gimp_spin_scale_button_press (GtkWidget *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, @@ -879,36 +679,6 @@ gimp_spin_scale_button_press (GtkWidget *widget, 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); } @@ -918,22 +688,16 @@ 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; } @@ -948,21 +712,15 @@ gimp_spin_scale_motion_notify (GtkWidget *widget, gdk_event_request_motions (event); -#if WITH_GTKMM_3_0 gint x, y; gimp_spin_scale_event_to_widget_coords (widget, event->window, event->x, event->y, &x, &y); -#endif if (private->changing_value) { -#if WITH_GTKMM_3_0 gimp_spin_scale_change_value (widget, x); -#else - gimp_spin_scale_change_value (widget, event->x); -#endif return TRUE; } @@ -971,20 +729,12 @@ gimp_spin_scale_motion_notify (GtkWidget *widget, 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); @@ -1002,17 +752,11 @@ gimp_spin_scale_motion_notify (GtkWidget *widget, 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; diff --git a/src/ui/widget/gimpspinscale.h b/src/widgets/gimp/gimpspinscale.h index b42a0faf8..b42a0faf8 100644 --- a/src/ui/widget/gimpspinscale.h +++ b/src/widgets/gimp/gimpspinscale.h diff --git a/src/widgets/ruler.cpp b/src/widgets/gimp/ruler.cpp index deffd384a..bfb9c9071 100644 --- a/src/widgets/ruler.cpp +++ b/src/widgets/gimp/ruler.cpp @@ -31,7 +31,6 @@ #include <cmath> #include <cstdio> -#include "widget-sizes.h" #include "ruler.h" #include "round.h" #include <glibmm/i18n.h> @@ -120,7 +119,6 @@ static void sp_ruler_unmap (GtkWidget *widget); static void sp_ruler_size_allocate (GtkWidget *widget, GtkAllocation *allocation); -#if GTK_CHECK_VERSION(3,0,0) static void sp_ruler_get_preferred_width (GtkWidget *widget, gint *minimum_width, gint *natural_width); @@ -129,21 +127,11 @@ static void sp_ruler_get_preferred_height (GtkWidget *widget, gint *minimum_height, gint *natural_height); static void sp_ruler_style_updated (GtkWidget *widget); -#else -static void sp_ruler_size_request (GtkWidget *widget, - GtkRequisition *requisition); -static void sp_ruler_style_set (GtkWidget *widget, - GtkStyle *prev_style); -#endif static gboolean sp_ruler_motion_notify (GtkWidget *widget, GdkEventMotion *event); static gboolean sp_ruler_draw (GtkWidget *widget, cairo_t *cr); -#if !GTK_CHECK_VERSION(3,0,0) -static gboolean sp_ruler_expose (GtkWidget *widget, - GdkEventExpose *event); -#endif static void sp_ruler_draw_ticks (SPRuler *ruler); static GdkRectangle sp_ruler_get_pos_rect (SPRuler *ruler, gdouble position); @@ -181,16 +169,10 @@ sp_ruler_class_init (SPRulerClass *klass) widget_class->map = sp_ruler_map; widget_class->unmap = sp_ruler_unmap; widget_class->size_allocate = sp_ruler_size_allocate; -#if GTK_CHECK_VERSION(3,0,0) widget_class->get_preferred_width = sp_ruler_get_preferred_width; widget_class->get_preferred_height = sp_ruler_get_preferred_height; widget_class->style_updated = sp_ruler_style_updated; widget_class->draw = sp_ruler_draw; -#else - widget_class->size_request = sp_ruler_size_request; - widget_class->style_set = sp_ruler_style_set; - widget_class->expose_event = sp_ruler_expose; -#endif widget_class->motion_notify_event = sp_ruler_motion_notify; g_type_class_add_private (object_class, sizeof (SPRulerPrivate)); @@ -487,16 +469,10 @@ sp_ruler_realize (GtkWidget *widget) attributes.width = allocation.width; attributes.height = allocation.height; attributes.wclass = GDK_INPUT_ONLY; -#if GTK_CHECK_VERSION(3,0,0) attributes.event_mask = (gtk_widget_get_events (widget) | GDK_EXPOSURE_MASK | GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK); -#else - attributes.event_mask = (gtk_widget_get_events (widget) | - GDK_EXPOSURE_MASK | - GDK_POINTER_MOTION_MASK); -#endif attributes_mask = GDK_WA_X | GDK_WA_Y; @@ -599,7 +575,6 @@ sp_ruler_size_request (GtkWidget *widget, size = 2 + ink_rect.height * 1.7; -#if GTK_CHECK_VERSION(3,0,0) GtkStyleContext *context = gtk_widget_get_style_context (widget); GtkBorder border; @@ -607,47 +582,25 @@ sp_ruler_size_request (GtkWidget *widget, requisition->width = border.left + border.right; requisition->height = border.top + border.bottom; -#else - GtkStyle *style = gtk_widget_get_style(widget); -#endif if (priv->orientation == GTK_ORIENTATION_HORIZONTAL) { -#if GTK_CHECK_VERSION(3,0,0) requisition->width += 1; requisition->height += size; -#else - requisition->width = style->xthickness * 2 + 1; - requisition->height = style->ythickness * 2 + size; -#endif } else { -#if GTK_CHECK_VERSION(3,0,0) requisition->width += size; requisition->height += 1; -#else - requisition->width = style->xthickness * 2 + size; - requisition->height = style->ythickness * 2 + 1; -#endif } } static void -#if GTK_CHECK_VERSION(3,0,0) sp_ruler_style_updated (GtkWidget *widget) -#else -sp_ruler_style_set (GtkWidget *widget, - GtkStyle *prev_style) -#endif { SPRulerPrivate *priv = SP_RULER_GET_PRIVATE (widget); -#if GTK_CHECK_VERSION(3,0,0) GTK_WIDGET_CLASS (sp_ruler_parent_class)->style_updated (widget); -#else - GTK_WIDGET_CLASS (sp_ruler_parent_class)->style_set (widget, prev_style); -#endif gtk_widget_style_get (widget, "font-scale", &priv->font_scale, @@ -660,7 +613,6 @@ sp_ruler_style_set (GtkWidget *widget, } } -#if GTK_CHECK_VERSION(3,0,0) static void sp_ruler_get_preferred_width (GtkWidget *widget, gint *minimum_width, @@ -684,33 +636,19 @@ sp_ruler_get_preferred_height (GtkWidget *widget, *minimum_height = *natural_height = requisition.height; } -#else -static gboolean -sp_ruler_expose (GtkWidget *widget, - GdkEventExpose *event) -{ - cairo_t *cr = gdk_cairo_create(gtk_widget_get_window(widget)); - GtkAllocation allocation; - - gdk_cairo_region (cr, event->region); - cairo_clip (cr); - - gtk_widget_get_allocation (widget, &allocation); - - gboolean result = sp_ruler_draw (widget, cr); - - cairo_destroy (cr); - - return result; -} -#endif static gboolean sp_ruler_draw (GtkWidget *widget, cairo_t *cr) { - SPRuler *ruler = SP_RULER (widget); - SPRulerPrivate *priv = SP_RULER_GET_PRIVATE (ruler); + SPRuler *ruler = SP_RULER (widget); + SPRulerPrivate *priv = SP_RULER_GET_PRIVATE (ruler); + GtkStyleContext *context = gtk_widget_get_style_context (widget); + GtkAllocation allocation; + + gtk_widget_get_allocation (widget, &allocation); + gtk_render_background (context, cr, 0, 0, allocation.width, allocation.height); + gtk_render_frame (context, cr, 0, 0, allocation.width, allocation.height); sp_ruler_draw_ticks (ruler); @@ -736,7 +674,7 @@ sp_ruler_make_pixmap (SPRuler *ruler) priv->backing_store = gdk_window_create_similar_surface (gtk_widget_get_window (widget), - CAIRO_CONTENT_COLOR, + CAIRO_CONTENT_COLOR_ALPHA, allocation.width, allocation.height); @@ -749,13 +687,8 @@ sp_ruler_draw_pos (SPRuler *ruler, { GtkWidget *widget = GTK_WIDGET (ruler); -#if GTK_CHECK_VERSION(3,0,0) GtkStyleContext *context = gtk_widget_get_style_context (widget); GdkRGBA color; -#else - GtkStyle *style = gtk_widget_get_style (widget); - GtkStateType state = gtk_widget_get_state (widget); -#endif SPRulerPrivate *priv = SP_RULER_GET_PRIVATE (ruler); GdkRectangle pos_rect; @@ -767,13 +700,9 @@ sp_ruler_draw_pos (SPRuler *ruler, if ((pos_rect.width > 0) && (pos_rect.height > 0)) { -#if GTK_CHECK_VERSION(3,0,0) gtk_style_context_get_color (context, gtk_widget_get_state_flags (widget), &color); gdk_cairo_set_source_rgba (cr, &color); -#else - gdk_cairo_set_source_color (cr, &style->fg[state]); -#endif cairo_move_to (cr, pos_rect.x, pos_rect.y); @@ -1112,16 +1041,9 @@ sp_ruler_draw_ticks (SPRuler *ruler) { GtkWidget *widget = GTK_WIDGET (ruler); -#if GTK_CHECK_VERSION(3,0,0) GtkStyleContext *context = gtk_widget_get_style_context (widget); GtkBorder border; GdkRGBA color; -#else - GtkStyle *style = gtk_widget_get_style (widget); - GtkStateType state = gtk_widget_get_state (widget); - gint xthickness; - gint ythickness; -#endif SPRulerPrivate *priv = SP_RULER_GET_PRIVATE (ruler); GtkAllocation allocation; @@ -1150,12 +1072,7 @@ sp_ruler_draw_ticks (SPRuler *ruler) gtk_widget_get_allocation (widget, &allocation); -#if GTK_CHECK_VERSION(3,0,0) gtk_style_context_get_border (context, static_cast<GtkStateFlags>(0), &border); -#else - xthickness = style->xthickness; - ythickness = style->ythickness; -#endif layout = sp_ruler_get_layout (widget, "0123456789"); pango_layout_get_extents (layout, &ink_rect, &logical_rect); @@ -1166,28 +1083,20 @@ sp_ruler_draw_ticks (SPRuler *ruler) if (priv->orientation == GTK_ORIENTATION_HORIZONTAL) { width = allocation.width; -#if GTK_CHECK_VERSION(3,0,0) height = allocation.height - (border.top + border.bottom); -#else - height = allocation.height - ythickness * 2; -#endif } else { width = allocation.height; -#if GTK_CHECK_VERSION(3,0,0) height = allocation.width - (border.top + border.bottom); -#else - height = allocation.width - ythickness * 2; -#endif } cr = cairo_create (priv->backing_store); -#if GTK_CHECK_VERSION(3,0,0) - gtk_render_background (context, cr, 0, 0, allocation.width, allocation.height); - gtk_render_frame (context, cr, 0, 0, allocation.width, allocation.height); - + cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR); + cairo_paint (cr); + cairo_set_operator (cr, CAIRO_OPERATOR_OVER); + gtk_style_context_get_color (context, gtk_widget_get_state_flags (widget), &color); gdk_cairo_set_source_rgba (cr, &color); @@ -1208,30 +1117,6 @@ sp_ruler_draw_ticks (SPRuler *ruler) 1, allocation.height - (border.top + border.bottom)); } -#else - gdk_cairo_set_source_color (cr, &style->bg[state]); - - cairo_paint (cr); - - gdk_cairo_set_source_color(cr, &style->fg[state]); - - if (priv->orientation == GTK_ORIENTATION_HORIZONTAL) - { - cairo_rectangle (cr, - xthickness, - height + ythickness, - allocation.width - 2 * xthickness, - 1); - } - else - { - cairo_rectangle (cr, - height + xthickness, - ythickness, - 1, - allocation.height - 2 * ythickness); - } -#endif sp_ruler_get_range (ruler, &lower, &upper, &max_size); @@ -1312,7 +1197,6 @@ sp_ruler_draw_ticks (SPRuler *ruler) // by a pixel, and jump back on the next redraw). This is suppressed by adding 1e-9 (that's only one nanopixel ;-)) pos = gint(Inkscape::round((cur - lower) * increment + 1e-12)); -#if GTK_CHECK_VERSION(3,0,0) if (priv->orientation == GTK_ORIENTATION_HORIZONTAL) { cairo_rectangle (cr, @@ -1325,20 +1209,6 @@ sp_ruler_draw_ticks (SPRuler *ruler) height + border.left - length, pos, length, 1); } -#else - if (priv->orientation == GTK_ORIENTATION_HORIZONTAL) - { - cairo_rectangle (cr, - pos, height + ythickness - length, - 1, length); - } - else - { - cairo_rectangle (cr, - height + xthickness - length, pos, - length, 1); - } -#endif /* draw label */ double label_spacing_px = fabs(increment*(double)ruler_metric.ruler_scale[scale]/ruler_metric.subdivide[i]); @@ -1356,15 +1226,9 @@ sp_ruler_draw_ticks (SPRuler *ruler) pango_layout_set_text (layout, unit_str, -1); pango_layout_get_extents (layout, &logical_rect, NULL); -#if GTK_CHECK_VERSION(3,0,0) cairo_move_to (cr, pos + 2, border.top + PANGO_PIXELS (logical_rect.y - digit_offset)); -#else - cairo_move_to (cr, - pos + 2, - ythickness + PANGO_PIXELS (logical_rect.y - digit_offset)); -#endif pango_cairo_show_layout(cr, layout); } @@ -1378,15 +1242,9 @@ sp_ruler_draw_ticks (SPRuler *ruler) pango_layout_set_text (layout, digit_str, 1); pango_layout_get_extents (layout, NULL, &logical_rect); -#if GTK_CHECK_VERSION(3,0,0) cairo_move_to (cr, border.left + 1, pos + digit_height * j + 2 + PANGO_PIXELS (logical_rect.y - digit_offset)); -#else - cairo_move_to (cr, - xthickness + 1, - pos + digit_height * j + 2 + PANGO_PIXELS (logical_rect.y - digit_offset)); -#endif pango_cairo_show_layout (cr, layout); } } @@ -1423,7 +1281,6 @@ sp_ruler_get_pos_rect (SPRuler *ruler, gtk_widget_get_allocation (widget, &allocation); -#if GTK_CHECK_VERSION(3,0,0) GtkStyleContext *context = gtk_widget_get_style_context (widget); GtkBorder padding; @@ -1431,11 +1288,6 @@ sp_ruler_get_pos_rect (SPRuler *ruler, xthickness = padding.left + padding.right; ythickness = padding.top + padding.bottom; -#else - GtkStyle *style = gtk_widget_get_style (widget); - xthickness = style->xthickness; - ythickness = style->ythickness; -#endif if (priv->orientation == GTK_ORIENTATION_HORIZONTAL) { @@ -1473,9 +1325,6 @@ sp_ruler_get_pos_rect (SPRuler *ruler, rect.y = ROUND ((position - lower) * increment) + (ythickness - rect.height) / 2 - 1; } - rect.x += allocation.x; - rect.y += allocation.y; - return rect; } @@ -1498,18 +1347,21 @@ sp_ruler_queue_pos_redraw (SPRuler *ruler) { SPRulerPrivate *priv = SP_RULER_GET_PRIVATE (ruler); const GdkRectangle rect = sp_ruler_get_pos_rect (ruler, priv->position); + GtkAllocation allocation; + + gtk_widget_get_allocation (GTK_WIDGET(ruler), &allocation); gtk_widget_queue_draw_area (GTK_WIDGET(ruler), - rect.x, - rect.y, + rect.x + allocation.x, + rect.y + allocation.y, rect.width, rect.height); if (priv->last_pos_rect.width != 0 || priv->last_pos_rect.height != 0) { gtk_widget_queue_draw_area (GTK_WIDGET(ruler), - priv->last_pos_rect.x, - priv->last_pos_rect.y, + priv->last_pos_rect.x + allocation.x, + priv->last_pos_rect.y + allocation.y, priv->last_pos_rect.width, priv->last_pos_rect.height); diff --git a/src/widgets/ruler.h b/src/widgets/gimp/ruler.h index ed529d082..ed529d082 100644 --- a/src/widgets/ruler.h +++ b/src/widgets/gimp/ruler.h diff --git a/src/widgets/gradient-image.cpp b/src/widgets/gradient-image.cpp index 6901b8549..dff564feb 100644 --- a/src/widgets/gradient-image.cpp +++ b/src/widgets/gradient-image.cpp @@ -21,7 +21,6 @@ static void sp_gradient_image_size_request (GtkWidget *widget, GtkRequisition *requisition); -#if GTK_CHECK_VERSION(3,0,0) static void sp_gradient_image_destroy(GtkWidget *object); static void sp_gradient_image_get_preferred_width(GtkWidget *widget, gint *minimal_width, @@ -30,11 +29,6 @@ static void sp_gradient_image_get_preferred_width(GtkWidget *widget, static void sp_gradient_image_get_preferred_height(GtkWidget *widget, gint *minimal_height, gint *natural_height); -#else -static void sp_gradient_image_destroy(GtkObject *object); -static gboolean sp_gradient_image_expose(GtkWidget *widget, GdkEventExpose *event); -#endif - static gboolean sp_gradient_image_draw(GtkWidget *widget, cairo_t *cr); static void sp_gradient_image_gradient_release (SPObject *, SPGradientImage *im); static void sp_gradient_image_gradient_modified (SPObject *, guint flags, SPGradientImage *im); @@ -46,18 +40,10 @@ static void sp_gradient_image_class_init(SPGradientImageClass *klass) { GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass); -#if GTK_CHECK_VERSION(3,0,0) widget_class->get_preferred_width = sp_gradient_image_get_preferred_width; widget_class->get_preferred_height = sp_gradient_image_get_preferred_height; widget_class->draw = sp_gradient_image_draw; widget_class->destroy = sp_gradient_image_destroy; -#else - GtkObjectClass *object_class = GTK_OBJECT_CLASS(klass); - - object_class->destroy = sp_gradient_image_destroy; - widget_class->size_request = sp_gradient_image_size_request; - widget_class->expose_event = sp_gradient_image_expose; -#endif } static void @@ -71,11 +57,7 @@ sp_gradient_image_init (SPGradientImage *image) new (&image->modified_connection) sigc::connection(); } -#if GTK_CHECK_VERSION(3,0,0) static void sp_gradient_image_destroy(GtkWidget *object) -#else -static void sp_gradient_image_destroy(GtkObject *object) -#endif { SPGradientImage *image = SP_GRADIENT_IMAGE (object); @@ -88,13 +70,8 @@ static void sp_gradient_image_destroy(GtkObject *object) image->release_connection.~connection(); image->modified_connection.~connection(); -#if GTK_CHECK_VERSION(3,0,0) if (GTK_WIDGET_CLASS(sp_gradient_image_parent_class)->destroy) GTK_WIDGET_CLASS(sp_gradient_image_parent_class)->destroy(object); -#else - if (GTK_OBJECT_CLASS(sp_gradient_image_parent_class)->destroy) - GTK_OBJECT_CLASS(sp_gradient_image_parent_class)->destroy(object); -#endif } static void sp_gradient_image_size_request(GtkWidget * /*widget*/, GtkRequisition *requisition) @@ -103,7 +80,6 @@ static void sp_gradient_image_size_request(GtkWidget * /*widget*/, GtkRequisitio requisition->height = 12; } -#if GTK_CHECK_VERSION(3,0,0) static void sp_gradient_image_get_preferred_width(GtkWidget *widget, gint *minimal_width, gint *natural_width) { GtkRequisition requisition; @@ -117,27 +93,6 @@ static void sp_gradient_image_get_preferred_height(GtkWidget *widget, gint *mini sp_gradient_image_size_request(widget, &requisition); *minimal_height = *natural_height = requisition.height; } -#endif - -#if !GTK_CHECK_VERSION(3,0,0) -static gboolean sp_gradient_image_expose(GtkWidget *widget, GdkEventExpose *event) -{ - gboolean result = TRUE; - if(gtk_widget_is_drawable(widget)) { - cairo_t *ct = gdk_cairo_create(gtk_widget_get_window (widget)); - cairo_rectangle(ct, event->area.x, event->area.y, - event->area.width, event->area.height); - cairo_clip(ct); - GtkAllocation allocation; - gtk_widget_get_allocation(widget, &allocation); - cairo_translate(ct, allocation.x, allocation.y); - result = sp_gradient_image_draw(widget, ct); - cairo_destroy(ct); - } - - return result; -} -#endif static gboolean sp_gradient_image_draw(GtkWidget *widget, cairo_t *ct) { diff --git a/src/widgets/gradient-selector.cpp b/src/widgets/gradient-selector.cpp index 604ecd108..569f66c2b 100644 --- a/src/widgets/gradient-selector.cpp +++ b/src/widgets/gradient-selector.cpp @@ -14,7 +14,7 @@ */ #ifdef HAVE_CONFIG_H -# include "config.h" +#include <config.h> #endif #include <gtkmm/treeview.h> @@ -28,14 +28,11 @@ #include "inkscape.h" #include "verbs.h" #include "helper/action.h" -#include "helper/action-context.h" #include "preferences.h" #include "widgets/icon.h" #include <glibmm/i18n.h> -#include <xml/repr.h> -#include "gradient-selector.h" #include "paint-selector.h" #include "style.h" #include "id-clash.h" @@ -60,11 +57,7 @@ static void sp_gradient_selector_delete_vector_clicked (GtkWidget *w, SPGradient static guint signals[LAST_SIGNAL] = {0}; -#if GTK_CHECK_VERSION(3,0,0) G_DEFINE_TYPE(SPGradientSelector, sp_gradient_selector, GTK_TYPE_BOX); -#else -G_DEFINE_TYPE(SPGradientSelector, sp_gradient_selector, GTK_TYPE_VBOX); -#endif static void sp_gradient_selector_class_init(SPGradientSelectorClass *klass) { @@ -116,9 +109,7 @@ static void sp_gradient_selector_init(SPGradientSelector *sel) sel->safelyInit = true; sel->blocked = false; -#if GTK_CHECK_VERSION(3,0,0) gtk_orientable_set_orientation(GTK_ORIENTABLE(sel), GTK_ORIENTATION_VERTICAL); -#endif new (&sel->nonsolid) std::vector<GtkWidget*>(); new (&sel->swatch_widgets) std::vector<GtkWidget*>(); @@ -180,13 +171,8 @@ static void sp_gradient_selector_init(SPGradientSelector *sel) /* Create box for buttons */ -#if GTK_CHECK_VERSION(3,0,0) - GtkWidget *hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); + auto hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); gtk_box_set_homogeneous(GTK_BOX(hb), FALSE); -#else - GtkWidget *hb = gtk_hbox_new( FALSE, 2 ); -#endif - //sel->nonsolid.push_back(hb); gtk_box_pack_start( GTK_BOX(sel), hb, FALSE, FALSE, 0 ); sel->add = gtk_button_new(); diff --git a/src/widgets/gradient-selector.h b/src/widgets/gradient-selector.h index e090d7cbd..6b5d4ca60 100644 --- a/src/widgets/gradient-selector.h +++ b/src/widgets/gradient-selector.h @@ -45,11 +45,7 @@ class TreeView; struct SPGradientSelector { -#if GTK_CHECK_VERSION(3,0,0) GtkBox vbox; -#else - GtkVBox vbox; -#endif enum SelectorMode { MODE_LINEAR, @@ -131,11 +127,7 @@ struct SPGradientSelector { }; struct SPGradientSelectorClass { -#if GTK_CHECK_VERSION(3,0,0) GtkBoxClass parent_class; -#else - GtkVBoxClass parent_class; -#endif void (* grabbed) (SPGradientSelector *sel); void (* dragged) (SPGradientSelector *sel); diff --git a/src/widgets/gradient-toolbar.cpp b/src/widgets/gradient-toolbar.cpp index a44e9962e..8474327ca 100644 --- a/src/widgets/gradient-toolbar.cpp +++ b/src/widgets/gradient-toolbar.cpp @@ -13,7 +13,7 @@ */ #ifdef HAVE_CONFIG_H -# include "config.h" +#include <config.h> #endif #include "ui/widget/color-preview.h" @@ -27,9 +27,10 @@ #include "gradient-chemistry.h" #include "gradient-drag.h" #include "gradient-toolbar.h" -#include "widgets/ink-action.h" +#include "ink-action.h" +#include "ink-radio-action.h" +#include "ink-toggle-action.h" #include "macros.h" -#include "preferences.h" #include "selection.h" #include "sp-defs.h" #include "sp-linear-gradient.h" @@ -116,8 +117,8 @@ void gr_apply_gradient(Inkscape::Selection *selection, GrDrag *drag, SPGradient } // If no drag or no dragger selected, act on selection - std::vector<SPItem*> itemlist=selection->itemList(); - for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();++i){ + auto itemlist= selection->items(); + for(auto i=itemlist.begin();i!=itemlist.end();++i){ gr_apply_gradient_to_item(*i, gr, initialType, initialMode, initialMode); } } @@ -216,8 +217,8 @@ void gr_get_dt_selected_gradient(Inkscape::Selection *selection, SPGradient *&gr { SPGradient *gradient = 0; - std::vector<SPItem*> itemlist=selection->itemList(); - for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();++i){ + auto itemlist= selection->items(); + for(auto i=itemlist.begin();i!=itemlist.end();++i){ SPItem *item = *i;// get the items gradient, not the getVector() version SPStyle *style = item->style; SPPaintServer *server = 0; @@ -284,8 +285,8 @@ void gr_read_selection( Inkscape::Selection *selection, } // If no selected dragger, read desktop selection - std::vector<SPItem*> itemlist=selection->itemList(); - for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();++i){ + auto itemlist= selection->items(); + for(auto i=itemlist.begin();i!=itemlist.end();++i){ SPItem *item = *i; SPStyle *style = item->style; @@ -720,9 +721,9 @@ static void select_stop_by_drag(GtkWidget *combo_box, SPGradient *gradient, Tool static void select_stop_in_list( GtkWidget *combo_box, SPGradient *gradient, SPStop *new_stop, GtkWidget *data, gboolean block) { int i = 0; - for ( SPObject *ochild = gradient->firstChild() ; ochild ; ochild = ochild->getNext() ) { - if (SP_IS_STOP(ochild)) { - if (ochild == new_stop) { + for (auto& ochild: gradient->children) { + if (SP_IS_STOP(&ochild)) { + if (&ochild == new_stop) { blocked = block; gtk_combo_box_set_active(GTK_COMBO_BOX(combo_box) , i); gr_stop_set_offset(GTK_COMBO_BOX(combo_box), data); @@ -765,9 +766,9 @@ static gboolean update_stop_list( GtkWidget *stop_combo, SPGradient *gradient, S /* Populate the combobox store */ std::vector<SPObject *> sl; if ( gradient->hasStops() ) { - for ( SPObject *ochild = gradient->firstChild() ; ochild ; ochild = ochild->getNext() ) { - if (SP_IS_STOP(ochild)) { - sl.push_back(ochild); + for (auto& ochild: gradient->children) { + if (SP_IS_STOP(&ochild)) { + sl.push_back(&ochild); } } } diff --git a/src/widgets/gradient-vector.cpp b/src/widgets/gradient-vector.cpp index 97e65141f..0c5f3cf47 100644 --- a/src/widgets/gradient-vector.cpp +++ b/src/widgets/gradient-vector.cpp @@ -20,14 +20,13 @@ */ #ifdef HAVE_CONFIG_H -# include "config.h" +#include <config.h> #endif #include <glibmm.h> #include "gradient-vector.h" #include "ui/widget/color-preview.h" #include "verbs.h" -#include <gtk/gtk.h> #include "macros.h" #include <glibmm/i18n.h> #include <set> @@ -50,8 +49,6 @@ #include "desktop.h" #include "layer-manager.h" -#include <sigc++/functors/ptr_fun.h> -#include <sigc++/adaptors/bind.h> #include "document-undo.h" #include "ui/dialog-events.h" @@ -66,11 +63,7 @@ enum { LAST_SIGNAL }; -#if GTK_CHECK_VERSION(3,0,0) static void sp_gradient_vector_selector_destroy(GtkWidget *object); -#else -static void sp_gradient_vector_selector_destroy(GtkObject *object); -#endif static void sp_gvs_gradient_release(SPObject *obj, SPGradientVectorSelector *gvs); static void sp_gvs_defs_release(SPObject *defs, SPGradientVectorSelector *gvs); @@ -89,11 +82,7 @@ static win_data wd; static gint x = -1000, y = -1000, w = 0, h = 0; // impossible original values to make sure they are read from prefs static Glib::ustring const prefs_path = "/dialogs/gradienteditor/"; -#if GTK_CHECK_VERSION(3,0,0) G_DEFINE_TYPE(SPGradientVectorSelector, sp_gradient_vector_selector, GTK_TYPE_BOX); -#else -G_DEFINE_TYPE(SPGradientVectorSelector, sp_gradient_vector_selector, GTK_TYPE_VBOX); -#endif static void sp_gradient_vector_selector_class_init(SPGradientVectorSelectorClass *klass) { @@ -108,20 +97,13 @@ static void sp_gradient_vector_selector_class_init(SPGradientVectorSelectorClass G_TYPE_NONE, 1, G_TYPE_POINTER); -#if GTK_CHECK_VERSION(3,0,0) GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass); widget_class->destroy = sp_gradient_vector_selector_destroy; -#else - GtkObjectClass *object_class = GTK_OBJECT_CLASS(klass); - object_class->destroy = sp_gradient_vector_selector_destroy; -#endif } static void sp_gradient_vector_selector_init(SPGradientVectorSelector *gvs) { -#if GTK_CHECK_VERSION(3,0,0) gtk_orientable_set_orientation(GTK_ORIENTABLE(gvs), GTK_ORIENTATION_VERTICAL); -#endif gvs->idlabel = TRUE; @@ -140,11 +122,7 @@ static void sp_gradient_vector_selector_init(SPGradientVectorSelector *gvs) } -#if GTK_CHECK_VERSION(3,0,0) static void sp_gradient_vector_selector_destroy(GtkWidget *object) -#else -static void sp_gradient_vector_selector_destroy(GtkObject *object) -#endif { SPGradientVectorSelector *gvs = SP_GRADIENT_VECTOR_SELECTOR(object); @@ -165,15 +143,9 @@ static void sp_gradient_vector_selector_destroy(GtkObject *object) gvs->defs_modified_connection.~connection(); gvs->tree_select_connection.~connection(); -#if GTK_CHECK_VERSION(3,0,0) if ((GTK_WIDGET_CLASS(sp_gradient_vector_selector_parent_class))->destroy) { (GTK_WIDGET_CLASS(sp_gradient_vector_selector_parent_class))->destroy(object); } -#else - if ((GTK_OBJECT_CLASS(sp_gradient_vector_selector_parent_class))->destroy) { - (GTK_OBJECT_CLASS(sp_gradient_vector_selector_parent_class))->destroy(object); - } -#endif } GtkWidget *sp_gradient_vector_selector_new(SPDocument *doc, SPGradient *gr) @@ -363,13 +335,13 @@ unsigned long sp_gradient_to_hhssll(SPGradient *gr) 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)) { - list = g_slist_prepend(list, SP_ITEM(child)); + for (auto& child: from->children) { + if (SP_IS_ITEM(&child)) { + list = g_slist_prepend(list, SP_ITEM(&child)); } - if (ingroups || SP_IS_ITEM(child)) { - list = get_all_doc_items(list, child, onlyvisible, onlysensitive, ingroups, exclude); + if (ingroups || SP_IS_ITEM(&child)) { + list = get_all_doc_items(list, &child, onlyvisible, onlysensitive, ingroups, exclude); } } @@ -476,7 +448,6 @@ void SPGradientVectorSelector::setSwatched() #include "widgets/widget-sizes.h" #include "xml/node-event-vector.h" #include "svg/svg-color.h" -#include "ui/widget/color-notebook.h" #define PAD 4 @@ -484,15 +455,8 @@ static GtkWidget *sp_gradient_vector_widget_new(SPGradient *gradient, SPStop *st static void sp_gradient_vector_widget_load_gradient(GtkWidget *widget, SPGradient *gradient); static gint sp_gradient_vector_dialog_delete(GtkWidget *widget, GdkEvent *event, GtkWidget *dialog); - -#if GTK_CHECK_VERSION(3,0,0) static void sp_gradient_vector_dialog_destroy(GtkWidget *object, gpointer data); static void sp_gradient_vector_widget_destroy(GtkWidget *object, gpointer data); -#else -static void sp_gradient_vector_dialog_destroy(GtkObject *object, gpointer data); -static void sp_gradient_vector_widget_destroy(GtkObject *object, gpointer data); -#endif - static void sp_gradient_vector_gradient_release(SPObject *obj, GtkWidget *widget); static void sp_gradient_vector_gradient_modified(SPObject *obj, guint flags, GtkWidget *widget); static void sp_gradient_vector_color_dragged(Inkscape::UI::SelectedColor *selected_color, GObject *object); @@ -525,10 +489,10 @@ static void verify_grad(SPGradient *gradient) int i = 0; SPStop *stop = NULL; /* count stops */ - for ( SPObject *ochild = gradient->firstChild() ; ochild ; ochild = ochild->getNext() ) { - if (SP_IS_STOP(ochild)) { + for (auto& ochild: gradient->children) { + if (SP_IS_STOP(&ochild)) { i++; - stop = SP_STOP(ochild); + stop = SP_STOP(&ochild); } } @@ -568,9 +532,9 @@ static void select_stop_in_list( GtkWidget *vb, SPGradient *gradient, SPStop *ne GtkWidget *combo_box = static_cast<GtkWidget *>(g_object_get_data(G_OBJECT(vb), "combo_box")); int i = 0; - for ( SPObject *ochild = gradient->firstChild() ; ochild ; ochild = ochild->getNext() ) { - if (SP_IS_STOP(ochild)) { - if (ochild == new_stop) { + for (auto& ochild: gradient->children) { + if (SP_IS_STOP(&ochild)) { + if (&ochild == new_stop) { gtk_combo_box_set_active (GTK_COMBO_BOX(combo_box) , i); break; } @@ -603,9 +567,9 @@ static void update_stop_list( GtkWidget *vb, SPGradient *gradient, SPStop *new_s /* Populate the combobox store */ GSList *sl = NULL; if ( gradient->hasStops() ) { - for ( SPObject *ochild = gradient->firstChild() ; ochild ; ochild = ochild->getNext() ) { - if (SP_IS_STOP(ochild)) { - sl = g_slist_append(sl, ochild); + for (auto& ochild: gradient->children) { + if (SP_IS_STOP(&ochild)) { + sl = g_slist_append(sl, &ochild); } } } @@ -845,12 +809,8 @@ static GtkWidget * sp_gradient_vector_widget_new(SPGradient *gradient, SPStop *s g_return_val_if_fail(gradient != NULL, NULL); g_return_val_if_fail(SP_IS_GRADIENT(gradient), NULL); -#if GTK_CHECK_VERSION(3,0,0) vb = gtk_box_new(GTK_ORIENTATION_VERTICAL, PAD); gtk_box_set_homogeneous(GTK_BOX(vb), FALSE); -#else - vb = gtk_vbox_new(FALSE, PAD); -#endif g_signal_connect(G_OBJECT(vb), "destroy", G_CALLBACK(sp_gradient_vector_widget_destroy), NULL); w = sp_gradient_image_new(gradient); @@ -883,12 +843,8 @@ static GtkWidget * sp_gradient_vector_widget_new(SPGradient *gradient, SPStop *s g_signal_connect(G_OBJECT(combo_box), "changed", G_CALLBACK(sp_grad_edit_combo_box_changed), vb); /* Add and Remove buttons */ -#if GTK_CHECK_VERSION(3,0,0) - GtkWidget *hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 1); + auto hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 1); gtk_box_set_homogeneous(GTK_BOX(hb), FALSE); -#else - GtkWidget *hb = gtk_hbox_new(FALSE, 1); -#endif // TRANSLATORS: "Stop" means: a "phase" of a gradient GtkWidget *b = gtk_button_new_with_label(_("Add stop")); gtk_widget_show(b); @@ -905,21 +861,12 @@ static GtkWidget * sp_gradient_vector_widget_new(SPGradient *gradient, SPStop *s gtk_box_pack_start(GTK_BOX(vb),hb, FALSE, FALSE, AUX_BETWEEN_BUTTON_GROUPS); /* Offset Slider and stuff */ -#if GTK_CHECK_VERSION(3,0,0) hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); gtk_box_set_homogeneous(GTK_BOX(hb), FALSE); -#else - hb = gtk_hbox_new(FALSE, 0); -#endif /* Label */ GtkWidget *l = gtk_label_new(C_("Gradient","Offset:")); - -#if GTK_CHECK_VERSION(3,0,0) gtk_widget_set_halign(l, GTK_ALIGN_END); -#else - gtk_misc_set_alignment(GTK_MISC(l), 1.0, 0.5); -#endif gtk_box_pack_start(GTK_BOX(hb),l, FALSE, FALSE, AUX_BETWEEN_BUTTON_GROUPS); gtk_widget_show(l); @@ -937,11 +884,7 @@ static GtkWidget * sp_gradient_vector_widget_new(SPGradient *gradient, SPStop *s gtk_adjustment_set_value(Offset_adj, stop->offset); /* Slider */ -#if GTK_CHECK_VERSION(3,0,0) - GtkWidget *slider = gtk_scale_new(GTK_ORIENTATION_HORIZONTAL, Offset_adj); -#else - GtkWidget *slider = gtk_hscale_new(Offset_adj); -#endif + auto slider = gtk_scale_new(GTK_ORIENTATION_HORIZONTAL, Offset_adj); gtk_scale_set_draw_value( GTK_SCALE(slider), FALSE ); gtk_widget_show(slider); gtk_box_pack_start(GTK_BOX(hb),slider, TRUE, TRUE, AUX_BETWEEN_BUTTON_GROUPS); @@ -1179,11 +1122,7 @@ static void sp_gradient_vector_widget_load_gradient(GtkWidget *widget, SPGradien blocked = FALSE; } -#if GTK_CHECK_VERSION(3,0,0) static void sp_gradient_vector_dialog_destroy(GtkWidget * /*object*/, gpointer /*data*/) -#else -static void sp_gradient_vector_dialog_destroy(GtkObject * /*object*/, gpointer /*data*/) -#endif { GObject *obj = G_OBJECT(dlg); assert(obj != NULL); @@ -1234,11 +1173,7 @@ static gboolean sp_gradient_vector_dialog_delete(GtkWidget */*widget*/, GdkEvent } /* Widget destroy handler */ -#if GTK_CHECK_VERSION(3,0,0) static void sp_gradient_vector_widget_destroy(GtkWidget *object, gpointer /*data*/) -#else -static void sp_gradient_vector_widget_destroy(GtkObject *object, gpointer /*data*/) -#endif { SPObject *gradient = SP_OBJECT(g_object_get_data(G_OBJECT(object), "gradient")); diff --git a/src/widgets/gradient-vector.h b/src/widgets/gradient-vector.h index 5ae90b28f..b51b276b9 100644 --- a/src/widgets/gradient-vector.h +++ b/src/widgets/gradient-vector.h @@ -35,11 +35,7 @@ class SPGradient; class SPStop; struct SPGradientVectorSelector { -#if GTK_CHECK_VERSION(3,0,0) GtkBox vbox; -#else - GtkVBox vbox; -#endif guint idlabel : 1; @@ -61,11 +57,7 @@ struct SPGradientVectorSelector { }; struct SPGradientVectorSelectorClass { -#if GTK_CHECK_VERSION(3,0,0) GtkBoxClass parent_class; -#else - GtkVBoxClass parent_class; -#endif void (* vector_set) (SPGradientVectorSelector *gvs, SPGradient *gr); }; diff --git a/src/widgets/icon.cpp b/src/widgets/icon.cpp index f2031fe51..1efa8f06b 100644 --- a/src/widgets/icon.cpp +++ b/src/widgets/icon.cpp @@ -16,22 +16,19 @@ # include "config.h" #endif +#include <glibmm/fileutils.h> +#include <glibmm/miscutils.h> #include <gtkmm/icontheme.h> #include <cstring> -#include <glib.h> #include <glib/gstdio.h> #include <gtk/gtk.h> #include <gtkmm/image.h> -#include <gdkmm/pixbuf.h> -#include <glibmm/fileutils.h> -#include <glibmm/miscutils.h> #include <2geom/transforms.h> #include "path-prefix.h" #include "preferences.h" #include "inkscape.h" #include "document.h" -#include "sp-item.h" #include "display/cairo-utils.h" #include "display/drawing-context.h" #include "display/drawing-item.h" @@ -64,10 +61,6 @@ struct IconImpl { static void sizeAllocate(GtkWidget *widget, GtkAllocation *allocation); static gboolean draw(GtkWidget *widget, cairo_t *cr); -#if !GTK_CHECK_VERSION(3,0,0) - static gboolean expose(GtkWidget *widget, GdkEventExpose *event); -#endif - static void screenChanged( GtkWidget *widget, GdkScreen *previous_screen ); static void styleSet( GtkWidget *widget, GtkStyle *previous_style ); static void themeChanged( SPIcon *icon ); @@ -149,14 +142,9 @@ sp_icon_class_init(SPIconClass *klass) object_class->dispose = IconImpl::dispose; -#if GTK_CHECK_VERSION(3,0,0) widget_class->get_preferred_width = IconImpl::getPreferredWidth; widget_class->get_preferred_height = IconImpl::getPreferredHeight; widget_class->draw = IconImpl::draw; -#else - widget_class->size_request = IconImpl::sizeRequest; - widget_class->expose_event = IconImpl::expose; -#endif widget_class->size_allocate = IconImpl::sizeAllocate; widget_class->screen_changed = IconImpl::screenChanged; widget_class->style_set = IconImpl::styleSet; @@ -244,37 +232,15 @@ gboolean IconImpl::draw(GtkWidget *widget, cairo_t* cr) bool unref_image = false; /* copied from the expose function of GtkImage */ -#if GTK_CHECK_VERSION(3,0,0) if (gtk_widget_get_state_flags (GTK_WIDGET(icon)) != GTK_STATE_FLAG_NORMAL && image) { -#else - if (gtk_widget_get_state (GTK_WIDGET(icon)) != GTK_STATE_NORMAL && image) { - std::cerr << "IconImpl::draw: Ooops! It is called in GTK2" << std::endl; -#endif std::cerr << "IconImpl::draw: No image, creating fallback" << std::endl; -#if GTK_CHECK_VERSION(3,0,0) - // image = gtk_render_icon_pixbuf(gtk_widget_get_style_context(widget), - // source, - // (GtkIconSize)-1); - - // gtk_render_icon_pixbuf deprecated, replaced by: GtkIconTheme *icon_theme = gtk_icon_theme_get_default(); image = gtk_icon_theme_load_icon (icon_theme, "gtk-image", 32, (GtkIconLookupFlags)0, NULL); -#else - GtkIconSource *source = gtk_icon_source_new(); - gtk_icon_source_set_pixbuf(source, icon->pb); - gtk_icon_source_set_size(source, GTK_ICON_SIZE_SMALL_TOOLBAR); // note: this is boilerplate and not used - gtk_icon_source_set_size_wildcarded(source, FALSE); - image = gtk_style_render_icon(gtk_widget_get_style(widget), source, - gtk_widget_get_direction(widget), - (GtkStateType) gtk_widget_get_state(widget), - (GtkIconSize)-1, widget, "gtk-image"); - gtk_icon_source_free(source); -#endif unref_image = true; } @@ -283,12 +249,7 @@ gboolean IconImpl::draw(GtkWidget *widget, cairo_t* cr) GtkAllocation allocation; GtkRequisition requisition; gtk_widget_get_allocation(widget, &allocation); - -#if GTK_CHECK_VERSION(3,0,0) gtk_widget_get_preferred_size(widget, &requisition, NULL); -#else - gtk_widget_get_requisition(widget, &requisition); -#endif int x = floor(allocation.x + ((allocation.width - requisition.width) * 0.5)); int y = floor(allocation.y + ((allocation.height - requisition.height) * 0.5)); @@ -308,21 +269,6 @@ gboolean IconImpl::draw(GtkWidget *widget, cairo_t* cr) return TRUE; } -#if !GTK_CHECK_VERSION(3,0,0) -gboolean IconImpl::expose(GtkWidget *widget, GdkEventExpose * /*event*/) -{ - gboolean result = TRUE; - - if (gtk_widget_is_drawable(widget)) { - cairo_t * cr = gdk_cairo_create(gtk_widget_get_window(widget)); - result = draw(widget, cr); - cairo_destroy(cr); - } - - return result; -} -#endif - // PUBLIC CALL: void sp_icon_fetch_pixbuf( SPIcon *icon ) { diff --git a/src/widgets/ink-action.cpp b/src/widgets/ink-action.cpp index ace99d9aa..2f1bf94e4 100644 --- a/src/widgets/ink-action.cpp +++ b/src/widgets/ink-action.cpp @@ -1,20 +1,10 @@ +#include "ink-action.h" #include "widgets/icon.h" -#include "icon-size.h" -#include <glib/gi18n.h> - -#include "widgets/ink-action.h" - -#include "widgets/button.h" +#include "widgets/image-menu-item.h" #include <gtk/gtk.h> -#if GTK_CHECK_VERSION(3,0,0) - // Fork of gtk-imagemenuitem to continue support - #include "widgets/image-menu-item.h" - -#endif - static void ink_action_finalize( GObject* obj ); static void ink_action_get_property( GObject* obj, guint propId, GValue* value, GParamSpec * pspec ); static void ink_action_set_property( GObject* obj, guint propId, const GValue *value, GParamSpec* pspec ); @@ -165,12 +155,7 @@ static GtkWidget* ink_action_create_menu_item( GtkAction* action ) if ( act->private_data->iconId ) { gchar* label = 0; g_object_get( G_OBJECT(act), "label", &label, NULL ); - -#if GTK_CHECK_VERSION(3,0,0) item = image_menu_item_new_with_mnemonic( label ); -#else - item = gtk_image_menu_item_new_with_mnemonic( label ); -#endif GtkWidget* child = sp_icon_new( Inkscape::ICON_SIZE_MENU, act->private_data->iconId ); // TODO this work-around is until SPIcon will live properly inside of a popup menu @@ -185,12 +170,7 @@ static GtkWidget* ink_action_create_menu_item( GtkAction* action ) } } gtk_widget_show_all( child ); - -#if GTK_CHECK_VERSION(3,0,0) image_menu_item_set_image( IMAGE_MENU_ITEM(item), child ); -#else - gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM(item), child ); -#endif g_free( label ); label = 0; @@ -225,454 +205,13 @@ static GtkWidget* ink_action_create_tool_item( GtkAction* action ) return item; } - - -/* --------------------------------------------------------------- */ -/* --------------------------------------------------------------- */ -/* --------------------------------------------------------------- */ -/* --------------------------------------------------------------- */ - - -static void ink_toggle_action_finalize( GObject* obj ); -static void ink_toggle_action_get_property( GObject* obj, guint propId, GValue* value, GParamSpec * pspec ); -static void ink_toggle_action_set_property( GObject* obj, guint propId, const GValue *value, GParamSpec* pspec ); - -static GtkWidget* ink_toggle_action_create_menu_item( GtkAction* action ); -static GtkWidget* ink_toggle_action_create_tool_item( GtkAction* action ); - -static void ink_toggle_action_update_icon( InkToggleAction* action ); - -struct _InkToggleActionPrivate -{ - gchar* iconId; - Inkscape::IconSize iconSize; -}; - -#define INK_TOGGLE_ACTION_GET_PRIVATE( o ) ( G_TYPE_INSTANCE_GET_PRIVATE( (o), INK_TOGGLE_ACTION_TYPE, InkToggleActionPrivate ) ) - -G_DEFINE_TYPE(InkToggleAction, ink_toggle_action, GTK_TYPE_TOGGLE_ACTION); - -static void ink_toggle_action_class_init( InkToggleActionClass* klass ) -{ - if ( klass ) { - GObjectClass * objClass = G_OBJECT_CLASS( klass ); - - objClass->finalize = ink_toggle_action_finalize; - objClass->get_property = ink_toggle_action_get_property; - objClass->set_property = ink_toggle_action_set_property; - - klass->parent_class.parent_class.create_menu_item = ink_toggle_action_create_menu_item; - klass->parent_class.parent_class.create_tool_item = ink_toggle_action_create_tool_item; - /*klass->parent_class.connect_proxy = connect_proxy;*/ - /*klass->parent_class.disconnect_proxy = disconnect_proxy;*/ - - g_object_class_install_property( objClass, - PROP_INK_ID, - g_param_spec_string( "iconId", - "Icon ID", - "The id for the icon", - "", - (GParamFlags)(G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT) ) ); - - g_object_class_install_property( objClass, - PROP_INK_SIZE, - g_param_spec_int( "iconSize", - "Icon Size", - "The size the icon", - (int)Inkscape::ICON_SIZE_MENU, - (int)99, - (int)Inkscape::ICON_SIZE_SMALL_TOOLBAR, - (GParamFlags)(G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT) ) ); - - g_type_class_add_private( klass, sizeof(InkToggleActionClass) ); - } -} - -static void ink_toggle_action_init( InkToggleAction* action ) -{ - action->private_data = INK_TOGGLE_ACTION_GET_PRIVATE( action ); - action->private_data->iconId = 0; - action->private_data->iconSize = Inkscape::ICON_SIZE_SMALL_TOOLBAR; -} - -static void ink_toggle_action_finalize( GObject* obj ) -{ - InkToggleAction* action = INK_TOGGLE_ACTION( obj ); - - g_free( action->private_data->iconId ); - g_free( action->private_data ); - -} - -InkToggleAction* ink_toggle_action_new( const gchar *name, - const gchar *label, - const gchar *tooltip, - const gchar *inkId, - Inkscape::IconSize size, - SPAttributeEnum attr) -{ - GObject* obj = (GObject*)g_object_new( INK_TOGGLE_ACTION_TYPE, - "name", name, - "label", label, - "tooltip", tooltip, - "iconId", inkId, - "iconSize", Inkscape::getRegisteredIconSize(size), - //"SP_ATTR_INKSCAPE", attr, // Why doesn't this work and do I need to use g_object_set_data below? - NULL ); - - g_object_set_data(obj, "SP_ATTR_INKSCAPE", GINT_TO_POINTER(attr)); - InkToggleAction* action = INK_TOGGLE_ACTION( obj ); - - return action; -} - -static void ink_toggle_action_get_property( GObject* obj, guint propId, GValue* value, GParamSpec * pspec ) -{ - InkToggleAction* action = INK_TOGGLE_ACTION( obj ); - (void)action; - switch ( propId ) { - case PROP_INK_ID: - { - g_value_set_string( value, action->private_data->iconId ); - } - break; - - case PROP_INK_SIZE: - { - g_value_set_int( value, action->private_data->iconSize ); - } - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID( obj, propId, pspec ); - } -} - -void ink_toggle_action_set_property( GObject* obj, guint propId, const GValue *value, GParamSpec* pspec ) -{ - InkToggleAction* action = INK_TOGGLE_ACTION( obj ); - (void)action; - switch ( propId ) { - case PROP_INK_ID: - { - gchar* tmp = action->private_data->iconId; - action->private_data->iconId = g_value_dup_string( value ); - g_free( tmp ); - - ink_toggle_action_update_icon( action ); - } - break; - - case PROP_INK_SIZE: - { - action->private_data->iconSize = (Inkscape::IconSize)g_value_get_int( value ); - } - break; - - default: - { - G_OBJECT_WARN_INVALID_PROPERTY_ID( obj, propId, pspec ); - } - } -} - -static GtkWidget* ink_toggle_action_create_menu_item( GtkAction* action ) -{ - GtkWidget* item = GTK_TOGGLE_ACTION_CLASS(ink_toggle_action_parent_class)->parent_class.create_menu_item(action); - - return item; -} - -static GtkWidget* ink_toggle_action_create_tool_item( GtkAction* action ) -{ - InkToggleAction* act = INK_TOGGLE_ACTION( action ); - - GtkWidget* item = GTK_TOGGLE_ACTION_CLASS(ink_toggle_action_parent_class)->parent_class.create_tool_item(action); - if ( GTK_IS_TOOL_BUTTON(item) ) { - GtkToolButton* button = GTK_TOOL_BUTTON(item); - if ( act->private_data->iconId ) { - GtkWidget* child = sp_icon_new( act->private_data->iconSize, act->private_data->iconId ); - -#if GTK_CHECK_VERSION(3,0,0) - gtk_widget_set_hexpand(child, FALSE); - gtk_widget_set_vexpand(child, FALSE); - gtk_tool_button_set_icon_widget(button, child); -#else - GtkWidget* align = gtk_alignment_new( 0.5, 0.5, 0.0, 0.0 ); - gtk_container_add( GTK_CONTAINER(align), child ); - gtk_tool_button_set_icon_widget( button, align ); -#endif - } else { - gchar *label = 0; - g_object_get( G_OBJECT(action), "short_label", &label, NULL ); - gtk_tool_button_set_label( button, label ); - g_free( label ); - label = 0; - } - } else { - // For now trigger a warning but don't do anything else - GtkToolButton* button = GTK_TOOL_BUTTON(item); - (void)button; - } - gtk_widget_show_all( item ); - - return item; -} - - -static void ink_toggle_action_update_icon( InkToggleAction* action ) -{ - if ( action ) { - GSList* proxies = gtk_action_get_proxies( GTK_ACTION(action) ); - while ( proxies ) { - if ( GTK_IS_TOOL_ITEM(proxies->data) ) { - if ( GTK_IS_TOOL_BUTTON(proxies->data) ) { - GtkToolButton* button = GTK_TOOL_BUTTON(proxies->data); - - GtkWidget* child = sp_icon_new( action->private_data->iconSize, action->private_data->iconId ); - -#if GTK_CHECK_VERSION(3,0,0) - gtk_widget_set_hexpand(child, FALSE); - gtk_widget_set_vexpand(child, FALSE); - gtk_widget_show_all(child); - gtk_tool_button_set_icon_widget(button, child); -#else - 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 ); -#endif - } - } - - proxies = g_slist_next( proxies ); - } - } -} - - -/* --------------------------------------------------------------- */ -/* --------------------------------------------------------------- */ -/* --------------------------------------------------------------- */ -/* --------------------------------------------------------------- */ - - -static void ink_radio_action_finalize( GObject* obj ); -static void ink_radio_action_get_property( GObject* obj, guint propId, GValue* value, GParamSpec * pspec ); -static void ink_radio_action_set_property( GObject* obj, guint propId, const GValue *value, GParamSpec* pspec ); - -static GtkWidget* ink_radio_action_create_menu_item( GtkAction* action ); -static GtkWidget* ink_radio_action_create_tool_item( GtkAction* action ); - -struct _InkRadioActionPrivate -{ - gchar* iconId; - Inkscape::IconSize iconSize; -}; - -#define INK_RADIO_ACTION_GET_PRIVATE( o ) ( G_TYPE_INSTANCE_GET_PRIVATE( (o), INK_RADIO_ACTION_TYPE, InkRadioActionPrivate ) ) - -G_DEFINE_TYPE(InkRadioAction, ink_radio_action, GTK_TYPE_RADIO_ACTION); - -static void ink_radio_action_class_init( InkRadioActionClass* klass ) -{ - if ( klass ) { - GObjectClass * objClass = G_OBJECT_CLASS( klass ); - - objClass->finalize = ink_radio_action_finalize; - objClass->get_property = ink_radio_action_get_property; - objClass->set_property = ink_radio_action_set_property; - - klass->parent_class.parent_class.parent_class.create_menu_item = ink_radio_action_create_menu_item; - klass->parent_class.parent_class.parent_class.create_tool_item = ink_radio_action_create_tool_item; - /*klass->parent_class.connect_proxy = connect_proxy;*/ - /*klass->parent_class.disconnect_proxy = disconnect_proxy;*/ - - g_object_class_install_property( objClass, - PROP_INK_ID, - g_param_spec_string( "iconId", - "Icon ID", - "The id for the icon", - "", - (GParamFlags)(G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT) ) ); - - g_object_class_install_property( objClass, - PROP_INK_SIZE, - g_param_spec_int( "iconSize", - "Icon Size", - "The size the icon", - (int)Inkscape::ICON_SIZE_MENU, - (int)Inkscape::ICON_SIZE_DECORATION, - (int)Inkscape::ICON_SIZE_SMALL_TOOLBAR, - (GParamFlags)(G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT) ) ); - - g_type_class_add_private( klass, sizeof(InkRadioActionClass) ); - } -} - -static void ink_radio_action_init( InkRadioAction* action ) -{ - action->private_data = INK_RADIO_ACTION_GET_PRIVATE( action ); - action->private_data->iconId = 0; - action->private_data->iconSize = Inkscape::ICON_SIZE_SMALL_TOOLBAR; -} - -static void ink_radio_action_finalize( GObject* obj ) -{ - InkRadioAction* action = INK_RADIO_ACTION( obj ); - - g_free( action->private_data->iconId ); - g_free( action->private_data ); - -} - -InkRadioAction* ink_radio_action_new( const gchar *name, - const gchar *label, - const gchar *tooltip, - const gchar *inkId, - Inkscape::IconSize size ) -{ - GObject* obj = (GObject*)g_object_new( INK_RADIO_ACTION_TYPE, - "name", name, - "label", label, - "tooltip", tooltip, - "iconId", inkId, - "iconSize", Inkscape::getRegisteredIconSize(size), - NULL ); - - InkRadioAction* action = INK_RADIO_ACTION( obj ); - - return action; -} - -static void ink_radio_action_get_property( GObject* obj, guint propId, GValue* value, GParamSpec * pspec ) -{ - InkRadioAction* action = INK_RADIO_ACTION( obj ); - (void)action; - switch ( propId ) { - case PROP_INK_ID: - { - g_value_set_string( value, action->private_data->iconId ); - } - break; - - case PROP_INK_SIZE: - { - g_value_set_int( value, action->private_data->iconSize ); - } - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID( obj, propId, pspec ); - } -} - -void ink_radio_action_set_property( GObject* obj, guint propId, const GValue *value, GParamSpec* pspec ) -{ - InkRadioAction* action = INK_RADIO_ACTION( obj ); - (void)action; - switch ( propId ) { - case PROP_INK_ID: - { - gchar* tmp = action->private_data->iconId; - action->private_data->iconId = g_value_dup_string( value ); - g_free( tmp ); - } - break; - - case PROP_INK_SIZE: - { - action->private_data->iconSize = (Inkscape::IconSize)g_value_get_int( value ); - } - break; - - default: - { - G_OBJECT_WARN_INVALID_PROPERTY_ID( obj, propId, pspec ); - } - } -} - -static GtkWidget* ink_radio_action_create_menu_item( GtkAction* action ) -{ - GtkWidget* item = GTK_RADIO_ACTION_CLASS(ink_radio_action_parent_class)->parent_class.parent_class.create_menu_item(action); - - return item; -} - -static GtkWidget* ink_radio_action_create_tool_item( GtkAction* action ) -{ - InkRadioAction* act = INK_RADIO_ACTION( action ); - GtkWidget* item = GTK_RADIO_ACTION_CLASS(ink_radio_action_parent_class)->parent_class.parent_class.create_tool_item(action); - - if ( act->private_data->iconId ) { - if ( GTK_IS_TOOL_BUTTON(item) ) { - GtkToolButton* button = GTK_TOOL_BUTTON(item); - - GtkWidget* child = sp_icon_new( act->private_data->iconSize, act->private_data->iconId ); - -#if GTK_CHECK_VERSION(3,0,0) - gtk_widget_set_hexpand(child, FALSE); - gtk_widget_set_vexpand(child, FALSE); - gtk_tool_button_set_icon_widget(button, child); -#else - GtkWidget* align = gtk_alignment_new( 0.5, 0.5, 0.0, 0.0 ); - gtk_container_add( GTK_CONTAINER(align), child ); - gtk_tool_button_set_icon_widget( button, align ); -#endif - } else { - // For now trigger a warning but don't do anything else - GtkToolButton* button = GTK_TOOL_BUTTON(item); - (void)button; - } - } - - // TODO investigate if needed - gtk_widget_show_all( item ); - - return item; -} - - -/* --------------------------------------------------------------- */ -/* --------------------------------------------------------------- */ -/* --------------------------------------------------------------- */ -/* --------------------------------------------------------------- */ - -// ToolMenu Action is happily derived from http://www.gtkforums.com/viewtopic.php?t=4215 - -G_DEFINE_TYPE(InkToolMenuAction, ink_tool_menu_action, INK_ACTION_TYPE); - -static void -ink_tool_menu_action_class_init (InkToolMenuActionClass *klass) -{ - GtkActionClass *action_class = GTK_ACTION_CLASS (klass); - action_class->toolbar_item_type = GTK_TYPE_MENU_TOOL_BUTTON; -} - -static void -ink_tool_menu_action_init (InkToolMenuAction* /*tma*/) -{ -} - -InkToolMenuAction * -ink_tool_menu_action_new (const gchar *name, - const gchar *label, - const gchar *tooltip, - const gchar *inkId, - Inkscape::IconSize size ) -{ - g_return_val_if_fail (name != NULL, NULL); - - GObject* obj = (GObject*)g_object_new( INK_TOOL_MENU_ACTION_TYPE, - "name", name, - "label", label, - "tooltip", tooltip, - "iconId", inkId, - "iconSize", size, - NULL ); - - InkToolMenuAction* action = INK_TOOL_MENU_ACTION( obj ); - - return action; -} +/* + 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/ink-action.h b/src/widgets/ink-action.h index ac5cb9873..738212c61 100644 --- a/src/widgets/ink-action.h +++ b/src/widgets/ink-action.h @@ -1,7 +1,6 @@ #ifndef SEEN_INK_ACTION #define SEEN_INK_ACTION - #include <gtk/gtk.h> #include "icon-size.h" #include "attributes.h" @@ -41,119 +40,16 @@ InkAction* ink_action_new( const gchar *name, Inkscape::IconSize size ); -/* --------------------------------------------------------------- */ -/* --------------------------------------------------------------- */ -/* --------------------------------------------------------------- */ -/* --------------------------------------------------------------- */ - - -#define INK_TOGGLE_ACTION_TYPE ( ink_toggle_action_get_type() ) -#define INK_TOGGLE_ACTION( obj ) ( G_TYPE_CHECK_INSTANCE_CAST( (obj), INK_TOGGLE_ACTION_TYPE, InkToggleAction) ) -#define INK_TOGGLE_ACTION_CLASS( klass ) ( G_TYPE_CHECK_CLASS_CAST( (klass), INK_TOGGLE_ACTION_TYPE, InkToggleActionClass) ) -#define IS_INK_TOGGLE_ACTION( obj ) ( G_TYPE_CHECK_INSTANCE_TYPE( (obj), INK_TOGGLE_ACTION_TYPE) ) -#define IS_INK_TOGGLE_ACTION_CLASS( klass ) ( G_TYPE_CHECK_CLASS_TYPE( (klass), INK_TOGGLE_ACTION_TYPE) ) -#define INK_TOGGLE_ACTION_GET_CLASS( obj ) ( G_TYPE_INSTANCE_GET_CLASS( (obj), INK_TOGGLE_ACTION_TYPE, InkToggleActionClass) ) - -typedef struct _InkToggleAction InkToggleAction; -typedef struct _InkToggleActionClass InkToggleActionClass; -typedef struct _InkToggleActionPrivate InkToggleActionPrivate; - -struct _InkToggleAction -{ - GtkToggleAction action; - InkToggleActionPrivate *private_data; -}; - -struct _InkToggleActionClass -{ - GtkToggleActionClass parent_class; -}; - -GType ink_toggle_action_get_type( void ); - -InkToggleAction* ink_toggle_action_new( const gchar *name, - const gchar *label, - const gchar *tooltip, - const gchar *inkId, - Inkscape::IconSize size, - SPAttributeEnum attr = SP_ATTR_INVALID); - - -/* --------------------------------------------------------------- */ -/* --------------------------------------------------------------- */ -/* --------------------------------------------------------------- */ -/* --------------------------------------------------------------- */ - - -#define INK_RADIO_ACTION_TYPE ( ink_radio_action_get_type() ) -#define INK_RADIO_ACTION( obj ) ( G_TYPE_CHECK_INSTANCE_CAST( (obj), INK_RADIO_ACTION_TYPE, InkRadioAction) ) -#define INK_RADIO_ACTION_CLASS( klass ) ( G_TYPE_CHECK_CLASS_CAST( (klass), INK_RADIO_ACTION_TYPE, InkRadioActionClass) ) -#define IS_INK_RADIO_ACTION( obj ) ( G_TYPE_CHECK_INSTANCE_TYPE( (obj), INK_RADIO_ACTION_TYPE) ) -#define IS_INK_RADIO_ACTION_CLASS( klass ) ( G_TYPE_CHECK_CLASS_TYPE( (klass), INK_RADIO_ACTION_TYPE) ) -#define INK_RADIO_ACTION_GET_CLASS( obj ) ( G_TYPE_INSTANCE_GET_CLASS( (obj), INK_RADIO_ACTION_TYPE, InkRadioActionClass) ) - -typedef struct _InkRadioAction InkRadioAction; -typedef struct _InkRadioActionClass InkRadioActionClass; -typedef struct _InkRadioActionPrivate InkRadioActionPrivate; - -struct _InkRadioAction -{ - GtkRadioAction action; - InkRadioActionPrivate *private_data; -}; - -struct _InkRadioActionClass -{ - GtkRadioActionClass parent_class; -}; - -GType ink_radio_action_get_type( void ); - -InkRadioAction* ink_radio_action_new( const gchar *name, - const gchar *label, - const gchar *tooltip, - const gchar *inkId, - Inkscape::IconSize size ); - - -/* --------------------------------------------------------------- */ -/* --------------------------------------------------------------- */ -/* --------------------------------------------------------------- */ -/* --------------------------------------------------------------- */ - -// ToolMenu Action is happily derived from http://www.gtkforums.com/viewtopic.php?t=4215 - -#define INK_TOOL_MENU_ACTION_TYPE ( ink_tool_menu_action_get_type() ) -#define INK_TOOL_MENU_ACTION( obj ) ( G_TYPE_CHECK_INSTANCE_CAST( (obj), INK_TOOL_MENU_ACTION_TYPE, InkToolMenuAction) ) -#define INK_TOOL_MENU_ACTION_CLASS( klass ) ( G_TYPE_CHECK_CLASS_CAST( (klass), INK_TOOL_MENU_ACTION_TYPE, InkToolMenuActionClass) ) -#define IS_INK_TOOL_MENU_ACTION( obj ) ( G_TYPE_CHECK_INSTANCE_TYPE( (obj), INK_TOOL_MENU_ACTION_TYPE) ) -#define IS_INK_TOOL_MENU_ACTION_CLASS( klass ) ( G_TYPE_CHECK_CLASS_TYPE( (klass), INK_TOOL_MENU_ACTION_TYPE) ) -#define INK_TOOL_MENU_ACTION_GET_CLASS( obj ) ( G_TYPE_INSTANCE_GET_CLASS( (obj), INK_TOOL_MENU_ACTION_TYPE, InkToolMenuActionClass) ) - -typedef struct _InkToolMenuAction InkToolMenuAction; -typedef struct _InkToolMenuActionClass InkToolMenuActionClass; -typedef struct _InkToolMenuActionPrivate InkToolMenuActionPrivate; - -struct _InkToolMenuAction -{ - InkAction action; -}; - -struct _InkToolMenuActionClass -{ - InkActionClass parent_class; -}; - -GType ink_tool_menu_action_get_type( void ); - -InkToolMenuAction* ink_tool_menu_action_new( const gchar *name, - const gchar *label, - const gchar *tooltip, - const gchar *inkId, - Inkscape::IconSize size ); - - - G_END_DECLS #endif /* SEEN_INK_ACTION */ +/* + 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/ink-comboboxentry-action.cpp b/src/widgets/ink-comboboxentry-action.cpp index ec5e26cf5..2fecb06a4 100644 --- a/src/widgets/ink-comboboxentry-action.cpp +++ b/src/widgets/ink-comboboxentry-action.cpp @@ -371,16 +371,10 @@ GtkWidget* create_tool_item( GtkAction* action ) g_free( combobox_name ); { -#if GTK_CHECK_VERSION(3,0,0) gtk_widget_set_halign(comboBoxEntry, GTK_ALIGN_START); gtk_widget_set_hexpand(comboBoxEntry, FALSE); gtk_widget_set_vexpand(comboBoxEntry, FALSE); gtk_container_add(GTK_CONTAINER(item), comboBoxEntry); -#else - GtkWidget *align = gtk_alignment_new(0, 0.5, 0, 0); - gtk_container_add( GTK_CONTAINER(align), comboBoxEntry ); - gtk_container_add( GTK_CONTAINER(item), align ); -#endif } ink_comboboxentry_action->combobox = GTK_COMBO_BOX (comboBoxEntry); @@ -414,11 +408,7 @@ GtkWidget* create_tool_item( GtkAction* action ) // Optionally widen the combobox width... which widens the drop-down list in list mode. if( ink_comboboxentry_action->extra_width > 0 ) { GtkRequisition req; -#if GTK_CHECK_VERSION(3,0,0) gtk_widget_get_preferred_size(GTK_WIDGET(ink_comboboxentry_action->combobox), &req, NULL); -#else - gtk_widget_size_request( GTK_WIDGET( ink_comboboxentry_action->combobox ), &req ); -#endif gtk_widget_set_size_request( GTK_WIDGET( ink_comboboxentry_action->combobox ), req.width + ink_comboboxentry_action->extra_width, -1 ); } @@ -635,11 +625,7 @@ void ink_comboboxentry_action_set_extra_width( Ink_ComboBoxEntry_Action* action, // Widget may not have been created.... if( action->combobox ) { GtkRequisition req; -#if GTK_CHECK_VERSION(3,0,0) gtk_widget_get_preferred_size(GTK_WIDGET(action->combobox), &req, NULL); -#else - gtk_widget_size_request( GTK_WIDGET( action->combobox ), &req ); -#endif gtk_widget_set_size_request( GTK_WIDGET( action->combobox ), req.width + action->extra_width, -1 ); } } diff --git a/src/widgets/ink-radio-action.cpp b/src/widgets/ink-radio-action.cpp new file mode 100644 index 000000000..2113819c3 --- /dev/null +++ b/src/widgets/ink-radio-action.cpp @@ -0,0 +1,185 @@ +#include "ink-radio-action.h" + +static void ink_radio_action_finalize( GObject* obj ); +static void ink_radio_action_get_property( GObject* obj, guint propId, GValue* value, GParamSpec * pspec ); +static void ink_radio_action_set_property( GObject* obj, guint propId, const GValue *value, GParamSpec* pspec ); + +static GtkWidget* ink_radio_action_create_menu_item( GtkAction* action ); +static GtkWidget* ink_radio_action_create_tool_item( GtkAction* action ); + +struct _InkRadioActionPrivate +{ + gchar* iconId; + Inkscape::IconSize iconSize; +}; + +#define INK_RADIO_ACTION_GET_PRIVATE( o ) ( G_TYPE_INSTANCE_GET_PRIVATE( (o), INK_RADIO_ACTION_TYPE, InkRadioActionPrivate ) ) + +G_DEFINE_TYPE(InkRadioAction, ink_radio_action, GTK_TYPE_RADIO_ACTION); + +enum { + PROP_INK_ID = 1, + PROP_INK_SIZE +}; + +static void ink_radio_action_class_init( InkRadioActionClass* klass ) +{ + if ( klass ) { + GObjectClass * objClass = G_OBJECT_CLASS( klass ); + + objClass->finalize = ink_radio_action_finalize; + objClass->get_property = ink_radio_action_get_property; + objClass->set_property = ink_radio_action_set_property; + + klass->parent_class.parent_class.parent_class.create_menu_item = ink_radio_action_create_menu_item; + klass->parent_class.parent_class.parent_class.create_tool_item = ink_radio_action_create_tool_item; + /*klass->parent_class.connect_proxy = connect_proxy;*/ + /*klass->parent_class.disconnect_proxy = disconnect_proxy;*/ + + g_object_class_install_property( objClass, + PROP_INK_ID, + g_param_spec_string( "iconId", + "Icon ID", + "The id for the icon", + "", + (GParamFlags)(G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT) ) ); + + g_object_class_install_property( objClass, + PROP_INK_SIZE, + g_param_spec_int( "iconSize", + "Icon Size", + "The size the icon", + (int)Inkscape::ICON_SIZE_MENU, + (int)Inkscape::ICON_SIZE_DECORATION, + (int)Inkscape::ICON_SIZE_SMALL_TOOLBAR, + (GParamFlags)(G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT) ) ); + + g_type_class_add_private( klass, sizeof(InkRadioActionClass) ); + } +} + +static void ink_radio_action_init( InkRadioAction* action ) +{ + action->private_data = INK_RADIO_ACTION_GET_PRIVATE( action ); + action->private_data->iconId = 0; + action->private_data->iconSize = Inkscape::ICON_SIZE_SMALL_TOOLBAR; +} + +static void ink_radio_action_finalize( GObject* obj ) +{ + InkRadioAction* action = INK_RADIO_ACTION( obj ); + + g_free( action->private_data->iconId ); + g_free( action->private_data ); + +} + +InkRadioAction* ink_radio_action_new( const gchar *name, + const gchar *label, + const gchar *tooltip, + const gchar *inkId, + Inkscape::IconSize size ) +{ + GObject* obj = (GObject*)g_object_new( INK_RADIO_ACTION_TYPE, + "name", name, + "label", label, + "tooltip", tooltip, + "iconId", inkId, + "iconSize", Inkscape::getRegisteredIconSize(size), + NULL ); + + InkRadioAction* action = INK_RADIO_ACTION( obj ); + + return action; +} + +static void ink_radio_action_get_property( GObject* obj, guint propId, GValue* value, GParamSpec * pspec ) +{ + InkRadioAction* action = INK_RADIO_ACTION( obj ); + (void)action; + switch ( propId ) { + case PROP_INK_ID: + { + g_value_set_string( value, action->private_data->iconId ); + } + break; + + case PROP_INK_SIZE: + { + g_value_set_int( value, action->private_data->iconSize ); + } + break; + + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID( obj, propId, pspec ); + } +} + +void ink_radio_action_set_property( GObject* obj, guint propId, const GValue *value, GParamSpec* pspec ) +{ + InkRadioAction* action = INK_RADIO_ACTION( obj ); + (void)action; + switch ( propId ) { + case PROP_INK_ID: + { + gchar* tmp = action->private_data->iconId; + action->private_data->iconId = g_value_dup_string( value ); + g_free( tmp ); + } + break; + + case PROP_INK_SIZE: + { + action->private_data->iconSize = (Inkscape::IconSize)g_value_get_int( value ); + } + break; + + default: + { + G_OBJECT_WARN_INVALID_PROPERTY_ID( obj, propId, pspec ); + } + } +} + +static GtkWidget* ink_radio_action_create_menu_item( GtkAction* action ) +{ + GtkWidget* item = GTK_RADIO_ACTION_CLASS(ink_radio_action_parent_class)->parent_class.parent_class.create_menu_item(action); + + return item; +} + +static GtkWidget* ink_radio_action_create_tool_item( GtkAction* action ) +{ + InkRadioAction* act = INK_RADIO_ACTION( action ); + GtkWidget* item = GTK_RADIO_ACTION_CLASS(ink_radio_action_parent_class)->parent_class.parent_class.create_tool_item(action); + + if ( act->private_data->iconId ) { + if ( GTK_IS_TOOL_BUTTON(item) ) { + GtkToolButton* button = GTK_TOOL_BUTTON(item); + + GtkWidget* child = sp_icon_new( act->private_data->iconSize, act->private_data->iconId ); + gtk_widget_set_hexpand(child, FALSE); + gtk_widget_set_vexpand(child, FALSE); + gtk_tool_button_set_icon_widget(button, child); + } else { + // For now trigger a warning but don't do anything else + GtkToolButton* button = GTK_TOOL_BUTTON(item); + (void)button; + } + } + + // TODO investigate if needed + gtk_widget_show_all( item ); + + return item; +} +/* + 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/ink-radio-action.h b/src/widgets/ink-radio-action.h new file mode 100644 index 000000000..c1f059c4f --- /dev/null +++ b/src/widgets/ink-radio-action.h @@ -0,0 +1,52 @@ +#ifndef INK_RADIO_ACTION_H +#define INK_RADIO_ACTION_H + +#include <gtk/gtk.h> + +#include "icon.h" + +G_BEGIN_DECLS + +#define INK_RADIO_ACTION_TYPE ( ink_radio_action_get_type() ) +#define INK_RADIO_ACTION( obj ) ( G_TYPE_CHECK_INSTANCE_CAST( (obj), INK_RADIO_ACTION_TYPE, InkRadioAction) ) +#define INK_RADIO_ACTION_CLASS( klass ) ( G_TYPE_CHECK_CLASS_CAST( (klass), INK_RADIO_ACTION_TYPE, InkRadioActionClass) ) +#define IS_INK_RADIO_ACTION( obj ) ( G_TYPE_CHECK_INSTANCE_TYPE( (obj), INK_RADIO_ACTION_TYPE) ) +#define IS_INK_RADIO_ACTION_CLASS( klass ) ( G_TYPE_CHECK_CLASS_TYPE( (klass), INK_RADIO_ACTION_TYPE) ) +#define INK_RADIO_ACTION_GET_CLASS( obj ) ( G_TYPE_INSTANCE_GET_CLASS( (obj), INK_RADIO_ACTION_TYPE, InkRadioActionClass) ) + +typedef struct _InkRadioAction InkRadioAction; +typedef struct _InkRadioActionClass InkRadioActionClass; +typedef struct _InkRadioActionPrivate InkRadioActionPrivate; + +struct _InkRadioAction +{ + GtkRadioAction action; + InkRadioActionPrivate *private_data; +}; + +struct _InkRadioActionClass +{ + GtkRadioActionClass parent_class; +}; + +GType ink_radio_action_get_type( void ); + +InkRadioAction* ink_radio_action_new( const gchar *name, + const gchar *label, + const gchar *tooltip, + const gchar *inkId, + Inkscape::IconSize size ); + +G_END_DECLS + +#endif // INK_RADIO_ACTION_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/widgets/ink-toggle-action.cpp b/src/widgets/ink-toggle-action.cpp new file mode 100644 index 000000000..3eed974dc --- /dev/null +++ b/src/widgets/ink-toggle-action.cpp @@ -0,0 +1,221 @@ +#include "ink-toggle-action.h" +#include "icon.h" + +static void ink_toggle_action_finalize( GObject* obj ); +static void ink_toggle_action_get_property( GObject* obj, guint propId, GValue* value, GParamSpec * pspec ); +static void ink_toggle_action_set_property( GObject* obj, guint propId, const GValue *value, GParamSpec* pspec ); + +static GtkWidget* ink_toggle_action_create_menu_item( GtkAction* action ); +static GtkWidget* ink_toggle_action_create_tool_item( GtkAction* action ); + +static void ink_toggle_action_update_icon( InkToggleAction* action ); + +struct _InkToggleActionPrivate +{ + gchar* iconId; + Inkscape::IconSize iconSize; +}; + +#define INK_TOGGLE_ACTION_GET_PRIVATE( o ) ( G_TYPE_INSTANCE_GET_PRIVATE( (o), INK_TOGGLE_ACTION_TYPE, InkToggleActionPrivate ) ) + +G_DEFINE_TYPE(InkToggleAction, ink_toggle_action, GTK_TYPE_TOGGLE_ACTION); + +enum { + PROP_INK_ID = 1, + PROP_INK_SIZE +}; + +static void ink_toggle_action_class_init( InkToggleActionClass* klass ) +{ + if ( klass ) { + GObjectClass * objClass = G_OBJECT_CLASS( klass ); + + objClass->finalize = ink_toggle_action_finalize; + objClass->get_property = ink_toggle_action_get_property; + objClass->set_property = ink_toggle_action_set_property; + + klass->parent_class.parent_class.create_menu_item = ink_toggle_action_create_menu_item; + klass->parent_class.parent_class.create_tool_item = ink_toggle_action_create_tool_item; + /*klass->parent_class.connect_proxy = connect_proxy;*/ + /*klass->parent_class.disconnect_proxy = disconnect_proxy;*/ + + g_object_class_install_property( objClass, + PROP_INK_ID, + g_param_spec_string( "iconId", + "Icon ID", + "The id for the icon", + "", + (GParamFlags)(G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT) ) ); + + g_object_class_install_property( objClass, + PROP_INK_SIZE, + g_param_spec_int( "iconSize", + "Icon Size", + "The size the icon", + (int)Inkscape::ICON_SIZE_MENU, + (int)99, + (int)Inkscape::ICON_SIZE_SMALL_TOOLBAR, + (GParamFlags)(G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT) ) ); + + g_type_class_add_private( klass, sizeof(InkToggleActionClass) ); + } +} + +static void ink_toggle_action_init( InkToggleAction* action ) +{ + action->private_data = INK_TOGGLE_ACTION_GET_PRIVATE( action ); + action->private_data->iconId = 0; + action->private_data->iconSize = Inkscape::ICON_SIZE_SMALL_TOOLBAR; +} + +static void ink_toggle_action_finalize( GObject* obj ) +{ + InkToggleAction* action = INK_TOGGLE_ACTION( obj ); + + g_free( action->private_data->iconId ); + g_free( action->private_data ); + +} + +InkToggleAction* ink_toggle_action_new( const gchar *name, + const gchar *label, + const gchar *tooltip, + const gchar *inkId, + Inkscape::IconSize size, + SPAttributeEnum attr) +{ + GObject* obj = (GObject*)g_object_new( INK_TOGGLE_ACTION_TYPE, + "name", name, + "label", label, + "tooltip", tooltip, + "iconId", inkId, + "iconSize", Inkscape::getRegisteredIconSize(size), + //"SP_ATTR_INKSCAPE", attr, // Why doesn't this work and do I need to use g_object_set_data below? + NULL ); + + g_object_set_data(obj, "SP_ATTR_INKSCAPE", GINT_TO_POINTER(attr)); + InkToggleAction* action = INK_TOGGLE_ACTION( obj ); + + return action; +} + +static void ink_toggle_action_get_property( GObject* obj, guint propId, GValue* value, GParamSpec * pspec ) +{ + InkToggleAction* action = INK_TOGGLE_ACTION( obj ); + (void)action; + switch ( propId ) { + case PROP_INK_ID: + { + g_value_set_string( value, action->private_data->iconId ); + } + break; + + case PROP_INK_SIZE: + { + g_value_set_int( value, action->private_data->iconSize ); + } + break; + + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID( obj, propId, pspec ); + } +} + +void ink_toggle_action_set_property( GObject* obj, guint propId, const GValue *value, GParamSpec* pspec ) +{ + InkToggleAction* action = INK_TOGGLE_ACTION( obj ); + (void)action; + switch ( propId ) { + case PROP_INK_ID: + { + gchar* tmp = action->private_data->iconId; + action->private_data->iconId = g_value_dup_string( value ); + g_free( tmp ); + + ink_toggle_action_update_icon( action ); + } + break; + + case PROP_INK_SIZE: + { + action->private_data->iconSize = (Inkscape::IconSize)g_value_get_int( value ); + } + break; + + default: + { + G_OBJECT_WARN_INVALID_PROPERTY_ID( obj, propId, pspec ); + } + } +} + +static GtkWidget* ink_toggle_action_create_menu_item( GtkAction* action ) +{ + GtkWidget* item = GTK_TOGGLE_ACTION_CLASS(ink_toggle_action_parent_class)->parent_class.create_menu_item(action); + + return item; +} + +static GtkWidget* ink_toggle_action_create_tool_item( GtkAction* action ) +{ + InkToggleAction* act = INK_TOGGLE_ACTION( action ); + + GtkWidget* item = GTK_TOGGLE_ACTION_CLASS(ink_toggle_action_parent_class)->parent_class.create_tool_item(action); + if ( GTK_IS_TOOL_BUTTON(item) ) { + GtkToolButton* button = GTK_TOOL_BUTTON(item); + if ( act->private_data->iconId ) { + GtkWidget* child = sp_icon_new( act->private_data->iconSize, act->private_data->iconId ); + + gtk_widget_set_hexpand(child, FALSE); + gtk_widget_set_vexpand(child, FALSE); + gtk_tool_button_set_icon_widget(button, child); + } else { + gchar *label = 0; + g_object_get( G_OBJECT(action), "short_label", &label, NULL ); + gtk_tool_button_set_label( button, label ); + g_free( label ); + label = 0; + } + } else { + // For now trigger a warning but don't do anything else + GtkToolButton* button = GTK_TOOL_BUTTON(item); + (void)button; + } + gtk_widget_show_all( item ); + + return item; +} + + +static void ink_toggle_action_update_icon( InkToggleAction* action ) +{ + if ( action ) { + GSList* proxies = gtk_action_get_proxies( GTK_ACTION(action) ); + while ( proxies ) { + if ( GTK_IS_TOOL_ITEM(proxies->data) ) { + if ( GTK_IS_TOOL_BUTTON(proxies->data) ) { + GtkToolButton* button = GTK_TOOL_BUTTON(proxies->data); + + GtkWidget* child = sp_icon_new( action->private_data->iconSize, action->private_data->iconId ); + gtk_widget_set_hexpand(child, FALSE); + gtk_widget_set_vexpand(child, FALSE); + gtk_widget_show_all(child); + gtk_tool_button_set_icon_widget(button, child); + } + } + + proxies = g_slist_next( proxies ); + } + } +} + +/* + 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/ink-toggle-action.h b/src/widgets/ink-toggle-action.h new file mode 100644 index 000000000..8e9d5e257 --- /dev/null +++ b/src/widgets/ink-toggle-action.h @@ -0,0 +1,53 @@ +#ifndef INK_TOGGLE_ACTION_H +#define INK_TOGGLE_ACTION_H + +#include <gtk/gtk.h> + +#include "attributes.h" +#include "icon-size.h" + +G_BEGIN_DECLS +#define INK_TOGGLE_ACTION_TYPE ( ink_toggle_action_get_type() ) +#define INK_TOGGLE_ACTION( obj ) ( G_TYPE_CHECK_INSTANCE_CAST( (obj), INK_TOGGLE_ACTION_TYPE, InkToggleAction) ) +#define INK_TOGGLE_ACTION_CLASS( klass ) ( G_TYPE_CHECK_CLASS_CAST( (klass), INK_TOGGLE_ACTION_TYPE, InkToggleActionClass) ) +#define IS_INK_TOGGLE_ACTION( obj ) ( G_TYPE_CHECK_INSTANCE_TYPE( (obj), INK_TOGGLE_ACTION_TYPE) ) +#define IS_INK_TOGGLE_ACTION_CLASS( klass ) ( G_TYPE_CHECK_CLASS_TYPE( (klass), INK_TOGGLE_ACTION_TYPE) ) +#define INK_TOGGLE_ACTION_GET_CLASS( obj ) ( G_TYPE_INSTANCE_GET_CLASS( (obj), INK_TOGGLE_ACTION_TYPE, InkToggleActionClass) ) + +typedef struct _InkToggleAction InkToggleAction; +typedef struct _InkToggleActionClass InkToggleActionClass; +typedef struct _InkToggleActionPrivate InkToggleActionPrivate; + +struct _InkToggleAction +{ + GtkToggleAction action; + InkToggleActionPrivate *private_data; +}; + +struct _InkToggleActionClass +{ + GtkToggleActionClass parent_class; +}; + +GType ink_toggle_action_get_type( void ); + +InkToggleAction* ink_toggle_action_new( const gchar *name, + const gchar *label, + const gchar *tooltip, + const gchar *inkId, + Inkscape::IconSize size, + SPAttributeEnum attr = SP_ATTR_INVALID); + +G_END_DECLS + +#endif // INK_TOGGLE_ACTION_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/widgets/ink-tool-menu-action.cpp b/src/widgets/ink-tool-menu-action.cpp new file mode 100644 index 000000000..29d8dc92f --- /dev/null +++ b/src/widgets/ink-tool-menu-action.cpp @@ -0,0 +1,49 @@ +#include "ink-tool-menu-action.h" + +// ToolMenu Action is happily derived from http://www.gtkforums.com/viewtopic.php?t=4215 + +G_DEFINE_TYPE(InkToolMenuAction, ink_tool_menu_action, INK_ACTION_TYPE); + +static void +ink_tool_menu_action_class_init (InkToolMenuActionClass *klass) +{ + GtkActionClass *action_class = GTK_ACTION_CLASS (klass); + action_class->toolbar_item_type = GTK_TYPE_MENU_TOOL_BUTTON; +} + +static void +ink_tool_menu_action_init (InkToolMenuAction* /*tma*/) +{ +} + +InkToolMenuAction * +ink_tool_menu_action_new (const gchar *name, + const gchar *label, + const gchar *tooltip, + const gchar *inkId, + Inkscape::IconSize size ) +{ + g_return_val_if_fail (name != NULL, NULL); + + GObject* obj = (GObject*)g_object_new( INK_TOOL_MENU_ACTION_TYPE, + "name", name, + "label", label, + "tooltip", tooltip, + "iconId", inkId, + "iconSize", size, + NULL ); + + InkToolMenuAction* action = INK_TOOL_MENU_ACTION( obj ); + + return action; +} +/* + 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/ink-tool-menu-action.h b/src/widgets/ink-tool-menu-action.h new file mode 100644 index 000000000..be04489d3 --- /dev/null +++ b/src/widgets/ink-tool-menu-action.h @@ -0,0 +1,52 @@ +#ifndef INK_TOOL_MENU_ACTION_H +#define INK_TOOL_MENU_ACTION_H + +#include "ink-action.h" + +// ToolMenu Action is happily derived from http://www.gtkforums.com/viewtopic.php?t=4215 + +G_BEGIN_DECLS + +#define INK_TOOL_MENU_ACTION_TYPE ( ink_tool_menu_action_get_type() ) +#define INK_TOOL_MENU_ACTION( obj ) ( G_TYPE_CHECK_INSTANCE_CAST( (obj), INK_TOOL_MENU_ACTION_TYPE, InkToolMenuAction) ) +#define INK_TOOL_MENU_ACTION_CLASS( klass ) ( G_TYPE_CHECK_CLASS_CAST( (klass), INK_TOOL_MENU_ACTION_TYPE, InkToolMenuActionClass) ) +#define IS_INK_TOOL_MENU_ACTION( obj ) ( G_TYPE_CHECK_INSTANCE_TYPE( (obj), INK_TOOL_MENU_ACTION_TYPE) ) +#define IS_INK_TOOL_MENU_ACTION_CLASS( klass ) ( G_TYPE_CHECK_CLASS_TYPE( (klass), INK_TOOL_MENU_ACTION_TYPE) ) +#define INK_TOOL_MENU_ACTION_GET_CLASS( obj ) ( G_TYPE_INSTANCE_GET_CLASS( (obj), INK_TOOL_MENU_ACTION_TYPE, InkToolMenuActionClass) ) + +typedef struct _InkToolMenuAction InkToolMenuAction; +typedef struct _InkToolMenuActionClass InkToolMenuActionClass; +typedef struct _InkToolMenuActionPrivate InkToolMenuActionPrivate; + +struct _InkToolMenuAction +{ + InkAction action; +}; + +struct _InkToolMenuActionClass +{ + InkActionClass parent_class; +}; + +GType ink_tool_menu_action_get_type( void ); + +InkToolMenuAction* ink_tool_menu_action_new( const gchar *name, + const gchar *label, + const gchar *tooltip, + const gchar *inkId, + Inkscape::IconSize size ); + +G_END_DECLS + +#endif // INK_TOOL_MENU_ACTION_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/widgets/lpe-toolbar.cpp b/src/widgets/lpe-toolbar.cpp index 387bf6dee..5df5fde70 100644 --- a/src/widgets/lpe-toolbar.cpp +++ b/src/widgets/lpe-toolbar.cpp @@ -25,27 +25,20 @@ */ #ifdef HAVE_CONFIG_H -# include "config.h" +#include <config.h> #endif #include "live_effects/lpe-line_segment.h" #include "lpe-toolbar.h" -#include "desktop.h" -#include "document-undo.h" #include "widgets/ege-select-one-action.h" #include "helper/action-context.h" #include "helper/action.h" -#include "widgets/ink-action.h" -#include "live_effects/effect.h" -#include "preferences.h" -#include "selection.h" -#include "sp-namedview.h" +#include "ink-radio-action.h" +#include "ink-toggle-action.h" #include "ui/tools-switch.h" #include "ui/tools/lpe-tool.h" #include "ui/widget/unit-tracker.h" -#include "util/units.h" -#include "verbs.h" using Inkscape::UI::Widget::UnitTracker; using Inkscape::Util::Unit; diff --git a/src/widgets/measure-toolbar.cpp b/src/widgets/measure-toolbar.cpp index 990989f4a..a8c974bbc 100644 --- a/src/widgets/measure-toolbar.cpp +++ b/src/widgets/measure-toolbar.cpp @@ -25,7 +25,7 @@ */ #ifdef HAVE_CONFIG_H -# include "config.h" +#include <config.h> #endif #include <glibmm/i18n.h> @@ -38,9 +38,9 @@ #include "document-undo.h" #include "widgets/ege-adjustment-action.h" #include "widgets/ege-output-action.h" -#include "preferences.h" #include "toolbox.h" -#include "widgets/ink-action.h" +#include "ink-action.h" +#include "ink-toggle-action.h" #include "ui/icon-names.h" #include "ui/tools/measure-tool.h" #include "ui/widget/unit-tracker.h" diff --git a/src/widgets/mesh-toolbar.cpp b/src/widgets/mesh-toolbar.cpp index 3643ce00c..0e689fee0 100644 --- a/src/widgets/mesh-toolbar.cpp +++ b/src/widgets/mesh-toolbar.cpp @@ -15,7 +15,7 @@ */ #ifdef HAVE_CONFIG_H -# include "config.h" +#include <config.h> #endif // REVIEW THESE AT END OF REWRITE @@ -25,17 +25,13 @@ #include "verbs.h" -#include "macros.h" #include "widgets/button.h" -#include "widgets/widget-sizes.h" -#include "widgets/spw-utilities.h" #include "widgets/spinbutton-events.h" #include "widgets/gradient-vector.h" #include "widgets/gradient-image.h" #include "style.h" #include "inkscape.h" -#include "preferences.h" #include "document-private.h" #include "document-undo.h" #include "desktop.h" @@ -45,25 +41,20 @@ #include "ui/tools/gradient-tool.h" #include "ui/tools/mesh-tool.h" #include "gradient-drag.h" -#include "sp-mesh.h" +#include "sp-mesh-gradient.h" #include "gradient-chemistry.h" -#include "gradient-selector.h" -#include "selection.h" #include "ui/icon-names.h" #include "widgets/ege-adjustment-action.h" -#include "widgets/ege-output-action.h" #include "widgets/ege-select-one-action.h" -#include "widgets/ink-action.h" -#include "widgets/ink-comboboxentry-action.h" +#include "ink-action.h" +#include "ink-radio-action.h" +#include "ink-toggle-action.h" #include "sp-stop.h" #include "svg/css-ostringstream.h" -#include "svg/svg-color.h" #include "desktop-style.h" -#include "toolbox.h" - using Inkscape::DocumentUndo; using Inkscape::UI::ToolboxFactory; using Inkscape::UI::PrefPusher; @@ -79,7 +70,7 @@ static bool blocked = false; * Get the current selection and dragger status from the desktop */ void ms_read_selection( Inkscape::Selection *selection, - SPMesh *&ms_selected, + SPMeshGradient *&ms_selected, bool &ms_selected_multi, SPMeshType &ms_type, bool &ms_type_multi ) @@ -89,16 +80,16 @@ void ms_read_selection( Inkscape::Selection *selection, bool first = true; ms_type = SP_MESH_TYPE_COONS; - std::vector<SPItem*> itemlist=selection->itemList(); - for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();++i){ + auto itemlist= selection->items(); + for(auto i=itemlist.begin();i!=itemlist.end();++i){ SPItem *item = *i; SPStyle *style = item->style; if (style && (style->fill.isPaintserver())) { SPPaintServer *server = item->style->getFillPaintServer(); - if ( SP_IS_MESH(server) ) { + if ( SP_IS_MESHGRADIENT(server) ) { - SPMesh *gradient = SP_MESH(server); // ->getVector(); + SPMeshGradient *gradient = SP_MESHGRADIENT(server); // ->getVector(); SPMeshType type = gradient->type; if (gradient != ms_selected) { @@ -121,9 +112,9 @@ void ms_read_selection( Inkscape::Selection *selection, if (style && (style->stroke.isPaintserver())) { SPPaintServer *server = item->style->getStrokePaintServer(); - if ( SP_IS_MESH(server) ) { + if ( SP_IS_MESHGRADIENT(server) ) { - SPMesh *gradient = SP_MESH(server); // ->getVector(); + SPMeshGradient *gradient = SP_MESHGRADIENT(server); // ->getVector(); SPMeshType type = gradient->type; if (gradient != ms_selected) { @@ -173,7 +164,7 @@ static void ms_tb_selection_changed(Inkscape::Selection * /*selection*/, gpointe // // Hide/show handles? // } - SPMesh *ms_selected = 0; + SPMeshGradient *ms_selected = 0; SPMeshType ms_type = SP_MESH_TYPE_COONS; bool ms_selected_multi = false; bool ms_type_multi = false; @@ -212,12 +203,12 @@ static void ms_defs_modified(SPObject * /*defs*/, guint /*flags*/, GObject *widg ms_tb_selection_changed(NULL, widget); } -void ms_get_dt_selected_gradient(Inkscape::Selection *selection, SPMesh *&ms_selected) +void ms_get_dt_selected_gradient(Inkscape::Selection *selection, SPMeshGradient *&ms_selected) { - SPMesh *gradient = 0; + SPMeshGradient *gradient = 0; - std::vector<SPItem*> itemlist=selection->itemList(); - for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();++i){ + auto itemlist= selection->items(); + for(auto i=itemlist.begin();i!=itemlist.end();++i){ SPItem *item = *i;// get the items gradient, not the getVector() version SPStyle *style = item->style; SPPaintServer *server = 0; @@ -229,8 +220,8 @@ void ms_get_dt_selected_gradient(Inkscape::Selection *selection, SPMesh *&ms_sel server = item->style->getStrokePaintServer(); } - if ( SP_IS_MESH(server) ) { - gradient = SP_MESH(server); + if ( SP_IS_MESHGRADIENT(server) ) { + gradient = SP_MESHGRADIENT(server); } } @@ -304,7 +295,7 @@ static void ms_type_changed(EgeSelectOneAction *act, GtkWidget *widget) SPDesktop *desktop = static_cast<SPDesktop *>(g_object_get_data(G_OBJECT(widget), "desktop")); Inkscape::Selection *selection = desktop->getSelection(); - SPMesh *gradient = 0; + SPMeshGradient *gradient = 0; ms_get_dt_selected_gradient(selection, gradient); if (gradient) { diff --git a/src/widgets/node-toolbar.cpp b/src/widgets/node-toolbar.cpp index 113061519..31efaa0b4 100644 --- a/src/widgets/node-toolbar.cpp +++ b/src/widgets/node-toolbar.cpp @@ -25,7 +25,7 @@ */ #ifdef HAVE_CONFIG_H -# include "config.h" +#include <config.h> #endif #include "ui/tool/multi-path-manipulator.h" @@ -35,18 +35,16 @@ #include "desktop.h" #include "document-undo.h" #include "widgets/ege-adjustment-action.h" -#include "widgets/ink-action.h" +#include "ink-toggle-action.h" +#include "ink-tool-menu-action.h" #include "inkscape.h" -#include "preferences.h" #include "selection-chemistry.h" -#include "selection.h" #include "sp-namedview.h" #include "toolbox.h" #include "ui/icon-names.h" #include "ui/tool/control-point-selection.h" #include "ui/tools/node-tool.h" #include "ui/widget/unit-tracker.h" -#include "util/units.h" #include "verbs.h" #include "widgets/widget-sizes.h" diff --git a/src/widgets/paint-selector.cpp b/src/widgets/paint-selector.cpp index 58a178aec..ddac90730 100644 --- a/src/widgets/paint-selector.cpp +++ b/src/widgets/paint-selector.cpp @@ -33,7 +33,7 @@ #include "sp-linear-gradient.h" #include "sp-radial-gradient.h" -#include "sp-mesh.h" +#include "sp-mesh-gradient.h" #include "sp-stop.h" /* fixme: Move it from dialogs to here */ #include "gradient-selector.h" @@ -41,7 +41,6 @@ #include <document-private.h> #include <desktop-style.h> #include <style.h> -#include "svg/svg-color.h" #include "svg/css-ostringstream.h" #include "path-prefix.h" #include "io/sys.h" @@ -55,8 +54,6 @@ #include "svg/svg-icc-color.h" #endif // SP_PS_VERBOSE -#include <gtk/gtk.h> - using Inkscape::Widgets::SwatchSelector; using Inkscape::UI::SelectedColor; @@ -134,11 +131,7 @@ static SPGradientSelector *getGradientFromData(SPPaintSelector const *psel) return grad; } -#if GTK_CHECK_VERSION(3,0,0) G_DEFINE_TYPE(SPPaintSelector, sp_paint_selector, GTK_TYPE_BOX); -#else -G_DEFINE_TYPE(SPPaintSelector, sp_paint_selector, GTK_TYPE_VBOX); -#endif static void sp_paint_selector_class_init(SPPaintSelectorClass *klass) @@ -197,19 +190,13 @@ sp_paint_selector_class_init(SPPaintSelectorClass *klass) static void sp_paint_selector_init(SPPaintSelector *psel) { -#if GTK_CHECK_VERSION(3,0,0) gtk_orientable_set_orientation(GTK_ORIENTABLE(psel), GTK_ORIENTATION_VERTICAL); -#endif psel->mode = static_cast<SPPaintSelector::Mode>(-1); // huh? do you mean 0xff? -- I think this means "not in the enum" /* Paint style button box */ -#if GTK_CHECK_VERSION(3,0,0) psel->style = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); gtk_box_set_homogeneous(GTK_BOX(psel->style), FALSE); -#else - psel->style = gtk_hbox_new(FALSE, 0); -#endif gtk_widget_show(psel->style); gtk_container_set_border_width(GTK_CONTAINER(psel->style), 4); gtk_box_pack_start(GTK_BOX(psel), psel->style, FALSE, FALSE, 0); @@ -236,12 +223,8 @@ sp_paint_selector_init(SPPaintSelector *psel) /* Fillrule */ { -#if GTK_CHECK_VERSION(3,0,0) - psel->fillrulebox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); - gtk_box_set_homogeneous(GTK_BOX(psel->fillrulebox), FALSE); -#else - psel->fillrulebox = gtk_hbox_new(FALSE, 0); -#endif + psel->fillrulebox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); + gtk_box_set_homogeneous(GTK_BOX(psel->fillrulebox), FALSE); gtk_box_pack_end(GTK_BOX(psel->style), psel->fillrulebox, FALSE, FALSE, 0); GtkWidget *w; @@ -270,22 +253,14 @@ sp_paint_selector_init(SPPaintSelector *psel) /* Frame */ psel->label = gtk_label_new(""); -#if GTK_CHECK_VERSION(3,0,0) - GtkWidget *lbbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 4); + auto lbbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 4); gtk_box_set_homogeneous(GTK_BOX(lbbox), FALSE); -#else - GtkWidget *lbbox = gtk_hbox_new(FALSE, 4); -#endif gtk_widget_show(psel->label); gtk_box_pack_start(GTK_BOX(lbbox), psel->label, false, false, 4); gtk_box_pack_start(GTK_BOX(psel), lbbox, false, false, 4); -#if GTK_CHECK_VERSION(3,0,0) psel->frame = gtk_box_new(GTK_ORIENTATION_VERTICAL, 4); gtk_box_set_homogeneous(GTK_BOX(psel->frame), FALSE); -#else - psel->frame = gtk_vbox_new(FALSE, 4); -#endif gtk_widget_show(psel->frame); //gtk_container_set_border_width(GTK_CONTAINER(psel->frame), 0); gtk_box_pack_start(GTK_BOX(psel), psel->frame, TRUE, TRUE, 0); @@ -700,12 +675,8 @@ static void sp_paint_selector_set_mode_color(SPPaintSelector *psel, SPPaintSelec sp_paint_selector_clear_frame(psel); /* Create new color selector */ /* Create vbox */ -#if GTK_CHECK_VERSION(3,0,0) - GtkWidget *vb = gtk_box_new(GTK_ORIENTATION_VERTICAL, 4); - gtk_box_set_homogeneous(GTK_BOX(vb), FALSE); -#else - GtkWidget *vb = gtk_vbox_new(FALSE, 4); -#endif + auto vb = gtk_box_new(GTK_ORIENTATION_VERTICAL, 4); + gtk_box_set_homogeneous(GTK_BOX(vb), FALSE); gtk_widget_show(vb); /* Color selector */ @@ -1046,21 +1017,13 @@ static void sp_paint_selector_set_mode_pattern(SPPaintSelector *psel, SPPaintSel sp_paint_selector_clear_frame(psel); /* Create vbox */ -#if GTK_CHECK_VERSION(3,0,0) tbl = gtk_box_new(GTK_ORIENTATION_VERTICAL, 4); gtk_box_set_homogeneous(GTK_BOX(tbl), FALSE); -#else - tbl = gtk_vbox_new(FALSE, 4); -#endif gtk_widget_show(tbl); { -#if GTK_CHECK_VERSION(3,0,0) - GtkWidget *hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 1); + auto hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 1); gtk_box_set_homogeneous(GTK_BOX(hb), FALSE); -#else - GtkWidget *hb = gtk_hbox_new(FALSE, 1); -#endif /** * Create a combo_box and store with 4 columns, @@ -1088,13 +1051,9 @@ static void sp_paint_selector_set_mode_pattern(SPPaintSelector *psel, SPPaintSel } { -#if GTK_CHECK_VERSION(3,0,0) - GtkWidget *hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); + auto hb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); gtk_box_set_homogeneous(GTK_BOX(hb), FALSE); -#else - GtkWidget *hb = gtk_hbox_new(FALSE, 0); -#endif - GtkWidget *l = gtk_label_new(NULL); + auto l = gtk_label_new(NULL); gtk_label_set_markup(GTK_LABEL(l), _("Use the <b>Node tool</b> to adjust position, scale, and rotation of the pattern on canvas. Use <b>Object > Pattern > Objects to Pattern</b> to create a new pattern from selection.")); gtk_label_set_line_wrap(GTK_LABEL(l), true); gtk_widget_set_size_request(l, 180, -1); @@ -1262,7 +1221,7 @@ SPPaintSelector::Mode SPPaintSelector::getModeForStyle(SPStyle const & style, Fi } else if (SP_IS_RADIALGRADIENT(server)) { mode = MODE_GRADIENT_RADIAL; #ifdef WITH_MESH - } else if (SP_IS_MESH(server)) { + } else if (SP_IS_MESHGRADIENT(server)) { mode = MODE_GRADIENT_MESH; #endif } else if (SP_IS_PATTERN(server)) { diff --git a/src/widgets/paint-selector.h b/src/widgets/paint-selector.h index 23c2dd456..dde14b6a6 100644 --- a/src/widgets/paint-selector.h +++ b/src/widgets/paint-selector.h @@ -40,11 +40,7 @@ class SPStyle; * Generic paint selector widget. */ struct SPPaintSelector { -#if GTK_CHECK_VERSION(3,0,0) GtkBox vbox; -#else - GtkVBox vbox; -#endif enum Mode { MODE_EMPTY, @@ -130,11 +126,7 @@ enum {COMBO_COL_LABEL=0, COMBO_COL_STOCK=1, COMBO_COL_PATTERN=2, COMBO_COL_SEP=3 /// The SPPaintSelector vtable struct SPPaintSelectorClass { -#if GTK_CHECK_VERSION(3,0,0) GtkBoxClass parent_class; -#else - GtkVBoxClass parent_class; -#endif void (* mode_changed) (SPPaintSelector *psel, SPPaintSelector::Mode mode); diff --git a/src/widgets/paintbucket-toolbar.cpp b/src/widgets/paintbucket-toolbar.cpp index b717d74fa..3d1565924 100644 --- a/src/widgets/paintbucket-toolbar.cpp +++ b/src/widgets/paintbucket-toolbar.cpp @@ -25,7 +25,7 @@ */ #ifdef HAVE_CONFIG_H -# include "config.h" +#include <config.h> #endif #include <glibmm/i18n.h> @@ -35,13 +35,11 @@ #include "document-undo.h" #include "widgets/ege-adjustment-action.h" #include "widgets/ege-select-one-action.h" -#include "preferences.h" #include "toolbox.h" #include "ui/icon-names.h" #include "ui/tools/flood-tool.h" #include "ui/uxmanager.h" #include "ui/widget/unit-tracker.h" -#include "util/units.h" #include "widgets/ink-action.h" using Inkscape::UI::Widget::UnitTracker; diff --git a/src/widgets/pencil-toolbar.cpp b/src/widgets/pencil-toolbar.cpp index 55127206c..582fb66ba 100644 --- a/src/widgets/pencil-toolbar.cpp +++ b/src/widgets/pencil-toolbar.cpp @@ -25,19 +25,19 @@ */ #ifdef HAVE_CONFIG_H -# include "config.h" +#include <config.h> #endif #include <gtkmm.h> #include <glibmm/i18n.h> -#include <list> #include "pencil-toolbar.h" #include "desktop.h" #include "widgets/ege-adjustment-action.h" #include "widgets/ege-select-one-action.h" -#include "widgets/ink-action.h" -#include "preferences.h" +#include "ink-action.h" +#include "ink-radio-action.h" +#include "ink-toggle-action.h" #include "toolbox.h" #include "ui/tools-switch.h" #include "ui/icon-names.h" @@ -46,13 +46,10 @@ #include "widgets/spinbutton-events.h" #include <selection.h> #include "display/curve.h" -#include "live_effects/effect.h" #include "live_effects/lpe-simplify.h" #include "live_effects/lpe-powerstroke.h" -#include "live_effects/effect-enum.h" #include "live_effects/lpeobject.h" #include "live_effects/lpeobject-reference.h" -#include "sp-lpe-item.h" using Inkscape::UI::UXManager; using Inkscape::UI::ToolboxFactory; @@ -240,8 +237,8 @@ static void sp_pencil_tb_defaults(GtkWidget * /*widget*/, GObject *obj) static void sp_simplify_flatten(GtkWidget * /*widget*/, GObject *obj) { SPDesktop *desktop = static_cast<SPDesktop *>(g_object_get_data(obj, "desktop")); - std::vector<SPItem *> selected = desktop->getSelection()->itemList(); - for (std::vector<SPItem *>::iterator it(selected.begin()); it != selected.end(); ++it){ + auto selected = desktop->getSelection()->items(); + for (auto it(selected.begin()); it != selected.end(); ++it){ SPLPEItem* lpeitem = dynamic_cast<SPLPEItem*>(*it); if (lpeitem && lpeitem->hasPathEffect()){ PathEffectList lpelist = lpeitem->getEffectList(); @@ -285,8 +282,8 @@ static void sp_pencil_tb_tolerance_value_changed(GtkAdjustment *adj, GObject *tb gtk_adjustment_get_value(adj)); g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) ); SPDesktop *desktop = static_cast<SPDesktop *>(g_object_get_data(tbl, "desktop")); - std::vector<SPItem *> selected = desktop->getSelection()->itemList(); - for (std::vector<SPItem *>::iterator it(selected.begin()); it != selected.end(); ++it){ + auto selected = desktop->getSelection()->items(); + for (auto it(selected.begin()); it != selected.end(); ++it){ SPLPEItem* lpeitem = dynamic_cast<SPLPEItem*>(*it); if (lpeitem && lpeitem->hasPathEffect()){ Inkscape::LivePathEffect::Effect* simplify = lpeitem->getPathEffectOfType(Inkscape::LivePathEffect::SIMPLIFY); diff --git a/src/widgets/rect-toolbar.cpp b/src/widgets/rect-toolbar.cpp index bc27d003c..67947c1fd 100644 --- a/src/widgets/rect-toolbar.cpp +++ b/src/widgets/rect-toolbar.cpp @@ -25,7 +25,7 @@ */ #ifdef HAVE_CONFIG_H -# include "config.h" +#include <config.h> #endif #include <glibmm/i18n.h> @@ -38,8 +38,6 @@ #include "widgets/ege-output-action.h" #include "widgets/ink-action.h" #include "inkscape.h" -#include "preferences.h" -#include "selection.h" #include "sp-namedview.h" #include "sp-rect.h" #include "toolbox.h" @@ -47,11 +45,9 @@ #include "ui/tools/rect-tool.h" #include "ui/uxmanager.h" #include "ui/widget/unit-tracker.h" -#include "util/units.h" #include "verbs.h" #include "widgets/widget-sizes.h" #include "xml/node-event-vector.h" -#include "xml/repr.h" using Inkscape::UI::Widget::UnitTracker; using Inkscape::UI::UXManager; @@ -106,8 +102,8 @@ static void sp_rtb_value_changed(GtkAdjustment *adj, GObject *tbl, gchar const * bool modmade = false; Inkscape::Selection *selection = desktop->getSelection(); - std::vector<SPItem*> itemlist=selection->itemList(); - for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();++i){ + auto itemlist= selection->items(); + for(auto i=itemlist.begin();i!=itemlist.end();++i){ if (SP_IS_RECT(*i)) { if (gtk_adjustment_get_value(adj) != 0) { (SP_RECT(*i)->*setter)(Quantity::convert(gtk_adjustment_get_value(adj), unit, "px")); @@ -243,8 +239,8 @@ static void sp_rect_toolbox_selection_changed(Inkscape::Selection *selection, GO } purge_repr_listener( tbl, tbl ); - std::vector<SPItem*> itemlist=selection->itemList(); - for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();++i){ + auto itemlist= selection->items(); + for(auto i=itemlist.begin();i!=itemlist.end();++i){ if (SP_IS_RECT(*i)) { n_selected++; item = *i; diff --git a/src/widgets/select-toolbar.cpp b/src/widgets/select-toolbar.cpp index 9851b0606..e551c28c3 100644 --- a/src/widgets/select-toolbar.cpp +++ b/src/widgets/select-toolbar.cpp @@ -13,7 +13,7 @@ */ #ifdef HAVE_CONFIG_H -# include "config.h" +#include <config.h> #endif #include <2geom/rect.h> @@ -29,22 +29,19 @@ #include "widgets/ege-adjustment-action.h" #include "helper/action-context.h" #include "helper/action.h" -#include "widgets/ink-action.h" +#include "ink-action.h" +#include "ink-toggle-action.h" #include "inkscape.h" #include "message-stack.h" -#include "preferences.h" #include "selection-chemistry.h" -#include "selection.h" #include "sp-item-transform.h" #include "sp-namedview.h" #include "toolbox.h" #include "ui/icon-names.h" #include "ui/widget/unit-tracker.h" -#include "util/units.h" #include "verbs.h" #include "widgets/icon.h" #include "widgets/sp-widget.h" -#include "widgets/spw-utilities.h" #include "widgets/widget-sizes.h" using Inkscape::UI::Widget::UnitTracker; @@ -257,7 +254,7 @@ sp_object_layout_any_value_changed(GtkAdjustment *adj, GObject *tbl) scaler = get_scale_transform_for_uniform_stroke (*bbox_geom, 0, 0, false, false, x0, y0, x1, y1); } - sp_selection_apply_affine(selection, scaler); + sp_object_set_apply_affine(selection, scaler); DocumentUndo::maybeDone(document, actionkey, SP_VERB_CONTEXT_SELECT, _("Transform by toolbar")); @@ -415,12 +412,8 @@ void sp_select_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GOb g_object_set_data(G_OBJECT(spw), "dtw", desktop->getCanvas()); // The vb frame holds all other widgets and is used to set sensitivity depending on selection state. -#if GTK_CHECK_VERSION(3,0,0) - GtkWidget *vb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); + auto vb = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); gtk_box_set_homogeneous(GTK_BOX(vb), FALSE); -#else - GtkWidget *vb = gtk_hbox_new(FALSE, 0); -#endif gtk_widget_show(vb); gtk_container_add(GTK_CONTAINER(spw), vb); diff --git a/src/widgets/sp-attribute-widget.cpp b/src/widgets/sp-attribute-widget.cpp index fb7eb1420..cbff62b23 100644 --- a/src/widgets/sp-attribute-widget.cpp +++ b/src/widgets/sp-attribute-widget.cpp @@ -16,16 +16,7 @@ #include <glibmm/i18n.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 <sigc++/functors/ptr_fun.h> -#include <sigc++/adaptors/bind.h> +#include <gtkmm/grid.h> #include "sp-object.h" #include "xml/repr.h" @@ -156,11 +147,7 @@ void SPAttributeTable::set_object(SPObject *object, release_connection = object->connectRelease (sigc::bind<1>(sigc::ptr_fun(&sp_attribute_table_object_release), this)); // Create table -#if WITH_GTKMM_3_0 table = new Gtk::Grid(); -#else - table = new Gtk::Table(attributes.size(), 2, false); -#endif if (!(parent == NULL)) gtk_container_add(GTK_CONTAINER(parent), (GtkWidget*)table->gobj()); @@ -171,27 +158,17 @@ void SPAttributeTable::set_object(SPObject *object, Gtk::Label *ll = new Gtk::Label (_(labels[i].c_str())); ll->show(); ll->set_alignment (1.0, 0.5); - -#if WITH_GTKMM_3_0 ll->set_vexpand(); ll->set_margin_left(XPAD); ll->set_margin_right(XPAD); ll->set_margin_top(XPAD); ll->set_margin_bottom(XPAD); table->attach(*ll, 0, i, 1, 1); -#else - table->attach (*ll, 0, 1, i, i + 1, - Gtk::FILL, - (Gtk::EXPAND | Gtk::FILL), - XPAD, YPAD ); -#endif Gtk::Entry *ee = new Gtk::Entry(); ee->show(); const gchar *val = object->getRepr()->attribute(attributes[i].c_str()); ee->set_text (val ? val : (const gchar *) ""); - -#if WITH_GTKMM_3_0 ee->set_hexpand(); ee->set_vexpand(); ee->set_margin_left(XPAD); @@ -199,12 +176,6 @@ void SPAttributeTable::set_object(SPObject *object, ee->set_margin_top(XPAD); ee->set_margin_bottom(XPAD); table->attach(*ee, 1, i, 1, 1); -#else - table->attach (*ee, 1, 2, i, i + 1, - (Gtk::EXPAND | Gtk::FILL), - (Gtk::EXPAND | Gtk::FILL), - XPAD, YPAD ); -#endif _entries.push_back(ee); g_signal_connect ( ee->gobj(), "changed", diff --git a/src/widgets/sp-attribute-widget.h b/src/widgets/sp-attribute-widget.h index d9b972201..161bb706a 100644 --- a/src/widgets/sp-attribute-widget.h +++ b/src/widgets/sp-attribute-widget.h @@ -25,12 +25,7 @@ namespace Gtk { class Entry; - -#if WITH_GTKMM_3_0 class Grid; -#else -class Table; -#endif } namespace Inkscape { @@ -138,11 +133,7 @@ private: /** * Container widget for the dynamically created child widgets (labels and entry boxes). */ -#if WITH_GTKMM_3_0 Gtk::Grid *table; -#else - Gtk::Table *table; -#endif /** * List of attributes. diff --git a/src/widgets/sp-color-selector.cpp b/src/widgets/sp-color-selector.cpp index 93eaaee8b..159350012 100644 --- a/src/widgets/sp-color-selector.cpp +++ b/src/widgets/sp-color-selector.cpp @@ -4,7 +4,7 @@ */ #ifdef HAVE_CONFIG_H -# include "config.h" +#include <config.h> #endif #include <math.h> @@ -32,11 +32,7 @@ static guint csel_signals[LAST_SIGNAL] = {0}; double ColorSelector::_epsilon = 1e-4; -#if GTK_CHECK_VERSION(3,0,0) G_DEFINE_TYPE(SPColorSelector, sp_color_selector, GTK_TYPE_BOX); -#else -G_DEFINE_TYPE(SPColorSelector, sp_color_selector, GTK_TYPE_VBOX); -#endif void sp_color_selector_class_init( SPColorSelectorClass *klass ) { @@ -86,9 +82,7 @@ void sp_color_selector_class_init( SPColorSelectorClass *klass ) void sp_color_selector_init( SPColorSelector *csel ) { -#if GTK_CHECK_VERSION(3,0,0) gtk_orientable_set_orientation(GTK_ORIENTABLE(csel), GTK_ORIENTATION_VERTICAL); -#endif if ( csel->base ) { @@ -180,8 +174,6 @@ gfloat ColorSelector::getAlpha() const return _alpha; } -#include "svg/svg-icc-color.h" - /** Called from the outside to set the color; optionally emits signal (only when called from downstream, e.g. the RGBA value field, but not from the rest of the program) diff --git a/src/widgets/sp-color-selector.h b/src/widgets/sp-color-selector.h index 75cb79b00..14a9fccdf 100644 --- a/src/widgets/sp-color-selector.h +++ b/src/widgets/sp-color-selector.h @@ -64,21 +64,12 @@ private: #define SP_COLOR_SELECTOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SP_TYPE_COLOR_SELECTOR, SPColorSelectorClass)) struct SPColorSelector { -#if GTK_CHECK_VERSION(3,0,0) GtkBox vbox; -#else - GtkVBox vbox; -#endif - ColorSelector* base; }; struct SPColorSelectorClass { -#if GTK_CHECK_VERSION(3,0,0) GtkBoxClass parent_class; -#else - GtkVBoxClass parent_class; -#endif const gchar **name; guint submode_count; diff --git a/src/widgets/sp-widget.cpp b/src/widgets/sp-widget.cpp index 5ab6b1bb5..707e62c12 100644 --- a/src/widgets/sp-widget.cpp +++ b/src/widgets/sp-widget.cpp @@ -13,7 +13,6 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include "macros.h" #include "document.h" #include "inkscape.h" #include "sp-widget.h" @@ -41,7 +40,6 @@ public: static void show(GtkWidget *widget); static void hide(GtkWidget *widget); -#if GTK_CHECK_VERSION(3,0,0) static void getPreferredWidth(GtkWidget *widget, gint *minimal_width, gint *natural_width); @@ -50,10 +48,6 @@ public: gint *minimal_height, gint *natural_height); static gboolean draw(GtkWidget *widget, cairo_t *cr); -#else - static void sizeRequest(GtkWidget *widget, GtkRequisition *requisition); - static gboolean expose(GtkWidget *widget, GdkEventExpose *event); -#endif static void sizeAllocate(GtkWidget *widget, GtkAllocation *allocation); static void modifySelectionCB(Selection *selection, guint flags, SPWidget *spw); @@ -120,14 +114,9 @@ sp_widget_class_init(SPWidgetClass *klass) widget_class->show = SPWidgetImpl::show; widget_class->hide = SPWidgetImpl::hide; -#if GTK_CHECK_VERSION(3,0,0) widget_class->get_preferred_width = SPWidgetImpl::getPreferredWidth; widget_class->get_preferred_height = SPWidgetImpl::getPreferredHeight; widget_class->draw = SPWidgetImpl::draw; -#else - widget_class->size_request = SPWidgetImpl::sizeRequest; - widget_class->expose_event = SPWidgetImpl::expose; -#endif widget_class->size_allocate = SPWidgetImpl::sizeAllocate; } @@ -207,27 +196,18 @@ void SPWidgetImpl::hide(GtkWidget *widget) } } -#if GTK_CHECK_VERSION(3,0,0) gboolean SPWidgetImpl::draw(GtkWidget *widget, cairo_t *cr) -#else -gboolean SPWidgetImpl::expose(GtkWidget *widget, GdkEventExpose *event) -#endif { GtkBin *bin = GTK_BIN(widget); GtkWidget *child = gtk_bin_get_child(bin); if (child) { -#if GTK_CHECK_VERSION(3,0,0) gtk_container_propagate_draw(GTK_CONTAINER(widget), child, cr); -#else - gtk_container_propagate_expose(GTK_CONTAINER(widget), child, event); -#endif } return FALSE; } -#if GTK_CHECK_VERSION(3,0,0) void SPWidgetImpl::getPreferredWidth(GtkWidget *widget, gint *minimal_width, gint *natural_width) { GtkBin *bin = GTK_BIN(widget); @@ -247,17 +227,6 @@ void SPWidgetImpl::getPreferredHeight(GtkWidget *widget, gint *minimal_height, g gtk_widget_get_preferred_height(child, minimal_height, natural_height); } } -#else -void SPWidgetImpl::sizeRequest(GtkWidget *widget, GtkRequisition *requisition) -{ - GtkBin *bin = GTK_BIN(widget); - GtkWidget *child = gtk_bin_get_child(bin); - - if (child) { - gtk_widget_size_request(child, requisition); - } -} -#endif void SPWidgetImpl::sizeAllocate(GtkWidget *widget, GtkAllocation *allocation) { diff --git a/src/widgets/sp-xmlview-attr-list.cpp b/src/widgets/sp-xmlview-attr-list.cpp index a4c00db7c..e99605b97 100644 --- a/src/widgets/sp-xmlview-attr-list.cpp +++ b/src/widgets/sp-xmlview-attr-list.cpp @@ -10,7 +10,7 @@ */ #ifdef HAVE_CONFIG_H -# include <config.h> +#include <config.h> #endif #include <cstring> @@ -20,11 +20,7 @@ #include "../xml/node-event-vector.h" #include "sp-xmlview-attr-list.h" -#if GTK_CHECK_VERSION(3,0,0) static void sp_xmlview_attr_list_destroy(GtkWidget * object); -#else -static void sp_xmlview_attr_list_destroy(GtkObject * object); -#endif static void event_attr_changed (Inkscape::XML::Node * repr, const gchar * name, const gchar * old_value, const gchar * new_value, bool is_interactive, gpointer data); @@ -87,13 +83,8 @@ G_DEFINE_TYPE(SPXMLViewAttrList, sp_xmlview_attr_list, GTK_TYPE_TREE_VIEW); void sp_xmlview_attr_list_class_init (SPXMLViewAttrListClass * klass) { -#if GTK_CHECK_VERSION(3,0,0) - GtkWidgetClass * widget_class = GTK_WIDGET_CLASS(klass); + auto widget_class = GTK_WIDGET_CLASS(klass); widget_class->destroy = sp_xmlview_attr_list_destroy; -#else - GtkObjectClass * object_class = GTK_OBJECT_CLASS(klass); - object_class->destroy = sp_xmlview_attr_list_destroy; -#endif g_signal_new("row-value-changed", G_TYPE_FROM_CLASS(klass), @@ -112,11 +103,7 @@ sp_xmlview_attr_list_init (SPXMLViewAttrList * list) list->repr = NULL; } -#if GTK_CHECK_VERSION(3,0,0) void sp_xmlview_attr_list_destroy(GtkWidget * object) -#else -void sp_xmlview_attr_list_destroy(GtkObject * object) -#endif { SPXMLViewAttrList * list; @@ -125,11 +112,7 @@ void sp_xmlview_attr_list_destroy(GtkObject * object) g_object_unref(list->store); sp_xmlview_attr_list_set_repr (list, NULL); -#if GTK_CHECK_VERSION(3,0,0) GTK_WIDGET_CLASS(sp_xmlview_attr_list_parent_class)->destroy (object); -#else - GTK_OBJECT_CLASS(sp_xmlview_attr_list_parent_class)->destroy (object); -#endif } void sp_xmlview_attr_list_select_row_by_key(SPXMLViewAttrList * list, const gchar *name) diff --git a/src/widgets/sp-xmlview-content.cpp b/src/widgets/sp-xmlview-content.cpp index a1d8475ba..6e59ba3cd 100644 --- a/src/widgets/sp-xmlview-content.cpp +++ b/src/widgets/sp-xmlview-content.cpp @@ -23,11 +23,7 @@ using Inkscape::DocumentUndo; -#if GTK_CHECK_VERSION(3,0,0) static void sp_xmlview_content_destroy(GtkWidget * object); -#else -static void sp_xmlview_content_destroy(GtkObject * object); -#endif void sp_xmlview_content_changed (GtkTextBuffer *tb, SPXMLViewContent *text); @@ -80,13 +76,8 @@ G_DEFINE_TYPE(SPXMLViewContent, sp_xmlview_content, GTK_TYPE_TEXT_VIEW); void sp_xmlview_content_class_init(SPXMLViewContentClass * klass) { -#if GTK_CHECK_VERSION(3,0,0) - GtkWidgetClass * widget_class = GTK_WIDGET_CLASS(klass); + auto widget_class = GTK_WIDGET_CLASS(klass); widget_class->destroy = sp_xmlview_content_destroy; -#else - GtkObjectClass * object_class = GTK_OBJECT_CLASS(klass); - object_class->destroy = sp_xmlview_content_destroy; -#endif } void @@ -96,21 +87,13 @@ sp_xmlview_content_init (SPXMLViewContent *text) text->blocked = FALSE; } -#if GTK_CHECK_VERSION(3,0,0) void sp_xmlview_content_destroy(GtkWidget * object) -#else -void sp_xmlview_content_destroy(GtkObject * object) -#endif { SPXMLViewContent * text = SP_XMLVIEW_CONTENT (object); sp_xmlview_content_set_repr (text, NULL); -#if GTK_CHECK_VERSION(3,0,0) GTK_WIDGET_CLASS (sp_xmlview_content_parent_class)->destroy (object); -#else - GTK_OBJECT_CLASS (sp_xmlview_content_parent_class)->destroy (object); -#endif } void diff --git a/src/widgets/sp-xmlview-tree.cpp b/src/widgets/sp-xmlview-tree.cpp index 5dff9adf3..3f8cc6063 100644 --- a/src/widgets/sp-xmlview-tree.cpp +++ b/src/widgets/sp-xmlview-tree.cpp @@ -10,7 +10,6 @@ */ #include <cstring> -#include <string> #include "xml/node-event-vector.h" #include "sp-xmlview-tree.h" @@ -23,11 +22,7 @@ struct NodeData { enum { STORE_TEXT_COL = 0, STORE_DATA_COL, STORE_REPR_COL, STORE_N_COLS }; -#if GTK_CHECK_VERSION(3,0,0) static void sp_xmlview_tree_destroy(GtkWidget * object); -#else -static void sp_xmlview_tree_destroy(GtkObject * object); -#endif static NodeData * node_data_new (SPXMLViewTree * tree, GtkTreeIter * node, GtkTreeRowReference *rowref, Inkscape::XML::Node * repr); @@ -121,13 +116,8 @@ G_DEFINE_TYPE(SPXMLViewTree, sp_xmlview_tree, GTK_TYPE_TREE_VIEW); void sp_xmlview_tree_class_init(SPXMLViewTreeClass * klass) { -#if GTK_CHECK_VERSION(3,0,0) - GtkWidgetClass * widget_class = GTK_WIDGET_CLASS(klass); + auto widget_class = GTK_WIDGET_CLASS(klass); widget_class->destroy = sp_xmlview_tree_destroy; -#else - GtkObjectClass * object_class = GTK_OBJECT_CLASS(klass); - object_class->destroy = sp_xmlview_tree_destroy; -#endif // Signal for when a tree drag and drop has completed g_signal_new ( "tree_move", @@ -148,22 +138,13 @@ sp_xmlview_tree_init (SPXMLViewTree * tree) tree->dndactive = FALSE; } - -#if GTK_CHECK_VERSION(3,0,0) void sp_xmlview_tree_destroy(GtkWidget * object) -#else -void sp_xmlview_tree_destroy(GtkObject * object) -#endif { SPXMLViewTree * tree = SP_XMLVIEW_TREE (object); sp_xmlview_tree_set_repr (tree, NULL); -#if GTK_CHECK_VERSION(3,0,0) GTK_WIDGET_CLASS(sp_xmlview_tree_parent_class)->destroy (object); -#else - GTK_OBJECT_CLASS(sp_xmlview_tree_parent_class)->destroy (object); -#endif } /* diff --git a/src/widgets/spinbutton-events.cpp b/src/widgets/spinbutton-events.cpp index 0280694f6..fdf88ec85 100644 --- a/src/widgets/spinbutton-events.cpp +++ b/src/widgets/spinbutton-events.cpp @@ -12,7 +12,7 @@ */ #ifdef HAVE_CONFIG_H -# include "config.h" +#include <config.h> #endif #include <gtk/gtk.h> @@ -21,7 +21,6 @@ #include "ui/tools/tool-base.h" #include "sp-widget.h" -#include "widget-sizes.h" #include "spinbutton-events.h" gboolean spinbutton_focus_in(GtkWidget *w, GdkEventKey * /*event*/, gpointer /*data*/) diff --git a/src/widgets/spiral-toolbar.cpp b/src/widgets/spiral-toolbar.cpp index 7e7398091..98d21c84d 100644 --- a/src/widgets/spiral-toolbar.cpp +++ b/src/widgets/spiral-toolbar.cpp @@ -25,7 +25,7 @@ */ #ifdef HAVE_CONFIG_H -# include "config.h" +#include <config.h> #endif #include <glibmm/i18n.h> @@ -37,7 +37,6 @@ #include "widgets/ege-adjustment-action.h" #include "widgets/ege-output-action.h" #include "widgets/ink-action.h" -#include "preferences.h" #include "selection.h" #include "sp-spiral.h" #include "toolbox.h" @@ -46,8 +45,6 @@ #include "verbs.h" #include "widgets/spinbutton-events.h" #include "xml/node-event-vector.h" -#include "xml/node.h" -#include "xml/repr.h" using Inkscape::UI::UXManager; using Inkscape::DocumentUndo; @@ -79,8 +76,8 @@ static void sp_spl_tb_value_changed(GtkAdjustment *adj, GObject *tbl, Glib::ustr gchar* namespaced_name = g_strconcat("sodipodi:", value_name.data(), NULL); bool modmade = false; - std::vector<SPItem*> itemlist=desktop->getSelection()->itemList(); - for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end(); ++i){ + auto itemlist= desktop->getSelection()->items(); + for(auto i=itemlist.begin();i!=itemlist.end(); ++i){ SPItem *item = *i; if (SP_IS_SPIRAL(item)) { Inkscape::XML::Node *repr = item->getRepr(); @@ -195,8 +192,8 @@ static void sp_spiral_toolbox_selection_changed(Inkscape::Selection *selection, purge_repr_listener( tbl, tbl ); - std::vector<SPItem*> itemlist=selection->itemList(); - for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end(); ++i){ + auto itemlist= selection->items(); + for(auto i=itemlist.begin();i!=itemlist.end(); ++i){ SPItem *item = *i; if (SP_IS_SPIRAL(item)) { n_selected++; diff --git a/src/widgets/spray-toolbar.cpp b/src/widgets/spray-toolbar.cpp index 9e142a8db..a724637e3 100644 --- a/src/widgets/spray-toolbar.cpp +++ b/src/widgets/spray-toolbar.cpp @@ -26,7 +26,7 @@ */ #ifdef HAVE_CONFIG_H -# include "config.h" +#include <config.h> #endif #include <gtkmm.h> @@ -36,8 +36,8 @@ #include "inkscape.h" #include "widgets/ege-adjustment-action.h" #include "widgets/ege-select-one-action.h" -#include "widgets/ink-action.h" -#include "preferences.h" +#include "ink-radio-action.h" +#include "ink-toggle-action.h" #include "toolbox.h" #include "ui/dialog/clonetiler.h" #include "ui/dialog/dialog-manager.h" diff --git a/src/widgets/spw-utilities.cpp b/src/widgets/spw-utilities.cpp index 5500e1068..88a76b1ed 100644 --- a/src/widgets/spw-utilities.cpp +++ b/src/widgets/spw-utilities.cpp @@ -11,7 +11,7 @@ */ #ifdef HAVE_CONFIG_H -# include "config.h" +#include <config.h> #endif #include <cstring> @@ -19,28 +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 "spw-utilities.h" -#include <gtk/gtk.h> - /** * Creates a label widget with the given text, at the given col, row * position in the table. */ -#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); @@ -56,7 +45,6 @@ Gtk::Label * spw_label(Gtk::Table *table, const gchar *label_text, int col, int 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); @@ -70,9 +58,6 @@ Gtk::Label * spw_label(Gtk::Table *table, const gchar *label_text, int col, int #endif 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; } @@ -84,16 +69,9 @@ spw_label_old(GtkWidget *table, const gchar *label_text, int col, int row) label_widget = gtk_label_new (label_text); g_assert(label_widget != NULL); - -#if GTK_CHECK_VERSION(3,0,0) gtk_widget_set_halign(label_widget, GTK_ALIGN_END); -#else - gtk_misc_set_alignment (GTK_MISC (label_widget), 1.0, 0.5); -#endif - gtk_widget_show (label_widget); -#if GTK_CHECK_VERSION(3,0,0) #if GTK_CHECK_VERSION(3,12,0) gtk_widget_set_margin_start(label_widget, 4); gtk_widget_set_margin_end(label_widget, 4); @@ -105,10 +83,6 @@ spw_label_old(GtkWidget *table, const gchar *label_text, int col, int row) 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; } @@ -117,25 +91,16 @@ 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. */ -#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; } @@ -177,37 +142,21 @@ spw_checkbutton(GtkWidget * dialog, GtkWidget * table, g_assert(table != NULL); GtkWidget *l = gtk_label_new (label); - -#if GTK_CHECK_VERSION(3,0,0) gtk_widget_set_halign(l, GTK_ALIGN_END); -#else - gtk_misc_set_alignment (GTK_MISC (l), 1.0, 0.5); -#endif - gtk_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); @@ -235,16 +184,10 @@ 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; @@ -255,8 +198,7 @@ sp_set_font_size_recursive (GtkWidget *w, gpointer font) { guint size = GPOINTER_TO_UINT (font); -#if GTK_CHECK_VERSION(3,0,0) - GtkCssProvider *css_provider = gtk_css_provider_new(); + auto css_provider = gtk_css_provider_new(); const double pt_size = size / static_cast<double>(PANGO_SCALE); std::ostringstream css_data; @@ -268,25 +210,16 @@ sp_set_font_size_recursive (GtkWidget *w, gpointer font) css_data.str().c_str(), -1, NULL); - GtkStyleContext *style_context = gtk_widget_get_style_context(w); + auto style_context = gtk_widget_get_style_context(w); gtk_style_context_add_provider(style_context, GTK_STYLE_PROVIDER(css_provider), GTK_STYLE_PROVIDER_PRIORITY_USER); -#else - PangoFontDescription* pan = pango_font_description_new (); - pango_font_description_set_size (pan, size); - gtk_widget_modify_font (w, pan); -#endif if (GTK_IS_CONTAINER(w)) { gtk_container_foreach (GTK_CONTAINER(w), (GtkCallback) sp_set_font_size_recursive, font); } -#if GTK_CHECK_VERSION(3,0,0) g_object_unref(css_provider); -#else - pango_font_description_free (pan); -#endif } void diff --git a/src/widgets/spw-utilities.h b/src/widgets/spw-utilities.h index 31f29e026..71b451631 100644 --- a/src/widgets/spw-utilities.h +++ b/src/widgets/spw-utilities.h @@ -20,25 +20,13 @@ namespace Gtk { class Label; - -#if GTK_CHECK_VERSION(3,0,0) class Grid; -#else - class Table; -#endif - class HBox; class Widget; } -#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 - GtkWidget * spw_label_old(GtkWidget *table, gchar const *label_text, int col, int row); GtkWidget * diff --git a/src/widgets/star-toolbar.cpp b/src/widgets/star-toolbar.cpp index 982a3c854..8f667a656 100644 --- a/src/widgets/star-toolbar.cpp +++ b/src/widgets/star-toolbar.cpp @@ -25,7 +25,7 @@ */ #ifdef HAVE_CONFIG_H -# include "config.h" +#include <config.h> #endif #include <glibmm/i18n.h> @@ -37,7 +37,8 @@ #include "widgets/ege-adjustment-action.h" #include "widgets/ege-output-action.h" #include "widgets/ege-select-one-action.h" -#include "widgets/ink-action.h" +#include "ink-action.h" +#include "ink-radio-action.h" #include "selection.h" #include "sp-star.h" #include "toolbox.h" @@ -45,10 +46,7 @@ #include "ui/tools/star-tool.h" #include "ui/uxmanager.h" #include "verbs.h" -#include "widgets/../preferences.h" #include "xml/node-event-vector.h" -#include "xml/node.h" -#include "xml/repr.h" using Inkscape::UI::UXManager; using Inkscape::DocumentUndo; @@ -83,8 +81,8 @@ static void sp_stb_magnitude_value_changed( GtkAdjustment *adj, GObject *dataKlu bool modmade = false; Inkscape::Selection *selection = desktop->getSelection(); - std::vector<SPItem*> itemlist=selection->itemList(); - for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();++i){ + auto itemlist= selection->items(); + for(auto i=itemlist.begin();i!=itemlist.end();++i){ SPItem *item = *i; if (SP_IS_STAR(item)) { Inkscape::XML::Node *repr = item->getRepr(); @@ -128,8 +126,8 @@ static void sp_stb_proportion_value_changed( GtkAdjustment *adj, GObject *dataKl bool modmade = false; Inkscape::Selection *selection = desktop->getSelection(); - std::vector<SPItem*> itemlist=selection->itemList(); - for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();++i){ + auto itemlist= selection->items(); + for(auto i=itemlist.begin();i!=itemlist.end();++i){ SPItem *item = *i; if (SP_IS_STAR(item)) { Inkscape::XML::Node *repr = item->getRepr(); @@ -185,8 +183,8 @@ static void sp_stb_sides_flat_state_changed( EgeSelectOneAction *act, GObject *d gtk_action_set_visible( prop_action, !flat ); } - std::vector<SPItem*> itemlist=selection->itemList(); - for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();++i){ + auto itemlist= selection->items(); + for(auto i=itemlist.begin();i!=itemlist.end();++i){ SPItem *item = *i; if (SP_IS_STAR(item)) { Inkscape::XML::Node *repr = item->getRepr(); @@ -224,8 +222,8 @@ static void sp_stb_rounded_value_changed( GtkAdjustment *adj, GObject *dataKludg bool modmade = false; Inkscape::Selection *selection = desktop->getSelection(); - std::vector<SPItem*> itemlist=selection->itemList(); - for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();++i){ + auto itemlist= selection->items(); + for(auto i=itemlist.begin();i!=itemlist.end();++i){ SPItem *item = *i; if (SP_IS_STAR(item)) { Inkscape::XML::Node *repr = item->getRepr(); @@ -264,8 +262,8 @@ static void sp_stb_randomized_value_changed( GtkAdjustment *adj, GObject *dataKl bool modmade = false; Inkscape::Selection *selection = desktop->getSelection(); - std::vector<SPItem*> itemlist=selection->itemList(); - for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();++i){ + auto itemlist= selection->items(); + for(auto i=itemlist.begin();i!=itemlist.end();++i){ SPItem *item = *i; if (SP_IS_STAR(item)) { Inkscape::XML::Node *repr = item->getRepr(); @@ -367,8 +365,8 @@ sp_star_toolbox_selection_changed(Inkscape::Selection *selection, GObject *tbl) purge_repr_listener( tbl, tbl ); - std::vector<SPItem*> itemlist=selection->itemList(); - for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();++i){ + auto itemlist= selection->items(); + for(auto i=itemlist.begin();i!=itemlist.end();++i){ SPItem *item = *i; if (SP_IS_STAR(item)) { n_selected++; diff --git a/src/widgets/stroke-marker-selector.cpp b/src/widgets/stroke-marker-selector.cpp index e273faad7..b0c23a88c 100644 --- a/src/widgets/stroke-marker-selector.cpp +++ b/src/widgets/stroke-marker-selector.cpp @@ -18,17 +18,13 @@ #include "stroke-marker-selector.h" -#include <cstring> -#include <string> #include <glibmm/i18n.h> -#include <2geom/coord.h> #include "style.h" #include "ui/dialog-events.h" #include "desktop-style.h" -#include "preferences.h" #include "path-prefix.h" #include "io/sys.h" #include "sp-marker.h" @@ -39,10 +35,8 @@ #include "gradient-vector.h" #include <gtkmm/icontheme.h> -#include <gtkmm/adjustment.h> #include "ui/widget/spinbutton.h" #include "stroke-style.h" -#include "gradient-chemistry.h" static Inkscape::UI::Cache::SvgPreview svg_preview_cache; @@ -335,10 +329,10 @@ GSList *MarkerComboBox::get_marker_list (SPDocument *source) return NULL; } - for ( SPObject *child = defs->firstChild(); child; child = child->getNext() ) + for (auto& child: defs->children) { - if (SP_IS_MARKER(child)) { - ml = g_slist_prepend (ml, child); + if (SP_IS_MARKER(&child)) { + ml = g_slist_prepend (ml, &child); } } return ml; diff --git a/src/widgets/stroke-style.cpp b/src/widgets/stroke-style.cpp index 84a6e77ad..4a658c5dc 100644 --- a/src/widgets/stroke-style.cpp +++ b/src/widgets/stroke-style.cpp @@ -18,11 +18,8 @@ #define noSP_SS_VERBOSE #include "stroke-style.h" -#include "gradient-chemistry.h" -#include "sp-gradient.h" #include "sp-stop.h" #include "svg/svg-color.h" -#include "util/units.h" #include "ui/widget/unit-menu.h" #include "desktop-widget.h" @@ -155,17 +152,9 @@ StrokeStyle::StrokeStyle() : Gtk::HBox *f = new Gtk::HBox(false, 0); 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->set_border_width(4); - table->set_row_spacings(4); -#endif - table->show(); f->add(*table); @@ -181,13 +170,7 @@ StrokeStyle::StrokeStyle() : // stroke_width_set_unit will be removed (because ScalarUnit takes care of conversions itself), and // with it, the two remaining calls of stroke_average_width, allowing us to get rid of that // function in desktop-style. - -#if WITH_GTKMM_3_0 widthAdj = new Glib::RefPtr<Gtk::Adjustment>(Gtk::Adjustment::create(1.0, 0.0, 1000.0, 0.1, 10.0, 0.0)); -#else - widthAdj = new Gtk::Adjustment(1.0, 0.0, 1000.0, 0.1, 10.0, 0.0); -#endif - widthSpin = new Inkscape::UI::Widget::SpinButton(*widthAdj, 0.1, 3); widthSpin->set_tooltip_text(_("Stroke width")); widthSpin->show(); @@ -213,12 +196,7 @@ StrokeStyle::StrokeStyle() : us->show(); hb->pack_start(*us, FALSE, FALSE, 0); - -#if WITH_GTKMM_3_0 (*widthAdj)->signal_value_changed().connect(sigc::mem_fun(*this, &StrokeStyle::widthChangedCB)); -#else - widthAdj->signal_value_changed().connect(sigc::mem_fun(*this, &StrokeStyle::widthChangedCB)); -#endif i++; /* Dash */ @@ -230,16 +208,10 @@ StrokeStyle::StrokeStyle() : dashSelector = Gtk::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++; @@ -323,28 +295,14 @@ StrokeStyle::StrokeStyle() : // miter limit is to cut off such spikes (i.e. convert them into bevels) // when they become too long. //spw_label(t, _("Miter _limit:"), 0, i); - -#if WITH_GTKMM_3_0 miterLimitAdj = new Glib::RefPtr<Gtk::Adjustment>(Gtk::Adjustment::create(4.0, 0.0, 100.0, 0.1, 10.0, 0.0)); miterLimitSpin = new Inkscape::UI::Widget::SpinButton(*miterLimitAdj, 0.1, 2); -#else - miterLimitAdj = new Gtk::Adjustment(4.0, 0.0, 100.0, 0.1, 10.0, 0.0); - miterLimitSpin = new Inkscape::UI::Widget::SpinButton(*miterLimitAdj, 0.1, 2); -#endif - miterLimitSpin->set_tooltip_text(_("Maximum length of the miter (in units of stroke width)")); miterLimitSpin->show(); sp_dialog_defocus_on_enter_cpp(miterLimitSpin); hb->pack_start(*miterLimitSpin, false, false, 0); - -#if WITH_GTKMM_3_0 (*miterLimitAdj)->signal_value_changed().connect(sigc::mem_fun(*this, &StrokeStyle::miterLimitChangedCB)); - -#else - miterLimitAdj->signal_value_changed().connect(sigc::mem_fun(*this, &StrokeStyle::miterLimitChangedCB)); -#endif - i++; /* Cap type */ @@ -515,8 +473,8 @@ void StrokeStyle::markerSelectCB(MarkerComboBox *marker_combo, StrokeStyle *spw, //spw->updateMarkerHist(which); Inkscape::Selection *selection = spw->desktop->getSelection(); - std::vector<SPItem*> itemlist=selection->itemList(); - for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();++i){ + auto itemlist= selection->items(); + for(auto i=itemlist.begin();i!=itemlist.end();++i){ SPItem *item = *i; if (!SP_IS_SHAPE(item) || SP_IS_RECT(item)) { // can't set marker to rect, until it's converted to using <path> continue; @@ -927,17 +885,9 @@ StrokeStyle::updateLine() if (unit->type == Inkscape::Util::UNIT_TYPE_LINEAR) { double avgwidth = Inkscape::Util::Quantity::convert(query.stroke_width.computed, "px", unit); -#if WITH_GTKMM_3_0 (*widthAdj)->set_value(avgwidth); -#else - widthAdj->set_value(avgwidth); -#endif } else { -#if WITH_GTKMM_3_0 (*widthAdj)->set_value(100); -#else - widthAdj->set_value(100); -#endif } // if none of the selected objects has a stroke, than quite some controls should be disabled @@ -958,11 +908,7 @@ StrokeStyle::updateLine() } if (result_ml != QUERY_STYLE_NOTHING) -#if WITH_GTKMM_3_0 (*miterLimitAdj)->set_value(query.stroke_miterlimit.value); // TODO: reflect averagedness? -#else - miterLimitAdj->set_value(query.stroke_miterlimit.value); // TODO: reflect averagedness? -#endif if (result_join != QUERY_STYLE_MULTIPLE_DIFFERENT && result_join != QUERY_STYLE_NOTHING ) { @@ -988,7 +934,7 @@ StrokeStyle::updateLine() if (!sel || sel->isEmpty()) return; - std::vector<SPItem*> const objects = sel->itemList(); + std::vector<SPItem*> const objects(sel->items().begin(), sel->items().end()); SPObject * const object = objects[0]; SPStyle * const style = object->style; @@ -1044,19 +990,14 @@ StrokeStyle::scaleLine() SPDocument *document = desktop->getDocument(); Inkscape::Selection *selection = desktop->getSelection(); - std::vector<SPItem*> items=selection->itemList(); + auto items= selection->items(); /* TODO: Create some standardized method */ SPCSSAttr *css = sp_repr_css_attr_new(); if (!items.empty()) { -#if WITH_GTKMM_3_0 double width_typed = (*widthAdj)->get_value(); double const miterlimit = (*miterLimitAdj)->get_value(); -#else - double width_typed = widthAdj->get_value(); - double const miterlimit = miterLimitAdj->get_value(); -#endif Inkscape::Util::Unit const *const unit = unitSelector->getUnit(); @@ -1064,7 +1005,7 @@ StrokeStyle::scaleLine() int ndash; dashSelector->get_dash(&ndash, &dash, &offset); - for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();++i){ + for(auto i=items.begin();i!=items.end();++i){ /* Set stroke width */ double width; if (unit->type == Inkscape::Util::UNIT_TYPE_LINEAR) { @@ -1096,11 +1037,7 @@ StrokeStyle::scaleLine() if (unit->type != Inkscape::Util::UNIT_TYPE_LINEAR) { // reset to 100 percent -#if WITH_GTKMM_3_0 (*widthAdj)->set_value(100.0); -#else - widthAdj->set_value(100.0); -#endif } } diff --git a/src/widgets/stroke-style.h b/src/widgets/stroke-style.h index d83067a4a..76582602d 100644 --- a/src/widgets/stroke-style.h +++ b/src/widgets/stroke-style.h @@ -23,12 +23,7 @@ #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> @@ -189,15 +184,9 @@ private: MarkerComboBox *startMarkerCombo; MarkerComboBox *midMarkerCombo; MarkerComboBox *endMarkerCombo; -#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 Inkscape::UI::Widget::SpinButton *miterLimitSpin; Inkscape::UI::Widget::SpinButton *widthSpin; Inkscape::UI::Widget::UnitMenu *unitSelector; diff --git a/src/widgets/text-toolbar.cpp b/src/widgets/text-toolbar.cpp index 23acb74af..4b22c8d7e 100644 --- a/src/widgets/text-toolbar.cpp +++ b/src/widgets/text-toolbar.cpp @@ -25,7 +25,7 @@ */ #ifdef HAVE_CONFIG_H -# include "config.h" +#include <config.h> #endif #include "libnrtype/font-lister.h" @@ -38,12 +38,11 @@ #include "document.h" #include "widgets/ege-adjustment-action.h" #include "widgets/ege-select-one-action.h" -#include "widgets/ink-action.h" +#include "ink-radio-action.h" +#include "ink-toggle-action.h" #include "widgets/ink-comboboxentry-action.h" #include "inkscape.h" -#include "preferences.h" #include "selection-chemistry.h" -#include "selection.h" #include "sp-flowtext.h" #include "sp-root.h" #include "sp-text.h" @@ -53,11 +52,8 @@ #include "toolbox.h" #include "ui/icon-names.h" #include "ui/tools/text-tool.h" -#include "ui/tools/tool-base.h" #include "ui/widget/unit-tracker.h" -#include "util/units.h" #include "verbs.h" -#include "xml/repr.h" using Inkscape::DocumentUndo; using Inkscape::UI::ToolboxFactory; @@ -378,8 +374,8 @@ 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 = desktop->getSelection(); - std::vector<SPItem*> itemlist=selection->itemList(); - for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end(); ++i){ + auto itemlist= selection->items(); + for(auto i=itemlist.begin();i!=itemlist.end(); ++i){ if (SP_IS_TEXT(*i)) { SPItem *item = *i; @@ -560,8 +556,8 @@ static void sp_text_lineheight_value_changed( GtkAdjustment *adj, GObject *tbl ) // Only need to save for undo if a text item has been changed. Inkscape::Selection *selection = desktop->getSelection(); bool modmade = false; - std::vector<SPItem*> itemlist=selection->itemList(); - for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end(); ++i){ + auto itemlist= selection->items(); + for(auto i=itemlist.begin();i!=itemlist.end(); ++i){ if (SP_IS_TEXT (*i)) { modmade = true; } @@ -569,6 +565,16 @@ static void sp_text_lineheight_value_changed( GtkAdjustment *adj, GObject *tbl ) // Save for undo if(modmade) { + // Call ensureUpToDate() causes rebuild of text layout (with all proper style + // cascading, etc.). For multi-line text with sodipodi::role="line", we must explicitly + // save new <tspan> 'x' and 'y' attribute values by calling updateRepr(). + // Partial fix for bug #1590141. + desktop->getDocument()->ensureUpToDate(); + for(auto i=itemlist.begin();i!=itemlist.end(); ++i){ + if (SP_IS_TEXT (*i)) { + (*i)->updateRepr(); + } + } DocumentUndo::maybeDone(SP_ACTIVE_DESKTOP->getDocument(), "ttb:line-height", SP_VERB_NONE, _("Text: Change line-height")); } @@ -625,7 +631,7 @@ static void sp_text_lineheight_unit_changed( gpointer /* */, GObject *tbl ) SPDesktop *desktop = SP_ACTIVE_DESKTOP; Inkscape::Selection *selection = desktop->getSelection(); - std::vector<SPItem*> itemlist=selection->itemList(); + auto itemlist = selection->items(); // Convert between units if ((unit->abbr == "" || unit->abbr == "em") && old_unit == SP_CSS_UNIT_EX) { @@ -644,7 +650,7 @@ static void sp_text_lineheight_unit_changed( gpointer /* */, GObject *tbl ) // Convert absolute to relative... for the moment use average font-size double font_size = 0; int count = 0; - for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end(); ++i){ + for(auto i=itemlist.begin();i!=itemlist.end(); ++i){ if (SP_IS_TEXT (*i)) { double doc_scale = Geom::Affine((*i)->i2dt_affine()).descrim(); font_size += (*i)->style->font_size.computed * doc_scale; @@ -673,7 +679,7 @@ static void sp_text_lineheight_unit_changed( gpointer /* */, GObject *tbl ) // Convert relative to absolute... for the moment use average font-size double font_size = 0; int count = 0; - for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end(); ++i){ + for(auto i=itemlist.begin();i!=itemlist.end(); ++i){ if (SP_IS_TEXT (*i)) { double doc_scale = Geom::Affine((*i)->i2dt_affine()).descrim(); font_size += (*i)->style->font_size.computed * doc_scale; @@ -716,7 +722,7 @@ static void sp_text_lineheight_unit_changed( gpointer /* */, GObject *tbl ) // Only need to save for undo if a text item has been changed. bool modmade = false; - for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end(); ++i){ + for(auto i=itemlist.begin();i!=itemlist.end(); ++i){ if (SP_IS_TEXT (*i)) { modmade = true; } @@ -1120,8 +1126,8 @@ static void sp_text_toolbox_selection_changed(Inkscape::Selection */*selection*/ // Only flowed text can be justified, only normal text can be kerned... // Find out if we have flowed text now so we can use it several places gboolean isFlow = false; - std::vector<SPItem*> itemlist=SP_ACTIVE_DESKTOP->getSelection()->itemList(); - for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end(); ++i){ + auto itemlist= SP_ACTIVE_DESKTOP->getSelection()->items(); + for(auto i=itemlist.begin();i!=itemlist.end(); ++i){ // const gchar* id = reinterpret_cast<SPItem *>(items->data)->getId(); // std::cout << " " << id << std::endl; if( SP_IS_FLOWTEXT(*i)) { @@ -1562,8 +1568,7 @@ void sp_text_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje g_object_set_data( holder, "TextFontFamilyAction", act ); // Change style of drop-down from menu to list -#if GTK_CHECK_VERSION(3,0,0) - GtkCssProvider *css_provider = gtk_css_provider_new(); + auto css_provider = gtk_css_provider_new(); gtk_css_provider_load_from_data(css_provider, "#TextFontFamilyAction_combobox {\n" " -GtkComboBox-appears-as-list: true;\n" @@ -1574,24 +1579,10 @@ void sp_text_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje "}\n", -1, NULL); - GdkScreen *screen = gdk_screen_get_default(); + auto screen = gdk_screen_get_default(); gtk_style_context_add_provider_for_screen(screen, GTK_STYLE_PROVIDER(css_provider), GTK_STYLE_PROVIDER_PRIORITY_USER); -#else - gtk_rc_parse_string ( - "style \"dropdown-as-list-style\"\n" - "{\n" - " GtkComboBox::appears-as-list = 1\n" - "}\n" - "widget \"*.TextFontFamilyAction_combobox\" style \"dropdown-as-list-style\"" - "style \"fontfamily-separator-style\"\n" - "{\n" - " GtkWidget::wide-separators = 1\n" - " GtkWidget::separator-height = 6\n" - "}\n" - "widget \"*gtk-combobox-popup-window.GtkScrolledWindow.GtkTreeView\" style \"fontfamily-separator-style\""); -#endif } /* Font size */ diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index 8113c9619..c03ca85e6 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -27,7 +27,7 @@ */ #ifdef HAVE_CONFIG_H -# include "config.h" +#include "config.h" #endif #include <gtkmm/box.h> @@ -40,14 +40,10 @@ #include "../desktop-style.h" #include "document-undo.h" #include "widgets/ege-adjustment-action.h" -#include "widgets/ege-output-action.h" -#include "widgets/ege-select-one-action.h" -#include "../graphlayout.h" #include "../helper/action.h" -#include "../helper/action-context.h" #include "icon.h" #include "ink-action.h" -#include "ink-comboboxentry-action.h" +#include "ink-toggle-action.h" #include "../inkscape.h" #include "ui/interface.h" #include "../shortcuts.h" @@ -64,7 +60,6 @@ #include "../widgets/widget-sizes.h" #include "../xml/attribute-record.h" #include "../xml/node-event-vector.h" -#include "../xml/repr.h" #include "ui/uxmanager.h" @@ -95,7 +90,6 @@ #include "zoom-toolbar.h" #include "toolbox.h" -#include <gtk/gtk.h> #include "ui/tools/tool-base.h" @@ -499,6 +493,13 @@ static gchar const * ui_descr = " <toolitem action='EraserModeAction' />" " <separator />" " <toolitem action='EraserWidthAction' />" + " <toolitem action='EraserPressureAction' />" + " <separator />" + " <toolitem action='EraserThinningAction' />" + " <separator />" + " <toolitem action='EraserCapRoundingAction' />" + " <separator />" + " <toolitem action='EraserTremorAction' />" " <separator />" " <toolitem action='EraserMassAction' />" " <separator />" @@ -1016,26 +1017,18 @@ static GtkWidget* toolboxNewCommon( GtkWidget* tb, BarId id, GtkPositionType /*h GtkWidget *ToolboxFactory::createToolToolbox() { -#if GTK_CHECK_VERSION(3,0,0) - GtkWidget *tb = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); + auto tb = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); gtk_widget_set_name(tb, "ToolToolbox"); gtk_box_set_homogeneous(GTK_BOX(tb), FALSE); -#else - GtkWidget *tb = gtk_vbox_new(FALSE, 0); -#endif return toolboxNewCommon( tb, BAR_TOOL, GTK_POS_TOP ); } GtkWidget *ToolboxFactory::createAuxToolbox() { -#if GTK_CHECK_VERSION(3,0,0) - GtkWidget *tb = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); + auto tb = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); gtk_widget_set_name(tb, "AuxToolbox"); gtk_box_set_homogeneous(GTK_BOX(tb), FALSE); -#else - GtkWidget *tb = gtk_vbox_new(FALSE, 0); -#endif return toolboxNewCommon( tb, BAR_AUX, GTK_POS_LEFT ); } @@ -1046,38 +1039,26 @@ GtkWidget *ToolboxFactory::createAuxToolbox() GtkWidget *ToolboxFactory::createCommandsToolbox() { -#if GTK_CHECK_VERSION(3,0,0) - GtkWidget *tb = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); + auto tb = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); gtk_widget_set_name(tb, "CommandsToolbox"); gtk_box_set_homogeneous(GTK_BOX(tb), FALSE); -#else - GtkWidget *tb = gtk_vbox_new(FALSE, 0); -#endif return toolboxNewCommon( tb, BAR_COMMANDS, GTK_POS_LEFT ); } GtkWidget *ToolboxFactory::createSnapToolbox() { -#if GTK_CHECK_VERSION(3,0,0) - GtkWidget *tb = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); + auto tb = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); gtk_widget_set_name(tb, "SnapToolbox"); gtk_box_set_homogeneous(GTK_BOX(tb), FALSE); -#else - GtkWidget *tb = gtk_vbox_new(FALSE, 0); -#endif return toolboxNewCommon( tb, BAR_SNAP, GTK_POS_LEFT ); } static GtkWidget* createCustomSlider( GtkAdjustment *adjustment, gdouble climbRate, guint digits, Inkscape::UI::Widget::UnitTracker *unit_tracker) { -#if WITH_GTKMM_3_0 - Glib::RefPtr<Gtk::Adjustment> adj = Glib::wrap(adjustment, true); - Inkscape::UI::Widget::SpinButton *inkSpinner = new Inkscape::UI::Widget::SpinButton(adj, climbRate, digits); -#else - Inkscape::UI::Widget::SpinButton *inkSpinner = new Inkscape::UI::Widget::SpinButton(*Glib::wrap(adjustment, true), climbRate, digits); -#endif + auto adj = Glib::wrap(adjustment, true); + auto inkSpinner = new Inkscape::UI::Widget::SpinButton(adj, climbRate, digits); inkSpinner->addUnitTracker(unit_tracker); inkSpinner = Gtk::manage( inkSpinner ); GtkWidget *widget = GTK_WIDGET( inkSpinner->gobj() ); @@ -1439,17 +1420,10 @@ void setup_aux_toolbox(GtkWidget *toolbox, SPDesktop *desktop) if ( aux_toolboxes[i].prep_func ) { // converted to GtkActions and UIManager - GtkWidget* kludge = dataHolders[aux_toolboxes[i].type_name]; - -#if GTK_CHECK_VERSION(3,0,0) - GtkWidget* holder = gtk_grid_new(); + auto kludge = dataHolders[aux_toolboxes[i].type_name]; + auto holder = gtk_grid_new(); gtk_widget_set_name( holder, "ToolbarHolder" ); 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 ); g_free( tmp ); @@ -1461,30 +1435,20 @@ 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) ); swatch->setDesktop( desktop ); swatch->setClickVerb( aux_toolboxes[i].swatch_verb_id ); swatch->setWatchedTool( aux_toolboxes[i].swatch_tool, true ); - GtkWidget *swatch_ = GTK_WIDGET( swatch->gobj() ); - -#if GTK_CHECK_VERSION(3,0,0) + auto swatch_ = GTK_WIDGET( swatch->gobj() ); 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 } if(i==0){ gtk_widget_show_all( holder ); diff --git a/src/widgets/tweak-toolbar.cpp b/src/widgets/tweak-toolbar.cpp index a185ea956..a6b8ba436 100644 --- a/src/widgets/tweak-toolbar.cpp +++ b/src/widgets/tweak-toolbar.cpp @@ -25,7 +25,7 @@ */ #ifdef HAVE_CONFIG_H -# include "config.h" +#include "config.h" #endif #include "ui/widget/spinbutton.h" @@ -36,8 +36,8 @@ #include "widgets/ege-adjustment-action.h" #include "widgets/ege-output-action.h" #include "widgets/ege-select-one-action.h" -#include "widgets/ink-action.h" -#include "preferences.h" +#include "ink-radio-action.h" +#include "ink-toggle-action.h" #include "toolbox.h" #include "ui/icon-names.h" #include "ui/tools/tweak-tool.h" diff --git a/src/widgets/zoom-toolbar.cpp b/src/widgets/zoom-toolbar.cpp index 79feef86d..a961c0061 100644 --- a/src/widgets/zoom-toolbar.cpp +++ b/src/widgets/zoom-toolbar.cpp @@ -25,7 +25,7 @@ */ #ifdef HAVE_CONFIG_H -# include "config.h" +#include "config.h" #endif #include "zoom-toolbar.h" diff --git a/src/xml/Makefile_insert b/src/xml/Makefile_insert deleted file mode 100644 index da55d7f7e..000000000 --- a/src/xml/Makefile_insert +++ /dev/null @@ -1,51 +0,0 @@ -## Makefile.am fragment sourced by src/Makefile.am. - -ink_common_sources += \ - xml/comment-node.h \ - xml/composite-node-observer.cpp xml/composite-node-observer.h \ - xml/element-node.h \ - xml/helper-observer.cpp \ - xml/helper-observer.h \ - xml/node-observer.h \ - xml/quote.cpp \ - xml/quote.h \ - xml/repr-css.cpp \ - xml/log-builder.cpp \ - xml/log-builder.h \ - xml/node-fns.cpp \ - xml/node-fns.h \ - xml/pi-node.h \ - xml/rebase-hrefs.cpp \ - xml/rebase-hrefs.h \ - xml/repr-io.cpp \ - xml/repr-sorting.cpp \ - xml/repr-sorting.h \ - xml/repr-util.cpp \ - xml/repr.cpp \ - xml/repr.h \ - xml/simple-document.h \ - xml/simple-document.cpp \ - xml/simple-node.h \ - xml/simple-node.cpp \ - xml/node.h \ - xml/croco-node-iface.cpp \ - xml/croco-node-iface.h \ - xml/attribute-record.h \ - xml/sp-css-attr.h \ - xml/event.cpp xml/event.h xml/event-fns.h \ - xml/document.h \ - xml/node-event-vector.h \ - xml/node-iterators.h \ - xml/sp-css-attr.h \ - xml/subtree.cpp \ - xml/subtree.h \ - xml/text-node.h \ - xml/invalid-operation-exception.h - -# ###################### -# ### CxxTest stuff #### -# ###################### -CXXTEST_TESTSUITES += \ - $(srcdir)/xml/rebase-hrefs-test.h \ - $(srcdir)/xml/repr-action-test.h \ - $(srcdir)/xml/quote-test.h diff --git a/src/xml/node-fns.cpp b/src/xml/node-fns.cpp index eb3870978..e1506e3f2 100644 --- a/src/xml/node-fns.cpp +++ b/src/xml/node-fns.cpp @@ -1,5 +1,4 @@ #ifdef HAVE_CONFIG_H -# include "config.h" #endif #include <map> diff --git a/src/xml/rebase-hrefs.cpp b/src/xml/rebase-hrefs.cpp index a8ac3b4cc..7e3d4fa7e 100644 --- a/src/xml/rebase-hrefs.cpp +++ b/src/xml/rebase-hrefs.cpp @@ -4,10 +4,7 @@ #include "io/sys.h" #include "sp-object.h" #include "streq.h" -#include "util/share.h" -#include "xml/attribute-record.h" #include "xml/node.h" -#include <glib.h> #include <glibmm/miscutils.h> #include <glibmm/convert.h> #include <glibmm/uriutils.h> diff --git a/src/xml/repr-css.cpp b/src/xml/repr-css.cpp index c043904a7..9590fa97f 100644 --- a/src/xml/repr-css.cpp +++ b/src/xml/repr-css.cpp @@ -26,10 +26,8 @@ #include "xml/repr.h" #include "xml/simple-document.h" -#include "xml/simple-node.h" #include "xml/sp-css-attr.h" #include "style.h" -#include "libcroco/cr-sel-eng.h" using Inkscape::Util::List; using Inkscape::XML::AttributeRecord; diff --git a/src/xml/repr-io.cpp b/src/xml/repr-io.cpp index 6977bc1e2..5f576d00f 100644 --- a/src/xml/repr-io.cpp +++ b/src/xml/repr-io.cpp @@ -11,7 +11,7 @@ */ #ifdef HAVE_CONFIG_H -# include <config.h> +#include <config.h> #endif #include <cstring> @@ -39,7 +39,6 @@ #include "preferences.h" #include <glibmm/miscutils.h> -#include <map> using Inkscape::IO::Writer; using Inkscape::Util::List; diff --git a/src/xml/repr-util.cpp b/src/xml/repr-util.cpp index ce93bccab..4d093a4ea 100644 --- a/src/xml/repr-util.cpp +++ b/src/xml/repr-util.cpp @@ -17,8 +17,6 @@ #include "config.h" -#include <math.h> - #if HAVE_STRING_H # include <cstring> #endif diff --git a/src/xml/repr.cpp b/src/xml/repr.cpp index 0a384c9c1..8ad1ac06b 100644 --- a/src/xml/repr.cpp +++ b/src/xml/repr.cpp @@ -17,7 +17,7 @@ #define noREPR_VERBOSE #ifdef HAVE_CONFIG_H -# include "config.h" +#include <config.h> #endif #include <cstring> diff --git a/src/xml/simple-node.cpp b/src/xml/simple-node.cpp index 3cbedc80b..6bd47fd22 100644 --- a/src/xml/simple-node.cpp +++ b/src/xml/simple-node.cpp @@ -21,14 +21,11 @@ #include "preferences.h" -#include "xml/node.h" #include "xml/simple-node.h" #include "xml/node-event-vector.h" #include "xml/node-fns.h" -#include "xml/repr.h" #include "debug/event-tracker.h" #include "debug/simple-event.h" -#include "util/share.h" #include "util/format.h" #include "attribute-rel-util.h" |
