aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrathnor <rathnor>2003-11-16 22:33:56 (GMT)
committerrathnor <rathnor>2003-11-16 22:33:56 (GMT)
commitc8d1e5491bf5ca9b7e3a7d16780faebb4a40793e (patch)
tree13bc7e69b0cefaa870c2cfd14ff61843e833b451
parent7a3bc3df9ae14fda35f40b5fbf6d059c392c6a26 (diff)
downloadfluxbox_pavel-c8d1e5491bf5ca9b7e3a7d16780faebb4a40793e.zip
fluxbox_pavel-c8d1e5491bf5ca9b7e3a7d16780faebb4a40793e.tar.bz2
add better theme path searching
-rw-r--r--ChangeLog7
-rw-r--r--src/FbTk/Image.cc6
-rw-r--r--src/FbTk/Image.hh4
-rw-r--r--src/FbTk/Theme.cc40
-rw-r--r--src/FbTk/Theme.hh4
-rw-r--r--src/Screen.cc5
6 files changed, 57 insertions, 9 deletions
diff --git a/ChangeLog b/ChangeLog
index 2b179b8..0d6018c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
1(Format: Year/Month/Day) 1(Format: Year/Month/Day)
2Changes for 0.9.6: 2Changes for 0.9.6:
3*03/11/16:
4 * Add image search paths when loading a style (Simon)
5 - now looks for pixmaps in <stylebase> and <stylebase>/pixmaps
6 - now looks for styles in <stylesdir>/<stylename>/theme.cfg
7 => for this, stylebase is the style directory
8 - pixmap styles should use the new format for portability
9 Theme.hh/cc Image.hh/cc Screen.cc
3*03/11/15: 10*03/11/15:
4 * Moved fluxbox-generate_menu to fluxbox-generate_menu.in (Thanks Han) 11 * Moved fluxbox-generate_menu to fluxbox-generate_menu.in (Thanks Han)
5 fixed empty submenu problem 12 fixed empty submenu problem
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
116void Image::removeSearchPath(const std::string &search_path) {
117 s_search_paths.remove(search_path);
118}
119
116void Image::removeAllSearchPaths() { 120void 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();
51private: 53private:
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
34using namespace std; 36using namespace std;
35 37
36namespace FbTk { 38namespace FbTk {
@@ -50,7 +52,8 @@ ThemeManager &ThemeManager::instance() {
50 52
51ThemeManager::ThemeManager(): 53ThemeManager::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
73bool ThemeManager::load(const std::string &filename) { 76bool 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