all repos — fluxbox @ 9dadf682d61fbfe9ea706b89aa635c1180f030cc

custom fork of the fluxbox windowmanager

using iconbar mode
fluxgen fluxgen
commit

9dadf682d61fbfe9ea706b89aa635c1180f030cc

parent

aa13ddc1abe2ad7798c38c3901dae1034c71ad95

2 files changed, 10 insertions(+), 110 deletions(-)

jump to
M src/ToolbarHandler.ccsrc/ToolbarHandler.cc

@@ -20,7 +20,7 @@ // 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.27 2003/08/11 20:51:32 fluxgen Exp $ +// $Id: ToolbarHandler.cc,v 1.28 2003/09/08 18:18:25 fluxgen Exp $ /** * The ToolbarHandler class acts as a rough interface to the toolbar.

@@ -45,109 +45,9 @@ #include <string>

using namespace std; -template<> -void FbTk::Resource<ToolbarHandler::ToolbarMode>:: -setFromString(const char *strval) { - if (strcasecmp(strval, "Off") == 0) - m_value = ToolbarHandler::OFF; - else if (strcasecmp(strval, "None") == 0) - m_value = ToolbarHandler::NONE; - else if (strcasecmp(strval, "Icons") == 0) - m_value = ToolbarHandler::ICONS; - else if (strcasecmp(strval, "WorkspaceIcons") == 0) - m_value = ToolbarHandler::WORKSPACEICONS; - else if (strcasecmp(strval, "Workspace") == 0) - m_value = ToolbarHandler::WORKSPACE; - else if (strcasecmp(strval, "AllWindows") == 0) - m_value = ToolbarHandler::ALLWINDOWS; - else - setDefaultValue(); -} - - -template<> -string FbTk::Resource<ToolbarHandler::ToolbarMode>:: -getString() { - switch (m_value) { - case ToolbarHandler::OFF: - return string("Off"); - break; - case ToolbarHandler::NONE: - return string("None"); - break; - case ToolbarHandler::LASTMODE: - case ToolbarHandler::ICONS: - return string("Icons"); - break; - case ToolbarHandler::WORKSPACEICONS: - return string("WorkspaceIcons"); - break; - case ToolbarHandler::WORKSPACE: - return string("Workspace"); - break; - case ToolbarHandler::ALLWINDOWS: - return string("AllWindows"); - break; - } - // default string - return string("Icons"); -} - -namespace { - -class ToolbarModeMenuItem : public FbTk::MenuItem { -public: - ToolbarModeMenuItem(const char *label, ToolbarHandler &handler, - ToolbarHandler::ToolbarMode mode, - FbTk::RefCount<FbTk::Command> &cmd): - FbTk::MenuItem(label, cmd), m_handler(handler), m_mode(mode) { - } - bool isEnabled() const { return m_handler.mode() != m_mode; } - void click(int button, int time) { - m_handler.setMode(m_mode); - FbTk::MenuItem::click(button, time); - } - -private: - ToolbarHandler &m_handler; - ToolbarHandler::ToolbarMode m_mode; -}; - -void setupModeMenu(FbTk::Menu &menu, ToolbarHandler &handler) { - //I18n *i18n = I18n::instance(); - //using namespace FBNLS; - using namespace FbTk; - - // TODO: nls - menu.setLabel("Toolbar Mode"); - - RefCount<Command> saverc_cmd(new SimpleCommand<Fluxbox>( - *Fluxbox::instance(), - &Fluxbox::save_rc)); - - //TODO: nls - menu.insert(new ToolbarModeMenuItem("Off", handler, - ToolbarHandler::OFF, saverc_cmd)); - menu.insert(new ToolbarModeMenuItem("None", handler, - ToolbarHandler::NONE, saverc_cmd)); - menu.insert(new ToolbarModeMenuItem("Icons", handler, - ToolbarHandler::ICONS, saverc_cmd)); - menu.insert(new ToolbarModeMenuItem("Workspace Icons", handler, - ToolbarHandler::WORKSPACEICONS, saverc_cmd)); - menu.insert(new ToolbarModeMenuItem("Workspace", handler, - ToolbarHandler::WORKSPACE, saverc_cmd)); - menu.insert(new ToolbarModeMenuItem("All Windows", handler, - ToolbarHandler::ALLWINDOWS, saverc_cmd)); - menu.update(); -} - -}; // end anonymous namespace - ToolbarHandler::ToolbarHandler(BScreen &screen) : m_screen(screen), // no need to lock since only one resource - m_rc_mode(screen.resourceManager(), ToolbarHandler::ICONS, - screen.name() + ".toolbar.mode", screen.altName() + ".Toolbar.Mode"), m_toolbar(0), m_current_workspace(0), m_modemenu(*screen.menuTheme(),

@@ -156,8 +56,11 @@ m_toolbarmenu(*screen.menuTheme(),

screen.screenNumber(), screen.imageControl()) { m_modemenu.setInternalMenu(); m_toolbarmenu.setInternalMenu(); - setupModeMenu(m_modemenu, *this); - setMode(*m_rc_mode, false); // the atomhandler part will initialise it shortly + + 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)

@@ -166,10 +69,9 @@ enableUpdate();

} void ToolbarHandler::setMode(ToolbarMode newmode, bool initialise) { - if (newmode < 0 || newmode >= LASTMODE || (newmode == mode() && initialise)) + if (newmode < 0 || newmode >= LASTMODE) return; - *m_rc_mode = newmode; if (newmode == OFF) { m_toolbarmenu.removeAll();
M src/ToolbarHandler.hhsrc/ToolbarHandler.hh

@@ -20,7 +20,7 @@ // 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.7 2003/07/28 15:06:34 rathnor Exp $ +// $Id: ToolbarHandler.hh,v 1.8 2003/09/08 18:18:25 fluxgen Exp $ #ifndef TOOLBARHANDLER_HH #define TOOLBARHANDLER_HH

@@ -49,7 +49,6 @@ explicit ToolbarHandler(BScreen &screen);

~ToolbarHandler() { } void setMode(ToolbarMode mode, bool initialise = true); - ToolbarMode mode() const { return *m_rc_mode; }; inline const Toolbar *toolbar() const { return m_toolbar.get(); } inline Toolbar *toolbar() { return m_toolbar.get(); }

@@ -85,13 +84,12 @@ 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; - FbTk::Resource<ToolbarMode> m_rc_mode; std::auto_ptr<Toolbar> m_toolbar; unsigned int m_current_workspace; - + ToolbarMode m_mode; FbTk::Menu m_modemenu; FbTk::Menu m_toolbarmenu; };