More fixes for labels plugin webui

Disabled options and remove for filters No Label and All
Removed All from torrent menu
Fixed No Label not working in torrent menu
Bumped version to 0.2
This commit is contained in:
Calum Lind 2012-02-22 15:46:58 +00:00
parent 330019bb3d
commit b5c63c4d58
2 changed files with 19 additions and 24 deletions

View File

@ -357,13 +357,6 @@ Deluge.plugins.LabelPlugin = Ext.extend(Deluge.Plugin, {
name: 'Label', name: 'Label',
noLabelItem: {
text: _('No Label'),
label: '',
handler: this.onTorrentMenuClick,
scope: this
},
createMenu: function() { createMenu: function() {
this.labelMenu = new Ext.menu.Menu({ this.labelMenu = new Ext.menu.Menu({
items: [{ items: [{
@ -388,14 +381,22 @@ Deluge.plugins.LabelPlugin = Ext.extend(Deluge.Plugin, {
setFilter: function(filter) { setFilter: function(filter) {
filter.show_zero = true; filter.show_zero = true;
filter.list.on('contextmenu', this.onLabelContextMenu, this); filter.list.on('contextmenu', this.onLabelContextMenu, this);
filter.header.on('contextmenu', this.onLabelHeaderContextMenu, this); filter.header.on('contextmenu', this.onLabelHeaderContextMenu, this);
this.filter = filter; this.filter = filter;
}, },
updateTorrentMenu: function(states) { updateTorrentMenu: function(states) {
this.torrentMenu.removeAll(true);
this.torrentMenu.addMenuItem({
text: _('No Label'),
label: '',
handler: this.onTorrentMenuClick,
scope: this
});
for (var state in states) { for (var state in states) {
if (!state) continue; if (!state || state == 'All' ) continue;
this.torrentMenu.addMenuItem({ this.torrentMenu.addMenuItem({
text: state, text: state,
label: state, label: state,
@ -415,9 +416,7 @@ Deluge.plugins.LabelPlugin = Ext.extend(Deluge.Plugin, {
}, },
onEnable: function() { onEnable: function() {
this.torrentMenu = new Ext.menu.Menu({ this.torrentMenu = new Ext.menu.Menu();
items: [ this.noLabelItem ]
});
this.tmSep = deluge.menus.torrent.add({ this.tmSep = deluge.menus.torrent.add({
xtype: 'menuseparator' xtype: 'menuseparator'
@ -472,21 +471,15 @@ Deluge.plugins.LabelPlugin = Ext.extend(Deluge.Plugin, {
var statesArray = []; var statesArray = [];
for (state in states) { for (state in states) {
if (!state || state == 'All') continue;
statesArray.push(state); statesArray.push(state);
} }
var none = statesArray.shift();
var all = statesArray.shift();
this.torrentMenu.removeAll(true);
this.torrentMenu.addMenuItem(this.noLabelItem);
statesArray.push(label.toLowerCase()); statesArray.push(label.toLowerCase());
statesArray.sort(); statesArray.sort();
statesArray.unshift(all);
console.log(states); //console.log(states);
console.log(statesArray); //console.log(statesArray);
states = {} states = {}
@ -500,12 +493,14 @@ Deluge.plugins.LabelPlugin = Ext.extend(Deluge.Plugin, {
onLabelContextMenu: function(dv, i, node, e) { onLabelContextMenu: function(dv, i, node, e) {
e.preventDefault(); e.preventDefault();
if (!this.labelMenu) this.createMenu(); if (!this.labelMenu) this.createMenu();
var r = dv.getRecord(node); var r = dv.getRecord(node).get('filter');
if (dv.getRecord(node).get('filter')) { if ( !r || r == 'All') {
this.labelMenu.items.get(1).setDisabled(true);
this.labelMenu.items.get(2).setDisabled(true);
} else {
this.labelMenu.items.get(1).setDisabled(false); this.labelMenu.items.get(1).setDisabled(false);
this.labelMenu.items.get(2).setDisabled(false); this.labelMenu.items.get(2).setDisabled(false);
} }
dv.select(i); dv.select(i);
this.labelMenu.showAt(e.getXY()); this.labelMenu.showAt(e.getXY());
}, },

View File

@ -36,7 +36,7 @@ from setuptools import setup, find_packages
__plugin_name__ = "Label" __plugin_name__ = "Label"
__author__ = "Martijn Voncken" __author__ = "Martijn Voncken"
__author_email__ = "mvoncken@gmail.com" __author_email__ = "mvoncken@gmail.com"
__version__ = "0.1" __version__ = "0.2"
__url__ = "http://deluge-torrent.org" __url__ = "http://deluge-torrent.org"
__license__ = "GPLv3" __license__ = "GPLv3"
__description__ = "Allows labels to be assigned to torrents" __description__ = "Allows labels to be assigned to torrents"