started to fill in the application item
authormishas <mikhail.sobolev@gmail.com>
Fri, 21 Sep 2007 13:10:20 +0000 (13:10 +0000)
committermishas <mikhail.sobolev@gmail.com>
Fri, 21 Sep 2007 13:10:20 +0000 (13:10 +0000)
git-svn-id: file:///svnroot/simple-launcher/trunk@237 3ba93dab-e023-0410-b42a-de7732cf370a

misc/ApplicationItem.cc
misc/ApplicationItem.h

index d2d2c2f..3052a1f 100644 (file)
@@ -34,3 +34,39 @@ ApplicationItem::ApplicationItem(const std::string& itemID): BasicItem(factory.f
 
 ApplicationItem::~ApplicationItem() {
 }
+
+bool ApplicationItem::load() {
+  GKeyFileWrapper key_file;
+
+  for (;;) {
+    if (!key_file.load(myID)) {
+      break;
+    }
+
+    if (key_file.getString(DESKTOP_ENTRY_GROUP, DESKTOP_ENTRY_TYPE_FIELD) != "Application") {
+      break;
+    }
+
+    myName = key_file.getLocaleString(DESKTOP_ENTRY_GROUP, DESKTOP_ENTRY_NAME_FIELD);
+    myComment = key_file.getLocaleString(DESKTOP_ENTRY_GROUP, DESKTOP_ENTRY_COMMENT_FIELD);
+    myIcon = key_file.getString(DESKTOP_ENTRY_GROUP, DESKTOP_ENTRY_ICON_FIELD);
+    myService = key_file.getString(DESKTOP_ENTRY_GROUP, DESKTOP_ENTRY_SERVICE_FIELD);
+    myExec = key_file.getString(DESKTOP_ENTRY_GROUP, DESKTOP_ENTRY_EXEC_FIELD);
+    myTextDomain = key_file.getString(DESKTOP_ENTRY_GROUP, DESKTOP_ENTRY_TEXT_DOMAIN);
+
+    break;
+  }
+
+  return (myEnabled = checkSanity());
+}
+
+void ApplicationItem::activate(osso_context_t *context) {
+  bool result = false;
+
+  if (myService.empty() || !(result = osso_rpc_run_with_defaults(context, myService.c_str(), "top_application", NULL, DBUS_TYPE_INVALID) == OSSO_OK)) {
+    runApplication(getExec());
+    return true;
+  } else {
+    return result;
+  }
+}
index 695715a..de78bac 100644 (file)
@@ -36,13 +36,17 @@ protected:
   ApplicationItem(const std::string& itemID);
  ~ApplicationItem();
 
+  bool load();
+
   std::string getName() const;
   std::string getComment() const;
   GdkPixbuf *getIcon(int iconSize) const;
 
-  void activate();
+  bool isSane() const { return !myID.empty() && (!myService.empty() || !myExec.empty()); }
 
-  bool isSane() const;
+  void activate(osso_context_t *);
+private:
+  std::string myService, myExec;
 };
 
 #endif