From c45583e8e768c2db5ea8015d46b0929f38443060 Mon Sep 17 00:00:00 2001 From: Damien Churchill Date: Wed, 28 Apr 2010 17:46:21 +0100 Subject: [PATCH] enable and disable the panel toolbar buttons upon selection change --- deluge/plugins/execute/execute/data/execute.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/deluge/plugins/execute/execute/data/execute.js b/deluge/plugins/execute/execute/data/execute.js index 0e6b3b199..c6d31da47 100644 --- a/deluge/plugins/execute/execute/data/execute.js +++ b/deluge/plugins/execute/execute/data/execute.js @@ -182,6 +182,7 @@ Deluge.ux.preferences.ExecutePage = Ext.extend(Ext.Panel, { singleSelect: true, autoExpandColumn: 'name' }); + this.list.on('selectionchange', this.onSelectionChange, this); this.panel = this.add({ items: [this.list], @@ -195,12 +196,14 @@ Deluge.ux.preferences.ExecutePage = Ext.extend(Ext.Panel, { text: _('Edit'), iconCls: 'icon-edit', handler: this.onEditClick, - scope: this + scope: this, + disabled: true }, '->', { text: _('Remove'), iconCls: 'icon-remove', handler: this.onRemoveClick, - scope: this + scope: this, + disabled: true }] } }); @@ -256,6 +259,16 @@ Deluge.ux.preferences.ExecutePage = Ext.extend(Ext.Panel, { }, scope: this }); + }, + + onSelectionChange: function(dv, selections) { + if (selections.length) { + this.panel.getBottomToolbar().items.get(1).enable(); + this.panel.getBottomToolbar().items.get(3).enable(); + } else { + this.panel.getBottomToolbar().items.get(1).disable(); + this.panel.getBottomToolbar().items.get(3).disable(); + } } });