add better theme path searching
This commit is contained in:
parent
7a3bc3df9a
commit
c8d1e5491b
6 changed files with 57 additions and 9 deletions
|
@ -1,5 +1,12 @@
|
|||
(Format: Year/Month/Day)
|
||||
Changes for 0.9.6:
|
||||
*03/11/16:
|
||||
* Add image search paths when loading a style (Simon)
|
||||
- now looks for pixmaps in <stylebase> and <stylebase>/pixmaps
|
||||
- now looks for styles in <stylesdir>/<stylename>/theme.cfg
|
||||
=> for this, stylebase is the style directory
|
||||
- pixmap styles should use the new format for portability
|
||||
Theme.hh/cc Image.hh/cc Screen.cc
|
||||
*03/11/15:
|
||||
* Moved fluxbox-generate_menu to fluxbox-generate_menu.in (Thanks Han)
|
||||
fixed empty submenu problem
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
// $Id: Image.cc,v 1.1 2003/08/22 21:25:14 fluxgen Exp $
|
||||
// $Id: Image.cc,v 1.2 2003/11/16 22:33:55 rathnor Exp $
|
||||
|
||||
#include "Image.hh"
|
||||
#include "StringUtil.hh"
|
||||
|
@ -113,6 +113,10 @@ void Image::addSearchPath(const std::string &search_path) {
|
|||
s_search_paths.push_back(search_path);
|
||||
}
|
||||
|
||||
void Image::removeSearchPath(const std::string &search_path) {
|
||||
s_search_paths.remove(search_path);
|
||||
}
|
||||
|
||||
void Image::removeAllSearchPaths() {
|
||||
s_search_paths.clear();
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
// $Id: Image.hh,v 1.1 2003/08/22 21:25:14 fluxgen Exp $
|
||||
// $Id: Image.hh,v 1.2 2003/11/16 22:33:55 rathnor Exp $
|
||||
|
||||
#ifndef FBTK_IMAGE_HH
|
||||
#define FBTK_IMAGE_HH
|
||||
|
@ -46,6 +46,8 @@ public:
|
|||
static void remove(ImageBase &base);
|
||||
/// adds a path to search images from
|
||||
static void addSearchPath(const std::string &search_path);
|
||||
/// removes a path to search images from
|
||||
static void removeSearchPath(const std::string &search_path);
|
||||
/// adds a path to search images from
|
||||
static void removeAllSearchPaths();
|
||||
private:
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
// $Id: Theme.cc,v 1.20 2003/10/13 22:57:14 fluxgen Exp $
|
||||
// $Id: Theme.cc,v 1.21 2003/11/16 22:33:55 rathnor Exp $
|
||||
|
||||
#include "Theme.hh"
|
||||
|
||||
|
@ -27,10 +27,12 @@
|
|||
#include "App.hh"
|
||||
#include "StringUtil.hh"
|
||||
#include "ThemeItems.hh"
|
||||
#include "Directory.hh"
|
||||
|
||||
#include <cstdio>
|
||||
#include <memory>
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace FbTk {
|
||||
|
@ -50,7 +52,8 @@ ThemeManager &ThemeManager::instance() {
|
|||
|
||||
ThemeManager::ThemeManager():
|
||||
m_max_screens(ScreenCount(FbTk::App::instance()->display())),
|
||||
m_verbose(false) {
|
||||
m_verbose(false),
|
||||
m_themelocation("") {
|
||||
|
||||
}
|
||||
|
||||
|
@ -71,10 +74,39 @@ bool ThemeManager::unregisterTheme(Theme &tm) {
|
|||
}
|
||||
|
||||
bool ThemeManager::load(const std::string &filename) {
|
||||
|
||||
if (!m_database.load(FbTk::StringUtil::expandFilename(filename).c_str()))
|
||||
std::string location = FbTk::StringUtil::expandFilename(filename).c_str();
|
||||
std::string prefix = "";
|
||||
|
||||
if (Directory::isDirectory(filename)) {
|
||||
prefix = location;
|
||||
|
||||
location.append("/theme.cfg");
|
||||
if (!Directory::isRegularFile(location)) {
|
||||
cerr<<"Error loading theme file "<<location<<": not a regular file"<<endl;
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
// dirname
|
||||
prefix = location.substr(0, location.find_last_of('/'));
|
||||
}
|
||||
|
||||
if (!m_database.load(location.c_str()))
|
||||
return false;
|
||||
|
||||
// relies on the fact that load_rc clears search paths each time
|
||||
if (m_themelocation != "") {
|
||||
Image::removeSearchPath(m_themelocation);
|
||||
m_themelocation.append("/pixmaps");
|
||||
Image::removeSearchPath(m_themelocation);
|
||||
}
|
||||
|
||||
m_themelocation = prefix;
|
||||
|
||||
location = prefix;
|
||||
Image::addSearchPath(location);
|
||||
location.append("/pixmaps");
|
||||
Image::addSearchPath(location);
|
||||
|
||||
//get list and go throu all the resources and load them
|
||||
ThemeList::iterator theme_it = m_themelist.begin();
|
||||
const ThemeList::iterator theme_it_end = m_themelist.end();
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
// $Id: Theme.hh,v 1.10 2003/09/14 11:17:21 fluxgen Exp $
|
||||
// $Id: Theme.hh,v 1.11 2003/11/16 22:33:56 rathnor Exp $
|
||||
|
||||
/**
|
||||
@file holds ThemeItem<T>, Theme and ThemeManager which is the base for any theme
|
||||
|
@ -149,6 +149,8 @@ private:
|
|||
const int m_max_screens;
|
||||
XrmDatabaseHelper m_database;
|
||||
bool m_verbose;
|
||||
|
||||
std::string m_themelocation;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
// $Id: Screen.cc,v 1.240 2003/10/31 10:37:09 rathnor Exp $
|
||||
// $Id: Screen.cc,v 1.241 2003/11/16 22:33:55 rathnor Exp $
|
||||
|
||||
|
||||
#include "Screen.hh"
|
||||
|
@ -2016,7 +2016,8 @@ void BScreen::createStyleMenu(FbTk::Menu &menu,
|
|||
for (size_t file_index = 0; file_index < dir.entries(); file_index++) {
|
||||
std::string style(stylesdir + '/' + filelist[file_index]);
|
||||
// add to menu only if the file is a regular file
|
||||
if (FbTk::Directory::isRegularFile(style))
|
||||
if (FbTk::Directory::isRegularFile(style) ||
|
||||
FbTk::Directory::isRegularFile(style + "/theme.cfg"))
|
||||
menu.insert(new StyleMenuItem(filelist[file_index], style));
|
||||
}
|
||||
// update menu graphics
|
||||
|
|
Loading…
Reference in a new issue