summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAlexander Valavanis <valavanisalex@gmail.com>2019-01-19 13:58:54 +0000
committerAlexander Valavanis <valavanisalex@gmail.com>2019-01-19 13:58:54 +0000
commit199c3dd0acac8c7a7cc835067e07ad6c4c069015 (patch)
treecf6f24a57943858136ffc41366de6502d28c9d65 /src
parentderive all toolbars from Inkscape::Toolbar (diff)
parentDisable app menu (deprecated in GTK 3.32). (diff)
downloadinkscape-199c3dd0acac8c7a7cc835067e07ad6c4c069015.tar.gz
inkscape-199c3dd0acac8c7a7cc835067e07ad6c4c069015.zip
Merge branch 'master' of gitlab.com:inkscape/inkscape
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt4
-rw-r--r--src/display/nr-filter-displacement-map.cpp5
-rw-r--r--src/extension/CMakeLists.txt2
-rw-r--r--src/extension/init.cpp14
-rw-r--r--src/extension/internal/cairo-png-out.cpp126
-rw-r--r--src/extension/internal/cairo-png-out.h55
-rw-r--r--src/extension/internal/cairo-ps-out.cpp3
-rw-r--r--src/extension/internal/cairo-ps-out.h4
-rw-r--r--src/extension/internal/cairo-renderer-pdf-out.cpp3
-rw-r--r--src/extension/internal/cairo-renderer-pdf-out.h4
-rw-r--r--src/inkscape-application.cpp7
-rw-r--r--src/inkscape-window.cpp14
-rw-r--r--src/libnrtype/Layout-TNG-OutIter.cpp14
-rw-r--r--src/libnrtype/Layout-TNG-Output.cpp10
-rw-r--r--src/libnrtype/Layout-TNG.h4
-rw-r--r--src/main-cmdlineact.cpp126
-rw-r--r--src/main-cmdlineact.h59
-rw-r--r--src/main-cmdlinexact.cpp593
-rw-r--r--src/main-cmdlinexact.h60
-rw-r--r--src/ui/dialog/aboutbox.cpp2
-rw-r--r--src/ui/dialog/attrdialog.cpp79
-rw-r--r--src/ui/dialog/objects.cpp9
-rw-r--r--src/ui/dialog/xml-tree.cpp6
23 files changed, 107 insertions, 1096 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index a2ed83c20..9d23fd1c3 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -48,8 +48,6 @@ set(inkscape_SRC
layer-model.cpp
line-geometry.cpp
line-snapper.cpp
- main-cmdlineact.cpp
- main-cmdlinexact.cpp
media.cpp
message-context.cpp
message-stack.cpp
@@ -153,8 +151,6 @@ set(inkscape_SRC
layer-model.h
line-geometry.h
line-snapper.h
- main-cmdlineact.h
- main-cmdlinexact.h
media.h
menus-skeleton.h
message-context.h
diff --git a/src/display/nr-filter-displacement-map.cpp b/src/display/nr-filter-displacement-map.cpp
index a72e60db5..9d83e5417 100644
--- a/src/display/nr-filter-displacement-map.cpp
+++ b/src/display/nr-filter-displacement-map.cpp
@@ -72,17 +72,12 @@ private:
void FilterDisplacementMap::render_cairo(FilterSlot &slot)
{
- std::cout << "FilterDisplacementMap:" << std::endl;
cairo_surface_t *texture = slot.getcairo(_input);
cairo_surface_t *map = slot.getcairo(_input2);
cairo_surface_t *out = ink_cairo_surface_create_identical(texture);
// color_interpolation_filters for out same as texture. See spec.
copy_cairo_surface_ci( texture, out );
- std::cout << " texture: " << cairo_image_surface_get_width(texture) << std::endl;
- std::cout << " map: " << cairo_image_surface_get_width(map) << std::endl;
- std::cout << " out: " << cairo_image_surface_get_width(out) << std::endl;
-
// We may need to transform map surface to correct color interpolation space. The map surface
// might be used as input to another primitive but it is likely that all the primitives in a given
// filter use the same color interpolation space so we don't copy the map before converting.
diff --git a/src/extension/CMakeLists.txt b/src/extension/CMakeLists.txt
index 8f0f1bcc4..e779f788a 100644
--- a/src/extension/CMakeLists.txt
+++ b/src/extension/CMakeLists.txt
@@ -33,7 +33,6 @@ set(extension_SRC
param/string.cpp
internal/bluredge.cpp
- internal/cairo-png-out.cpp
internal/cairo-ps-out.cpp
internal/cairo-render-context.cpp
internal/cairo-renderer.cpp
@@ -99,7 +98,6 @@ set(extension_SRC
implementation/xslt.h
internal/bluredge.h
- internal/cairo-png-out.h
internal/cairo-ps-out.h
internal/cairo-render-context.h
internal/cairo-renderer-pdf-out.h
diff --git a/src/extension/init.cpp b/src/extension/init.cpp
index 8e3c757f8..6626ff20d 100644
--- a/src/extension/init.cpp
+++ b/src/extension/init.cpp
@@ -36,9 +36,12 @@
# include "internal/emf-print.h"
# include "internal/wmf-inout.h"
# include "internal/wmf-print.h"
-#ifdef HAVE_CAIRO_PDF
+
+#include <cairo.h>
+#ifdef CAIRO_HAS_PDF_SURFACE
# include "internal/cairo-renderer-pdf-out.h"
-# include "internal/cairo-png-out.h"
+#endif
+#ifdef CAIRO_HAS_PS_SURFACE
# include "internal/cairo-ps-out.h"
#endif
#include "internal/pov-out.h"
@@ -152,11 +155,10 @@ init()
Internal::Svg::init();
Internal::Svgz::init();
-#ifdef HAVE_CAIRO_PDF
- //g_print ("Using CairoRendererPdfOutput: new pdf exporter\n");
+#ifdef CAIRO_HAS_PDF_SURFACE
Internal::CairoRendererPdfOutput::init();
- Internal::CairoRendererOutput::init();
-
+#endif
+#ifdef CAIRO_HAS_PS_SURFACE
Internal::CairoPsOutput::init();
Internal::CairoEpsOutput::init();
#endif
diff --git a/src/extension/internal/cairo-png-out.cpp b/src/extension/internal/cairo-png-out.cpp
deleted file mode 100644
index 446e593ca..000000000
--- a/src/extension/internal/cairo-png-out.cpp
+++ /dev/null
@@ -1,126 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-or-later
-/*
- * A quick hack to use the Cairo renderer to write out a file. This
- * then makes 'save as...' PNG.
- *
- * Authors:
- * Ted Gould <ted@gould.cx>
- * Ulf Erikson <ulferikson@users.sf.net>
- * Jon A. Cruz <jon@joncruz.org>
- * Abhishek Sharma
- *
- * Copyright (C) 2004-2006 Authors
- *
- * Released under GNU GPL v2+, read the file 'COPYING' for more information.
- */
-
-#ifdef HAVE_CONFIG_H
-# include "config.h" // only include where actually required!
-#endif
-
-#ifdef HAVE_CAIRO_PDF
-
-#include "cairo-png-out.h"
-#include "cairo-render-context.h"
-#include "cairo-renderer.h"
-#include <print.h>
-#include "extension/system.h"
-#include "extension/print.h"
-#include "extension/db.h"
-#include "extension/output.h"
-#include "display/drawing.h"
-
-#include "display/curve.h"
-#include "display/canvas-bpath.h"
-#include "object/sp-item.h"
-#include "object/sp-root.h"
-
-#include "io/sys.h"
-#include "document.h"
-
-namespace Inkscape {
-namespace Extension {
-namespace Internal {
-
-bool CairoRendererOutput::check(Inkscape::Extension::Extension * /*module*/)
-{
- return true;
-}
-
-static bool
-png_render_document_to_file(SPDocument *doc, gchar const *filename)
-{
- CairoRenderer *renderer;
- CairoRenderContext *ctx;
-
- doc->ensureUpToDate();
-
-/* Start */
-
- SPItem *base = doc->getRoot();
- Inkscape::Drawing drawing;
- unsigned dkey = SPItem::display_key_new(1);
- base->invoke_show(drawing, dkey, SP_ITEM_SHOW_DISPLAY);
-
- /* Create renderer and context */
- renderer = new CairoRenderer();
- ctx = renderer->createContext();
-
- /* Render document */
- bool ret = renderer->setupDocument(ctx, doc, TRUE, 0., nullptr);
- if (ret) {
- renderer->renderItem(ctx, base);
- ctx->saveAsPng(filename);
- ret = ctx->finish();
- }
- renderer->destroyContext(ctx);
-
- base->invoke_hide(dkey);
-/* end */
- delete renderer;
-
- return ret;
-}
-
-
-/**
- \brief This function calls the output module with the filename
- \param mod unused
- \param doc Document to be saved
- \param uri Filename to save to (probably will end in .png)
-*/
-void CairoRendererOutput::save(Inkscape::Extension::Output * /*mod*/, SPDocument *doc, gchar const *filename)
-{
- if (!png_render_document_to_file(doc, filename)) {
- throw Inkscape::Extension::Output::save_failed();
- }
-}
-
-/**
- \brief A function allocate a copy of this function.
-
- This is the definition of Cairo PNG out. This function just
- calls the extension system with the memory allocated XML that
- describes the data.
-*/
-void
-CairoRendererOutput::init ()
-{
- Inkscape::Extension::build_from_mem(
- "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
- "<name>Cairo PNG Output</name>\n"
- "<id>org.inkscape.output.png.cairo</id>\n"
- "<output>\n"
- "<extension>.png</extension>\n"
- "<mimetype>image/png</mimetype>\n"
- "<filetypename>Cairo PNG (*.png)</filetypename>\n"
- "<filetypetooltip>PNG File</filetypetooltip>\n"
- "</output>\n"
- "</inkscape-extension>", new CairoRendererOutput());
-
- return;
-}
-
-} } } /* namespace Inkscape, Extension, Implementation */
-
-#endif /* HAVE_CAIRO_PDF */
diff --git a/src/extension/internal/cairo-png-out.h b/src/extension/internal/cairo-png-out.h
deleted file mode 100644
index 12ebdae64..000000000
--- a/src/extension/internal/cairo-png-out.h
+++ /dev/null
@@ -1,55 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-or-later
-/*
- * A quick hack to use the print output to write out a file. This
- * then makes 'save as...' PNG.
- *
- * Authors:
- * Ted Gould <ted@gould.cx>
- * Ulf Erikson <ulferikson@users.sf.net>
- *
- * Copyright (C) 2004-2006 Authors
- *
- * Released under GNU GPL v2+, read the file 'COPYING' for more information.
- */
-
-#ifndef EXTENSION_INTERNAL_CAIRO_PNG_OUT_H
-#define EXTENSION_INTERNAL_CAIRO_PNG_OUT_H
-
-#ifdef HAVE_CONFIG_H
-# include "config.h" // only include where actually required!
-#endif
-
-#include "extension/implementation/implementation.h"
-
-#ifdef HAVE_CAIRO_PDF
-
-namespace Inkscape {
-namespace Extension {
-namespace Internal {
-
-class CairoRendererOutput : Inkscape::Extension::Implementation::Implementation {
-
-public:
- bool check(Inkscape::Extension::Extension *module) override;
- void save(Inkscape::Extension::Output *mod,
- SPDocument *doc,
- gchar const *filename) override;
- static void init();
-};
-
-} } } /* namespace Inkscape, Extension, Implementation */
-
-#endif /* HAVE_CAIRO_PDF */
-
-#endif /* !EXTENSION_INTERNAL_CAIRO_PNG_OUT_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/extension/internal/cairo-ps-out.cpp b/src/extension/internal/cairo-ps-out.cpp
index ed5be808c..baa1cf1b0 100644
--- a/src/extension/internal/cairo-ps-out.cpp
+++ b/src/extension/internal/cairo-ps-out.cpp
@@ -19,7 +19,8 @@
# include "config.h" // only include where actually required!
#endif
-#ifdef HAVE_CAIRO_PDF
+#include <cairo.h>
+#ifdef CAIRO_HAS_PS_SURFACE
#include "cairo-ps.h"
#include "cairo-ps-out.h"
diff --git a/src/extension/internal/cairo-ps-out.h b/src/extension/internal/cairo-ps-out.h
index b0e14e5a8..974f9668a 100644
--- a/src/extension/internal/cairo-ps-out.h
+++ b/src/extension/internal/cairo-ps-out.h
@@ -23,8 +23,6 @@
#include "extension/implementation/implementation.h"
-#ifdef HAVE_CAIRO_PDF
-
namespace Inkscape {
namespace Extension {
namespace Internal {
@@ -55,8 +53,6 @@ public:
} } } /* namespace Inkscape, Extension, Implementation */
-#endif /* HAVE_CAIRO_PDF */
-
#endif /* !EXTENSION_INTERNAL_CAIRO_PS_OUT_H */
/*
diff --git a/src/extension/internal/cairo-renderer-pdf-out.cpp b/src/extension/internal/cairo-renderer-pdf-out.cpp
index d2e96e31a..9ff3579ed 100644
--- a/src/extension/internal/cairo-renderer-pdf-out.cpp
+++ b/src/extension/internal/cairo-renderer-pdf-out.cpp
@@ -19,7 +19,8 @@
# include "config.h" // only include where actually required!
#endif
-#ifdef HAVE_CAIRO_PDF
+#include <cairo.h>
+#ifdef CAIRO_HAS_PDF_SURFACE
#include "cairo-renderer-pdf-out.h"
#include "cairo-render-context.h"
diff --git a/src/extension/internal/cairo-renderer-pdf-out.h b/src/extension/internal/cairo-renderer-pdf-out.h
index c69b86ef6..dfb2ad3a9 100644
--- a/src/extension/internal/cairo-renderer-pdf-out.h
+++ b/src/extension/internal/cairo-renderer-pdf-out.h
@@ -21,8 +21,6 @@
#include "extension/implementation/implementation.h"
-#ifdef HAVE_CAIRO_PDF
-
namespace Inkscape {
namespace Extension {
namespace Internal {
@@ -39,8 +37,6 @@ public:
} } } /* namespace Inkscape, Extension, Internal */
-#endif /* HAVE_CAIRO_PDF */
-
#endif /* !EXTENSION_INTERNAL_CAIRO_RENDERER_PDF_OUT_H */
/*
diff --git a/src/inkscape-application.cpp b/src/inkscape-application.cpp
index 54deedbbc..ec7ab7826 100644
--- a/src/inkscape-application.cpp
+++ b/src/inkscape-application.cpp
@@ -197,6 +197,8 @@ ConcreteInkscapeApplication<Gtk::Application>::on_startup2()
Inkscape::UI::Widget::Panel::prep();
// ========================= Builder ==========================
+ // App menus deprecated in 3.32. This whole block of code should be
+ // removed after confirming this code isn't required.
_builder = Gtk::Builder::create();
Glib::ustring app_builder_file = get_filename(UIS, "inkscape-application.xml");
@@ -215,7 +217,7 @@ ConcreteInkscapeApplication<Gtk::Application>::on_startup2()
if (!menu) {
std::cerr << "InkscapeApplication: failed to load application menu!" << std::endl;
} else {
- set_app_menu(menu);
+ // set_app_menu(menu);
}
}
@@ -340,9 +342,6 @@ ConcreteInkscapeApplication<Gtk::Application>::create_window(const Glib::RefPtr<
_active_document = desktop->getDocument();
// _documents.push_back(desktop->getDocument());
- // Add Gtk::Window to app window list.
- add_window(*desktop->getToplevel());
-
return (desktop); // Temp: Need to track desktop for shell mode.
}
diff --git a/src/inkscape-window.cpp b/src/inkscape-window.cpp
index 7227993cf..e6f488215 100644
--- a/src/inkscape-window.cpp
+++ b/src/inkscape-window.cpp
@@ -18,12 +18,26 @@
#include "inkscape-window.h"
#include "inkscape.h" // SP_ACTIVE_DESKTOP
#include "shortcuts.h"
+#include "inkscape-application.h"
#include "widgets/desktop-widget.h"
InkscapeWindow::InkscapeWindow(SPDocument* document)
: _document(document)
{
+ if (!_document) {
+ std::cerr << "InkscapeWindow::InkscapeWindow: null document!" << std::endl;
+ return;
+ }
+
+ Glib::RefPtr<Gio::Application> gio_app = Gio::Application::get_default();
+ Glib::RefPtr<Gtk::Application> app = Glib::RefPtr<Gtk::Application>::cast_dynamic(gio_app);
+ if (app) {
+ set_application(app); // Same as Gtk::Application::add_window()
+ } else {
+ std::cerr << "InkscapeWindow::InkscapeWindow:: Didn't get app!" << std::endl;
+ }
+
set_resizable(true);
// Callbacks
diff --git a/src/libnrtype/Layout-TNG-OutIter.cpp b/src/libnrtype/Layout-TNG-OutIter.cpp
index 77cedaa61..1c20ac30b 100644
--- a/src/libnrtype/Layout-TNG-OutIter.cpp
+++ b/src/libnrtype/Layout-TNG-OutIter.cpp
@@ -47,7 +47,10 @@ Layout::iterator Layout::_cursorXOnLineToIterator(unsigned line_index, double lo
best_x_difference = this_x_difference;
}
}
- if (best_char_index == -1) return iterator(this, char_index);
+ if (best_char_index == -1)
+ best_char_index = char_index;
+ if (best_char_index == _characters.size())
+ return end();
return iterator(this, best_char_index);
}
@@ -183,6 +186,8 @@ Layout::iterator Layout::sourceToIterator(void *source_cookie /*, Glib::ustring:
if (_input_stream[source_index]->Type() != TEXT_SOURCE)
return iterator(this, char_index);
+ if (char_index >= _characters.size())
+ return end();
return iterator(this, char_index);
/* This code was never used, the text_iterator argument was "NULL" in all calling code
InputStreamTextSource const *text_source = static_cast<InputStreamTextSource const *>(_input_stream[source_index]);
@@ -498,7 +503,7 @@ void Layout::queryCursorShape(iterator const &it, Geom::Point &position, double
if (it._glyph_index == -1) {
rotation = 0.0;
} else if(it._glyph_index == 0) {
- rotation = _glyphs[0].rotation;
+ rotation = _glyphs.empty() ? 0.0 : _glyphs[0].rotation;
} else{
rotation = _glyphs[it._glyph_index - 1].rotation;
}
@@ -784,7 +789,10 @@ bool Layout::iterator::nextLineCursor(int n)
- _parent_layout->_chunks[_parent_layout->_spans[_parent_layout->_lineToSpan(line_index)].in_chunk].left_x;
}
_char_index = _parent_layout->_cursorXOnLineToIterator(line_index + n, _x_coordinate)._char_index;
- _glyph_index = _parent_layout->_characters[_char_index].in_glyph;
+ if (_char_index == _parent_layout->_characters.size())
+ _glyph_index = _parent_layout->_glyphs.size();
+ else
+ _glyph_index = _parent_layout->_characters[_char_index].in_glyph;
return true;
}
diff --git a/src/libnrtype/Layout-TNG-Output.cpp b/src/libnrtype/Layout-TNG-Output.cpp
index 6ff52f2a7..2a7c835f3 100644
--- a/src/libnrtype/Layout-TNG-Output.cpp
+++ b/src/libnrtype/Layout-TNG-Output.cpp
@@ -29,14 +29,6 @@
#include <3rdparty/libuemf/symbol_convert.h>
-namespace Inkscape {
- namespace Extension {
- namespace Internal {
- class CairoRenderContext;
- }
- }
-}
-
using Inkscape::Extension::Internal::CairoRenderContext;
using Inkscape::Extension::Internal::CairoGlyphInfo;
@@ -424,7 +416,6 @@ std:: cout << "DEBUG Layout::print in while --- "
}
-#ifdef HAVE_CAIRO_PDF
void Layout::showGlyphs(CairoRenderContext *ctx) const
{
if (_input_stream.empty()) return;
@@ -519,7 +510,6 @@ void Layout::showGlyphs(CairoRenderContext *ctx) const
}
}
}
-#endif
#if DEBUG_TEXTLAYOUT_DUMPASTEXT
// these functions are for dumpAsText() only. No need to translate
diff --git a/src/libnrtype/Layout-TNG.h b/src/libnrtype/Layout-TNG.h
index e5317b501..c09fc27ca 100644
--- a/src/libnrtype/Layout-TNG.h
+++ b/src/libnrtype/Layout-TNG.h
@@ -28,7 +28,6 @@
#include <svg/svg-length.h>
#include "style-enums.h"
-#ifdef HAVE_CAIRO_PDF
namespace Inkscape {
namespace Extension {
namespace Internal {
@@ -38,7 +37,6 @@ namespace Inkscape {
}
using Inkscape::Extension::Internal::CairoRenderContext;
-#endif
class SPStyle;
class Shape;
@@ -403,12 +401,10 @@ public:
*/
void print(SPPrintContext *ctx, Geom::OptRect const &pbox, Geom::OptRect const &dbox, Geom::OptRect const &bbox, Geom::Affine const &ctm) const;
-#ifdef HAVE_CAIRO_PDF
/** Renders all the glyphs to the given Cairo rendering context.
\param ctx The Cairo rendering context to be used
*/
void showGlyphs(CairoRenderContext *ctx) const;
-#endif
/** Returns the font family of the indexed span */
Glib::ustring getFontFamily(unsigned span_index) const;
diff --git a/src/main-cmdlineact.cpp b/src/main-cmdlineact.cpp
deleted file mode 100644
index dbe855536..000000000
--- a/src/main-cmdlineact.cpp
+++ /dev/null
@@ -1,126 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-or-later
-/*
- * Authors:
- * Ted Gould <ted@gould.cx>
- *
- * Copyright (C) 2007 Authors
- *
- * Released under GNU GPL v2+, read the file 'COPYING' for more information.
- */
-
-#include <list>
-
-#include "main-cmdlineact.h"
-
-#include "desktop.h"
-#include "document.h"
-#include "file.h"
-#include "inkscape.h"
-#include "selection.h"
-#include "verbs.h"
-
-#include "helper/action.h"
-
-#include "ui/view/view.h"
-
-#include <glibmm/i18n.h>
-
-namespace Inkscape {
-
-std::list <CmdLineAction *> CmdLineAction::_list;
-
-CmdLineAction::CmdLineAction (bool isVerb, gchar const * arg) : _isVerb(isVerb), _arg(nullptr) {
- if (arg != nullptr) {
- _arg = g_strdup(arg);
- }
-
- _list.insert(_list.end(), this);
-
- return;
-}
-
-CmdLineAction::~CmdLineAction () {
- if (_arg != nullptr) {
- g_free(_arg);
- }
-}
-
-bool
-CmdLineAction::isExtended() {
- return false;
-}
-
-void
-CmdLineAction::doItX (ActionContext const & context)
-{
- (void)context;
- printf("CmdLineAction::doItX() %s\n", _arg);
-}
-
-void
-CmdLineAction::doIt (ActionContext const & context) {
- //printf("Doing: %s\n", _arg);
- if (_isVerb) {
- if (isExtended()) {
- doItX(context);
- return;
- }
-
- Inkscape::Verb * verb = Inkscape::Verb::getbyid(_arg);
- if (verb == nullptr) {
- 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, nullptr);
- } else {
- if (context.getDocument() == nullptr || context.getSelection() == nullptr) { return; }
-
- SPDocument * doc = context.getDocument();
- SPObject * obj = doc->getObjectById(_arg);
- if (obj == nullptr) {
- 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 (auto entry : _list) {
- entry->doIt(context);
- }
- return hasActions;
-}
-
-bool
-CmdLineAction::idle () {
- 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 (auto desktop : desktops) {
- //Inkscape::UI::View::View * view = dynamic_cast<Inkscape::UI::View::View *>(desktop);
- doList(ActionContext(desktop));
- }
- return false;
-}
-
-} // 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 :
diff --git a/src/main-cmdlineact.h b/src/main-cmdlineact.h
deleted file mode 100644
index d880e5220..000000000
--- a/src/main-cmdlineact.h
+++ /dev/null
@@ -1,59 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-or-later
-
-#ifndef __INK_MAIN_CMD_LINE_ACTIONS_H__
-#define __INK_MAIN_CMD_LINE_ACTIONS_H__
-
-/** \file
- * Small actions that can be queued at the command line
- */
-
-/*
- * Authors:
- * Ted Gould <ted@gould.cx>
- *
- * Copyright (C) 2007 Authors
- *
- * Released under GNU GPL v2+, read the file 'COPYING' for more information.
- */
-
-namespace Inkscape {
-
-class ActionContext;
-
-class CmdLineAction {
- bool _isVerb;
- static std::list <CmdLineAction *> _list;
- static bool _requestQuit;
-
-protected:
- char * _arg;
-
-public:
- CmdLineAction (bool isVerb, char const * arg);
- virtual ~CmdLineAction ();
- virtual bool isExtended();
- virtual void doItX (ActionContext const & context);
-
- void doIt (ActionContext const & context);
-
- /** Return true if any actions were performed */
- static bool doList (ActionContext const & context);
- static bool idle ();
-};
-
-} // Inkscape
-
-
-
-#endif /* __INK_MAIN_CMD_LINE_ACTIONS_H__ */
-
-/*
- Local Variables:
- mode:c++
- c-file-style:"stroustrup"
- c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
- indent-tabs-mode:nil
- fill-column:99
- End:
-*/
-// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
diff --git a/src/main-cmdlinexact.cpp b/src/main-cmdlinexact.cpp
deleted file mode 100644
index b06f584f4..000000000
--- a/src/main-cmdlinexact.cpp
+++ /dev/null
@@ -1,593 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-or-later
-/** @file
- * Extended actions ("xverbs") that can be queued in a yaml file
- *//*
- * Authors:
- * Dmitry Zhulanov <dmitry.zhulanov@gmail.com>
- *
- * Copyright (C) 2016 Authors
- *
- * Released under GNU GPL v2+, read the file 'COPYING' for more information.
- *
- * more details: http://wiki.inkscape.org/wiki/index.php/Using_xverbs
- */
-
-#ifdef HAVE_CONFIG_H
-# include "config.h" // only include where actually required!
-#endif
-
-#ifdef WITH_YAML
-
-#include <list>
-#include <map>
-
-#include <glib.h>
-#include <glib/gstdio.h>
-#include <glibmm/i18n.h>
-
-#include "main-cmdlinexact.h"
-
-#include "desktop.h"
-#include "document-undo.h"
-#include "document-undo.h"
-#include "document.h"
-#include "file.h"
-#include "inkscape.h"
-#include "preferences.h"
-#include "selection.h"
-#include "verbs.h"
-#include "yaml.h"
-
-#include "extension/db.h"
-#include "extension/system.h"
-
-#include "helper/action-context.h"
-#include "helper/action.h"
-#include "helper/png-write.h"
-
-#include "io/resource-manager.h"
-#include "io/sys.h"
-
-#include "object/sp-namedview.h"
-#include "object/sp-root.h"
-
-#include "ui/dialog/font-substitution.h"
-#include "ui/interface.h"
-#include "ui/view/view-widget.h"
-#include "ui/view/view.h"
-
-#include "util/units.h"
-
-#define DPI_BASE Inkscape::Util::Quantity::convert(1, "in", "px")
-
-namespace
-{
-bool s_verbose = false;
-Glib::ustring s_yaml_filename("");
-
-bool createDirForFilename( const std::string &filename )
-{
- size_t found = filename.find_last_of("/\\");
- std::string output_directory = filename.substr(0,found);
-
- if( output_directory == filename )
- return true;
-
- if (g_mkdir_with_parents(output_directory.c_str(), 0755)) {
- printf("Can't create directory %s\n", output_directory.c_str());
- fflush(stdout);
-
- return false;
- }
-
- return true;
-}
-
-std::vector<std::string> vectorFromString(const std::string &csv)
-{
- std::vector<std::string> result;
-
- std::string delimiters = ",";
-
- // Skip delimiters at beginning.
- std::string::size_type lastPos = csv.find_first_not_of(delimiters, 0);
-
- // Find first non-delimiter.
- std::string::size_type pos = csv.find_first_of(delimiters, lastPos);
-
- while (std::string::npos != pos || std::string::npos != lastPos) {
- // Found a token, add it to the vector.
- std::string token = csv.substr(lastPos, pos - lastPos);
- token.erase(0, token.find_first_not_of(' ')); //prefixing spaces
- token.erase(token.find_last_not_of(' ')+1); //surfixing spaces
- result.push_back(token);
-
- // Skip delimiters.
- lastPos = csv.find_first_not_of(delimiters, pos);
-
- // Find next non-delimiter.
- pos = csv.find_first_of(delimiters, lastPos);
- }
-
- return result;
-}
-
-Glib::ustring getDocumentPathRelatedYaml( const Glib::ustring &uri )
-{
- if (g_path_is_absolute (uri.c_str()))
- return uri;
-
- gchar *yaml_dirname = g_path_get_dirname(s_yaml_filename.c_str());
- gchar *document_path = g_build_filename(yaml_dirname, uri.c_str(), NULL);
-
- Glib::ustring result(document_path);
-
- g_free(document_path);
- g_free(yaml_dirname);
-
- return result;
-}
-
-void xFileOpen( const Glib::ustring &uri )
-{
- Glib::ustring document_filename = getDocumentPathRelatedYaml(uri);
-
- if (!Inkscape::IO::file_test(document_filename.c_str(), (GFileTest)(G_FILE_TEST_EXISTS))) {
- printf("SVG document does not exist: %s\n", document_filename.c_str());
- exit(1);
- }
-
- if (s_verbose) {
- printf("open %s\n", document_filename.c_str());
- fflush(stdout);
- }
-
- SPDesktop *desktop = SP_ACTIVE_DESKTOP;
- if (desktop) {
- SPDocument *old_document = desktop->getDocument();
- desktop->setWaitingCursor();
- Inkscape::DocumentUndo::clearRedo(old_document);
- Inkscape::DocumentUndo::clearUndo(old_document);
- }
-
- SPDocument *doc = nullptr;
- Inkscape::Extension::Extension *key = nullptr;
- try {
- doc = Inkscape::Extension::open(key, document_filename.c_str());
- } catch (std::exception &e) {
- doc = nullptr;
- std::string exeption_mgs = e.what();
- printf("Error: open %s:%s\n",document_filename.c_str(), exeption_mgs.c_str() );
- fflush(stdout);
- }
-
- // Set viewBox if it doesn't exist
- if (!doc->getRoot()->viewBox_set
- && (doc->getRoot()->width.unit != SVGLength::PERCENT)
- && (doc->getRoot()->height.unit != SVGLength::PERCENT)) {
- doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().value(doc->getDisplayUnit()), doc->getHeight().value(doc->getDisplayUnit())));
- }
-
- desktop->change_document(doc);
- doc->emitResizedSignal(doc->getWidth().value("px"), doc->getHeight().value("px"));
- if(desktop)
- desktop->clearWaitingCursor();
-
- doc->virgin = FALSE;
-
- // everyone who cares now has a reference, get rid of our`s
- doc->doUnref();
-
- // resize the window to match the document properties
- sp_namedview_window_from_document(desktop);
- sp_namedview_update_layers_from_document(desktop);
-
- if ( INKSCAPE.use_gui() ) {
- // Perform a fixup pass for hrefs.
- if ( Inkscape::ResourceManager::getManager().fixupBrokenLinks(doc) ) {
- Glib::ustring msg = _("Broken links have been changed to point to existing files.");
- desktop->showInfoDialog(msg);
- }
-
- // Check for font substitutions
- Inkscape::UI::Dialog::FontSubstitution::getInstance().checkFontSubstitutions(doc);
- }
-}
-
-void xFileSaveAs( Inkscape::ActionContext const & context, const Glib::ustring &uri )
-{
- Glib::ustring document_filename = getDocumentPathRelatedYaml(uri);
- SPDocument *doc = context.getDocument();
- if (s_verbose) {
- printf("save as %s\n", document_filename.c_str());
- fflush(stdout);
- }
-
- if( createDirForFilename( document_filename )) {
- Inkscape::Extension::save(
- Inkscape::Extension::db.get("org.inkscape.output.svg.inkscape"),
- doc, document_filename.c_str(), false, false, true, Inkscape::Extension::FILE_SAVE_METHOD_SAVE_AS);
- if (s_verbose) {
- printf("save done: %s\n", document_filename.c_str() );
- fflush(stdout);
- }
- }
- else {
- printf("can't create dirs for filename %s\n", document_filename.c_str() );
- fflush(stdout);
- }
-}
-
-void xFileExportPNG( Inkscape::ActionContext const & context, const Glib::ustring &uri )
-{
- Glib::ustring document_filename = getDocumentPathRelatedYaml(uri);
- if (s_verbose) {
- printf("export png %s\n", document_filename.c_str());
- fflush(stdout);
- }
-
- SPDocument *doc = context.getDocument();
-
- gdouble dpi = 200.0;
- SPDesktop *desktop = SP_ACTIVE_DESKTOP;
-
- Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- dpi = prefs->getDouble("/dialogs/export/defaultxdpi/value", DPI_BASE);
-
- gdouble width = doc->getWidth().value(doc->getDisplayUnit());
- gdouble height = doc->getHeight().value(doc->getDisplayUnit());
-
- gdouble bmwidth = (width) * dpi / DPI_BASE;
- gdouble bmheight = (height) * dpi / DPI_BASE;
-
- int png_width = (int)(0.5 + bmwidth);
- int png_height = (int)(0.5 + bmheight);
-
- SPNamedView *nv = desktop->getNamedView();
-
- ExportResult status = sp_export_png_file(doc, document_filename.c_str(),
- Geom::Rect(Geom::Point(0,0), Geom::Point(width, height)), png_width, png_height, dpi, dpi,
- nv->pagecolor, nullptr, nullptr, TRUE);
-}
-
-void xSelectElement( Inkscape::ActionContext const & context, const Glib::ustring &element_name )
-{
- if (context.getDocument() == nullptr || context.getSelection() == nullptr) {
- return;
- }
-
- if (s_verbose) {
- printf("select element: %s\n", element_name.c_str());
- fflush(stdout);
- }
-
- SPDocument * doc = context.getDocument();
- SPObject * obj = doc->getObjectById(element_name);
-
- if (obj == nullptr) {
- printf(_("Unable to find node ID: '%s'\n"), element_name.c_str());
- fflush(stdout);
- return;
- }
-
- Inkscape::Selection * selection = context.getSelection();
- selection->add(obj);
-
- if (s_verbose) {
- printf("select done %s\n", element_name.c_str());
- fflush(stdout);
- }
-}
-
-} // end of unnamed namespace
-
-namespace Inkscape {
-
-CmdLineXAction::CmdLineXAction (gchar const * arg, xaction_args_values_map_t &values_map):
- CmdLineAction(true, arg), _values_map(values_map) {
- this->arg = (char *)arg;
- return;
-}
-
-bool
-CmdLineXAction::isExtended() {
- return true;
-}
-
-void
-CmdLineXAction::doItX (ActionContext const & context) {
- (void)(context);
-
- if( arg == "XFileSaveAs")
- xFileSaveAs( context, _values_map["filename"] );
- else if (arg == "XFileOpen")
- xFileOpen( _values_map["filename"] );
- else if (arg == "XFileExportPNG")
- xFileExportPNG( context, _values_map["png_filename"] );
- else if (arg == "XSelectElement")
- xSelectElement( context, _values_map["element-id"] );
- else {
- printf("unknown xverb: %s", arg.c_str());
- fflush(stdout);
- }
-
- return;
-}
-
-enum parser_state_t { HANDLING_ROOT,
- HANDLING_VERBOSE, // options
- HANDLING_RUN, HANDLING_RUN_LIST, HANDLING_RUN_LIST_ENTRY
- }; // run entries
-
-struct verb_info_t
-{
- bool xverb;
- std::vector<std::string> args;
-};
-
-typedef std::list<verb_info_t> verbs_list_t;
-
-static verbs_list_t
-parseVerbsYAMLFile(gchar const *yaml_filename)
-{
- verbs_list_t verbs_list;
-
- FILE *fh = g_fopen(yaml_filename, "r");
- if(fh == nullptr) {
- printf("Failed to read from file %s\n", yaml_filename);
- fflush(stdout);
-
- // exit with error
- exit(1);
- }
-
- yaml_parser_t parser;
- if(!yaml_parser_initialize(&parser)) {
- printf("Failed to initialize parser!\n");
- fflush(stdout);
- return verbs_list;
- }
-
- /* Set input file */
- yaml_parser_set_input_file(&parser, fh);
-
- parser_state_t state = HANDLING_ROOT;
-
- bool handling_key = false;
- bool handling_value = false;
-
- std::string key;
-
- // parse
- yaml_token_t token;
- do {
- yaml_parser_scan(&parser, &token);
- switch(token.type)
- {
- // avoid "warning: enumeration value", "-Wswitch"
- case YAML_NO_TOKEN:
- break;
- case YAML_STREAM_START_TOKEN:
- break;
- case YAML_STREAM_END_TOKEN:
- break;
- case YAML_VERSION_DIRECTIVE_TOKEN:
- break;
- case YAML_TAG_DIRECTIVE_TOKEN:
- break;
- case YAML_DOCUMENT_START_TOKEN:
- break;
- case YAML_DOCUMENT_END_TOKEN:
- break;
- case YAML_FLOW_SEQUENCE_START_TOKEN:
- break;
- case YAML_FLOW_SEQUENCE_END_TOKEN:
- break;
- case YAML_FLOW_MAPPING_START_TOKEN:
- break;
- case YAML_FLOW_MAPPING_END_TOKEN:
- break;
- case YAML_FLOW_ENTRY_TOKEN:
- break;
- case YAML_ALIAS_TOKEN:
- break;
- case YAML_ANCHOR_TOKEN:
- break;
- case YAML_TAG_TOKEN:
- break;
-
- /* Token types (read before actual token) */
- case YAML_KEY_TOKEN:
- handling_key = true;
- handling_value = false;
- break;
- case YAML_VALUE_TOKEN:
- handling_key = false;
- handling_value = true;
- break;
-
- /* Block delimiters */
- case YAML_BLOCK_SEQUENCE_START_TOKEN:
- if( state == HANDLING_ROOT ) {
- if( key == "run" )
- state = HANDLING_RUN;
- }
- break;
- case YAML_BLOCK_ENTRY_TOKEN:
- if( state == HANDLING_RUN )
- state = HANDLING_RUN_LIST;
- else if( state == HANDLING_RUN_LIST )
- state = HANDLING_RUN_LIST_ENTRY;
- else if( state == HANDLING_VERBOSE )
- state = HANDLING_ROOT;
- break;
- case YAML_BLOCK_END_TOKEN:
- if( state == HANDLING_RUN_LIST_ENTRY )
- state = HANDLING_RUN_LIST;
- else if( state == HANDLING_RUN_LIST )
- state = HANDLING_RUN;
- else if( state == HANDLING_VERBOSE )
- state = HANDLING_ROOT;
- else if( state == HANDLING_RUN )
- state = HANDLING_ROOT;
- break;
-
- /* Data */
- case YAML_BLOCK_MAPPING_START_TOKEN:
- break;
- case YAML_SCALAR_TOKEN:
- if( handling_key )
- key = (char *)token.data.scalar.value;
- else if ( handling_value ) {
- if(state == HANDLING_RUN_LIST) {
- if(key == "xverb-id") {
- verb_info_t verb;
- verb.xverb = true;
- verb.args = vectorFromString((char *)token.data.scalar.value);
- if ((verb.args.size() > 1) && Verb::getbyid((char *)token.data.scalar.value, false))
- verb.xverb = false;
- verbs_list.push_back(verb);
- }
- else if(key == "verb-id") {
- verb_info_t verb;
- verb.xverb = false;
- verb.args = vectorFromString((char *)token.data.scalar.value);
- verbs_list.push_back(verb);
- }
- else {
- printf("unknown verb type [%s]\n", key.c_str());
- fflush(stdout);
- }
- }
- else if(state == HANDLING_ROOT) {
- std::string value = (char *)token.data.scalar.value;
- if( (key == "verbose") && (value == "yes") )
- s_verbose = true;
- }
- }
- break;
- }
- } while(token.type != YAML_STREAM_END_TOKEN);
-
- /* Cleanup */
- yaml_token_delete(&token);
- yaml_parser_delete(&parser);
- fclose(fh);
-
- return verbs_list;
-}
-
-void
-CmdLineXAction::createActionsFromYAML( gchar const *yaml_filename )
-{
- s_yaml_filename = Glib::ustring(yaml_filename);
-
- verbs_list_t verbs_list = parseVerbsYAMLFile(yaml_filename);
-
- typedef std::map<std::string,int> undo_labels_map_t;
- undo_labels_map_t undo_labels_map;
- int undo_counter = 0;
-
- verbs_list_t::iterator iter = verbs_list.begin();
- for (; iter != verbs_list.end(); ++iter) {
- verb_info_t &verb = *iter;
- std::string &verb_word = verb.args[0];
- if (s_verbose)
- printf("handle %s and args count is %d\n", verb_word.c_str(), (int)verb.args.size());
-
- if (verb_word == "XFileOpen") {
- if( verb.args.size() < 2 )
- {
- printf("bad arguments for XFileOpen\n");
- continue;
- }
-
- xaction_args_values_map_t values_map;
- values_map["filename"] = verb.args[1];
- new CmdLineXAction(verb_word.c_str(), values_map);
- } else if (verb_word == "XFileSaveAs")
- {
- if (verb.args.size() < 2) {
- printf("bad arguments for XFileSaveAs\n");
- continue;
- }
-
- xaction_args_values_map_t values_map;
- values_map["filename"] = verb.args[1];
- new CmdLineXAction(verb_word.c_str(), values_map);
- } else if (verb_word == "XUndoLabel") {
- if (verb.args.size() < 2) {
- printf("bad arguments for XUndoLabel\n");
- continue;
- }
- undo_labels_map[verb.args[1]] = undo_counter;
- } else if (verb_word == "XUndoToLabel") {
- if (verb.args.size() < 2) {
- printf("bad arguments for XUndoToLabel\n");
- continue;
- }
-
- undo_labels_map_t::iterator iter = undo_labels_map.find(verb.args[1]);
- if(iter != undo_labels_map.end()) {
- int counter = undo_counter - iter->second;
- if( counter > 0 ) {
- for(int i = 0; i < counter; ++i)
- new CmdLineAction(true, "EditUndo");
- undo_counter -= counter;
- }
- }
- } else if (verb_word == "XSelectElement") {
- if (verb.args.size() < 2) {
- printf("bad arguments for XSelectElement\n");
- continue;
- }
- ++undo_counter;
-
- xaction_args_values_map_t values_map;
- values_map["element-id"] = verb.args[1];
- new CmdLineXAction(verb_word.c_str(), values_map);
- } else if (verb_word == "XFileExportPNG") {
- if (verb.args.size() < 2) {
- printf("bad arguments for XFileExportPNG\n");
- continue;
- }
-
- xaction_args_values_map_t values_map;
- std::string &png_filename = verb.args[1];
- values_map["png_filename"] = png_filename;
- if(createDirForFilename( png_filename ))
- new CmdLineXAction(verb_word.c_str(), values_map);
- }
- else if(!verb.xverb) {
- ++undo_counter;
- new CmdLineAction(true, verb.args[0].c_str());
- }
- else if( Verb::getbyid(verb.args[0].c_str()) != nullptr )
- {
- ++undo_counter;
- new CmdLineAction(true, verb.args[0].c_str());
- }
- else {
- printf("Unhadled xverb %s\n", verb.args[0].c_str());
- fflush(stdout);
- }
- }
-
- fflush(stdout);
-}
-
-
-} // Inkscape
-
-#endif // WITH_YAML
-
-/*
- 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/main-cmdlinexact.h b/src/main-cmdlinexact.h
deleted file mode 100644
index 13ebcb783..000000000
--- a/src/main-cmdlinexact.h
+++ /dev/null
@@ -1,60 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-or-later
-#ifndef __INK_MAIN_CMD_LINE_XACTIONS_H__
-#define __INK_MAIN_CMD_LINE_XACTIONS_H__
-
-#ifdef HAVE_CONFIG_H
-# include "config.h" // only include where actually required!
-#endif
-
-#ifdef WITH_YAML
-
-/** \file
- * Extended actions that can be queued at the yaml file
- */
-
-/*
- * Authors:
- * Dmitry Zhulanov <dmitry.zhulanov@gmail.com>
- *
- * Copyright (C) 2016 Authors
- *
- * Released under GNU GPL v2+, read the file 'COPYING' for more information.
- *
- * more details: http://wiki.inkscape.org/wiki/index.php/Using_xverbs
- */
-
-#include "main-cmdlineact.h"
-#include <string>
-
-namespace Inkscape {
-
-typedef std::map<std::string, std::string > xaction_args_values_map_t;
-
-class CmdLineXAction : public CmdLineAction {
- std::string arg;
- xaction_args_values_map_t _values_map;
-public:
- CmdLineXAction (gchar const * arg, xaction_args_values_map_t &values_map);
-
- void doItX (ActionContext const & context) override;
- bool isExtended() override;
-
- static void createActionsFromYAML( gchar const *filename );
-};
-
-} // Inkscape
-
-
-#endif // WITH_YAML
-#endif /* __INK_MAIN_CMD_LINE_XACTIONS_H__ */
-
-/*
- Local Variables:
- mode:c++
- c-file-style:"stroustrup"
- c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
- indent-tabs-mode:nil
- fill-column:99
- End:
-*/
-// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
diff --git a/src/ui/dialog/aboutbox.cpp b/src/ui/dialog/aboutbox.cpp
index d79a14861..3db65411a 100644
--- a/src/ui/dialog/aboutbox.cpp
+++ b/src/ui/dialog/aboutbox.cpp
@@ -133,8 +133,6 @@ void AboutBox::build_splash_widget() {
double height=doc->getHeight().value("px") / 2.0;
viewer->setResize(width, height);
- doc->doUnref();
-
_splash_widget = new Gtk::AspectFrame();
_splash_widget->unset_label();
_splash_widget->set_shadow_type(Gtk::SHADOW_NONE);
diff --git a/src/ui/dialog/attrdialog.cpp b/src/ui/dialog/attrdialog.cpp
index 21e92f600..4ccb037ef 100644
--- a/src/ui/dialog/attrdialog.cpp
+++ b/src/ui/dialog/attrdialog.cpp
@@ -36,11 +36,20 @@ static void on_attr_changed (Inkscape::XML::Node * repr,
{
ATTR_DIALOG(data)->onAttrChanged(repr, name, new_value);
}
+
+static void on_content_changed (Inkscape::XML::Node * repr,
+ gchar const * oldcontent,
+ gchar const * newcontent,
+ gpointer data)
+{
+ ATTR_DIALOG(data)->onAttrChanged(repr, "content", repr->content());
+}
+
Inkscape::XML::NodeEventVector _repr_events = {
nullptr, /* child_added */
nullptr, /* child_removed */
on_attr_changed,
- nullptr, /* content_changed */
+ on_content_changed, /* content_changed */
nullptr /* order_changed */
};
@@ -127,7 +136,6 @@ AttrDialog::AttrDialog():
setDesktop(getDesktop());
}
-
/**
* @brief AttrDialog::~AttrDialog
* Class destructor
@@ -226,10 +234,16 @@ void AttrDialog::onAttrChanged(Inkscape::XML::Node *repr, const gchar * name, co
}
}
}
- if(new_value) {
- Gtk::TreeModel::Row row = *(_store->append());
- row[_attrColumns._attributeName] = name;
- row[_attrColumns._attributeValue] = new_value;
+ if (new_value) {
+ if ((repr->type() == Inkscape::XML::TEXT_NODE || repr->type() == Inkscape::XML::COMMENT_NODE) &&
+ name != "content")
+ {
+ return;
+ } else {
+ Gtk::TreeModel::Row row = *(_store->append());
+ row[_attrColumns._attributeName] = name;
+ row[_attrColumns._attributeValue] = new_value;
+ }
}
}
@@ -260,8 +274,13 @@ void AttrDialog::onAttrDelete(Glib::ustring path)
Gtk::TreeModel::Row row = *_store->get_iter(path);
if (row) {
Glib::ustring name = row[_attrColumns._attributeName];
- this->_repr->setAttribute(name.c_str(), nullptr, false);
- this->setUndo(_("Delete attribute"));
+ if (name == "content") {
+ return;
+ } else {
+ this->_store->erase(row);
+ this->_repr->setAttribute(name.c_str(), nullptr, false);
+ this->setUndo(_("Delete attribute"));
+ }
}
}
@@ -283,8 +302,13 @@ bool AttrDialog::onKeyPressed(GdkEventKey *event)
{
// Create new attribute (repeat code, fold into above event!)
Glib::ustring name = row[_attrColumns._attributeName];
- this->_repr->setAttribute(name.c_str(), nullptr, false);
- this->setUndo(_("Delete attribute"));
+ if(name == "content") {
+ return true;
+ } else {
+ this->_store->erase(row);
+ this->_repr->setAttribute(name.c_str(), nullptr, false);
+ this->setUndo(_("Delete attribute"));
+ }
return true;
}
case GDK_KEY_plus:
@@ -314,21 +338,22 @@ void AttrDialog::nameEdited (const Glib::ustring& path, const Glib::ustring& nam
Gtk::TreeModel::Row row = *_store->get_iter(path);
if(row && this->_repr) {
Glib::ustring old_name = row[_attrColumns._attributeName];
+ if (old_name == "content" ||
+ old_name == name)
+ {
+ return;
+ }
Glib::ustring value = row[_attrColumns._attributeValue];
- if(!old_name.empty()) {
- // Remove named value
- _repr->setAttribute(old_name, nullptr, false);
- _repr->setAttribute(name, value, false);
- this->setUndo(_("Rename attribute"));
- } else {
- // Move to editing value, we set the name as a temporary store value
+ // Move to editing value, we set the name as a temporary store value
+ if (!old_name.empty()) {
+ // Remove old named value
+ _repr->setAttribute(old_name.c_str(), nullptr, false);
+ }
+ if (!name.empty()) {
+ _repr->setAttribute(name.c_str(), value, false);
row[_attrColumns._attributeName] = name;
- // This would be nice to have, but it causes a crash when treeview looses focus
- // because signaling vs. focus is in some sort of conflict.
- //Gtk::TreeModel::Path _path = (Gtk::TreeModel::Path)row;
- //_treeView.set_cursor(_path, *_valueCol, true);
- //grab_focus();
}
+ this->setUndo(_("Rename attribute"));
}
}
@@ -344,7 +369,15 @@ void AttrDialog::valueEdited (const Glib::ustring& path, const Glib::ustring& va
if(row && this->_repr) {
Glib::ustring name = row[_attrColumns._attributeName];
if(name.empty()) return;
- _repr->setAttribute(name, value, false);
+ if (name == "content") {
+ _repr->setContent(value.c_str());
+ } else {
+ _repr->setAttribute(name.c_str(), value, false);
+ }
+ if(!value.empty()) {
+ row[_attrColumns._attributeValue] = value;
+ }
+
this->setUndo(_("Change attribute value"));
}
}
diff --git a/src/ui/dialog/objects.cpp b/src/ui/dialog/objects.cpp
index 9e115a2d6..f02df8042 100644
--- a/src/ui/dialog/objects.cpp
+++ b/src/ui/dialog/objects.cpp
@@ -422,13 +422,16 @@ void ObjectsPanel::_updateObject( SPObject *obj, bool recurse ) {
bool ObjectsPanel::_checkForUpdated(const Gtk::TreeIter& iter, SPObject* obj)
{
Gtk::TreeModel::Row row = *iter;
- if ( obj == row[_model->_colObject] )
+ if (obj && *iter && obj == row[_model->_colObject] )
{
//We found our item in the tree!! Update it!
SPItem * item = SP_IS_ITEM(obj) ? SP_ITEM(obj) : nullptr;
SPGroup * group = SP_IS_GROUP(obj) ? SP_GROUP(obj) : nullptr;
-
- row[_model->_colLabel] = obj->label() ? obj->label() : obj->getId();
+ gchar const * id = obj->getId();
+ if (!id) {
+ id = _("no-id");
+ }
+ row[_model->_colLabel] = obj->label() ? obj->label() : id;
row[_model->_colVisible] = item ? !item->isHidden() : false;
row[_model->_colLocked] = item ? !item->isSensitive() : false;
row[_model->_colType] = group ? (group->layerMode() == SPGroup::LAYER ? 2 : 1) : 0;
diff --git a/src/ui/dialog/xml-tree.cpp b/src/ui/dialog/xml-tree.cpp
index c6058945f..7d8f0a296 100644
--- a/src/ui/dialog/xml-tree.cpp
+++ b/src/ui/dialog/xml-tree.cpp
@@ -353,7 +353,11 @@ void XmlTree::set_tree_select(Inkscape::XML::Node *repr)
void XmlTree::propagate_tree_select(Inkscape::XML::Node *repr)
{
- if (repr && (repr->type() == Inkscape::XML::ELEMENT_NODE)) {
+ if (repr &&
+ (repr->type() == Inkscape::XML::ELEMENT_NODE ||
+ repr->type() == Inkscape::XML::TEXT_NODE ||
+ repr->type() == Inkscape::XML::COMMENT_NODE))
+ {
attributes->setRepr(repr);
} else {
attributes->setRepr(nullptr);