summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJabier Arraiza <jabier.arraiza@marker.es>2017-06-24 17:50:36 +0000
committerJabier Arraiza <jabier.arraiza@marker.es>2017-06-24 17:50:36 +0000
commitd71265c629a103d8c821fe85ccf71bd9c93baf47 (patch)
treec01fe4543cd48f64a8ca4b60e01e1bb5040922d9 /src
parentWorking with powerclip and powermask (diff)
parentMerge branch 'ui-files-for-ui-xml' (diff)
downloadinkscape-d71265c629a103d8c821fe85ccf71bd9c93baf47.tar.gz
inkscape-d71265c629a103d8c821fe85ccf71bd9c93baf47.zip
Updating to master
Diffstat (limited to 'src')
-rw-r--r--src/attributes.cpp3
-rw-r--r--src/attributes.h3
-rw-r--r--src/extension/internal/cairo-render-context.cpp35
-rw-r--r--src/extension/internal/cairo-render-context.h1
-rw-r--r--src/inkgc/gc-core.h4
-rw-r--r--src/io/resource.cpp36
-rw-r--r--src/io/resource.h2
-rw-r--r--src/path-prefix.h32
-rw-r--r--src/prefix.cpp75
-rw-r--r--src/prefix.h12
-rw-r--r--src/style-internal.cpp83
-rw-r--r--src/style-internal.h51
-rw-r--r--src/style.cpp10
-rw-r--r--src/style.h3
-rw-r--r--src/trace/trace.h2
-rw-r--r--src/ui/dialog/filedialogimpl-win32.cpp25
-rw-r--r--src/ui/dialog/styledialog.cpp138
-rw-r--r--src/ui/dialog/styledialog.h12
-rw-r--r--src/util/ege-tags.cpp2
-rw-r--r--src/widgets/desktop-widget.cpp94
-rw-r--r--src/widgets/ege-paint-def.cpp2
-rw-r--r--src/widgets/toolbox.cpp563
-rw-r--r--src/xml/repr-util.cpp4
23 files changed, 512 insertions, 680 deletions
diff --git a/src/attributes.cpp b/src/attributes.cpp
index c375ba903..9ba646ab4 100644
--- a/src/attributes.cpp
+++ b/src/attributes.cpp
@@ -480,6 +480,9 @@ static SPStyleProp const props[] = {
{SP_PROP_FONT_VARIANT_EAST_ASIAN, "font-variant-east-asian"},
{SP_PROP_FONT_FEATURE_SETTINGS, "font-feature-settings"},
+ /* Variable Fonts (CSS Fonts Module Level 4) */
+ {SP_PROP_FONT_VARIATION_SETTINGS, "font-variation-settings"},
+
/* Text */
{SP_PROP_TEXT_INDENT, "text-indent"},
{SP_PROP_TEXT_ALIGN, "text-align"},
diff --git a/src/attributes.h b/src/attributes.h
index c4658b85b..3fee14133 100644
--- a/src/attributes.h
+++ b/src/attributes.h
@@ -488,6 +488,9 @@ enum SPAttributeEnum {
SP_PROP_FONT_VARIANT_EAST_ASIAN,
SP_PROP_FONT_FEATURE_SETTINGS,
+ /* Variable Fonts (CSS Fonts Module Level 4) */
+ SP_PROP_FONT_VARIATION_SETTINGS,
+
/* Text Layout */
SP_PROP_TEXT_INDENT,
SP_PROP_TEXT_ALIGN,
diff --git a/src/extension/internal/cairo-render-context.cpp b/src/extension/internal/cairo-render-context.cpp
index 21902db7d..c513744a8 100644
--- a/src/extension/internal/cairo-render-context.cpp
+++ b/src/extension/internal/cairo-render-context.cpp
@@ -128,7 +128,8 @@ CairoRenderContext::CairoRenderContext(CairoRenderer *parent) :
_renderer(parent),
_render_mode(RENDER_MODE_NORMAL),
_clip_mode(CLIP_MODE_MASK),
- _omittext_state(EMPTY)
+ _omittext_state(EMPTY),
+ _omittext_missing_pages(0)
{
}
@@ -884,6 +885,13 @@ CairoRenderContext::finish(void)
if (_vector_based_target)
cairo_show_page(_cr);
+ // PDF+TeX Output, see CairoRenderContext::_prepareRenderGraphic()
+ while (_omittext_missing_pages > 0) {
+ _omittext_missing_pages--;
+ g_warning("PDF+TeX output: issuing blank PDF page at end (workaround for previous error)");
+ cairo_show_page(_cr);
+ }
+
cairo_destroy(_cr);
cairo_surface_finish(_surface);
cairo_status_t status = cairo_surface_status(_surface);
@@ -1435,8 +1443,29 @@ CairoRenderContext::_prepareRenderGraphic()
// Only PDFLaTeX supports importing a single page of a graphics file,
// so only PDF backend gets interleaved text/graphics
if (_is_omittext && _target == CAIRO_SURFACE_TYPE_PDF) {
- if (_omittext_state == NEW_PAGE_ON_GRAPHIC)
- cairo_show_page(_cr);
+ if (_omittext_state == NEW_PAGE_ON_GRAPHIC) {
+ if (cairo_get_group_target(_cr) != cairo_get_target(_cr)) {
+ // we are in the middle of a group, i. e., between cairo_push_group() and cairo_pop_group().
+ // cairo_show_page() has no effect here!
+ // To ensure that the the generated TeX source doesn't try to include non-existing pages,
+ // we will later output an extra blank page.
+ // This is a workaround for bug #1417470.
+ g_warning("PDF+TeX output: Found text inside a clipped/masked group. This is not supported, the Z-order will be incorrect. Blank pages will be added to the PDF output to work around bug #1417470.");
+ _omittext_missing_pages++;
+ } else {
+ // no group is active, create new page
+ cairo_show_page(_cr);
+ // Output missing pages (workaround for the 'if' case above).
+ // With this solution, the Z-order is more wrong than necessary.
+ // It would be better to print the blank pages first, and then the actual current page.
+ // However, this isn't easily possible with cairo.
+ while (_omittext_missing_pages > 0) {
+ _omittext_missing_pages--;
+ g_warning("PDF+TeX output: issuing blank PDF page (workaround for previous error)");
+ cairo_show_page(_cr);
+ }
+ }
+ }
_omittext_state = GRAPHIC_ON_TOP;
}
}
diff --git a/src/extension/internal/cairo-render-context.h b/src/extension/internal/cairo-render-context.h
index dfa6084d1..9b976fd6d 100644
--- a/src/extension/internal/cairo-render-context.h
+++ b/src/extension/internal/cairo-render-context.h
@@ -207,6 +207,7 @@ protected:
CairoClipMode _clip_mode;
CairoOmitTextPageState _omittext_state;
+ int _omittext_missing_pages;
cairo_pattern_t *_createPatternForPaintServer(SPPaintServer const *const paintserver,
Geom::OptRect const &pbox, float alpha);
diff --git a/src/inkgc/gc-core.h b/src/inkgc/gc-core.h
index a27510f50..407c857fb 100644
--- a/src/inkgc/gc-core.h
+++ b/src/inkgc/gc-core.h
@@ -19,11 +19,7 @@
#include <new>
#include <cstdlib>
-#ifdef HAVE_GC_GC_H
-# include <gc/gc.h>
-#else
# include <gc.h>
-#endif
namespace Inkscape {
namespace GC {
diff --git a/src/io/resource.cpp b/src/io/resource.cpp
index 501eab03b..52ac884b1 100644
--- a/src/io/resource.cpp
+++ b/src/io/resource.cpp
@@ -19,15 +19,18 @@
#include <glib.h> // g_assert()
#include "path-prefix.h"
#include "inkscape.h"
+#include "io/sys.h"
#include "io/resource.h"
+using Inkscape::IO::file_test;
+
namespace Inkscape {
namespace IO {
namespace Resource {
-Util::ptr_shared<char> get_path(Domain domain, Type type, char const *filename)
+gchar *_get_path(Domain domain, Type type, char const *filename)
{
gchar *path=NULL;
switch (domain) {
@@ -71,7 +74,8 @@ Util::ptr_shared<char> get_path(Domain domain, Type type, char const *filename)
case PALETTES: name = "palettes"; break;
case PATTERNS: name = "patterns"; break;
case TEMPLATES: name = "templates"; break;
- default: return get_path(SYSTEM, type, filename);
+ case UI: name = "ui"; break;
+ default: return _get_path(SYSTEM, type, filename);
}
path = Inkscape::Application::profile_path(name);
} break;
@@ -83,11 +87,39 @@ Util::ptr_shared<char> get_path(Domain domain, Type type, char const *filename)
path = temp;
}
+ return path;
+}
+
+Util::ptr_shared<char> get_path(Domain domain, Type type, char const *filename)
+{
+ char *path = _get_path(domain, type, filename);
Util::ptr_shared<char> result=Util::share_string(path);
g_free(path);
return result;
}
+/*
+ * Same as get_path, but checks for file's existance and falls back
+ * from USER to SYSTEM modes.
+ */
+Util::ptr_shared<char> get_filename(Type type, char const *filename)
+{
+ Util::ptr_shared<char> result;
+ char *user_filename = _get_path(USER, type, filename);
+ char *sys_filename = _get_path(SYSTEM, type, filename);
+
+ if (file_test(user_filename, G_FILE_TEST_EXISTS)) {
+ result = Util::share_string(user_filename);
+ } else if(file_test(sys_filename, G_FILE_TEST_EXISTS)) {
+ result = Util::share_string(sys_filename);
+ } else {
+ g_warning("Failed to load resource: %s", filename);
+ }
+ g_free(user_filename);
+ g_free(sys_filename);
+ return result;
+}
+
}
}
diff --git a/src/io/resource.h b/src/io/resource.h
index 36fe5f81e..fbf2111f4 100644
--- a/src/io/resource.h
+++ b/src/io/resource.h
@@ -48,6 +48,8 @@ enum Domain {
Util::ptr_shared<char> get_path(Domain domain, Type type,
char const *filename=NULL);
+Util::ptr_shared<char> get_filename(Type type, char const *filename=NULL);
+
}
}
diff --git a/src/path-prefix.h b/src/path-prefix.h
index 8a39ede84..e54a80f28 100644
--- a/src/path-prefix.h
+++ b/src/path-prefix.h
@@ -51,22 +51,22 @@
#else
# ifdef WIN32
# define INKSCAPE_APPICONDIR WIN32_DATADIR("pixmaps")
-# define INKSCAPE_ATTRRELDIR WIN32_DATADIR("share\\attributes")
-# define INKSCAPE_BINDDIR WIN32_DATADIR("share\\bind")
-# define INKSCAPE_EXAMPLESDIR WIN32_DATADIR("share\\examples")
-# define INKSCAPE_EXTENSIONDIR WIN32_DATADIR("share\\extensions")
-# define INKSCAPE_FILTERDIR WIN32_DATADIR("share\\filters")
-# define INKSCAPE_GRADIENTSDIR WIN32_DATADIR("share\\gradients")
-# define INKSCAPE_KEYSDIR WIN32_DATADIR("share\\keys")
-# define INKSCAPE_PIXMAPDIR WIN32_DATADIR("share\\icons")
-# define INKSCAPE_MARKERSDIR WIN32_DATADIR("share\\markers")
-# define INKSCAPE_PALETTESDIR WIN32_DATADIR("share\\palettes")
-# define INKSCAPE_PATTERNSDIR WIN32_DATADIR("share\\patterns")
-# define INKSCAPE_SCREENSDIR WIN32_DATADIR("share\\screens")
-# define INKSCAPE_SYMBOLSDIR WIN32_DATADIR("share\\symbols")
-# define INKSCAPE_TUTORIALSDIR WIN32_DATADIR("share\\tutorials")
-# define INKSCAPE_TEMPLATESDIR WIN32_DATADIR("share\\templates")
-# define INKSCAPE_UIDIR WIN32_DATADIR("share\\ui")
+# define INKSCAPE_ATTRRELDIR WIN32_DATADIR("attributes")
+# define INKSCAPE_BINDDIR WIN32_DATADIR("bind")
+# define INKSCAPE_EXAMPLESDIR WIN32_DATADIR("examples")
+# define INKSCAPE_EXTENSIONDIR WIN32_DATADIR("extensions")
+# define INKSCAPE_FILTERDIR WIN32_DATADIR("filters")
+# define INKSCAPE_GRADIENTSDIR WIN32_DATADIR("gradients")
+# define INKSCAPE_KEYSDIR WIN32_DATADIR("keys")
+# define INKSCAPE_PIXMAPDIR WIN32_DATADIR("icons")
+# define INKSCAPE_MARKERSDIR WIN32_DATADIR("markers")
+# define INKSCAPE_PALETTESDIR WIN32_DATADIR("palettes")
+# define INKSCAPE_PATTERNSDIR WIN32_DATADIR("patterns")
+# define INKSCAPE_SCREENSDIR WIN32_DATADIR("screens")
+# define INKSCAPE_SYMBOLSDIR WIN32_DATADIR("symbols")
+# define INKSCAPE_TUTORIALSDIR WIN32_DATADIR("tutorials")
+# define INKSCAPE_TEMPLATESDIR WIN32_DATADIR("templates")
+# define INKSCAPE_UIDIR WIN32_DATADIR("ui")
//CREATE V0.1 WIN32 support
# define CREATE_GRADIENTSDIR WIN32_DATADIR("create\\gradients\\gimp")
# define CREATE_PALETTESDIR WIN32_DATADIR("create\\swatches")
diff --git a/src/prefix.cpp b/src/prefix.cpp
index 4e2204cff..c8bf7abec 100644
--- a/src/prefix.cpp
+++ b/src/prefix.cpp
@@ -419,72 +419,37 @@ br_extract_prefix (const char *path)
#ifdef __WIN32__
-
/**
* Provide a similar mechanism for Win32. Enable a macro,
* WIN32_DATADIR, that can look up subpaths for inkscape resources
- */
-
-#include <windows.h>
-#include <glibmm/ustring.h>
-
-/**
- * Return the directory of the .exe that is currently running
*/
-Glib::ustring win32_getExePath()
-{
- gunichar2 path[2048];
- GetModuleFileNameW(0, (WCHAR*) path, 2048);
- gchar *exe = g_utf16_to_utf8(path, -1, 0,0,0);
- gchar *dir = g_path_get_dirname(exe);
- Glib::ustring ret = dir;
- g_free(dir);
- g_free(exe);
- return ret;
-}
-
/**
- * Return the relocatable version of the datadir,
- * probably c:\inkscape
+ * Get the Windows-equivalent of INKSCAPE_DATADIR and append a relative path
+ *
+ * - by default INKSCAPE_DATADIR will be relative to the called executable
+ * (typically inkscape/share but also handles the case where the executable is in a /bin subfolder)
+ * - to override set the INKSCAPE_DATADIR environment variable
*/
-static Glib::ustring win32_getDataDir()
-{
- Glib::ustring dir = win32_getExePath();
- if (INKSCAPE_DATADIR && *INKSCAPE_DATADIR &&
- strcmp(INKSCAPE_DATADIR, ".") != 0)
- {
- dir += "\\";
- dir += INKSCAPE_DATADIR;
- }
- return dir;
-}
-
-static Glib::ustring win32_getResourcePath(const Glib::ustring &childPath)
+char *win32_append_datadir(const char *relative_path)
{
- Glib::ustring dir = win32_getDataDir();
- if (childPath.size() > 0)
- {
- dir += "\\";
- dir += childPath;
+ static gchar *datadir;
+ if (!datadir) {
+ gchar const *inkscape_datadir = g_getenv("INKSCAPE_DATADIR");
+ if (inkscape_datadir) {
+ datadir = g_strdup(inkscape_datadir);
+ } else {
+ gchar *module_path = g_win32_get_package_installation_directory_of_module(NULL);
+ datadir = g_build_filename(module_path, "share", NULL);
+ g_free(module_path);
}
- return dir;
-}
+ }
+ if (!relative_path) {
+ relative_path = "";
+ }
-/**
- * This is the visible utility function
- */
-char *win32_relative_path(const char *childPath)
-{
- static char *returnPath = 0;
- if (!childPath)
- childPath = "";
- Glib::ustring resourcePath = win32_getResourcePath(childPath);
- if (returnPath)
- free(returnPath);
- returnPath = strdup(resourcePath.c_str());
- return returnPath;
+ return g_build_filename(datadir, relative_path, NULL);
}
#endif /* __WIN32__ */
diff --git a/src/prefix.h b/src/prefix.h
index 7c5a1fd3c..d28e896d0 100644
--- a/src/prefix.h
+++ b/src/prefix.h
@@ -119,14 +119,10 @@ char *br_extract_prefix(const char *path);
#endif /* __cplusplus */
#ifdef __WIN32__
-
-#include <glibmm/ustring.h>
-
-Glib::ustring win32_getExePath();
-char *win32_relative_path(const char *childPath);
-
-#define WIN32_DATADIR(suffix) (win32_relative_path(suffix))
-
+char *win32_append_datadir(const char *relative_path);
+#undef INKSCAPE_DATADIR
+#define INKSCAPE_DATADIR win32_append_datadir(NULL)
+#define WIN32_DATADIR(suffix) (win32_append_datadir(suffix))
#endif
#endif /* _PREFIX_H_ */
diff --git a/src/style-internal.cpp b/src/style-internal.cpp
index 54d1a0867..5c2f5697f 100644
--- a/src/style-internal.cpp
+++ b/src/style-internal.cpp
@@ -521,6 +521,89 @@ SPILengthOrNormal::operator==(const SPIBase& rhs) {
}
+// SPIFontVariationSettings ----------------------------------------------------
+
+void
+SPIFontVariationSettings::read( gchar const *str ) {
+
+ if( !str ) return;
+
+ if ( !strcmp(str, "normal") ) {
+ set = true;
+ inherit = false;
+ normal = true;
+ axes.empty();
+ return;
+ }
+
+ gchar ** strarray = g_strsplit(str, " ", 0);
+ unsigned int i=0;
+ while (strarray[i]){
+ char axis_name[5];
+ if (strlen(strarray[i]) >= 8
+ && (strarray[i][0] == '\"' || strarray[i][0] == '\'')
+ && (strarray[i][5] == '\"' || strarray[i][5] == '\'')
+ && strarray[i][6] == ' ') {
+ strncpy(axis_name, &strarray[i][1], 4);
+ axis_name[4] = '\0';
+
+ gfloat value;
+ if (sp_svg_number_read_f(&strarray[i][7], &value)) {
+ set = true;
+ inherit = false;
+ axes.insert(std::pair<char*,float>(axis_name,value));
+ } else {
+ //invalid syntax while parsing attribute
+ break;
+ }
+ normal = false;
+ }
+ i++;
+ }
+ g_strfreev (strarray);
+};
+
+const Glib::ustring
+SPIFontVariationSettings::write( guint const flags, SPStyleSrc const &style_src_req, SPIBase const *const base) const {
+
+ SPIFontVariationSettings const *const my_base = dynamic_cast<const SPIFontVariationSettings*>(base);
+ bool dfp = (!inherits || !my_base || (my_base != this)); // Different from parent
+ bool src = (style_src_req == style_src || !(flags & SP_STYLE_FLAG_IFSRC));
+ if (should_write(flags, set, dfp, src)) {
+ if (this->normal) {
+ return (name + ":normal;");
+ } else {
+ Inkscape::CSSOStringStream os;
+ for (std::map<char*,float>::const_iterator it=axes.begin(); it!=axes.end(); ++it){
+ os << "\"" << it->first << "\" " << it->second << " ";
+ // FIXME: can we avoid the last space char ?
+ }
+ return os.str();
+ }
+ }
+ return Glib::ustring("");
+}
+
+void
+SPIFontVariationSettings::cascade( const SPIBase* const parent ) {
+// std::cerr << "SPIVariableFontAxisOrNormal::cascade(): TODO: Implement-me!" << std::endl;
+}
+
+void
+SPIFontVariationSettings::merge( const SPIBase* const parent ) {
+// std::cerr << "SPIVariableFontAxisOrNormal::merge(): TODO: Implement-me!" << std::endl;
+}
+
+bool
+SPIFontVariationSettings::operator==(const SPIBase& rhs) {
+ if( const SPIFontVariationSettings* r = dynamic_cast<const SPIFontVariationSettings*>(&rhs) ) {
+ if( normal && r->normal ) { return true; }
+ if( normal != r->normal ) { return false; }
+ return axes == r->axes;
+ } else {
+ return false;
+ }
+}
// SPIEnum --------------------------------------------------------------
diff --git a/src/style-internal.h b/src/style-internal.h
index 154538833..c0b2f3e72 100644
--- a/src/style-internal.h
+++ b/src/style-internal.h
@@ -29,6 +29,7 @@
#include "xml/repr.h"
#include <vector>
+#include <map>
struct SPStyleEnum;
@@ -447,6 +448,56 @@ public:
};
+/// Extended length type internal to SPStyle.
+// Used for: font-variation-settings
+class SPIFontVariationSettings : public SPIBase
+{
+
+public:
+ SPIFontVariationSettings()
+ : SPIBase( "anonymous_fontvariationsettings" ),
+ normal(true)
+ {}
+
+ SPIFontVariationSettings( Glib::ustring const &name )
+ : SPIBase( name ),
+ normal(true)
+ {}
+
+ virtual ~SPIFontVariationSettings()
+ {}
+
+ virtual void read( gchar const *str );
+ virtual const Glib::ustring write( guint const flags = SP_STYLE_FLAG_IFSET,
+ SPStyleSrc const &style_src_req = SP_STYLE_SRC_STYLE_PROP,
+ SPIBase const *const base = NULL ) const;
+ virtual void clear() {
+ axes.empty();
+ normal = true;
+ }
+
+ virtual void cascade( const SPIBase* const parent );
+ virtual void merge( const SPIBase* const parent );
+
+ SPIFontVariationSettings& operator=(const SPIFontVariationSettings& rhs) {
+ axes = rhs.axes;
+ normal = rhs.normal;
+ return *this;
+ }
+
+ virtual bool operator==(const SPIBase& rhs);
+ virtual bool operator!=(const SPIBase& rhs) {
+ return !(*this == rhs);
+ }
+
+ // To do: make private
+public:
+ bool normal : 1;
+ bool inherit : 1;
+ std::map<char*, float> axes;
+};
+
+
/// Enum type internal to SPStyle.
// Used for many properties. 'font-stretch' and 'font-weight' must be special cased.
class SPIEnum : public SPIBase
diff --git a/src/style.cpp b/src/style.cpp
index 0b0358bb2..ca0eed6f7 100644
--- a/src/style.cpp
+++ b/src/style.cpp
@@ -115,6 +115,9 @@ SPStyle::SPStyle(SPDocument *document_in, SPObject *object_in) :
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" ),
+ // Variable Fonts
+ font_variation_settings( "font-variation-settings" ), // SPIFontVariationSettings
+
// Text related properties
text_indent( "text-indent", 0.0 ), // SPILength
text_align( "text-align", enum_text_align, SP_CSS_TEXT_ALIGN_START ),
@@ -298,6 +301,9 @@ SPStyle::SPStyle(SPDocument *document_in, SPObject *object_in) :
_properties.push_back( &font_variant_east_asian );
_properties.push_back( &font_feature_settings );
+ // Variable Fonts
+ _properties.push_back( &font_variation_settings );
+
_properties.push_back( &text_indent );
_properties.push_back( &text_align );
@@ -741,6 +747,10 @@ SPStyle::readIfUnset( gint id, gchar const *val, SPStyleSrc const &source ) {
font_feature_settings.readIfUnset( val, source );
break;
+ case SP_PROP_FONT_VARIATION_SETTINGS:
+ font_variation_settings.readIfUnset( val, source );
+ break;
+
/* Text */
case SP_PROP_TEXT_INDENT:
text_indent.readIfUnset( val, source );
diff --git a/src/style.h b/src/style.h
index 00c8c032a..fc50c3580 100644
--- a/src/style.h
+++ b/src/style.h
@@ -128,6 +128,9 @@ public:
/** Font feature settings (Low level access to TrueType tables) */
SPIString font_feature_settings;
+ /** Font variation settings (Low level access to OpenType variable font design-coordinate values) */
+ SPIFontVariationSettings font_variation_settings;
+
/* Text ----------------------------- */
/** First line indent of paragraphs (css2 16.1) */
diff --git a/src/trace/trace.h b/src/trace/trace.h
index f562e89aa..4bf13123b 100644
--- a/src/trace/trace.h
+++ b/src/trace/trace.h
@@ -13,9 +13,7 @@
# include "config.h"
#endif
-#ifdef HAVE_STRING_H
# include <string.h>
-#endif
#include <glibmm/refptr.h>
#include <gdkmm/pixbuf.h>
diff --git a/src/ui/dialog/filedialogimpl-win32.cpp b/src/ui/dialog/filedialogimpl-win32.cpp
index 1efec7d52..4fb8089ee 100644
--- a/src/ui/dialog/filedialogimpl-win32.cpp
+++ b/src/ui/dialog/filedialogimpl-win32.cpp
@@ -1586,10 +1586,15 @@ FileSaveDialogImplWin32::FileSaveDialogImplWin32(Gtk::Window &parent,
if (len != 0 && udir[len - 1] == '\\') udir.erase(len - 1);
// Remove the extension: remove everything past the last period found past the last slash
- size_t last_slash_index = udir.find_last_of( '\\' );
- size_t last_period_index = udir.find_last_of( '.' );
- if (last_period_index > last_slash_index) {
- myFilename = udir.substr(0, last_period_index );
+ // (not for CUSTOM_TYPE as we can not automatically add a file extension in that case yet)
+ if (dialogType == CUSTOM_TYPE) {
+ myFilename = udir;
+ } else {
+ size_t last_slash_index = udir.find_last_of( '\\' );
+ size_t last_period_index = udir.find_last_of( '.' );
+ if (last_period_index > last_slash_index) {
+ myFilename = udir.substr(0, last_period_index );
+ }
}
// remove one slash if double
@@ -1685,28 +1690,28 @@ void FileSaveDialogImplWin32::addFileType(Glib::ustring name, Glib::ustring patt
knownExtensions.clear();
- int extension_index = 0;
- int filter_length = 1;
-
- ustring all_exe_files_filter = pattern;
Filter all_exe_files;
const gchar *all_exe_files_filter_name = name.data();
+ const gchar *all_exe_files_filter = pattern.data();
// Calculate the amount of memory required
int filter_count = 1;
-
+ int filter_length = 1;
// Filter Executable Files
all_exe_files.name = g_utf8_to_utf16(all_exe_files_filter_name,
-1, NULL, &all_exe_files.name_length, NULL);
- all_exe_files.filter = g_utf8_to_utf16(all_exe_files_filter.data(),
+ all_exe_files.filter = g_utf8_to_utf16(all_exe_files_filter,
-1, NULL, &all_exe_files.filter_length, NULL);
all_exe_files.mod = NULL;
filter_list.push_front(all_exe_files);
+
+ filter_length = all_exe_files.name_length + all_exe_files.filter_length + 3; // Add 3 for two \0s and a *
knownExtensions.insert( Glib::ustring(all_exe_files_filter).casefold() );
+ int extension_index = 0;
_extension_map = new Inkscape::Extension::Extension*[filter_count];
_filter = new wchar_t[filter_length];
diff --git a/src/ui/dialog/styledialog.cpp b/src/ui/dialog/styledialog.cpp
index b1bcddd45..8679659ce 100644
--- a/src/ui/dialog/styledialog.cpp
+++ b/src/ui/dialog/styledialog.cpp
@@ -45,6 +45,7 @@ namespace Inkscape {
namespace UI {
namespace Dialog {
+// Keeps a watch on style element
class StyleDialog::NodeObserver : public Inkscape::XML::NodeObserver {
public:
NodeObserver(StyleDialog* styleDialog) :
@@ -78,6 +79,93 @@ StyleDialog::NodeObserver::notifyContentChanged(
}
+// Keeps a watch for new/removed/changed nodes
+// (Must update objects that selectors match.)
+class StyleDialog::NodeWatcher : public Inkscape::XML::NodeObserver {
+public:
+ NodeWatcher(StyleDialog* styleDialog, Inkscape::XML::Node *repr) :
+ _styleDialog(styleDialog),
+ _repr(repr)
+ {
+#ifdef DEBUG_STYLEDIALOG
+ std::cout << "StyleDialog::NodeWatcher: Constructor" << std::endl;
+#endif
+ };
+
+ virtual void notifyChildAdded( Inkscape::XML::Node &/*node*/,
+ Inkscape::XML::Node &child,
+ Inkscape::XML::Node */*prev*/ )
+ {
+ if ( _styleDialog && _repr ) {
+ _styleDialog->_nodeAdded( child );
+ }
+ }
+
+ virtual void notifyChildRemoved( Inkscape::XML::Node &/*node*/,
+ Inkscape::XML::Node &child,
+ Inkscape::XML::Node */*prev*/ )
+ {
+ if ( _styleDialog && _repr ) {
+ _styleDialog->_nodeRemoved( child );
+ }
+ }
+
+ virtual void notifyAttributeChanged( Inkscape::XML::Node &node,
+ GQuark qname,
+ Util::ptr_shared<char> /*old_value*/,
+ Util::ptr_shared<char> /*new_value*/ ) {
+ if ( _styleDialog && _repr ) {
+
+ // For the moment only care about attributes that are directly used in selectors.
+ const gchar * cname = g_quark_to_string (qname );
+ Glib::ustring name;
+ if (cname) {
+ name = cname;
+ }
+
+ if ( name == "id" || name == "class" ) {
+ _styleDialog->_nodeChanged( node );
+ }
+ }
+ }
+
+ StyleDialog * _styleDialog;
+ Inkscape::XML::Node * _repr; // Need to track if document changes.
+};
+
+void
+StyleDialog::_nodeAdded( Inkscape::XML::Node &node ) {
+
+ StyleDialog::NodeWatcher *w = new StyleDialog::NodeWatcher (this, &node);
+ node.addObserver (*w);
+ _nodeWatchers.push_back(w);
+
+ _readStyleElement();
+ _selectRow();
+}
+
+void
+StyleDialog::_nodeRemoved( Inkscape::XML::Node &repr ) {
+
+ for (auto it = _nodeWatchers.begin(); it != _nodeWatchers.end(); ++it) {
+ if ( (*it)->_repr == &repr ) {
+ (*it)->_repr->removeObserver (**it);
+ _nodeWatchers.erase( it );
+ break;
+ }
+ }
+
+ _readStyleElement();
+ _selectRow();
+}
+
+void
+StyleDialog::_nodeChanged( Inkscape::XML::Node &object ) {
+
+ _readStyleElement();
+ _selectRow();
+}
+
StyleDialog::TreeStore::TreeStore()
{
}
@@ -248,6 +336,9 @@ StyleDialog::StyleDialog() :
_selection_changed_connection = getDesktop()->getSelection()->connectChanged(
sigc::hide(sigc::mem_fun(this, &StyleDialog::_handleSelectionChanged)));
+ // Add watchers
+ _updateWatchers();
+
// Load tree
_readStyleElement();
_selectRow();
@@ -407,6 +498,7 @@ void StyleDialog::_readStyleElement()
// Add as children, objects that match selector.
for (auto& obj: objVec) {
+ if (obj->cloned) continue; // Skip cloned objects (they also don't have 'id').
Gtk::TreeModel::Row childrow = *(_store->append(row->children()));
childrow[_mColumns._colSelector] = "#" + Glib::ustring(obj->getId());
childrow[_mColumns._colIsSelector] = false;
@@ -446,6 +538,49 @@ void StyleDialog::_writeStyleElement()
}
+void StyleDialog::_addWatcherRecursive(Inkscape::XML::Node *node) {
+
+#ifdef DEBUG_STYLEDIALOG
+ std::cout << "StyleDialog::_addWatcherRecursive()" << std::endl;
+#endif
+
+ StyleDialog::NodeWatcher *w = new StyleDialog::NodeWatcher(this, node);
+ node->addObserver(*w);
+ _nodeWatchers.push_back(w);
+
+ for (unsigned i = 0; i < node->childCount(); ++i) {
+ _addWatcherRecursive(node->nthChild(i));
+ }
+}
+
+/**
+ * @brief StyleDialog::_updateWatchers
+ * Update the watchers on objects.
+ */
+void StyleDialog::_updateWatchers()
+{
+ _updating = true;
+
+ // Remove old document watchers
+ while (!_nodeWatchers.empty()) {
+ StyleDialog::NodeWatcher *w = _nodeWatchers.back();
+ w->_repr->removeObserver(*w);
+ _nodeWatchers.pop_back();
+ delete w;
+ }
+
+ // Recursively add new watchers
+ Inkscape::XML::Node *root = SP_ACTIVE_DOCUMENT->getReprRoot();
+ _addWatcherRecursive(root);
+
+#ifdef DEBUG_STYLEDIALOG
+ std::cout << "StyleDialog::_updateWatchers(): " << _nodeWatchers.size() << std::endl;
+#endif
+
+ _updating = false;
+}
+
+
/**
* @brief StyleDialog::_addToSelector
* @param row
@@ -711,6 +846,7 @@ void StyleDialog::_selectObjects(int eventX, int eventY)
Gtk::TreeModel::Row row = *iter;
Gtk::TreeModel::Children children = row.children();
std::vector<SPObject *> objVec = row[_mColumns._colObj];
+
for (unsigned i = 0; i < objVec.size(); ++i) {
SPObject *obj = objVec[i];
getDesktop()->selection->add(obj);
@@ -1046,6 +1182,7 @@ StyleDialog::_handleDocumentReplaced(SPDesktop *desktop, SPDocument * /* documen
_selection_changed_connection = desktop->getSelection()->connectChanged(
sigc::hide(sigc::mem_fun(this, &StyleDialog::_handleSelectionChanged)));
+ _updateWatchers();
_readStyleElement();
_selectRow();
}
@@ -1076,6 +1213,7 @@ StyleDialog::_handleDesktopChanged(SPDesktop* desktop) {
_document_replaced_connection = desktop->connectDocumentReplaced(
sigc::mem_fun(this, &StyleDialog::_handleDocumentReplaced));
+ _updateWatchers();
_readStyleElement();
_selectRow();
}
diff --git a/src/ui/dialog/styledialog.h b/src/ui/dialog/styledialog.h
index e84489e66..dbbc1e480 100644
--- a/src/ui/dialog/styledialog.h
+++ b/src/ui/dialog/styledialog.h
@@ -58,6 +58,14 @@ private:
// Monitor <style> element for changes.
class NodeObserver;
+ // Monitor all objects for addition/removal/attribute change
+ class NodeWatcher;
+
+ std::vector<StyleDialog::NodeWatcher*> _nodeWatchers;
+ void _nodeAdded( Inkscape::XML::Node &repr );
+ void _nodeRemoved( Inkscape::XML::Node &repr );
+ void _nodeChanged( Inkscape::XML::Node &repr );
+
// Data structure
class ModelColumns : public Gtk::TreeModel::ColumnRecord {
public:
@@ -112,6 +120,10 @@ private:
Inkscape::XML::Node *_getStyleTextNode();
void _readStyleElement();
void _writeStyleElement();
+
+ // Update watchers
+ void _addWatcherRecursive(Inkscape::XML::Node *node);
+ void _updateWatchers();
// Manipulate Tree
void _addToSelector(Gtk::TreeModel::Row row);
diff --git a/src/util/ege-tags.cpp b/src/util/ege-tags.cpp
index 8a2ce0529..dcc28f370 100644
--- a/src/util/ege-tags.cpp
+++ b/src/util/ege-tags.cpp
@@ -38,9 +38,7 @@
#include "config.h"
#endif // HAVE_CONFIG_H
-#if HAVE_LIBINTL_H
#include <libintl.h>
-#endif // HAVE_LIBINTL_H
#if !defined(_)
#define _(s) gettext(s)
diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp
index d8c27f5b7..ce4c5936c 100644
--- a/src/widgets/desktop-widget.cpp
+++ b/src/widgets/desktop-widget.cpp
@@ -66,6 +66,7 @@
#include <gtkmm/cssprovider.h>
#include <gtkmm/paned.h>
#include <gtkmm/messagedialog.h>
+#include "inkscape-version.h"
using Inkscape::UI::Widget::UnitTracker;
using Inkscape::UI::UXManager;
@@ -761,69 +762,52 @@ SPDesktopWidget::updateTitle(gchar const* uri)
Gtk::Window *window = static_cast<Gtk::Window*>(g_object_get_data(G_OBJECT(this), "window"));
if (window) {
- gchar const *fname = uri;
- GString *name = g_string_new ("");
-
- gchar const *grayscalename = N_("grayscale");
- gchar const *grayscalenamecomma = N_(", grayscale");
- gchar const *printcolorsname = N_("print colors preview");
- gchar const *printcolorsnamecomma = N_(", print colors preview");
- gchar const *outlinename = N_("outline");
- gchar const *nofiltersname = N_("no filters");
- gchar const *colormodename = NULL;
- gchar const *colormodenamecomma = NULL;
- gchar const *rendermodename = NULL;
- gchar const *modifiedname = "";
+
SPDocument *doc = this->desktop->doc();
+
+ std::string Name;
if (doc->isModifiedSinceSave()) {
- modifiedname = "*";
+ Name += "*";
}
- if (this->desktop->getColorMode() == Inkscape::COLORMODE_GRAYSCALE) {
- colormodename = grayscalename;
- colormodenamecomma = grayscalenamecomma;
- } else if (this->desktop->getColorMode() == Inkscape::COLORMODE_PRINT_COLORS_PREVIEW) {
- colormodename = printcolorsname;
- colormodenamecomma = printcolorsnamecomma;
+ Name += uri;
+
+ if (desktop->number > 1) {
+ Name += ": ";
+ Name += std::to_string(desktop->number);
}
- if (this->desktop->getMode() == Inkscape::RENDERMODE_OUTLINE) {
- rendermodename = outlinename;
- } else if (this->desktop->getMode() == Inkscape::RENDERMODE_NO_FILTERS) {
- rendermodename = nofiltersname;
+ Name += " (";
+
+ if (desktop->getMode() == Inkscape::RENDERMODE_OUTLINE) {
+ Name += N_("outline");
+ } else if (desktop->getMode() == Inkscape::RENDERMODE_NO_FILTERS) {
+ Name += N_("no filters");
}
-
-
- if (this->desktop->number > 1) {
- if (rendermodename) {
- if (colormodenamecomma) {
- g_string_printf (name, _("%s%s: %d (%s%s) - Inkscape"), modifiedname, fname, this->desktop->number, _(rendermodename), _(colormodenamecomma));
- } else {
- g_string_printf (name, _("%s%s: %d (%s) - Inkscape"), modifiedname, fname, this->desktop->number, _(rendermodename));
- }
- } else {
- if (colormodename) {
- g_string_printf (name, _("%s%s: %d (%s) - Inkscape"), modifiedname, fname, this->desktop->number, _(colormodename));
- } else {
- g_string_printf (name, _("%s%s: %d - Inkscape"), modifiedname, fname, this->desktop->number);
- }
- }
+
+ if (desktop->getColorMode() != Inkscape::COLORMODE_NORMAL &&
+ desktop->getMode() != Inkscape::RENDERMODE_NORMAL) {
+ Name += ", ";
+ }
+
+ if (desktop->getColorMode() == Inkscape::COLORMODE_GRAYSCALE) {
+ Name += N_("grayscale");
+ } else if (desktop->getColorMode() == Inkscape::COLORMODE_PRINT_COLORS_PREVIEW) {
+ Name += N_("print colors preview");
+ }
+
+ if (*Name.rbegin() == '(') { // Can not use C++11 .back() or .pop_back() with ustring!
+ Name.erase(Name.size() - 2);
} else {
- if (rendermodename) {
- if (colormodenamecomma) {
- g_string_printf (name, _("%s%s (%s%s) - Inkscape"), modifiedname, fname, _(rendermodename), _(colormodenamecomma));
- } else {
- g_string_printf (name, _("%s%s (%s) - Inkscape"), modifiedname, fname, _(rendermodename));
- }
- } else {
- if (colormodename) {
- g_string_printf (name, _("%s%s (%s) - Inkscape"), modifiedname, fname, _(colormodename));
- } else {
- g_string_printf (name, _("%s%s - Inkscape"), modifiedname, fname);
- }
- }
+ Name += ")";
}
- window->set_title (name->str);
- g_string_free (name, TRUE);
+
+ Name += " - Inkscape";
+
+ // Name += " (";
+ // Name += Inkscape::version_string;
+ // Name += ")";
+
+ window->set_title (Name);
}
}
diff --git a/src/widgets/ege-paint-def.cpp b/src/widgets/ege-paint-def.cpp
index 1a8ad041a..8e0ec9352 100644
--- a/src/widgets/ege-paint-def.cpp
+++ b/src/widgets/ege-paint-def.cpp
@@ -36,9 +36,7 @@
#include "config.h"
-#ifdef HAVE_LIBINTL_H
#include <libintl.h>
-#endif
#include <stdint.h>
#include <string>
diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp
index 016eafdaa..65c54f0ce 100644
--- a/src/widgets/toolbox.cpp
+++ b/src/widgets/toolbox.cpp
@@ -61,7 +61,7 @@
#include "../xml/attribute-record.h"
#include "../xml/node-event-vector.h"
#include "ui/uxmanager.h"
-
+#include "io/resource.h"
#include "arc-toolbar.h"
#include "box3d-toolbar.h"
@@ -101,6 +101,9 @@ using Inkscape::UI::PrefPusher;
using Inkscape::UI::ToolboxFactory;
using Inkscape::UI::Tools::ToolBase;
+using Inkscape::IO::Resource::get_filename;
+using Inkscape::IO::Resource::UI;
+
typedef void (*SetupFunction)(GtkWidget *toolbox, SPDesktop *desktop);
typedef void (*UpdateFunction)(SPDesktop *desktop, ToolBase *eventcontext, GtkWidget *toolbox);
@@ -153,6 +156,9 @@ static struct {
{ "/tools/eraser", "eraser_tool", SP_VERB_CONTEXT_ERASER, SP_VERB_CONTEXT_ERASER_PREFS },
#if HAVE_POTRACE
{ "/tools/paintbucket", "paintbucket_tool", SP_VERB_CONTEXT_PAINTBUCKET, SP_VERB_CONTEXT_PAINTBUCKET_PREFS },
+#else
+ // Replacement blank action for ToolPaintBucket to prevent loading errors in ui file
+ { "/tools/paintbucket", "ToolPaintBucket", SP_VERB_NONE, SP_VERB_NONE },
#endif
{ "/tools/text", "text_tool", SP_VERB_CONTEXT_TEXT, SP_VERB_CONTEXT_TEXT_PREFS },
{ "/tools/connector","connector_tool", SP_VERB_CONTEXT_CONNECTOR, SP_VERB_CONTEXT_CONNECTOR_PREFS },
@@ -218,394 +224,12 @@ static struct {
#if HAVE_POTRACE
{ "/tools/paintbucket", "paintbucket_toolbox", 0, sp_paintbucket_toolbox_prep, "PaintbucketToolbar",
SP_VERB_CONTEXT_PAINTBUCKET_PREFS, "/tools/paintbucket", N_("Style of Paint Bucket fill objects")},
+#else
+ { "/tools/paintbucket", "paintbucket_toolbox", 0, NULL, "PaintbucketToolbar", SP_VERB_NONE, "/tools/paintbucket", N_("Disabled")},
#endif
{ NULL, NULL, NULL, NULL, NULL, SP_VERB_INVALID, NULL, NULL }
};
-static gchar const * ui_descr =
- "<ui>"
- " <toolbar name='SelectToolbar'>"
- " <toolitem action='EditSelectAll' />"
- " <toolitem action='EditSelectAllInAllLayers' />"
- " <toolitem action='EditDeselect' />"
- " <separator />"
- " <toolitem action='ObjectRotate90CCW' />"
- " <toolitem action='ObjectRotate90' />"
- " <toolitem action='ObjectFlipHorizontally' />"
- " <toolitem action='ObjectFlipVertically' />"
- " <separator />"
- " <toolitem action='SelectionToBack' />"
- " <toolitem action='SelectionLower' />"
- " <toolitem action='SelectionRaise' />"
- " <toolitem action='SelectionToFront' />"
- " <separator />"
- " <toolitem action='XAction' />"
- " <toolitem action='YAction' />"
- " <toolitem action='WidthAction' />"
- " <toolitem action='LockAction' />"
- " <toolitem action='HeightAction' />"
- " <toolitem action='UnitsAction' />"
- " <separator />"
- " <toolitem action='transform_stroke' />"
- " <toolitem action='transform_corners' />"
- " <toolitem action='transform_gradient' />"
- " <toolitem action='transform_pattern' />"
- " </toolbar>"
-
- " <toolbar name='NodeToolbar'>"
- " <separator />"
- " <toolitem action='NodeInsertAction'>"
- " <menu action='NodeInsertActionMenu'>"
- " <menuitem action='NodeInsertActionMinX' />"
- " <menuitem action='NodeInsertActionMaxX' />"
- " <menuitem action='NodeInsertActionMinY' />"
- " <menuitem action='NodeInsertActionMaxY' />"
- " </menu>"
- " </toolitem>"
- " <toolitem action='NodeDeleteAction' />"
- " <separator />"
- " <toolitem action='NodeJoinAction' />"
- " <toolitem action='NodeBreakAction' />"
- " <separator />"
- " <toolitem action='NodeJoinSegmentAction' />"
- " <toolitem action='NodeDeleteSegmentAction' />"
- " <separator />"
- " <toolitem action='NodeCuspAction' />"
- " <toolitem action='NodeSmoothAction' />"
- " <toolitem action='NodeSymmetricAction' />"
- " <toolitem action='NodeAutoAction' />"
- " <separator />"
- " <toolitem action='NodeLineAction' />"
- " <toolitem action='NodeCurveAction' />"
- " <separator />"
- " <toolitem action='ObjectToPath' />"
- " <toolitem action='StrokeToPath' />"
- " <separator />"
- " <toolitem action='NodeXAction' />"
- " <toolitem action='NodeYAction' />"
- " <toolitem action='NodeUnitsAction' />"
- " <separator />"
- " <toolitem action='ObjectEditClipPathAction' />"
- " <toolitem action='ObjectEditMaskPathAction' />"
- " <toolitem action='EditNextPathEffectParameter' />"
- " <separator />"
- " <toolitem action='NodesShowTransformHandlesAction' />"
- " <toolitem action='NodesShowHandlesAction' />"
- " <toolitem action='NodesShowHelperpath' />"
- " </toolbar>"
-
- " <toolbar name='TweakToolbar'>"
- " <toolitem action='TweakWidthAction' />"
- " <separator />"
- " <toolitem action='TweakForceAction' />"
- " <toolitem action='TweakPressureAction' />"
- " <separator />"
- " <toolitem action='TweakModeAction' />"
- " <separator />"
- " <toolitem action='TweakFidelityAction' />"
- " <separator />"
- " <toolitem action='TweakChannelsLabel' />"
- " <toolitem action='TweakDoH' />"
- " <toolitem action='TweakDoS' />"
- " <toolitem action='TweakDoL' />"
- " <toolitem action='TweakDoO' />"
- " </toolbar>"
-
- " <toolbar name='SprayToolbar'>"
- " <toolitem action='SprayModeAction' />"
- " <separator />"
- " <toolitem action='SprayWidthAction' />"
- " <toolitem action='SprayPressureWidthAction' />"
- " <toolitem action='SprayPopulationAction' />"
- " <toolitem action='SprayPressurePopulationAction' />"
- " <separator />"
- " <toolitem action='SprayRotationAction' />"
- " <toolitem action='SprayScaleAction' />"
- " <toolitem action='SprayPressureScaleAction' />"
- " <separator />"
- " <toolitem action='SprayStandard_deviationAction' />"
- " <toolitem action='SprayMeanAction' />"
- " <separator />"
- " <toolitem action='SprayOverNoTransparentAction' />"
- " <toolitem action='SprayOverTransparentAction' />"
- " <toolitem action='SprayPickNoOverlapAction' />"
- " <toolitem action='SprayNoOverlapAction' />"
- " <toolitem action='SprayToolOffsetAction' />"
- " <separator />"
- " <toolitem action='SprayPickColorAction' />"
- " <toolitem action='SprayPickFillAction' />"
- " <toolitem action='SprayPickStrokeAction' />"
- " <toolitem action='SprayPickInverseValueAction' />"
- " <toolitem action='SprayPickCenterAction' />"
- " </toolbar>"
-
- " <toolbar name='ZoomToolbar'>"
- " <toolitem action='ZoomIn' />"
- " <toolitem action='ZoomOut' />"
- " <separator />"
- " <toolitem action='Zoom1:0' />"
- " <toolitem action='Zoom1:2' />"
- " <toolitem action='Zoom2:1' />"
- " <separator />"
- " <toolitem action='ZoomSelection' />"
- " <toolitem action='ZoomDrawing' />"
- " <toolitem action='ZoomPage' />"
- " <toolitem action='ZoomPageWidth' />"
- " <separator />"
- " <toolitem action='ZoomPrev' />"
- " <toolitem action='ZoomNext' />"
- " </toolbar>"
-
- " <toolbar name='MeasureToolbar'>"
- " <toolitem action='MeasureFontSizeAction' />"
- " <separator />"
- " <toolitem action='MeasurePrecisionAction' />"
- " <separator />"
- " <toolitem action='MeasureScaleAction' />"
- " <separator />"
- " <toolitem action='measure_units_label' />"
- " <toolitem action='MeasureUnitsAction' />"
- " <toolitem action='MeasureIgnore1stAndLast' />"
- " <toolitem action='MeasureInBettween' />"
- " <toolitem action='MeasureShowHidden' />"
- " <toolitem action='MeasureAllLayers' />"
- " <toolitem action='MeasureReverse' />"
- " <toolitem action='MeasureToPhantom' />"
- " <toolitem action='MeasureToGuides' />"
- " <toolitem action='MeasureToItem' />"
- " <toolitem action='MeasureMarkDimension' />"
- " <toolitem action='MeasureOffsetAction' />"
- " </toolbar>"
-
- " <toolbar name='StarToolbar'>"
- " <separator />"
- " <toolitem action='StarStateAction' />"
- " <separator />"
- " <toolitem action='FlatAction' />"
- " <separator />"
- " <toolitem action='MagnitudeAction' />"
- " <toolitem action='SpokeAction' />"
- " <toolitem action='RoundednessAction' />"
- " <toolitem action='RandomizationAction' />"
- " <separator />"
- " <toolitem action='StarResetAction' />"
- " </toolbar>"
-
- " <toolbar name='RectToolbar'>"
- " <toolitem action='RectStateAction' />"
- " <toolitem action='RectWidthAction' />"
- " <toolitem action='RectHeightAction' />"
- " <toolitem action='RadiusXAction' />"
- " <toolitem action='RadiusYAction' />"
- " <toolitem action='RectUnitsAction' />"
- " <separator />"
- " <toolitem action='RectResetAction' />"
- " </toolbar>"
-
- " <toolbar name='3DBoxToolbar'>"
- " <toolitem action='3DBoxAngleXAction' />"
- " <toolitem action='3DBoxVPXStateAction' />"
- " <separator />"
- " <toolitem action='3DBoxAngleYAction' />"
- " <toolitem action='3DBoxVPYStateAction' />"
- " <separator />"
- " <toolitem action='3DBoxAngleZAction' />"
- " <toolitem action='3DBoxVPZStateAction' />"
- " </toolbar>"
-
- " <toolbar name='SpiralToolbar'>"
- " <toolitem action='SpiralStateAction' />"
- " <toolitem action='SpiralRevolutionAction' />"
- " <toolitem action='SpiralExpansionAction' />"
- " <toolitem action='SpiralT0Action' />"
- " <separator />"
- " <toolitem action='SpiralResetAction' />"
- " </toolbar>"
-
- " <toolbar name='PenToolbar'>"
- " <toolitem action='FreehandModeActionPen' />"
- " <separator />"
- " <toolitem action='SetPenShapeAction'/>"
- " </toolbar>"
-
- " <toolbar name='PencilToolbar'>"
- " <toolitem action='FreehandModeActionPencil' />"
- " <separator />"
- " <toolitem action='PencilToleranceAction' />"
- " <toolitem action='PencilLpeSimplify' />"
- " <toolitem action='PencilLpeSimplifyFlatten' />"
- " <separator />"
- " <toolitem action='PencilResetAction' />"
- " <separator />"
- " <toolitem action='SetPencilShapeAction'/>"
- " </toolbar>"
-
- " <toolbar name='CalligraphyToolbar'>"
- " <separator />"
- " <toolitem action='SetProfileAction'/>"
- " <toolitem action='ProfileEditAction'/>"
- " <separator />"
- " <toolitem action='CalligraphyWidthAction' />"
- " <toolitem action='PressureAction' />"
- " <toolitem action='TraceAction' />"
- " <toolitem action='ThinningAction' />"
- " <separator />"
- " <toolitem action='AngleAction' />"
- " <toolitem action='TiltAction' />"
- " <toolitem action='FixationAction' />"
- " <separator />"
- " <toolitem action='CapRoundingAction' />"
- " <separator />"
- " <toolitem action='TremorAction' />"
- " <toolitem action='WiggleAction' />"
- " <toolitem action='MassAction' />"
- " <separator />"
- " </toolbar>"
-
- " <toolbar name='ArcToolbar'>"
- " <toolitem action='ArcStateAction' />"
- " <separator />"
- " <toolitem action='ArcStartAction' />"
- " <toolitem action='ArcEndAction' />"
- " <separator />"
- " <toolitem action='ArcOpenAction' />"
- " <separator />"
- " <toolitem action='ArcResetAction' />"
- " <separator />"
- " </toolbar>"
-
-#if HAVE_POTRACE
- " <toolbar name='PaintbucketToolbar'>"
- " <toolitem action='ChannelsAction' />"
- " <separator />"
- " <toolitem action='ThresholdAction' />"
- " <separator />"
- " <toolitem action='OffsetAction' />"
- " <toolitem action='PaintbucketUnitsAction' />"
- " <separator />"
- " <toolitem action='AutoGapAction' />"
- " <separator />"
- " <toolitem action='PaintbucketResetAction' />"
- " </toolbar>"
-#endif
-
- " <toolbar name='EraserToolbar'>"
- " <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 />"
- " <toolitem action='EraserBreakAppart' />"
- " </toolbar>"
-
- " <toolbar name='TextToolbar'>"
- " <toolitem action='TextFontFamilyAction' />"
- " <toolitem action='TextFontStyleAction' />"
- " <separator />"
- " <toolitem action='TextOuterStyleAction' />"
- " <toolitem action='TextFontSizeAction' />"
- " <toolitem action='TextLineHeightAction' />"
- " <toolitem action='TextLineHeightUnitsAction' />"
- " <toolitem action='TextLineHeightUnsetAction' />"
- " <separator />"
- " <toolitem action='TextAlignAction' />"
- " <separator />"
- " <toolitem action='TextSuperscriptAction' />"
- " <toolitem action='TextSubscriptAction' />"
- " <separator />"
- " <toolitem action='TextLetterSpacingAction' />"
- " <toolitem action='TextWordSpacingAction' />"
- " <toolitem action='TextDxAction' />"
- " <toolitem action='TextDyAction' />"
- " <toolitem action='TextRotationAction' />"
- " <separator />"
- " <toolitem action='TextWritingModeAction' />"
- " <separator />"
- " <toolitem action='TextOrientationAction' />"
- " <separator />"
- " <toolitem action='TextDirectionAction' />"
- " </toolbar>"
-
- " <toolbar name='LPEToolToolbar'>"
- " <toolitem action='LPEToolModeAction' />"
- " <separator />"
- " <toolitem action='LPEShowBBoxAction' />"
- " <toolitem action='LPEBBoxFromSelectionAction' />"
- " <separator />"
- " <toolitem action='LPELineSegmentAction' />"
- " <separator />"
- " <toolitem action='LPEMeasuringAction' />"
- " <toolitem action='LPEToolUnitsAction' />"
- " <separator />"
- " <toolitem action='LPEOpenLPEDialogAction' />"
- " </toolbar>"
-
- " <toolbar name='GradientToolbar'>"
- " <toolitem action='GradientNewTypeAction' />"
- " <toolitem action='GradientNewFillStrokeAction' />"
- " <separator />"
- " <toolitem action='GradientSelectGradientAction' />"
- " <toolitem action='GradientEditLinkAction' />"
- " <toolitem action='GradientEditReverseAction' />"
- " <toolitem action='GradientSelectRepeatAction' />"
- " <separator />"
- " <toolitem action='GradientEditStopsAction' />"
- " <toolitem action='GradientEditOffsetAction' />"
- " <toolitem action='GradientEditAddAction' />"
- " <toolitem action='GradientEditDeleteAction' />"
- " </toolbar>"
-
- " <toolbar name='MeshToolbar'>"
- " <toolitem action='MeshNewTypeAction' />"
- " <toolitem action='MeshNewFillStrokeAction' />"
- " <toolitem action='MeshRowAction' />"
- " <toolitem action='MeshColumnAction' />"
- " <separator />"
-// " <toolitem action='MeshEditFillAction' />"
-// " <toolitem action='MeshEditStrokeAction' />"
-// " <toolitem action='MeshShowHandlesAction' />"
- " <toolitem action='MeshToggleSidesAction' />"
- " <toolitem action='MeshMakeEllipticalAction' />"
- " <toolitem action='MeshPickColorsAction' />"
- " <toolitem action='MeshFitInBoundingBoxAction' />"
- " <separator />"
- " <toolitem action='MeshShowHandlesAction' />"
- " <toolitem action='MeshEditFillAction' />"
- " <toolitem action='MeshEditStrokeAction' />"
- " <separator />"
- " <toolitem action='MeshWarningAction' />"
- " <separator />"
- " <toolitem action='MeshSmoothAction' />"
- " </toolbar>"
-
- " <toolbar name='DropperToolbar'>"
- " <toolitem action='DropperOpacityAction' />"
- " <toolitem action='DropperPickAlphaAction' />"
- " <toolitem action='DropperSetAlphaAction' />"
- " </toolbar>"
-
- " <toolbar name='ConnectorToolbar'>"
- " <toolitem action='ConnectorAvoidAction' />"
- " <toolitem action='ConnectorIgnoreAction' />"
- " <toolitem action='ConnectorOrthogonalAction' />"
- " <toolitem action='ConnectorCurvatureAction' />"
- " <toolitem action='ConnectorSpacingAction' />"
- " <toolitem action='ConnectorGraphAction' />"
- " <toolitem action='ConnectorLengthAction' />"
- " <toolitem action='ConnectorDirectedAction' />"
- " <toolitem action='ConnectorOverlapAction' />"
- " </toolbar>"
-
- "</ui>"
-;
static Glib::RefPtr<Gtk::ActionGroup> create_or_fetch_actions( SPDesktop* desktop );
@@ -995,6 +619,12 @@ static Glib::RefPtr<Gtk::ActionGroup> create_or_fetch_actions( SPDesktop* deskto
if ( i == 0 ) {
va->set_active(true);
}
+ } else {
+ // This creates a blank action using the data_name, this can replace
+ // tools that have been disabled by compile time options.
+ Glib::RefPtr<Gtk::Action> act = Gtk::Action::create(Glib::ustring(tools[i].data_name));
+ act->set_sensitive(false);
+ mainActions->add(act);
}
}
}
@@ -1196,7 +826,7 @@ void ToolboxFactory::setToolboxDesktop(GtkWidget *toolbox, SPDesktop *desktop)
static void setupToolboxCommon( GtkWidget *toolbox,
SPDesktop *desktop,
- gchar const *descr,
+ gchar const *ui_file,
gchar const* toolbarName,
gchar const* sizePref )
{
@@ -1204,12 +834,19 @@ static void setupToolboxCommon( GtkWidget *toolbox,
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
GtkUIManager* mgr = gtk_ui_manager_new();
- GError* errVal = 0;
+ GError* err = 0;
GtkOrientation orientation = GTK_ORIENTATION_HORIZONTAL;
gtk_ui_manager_insert_action_group( mgr, mainActions->gobj(), 0 );
- gtk_ui_manager_add_ui_from_string( mgr, descr, -1, &errVal );
+
+ char const *filename = get_filename(UI, ui_file);
+ gtk_ui_manager_add_ui_from_file( mgr, filename, &err );
+ if(err) {
+ g_warning("Failed to load %s: %s", filename, err->message);
+ g_error_free(err);
+ return;
+ }
GtkWidget* toolBar = gtk_ui_manager_get_widget( mgr, toolbarName );
if ( prefs->getBool("/toolbox/icononly", true) ) {
@@ -1313,57 +950,10 @@ void ToolboxFactory::setOrientation(GtkWidget* toolbox, GtkOrientation orientati
void setup_tool_toolbox(GtkWidget *toolbox, SPDesktop *desktop)
{
- gchar const * descr =
- "<ui>"
- " <toolbar name='ToolToolbar'>"
-
- " <!-- Basics -->"
- " <toolitem action='ToolSelector' />"
- " <toolitem action='ToolNode' />"
- " <toolitem action='ToolTweak' />"
- " <toolitem action='ToolZoom' />"
- " <toolitem action='ToolMeasure' />"
-
- " <!-- Shapes -->"
- " <toolitem action='ToolRect' />"
- " <toolitem action='Tool3DBox' />"
- " <toolitem action='ToolArc' />"
- " <toolitem action='ToolStar' />"
- " <toolitem action='ToolSpiral' />"
-
- " <!-- Paths -->"
- " <toolitem action='ToolPencil' />"
- " <toolitem action='ToolPen' />"
- " <toolitem action='ToolCalligraphic' />"
-
- " <!-- Text -->"
- " <toolitem action='ToolText' />"
-
- " <!-- Paint large areas -->"
- " <toolitem action='ToolSpray' />"
- " <toolitem action='ToolEraser' />"
-
-#if HAVE_POTRACE
- " <!-- Fill -->"
- " <toolitem action='ToolPaintBucket' />"
-#endif
-
- " <toolitem action='ToolGradient' />"
-#ifdef WITH_MESH
- " <toolitem action='ToolMesh' />"
-#endif
- " <toolitem action='ToolDropper' />"
-
- " <toolitem action='ToolConnector' />"
-#ifdef WITH_LPETOOL
- " <toolitem action='ToolLPETool' />"
-#endif
- " </toolbar>"
- "</ui>";
-
- setupToolboxCommon( toolbox, desktop, descr,
- "/ui/ToolToolbar",
- "/toolbox/tools/small");
+ setupToolboxCommon( toolbox, desktop,
+ "tool-toolbar.ui",
+ "/ui/ToolToolbar",
+ "/toolbox/tools/small");
}
void update_tool_toolbox( SPDesktop *desktop, ToolBase *eventcontext, GtkWidget * /*toolbox*/ )
@@ -1391,9 +981,16 @@ void setup_aux_toolbox(GtkWidget *toolbox, SPDesktop *desktop)
GtkSizeGroup* grouper = gtk_size_group_new( GTK_SIZE_GROUP_BOTH );
Glib::RefPtr<Gtk::ActionGroup> mainActions = create_or_fetch_actions( desktop );
GtkUIManager* mgr = gtk_ui_manager_new();
- GError* errVal = 0;
+ GError *err = 0;
gtk_ui_manager_insert_action_group( mgr, mainActions->gobj(), 0 );
- gtk_ui_manager_add_ui_from_string( mgr, ui_descr, -1, &errVal );
+
+ char const *filename = get_filename(UI, "select-toolbar.ui");
+ guint ret = gtk_ui_manager_add_ui_from_file(mgr, filename, &err);
+ if(err) {
+ g_warning("Failed to load aux toolbar %s: %s", filename, err->message);
+ g_error_free(err);
+ return;
+ }
std::map<std::string, GtkWidget*> dataHolders;
@@ -1494,49 +1091,10 @@ void update_aux_toolbox(SPDesktop * /*desktop*/, ToolBase *eventcontext, GtkWidg
void setup_commands_toolbox(GtkWidget *toolbox, SPDesktop *desktop)
{
- gchar const * descr =
- "<ui>"
- " <toolbar name='CommandsToolbar'>"
- " <toolitem action='FileNew' />"
- " <toolitem action='FileOpen' />"
- " <toolitem action='FileSave' />"
- " <toolitem action='FilePrint' />"
- " <separator />"
- " <toolitem action='FileImport' />"
- " <toolitem action='DialogExport' />"
- " <separator />"
- " <toolitem action='EditUndo' />"
- " <toolitem action='EditRedo' />"
- " <separator />"
- " <toolitem action='EditCopy' />"
- " <toolitem action='EditCut' />"
- " <toolitem action='EditPaste' />"
- " <separator />"
- " <toolitem action='ZoomSelection' />"
- " <toolitem action='ZoomDrawing' />"
- " <toolitem action='ZoomPage' />"
- " <separator />"
- " <toolitem action='EditDuplicate' />"
- " <toolitem action='EditClone' />"
- " <toolitem action='EditUnlinkClone' />"
- " <separator />"
- " <toolitem action='SelectionGroup' />"
- " <toolitem action='SelectionUnGroup' />"
- " <separator />"
- " <toolitem action='DialogFillStroke' />"
- " <toolitem action='DialogText' />"
- " <toolitem action='DialogLayers' />"
- " <toolitem action='DialogXMLEditor' />"
- " <toolitem action='DialogAlignDistribute' />"
- " <separator />"
- " <toolitem action='DialogDocumentProperties' />"
- " <toolitem action='DialogPreferences' />"
- " </toolbar>"
- "</ui>";
-
- setupToolboxCommon( toolbox, desktop, descr,
- "/ui/CommandsToolbar",
- "/toolbox/small" );
+ setupToolboxCommon( toolbox, desktop,
+ "commands-toolbar.ui",
+ "/ui/CommandsToolbar",
+ "/toolbox/small" );
}
void update_commands_toolbox(SPDesktop * /*desktop*/, ToolBase * /*eventcontext*/, GtkWidget * /*toolbox*/)
@@ -1672,36 +1230,6 @@ void setup_snap_toolbox(GtkWidget *toolbox, SPDesktop *desktop)
{
Glib::RefPtr<Gtk::ActionGroup> mainActions = create_or_fetch_actions(desktop);
- gchar const * descr =
- "<ui>"
- " <toolbar name='SnapToolbar'>"
- " <toolitem action='ToggleSnapGlobal' />"
- " <separator />"
- " <toolitem action='ToggleSnapFromBBoxCorner' />"
- " <toolitem action='ToggleSnapToBBoxPath' />"
- " <toolitem action='ToggleSnapToBBoxNode' />"
- " <toolitem action='ToggleSnapToFromBBoxEdgeMidpoints' />"
- " <toolitem action='ToggleSnapToFromBBoxCenters' />"
- " <separator />"
- " <toolitem action='ToggleSnapFromNode' />"
- " <toolitem action='ToggleSnapToItemPath' />"
- " <toolitem action='ToggleSnapToPathIntersections' />"
- " <toolitem action='ToggleSnapToItemNode' />"
- " <toolitem action='ToggleSnapToSmoothNodes' />"
- " <toolitem action='ToggleSnapToFromLineMidpoints' />"
- " <separator />"
- " <toolitem action='ToggleSnapFromOthers' />"
- " <toolitem action='ToggleSnapToFromObjectCenters' />"
- " <toolitem action='ToggleSnapToFromRotationCenter' />"
- " <toolitem action='ToggleSnapToFromTextBaseline' />"
- " <separator />"
- " <toolitem action='ToggleSnapToPageBorder' />"
- " <toolitem action='ToggleSnapToGrids' />"
- " <toolitem action='ToggleSnapToGuides' />"
- //" <toolitem action='ToggleSnapToGridGuideIntersections' />"
- " </toolbar>"
- "</ui>";
-
Inkscape::IconSize secondarySize = ToolboxFactory::prefToSize("/toolbox/secondary", 1);
{
@@ -1880,9 +1408,10 @@ void setup_snap_toolbox(GtkWidget *toolbox, SPDesktop *desktop)
g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(toggle_snap_callback), toolbox );
}
- setupToolboxCommon( toolbox, desktop, descr,
- "/ui/SnapToolbar",
- "/toolbox/secondary" );
+ setupToolboxCommon( toolbox, desktop,
+ "snap-toolbar.ui",
+ "/ui/SnapToolbar",
+ "/toolbox/secondary" );
}
Glib::ustring ToolboxFactory::getToolboxName(GtkWidget* toolbox)
diff --git a/src/xml/repr-util.cpp b/src/xml/repr-util.cpp
index 4d093a4ea..6da1233db 100644
--- a/src/xml/repr-util.cpp
+++ b/src/xml/repr-util.cpp
@@ -17,13 +17,9 @@
#include "config.h"
-#if HAVE_STRING_H
# include <cstring>
-#endif
-#if HAVE_STDLIB_H
# include <cstdlib>
-#endif
#include <glib.h>