From 5324a82b01c3d15bcb6a0a96bbe6010a4fbca75d Mon Sep 17 00:00:00 2001 From: mathias Date: Wed, 8 Jun 2005 23:03:12 +0000 Subject: most used items should appear ontop of a menu. so i reordered the workspacemenu a bit to fit that idea. --- ChangeLog | 4 ++++ src/WorkspaceMenu.cc | 63 ++++++++++++++++++++++++++++++++++------------------ 2 files changed, 45 insertions(+), 22 deletions(-) diff --git a/ChangeLog b/ChangeLog index 845fb5d..f562273 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ (Format: Year/Month/Day) Changes for 0.9.14: +*05/06/09: + * Reordering of the WorkspaceMenu (Mathias) + Icon submenu ontop, workspaces below, new|edit|remove on bottom + WorkspaceMenu.cc *05/06/07: * Fixed justification in WorkspaceNameTool #1213262 (Mathias) WorkspaceNameTool.cc diff --git a/src/WorkspaceMenu.cc b/src/WorkspaceMenu.cc index d039b65..8642cc2 100644 --- a/src/WorkspaceMenu.cc +++ b/src/WorkspaceMenu.cc @@ -28,16 +28,30 @@ #include "Workspace.hh" #include "WorkspaceCmd.hh" #include "MenuCreator.hh" - +#include "CommandParser.hh" #include "FbTk/I18n.hh" #include "FbTk/SimpleCommand.hh" #include "FbTk/RefCount.hh" #include "FbTk/MenuItem.hh" +#include "FbTk/MenuSeparator.hh" #include "FbTk/MultiButtonMenuItem.hh" #include +// the menu consists of (* means static) +// - icons * 0 +// --------------------- * 1 +// - workspaces 2 +// --------------------- * 3 +// - new workspace * 4 +// - edit workspace name * 5 +// - remove last * 6 +// + +#define IDX_AFTER_ICONS 2 +#define NR_STATIC_ITEMS 6 + WorkspaceMenu::WorkspaceMenu(BScreen &screen): FbMenu(screen.menuTheme(), screen.imageControl(), @@ -57,20 +71,20 @@ void WorkspaceMenu::update(FbTk::Subject *subj) { BScreen &screen = screen_subj.screen(); if (subj == &screen.currentWorkspaceSig()) { FbTk::MenuItem *item = 0; - for (unsigned int i = 2; i < numberOfItems(); ++i) { - item = find(i); + for (unsigned int i = 0; i < screen.getCount(); ++i) { + item = find(i + IDX_AFTER_ICONS); if (item && item->isSelected()) { - setItemSelected(i, false); - updateMenu(i); + setItemSelected(i + IDX_AFTER_ICONS, false); + updateMenu(i + IDX_AFTER_ICONS); break; } } - setItemSelected(screen.currentWorkspace()->workspaceID() + 2, true); - updateMenu(screen.currentWorkspace()->workspaceID() + 2); + setItemSelected(screen.currentWorkspace()->workspaceID() + IDX_AFTER_ICONS, true); + updateMenu(screen.currentWorkspace()->workspaceID() + IDX_AFTER_ICONS); } else if (subj == &screen.workspaceCountSig() || subj == &screen.workspaceNamesSig()) { - while (numberOfItems() > 2) { - remove(numberOfItems()-1); + while (numberOfItems() > NR_STATIC_ITEMS) { + remove(IDX_AFTER_ICONS); } // for each workspace add workspace name and it's menu // to our workspace menu @@ -83,10 +97,8 @@ void WorkspaceMenu::update(FbTk::Subject *subj) { &wkspc->menu()); FbTk::RefCount jump_cmd(new JumpToWorkspaceCmd(wkspc->workspaceID())); mb_menu->setCommand(2, jump_cmd); - insert(mb_menu); + insert(mb_menu, workspace + IDX_AFTER_ICONS); } - insert(_FBTEXT(Menu, Icons, "Icons", "Iconic windows menu title"), - MenuCreator::createMenuType("iconmenu", screen.screenNumber())); updateMenu(-1); } @@ -105,12 +117,9 @@ void WorkspaceMenu::init(BScreen &screen) { removeAll(); setLabel(_FBTEXT(Workspace, MenuTitle, "Workspaces", "Title of main workspace menu")); - RefCount new_workspace(new SimpleCommand(screen, &BScreen::addWorkspace)); - RefCount remove_last(new SimpleCommand(screen, &BScreen::removeLastWorkspace)); - insert(_FBTEXT(Workspace, NewWorkspace, "New Workspace", "Add a new workspace"), - new_workspace); - insert(_FBTEXT(Workspace, RemoveLast, "Remove Last", "Remove the last workspace"), - remove_last); + insert(_FBTEXT(Menu, Icons, "Icons", "Iconic windows menu title"), + 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) { Workspace *wkspc = screen.getWorkspace(workspace); @@ -120,11 +129,21 @@ void WorkspaceMenu::init(BScreen &screen) { &wkspc->menu()); FbTk::RefCount jump_cmd(new JumpToWorkspaceCmd(wkspc->workspaceID())); mb_menu->setCommand(2, jump_cmd); - insert(mb_menu); + insert(mb_menu, workspace + IDX_AFTER_ICONS); } - setItemSelected(screen.currentWorkspace()->workspaceID() + 2, true); + setItemSelected(screen.currentWorkspace()->workspaceID() + IDX_AFTER_ICONS, true); - insert(_FBTEXT(Menu, Icons, "Icons", "Iconic windows menu title"), - MenuCreator::createMenuType("iconmenu", screen.screenNumber())); + RefCount new_workspace(new SimpleCommand(screen, &BScreen::addWorkspace)); + RefCount remove_last(new SimpleCommand(screen, &BScreen::removeLastWorkspace)); + RefCount start_edit(CommandParser::instance().parseLine("setworkspacenamedialog")); + + insert(new FbTk::MenuSeparator()); + insert(_FBTEXT(Workspace, NewWorkspace, "New Workspace", "Add a new workspace"), + new_workspace); + 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); + updateMenu(); } -- cgit v0.11.2