diff options
author | mathias <mathias> | 2004-12-02 03:12:55 (GMT) |
---|---|---|
committer | mathias <mathias> | 2004-12-02 03:12:55 (GMT) |
commit | 7ed6c5ed290253227399d2524cb858860f2da3a1 (patch) | |
tree | f82e03ea251e029e739fb0786492dc449cdda56c /src | |
parent | 96de2d57d642a5a5ac0c6755fa97133c2de44359 (diff) | |
download | fluxbox_pavel-7ed6c5ed290253227399d2524cb858860f2da3a1.zip fluxbox_pavel-7ed6c5ed290253227399d2524cb858860f2da3a1.tar.bz2 |
* 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
Diffstat (limited to 'src')
-rw-r--r-- | src/Slit.cc | 68 | ||||
-rw-r--r-- | src/Slit.hh | 4 |
2 files changed, 59 insertions, 13 deletions
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 @@ | |||
56 | #include "SlitClient.hh" | 56 | #include "SlitClient.hh" |
57 | #include "Xutil.hh" | 57 | #include "Xutil.hh" |
58 | #include "FbAtoms.hh" | 58 | #include "FbAtoms.hh" |
59 | #include "FbTk/MenuSeparator.hh" | ||
59 | #include "FbTk/StringUtil.hh" | 60 | #include "FbTk/StringUtil.hh" |
60 | #include "FbTk/I18n.hh" | 61 | #include "FbTk/I18n.hh" |
61 | 62 | ||
@@ -161,14 +162,13 @@ string FbTk::Resource<Slit::Direction>::getString() { | |||
161 | 162 | ||
162 | namespace { | 163 | namespace { |
163 | 164 | ||
164 | class SlitClientMenuItem: public FbTk::MenuItem { | 165 | class SlitClientMenuItem: public FbTk::MenuItem{ |
165 | public: | 166 | public: |
166 | explicit SlitClientMenuItem(SlitClient &client, FbTk::RefCount<FbTk::Command> &cmd): | 167 | explicit SlitClientMenuItem(Slit& slit, SlitClient &client, FbTk::RefCount<FbTk::Command> &cmd): |
167 | FbTk::MenuItem(client.matchName().c_str(), cmd), m_client(client) { | 168 | FbTk::MenuItem(client.matchName().c_str(), cmd), m_slit(slit), m_client(client) { |
169 | setCommand(cmd); | ||
168 | FbTk::MenuItem::setSelected(client.visible()); | 170 | FbTk::MenuItem::setSelected(client.visible()); |
169 | // save resources as default click action | 171 | setToggleItem(true); |
170 | FbTk::RefCount<FbTk::Command> save_rc(new FbCommands::SaveResources()); | ||
171 | setCommand(save_rc); | ||
172 | } | 172 | } |
173 | const std::string &label() const { | 173 | const std::string &label() const { |
174 | return m_client.matchName(); | 174 | return m_client.matchName(); |
@@ -176,11 +176,19 @@ public: | |||
176 | bool isSelected() const { | 176 | bool isSelected() const { |
177 | return m_client.visible(); | 177 | return m_client.visible(); |
178 | } | 178 | } |
179 | void click(int button, int time) { | 179 | void click(int button, int time) { |
180 | m_client.setVisible(!m_client.visible()); | 180 | if (button == 4) { // wheel up |
181 | FbTk::MenuItem::click(button, time); | 181 | m_slit.clientUp(&m_client); |
182 | } else if (button == 5) { // wheel down | ||
183 | m_slit.clientDown(&m_client); | ||
184 | } else { | ||
185 | m_client.setVisible(!m_client.visible()); | ||
186 | FbTk::MenuItem::setSelected(m_client.visible()); | ||
187 | FbTk::MenuItem::click(button, time); | ||
188 | } | ||
182 | } | 189 | } |
183 | private: | 190 | private: |
191 | Slit& m_slit; | ||
184 | SlitClient &m_client; | 192 | SlitClient &m_client; |
185 | }; | 193 | }; |
186 | 194 | ||
@@ -898,6 +906,35 @@ void Slit::shutdown() { | |||
898 | removeClient(m_client_list.front(), true, true); | 906 | removeClient(m_client_list.front(), true, true); |
899 | } | 907 | } |
900 | 908 | ||
909 | void Slit::clientUp(SlitClient* client) { | ||
910 | if (!client || m_client_list.size() < 2) | ||
911 | return; | ||
912 | |||
913 | SlitClients::iterator it = m_client_list.begin(); | ||
914 | |||
915 | for(it++; it != m_client_list.end(); it++) { | ||
916 | if ((*it) == client) { | ||
917 | swap(*it, *(it--)); | ||
918 | reconfigure(); | ||
919 | break; | ||
920 | } | ||
921 | } | ||
922 | } | ||
923 | |||
924 | void Slit::clientDown(SlitClient* client) { | ||
925 | if (!client || m_client_list.size() < 2) | ||
926 | return; | ||
927 | |||
928 | SlitClients::reverse_iterator it = m_client_list.rbegin(); | ||
929 | for(it++; it != m_client_list.rend(); it++) { | ||
930 | if ((*it) == client) { | ||
931 | swap(*it, *(it--)); | ||
932 | reconfigure(); | ||
933 | break; | ||
934 | } | ||
935 | } | ||
936 | } | ||
937 | |||
901 | void Slit::cycleClientsUp() { | 938 | void Slit::cycleClientsUp() { |
902 | if (m_client_list.size() < 2) | 939 | if (m_client_list.size() < 2) |
903 | return; | 940 | return; |
@@ -1108,17 +1145,22 @@ void Slit::updateClientmenu() { | |||
1108 | m_clientlist_menu.insert(_FBTEXT(Slit, CycleUp, "Cycle Up", "Cycle clients upwards"), cycle_up); | 1145 | m_clientlist_menu.insert(_FBTEXT(Slit, CycleUp, "Cycle Up", "Cycle clients upwards"), cycle_up); |
1109 | m_clientlist_menu.insert(_FBTEXT(Slit, CycleDown, "Cycle Down", "Cycle clients downwards"), cycle_down); | 1146 | m_clientlist_menu.insert(_FBTEXT(Slit, CycleDown, "Cycle Down", "Cycle clients downwards"), cycle_down); |
1110 | 1147 | ||
1111 | FbTk::MenuItem *separator = new FbTk::MenuItem("---"); | 1148 | m_clientlist_menu.insert(new FbTk::MenuSeparator()); |
1112 | separator->setEnabled(false); | ||
1113 | m_clientlist_menu.insert(separator); | ||
1114 | 1149 | ||
1115 | FbTk::RefCount<FbTk::Command> reconfig(new FbTk::SimpleCommand<Slit>(*this, &Slit::reconfigure)); | 1150 | FbTk::RefCount<FbTk::Command> reconfig(new FbTk::SimpleCommand<Slit>(*this, &Slit::reconfigure)); |
1116 | SlitClients::iterator it = m_client_list.begin(); | 1151 | SlitClients::iterator it = m_client_list.begin(); |
1117 | for (; it != m_client_list.end(); ++it) { | 1152 | for (; it != m_client_list.end(); ++it) { |
1118 | if ((*it) != 0 && (*it)->window() != 0) | 1153 | if ((*it) != 0 && (*it)->window() != 0) |
1119 | m_clientlist_menu.insert(new SlitClientMenuItem(*(*it), reconfig)); | 1154 | m_clientlist_menu.insert(new SlitClientMenuItem(*this, *(*it), reconfig)); |
1120 | } | 1155 | } |
1121 | 1156 | ||
1157 | m_clientlist_menu.insert(new FbTk::MenuSeparator()); | ||
1158 | FbTk::RefCount<FbTk::Command> savecmd(new FbTk::SimpleCommand<Slit>(*this, &Slit::saveClientList)); | ||
1159 | m_clientlist_menu.insert(_FBTEXT(Slit, | ||
1160 | SaveSlitList, | ||
1161 | "Save SlitList", "Saves the current order in the slit"), | ||
1162 | savecmd); | ||
1163 | |||
1122 | m_clientlist_menu.update(); | 1164 | m_clientlist_menu.update(); |
1123 | } | 1165 | } |
1124 | 1166 | ||
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: | |||
75 | void shutdown(); | 75 | void shutdown(); |
76 | /// save clients name in a file | 76 | /// save clients name in a file |
77 | void saveClientList(); | 77 | void saveClientList(); |
78 | /// move client one position up | ||
79 | void clientUp(SlitClient*); | ||
80 | /// move client one position down | ||
81 | void clientDown(SlitClient*); | ||
78 | /// cycle slit clients up one step | 82 | /// cycle slit clients up one step |
79 | void cycleClientsUp(); | 83 | void cycleClientsUp(); |
80 | /// cycle slit clients down one step | 84 | /// cycle slit clients down one step |