diff options
-rw-r--r-- | src/MenuCreator.cc | 71 | ||||
-rw-r--r-- | src/MenuCreator.hh | 21 |
2 files changed, 0 insertions, 92 deletions
diff --git a/src/MenuCreator.cc b/src/MenuCreator.cc index 70075d1..6a6accc 100644 --- a/src/MenuCreator.cc +++ b/src/MenuCreator.cc | |||
@@ -64,11 +64,6 @@ using std::list; | |||
64 | using std::less; | 64 | using std::less; |
65 | using FbTk::AutoReloadHelper; | 65 | using FbTk::AutoReloadHelper; |
66 | 66 | ||
67 | list<string> MenuCreator::encoding_stack; | ||
68 | list<size_t> MenuCreator::stacksize_stack; | ||
69 | |||
70 | FbTk::StringConvertor MenuCreator::m_stringconvertor(FbTk::StringConvertor::ToFbString); | ||
71 | |||
72 | namespace { | 67 | namespace { |
73 | 68 | ||
74 | std::auto_ptr<FbMenu> createStyleMenu(int screen_number, const string &label, | 69 | std::auto_ptr<FbMenu> createStyleMenu(int screen_number, const string &label, |
@@ -542,69 +537,3 @@ bool MenuCreator::createWindowMenuItem(const string &type, | |||
542 | 537 | ||
543 | return true; | 538 | return true; |
544 | } | 539 | } |
545 | |||
546 | /* push our encoding-stacksize onto the stack */ | ||
547 | void MenuCreator::startFile() { | ||
548 | if (encoding_stack.empty()) | ||
549 | m_stringconvertor.setSource(""); | ||
550 | stacksize_stack.push_back(encoding_stack.size()); | ||
551 | } | ||
552 | |||
553 | /** | ||
554 | * Pop necessary encodings from the stack | ||
555 | * (and endEncoding the final one) to our matching encoding-stacksize. | ||
556 | */ | ||
557 | void MenuCreator::endFile() { | ||
558 | size_t target_size = stacksize_stack.back(); | ||
559 | size_t curr_size = encoding_stack.size(); | ||
560 | |||
561 | if (target_size != curr_size) { | ||
562 | _FB_USES_NLS; | ||
563 | cerr<<_FB_CONSOLETEXT(Menu, ErrorEndEncoding, "Warning: unbalanced [encoding] tags", "User menu file had unbalanced [encoding] tags")<<endl; | ||
564 | } | ||
565 | |||
566 | for (; curr_size > (target_size+1); --curr_size) | ||
567 | encoding_stack.pop_back(); | ||
568 | |||
569 | if (curr_size == (target_size+1)) | ||
570 | endEncoding(); | ||
571 | |||
572 | stacksize_stack.pop_back(); | ||
573 | } | ||
574 | |||
575 | /** | ||
576 | * Push the encoding onto the stack, and make it active. | ||
577 | */ | ||
578 | void MenuCreator::startEncoding(const string &encoding) { | ||
579 | // we push it regardless of whether it's valid, since we | ||
580 | // need to stay balanced with the endEncodings. | ||
581 | encoding_stack.push_back(encoding); | ||
582 | |||
583 | // this won't change if it doesn't succeed | ||
584 | m_stringconvertor.setSource(encoding); | ||
585 | } | ||
586 | |||
587 | /** | ||
588 | * Pop the encoding from the stack, unless we are at our stacksize limit. | ||
589 | * Restore the previous (valid) encoding. | ||
590 | */ | ||
591 | void MenuCreator::endEncoding() { | ||
592 | size_t min_size = stacksize_stack.back(); | ||
593 | if (encoding_stack.size() <= min_size) { | ||
594 | _FB_USES_NLS; | ||
595 | cerr<<_FB_CONSOLETEXT(Menu, ErrorEndEncoding, "Warning: unbalanced [encoding] tags", "User menu file had unbalanced [encoding] tags")<<endl; | ||
596 | return; | ||
597 | } | ||
598 | |||
599 | encoding_stack.pop_back(); | ||
600 | m_stringconvertor.reset(); | ||
601 | |||
602 | list<string>::reverse_iterator it = encoding_stack.rbegin(); | ||
603 | list<string>::reverse_iterator it_end = encoding_stack.rend(); | ||
604 | while (it != it_end && !m_stringconvertor.setSource(*it)) | ||
605 | ++it; | ||
606 | |||
607 | if (it == it_end) | ||
608 | m_stringconvertor.setSource(""); | ||
609 | } | ||
610 | |||
diff --git a/src/MenuCreator.hh b/src/MenuCreator.hh index 8e5cad1..b2dd7d0 100644 --- a/src/MenuCreator.hh +++ b/src/MenuCreator.hh | |||
@@ -51,27 +51,6 @@ public: | |||
51 | FbTk::AutoReloadHelper *reloader = NULL); | 51 | FbTk::AutoReloadHelper *reloader = NULL); |
52 | static bool createWindowMenuItem(const std::string &type, const std::string &label, | 52 | static bool createWindowMenuItem(const std::string &type, const std::string &label, |
53 | FbTk::Menu &inject_into); | 53 | FbTk::Menu &inject_into); |
54 | |||
55 | /** | ||
56 | * Encoding-related helpers (encoding, aka codeset) | ||
57 | */ | ||
58 | |||
59 | // Files are guaranteed to be "balanced", unlike user-created [encoding] tags. | ||
60 | static void startFile(); | ||
61 | static void endFile(); | ||
62 | |||
63 | static void startEncoding(const std::string &encoding); | ||
64 | static void endEncoding(); | ||
65 | |||
66 | private: | ||
67 | // stack of encodings | ||
68 | static std::list<std::string> encoding_stack; | ||
69 | // stack of ints, representing stack size as each file is entered | ||
70 | // (a file should never end more encodings than it starts) | ||
71 | static std::list<size_t> stacksize_stack; | ||
72 | |||
73 | static FbTk::StringConvertor m_stringconvertor; | ||
74 | |||
75 | }; | 54 | }; |
76 | 55 | ||
77 | #endif // MENUCREATOR_HH | 56 | #endif // MENUCREATOR_HH |