diff options
author | rathnor <rathnor> | 2003-03-03 21:51:13 (GMT) |
---|---|---|
committer | rathnor <rathnor> | 2003-03-03 21:51:13 (GMT) |
commit | 19875e5a5ba474387971ede597cdc4aa7454d4c0 (patch) | |
tree | 99d672abcffa86d74734deacbd888eccde02ffd2 /src/Screen.cc | |
parent | 824fd0db7a4b8117fecba9bb46053bdd38691803 (diff) | |
download | fluxbox-19875e5a5ba474387971ede597cdc4aa7454d4c0.zip fluxbox-19875e5a5ba474387971ede597cdc4aa7454d4c0.tar.bz2 |
Add code for toolbar modes
Diffstat (limited to 'src/Screen.cc')
-rw-r--r-- | src/Screen.cc | 138 |
1 files changed, 88 insertions, 50 deletions
diff --git a/src/Screen.cc b/src/Screen.cc index e39b28a..076965f 100644 --- a/src/Screen.cc +++ b/src/Screen.cc | |||
@@ -22,7 +22,7 @@ | |||
22 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | 22 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
23 | // DEALINGS IN THE SOFTWARE. | 23 | // DEALINGS IN THE SOFTWARE. |
24 | 24 | ||
25 | // $Id: Screen.cc,v 1.116 2003/02/23 12:02:30 fluxgen Exp $ | 25 | // $Id: Screen.cc,v 1.117 2003/03/03 21:51:04 rathnor Exp $ |
26 | 26 | ||
27 | 27 | ||
28 | #include "Screen.hh" | 28 | #include "Screen.hh" |
@@ -202,6 +202,26 @@ setFromString(const char *strval) { | |||
202 | setDefaultValue(); | 202 | setDefaultValue(); |
203 | } | 203 | } |
204 | 204 | ||
205 | template<> | ||
206 | void Resource<ToolbarHandler::ToolbarMode>:: | ||
207 | setFromString(const char *strval) { | ||
208 | if (strcasecmp(strval, "Off") == 0) | ||
209 | m_value = ToolbarHandler::OFF; | ||
210 | else if (strcasecmp(strval, "None") == 0) | ||
211 | m_value = ToolbarHandler::NONE; | ||
212 | else if (strcasecmp(strval, "Icons") == 0) | ||
213 | m_value = ToolbarHandler::ICONS; | ||
214 | else if (strcasecmp(strval, "WorkspaceIcons") == 0) | ||
215 | m_value = ToolbarHandler::WORKSPACEICONS; | ||
216 | else if (strcasecmp(strval, "Workspace") == 0) | ||
217 | m_value = ToolbarHandler::WORKSPACE; | ||
218 | else if (strcasecmp(strval, "AllWindows") == 0) | ||
219 | m_value = ToolbarHandler::ALLWINDOWS; | ||
220 | else | ||
221 | setDefaultValue(); | ||
222 | } | ||
223 | |||
224 | |||
205 | //--------- resource accessors -------------- | 225 | //--------- resource accessors -------------- |
206 | template<> | 226 | template<> |
207 | string Resource<Tab::Alignment>:: | 227 | string Resource<Tab::Alignment>:: |
@@ -260,6 +280,34 @@ getString() { | |||
260 | return string("BottomCenter"); | 280 | return string("BottomCenter"); |
261 | } | 281 | } |
262 | 282 | ||
283 | template<> | ||
284 | string Resource<ToolbarHandler::ToolbarMode>:: | ||
285 | getString() { | ||
286 | switch (m_value) { | ||
287 | case ToolbarHandler::OFF: | ||
288 | return string("Off"); | ||
289 | break; | ||
290 | case ToolbarHandler::NONE: | ||
291 | return string("None"); | ||
292 | break; | ||
293 | case ToolbarHandler::LASTMODE: | ||
294 | case ToolbarHandler::ICONS: | ||
295 | return string("Icons"); | ||
296 | break; | ||
297 | case ToolbarHandler::WORKSPACEICONS: | ||
298 | return string("Workspace"); | ||
299 | break; | ||
300 | case ToolbarHandler::WORKSPACE: | ||
301 | return string("Workspace"); | ||
302 | break; | ||
303 | case ToolbarHandler::ALLWINDOWS: | ||
304 | return string("AllWindows"); | ||
305 | break; | ||
306 | } | ||
307 | // default string | ||
308 | return string("Icons"); | ||
309 | } | ||
310 | |||
263 | namespace { | 311 | namespace { |
264 | 312 | ||
265 | class AddWorkspaceCmd:public FbTk::Command { | 313 | class AddWorkspaceCmd:public FbTk::Command { |
@@ -373,6 +421,7 @@ BScreen::ScreenResource::ScreenResource(ResourceManager &rm, | |||
373 | toolbar_layernum(rm, Fluxbox::instance()->getDesktopLayer(), scrname+".toolbar.layer", altscrname+".Toolbar.Layer"), | 421 | toolbar_layernum(rm, Fluxbox::instance()->getDesktopLayer(), scrname+".toolbar.layer", altscrname+".Toolbar.Layer"), |
374 | tab_placement(rm, Tab::PTOP, scrname+".tab.placement", altscrname+".Tab.Placement"), | 422 | tab_placement(rm, Tab::PTOP, scrname+".tab.placement", altscrname+".Tab.Placement"), |
375 | tab_alignment(rm, Tab::ALEFT, scrname+".tab.alignment", altscrname+".Tab.Alignment"), | 423 | tab_alignment(rm, Tab::ALEFT, scrname+".tab.alignment", altscrname+".Tab.Alignment"), |
424 | toolbar_mode(rm, ToolbarHandler::ICONS, scrname+".toolbar.mode", altscrname+".Toolbar.Mode"), | ||
376 | toolbar_on_head(rm, 0, scrname+".toolbar.onhead", altscrname+".Toolbar.onHead"), | 425 | toolbar_on_head(rm, 0, scrname+".toolbar.onhead", altscrname+".Toolbar.onHead"), |
377 | toolbar_placement(rm, Toolbar::BOTTOMCENTER, scrname+".toolbar.placement", altscrname+".Toolbar.Placement") | 426 | toolbar_placement(rm, Toolbar::BOTTOMCENTER, scrname+".toolbar.placement", altscrname+".Toolbar.Placement") |
378 | { | 427 | { |
@@ -390,7 +439,8 @@ BScreen::BScreen(ResourceManager &rm, | |||
390 | theme(0), m_windowtheme(scrn), | 439 | theme(0), m_windowtheme(scrn), |
391 | m_menutheme(new FbTk::MenuTheme(scrn)), | 440 | m_menutheme(new FbTk::MenuTheme(scrn)), |
392 | resource(rm, screenname, altscreenname), | 441 | resource(rm, screenname, altscreenname), |
393 | m_root_theme(new RootTheme(*this)) | 442 | m_root_theme(new RootTheme(*this)), |
443 | m_toolbarhandler(0) | ||
394 | { | 444 | { |
395 | Display *disp = FbTk::App::instance()->display(); | 445 | Display *disp = FbTk::App::instance()->display(); |
396 | 446 | ||
@@ -524,31 +574,11 @@ BScreen::BScreen(ResourceManager &rm, | |||
524 | m_slit.reset(new Slit(*this, *layerManager().getLayer(getSlitLayerNum()))); | 574 | m_slit.reset(new Slit(*this, *layerManager().getLayer(getSlitLayerNum()))); |
525 | #endif // SLIT | 575 | #endif // SLIT |
526 | 576 | ||
527 | m_toolbar.reset(new Toolbar(*this, *layerManager().getLayer(getToolbarLayerNum()))); | 577 | m_toolbarhandler = new ToolbarHandler(*this, getToolbarMode()); |
528 | m_toolbar->setPlacement(*resource.toolbar_placement); | ||
529 | // setup toolbar width menu item | ||
530 | FbTk::MenuItem *toolbar_menuitem = new IntResMenuItem("Toolbar width percent", | ||
531 | resource.toolbar_width_percent, | ||
532 | 0, 100); // min/max value | ||
533 | FbTk::RefCount<FbTk::Command> reconfig_toolbar(new FbTk:: | ||
534 | SimpleCommand<Toolbar> | ||
535 | (*(m_toolbar.get()), &Toolbar::reconfigure)); | ||
536 | FbTk::RefCount<FbTk::Command> save_resources(new FbTk:: | ||
537 | SimpleCommand<Fluxbox> | ||
538 | (*Fluxbox::instance(), &Fluxbox::save_rc)); | ||
539 | FbTk::MacroCommand *toolbar_menuitem_macro = new FbTk::MacroCommand(); | ||
540 | toolbar_menuitem_macro->add(reconfig_toolbar); | ||
541 | toolbar_menuitem_macro->add(save_resources); | ||
542 | |||
543 | FbTk::RefCount<FbTk::Command> reconfig_toolbar_and_save_resource(toolbar_menuitem_macro); | ||
544 | 578 | ||
545 | toolbar_menuitem->setCommand(reconfig_toolbar_and_save_resource); | 579 | if (getToolbar()) |
580 | getToolbar()->setPlacement(*resource.toolbar_placement); | ||
546 | 581 | ||
547 | m_toolbar->menu().insert(toolbar_menuitem, 0); | ||
548 | |||
549 | m_toolbar->menu().insert(new BoolMenuItem("Auto hide", *resource.toolbar_auto_hide, reconfig_toolbar), 0); | ||
550 | |||
551 | |||
552 | setupWorkspacemenu(*this, *workspacemenu); | 582 | setupWorkspacemenu(*this, *workspacemenu); |
553 | 583 | ||
554 | m_configmenu.reset(createMenuFromScreen(*this)); | 584 | m_configmenu.reset(createMenuFromScreen(*this)); |
@@ -556,7 +586,8 @@ BScreen::BScreen(ResourceManager &rm, | |||
556 | 586 | ||
557 | workspacemenu->setItemSelected(2, true); | 587 | workspacemenu->setItemSelected(2, true); |
558 | 588 | ||
559 | m_toolbar->reconfigure(); | 589 | if (getToolbar() != 0) |
590 | getToolbar()->reconfigure(); | ||
560 | 591 | ||
561 | initMenu(); // create and initiate rootmenu | 592 | initMenu(); // create and initiate rootmenu |
562 | 593 | ||
@@ -622,11 +653,13 @@ BScreen::BScreen(ResourceManager &rm, | |||
622 | } | 653 | } |
623 | } | 654 | } |
624 | 655 | ||
625 | if (! isSloppyFocus()) { | 656 | if (! isSloppyFocus() && getToolbar() != 0) { |
626 | XSetInputFocus(disp, m_toolbar->getWindowID(), | 657 | XSetInputFocus(disp, getToolbar()->getWindowID(), |
627 | RevertToParent, CurrentTime); | 658 | RevertToParent, CurrentTime); |
628 | } | 659 | } |
629 | 660 | ||
661 | // set the toolbarhandler after the windows are setup, so it catches their state properly | ||
662 | |||
630 | XFree(children); | 663 | XFree(children); |
631 | XFlush(disp); | 664 | XFlush(disp); |
632 | } | 665 | } |
@@ -668,6 +701,14 @@ BScreen::~BScreen() { | |||
668 | 701 | ||
669 | } | 702 | } |
670 | 703 | ||
704 | const FbTk::Menu &BScreen::getToolbarModemenu() const { | ||
705 | return m_toolbarhandler->getModeMenu(); | ||
706 | } | ||
707 | |||
708 | FbTk::Menu &BScreen::getToolbarModemenu() { | ||
709 | return m_toolbarhandler->getModeMenu(); | ||
710 | } | ||
711 | |||
671 | /// TODO | 712 | /// TODO |
672 | unsigned int BScreen::getMaxLeft() const { | 713 | unsigned int BScreen::getMaxLeft() const { |
673 | return 0; | 714 | return 0; |
@@ -702,8 +743,8 @@ void BScreen::reconfigure() { | |||
702 | 743 | ||
703 | FbTk::ThemeManager::instance().load(filename.c_str()); // new theme engine | 744 | FbTk::ThemeManager::instance().load(filename.c_str()); // new theme engine |
704 | 745 | ||
705 | if (m_toolbar.get()) | 746 | if (getToolbar()) |
706 | m_toolbar->theme().font().setAntialias(*resource.antialias); | 747 | getToolbar()->theme().font().setAntialias(*resource.antialias); |
707 | 748 | ||
708 | theme->reconfigure(*resource.antialias); | 749 | theme->reconfigure(*resource.antialias); |
709 | 750 | ||
@@ -758,10 +799,11 @@ void BScreen::reconfigure() { | |||
758 | 799 | ||
759 | 800 | ||
760 | // m_toolbar->setPlacement(*resource.toolbar_placement); | 801 | // m_toolbar->setPlacement(*resource.toolbar_placement); |
761 | m_toolbar->reconfigure(); | 802 | if (getToolbar() != 0) { |
762 | if (m_toolbar->theme().font().isAntialias() != *resource.antialias) | 803 | getToolbar()->reconfigure(); |
763 | m_toolbar->theme().font().setAntialias(*resource.antialias); | 804 | if (getToolbar()->theme().font().isAntialias() != *resource.antialias) |
764 | 805 | getToolbar()->theme().font().setAntialias(*resource.antialias); | |
806 | } | ||
765 | #ifdef SLIT | 807 | #ifdef SLIT |
766 | if (m_slit.get()) { | 808 | if (m_slit.get()) { |
767 | m_slit->setPlacement(static_cast<Slit::Placement>(getSlitPlacement())); | 809 | m_slit->setPlacement(static_cast<Slit::Placement>(getSlitPlacement())); |
@@ -808,12 +850,9 @@ void BScreen::updateWorkspaceNamesAtom() { | |||
808 | void BScreen::addIcon(FluxboxWindow *w) { | 850 | void BScreen::addIcon(FluxboxWindow *w) { |
809 | if (! w) return; | 851 | if (! w) return; |
810 | 852 | ||
811 | w->setWorkspace(-1); | ||
812 | w->setWindowNumber(iconList.size()); | 853 | w->setWindowNumber(iconList.size()); |
813 | 854 | ||
814 | iconList.push_back(w); | 855 | iconList.push_back(w); |
815 | |||
816 | m_toolbar->addIcon(w); | ||
817 | } | 856 | } |
818 | 857 | ||
819 | 858 | ||
@@ -829,11 +868,9 @@ void BScreen::removeIcon(FluxboxWindow *w) { | |||
829 | iconList.erase(it); | 868 | iconList.erase(it); |
830 | break; | 869 | break; |
831 | } | 870 | } |
832 | } | 871 | } |
833 | } | 872 | } |
834 | 873 | ||
835 | m_toolbar->delIcon(w); | ||
836 | |||
837 | Icons::iterator it = iconList.begin(); | 874 | Icons::iterator it = iconList.begin(); |
838 | Icons::iterator it_end = iconList.end(); | 875 | Icons::iterator it_end = iconList.end(); |
839 | for (int i = 0; it != it_end; ++it, ++i) { | 876 | for (int i = 0; it != it_end; ++it, ++i) { |
@@ -873,8 +910,9 @@ int BScreen::addWorkspace() { | |||
873 | 910 | ||
874 | workspacemenu->update(); | 911 | workspacemenu->update(); |
875 | saveWorkspaces(workspacesList.size()); | 912 | saveWorkspaces(workspacesList.size()); |
876 | m_toolbar->reconfigure(); | 913 | if (getToolbar() != 0) |
877 | 914 | getToolbar()->reconfigure(); | |
915 | |||
878 | updateNetizenWorkspaceCount(); | 916 | updateNetizenWorkspaceCount(); |
879 | 917 | ||
880 | 918 | ||
@@ -901,7 +939,8 @@ int BScreen::removeLastWorkspace() { | |||
901 | workspacesList.pop_back(); | 939 | workspacesList.pop_back(); |
902 | delete wkspc; | 940 | delete wkspc; |
903 | 941 | ||
904 | m_toolbar->reconfigure(); | 942 | if (getToolbar() != 0) |
943 | getToolbar()->reconfigure(); | ||
905 | 944 | ||
906 | updateNetizenWorkspaceCount(); | 945 | updateNetizenWorkspaceCount(); |
907 | saveWorkspaces(workspacesList.size()); | 946 | saveWorkspaces(workspacesList.size()); |
@@ -949,7 +988,8 @@ void BScreen::changeWorkspaceID(unsigned int id) { | |||
949 | current_workspace = getWorkspace(id); | 988 | current_workspace = getWorkspace(id); |
950 | 989 | ||
951 | workspacemenu->setItemSelected(current_workspace->workspaceID() + 2, true); | 990 | workspacemenu->setItemSelected(current_workspace->workspaceID() + 2, true); |
952 | m_toolbar->redrawWorkspaceLabel(true); | 991 | if (getToolbar() != 0) |
992 | getToolbar()->redrawWorkspaceLabel(true); | ||
953 | 993 | ||
954 | current_workspace->showAll(); | 994 | current_workspace->showAll(); |
955 | 995 | ||
@@ -1309,7 +1349,7 @@ void BScreen::reassociateWindow(FluxboxWindow *w, unsigned int wkspc_id, bool ig | |||
1309 | #endif // DEBUG | 1349 | #endif // DEBUG |
1310 | } | 1350 | } |
1311 | 1351 | ||
1312 | if (w->getWorkspaceNumber() == wkspc_id) | 1352 | if (!w->isIconic() && w->getWorkspaceNumber() == wkspc_id) |
1313 | return; | 1353 | return; |
1314 | 1354 | ||
1315 | 1355 | ||
@@ -1781,11 +1821,9 @@ void BScreen::setupConfigmenu(FbTk::Menu &menu) { | |||
1781 | if (getSlit() != 0) | 1821 | if (getSlit() != 0) |
1782 | menu.insert("Slit", &getSlit()->menu()); | 1822 | menu.insert("Slit", &getSlit()->menu()); |
1783 | #endif // SLIT | 1823 | #endif // SLIT |
1784 | |||
1785 | menu.insert(i18n->getMessage( | 1824 | menu.insert(i18n->getMessage( |
1786 | ToolbarSet, ToolbarToolbarTitle, | 1825 | ToolbarSet, ToolbarToolbarTitle, |
1787 | "Toolbar"), &m_toolbar->menu()); | 1826 | "Toolbar"), &m_toolbarhandler->getToolbarMenu()); |
1788 | |||
1789 | menu.insert(new | 1827 | menu.insert(new |
1790 | BoolMenuItem(i18n->getMessage( | 1828 | BoolMenuItem(i18n->getMessage( |
1791 | ConfigmenuSet, ConfigmenuImageDithering, | 1829 | ConfigmenuSet, ConfigmenuImageDithering, |