diff options
author | Pavel Labath <pavelo@centrum.sk> | 2011-07-10 14:10:39 (GMT) |
---|---|---|
committer | Pavel Labath <pavelo@centrum.sk> | 2013-02-17 09:49:38 (GMT) |
commit | 3ec18bbdc84aa17c2cbbbcfcaa599a8e021b60de (patch) | |
tree | 6a8d3b8ed435e541dfcb07d34c0405982c0e46ab /src | |
parent | 6a701da32042b61a23fdd95c7bdfa84c2fb20e3e (diff) | |
download | fluxbox_pavel-3ec18bbdc84aa17c2cbbbcfcaa599a8e021b60de.zip fluxbox_pavel-3ec18bbdc84aa17c2cbbbcfcaa599a8e021b60de.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 c789b6b..119f378 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 | Keys* keys = Fluxbox::instance()->keys(); | 461 | Keys* keys = Fluxbox::instance()->keys(); |
462 | if (keys && keys->addBinding(m_keybind)) { | 462 | if (keys && keys->addBinding(m_keybind)) { |
463 | ofstream ofile(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 c4ad5ea..717a8fc 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(); |
@@ -609,16 +614,6 @@ void Keys::unregisterWindow(Window win) { | |||
609 | m_window_map.erase(win); | 614 | m_window_map.erase(win); |
610 | } | 615 | } |
611 | 616 | ||
612 | /** | ||
613 | deletes the tree and load configuration | ||
614 | returns true on success else false | ||
615 | */ | ||
616 | void Keys::reconfigure() { | ||
617 | m_filename = FbTk::StringUtil::expandFilename(Fluxbox::instance()->getKeysFilename()); | ||
618 | m_reloader->setMainFile(m_filename); | ||
619 | m_reloader->checkReload(); | ||
620 | } | ||
621 | |||
622 | void Keys::regrab() { | 617 | void Keys::regrab() { |
623 | setKeyMode(m_keylist); | 618 | setKeyMode(m_keylist); |
624 | } | 619 | } |
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 7b46123..1dfcab8 100644 --- a/src/fluxbox.cc +++ b/src/fluxbox.cc | |||
@@ -358,7 +358,6 @@ Fluxbox::Fluxbox(int argc, char **argv, | |||
358 | // Create keybindings handler and load keys file | 358 | // Create keybindings handler and load keys file |
359 | // Note: this needs to be done before creating screens | 359 | // Note: this needs to be done before creating screens |
360 | m_key.reset(new Keys); | 360 | m_key.reset(new Keys); |
361 | m_key->reconfigure(); | ||
362 | 361 | ||
363 | vector<int> screens; | 362 | vector<int> screens; |
364 | int i; | 363 | int i; |
@@ -1202,7 +1201,6 @@ void Fluxbox::reconfigure() { | |||
1202 | 1201 | ||
1203 | void Fluxbox::real_reconfigure() { | 1202 | void Fluxbox::real_reconfigure() { |
1204 | STLUtil::forAll(m_screen_list, mem_fun(&BScreen::reconfigure)); | 1203 | STLUtil::forAll(m_screen_list, mem_fun(&BScreen::reconfigure)); |
1205 | m_key->reconfigure(); | ||
1206 | } | 1204 | } |
1207 | 1205 | ||
1208 | BScreen *Fluxbox::findScreen(int id) { | 1206 | BScreen *Fluxbox::findScreen(int id) { |
diff --git a/src/fluxbox.hh b/src/fluxbox.hh index b028363..8ce82de 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 | ||