From 12365241a58ad2c6f8f19d3181a8911909da3748 Mon Sep 17 00:00:00 2001 From: Calum Lind Date: Mon, 4 Feb 2013 13:12:10 +0000 Subject: [PATCH] Fix #2260 : Add dialog pulling main window to active workspace --- deluge/ui/gtkui/addtorrentdialog.py | 6 +++++- deluge/ui/gtkui/mainwindow.py | 16 +++++++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/deluge/ui/gtkui/addtorrentdialog.py b/deluge/ui/gtkui/addtorrentdialog.py index 3d16af1e3..1bb8475ef 100644 --- a/deluge/ui/gtkui/addtorrentdialog.py +++ b/deluge/ui/gtkui/addtorrentdialog.py @@ -169,7 +169,11 @@ class AddTorrentDialog(component.Component): self.glade.get_widget("button_move_completed_location").hide() self.glade.get_widget("entry_move_completed_path").show() - self.dialog.set_transient_for(component.get("MainWindow").window) + if component.get("MainWindow").is_on_active_workspace(): + self.dialog.set_transient_for(component.get("MainWindow").window) + else: + self.dialog.set_transient_for(None) + self.dialog.present() if focus: self.dialog.window.focus() diff --git a/deluge/ui/gtkui/mainwindow.py b/deluge/ui/gtkui/mainwindow.py index b456dc16a..4606726a6 100644 --- a/deluge/ui/gtkui/mainwindow.py +++ b/deluge/ui/gtkui/mainwindow.py @@ -40,6 +40,11 @@ import gtk, gtk.glade import gobject import pkg_resources +try: + import wnck +except ImportError: + wnck = None + from deluge.ui.client import client import deluge.component as component from deluge.configmanager import ConfigManager @@ -54,6 +59,8 @@ from deluge.log import LOG as log class MainWindow(component.Component): def __init__(self): + if wnck: + self.screen = wnck.screen_get_default() component.Component.__init__(self, "MainWindow", interval=2) self.config = ConfigManager("gtkui.conf") # Get the glade file for the main window @@ -108,7 +115,6 @@ class MainWindow(component.Component): component.resume("TorrentDetails") except: pass - self.window.show() @@ -272,3 +278,11 @@ class MainWindow(component.Component): def on_torrentfinished_event(self, torrent_id): from deluge.ui.gtkui.notification import Notification Notification().notify(torrent_id) + + def is_on_active_workspace(self): + # Returns True if mainwindow is on active workspace or wnck module not available + 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())