Fixed resources

This commit is contained in:
fluxgen 2002-01-20 02:17:23 +00:00
parent aaa0c6d078
commit 6ea3678d02
2 changed files with 201 additions and 124 deletions

View file

@ -99,6 +99,8 @@
#endif // FONT_ELEMENT_SIZE
#include <iostream>
#include <memory>
using namespace std;
static Bool running = True;
@ -125,10 +127,108 @@ static int dcmp(const void *one, const void *two) {
return (strcmp((*(char **) one), (*(char **) two)));
}
BScreen::BScreen(Fluxbox *b, int scrn) : ScreenInfo(b, scrn),
rootcommand("")
//---------- resource manipulators ---------
template<>
void Resource<Tab::Alignment>::
setFromString(const char *strval) {
m_value = Tab::getTabAlignmentNum(strval);
}
template<>
void Resource<Tab::Placement>::
setFromString(const char *strval) {
m_value = Tab::getTabPlacementNum(strval);
}
template<>
void Resource<Toolbar::Placement>::
setFromString(const char *strval) {
if (strcasecmp(strval, "TopLeft")==0)
m_value = Toolbar::TOPLEFT;
else if (strcasecmp(strval, "BottomLeft")==0)
m_value = Toolbar::BOTTOMLEFT;
else if (strcasecmp(strval, "TopCenter")==0)
m_value = Toolbar::TOPCENTER;
else if (strcasecmp(strval, "BottomCenter")==0)
m_value = Toolbar::BOTTOMCENTER;
else if (strcasecmp(strval, "TopRight")==0)
m_value = Toolbar::TOPRIGHT;
else if (strcasecmp(strval, "BottomRight")==0)
m_value = Toolbar::BOTTOMRIGHT;
else
setDefaultValue();
}
//--------- resource accessors --------------
template<>
string Resource<Tab::Alignment>::
getString() {
return Tab::getTabAlignmentString(m_value);
}
template<>
string Resource<Tab::Placement>::
getString() {
return Tab::getTabPlacementString(m_value);
}
template<>
string Resource<Toolbar::Placement>::
getString() {
switch (m_value) {
case Toolbar::TOPLEFT:
return string("TopLeft");
break;
case Toolbar::BOTTOMLEFT:
return string("BottomLeft");
break;
case Toolbar::TOPCENTER:
return string("TopCenter");
break;
case Toolbar::BOTTOMCENTER:
return string("BottomCenter");
break;
case Toolbar::TOPRIGHT:
return string("TopRight");
break;
case Toolbar::BOTTOMRIGHT:
return string("BottomRight");
break;
}
//default string
return string("BottomCenter");
}
BScreen::ScreenResource::ScreenResource(ResourceManager &rm,
const std::string &scrname, const std::string &altscrname):
toolbar_on_top(rm, false, scrname+".toolbar.onTop", altscrname+".Toolbar.OnTop"),
toolbar_auto_hide(rm, false, scrname+".toolbar.autoHide", altscrname+".Toolbar.AutoHide"),
image_dither(rm, false, scrname+".imageDither", altscrname+".ImageDither"),
opaque_move(rm, false, "session.opaqueMove", "Session.OpaqueMove"),
full_max(rm, true, scrname+".fullMaximization", altscrname+".FullMaximization"),
max_over_slit(rm, true, scrname+".maxOverSlit",altscrname+".MaxOverSlit"),
tab_rotate_vertical(rm, true, scrname+".tab.rotatevertical", altscrname+".Tab.RotateVertical"),
sloppy_window_grouping(rm, true, scrname+".sloppywindowgrouping", altscrname+".SloppyWindowGrouping"),
rootcommand(rm, "", scrname+".rootCommand", altscrname+".RootCommand"),
workspaces(rm, 1, scrname+".workspaces", altscrname+".Workspaces"),
toolbar_width_percent(rm, 65, scrname+".toolbar.widthPercent", altscrname+".Toolbar.WidthPercent"),
edge_snap_threshold(rm, 0, scrname+".edgeSnapThreshold", altscrname+".EdgeSnapThreshold"),
tab_width(rm, 64, scrname+".tab.width", altscrname+".Tab.Width"),
tab_height(rm, 16, scrname+".tab.height", altscrname+".Tab.Height"),
tab_placement(rm, Tab::PTOP, scrname+".tab.placement", altscrname+".Tab.Placement"),
tab_alignment(rm, Tab::ALEFT, scrname+".tab.alignment", altscrname+".Tab.Alignment"),
toolbar_placement(rm, Toolbar::BOTTOMCENTER, scrname+".toolbar.placement", altscrname+".Toolbar.Placement")
{
};
BScreen::BScreen(ResourceManager &rm, Fluxbox *b,
const string &screenname, const string &altscreenname,
int scrn) : ScreenInfo(b, scrn),
theme(0),
resource(rm, screenname, altscreenname)
{
theme = 0;
fluxbox = b;
event_mask = ColormapChangeMask | EnterWindowMask | PropertyChangeMask |
@ -192,7 +292,7 @@ rootcommand("")
fluxbox->load_rc(this);
image_control->setDither(resource.image_dither);
image_control->setDither(*resource.image_dither);
theme = new Theme(getBaseDisplay()->getXDisplay(), getRootWindow(), getColormap(), getScreenNumber(),
image_control, fluxbox->getStyleFilename(), getRootCommand().c_str());
@ -226,6 +326,7 @@ rootcommand("")
0, 0,
#endif // NLS
"0: 0000 x 0: 0000");
int l = strlen(s);
if (i18n->multibyte()) {
@ -287,8 +388,8 @@ rootcommand("")
configmenu = new Configmenu(this);
Workspace *wkspc = (Workspace *) 0;
if (resource.workspaces != 0) {
for (int i = 0; i < resource.workspaces; ++i) {
if (*resource.workspaces != 0) {
for (int i = 0; i < *resource.workspaces; ++i) {
wkspc = new Workspace(this, workspacesList->count());
workspacesList->insert(wkspc);
workspacemenu->insert(wkspc->getName(), wkspc->getMenu());

View file

@ -22,7 +22,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
// $Id: Screen.hh,v 1.9 2002/01/11 10:20:00 fluxgen Exp $
// $Id: Screen.hh,v 1.10 2002/01/20 02:17:23 fluxgen Exp $
#ifndef _SCREEN_HH_
#define _SCREEN_HH_
@ -87,50 +87,39 @@ class BScreen;
class BScreen : public ScreenInfo {
public:
BScreen(Fluxbox *, int);
~BScreen(void);
BScreen(ResourceManager &rm, Fluxbox *b,
const string &screenname, const string &altscreenname,
int scrn);
~BScreen();
inline const Bool &isToolbarOnTop(void) const
{ return resource.toolbar_on_top; }
inline const Bool &doToolbarAutoHide(void) const
{ return resource.toolbar_auto_hide; }
inline const Bool &isSloppyFocus(void) const
{ return resource.sloppy_focus; }
inline const Bool &isSemiSloppyFocus(void) const
{ return resource.semi_sloppy_focus; }
inline const Bool &isRootColormapInstalled(void) const
{ return root_colormap_installed; }
inline const Bool &isScreenManaged(void) const { return managed; }
inline const Bool &isTabRotateVertical(void) const
{ return resource.tab_rotate_vertical; }
inline const Bool &isSloppyWindowGrouping(void) const
{ return resource.sloppy_window_grouping; }
inline const Bool &doAutoRaise(void) const { return resource.auto_raise; }
inline const Bool &doImageDither(void) const
{ return resource.image_dither; }
inline const Bool &doOrderedDither(void) const
{ return resource.ordered_dither; }
inline const Bool &doMaxOverSlit(void) const { return resource.max_over_slit; }
inline const Bool &doOpaqueMove(void) const { return resource.opaque_move; }
inline const Bool &doFullMax(void) const { return resource.full_max; }
inline const Bool &doFocusNew(void) const { return resource.focus_new; }
inline const Bool &doFocusLast(void) const { return resource.focus_last; }
inline const bool isToolbarOnTop(void) { return *resource.toolbar_on_top; }
inline const bool doToolbarAutoHide(void) { return *resource.toolbar_auto_hide; }
inline const bool isSloppyFocus(void) { return resource.sloppy_focus; }
inline const bool isSemiSloppyFocus(void) { return resource.semi_sloppy_focus; }
inline const bool isRootColormapInstalled(void) { return root_colormap_installed; }
inline const bool isScreenManaged(void) { return managed; }
inline const bool isTabRotateVertical(void) { return *resource.tab_rotate_vertical; }
inline const bool isSloppyWindowGrouping(void) { return *resource.sloppy_window_grouping; }
inline const bool doAutoRaise(void) { return resource.auto_raise; }
inline const bool doImageDither(void) { return *resource.image_dither; }
inline const bool doMaxOverSlit(void) { return *resource.max_over_slit; }
inline const bool doOpaqueMove(void) { return *resource.opaque_move; }
inline const bool doFullMax(void) { return *resource.full_max; }
inline const bool doFocusNew(void) { return resource.focus_new; }
inline const bool doFocusLast(void) { return resource.focus_last; }
inline const GC &getOpGC() const { return theme->getOpGC(); }
inline const BColor *getBorderColor(void) { return &theme->getBorderColor(); }
inline BImageControl *getImageControl(void) { return image_control; }
inline Rootmenu *getRootmenu(void) { return rootmenu; }
inline std::string &getRootCommand(void) { return rootcommand; }
inline std::string &getRootCommand(void) { return *resource.rootcommand; }
#ifdef SLIT
inline const Bool &isSlitOnTop(void) const { return resource.slit_on_top; }
inline const Bool &doSlitAutoHide(void) const
{ return resource.slit_auto_hide; }
inline const Bool &doSlitAutoHide(void) const { return resource.slit_auto_hide; }
inline Slit *getSlit(void) { return slit; }
inline const int &getSlitPlacement(void) const
{ return resource.slit_placement; }
inline const int &getSlitDirection(void) const
{ return resource.slit_direction; }
inline const int &getSlitPlacement(void) const { return resource.slit_placement; }
inline const int &getSlitDirection(void) const { return resource.slit_direction; }
inline void saveSlitPlacement(int p) { resource.slit_placement = p; }
inline void saveSlitDirection(int d) { resource.slit_direction = d; }
inline void saveSlitOnTop(Bool t) { resource.slit_on_top = t; }
@ -144,61 +133,41 @@ public:
inline Workspacemenu *getWorkspacemenu(void) { return workspacemenu; }
inline const unsigned int getHandleWidth(void) const
{ return theme->getHandleWidth(); }
inline const unsigned int getBevelWidth(void) const
{ return theme->getBevelWidth(); }
inline const unsigned int getFrameWidth(void) const
{ return theme->getFrameWidth(); }
inline const unsigned int getBorderWidth(void) const
{ return theme->getBorderWidth(); }
inline const unsigned int getBorderWidth2x(void) const
{ return theme->getBorderWidth()*2; }
inline const int getCurrentWorkspaceID()
{ return current_workspace->getWorkspaceID(); }
inline const unsigned int getHandleWidth(void) const { return theme->getHandleWidth(); }
inline const unsigned int getBevelWidth(void) const { return theme->getBevelWidth(); }
inline const unsigned int getFrameWidth(void) const { return theme->getFrameWidth(); }
inline const unsigned int getBorderWidth(void) const { return theme->getBorderWidth(); }
inline const unsigned int getBorderWidth2x(void) const { return theme->getBorderWidth()*2; }
inline const int getCurrentWorkspaceID() { return current_workspace->getWorkspaceID(); }
inline const int getCount(void) { return workspacesList->count(); }
inline const int getIconCount(void) { return iconList->count(); }
inline LinkedList<FluxboxWindow> *getIconList(void) { return iconList; }
inline const int &getNumberOfWorkspaces(void) const
{ return resource.workspaces; }
inline const int &getToolbarPlacement(void) const
{ return resource.toolbar_placement; }
inline const int &getToolbarWidthPercent(void) const
{ return resource.toolbar_width_percent; }
inline const int &getPlacementPolicy(void) const
{ return resource.placement_policy; }
inline const int &getEdgeSnapThreshold(void) const
{ return resource.edge_snap_threshold; }
inline const int &getRowPlacementDirection(void) const
{ return resource.row_direction; }
inline const int &getColPlacementDirection(void) const
{ return resource.col_direction; }
inline const unsigned int &getTabWidth(void) const
{ return resource.tab_width; }
inline const unsigned int &getTabHeight(void) const
{ return resource.tab_height; }
inline const int getTabPlacement(void)
{ return resource.tab_placement; }
inline const int getTabAlignment(void)
{ return resource.tab_alignment; }
inline const int getNumberOfWorkspaces(void) { return *resource.workspaces; }
inline const Toolbar::Placement getToolbarPlacement(void) { return *resource.toolbar_placement; }
inline const int getToolbarWidthPercent(void) { return *resource.toolbar_width_percent; }
inline const int getPlacementPolicy(void) const { return resource.placement_policy; }
inline const int getEdgeSnapThreshold(void) { return *resource.edge_snap_threshold; }
inline const int getRowPlacementDirection(void) const { return resource.row_direction; }
inline const int getColPlacementDirection(void) const { return resource.col_direction; }
inline const unsigned int getTabWidth(void) { return *resource.tab_width; }
inline const unsigned int getTabHeight(void) { return *resource.tab_height; }
inline const Tab::Placement getTabPlacement(void) { return *resource.tab_placement; }
inline const Tab::Alignment getTabAlignment(void) { return *resource.tab_alignment; }
inline void setRootColormapInstalled(Bool r) { root_colormap_installed = r; }
inline void saveRootCommand(std::string rootcmd) { rootcommand = rootcmd; }
inline void saveRootCommand(std::string rootcmd) { *resource.rootcommand = rootcmd; }
inline void saveSloppyFocus(Bool s) { resource.sloppy_focus = s; }
inline void saveSemiSloppyFocus(Bool s) { resource.semi_sloppy_focus = s; }
inline void saveAutoRaise(Bool a) { resource.auto_raise = a; }
inline void saveWorkspaces(int w) { resource.workspaces = w; }
inline void saveToolbarOnTop(Bool r) { resource.toolbar_on_top = r; }
inline void saveToolbarAutoHide(Bool r) { resource.toolbar_auto_hide = r; }
inline void saveToolbarWidthPercent(int w)
{ resource.toolbar_width_percent = w; }
inline void saveToolbarPlacement(int p) { resource.toolbar_placement = p; }
inline void saveToolbarWidthPercent(int w) { resource.toolbar_width_percent = w; }
inline void saveToolbarPlacement(Toolbar::Placement p) { *resource.toolbar_placement = p; }
inline void savePlacementPolicy(int p) { resource.placement_policy = p; }
inline void saveRowPlacementDirection(int d) { resource.row_direction = d; }
inline void saveColPlacementDirection(int d) { resource.col_direction = d; }
inline void saveEdgeSnapThreshold(int t)
{ resource.edge_snap_threshold = t; }
inline void saveEdgeSnapThreshold(int t) { resource.edge_snap_threshold = t; }
inline void saveImageDither(Bool d) { resource.image_dither = d; }
inline void saveMaxOverSlit(Bool m) { resource.max_over_slit = m; }
inline void saveOpaqueMove(Bool o) { resource.opaque_move = o; }
@ -207,8 +176,8 @@ public:
inline void saveFocusLast(Bool f) { resource.focus_last = f; }
inline void saveTabWidth(unsigned int w) { resource.tab_width = w; }
inline void saveTabHeight(unsigned int h) { resource.tab_height = h; }
inline void saveTabPlacement(unsigned int p) { resource.tab_placement = p; }
inline void saveTabAlignment(unsigned int a) { resource.tab_alignment = a; }
inline void saveTabPlacement(Tab::Placement p) { *resource.tab_placement = p; }
inline void saveTabAlignment(Tab::Alignment a) { *resource.tab_alignment = a; }
inline void saveTabRotateVertical(Bool r)
{ resource.tab_rotate_vertical = r; }
inline void saveSloppyWindowGrouping(Bool s)
@ -280,7 +249,6 @@ public:
private:
Theme *theme;
std::string rootcommand;
Bool root_colormap_installed, managed, geom_visible;
GC opGC;
@ -312,17 +280,25 @@ private:
LinkedList<char> *workspaceNames;
LinkedList<Workspace> *workspacesList;
struct resource {
struct ScreenResource {
ScreenResource(ResourceManager &rm, const std::string &scrname,
const std::string &altscrname);
Bool toolbar_on_top, toolbar_auto_hide, sloppy_focus, auto_raise,
auto_edge_balance, image_dither, ordered_dither, opaque_move, full_max,
focus_new, focus_last, max_over_slit, tab_rotate_vertical, semi_sloppy_focus,
Resource<bool> toolbar_on_top, toolbar_auto_hide,
image_dither, opaque_move, full_max,
max_over_slit, tab_rotate_vertical,
sloppy_window_grouping;
Resource<std::string> rootcommand;
bool auto_raise, sloppy_focus, semi_sloppy_focus, focus_new, focus_last,
ordered_dither;
Resource<int> workspaces, toolbar_width_percent, edge_snap_threshold,
tab_width, tab_height;
int placement_policy, row_direction, col_direction;
int workspaces, toolbar_placement, toolbar_width_percent, placement_policy,
edge_snap_threshold, row_direction, col_direction;
Resource<Tab::Placement> tab_placement;
Resource<Tab::Alignment> tab_alignment;
Resource<Toolbar::Placement> toolbar_placement;
unsigned int tab_placement, tab_alignment, tab_width, tab_height;
#ifdef SLIT
Bool slit_on_top, slit_auto_hide;