current profile icon
authorstack <stack@inventati.org>
Mon, 9 Jul 2012 00:16:13 +0000 (02:16 +0200)
committerstack <stack@inventati.org>
Mon, 9 Jul 2012 00:16:13 +0000 (02:16 +0200)
current-profile.png [new file with mode: 0644]
gui.py
profhandler.py
settings.py

diff --git a/current-profile.png b/current-profile.png
new file mode 100644 (file)
index 0000000..bc316c1
Binary files /dev/null and b/current-profile.png differ
diff --git a/gui.py b/gui.py
index a54d423..7b7fd57 100755 (executable)
--- a/gui.py
+++ b/gui.py
@@ -33,7 +33,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 """
 import sys
 import os
 """
 import sys
 import os
-from PyQt4 import QtGui
+from PyQt4 import QtGui, QtCore
 from PyQt4.QtCore import SIGNAL
 from qmenutooltip import QMenuToolTip
 
 from PyQt4.QtCore import SIGNAL
 from qmenutooltip import QMenuToolTip
 
@@ -91,7 +91,7 @@ class Gui(QtGui.QDialog):
 
         #profile manager component
         self.addProfile = QtGui.QAction("  Add &Profile  ", self,
 
         #profile manager component
         self.addProfile = QtGui.QAction("  Add &Profile  ", self,
-                triggered=self.addProfile, icon=QtGui.QIcon(appconf.icon))
+                triggered=self.addProfile)
 
 
     def createTrayIcon(self):
 
 
     def createTrayIcon(self):
@@ -120,15 +120,18 @@ class Gui(QtGui.QDialog):
         if reason in (QtGui.QSystemTrayIcon.Trigger, QtGui.QSystemTrayIcon.DoubleClick):
             self.menuProfiles = QMenuToolTip()
             self.menuProfiles.setTitle("Profiles")
         if reason in (QtGui.QSystemTrayIcon.Trigger, QtGui.QSystemTrayIcon.DoubleClick):
             self.menuProfiles = QMenuToolTip()
             self.menuProfiles.setTitle("Profiles")
+            QtCore.QCoreApplication.setAttribute(QtCore.Qt.AA_DontShowIconsInMenus, False)
 
             #Get profiles from the ProfHandler embedded in the gui
             profiles = self.profileManager.getProfilesList()
 
 
             #Get profiles from the ProfHandler embedded in the gui
             profiles = self.profileManager.getProfilesList()
 
-            for pr in profiles:
-                #pr is a profile path
-                receiver = self.activateProfileAction(pr)
-                pr = os.path.basename(pr)
+            for prpath in profiles:
+                pr = os.path.basename(prpath)
+                receiver = self.activateProfileAction(prpath)
                 menuItem_Profile = self.menuProfiles.addAction(pr)
                 menuItem_Profile = self.menuProfiles.addAction(pr)
+                if self.profileManager.isCurrentProfile(prpath):
+                    menuItem_Profile.setIcon(QtGui.QIcon(appconf.cpicon))
+                 
                 #Using lambda function to pass additional arguments to the function, in this case the path of the profile
                 self.connect(menuItem_Profile, SIGNAL('triggered()'), receiver)
                 #set menu item ToolTip
                 #Using lambda function to pass additional arguments to the function, in this case the path of the profile
                 self.connect(menuItem_Profile, SIGNAL('triggered()'), receiver)
                 #set menu item ToolTip
index 19a6b97..d0fbb17 100755 (executable)
@@ -111,7 +111,18 @@ class ProfHandler():
             raise AppError('Profile Name not valid')
         print("Profile "+profileName+" created.")
 
             raise AppError('Profile Name not valid')
         print("Profile "+profileName+" created.")
 
+    def isCurrentProfile(self, ppath):
+        """ Returns true if the current profile path is currently activated """
+        
+        pl = platform.system()
+        if pl in ('Linux','Darwin'):
+            if os.path.exists(self.getDropboxDirectory()):
+                return True if os.readlink(self.getDropboxDirectory()) == ppath else False
+            else:
+                return False
+
     def isValidProfileName(self, pname):
     def isValidProfileName(self, pname):
+
         if self.reg.match(pname) is not None:
             return True
         else:
         if self.reg.match(pname) is not None:
             return True
         else:
index b9fb468..38859e7 100644 (file)
@@ -38,6 +38,7 @@ class Settings():
         self.appname = "dboxswitch"
         self.appversion = "0.1"
         self.icon    = "./icon.png"
         self.appname = "dboxswitch"
         self.appversion = "0.1"
         self.icon    = "./icon.png"
+        self.cpicon  = "./current-profile.png"
 
 global conf
 appconf = Settings()
 
 global conf
 appconf = Settings()