implemented directory reading; next step is testing :)
authormishas <mikhail.sobolev@gmail.com>
Wed, 14 Mar 2007 19:45:35 +0000 (19:45 +0000)
committermishas <mikhail.sobolev@gmail.com>
Wed, 14 Mar 2007 19:45:35 +0000 (19:45 +0000)
git-svn-id: file:///svnroot/simple-launcher/trunk@82 3ba93dab-e023-0410-b42a-de7732cf370a

simple-launcher.cc

index ceddd7c..b9c894c 100644 (file)
@@ -19,6 +19,8 @@
 #include <vector>
 #include <fstream>
 
+#include <dirent.h>
+
 #include <gtk/gtk.h>
 
 #include <hildon-home-plugin/hildon-home-plugin-interface.h>
@@ -210,6 +212,27 @@ void SimpleLauncherApplet::saveConfig() {
 }
 
 void SimpleLauncherApplet::processDirectory(const std::string& dirname) {
+  DIR *dir = opendir(dirname.c_str());
+
+  if (dir != NULL) {
+    const std::string namePrefix = dirname + "/";
+    std::string shortName;
+    std::string desktopExtension = ".desktop";
+    const dirent *file;
+
+    while ((file = readdir(dir)) != 0) {
+      shortName = file->d_name;
+      if ((shortName == ".") || (shortName == "..")) {
+        continue;
+      }
+
+      if ((shortName.length() >= desktopExtension.length()) && (shortName.compare(shortName.length() - desktopExtension.length(), desktopExtension.length(), desktopExtension) == 0)) {
+        addItem(namePrefix+shortName, false);
+      }
+    }
+
+    closedir(dir);
+  }
 }
 
 bool SimpleLauncherApplet::initWidget() {