diff options
author | Pavel Labath <pavelo@centrum.sk> | 2011-07-10 14:10:39 (GMT) |
---|---|---|
committer | Paul Tagliamonte <paultag@fluxbox.org> | 2012-04-07 02:11:31 (GMT) |
commit | 30df36260411112985fdc6ded6d8ad17e079752d (patch) | |
tree | c54cd25af7b255e1f15e4c43a7bd9258332349e7 /src | |
parent | 7d488e2df6095fdd81b42c2d469c416b9b4d9144 (diff) | |
download | fluxbox_paul-30df36260411112985fdc6ded6d8ad17e079752d.zip fluxbox_paul-30df36260411112985fdc6ded6d8ad17e079752d.tar.bz2 |
Attach a modifiedSig handler to the session.keyFile resource
Diffstat (limited to 'src')
-rw-r--r-- | src/FbCommands.cc | 2 | ||||
-rw-r--r-- | src/Keys.cc | 21 | ||||
-rw-r--r-- | src/Keys.hh | 6 | ||||
-rw-r--r-- | src/fluxbox.cc | 2 | ||||
-rw-r--r-- | src/fluxbox.hh | 2 |
5 files changed, 12 insertions, 21 deletions
diff --git a/src/FbCommands.cc b/src/FbCommands.cc index 5ddfa3a..4e9d214 100644 --- a/src/FbCommands.cc +++ b/src/FbCommands.cc | |||
@@ -460,7 +460,7 @@ BindKeyCmd::BindKeyCmd(const string &keybind):m_keybind(keybind) { } | |||
460 | void BindKeyCmd::execute() { | 460 | void BindKeyCmd::execute() { |
461 | if (Fluxbox::instance()->keys() != 0) { | 461 | if (Fluxbox::instance()->keys() != 0) { |
462 | if (Fluxbox::instance()->keys()->addBinding(m_keybind)) { | 462 | if (Fluxbox::instance()->keys()->addBinding(m_keybind)) { |
463 | ofstream ofile(Fluxbox::instance()->keys()->filename().c_str(), ios::app); | 463 | ofstream ofile(Fluxbox::instance()->getKeysResource()->c_str(), ios::app); |
464 | if (!ofile) | 464 | if (!ofile) |
465 | return; | 465 | return; |
466 | ofile<<m_keybind<<endl; | 466 | ofile<<m_keybind<<endl; |
diff --git a/src/Keys.cc b/src/Keys.cc index f91c92e..5fc5715 100644 --- a/src/Keys.cc +++ b/src/Keys.cc | |||
@@ -188,7 +188,11 @@ Keys::Keys(): | |||
188 | m_reloader(new FbTk::AutoReloadHelper()), | 188 | m_reloader(new FbTk::AutoReloadHelper()), |
189 | m_keylist(0), | 189 | m_keylist(0), |
190 | next_key(0), saved_keymode(0) { | 190 | next_key(0), saved_keymode(0) { |
191 | |||
191 | m_reloader->setReloadCmd(FbTk::RefCount<FbTk::Command<void> >(new FbTk::SimpleCommand<Keys>(*this, &Keys::reload))); | 192 | m_reloader->setReloadCmd(FbTk::RefCount<FbTk::Command<void> >(new FbTk::SimpleCommand<Keys>(*this, &Keys::reload))); |
193 | m_reloader->setMainFile(*Fluxbox::instance()->getKeysResource()); | ||
194 | join(Fluxbox::instance()->getKeysResource().modifiedSig(), | ||
195 | MemFun(*m_reloader, &FbTk::AutoReloadHelper::setMainFile)); | ||
192 | } | 196 | } |
193 | 197 | ||
194 | Keys::~Keys() { | 198 | Keys::~Keys() { |
@@ -282,8 +286,9 @@ void Keys::grabWindow(Window win) { | |||
282 | void Keys::reload() { | 286 | void Keys::reload() { |
283 | // an intentionally empty file will still have one root mapping | 287 | // an intentionally empty file will still have one root mapping |
284 | bool firstload = m_map.empty(); | 288 | bool firstload = m_map.empty(); |
289 | const std::string filename = FbTk::StringUtil::expandFilename(*Fluxbox::instance()->getKeysResource()); | ||
285 | 290 | ||
286 | if (m_filename.empty()) { | 291 | if (filename.empty()) { |
287 | if (firstload) | 292 | if (firstload) |
288 | loadDefaults(); | 293 | loadDefaults(); |
289 | return; | 294 | return; |
@@ -291,12 +296,12 @@ void Keys::reload() { | |||
291 | 296 | ||
292 | FbTk::App::instance()->sync(false); | 297 | FbTk::App::instance()->sync(false); |
293 | 298 | ||
294 | if (! FbTk::FileUtil::isRegularFile(m_filename.c_str())) { | 299 | if (! FbTk::FileUtil::isRegularFile(filename.c_str())) { |
295 | return; | 300 | return; |
296 | } | 301 | } |
297 | 302 | ||
298 | // open the file | 303 | // open the file |
299 | ifstream infile(m_filename.c_str()); | 304 | ifstream infile(filename.c_str()); |
300 | if (!infile) { | 305 | if (!infile) { |
301 | if (firstload) | 306 | if (firstload) |
302 | loadDefaults(); | 307 | loadDefaults(); |
@@ -607,16 +612,6 @@ void Keys::unregisterWindow(Window win) { | |||
607 | m_window_map.erase(win); | 612 | m_window_map.erase(win); |
608 | } | 613 | } |
609 | 614 | ||
610 | /** | ||
611 | deletes the tree and load configuration | ||
612 | returns true on success else false | ||
613 | */ | ||
614 | void Keys::reconfigure() { | ||
615 | m_filename = FbTk::StringUtil::expandFilename(Fluxbox::instance()->getKeysFilename()); | ||
616 | m_reloader->setMainFile(m_filename); | ||
617 | m_reloader->checkReload(); | ||
618 | } | ||
619 | |||
620 | void Keys::regrab() { | 615 | void Keys::regrab() { |
621 | setKeyMode(m_keylist); | 616 | setKeyMode(m_keylist); |
622 | } | 617 | } |
diff --git a/src/Keys.hh b/src/Keys.hh index 7a6b3b8..076387b 100644 --- a/src/Keys.hh +++ b/src/Keys.hh | |||
@@ -24,6 +24,7 @@ | |||
24 | 24 | ||
25 | #include "FbTk/NotCopyable.hh" | 25 | #include "FbTk/NotCopyable.hh" |
26 | #include "FbTk/RefCount.hh" | 26 | #include "FbTk/RefCount.hh" |
27 | #include "FbTk/Signal.hh" | ||
27 | 28 | ||
28 | #include <X11/Xlib.h> | 29 | #include <X11/Xlib.h> |
29 | #include <string> | 30 | #include <string> |
@@ -36,7 +37,7 @@ namespace FbTk { | |||
36 | class AutoReloadHelper; | 37 | class AutoReloadHelper; |
37 | } | 38 | } |
38 | 39 | ||
39 | class Keys:private FbTk::NotCopyable { | 40 | class Keys: private FbTk::NotCopyable, private FbTk::SignalTracker { |
40 | public: | 41 | public: |
41 | 42 | ||
42 | // contexts for events | 43 | // contexts for events |
@@ -80,7 +81,6 @@ public: | |||
80 | /// grab keys again when keymap changes | 81 | /// grab keys again when keymap changes |
81 | void regrab(); | 82 | void regrab(); |
82 | 83 | ||
83 | const std::string& filename() const { return m_filename; } | ||
84 | /** | 84 | /** |
85 | Load configuration from file | 85 | Load configuration from file |
86 | */ | 86 | */ |
@@ -88,7 +88,6 @@ public: | |||
88 | /** | 88 | /** |
89 | Reload configuration if keys file has changed | 89 | Reload configuration if keys file has changed |
90 | */ | 90 | */ |
91 | void reconfigure(); | ||
92 | void keyMode(const std::string& keyMode); | 91 | void keyMode(const std::string& keyMode); |
93 | 92 | ||
94 | bool inKeychain() const { return saved_keymode != 0; } | 93 | bool inKeychain() const { return saved_keymode != 0; } |
@@ -114,7 +113,6 @@ private: | |||
114 | 113 | ||
115 | 114 | ||
116 | // member variables | 115 | // member variables |
117 | std::string m_filename; | ||
118 | FbTk::AutoReloadHelper* m_reloader; | 116 | FbTk::AutoReloadHelper* m_reloader; |
119 | RefKey m_keylist; | 117 | RefKey m_keylist; |
120 | keyspace_t m_map; | 118 | keyspace_t m_map; |
diff --git a/src/fluxbox.cc b/src/fluxbox.cc index fb56571..78741b5 100644 --- a/src/fluxbox.cc +++ b/src/fluxbox.cc | |||
@@ -354,7 +354,6 @@ Fluxbox::Fluxbox(int argc, char **argv, | |||
354 | // Create keybindings handler and load keys file | 354 | // Create keybindings handler and load keys file |
355 | // Note: this needs to be done before creating screens | 355 | // Note: this needs to be done before creating screens |
356 | m_key.reset(new Keys); | 356 | m_key.reset(new Keys); |
357 | m_key->reconfigure(); | ||
358 | 357 | ||
359 | vector<int> screens; | 358 | vector<int> screens; |
360 | int i; | 359 | int i; |
@@ -1237,7 +1236,6 @@ void Fluxbox::reconfigure() { | |||
1237 | 1236 | ||
1238 | void Fluxbox::real_reconfigure() { | 1237 | void Fluxbox::real_reconfigure() { |
1239 | STLUtil::forAll(m_screen_list, mem_fun(&BScreen::reconfigure)); | 1238 | STLUtil::forAll(m_screen_list, mem_fun(&BScreen::reconfigure)); |
1240 | m_key->reconfigure(); | ||
1241 | } | 1239 | } |
1242 | 1240 | ||
1243 | BScreen *Fluxbox::findScreen(int id) { | 1241 | BScreen *Fluxbox::findScreen(int id) { |
diff --git a/src/fluxbox.hh b/src/fluxbox.hh index f8a27bc..3e9e8d6 100644 --- a/src/fluxbox.hh +++ b/src/fluxbox.hh | |||
@@ -121,8 +121,8 @@ public: | |||
121 | const std::string &getStyleOverlayFilename() const { return *m_rc_styleoverlayfile; } | 121 | const std::string &getStyleOverlayFilename() const { return *m_rc_styleoverlayfile; } |
122 | 122 | ||
123 | const std::string &getMenuFilename() const { return *m_rc_menufile; } | 123 | const std::string &getMenuFilename() const { return *m_rc_menufile; } |
124 | const std::string &getKeysFilename() const { return *m_rc_keyfile; } | ||
125 | FbTk::StringResource &getAppsResource() { return m_rc_appsfile; } | 124 | FbTk::StringResource &getAppsResource() { return m_rc_appsfile; } |
125 | FbTk::StringResource &getKeysResource() { return m_rc_keyfile; } | ||
126 | int colorsPerChannel() const { return *m_rc_colors_per_channel; } | 126 | int colorsPerChannel() const { return *m_rc_colors_per_channel; } |
127 | int getTabsPadding() const { return *m_rc_tabs_padding; } | 127 | int getTabsPadding() const { return *m_rc_tabs_padding; } |
128 | 128 | ||