From 7c46623b6f990b6e0a93b8424e37967462c4f6e7 Mon Sep 17 00:00:00 2001 From: Pavel Labath Date: Thu, 16 Jun 2011 22:36:18 +0200 Subject: Make session.screenX.workspace_names a real FbTk::Resource instead of the add-on hack it was. This also fixes a lot of problems with saving of config. --- src/Screen.cc | 39 ++++++++++++++--------------- src/Screen.hh | 11 +++++--- src/fluxbox.cc | 79 ---------------------------------------------------------- 3 files changed, 27 insertions(+), 102 deletions(-) diff --git a/src/Screen.cc b/src/Screen.cc index 0aaa718..77b7ca3 100644 --- a/src/Screen.cc +++ b/src/Screen.cc @@ -243,8 +243,11 @@ const EnumTraits::Pair EnumTraits(), scrname + ".workspaceNames"), opaque_move(rm, true, scrname + ".opaqueMove"), full_max(rm, false, scrname+".fullMaximization"), max_ignore_inc(rm, true, scrname+".maxIgnoreIncrement"), @@ -388,9 +391,6 @@ BScreen::BScreen(FbTk::ResourceManager_base &rm, Keys::GLOBAL|Keys::ON_DESKTOP); rootWindow().setCursor(XCreateFontCursor(disp, XC_left_ptr)); - // load this screens resources - fluxbox->load_rc(*this); - // setup image cache engine m_image_control.reset(new FbTk::ImageControl(scrn, fluxbox->colorsPerChannel(), @@ -856,15 +856,14 @@ void BScreen::reconfigure() { // realize the number of workspaces from the init-file const unsigned int nr_ws = *resource.workspaces; - if (nr_ws > m_workspaces_list.size()) { - while(nr_ws != m_workspaces_list.size()) { - addWorkspace(); - } - } else if (nr_ws < m_workspaces_list.size()) { - while(nr_ws != m_workspaces_list.size()) { - removeLastWorkspace(); - } - } + while(nr_ws > m_workspaces_list.size()) + addWorkspace(); + while(nr_ws < m_workspaces_list.size()) + removeLastWorkspace(); + + // and update their names + for(size_t i = 0; i < std::min(m_workspaces_list.size(), resource.workspace_names->size()); ++i) + m_workspaces_list[i]->setName( (*resource.workspace_names)[i] ); // update menu filenames m_rootmenu->reloadHelper()->setMainFile(fluxbox->getMenuFilename()); @@ -904,14 +903,14 @@ void BScreen::reconfigureTabs() { void BScreen::updateWorkspaceName(unsigned int w) { Workspace *space = getWorkspace(w); if (space) { - m_workspace_names[w] = space->name(); + (*resource.workspace_names)[w] = space->name(); m_workspacenames_sig.emit(*this); Fluxbox::instance()->save_rc(); } } void BScreen::removeWorkspaceNames() { - m_workspace_names.clear(); + resource.workspace_names->clear(); } void BScreen::addIcon(FluxboxWindow *w) { @@ -1345,17 +1344,17 @@ void BScreen::updateAvailableWorkspaceArea() { m_workspace_area_sig.emit(*this); } -void BScreen::addWorkspaceName(const char *name) { - m_workspace_names.push_back(FbTk::FbStringUtil::LocaleStrToFb(name)); - Workspace *wkspc = getWorkspace(m_workspace_names.size()-1); +void BScreen::addWorkspaceName(const std::string &name) { + resource.workspace_names->push_back(name); + Workspace *wkspc = getWorkspace(resource.workspace_names->size()-1); if (wkspc) - wkspc->setName(m_workspace_names.back()); + wkspc->setName(name); } string BScreen::getNameOfWorkspace(unsigned int workspace) const { - if (workspace < m_workspace_names.size()) - return m_workspace_names[workspace]; + if (workspace < resource.workspace_names->size()) + return (*resource.workspace_names)[workspace]; else return ""; } diff --git a/src/Screen.hh b/src/Screen.hh index e7b439c..138cd1c 100644 --- a/src/Screen.hh +++ b/src/Screen.hh @@ -190,7 +190,7 @@ public: const Workspaces &getWorkspacesList() const { return m_workspaces_list; } Workspaces &getWorkspacesList() { return m_workspaces_list; } - const WorkspaceNames &getWorkspaceNames() const { return m_workspace_names; } + const WorkspaceNames &getWorkspaceNames() const { return *resource.workspace_names; } /** @name Screen signals */ @@ -321,7 +321,7 @@ public: /// remove all workspace names void removeWorkspaceNames(); /// add a workspace name to the end of the workspace name list - void addWorkspaceName(const char *name); + void addWorkspaceName(const std::string &name); /// add a window to the icon list void addIcon(FluxboxWindow *win); /// remove a window from the icon list @@ -493,7 +493,6 @@ private: Workspace *m_current_workspace; - WorkspaceNames m_workspace_names; Workspaces m_workspaces_list; std::auto_ptr m_focused_windowtheme, @@ -511,6 +510,12 @@ private: struct ScreenResource { ScreenResource(FbTk::ResourceManager_base &rm, const std::string &scrname); + static const char workspace_names_delim[]; + FbTk::Resource< + std::vector, + FbTk::VectorTraits + > workspace_names; + FbTk::BoolResource opaque_move, full_max, max_ignore_inc, max_disable_move, max_disable_resize, workspace_warping, show_window_pos, auto_raise, click_raises; diff --git a/src/fluxbox.cc b/src/fluxbox.cc index 0c391dc..162a409 100644 --- a/src/fluxbox.cc +++ b/src/fluxbox.cc @@ -1131,36 +1131,6 @@ void Fluxbox::save_rc() { cerr<<_FB_CONSOLETEXT(Fluxbox, BadRCFile, "rc filename is invalid!", "Bad settings file")<screenNumber()); - workspaces_string += ".workspaceNames: "; - - // these are static, but may not be saved in the users resource file, - // writing these resources will allow the user to edit them at a later - // time... but loading the defaults before saving allows us to rewrite the - // users changes... - - const BScreen::WorkspaceNames& names = screen->getWorkspaceNames(); - for (size_t i=0; i < names.size(); i++) { - workspaces_string += FbTk::FbStringUtil::FbStrToLocale(names[i]); - workspaces_string += ','; - } - - XrmPutLineResource(&new_rc, workspaces_string.c_str()); - - } - - XrmDatabase old_rc = XrmGetFileDatabase(dbfile.c_str()); - - XrmMergeDatabases(new_rc, &old_rc); - XrmPutFileDatabase(old_rc, dbfile.c_str()); - XrmDestroyDatabase(old_rc); - fbdbg<<__FILE__<<"("<<__LINE__<<"): ------------ SAVING DONE"<(names, values, ","); - BScreen::WorkspaceNames::iterator it; - for(it = names.begin(); it != names.end(); it++) { - if (!(*it).empty() && (*it) != "") - screen.addWorkspaceName((*it).c_str()); - } - - } -} - void Fluxbox::reconfigure() { load_rc(); m_reconfigure_wait = true; @@ -1273,11 +1199,6 @@ void Fluxbox::real_reconfigure() { FbTk::Transparent::usePseudoTransparent(*m_rc_pseudotrans); - ScreenList::iterator screen_it = m_screen_list.begin(); - ScreenList::iterator screen_it_end = m_screen_list.end(); - for (; screen_it != screen_it_end; ++screen_it) - load_rc(*(*screen_it)); - STLUtil::forAll(m_screen_list, mem_fun(&BScreen::reconfigure)); m_key->reconfigure(); STLUtil::forAll(m_atomhandler, mem_fun(&AtomHandler::reconfigure)); -- cgit v0.11.2