diff options
author | Pavel Labath <pavelo@centrum.sk> | 2011-06-16 20:36:18 (GMT) |
---|---|---|
committer | Paul Tagliamonte <paultag@fluxbox.org> | 2012-04-07 02:11:28 (GMT) |
commit | dbb84308855de040c043cf1c1f0ab941d6bd3be7 (patch) | |
tree | a46416d288c0d66f6113600c5bcb61f0339009f0 /src | |
parent | fadff675a5163dea6f78c53d7b157faed42f02ec (diff) | |
download | fluxbox_paul-dbb84308855de040c043cf1c1f0ab941d6bd3be7.zip fluxbox_paul-dbb84308855de040c043cf1c1f0ab941d6bd3be7.tar.bz2 |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/Screen.cc | 39 | ||||
-rw-r--r-- | src/Screen.hh | 11 | ||||
-rw-r--r-- | src/fluxbox.cc | 35 |
3 files changed, 27 insertions, 58 deletions
diff --git a/src/Screen.cc b/src/Screen.cc index 373932f..6db43ac 100644 --- a/src/Screen.cc +++ b/src/Screen.cc | |||
@@ -243,8 +243,11 @@ const EnumTraits<FbWinFrame::TabPlacement>::Pair EnumTraits<FbWinFrame::TabPlace | |||
243 | } // end namespace FbTk | 243 | } // end namespace FbTk |
244 | 244 | ||
245 | 245 | ||
246 | const char BScreen::ScreenResource::workspace_names_delim[] = ","; | ||
247 | |||
246 | BScreen::ScreenResource::ScreenResource(FbTk::ResourceManager_base &rm, | 248 | BScreen::ScreenResource::ScreenResource(FbTk::ResourceManager_base &rm, |
247 | const string &scrname): | 249 | const string &scrname): |
250 | workspace_names(rm, std::vector<std::string>(), scrname + ".workspaceNames"), | ||
248 | opaque_move(rm, true, scrname + ".opaqueMove"), | 251 | opaque_move(rm, true, scrname + ".opaqueMove"), |
249 | full_max(rm, false, scrname+".fullMaximization"), | 252 | full_max(rm, false, scrname+".fullMaximization"), |
250 | max_ignore_inc(rm, true, scrname+".maxIgnoreIncrement"), | 253 | max_ignore_inc(rm, true, scrname+".maxIgnoreIncrement"), |
@@ -388,9 +391,6 @@ BScreen::BScreen(FbTk::ResourceManager_base &rm, | |||
388 | Keys::GLOBAL|Keys::ON_DESKTOP); | 391 | Keys::GLOBAL|Keys::ON_DESKTOP); |
389 | rootWindow().setCursor(XCreateFontCursor(disp, XC_left_ptr)); | 392 | rootWindow().setCursor(XCreateFontCursor(disp, XC_left_ptr)); |
390 | 393 | ||
391 | // load this screens resources | ||
392 | fluxbox->load_rc(*this); | ||
393 | |||
394 | // setup image cache engine | 394 | // setup image cache engine |
395 | m_image_control.reset(new FbTk::ImageControl(scrn, | 395 | m_image_control.reset(new FbTk::ImageControl(scrn, |
396 | fluxbox->colorsPerChannel(), | 396 | fluxbox->colorsPerChannel(), |
@@ -856,15 +856,14 @@ void BScreen::reconfigure() { | |||
856 | 856 | ||
857 | // realize the number of workspaces from the init-file | 857 | // realize the number of workspaces from the init-file |
858 | const unsigned int nr_ws = *resource.workspaces; | 858 | const unsigned int nr_ws = *resource.workspaces; |
859 | if (nr_ws > m_workspaces_list.size()) { | 859 | while(nr_ws > m_workspaces_list.size()) |
860 | while(nr_ws != m_workspaces_list.size()) { | 860 | addWorkspace(); |
861 | addWorkspace(); | 861 | while(nr_ws < m_workspaces_list.size()) |
862 | } | 862 | removeLastWorkspace(); |
863 | } else if (nr_ws < m_workspaces_list.size()) { | 863 | |
864 | while(nr_ws != m_workspaces_list.size()) { | 864 | // and update their names |
865 | removeLastWorkspace(); | 865 | for(size_t i = 0; i < std::min(m_workspaces_list.size(), resource.workspace_names->size()); ++i) |
866 | } | 866 | m_workspaces_list[i]->setName( (*resource.workspace_names)[i] ); |
867 | } | ||
868 | 867 | ||
869 | // update menu filenames | 868 | // update menu filenames |
870 | m_rootmenu->reloadHelper()->setMainFile(fluxbox->getMenuFilename()); | 869 | m_rootmenu->reloadHelper()->setMainFile(fluxbox->getMenuFilename()); |
@@ -904,14 +903,14 @@ void BScreen::reconfigureTabs() { | |||
904 | void BScreen::updateWorkspaceName(unsigned int w) { | 903 | void BScreen::updateWorkspaceName(unsigned int w) { |
905 | Workspace *space = getWorkspace(w); | 904 | Workspace *space = getWorkspace(w); |
906 | if (space) { | 905 | if (space) { |
907 | m_workspace_names[w] = space->name(); | 906 | (*resource.workspace_names)[w] = space->name(); |
908 | m_workspacenames_sig.emit(*this); | 907 | m_workspacenames_sig.emit(*this); |
909 | Fluxbox::instance()->save_rc(); | 908 | Fluxbox::instance()->save_rc(); |
910 | } | 909 | } |
911 | } | 910 | } |
912 | 911 | ||
913 | void BScreen::removeWorkspaceNames() { | 912 | void BScreen::removeWorkspaceNames() { |
914 | m_workspace_names.clear(); | 913 | resource.workspace_names->clear(); |
915 | } | 914 | } |
916 | 915 | ||
917 | void BScreen::addIcon(FluxboxWindow *w) { | 916 | void BScreen::addIcon(FluxboxWindow *w) { |
@@ -1345,17 +1344,17 @@ void BScreen::updateAvailableWorkspaceArea() { | |||
1345 | m_workspace_area_sig.emit(*this); | 1344 | m_workspace_area_sig.emit(*this); |
1346 | } | 1345 | } |
1347 | 1346 | ||
1348 | void BScreen::addWorkspaceName(const char *name) { | 1347 | void BScreen::addWorkspaceName(const std::string &name) { |
1349 | m_workspace_names.push_back(FbTk::FbStringUtil::LocaleStrToFb(name)); | 1348 | resource.workspace_names->push_back(name); |
1350 | Workspace *wkspc = getWorkspace(m_workspace_names.size()-1); | 1349 | Workspace *wkspc = getWorkspace(resource.workspace_names->size()-1); |
1351 | if (wkspc) | 1350 | if (wkspc) |
1352 | wkspc->setName(m_workspace_names.back()); | 1351 | wkspc->setName(name); |
1353 | } | 1352 | } |
1354 | 1353 | ||
1355 | 1354 | ||
1356 | string BScreen::getNameOfWorkspace(unsigned int workspace) const { | 1355 | string BScreen::getNameOfWorkspace(unsigned int workspace) const { |
1357 | if (workspace < m_workspace_names.size()) | 1356 | if (workspace < resource.workspace_names->size()) |
1358 | return m_workspace_names[workspace]; | 1357 | return (*resource.workspace_names)[workspace]; |
1359 | else | 1358 | else |
1360 | return ""; | 1359 | return ""; |
1361 | } | 1360 | } |
diff --git a/src/Screen.hh b/src/Screen.hh index 05005f0..8c89ab2 100644 --- a/src/Screen.hh +++ b/src/Screen.hh | |||
@@ -191,7 +191,7 @@ public: | |||
191 | 191 | ||
192 | const Workspaces &getWorkspacesList() const { return m_workspaces_list; } | 192 | const Workspaces &getWorkspacesList() const { return m_workspaces_list; } |
193 | Workspaces &getWorkspacesList() { return m_workspaces_list; } | 193 | Workspaces &getWorkspacesList() { return m_workspaces_list; } |
194 | const WorkspaceNames &getWorkspaceNames() const { return m_workspace_names; } | 194 | const WorkspaceNames &getWorkspaceNames() const { return *resource.workspace_names; } |
195 | /** | 195 | /** |
196 | @name Screen signals | 196 | @name Screen signals |
197 | */ | 197 | */ |
@@ -322,7 +322,7 @@ public: | |||
322 | /// remove all workspace names | 322 | /// remove all workspace names |
323 | void removeWorkspaceNames(); | 323 | void removeWorkspaceNames(); |
324 | /// add a workspace name to the end of the workspace name list | 324 | /// add a workspace name to the end of the workspace name list |
325 | void addWorkspaceName(const char *name); | 325 | void addWorkspaceName(const std::string &name); |
326 | /// add a window to the icon list | 326 | /// add a window to the icon list |
327 | void addIcon(FluxboxWindow *win); | 327 | void addIcon(FluxboxWindow *win); |
328 | /// remove a window from the icon list | 328 | /// remove a window from the icon list |
@@ -510,7 +510,6 @@ private: | |||
510 | 510 | ||
511 | Workspace *m_current_workspace; | 511 | Workspace *m_current_workspace; |
512 | 512 | ||
513 | WorkspaceNames m_workspace_names; | ||
514 | Workspaces m_workspaces_list; | 513 | Workspaces m_workspaces_list; |
515 | 514 | ||
516 | std::auto_ptr<FbWinFrameTheme> m_focused_windowtheme, | 515 | std::auto_ptr<FbWinFrameTheme> m_focused_windowtheme, |
@@ -528,6 +527,12 @@ private: | |||
528 | struct ScreenResource { | 527 | struct ScreenResource { |
529 | ScreenResource(FbTk::ResourceManager_base &rm, const std::string &scrname); | 528 | ScreenResource(FbTk::ResourceManager_base &rm, const std::string &scrname); |
530 | 529 | ||
530 | static const char workspace_names_delim[]; | ||
531 | FbTk::Resource< | ||
532 | std::vector<std::string>, | ||
533 | FbTk::VectorTraits<FbTk::StringTraits, workspace_names_delim> | ||
534 | > workspace_names; | ||
535 | |||
531 | FbTk::BoolResource opaque_move, full_max, | 536 | FbTk::BoolResource opaque_move, full_max, |
532 | max_ignore_inc, max_disable_move, max_disable_resize, | 537 | max_ignore_inc, max_disable_move, max_disable_resize, |
533 | workspace_warping, show_window_pos, auto_raise, click_raises; | 538 | workspace_warping, show_window_pos, auto_raise, click_raises; |
diff --git a/src/fluxbox.cc b/src/fluxbox.cc index efb89b8..cda71ba 100644 --- a/src/fluxbox.cc +++ b/src/fluxbox.cc | |||
@@ -1131,36 +1131,6 @@ void Fluxbox::save_rc() { | |||
1131 | cerr<<_FB_CONSOLETEXT(Fluxbox, BadRCFile, "rc filename is invalid!", "Bad settings file")<<endl; | 1131 | cerr<<_FB_CONSOLETEXT(Fluxbox, BadRCFile, "rc filename is invalid!", "Bad settings file")<<endl; |
1132 | 1132 | ||
1133 | 1133 | ||
1134 | ScreenList::iterator it = m_screen_list.begin(); | ||
1135 | ScreenList::iterator it_end = m_screen_list.end(); | ||
1136 | for (; it != it_end; ++it) { | ||
1137 | BScreen *screen = *it; | ||
1138 | |||
1139 | std::string workspaces_string("screen"); | ||
1140 | workspaces_string += FbTk::StringUtil::number2String(screen->screenNumber()); | ||
1141 | workspaces_string += ".workspaceNames: "; | ||
1142 | |||
1143 | // these are static, but may not be saved in the users resource file, | ||
1144 | // writing these resources will allow the user to edit them at a later | ||
1145 | // time... but loading the defaults before saving allows us to rewrite the | ||
1146 | // users changes... | ||
1147 | |||
1148 | const BScreen::WorkspaceNames& names = screen->getWorkspaceNames(); | ||
1149 | for (size_t i=0; i < names.size(); i++) { | ||
1150 | workspaces_string += FbTk::FbStringUtil::FbStrToLocale(names[i]); | ||
1151 | workspaces_string += ','; | ||
1152 | } | ||
1153 | |||
1154 | XrmPutLineResource(&new_rc, workspaces_string.c_str()); | ||
1155 | |||
1156 | } | ||
1157 | |||
1158 | XrmDatabase old_rc = XrmGetFileDatabase(dbfile.c_str()); | ||
1159 | |||
1160 | XrmMergeDatabases(new_rc, &old_rc); | ||
1161 | XrmPutFileDatabase(old_rc, dbfile.c_str()); | ||
1162 | XrmDestroyDatabase(old_rc); | ||
1163 | |||
1164 | fbdbg<<__FILE__<<"("<<__LINE__<<"): ------------ SAVING DONE"<<endl; | 1134 | fbdbg<<__FILE__<<"("<<__LINE__<<"): ------------ SAVING DONE"<<endl; |
1165 | 1135 | ||
1166 | } | 1136 | } |
@@ -1273,11 +1243,6 @@ void Fluxbox::real_reconfigure() { | |||
1273 | 1243 | ||
1274 | FbTk::Transparent::usePseudoTransparent(*m_rc_pseudotrans); | 1244 | FbTk::Transparent::usePseudoTransparent(*m_rc_pseudotrans); |
1275 | 1245 | ||
1276 | ScreenList::iterator screen_it = m_screen_list.begin(); | ||
1277 | ScreenList::iterator screen_it_end = m_screen_list.end(); | ||
1278 | for (; screen_it != screen_it_end; ++screen_it) | ||
1279 | load_rc(*(*screen_it)); | ||
1280 | |||
1281 | STLUtil::forAll(m_screen_list, mem_fun(&BScreen::reconfigure)); | 1246 | STLUtil::forAll(m_screen_list, mem_fun(&BScreen::reconfigure)); |
1282 | m_key->reconfigure(); | 1247 | m_key->reconfigure(); |
1283 | STLUtil::forAll(m_atomhandler, mem_fun(&AtomHandler::reconfigure)); | 1248 | STLUtil::forAll(m_atomhandler, mem_fun(&AtomHandler::reconfigure)); |