diff options
author | Francesco Marella <francesco.marella@gmail.com> | 2010-06-22 12:46:45 +0200 |
---|---|---|
committer | Francesco Marella <francesco.marella@gmail.com> | 2010-06-22 12:46:45 +0200 |
commit | c9b0abf61022d55866bba65302708dfda65a57d1 (patch) | |
tree | b712e1f09749cad6f1ed83042239ec44ab9ca2b1 /src/gtk-redshift | |
parent | Rebase on trunk and add the missing bits to rsappindicator.py (diff) | |
download | redshift-ng-c9b0abf61022d55866bba65302708dfda65a57d1.tar.gz redshift-ng-c9b0abf61022d55866bba65302708dfda65a57d1.tar.bz2 redshift-ng-c9b0abf61022d55866bba65302708dfda65a57d1.tar.xz |
Disable autostart menu item when the desktop file can't be found
Diffstat (limited to 'src/gtk-redshift')
-rw-r--r-- | src/gtk-redshift/rsappindicator.py | 12 | ||||
-rw-r--r-- | src/gtk-redshift/statusicon.py | 12 | ||||
-rw-r--r-- | src/gtk-redshift/utils.py | 4 |
3 files changed, 20 insertions, 8 deletions
diff --git a/src/gtk-redshift/rsappindicator.py b/src/gtk-redshift/rsappindicator.py index 15a2dee..23f1ac8 100644 --- a/src/gtk-redshift/rsappindicator.py +++ b/src/gtk-redshift/rsappindicator.py @@ -76,9 +76,15 @@ def run(): status_menu.append(toggle_item) autostart_item = gtk.CheckMenuItem(_('Autostart')) - autostart_item.set_active(utils.get_autostart()) - autostart_item.connect('activate', autostart_cb) - status_menu.append(autostart_item) + try: + autostart_item.set_active(utils.get_autostart()) + except IOError as strerror: + print strerror + autostart_item.set_property('sensitive', False) + else: + autostart_item.connect('activate', autostart_cb) + finally: + status_menu.append(autostart_item) quit_item = gtk.ImageMenuItem(gtk.STOCK_QUIT) quit_item.connect('activate', destroy_cb) diff --git a/src/gtk-redshift/statusicon.py b/src/gtk-redshift/statusicon.py index 24f02da..8019ad4 100644 --- a/src/gtk-redshift/statusicon.py +++ b/src/gtk-redshift/statusicon.py @@ -67,9 +67,15 @@ def run(): status_menu.append(toggle_item) autostart_item = gtk.CheckMenuItem(_('Autostart')) - autostart_item.set_active(utils.get_autostart()) - autostart_item.connect('activate', autostart_cb) - status_menu.append(autostart_item) + try: + autostart_item.set_active(utils.get_autostart()) + except IOError as strerror: + print strerror + autostart_item.set_property('sensitive', False) + else: + autostart_item.connect('activate', autostart_cb) + finally: + status_menu.append(autostart_item) quit_item = gtk.ImageMenuItem(gtk.STOCK_QUIT) quit_item.connect('activate', destroy_cb) diff --git a/src/gtk-redshift/utils.py b/src/gtk-redshift/utils.py index 5c63a02..0344406 100644 --- a/src/gtk-redshift/utils.py +++ b/src/gtk-redshift/utils.py @@ -28,7 +28,7 @@ def get_autostart(): autostart_dir = base.save_config_path("autostart") autostart_file = os.path.join(autostart_dir, REDSHIFT_DESKTOP) if not os.path.exists(autostart_file): - return False + raise IOError("Installed redshift desktop file not found!") else: dfile = desktop.DesktopEntry(autostart_file) if dfile.get(AUTOSTART_KEY) == 'false': @@ -44,7 +44,7 @@ def set_autostart(active): desktop_files = list(base.load_data_paths("applications", REDSHIFT_DESKTOP)) if not desktop_files: - print "Error: Installed redshift desktop file not found!" + raise IOError("Installed redshift desktop file not found!") return desktop_file_path = desktop_files[0] # Read installed file and modify it |