diff --git a/deluge/plugins/label/label/data/label.js b/deluge/plugins/label/label/data/label.js index f718ae26a..d09f9898a 100644 --- a/deluge/plugins/label/label/data/label.js +++ b/deluge/plugins/label/label/data/label.js @@ -357,13 +357,6 @@ Deluge.plugins.LabelPlugin = Ext.extend(Deluge.Plugin, { name: 'Label', - noLabelItem: { - text: _('No Label'), - label: '', - handler: this.onTorrentMenuClick, - scope: this - }, - createMenu: function() { this.labelMenu = new Ext.menu.Menu({ items: [{ @@ -388,14 +381,22 @@ Deluge.plugins.LabelPlugin = Ext.extend(Deluge.Plugin, { setFilter: function(filter) { filter.show_zero = true; + filter.list.on('contextmenu', this.onLabelContextMenu, this); filter.header.on('contextmenu', this.onLabelHeaderContextMenu, this); this.filter = filter; }, updateTorrentMenu: function(states) { - for (var state in states) { - if (!state) continue; + this.torrentMenu.removeAll(true); + this.torrentMenu.addMenuItem({ + text: _('No Label'), + label: '', + handler: this.onTorrentMenuClick, + scope: this + }); + for (var state in states) { + if (!state || state == 'All' ) continue; this.torrentMenu.addMenuItem({ text: state, label: state, @@ -415,9 +416,7 @@ Deluge.plugins.LabelPlugin = Ext.extend(Deluge.Plugin, { }, onEnable: function() { - this.torrentMenu = new Ext.menu.Menu({ - items: [ this.noLabelItem ] - }); + this.torrentMenu = new Ext.menu.Menu(); this.tmSep = deluge.menus.torrent.add({ xtype: 'menuseparator' @@ -472,21 +471,15 @@ Deluge.plugins.LabelPlugin = Ext.extend(Deluge.Plugin, { var statesArray = []; for (state in states) { - statesArray.push(state); + if (!state || state == 'All') continue; + 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.sort(); - statesArray.unshift(all); - console.log(states); - console.log(statesArray); + //console.log(states); + //console.log(statesArray); states = {} @@ -500,12 +493,14 @@ Deluge.plugins.LabelPlugin = Ext.extend(Deluge.Plugin, { onLabelContextMenu: function(dv, i, node, e) { e.preventDefault(); if (!this.labelMenu) this.createMenu(); - var r = dv.getRecord(node); - if (dv.getRecord(node).get('filter')) { + var r = 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(2).setDisabled(false); } - dv.select(i); this.labelMenu.showAt(e.getXY()); }, diff --git a/deluge/plugins/label/setup.py b/deluge/plugins/label/setup.py index d196edaf1..1f6e9547e 100644 --- a/deluge/plugins/label/setup.py +++ b/deluge/plugins/label/setup.py @@ -36,7 +36,7 @@ from setuptools import setup __plugin_name__ = "Label" __author__ = "Martijn Voncken" __author_email__ = "mvoncken@gmail.com" -__version__ = "0.1" +__version__ = "0.2" __url__ = "http://deluge-torrent.org" __license__ = "GPLv3" __description__ = "Allows labels to be assigned to torrents"