From c6627256555b3356238e57ffd749c413d28e8a3c Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Wed, 14 Jun 2017 19:40:37 -0400 Subject: Remove duplicated build checks. Most of these #defines are not even checked anyway, though they could have the side-effect of failing configure before the build started. However, these checks are redundant due to other checks for the same thing: * concept_check.hpp was added to Boost in 1.19.0, released in 2000. I sincerely doubt anyone is using that version right now, but I added a minimum version to the find_package() call. In any case, no code actually checked the #define, so it wouldn't have built without it anyway. * FindBoehmGC puts gc.h on the compiler search path, so there's no need to try gc/gc.h also. * libintl.h is found by FindIntl. * unordered_set is part of the C++11 standard. * zlib.h is found by find_package(ZLIB). --- src/inkgc/gc-core.h | 4 ---- src/util/ege-tags.cpp | 2 -- src/widgets/ege-paint-def.cpp | 2 -- 3 files changed, 8 deletions(-) (limited to 'src') 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 #include -#ifdef HAVE_GC_GC_H -# include -#else # include -#endif namespace Inkscape { namespace GC { 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 -#endif // HAVE_LIBINTL_H #if !defined(_) #define _(s) gettext(s) 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 -#endif #include #include -- cgit v1.2.3 From a3393654f6ec49e012f9c79e7350a087340c4468 Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Wed, 14 Jun 2017 19:54:38 -0400 Subject: Remove cmake checks for C89 headers. These are roughly equivalent to autoconf's AC_HEADER_STDC and even they say that macro is obsolescent. strings.h is not really a C89 header, but it defined some things that are no longer needed [1]. And no file actually #includes it. [1] https://stackoverflow.com/a/4291328 --- src/trace/trace.h | 2 -- src/xml/repr-util.cpp | 4 ---- 2 files changed, 6 deletions(-) (limited to 'src') 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 -#endif #include #include 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 -#endif -#if HAVE_STDLIB_H # include -#endif #include -- cgit v1.2.3 From 1a66c0aae0da7c3b860d06e72f5ff87f444bc462 Mon Sep 17 00:00:00 2001 From: Eduard Braun Date: Thu, 15 Jun 2017 18:12:00 +0200 Subject: Improve Windows relocation support. Remove a lot of unused / overly compicated path manipulation functions and replace them with a solution that also handles the case where inkscape.exe is located in a /bin subdirectory. --- src/prefix.cpp | 66 +++++++++------------------------------------------------- src/prefix.h | 5 ++--- 2 files changed, 12 insertions(+), 59 deletions(-) (limited to 'src') diff --git a/src/prefix.cpp b/src/prefix.cpp index 4e2204cff..cf0f752d2 100644 --- a/src/prefix.cpp +++ b/src/prefix.cpp @@ -419,72 +419,26 @@ 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 -#include - -/** - * 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 + * Gets the directory where folders like "lib" and "share" are located and appends a relative path + * Handles the case where inkscape.exe is located in a "bin" subfolder as well */ -static Glib::ustring win32_getDataDir() +char *win32_append_module_path(const char *relative_path) { - 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) -{ - Glib::ustring dir = win32_getDataDir(); - if (childPath.size() > 0) - { - dir += "\\"; - dir += childPath; - } - return dir; -} + if (!relative_path) { + relative_path = ""; + } + gchar *module_path = g_win32_get_package_installation_directory_of_module(NULL); + gchar *return_path = g_build_filename(module_path, relative_path, NULL); + g_free(module_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 return_path; } #endif /* __WIN32__ */ diff --git a/src/prefix.h b/src/prefix.h index 7c5a1fd3c..fc01fd7ea 100644 --- a/src/prefix.h +++ b/src/prefix.h @@ -122,10 +122,9 @@ char *br_extract_prefix(const char *path); #include -Glib::ustring win32_getExePath(); -char *win32_relative_path(const char *childPath); +char *win32_append_module_path(const char *relative_path); -#define WIN32_DATADIR(suffix) (win32_relative_path(suffix)) +#define WIN32_DATADIR(suffix) (win32_append_module_path(suffix)) #endif -- cgit v1.2.3 From d46bd5b844d666d174fcd2167fb787f244d4b9f9 Mon Sep 17 00:00:00 2001 From: Eduard Braun Date: Thu, 15 Jun 2017 19:19:11 +0200 Subject: cleanup --- src/prefix.h | 5 ----- 1 file changed, 5 deletions(-) (limited to 'src') diff --git a/src/prefix.h b/src/prefix.h index fc01fd7ea..da1295986 100644 --- a/src/prefix.h +++ b/src/prefix.h @@ -119,13 +119,8 @@ char *br_extract_prefix(const char *path); #endif /* __cplusplus */ #ifdef __WIN32__ - -#include - char *win32_append_module_path(const char *relative_path); - #define WIN32_DATADIR(suffix) (win32_append_module_path(suffix)) - #endif #endif /* _PREFIX_H_ */ -- cgit v1.2.3 From 2cf0d896e314d46767ec2c0f7e2734473f523490 Mon Sep 17 00:00:00 2001 From: Eduard Braun Date: Thu, 15 Jun 2017 21:45:48 +0200 Subject: Refactor 1a66c0aae0da7c3b860d06e72f5ff87f444bc462 and allow to use a different data directory by setting the environment variable INKSCAPE_DATADIR at runtime --- src/path-prefix.h | 32 ++++++++++++++++---------------- src/prefix.cpp | 27 +++++++++++++++++++-------- src/prefix.h | 6 ++++-- 3 files changed, 39 insertions(+), 26 deletions(-) (limited to 'src') 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 cf0f752d2..c8bf7abec 100644 --- a/src/prefix.cpp +++ b/src/prefix.cpp @@ -425,20 +425,31 @@ br_extract_prefix (const char *path) */ /** - * Gets the directory where folders like "lib" and "share" are located and appends a relative path - * Handles the case where inkscape.exe is located in a "bin" subfolder as well + * 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 */ -char *win32_append_module_path(const char *relative_path) +char *win32_append_datadir(const char *relative_path) { + 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); + } + } + if (!relative_path) { relative_path = ""; } - gchar *module_path = g_win32_get_package_installation_directory_of_module(NULL); - gchar *return_path = g_build_filename(module_path, relative_path, NULL); - g_free(module_path); - - return return_path; + return g_build_filename(datadir, relative_path, NULL); } #endif /* __WIN32__ */ diff --git a/src/prefix.h b/src/prefix.h index da1295986..d28e896d0 100644 --- a/src/prefix.h +++ b/src/prefix.h @@ -119,8 +119,10 @@ char *br_extract_prefix(const char *path); #endif /* __cplusplus */ #ifdef __WIN32__ -char *win32_append_module_path(const char *relative_path); -#define WIN32_DATADIR(suffix) (win32_append_module_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_ */ -- cgit v1.2.3 From 23e929240ea0e2d5ec5c84c1ba37ce4b99ed34c8 Mon Sep 17 00:00:00 2001 From: Martin Owens Date: Wed, 14 Jun 2017 21:20:41 -0400 Subject: Use user interface files for the user interface --- src/io/resource.cpp | 36 ++++++++++++++++++++++++++++++++++-- src/io/resource.h | 2 ++ src/widgets/toolbox.cpp | 20 +++++++++++++++++--- 3 files changed, 53 insertions(+), 5 deletions(-) (limited to 'src') 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 // 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 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 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 get_path(Domain domain, Type type, char const *filename) path = temp; } + return path; +} + +Util::ptr_shared get_path(Domain domain, Type type, char const *filename) +{ + char *path = _get_path(domain, type, filename); Util::ptr_shared 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 get_filename(Type type, char const *filename) +{ + Util::ptr_shared 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 get_path(Domain domain, Type type, char const *filename=NULL); +Util::ptr_shared get_filename(Type type, char const *filename=NULL); + } } diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index 016eafdaa..3f595dd35 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); @@ -1209,7 +1212,15 @@ static void setupToolboxCommon( GtkWidget *toolbox, 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 ); + + // This isn't good, but it is flexible. + if(descr[0] == '<') { + gtk_ui_manager_add_ui_from_string( mgr, descr, -1, &errVal ); + } else { + char const *filename = get_filename(UI, descr); + gtk_ui_manager_add_ui_from_file( mgr, filename, &errVal ); + g_warning("RET CODE: %d", errVal); + } GtkWidget* toolBar = gtk_ui_manager_get_widget( mgr, toolbarName ); if ( prefs->getBool("/toolbox/icononly", true) ) { @@ -1313,12 +1324,14 @@ void ToolboxFactory::setOrientation(GtkWidget* toolbox, GtkOrientation orientati void setup_tool_toolbox(GtkWidget *toolbox, SPDesktop *desktop) { - gchar const * descr = + gchar const * descr = "tool-toolbar.ui"; + /* "" " " " " " " + " " " " " " " " @@ -1360,6 +1373,7 @@ void setup_tool_toolbox(GtkWidget *toolbox, SPDesktop *desktop) #endif " " ""; +*/ setupToolboxCommon( toolbox, desktop, descr, "/ui/ToolToolbar", -- cgit v1.2.3 From ee36458b5c235d13d30ae8e16a5be44415fe0dfb Mon Sep 17 00:00:00 2001 From: Martin Owens Date: Thu, 15 Jun 2017 13:15:06 -0400 Subject: Cleanup old xml --- src/widgets/toolbox.cpp | 59 ++++--------------------------------------------- 1 file changed, 4 insertions(+), 55 deletions(-) (limited to 'src') diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index 3f595dd35..846321c71 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -1219,7 +1219,6 @@ static void setupToolboxCommon( GtkWidget *toolbox, } else { char const *filename = get_filename(UI, descr); gtk_ui_manager_add_ui_from_file( mgr, filename, &errVal ); - g_warning("RET CODE: %d", errVal); } GtkWidget* toolBar = gtk_ui_manager_get_widget( mgr, toolbarName ); @@ -1324,60 +1323,10 @@ void ToolboxFactory::setOrientation(GtkWidget* toolbox, GtkOrientation orientati void setup_tool_toolbox(GtkWidget *toolbox, SPDesktop *desktop) { - gchar const * descr = "tool-toolbar.ui"; - /* - "" - " " - - " " - " " - " " - " " - " " - " " - " " - - " " - " " - " " - " " - " " - " " - - " " - " " - " " - " " - - " " - " " - - " " - " " - " " - -#if HAVE_POTRACE - " " - " " -#endif - - " " -#ifdef WITH_MESH - " " -#endif - " " - - " " -#ifdef WITH_LPETOOL - " " -#endif - " " - ""; -*/ - - 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*/ ) -- cgit v1.2.3 From 57be02b6e23a06a2d5e3a1a26655ec0003841469 Mon Sep 17 00:00:00 2001 From: Martin Owens Date: Thu, 15 Jun 2017 22:08:04 -0400 Subject: Complete to move to using ui files instead of compiled in xml --- src/widgets/toolbox.cpp | 493 +++--------------------------------------------- 1 file changed, 23 insertions(+), 470 deletions(-) (limited to 'src') diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index 846321c71..671689716 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -225,390 +225,6 @@ static struct { { NULL, NULL, NULL, NULL, NULL, SP_VERB_INVALID, NULL, NULL } }; -static gchar const * ui_descr = - "" - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - - " " - " " - " " - " " - " " - " " - " " - " " - - " " - " " - " " - " " - " " - - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - -#if HAVE_POTRACE - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " -#endif - - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - - " " - " " - " " - " " - " " - " " -// " " -// " " -// " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - - " " - " " - " " - " " - " " - - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - - "" -; static Glib::RefPtr create_or_fetch_actions( SPDesktop* desktop ); @@ -1199,7 +815,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 ) { @@ -1207,18 +823,17 @@ 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 ); - // This isn't good, but it is flexible. - if(descr[0] == '<') { - gtk_ui_manager_add_ui_from_string( mgr, descr, -1, &errVal ); - } else { - char const *filename = get_filename(UI, descr); - gtk_ui_manager_add_ui_from_file( mgr, filename, &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); + return; } GtkWidget* toolBar = gtk_ui_manager_get_widget( mgr, toolbarName ); @@ -1354,9 +969,15 @@ void setup_aux_toolbox(GtkWidget *toolbox, SPDesktop *desktop) GtkSizeGroup* grouper = gtk_size_group_new( GTK_SIZE_GROUP_BOTH ); Glib::RefPtr 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); + return; + } std::map dataHolders; @@ -1457,49 +1078,10 @@ void update_aux_toolbox(SPDesktop * /*desktop*/, ToolBase *eventcontext, GtkWidg void setup_commands_toolbox(GtkWidget *toolbox, SPDesktop *desktop) { - gchar const * descr = - "" - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - ""; - - 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*/) @@ -1635,36 +1217,6 @@ void setup_snap_toolbox(GtkWidget *toolbox, SPDesktop *desktop) { Glib::RefPtr mainActions = create_or_fetch_actions(desktop); - gchar const * descr = - "" - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - " " - //" " - " " - ""; - Inkscape::IconSize secondarySize = ToolboxFactory::prefToSize("/toolbox/secondary", 1); { @@ -1843,9 +1395,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) -- cgit v1.2.3 From 3821d895efa6b20ade67292fd9f6732b695d9fe3 Mon Sep 17 00:00:00 2001 From: Martin Owens Date: Fri, 16 Jun 2017 07:18:39 -0400 Subject: Fix err leaking and cmake --- src/widgets/toolbox.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index 671689716..45f81ee81 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -833,6 +833,7 @@ static void setupToolboxCommon( GtkWidget *toolbox, 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; } @@ -976,6 +977,7 @@ void setup_aux_toolbox(GtkWidget *toolbox, SPDesktop *desktop) 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; } -- cgit v1.2.3 From 67bf524361882fb368175d3455620f5edc15d218 Mon Sep 17 00:00:00 2001 From: Martin Owens Date: Fri, 16 Jun 2017 10:29:04 -0400 Subject: Attempt to make paintbucket build option not cause errors for toolbar loading --- src/widgets/toolbox.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src') diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index 45f81ee81..65c54f0ce 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -156,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 }, @@ -221,6 +224,8 @@ 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 } }; @@ -614,6 +619,12 @@ static Glib::RefPtr 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 act = Gtk::Action::create(Glib::ustring(tools[i].data_name)); + act->set_sensitive(false); + mainActions->add(act); } } } -- cgit v1.2.3