diff options
author | rathnor <rathnor> | 2004-06-07 11:46:05 (GMT) |
---|---|---|
committer | rathnor <rathnor> | 2004-06-07 11:46:05 (GMT) |
commit | fff4456dee29e675d7f2ed3490db39bcb7e10e53 (patch) | |
tree | 2d2dbf386551773cbdc8231b2a93b493187bd733 /src/MenuCreator.cc | |
parent | 073065ac56b388db1169108d44f37d32f1d19c67 (diff) | |
download | fluxbox_lack-fff4456dee29e675d7f2ed3490db39bcb7e10e53.zip fluxbox_lack-fff4456dee29e675d7f2ed3490db39bcb7e10e53.tar.bz2 |
update NLS string handling...
Diffstat (limited to 'src/MenuCreator.cc')
-rw-r--r-- | src/MenuCreator.cc | 58 |
1 files changed, 20 insertions, 38 deletions
diff --git a/src/MenuCreator.cc b/src/MenuCreator.cc index 970b799..90a4386 100644 --- a/src/MenuCreator.cc +++ b/src/MenuCreator.cc | |||
@@ -20,7 +20,7 @@ | |||
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: MenuCreator.cc,v 1.5 2004/05/03 21:37:01 fluxgen Exp $ | 23 | // $Id: MenuCreator.cc,v 1.6 2004/06/07 11:46:04 rathnor Exp $ |
24 | 24 | ||
25 | #include "MenuCreator.hh" | 25 | #include "MenuCreator.hh" |
26 | 26 | ||
@@ -29,7 +29,6 @@ | |||
29 | #include "fluxbox.hh" | 29 | #include "fluxbox.hh" |
30 | #include "CommandParser.hh" | 30 | #include "CommandParser.hh" |
31 | #include "Window.hh" | 31 | #include "Window.hh" |
32 | #include "I18n.hh" | ||
33 | 32 | ||
34 | #include "FbMenu.hh" | 33 | #include "FbMenu.hh" |
35 | #include "IconMenu.hh" | 34 | #include "IconMenu.hh" |
@@ -40,6 +39,7 @@ | |||
40 | #include "FbMenuParser.hh" | 39 | #include "FbMenuParser.hh" |
41 | #include "StyleMenuItem.hh" | 40 | #include "StyleMenuItem.hh" |
42 | 41 | ||
42 | #include "FbTk/I18n.hh" | ||
43 | #include "FbTk/MultiButtonMenuItem.hh" | 43 | #include "FbTk/MultiButtonMenuItem.hh" |
44 | #include "FbTk/RefCount.hh" | 44 | #include "FbTk/RefCount.hh" |
45 | #include "FbTk/MacroCommand.hh" | 45 | #include "FbTk/MacroCommand.hh" |
@@ -119,10 +119,7 @@ static void translateMenuItem(Parser &parse, | |||
119 | FbTk::Menu &menu) { | 119 | FbTk::Menu &menu) { |
120 | 120 | ||
121 | const int screen_number = menu.screenNumber(); | 121 | const int screen_number = menu.screenNumber(); |
122 | static I18n &i18n = *I18n::instance(); | 122 | _FB_USES_NLS; |
123 | using namespace FBNLS; | ||
124 | |||
125 | #define SCREENNLS(a, b) i18n.getMessage(ScreenSet, a, b) | ||
126 | 123 | ||
127 | if (str_key == "end") { | 124 | if (str_key == "end") { |
128 | return; | 125 | return; |
@@ -133,13 +130,13 @@ static void translateMenuItem(Parser &parse, | |||
133 | if (submenu == 0) | 130 | if (submenu == 0) |
134 | return; | 131 | return; |
135 | if (str_label.empty()) | 132 | if (str_label.empty()) |
136 | menu.insert(i18n.getMessage(IconSet, IconIcons, "Icons")); | 133 | menu.insert(_FBTEXT(Menu, Icons, "Icons", "Iconic windows menu title")); |
137 | else | 134 | else |
138 | menu.insert(str_label.c_str(), submenu); | 135 | menu.insert(str_label.c_str(), submenu); |
139 | } else if (str_key == "exit") { // exit | 136 | } else if (str_key == "exit") { // exit |
140 | FbTk::RefCount<FbTk::Command> exit_cmd(CommandParser::instance().parseLine("exit")); | 137 | FbTk::RefCount<FbTk::Command> exit_cmd(CommandParser::instance().parseLine("exit")); |
141 | if (str_label.empty()) | 138 | if (str_label.empty()) |
142 | menu.insert(SCREENNLS(ScreenExit, "Exit"), exit_cmd); | 139 | menu.insert(_FBTEXT(Menu, Exit, "Exit", "Exit Command"), exit_cmd); |
143 | else | 140 | else |
144 | menu.insert(str_label.c_str(), exit_cmd); | 141 | menu.insert(str_label.c_str(), exit_cmd); |
145 | } else if (str_key == "exec") { | 142 | } else if (str_key == "exec") { |
@@ -191,18 +188,18 @@ static void translateMenuItem(Parser &parse, | |||
191 | FbTk::RefCount<FbTk::Command> restart_fb(CommandParser::instance(). | 188 | FbTk::RefCount<FbTk::Command> restart_fb(CommandParser::instance(). |
192 | parseLine("restart")); | 189 | parseLine("restart")); |
193 | if (str_label.empty()) | 190 | if (str_label.empty()) |
194 | menu.insert(SCREENNLS(ScreenRestart, "Restart"), restart_fb); | 191 | menu.insert(_FBTEXT(Menu, Restart, "Restart", "Restart Command"), restart_fb); |
195 | else | 192 | else |
196 | menu.insert(str_label.c_str(), restart_fb); | 193 | menu.insert(str_label.c_str(), restart_fb); |
197 | } // end of restart | 194 | } // end of restart |
198 | else if (str_key == "reconfig") { // reconf | 195 | else if (str_key == "reconfig") { // reconf |
199 | // | ||
200 | //!! TODO: NLS | ||
201 | // | ||
202 | FbTk::RefCount<FbTk::Command> | 196 | FbTk::RefCount<FbTk::Command> |
203 | reconfig_fb_cmd(CommandParser::instance(). | 197 | reconfig_fb_cmd(CommandParser::instance(). |
204 | parseLine("reconfigure")); | 198 | parseLine("reconfigure")); |
205 | menu.insert(str_label.c_str(), reconfig_fb_cmd); | 199 | if (str_label.empty()) |
200 | menu.insert(_FBTEXT(Menu, Reconfigure, "Reload Config", "Reload all the configs"), reconfig_fb_cmd); | ||
201 | else | ||
202 | menu.insert(str_label.c_str(), reconfig_fb_cmd); | ||
206 | 203 | ||
207 | } else if (str_key == "stylesdir" || str_key == "stylesmenu") { | 204 | } else if (str_key == "stylesdir" || str_key == "stylesmenu") { |
208 | createStyleMenu(menu, str_label, | 205 | createStyleMenu(menu, str_label, |
@@ -223,8 +220,6 @@ static void translateMenuItem(Parser &parse, | |||
223 | if (*command != 0) | 220 | if (*command != 0) |
224 | menu.insert(str_label.c_str(), command); | 221 | menu.insert(str_label.c_str(), command); |
225 | } | 222 | } |
226 | #undef SCREENNLS | ||
227 | |||
228 | } | 223 | } |
229 | 224 | ||
230 | 225 | ||
@@ -347,23 +342,18 @@ bool MenuCreator::createWindowMenuItem(const std::string &type, | |||
347 | const std::string &label, | 342 | const std::string &label, |
348 | FbTk::Menu &menu, | 343 | FbTk::Menu &menu, |
349 | FluxboxWindow &win) { | 344 | FluxboxWindow &win) { |
350 | static I18n &i18n = *I18n::instance(); | ||
351 | typedef FbTk::RefCount<FbTk::Command> RefCmd; | 345 | typedef FbTk::RefCount<FbTk::Command> RefCmd; |
352 | typedef FbTk::SimpleCommand<FluxboxWindow> WindowCmd; | 346 | typedef FbTk::SimpleCommand<FluxboxWindow> WindowCmd; |
353 | using namespace FBNLS; | 347 | _FB_USES_NLS; |
354 | |||
355 | #define WINDOWNLS(a, b) std::string real_label = label; if (label.empty()) real_label = i18n.getMessage(FBNLS::WindowmenuSet, a, b) | ||
356 | 348 | ||
357 | if (type == "shade") { | 349 | if (type == "shade") { |
358 | WINDOWNLS(WindowmenuShade, "Shade"); | ||
359 | RefCmd shade_cmd(new WindowCmd(win, &FluxboxWindow::shade)); | 350 | RefCmd shade_cmd(new WindowCmd(win, &FluxboxWindow::shade)); |
360 | menu.insert(real_label.c_str(), shade_cmd); | 351 | menu.insert(label.empty()?_FBTEXT(Windowmenu, Shade, "Shade", "Shade the window"):label.c_str(), shade_cmd); |
361 | } else if (type == "maximize") { | 352 | } else if (type == "maximize") { |
362 | WINDOWNLS(WindowmenuMaximize, "Maximize"); | ||
363 | RefCmd maximize_cmd(new WindowCmd(win, &FluxboxWindow::maximizeFull)); | 353 | RefCmd maximize_cmd(new WindowCmd(win, &FluxboxWindow::maximizeFull)); |
364 | RefCmd maximize_vert_cmd(new WindowCmd(win, &FluxboxWindow::maximizeVertical)); | 354 | RefCmd maximize_vert_cmd(new WindowCmd(win, &FluxboxWindow::maximizeVertical)); |
365 | RefCmd maximize_horiz_cmd(new WindowCmd(win, &FluxboxWindow::maximizeHorizontal)); | 355 | RefCmd maximize_horiz_cmd(new WindowCmd(win, &FluxboxWindow::maximizeHorizontal)); |
366 | FbTk::MultiButtonMenuItem *maximize_item = new FbTk::MultiButtonMenuItem(3, real_label.c_str()); | 356 | FbTk::MultiButtonMenuItem *maximize_item = new FbTk::MultiButtonMenuItem(3, label.empty()?_FBTEXT(Windowmenu, Maximize, "Maximize", "Maximize the window"):label.c_str()); |
367 | // create maximize item with: | 357 | // create maximize item with: |
368 | // button1: Maximize normal | 358 | // button1: Maximize normal |
369 | // button2: Maximize Vertical | 359 | // button2: Maximize Vertical |
@@ -373,25 +363,20 @@ bool MenuCreator::createWindowMenuItem(const std::string &type, | |||
373 | maximize_item->setCommand(3, maximize_horiz_cmd); | 363 | maximize_item->setCommand(3, maximize_horiz_cmd); |
374 | menu.insert(maximize_item); | 364 | menu.insert(maximize_item); |
375 | } else if (type == "iconify") { | 365 | } else if (type == "iconify") { |
376 | WINDOWNLS(WindowmenuIconify, "Iconify"); | ||
377 | RefCmd iconify_cmd(new WindowCmd(win, &FluxboxWindow::iconify)); | 366 | RefCmd iconify_cmd(new WindowCmd(win, &FluxboxWindow::iconify)); |
378 | menu.insert(real_label.c_str(), iconify_cmd); | 367 | menu.insert(label.empty()?_FBTEXT(Windowmenu, Iconify, "Iconify", "Iconify the window"):label.c_str(), iconify_cmd); |
379 | } else if (type == "close") { | 368 | } else if (type == "close") { |
380 | WINDOWNLS(WindowmenuClose, "Close"); | ||
381 | RefCmd close_cmd(new WindowCmd(win, &FluxboxWindow::close)); | 369 | RefCmd close_cmd(new WindowCmd(win, &FluxboxWindow::close)); |
382 | menu.insert(real_label.c_str(), close_cmd); | 370 | menu.insert(label.empty()?_FBTEXT(Windowmenu, Close, "Close", "Close the window"):label.c_str(), close_cmd); |
383 | } else if (type == "lower") { | 371 | } else if (type == "lower") { |
384 | WINDOWNLS(WindowmenuLower, "Lower"); | ||
385 | RefCmd lower_cmd(new WindowCmd(win, &FluxboxWindow::lower)); | 372 | RefCmd lower_cmd(new WindowCmd(win, &FluxboxWindow::lower)); |
386 | menu.insert(real_label.c_str(), lower_cmd); | 373 | menu.insert(label.empty()?_FBTEXT(Windowmenu, Lower, "Lower", "Lower the window"):label.c_str(), lower_cmd); |
387 | } else if (type == "raise") { | 374 | } else if (type == "raise") { |
388 | WINDOWNLS(WindowmenuRaise, "Raise"); | ||
389 | RefCmd raise_cmd(new WindowCmd(win, &FluxboxWindow::raise)); | 375 | RefCmd raise_cmd(new WindowCmd(win, &FluxboxWindow::raise)); |
390 | menu.insert(real_label.c_str(), raise_cmd); | 376 | menu.insert(label.empty()?_FBTEXT(Windowmenu, Raise, "Raise", "Raise the window"):label.c_str(), raise_cmd); |
391 | } else if (type == "stick") { | 377 | } else if (type == "stick") { |
392 | WINDOWNLS(WindowmenuStick, "Stick"); | ||
393 | RefCmd stick_cmd(new WindowCmd(win, &FluxboxWindow::stick)); | 378 | RefCmd stick_cmd(new WindowCmd(win, &FluxboxWindow::stick)); |
394 | menu.insert(real_label.c_str(), stick_cmd); | 379 | menu.insert(label.empty()?_FBTEXT(Windowmenu, Stick, "Stick", "Stick the window"):label.c_str(), stick_cmd); |
395 | } else if (type == "extramenus") { | 380 | } else if (type == "extramenus") { |
396 | FluxboxWindow::ExtraMenus::iterator it = win.extraMenus().begin(); | 381 | FluxboxWindow::ExtraMenus::iterator it = win.extraMenus().begin(); |
397 | FluxboxWindow::ExtraMenus::iterator it_end = win.extraMenus().end(); | 382 | FluxboxWindow::ExtraMenus::iterator it_end = win.extraMenus().end(); |
@@ -401,10 +386,8 @@ bool MenuCreator::createWindowMenuItem(const std::string &type, | |||
401 | } | 386 | } |
402 | 387 | ||
403 | } else if (type == "sendto") { | 388 | } else if (type == "sendto") { |
404 | WINDOWNLS(WindowmenuSendTo, "Send To ..."); | 389 | menu.insert(label.empty()?_FBTEXT(Windowmenu, Shade, "Shade", "Shade the window"):label.c_str(), new SendToMenu(win)); |
405 | menu.insert(real_label.c_str(), new SendToMenu(win)); | ||
406 | } else if (type == "layer") { | 390 | } else if (type == "layer") { |
407 | WINDOWNLS(WindowmenuLayer, "Layer ..."); | ||
408 | BScreen *screen = Fluxbox::instance()->findScreen(menu.screenNumber()); | 391 | BScreen *screen = Fluxbox::instance()->findScreen(menu.screenNumber()); |
409 | if (screen == 0) | 392 | if (screen == 0) |
410 | return false; | 393 | return false; |
@@ -415,14 +398,13 @@ bool MenuCreator::createWindowMenuItem(const std::string &type, | |||
415 | &win, | 398 | &win, |
416 | false); | 399 | false); |
417 | submenu->disableTitle(); | 400 | submenu->disableTitle(); |
418 | menu.insert(real_label.c_str(), submenu); | 401 | menu.insert(label.empty()?_FBTEXT(Windowmenu, Layer, "Layer ...", "Layer menu"):label.c_str(), submenu); |
419 | 402 | ||
420 | 403 | ||
421 | } else if (type == "separator") { | 404 | } else if (type == "separator") { |
422 | menu.insert("---"); | 405 | menu.insert("---"); |
423 | } else | 406 | } else |
424 | return false; | 407 | return false; |
425 | #undef WINDOWNLS | ||
426 | 408 | ||
427 | return true; | 409 | return true; |
428 | } | 410 | } |