From 57b594041a5c6b7a8e8d0ccfd8fda4d6d643a698 Mon Sep 17 00:00:00 2001 From: Calum Lind Date: Mon, 25 Aug 2014 00:09:58 +0100 Subject: [PATCH] [#2493] [GTKUI] Fix TypeError if active workspace is None --- deluge/ui/gtkui/mainwindow.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/deluge/ui/gtkui/mainwindow.py b/deluge/ui/gtkui/mainwindow.py index e6e72517a..27878fd2b 100644 --- a/deluge/ui/gtkui/mainwindow.py +++ b/deluge/ui/gtkui/mainwindow.py @@ -330,9 +330,17 @@ class MainWindow(component.Component): Notification().notify(torrent_id) def is_on_active_workspace(self): - # Returns True if mainwindow is on active workspace or wnck module not available + """Determines if MainWindow is on the active workspace. + + Returns: + bool: True if on active workspace (or wnck module not available), otherwise False. + + """ if not wnck: return True - for win in self.screen.get_windows(): - if win.get_xid() == self.window.window.xid: - return win.is_on_workspace(win.get_screen().get_active_workspace()) + win = wnck.window_get(self.window.window.xid) + active_wksp = win.get_screen().get_active_workspace() + if active_wksp: + return win.is_on_workspace(active_wksp) + else: + return False