diff options
author | fluxgen <fluxgen> | 2004-09-12 00:31:11 (GMT) |
---|---|---|
committer | fluxgen <fluxgen> | 2004-09-12 00:31:11 (GMT) |
commit | d24bbb998b456ecdcfe41e5c9aae8ba93152f83d (patch) | |
tree | 1cfbfb8a20f4e2d651758ba55be7422c8c91207b /src/MenuCreator.cc | |
parent | a4043853ffa0fa8f7b585facb45659964aadc459 (diff) | |
download | fluxbox-d24bbb998b456ecdcfe41e5c9aae8ba93152f83d.zip fluxbox-d24bbb998b456ecdcfe41e5c9aae8ba93152f83d.tar.bz2 |
inject an entire directory of menu files with include + path, patch from Ciaran McCreesh
Diffstat (limited to 'src/MenuCreator.cc')
-rw-r--r-- | src/MenuCreator.cc | 41 |
1 files changed, 37 insertions, 4 deletions
diff --git a/src/MenuCreator.cc b/src/MenuCreator.cc index 294b6ae..12bec82 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.14 2004/09/09 14:32:56 akir Exp $ | 23 | // $Id: MenuCreator.cc,v 1.15 2004/09/12 00:31:11 fluxgen Exp $ |
24 | 24 | ||
25 | #include "MenuCreator.hh" | 25 | #include "MenuCreator.hh" |
26 | 26 | ||
@@ -220,10 +220,43 @@ static void translateMenuItem(Parser &parse, ParseItem &pitem) { | |||
220 | menu.insert(str_label.c_str(), &screen->configMenu()); | 220 | menu.insert(str_label.c_str(), &screen->configMenu()); |
221 | } // end of config | 221 | } // end of config |
222 | else if (str_key == "include") { // include | 222 | else if (str_key == "include") { // include |
223 | |||
224 | // this will make sure we dont get stuck in a loop | ||
225 | static size_t safe_counter = 0; | ||
226 | if (safe_counter > 10) | ||
227 | return; | ||
228 | |||
229 | safe_counter++; | ||
230 | |||
223 | string newfile = FbTk::StringUtil::expandFilename(str_label); | 231 | string newfile = FbTk::StringUtil::expandFilename(str_label); |
224 | // inject this file into the current menu | 232 | if (FbTk::Directory::isDirectory(newfile)) { |
225 | MenuCreator::createFromFile(newfile, menu); | 233 | // inject every file in this directory into the current menu |
226 | Fluxbox::instance()->saveMenuFilename(newfile.c_str()); | 234 | FbTk::Directory dir(newfile.c_str()); |
235 | |||
236 | std::vector<std::string> filelist(dir.entries()); | ||
237 | for (size_t file_index = 0; file_index < dir.entries(); ++file_index) | ||
238 | filelist[file_index] = dir.readFilename(); | ||
239 | std::sort(filelist.begin(), filelist.end(), less<string>()); | ||
240 | |||
241 | for (size_t file_index = 0; file_index < dir.entries(); file_index++) { | ||
242 | std::string thisfile(newfile + '/' + filelist[file_index]); | ||
243 | |||
244 | if (FbTk::Directory::isRegularFile(thisfile) && | ||
245 | (filelist[file_index][0] != '.') && | ||
246 | (thisfile[thisfile.length() - 1] != '~')) { | ||
247 | MenuCreator::createFromFile(thisfile, menu); | ||
248 | Fluxbox::instance()->saveMenuFilename(thisfile.c_str()); | ||
249 | } | ||
250 | } | ||
251 | |||
252 | } else { | ||
253 | // inject this file into the current menu | ||
254 | MenuCreator::createFromFile(newfile, menu); | ||
255 | Fluxbox::instance()->saveMenuFilename(newfile.c_str()); | ||
256 | } | ||
257 | |||
258 | safe_counter--; | ||
259 | |||
227 | } // end of include | 260 | } // end of include |
228 | else if (str_key == "submenu") { | 261 | else if (str_key == "submenu") { |
229 | 262 | ||