Code

Clear the mssage context after drag filling
[inkscape.git] / src / io / resource.cpp
1 /** \file
2  * Inkscape::IO::Resource - simple resource API
3  *
4  * Copyright 2006 MenTaLguY <mental@rydia.net>
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * See the file COPYING for details.
12  *
13  */
15 #ifdef HAVE_CONFIG_H
16 #include "config.h"
17 #endif
19 #include <glib/gmessages.h>
20 #include <glib/gstrfuncs.h>
21 #include <glib/gfileutils.h>
22 #include "path-prefix.h"
23 #include "inkscape.h"
24 #include "io/resource.h"
26 namespace Inkscape {
28 namespace IO {
30 namespace Resource {
32 Util::ptr_shared<char> get_path(Domain domain, Type type, char const *filename)
33 {
34     gchar *path=NULL;
35     switch (domain) {
36         case SYSTEM: {
37             gchar const* temp = 0;
38             switch (type) {
39                 case APPICONS: temp = INKSCAPE_APPICONDIR; break;
40                 case EXTENSIONS: temp = INKSCAPE_EXTENSIONDIR; break;
41                 case GRADIENTS: temp = INKSCAPE_GRADIENTSDIR; break;
42                 case ICONS: temp = INKSCAPE_PIXMAPDIR; break;
43                 case KEYS: temp = INKSCAPE_KEYSDIR; break;
44                 case MARKERS: temp = INKSCAPE_MARKERSDIR; break;
45                 case PALETTES: temp = INKSCAPE_PALETTESDIR; break;
46                 case PATTERNS: temp = INKSCAPE_PATTERNSDIR; break;
47                 case PLUGINS: temp = INKSCAPE_PLUGINDIR; break;
48                 case SCREENS: temp = INKSCAPE_SCREENSDIR; break;
49                 case TEMPLATES: temp = INKSCAPE_TEMPLATESDIR; break;
50                 case TUTORIALS: temp = INKSCAPE_TUTORIALSDIR; break;
51                 case UI: temp = INKSCAPE_UIDIR; break;
52                 default: g_assert_not_reached();
53             }
54             path = g_strdup(temp);
55         } break;
56         case CREATE: {
57             gchar const* temp = 0;
58             switch (type) {
59                 case GRADIENTS: temp = CREATE_GRADIENTSDIR; break;
60                 case PALETTES: temp = CREATE_PALETTESDIR; break;
61                 case PATTERNS: temp = CREATE_PATTERNSDIR; break;
62                 default: g_assert_not_reached();
63             }
64             path = g_strdup(temp);
65         } break;
66         case USER: {
67             char const *name=NULL;
68             switch (type) {
69                 case EXTENSIONS: name = "extensions"; break;
70                 case GRADIENTS: name = "gradients"; break;
71                 case ICONS: name = "icons"; break;
72                 case KEYS: name = "keys"; break;
73                 case MARKERS: name = "markers"; break;
74                 case PALETTES: name = "palettes"; break;
75                 case PATTERNS: name = "patterns"; break;
76                 case PLUGINS: name = "plugins"; break;
77                 case TEMPLATES: name = "templates"; break;
78                 default: return get_path(SYSTEM, type, filename);
79             }
80             path = profile_path(name);
81         } break;
82     }
84     if (filename) {
85         gchar *temp=g_build_filename(path, filename, NULL);
86         g_free(path);
87         path = temp;
88     }
90     Util::ptr_shared<char> result=Util::share_string(path);
91     g_free(path);
92     return result;
93 }
95 }
97 }
99 }
101 /*
102   Local Variables:
103   mode:c++
104   c-file-style:"stroustrup"
105   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
106   indent-tabs-mode:nil
107   fill-column:99
108   End:
109 */
110 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :