diff --git a/deluge/ui/gtk3/glade/main_window.tabs.ui b/deluge/ui/gtk3/glade/main_window.tabs.ui index 159ea160b..e9a075d67 100644 --- a/deluge/ui/gtk3/glade/main_window.tabs.ui +++ b/deluge/ui/gtk3/glade/main_window.tabs.ui @@ -1,5 +1,5 @@ - + @@ -38,14 +38,14 @@ False - + True True - left + True True diff --git a/deluge/ui/gtk3/gtkui.py b/deluge/ui/gtk3/gtkui.py index d8d335866..c3593da16 100644 --- a/deluge/ui/gtk3/gtkui.py +++ b/deluge/ui/gtk3/gtkui.py @@ -121,6 +121,7 @@ DEFAULT_PREFS = { 'show_toolbar': True, 'show_statusbar': True, 'show_tabsbar': True, + 'tabsbar_tab_pos': 'left', 'tabsbar_position': 235, 'sidebar_show_zero': False, 'sidebar_show_trackers': True, diff --git a/deluge/ui/gtk3/mainwindow.py b/deluge/ui/gtk3/mainwindow.py index daed58910..b0135bdc9 100644 --- a/deluge/ui/gtk3/mainwindow.py +++ b/deluge/ui/gtk3/mainwindow.py @@ -108,6 +108,7 @@ class MainWindow(component.Component): self.window = self.main_builder.get_object('main_window') self.window.set_icon(get_deluge_icon()) self.tabsbar_pane = self.main_builder.get_object('tabsbar_pane') + self.tabsbar_torrent_info = self.main_builder.get_object('torrent_info') self.sidebar_pane = self.main_builder.get_object('sidebar_pane') # Keep a list of components to pause and resume when changing window state. @@ -154,6 +155,10 @@ class MainWindow(component.Component): self.main_builder.prev_connect_signals(self.gtk_builder_signals_holder) self.sidebar_pane.set_position(self.config['sidebar_position']) self.tabsbar_pane.set_position(self.config['tabsbar_position']) + tab_pos = self.config['tabsbar_tab_pos'] + self.tabsbar_torrent_info.set_tab_pos( + getattr(Gtk.PositionType, tab_pos.upper()) + ) if not ( self.config['start_in_tray'] and self.config['enable_system_tray'] 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