[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.
This commit is contained in:
Calum Lind 2018-11-06 18:17:03 +00:00
parent f11a42b9bf
commit 7e2192e875
6 changed files with 29 additions and 31 deletions

View File

@ -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]

View File

@ -610,12 +610,12 @@ This will filter torrents for the current selection on the sidebar.</property>
<property name="can_focus">False</property>
<property name="top_padding">2</property>
<child>
<object class="GtkPaned" id="vpaned">
<object class="GtkPaned" id="tabsbar_pane">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkPaned" id="main_window_hpaned">
<object class="GtkPaned" id="sidebar_pane">
<property name="visible">True</property>
<property name="can_focus">True</property>
<child>

View File

@ -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,

View File

@ -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

View File

@ -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):

View File

@ -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"""