mirror of
https://github.com/codex-storage/deluge.git
synced 2025-01-11 03:55:43 +00:00
[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:
parent
f11a42b9bf
commit
7e2192e875
@ -115,11 +115,13 @@ class FilterTreeView(component.Component):
|
|||||||
|
|
||||||
self.default_menu_items = self.menu.get_children()
|
self.default_menu_items = self.menu.get_children()
|
||||||
|
|
||||||
def start(self):
|
|
||||||
# add Cat nodes:
|
# add Cat nodes:
|
||||||
self.cat_nodes = {}
|
self.cat_nodes = {}
|
||||||
self.filters = {}
|
self.filters = {}
|
||||||
|
|
||||||
|
def start(self):
|
||||||
|
self.cat_nodes = {}
|
||||||
|
self.filters = {}
|
||||||
# initial order of state filter:
|
# initial order of state filter:
|
||||||
self.cat_nodes['state'] = self.treestore.append(
|
self.cat_nodes['state'] = self.treestore.append(
|
||||||
None, ['cat', 'state', _('States'), 0, None, False]
|
None, ['cat', 'state', _('States'), 0, None, False]
|
||||||
|
@ -610,12 +610,12 @@ This will filter torrents for the current selection on the sidebar.</property>
|
|||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<property name="top_padding">2</property>
|
<property name="top_padding">2</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkPaned" id="vpaned">
|
<object class="GtkPaned" id="tabsbar_pane">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<property name="orientation">vertical</property>
|
<property name="orientation">vertical</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkPaned" id="main_window_hpaned">
|
<object class="GtkPaned" id="sidebar_pane">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
<child>
|
<child>
|
||||||
|
@ -107,7 +107,6 @@ DEFAULT_PREFS = {
|
|||||||
'pref_dialog_height': None,
|
'pref_dialog_height': None,
|
||||||
'edit_trackers_dialog_width': None,
|
'edit_trackers_dialog_width': None,
|
||||||
'edit_trackers_dialog_height': 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_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],
|
'tray_upload_speed_list': [5.0, 10.0, 30.0, 80.0, 300.0],
|
||||||
'connection_limit_list': [50, 100, 200, 300, 500],
|
'connection_limit_list': [50, 100, 200, 300, 500],
|
||||||
@ -122,6 +121,8 @@ DEFAULT_PREFS = {
|
|||||||
'show_sidebar': True,
|
'show_sidebar': True,
|
||||||
'show_toolbar': True,
|
'show_toolbar': True,
|
||||||
'show_statusbar': True,
|
'show_statusbar': True,
|
||||||
|
'show_tabsbar': True,
|
||||||
|
'tabsbar_position': 235,
|
||||||
'sidebar_show_zero': False,
|
'sidebar_show_zero': False,
|
||||||
'sidebar_show_trackers': True,
|
'sidebar_show_trackers': True,
|
||||||
'sidebar_show_owners': True,
|
'sidebar_show_owners': True,
|
||||||
|
@ -101,8 +101,8 @@ class MainWindow(component.Component):
|
|||||||
|
|
||||||
self.window = self.main_builder.get_object('main_window')
|
self.window = self.main_builder.get_object('main_window')
|
||||||
self.window.set_icon(get_deluge_icon())
|
self.window.set_icon(get_deluge_icon())
|
||||||
self.vpaned = self.main_builder.get_object('vpaned')
|
self.tabsbar_pane = self.main_builder.get_object('tabsbar_pane')
|
||||||
self.initial_vpaned_position = self.config['window_pane_position']
|
self.sidebar_pane = self.main_builder.get_object('sidebar_pane')
|
||||||
|
|
||||||
# Keep a list of components to pause and resume when changing window state.
|
# Keep a list of components to pause and resume when changing window state.
|
||||||
self.child_components = ['TorrentView', 'StatusBar', 'TorrentDetails']
|
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('configure-event', self.on_window_configure_event)
|
||||||
self.window.connect('delete-event', self.on_window_delete_event)
|
self.window.connect('delete-event', self.on_window_delete_event)
|
||||||
self.window.connect('drag-data-received', self.on_drag_data_received_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.window.connect('draw', self.on_expose_event)
|
||||||
|
|
||||||
self.config.register_set_function(
|
self.config.register_set_function(
|
||||||
@ -141,7 +146,9 @@ class MainWindow(component.Component):
|
|||||||
|
|
||||||
def first_show(self):
|
def first_show(self):
|
||||||
self.main_builder.prev_connect_signals(self.gtk_builder_signals_holder)
|
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 (
|
if not (
|
||||||
self.config['start_in_tray'] and self.config['enable_system_tray']
|
self.config['start_in_tray'] and self.config['enable_system_tray']
|
||||||
) and not self.window.get_property('visible'):
|
) and not self.window.get_property('visible'):
|
||||||
@ -280,8 +287,11 @@ class MainWindow(component.Component):
|
|||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def on_vpaned_position_event(self, obj, param):
|
def on_tabsbar_pane_position_event(self, obj, param):
|
||||||
self.config['window_pane_position'] = self.vpaned.get_position()
|
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(
|
def on_drag_data_received_event(
|
||||||
self, widget, drag_context, x, y, selection_data, info, timestamp
|
self, widget, drag_context, x, y, selection_data, info, timestamp
|
||||||
|
@ -30,9 +30,7 @@ class SideBar(component.Component):
|
|||||||
component.Component.__init__(self, 'SideBar')
|
component.Component.__init__(self, 'SideBar')
|
||||||
main_builder = component.get('MainWindow').get_builder()
|
main_builder = component.get('MainWindow').get_builder()
|
||||||
self.notebook = main_builder.get_object('sidebar_notebook')
|
self.notebook = main_builder.get_object('sidebar_notebook')
|
||||||
self.hpaned = main_builder.get_object('main_window_hpaned')
|
|
||||||
self.config = ConfigManager('gtk3ui.conf')
|
self.config = ConfigManager('gtk3ui.conf')
|
||||||
# self.hpaned_position = self.hpaned.get_position()
|
|
||||||
|
|
||||||
# Tabs holds references to the Tab widgets by their name
|
# Tabs holds references to the Tab widgets by their name
|
||||||
self.tabs = {}
|
self.tabs = {}
|
||||||
@ -40,21 +38,8 @@ class SideBar(component.Component):
|
|||||||
# Hide if necessary
|
# Hide if necessary
|
||||||
self.visible(self.config['show_sidebar'])
|
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):
|
def visible(self, visible):
|
||||||
if visible:
|
self.notebook.show() if visible else self.notebook.hide()
|
||||||
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.config['show_sidebar'] = visible
|
self.config['show_sidebar'] = visible
|
||||||
|
|
||||||
def add_tab(self, widget, tab_name, label):
|
def add_tab(self, widget, tab_name, label):
|
||||||
|
@ -175,6 +175,9 @@ class TorrentDetails(component.Component):
|
|||||||
# Generate the checklist menu
|
# Generate the checklist menu
|
||||||
self.generate_menu()
|
self.generate_menu()
|
||||||
|
|
||||||
|
self.config = component.get('MainWindow').config
|
||||||
|
self.visible(self.config['show_tabsbar'])
|
||||||
|
|
||||||
def tab_insert_position(self, weight):
|
def tab_insert_position(self, weight):
|
||||||
"""Returns the position a tab with a given weight should be inserted in"""
|
"""Returns the position a tab with a given weight should be inserted in"""
|
||||||
# Determine insert position based on weight
|
# Determine insert position based on weight
|
||||||
@ -348,11 +351,8 @@ class TorrentDetails(component.Component):
|
|||||||
self.menu_tabs.show_all()
|
self.menu_tabs.show_all()
|
||||||
|
|
||||||
def visible(self, visible):
|
def visible(self, visible):
|
||||||
if visible:
|
self.notebook.show() if visible else self.notebook.hide()
|
||||||
self.notebook.show()
|
self.config['show_tabsbar'] = visible
|
||||||
else:
|
|
||||||
self.notebook.hide()
|
|
||||||
component.get('MainWindow').vpaned.set_position(-1)
|
|
||||||
|
|
||||||
def set_tab_visible(self, tab_name, visible):
|
def set_tab_visible(self, tab_name, visible):
|
||||||
"""Sets the tab to visible"""
|
"""Sets the tab to visible"""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user