From 3626faea73a7e033e14ec2d06bdcb2b180d06172 Mon Sep 17 00:00:00 2001
From: fluxgen <fluxgen>
Date: Mon, 4 Jul 2005 18:19:09 +0000
Subject: cleaning, change getCount to numberOfWorkspaces

---
 src/IconMenu.cc      |  4 ++--
 src/MenuCreator.cc   |  4 ++--
 src/WorkspaceCmd.cc  |  2 +-
 src/WorkspaceMenu.cc | 29 ++++++++++++++++++++++-------
 4 files changed, 27 insertions(+), 12 deletions(-)

diff --git a/src/IconMenu.cc b/src/IconMenu.cc
index 195f79b..6fbe0a6 100644
--- a/src/IconMenu.cc
+++ b/src/IconMenu.cc
@@ -32,8 +32,8 @@
 
 static void updateItems(FbTk::Menu &menu, BScreen &screen) {
     menu.removeAll();
-    BScreen::Icons::iterator it = screen.getIconList().begin();
-    BScreen::Icons::iterator it_end = screen.getIconList().end();
+    BScreen::Icons::iterator it = screen.iconList().begin();
+    BScreen::Icons::iterator it_end = screen.iconList().end();
     for (; it != it_end; ++it) {
         FluxboxWindow::ClientList::iterator client_it = (*it)->clientList().begin();
         FluxboxWindow::ClientList::iterator client_it_end = (*it)->clientList().end();
diff --git a/src/MenuCreator.cc b/src/MenuCreator.cc
index 0bbd14f..cb1f33c 100644
--- a/src/MenuCreator.cc
+++ b/src/MenuCreator.cc
@@ -290,8 +290,8 @@ static void translateMenuItem(Parser &parse, ParseItem &pitem) {
     else if (str_key == "workspaces") {
         BScreen *screen = Fluxbox::instance()->findScreen(screen_number);
         if (screen != 0) {
-            screen->getWorkspacemenu().setInternalMenu();
-            menu.insert(str_label.c_str(), &screen->getWorkspacemenu());
+            screen->workspaceMenu().setInternalMenu();
+            menu.insert(str_label.c_str(), &screen->workspaceMenu());
         }
     } else if (str_key == "separator") {
         menu.insert(new FbTk::MenuSeparator());
diff --git a/src/WorkspaceCmd.cc b/src/WorkspaceCmd.cc
index 08473df..eba4616 100644
--- a/src/WorkspaceCmd.cc
+++ b/src/WorkspaceCmd.cc
@@ -127,7 +127,7 @@ JumpToWorkspaceCmd::JumpToWorkspaceCmd(int workspace_num):m_workspace_num(worksp
 
 void JumpToWorkspaceCmd::execute() {
     BScreen *screen = Fluxbox::instance()->mouseScreen();
-    if (screen != 0 && m_workspace_num >= 0 && m_workspace_num < screen->getNumberOfWorkspaces())
+    if (screen != 0)
         screen->changeWorkspaceID(m_workspace_num);
 }
 
diff --git a/src/WorkspaceMenu.cc b/src/WorkspaceMenu.cc
index 8642cc2..bb8ae4b 100644
--- a/src/WorkspaceMenu.cc
+++ b/src/WorkspaceMenu.cc
@@ -29,9 +29,11 @@
 #include "WorkspaceCmd.hh"
 #include "MenuCreator.hh"
 #include "CommandParser.hh"
+#include "FbCommands.hh"
 
 #include "FbTk/I18n.hh"
 #include "FbTk/SimpleCommand.hh"
+#include "FbTk/MacroCommand.hh"
 #include "FbTk/RefCount.hh"
 #include "FbTk/MenuItem.hh"
 #include "FbTk/MenuSeparator.hh"
@@ -71,7 +73,7 @@ void WorkspaceMenu::update(FbTk::Subject *subj) {
         BScreen &screen = screen_subj.screen();
         if (subj == &screen.currentWorkspaceSig()) {
             FbTk::MenuItem *item = 0;
-            for (unsigned int i = 0; i < screen.getCount(); ++i) {
+            for (unsigned int i = 0; i < screen.numberOfWorkspaces(); ++i) {
                 item = find(i + IDX_AFTER_ICONS);
                 if (item && item->isSelected()) {
                     setItemSelected(i + IDX_AFTER_ICONS, false);
@@ -88,7 +90,7 @@ void WorkspaceMenu::update(FbTk::Subject *subj) {
             }
             // for each workspace add workspace name and it's menu
             // to our workspace menu
-            for (size_t workspace = 0; workspace < screen.getCount(); 
+            for (size_t workspace = 0; workspace < screen.numberOfWorkspaces(); 
                  ++workspace) {
                 Workspace *wkspc = screen.getWorkspace(workspace);
                 wkspc->menu().setInternalMenu();
@@ -121,7 +123,7 @@ void WorkspaceMenu::init(BScreen &screen) {
            MenuCreator::createMenuType("iconmenu", screen.screenNumber()));
     insert(new FbTk::MenuSeparator());
     // for each workspace add workspace name and it's menu to our workspace menu
-    for (size_t workspace = 0; workspace < screen.getCount(); ++workspace) {
+    for (size_t workspace = 0; workspace < screen.numberOfWorkspaces(); ++workspace) {
         Workspace *wkspc = screen.getWorkspace(workspace);
         wkspc->menu().setInternalMenu();
         FbTk::MultiButtonMenuItem* mb_menu = new FbTk::MultiButtonMenuItem(5, 
@@ -133,17 +135,30 @@ void WorkspaceMenu::init(BScreen &screen) {
     }
     setItemSelected(screen.currentWorkspace()->workspaceID() + IDX_AFTER_ICONS, true);
 
-    RefCount<Command> new_workspace(new SimpleCommand<BScreen, int>(screen, &BScreen::addWorkspace));
-    RefCount<Command> remove_last(new SimpleCommand<BScreen, int>(screen, &BScreen::removeLastWorkspace));
+
+    RefCount<Command> saverc_cmd(new FbCommands::SaveResources());
+
+    MacroCommand *new_workspace_macro = new MacroCommand();
+    RefCount<Command> addworkspace(new SimpleCommand<BScreen, int>(screen, &BScreen::addWorkspace));
+    new_workspace_macro->add(addworkspace);
+    new_workspace_macro->add(saverc_cmd);
+    RefCount<Command> new_workspace_cmd(new_workspace_macro);
+
+    MacroCommand *remove_workspace_macro = new MacroCommand();
+    RefCount<Command> rmworkspace(new SimpleCommand<BScreen, int>(screen, &BScreen::removeLastWorkspace));
+    remove_workspace_macro->add(rmworkspace);
+    remove_workspace_macro->add(saverc_cmd);
+    RefCount<Command> remove_last_cmd(remove_workspace_macro);
+
     RefCount<Command> start_edit(CommandParser::instance().parseLine("setworkspacenamedialog"));
 
     insert(new FbTk::MenuSeparator());
     insert(_FBTEXT(Workspace, NewWorkspace, "New Workspace", "Add a new workspace"), 
-           new_workspace);
+           new_workspace_cmd);
     insert(_FBTEXT(Toolbar, EditWkspcName, "Edit current workspace name", "Edit current workspace name"),
            start_edit);
     insert(_FBTEXT(Workspace, RemoveLast, "Remove Last", "Remove the last workspace"), 
-          remove_last);
+          remove_last_cmd);
     
     updateMenu();
 }
-- 
cgit v0.11.2