Fixed better resourcehandling with Resource<T>
This commit is contained in:
parent
a8af15fdc2
commit
f16075f277
2 changed files with 998 additions and 1026 deletions
456
src/fluxbox.cc
456
src/fluxbox.cc
|
@ -22,7 +22,7 @@
|
|||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
// $Id: fluxbox.cc,v 1.20 2002/01/11 22:48:45 pekdon Exp $
|
||||
// $Id: fluxbox.cc,v 1.21 2002/01/18 01:23:54 fluxgen Exp $
|
||||
|
||||
// stupid macros needed to access some functions in version 2 of the GNU C
|
||||
// library
|
||||
|
@ -50,6 +50,7 @@
|
|||
#include "Workspace.hh"
|
||||
#include "Workspacemenu.hh"
|
||||
#include "StringUtil.hh"
|
||||
#include "Resource.hh"
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
|
@ -155,7 +156,126 @@ static Bool queueScanner(Display *, XEvent *e, char *args) {
|
|||
|
||||
return False;
|
||||
}
|
||||
//-----------------------------------------------------------------
|
||||
//---- accessors for int, bool, and some enums with Resource ------
|
||||
//-----------------------------------------------------------------
|
||||
template<>
|
||||
void Resource<int>::
|
||||
setFromString(const char* strval) {
|
||||
int val;
|
||||
if (sscanf(strval, "%d", &val)==1)
|
||||
*this = val;
|
||||
}
|
||||
|
||||
template<>
|
||||
void Resource<std::string>::
|
||||
setFromString(const char *strval) {
|
||||
*this = strval;
|
||||
}
|
||||
|
||||
template<>
|
||||
void Resource<bool>::
|
||||
setFromString(char const *strval) {
|
||||
if (strcasecmp(strval, "true")==0)
|
||||
*this = true;
|
||||
else
|
||||
*this = false;
|
||||
}
|
||||
|
||||
template<>
|
||||
void Resource<Fluxbox::TitlebarList>::
|
||||
setFromString(char const *strval) {
|
||||
vector<std::string> val;
|
||||
StringUtil::stringtok(val, strval);
|
||||
int size=val.size();
|
||||
//clear old values
|
||||
m_value.clear();
|
||||
|
||||
for (int i=0; i<size; i++) {
|
||||
if (strcasecmp(val[i].c_str(), "Maximize")==0)
|
||||
m_value.push_back(Fluxbox::MAXIMIZE);
|
||||
else if (strcasecmp(val[i].c_str(), "Minimize")==0)
|
||||
m_value.push_back(Fluxbox::MINIMIZE);
|
||||
else if (strcasecmp(val[i].c_str(), "Shade")==0)
|
||||
m_value.push_back(Fluxbox::SHADE);
|
||||
else if (strcasecmp(val[i].c_str(), "Stick")==0)
|
||||
m_value.push_back(Fluxbox::STICK);
|
||||
else if (strcasecmp(val[i].c_str(), "Menu")==0)
|
||||
m_value.push_back(Fluxbox::MENU);
|
||||
else if (strcasecmp(val[i].c_str(), "Close")==0)
|
||||
m_value.push_back(Fluxbox::CLOSE);
|
||||
}
|
||||
}
|
||||
|
||||
template<>
|
||||
void Resource<unsigned int>::
|
||||
setFromString(const char *strval) {
|
||||
if (sscanf(strval, "%ul", &m_value) != 1)
|
||||
setDefaultValue();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------
|
||||
//---- manipulators for int, bool, and some enums with Resource ---
|
||||
//-----------------------------------------------------------------
|
||||
template<>
|
||||
std::string Resource<bool>::
|
||||
getString() {
|
||||
return std::string(**this == true ? "true" : "false");
|
||||
}
|
||||
|
||||
template<>
|
||||
std::string Resource<int>::
|
||||
getString() {
|
||||
char strval[256];
|
||||
sprintf(strval, "%d", **this);
|
||||
return std::string(strval);
|
||||
}
|
||||
|
||||
template<>
|
||||
std::string Resource<std::string>::
|
||||
getString() { return **this; }
|
||||
|
||||
template<>
|
||||
string Resource<Fluxbox::TitlebarList>::
|
||||
getString() {
|
||||
string retval;
|
||||
int size=m_value.size();
|
||||
for (int i=0; i<size; i++) {
|
||||
switch (m_value[i]) {
|
||||
case Fluxbox::SHADE:
|
||||
retval.append("Shade");
|
||||
break;
|
||||
case Fluxbox::MINIMIZE:
|
||||
retval.append("Minimize");
|
||||
break;
|
||||
case Fluxbox::MAXIMIZE:
|
||||
retval.append("Maximize");
|
||||
break;
|
||||
case Fluxbox::CLOSE:
|
||||
retval.append("Close");
|
||||
break;
|
||||
case Fluxbox::STICK:
|
||||
retval.append("Stick");
|
||||
break;
|
||||
case Fluxbox::MENU:
|
||||
retval.append("Menu");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
retval.append(" ");
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
template<>
|
||||
string Resource<unsigned int>::
|
||||
getString() {
|
||||
char tmpstr[128];
|
||||
sprintf(tmpstr, "%ul", m_value);
|
||||
return string(tmpstr);
|
||||
}
|
||||
|
||||
//static singleton var
|
||||
Fluxbox *Fluxbox::singleton=0;
|
||||
|
@ -170,7 +290,23 @@ Fluxbox *Fluxbox::instance(int m_argc, char **m_argv, char *dpy_name, char *rc)
|
|||
|
||||
|
||||
Fluxbox::Fluxbox(int m_argc, char **m_argv, char *dpy_name, char *rc)
|
||||
: BaseDisplay(m_argv[0], dpy_name)
|
||||
: BaseDisplay(m_argv[0], dpy_name),
|
||||
m_resourcemanager(),
|
||||
m_rc_tabs(m_resourcemanager, true, "session.tabs", "Session.Tabs"),
|
||||
m_rc_iconbar(m_resourcemanager, true, "session.iconbar", "Session.Iconbar"),
|
||||
m_rc_colors_per_channel(m_resourcemanager, 4, "session.colorsPerChannel", "Session.ColorsPerChannel"),
|
||||
m_rc_stylefile(m_resourcemanager, "", "session.styleFile", "Session.StyleFile"),
|
||||
m_rc_menufile(m_resourcemanager, DEFAULTMENU, "session.menuFile", "Session.MenuFile"),
|
||||
m_rc_keyfile(m_resourcemanager, DEFAULTKEYSFILE, "session.keyFile", "Session.KeyFile"),
|
||||
m_rc_titlebar_left(m_resourcemanager, TitlebarList(0), "session.titlebar.left", "Session.Titlebar.Left"),
|
||||
m_rc_titlebar_right(m_resourcemanager, TitlebarList(0), "session.titlebar.right", "Session.Titlebar.Right"),
|
||||
m_rc_cache_life(m_resourcemanager, 5, "session.cacheLife", "Session.CacheLife"),
|
||||
m_rc_cache_max(m_resourcemanager, 200, "session.cacheMax", "Session.CacheMax"),
|
||||
focused_window(0),
|
||||
masked_window(0),
|
||||
no_focus(0),
|
||||
rc_file(rc)
|
||||
|
||||
{
|
||||
|
||||
//singleton pointer
|
||||
|
@ -187,20 +323,15 @@ Fluxbox::Fluxbox(int m_argc, char **m_argv, char *dpy_name, char *rc)
|
|||
|
||||
argc = m_argc;
|
||||
argv = m_argv;
|
||||
rc_file = rc;
|
||||
key=0;
|
||||
|
||||
no_focus = False;
|
||||
resource.titlebar_file = resource.menu_file = resource.style_file = resource.keys_file = 0;
|
||||
// resource.titlebar_file = resource.keys_file = 0;
|
||||
|
||||
resource.auto_raise_delay.tv_sec = resource.auto_raise_delay.tv_usec = 0;
|
||||
|
||||
focused_window = masked_window = (FluxboxWindow *) 0;
|
||||
|
||||
masked = None;
|
||||
/*resource.tabtype.listtype = TabType::Vertical;
|
||||
resource.tabtype.listpos = TabType::Top;
|
||||
resource.tabtype.pos = TabType::Right;
|
||||
*/
|
||||
|
||||
windowSearchList = new LinkedList<WindowSearch>;
|
||||
menuSearchList = new LinkedList<MenuSearch>;
|
||||
|
@ -221,7 +352,6 @@ Fluxbox::Fluxbox(int m_argc, char **m_argv, char *dpy_name, char *rc)
|
|||
|
||||
menuTimestamps = new LinkedList<MenuTimestamp>;
|
||||
|
||||
XrmInitialize();
|
||||
load_rc();
|
||||
|
||||
#ifdef HAVE_GETPID
|
||||
|
@ -267,7 +397,7 @@ Fluxbox::Fluxbox(int m_argc, char **m_argv, char *dpy_name, char *rc)
|
|||
timer->fireOnce(True);
|
||||
|
||||
//create keybindings handler and load keys file
|
||||
key = new Keys(getXDisplay(), resource.keys_file);
|
||||
key = new Keys(getXDisplay(), const_cast<char *>((*m_rc_keyfile).c_str()));
|
||||
|
||||
ungrab();
|
||||
}
|
||||
|
@ -290,18 +420,6 @@ Fluxbox::~Fluxbox(void) {
|
|||
delete key;
|
||||
key = 0;
|
||||
|
||||
if (resource.menu_file)
|
||||
delete [] resource.menu_file;
|
||||
|
||||
if (resource.style_file)
|
||||
delete [] resource.style_file;
|
||||
|
||||
if (resource.titlebar_file)
|
||||
delete resource.titlebar_file;
|
||||
|
||||
if (resource.keys_file)
|
||||
delete resource.keys_file;
|
||||
|
||||
delete timer;
|
||||
|
||||
delete screenList;
|
||||
|
@ -354,10 +472,10 @@ void Fluxbox::process_event(XEvent *e) {
|
|||
} else if ((menu = searchMenu(e->xbutton.window))) {
|
||||
menu->buttonPressEvent(&e->xbutton);
|
||||
|
||||
#ifdef SLIT
|
||||
#ifdef SLIT
|
||||
} else if ((slit = searchSlit(e->xbutton.window))) {
|
||||
slit->buttonPressEvent(&e->xbutton);
|
||||
#endif // SLIT
|
||||
#endif // SLIT
|
||||
|
||||
} else if ((tbar = searchToolbar(e->xbutton.window))) {
|
||||
tbar->buttonPressEvent(&e->xbutton);
|
||||
|
@ -508,18 +626,19 @@ void Fluxbox::process_event(XEvent *e) {
|
|||
|
||||
case MapRequest:
|
||||
{
|
||||
#ifdef DEBUG
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr,
|
||||
I18n::instance()->
|
||||
getMessage(
|
||||
# ifdef NLS
|
||||
#ifdef NLS
|
||||
blackboxSet, blackboxMapRequest,
|
||||
# else // !NLS
|
||||
#else // !NLS
|
||||
0, 0,
|
||||
# endif // NLS
|
||||
#endif // NLS
|
||||
"Fluxbox::process_event(): MapRequest for 0x%lx\n"),
|
||||
e->xmaprequest.window);
|
||||
#endif // DEBUG
|
||||
#endif // DEBUG
|
||||
|
||||
#ifdef SLIT
|
||||
#ifdef KDE
|
||||
//Check and see if client is KDE dock applet.
|
||||
|
@ -566,9 +685,15 @@ void Fluxbox::process_event(XEvent *e) {
|
|||
|
||||
FluxboxWindow *win = searchWindow(e->xmaprequest.window);
|
||||
|
||||
if (! win)
|
||||
if (! win) {
|
||||
try {
|
||||
win = new FluxboxWindow(e->xmaprequest.window);
|
||||
|
||||
} catch (FluxboxWindow::Error error) {
|
||||
FluxboxWindow::showError(error);
|
||||
delete win;
|
||||
win = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if ((win = searchWindow(e->xmaprequest.window)))
|
||||
win->mapRequestEvent(&e->xmaprequest);
|
||||
|
@ -1448,8 +1573,9 @@ void Fluxbox::shutdown(void) {
|
|||
save_rc();
|
||||
}
|
||||
|
||||
//save_rc
|
||||
//------ save_rc --------
|
||||
//saves resources
|
||||
//----------------------
|
||||
void Fluxbox::save_rc(void) {
|
||||
|
||||
XrmDatabase new_blackboxrc = (XrmDatabase) 0;
|
||||
|
@ -1457,28 +1583,13 @@ void Fluxbox::save_rc(void) {
|
|||
|
||||
auto_ptr<char> dbfile(getRcFilename());
|
||||
|
||||
// load_rc();
|
||||
// This overwrites configs made while running, for example
|
||||
// usage of iconbar and tabs
|
||||
|
||||
sprintf(rc_string, "session.iconbar: %s", resource.iconbar ? "true" : "false");
|
||||
XrmPutLineResource(&new_blackboxrc, rc_string);
|
||||
|
||||
sprintf(rc_string, "session.tabs: %s", resource.tabs ? "true" : "false");
|
||||
XrmPutLineResource(&new_blackboxrc, rc_string);
|
||||
|
||||
sprintf(rc_string, "session.menuFile: %s", resource.menu_file);
|
||||
XrmPutLineResource(&new_blackboxrc, rc_string);
|
||||
|
||||
sprintf(rc_string, "session.titlebarFile: %s", resource.titlebar_file);
|
||||
XrmPutLineResource(&new_blackboxrc, rc_string);
|
||||
|
||||
sprintf(rc_string, "session.keyFile: %s", resource.keys_file);
|
||||
XrmPutLineResource(&new_blackboxrc, rc_string);
|
||||
|
||||
sprintf(rc_string, "session.colorsPerChannel: %d",
|
||||
resource.colors_per_channel);
|
||||
XrmPutLineResource(&new_blackboxrc, rc_string);
|
||||
// load_rc();
|
||||
// This overwrites configs made while running, for example
|
||||
// usage of iconbar and tabs
|
||||
if (*dbfile)
|
||||
m_resourcemanager.save(dbfile.get(), dbfile.get());
|
||||
else
|
||||
cerr<<"database filename is invalid!"<<endl;
|
||||
|
||||
sprintf(rc_string, "session.doubleClickInterval: %lu",
|
||||
resource.double_click_interval);
|
||||
|
@ -1489,12 +1600,6 @@ void Fluxbox::save_rc(void) {
|
|||
(resource.auto_raise_delay.tv_usec / 1000)));
|
||||
XrmPutLineResource(&new_blackboxrc, rc_string);
|
||||
|
||||
sprintf(rc_string, "session.cacheLife: %lu", resource.cache_life / 60000);
|
||||
XrmPutLineResource(&new_blackboxrc, rc_string);
|
||||
|
||||
sprintf(rc_string, "session.cacheMax: %lu", resource.cache_max);
|
||||
XrmPutLineResource(&new_blackboxrc, rc_string);
|
||||
|
||||
LinkedListIterator<BScreen> it(screenList);
|
||||
for (; it.current(); it++) {
|
||||
BScreen *screen = it.current();
|
||||
|
@ -1699,7 +1804,8 @@ void Fluxbox::save_rc(void) {
|
|||
(char *) ((screen->getWorkspace(i)->getName()) ?
|
||||
screen->getWorkspace(i)->getName() : "Null");
|
||||
|
||||
while (--len) *(save_string_pos++) = *(name_string_pos++);
|
||||
while (--len)
|
||||
*(save_string_pos++) = *(name_string_pos++);
|
||||
*(save_string_pos++) = ',';
|
||||
}
|
||||
}
|
||||
|
@ -1725,7 +1831,6 @@ void Fluxbox::save_rc(void) {
|
|||
|
||||
//-------- getRcFilename -------------
|
||||
// Returns filename of resource file
|
||||
// TODO: possible replacement with strstream?
|
||||
//------------------------------------
|
||||
char *Fluxbox::getRcFilename() {
|
||||
char *dbfile=0;
|
||||
|
@ -1745,6 +1850,45 @@ void Fluxbox::load_rc(void) {
|
|||
|
||||
//get resource filename
|
||||
auto_ptr<char> dbfile(getRcFilename());
|
||||
#ifdef DEBUG
|
||||
cerr<<__FILE__<<"("<<__LINE__<<"): dbfile="<<dbfile.get()<<endl;
|
||||
#endif
|
||||
if (dbfile.get()) {
|
||||
if (!m_resourcemanager.load(dbfile.get())) {
|
||||
cerr<<"Faild to load database:"<<dbfile.get()<<endl;
|
||||
cerr<<"Trying with: "<<DEFAULT_INITFILE<<endl;
|
||||
if (!m_resourcemanager.load(DEFAULT_INITFILE))
|
||||
cerr<<"Faild to load database: "<<DEFAULT_INITFILE<<endl;
|
||||
}
|
||||
} else {
|
||||
if (!m_resourcemanager.load(DEFAULT_INITFILE))
|
||||
cerr<<"Faild to load database: "<<DEFAULT_INITFILE<<endl;
|
||||
}
|
||||
|
||||
XrmValue value;
|
||||
char *value_type;
|
||||
|
||||
if (m_rc_menufile->size()) {
|
||||
char *tmpvar =StringUtil::expandFilename(m_rc_menufile->c_str());
|
||||
*m_rc_menufile = (tmpvar==0 ? "" : tmpvar);
|
||||
if (!m_rc_menufile->size())
|
||||
m_rc_menufile.setDefaultValue();
|
||||
|
||||
delete tmpvar;
|
||||
} else
|
||||
m_rc_menufile.setDefaultValue();
|
||||
|
||||
if (*m_rc_colors_per_channel < 2)
|
||||
*m_rc_colors_per_channel = 2;
|
||||
else if (*m_rc_colors_per_channel > 6)
|
||||
*m_rc_colors_per_channel = 6;
|
||||
|
||||
if (*m_rc_stylefile=="")
|
||||
*m_rc_stylefile = DEFAULTSTYLE;
|
||||
else {
|
||||
auto_ptr<char> tmpvar(StringUtil::expandFilename(m_rc_stylefile->c_str()));
|
||||
*m_rc_stylefile = (tmpvar.get()==0 ? "" : tmpvar.get());
|
||||
}
|
||||
|
||||
//load file
|
||||
database = XrmGetFileDatabase(dbfile.get());
|
||||
|
@ -1754,87 +1898,6 @@ void Fluxbox::load_rc(void) {
|
|||
database = XrmGetFileDatabase(DEFAULT_INITFILE);
|
||||
}
|
||||
|
||||
XrmValue value;
|
||||
char *value_type;
|
||||
|
||||
if (resource.menu_file) {
|
||||
delete [] resource.menu_file;
|
||||
resource.menu_file = 0;
|
||||
}
|
||||
//get menu filename
|
||||
if (XrmGetResource(database, "session.menuFile", "Session.MenuFile",
|
||||
&value_type, &value)) {
|
||||
|
||||
resource.menu_file = StringUtil::expandFilename(value.addr); // expand ~ to $HOME
|
||||
} else
|
||||
resource.menu_file = StringUtil::strdup(DEFAULTMENU);
|
||||
|
||||
if (resource.titlebar_file) {
|
||||
delete resource.titlebar_file;
|
||||
resource.titlebar_file = 0;
|
||||
}
|
||||
|
||||
//get titlebar filename
|
||||
if (XrmGetResource(database, "session.titlebarFile", "Session.TitlebarFile",
|
||||
&value_type, &value)) {
|
||||
resource.titlebar_file = StringUtil::expandFilename(value.addr); //expand ~ to home
|
||||
} else
|
||||
resource.titlebar_file = StringUtil::strdup(DEFAULTTITLEBAR);
|
||||
|
||||
//if already allocated memory for keys_file destroy it
|
||||
if (resource.keys_file) {
|
||||
delete resource.keys_file;
|
||||
resource.keys_file = 0;
|
||||
}
|
||||
|
||||
//get keys filename
|
||||
if (XrmGetResource(database, "session.keyFile", "Session.keyFile",
|
||||
&value_type, &value)) {
|
||||
resource.keys_file = StringUtil::expandFilename(value.addr); //expand ~ to home
|
||||
} else
|
||||
resource.keys_file = StringUtil::strdup(DEFAULTKEYSFILE);
|
||||
|
||||
|
||||
if (XrmGetResource(database, "session.iconbar", "Session.Iconbar",
|
||||
&value_type, &value)) {
|
||||
if (! strncasecmp("true", value.addr, value.size))
|
||||
resource.iconbar = true;
|
||||
else
|
||||
resource.iconbar = false;
|
||||
} else
|
||||
resource.iconbar = true;
|
||||
|
||||
if (XrmGetResource(database, "session.tabs", "Session.Tabs",
|
||||
&value_type, &value)) {
|
||||
if (! strncasecmp("true", value.addr, value.size))
|
||||
resource.tabs = true;
|
||||
else
|
||||
resource.tabs = false;
|
||||
} else
|
||||
resource.tabs = true;
|
||||
|
||||
if (XrmGetResource(database, "session.colorsPerChannel",
|
||||
"Session.ColorsPerChannel", &value_type, &value)) {
|
||||
if (sscanf(value.addr, "%d", &resource.colors_per_channel) != 1)
|
||||
resource.colors_per_channel = 4;
|
||||
else {
|
||||
if (resource.colors_per_channel < 2)
|
||||
resource.colors_per_channel = 2;
|
||||
if (resource.colors_per_channel > 6)
|
||||
resource.colors_per_channel = 6;
|
||||
}
|
||||
} else
|
||||
resource.colors_per_channel = 4;
|
||||
|
||||
if (resource.style_file)
|
||||
delete [] resource.style_file;
|
||||
|
||||
if (XrmGetResource(database, "session.styleFile", "Session.StyleFile",
|
||||
&value_type, &value))
|
||||
resource.style_file = StringUtil::expandFilename(value.addr);
|
||||
else
|
||||
resource.style_file = StringUtil::strdup(DEFAULTSTYLE);
|
||||
|
||||
if (XrmGetResource(database, "session.doubleClickInterval",
|
||||
"Session.DoubleClickInterval", &value_type, &value)) {
|
||||
if (sscanf(value.addr, "%lu", &resource.double_click_interval) != 1)
|
||||
|
@ -1854,100 +1917,8 @@ void Fluxbox::load_rc(void) {
|
|||
(resource.auto_raise_delay.tv_sec * 1000);
|
||||
resource.auto_raise_delay.tv_usec *= 1000;
|
||||
|
||||
if (XrmGetResource(database, "session.cacheLife", "Session.CacheLife",
|
||||
&value_type, &value)) {
|
||||
if (sscanf(value.addr, "%lu", &resource.cache_life) != 1)
|
||||
resource.cache_life = 5l;
|
||||
} else
|
||||
resource.cache_life = 5l;
|
||||
XrmDestroyDatabase(database);
|
||||
|
||||
resource.cache_life *= 60000;
|
||||
|
||||
if (XrmGetResource(database, "session.cacheMax", "Session.CacheMax",
|
||||
&value_type, &value)) {
|
||||
if (sscanf(value.addr, "%lu", &resource.cache_max) != 1)
|
||||
resource.cache_max = 200;
|
||||
} else
|
||||
resource.cache_max = 200;
|
||||
|
||||
//XrmDestroyDatabase(database);
|
||||
|
||||
loadTitlebar();
|
||||
}
|
||||
//parseTitleArgs
|
||||
//parses the titlearg configline
|
||||
vector<string> Fluxbox::parseTitleArgs(const char *arg) {
|
||||
vector<string> args;
|
||||
string tmp;
|
||||
unsigned int i=0;
|
||||
while ( i<strlen(arg) ) {
|
||||
for (; arg[i] != ' ' && i<strlen(arg); i++)
|
||||
tmp+=arg[i];
|
||||
i++;
|
||||
args.push_back(tmp);
|
||||
tmp="";
|
||||
}
|
||||
|
||||
return args;
|
||||
}
|
||||
|
||||
void Fluxbox::setTitlebar(vector<Fluxbox::Titlebar>& dir, const char *arg) {
|
||||
vector<string> argv = parseTitleArgs(arg);
|
||||
for (unsigned int i=0; i<argv.size(); i++) {
|
||||
if (argv[i]==NAME_STICKY)
|
||||
dir.push_back(STICK);
|
||||
else if (argv[i]==NAME_MAXIMIZE)
|
||||
dir.push_back(MAXIMIZE);
|
||||
else if (argv[i]==NAME_MINIMIZE)
|
||||
dir.push_back(MINIMIZE);
|
||||
else if (argv[i]== NAME_CLOSE)
|
||||
dir.push_back(CLOSE);
|
||||
else if (argv[i]==NAME_SHADE)
|
||||
dir.push_back(SHADE);
|
||||
else if (argv[i]==NAME_MENU)
|
||||
dir.push_back(MENU);
|
||||
else if(argv[i]==NAME_NONE);//do nothing
|
||||
else
|
||||
cerr<<"Fluxbox::Titlebar Unknown type: \""<<argv[i]<<"\""<<endl;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void Fluxbox::loadTitlebar() {
|
||||
XrmDatabase database;
|
||||
database = XrmGetFileDatabase(resource.titlebar_file);
|
||||
if (!database)
|
||||
cerr<<"Fluxbox: Cant open "<<resource.titlebar_file<<" !"<<endl;
|
||||
|
||||
XrmValue value;
|
||||
char *value_type;
|
||||
|
||||
//clear titlebar
|
||||
titlebar.left.clear();
|
||||
titlebar.right.clear();
|
||||
|
||||
if (XrmGetResource(database, "left", "Left", &value_type, &value)) {
|
||||
setTitlebar(titlebar.left, value.addr);
|
||||
} else {
|
||||
cerr<<"Fluxbox: \'Left\' not found in "<<resource.titlebar_file<<endl;
|
||||
cerr<<"Using default."<<endl;
|
||||
//default settings
|
||||
titlebar.left.push_back(SHADE);
|
||||
}
|
||||
|
||||
if (XrmGetResource(database, "right", "Right", &value_type, &value)) {
|
||||
setTitlebar(titlebar.right, value.addr);
|
||||
} else {
|
||||
cerr<<"Fluxbox: \'Right\' not found in "<<resource.titlebar_file<<endl;
|
||||
cerr<<"Using default."<<endl;
|
||||
//default settings
|
||||
titlebar.right.push_back(STICK);
|
||||
titlebar.right.push_back(MINIMIZE);
|
||||
titlebar.right.push_back(MAXIMIZE);
|
||||
titlebar.right.push_back(CLOSE);
|
||||
}
|
||||
|
||||
// XrmDestroyDatabase(database);
|
||||
}
|
||||
|
||||
void Fluxbox::load_rc(BScreen *screen) {
|
||||
|
@ -2418,13 +2389,8 @@ void Fluxbox::real_reconfigure(void) {
|
|||
grab();
|
||||
|
||||
XrmDatabase new_blackboxrc = (XrmDatabase) 0;
|
||||
char style[MAXPATHLEN + 64];
|
||||
|
||||
auto_ptr<char> dbfile(getRcFilename());
|
||||
|
||||
sprintf(style, "session.styleFile: %s", resource.style_file);
|
||||
XrmPutLineResource(&new_blackboxrc, style);
|
||||
|
||||
XrmDatabase old_blackboxrc = XrmGetFileDatabase(dbfile.get());
|
||||
|
||||
XrmMergeDatabases(new_blackboxrc, &old_blackboxrc);
|
||||
|
@ -2452,7 +2418,7 @@ void Fluxbox::real_reconfigure(void) {
|
|||
}
|
||||
|
||||
//reconfigure keys
|
||||
key->reconfigure(resource.keys_file);
|
||||
key->reconfigure(const_cast<char *>(m_rc_keyfile->c_str()));
|
||||
|
||||
//reconfigure tabs
|
||||
reconfigureTabs();
|
||||
|
@ -2527,14 +2493,14 @@ void Fluxbox::real_rereadMenu(void) {
|
|||
it.current()->rereadMenu();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
void Fluxbox::saveStyleFilename(const char *filename) {
|
||||
if (resource.style_file)
|
||||
delete [] resource.style_file;
|
||||
|
||||
resource.style_file = StringUtil::strdup(filename);
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
void Fluxbox::saveMenuFilename(const char *filename) {
|
||||
Bool found = False;
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
// $Id: fluxbox.hh,v 1.6 2002/01/11 09:18:58 fluxgen Exp $
|
||||
// $Id: fluxbox.hh,v 1.7 2002/01/18 01:23:54 fluxgen Exp $
|
||||
|
||||
#ifndef _FLUXBOX_HH_
|
||||
#define _FLUXBOX_HH_
|
||||
|
@ -45,8 +45,13 @@
|
|||
# endif // HAVE_SYS_TIME_H
|
||||
#endif // TIME_WITH_SYS_TIME
|
||||
|
||||
//forward declaration
|
||||
class Fluxbox;
|
||||
#ifndef _RESOURCE_HH_
|
||||
#include "Resource.hh"
|
||||
#endif
|
||||
|
||||
#ifndef _KEYS_HH_
|
||||
#include "Keys.hh"
|
||||
#endif
|
||||
|
||||
#ifndef _BASEDISPLAY_HH_
|
||||
#include "BaseDisplay.hh"
|
||||
|
@ -76,10 +81,6 @@ class Fluxbox;
|
|||
#include "Toolbar.hh"
|
||||
#endif
|
||||
|
||||
#ifndef _KEYS_HH_
|
||||
#include "Keys.hh"
|
||||
#endif
|
||||
|
||||
#ifdef SLIT
|
||||
# include "Slit.hh"
|
||||
#endif // SLIT
|
||||
|
@ -93,10 +94,10 @@ public:
|
|||
|
||||
static Fluxbox *instance(int m_argc=0, char **m_argv=0, char *dpy_name=0, char *rc=0);
|
||||
|
||||
inline bool useTabs() const { return resource.tabs; }
|
||||
inline bool useIconBar() const { return resource.iconbar; }
|
||||
inline void saveTabs(bool value) { resource.tabs = value; }
|
||||
inline void saveIconBar(bool value) { resource.iconbar = value; }
|
||||
inline bool useTabs() { return *m_rc_tabs; }
|
||||
inline bool useIconBar() { return *m_rc_iconbar; }
|
||||
inline void saveTabs(bool value) { *m_rc_tabs = value; }
|
||||
inline void saveIconBar(bool value) { m_rc_iconbar = value; }
|
||||
#ifdef HAVE_GETPID
|
||||
inline const Atom &getFluxboxPidAtom(void) const { return fluxbox_pid; }
|
||||
#ifdef KDE
|
||||
|
@ -124,24 +125,24 @@ public:
|
|||
|
||||
enum Titlebar{SHADE=0, MINIMIZE, MAXIMIZE, CLOSE, STICK, MENU, EMPTY};
|
||||
|
||||
inline const std::vector<Fluxbox::Titlebar>& getTitlebarRight() { return titlebar.right; }
|
||||
inline const std::vector<Fluxbox::Titlebar>& getTitlebarLeft() { return titlebar.left; }
|
||||
inline const char *getStyleFilename(void) const
|
||||
{ return resource.style_file; }
|
||||
inline const std::vector<Fluxbox::Titlebar>& getTitlebarRight() { return *m_rc_titlebar_right; }
|
||||
inline const std::vector<Fluxbox::Titlebar>& getTitlebarLeft() { return *m_rc_titlebar_left; }
|
||||
inline const char *getStyleFilename(void)
|
||||
{ return m_rc_stylefile->c_str(); }
|
||||
|
||||
inline const char *getMenuFilename(void) const
|
||||
{ return resource.menu_file; }
|
||||
inline const char *getMenuFilename(void)
|
||||
{ return m_rc_menufile->c_str(); }
|
||||
|
||||
inline const int &getColorsPerChannel(void) const
|
||||
{ return resource.colors_per_channel; }
|
||||
inline const int &getColorsPerChannel(void)
|
||||
{ return *m_rc_colors_per_channel; }
|
||||
|
||||
inline const timeval &getAutoRaiseDelay(void) const
|
||||
{ return resource.auto_raise_delay; }
|
||||
|
||||
inline const unsigned long &getCacheLife(void) const
|
||||
{ return resource.cache_life; }
|
||||
inline const unsigned long &getCacheMax(void) const
|
||||
{ return resource.cache_max; }
|
||||
inline const unsigned int getCacheLife(void)
|
||||
{ return *m_rc_cache_life * 60000; }
|
||||
inline const unsigned int getCacheMax(void)
|
||||
{ return *m_rc_cache_max; }
|
||||
|
||||
inline void maskWindowEvents(Window w, FluxboxWindow *bw)
|
||||
{ masked = w; masked_window = bw; }
|
||||
|
@ -152,7 +153,7 @@ public:
|
|||
void load_rc(BScreen *);
|
||||
void loadRootCommand(BScreen *);
|
||||
void loadTitlebar();
|
||||
void saveStyleFilename(const char *);
|
||||
void saveStyleFilename(const char *val) { m_rc_stylefile = (val == 0 ? "" : val); }
|
||||
void saveMenuFilename(const char *);
|
||||
void saveTitlebarFilename(const char *);
|
||||
void saveMenuSearch(Window, Basemenu *);
|
||||
|
@ -201,6 +202,7 @@ public:
|
|||
inline Z *getData(void) { return data; }
|
||||
};
|
||||
|
||||
typedef std::vector<Fluxbox::Titlebar> TitlebarList;
|
||||
|
||||
private:
|
||||
typedef struct MenuTimestamp {
|
||||
|
@ -211,20 +213,22 @@ private:
|
|||
struct resource {
|
||||
Time double_click_interval;
|
||||
|
||||
char *menu_file, *style_file, *titlebar_file, *keys_file;
|
||||
int colors_per_channel;
|
||||
timeval auto_raise_delay;
|
||||
unsigned long cache_life, cache_max;
|
||||
bool tabs, iconbar;
|
||||
//unsigned long cache_life, cache_max;
|
||||
} resource;
|
||||
|
||||
struct titlebar_t {
|
||||
std::vector<Fluxbox::Titlebar> left;
|
||||
std::vector<Fluxbox::Titlebar> right;
|
||||
};
|
||||
ResourceManager m_resourcemanager;
|
||||
|
||||
titlebar_t titlebar;
|
||||
std::vector<std::string> parseTitleArgs(const char *arg);
|
||||
//--- Resources
|
||||
Resource<bool> m_rc_tabs, m_rc_iconbar;
|
||||
Resource<int> m_rc_colors_per_channel;
|
||||
Resource<std::string> m_rc_stylefile,
|
||||
m_rc_menufile, m_rc_keyfile;
|
||||
|
||||
Resource<TitlebarList> m_rc_titlebar_left, m_rc_titlebar_right;
|
||||
Resource<unsigned int> m_rc_cache_life, m_rc_cache_max;
|
||||
|
||||
//std::vector<std::string> parseTitleArgs(const char *arg);
|
||||
void setTitlebar(std::vector<Fluxbox::Titlebar>& dir, const char *arg);
|
||||
|
||||
typedef DataSearch<FluxboxWindow> WindowSearch;
|
||||
|
@ -262,6 +266,7 @@ private:
|
|||
char *rc_file, **argv;
|
||||
int argc;
|
||||
Keys *key;
|
||||
|
||||
void doWindowAction(Keys::KeyAction action);
|
||||
protected:
|
||||
Fluxbox(int, char **, char * = 0, char * = 0);
|
||||
|
@ -274,6 +279,7 @@ protected:
|
|||
|
||||
virtual void process_event(XEvent *);
|
||||
//only main should be able to creat new blackbox object
|
||||
//TODO this must be removed!
|
||||
friend int main(int,char **);
|
||||
static Fluxbox *singleton; //singleton object ( can only be destroyed by main )
|
||||
virtual ~Fluxbox(void);
|
||||
|
|
Loading…
Reference in a new issue