summaryrefslogtreecommitdiffstats
path: root/deluge/plugins/Toggle/deluge_toggle
diff options
context:
space:
mode:
Diffstat (limited to 'deluge/plugins/Toggle/deluge_toggle')
-rw-r--r--deluge/plugins/Toggle/deluge_toggle/__init__.py38
-rw-r--r--deluge/plugins/Toggle/deluge_toggle/common.py20
-rw-r--r--deluge/plugins/Toggle/deluge_toggle/core.py47
-rw-r--r--deluge/plugins/Toggle/deluge_toggle/data/toggle.js27
-rw-r--r--deluge/plugins/Toggle/deluge_toggle/gtkui.py53
-rw-r--r--deluge/plugins/Toggle/deluge_toggle/webui.py30
6 files changed, 215 insertions, 0 deletions
diff --git a/deluge/plugins/Toggle/deluge_toggle/__init__.py b/deluge/plugins/Toggle/deluge_toggle/__init__.py
new file mode 100644
index 0000000..b0332ee
--- /dev/null
+++ b/deluge/plugins/Toggle/deluge_toggle/__init__.py
@@ -0,0 +1,38 @@
+#
+# Copyright (C) 2010 John Garland <johnnybg+deluge@gmail.com>
+#
+# Basic plugin template created by:
+# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
+# Copyright (C) 2007-2009 Andrew Resch <andrewresch@gmail.com>
+# Copyright (C) 2009 Damien Churchill <damoxc@gmail.com>
+#
+# This file is part of Deluge and is licensed under GNU General Public License 3.0, or later, with
+# the additional special exception to link portions of this program with the OpenSSL library.
+# See LICENSE for more details.
+#
+
+from deluge.plugins.init import PluginInitBase
+
+
+class CorePlugin(PluginInitBase):
+ def __init__(self, plugin_name):
+ from .core import Core as _pluginCls
+
+ self._plugin_cls = _pluginCls
+ super().__init__(plugin_name)
+
+
+class GtkUIPlugin(PluginInitBase):
+ def __init__(self, plugin_name):
+ from .gtkui import GtkUI as _pluginCls
+
+ self._plugin_cls = _pluginCls
+ super().__init__(plugin_name)
+
+
+class WebUIPlugin(PluginInitBase):
+ def __init__(self, plugin_name):
+ from .webui import WebUI as _pluginCls
+
+ self._plugin_cls = _pluginCls
+ super().__init__(plugin_name)
diff --git a/deluge/plugins/Toggle/deluge_toggle/common.py b/deluge/plugins/Toggle/deluge_toggle/common.py
new file mode 100644
index 0000000..eb47f13
--- /dev/null
+++ b/deluge/plugins/Toggle/deluge_toggle/common.py
@@ -0,0 +1,20 @@
+#
+# Basic plugin template created by:
+# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
+# 2007-2009 Andrew Resch <andrewresch@gmail.com>
+# 2009 Damien Churchill <damoxc@gmail.com>
+# 2010 Pedro Algarvio <pedro@algarvio.me>
+# 2017 Calum Lind <calumlind+deluge@gmail.com>
+#
+# This file is part of Deluge and is licensed under GNU General Public License 3.0, or later, with
+# the additional special exception to link portions of this program with the OpenSSL library.
+# See LICENSE for more details.
+#
+
+import os.path
+
+from pkg_resources import resource_filename
+
+
+def get_resource(filename):
+ return resource_filename(__package__, os.path.join('data', filename))
diff --git a/deluge/plugins/Toggle/deluge_toggle/core.py b/deluge/plugins/Toggle/deluge_toggle/core.py
new file mode 100644
index 0000000..ab4581b
--- /dev/null
+++ b/deluge/plugins/Toggle/deluge_toggle/core.py
@@ -0,0 +1,47 @@
+#
+# Copyright (C) 2010 John Garland <johnnybg+deluge@gmail.com>
+#
+# Basic plugin template created by:
+# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
+# Copyright (C) 2007-2009 Andrew Resch <andrewresch@gmail.com>
+# Copyright (C) 2009 Damien Churchill <damoxc@gmail.com>
+#
+# This file is part of Deluge and is licensed under GNU General Public License 3.0, or later, with
+# the additional special exception to link portions of this program with the OpenSSL library.
+# See LICENSE for more details.
+#
+
+import logging
+
+import deluge.component as component
+from deluge.core.rpcserver import export
+from deluge.plugins.pluginbase import CorePluginBase
+
+log = logging.getLogger(__name__)
+
+DEFAULT_PREFS = {}
+
+
+class Core(CorePluginBase):
+ def enable(self):
+ self.core = component.get('Core')
+
+ def disable(self):
+ pass
+
+ def update(self):
+ pass
+
+ @export
+ def get_status(self):
+ return self.core.session.is_paused()
+
+ @export
+ def toggle(self):
+ if self.core.session.is_paused():
+ self.core.resume_session()
+ paused = False
+ else:
+ self.core.pause_session()
+ paused = True
+ return paused
diff --git a/deluge/plugins/Toggle/deluge_toggle/data/toggle.js b/deluge/plugins/Toggle/deluge_toggle/data/toggle.js
new file mode 100644
index 0000000..20fa4f4
--- /dev/null
+++ b/deluge/plugins/Toggle/deluge_toggle/data/toggle.js
@@ -0,0 +1,27 @@
+/**
+ * Script: toggle.js
+ * The client-side javascript code for the Toggle plugin.
+ *
+ * Copyright (C) John Garland 2010 <johnnybg+deluge@gmail.com>
+ *
+ * This file is part of Deluge and is licensed under GNU General Public License 3.0, or later, with
+ * the additional special exception to link portions of this program with the OpenSSL library.
+ * See LICENSE for more details.
+ */
+
+TogglePlugin = Ext.extend(Deluge.Plugin, {
+ constructor: function (config) {
+ config = Ext.apply(
+ {
+ name: 'Toggle',
+ },
+ config
+ );
+ TogglePlugin.superclass.constructor.call(this, config);
+ },
+
+ onDisable: function () {},
+
+ onEnable: function () {},
+});
+new TogglePlugin();
diff --git a/deluge/plugins/Toggle/deluge_toggle/gtkui.py b/deluge/plugins/Toggle/deluge_toggle/gtkui.py
new file mode 100644
index 0000000..bfb90de
--- /dev/null
+++ b/deluge/plugins/Toggle/deluge_toggle/gtkui.py
@@ -0,0 +1,53 @@
+#
+# Copyright (C) 2010 John Garland <johnnybg+deluge@gmail.com>
+#
+# Basic plugin template created by:
+# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
+# Copyright (C) 2007-2009 Andrew Resch <andrewresch@gmail.com>
+# Copyright (C) 2009 Damien Churchill <damoxc@gmail.com>
+#
+# This file is part of Deluge and is licensed under GNU General Public License 3.0, or later, with
+# the additional special exception to link portions of this program with the OpenSSL library.
+# See LICENSE for more details.
+#
+
+import logging
+
+import deluge.component as component
+from deluge.plugins.pluginbase import Gtk3PluginBase
+from deluge.ui.client import client
+
+log = logging.getLogger(__name__)
+
+
+class GtkUI(Gtk3PluginBase):
+ def enable(self):
+ self.core = client.toggle
+ self.plugin = component.get('PluginManager')
+ self.separator = self.plugin.add_toolbar_separator()
+ self.button = self.plugin.add_toolbar_button(
+ self._on_button_clicked,
+ label='Pause Session',
+ stock='gtk-media-pause',
+ tooltip='Pause the session',
+ )
+
+ def disable(self):
+ component.get('PluginManager').remove_toolbar_button(self.button)
+ component.get('PluginManager').remove_toolbar_button(self.separator)
+
+ def update(self):
+ def _on_get_status(paused):
+ if paused:
+ self.button.set_label('Resume Session')
+ self.button.set_tooltip_text('Resume the session')
+ self.button.set_stock_id('gtk-media-play')
+ else:
+ self.button.set_label('Pause Session')
+ self.button.set_tooltip_text('Pause the session')
+ self.button.set_stock_id('gtk-media-pause')
+
+ self.core.get_status().addCallback(_on_get_status)
+
+ def _on_button_clicked(self, widget):
+ self.core.toggle()
diff --git a/deluge/plugins/Toggle/deluge_toggle/webui.py b/deluge/plugins/Toggle/deluge_toggle/webui.py
new file mode 100644
index 0000000..637365c
--- /dev/null
+++ b/deluge/plugins/Toggle/deluge_toggle/webui.py
@@ -0,0 +1,30 @@
+#
+# Copyright (C) 2010 John Garland <johnnybg+deluge@gmail.com>
+#
+# Basic plugin template created by:
+# Copyright (C) 2008 Martijn Voncken <mvoncken@gmail.com>
+# Copyright (C) 2007-2009 Andrew Resch <andrewresch@gmail.com>
+# Copyright (C) 2009 Damien Churchill <damoxc@gmail.com>
+#
+# This file is part of Deluge and is licensed under GNU General Public License 3.0, or later, with
+# the additional special exception to link portions of this program with the OpenSSL library.
+# See LICENSE for more details.
+#
+
+import logging
+
+from deluge.plugins.pluginbase import WebPluginBase
+
+from .common import get_resource
+
+log = logging.getLogger(__name__)
+
+
+class WebUI(WebPluginBase):
+ scripts = [get_resource('toggle.js')]
+
+ def enable(self):
+ pass
+
+ def disable(self):
+ pass