aboutsummaryrefslogtreecommitdiff
path: root/src/Slit.cc
diff options
context:
space:
mode:
authorrathnor <rathnor>2003-04-16 16:18:06 (GMT)
committerrathnor <rathnor>2003-04-16 16:18:06 (GMT)
commite48f7836fdaca03e0626b3e7ac4d37c99dd35dc9 (patch)
treedd5421ed6b26c0d882dd34a91dfc01eb1ae3ee85 /src/Slit.cc
parent9163668e98e1683b95fb5cc44c19b3695c7857c4 (diff)
downloadfluxbox_pavel-e48f7836fdaca03e0626b3e7ac4d37c99dd35dc9.zip
fluxbox_pavel-e48f7836fdaca03e0626b3e7ac4d37c99dd35dc9.tar.bz2
fix saving of various slit params (Simon)
Diffstat (limited to 'src/Slit.cc')
-rw-r--r--src/Slit.cc54
1 files changed, 39 insertions, 15 deletions
diff --git a/src/Slit.cc b/src/Slit.cc
index bb910f7..421ff79 100644
--- a/src/Slit.cc
+++ b/src/Slit.cc
@@ -22,7 +22,7 @@
22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23// DEALINGS IN THE SOFTWARE. 23// DEALINGS IN THE SOFTWARE.
24 24
25// $Id: Slit.cc,v 1.39 2003/04/16 13:43:43 rathnor Exp $ 25// $Id: Slit.cc,v 1.40 2003/04/16 16:18:02 rathnor Exp $
26 26
27#include "Slit.hh" 27#include "Slit.hh"
28 28
@@ -185,9 +185,10 @@ private:
185 185
186class SlitDirMenuItem: public FbTk::MenuItem { 186class SlitDirMenuItem: public FbTk::MenuItem {
187public: 187public:
188 SlitDirMenuItem(const char *label, Slit &slit):FbTk::MenuItem(label), 188 SlitDirMenuItem(const char *label, Slit &slit, FbTk::RefCount<FbTk::Command> &cmd)
189 m_slit(slit), 189 :FbTk::MenuItem(label,cmd),
190 m_label(label ? label : "") { 190 m_slit(slit),
191 m_label(label ? label : "") {
191 setLabel(m_label.c_str()); // update label 192 setLabel(m_label.c_str()); // update label
192 } 193 }
193 void click(int button, int time) { 194 void click(int button, int time) {
@@ -197,6 +198,7 @@ public:
197 else 198 else
198 m_slit.setDirection(Slit::HORIZONTAL); 199 m_slit.setDirection(Slit::HORIZONTAL);
199 setLabel(m_label.c_str()); 200 setLabel(m_label.c_str());
201 FbTk::MenuItem::click(button, time);
200 } 202 }
201 203
202 void setLabel(const char *label) { 204 void setLabel(const char *label) {
@@ -219,13 +221,14 @@ private:
219 221
220class PlaceSlitMenuItem: public FbTk::MenuItem { 222class PlaceSlitMenuItem: public FbTk::MenuItem {
221public: 223public:
222 PlaceSlitMenuItem(const char *label, Slit &slit, Slit::Placement place): 224 PlaceSlitMenuItem(const char *label, Slit &slit, Slit::Placement place, FbTk::RefCount<FbTk::Command> &cmd):
223 FbTk::MenuItem(label), m_slit(slit), m_place(place) { 225 FbTk::MenuItem(label, cmd), m_slit(slit), m_place(place) {
224 226
225 } 227 }
226 bool isEnabled() const { return m_slit.placement() != m_place; } 228 bool isEnabled() const { return m_slit.placement() != m_place; }
227 void click(int button, int time) { 229 void click(int button, int time) {
228 m_slit.setPlacement(m_place); 230 m_slit.setPlacement(m_place);
231 FbTk::MenuItem::click(button, time);
229 } 232 }
230private: 233private:
231 Slit &m_slit; 234 Slit &m_slit;
@@ -258,9 +261,9 @@ Slit::Slit(BScreen &scr, FbTk::XLayer &layer, const char *filename)
258 true)); 261 true));
259 262
260 // default placement and direction 263 // default placement and direction
261 m_direction = HORIZONTAL; 264 m_direction = screen().getSlitDirection();
262 m_placement = BOTTOMRIGHT; 265 m_placement = screen().getSlitPlacement();
263 hidden = do_auto_hide = false; 266 hidden = do_auto_hide = screen().doSlitAutoHide();
264 267
265 frame.pixmap = None; 268 frame.pixmap = None;
266 269
@@ -456,11 +459,13 @@ void Slit::addClient(Window w) {
456 459
457void Slit::setDirection(Direction dir) { 460void Slit::setDirection(Direction dir) {
458 m_direction = dir; 461 m_direction = dir;
462 screen().saveSlitDirection(dir);
459 reconfigure(); 463 reconfigure();
460} 464}
461 465
462void Slit::setPlacement(Placement place) { 466void Slit::setPlacement(Placement place) {
463 m_placement = place; 467 m_placement = place;
468 screen().saveSlitPlacement(place);
464 reconfigure(); 469 reconfigure();
465} 470}
466 471
@@ -533,6 +538,9 @@ void Slit::reconfigure() {
533 frame.width = 0; 538 frame.width = 0;
534 frame.height = 0; 539 frame.height = 0;
535 540
541 // be sure to sync slit auto hide up with the screen's menu resource
542 do_auto_hide = screen().doSlitAutoHide();
543
536 // Need to count windows because not all client list entries 544 // Need to count windows because not all client list entries
537 // actually correspond to mapped windows. 545 // actually correspond to mapped windows.
538 int num_windows = 0; 546 int num_windows = 0;
@@ -1091,6 +1099,7 @@ void Slit::saveClientList() {
1091 1099
1092void Slit::setAutoHide(bool val) { 1100void Slit::setAutoHide(bool val) {
1093 do_auto_hide = val; 1101 do_auto_hide = val;
1102 screen().saveSlitAutoHide(val);
1094} 1103}
1095 1104
1096void Slit::setupMenu() { 1105void Slit::setupMenu() {
@@ -1098,7 +1107,14 @@ void Slit::setupMenu() {
1098 using namespace FBNLS; 1107 using namespace FBNLS;
1099 using namespace FbTk; 1108 using namespace FbTk;
1100 1109
1101 RefCount<Command> menu_cmd(new SimpleCommand<Slit>(*this, &Slit::reconfigure)); 1110 FbTk::MacroCommand *s_a_reconf_macro = new FbTk::MacroCommand();
1111 FbTk::RefCount<FbTk::Command> saverc_cmd(new FbTk::SimpleCommand<Fluxbox>(*Fluxbox::instance(),
1112 &Fluxbox::save_rc));
1113 FbTk::RefCount<FbTk::Command> reconf_cmd(new FbCommands::ReconfigureFluxboxCmd());
1114 s_a_reconf_macro->add(saverc_cmd);
1115 s_a_reconf_macro->add(reconf_cmd);
1116 FbTk::RefCount<FbTk::Command> save_and_reconfigure(s_a_reconf_macro);
1117
1102 // setup base menu 1118 // setup base menu
1103 slitmenu.setLabel("Slit"); 1119 slitmenu.setLabel("Slit");
1104 slitmenu.insert(i18n->getMessage( 1120 slitmenu.insert(i18n->getMessage(
@@ -1111,12 +1127,14 @@ void Slit::setupMenu() {
1111 slitmenu.insert(new BoolMenuItem(i18n->getMessage( 1127 slitmenu.insert(new BoolMenuItem(i18n->getMessage(
1112 CommonSet, CommonAutoHide, 1128 CommonSet, CommonAutoHide,
1113 "Auto hide"), 1129 "Auto hide"),
1114 do_auto_hide, 1130 screen().doSlitAutoHide(),
1115 menu_cmd)); 1131 save_and_reconfigure));
1116 1132
1117 slitmenu.insert(new SlitDirMenuItem(i18n->getMessage( 1133 slitmenu.insert(new SlitDirMenuItem(i18n->getMessage(
1118 SlitSet, SlitSlitDirection, 1134 SlitSet, SlitSlitDirection,
1119 "Slit Direction"), *this)); 1135 "Slit Direction"),
1136 *this,
1137 save_and_reconfigure));
1120 slitmenu.insert("Clients", &clientlist_menu); 1138 slitmenu.insert("Clients", &clientlist_menu);
1121 slitmenu.update(); 1139 slitmenu.update();
1122 1140
@@ -1156,9 +1174,15 @@ void Slit::setupMenu() {
1156 place_menu[i].base, 1174 place_menu[i].base,
1157 place_menu[i].default_str); 1175 place_menu[i].default_str);
1158 placement_menu.insert(new PlaceSlitMenuItem(i18n_str, *this, 1176 placement_menu.insert(new PlaceSlitMenuItem(i18n_str, *this,
1159 place_menu[i].slit_placement)); 1177 place_menu[i].slit_placement,
1178 save_and_reconfigure));
1160 } 1179 }
1161 } 1180 }
1162 // finaly update sub menu 1181 // finaly update sub menu
1163 placement_menu.update(); 1182 placement_menu.update();
1164} 1183}
1184
1185void Slit::moveToLayer(int layernum) {
1186 m_layeritem->moveToLayer(layernum);
1187 m_screen.saveSlitLayer((Fluxbox::Layer) layernum);
1188}