Author: damoxc
Revision: 5741
Log:
change the scheduler plugin to use the new plugin architecture
Diff:
Modified: trunk/deluge/plugins/scheduler/scheduler/data/scheduler.js
===================================================================
--- trunk/deluge/plugins/scheduler/scheduler/data/scheduler.js 2009-09-14
10:26:29 UTC (rev 5740)
+++ trunk/deluge/plugins/scheduler/scheduler/data/scheduler.js 2009-09-14
10:26:59 UTC (rev 5741)
@@ -1,92 +1,109 @@
-(function() {
- function createEl(parent, type) {
- var el = document.createElement(type);
- parent.appendChild(el);
- return el;
- }
+ScheduleSelectPanel = Ext.extend(Ext.form.FieldSet, {
+ constructor: function(config) {
+ config = Ext.apply({
+ title: _('Schedule'),
+ autoHeight: true
+ }, config);
+ ScheduleSelectPanel.superclass.constructor.call(this, config);
+ },
- var DAYS = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'];
-
- ScheduleSelectPanel = Ext.extend(Ext.form.FieldSet, {
- constructor: function(config) {
- config = Ext.apply({
- title: _('Schedule'),
- autoHeight: true
- }, config);
- ScheduleSelectPanel.superclass.constructor.call(this,
config);
- },
+ onRender: function(ct, position) {
+ ScheduleSelectPanel.superclass.onRender.call(this, ct,
position);
- onRender: function(ct, position) {
- ScheduleSelectPanel.superclass.onRender.call(this, ct,
position);
-
- var dom = this.body.dom;
- var table = createEl(dom, 'table');
-
- Ext.each(DAYS, function(day) {
- var row = createEl(table, 'tr');
- var label = createEl(row, 'th');
- label.setAttribute('style', 'font-weight: bold;
padding-right: 5px;');
- label.innerHTML = day;
- for (var hour = 0; hour < 24; hour++) {
- var cell = createEl(row, 'td');
- cell.setAttribute('style', 'border: 1px
solid Green; width: 16px; height: 20px; background: LightGreen;');
- }
- });
+ var dom = this.body.dom;
+ var table = createEl(dom, 'table');
+
+ function createEl(parent, type) {
+ var el = document.createElement(type);
+ parent.appendChild(el);
+ return el;
}
- });
-
- SchedulerPreferences = Ext.extend(Ext.Panel, {
- constructor: function(config) {
- config = Ext.apply({
- border: false,
- title: _('Scheduler')
- }, config);
- SchedulerPreferences.superclass.constructor.call(this,
config);
- },
- initComponent: function() {
-
SchedulerPreferences.superclass.initComponent.call(this);
+ Ext.each(['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
function(day) {
+ var row = createEl(table, 'tr');
+ var label = createEl(row, 'th');
+ label.setAttribute('style', 'font-weight: bold;
padding-right: 5px;');
+ label.innerHTML = day;
+ for (var hour = 0; hour < 24; hour++) {
+ var cell = createEl(row, 'td');
+ cell.setAttribute('style', 'border: 1px solid
Green; width: 16px; height: 20px; background: LightGreen;');
+ }
+ });
+ }
+});
- this.form = this.add({
- xtype: 'form',
- layout: 'form',
- border: false,
- autoHeight: true
- });
-
- this.schedule = this.form.add(new
ScheduleSelectPanel());
-
- this.slowSettings = this.form.add({
- xtype: 'fieldset',
- title: _('Slow Settings'),
- autoHeight: true,
- defaultType: 'uxspinner'
- });
-
- this.downloadLimit = this.slowSettings.add({
- fieldLabel: _('Download Limit'),
- name: 'download_limit'
- });
- this.uploadLimit = this.slowSettings.add({
- fieldLabel: _('Upload Limit'),
- name: 'upload_limit'
- });
- this.activeTorrents = this.slowSettings.add({
- fieldLabel: _('Active Torrents'),
- name: 'active_torrents'
- });
- },
+SchedulerPreferences = Ext.extend(Ext.Panel, {
+ constructor: function(config) {
+ config = Ext.apply({
+ border: false,
+ title: _('Scheduler')
+ }, config);
+ SchedulerPreferences.superclass.constructor.call(this, config);
+ },
+
+ initComponent: function() {
+ SchedulerPreferences.superclass.initComponent.call(this);
+
+ this.form = this.add({
+ xtype: 'form',
+ layout: 'form',
+ border: false,
+ autoHeight: true
+ });
- onRender: function(ct, position) {
- SchedulerPreferences.superclass.onRender.call(this, ct,
position);
- this.form.layout = new Ext.layout.FormLayout();
- this.form.layout.setContainer(this);
- this.form.doLayout();
- },
+ this.schedule = this.form.add(new ScheduleSelectPanel());
- onShow: function() {
- SchedulerPreferences.superclass.onShow.call(this);
- }
- });
- Deluge.Preferences.addPage(new SchedulerPreferences());
+ this.slowSettings = this.form.add({
+ xtype: 'fieldset',
+ title: _('Slow Settings'),
+ autoHeight: true,
+ defaultType: 'uxspinner'
+ });
+
+ this.downloadLimit = this.slowSettings.add({
+ fieldLabel: _('Download Limit'),
+ name: 'download_limit'
+ });
+ this.uploadLimit = this.slowSettings.add({
+ fieldLabel: _('Upload Limit'),
+ name: 'upload_limit'
+ });
+ this.activeTorrents = this.slowSettings.add({
+ fieldLabel: _('Active Torrents'),
+ name: 'active_torrents'
+ });
+ },
+
+ onRender: function(ct, position) {
+ SchedulerPreferences.superclass.onRender.call(this, ct,
position);
+ this.form.layout = new Ext.layout.FormLayout();
+ this.form.layout.setContainer(this);
+ this.form.doLayout();
+ },
+
+ onShow: function() {
+ SchedulerPreferences.superclass.onShow.call(this);
+ }
+});
+
+SchedulerPlugin = Ext.extend(Deluge.Plugin, {
+ constructor: function(config) {
+ config = Ext.apply({
+ name: "Scheduler"
+ }, config);
+ SchedulerPlugin.superclass.constructor.call(this, config);
+ },
+
+ onDisable: function() {
+ Deluge.Preferences.removePage(this.prefsPage);
+ },
+
+ onEnable: function() {
+ this.prefsPage = new SchedulerPreferences();
+ Deluge.Preferences.addPage(this.prefsPage);
+ }
+});
+
+(function() {
+ var plugin = new SchedulerPlugin();
})();
\ No newline at end of file
Modified: trunk/deluge/plugins/scheduler/scheduler/webui.py
===================================================================
--- trunk/deluge/plugins/scheduler/scheduler/webui.py 2009-09-14 10:26:29 UTC
(rev 5740)
+++ trunk/deluge/plugins/scheduler/scheduler/webui.py 2009-09-14 10:26:59 UTC
(rev 5741)
@@ -1,7 +1,7 @@
#
# webui.py
#
-# Copyright (C) 2009 Andrew Resch <[email protected]>
+# Copyright (C) 2009 Damien Churchill <[email protected]>
#
# Basic plugin template created by:
# Copyright (C) 2008 Martijn Voncken <[email protected]>
@@ -36,8 +36,6 @@
# statement from all source files in the program, then also delete it here.
#
-import pkg_resources
-
from deluge.log import LOG as log
from deluge.ui.client import client
from deluge import component
@@ -46,16 +44,5 @@
from common import get_resource
class WebUI(WebPluginBase):
- def enable(self):
- deluge_web = component.get("DelugeWeb").top_level
- deluge_web.add_script("/js/scheduler.js")
-
- javascript = component.get("Javascript").directories
- javascript.append(get_resource(""))
-
- def disable(self):
- deluge_web = component.get("DelugeWeb").top_level
- deluge_web.remove_script("/js/scheduler.js")
-
- javascript = component.get("Javascript").directories
- javascript.remove(get_resource(""))
+
+ scripts = [get_resource("scheduler.js")]
\ No newline at end of file
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"deluge-commit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/deluge-commit?hl=en
-~----------~----~----~----~------~----~------~--~---