summaryrefslogtreecommitdiffstats
path: root/src/ui
diff options
context:
space:
mode:
authorMartin Owens <doctormo@gmail.com>2017-06-28 07:04:16 +0000
committerMartin Owens <doctormo@gmail.com>2017-06-28 07:04:16 +0000
commitcf457eea72b81850da5503d0091952871135c1fd (patch)
tree3709bcf46a0152434a89ed68bbb343a8d45408dd /src/ui
parentUpdate dxf_input.py for LP Bug #1700582 (diff)
downloadinkscape-cf457eea72b81850da5503d0091952871135c1fd.tar.gz
inkscape-cf457eea72b81850da5503d0091952871135c1fd.zip
Refactor profile directory use and promote IO::Resource get_path and get_filename methods
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/dialog/export.cpp3
-rw-r--r--src/ui/dialog/filedialogimpl-gtkmm.cpp6
-rw-r--r--src/ui/dialog/inkscape-preferences.cpp2
-rw-r--r--src/ui/dialog/swatches.cpp7
-rw-r--r--src/ui/dialog/symbols.cpp17
-rw-r--r--src/ui/dialog/template-load-tab.cpp17
-rw-r--r--src/ui/dialog/template-load-tab.h4
7 files changed, 27 insertions, 29 deletions
diff --git a/src/ui/dialog/export.cpp b/src/ui/dialog/export.cpp
index 1bb952de4..b1b1cc291 100644
--- a/src/ui/dialog/export.cpp
+++ b/src/ui/dialog/export.cpp
@@ -54,6 +54,7 @@
#include "extension/db.h"
#include "io/sys.h"
+#include "io/resource.h"
#include "helper/png-write.h"
@@ -564,7 +565,7 @@ Glib::ustring Export::create_filepath_from_id (Glib::ustring id, const Glib::ust
}
if (directory.empty()) {
- directory = INKSCAPE.homedir_path(NULL);
+ directory = Inkscape::IO::Resource::homedir_path(NULL);
}
Glib::ustring filename = Glib::build_filename(directory, id+".png");
diff --git a/src/ui/dialog/filedialogimpl-gtkmm.cpp b/src/ui/dialog/filedialogimpl-gtkmm.cpp
index 92e9ce834..b69e9ce97 100644
--- a/src/ui/dialog/filedialogimpl-gtkmm.cpp
+++ b/src/ui/dialog/filedialogimpl-gtkmm.cpp
@@ -27,6 +27,7 @@
#include "ui/dialog-events.h"
#include "ui/interface.h"
#include "io/sys.h"
+#include "io/resource.h"
#include "path-prefix.h"
#include "preferences.h"
@@ -1038,13 +1039,12 @@ FileSaveDialogImplGtk::FileSaveDialogImplGtk(Gtk::Window &parentWindow, const Gl
}
// allow easy access to the user's own templates folder
- gchar *templates = Inkscape::Application::profile_path("templates");
+ using namespace Inkscape::IO::Resource;
+ char const *templates = Inkscape::IO::Resource::get_path(USER, TEMPLATES);
if (Inkscape::IO::file_test(templates, G_FILE_TEST_EXISTS) &&
Inkscape::IO::file_test(templates, G_FILE_TEST_IS_DIR) && g_path_is_absolute(templates)) {
add_shortcut_folder(templates);
}
- g_free(templates);
-
// if (extension == NULL)
// checkbox.set_sensitive(FALSE);
diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp
index 646439613..1ad44941f 100644
--- a/src/ui/dialog/inkscape-preferences.cpp
+++ b/src/ui/dialog/inkscape-preferences.cpp
@@ -1947,7 +1947,7 @@ void InkscapePreferences::initPageSystem()
_page_system.add_group_header( _("System info"));
- _sys_user_config.set_text((char const *)Inkscape::Application::profile_path(""));
+ _sys_user_config.set_text((char const *)Inkscape::IO::Resource::profile_path(""));
_sys_user_config.set_editable(false);
_page_system.add_line(true, _("User config: "), _sys_user_config, "", _("Location of users configuration"), true);
diff --git a/src/ui/dialog/swatches.cpp b/src/ui/dialog/swatches.cpp
index 87bfa9252..82b099bd1 100644
--- a/src/ui/dialog/swatches.cpp
+++ b/src/ui/dialog/swatches.cpp
@@ -512,15 +512,16 @@ compare_swatch_names(SwatchPage const *a, SwatchPage const *b) {
static void loadEmUp()
{
+ using namespace Inkscape::IO::Resource;
static bool beenHere = false;
gboolean userPalette = true;
if ( !beenHere ) {
beenHere = true;
std::list<gchar *> sources;
- sources.push_back( Inkscape::Application::profile_path("palettes") );
- sources.push_back( g_strdup(INKSCAPE_PALETTESDIR) );
- sources.push_back( g_strdup(CREATE_PALETTESDIR) );
+ sources.push_back(g_strdup(get_path(USER, PALETTES)));
+ sources.push_back(g_strdup(get_path(SYSTEM, PALETTES)));
+ sources.push_back(g_strdup(get_path(CREATE, PALETTES)));
// Use this loop to iterate through a list of possible document locations.
while (!sources.empty()) {
diff --git a/src/ui/dialog/symbols.cpp b/src/ui/dialog/symbols.cpp
index e9a13620b..b7a43a1ca 100644
--- a/src/ui/dialog/symbols.cpp
+++ b/src/ui/dialog/symbols.cpp
@@ -31,6 +31,7 @@
#include <glibmm/i18n.h>
#include "path-prefix.h"
#include "io/sys.h"
+#include "io/resource.h"
#include "ui/cache/svg_preview_cache.h"
#include "ui/clipboard.h"
@@ -577,19 +578,15 @@ void SymbolsDialog::get_symbols() {
std::list<Glib::ustring> directories;
-// \TODO optimize this
-
- if( Inkscape::IO::file_test( INKSCAPE_SYMBOLSDIR, G_FILE_TEST_EXISTS ) &&
- Inkscape::IO::file_test( INKSCAPE_SYMBOLSDIR, G_FILE_TEST_IS_DIR ) ) {
- directories.push_back( INKSCAPE_SYMBOLSDIR );
- }
- if( Inkscape::IO::file_test( Inkscape::Application::profile_path("symbols"), G_FILE_TEST_EXISTS ) &&
- Inkscape::IO::file_test( Inkscape::Application::profile_path("symbols"), G_FILE_TEST_IS_DIR ) ) {
- directories.push_back( Inkscape::Application::profile_path("symbols") );
- }
+ using namespace Inkscape::IO::Resource;
+ directories.push_back(get_path_ustring(USER, SYMBOLS));
+ directories.push_back(get_path_ustring(SYSTEM, SYMBOLS));
std::list<Glib::ustring>::iterator it;
for( it = directories.begin(); it != directories.end(); ++it ) {
+ if(!Inkscape::IO::file_test((*it).c_str(), G_FILE_TEST_IS_DIR)) {
+ continue;
+ }
GError *err = 0;
GDir *dir = g_dir_open( (*it).c_str(), 0, &err );
diff --git a/src/ui/dialog/template-load-tab.cpp b/src/ui/dialog/template-load-tab.cpp
index 7b96c2b97..10b4716ff 100644
--- a/src/ui/dialog/template-load-tab.cpp
+++ b/src/ui/dialog/template-load-tab.cpp
@@ -24,6 +24,8 @@
#include "file.h"
#include "path-prefix.h"
+using namespace Inkscape::IO::Resource;
+
namespace Inkscape {
namespace UI {
@@ -57,7 +59,6 @@ TemplateLoadTab::TemplateLoadTab(NewFromTemplate* parent)
sigc::mem_fun(*this, &TemplateLoadTab::_keywordSelected));
this->show_all();
- _loading_path = "";
_loadTemplates();
_initLists();
}
@@ -207,11 +208,8 @@ void TemplateLoadTab::_refreshTemplatesList()
void TemplateLoadTab::_loadTemplates()
{
- // user's local dir
- _getTemplatesFromDir(Inkscape::Application::profile_path("templates") + _loading_path);
-
- // system templates dir
- _getTemplatesFromDir(INKSCAPE_TEMPLATESDIR + _loading_path);
+ _getTemplatesFromDomain(USER);
+ _getTemplatesFromDomain(SYSTEM);
// procedural templates
_getProceduralTemplates();
@@ -252,11 +250,12 @@ TemplateLoadTab::TemplateData TemplateLoadTab::_processTemplateFile(const std::s
}
-void TemplateLoadTab::_getTemplatesFromDir(const std::string &path)
+void TemplateLoadTab::_getTemplatesFromDomain(Domain domain)
{
- if ( !Glib::file_test(path, Glib::FILE_TEST_EXISTS) ||
- !Glib::file_test(path, Glib::FILE_TEST_IS_DIR))
+ Glib::ustring path = get_path_ustring(domain, TEMPLATES);
+ if (!Glib::file_test(path, Glib::FILE_TEST_IS_DIR)) {
return;
+ }
Glib::Dir dir(path);
diff --git a/src/ui/dialog/template-load-tab.h b/src/ui/dialog/template-load-tab.h
index d11c4c77f..0a5521d93 100644
--- a/src/ui/dialog/template-load-tab.h
+++ b/src/ui/dialog/template-load-tab.h
@@ -21,6 +21,7 @@
#include <string>
#include "xml/node.h"
+#include "io/resource.h"
#include "extension/effect.h"
@@ -66,7 +67,6 @@ protected:
Glib::ustring _current_keyword;
Glib::ustring _current_template;
- std::string _loading_path;
std::map<Glib::ustring, TemplateData> _tdata;
std::set<Glib::ustring> _keywords;
@@ -100,7 +100,7 @@ private:
void _getDataFromNode(Inkscape::XML::Node *, TemplateData &);
void _getProceduralTemplates();
- void _getTemplatesFromDir(const std::string &);
+ void _getTemplatesFromDomain(Inkscape::IO::Resource::Domain domain);
void _keywordSelected();
TemplateData _processTemplateFile(const std::string &);