summaryrefslogtreecommitdiffstats
path: root/src/extension
diff options
context:
space:
mode:
authorEduard Braun <eduard.braun2@gmx.de>2017-07-09 12:42:10 +0000
committerEduard Braun <eduard.braun2@gmx.de>2017-07-09 12:42:10 +0000
commit241554b7ad311b5868ba284c7a4e6a410432b9bd (patch)
tree8bf6fed572d27e9b97ca60b90ae1684ba4856eeb /src/extension
parentUse .xml when exporting shortcuts by default (diff)
parentShortcuts: Fix for 7d248fbba5b0c24d9a24cda8c3f2e79f96395553 (is_user_set was ... (diff)
downloadinkscape-241554b7ad311b5868ba284c7a4e6a410432b9bd.tar.gz
inkscape-241554b7ad311b5868ba284c7a4e6a410432b9bd.zip
Merge branch 'master' into shortcuts
Diffstat (limited to 'src/extension')
-rw-r--r--src/extension/dependency.cpp12
-rw-r--r--src/extension/error-file.cpp3
-rw-r--r--src/extension/extension.cpp4
-rw-r--r--src/extension/extension.h1
-rw-r--r--src/extension/implementation/script.cpp22
-rw-r--r--src/extension/implementation/xslt.cpp22
-rw-r--r--src/extension/init.cpp77
-rw-r--r--src/extension/internal/cdr-input.cpp1
-rw-r--r--src/extension/internal/filter/filter-file.cpp82
-rw-r--r--src/extension/internal/filter/filter.h2
-rw-r--r--src/extension/internal/pdfinput/pdf-input.cpp1
-rw-r--r--src/extension/internal/vsd-input.cpp1
12 files changed, 46 insertions, 182 deletions
diff --git a/src/extension/dependency.cpp b/src/extension/dependency.cpp
index 837520381..827475011 100644
--- a/src/extension/dependency.cpp
+++ b/src/extension/dependency.cpp
@@ -18,6 +18,7 @@
#include "dependency.h"
#include "db.h"
#include "extension.h"
+#include "io/resource.h"
namespace Inkscape {
namespace Extension {
@@ -151,12 +152,11 @@ bool Dependency::check (void) const
Glib::ustring location(_string);
switch (_location) {
case LOCATION_EXTENSIONS: {
- for (unsigned int i=0; i<Inkscape::Extension::Extension::search_path.size(); i++) {
- std::string temploc = Glib::build_filename(Inkscape::Extension::Extension::search_path[i], location);
- if (Glib::file_test(temploc, filetest)) {
- location = temploc;
- break;
- }
+ using namespace Inkscape::IO::Resource;
+ Glib::ustring temploc = get_filename(EXTENSIONS, location.c_str());
+ if(Glib::file_test(temploc, filetest)) {
+ location = temploc;
+ break;
}
} /* PASS THROUGH!!! */
case LOCATION_ABSOLUTE: {
diff --git a/src/extension/error-file.cpp b/src/extension/error-file.cpp
index 342511ec9..063e43f42 100644
--- a/src/extension/error-file.cpp
+++ b/src/extension/error-file.cpp
@@ -18,6 +18,7 @@
#include "inkscape.h"
#include "preferences.h"
#include "extension/extension.h"
+#include "io/resource.h"
#include "error-file.h"
@@ -51,7 +52,7 @@ ErrorFileNotice::ErrorFileNotice (void) :
// \FIXME change this
/* This is some filler text, needs to change before relase */
Glib::ustring dialog_text(_("<span weight=\"bold\" size=\"larger\">One or more extensions failed to load</span>\n\nThe failed extensions have been skipped. Inkscape will continue to run normally but those extensions will be unavailable. For details to troubleshoot this problem, please refer to the error log located at: "));
- gchar * ext_error_file = Inkscape::Application::profile_path(EXTENSION_ERROR_LOG_FILENAME);
+ gchar * ext_error_file = Inkscape::IO::Resource::log_path(EXTENSION_ERROR_LOG_FILENAME);
dialog_text += ext_error_file;
g_free(ext_error_file);
set_message(dialog_text, true);
diff --git a/src/extension/extension.cpp b/src/extension/extension.cpp
index 497f98431..f1b328f05 100644
--- a/src/extension/extension.cpp
+++ b/src/extension/extension.cpp
@@ -33,13 +33,13 @@
#include "dependency.h"
#include "timer.h"
#include "param/parameter.h"
+#include "io/resource.h"
namespace Inkscape {
namespace Extension {
/* Inkscape::Extension::Extension */
-std::vector<const gchar *> Extension::search_path;
std::ofstream Extension::error_file;
/**
@@ -658,7 +658,7 @@ Extension::set_param_color (const gchar * name, guint32 color, SPDocument * doc,
void
Extension::error_file_open (void)
{
- gchar * ext_error_file = Inkscape::Application::profile_path(EXTENSION_ERROR_LOG_FILENAME);
+ gchar * ext_error_file = Inkscape::IO::Resource::log_path(EXTENSION_ERROR_LOG_FILENAME);
gchar * filename = g_filename_from_utf8( ext_error_file, -1, NULL, NULL, NULL );
error_file.open(filename);
if (!error_file.is_open()) {
diff --git a/src/extension/extension.h b/src/extension/extension.h
index bbd6d068b..962c3c8a7 100644
--- a/src/extension/extension.h
+++ b/src/extension/extension.h
@@ -95,7 +95,6 @@ public:
STATE_UNLOADED, /**< The extension has not been loaded */
STATE_DEACTIVATED /**< The extension is missing something which makes it unusable */
} state_t;
- static std::vector<const gchar *> search_path; /**< A vector of paths to search for extensions */
private:
gchar *id; /**< The unique identifier for the Extension */
diff --git a/src/extension/implementation/script.cpp b/src/extension/implementation/script.cpp
index b1058d415..8da56fecd 100644
--- a/src/extension/implementation/script.cpp
+++ b/src/extension/implementation/script.cpp
@@ -33,6 +33,7 @@
#include "extension/db.h"
#include "inkscape.h"
#include "io/sys.h"
+#include "io/resource.h"
#include "preferences.h"
#include "script.h"
#include "selection.h"
@@ -184,25 +185,8 @@ std::string Script::solve_reldir(Inkscape::XML::Node *reprin) {
Glib::ustring str = reprin->firstChild()->content();
return str;
}
-
- Glib::ustring reldir = s;
- for (unsigned int i=0;
- i < Inkscape::Extension::Extension::search_path.size();
- i++) {
-
- gchar * fname = g_build_filename(
- Inkscape::Extension::Extension::search_path[i],
- reprin->firstChild()->content(),
- NULL);
- Glib::ustring filename = fname;
- g_free(fname);
- //printf("Filename: %s\n", filename.c_str());
- if ( Inkscape::IO::file_test(filename.c_str(), G_FILE_TEST_EXISTS) ) {
- return Glib::filename_from_utf8(filename);
- }
- }
-
- return "";
+ using namespace Inkscape::IO::Resource;
+ return get_filename(EXTENSIONS, reprin->firstChild()->content());
}
diff --git a/src/extension/implementation/xslt.cpp b/src/extension/implementation/xslt.cpp
index 373378d97..94852a98e 100644
--- a/src/extension/implementation/xslt.cpp
+++ b/src/extension/implementation/xslt.cpp
@@ -23,6 +23,7 @@
#include "extension/input.h"
#include "io/sys.h"
+#include "io/resource.h"
#include <unistd.h>
#include <cstring>
#include "document.h"
@@ -62,30 +63,13 @@ Glib::ustring XSLT::solve_reldir(Inkscape::XML::Node *reprin) {
}
Glib::ustring reldir = s;
-
if (reldir == "extensions") {
-
- for (unsigned int i=0;
- i < Inkscape::Extension::Extension::search_path.size();
- i++) {
-
- gchar * fname = g_build_filename(
- Inkscape::Extension::Extension::search_path[i],
- reprin->firstChild()->content(),
- NULL);
- Glib::ustring filename = fname;
- g_free(fname);
-
- if ( Inkscape::IO::file_test(filename.c_str(), G_FILE_TEST_EXISTS) )
- return filename;
-
- }
+ using namespace Inkscape::IO::Resource;
+ return get_filename(EXTENSIONS, reprin->firstChild()->content());
} else {
Glib::ustring str = reprin->firstChild()->content();
return str;
}
-
- return "";
}
bool XSLT::check(Inkscape::Extension::Extension *module)
diff --git a/src/extension/init.cpp b/src/extension/init.cpp
index af7af2cb1..9830b0176 100644
--- a/src/extension/init.cpp
+++ b/src/extension/init.cpp
@@ -60,11 +60,13 @@
#endif
#include "preferences.h"
#include "io/sys.h"
+#include "io/resource.h"
#ifdef WITH_DBUS
#include "dbus/dbus-init.h"
#endif
#ifdef WITH_IMAGE_MAGICK
+#include <Magick++.h>
#include "internal/bitmap/adaptiveThreshold.h"
#include "internal/bitmap/addNoise.h"
#include "internal/bitmap/blur.h"
@@ -106,6 +108,8 @@
#include "init.h"
+using namespace Inkscape::IO::Resource;
+
namespace Inkscape {
namespace Extension {
@@ -113,7 +117,6 @@ namespace Extension {
the extension directory and parsed */
#define SP_MODULE_EXTENSION "inx"
-static void build_module_from_dir(gchar const *dirname);
static void check_extensions();
/**
@@ -150,8 +153,7 @@ update_pref(Glib::ustring const &pref_path,
* Invokes the init routines for internal modules.
*
* This should be a list of all the internal modules that need to initialized. This is just a
- * convinent place to put them. Also, this function calls build_module_from_dir to parse the
- * Inkscape extensions directory.
+ * convinent place to put them.
*/
void
init()
@@ -201,6 +203,8 @@ init()
/* Raster Effects */
#ifdef WITH_IMAGE_MAGICK
+ Magick::InitializeMagick(NULL);
+
Internal::Bitmap::AdaptiveThreshold::init();
Internal::Bitmap::AddNoise::init();
Internal::Bitmap::Blur::init();
@@ -240,17 +244,8 @@ init()
Internal::Filter::Filter::filters_all();
- /* Load search path for extensions */
- if (Inkscape::Extension::Extension::search_path.size() == 0)
- {
- Inkscape::Extension::Extension::search_path.push_back(Inkscape::Application::profile_path("extensions"));
-
- Inkscape::Extension::Extension::search_path.push_back(g_strdup(INKSCAPE_EXTENSIONDIR));
-
- }
-
- for (unsigned int i=0; i<Inkscape::Extension::Extension::search_path.size(); i++) {
- build_module_from_dir(Inkscape::Extension::Extension::search_path[i]);
+ for(auto &filename: get_filenames(EXTENSIONS, {SP_MODULE_EXTENSION})) {
+ build_from_file(filename.c_str());
}
/* this is at the very end because it has several catch-alls
@@ -271,60 +266,6 @@ init()
);
}
-/**
- * \return none
- * \brief This function parses a directory for files of SP_MODULE_EXTENSION
- * type and loads them.
- * \param dirname The directory that should be searched for modules
- *
- * Here is just a basic function that moves through a directory. It looks at every entry, and
- * compares its filename with SP_MODULE_EXTENSION. Of those that pass, build_from_file is called
- * with their filenames.
- */
-static void
-build_module_from_dir(gchar const *dirname)
-{
- if (!dirname) {
- g_warning("%s", _("Null external module directory name. Modules will not be loaded."));
- return;
- }
-
- if (!Glib::file_test(std::string(dirname), Glib::FILE_TEST_EXISTS | Glib::FILE_TEST_IS_DIR)) {
- return;
- }
-
- //# Hopefully doing this the Glib way is portable
-
- GError *err;
- GDir *directory = g_dir_open(dirname, 0, &err);
- if (!directory) {
- gchar *safeDir = Inkscape::IO::sanitizeString(dirname);
- g_warning(_("Modules directory (%s) is unavailable. External modules in that directory will not be loaded."), safeDir);
- g_free(safeDir);
- return;
- }
-
- gchar *filename;
- while ((filename = (gchar *)g_dir_read_name(directory)) != NULL) {
- if (strlen(filename) < strlen(SP_MODULE_EXTENSION)) {
- continue;
- }
-
- if (strcmp(SP_MODULE_EXTENSION, filename + (strlen(filename) - strlen(SP_MODULE_EXTENSION)))) {
- continue;
- }
-
- gchar *pathname = g_build_filename(dirname, filename, (char *) NULL);
- build_from_file(pathname);
- g_free(pathname);
- }
-
- g_dir_close(directory);
-
- return;
-}
-
-
static void
check_extensions_internal(Extension *in_plug, gpointer in_data)
{
diff --git a/src/extension/internal/cdr-input.cpp b/src/extension/internal/cdr-input.cpp
index b94408b36..2b6714908 100644
--- a/src/extension/internal/cdr-input.cpp
+++ b/src/extension/internal/cdr-input.cpp
@@ -40,7 +40,6 @@
typedef libcdr::CDRStringVector RVNGStringVector;
#endif
-#include <gtkmm/alignment.h>
#include <gtkmm/grid.h>
#include <gtkmm/spinbutton.h>
diff --git a/src/extension/internal/filter/filter-file.cpp b/src/extension/internal/filter/filter-file.cpp
index b1993057d..c18879430 100644
--- a/src/extension/internal/filter/filter-file.cpp
+++ b/src/extension/internal/filter/filter-file.cpp
@@ -8,6 +8,7 @@
#include "filter.h"
#include "io/sys.h"
+#include "io/resource.h"
#include "io/inkscapestream.h"
/* Directory includes */
@@ -22,78 +23,26 @@
#include <glibmm/i18n.h>
#include <glibmm/fileutils.h>
+using namespace Inkscape::IO::Resource;
+
namespace Inkscape {
namespace Extension {
namespace Internal {
namespace Filter {
-void Filter::filters_all_files(void)
-{
- gchar *filtersProfilePath = Inkscape::Application::profile_path("filters");
-
- filters_load_dir(INKSCAPE_FILTERDIR, _("Bundled"));
- filters_load_dir(filtersProfilePath, _("Personal"));
-
- g_free(filtersProfilePath);
- filtersProfilePath = 0;
-}
-
-#define INKSCAPE_FILTER_FILE ".svg"
-
void
-Filter::filters_load_dir (gchar const * dirname, gchar * menuname)
+filters_load_file (Glib::ustring filename, gchar * menuname)
{
- if (!dirname) {
- g_warning("%s", _("Null external module directory name. Filters will not be loaded."));
- return;
- }
-
- if (!Glib::file_test(std::string(dirname), Glib::FILE_TEST_EXISTS | Glib::FILE_TEST_IS_DIR)) {
- return;
- }
-
- GError *err;
- GDir *directory = g_dir_open(dirname, 0, &err);
- if (!directory) {
- gchar *safeDir = Inkscape::IO::sanitizeString(dirname);
- g_warning(_("Modules directory (%s) is unavailable. External modules in that directory will not be loaded."), safeDir);
- g_free(safeDir);
- return;
- }
-
- gchar *filename;
- while ((filename = (gchar *)g_dir_read_name(directory)) != NULL) {
- if (strlen(filename) < strlen(INKSCAPE_FILTER_FILE)) {
- continue;
- }
-
- if (strcmp(INKSCAPE_FILTER_FILE, filename + (strlen(filename) - strlen(INKSCAPE_FILTER_FILE)))) {
- continue;
- }
-
- gchar *pathname = g_build_filename(dirname, filename, NULL);
- filters_load_file(pathname, menuname);
- g_free(pathname);
- }
-
- g_dir_close(directory);
-
- return;
-}
-
-void
-Filter::filters_load_file (gchar * filename, gchar * menuname)
-{
- Inkscape::XML::Document *doc = sp_repr_read_file(filename, INKSCAPE_EXTENSION_URI);
+ Inkscape::XML::Document *doc = sp_repr_read_file(filename.c_str(), INKSCAPE_EXTENSION_URI);
if (doc == NULL) {
- g_warning("File (%s) is not parseable as XML. Ignored.", filename);
+ g_warning("File (%s) is not parseable as XML. Ignored.", filename.c_str());
return;
}
Inkscape::XML::Node * root = doc->root();
if (strcmp(root->name(), "svg:svg")) {
Inkscape::GC::release(doc);
- g_warning("File (%s) is not SVG. Ignored.", filename);
+ g_warning("File (%s) is not SVG. Ignored.", filename.c_str());
return;
}
@@ -103,7 +52,7 @@ Filter::filters_load_file (gchar * filename, gchar * menuname)
for (Inkscape::XML::Node * defs = child->firstChild();
defs != NULL; defs = defs->next()) {
if (!strcmp(defs->name(), "svg:filter")) {
- filters_load_node(defs, menuname);
+ Filter::filters_load_node(defs, menuname);
} // oh! a filter
} //defs
} // is defs
@@ -113,6 +62,17 @@ Filter::filters_load_file (gchar * filename, gchar * menuname)
return;
}
+void Filter::filters_all_files(void)
+{
+ for(auto &filename: get_filenames(USER, FILTERS, {".svg"})) {
+ filters_load_file(filename, _("Personal"));
+ }
+ for(auto &filename: get_filenames(SYSTEM, FILTERS, {".svg"})) {
+ filters_load_file(filename, _("Bundled"));
+ }
+}
+
+
#include "extension/internal/clear-n_.h"
class mywriter : public Inkscape::IO::BasicWriter {
@@ -149,8 +109,8 @@ Filter::filters_load_node (Inkscape::XML::Node * node, gchar * menuname)
"<object-type>all</object-type>\n"
"<effects-menu>\n"
"<submenu name=\"" N_("Filters") "\">\n"
- "<submenu name=\"%s\"/>\n"
- "</submenu>\n"
+ "<submenu name=\"%s\"/>\n"
+ "</submenu>\n"
"</effects-menu>\n"
"<menu-tip>%s</menu-tip>\n"
"</effect>\n"
diff --git a/src/extension/internal/filter/filter.h b/src/extension/internal/filter/filter.h
index 9aaa84aec..8fa086b69 100644
--- a/src/extension/internal/filter/filter.h
+++ b/src/extension/internal/filter/filter.h
@@ -53,8 +53,6 @@ public:
/* File loader related */
static void filters_all_files(void);
- static void filters_load_dir(gchar const * filename, gchar * menuname);
- static void filters_load_file(gchar * filename, gchar * menuname);
static void filters_load_node(Inkscape::XML::Node * node, gchar * menuname);
};
diff --git a/src/extension/internal/pdfinput/pdf-input.cpp b/src/extension/internal/pdfinput/pdf-input.cpp
index 2ee713085..844d16c17 100644
--- a/src/extension/internal/pdfinput/pdf-input.cpp
+++ b/src/extension/internal/pdfinput/pdf-input.cpp
@@ -31,7 +31,6 @@
#include <poppler/glib/poppler-page.h>
#endif
-#include <gtkmm/alignment.h>
#include <gtkmm/checkbutton.h>
#include <gtkmm/comboboxtext.h>
#include <gtkmm/drawingarea.h>
diff --git a/src/extension/internal/vsd-input.cpp b/src/extension/internal/vsd-input.cpp
index c1cfb5cc6..0d7a467f0 100644
--- a/src/extension/internal/vsd-input.cpp
+++ b/src/extension/internal/vsd-input.cpp
@@ -40,7 +40,6 @@
typedef libvisio::VSDStringVector RVNGStringVector;
#endif
-#include <gtkmm/alignment.h>
#include <gtkmm/spinbutton.h>
#include "extension/system.h"