aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfluxgen <fluxgen>2003-08-17 13:21:32 (GMT)
committerfluxgen <fluxgen>2003-08-17 13:21:32 (GMT)
commitd101fdb7704d1dd3d7ddefd6a02bbbc7325e83dc (patch)
treee01b625be6c5b294982c91252d94dc806ade3e2c
parent2211428f2d3de7da6e057624e43dc8d13a106a54 (diff)
downloadfluxbox-d101fdb7704d1dd3d7ddefd6a02bbbc7325e83dc.zip
fluxbox-d101fdb7704d1dd3d7ddefd6a02bbbc7325e83dc.tar.bz2
cleaning
-rw-r--r--src/Screen.cc71
1 files changed, 27 insertions, 44 deletions
diff --git a/src/Screen.cc b/src/Screen.cc
index 58fde04..5106b6b 100644
--- a/src/Screen.cc
+++ b/src/Screen.cc
@@ -22,7 +22,7 @@
22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23// DEALINGS IN THE SOFTWARE. 23// DEALINGS IN THE SOFTWARE.
24 24
25// $Id: Screen.cc,v 1.219 2003/08/13 16:53:13 fluxgen Exp $ 25// $Id: Screen.cc,v 1.220 2003/08/17 13:21:32 fluxgen Exp $
26 26
27 27
28#include "Screen.hh" 28#include "Screen.hh"
@@ -2047,54 +2047,37 @@ void BScreen::createStyleMenu(FbTk::Menu &menu,
2047 string stylesdir(FbTk::StringUtil::expandFilename(directory ? directory : "")); 2047 string stylesdir(FbTk::StringUtil::expandFilename(directory ? directory : ""));
2048 2048
2049 I18n *i18n = I18n::instance(); 2049 I18n *i18n = I18n::instance();
2050 struct stat statbuf; 2050
2051 2051 if (!FbTk::Directory::isDirectory(stylesdir)) {
2052 if (! stat(stylesdir.c_str(), &statbuf)) { 2052 //!! TODO: NLS
2053 if (S_ISDIR(statbuf.st_mode)) { // is a directory? 2053 cerr<<"Error creating style menu! Stylesdir: "<<stylesdir<<" does not exist or is not a directory!"<<endl;
2054 2054 return;
2055 FbTk::Directory dir(stylesdir.c_str()); 2055 }
2056
2056 2057
2057 // create a vector of all the filenames in the directory 2058 FbTk::Directory dir(stylesdir.c_str());
2058 // add sort it
2059 std::vector<std::string> filelist(dir.entries());
2060 for (size_t file_index = 0; file_index < dir.entries(); ++file_index)
2061 filelist[file_index] = dir.readFilename();
2062 2059
2063 std::sort(filelist.begin(), filelist.end(), less<string>()); 2060 // create a vector of all the filenames in the directory
2061 // add sort it
2062 std::vector<std::string> filelist(dir.entries());
2063 for (size_t file_index = 0; file_index < dir.entries(); ++file_index)
2064 filelist[file_index] = dir.readFilename();
2064 2065
2065 int slen = stylesdir.size(); 2066 std::sort(filelist.begin(), filelist.end(), less<string>());
2066 // for each file in directory add filename and path to menu
2067 for (size_t file_index = 0; file_index < dir.entries(); file_index++) {
2068 int nlen = filelist[file_index].size();
2069 char style[MAXPATHLEN + 1];
2070 2067
2071 strncpy(style, stylesdir.c_str(), slen); 2068 int slen = stylesdir.size();
2072 *(style + slen) = '/'; 2069 // for each file in directory add filename and path to menu
2073 strncpy(style + slen + 1, filelist[file_index].c_str(), nlen + 1); 2070 for (size_t file_index = 0; file_index < dir.entries(); file_index++) {
2071 std::string style(stylesdir + '/' + filelist[file_index])
2074 2072
2075 if ( !stat(style, &statbuf) && S_ISREG(statbuf.st_mode)) { 2073 if (FbTk::Directory::isRegularFile(style)) {
2076 FbTk::MenuItem *item = new StyleMenuItem(filelist[file_index], style); 2074 FbTk::MenuItem *item = new StyleMenuItem(filelist[file_index], style);
2077 menu.insert(item); 2075 menu.insert(item);
2078 } 2076 }
2079 } 2077 }
2080 // update menu graphics 2078 // update menu graphics
2081 menu.update(); 2079 menu.update();
2082 Fluxbox::instance()->saveMenuFilename(stylesdir.c_str()); 2080 Fluxbox::instance()->saveMenuFilename(stylesdir.c_str());
2083 } else { // no directory
2084 fprintf(stderr,
2085 i18n->
2086 getMessage(FBNLS::ScreenSet, FBNLS::ScreenSTYLESDIRErrorNotDir,
2087 "BScreen::parseMenuFile:"
2088 " [stylesdir/stylesmenu] error, %s is not a"
2089 " directory\n"), stylesdir.c_str());
2090 } // end of directory check
2091 } else { // stat failed
2092 fprintf(stderr,
2093 i18n->
2094 getMessage(FBNLS::ScreenSet, FBNLS::ScreenSTYLESDIRErrorNoExist,
2095 "BScreen::parseMenuFile: [stylesdir/stylesmenu]"
2096 " error, %s does not exist\n"), stylesdir.c_str());
2097 } // end of stat
2098 2081
2099} 2082}
2100 2083