From 7e2192e875ea0cc1ed160e0ebf6138e37e975035 Mon Sep 17 00:00:00 2001 From: Calum Lind Date: Tue, 6 Nov 2018 18:17:03 +0000 Subject: [PATCH] [GTK] Fix showing sidebar and tabsbar - Fixed the sidebar position not being restored by applying the config value in main_window first_show and updating config in position callback. - Renamed the main_window vpaned and hpaned widgets to aid identifying purpose. - Fixed filtertreeview KeyError when not conneted and hiding tabsbar. - Fixed the tabsbar notebook not being hidden on restart by adding a new config value. --- deluge/ui/gtk3/filtertreeview.py | 4 +++- deluge/ui/gtk3/glade/main_window.ui | 4 ++-- deluge/ui/gtk3/gtkui.py | 3 ++- deluge/ui/gtk3/mainwindow.py | 22 ++++++++++++++++------ deluge/ui/gtk3/sidebar.py | 17 +---------------- deluge/ui/gtk3/torrentdetails.py | 10 +++++----- 6 files changed, 29 insertions(+), 31 deletions(-) diff --git a/deluge/ui/gtk3/filtertreeview.py b/deluge/ui/gtk3/filtertreeview.py index 36daf5408..bd781e03a 100644 --- a/deluge/ui/gtk3/filtertreeview.py +++ b/deluge/ui/gtk3/filtertreeview.py @@ -115,11 +115,13 @@ class FilterTreeView(component.Component): self.default_menu_items = self.menu.get_children() - def start(self): # add Cat nodes: self.cat_nodes = {} self.filters = {} + def start(self): + self.cat_nodes = {} + self.filters = {} # initial order of state filter: self.cat_nodes['state'] = self.treestore.append( None, ['cat', 'state', _('States'), 0, None, False] diff --git a/deluge/ui/gtk3/glade/main_window.ui b/deluge/ui/gtk3/glade/main_window.ui index c6cac5571..43d8bf0e9 100644 --- a/deluge/ui/gtk3/glade/main_window.ui +++ b/deluge/ui/gtk3/glade/main_window.ui @@ -610,12 +610,12 @@ This will filter torrents for the current selection on the sidebar. False 2 - + True False vertical - + True True diff --git a/deluge/ui/gtk3/gtkui.py b/deluge/ui/gtk3/gtkui.py index 36991e755..88fb1016b 100644 --- a/deluge/ui/gtk3/gtkui.py +++ b/deluge/ui/gtk3/gtkui.py @@ -107,7 +107,6 @@ DEFAULT_PREFS = { 'pref_dialog_height': None, 'edit_trackers_dialog_width': None, 'edit_trackers_dialog_height': None, - 'window_pane_position': 235, 'tray_download_speed_list': [5.0, 10.0, 30.0, 80.0, 300.0], 'tray_upload_speed_list': [5.0, 10.0, 30.0, 80.0, 300.0], 'connection_limit_list': [50, 100, 200, 300, 500], @@ -122,6 +121,8 @@ DEFAULT_PREFS = { 'show_sidebar': True, 'show_toolbar': True, 'show_statusbar': True, + 'show_tabsbar': True, + 'tabsbar_position': 235, 'sidebar_show_zero': False, 'sidebar_show_trackers': True, 'sidebar_show_owners': True, diff --git a/deluge/ui/gtk3/mainwindow.py b/deluge/ui/gtk3/mainwindow.py index 42ffc59e9..51292e052 100644 --- a/deluge/ui/gtk3/mainwindow.py +++ b/deluge/ui/gtk3/mainwindow.py @@ -101,8 +101,8 @@ class MainWindow(component.Component): self.window = self.main_builder.get_object('main_window') self.window.set_icon(get_deluge_icon()) - self.vpaned = self.main_builder.get_object('vpaned') - self.initial_vpaned_position = self.config['window_pane_position'] + self.tabsbar_pane = self.main_builder.get_object('tabsbar_pane') + self.sidebar_pane = self.main_builder.get_object('sidebar_pane') # Keep a list of components to pause and resume when changing window state. self.child_components = ['TorrentView', 'StatusBar', 'TorrentDetails'] @@ -125,7 +125,12 @@ class MainWindow(component.Component): self.window.connect('configure-event', self.on_window_configure_event) self.window.connect('delete-event', self.on_window_delete_event) self.window.connect('drag-data-received', self.on_drag_data_received_event) - self.vpaned.connect('notify::position', self.on_vpaned_position_event) + self.tabsbar_pane.connect( + 'notify::position', self.on_tabsbar_pane_position_event + ) + self.sidebar_pane.connect( + 'notify::position', self.on_sidebar_pane_position_event + ) self.window.connect('draw', self.on_expose_event) self.config.register_set_function( @@ -141,7 +146,9 @@ class MainWindow(component.Component): def first_show(self): self.main_builder.prev_connect_signals(self.gtk_builder_signals_holder) - self.vpaned.set_position(self.initial_vpaned_position) + self.sidebar_pane.set_position(self.config['sidebar_position']) + self.tabsbar_pane.set_position(self.config['tabsbar_position']) + if not ( self.config['start_in_tray'] and self.config['enable_system_tray'] ) and not self.window.get_property('visible'): @@ -280,8 +287,11 @@ class MainWindow(component.Component): return True - def on_vpaned_position_event(self, obj, param): - self.config['window_pane_position'] = self.vpaned.get_position() + def on_tabsbar_pane_position_event(self, obj, param): + self.config['tabsbar_position'] = self.tabsbar_pane.get_position() + + def on_sidebar_pane_position_event(self, obj, param): + self.config['sidebar_position'] = self.sidebar_pane.get_position() def on_drag_data_received_event( self, widget, drag_context, x, y, selection_data, info, timestamp diff --git a/deluge/ui/gtk3/sidebar.py b/deluge/ui/gtk3/sidebar.py index 47d9ebdc4..1d751918f 100644 --- a/deluge/ui/gtk3/sidebar.py +++ b/deluge/ui/gtk3/sidebar.py @@ -30,9 +30,7 @@ class SideBar(component.Component): component.Component.__init__(self, 'SideBar') 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('gtk3ui.conf') - # self.hpaned_position = self.hpaned.get_position() # Tabs holds references to the Tab widgets by their name self.tabs = {} @@ -40,21 +38,8 @@ class SideBar(component.Component): # Hide if necessary self.visible(self.config['show_sidebar']) - def shutdown(self): - log.debug('hpaned.position: %s', self.hpaned.get_position()) - self.config['sidebar_position'] = self.hpaned.get_position() - def visible(self, visible): - if visible: - if self.config['sidebar_position']: - self.hpaned.set_position(self.config['sidebar_position']) - self.notebook.show() - else: - self.notebook.hide() - # Store the position for restoring upon show() - self.config['sidebar_position'] = self.hpaned.get_position() - self.hpaned.set_position(-1) - + self.notebook.show() if visible else self.notebook.hide() self.config['show_sidebar'] = visible def add_tab(self, widget, tab_name, label): diff --git a/deluge/ui/gtk3/torrentdetails.py b/deluge/ui/gtk3/torrentdetails.py index 6bfa4668a..29e019326 100644 --- a/deluge/ui/gtk3/torrentdetails.py +++ b/deluge/ui/gtk3/torrentdetails.py @@ -175,6 +175,9 @@ class TorrentDetails(component.Component): # Generate the checklist menu self.generate_menu() + self.config = component.get('MainWindow').config + self.visible(self.config['show_tabsbar']) + def tab_insert_position(self, weight): """Returns the position a tab with a given weight should be inserted in""" # Determine insert position based on weight @@ -348,11 +351,8 @@ class TorrentDetails(component.Component): self.menu_tabs.show_all() def visible(self, visible): - if visible: - self.notebook.show() - else: - self.notebook.hide() - component.get('MainWindow').vpaned.set_position(-1) + self.notebook.show() if visible else self.notebook.hide() + self.config['show_tabsbar'] = visible def set_tab_visible(self, tab_name, visible): """Sets the tab to visible"""