From 7ed6c5ed290253227399d2524cb858860f2da3a1 Mon Sep 17 00:00:00 2001 From: mathias Date: Thu, 2 Dec 2004 03:12:55 +0000 Subject: * leftclick on the slitclients in the clientmenu enables/disables it * wheel up/down move the slitclient up/down * visual cosmetic for the slitclient-menu * added "Save SlitList" - menuentry in slitclient-menu --- nls/fluxbox-nls.hh | 5 ++-- src/Slit.cc | 68 +++++++++++++++++++++++++++++++++++++++++++----------- src/Slit.hh | 4 ++++ 3 files changed, 62 insertions(+), 15 deletions(-) diff --git a/nls/fluxbox-nls.hh b/nls/fluxbox-nls.hh index 5f396a4..9f545a4 100644 --- a/nls/fluxbox-nls.hh +++ b/nls/fluxbox-nls.hh @@ -1,4 +1,4 @@ -// This file generated by nlsinfo -H -N FBNLS ../src ../util, on Wed Dec 1 02:25:27 2004 +// This file generated by nlsinfo -H -N FBNLS ../src ../util, on Thu Dec 2 03:12:30 2004 #ifndef FLUXBOX_NLS_HH #define FLUXBOX_NLS_HH @@ -164,7 +164,8 @@ enum { SlitLayer = 5, SlitOnHead = 6, SlitPlacement = 7, - SlitSlit = 8, + SlitSaveSlitList = 8, + SlitSlit = 9, ToolbarSet = 15, ToolbarClock12 = 1, diff --git a/src/Slit.cc b/src/Slit.cc index 4134075..8a09e6c 100644 --- a/src/Slit.cc +++ b/src/Slit.cc @@ -56,6 +56,7 @@ #include "SlitClient.hh" #include "Xutil.hh" #include "FbAtoms.hh" +#include "FbTk/MenuSeparator.hh" #include "FbTk/StringUtil.hh" #include "FbTk/I18n.hh" @@ -161,14 +162,13 @@ string FbTk::Resource::getString() { namespace { -class SlitClientMenuItem: public FbTk::MenuItem { +class SlitClientMenuItem: public FbTk::MenuItem{ public: - explicit SlitClientMenuItem(SlitClient &client, FbTk::RefCount &cmd): - FbTk::MenuItem(client.matchName().c_str(), cmd), m_client(client) { + explicit SlitClientMenuItem(Slit& slit, SlitClient &client, FbTk::RefCount &cmd): + FbTk::MenuItem(client.matchName().c_str(), cmd), m_slit(slit), m_client(client) { + setCommand(cmd); FbTk::MenuItem::setSelected(client.visible()); - // save resources as default click action - FbTk::RefCount save_rc(new FbCommands::SaveResources()); - setCommand(save_rc); + setToggleItem(true); } const std::string &label() const { return m_client.matchName(); @@ -176,11 +176,19 @@ public: bool isSelected() const { return m_client.visible(); } - void click(int button, int time) { - m_client.setVisible(!m_client.visible()); - FbTk::MenuItem::click(button, time); + void click(int button, int time) { + if (button == 4) { // wheel up + m_slit.clientUp(&m_client); + } else if (button == 5) { // wheel down + m_slit.clientDown(&m_client); + } else { + m_client.setVisible(!m_client.visible()); + FbTk::MenuItem::setSelected(m_client.visible()); + FbTk::MenuItem::click(button, time); + } } private: + Slit& m_slit; SlitClient &m_client; }; @@ -898,6 +906,35 @@ void Slit::shutdown() { removeClient(m_client_list.front(), true, true); } +void Slit::clientUp(SlitClient* client) { + if (!client || m_client_list.size() < 2) + return; + + SlitClients::iterator it = m_client_list.begin(); + + for(it++; it != m_client_list.end(); it++) { + if ((*it) == client) { + swap(*it, *(it--)); + reconfigure(); + break; + } + } +} + +void Slit::clientDown(SlitClient* client) { + if (!client || m_client_list.size() < 2) + return; + + SlitClients::reverse_iterator it = m_client_list.rbegin(); + for(it++; it != m_client_list.rend(); it++) { + if ((*it) == client) { + swap(*it, *(it--)); + reconfigure(); + break; + } + } +} + void Slit::cycleClientsUp() { if (m_client_list.size() < 2) return; @@ -1108,17 +1145,22 @@ void Slit::updateClientmenu() { m_clientlist_menu.insert(_FBTEXT(Slit, CycleUp, "Cycle Up", "Cycle clients upwards"), cycle_up); m_clientlist_menu.insert(_FBTEXT(Slit, CycleDown, "Cycle Down", "Cycle clients downwards"), cycle_down); - FbTk::MenuItem *separator = new FbTk::MenuItem("---"); - separator->setEnabled(false); - m_clientlist_menu.insert(separator); + m_clientlist_menu.insert(new FbTk::MenuSeparator()); FbTk::RefCount reconfig(new FbTk::SimpleCommand(*this, &Slit::reconfigure)); SlitClients::iterator it = m_client_list.begin(); for (; it != m_client_list.end(); ++it) { if ((*it) != 0 && (*it)->window() != 0) - m_clientlist_menu.insert(new SlitClientMenuItem(*(*it), reconfig)); + m_clientlist_menu.insert(new SlitClientMenuItem(*this, *(*it), reconfig)); } + m_clientlist_menu.insert(new FbTk::MenuSeparator()); + FbTk::RefCount savecmd(new FbTk::SimpleCommand(*this, &Slit::saveClientList)); + m_clientlist_menu.insert(_FBTEXT(Slit, + SaveSlitList, + "Save SlitList", "Saves the current order in the slit"), + savecmd); + m_clientlist_menu.update(); } diff --git a/src/Slit.hh b/src/Slit.hh index 3fe56c5..4f95afc 100644 --- a/src/Slit.hh +++ b/src/Slit.hh @@ -75,6 +75,10 @@ public: void shutdown(); /// save clients name in a file void saveClientList(); + /// move client one position up + void clientUp(SlitClient*); + /// move client one position down + void clientDown(SlitClient*); /// cycle slit clients up one step void cycleClientsUp(); /// cycle slit clients down one step -- cgit v0.11.2