summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: c07546a)
raw | patch | inline | side by side (parent: c07546a)
author | mental <mental@users.sourceforge.net> | |
Thu, 6 Apr 2006 03:34:45 +0000 (03:34 +0000) | ||
committer | mental <mental@users.sourceforge.net> | |
Thu, 6 Apr 2006 03:34:45 +0000 (03:34 +0000) |
ChangeLog | patch | blob | history | |
src/io/Makefile_insert | patch | blob | history | |
src/io/resource.cpp | [new file with mode: 0644] | patch | blob |
src/io/resource.h | [new file with mode: 0644] | patch | blob |
src/path-prefix.h | patch | blob | history |
diff --git a/ChangeLog b/ChangeLog
index c4e4df38547e1d1e0da40f5f65418011b0df7f78..c604ebde817829942e28d76a680ed6c71f57ec78 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
-2005-04-05 Jon A. Cruz <jon@joncruz.org>
+2006-04-05 MenTaLguY <mental@rydia.net>
+
+ * src/io/Makefile_insert, src/io/resource.cpp, src/io/resource.h:
+
+ introduce uniform resource path API to replace copy-and-pasted hacks
+
+2006-04-05 Jon A. Cruz <jon@joncruz.org>
* src/svg/svg-color-test.h, src/svg/svg-color.cpp:
Tuned icc-color() parsing.
-2005-04-02 Jon A. Cruz <jon@joncruz.org>
+2006-04-02 Jon A. Cruz <jon@joncruz.org>
* src/color-profile.h, src/color-profile.cpp,
src/color-profile-fns.h, src/sp-image.h, src/sp-image.cpp:
Initial support of color-profile on <image> elements.
-2005-04-02 Jon A. Cruz <jon@joncruz.org>
+2006-04-02 Jon A. Cruz <jon@joncruz.org>
* src/color-profile.h, src/color-profile.cpp,
src/color-profile-fns.h, src/Makefile_insert, src/attributes.cpp,
Adding support for <color-profile> element.
-2005-04-02 Jon A. Cruz <jon@joncruz.org>
+2006-04-02 Jon A. Cruz <jon@joncruz.org>
* src/knot.h: Fixed warning messages.
diff --git a/src/io/Makefile_insert b/src/io/Makefile_insert
index 57978d67842176e8ef0f39a80343daf91e51ee6d..f575b6e8ded84880b1c3a295f7e4b8de7456339f 100644 (file)
--- a/src/io/Makefile_insert
+++ b/src/io/Makefile_insert
io/gzipstream.h \
io/inkscapestream.cpp \
io/inkscapestream.h \
+ io/resource.cpp \
+ io/resource.h \
io/simple-sax.cpp \
io/simple-sax.h \
io/stringstream.cpp \
diff --git a/src/io/resource.cpp b/src/io/resource.cpp
--- /dev/null
+++ b/src/io/resource.cpp
@@ -0,0 +1,99 @@
+/** \file
+ * Inkscape::IO::Resource - simple resource API
+ *
+ * Copyright 2006 MenTaLguY <mental@rydia.net>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * See the file COPYING for details.
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <glib/gmessages.h>
+#include <glib/gstrfuncs.h>
+#include <glib/gfileutils.h>
+#include "path-prefix.h"
+#include "inkscape.h"
+#include "io/resource.h"
+
+namespace Inkscape {
+
+namespace IO {
+
+namespace Resource {
+
+Util::ptr_shared<char> get_path(Domain domain, Type type, char const *filename)
+{
+ gchar *path=NULL;
+ switch (domain) {
+ case SYSTEM: {
+ switch (type) {
+ case APPICONS: path = INKSCAPE_APPICONDIR; break;
+ case EXTENSIONS: path = INKSCAPE_EXTENSIONDIR; break;
+ case GRADIENTS: path = INKSCAPE_GRADIENTSDIR; break;
+ case ICONS: path = INKSCAPE_PIXMAPDIR; break;
+ case KEYS: path = INKSCAPE_KEYSDIR; break;
+ case MARKERS: path = INKSCAPE_MARKERSDIR; break;
+ case PALETTES: path = INKSCAPE_PALETTESDIR; break;
+ case PATTERNS: path = INKSCAPE_PATTERNSDIR; break;
+ case PLUGINS: path = INKSCAPE_PLUGINDIR; break;
+ case SCREENS: path = INKSCAPE_SCREENSDIR; break;
+ case TEMPLATES: path = INKSCAPE_TEMPLATESDIR; break;
+ case TUTORIALS: path = INKSCAPE_TUTORIALSDIR; break;
+ case UI: path = INKSCAPE_UIDIR; break;
+ default: g_assert_not_reached();
+ }
+ path = g_strdup(path);
+ } break;
+ case USER: {
+ char const *name=NULL;
+ switch (type) {
+ case EXTENSIONS: name = "extensions"; break;
+ case GRADIENTS: name = "gradients"; break;
+ case ICONS: name = "icons"; break;
+ case KEYS: name = "keys"; break;
+ case MARKERS: name = "markers"; break;
+ case PALETTES: name = "palettes"; break;
+ case PATTERNS: name = "patterns"; break;
+ case PLUGINS: name = "plugins"; break;
+ case TEMPLATES: name = "templates"; break;
+ default: return get_path(SYSTEM, type, filename);
+ }
+ path = profile_path(name);
+ } break;
+ }
+
+ if (filename) {
+ gchar *temp=g_build_filename(path, filename, NULL);
+ g_free(path);
+ path = temp;
+ }
+
+ Util::ptr_shared<char> result=Util::share_string(path);
+ g_free(path);
+ return result;
+}
+
+}
+
+}
+
+}
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
diff --git a/src/io/resource.h b/src/io/resource.h
--- /dev/null
+++ b/src/io/resource.h
@@ -0,0 +1,66 @@
+/** \file
+ * Inkscape::IO::Resource - simple resource API
+ *
+ * Copyright 2006 MenTaLguY <mental@rydia.net>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * See the file COPYING for details.
+ *
+ */
+
+#ifndef SEEN_INKSCAPE_IO_RESOURCE_H
+#define SEEN_INKSCAPE_IO_RESOURCE_H
+
+#include "util/share.h"
+
+namespace Inkscape {
+
+namespace IO {
+
+namespace Resource {
+
+enum Type {
+ APPICONS,
+ EXTENSIONS,
+ GRADIENTS,
+ ICONS,
+ KEYS,
+ MARKERS,
+ PALETTES,
+ PATTERNS,
+ PLUGINS,
+ SCREENS,
+ TEMPLATES,
+ TUTORIALS,
+ UI
+};
+
+enum Domain {
+ SYSTEM,
+ USER
+};
+
+Util::ptr_shared<char> get_path(Domain domain, Type type,
+ char const *filename=NULL);
+
+}
+
+}
+
+}
+
+#endif
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
diff --git a/src/path-prefix.h b/src/path-prefix.h
index 89bc6309cd5d7adb2ea9f49353eed34f2cdf883d..00862917f19197cacd71dd6fa429203a85b7c24a 100644 (file)
--- a/src/path-prefix.h
+++ b/src/path-prefix.h
# define INKSCAPE_APPICONDIR BR_DATADIR( "/pixmaps" )
# define INKSCAPE_EXTENSIONDIR BR_DATADIR( "/inkscape/extensions" )
# define INKSCAPE_GRADIENTSDIR BR_DATADIR( "/inkscape/gradients" )
+# define INKSCAPE_KEYSDIR BR_DATADIR( "/inkscape/keys" )
# define INKSCAPE_PIXMAPDIR BR_DATADIR( "/inkscape/icons" )
# define INKSCAPE_MARKERSDIR BR_DATADIR( "/inkscape/markers" )
# define INKSCAPE_PALETTESDIR BR_DATADIR( "/inkscape/palettes" )
# define INKSCAPE_APPICONDIR "pixmaps"
# define INKSCAPE_EXTENSIONDIR "share\\extensions"
# define INKSCAPE_GRADIENTSDIR "share\\gradients"
+# define INKSCAPE_KEYSDIR "share\\keys"
# define INKSCAPE_PIXMAPDIR "share\\icons"
# define INKSCAPE_MARKERSDIR "share\\markers"
# define INKSCAPE_PALETTESDIR "share\\palettes"
# define INKSCAPE_APPICONDIR "Contents/Resources/pixmaps"
# define INKSCAPE_EXTENSIONDIR "Contents/Resources/extensions"
# define INKSCAPE_GRADIENTSDIR "Contents/Resources/gradients"
+# define INKSCAPE_KEYSDIR "Contents/Resources/keys"
# define INKSCAPE_PIXMAPDIR "Contents/Resources/icons"
# define INKSCAPE_MARKERSDIR "Contents/Resources/markers"
# define INKSCAPE_PALETTESDIR "Contents/Resources/palettes"
# define INKSCAPE_APPICONDIR INKSCAPE_DATADIR "/pixmaps"
# define INKSCAPE_EXTENSIONDIR INKSCAPE_DATADIR "/inkscape/extensions"
# define INKSCAPE_GRADIENTSDIR INKSCAPE_DATADIR "/inkscape/gradients"
+# define INKSCAPE_KEYSDIR INKSCAPE_DATADIR "/inkscape/keys"
# define INKSCAPE_PIXMAPDIR INKSCAPE_DATADIR "/inkscape/icons"
# define INKSCAPE_MARKERSDIR INKSCAPE_DATADIR "/inkscape/markers"
# define INKSCAPE_PALETTESDIR INKSCAPE_DATADIR "/inkscape/palettes"