summaryrefslogtreecommitdiffstats
path: root/deluge/ui/gtk3/torrentdetails.py
diff options
context:
space:
mode:
authorCalum Lind <calumlind+deluge@gmail.com>2021-02-20 14:48:58 +0000
committerCalum Lind <calumlind+deluge@gmail.com>2021-02-20 15:22:08 +0000
commit1022448e4fbd7934b69b28abb3ff0c474b7b16ec (patch)
tree7813386021715212e5e98770e8a2a023c94ec1ca /deluge/ui/gtk3/torrentdetails.py
parent291540b601939ffa4a1b985159004420bf82b545 (diff)
downloaddeluge-1022448e4fbd7934b69b28abb3ff0c474b7b16ec.tar.gz
deluge-1022448e4fbd7934b69b28abb3ff0c474b7b16ec.tar.bz2
deluge-1022448e4fbd7934b69b28abb3ff0c474b7b16ec.zip
[#3441|GTKUI] Add a torrentdetails tabs position menu
The tabs placement for the torrentdetails notebook might not be to everyone's liking so add a menu item to configure it. Default the position back to top.
Diffstat (limited to 'deluge/ui/gtk3/torrentdetails.py')
-rw-r--r--deluge/ui/gtk3/torrentdetails.py33
1 files changed, 31 insertions, 2 deletions
diff --git a/deluge/ui/gtk3/torrentdetails.py b/deluge/ui/gtk3/torrentdetails.py
index b2124b309..34e966f7b 100644
--- a/deluge/ui/gtk3/torrentdetails.py
+++ b/deluge/ui/gtk3/torrentdetails.py
@@ -14,7 +14,14 @@ from __future__ import unicode_literals
import logging
from collections import namedtuple
-from gi.repository.Gtk import CheckMenuItem, Menu, SeparatorMenuItem
+from gi.repository.Gtk import (
+ CheckMenuItem,
+ Menu,
+ MenuItem,
+ PositionType,
+ RadioMenuItem,
+ SeparatorMenuItem,
+)
import deluge.component as component
from deluge.ui.client import client
@@ -100,6 +107,7 @@ class TorrentDetails(component.Component):
def __init__(self):
component.Component.__init__(self, 'TorrentDetails', interval=2)
main_builder = component.get('MainWindow').get_builder()
+ self.config = component.get('MainWindow').config
self.notebook = main_builder.get_object('torrent_info')
@@ -175,7 +183,6 @@ 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):
@@ -314,9 +321,24 @@ class TorrentDetails(component.Component):
self.generate_menu()
self.visible(True)
+ def create_tab_pos_menuitem(self):
+ """Returns a menu to select which side of the notebook the tabs should be shown"""
+ tab_pos_menu = Menu()
+ tab_pos_menuitem = MenuItem(_('Position'))
+ group = []
+ for pos in ('top', 'right', 'bottom', 'left'):
+ menuitem = RadioMenuItem.new_with_mnemonic(group, _(pos.capitalize()))
+ group = menuitem.get_group()
+ menuitem.connect('toggled', self._on_tabs_pos_toggled, pos)
+ menuitem.set_active(pos == self.notebook.get_tab_pos().value_nick)
+ tab_pos_menu.append(menuitem)
+ tab_pos_menuitem.set_submenu(tab_pos_menu)
+ return tab_pos_menuitem
+
def generate_menu(self):
"""Generates the checklist menu for all the tabs and attaches it"""
menu = Menu()
+
# Create 'All' menuitem and a separator
menuitem = CheckMenuItem.new_with_mnemonic(self.translate_tabs['All'])
menuitem.set_name('All')
@@ -347,6 +369,9 @@ class TorrentDetails(component.Component):
menuitem.connect('toggled', self._on_menuitem_toggled)
menu.append(menuitem)
+ menu.append(SeparatorMenuItem())
+ menu.append(self.create_tab_pos_menuitem())
+
self.menu_tabs.set_submenu(menu)
self.menu_tabs.show_all()
@@ -440,6 +465,10 @@ class TorrentDetails(component.Component):
self.set_tab_visible(name, widget.get_active())
+ def _on_tabs_pos_toggled(self, widget, position):
+ self.config['tabsbar_tab_pos'] = position
+ self.notebook.set_tab_pos(getattr(PositionType, position.upper()))
+
def save_state(self):
"""We save the state, which is basically the tab_index list"""
# Update the visiblity status of all tabs