diff options
author | Pavel Labath <pavelo@centrum.sk> | 2011-08-19 14:31:59 (GMT) |
---|---|---|
committer | Pavel Labath <pavelo@centrum.sk> | 2011-11-01 10:04:03 (GMT) |
commit | 18e8f7cd9906728864ecc3e25b2ab3e29070ec8a (patch) | |
tree | 8c81c6baae0fa7e76dec5d0db7cc1907a35e183d | |
parent | b29a8af7434eca71dd56094f0a20fef6d683212e (diff) | |
download | fluxbox_paul-18e8f7cd9906728864ecc3e25b2ab3e29070ec8a.zip fluxbox_paul-18e8f7cd9906728864ecc3e25b2ab3e29070ec8a.tar.bz2 |
Make stylesdir and wallpapers generate inline menu entries
instead of submenus. This is more in line (no pun intended :P) with how the old menu files worked.
-rw-r--r-- | src/MenuCreator.cc | 32 |
1 files changed, 11 insertions, 21 deletions
diff --git a/src/MenuCreator.cc b/src/MenuCreator.cc index 536a5bc..5156505 100644 --- a/src/MenuCreator.cc +++ b/src/MenuCreator.cc | |||
@@ -70,16 +70,13 @@ namespace { | |||
70 | typedef FbTk::RefCount<FbTk::Menu> RefMenu; | 70 | typedef FbTk::RefCount<FbTk::Menu> RefMenu; |
71 | typedef FbTk::RefCount<FbTk::Command<void> > RefCmd; | 71 | typedef FbTk::RefCount<FbTk::Command<void> > RefCmd; |
72 | 72 | ||
73 | RefMenu createStyleMenu(int screen_number, const string &label, | 73 | void createStyleMenu(FbTk::Menu &menu, AutoReloadHelper *reloader, const string &directory) { |
74 | AutoReloadHelper *reloader, const string &directory) { | ||
75 | |||
76 | FbTk::RefCount<FbMenu> menu(MenuCreator::createMenu(label, screen_number)); | ||
77 | 74 | ||
78 | // perform shell style ~ home directory expansion | 75 | // perform shell style ~ home directory expansion |
79 | string stylesdir(FbTk::StringUtil::expandFilename(directory)); | 76 | string stylesdir(FbTk::StringUtil::expandFilename(directory)); |
80 | 77 | ||
81 | if (!FbTk::FileUtil::isDirectory(stylesdir.c_str())) | 78 | if (!FbTk::FileUtil::isDirectory(stylesdir.c_str())) |
82 | return menu; | 79 | return; |
83 | 80 | ||
84 | if (reloader) | 81 | if (reloader) |
85 | reloader->addFile(stylesdir); | 82 | reloader->addFile(stylesdir); |
@@ -87,7 +84,7 @@ RefMenu createStyleMenu(int screen_number, const string &label, | |||
87 | FbTk::Directory dir(stylesdir.c_str()); | 84 | FbTk::Directory dir(stylesdir.c_str()); |
88 | 85 | ||
89 | // create a vector of all the filenames in the directory | 86 | // create a vector of all the filenames in the directory |
90 | // add sort it | 87 | // and sort it |
91 | vector<string> filelist(dir.entries()); | 88 | vector<string> filelist(dir.entries()); |
92 | for (size_t file_index = 0; file_index < dir.entries(); ++file_index) | 89 | for (size_t file_index = 0; file_index < dir.entries(); ++file_index) |
93 | filelist[file_index] = dir.readFilename(); | 90 | filelist[file_index] = dir.readFilename(); |
@@ -104,24 +101,20 @@ RefMenu createStyleMenu(int screen_number, const string &label, | |||
104 | (style[style.length() - 1] != '~')) || | 101 | (style[style.length() - 1] != '~')) || |
105 | FbTk::FileUtil::isRegularFile((style + "/theme.cfg").c_str()) || | 102 | FbTk::FileUtil::isRegularFile((style + "/theme.cfg").c_str()) || |
106 | FbTk::FileUtil::isRegularFile((style + "/style.cfg").c_str())) | 103 | FbTk::FileUtil::isRegularFile((style + "/style.cfg").c_str())) |
107 | menu->insert(new StyleMenuItem(filelist[file_index], style)); | 104 | menu.insert(new StyleMenuItem(filelist[file_index], style)); |
108 | } | 105 | } |
109 | // update menu graphics | 106 | // update menu graphics |
110 | menu->updateMenu(); | 107 | menu.updateMenu(); |
111 | return menu; | ||
112 | } | 108 | } |
113 | 109 | ||
114 | RefMenu createRootCmdMenu(int screen_number, const string &label, | 110 | void createRootCmdMenu(FbTk::Menu &menu, const string &directory, AutoReloadHelper *reloader, |
115 | const string &directory, AutoReloadHelper *reloader, | ||
116 | const string &cmd) { | 111 | const string &cmd) { |
117 | 112 | ||
118 | FbTk::RefCount<FbMenu> menu(MenuCreator::createMenu(label, screen_number)); | ||
119 | |||
120 | // perform shell style ~ home directory expansion | 113 | // perform shell style ~ home directory expansion |
121 | string rootcmddir(FbTk::StringUtil::expandFilename(directory)); | 114 | string rootcmddir(FbTk::StringUtil::expandFilename(directory)); |
122 | 115 | ||
123 | if (!FbTk::FileUtil::isDirectory(rootcmddir.c_str())) | 116 | if (!FbTk::FileUtil::isDirectory(rootcmddir.c_str())) |
124 | return menu; | 117 | return; |
125 | 118 | ||
126 | if (reloader) | 119 | if (reloader) |
127 | reloader->addFile(rootcmddir); | 120 | reloader->addFile(rootcmddir); |
@@ -145,11 +138,10 @@ RefMenu createRootCmdMenu(int screen_number, const string &label, | |||
145 | if ((FbTk::FileUtil::isRegularFile(rootcmd.c_str()) && | 138 | if ((FbTk::FileUtil::isRegularFile(rootcmd.c_str()) && |
146 | (filelist[file_index][0] != '.') && | 139 | (filelist[file_index][0] != '.') && |
147 | (rootcmd[rootcmd.length() - 1] != '~'))) | 140 | (rootcmd[rootcmd.length() - 1] != '~'))) |
148 | menu->insert(new RootCmdMenuItem(filelist[file_index], rootcmd, cmd)); | 141 | menu.insert(new RootCmdMenuItem(filelist[file_index], rootcmd, cmd)); |
149 | } | 142 | } |
150 | // update menu graphics | 143 | // update menu graphics |
151 | menu->updateMenu(); | 144 | menu.updateMenu(); |
152 | return menu; | ||
153 | } | 145 | } |
154 | 146 | ||
155 | 147 | ||
@@ -260,14 +252,12 @@ insertMenuItem(lua::state &l, FbTk::Menu &menu, FbTk::StringConvertor &parent_co | |||
260 | } else if(str_key == "style") | 252 | } else if(str_key == "style") |
261 | menu.insert(new StyleMenuItem(str_label, str_cmd)); | 253 | menu.insert(new StyleMenuItem(str_label, str_cmd)); |
262 | else if (str_key == "stylesdir") | 254 | else if (str_key == "stylesdir") |
263 | menu.insert(str_label, | 255 | createStyleMenu(menu, reloader, str_cmd); |
264 | createStyleMenu(screen_number, str_label, reloader, str_cmd)); | ||
265 | else if (str_key == "wallpapers") { | 256 | else if (str_key == "wallpapers") { |
266 | string program = getField(l, -1, "program"); | 257 | string program = getField(l, -1, "program"); |
267 | if(program.empty()) | 258 | if(program.empty()) |
268 | program = realProgramName("fbsetbg"); | 259 | program = realProgramName("fbsetbg"); |
269 | menu.insert(str_label, createRootCmdMenu(screen_number, str_label, str_cmd, | 260 | createRootCmdMenu(menu, str_cmd, reloader, program); |
270 | reloader, program) ); | ||
271 | } else if (str_key == "workspaces") { | 261 | } else if (str_key == "workspaces") { |
272 | menu.insert(str_label, RefMenu(screen->workspaceMenu()) ); | 262 | menu.insert(str_label, RefMenu(screen->workspaceMenu()) ); |
273 | // finally, try window-related commands | 263 | // finally, try window-related commands |