Add a visible columns dialog in all torrents view under 'v' key

This commit is contained in:
Asmageddon 2012-05-29 19:29:30 +02:00
parent a8549ef882
commit 4735a6c49a
1 changed files with 35 additions and 4 deletions

View File

@ -44,12 +44,12 @@ from collections import deque
from deluge.ui.sessionproxy import SessionProxy from deluge.ui.sessionproxy import SessionProxy
from popup import Popup,SelectablePopup,MessagePopup from popup import Popup, SelectablePopup, MessagePopup, ALIGN
from add_util import add_torrent from add_util import add_torrent
from input_popup import InputPopup from input_popup import InputPopup, ALIGN
from torrentdetail import TorrentDetail from torrentdetail import TorrentDetail
from preferences import Preferences from preferences import Preferences
from torrent_actions import torrent_actions_popup, ACTION from torrent_actions import torrent_actions_popup
from eventview import EventView from eventview import EventView
from legacy import Legacy from legacy import Legacy
@ -625,7 +625,7 @@ class AllTorrents(BaseMode, component.Component):
return True return True
def _show_torrent_filter_popup(self): def _show_torrent_filter_popup(self):
self.popup = SelectablePopup(self,"Filter Torrents",self._torrent_filter) self.popup = SelectablePopup(self,"Filter Torrents", self._torrent_filter)
self.popup.add_line("_All",data=FILTER.ALL) self.popup.add_line("_All",data=FILTER.ALL)
self.popup.add_line("Ac_tive",data=FILTER.ACTIVE) self.popup.add_line("Ac_tive",data=FILTER.ACTIVE)
self.popup.add_line("_Downloading",data=FILTER.DOWNLOADING,foreground="green") self.popup.add_line("_Downloading",data=FILTER.DOWNLOADING,foreground="green")
@ -689,6 +689,33 @@ class AllTorrents(BaseMode, component.Component):
self.popup.add_spaces(1) self.popup.add_spaces(1)
self.popup.add_select_input("Path is:","path_type",["Auto","File","URL"],[0,1,2],0) self.popup.add_select_input("Path is:","path_type",["Auto","File","URL"],[0,1,2],0)
def _do_set_column_visibility(self, data):
for key, value in data.items():
self.config[key] = value
self.config.save()
self.update_config()
self.__update_columns()
self.refresh([])
def _show_visible_columns_popup(self):
title = "Visible columns (Enter to exit)"
self.popup = InputPopup(self,
title,
close_cb=self._do_set_column_visibility,
immediate_action=True,
height_req= len(column_pref_names) + 1,
width_req= max([len(col) for col in column_pref_names + [title]]) + 8
)
for col in column_pref_names:
name = prefs_to_names[col]
prop = "show_%s" % col
if prop not in self.config:
continue
state = self.config[prop]
self.popup.add_checked_input(name, prop, state)
def report_message(self,title,message): def report_message(self,title,message):
self.messages.append((title,message)) self.messages.append((title,message))
@ -1109,6 +1136,10 @@ class AllTorrents(BaseMode, component.Component):
self.last_mark = -1 self.last_mark = -1
elif chr(c) == 'a': elif chr(c) == 'a':
self._show_torrent_add_popup() self._show_torrent_add_popup()
elif chr(c) == 'v':
self._show_visible_columns_popup()
elif chr(c) == 'o': elif chr(c) == 'o':
if not self.marked: if not self.marked:
self.marked = [self.cursel] self.marked = [self.cursel]