From 92a048625ada379c8965e2f85344a05a7c47fa68 Mon Sep 17 00:00:00 2001 From: Calum Lind Date: Mon, 17 Sep 2018 15:54:08 +0100 Subject: [PATCH] [GTK3] Fix the transient parent for PathChooser The filechooser dialog was wrongly transient to the main window causing weird behaviour, namely the main window moving but dialog remaining in place when attempting to move the child dialog. The solution is to pass the parent dialog to PathChooser so it can be properly set the filechooser dialog transient property. Fixed the Preferences dialog not being set to be modal to main window. --- deluge/ui/gtk3/addtorrentdialog.py | 6 ++++-- deluge/ui/gtk3/glade/preferences_dialog.ui | 1 + deluge/ui/gtk3/menubar.py | 4 +++- deluge/ui/gtk3/options_tab.py | 4 +++- deluge/ui/gtk3/path_chooser.py | 4 ++-- deluge/ui/gtk3/path_combo_chooser.py | 12 ++++++++---- deluge/ui/gtk3/preferences.py | 8 +++++--- 7 files changed, 26 insertions(+), 13 deletions(-) diff --git a/deluge/ui/gtk3/addtorrentdialog.py b/deluge/ui/gtk3/addtorrentdialog.py index c6751f772..b9ce00934 100644 --- a/deluge/ui/gtk3/addtorrentdialog.py +++ b/deluge/ui/gtk3/addtorrentdialog.py @@ -420,7 +420,9 @@ class AddTorrentDialog(component.Component): self.move_completed_hbox = self.builder.get_object( 'hbox_move_completed_chooser' ) - self.move_completed_path_chooser = PathChooser('move_completed_paths_list') + self.move_completed_path_chooser = PathChooser( + 'move_completed_paths_list', parent=self.dialog + ) self.move_completed_hbox.add(self.move_completed_path_chooser) self.move_completed_hbox.show_all() @@ -429,7 +431,7 @@ class AddTorrentDialog(component.Component): 'hbox_download_location_chooser' ) self.download_location_path_chooser = PathChooser( - 'download_location_paths_list' + 'download_location_paths_list', parent=self.dialog ) self.download_location_hbox.add(self.download_location_path_chooser) self.download_location_hbox.show_all() diff --git a/deluge/ui/gtk3/glade/preferences_dialog.ui b/deluge/ui/gtk3/glade/preferences_dialog.ui index ae28d7457..48b37a9ed 100644 --- a/deluge/ui/gtk3/glade/preferences_dialog.ui +++ b/deluge/ui/gtk3/glade/preferences_dialog.ui @@ -237,6 +237,7 @@ False 5 Preferences + True center-on-parent 450 500 diff --git a/deluge/ui/gtk3/menubar.py b/deluge/ui/gtk3/menubar.py index a79c342e3..84d00c82e 100644 --- a/deluge/ui/gtk3/menubar.py +++ b/deluge/ui/gtk3/menubar.py @@ -343,7 +343,9 @@ class MenuBar(component.Component): self.move_storage_dialog = builder.get_object('move_storage_dialog') self.move_storage_dialog.set_transient_for(self.mainwindow.window) self.move_storage_dialog_hbox = builder.get_object('hbox_entry') - self.move_storage_path_chooser = PathChooser('move_completed_paths_list') + self.move_storage_path_chooser = PathChooser( + 'move_completed_paths_list', self.move_storage_dialog + ) self.move_storage_dialog_hbox.add(self.move_storage_path_chooser) self.move_storage_dialog_hbox.show_all() self.move_storage_path_chooser.set_text(status['download_location']) diff --git a/deluge/ui/gtk3/options_tab.py b/deluge/ui/gtk3/options_tab.py index d088ef429..6a25fd1e8 100644 --- a/deluge/ui/gtk3/options_tab.py +++ b/deluge/ui/gtk3/options_tab.py @@ -58,7 +58,9 @@ class OptionsTab(Tab): self.button_apply = self.main_builder.get_object('button_apply') - self.move_completed_path_chooser = PathChooser('move_completed_paths_list') + self.move_completed_path_chooser = PathChooser( + 'move_completed_paths_list', parent=component.get('MainWindow').window + ) self.move_completed_path_chooser.set_sensitive( self.tab_widgets['chk_move_completed'].obj.get_active() ) diff --git a/deluge/ui/gtk3/path_chooser.py b/deluge/ui/gtk3/path_chooser.py index 798a02a7d..4a3e7d64b 100644 --- a/deluge/ui/gtk3/path_chooser.py +++ b/deluge/ui/gtk3/path_chooser.py @@ -123,9 +123,9 @@ class PathChoosersHandler(component.Component): class PathChooser(PathChooserComboBox): - def __init__(self, paths_config_key=None): + def __init__(self, paths_config_key=None, parent=None): self.paths_config_key = paths_config_key - super(PathChooser, self).__init__() + super(PathChooser, self).__init__(parent=parent) self.chooser_handler = PathChoosersHandler() self.chooser_handler.register_chooser(self) self.set_auto_completer_func(self.on_completion) diff --git a/deluge/ui/gtk3/path_combo_chooser.py b/deluge/ui/gtk3/path_combo_chooser.py index a2c374353..172560749 100755 --- a/deluge/ui/gtk3/path_combo_chooser.py +++ b/deluge/ui/gtk3/path_combo_chooser.py @@ -18,7 +18,6 @@ from gi.module import get_introspection_module from gi.repository import Gdk, GObject, Gtk from gi.repository.GObject import SignalFlags -import deluge.component as component from deluge.common import PY2, resource_filename from deluge.path_chooser_common import get_completion_paths @@ -1130,7 +1129,11 @@ class PathChooserComboBox(GtkGI.Box, StoredValuesPopup, GObject.GObject): } def __init__( - self, max_visible_rows=20, auto_complete=True, use_completer_popup=True + self, + max_visible_rows=20, + auto_complete=True, + use_completer_popup=True, + parent=None, ): GtkGI.Box.__init__(self) GObject.GObject.__init__(self) @@ -1143,6 +1146,7 @@ class PathChooserComboBox(GtkGI.Box, StoredValuesPopup, GObject.GObject): self.show_folder_name_on_button = False self.setting_accelerator_key = False self.builder = Gtk.Builder() + self.parent = parent self.popup_buttonbox = self.builder.get_object('buttonbox') self.builder.add_from_file( resource_filename( @@ -1156,7 +1160,7 @@ class PathChooserComboBox(GtkGI.Box, StoredValuesPopup, GObject.GObject): ) self.filechooser_button = self.open_filechooser_dialog_button self.filechooserdialog = self.builder.get_object('filechooserdialog') - self.filechooserdialog.set_transient_for(component.get('MainWindow').window) + self.filechooserdialog.set_transient_for(self.parent) self.filechooser_widget = self.builder.get_object('filechooser_widget') self.folder_name_label = self.builder.get_object('folder_name_label') self.default_text = None @@ -1550,7 +1554,7 @@ class PathChooserComboBox(GtkGI.Box, StoredValuesPopup, GObject.GObject): self.show_folder_name_on_button_checkbutton = self.builder.get_object( 'show_folder_name_on_button_checkbutton' ) - self.config_dialog.set_transient_for(component.get('MainWindow').window) + self.config_dialog.set_transient_for(self.parent) def on_close(widget, event=None): if not self.setting_accelerator_key: diff --git a/deluge/ui/gtk3/preferences.py b/deluge/ui/gtk3/preferences.py index d3a1c77b7..6333ae26e 100644 --- a/deluge/ui/gtk3/preferences.py +++ b/deluge/ui/gtk3/preferences.py @@ -189,7 +189,7 @@ class Preferences(component.Component): 'hbox_download_to_path_chooser' ) self.download_location_path_chooser = PathChooser( - 'download_location_paths_list' + 'download_location_paths_list', parent=self.pref_dialog ) self.download_location_hbox.add(self.download_location_path_chooser) self.download_location_hbox.show_all() @@ -197,7 +197,9 @@ class Preferences(component.Component): self.move_completed_hbox = self.builder.get_object( 'hbox_move_completed_to_path_chooser' ) - self.move_completed_path_chooser = PathChooser('move_completed_paths_list') + self.move_completed_path_chooser = PathChooser( + 'move_completed_paths_list', parent=self.pref_dialog + ) self.move_completed_hbox.add(self.move_completed_path_chooser) self.move_completed_hbox.show_all() @@ -205,7 +207,7 @@ class Preferences(component.Component): 'hbox_copy_torrent_files_path_chooser' ) self.copy_torrent_files_path_chooser = PathChooser( - 'copy_torrent_files_to_paths_list' + 'copy_torrent_files_to_paths_list', parent=self.pref_dialog ) self.copy_torrents_to_hbox.add(self.copy_torrent_files_path_chooser) self.copy_torrents_to_hbox.show_all()