* store the file name for later re-use
authormishas <mikhail.sobolev@gmail.com>
Mon, 12 Mar 2007 16:32:51 +0000 (16:32 +0000)
committermishas <mikhail.sobolev@gmail.com>
Mon, 12 Mar 2007 16:32:51 +0000 (16:32 +0000)
 * perform better check on enabling/toggling launcher-items

git-svn-id: file:///svnroot/simple-launcher/trunk@71 3ba93dab-e023-0410-b42a-de7732cf370a

launcher-item.cc
launcher-item.h

index afc24cf..896d440 100644 (file)
@@ -94,6 +94,8 @@ bool LauncherItem::load(const std::string& filename) {
   GKeyFileWrapper key_file;
 
   for (;;) {
+    myFileName = filename;
+
     if (!key_file.load(filename)) {
       break;
     }
@@ -110,7 +112,7 @@ bool LauncherItem::load(const std::string& filename) {
     break;
   }
 
-  return !(myName.empty() || myIcon.empty() || myService.empty());
+  return (myEnabled = checkSanity());
 }
 
 GdkPixbuf *LauncherItem::getIcon(int icon_size) const {
index 0d32405..39cc896 100644 (file)
@@ -33,18 +33,28 @@ public:
 
   GdkPixbuf *getIcon(int icon_size) const;
 
+  const std::string& getFileName() const { return myFileName; }
   const std::string& getName() const { return myName; }
   const std::string& getComment() const { return myComment; }
   const std::string& getService() const { return myService; }
 
   bool isEnabled(void) const { return myEnabled; }
 
-  void enable() { myEnabled = true; }
+  void enable() { myEnabled = checkSanity(); }
   void disable() { myEnabled = false; }
-  void toggle() { myEnabled = !myEnabled; }
+  void toggle() {
+    if (myEnabled) {
+      disable();
+    } else {
+      enable();
+    }
+  }
 
 private:
-  std::string myName, myComment, myIcon, myService;
+  bool checkSanity(void) { return !(myName.empty() || myIcon.empty() || myService.empty()); }
+
+private:
+  std::string myFileName, myName, myComment, myIcon, myService;
   bool myEnabled;
 
   static GtkIconTheme *ourTheme;