Workspace switching on the toolbar via the mouse buttons

This commit is contained in:
Soeren Beye 2013-02-27 09:44:49 +01:00 committed by Mathias Gumz
parent ec7fe513c8
commit 0810d7db5e
3 changed files with 12 additions and 6 deletions

View file

@ -557,7 +557,9 @@ The possible tools are:
The Systemtray can hold applications that are made to use it. The Systemtray can hold applications that are made to use it.
*WorkspaceName*::: *WorkspaceName*:::
This displays the name of the current workspace. This displays the name of the current workspace. Also, one is able to switch
to the workspace left of the current one with a left click and to the
workspace right of the current one with a right click.
*PrevWorkspace*::: *PrevWorkspace*:::
This displays an arrow that allows one to switch to the workspace left of This displays an arrow that allows one to switch to the workspace left of
@ -577,7 +579,7 @@ The possible tools are:
Other aspects of the toolbar can be configured in two ways: through the toolbar Other aspects of the toolbar can be configured in two ways: through the toolbar
menu, which is accessible in the Configuration part of the RootMenu or with a menu, which is accessible in the Configuration part of the RootMenu or with a
right click on the edge the toolbar, or by editing the init file (see the middle click on the edge the toolbar, or by editing the init file (see the
*RESOURCES* section for more information about that). *RESOURCES* section for more information about that).
Toolbar Menu Toolbar Menu

View file

@ -75,6 +75,8 @@ ToolFactory::ToolFactory(BScreen &screen):m_screen(screen),
ToolbarItem *ToolFactory::create(const std::string &name, const FbTk::FbWindow &parent, Toolbar &tbar) { ToolbarItem *ToolFactory::create(const std::string &name, const FbTk::FbWindow &parent, Toolbar &tbar) {
ToolbarItem * item = 0; ToolbarItem * item = 0;
FbTk::CommandParser<void>& cp = FbTk::CommandParser<void>::instance();
unsigned int button_size = 24; unsigned int button_size = 24;
if (tbar.theme()->buttonSize() > 0) if (tbar.theme()->buttonSize() > 0)
button_size = tbar.theme()->buttonSize(); button_size = tbar.theme()->buttonSize();
@ -83,8 +85,10 @@ ToolbarItem *ToolFactory::create(const std::string &name, const FbTk::FbWindow &
WorkspaceNameTool *witem = new WorkspaceNameTool(parent, WorkspaceNameTool *witem = new WorkspaceNameTool(parent,
*m_workspace_theme, screen()); *m_workspace_theme, screen());
using namespace FbTk; using namespace FbTk;
RefCount<Command<void> > showmenu(new ShowMenuAboveToolbar(tbar)); RefCount< Command<void> > leftCommand(cp.parse("prevworkspace"));
witem->button().setOnClick(showmenu); RefCount< Command<void> > rightCommand(cp.parse("nextworkspace"));
witem->button().setOnClick(leftCommand);
witem->button().setOnClick(rightCommand, 3);
item = witem; item = witem;
} else if (name == "iconbar") { } else if (name == "iconbar") {
item = new IconbarTool(parent, m_iconbar_theme, m_focused_iconbar_theme, m_unfocused_iconbar_theme, screen(), tbar.menu()); item = new IconbarTool(parent, m_iconbar_theme, m_focused_iconbar_theme, m_unfocused_iconbar_theme, screen(), tbar.menu());
@ -101,7 +105,7 @@ ToolbarItem *ToolFactory::create(const std::string &name, const FbTk::FbWindow &
cmd_str += " (workspace=[current])"; cmd_str += " (workspace=[current])";
} }
FbTk::RefCount<FbTk::Command<void> > cmd(FbTk::CommandParser<void>::instance().parse(cmd_str)); FbTk::RefCount<FbTk::Command<void> > cmd(cp.parse(cmd_str));
if (cmd == 0) // we need a command if (cmd == 0) // we need a command
return 0; return 0;

View file

@ -517,7 +517,7 @@ void Toolbar::buttonPressEvent(XButtonEvent &be) {
if (be.button == 1) if (be.button == 1)
raise(); raise();
if (be.button != 3) if (be.button != 2)
return; return;
screen() screen()