[LP:#1168858] Nautilus window opens behind current window

This commit is contained in:
Calum Lind 2014-08-09 00:47:09 +01:00
parent 98dcc3f26e
commit 8bdf1e9044
3 changed files with 13 additions and 4 deletions

View File

@ -231,12 +231,14 @@ def get_pixmap(fname):
return pkg_resources.resource_filename("deluge", os.path.join("data", \ return pkg_resources.resource_filename("deluge", os.path.join("data", \
"pixmaps", fname)) "pixmaps", fname))
def open_file(path): def open_file(path, timestamp=None):
""" """
Opens a file or folder using the system configured program Opens a file or folder using the system configured program
:param path: the path to the file or folder to open :param path: the path to the file or folder to open
:type path: string :type path: string
:param timestamp: the timestamp of the event that requested to open
:type timestamp: int
""" """
if windows_check(): if windows_check():
@ -244,7 +246,12 @@ def open_file(path):
elif osx_check(): elif osx_check():
subprocess.Popen(["open", "%s" % path]) subprocess.Popen(["open", "%s" % path])
else: else:
subprocess.Popen(["xdg-open", "%s" % path]) if timestamp is None:
timestamp = int(time.time())
env = os.environ.copy()
env["DESKTOP_STARTUP_ID"] = "%s-%u-%s-xdg_open_TIME%d" % \
(os.path.basename(sys.argv[0]), os.getpid(), os.uname()[1], timestamp)
subprocess.Popen(["xdg-open", "%s" % path], env=env)
def open_url_in_browser(url): def open_url_in_browser(url):
""" """

View File

@ -361,7 +361,8 @@ class FilesTab(Tab):
path = self.get_file_path(select).split("/") path = self.get_file_path(select).split("/")
filepath = os.path.join(status["save_path"], *path) filepath = os.path.join(status["save_path"], *path)
log.debug("Open file '%s'", filepath) log.debug("Open file '%s'", filepath)
deluge.common.open_file(filepath) timestamp = gtk.get_current_event_time()
deluge.common.open_file(filepath, timestamp=timestamp)
## The following 3 methods create the folder/file view in the treeview ## The following 3 methods create the folder/file view in the treeview
def prepare_file_store(self, files): def prepare_file_store(self, files):

View File

@ -307,7 +307,8 @@ class MenuBar(component.Component):
def on_menuitem_open_folder_activate(self, data=None): def on_menuitem_open_folder_activate(self, data=None):
log.debug("on_menuitem_open_folder") log.debug("on_menuitem_open_folder")
def _on_torrent_status(status): def _on_torrent_status(status):
deluge.common.open_file(status["save_path"]) timestamp = gtk.get_current_event_time()
deluge.common.open_file(status["save_path"], timestamp=timestamp)
for torrent_id in component.get("TorrentView").get_selected_torrents(): for torrent_id in component.get("TorrentView").get_selected_torrents():
component.get("SessionProxy").get_torrent_status(torrent_id, ["save_path"]).addCallback(_on_torrent_status) component.get("SessionProxy").get_torrent_status(torrent_id, ["save_path"]).addCallback(_on_torrent_status)