tidy up toolbar event handlers
add a client connection check and act accordingly when its disconnected
This commit is contained in:
parent
eae92d78eb
commit
376b0daa11
|
@ -26,6 +26,10 @@ Deluge.ToolBar = {
|
||||||
Deluge.Login.Window.show();
|
Deluge.Login.Window.show();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
onConnectionManagerClick: function(item) {
|
||||||
|
Deluge.Connections.Window.show();
|
||||||
|
},
|
||||||
|
|
||||||
onTorrentAction: function(item) {
|
onTorrentAction: function(item) {
|
||||||
var selection = Deluge.Torrents.getSelectionModel().getSelections();
|
var selection = Deluge.Torrents.getSelectionModel().getSelections();
|
||||||
var ids = new Array();
|
var ids = new Array();
|
||||||
|
@ -42,36 +46,21 @@ Deluge.ToolBar = {
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case 'pause':
|
case 'pause':
|
||||||
Deluge.Client.core.pause_torrent(ids, {
|
|
||||||
onSuccess: function() {
|
|
||||||
Deluge.Ui.update();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
case 'resume':
|
case 'resume':
|
||||||
Deluge.Client.core.resume_torrent(ids, {
|
Deluge.Client.core[item.id + '_torrent'](ids, {
|
||||||
onSuccess: function() {
|
onSuccess: function() {
|
||||||
Deluge.Ui.update();
|
Deluge.Ui.update();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case 'up':
|
case 'up':
|
||||||
Deluge.Client.core.queue_up(ids, {
|
|
||||||
onSuccess: function() {
|
|
||||||
Deluge.Ui.update();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
case 'down':
|
case 'down':
|
||||||
Deluge.Client.core.queue_down(ids, {
|
Deluge.Client.core['queue_' + item.id](ids, {
|
||||||
onSuccess: function() {
|
onSuccess: function() {
|
||||||
Deluge.Ui.update();
|
Deluge.Ui.update();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case 'connectionman':
|
|
||||||
Deluge.Connections.Window.show();
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -143,13 +132,16 @@ Deluge.ToolBar.Bar = new Ext.Toolbar({
|
||||||
cls: 'x-btn-text-icon',
|
cls: 'x-btn-text-icon',
|
||||||
text: _('Connection Manager'),
|
text: _('Connection Manager'),
|
||||||
icon: '/icons/16/connection_manager.png',
|
icon: '/icons/16/connection_manager.png',
|
||||||
handler: Deluge.ToolBar.onTorrentAction
|
handler: Deluge.ToolBar.onConnectionManagerClick,
|
||||||
|
scope: Deluge.ToolBar
|
||||||
},'->',{
|
},'->',{
|
||||||
id: 'help',
|
id: 'help',
|
||||||
cls: 'x-btn-text-icon',
|
cls: 'x-btn-text-icon',
|
||||||
disabled: true,
|
disabled: true,
|
||||||
icon: '/icons/16/help.png',
|
icon: '/icons/16/help.png',
|
||||||
text: _('Help')
|
text: _('Help'),
|
||||||
|
handler: Deluge.ToolBar.onHelpClick,
|
||||||
|
scope: Deluge.ToolBar
|
||||||
},{
|
},{
|
||||||
id: 'logout',
|
id: 'logout',
|
||||||
cls: 'x-btn-text-icon',
|
cls: 'x-btn-text-icon',
|
||||||
|
|
|
@ -29,6 +29,15 @@ Deluge.Ui = {
|
||||||
onSuccess: this.onUpdate.bindWithEvent(this),
|
onSuccess: this.onUpdate.bindWithEvent(this),
|
||||||
onFailure: this.onUpdateError.bindWithEvent(this)
|
onFailure: this.onUpdateError.bindWithEvent(this)
|
||||||
});
|
});
|
||||||
|
Deluge.Client.web.connected({
|
||||||
|
onSuccess: this.onConnectedCheck.bindWithEvent(this)
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
onConnectedCheck: function(connected) {
|
||||||
|
if (!connected) {
|
||||||
|
Deluge.Events.fire('disconnect');
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
onUpdateError: function(error) {
|
onUpdateError: function(error) {
|
||||||
|
|
|
@ -142,7 +142,8 @@ class JSON(resource.Resource):
|
||||||
"web.add_torrents": self.add_torrents,
|
"web.add_torrents": self.add_torrents,
|
||||||
"web.login": self.login,
|
"web.login": self.login,
|
||||||
"web.get_hosts": self.get_hosts,
|
"web.get_hosts": self.get_hosts,
|
||||||
"web.connect": self.connect
|
"web.connect": self.connect,
|
||||||
|
"web.connected": self.connected
|
||||||
}
|
}
|
||||||
for entry in open(common.get_default_config_dir("auth")):
|
for entry in open(common.get_default_config_dir("auth")):
|
||||||
parts = entry.split(":")
|
parts = entry.split(":")
|
||||||
|
@ -307,13 +308,17 @@ class JSON(resource.Resource):
|
||||||
self._connect(*host[1:]).addCallback(on_connected)
|
self._connect(*host[1:]).addCallback(on_connected)
|
||||||
return d
|
return d
|
||||||
|
|
||||||
def update_ui(self, keys, filter_dict, cache_id=None):
|
def connected(self):
|
||||||
|
d = Deferred()
|
||||||
|
d.callback(client.connected())
|
||||||
|
return d
|
||||||
|
|
||||||
|
def update_ui(self, keys, filter_dict):
|
||||||
|
|
||||||
ui_info = {
|
ui_info = {
|
||||||
"torrents": None,
|
"torrents": None,
|
||||||
"filters": None,
|
"filters": None,
|
||||||
"stats": None,
|
"stats": None
|
||||||
"cache_id": -1
|
|
||||||
}
|
}
|
||||||
|
|
||||||
d = Deferred()
|
d = Deferred()
|
||||||
|
|
Loading…
Reference in New Issue