This commit is contained in:
fluxgen 2003-12-03 00:32:58 +00:00
parent 82e72ab493
commit 8971b068ac
2 changed files with 0 additions and 324 deletions

View file

@ -1,227 +0,0 @@
// ToolbarHandler for fluxbox
// Copyright (c) 2003 Simon Bowden (rathnor at fluxbox.org)
// and Henrik Kinnunen (fluxgen at fluxbox.org)
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
// $Id: ToolbarHandler.cc,v 1.29 2003/10/06 06:22:43 rathnor Exp $
/**
* The ToolbarHandler class acts as a rough interface to the toolbar.
* It deals with whether it should be there or not, so anything that
* always needs to be accessible must come through the handler.
*/
#include "ToolbarHandler.hh"
#include "Window.hh"
#include "Screen.hh"
#include "Workspace.hh"
#include "MenuItem.hh"
#include "FbMenu.hh"
#include "FbCommands.hh"
#include "RefCount.hh"
#include "SimpleCommand.hh"
#include "MacroCommand.hh"
#include "IntResMenuItem.hh"
#include "BoolMenuItem.hh"
#include <string>
using namespace std;
ToolbarHandler::ToolbarHandler(BScreen &screen)
: m_screen(screen),
// no need to lock since only one resource
m_toolbar(0),
m_current_workspace(0),
m_modemenu(*screen.menuTheme(),
screen.screenNumber(), screen.imageControl(),
*screen.layerManager().getLayer(Fluxbox::instance()->getMenuLayer())),
m_toolbarmenu(*screen.menuTheme(),
screen.screenNumber(), screen.imageControl(),
*screen.layerManager().getLayer(Fluxbox::instance()->getMenuLayer())) {
m_modemenu.setInternalMenu();
m_toolbarmenu.setInternalMenu();
m_mode = WORKSPACE;
m_toolbar.reset(new Toolbar(m_screen,
*m_screen.layerManager().getLayer(Fluxbox::instance()->getNormalLayer()),
m_toolbarmenu));
// now add this to the config menus for the screen
// (we only want it done once, so it can't go in initforscreen)
screen.addConfigMenu("Toolbar", m_toolbarmenu);
enableUpdate();
}
void ToolbarHandler::setMode(ToolbarMode newmode, bool initialise) {
if (newmode < 0 || newmode >= LASTMODE)
return;
if (newmode == OFF) {
m_toolbarmenu.removeAll();
//TODO: nls
m_toolbarmenu.insert("Mode...", &m_modemenu);
m_toolbar.reset(0);
m_toolbarmenu.update();
return;
} else if (!m_toolbar.get()) {
m_toolbarmenu.removeAll();
m_toolbar.reset(new Toolbar(m_screen,
*m_screen.layerManager().getLayer(Fluxbox::instance()->getNormalLayer()), m_toolbarmenu));
m_toolbar->reconfigure();
m_toolbarmenu.insert("Mode...", &m_modemenu);
m_toolbarmenu.update();
}
if (newmode == NONE) {
//!! TODO disable iconbar
} else {
// rebuild it
// be sure the iconbar is on
//!! TODO enable iconbar
}
if (initialise)
initForScreen(m_screen);
}
void ToolbarHandler::initForScreen(BScreen &screen) {
if (&m_screen != &screen)
return;
switch (mode()) {
case OFF:
break;
case NONE:
break;
case ALLWINDOWS:
//!! TODO: change iconbar mode
// fall through and add icons
case LASTMODE:
case ICONS:
//!! TODO: update iconbar mode
break;
case WORKSPACE:
//!! TODO: update iconbar mode
// fall through and add icons for this workspace
case WORKSPACEICONS:
//!! TODO: update iconbar mode
break;
}
}
void ToolbarHandler::setupFrame(FluxboxWindow &win) {
if (&win.screen() != &m_screen)
return;
switch (mode()) {
case OFF:
case NONE:
break;
case WORKSPACE:
break;
case WORKSPACEICONS:
break;
// else fall through and add the icon
case LASTMODE:
case ICONS:
break;
case ALLWINDOWS:
break;
}
}
void ToolbarHandler::updateFrameClose(FluxboxWindow &win) {
if (&win.screen() != &m_screen)
return;
// check status of window (in current workspace, etc) and remove if necessary
switch (mode()) {
case OFF:
case NONE:
break;
case WORKSPACEICONS:
if (win.workspaceNumber() != m_current_workspace)
break;
// else fall through and remove the icon
case LASTMODE:
case ICONS:
break;
case WORKSPACE:
break;
case ALLWINDOWS:
break;
}
}
void ToolbarHandler::updateState(FluxboxWindow &win) {
if (&win.screen() != &m_screen)
return;
// this function only relevant for icons
switch (mode()) {
case OFF:
case NONE:
case WORKSPACE:
case ALLWINDOWS:
break;
case WORKSPACEICONS:
if (win.workspaceNumber() != m_current_workspace)
break;
// else fall through and do the same as icons (knowing it is the right ws)
case LASTMODE:
case ICONS:
break;
}
}
void ToolbarHandler::updateWorkspace(FluxboxWindow &win) {
if (&win.screen() != &m_screen)
return;
// don't care about current workspace except if in workspace mode
if (!(mode() == WORKSPACE ||
(mode() == WORKSPACEICONS && win.isIconic())))
return;
if (win.workspaceNumber() == m_current_workspace) {
} else {
}
}
void ToolbarHandler::updateCurrentWorkspace(BScreen &screen) {
if (&screen != &m_screen || mode() == OFF)
return;
if (mode() != NONE)
initForScreen(m_screen);
}

View file

@ -1,97 +0,0 @@
// ToolbarHandler for fluxbox
// Copyright (c) 2003 Simon Bowden (rathnor at fluxbox.org)
// and Henrik Kinnunen (fluxgen at fluxbox.org)
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
// $Id: ToolbarHandler.hh,v 1.9 2003/10/06 06:22:43 rathnor Exp $
#ifndef TOOLBARHANDLER_HH
#define TOOLBARHANDLER_HH
#include "AtomHandler.hh"
#include "Menu.hh"
#include "Toolbar.hh"
#include "Resource.hh"
class BScreen;
class FluxboxWindow;
class ToolbarHandler : public AtomHandler {
public:
enum ToolbarMode {
OFF=0,
NONE,
ICONS,
WORKSPACEICONS,
WORKSPACE,
ALLWINDOWS,
LASTMODE
};
explicit ToolbarHandler(BScreen &screen);
~ToolbarHandler() { }
void setMode(ToolbarMode mode, bool initialise = true);
inline const Toolbar *toolbar() const { return m_toolbar.get(); }
inline Toolbar *toolbar() { return m_toolbar.get(); }
void initForScreen(BScreen &screen);
void setupFrame(FluxboxWindow &win);
// TODO: add setupClient and configure option to show groups or indiv. clients
void setupClient(WinClient &winclient) {}
void updateState(FluxboxWindow &win);
void updateFrameClose(FluxboxWindow &win);
void updateClientClose(WinClient &winclient) {}
void updateWorkspace(FluxboxWindow &win);
void updateCurrentWorkspace(BScreen &screen);
// these ones don't affect us
void updateWorkspaceNames(BScreen &screen) {}
void updateWorkspaceCount(BScreen &screen) {}
void updateClientList(BScreen &screen) {}
void updateHints(FluxboxWindow &win) {}
void updateLayer(FluxboxWindow &win) {}
bool checkClientMessage(const XClientMessageEvent &ce,
BScreen * screen, WinClient * const winclient) { return false; }
bool propertyNotify(WinClient &winclient, Atom the_atom) { return false; }
inline FbTk::Menu &getModeMenu() { return m_modemenu; }
inline const FbTk::Menu &getModeMenu() const { return m_modemenu; }
inline FbTk::Menu &getToolbarMenu() { return m_toolbarmenu; }
inline const FbTk::Menu &getToolbarMenu() const { return m_toolbarmenu; }
inline BScreen &screen() { return m_screen; }
inline const BScreen &screen() const { return m_screen; }
ToolbarMode mode() const { return m_mode; }
private:
BScreen &m_screen;
std::auto_ptr<Toolbar> m_toolbar;
unsigned int m_current_workspace;
ToolbarMode m_mode;
FbMenu m_modemenu;
FbMenu m_toolbarmenu;
};
#endif // TOOLBARHANDLER_HH