diff options
author | mathias <mathias> | 2005-06-08 23:03:12 (GMT) |
---|---|---|
committer | mathias <mathias> | 2005-06-08 23:03:12 (GMT) |
commit | 5324a82b01c3d15bcb6a0a96bbe6010a4fbca75d (patch) | |
tree | 21b45ecf12a285a96bc2d10fd46f2fed0f70b274 /src/WorkspaceMenu.cc | |
parent | a663db8fd369fb04ad55cfb599e8c7fdecca6d1e (diff) | |
download | fluxbox_lack-5324a82b01c3d15bcb6a0a96bbe6010a4fbca75d.zip fluxbox_lack-5324a82b01c3d15bcb6a0a96bbe6010a4fbca75d.tar.bz2 |
most used items should appear ontop of a menu. so i reordered the
workspacemenu a bit to fit that idea.
Diffstat (limited to 'src/WorkspaceMenu.cc')
-rw-r--r-- | src/WorkspaceMenu.cc | 63 |
1 files changed, 41 insertions, 22 deletions
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 @@ | |||
28 | #include "Workspace.hh" | 28 | #include "Workspace.hh" |
29 | #include "WorkspaceCmd.hh" | 29 | #include "WorkspaceCmd.hh" |
30 | #include "MenuCreator.hh" | 30 | #include "MenuCreator.hh" |
31 | 31 | #include "CommandParser.hh" | |
32 | 32 | ||
33 | #include "FbTk/I18n.hh" | 33 | #include "FbTk/I18n.hh" |
34 | #include "FbTk/SimpleCommand.hh" | 34 | #include "FbTk/SimpleCommand.hh" |
35 | #include "FbTk/RefCount.hh" | 35 | #include "FbTk/RefCount.hh" |
36 | #include "FbTk/MenuItem.hh" | 36 | #include "FbTk/MenuItem.hh" |
37 | #include "FbTk/MenuSeparator.hh" | ||
37 | #include "FbTk/MultiButtonMenuItem.hh" | 38 | #include "FbTk/MultiButtonMenuItem.hh" |
38 | 39 | ||
39 | #include <typeinfo> | 40 | #include <typeinfo> |
40 | 41 | ||
42 | // the menu consists of (* means static) | ||
43 | // - icons * 0 | ||
44 | // --------------------- * 1 | ||
45 | // - workspaces 2 | ||
46 | // --------------------- * 3 | ||
47 | // - new workspace * 4 | ||
48 | // - edit workspace name * 5 | ||
49 | // - remove last * 6 | ||
50 | // | ||
51 | |||
52 | #define IDX_AFTER_ICONS 2 | ||
53 | #define NR_STATIC_ITEMS 6 | ||
54 | |||
41 | WorkspaceMenu::WorkspaceMenu(BScreen &screen): | 55 | WorkspaceMenu::WorkspaceMenu(BScreen &screen): |
42 | FbMenu(screen.menuTheme(), | 56 | FbMenu(screen.menuTheme(), |
43 | screen.imageControl(), | 57 | screen.imageControl(), |
@@ -57,20 +71,20 @@ void WorkspaceMenu::update(FbTk::Subject *subj) { | |||
57 | BScreen &screen = screen_subj.screen(); | 71 | BScreen &screen = screen_subj.screen(); |
58 | if (subj == &screen.currentWorkspaceSig()) { | 72 | if (subj == &screen.currentWorkspaceSig()) { |
59 | FbTk::MenuItem *item = 0; | 73 | FbTk::MenuItem *item = 0; |
60 | for (unsigned int i = 2; i < numberOfItems(); ++i) { | 74 | for (unsigned int i = 0; i < screen.getCount(); ++i) { |
61 | item = find(i); | 75 | item = find(i + IDX_AFTER_ICONS); |
62 | if (item && item->isSelected()) { | 76 | if (item && item->isSelected()) { |
63 | setItemSelected(i, false); | 77 | setItemSelected(i + IDX_AFTER_ICONS, false); |
64 | updateMenu(i); | 78 | updateMenu(i + IDX_AFTER_ICONS); |
65 | break; | 79 | break; |
66 | } | 80 | } |
67 | } | 81 | } |
68 | setItemSelected(screen.currentWorkspace()->workspaceID() + 2, true); | 82 | setItemSelected(screen.currentWorkspace()->workspaceID() + IDX_AFTER_ICONS, true); |
69 | updateMenu(screen.currentWorkspace()->workspaceID() + 2); | 83 | updateMenu(screen.currentWorkspace()->workspaceID() + IDX_AFTER_ICONS); |
70 | } else if (subj == &screen.workspaceCountSig() || | 84 | } else if (subj == &screen.workspaceCountSig() || |
71 | subj == &screen.workspaceNamesSig()) { | 85 | subj == &screen.workspaceNamesSig()) { |
72 | while (numberOfItems() > 2) { | 86 | while (numberOfItems() > NR_STATIC_ITEMS) { |
73 | remove(numberOfItems()-1); | 87 | remove(IDX_AFTER_ICONS); |
74 | } | 88 | } |
75 | // for each workspace add workspace name and it's menu | 89 | // for each workspace add workspace name and it's menu |
76 | // to our workspace menu | 90 | // to our workspace menu |
@@ -83,10 +97,8 @@ void WorkspaceMenu::update(FbTk::Subject *subj) { | |||
83 | &wkspc->menu()); | 97 | &wkspc->menu()); |
84 | FbTk::RefCount<FbTk::Command> jump_cmd(new JumpToWorkspaceCmd(wkspc->workspaceID())); | 98 | FbTk::RefCount<FbTk::Command> jump_cmd(new JumpToWorkspaceCmd(wkspc->workspaceID())); |
85 | mb_menu->setCommand(2, jump_cmd); | 99 | mb_menu->setCommand(2, jump_cmd); |
86 | insert(mb_menu); | 100 | insert(mb_menu, workspace + IDX_AFTER_ICONS); |
87 | } | 101 | } |
88 | insert(_FBTEXT(Menu, Icons, "Icons", "Iconic windows menu title"), | ||
89 | MenuCreator::createMenuType("iconmenu", screen.screenNumber())); | ||
90 | 102 | ||
91 | updateMenu(-1); | 103 | updateMenu(-1); |
92 | } | 104 | } |
@@ -105,12 +117,9 @@ void WorkspaceMenu::init(BScreen &screen) { | |||
105 | removeAll(); | 117 | removeAll(); |
106 | 118 | ||
107 | setLabel(_FBTEXT(Workspace, MenuTitle, "Workspaces", "Title of main workspace menu")); | 119 | setLabel(_FBTEXT(Workspace, MenuTitle, "Workspaces", "Title of main workspace menu")); |
108 | RefCount<Command> new_workspace(new SimpleCommand<BScreen, int>(screen, &BScreen::addWorkspace)); | 120 | insert(_FBTEXT(Menu, Icons, "Icons", "Iconic windows menu title"), |
109 | RefCount<Command> remove_last(new SimpleCommand<BScreen, int>(screen, &BScreen::removeLastWorkspace)); | 121 | MenuCreator::createMenuType("iconmenu", screen.screenNumber())); |
110 | insert(_FBTEXT(Workspace, NewWorkspace, "New Workspace", "Add a new workspace"), | 122 | insert(new FbTk::MenuSeparator()); |
111 | new_workspace); | ||
112 | insert(_FBTEXT(Workspace, RemoveLast, "Remove Last", "Remove the last workspace"), | ||
113 | remove_last); | ||
114 | // for each workspace add workspace name and it's menu to our workspace menu | 123 | // for each workspace add workspace name and it's menu to our workspace menu |
115 | for (size_t workspace = 0; workspace < screen.getCount(); ++workspace) { | 124 | for (size_t workspace = 0; workspace < screen.getCount(); ++workspace) { |
116 | Workspace *wkspc = screen.getWorkspace(workspace); | 125 | Workspace *wkspc = screen.getWorkspace(workspace); |
@@ -120,11 +129,21 @@ void WorkspaceMenu::init(BScreen &screen) { | |||
120 | &wkspc->menu()); | 129 | &wkspc->menu()); |
121 | FbTk::RefCount<FbTk::Command> jump_cmd(new JumpToWorkspaceCmd(wkspc->workspaceID())); | 130 | FbTk::RefCount<FbTk::Command> jump_cmd(new JumpToWorkspaceCmd(wkspc->workspaceID())); |
122 | mb_menu->setCommand(2, jump_cmd); | 131 | mb_menu->setCommand(2, jump_cmd); |
123 | insert(mb_menu); | 132 | insert(mb_menu, workspace + IDX_AFTER_ICONS); |
124 | } | 133 | } |
125 | setItemSelected(screen.currentWorkspace()->workspaceID() + 2, true); | 134 | setItemSelected(screen.currentWorkspace()->workspaceID() + IDX_AFTER_ICONS, true); |
126 | 135 | ||
127 | insert(_FBTEXT(Menu, Icons, "Icons", "Iconic windows menu title"), | 136 | RefCount<Command> new_workspace(new SimpleCommand<BScreen, int>(screen, &BScreen::addWorkspace)); |
128 | MenuCreator::createMenuType("iconmenu", screen.screenNumber())); | 137 | RefCount<Command> remove_last(new SimpleCommand<BScreen, int>(screen, &BScreen::removeLastWorkspace)); |
138 | RefCount<Command> start_edit(CommandParser::instance().parseLine("setworkspacenamedialog")); | ||
139 | |||
140 | insert(new FbTk::MenuSeparator()); | ||
141 | insert(_FBTEXT(Workspace, NewWorkspace, "New Workspace", "Add a new workspace"), | ||
142 | new_workspace); | ||
143 | insert(_FBTEXT(Toolbar, EditWkspcName, "Edit current workspace name", "Edit current workspace name"), | ||
144 | start_edit); | ||
145 | insert(_FBTEXT(Workspace, RemoveLast, "Remove Last", "Remove the last workspace"), | ||
146 | remove_last); | ||
147 | |||
129 | updateMenu(); | 148 | updateMenu(); |
130 | } | 149 | } |