aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/MenuCreator.cc74
1 files changed, 0 insertions, 74 deletions
diff --git a/src/MenuCreator.cc b/src/MenuCreator.cc
index b357dce..6a6accc 100644
--- a/src/MenuCreator.cc
+++ b/src/MenuCreator.cc
@@ -66,78 +66,6 @@ using FbTk::AutoReloadHelper;
66 66
67namespace { 67namespace {
68 68
69FbTk::StringConvertor s_stringconvertor(FbTk::StringConvertor::ToFbString);
70
71list<string> s_encoding_stack;
72list<size_t> s_stacksize_stack;
73
74/**
75 * Push the encoding onto the stack, and make it active.
76 */
77void startEncoding(const string &encoding) {
78 // we push it regardless of whether it's valid, since we
79 // need to stay balanced with the endEncodings.
80 s_encoding_stack.push_back(encoding);
81
82 // this won't change if it doesn't succeed
83 s_stringconvertor.setSource(encoding);
84}
85
86/**
87 * Pop the encoding from the stack, unless we are at our stacksize limit.
88 * Restore the previous (valid) encoding.
89 */
90void endEncoding() {
91 size_t min_size = s_stacksize_stack.back();
92 if (s_encoding_stack.size() <= min_size) {
93 _FB_USES_NLS;
94 cerr<<_FB_CONSOLETEXT(Menu, ErrorEndEncoding, "Warning: unbalanced [encoding] tags", "User menu file had unbalanced [encoding] tags")<<endl;
95 return;
96 }
97
98 s_encoding_stack.pop_back();
99 s_stringconvertor.reset();
100
101 list<string>::reverse_iterator it = s_encoding_stack.rbegin();
102 list<string>::reverse_iterator it_end = s_encoding_stack.rend();
103 while (it != it_end && !s_stringconvertor.setSource(*it))
104 ++it;
105
106 if (it == it_end)
107 s_stringconvertor.setSource("");
108}
109
110
111/* push our encoding-stacksize onto the stack */
112void startFile() {
113 if (s_encoding_stack.empty())
114 s_stringconvertor.setSource("");
115 s_stacksize_stack.push_back(s_encoding_stack.size());
116}
117
118/**
119 * Pop necessary encodings from the stack
120 * (and endEncoding the final one) to our matching encoding-stacksize.
121 */
122void endFile() {
123 size_t target_size = s_stacksize_stack.back();
124 size_t curr_size = s_encoding_stack.size();
125
126 if (target_size != curr_size) {
127 _FB_USES_NLS;
128 cerr<<_FB_CONSOLETEXT(Menu, ErrorEndEncoding, "Warning: unbalanced [encoding] tags", "User menu file had unbalanced [encoding] tags")<<endl;
129 }
130
131 for (; curr_size > (target_size+1); --curr_size)
132 s_encoding_stack.pop_back();
133
134 if (curr_size == (target_size+1))
135 endEncoding();
136
137 s_stacksize_stack.pop_back();
138}
139
140
141std::auto_ptr<FbMenu> createStyleMenu(int screen_number, const string &label, 69std::auto_ptr<FbMenu> createStyleMenu(int screen_number, const string &label,
142 AutoReloadHelper *reloader, const string &directory) { 70 AutoReloadHelper *reloader, const string &directory) {
143 71
@@ -609,5 +537,3 @@ bool MenuCreator::createWindowMenuItem(const string &type,
609 537
610 return true; 538 return true;
611} 539}
612
613