diff options
author | Mark Tiefenbruck <mark@fluxbox.org> | 2008-01-11 07:41:22 (GMT) |
---|---|---|
committer | Mark Tiefenbruck <mark@fluxbox.org> | 2008-01-11 07:41:22 (GMT) |
commit | 9f2f65a698c4cc71373a7fe9d73a0889e0d3487b (patch) | |
tree | 4ad67db771d73ea3c48f80a1244037fc9754edd2 /src/FbCommands.cc | |
parent | 1f01d84c080d607a91eb417efcaf5e500b5f1d7e (diff) | |
download | fluxbox_pavel-9f2f65a698c4cc71373a7fe9d73a0889e0d3487b.zip fluxbox_pavel-9f2f65a698c4cc71373a7fe9d73a0889e0d3487b.tar.bz2 |
make FbTk::Command a template class, split parsing information out of ObjectRegistry
Diffstat (limited to 'src/FbCommands.cc')
-rw-r--r-- | src/FbCommands.cc | 60 |
1 files changed, 30 insertions, 30 deletions
diff --git a/src/FbCommands.cc b/src/FbCommands.cc index 1569704..5e7f6dc 100644 --- a/src/FbCommands.cc +++ b/src/FbCommands.cc | |||
@@ -31,7 +31,7 @@ | |||
31 | 31 | ||
32 | #include "FbTk/Theme.hh" | 32 | #include "FbTk/Theme.hh" |
33 | #include "FbTk/Menu.hh" | 33 | #include "FbTk/Menu.hh" |
34 | #include "FbTk/ObjectRegistry.hh" | 34 | #include "FbTk/CommandParser.hh" |
35 | #include "FbTk/StringUtil.hh" | 35 | #include "FbTk/StringUtil.hh" |
36 | #include "FbTk/stringstream.hh" | 36 | #include "FbTk/stringstream.hh" |
37 | 37 | ||
@@ -123,9 +123,9 @@ namespace FbCommands { | |||
123 | 123 | ||
124 | using FbTk::Command; | 124 | using FbTk::Command; |
125 | 125 | ||
126 | REGISTER_UNTRUSTED_OBJECT_WITH_ARGS(exec, FbCommands::ExecuteCmd, Command); | 126 | REGISTER_UNTRUSTED_COMMAND_WITH_ARGS(exec, FbCommands::ExecuteCmd, void); |
127 | REGISTER_UNTRUSTED_OBJECT_WITH_ARGS(execute, FbCommands::ExecuteCmd, Command); | 127 | REGISTER_UNTRUSTED_COMMAND_WITH_ARGS(execute, FbCommands::ExecuteCmd, void); |
128 | REGISTER_UNTRUSTED_OBJECT_WITH_ARGS(execcommand, FbCommands::ExecuteCmd, Command); | 128 | REGISTER_UNTRUSTED_COMMAND_WITH_ARGS(execcommand, FbCommands::ExecuteCmd, void); |
129 | 129 | ||
130 | ExecuteCmd::ExecuteCmd(const string &cmd, int screen_num):m_cmd(cmd), m_screen_num(screen_num) { | 130 | ExecuteCmd::ExecuteCmd(const string &cmd, int screen_num):m_cmd(cmd), m_screen_num(screen_num) { |
131 | 131 | ||
@@ -176,7 +176,7 @@ int ExecuteCmd::run() { | |||
176 | return pid; // compiler happy -> we are happy ;) | 176 | return pid; // compiler happy -> we are happy ;) |
177 | } | 177 | } |
178 | 178 | ||
179 | FbTk::Command *ExportCmd::parse(const string &command, const string &args, | 179 | FbTk::Command<void> *ExportCmd::parse(const string &command, const string &args, |
180 | bool trusted) { | 180 | bool trusted) { |
181 | string name = args; | 181 | string name = args; |
182 | FbTk::StringUtil::removeFirstWhitespace(name); | 182 | FbTk::StringUtil::removeFirstWhitespace(name); |
@@ -193,9 +193,9 @@ FbTk::Command *ExportCmd::parse(const string &command, const string &args, | |||
193 | return new ExportCmd(name, value); | 193 | return new ExportCmd(name, value); |
194 | } | 194 | } |
195 | 195 | ||
196 | REGISTER_OBJECT_PARSER(setenv, ExportCmd::parse, Command); | 196 | REGISTER_COMMAND_PARSER(setenv, ExportCmd::parse, void); |
197 | REGISTER_OBJECT_PARSER(export, ExportCmd::parse, Command); | 197 | REGISTER_COMMAND_PARSER(export, ExportCmd::parse, void); |
198 | REGISTER_OBJECT_PARSER(setresourcevalue, ExportCmd::parse, Command); | 198 | REGISTER_COMMAND_PARSER(setresourcevalue, ExportCmd::parse, void); |
199 | 199 | ||
200 | ExportCmd::ExportCmd(const string& name, const string& value) : | 200 | ExportCmd::ExportCmd(const string& name, const string& value) : |
201 | m_name(name), m_value(value) { | 201 | m_name(name), m_value(value) { |
@@ -233,20 +233,20 @@ void ExportCmd::execute() { | |||
233 | } | 233 | } |
234 | } | 234 | } |
235 | 235 | ||
236 | REGISTER_OBJECT(exit, FbCommands::ExitFluxboxCmd, Command); | 236 | REGISTER_COMMAND(exit, FbCommands::ExitFluxboxCmd, void); |
237 | REGISTER_OBJECT(quit, FbCommands::ExitFluxboxCmd, Command); | 237 | REGISTER_COMMAND(quit, FbCommands::ExitFluxboxCmd, void); |
238 | 238 | ||
239 | void ExitFluxboxCmd::execute() { | 239 | void ExitFluxboxCmd::execute() { |
240 | Fluxbox::instance()->shutdown(); | 240 | Fluxbox::instance()->shutdown(); |
241 | } | 241 | } |
242 | 242 | ||
243 | REGISTER_OBJECT(saverc, FbCommands::SaveResources, Command); | 243 | REGISTER_COMMAND(saverc, FbCommands::SaveResources, void); |
244 | 244 | ||
245 | void SaveResources::execute() { | 245 | void SaveResources::execute() { |
246 | Fluxbox::instance()->save_rc(); | 246 | Fluxbox::instance()->save_rc(); |
247 | } | 247 | } |
248 | 248 | ||
249 | REGISTER_UNTRUSTED_OBJECT_WITH_ARGS(restart, FbCommands::RestartFluxboxCmd, Command); | 249 | REGISTER_UNTRUSTED_COMMAND_WITH_ARGS(restart, FbCommands::RestartFluxboxCmd, void); |
250 | 250 | ||
251 | RestartFluxboxCmd::RestartFluxboxCmd(const string &cmd):m_cmd(cmd){ | 251 | RestartFluxboxCmd::RestartFluxboxCmd(const string &cmd):m_cmd(cmd){ |
252 | } | 252 | } |
@@ -258,21 +258,21 @@ void RestartFluxboxCmd::execute() { | |||
258 | Fluxbox::instance()->restart(m_cmd.c_str()); | 258 | Fluxbox::instance()->restart(m_cmd.c_str()); |
259 | } | 259 | } |
260 | 260 | ||
261 | REGISTER_OBJECT(reconfigure, FbCommands::ReconfigureFluxboxCmd, Command); | 261 | REGISTER_COMMAND(reconfigure, FbCommands::ReconfigureFluxboxCmd, void); |
262 | REGISTER_OBJECT(reconfig, FbCommands::ReconfigureFluxboxCmd, Command); | 262 | REGISTER_COMMAND(reconfig, FbCommands::ReconfigureFluxboxCmd, void); |
263 | 263 | ||
264 | void ReconfigureFluxboxCmd::execute() { | 264 | void ReconfigureFluxboxCmd::execute() { |
265 | Fluxbox::instance()->reconfigure(); | 265 | Fluxbox::instance()->reconfigure(); |
266 | } | 266 | } |
267 | 267 | ||
268 | REGISTER_OBJECT(reloadstyle, FbCommands::ReloadStyleCmd, Command); | 268 | REGISTER_COMMAND(reloadstyle, FbCommands::ReloadStyleCmd, void); |
269 | 269 | ||
270 | void ReloadStyleCmd::execute() { | 270 | void ReloadStyleCmd::execute() { |
271 | SetStyleCmd cmd(Fluxbox::instance()->getStyleFilename()); | 271 | SetStyleCmd cmd(Fluxbox::instance()->getStyleFilename()); |
272 | cmd.execute(); | 272 | cmd.execute(); |
273 | } | 273 | } |
274 | 274 | ||
275 | REGISTER_OBJECT_WITH_ARGS(setstyle, FbCommands::SetStyleCmd, Command); | 275 | REGISTER_COMMAND_WITH_ARGS(setstyle, FbCommands::SetStyleCmd, void); |
276 | 276 | ||
277 | SetStyleCmd::SetStyleCmd(const string &filename):m_filename(filename) { | 277 | SetStyleCmd::SetStyleCmd(const string &filename):m_filename(filename) { |
278 | 278 | ||
@@ -285,7 +285,7 @@ void SetStyleCmd::execute() { | |||
285 | Fluxbox::instance()->getStyleOverlayFilename()); | 285 | Fluxbox::instance()->getStyleOverlayFilename()); |
286 | } | 286 | } |
287 | 287 | ||
288 | REGISTER_OBJECT_WITH_ARGS(keymode, FbCommands::KeyModeCmd, Command); | 288 | REGISTER_COMMAND_WITH_ARGS(keymode, FbCommands::KeyModeCmd, void); |
289 | 289 | ||
290 | KeyModeCmd::KeyModeCmd(const string &arguments):m_keymode(arguments),m_end_args("None Escape") { | 290 | KeyModeCmd::KeyModeCmd(const string &arguments):m_keymode(arguments),m_end_args("None Escape") { |
291 | string::size_type second_pos = m_keymode.find_first_of(" \t", 0); | 291 | string::size_type second_pos = m_keymode.find_first_of(" \t", 0); |
@@ -302,13 +302,13 @@ void KeyModeCmd::execute() { | |||
302 | Fluxbox::instance()->keys()->keyMode(m_keymode); | 302 | Fluxbox::instance()->keys()->keyMode(m_keymode); |
303 | } | 303 | } |
304 | 304 | ||
305 | REGISTER_OBJECT(hidemenus, FbCommands::HideMenuCmd, Command); | 305 | REGISTER_COMMAND(hidemenus, FbCommands::HideMenuCmd, void); |
306 | 306 | ||
307 | void HideMenuCmd::execute() { | 307 | void HideMenuCmd::execute() { |
308 | FbTk::Menu::hideShownMenu(); | 308 | FbTk::Menu::hideShownMenu(); |
309 | } | 309 | } |
310 | 310 | ||
311 | FbTk::Command *ShowClientMenuCmd::parse(const string &command, | 311 | FbTk::Command<void> *ShowClientMenuCmd::parse(const string &command, |
312 | const string &args, bool trusted) { | 312 | const string &args, bool trusted) { |
313 | int opts; | 313 | int opts; |
314 | string pat; | 314 | string pat; |
@@ -316,7 +316,7 @@ FbTk::Command *ShowClientMenuCmd::parse(const string &command, | |||
316 | return new ShowClientMenuCmd(opts, pat); | 316 | return new ShowClientMenuCmd(opts, pat); |
317 | } | 317 | } |
318 | 318 | ||
319 | REGISTER_OBJECT_PARSER(clientmenu, ShowClientMenuCmd::parse, Command); | 319 | REGISTER_COMMAND_PARSER(clientmenu, ShowClientMenuCmd::parse, void); |
320 | 320 | ||
321 | void ShowClientMenuCmd::execute() { | 321 | void ShowClientMenuCmd::execute() { |
322 | BScreen *screen = Fluxbox::instance()->mouseScreen(); | 322 | BScreen *screen = Fluxbox::instance()->mouseScreen(); |
@@ -339,7 +339,7 @@ void ShowClientMenuCmd::execute() { | |||
339 | ::showMenu(*screen, **m_menu); | 339 | ::showMenu(*screen, **m_menu); |
340 | } | 340 | } |
341 | 341 | ||
342 | REGISTER_OBJECT_WITH_ARGS(custommenu, FbCommands::ShowCustomMenuCmd, Command); | 342 | REGISTER_COMMAND_WITH_ARGS(custommenu, FbCommands::ShowCustomMenuCmd, void); |
343 | 343 | ||
344 | ShowCustomMenuCmd::ShowCustomMenuCmd(const string &arguments) : custom_menu_file(arguments) {} | 344 | ShowCustomMenuCmd::ShowCustomMenuCmd(const string &arguments) : custom_menu_file(arguments) {} |
345 | 345 | ||
@@ -354,7 +354,7 @@ void ShowCustomMenuCmd::execute() { | |||
354 | ::showMenu(*screen, **m_menu); | 354 | ::showMenu(*screen, **m_menu); |
355 | } | 355 | } |
356 | 356 | ||
357 | REGISTER_OBJECT(rootmenu, FbCommands::ShowRootMenuCmd, Command); | 357 | REGISTER_COMMAND(rootmenu, FbCommands::ShowRootMenuCmd, void); |
358 | 358 | ||
359 | void ShowRootMenuCmd::execute() { | 359 | void ShowRootMenuCmd::execute() { |
360 | BScreen *screen = Fluxbox::instance()->mouseScreen(); | 360 | BScreen *screen = Fluxbox::instance()->mouseScreen(); |
@@ -364,7 +364,7 @@ void ShowRootMenuCmd::execute() { | |||
364 | ::showMenu(*screen, screen->rootMenu()); | 364 | ::showMenu(*screen, screen->rootMenu()); |
365 | } | 365 | } |
366 | 366 | ||
367 | REGISTER_OBJECT(workspacemenu, FbCommands::ShowWorkspaceMenuCmd, Command); | 367 | REGISTER_COMMAND(workspacemenu, FbCommands::ShowWorkspaceMenuCmd, void); |
368 | 368 | ||
369 | void ShowWorkspaceMenuCmd::execute() { | 369 | void ShowWorkspaceMenuCmd::execute() { |
370 | BScreen *screen = Fluxbox::instance()->mouseScreen(); | 370 | BScreen *screen = Fluxbox::instance()->mouseScreen(); |
@@ -374,7 +374,7 @@ void ShowWorkspaceMenuCmd::execute() { | |||
374 | ::showMenu(*screen, screen->workspaceMenu()); | 374 | ::showMenu(*screen, screen->workspaceMenu()); |
375 | } | 375 | } |
376 | 376 | ||
377 | REGISTER_OBJECT_WITH_ARGS(setworkspacename, FbCommands::SetWorkspaceNameCmd, Command); | 377 | REGISTER_COMMAND_WITH_ARGS(setworkspacename, FbCommands::SetWorkspaceNameCmd, void); |
378 | 378 | ||
379 | SetWorkspaceNameCmd::SetWorkspaceNameCmd(const string &name, int spaceid): | 379 | SetWorkspaceNameCmd::SetWorkspaceNameCmd(const string &name, int spaceid): |
380 | m_name(name), m_workspace(spaceid) { | 380 | m_name(name), m_workspace(spaceid) { |
@@ -403,7 +403,7 @@ void SetWorkspaceNameCmd::execute() { | |||
403 | Fluxbox::instance()->save_rc(); | 403 | Fluxbox::instance()->save_rc(); |
404 | } | 404 | } |
405 | 405 | ||
406 | REGISTER_OBJECT(setworkspacenamedialog, FbCommands::WorkspaceNameDialogCmd, Command); | 406 | REGISTER_COMMAND(setworkspacenamedialog, FbCommands::WorkspaceNameDialogCmd, void); |
407 | 407 | ||
408 | void WorkspaceNameDialogCmd::execute() { | 408 | void WorkspaceNameDialogCmd::execute() { |
409 | 409 | ||
@@ -416,7 +416,7 @@ void WorkspaceNameDialogCmd::execute() { | |||
416 | win->show(); | 416 | win->show(); |
417 | } | 417 | } |
418 | 418 | ||
419 | REGISTER_OBJECT(commanddialog, FbCommands::CommandDialogCmd, Command); | 419 | REGISTER_COMMAND(commanddialog, FbCommands::CommandDialogCmd, void); |
420 | 420 | ||
421 | void CommandDialogCmd::execute() { | 421 | void CommandDialogCmd::execute() { |
422 | BScreen *screen = Fluxbox::instance()->mouseScreen(); | 422 | BScreen *screen = Fluxbox::instance()->mouseScreen(); |
@@ -443,7 +443,7 @@ void SetResourceValueCmd::execute() { | |||
443 | Fluxbox::instance()->save_rc(); | 443 | Fluxbox::instance()->save_rc(); |
444 | } | 444 | } |
445 | 445 | ||
446 | REGISTER_OBJECT(setresourcevaluedialog, FbCommands::SetResourceValueDialogCmd, Command); | 446 | REGISTER_COMMAND(setresourcevaluedialog, FbCommands::SetResourceValueDialogCmd, void); |
447 | 447 | ||
448 | void SetResourceValueDialogCmd::execute() { | 448 | void SetResourceValueDialogCmd::execute() { |
449 | BScreen *screen = Fluxbox::instance()->mouseScreen(); | 449 | BScreen *screen = Fluxbox::instance()->mouseScreen(); |
@@ -454,7 +454,7 @@ void SetResourceValueDialogCmd::execute() { | |||
454 | win->show(); | 454 | win->show(); |
455 | }; | 455 | }; |
456 | 456 | ||
457 | REGISTER_UNTRUSTED_OBJECT_WITH_ARGS(bindkey, FbCommands::BindKeyCmd, Command); | 457 | REGISTER_UNTRUSTED_COMMAND_WITH_ARGS(bindkey, FbCommands::BindKeyCmd, void); |
458 | 458 | ||
459 | BindKeyCmd::BindKeyCmd(const string &keybind):m_keybind(keybind) { } | 459 | BindKeyCmd::BindKeyCmd(const string &keybind):m_keybind(keybind) { } |
460 | 460 | ||
@@ -469,7 +469,7 @@ void BindKeyCmd::execute() { | |||
469 | } | 469 | } |
470 | } | 470 | } |
471 | 471 | ||
472 | FbTk::Command *DeiconifyCmd::parse(const string &command, const string &args, | 472 | FbTk::Command<void> *DeiconifyCmd::parse(const string &command, const string &args, |
473 | bool trusted) { | 473 | bool trusted) { |
474 | FbTk_istringstream iss(args.c_str()); | 474 | FbTk_istringstream iss(args.c_str()); |
475 | string mode; | 475 | string mode; |
@@ -502,7 +502,7 @@ FbTk::Command *DeiconifyCmd::parse(const string &command, const string &args, | |||
502 | return new DeiconifyCmd(DeiconifyCmd::LASTWORKSPACE, dest); | 502 | return new DeiconifyCmd(DeiconifyCmd::LASTWORKSPACE, dest); |
503 | } | 503 | } |
504 | 504 | ||
505 | REGISTER_OBJECT_PARSER(deiconify, DeiconifyCmd::parse, Command); | 505 | REGISTER_COMMAND_PARSER(deiconify, DeiconifyCmd::parse, void); |
506 | 506 | ||
507 | DeiconifyCmd::DeiconifyCmd(Mode mode, | 507 | DeiconifyCmd::DeiconifyCmd(Mode mode, |
508 | Destination dest) : m_mode(mode), m_dest(dest) { } | 508 | Destination dest) : m_mode(mode), m_dest(dest) { } |