aboutsummaryrefslogtreecommitdiff
path: root/src/FbTk/Theme.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/FbTk/Theme.cc')
-rw-r--r--src/FbTk/Theme.cc40
1 files changed, 36 insertions, 4 deletions
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();