From 838cef1c3608bd0c20bcbc1879395b664cbb153c Mon Sep 17 00:00:00 2001 From: Andrew Resch Date: Sat, 1 Aug 2009 00:15:05 +0000 Subject: [PATCH] Fix shutdown handler with GNOME session manager --- ChangeLog | 1 + deluge/ui/gtkui/gtkui.py | 13 +++++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3676a2a26..42f362a1f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -17,6 +17,7 @@ * Fix #518 remove header in add torrent dialog to save vertical space * Add a Cache preferences page to adjust cache settings and examine cache status * Add ability to rename files prior to adding them + * Fix shutdown handler with GNOME session manager ==== ConsoleUI ==== * Changed to use curses for a more interactive client diff --git a/deluge/ui/gtkui/gtkui.py b/deluge/ui/gtkui/gtkui.py index a5ca9d04c..ec3711a51 100644 --- a/deluge/ui/gtkui/gtkui.py +++ b/deluge/ui/gtkui/gtkui.py @@ -159,10 +159,15 @@ class GtkUI(object): # Setup signals try: import gnome.ui - self.gnome_client = gnome.ui.Client() - self.gnome_client.connect("die", gtk.main_quit) - except: - pass + import gnome + self.gnome_prog = gnome.init("Deluge", deluge.common.get_version()) + self.gnome_client = gnome.ui.master_client() + def on_die(*args): + gtk.main_quit() + self.gnome_client.connect("die", on_die) + log.debug("GNOME session 'die' handler registered!") + except Exception, e: + log.warning("Unable to register a 'die' handler with the GNOME session manager: %s", e) if deluge.common.windows_check(): from win32api import SetConsoleCtrlHandler