diff options
author | rathnor <rathnor> | 2003-11-16 22:33:56 (GMT) |
---|---|---|
committer | rathnor <rathnor> | 2003-11-16 22:33:56 (GMT) |
commit | c8d1e5491bf5ca9b7e3a7d16780faebb4a40793e (patch) | |
tree | 13bc7e69b0cefaa870c2cfd14ff61843e833b451 /src | |
parent | 7a3bc3df9ae14fda35f40b5fbf6d059c392c6a26 (diff) | |
download | fluxbox_paul-c8d1e5491bf5ca9b7e3a7d16780faebb4a40793e.zip fluxbox_paul-c8d1e5491bf5ca9b7e3a7d16780faebb4a40793e.tar.bz2 |
add better theme path searching
Diffstat (limited to 'src')
-rw-r--r-- | src/FbTk/Image.cc | 6 | ||||
-rw-r--r-- | src/FbTk/Image.hh | 4 | ||||
-rw-r--r-- | src/FbTk/Theme.cc | 40 | ||||
-rw-r--r-- | src/FbTk/Theme.hh | 4 | ||||
-rw-r--r-- | src/Screen.cc | 5 |
5 files changed, 50 insertions, 9 deletions
diff --git a/src/FbTk/Image.cc b/src/FbTk/Image.cc index e4ab6ac..f5ffc24 100644 --- a/src/FbTk/Image.cc +++ b/src/FbTk/Image.cc | |||
@@ -19,7 +19,7 @@ | |||
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | 19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
20 | // DEALINGS IN THE SOFTWARE. | 20 | // DEALINGS IN THE SOFTWARE. |
21 | 21 | ||
22 | // $Id: Image.cc,v 1.1 2003/08/22 21:25:14 fluxgen Exp $ | 22 | // $Id: Image.cc,v 1.2 2003/11/16 22:33:55 rathnor Exp $ |
23 | 23 | ||
24 | #include "Image.hh" | 24 | #include "Image.hh" |
25 | #include "StringUtil.hh" | 25 | #include "StringUtil.hh" |
@@ -113,6 +113,10 @@ void Image::addSearchPath(const std::string &search_path) { | |||
113 | s_search_paths.push_back(search_path); | 113 | s_search_paths.push_back(search_path); |
114 | } | 114 | } |
115 | 115 | ||
116 | void Image::removeSearchPath(const std::string &search_path) { | ||
117 | s_search_paths.remove(search_path); | ||
118 | } | ||
119 | |||
116 | void Image::removeAllSearchPaths() { | 120 | void Image::removeAllSearchPaths() { |
117 | s_search_paths.clear(); | 121 | s_search_paths.clear(); |
118 | } | 122 | } |
diff --git a/src/FbTk/Image.hh b/src/FbTk/Image.hh index c655a2e..1dc3f1b 100644 --- a/src/FbTk/Image.hh +++ b/src/FbTk/Image.hh | |||
@@ -19,7 +19,7 @@ | |||
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | 19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
20 | // DEALINGS IN THE SOFTWARE. | 20 | // DEALINGS IN THE SOFTWARE. |
21 | 21 | ||
22 | // $Id: Image.hh,v 1.1 2003/08/22 21:25:14 fluxgen Exp $ | 22 | // $Id: Image.hh,v 1.2 2003/11/16 22:33:55 rathnor Exp $ |
23 | 23 | ||
24 | #ifndef FBTK_IMAGE_HH | 24 | #ifndef FBTK_IMAGE_HH |
25 | #define FBTK_IMAGE_HH | 25 | #define FBTK_IMAGE_HH |
@@ -46,6 +46,8 @@ public: | |||
46 | static void remove(ImageBase &base); | 46 | static void remove(ImageBase &base); |
47 | /// adds a path to search images from | 47 | /// adds a path to search images from |
48 | static void addSearchPath(const std::string &search_path); | 48 | static void addSearchPath(const std::string &search_path); |
49 | /// removes a path to search images from | ||
50 | static void removeSearchPath(const std::string &search_path); | ||
49 | /// adds a path to search images from | 51 | /// adds a path to search images from |
50 | static void removeAllSearchPaths(); | 52 | static void removeAllSearchPaths(); |
51 | private: | 53 | private: |
diff --git a/src/FbTk/Theme.cc b/src/FbTk/Theme.cc index c554545..59e9817 100644 --- a/src/FbTk/Theme.cc +++ b/src/FbTk/Theme.cc | |||
@@ -19,7 +19,7 @@ | |||
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | 19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
20 | // DEALINGS IN THE SOFTWARE. | 20 | // DEALINGS IN THE SOFTWARE. |
21 | 21 | ||
22 | // $Id: Theme.cc,v 1.20 2003/10/13 22:57:14 fluxgen Exp $ | 22 | // $Id: Theme.cc,v 1.21 2003/11/16 22:33:55 rathnor Exp $ |
23 | 23 | ||
24 | #include "Theme.hh" | 24 | #include "Theme.hh" |
25 | 25 | ||
@@ -27,10 +27,12 @@ | |||
27 | #include "App.hh" | 27 | #include "App.hh" |
28 | #include "StringUtil.hh" | 28 | #include "StringUtil.hh" |
29 | #include "ThemeItems.hh" | 29 | #include "ThemeItems.hh" |
30 | #include "Directory.hh" | ||
30 | 31 | ||
31 | #include <cstdio> | 32 | #include <cstdio> |
32 | #include <memory> | 33 | #include <memory> |
33 | #include <iostream> | 34 | #include <iostream> |
35 | |||
34 | using namespace std; | 36 | using namespace std; |
35 | 37 | ||
36 | namespace FbTk { | 38 | namespace FbTk { |
@@ -50,7 +52,8 @@ ThemeManager &ThemeManager::instance() { | |||
50 | 52 | ||
51 | ThemeManager::ThemeManager(): | 53 | ThemeManager::ThemeManager(): |
52 | m_max_screens(ScreenCount(FbTk::App::instance()->display())), | 54 | m_max_screens(ScreenCount(FbTk::App::instance()->display())), |
53 | m_verbose(false) { | 55 | m_verbose(false), |
56 | m_themelocation("") { | ||
54 | 57 | ||
55 | } | 58 | } |
56 | 59 | ||
@@ -71,10 +74,39 @@ bool ThemeManager::unregisterTheme(Theme &tm) { | |||
71 | } | 74 | } |
72 | 75 | ||
73 | bool ThemeManager::load(const std::string &filename) { | 76 | bool ThemeManager::load(const std::string &filename) { |
74 | 77 | std::string location = FbTk::StringUtil::expandFilename(filename).c_str(); | |
75 | if (!m_database.load(FbTk::StringUtil::expandFilename(filename).c_str())) | 78 | std::string prefix = ""; |
79 | |||
80 | if (Directory::isDirectory(filename)) { | ||
81 | prefix = location; | ||
82 | |||
83 | location.append("/theme.cfg"); | ||
84 | if (!Directory::isRegularFile(location)) { | ||
85 | cerr<<"Error loading theme file "<<location<<": not a regular file"<<endl; | ||
86 | return false; | ||
87 | } | ||
88 | } else { | ||
89 | // dirname | ||
90 | prefix = location.substr(0, location.find_last_of('/')); | ||
91 | } | ||
92 | |||
93 | if (!m_database.load(location.c_str())) | ||
76 | return false; | 94 | return false; |
77 | 95 | ||
96 | // relies on the fact that load_rc clears search paths each time | ||
97 | if (m_themelocation != "") { | ||
98 | Image::removeSearchPath(m_themelocation); | ||
99 | m_themelocation.append("/pixmaps"); | ||
100 | Image::removeSearchPath(m_themelocation); | ||
101 | } | ||
102 | |||
103 | m_themelocation = prefix; | ||
104 | |||
105 | location = prefix; | ||
106 | Image::addSearchPath(location); | ||
107 | location.append("/pixmaps"); | ||
108 | Image::addSearchPath(location); | ||
109 | |||
78 | //get list and go throu all the resources and load them | 110 | //get list and go throu all the resources and load them |
79 | ThemeList::iterator theme_it = m_themelist.begin(); | 111 | ThemeList::iterator theme_it = m_themelist.begin(); |
80 | const ThemeList::iterator theme_it_end = m_themelist.end(); | 112 | const ThemeList::iterator theme_it_end = m_themelist.end(); |
diff --git a/src/FbTk/Theme.hh b/src/FbTk/Theme.hh index 42064f8..bea4680 100644 --- a/src/FbTk/Theme.hh +++ b/src/FbTk/Theme.hh | |||
@@ -19,7 +19,7 @@ | |||
19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | 19 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
20 | // DEALINGS IN THE SOFTWARE. | 20 | // DEALINGS IN THE SOFTWARE. |
21 | 21 | ||
22 | // $Id: Theme.hh,v 1.10 2003/09/14 11:17:21 fluxgen Exp $ | 22 | // $Id: Theme.hh,v 1.11 2003/11/16 22:33:56 rathnor Exp $ |
23 | 23 | ||
24 | /** | 24 | /** |
25 | @file holds ThemeItem<T>, Theme and ThemeManager which is the base for any theme | 25 | @file holds ThemeItem<T>, Theme and ThemeManager which is the base for any theme |
@@ -149,6 +149,8 @@ private: | |||
149 | const int m_max_screens; | 149 | const int m_max_screens; |
150 | XrmDatabaseHelper m_database; | 150 | XrmDatabaseHelper m_database; |
151 | bool m_verbose; | 151 | bool m_verbose; |
152 | |||
153 | std::string m_themelocation; | ||
152 | }; | 154 | }; |
153 | 155 | ||
154 | 156 | ||
diff --git a/src/Screen.cc b/src/Screen.cc index 1aa2e73..5194434 100644 --- a/src/Screen.cc +++ b/src/Screen.cc | |||
@@ -22,7 +22,7 @@ | |||
22 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | 22 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
23 | // DEALINGS IN THE SOFTWARE. | 23 | // DEALINGS IN THE SOFTWARE. |
24 | 24 | ||
25 | // $Id: Screen.cc,v 1.240 2003/10/31 10:37:09 rathnor Exp $ | 25 | // $Id: Screen.cc,v 1.241 2003/11/16 22:33:55 rathnor Exp $ |
26 | 26 | ||
27 | 27 | ||
28 | #include "Screen.hh" | 28 | #include "Screen.hh" |
@@ -2016,7 +2016,8 @@ void BScreen::createStyleMenu(FbTk::Menu &menu, | |||
2016 | for (size_t file_index = 0; file_index < dir.entries(); file_index++) { | 2016 | for (size_t file_index = 0; file_index < dir.entries(); file_index++) { |
2017 | std::string style(stylesdir + '/' + filelist[file_index]); | 2017 | std::string style(stylesdir + '/' + filelist[file_index]); |
2018 | // add to menu only if the file is a regular file | 2018 | // add to menu only if the file is a regular file |
2019 | if (FbTk::Directory::isRegularFile(style)) | 2019 | if (FbTk::Directory::isRegularFile(style) || |
2020 | FbTk::Directory::isRegularFile(style + "/theme.cfg")) | ||
2020 | menu.insert(new StyleMenuItem(filelist[file_index], style)); | 2021 | menu.insert(new StyleMenuItem(filelist[file_index], style)); |
2021 | } | 2022 | } |
2022 | // update menu graphics | 2023 | // update menu graphics |