diff options
author | fluxgen <fluxgen> | 2003-04-26 12:46:18 (GMT) |
---|---|---|
committer | fluxgen <fluxgen> | 2003-04-26 12:46:18 (GMT) |
commit | d44da76ad45ad9c259c7075ea85b98b55ca18e1a (patch) | |
tree | 19777c1d9b0c0b260b07950cda15708e13b57fab /src/Remember.cc | |
parent | 0c2888202505bfcdf631d870f607aafb9ccc5bec (diff) | |
download | fluxbox_pavel-d44da76ad45ad9c259c7075ea85b98b55ca18e1a.zip fluxbox_pavel-d44da76ad45ad9c259c7075ea85b98b55ca18e1a.tar.bz2 |
indentation and minor fixes
Diffstat (limited to 'src/Remember.cc')
-rw-r--r-- | src/Remember.cc | 137 |
1 files changed, 72 insertions, 65 deletions
diff --git a/src/Remember.cc b/src/Remember.cc index 81de0b3..3ec7d46 100644 --- a/src/Remember.cc +++ b/src/Remember.cc | |||
@@ -20,35 +20,41 @@ | |||
20 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | 20 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
21 | // DEALINGS IN THE SOFTWARE. | 21 | // DEALINGS IN THE SOFTWARE. |
22 | 22 | ||
23 | // $Id: Remember.cc,v 1.3 2003/04/26 12:01:55 rathnor Exp $ | 23 | // $Id: Remember.cc,v 1.4 2003/04/26 12:46:18 fluxgen Exp $ |
24 | 24 | ||
25 | #include "Remember.hh" | 25 | #include "Remember.hh" |
26 | #include "StringUtil.hh" | 26 | #include "StringUtil.hh" |
27 | #include "Screen.hh" | ||
28 | #include "Window.hh" | ||
27 | #include "WinClient.hh" | 29 | #include "WinClient.hh" |
28 | #include "FbMenu.hh" | 30 | #include "FbMenu.hh" |
29 | #include "MenuItem.hh" | 31 | #include "MenuItem.hh" |
32 | #include "App.hh" | ||
30 | 33 | ||
31 | // TODO get rid of these | 34 | // TODO get rid of these |
32 | #define RC_PATH "fluxbox" | 35 | #define RC_PATH "fluxbox" |
33 | #define RC_INIT_FILE "init" | 36 | #define RC_INIT_FILE "init" |
34 | 37 | ||
38 | #include <X11/Xlib.h> | ||
39 | |||
35 | //use GNU extensions | 40 | //use GNU extensions |
36 | #ifndef _GNU_SOURCE | 41 | #ifndef _GNU_SOURCE |
37 | #define _GNU_SOURCE | 42 | #define _GNU_SOURCE |
38 | #endif // _GNU_SOURCE | 43 | #endif // _GNU_SOURCE |
39 | 44 | ||
45 | |||
40 | #include <iostream> | 46 | #include <iostream> |
41 | #include <sstream> | 47 | #include <sstream> |
42 | #include <fstream> | 48 | #include <fstream> |
43 | #include <string> | 49 | #include <string> |
44 | #include <memory> | 50 | #include <memory> |
45 | 51 | ||
52 | using namespace std; | ||
53 | |||
46 | #ifndef MAXPATHLEN | 54 | #ifndef MAXPATHLEN |
47 | #define MAXPATHLEN 255 | 55 | #define MAXPATHLEN 255 |
48 | #endif // MAXPATHLEN | 56 | #endif // MAXPATHLEN |
49 | 57 | ||
50 | using namespace std; | ||
51 | |||
52 | namespace { | 58 | namespace { |
53 | 59 | ||
54 | class RememberMenuItem : public FbTk::MenuItem { | 60 | class RememberMenuItem : public FbTk::MenuItem { |
@@ -98,58 +104,28 @@ FbTk::Menu *createRememberMenu(Remember &remember, FluxboxWindow &win) { | |||
98 | 104 | ||
99 | // TODO: nls | 105 | // TODO: nls |
100 | menu->insert(new RememberMenuItem("Workspace", remember, win, | 106 | menu->insert(new RememberMenuItem("Workspace", remember, win, |
101 | Remember::REM_WORKSPACE)); | 107 | Remember::REM_WORKSPACE)); |
102 | menu->insert(new RememberMenuItem("Jump to workspace", remember, win, | 108 | menu->insert(new RememberMenuItem("Jump to workspace", remember, win, |
103 | Remember::REM_JUMPWORKSPACE)); | 109 | Remember::REM_JUMPWORKSPACE)); |
104 | menu->insert(new RememberMenuItem("Dimensions", remember, win, | 110 | menu->insert(new RememberMenuItem("Dimensions", remember, win, |
105 | Remember::REM_DIMENSIONS)); | 111 | Remember::REM_DIMENSIONS)); |
106 | menu->insert(new RememberMenuItem("Position", remember, win, | 112 | menu->insert(new RememberMenuItem("Position", remember, win, |
107 | Remember::REM_POSITION)); | 113 | Remember::REM_POSITION)); |
108 | menu->insert(new RememberMenuItem("Sticky", remember, win, | 114 | menu->insert(new RememberMenuItem("Sticky", remember, win, |
109 | Remember::REM_STUCKSTATE)); | 115 | Remember::REM_STUCKSTATE)); |
110 | menu->insert(new RememberMenuItem("Decorations", remember, win, | 116 | menu->insert(new RememberMenuItem("Decorations", remember, win, |
111 | Remember::REM_DECOSTATE)); | 117 | Remember::REM_DECOSTATE)); |
112 | menu->insert(new RememberMenuItem("Shaded", remember, win, | 118 | menu->insert(new RememberMenuItem("Shaded", remember, win, |
113 | Remember::REM_SHADEDSTATE)); | 119 | Remember::REM_SHADEDSTATE)); |
114 | // menu->insert(new RememberMenuItem("Tab", remember, win, | 120 | // menu->insert(new RememberMenuItem("Tab", remember, win, |
115 | // Remember::REM_TABSTATE)); | 121 | // Remember::REM_TABSTATE)); |
116 | menu->insert(new RememberMenuItem("Save on close", remember, win, | 122 | menu->insert(new RememberMenuItem("Save on close", remember, win, |
117 | Remember::REM_SAVEONCLOSE)); | 123 | Remember::REM_SAVEONCLOSE)); |
118 | 124 | ||
119 | menu->update(); | 125 | menu->update(); |
120 | return menu; | 126 | return menu; |
121 | }; | 127 | }; |
122 | 128 | ||
123 | }; | ||
124 | |||
125 | Application::Application() { | ||
126 | workspace_remember = | ||
127 | dimensions_remember = | ||
128 | position_remember = | ||
129 | stuckstate_remember = | ||
130 | decostate_remember = | ||
131 | shadedstate_remember = | ||
132 | tabstate_remember = | ||
133 | jumpworkspace_remember = | ||
134 | save_on_close_remember = false; | ||
135 | } | ||
136 | |||
137 | Remember::Remember() { | ||
138 | load(); | ||
139 | } | ||
140 | |||
141 | Application* Remember::add(const char* app_name) { | ||
142 | if (!app_name) | ||
143 | return NULL; | ||
144 | Application* a = new Application(); | ||
145 | apps[app_name] = a; | ||
146 | return a; | ||
147 | } | ||
148 | |||
149 | // FIXME, I am evil | ||
150 | #include "X11/Xlib.h" | ||
151 | #include "App.hh" | ||
152 | |||
153 | const char * getWMClass(Window w) { | 129 | const char * getWMClass(Window w) { |
154 | XClassHint ch; | 130 | XClassHint ch; |
155 | 131 | ||
@@ -174,24 +150,49 @@ const char * getWMClass(Window w) { | |||
174 | } | 150 | } |
175 | } | 151 | } |
176 | 152 | ||
153 | }; | ||
154 | |||
155 | Application::Application() { | ||
156 | workspace_remember = | ||
157 | dimensions_remember = | ||
158 | position_remember = | ||
159 | stuckstate_remember = | ||
160 | decostate_remember = | ||
161 | shadedstate_remember = | ||
162 | tabstate_remember = | ||
163 | jumpworkspace_remember = | ||
164 | save_on_close_remember = false; | ||
165 | } | ||
166 | |||
167 | Remember::Remember() { | ||
168 | load(); | ||
169 | } | ||
170 | |||
171 | Application* Remember::add(const char* app_name) { | ||
172 | if (!app_name) | ||
173 | return 0; | ||
174 | Application* a = new Application(); | ||
175 | apps[app_name] = a; | ||
176 | return a; | ||
177 | } | ||
177 | 178 | ||
178 | Application* Remember::find(WinClient &winclient) { | 179 | Application* Remember::find(WinClient &winclient) { |
179 | return find(getWMClass(winclient.fbwindow()->getClientWindow())); //FIXME | 180 | return find(getWMClass(winclient.window())); |
180 | } | 181 | } |
181 | 182 | ||
182 | Application* Remember::add(WinClient &winclient) { | 183 | Application* Remember::add(WinClient &winclient) { |
183 | return add(getWMClass(winclient.fbwindow()->getClientWindow())); //FIXME | 184 | return add(getWMClass(winclient.window)); |
184 | } | 185 | } |
185 | 186 | ||
186 | 187 | ||
187 | Application* Remember::find(const char* app_name) { | 188 | Application* Remember::find(const char* app_name) { |
188 | if (!app_name) | 189 | if (!app_name) |
189 | return NULL; | 190 | return 0; |
190 | Apps::iterator i = apps.find(app_name); | 191 | Apps::iterator i = apps.find(app_name); |
191 | if (i!=apps.end()) | 192 | if (i!=apps.end()) |
192 | return i->second; | 193 | return i->second; |
193 | else | 194 | else |
194 | return NULL; | 195 | return 0; |
195 | } | 196 | } |
196 | 197 | ||
197 | int Remember::parseApp(ifstream &file, Application *a) { | 198 | int Remember::parseApp(ifstream &file, Application *a) { |
@@ -206,7 +207,9 @@ int Remember::parseApp(ifstream &file, Application *a) { | |||
206 | err = StringUtil::getStringBetween(str_key, line.c_str(), '[', ']'); | 207 | err = StringUtil::getStringBetween(str_key, line.c_str(), '[', ']'); |
207 | if (err > 0 ) { | 208 | if (err > 0 ) { |
208 | parse_pos += err; | 209 | parse_pos += err; |
209 | err = StringUtil::getStringBetween(str_label, line.c_str() + parse_pos, '{', '}'); | 210 | err = StringUtil::getStringBetween(str_label, |
211 | line.c_str() + parse_pos, | ||
212 | '{', '}'); | ||
210 | if (err>0) { | 213 | if (err>0) { |
211 | parse_pos += err; | 214 | parse_pos += err; |
212 | } | 215 | } |
@@ -240,15 +243,15 @@ int Remember::parseApp(ifstream &file, Application *a) { | |||
240 | a->rememberDecostate((unsigned int) 0xfffffff); | 243 | a->rememberDecostate((unsigned int) 0xfffffff); |
241 | } else if (str_label == "TINY") { | 244 | } else if (str_label == "TINY") { |
242 | a->rememberDecostate((unsigned int) | 245 | a->rememberDecostate((unsigned int) |
243 | FluxboxWindow::DECORM_TITLEBAR | 246 | FluxboxWindow::DECORM_TITLEBAR |
244 | | FluxboxWindow::DECORM_ICONIFY | 247 | | FluxboxWindow::DECORM_ICONIFY |
245 | | FluxboxWindow::DECORM_MENU | 248 | | FluxboxWindow::DECORM_MENU |
246 | ); | 249 | ); |
247 | } else if (str_label == "TOOL") { | 250 | } else if (str_label == "TOOL") { |
248 | a->rememberDecostate((unsigned int) | 251 | a->rememberDecostate((unsigned int) |
249 | FluxboxWindow::DECORM_TITLEBAR | 252 | FluxboxWindow::DECORM_TITLEBAR |
250 | | FluxboxWindow::DECORM_MENU | 253 | | FluxboxWindow::DECORM_MENU |
251 | ); | 254 | ); |
252 | } else { | 255 | } else { |
253 | unsigned int mask; | 256 | unsigned int mask; |
254 | const char * str = str_label.c_str(); | 257 | const char * str = str_label.c_str(); |
@@ -280,11 +283,13 @@ int Remember::parseApp(ifstream &file, Application *a) { | |||
280 | } | 283 | } |
281 | 284 | ||
282 | void Remember::load() { | 285 | void Remember::load() { |
286 | |||
287 | string apps_string = getenv("HOME")+string("/.")+RC_PATH+string("/")+"apps"; | ||
283 | #ifdef DEBUG | 288 | #ifdef DEBUG |
284 | cerr << "Loading apps file..." << endl; | 289 | cerr<<__FILE__<<"("<<__FUNCTION__<<"): Loading apps file ["<<apps_string<<"]"<<endl; |
285 | #endif // DEBUG | 290 | #endif // DEBUG |
286 | string apps_string = getenv("HOME")+string("/.")+RC_PATH+string("/")+"apps"; | ||
287 | ifstream apps_file(apps_string.c_str()); | 291 | ifstream apps_file(apps_string.c_str()); |
292 | |||
288 | if (!apps_file.fail()) { | 293 | if (!apps_file.fail()) { |
289 | if (!apps_file.eof()) { | 294 | if (!apps_file.eof()) { |
290 | string line; | 295 | string line; |
@@ -318,7 +323,7 @@ void Remember::load() { | |||
318 | } | 323 | } |
319 | } else { | 324 | } else { |
320 | #ifdef DEBUG | 325 | #ifdef DEBUG |
321 | cerr<<__FILE__<<"("<<__LINE__<< ") Empty apps file" << endl; | 326 | cerr<<__FILE__<<"("<<__FUNCTION__<< ") Empty apps file" << endl; |
322 | #endif | 327 | #endif |
323 | } | 328 | } |
324 | } else { | 329 | } else { |
@@ -328,7 +333,7 @@ void Remember::load() { | |||
328 | 333 | ||
329 | void Remember::save() { | 334 | void Remember::save() { |
330 | #ifdef DEBUG | 335 | #ifdef DEBUG |
331 | cerr << "Saving apps file..." << endl; | 336 | cerr<<__FILE__<<"("<<__FUNCTION__<<"): Saving apps file..."<<endl; |
332 | #endif // DEBUG | 337 | #endif // DEBUG |
333 | string apps_string = getenv("HOME")+string("/.")+RC_PATH+string("/")+"apps"; | 338 | string apps_string = getenv("HOME")+string("/.")+RC_PATH+string("/")+"apps"; |
334 | ofstream apps_file(apps_string.c_str()); | 339 | ofstream apps_file(apps_string.c_str()); |
@@ -410,9 +415,9 @@ bool Remember::isRemembered(WinClient &winclient, Attribute attrib) { | |||
410 | case REM_SHADEDSTATE: | 415 | case REM_SHADEDSTATE: |
411 | return app->shadedstate_remember; | 416 | return app->shadedstate_remember; |
412 | break; | 417 | break; |
413 | // case REM_TABSTATE: | 418 | // case REM_TABSTATE: |
414 | // return app->tabstate_remember; | 419 | // return app->tabstate_remember; |
415 | // break; | 420 | // break; |
416 | case REM_JUMPWORKSPACE: | 421 | case REM_JUMPWORKSPACE: |
417 | return app->jumpworkspace_remember; | 422 | return app->jumpworkspace_remember; |
418 | break; | 423 | break; |
@@ -452,8 +457,8 @@ void Remember::rememberAttrib(WinClient &winclient, Attribute attrib) { | |||
452 | case REM_SHADEDSTATE: | 457 | case REM_SHADEDSTATE: |
453 | app->rememberStuckstate(win->isStuck()); | 458 | app->rememberStuckstate(win->isStuck()); |
454 | break; | 459 | break; |
455 | // case REM_TABSTATE: | 460 | // case REM_TABSTATE: |
456 | // break; | 461 | // break; |
457 | case REM_JUMPWORKSPACE: | 462 | case REM_JUMPWORKSPACE: |
458 | app->rememberJumpworkspace(true); | 463 | app->rememberJumpworkspace(true); |
459 | break; | 464 | break; |
@@ -555,7 +560,9 @@ void Remember::setupWindow(FluxboxWindow &win) { | |||
555 | 560 | ||
556 | // add the menu, this -2 is somewhat dodgy... :-/ | 561 | // add the menu, this -2 is somewhat dodgy... :-/ |
557 | // TODO: nls | 562 | // TODO: nls |
558 | win.getWindowmenu().insert("Remember...", createRememberMenu(*this, win), win.getWindowmenu().numberOfItems()-2); | 563 | win.getWindowmenu().insert("Remember...", |
564 | createRememberMenu(*this, win), | ||
565 | win.getWindowmenu().numberOfItems()-2); | ||
559 | win.getWindowmenu().update(); | 566 | win.getWindowmenu().update(); |
560 | } | 567 | } |
561 | 568 | ||