Properly handle apps without an icon or with an invalid one and fallback to blue.
authorStefanos Harhalakis <v13@v13.gr>
Sun, 18 Jul 2010 08:40:40 +0000 (08:40 +0000)
committerStefanos Harhalakis <v13@v13.gr>
Sun, 18 Jul 2010 08:40:40 +0000 (08:40 +0000)
v0.4

setup.py
src/config.py
src/icon.py

index d440b73..fdb9e2c 100755 (executable)
--- a/setup.py
+++ b/setup.py
@@ -24,7 +24,7 @@ from distutils.core import setup
 
 setup(
     name='drlaunch',
-    version="0.3",
+    version="0.4",
     description="DrLaunch",
     author="Stefanos Harhalakis",
     author_email="v13@v13.gr",
index a7520af..6250eaf 100755 (executable)
@@ -25,7 +25,7 @@ __version__ = "$Id: 0.py 2265 2010-02-21 19:16:26Z v13 $"
 import os
 import pickle
 
-version = "0.3"
+version = "0.4"
 
 try:
     from glib import get_user_config_dir
index 69f3b04..aafe320 100755 (executable)
@@ -39,8 +39,24 @@ from xdg.IconTheme import getIconPath
 #import config
 import apps
 
+# Load an icon
+# Fall-back to default/blue if not found or name==None
 def getIcon(name, iconsize):
-    ico=getIconPath(name, iconsize)
+    # Default icon
+    idef='tasklaunch_default_application'
+
+    # If name==None then use the default icon
+    if name==None or name=='':
+       iname=idef
+    else:
+       iname=name
+
+    ico=getIconPath(iname, iconsize)
+
+    # If not found then use the default icon
+    if ico==None:
+       ico=getIconPath(idef, iconsize)
+
     ret=gtk.gdk.pixbuf_new_from_file_at_size(ico, iconsize, iconsize)
 
     return(ret)