[UI] Update UIs for new default piece priority
- libtorrent 1.1 changes default piece priorty to 4 so changes to the UIs are required. Some refactoring and improvements were made as well: - A new 'Low' priority introduced that is values 1-3. - 'Normal' priority is now value 4. - Removed 'Highest' with the addition of 'Low' and 'High' is now values 5-7. - Renamed 'Do not download' to 'Ignore' so it is more succinct. - Moved file priority constant to ui.common.
This commit is contained in:
parent
bb44411a50
commit
a481c4d243
|
@ -56,21 +56,6 @@ TORRENT_STATE = [
|
|||
'Moving'
|
||||
]
|
||||
|
||||
FILE_PRIORITY = {
|
||||
0: 'Do Not Download',
|
||||
1: 'Normal Priority',
|
||||
2: 'High Priority',
|
||||
3: 'High Priority',
|
||||
4: 'High Priority',
|
||||
5: 'High Priority',
|
||||
6: 'High Priority',
|
||||
7: 'Highest Priority',
|
||||
'Do Not Download': 0,
|
||||
'Normal Priority': 1,
|
||||
'High Priority': 5,
|
||||
'Highest Priority': 7
|
||||
}
|
||||
|
||||
|
||||
def get_version():
|
||||
"""
|
||||
|
|
|
@ -24,7 +24,7 @@ from deluge.common import utf8_encoded
|
|||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
# Dummy translation dicts so Torrent and Tracker states are available for Translators.
|
||||
# Dummy translation dicts so the text is available for Translators.
|
||||
#
|
||||
# All entries in deluge.common.TORRENT_STATE should be added here.
|
||||
#
|
||||
|
@ -90,13 +90,28 @@ TORRENT_DATA_FIELD = {
|
|||
'owner': {'name': _('Owner'), 'status': ['owner']}
|
||||
}
|
||||
|
||||
|
||||
TRACKER_STATUS_TRANSLATION = [
|
||||
_('Error'),
|
||||
_('Warning'),
|
||||
_('Announce OK'),
|
||||
_('Announce Sent')
|
||||
]
|
||||
|
||||
FILE_PRIORITY = {
|
||||
0: 'Ignore',
|
||||
1: 'Low',
|
||||
2: 'Low',
|
||||
3: 'Low',
|
||||
4: 'Normal',
|
||||
5: 'High',
|
||||
6: 'High',
|
||||
7: 'High',
|
||||
_('Ignore'): 0,
|
||||
_('Low'): 1,
|
||||
_('Normal'): 4,
|
||||
_('High'): 7,
|
||||
}
|
||||
|
||||
del _
|
||||
|
||||
DEFAULT_HOST = '127.0.0.1'
|
||||
|
|
|
@ -16,6 +16,7 @@ import deluge.common as common
|
|||
import deluge.component as component
|
||||
import deluge.ui.console.utils.colors as colors
|
||||
from deluge.ui.client import client
|
||||
from deluge.ui.common import FILE_PRIORITY
|
||||
from deluge.ui.console.utils import format_utils
|
||||
|
||||
from . import BaseCommand
|
||||
|
@ -198,7 +199,7 @@ class Command(BaseCommand):
|
|||
|
||||
col_priority = ' {!info!}Priority: '
|
||||
|
||||
file_priority = common.FILE_PRIORITY[status['file_priorities'][index]].replace('Priority', '')
|
||||
file_priority = FILE_PRIORITY[status['file_priorities'][index]].replace('Priority', '')
|
||||
if status['file_progress'][index] != 1.0:
|
||||
if file_priority == 'Do Not Download':
|
||||
col_priority += '{!error!}'
|
||||
|
|
|
@ -12,9 +12,10 @@ from __future__ import division
|
|||
import logging
|
||||
|
||||
import deluge.component as component
|
||||
from deluge.common import FILE_PRIORITY, fsize
|
||||
from deluge.common import fsize
|
||||
from deluge.decorators import overrides
|
||||
from deluge.ui.client import client
|
||||
from deluge.ui.common import FILE_PRIORITY
|
||||
from deluge.ui.console.modes.basemode import BaseMode
|
||||
from deluge.ui.console.modes.torrentlist.torrentactions import ACTION, torrent_actions_popup
|
||||
from deluge.ui.console.utils import curses_util as util
|
||||
|
@ -308,16 +309,19 @@ class TorrentDetail(BaseMode, PopupsHandler):
|
|||
bg = 'black'
|
||||
attr = ''
|
||||
|
||||
if fl[6] == -2:
|
||||
pass # Mixed
|
||||
elif fl[6] == 0:
|
||||
fg = 'red' # Do Not Download
|
||||
elif fl[6] == 1:
|
||||
pass # Normal
|
||||
elif fl[6] <= 6:
|
||||
fg = 'yellow' # High
|
||||
elif fl[6] == 7:
|
||||
fg = 'green' # Highest
|
||||
priority_fg_color = {
|
||||
-2: 'white', # Mixed
|
||||
0: 'red', # Ignore
|
||||
1: 'yellow', # Low
|
||||
2: 'yellow',
|
||||
3: 'yellow',
|
||||
4: 'white', # Normal
|
||||
5: 'green',
|
||||
6: 'green',
|
||||
7: 'green' # High
|
||||
}
|
||||
|
||||
fg = priority_fg_color[fl[6]]
|
||||
|
||||
if idx >= self.file_off:
|
||||
# set fg/bg colors based on whether the file is selected/marked or not
|
||||
|
@ -581,13 +585,14 @@ class TorrentDetail(BaseMode, PopupsHandler):
|
|||
|
||||
if self.marked:
|
||||
popup = SelectablePopup(self, 'Set File Priority', popup_func, border_off_north=1)
|
||||
popup.add_line('do_not_download', '_Do Not Download',
|
||||
cb_arg=FILE_PRIORITY['Do Not Download'], foreground='red')
|
||||
popup.add_line('normal_priority', '_Normal Priority', cb_arg=FILE_PRIORITY['Normal Priority'])
|
||||
popup.add_line('ignore_priority', '_Ignore',
|
||||
cb_arg=FILE_PRIORITY['Ignore'], foreground='red')
|
||||
popup.add_line('low_priority', '_Low Priority',
|
||||
cb_arg=FILE_PRIORITY['Low Priority'], foreground='yellow')
|
||||
popup.add_line('normal_priority', '_Normal Priority',
|
||||
cb_arg=FILE_PRIORITY['Normal Priority'])
|
||||
popup.add_line('high_priority', '_High Priority',
|
||||
cb_arg=FILE_PRIORITY['High Priority'], foreground='yellow')
|
||||
popup.add_line('highest_priority', 'H_ighest Priority',
|
||||
cb_arg=FILE_PRIORITY['Highest Priority'], foreground='green')
|
||||
cb_arg=FILE_PRIORITY['High Priority'], foreground='green')
|
||||
popup._selected = 1
|
||||
self.push_popup(popup)
|
||||
|
||||
|
|
|
@ -18,8 +18,9 @@ from gobject import TYPE_UINT64
|
|||
from gtk.gdk import ACTION_DEFAULT, ACTION_MOVE, BUTTON1_MASK, keyval_name # pylint: disable=ungrouped-imports
|
||||
|
||||
import deluge.component as component
|
||||
from deluge.common import FILE_PRIORITY, open_file, show_file
|
||||
from deluge.common import open_file, show_file
|
||||
from deluge.ui.client import client
|
||||
from deluge.ui.common import FILE_PRIORITY
|
||||
from deluge.ui.gtkui.common import (listview_replace_treestore, load_pickled_state_file, reparent_iter,
|
||||
save_pickled_state_file)
|
||||
from deluge.ui.gtkui.torrentdetails import Tab
|
||||
|
@ -27,24 +28,12 @@ from deluge.ui.gtkui.torrentview_data_funcs import cell_data_size
|
|||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def _(message):
|
||||
return message
|
||||
|
||||
|
||||
TRANSLATE = {
|
||||
'Do Not Download': _('Do Not Download'),
|
||||
'Normal Priority': _('Normal Priority'),
|
||||
'High Priority': _('High Priority'),
|
||||
'Highest Priority': _('Highest Priority'),
|
||||
CELL_PRIORITY_ICONS = {
|
||||
'Ignore': gtk.STOCK_NO,
|
||||
'Low': gtk.STOCK_GO_DOWN,
|
||||
'Normal': gtk.STOCK_OK,
|
||||
'High': gtk.STOCK_GO_UP
|
||||
}
|
||||
del _
|
||||
|
||||
|
||||
def _t(text):
|
||||
if text in TRANSLATE:
|
||||
text = TRANSLATE[text]
|
||||
return _(text)
|
||||
|
||||
|
||||
def cell_priority(column, cell, model, row, data):
|
||||
|
@ -53,7 +42,7 @@ def cell_priority(column, cell, model, row, data):
|
|||
cell.set_property('text', '')
|
||||
return
|
||||
priority = model.get_value(row, data)
|
||||
cell.set_property('text', _t(FILE_PRIORITY[priority]))
|
||||
cell.set_property('text', _(FILE_PRIORITY[priority]))
|
||||
|
||||
|
||||
def cell_priority_icon(column, cell, model, row, data):
|
||||
|
@ -62,14 +51,7 @@ def cell_priority_icon(column, cell, model, row, data):
|
|||
cell.set_property('stock-id', None)
|
||||
return
|
||||
priority = model.get_value(row, data)
|
||||
if FILE_PRIORITY[priority] == 'Do Not Download':
|
||||
cell.set_property('stock-id', gtk.STOCK_NO)
|
||||
elif FILE_PRIORITY[priority] == 'Normal Priority':
|
||||
cell.set_property('stock-id', gtk.STOCK_YES)
|
||||
elif FILE_PRIORITY[priority] == 'High Priority':
|
||||
cell.set_property('stock-id', gtk.STOCK_GO_UP)
|
||||
elif FILE_PRIORITY[priority] == 'Highest Priority':
|
||||
cell.set_property('stock-id', gtk.STOCK_GOTO_TOP)
|
||||
cell.set_property('stock-id', CELL_PRIORITY_ICONS[FILE_PRIORITY[priority]])
|
||||
|
||||
|
||||
def cell_filename(column, cell, model, row, data):
|
||||
|
@ -175,10 +157,10 @@ class FilesTab(Tab):
|
|||
|
||||
self.file_menu = main_builder.get_object('menu_file_tab')
|
||||
self.file_menu_priority_items = [
|
||||
main_builder.get_object('menuitem_donotdownload'),
|
||||
main_builder.get_object('menuitem_ignore'),
|
||||
main_builder.get_object('menuitem_low'),
|
||||
main_builder.get_object('menuitem_normal'),
|
||||
main_builder.get_object('menuitem_high'),
|
||||
main_builder.get_object('menuitem_highest'),
|
||||
main_builder.get_object('menuitem_priority_sep')
|
||||
]
|
||||
|
||||
|
@ -202,10 +184,10 @@ class FilesTab(Tab):
|
|||
component.get('MainWindow').connect_signals({
|
||||
'on_menuitem_open_file_activate': self._on_menuitem_open_file_activate,
|
||||
'on_menuitem_show_file_activate': self._on_menuitem_show_file_activate,
|
||||
'on_menuitem_donotdownload_activate': self._on_menuitem_donotdownload_activate,
|
||||
'on_menuitem_ignore_activate': self._on_menuitem_ignore_activate,
|
||||
'on_menuitem_low_activate': self._on_menuitem_low_activate,
|
||||
'on_menuitem_normal_activate': self._on_menuitem_normal_activate,
|
||||
'on_menuitem_high_activate': self._on_menuitem_high_activate,
|
||||
'on_menuitem_highest_activate': self._on_menuitem_highest_activate,
|
||||
'on_menuitem_expand_all_activate': self._on_menuitem_expand_all_activate
|
||||
})
|
||||
|
||||
|
@ -543,25 +525,21 @@ class FilesTab(Tab):
|
|||
log.debug('priorities: %s', priorities)
|
||||
client.core.set_torrent_options([self.torrent_id], {'file_priorities': priorities})
|
||||
|
||||
def _on_menuitem_donotdownload_activate(self, menuitem):
|
||||
def _on_menuitem_ignore_activate(self, menuitem):
|
||||
self._set_file_priorities_on_user_change(
|
||||
self.get_selected_files(),
|
||||
FILE_PRIORITY['Do Not Download'])
|
||||
self.get_selected_files(), FILE_PRIORITY['Ignore'])
|
||||
|
||||
def _on_menuitem_low_activate(self, menuitem):
|
||||
self._set_file_priorities_on_user_change(
|
||||
self.get_selected_files(), FILE_PRIORITY['Low'])
|
||||
|
||||
def _on_menuitem_normal_activate(self, menuitem):
|
||||
self._set_file_priorities_on_user_change(
|
||||
self.get_selected_files(),
|
||||
FILE_PRIORITY['Normal Priority'])
|
||||
self.get_selected_files(), FILE_PRIORITY['Normal'])
|
||||
|
||||
def _on_menuitem_high_activate(self, menuitem):
|
||||
self._set_file_priorities_on_user_change(
|
||||
self.get_selected_files(),
|
||||
FILE_PRIORITY['High Priority'])
|
||||
|
||||
def _on_menuitem_highest_activate(self, menuitem):
|
||||
self._set_file_priorities_on_user_change(
|
||||
self.get_selected_files(),
|
||||
FILE_PRIORITY['Highest Priority'])
|
||||
self.get_selected_files(), FILE_PRIORITY['High'])
|
||||
|
||||
def _on_menuitem_expand_all_activate(self, menuitem):
|
||||
self.listview.expand_all()
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
<object class="GtkImage" id="image5">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="stock">gtk-goto-top</property>
|
||||
<property name="stock">gtk-go-down</property>
|
||||
<property name="icon-size">1</property>
|
||||
</object>
|
||||
<object class="GtkMenu" id="menu_file_tab">
|
||||
|
@ -82,15 +82,27 @@
|
|||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkImageMenuItem" id="menuitem_donotdownload">
|
||||
<property name="label" translatable="yes">_Do Not Download</property>
|
||||
<object class="GtkImageMenuItem" id="menuitem_ignore">
|
||||
<property name="label" translatable="yes">_Ignore</property>
|
||||
<property name="use_action_appearance">False</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="image">image2</property>
|
||||
<property name="use_stock">False</property>
|
||||
<signal name="activate" handler="on_menuitem_donotdownload_activate" swapped="no"/>
|
||||
<signal name="activate" handler="on_menuitem_ignore_activate" swapped="no"/>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkImageMenuItem" id="menuitem_low">
|
||||
<property name="label" translatable="yes">_Low Priority</property>
|
||||
<property name="use_action_appearance">False</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="image">image5</property>
|
||||
<property name="use_stock">False</property>
|
||||
<signal name="activate" handler="on_menuitem_low_activate" swapped="no"/>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
|
@ -114,19 +126,7 @@
|
|||
<property name="use_underline">True</property>
|
||||
<property name="image">image4</property>
|
||||
<property name="use_stock">False</property>
|
||||
<signal name="activate" handler="on_menuitem_high_activate" swapped="no"/>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkImageMenuItem" id="menuitem_highest">
|
||||
<property name="label" translatable="yes">Hi_ghest Priority</property>
|
||||
<property name="use_action_appearance">False</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="image">image5</property>
|
||||
<property name="use_stock">False</property>
|
||||
<signal name="activate" handler="on_menuitem_highest_activate" swapped="no"/>
|
||||
<signal name="activate" handler="on_menuitem_normal_activate" swapped="no"/>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
|
|
|
@ -346,7 +346,7 @@ dl.singleline dd {
|
|||
}
|
||||
|
||||
/* Filepriority styles */
|
||||
.x-no-download, .x-normal-download, .x-high-download, .x-highest-download, .x-mixed-download {
|
||||
.x-no-download, .x-low-download, .x-normal-download, .x-high-download, .x-mixed-download {
|
||||
padding-left: 20px;
|
||||
background-repeat: no-repeat;
|
||||
line-height: 16px;
|
||||
|
@ -356,6 +356,10 @@ dl.singleline dd {
|
|||
background-image: url(../icons/no_download.png);
|
||||
}
|
||||
|
||||
.x-low-download {
|
||||
background-image: url(../icons/low.png);
|
||||
}
|
||||
|
||||
.x-normal-download {
|
||||
background-image: url(../icons/normal.png);
|
||||
}
|
||||
|
@ -364,10 +368,6 @@ dl.singleline dd {
|
|||
background-image: url(../icons/high.png);
|
||||
}
|
||||
|
||||
.x-highest-download {
|
||||
background-image: url(../icons/highest.png);
|
||||
}
|
||||
|
||||
.x-mixed-download {
|
||||
/*background-image: url(../icons/mixed.png);*/
|
||||
}
|
||||
|
@ -485,6 +485,10 @@ dl.singleline dd {
|
|||
background-image: url('../icons/no_download.png') !important;
|
||||
}
|
||||
|
||||
.icon-low {
|
||||
background-image: url('../icons/low.png') !important;
|
||||
}
|
||||
|
||||
.icon-normal {
|
||||
background-image: url('../icons/normal.png') !important;
|
||||
}
|
||||
|
@ -492,7 +496,3 @@ dl.singleline dd {
|
|||
.icon-high {
|
||||
background-image: url('../icons/high.png') !important;
|
||||
}
|
||||
|
||||
.icon-highest {
|
||||
background-image: url('../icons/highest.png') !important;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*!
|
||||
* Deluge.js
|
||||
*
|
||||
*
|
||||
* Copyright (c) Damien Churchill 2009-2010 <damoxc@gmail.com>
|
||||
*
|
||||
* This file is part of Deluge and is licensed under GNU General Public License 3.0, or later, with
|
||||
|
@ -41,7 +41,7 @@ Ext.apply(Ext, {
|
|||
}
|
||||
return equal;
|
||||
},
|
||||
|
||||
|
||||
keys: function(obj) {
|
||||
var keys = [];
|
||||
for (var i in obj) if (obj.hasOwnProperty(i))
|
||||
|
@ -60,7 +60,7 @@ Ext.apply(Ext, {
|
|||
}
|
||||
return values;
|
||||
},
|
||||
|
||||
|
||||
splat: function(obj) {
|
||||
var type = Ext.type(obj);
|
||||
return (type) ? ((type != 'array') ? [obj] : obj) : [];
|
||||
|
@ -75,7 +75,7 @@ Ext.apply(Deluge, {
|
|||
|
||||
// private
|
||||
pluginStore: {},
|
||||
|
||||
|
||||
// private
|
||||
progressTpl: '<div class="x-progress-wrap x-progress-renderered">' +
|
||||
'<div class="x-progress-inner">' +
|
||||
|
@ -90,7 +90,7 @@ Ext.apply(Deluge, {
|
|||
'</div>' +
|
||||
'</div>',
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* A method to create a progress bar that can be used by renderers
|
||||
* to display a bar within a grid or tree.
|
||||
|
@ -131,36 +131,42 @@ Ext.apply(Deluge, {
|
|||
registerPlugin: function(name, plugin) {
|
||||
Deluge.pluginStore[name] = plugin;
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
// Setup a space for plugins to insert themselves
|
||||
deluge.plugins = {};
|
||||
|
||||
// Hinting for gettext_gen.py
|
||||
// _('Do Not Download')
|
||||
// _('Normal Priority')
|
||||
// _('High Priority')
|
||||
// _('Highest Priority')
|
||||
// _('Ignore')
|
||||
// _('Low')
|
||||
// _('Normal')
|
||||
// _('High')
|
||||
FILE_PRIORITY = {
|
||||
0: 'Ignore',
|
||||
1: 'Low',
|
||||
2: 'Low',
|
||||
3: 'Low',
|
||||
4: 'Normal',
|
||||
5: 'High',
|
||||
6: 'High',
|
||||
7: 'High',
|
||||
9: 'Mixed',
|
||||
0: 'Do Not Download',
|
||||
1: 'Normal Priority',
|
||||
2: 'High Priority',
|
||||
5: 'High Priority',
|
||||
7: 'Highest Priority',
|
||||
'Mixed': 9,
|
||||
'Do Not Download': 0,
|
||||
'Normal Priority': 1,
|
||||
'High Priority': 5,
|
||||
'Highest Priority': 7
|
||||
'Ignore': 0,
|
||||
'Low': 1,
|
||||
'Normal': 4,
|
||||
'High': 7,
|
||||
'Mixed': 9
|
||||
}
|
||||
|
||||
FILE_PRIORITY_CSS = {
|
||||
9: 'x-mixed-download',
|
||||
0: 'x-no-download',
|
||||
1: 'x-normal-download',
|
||||
2: 'x-high-download',
|
||||
1: 'x-low-download',
|
||||
2: 'x-low-download',
|
||||
3: 'x-low-download',
|
||||
4: 'x-normal-download',
|
||||
5: 'x-high-download',
|
||||
7: 'x-highest-download'
|
||||
6: 'x-high-download',
|
||||
7: 'x-high-download',
|
||||
9: 'x-mixed-download'
|
||||
}
|
||||
|
|
|
@ -301,24 +301,24 @@ deluge.menus.filePriorities = new Ext.menu.Menu({
|
|||
text: _('Expand All'),
|
||||
iconCls: 'icon-expand-all'
|
||||
}, '-', {
|
||||
id: 'no_download',
|
||||
text: _('Do Not Download'),
|
||||
id: 'ignore',
|
||||
text: _('Ignore'),
|
||||
iconCls: 'icon-do-not-download',
|
||||
filePriority: FILE_PRIORITY['Do Not Download']
|
||||
filePriority: FILE_PRIORITY['Ignore']
|
||||
}, {
|
||||
id: 'low',
|
||||
text: _('Low'),
|
||||
iconCls: 'icon-low',
|
||||
filePriority: FILE_PRIORITY['Low']
|
||||
}, {
|
||||
id: 'normal',
|
||||
text: _('Normal Priority'),
|
||||
text: _('Normal'),
|
||||
iconCls: 'icon-normal',
|
||||
filePriority: FILE_PRIORITY['Normal Priority']
|
||||
filePriority: FILE_PRIORITY['Normal']
|
||||
}, {
|
||||
id: 'high',
|
||||
text: _('High Priority'),
|
||||
text: _('High'),
|
||||
iconCls: 'icon-high',
|
||||
filePriority: FILE_PRIORITY['High Priority']
|
||||
}, {
|
||||
id: 'highest',
|
||||
text: _('Highest Priority'),
|
||||
iconCls: 'icon-highest',
|
||||
filePriority: FILE_PRIORITY['Highest Priority']
|
||||
filePriority: FILE_PRIORITY['High']
|
||||
}]
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue