diff options
author | rathnor <rathnor> | 2003-07-10 13:23:09 (GMT) |
---|---|---|
committer | rathnor <rathnor> | 2003-07-10 13:23:09 (GMT) |
commit | a3c69f66110df1d2c254a363dcb68c370284519b (patch) | |
tree | c0a4d3b8bb3e97bb6bb01baebf8503a2a9c1a4f8 | |
parent | c4333aeda129cb65d891808859bdc1a369d49766 (diff) | |
download | fluxbox-a3c69f66110df1d2c254a363dcb68c370284519b.zip fluxbox-a3c69f66110df1d2c254a363dcb68c370284519b.tar.bz2 |
add [startup] to remember
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | RoadMap | 2 | ||||
-rw-r--r-- | src/Remember.cc | 75 | ||||
-rw-r--r-- | src/Remember.hh | 7 |
4 files changed, 87 insertions, 4 deletions
@@ -1,6 +1,13 @@ | |||
1 | (Format: Year/Month/Day) | 1 | (Format: Year/Month/Day) |
2 | Changes for 0.9.4: | 2 | Changes for 0.9.4: |
3 | *03/07/10: | 3 | *03/07/10: |
4 | * Add [startup] to Remember (Simon) | ||
5 | Can now add entries to apps file like: | ||
6 | [startup] {xterm} | ||
7 | Then "xterm" will be launched on fluxbox startup. | ||
8 | Can also give a screen option: | ||
9 | [startup] (screen=1) {xterm} | ||
10 | will start it on screen 1 rather than the default 0. | ||
4 | * Added new shape theme items (Henrik) | 11 | * Added new shape theme items (Henrik) |
5 | * toolbar.shape: <bool> this will make the toolbar shape the corners that are towards center | 12 | * toolbar.shape: <bool> this will make the toolbar shape the corners that are towards center |
6 | of the screen | 13 | of the screen |
@@ -139,7 +139,7 @@ Key Features: | |||
139 | * Improved screen object placement (Henrik) | 139 | * Improved screen object placement (Henrik) |
140 | (will fix Maximize over slit/toolbar) | 140 | (will fix Maximize over slit/toolbar) |
141 | Other Minor Features: | 141 | Other Minor Features: |
142 | - Add some sort of program launch function (Simon) | 142 | * Add some sort of program launch function (Simon) |
143 | - nls code - layers, remember, new stuff... (Both) | 143 | - nls code - layers, remember, new stuff... (Both) |
144 | Bugfixes/lower priority: | 144 | Bugfixes/lower priority: |
145 | * Titlebar sometimes doesn't redraw properly | 145 | * Titlebar sometimes doesn't redraw properly |
diff --git a/src/Remember.cc b/src/Remember.cc index 0b4b248..883d00e 100644 --- a/src/Remember.cc +++ b/src/Remember.cc | |||
@@ -21,7 +21,7 @@ | |||
21 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | 21 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
22 | // DEALINGS IN THE SOFTWARE. | 22 | // DEALINGS IN THE SOFTWARE. |
23 | 23 | ||
24 | // $Id: Remember.cc,v 1.26 2003/07/04 14:06:20 rathnor Exp $ | 24 | // $Id: Remember.cc,v 1.27 2003/07/10 13:23:09 rathnor Exp $ |
25 | 25 | ||
26 | #include "Remember.hh" | 26 | #include "Remember.hh" |
27 | #include "ClientPattern.hh" | 27 | #include "ClientPattern.hh" |
@@ -32,6 +32,7 @@ | |||
32 | #include "FbMenu.hh" | 32 | #include "FbMenu.hh" |
33 | #include "MenuItem.hh" | 33 | #include "MenuItem.hh" |
34 | #include "App.hh" | 34 | #include "App.hh" |
35 | #include "FbCommands.hh" | ||
35 | 36 | ||
36 | #include <X11/Xlib.h> | 37 | #include <X11/Xlib.h> |
37 | 38 | ||
@@ -127,8 +128,63 @@ FbTk::Menu *createRememberMenu(Remember &remember, FluxboxWindow &win) { | |||
127 | return menu; | 128 | return menu; |
128 | }; | 129 | }; |
129 | 130 | ||
131 | // offset is the offset in the string that we start looking from | ||
132 | // return true if all ok, false on error | ||
133 | bool handleStartupItem(string line, int offset) { | ||
134 | int next = 0; | ||
135 | string str; | ||
136 | int screen = 0; | ||
137 | |||
138 | // accept some options, for now only "screen=NN" | ||
139 | // these option are given in parentheses before the command | ||
140 | next = FbTk::StringUtil::getStringBetween(str, | ||
141 | line.c_str() + offset, | ||
142 | '(', ')'); | ||
143 | if (next > 0) { | ||
144 | // there are some options | ||
145 | string option; | ||
146 | int pos = str.find('='); | ||
147 | bool error = false; | ||
148 | if (pos > 0) { | ||
149 | option = str.substr(0, pos); | ||
150 | if (option == "screen") { | ||
151 | istringstream iss(str.c_str() + pos + 1); | ||
152 | iss >> screen; | ||
153 | } else { | ||
154 | error = true; | ||
155 | } | ||
156 | } else { | ||
157 | error = true; | ||
158 | } | ||
159 | if (error) { | ||
160 | cerr<<"Error parsing startup options."<<endl; | ||
161 | return false; | ||
162 | } | ||
163 | } else { | ||
164 | next = 0; | ||
165 | } | ||
166 | |||
167 | next = FbTk::StringUtil::getStringBetween(str, | ||
168 | line.c_str() + offset + next, | ||
169 | '{', '}'); | ||
170 | |||
171 | if (next <= 0) { | ||
172 | cerr<<"Error parsing [startup] at column "<<offset<<" - expecting {command}."<<endl; | ||
173 | return false; | ||
174 | } else { | ||
175 | FbCommands::ExecuteCmd *tmp_exec_cmd = new FbCommands::ExecuteCmd(str, screen); | ||
176 | #ifdef DEBUG | ||
177 | cerr<<"Executing startup command '"<<str<<"' on screen "<<screen<<endl; | ||
178 | #endif // DEBUG | ||
179 | tmp_exec_cmd->execute(); | ||
180 | delete tmp_exec_cmd; | ||
181 | return true; | ||
182 | } | ||
183 | }; | ||
184 | |||
130 | }; // end anonymous namespace | 185 | }; // end anonymous namespace |
131 | 186 | ||
187 | |||
132 | Application::Application(bool grouped) | 188 | Application::Application(bool grouped) |
133 | : is_grouped(grouped), | 189 | : is_grouped(grouped), |
134 | group(0) | 190 | group(0) |
@@ -350,6 +406,12 @@ void Remember::load() { | |||
350 | } else { | 406 | } else { |
351 | grouped_pats.push_back(pat); | 407 | grouped_pats.push_back(pat); |
352 | } | 408 | } |
409 | } else if (pos > 0 && key == "startup") { | ||
410 | if (!handleStartupItem(line, pos)) { | ||
411 | cerr<<"Error reading apps file at line "<<row<<"."<<endl; | ||
412 | } | ||
413 | // save the item even if it was bad (aren't we nice) | ||
414 | m_startups.push_back(line.substr(pos)); | ||
353 | } else if (pos > 0 && key == "group") { | 415 | } else if (pos > 0 && key == "group") { |
354 | in_group = true; | 416 | in_group = true; |
355 | } else if (in_group) { | 417 | } else if (in_group) { |
@@ -389,6 +451,14 @@ void Remember::save() { | |||
389 | string apps_string; | 451 | string apps_string; |
390 | Fluxbox::instance()->getDefaultDataFilename("apps", apps_string); | 452 | Fluxbox::instance()->getDefaultDataFilename("apps", apps_string); |
391 | ofstream apps_file(apps_string.c_str()); | 453 | ofstream apps_file(apps_string.c_str()); |
454 | |||
455 | // first of all we output all the startup commands | ||
456 | Startups::iterator sit = m_startups.begin(); | ||
457 | Startups::iterator sit_end = m_startups.end(); | ||
458 | for (; sit != sit_end; ++sit) { | ||
459 | apps_file<<"[startup] "<<(*sit)<<endl; | ||
460 | } | ||
461 | |||
392 | Patterns::iterator it = m_pats.begin(); | 462 | Patterns::iterator it = m_pats.begin(); |
393 | Patterns::iterator it_end = m_pats.end(); | 463 | Patterns::iterator it_end = m_pats.end(); |
394 | 464 | ||
@@ -400,12 +470,13 @@ void Remember::save() { | |||
400 | // if already processed | 470 | // if already processed |
401 | if (grouped_apps.find(&a) != grouped_apps.end()) | 471 | if (grouped_apps.find(&a) != grouped_apps.end()) |
402 | continue; | 472 | continue; |
473 | grouped_apps.insert(&a); | ||
403 | // otherwise output this whole group | 474 | // otherwise output this whole group |
404 | apps_file << "[group]" << endl; | 475 | apps_file << "[group]" << endl; |
405 | Patterns::iterator git = m_pats.begin(); | 476 | Patterns::iterator git = m_pats.begin(); |
406 | Patterns::iterator git_end = m_pats.end(); | 477 | Patterns::iterator git_end = m_pats.end(); |
407 | for (; git != git_end; git++) { | 478 | for (; git != git_end; git++) { |
408 | if (git->second->group == a.group) { | 479 | if (git->second == &a) { |
409 | apps_file << " [app]"<<git->first->toString()<<endl; | 480 | apps_file << " [app]"<<git->first->toString()<<endl; |
410 | } | 481 | } |
411 | } | 482 | } |
diff --git a/src/Remember.hh b/src/Remember.hh index c687137..4520c23 100644 --- a/src/Remember.hh +++ b/src/Remember.hh | |||
@@ -21,7 +21,7 @@ | |||
21 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | 21 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
22 | // DEALINGS IN THE SOFTWARE. | 22 | // DEALINGS IN THE SOFTWARE. |
23 | 23 | ||
24 | // $Id: Remember.hh,v 1.10 2003/07/04 14:06:20 rathnor Exp $ | 24 | // $Id: Remember.hh,v 1.11 2003/07/10 13:23:09 rathnor Exp $ |
25 | 25 | ||
26 | /* Based on the original "Remember patch" by Xavier Brouckaert */ | 26 | /* Based on the original "Remember patch" by Xavier Brouckaert */ |
27 | 27 | ||
@@ -148,6 +148,9 @@ public: | |||
148 | // particularly useful to update counters etc on windowclose | 148 | // particularly useful to update counters etc on windowclose |
149 | typedef std::map<WinClient *, Application *> Clients; | 149 | typedef std::map<WinClient *, Application *> Clients; |
150 | 150 | ||
151 | // we have to remember any startups we did so that they are saved again | ||
152 | typedef std::list<std::string> Startups; | ||
153 | |||
151 | Remember(); | 154 | Remember(); |
152 | ~Remember(); | 155 | ~Remember(); |
153 | 156 | ||
@@ -196,6 +199,8 @@ private: | |||
196 | Patterns m_pats; | 199 | Patterns m_pats; |
197 | Clients m_clients; | 200 | Clients m_clients; |
198 | 201 | ||
202 | Startups m_startups; | ||
203 | |||
199 | }; | 204 | }; |
200 | 205 | ||
201 | #endif // REMEMBER_HH | 206 | #endif // REMEMBER_HH |