From 86549eb3ee2e61568cb2a98fea50b9d53951aa30 Mon Sep 17 00:00:00 2001 From: Calum Lind Date: Thu, 10 Nov 2016 15:44:55 +0000 Subject: [PATCH] [GTKUI] Cleanup references to MainWindow --- deluge/ui/gtkui/connectionmanager.py | 4 +-- deluge/ui/gtkui/details_tab.py | 24 +++++++------- deluge/ui/gtkui/files_tab.py | 26 +++++++-------- deluge/ui/gtkui/filtertreeview.py | 3 +- deluge/ui/gtkui/menubar.py | 16 ++++----- deluge/ui/gtkui/menubar_osx.py | 5 ++- deluge/ui/gtkui/new_release_dialog.py | 26 +++++++-------- deluge/ui/gtkui/options_tab.py | 38 ++++++++++----------- deluge/ui/gtkui/peers_tab.py | 10 +++--- deluge/ui/gtkui/sidebar.py | 7 ++-- deluge/ui/gtkui/status_tab.py | 48 +++++++++++++++------------ deluge/ui/gtkui/statusbar.py | 4 +-- deluge/ui/gtkui/systemtray.py | 34 +++++++++---------- deluge/ui/gtkui/toolbar.py | 13 ++++---- deluge/ui/gtkui/torrentdetails.py | 9 +++-- deluge/ui/gtkui/torrentview.py | 21 ++++++------ deluge/ui/gtkui/trackers_tab.py | 16 ++++----- 17 files changed, 152 insertions(+), 152 deletions(-) diff --git a/deluge/ui/gtkui/connectionmanager.py b/deluge/ui/gtkui/connectionmanager.py index 48ae31061..ab34252b8 100644 --- a/deluge/ui/gtkui/connectionmanager.py +++ b/deluge/ui/gtkui/connectionmanager.py @@ -126,11 +126,10 @@ class ConnectionManager(component.Component): self.builder.add_from_file(resource_filename( 'deluge.ui.gtkui', os.path.join('glade', 'connection_manager.askpassword.ui') )) - self.window = component.get('MainWindow') # Setup the ConnectionManager dialog self.connection_manager = self.builder.get_object('connection_manager') - self.connection_manager.set_transient_for(self.window.window) + self.connection_manager.set_transient_for(component.get('MainWindow').window) self.connection_manager.set_icon(get_deluge_icon()) @@ -199,7 +198,6 @@ class ConnectionManager(component.Component): self.connection_manager.destroy() del self.builder - del self.window del self.connection_manager del self.liststore del self.hostlist diff --git a/deluge/ui/gtkui/details_tab.py b/deluge/ui/gtkui/details_tab.py index 0c71b3f0a..fb2516711 100644 --- a/deluge/ui/gtkui/details_tab.py +++ b/deluge/ui/gtkui/details_tab.py @@ -23,22 +23,22 @@ class DetailsTab(Tab): Tab.__init__(self) # Get the labels we need to update. # widget name, modifier function, status keys - builder = component.get('MainWindow').get_builder() + main_builder = component.get('MainWindow').get_builder() self._name = 'Details' - self._child_widget = builder.get_object('details_tab') - self._tab_label = builder.get_object('details_tab_label') + self._child_widget = main_builder.get_object('details_tab') + self._tab_label = main_builder.get_object('details_tab_label') self.label_widgets = [ - (builder.get_object('summary_name'), None, ('name',)), - (builder.get_object('summary_total_size'), fsize, ('total_size',)), - (builder.get_object('summary_num_files'), str, ('num_files',)), - (builder.get_object('summary_completed'), fdate_or_dash, ('completed_time',)), - (builder.get_object('summary_date_added'), fdate, ('time_added',)), - (builder.get_object('summary_torrent_path'), None, ('download_location',)), - (builder.get_object('summary_hash'), str, ('hash',)), - (builder.get_object('summary_comments'), str, ('comment',)), - (builder.get_object('summary_pieces'), fpieces_num_size, ('num_pieces', 'piece_length')), + (main_builder.get_object('summary_name'), None, ('name',)), + (main_builder.get_object('summary_total_size'), fsize, ('total_size',)), + (main_builder.get_object('summary_num_files'), str, ('num_files',)), + (main_builder.get_object('summary_completed'), fdate_or_dash, ('completed_time',)), + (main_builder.get_object('summary_date_added'), fdate, ('time_added',)), + (main_builder.get_object('summary_torrent_path'), None, ('download_location',)), + (main_builder.get_object('summary_hash'), str, ('hash',)), + (main_builder.get_object('summary_comments'), str, ('comment',)), + (main_builder.get_object('summary_pieces'), fpieces_num_size, ('num_pieces', 'piece_length')), ] self.status_keys = [status for widget in self.label_widgets for status in widget[2]] diff --git a/deluge/ui/gtkui/files_tab.py b/deluge/ui/gtkui/files_tab.py index 29a734ba8..fec67a107 100644 --- a/deluge/ui/gtkui/files_tab.py +++ b/deluge/ui/gtkui/files_tab.py @@ -89,13 +89,13 @@ def cell_progress(column, cell, model, row, data): class FilesTab(Tab): def __init__(self): Tab.__init__(self) - builder = component.get('MainWindow').get_builder() + main_builder = component.get('MainWindow').get_builder() self._name = 'Files' - self._child_widget = builder.get_object('files_tab') - self._tab_label = builder.get_object('files_tab_label') + self._child_widget = main_builder.get_object('files_tab') + self._tab_label = main_builder.get_object('files_tab_label') - self.listview = builder.get_object('files_listview') + self.listview = main_builder.get_object('files_listview') # filename, size, progress string, progress value, priority, file index, icon id self.treestore = gtk.TreeStore(str, TYPE_UINT64, str, float, int, int, str) self.treestore.set_sort_column_id(0, gtk.SORT_ASCENDING) @@ -173,19 +173,19 @@ class FilesTab(Tab): self.listview.get_selection().set_mode(gtk.SELECTION_MULTIPLE) - self.file_menu = builder.get_object('menu_file_tab') + self.file_menu = main_builder.get_object('menu_file_tab') self.file_menu_priority_items = [ - builder.get_object('menuitem_donotdownload'), - builder.get_object('menuitem_normal'), - builder.get_object('menuitem_high'), - builder.get_object('menuitem_highest'), - builder.get_object('menuitem_priority_sep') + main_builder.get_object('menuitem_donotdownload'), + main_builder.get_object('menuitem_normal'), + main_builder.get_object('menuitem_high'), + main_builder.get_object('menuitem_highest'), + main_builder.get_object('menuitem_priority_sep') ] self.localhost_widgets = [ - builder.get_object('menuitem_open_file'), - builder.get_object('menuitem_show_file'), - builder.get_object('menuitem3') + main_builder.get_object('menuitem_open_file'), + main_builder.get_object('menuitem_show_file'), + main_builder.get_object('menuitem3') ] self.listview.connect('row-activated', self._on_row_activated) diff --git a/deluge/ui/gtkui/filtertreeview.py b/deluge/ui/gtkui/filtertreeview.py index f257f3556..538f2a0e3 100644 --- a/deluge/ui/gtkui/filtertreeview.py +++ b/deluge/ui/gtkui/filtertreeview.py @@ -48,7 +48,6 @@ FILTER_COLUMN = 5 class FilterTreeView(component.Component): def __init__(self): component.Component.__init__(self, 'FilterTreeView', interval=2) - self.window = component.get('MainWindow') self.config = ConfigManager('gtkui.conf') self.tracker_icons = component.get('TrackerIcons') @@ -99,7 +98,7 @@ class FilterTreeView(component.Component): self.treeview.connect('button-press-event', self.on_button_press_event) # colors using current theme. - style = self.window.window.get_style() + style = component.get('MainWindow').window.get_style() self.colour_background = style.bg[gtk.STATE_NORMAL] self.colour_foreground = style.fg[gtk.STATE_NORMAL] diff --git a/deluge/ui/gtkui/menubar.py b/deluge/ui/gtkui/menubar.py index 62053db44..7b1b4b19c 100644 --- a/deluge/ui/gtkui/menubar.py +++ b/deluge/ui/gtkui/menubar.py @@ -29,8 +29,8 @@ class MenuBar(component.Component): def __init__(self): log.debug('MenuBar init..') component.Component.__init__(self, 'MenuBar') - self.window = component.get('MainWindow') - self.main_builder = self.window.get_builder() + self.mainwindow = component.get('MainWindow') + self.main_builder = self.mainwindow.get_builder() self.config = ConfigManager('gtkui.conf') self.builder = gtk.Builder() @@ -107,7 +107,7 @@ class MenuBar(component.Component): self.main_builder.get_object('sidebar_show_owners').set_active(self.config['sidebar_show_owners']) # Connect main window Signals # - component.get('MainWindow').connect_signals({ + self.mainwindow.connect_signals({ # File Menu 'on_menuitem_addtorrent_activate': self.on_menuitem_addtorrent_activate, 'on_menuitem_createtorrent_activate': self.on_menuitem_createtorrent_activate, @@ -249,11 +249,11 @@ class MenuBar(component.Component): def on_menuitem_quitdaemon_activate(self, data=None): log.debug('on_menuitem_quitdaemon_activate') - self.window.quit(shutdown=True) + self.mainwindow.quit(shutdown=True) def on_menuitem_quit_activate(self, data=None): log.debug('on_menuitem_quit_activate') - self.window.quit() + self.mainwindow.quit() # Edit Menu # def on_menuitem_preferences_activate(self, data=None): @@ -285,7 +285,7 @@ class MenuBar(component.Component): from deluge.ui.gtkui.edittrackersdialog import EditTrackersDialog dialog = EditTrackersDialog( component.get('TorrentView').get_selected_torrent(), - component.get('MainWindow').window) + self.mainwindow.window) dialog.run() def on_menuitem_remove_activate(self, data=None): @@ -326,7 +326,7 @@ class MenuBar(component.Component): # Keep it referenced: # https://bugzilla.gnome.org/show_bug.cgi?id=546802 self.move_storage_dialog = builder.get_object('move_storage_dialog') - self.move_storage_dialog.set_transient_for(self.window.window) + 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_dialog_hbox.add(self.move_storage_path_chooser) @@ -554,7 +554,7 @@ class MenuBar(component.Component): ErrorDialog( _('Ownership Change Error'), _('There was an error while trying changing ownership.'), - self.window.window, details=failure.value.logable() + self.mainwindow.window, details=failure.value.logable() ).run() client.core.set_owner( update_torrents, username).addErrback(failed_change_owner) diff --git a/deluge/ui/gtkui/menubar_osx.py b/deluge/ui/gtkui/menubar_osx.py index 7b5a6a4fe..994cdfc3e 100644 --- a/deluge/ui/gtkui/menubar_osx.py +++ b/deluge/ui/gtkui/menubar_osx.py @@ -22,10 +22,9 @@ def accel_meta(item, group, key): def menubar_osx(gtkui, osxapp): - window = gtkui.mainwindow - main_builder = window.get_builder() + main_builder = gtkui.mainwindow.get_builder() menubar = main_builder.get_object('menubar') - group = gtk.accel_groups_from_object(window.window)[0] + group = gtk.accel_groups_from_object(gtkui.mainwindow.window)[0] config = ConfigManager('gtkui.conf') diff --git a/deluge/ui/gtkui/new_release_dialog.py b/deluge/ui/gtkui/new_release_dialog.py index fd0a0c960..3de667469 100644 --- a/deluge/ui/gtkui/new_release_dialog.py +++ b/deluge/ui/gtkui/new_release_dialog.py @@ -20,31 +20,31 @@ class NewReleaseDialog(object): def show(self, available_version): self.config = ConfigManager('gtkui.conf') - builder = component.get('MainWindow').get_builder() - self.dialog = builder.get_object('new_release_dialog') + main_builder = component.get('MainWindow').get_builder() + self.dialog = main_builder.get_object('new_release_dialog') # Set the version labels if deluge.common.windows_check() or deluge.common.osx_check(): - builder.get_object('image_new_release').set_from_file( + main_builder.get_object('image_new_release').set_from_file( deluge.common.get_pixmap('deluge16.png')) else: - builder.get_object('image_new_release').set_from_icon_name('deluge', 4) - builder.get_object('label_available_version').set_text(available_version) - builder.get_object('label_client_version').set_text( + main_builder.get_object('image_new_release').set_from_icon_name('deluge', 4) + main_builder.get_object('label_available_version').set_text(available_version) + main_builder.get_object('label_client_version').set_text( deluge.common.get_version()) - self.chk_not_show_dialog = builder.get_object('chk_do_not_show_new_release') - builder.get_object('button_goto_downloads').connect( + self.chk_not_show_dialog = main_builder.get_object('chk_do_not_show_new_release') + main_builder.get_object('button_goto_downloads').connect( 'clicked', self._on_button_goto_downloads) - builder.get_object('button_close_new_release').connect( + main_builder.get_object('button_close_new_release').connect( 'clicked', self._on_button_close_new_release) if client.connected(): def on_info(version): - builder.get_object('label_server_version').set_text(version) - builder.get_object('label_server_version').show() - builder.get_object('label_server_version_text').show() + main_builder.get_object('label_server_version').set_text(version) + main_builder.get_object('label_server_version').show() + main_builder.get_object('label_server_version_text').show() if not client.is_standalone(): - builder.get_object('label_client_version_text').set_label(_('Client Version')) + main_builder.get_object('label_client_version_text').set_label(_('Client Version')) client.daemon.info().addCallback(on_info) self.dialog.show() diff --git a/deluge/ui/gtkui/options_tab.py b/deluge/ui/gtkui/options_tab.py index a17d0c9bf..0f53c6697 100644 --- a/deluge/ui/gtkui/options_tab.py +++ b/deluge/ui/gtkui/options_tab.py @@ -18,29 +18,29 @@ from deluge.ui.gtkui.torrentdetails import Tab class OptionsTab(Tab): def __init__(self): Tab.__init__(self) - builder = component.get('MainWindow').get_builder() + main_builder = component.get('MainWindow').get_builder() self._name = 'Options' - self._child_widget = builder.get_object('options_tab') - self._tab_label = builder.get_object('options_tab_label') + self._child_widget = main_builder.get_object('options_tab') + self._tab_label = main_builder.get_object('options_tab_label') - self.spin_max_download = builder.get_object('spin_max_download') - self.spin_max_upload = builder.get_object('spin_max_upload') - self.spin_max_connections = builder.get_object('spin_max_connections') - self.spin_max_upload_slots = builder.get_object('spin_max_upload_slots') - self.chk_prioritize_first_last = builder.get_object('chk_prioritize_first_last') - self.chk_sequential_download = builder.get_object('chk_sequential_download') - self.chk_auto_managed = builder.get_object('chk_auto_managed') - self.chk_stop_at_ratio = builder.get_object('chk_stop_at_ratio') - self.chk_remove_at_ratio = builder.get_object('chk_remove_at_ratio') - self.spin_stop_ratio = builder.get_object('spin_stop_ratio') - self.chk_move_completed = builder.get_object('chk_move_completed') - self.entry_move_completed = builder.get_object('entry_move_completed') - self.chk_shared = builder.get_object('chk_shared') - self.button_apply = builder.get_object('button_apply') - self.summary_owner = builder.get_object('summary_owner') + self.spin_max_download = main_builder.get_object('spin_max_download') + self.spin_max_upload = main_builder.get_object('spin_max_upload') + self.spin_max_connections = main_builder.get_object('spin_max_connections') + self.spin_max_upload_slots = main_builder.get_object('spin_max_upload_slots') + self.chk_prioritize_first_last = main_builder.get_object('chk_prioritize_first_last') + self.chk_sequential_download = main_builder.get_object('chk_sequential_download') + self.chk_auto_managed = main_builder.get_object('chk_auto_managed') + self.chk_stop_at_ratio = main_builder.get_object('chk_stop_at_ratio') + self.chk_remove_at_ratio = main_builder.get_object('chk_remove_at_ratio') + self.spin_stop_ratio = main_builder.get_object('spin_stop_ratio') + self.chk_move_completed = main_builder.get_object('chk_move_completed') + self.entry_move_completed = main_builder.get_object('entry_move_completed') + self.chk_shared = main_builder.get_object('chk_shared') + self.button_apply = main_builder.get_object('button_apply') + self.summary_owner = main_builder.get_object('summary_owner') - self.move_completed_hbox = builder.get_object('hbox_move_completed_path_chooser') + self.move_completed_hbox = main_builder.get_object('hbox_move_completed_path_chooser') self.move_completed_path_chooser = PathChooser('move_completed_paths_list') self.move_completed_path_chooser.set_sensitive(self.chk_move_completed.get_active()) self.move_completed_hbox.add(self.move_completed_path_chooser) diff --git a/deluge/ui/gtkui/peers_tab.py b/deluge/ui/gtkui/peers_tab.py index 0614b4e81..14332b7b5 100644 --- a/deluge/ui/gtkui/peers_tab.py +++ b/deluge/ui/gtkui/peers_tab.py @@ -33,17 +33,17 @@ def cell_data_progress(column, cell, model, row, data): class PeersTab(Tab): def __init__(self): Tab.__init__(self) - builder = component.get('MainWindow').get_builder() + main_builder = component.get('MainWindow').get_builder() self._name = 'Peers' - self._child_widget = builder.get_object('peers_tab') - self._tab_label = builder.get_object('peers_tab_label') - self.peer_menu = builder.get_object('menu_peer_tab') + self._child_widget = main_builder.get_object('peers_tab') + self._tab_label = main_builder.get_object('peers_tab_label') + self.peer_menu = main_builder.get_object('menu_peer_tab') component.get('MainWindow').connect_signals({ 'on_menuitem_add_peer_activate': self._on_menuitem_add_peer_activate, }) - self.listview = builder.get_object('peers_listview') + self.listview = main_builder.get_object('peers_listview') self.listview.props.has_tooltip = True self.listview.connect('button-press-event', self._on_button_press_event) self.listview.connect('query-tooltip', self._on_query_tooltip) diff --git a/deluge/ui/gtkui/sidebar.py b/deluge/ui/gtkui/sidebar.py index 7fc5db6a2..a0aeb5d87 100644 --- a/deluge/ui/gtkui/sidebar.py +++ b/deluge/ui/gtkui/sidebar.py @@ -25,10 +25,9 @@ class SideBar(component.Component): """ def __init__(self): component.Component.__init__(self, 'SideBar') - self.window = component.get('MainWindow') - builder = self.window.get_builder() - self.notebook = builder.get_object('sidebar_notebook') - self.hpaned = builder.get_object('main_window_hpaned') + main_builder = component.get('MainWindow').get_builder() + self.notebook = main_builder.get_object('sidebar_notebook') + self.hpaned = main_builder.get_object('main_window_hpaned') self.config = ConfigManager('gtkui.conf') # self.hpaned_position = self.hpaned.get_position() diff --git a/deluge/ui/gtkui/status_tab.py b/deluge/ui/gtkui/status_tab.py index 7b9d2ee61..7cee6c007 100644 --- a/deluge/ui/gtkui/status_tab.py +++ b/deluge/ui/gtkui/status_tab.py @@ -27,35 +27,38 @@ class StatusTab(Tab): Tab.__init__(self) # Get the labels we need to update. # widget name, modifier function, status keys - self.builder = builder = component.get('MainWindow').get_builder() + main_builder = component.get('MainWindow').get_builder() self._name = 'Status' - self._child_widget = builder.get_object('status_tab') - self._tab_label = builder.get_object('status_tab_label') + self._child_widget = main_builder.get_object('status_tab') + self._tab_label = main_builder.get_object('status_tab_label') self.config = ConfigManager('gtkui.conf') - self.progressbar = builder.get_object('progressbar') + self.progressbar = main_builder.get_object('progressbar') self.piecesbar = None self.piecesbar_label_widget = None self.label_widgets = [ - (builder.get_object('summary_availability'), fratio, ('distributed_copies',)), - (builder.get_object('summary_total_downloaded'), ftotal_sized, ('all_time_download', - 'total_payload_download')), - (builder.get_object('summary_total_uploaded'), ftotal_sized, ('total_uploaded', 'total_payload_upload')), - (builder.get_object('summary_download_speed'), fspeed_max, ('download_payload_rate', 'max_download_speed')), - (builder.get_object('summary_upload_speed'), fspeed_max, ('upload_payload_rate', 'max_upload_speed')), - (builder.get_object('summary_seeds'), fpeer, ('num_seeds', 'total_seeds')), - (builder.get_object('summary_peers'), fpeer, ('num_peers', 'total_peers')), - (builder.get_object('summary_eta'), ftime_or_dash, ('eta',)), - (builder.get_object('summary_share_ratio'), fratio, ('ratio',)), - (builder.get_object('summary_active_time'), ftime_or_dash, ('active_time',)), - (builder.get_object('summary_seed_time'), ftime_or_dash, ('seeding_time',)), - (builder.get_object('summary_seed_rank'), fseed_rank_or_dash, ('seed_rank', 'seeding_time')), - (builder.get_object('progressbar'), fpcnt, ('progress', 'state', 'message')), - (builder.get_object('summary_last_seen_complete'), fdate_or_never, ('last_seen_complete',)), - (builder.get_object('summary_last_active'), flast_active, ('time_since_download', - 'time_since_upload')), + (main_builder.get_object('summary_availability'), fratio, ('distributed_copies',)), + (main_builder.get_object('summary_total_downloaded'), ftotal_sized, ('all_time_download', + 'total_payload_download')), + (main_builder.get_object('summary_total_uploaded'), ftotal_sized, ('total_uploaded', + 'total_payload_upload')), + (main_builder.get_object('summary_download_speed'), fspeed_max, ('download_payload_rate', + 'max_download_speed')), + (main_builder.get_object('summary_upload_speed'), fspeed_max, ('upload_payload_rate', + 'max_upload_speed')), + (main_builder.get_object('summary_seeds'), fpeer, ('num_seeds', 'total_seeds')), + (main_builder.get_object('summary_peers'), fpeer, ('num_peers', 'total_peers')), + (main_builder.get_object('summary_eta'), ftime_or_dash, ('eta',)), + (main_builder.get_object('summary_share_ratio'), fratio, ('ratio',)), + (main_builder.get_object('summary_active_time'), ftime_or_dash, ('active_time',)), + (main_builder.get_object('summary_seed_time'), ftime_or_dash, ('seeding_time',)), + (main_builder.get_object('summary_seed_rank'), fseed_rank_or_dash, ('seed_rank', 'seeding_time')), + (main_builder.get_object('progressbar'), fpcnt, ('progress', 'state', 'message')), + (main_builder.get_object('summary_last_seen_complete'), fdate_or_never, ('last_seen_complete',)), + (main_builder.get_object('summary_last_active'), flast_active, ('time_since_download', + 'time_since_upload')), ] self.status_keys = [status for widget in self.label_widgets for status in widget[2]] @@ -112,7 +115,8 @@ class StatusTab(Tab): def show_piecesbar(self): if self.piecesbar is None: self.piecesbar = PiecesBar() - self.builder.get_object('status_progress_vbox').pack_start(self.piecesbar, False, False, 0) + main_builder = component.get('MainWindow').get_builder() + main_builder.get_object('status_progress_vbox').pack_start(self.piecesbar, False, False, 0) self.piecesbar_label_widget = (self.piecesbar, fpcnt, ('progress', 'state', 'message')) self.label_widgets.append(self.piecesbar_label_widget) self.piecesbar.show() diff --git a/deluge/ui/gtkui/statusbar.py b/deluge/ui/gtkui/statusbar.py index 033c9dff8..f88c46703 100644 --- a/deluge/ui/gtkui/statusbar.py +++ b/deluge/ui/gtkui/statusbar.py @@ -101,8 +101,8 @@ class StatusBarItem(object): class StatusBar(component.Component): def __init__(self): component.Component.__init__(self, 'StatusBar', interval=3) - self.window = component.get('MainWindow') - self.statusbar = self.window.get_builder().get_object('statusbar') + main_builder = component.get('MainWindow').get_builder() + self.statusbar = main_builder.get_object('statusbar') self.config = ConfigManager('gtkui.conf') # Status variables that are updated via callback diff --git a/deluge/ui/gtkui/systemtray.py b/deluge/ui/gtkui/systemtray.py index 97fa53c0c..c13193f9d 100644 --- a/deluge/ui/gtkui/systemtray.py +++ b/deluge/ui/gtkui/systemtray.py @@ -31,7 +31,7 @@ log = logging.getLogger(__name__) class SystemTray(component.Component): def __init__(self): component.Component.__init__(self, 'SystemTray', interval=4) - self.window = component.get('MainWindow') + self.mainwindow = component.get('MainWindow') self.config = ConfigManager('gtkui.conf') # List of widgets that need to be hidden when not connected to a host self.hide_widget_list = [ @@ -91,9 +91,9 @@ class SystemTray(component.Component): self.indicator.set_menu(self.tray_menu) # Make sure the status of the Show Window MenuItem is correct - self._sig_win_hide = self.window.window.connect('hide', self._on_window_hide) - self._sig_win_show = self.window.window.connect('show', self._on_window_show) - if self.window.visible(): + self._sig_win_hide = self.mainwindow.window.connect('hide', self._on_window_hide) + self._sig_win_show = self.mainwindow.window.connect('show', self._on_window_show) + if self.mainwindow.visible(): self.builder.get_object('menuitem_show_deluge').set_active(True) else: self.builder.get_object('menuitem_show_deluge').set_active(False) @@ -202,7 +202,7 @@ class SystemTray(component.Component): # Tool tip text not available for appindicator if appindicator and self.config['enable_appindicator']: - if self.window.visible(): + if self.mainwindow.visible(): self.builder.get_object('menuitem_show_deluge').set_active(True) else: self.builder.get_object('menuitem_show_deluge').set_active(False) @@ -264,8 +264,8 @@ class SystemTray(component.Component): app_ind_conf = self.config['enable_appindicator'] if appindicator and app_ind_conf: if hasattr(self, '_sig_win_hide'): - self.window.window.disconnect(self._sig_win_hide) - self.window.window.disconnect(self._sig_win_show) + self.mainwindow.window.disconnect(self._sig_win_hide) + self.mainwindow.window.disconnect(self._sig_win_show) log.debug('Disabling the application indicator..') self.indicator.set_status(appindicator.STATUS_PASSIVE) @@ -305,16 +305,16 @@ class SystemTray(component.Component): """Called when the tray icon is left clicked.""" self.blink(False) - if self.window.active(): - self.window.hide() + if self.mainwindow.active(): + self.mainwindow.hide() else: - self.window.present() + self.mainwindow.present() def on_tray_popup(self, status_icon, button, activate_time): """Called when the tray icon is right clicked.""" self.blink(False) - if self.window.visible(): + if self.mainwindow.visible(): self.builder.get_object('menuitem_show_deluge').set_active(True) else: self.builder.get_object('menuitem_show_deluge').set_active(False) @@ -327,10 +327,10 @@ class SystemTray(component.Component): def on_menuitem_show_deluge_activate(self, menuitem): log.debug('on_menuitem_show_deluge_activate') - if menuitem.get_active() and not self.window.visible(): - self.window.present() - elif not menuitem.get_active() and self.window.visible(): - self.window.hide() + if menuitem.get_active() and not self.mainwindow.visible(): + self.mainwindow.present() + elif not menuitem.get_active() and self.mainwindow.visible(): + self.mainwindow.hide() def on_menuitem_add_torrent_activate(self, menuitem): log.debug('on_menuitem_add_torrent_activate') @@ -346,11 +346,11 @@ class SystemTray(component.Component): def on_menuitem_quit_activate(self, menuitem): log.debug('on_menuitem_quit_activate') - self.window.quit() + self.mainwindow.quit() def on_menuitem_quitdaemon_activate(self, menuitem): log.debug('on_menuitem_quitdaemon_activate') - self.window.quit(shutdown=True) + self.mainwindow.quit(shutdown=True) def on_tray_setbwdown(self, widget, data=None): if isinstance(widget, gtk.RadioMenuItem): diff --git a/deluge/ui/gtkui/toolbar.py b/deluge/ui/gtkui/toolbar.py index a8024ca08..cd590b3a5 100644 --- a/deluge/ui/gtkui/toolbar.py +++ b/deluge/ui/gtkui/toolbar.py @@ -21,11 +21,12 @@ class ToolBar(component.Component): def __init__(self): component.Component.__init__(self, 'ToolBar') log.debug('ToolBar Init..') - self.window = component.get('MainWindow') - self.toolbar = self.window.get_builder().get_object('toolbar') + mainwindow = component.get('MainWindow') + self.main_builder = mainwindow.get_builder() + self.toolbar = self.main_builder.get_object('toolbar') self.config = ConfigManager('gtkui.conf') # Connect main window Signals # - self.window.connect_signals({ + mainwindow.connect_signals({ 'on_toolbutton_add_clicked': self.on_toolbutton_add_clicked, 'on_toolbutton_remove_clicked': self.on_toolbutton_remove_clicked, 'on_toolbutton_pause_clicked': self.on_toolbutton_pause_clicked, @@ -50,15 +51,15 @@ class ToolBar(component.Component): self.visible(self.config['show_toolbar']) def start(self): - self.window.get_builder().get_object('toolbutton_connectionmanager').set_visible( + self.main_builder.get_object('toolbutton_connectionmanager').set_visible( not self.config['standalone']) for widget in self.change_sensitivity: - self.window.get_builder().get_object(widget).set_sensitive(True) + self.main_builder.get_object(widget).set_sensitive(True) def stop(self): for widget in self.change_sensitivity: - self.window.get_builder().get_object(widget).set_sensitive(False) + self.main_builder.get_object(widget).set_sensitive(False) def visible(self, visible): if visible: diff --git a/deluge/ui/gtkui/torrentdetails.py b/deluge/ui/gtkui/torrentdetails.py index 3082659e1..646eba4f2 100644 --- a/deluge/ui/gtkui/torrentdetails.py +++ b/deluge/ui/gtkui/torrentdetails.py @@ -61,13 +61,12 @@ class Tab(object): class TorrentDetails(component.Component): def __init__(self): component.Component.__init__(self, 'TorrentDetails', interval=2) - self.window = component.get('MainWindow') - builder = self.window.get_builder() + main_builder = component.get('MainWindow').get_builder() - self.notebook = builder.get_object('torrent_info') + self.notebook = main_builder.get_object('torrent_info') # This is the menu item we'll attach the tabs checklist menu to - self.menu_tabs = builder.get_object('menu_tabs') + self.menu_tabs = main_builder.get_object('menu_tabs') self.notebook.connect('switch-page', self._on_switch_page) @@ -306,7 +305,7 @@ class TorrentDetails(component.Component): self.notebook.show() else: self.notebook.hide() - self.window.vpaned.set_position(-1) + component.get('MainWindow').vpaned.set_position(-1) def set_tab_visible(self, tab_name, visible): """Sets the tab to visible""" diff --git a/deluge/ui/gtkui/torrentview.py b/deluge/ui/gtkui/torrentview.py index 1adf3c52c..d0ddfc176 100644 --- a/deluge/ui/gtkui/torrentview.py +++ b/deluge/ui/gtkui/torrentview.py @@ -93,16 +93,17 @@ def progress_sort(model, iter1, iter2, sort_column_id): class SearchBox(object): def __init__(self, torrentview): self.torrentview = torrentview - self.window = torrentview.window + mainwindow = component.get('MainWindow') + main_builder = mainwindow.get_builder() self.visible = False self.search_pending = self.prefiltered = None - self.search_box = self.window.main_builder.get_object('search_box') - self.search_torrents_entry = self.window.main_builder.get_object('search_torrents_entry') - self.close_search_button = self.window.main_builder.get_object('close_search_button') - self.match_search_button = self.window.main_builder.get_object('search_torrents_match') - self.window.connect_signals(self) + self.search_box = main_builder.get_object('search_box') + self.search_torrents_entry = main_builder.get_object('search_torrents_entry') + self.close_search_button = main_builder.get_object('close_search_button') + self.match_search_button = main_builder.get_object('search_torrents_match') + mainwindow.connect_signals(self) def show(self): self.visible = True @@ -222,9 +223,9 @@ class TorrentView(ListView, component.Component): """TorrentView handles the listing of torrents.""" def __init__(self): component.Component.__init__(self, 'TorrentView', interval=2, depend=['SessionProxy']) - self.window = component.get('MainWindow') + main_builder = component.get('MainWindow').get_builder() # Call the ListView constructor - ListView.__init__(self, self.window.main_builder.get_object('torrent_view'), 'torrentview.state') + ListView.__init__(self, main_builder.get_object('torrent_view'), 'torrentview.state') log.debug('TorrentView Init..') # If we have gotten the state yet @@ -237,7 +238,7 @@ class TorrentView(ListView, component.Component): self.prev_status = {} # Register the columns menu with the listview so it gets updated accordingly. - self.register_checklist_menu(self.window.main_builder.get_object('menu_columns')) + self.register_checklist_menu(main_builder.get_object('menu_columns')) # Add the columns to the listview self.add_text_column('torrent_id', hidden=True, unique=True) @@ -379,7 +380,7 @@ class TorrentView(ListView, component.Component): """ Saves the state of the torrent view. """ - if self.window.visible(): + if component.get('MainWindow').visible(): ListView.save_state(self, 'torrentview.state') def remove_column(self, header): diff --git a/deluge/ui/gtkui/trackers_tab.py b/deluge/ui/gtkui/trackers_tab.py index 1b4ecb60c..8d514d164 100644 --- a/deluge/ui/gtkui/trackers_tab.py +++ b/deluge/ui/gtkui/trackers_tab.py @@ -22,18 +22,18 @@ class TrackersTab(Tab): Tab.__init__(self) # Get the labels we need to update. # widget name, modifier function, status keys - builder = component.get('MainWindow').get_builder() + main_builder = component.get('MainWindow').get_builder() self._name = 'Trackers' - self._child_widget = builder.get_object('trackers_tab') - self._tab_label = builder.get_object('trackers_tab_label') + self._child_widget = main_builder.get_object('trackers_tab') + self._tab_label = main_builder.get_object('trackers_tab_label') self.label_widgets = [ - (builder.get_object('summary_next_announce'), ftime, ('next_announce',)), - (builder.get_object('summary_tracker'), None, ('tracker_host',)), - (builder.get_object('summary_tracker_status'), ftranslate, ('tracker_status',)), - (builder.get_object('summary_tracker_total'), fcount, ('trackers',)), - (builder.get_object('summary_private'), fyes_no, ('private',)), + (main_builder.get_object('summary_next_announce'), ftime, ('next_announce',)), + (main_builder.get_object('summary_tracker'), None, ('tracker_host',)), + (main_builder.get_object('summary_tracker_status'), ftranslate, ('tracker_status',)), + (main_builder.get_object('summary_tracker_total'), fcount, ('trackers',)), + (main_builder.get_object('summary_private'), fyes_no, ('private',)), ] self.status_keys = [status for widget in self.label_widgets for status in widget[2]]