summaryrefslogtreecommitdiffstats
path: root/deluge/plugins/Toggle
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-10 21:38:38 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-10 21:38:38 +0000
commit2e2851dc13d73352530dd4495c7e05603b2e520d (patch)
tree622b9cd8e5d32091c9aa9e4937b533975a40356c /deluge/plugins/Toggle
parentInitial commit. (diff)
downloaddeluge-upstream.tar.xz
deluge-upstream.zip
Adding upstream version 2.1.2~dev0+20240219.upstream/2.1.2_dev0+20240219upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'deluge/plugins/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
-rw-r--r--deluge/plugins/Toggle/setup.py46
7 files changed, 261 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
diff --git a/deluge/plugins/Toggle/setup.py b/deluge/plugins/Toggle/setup.py
new file mode 100644
index 0000000..dadd32e
--- /dev/null
+++ b/deluge/plugins/Toggle/setup.py
@@ -0,0 +1,46 @@
+#
+# 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 setuptools import find_packages, setup
+
+__plugin_name__ = 'Toggle'
+__author__ = 'John Garland'
+__author_email__ = 'johnnybg+deluge@gmail.com'
+__version__ = '0.4'
+__url__ = 'http://deluge-torrent.org'
+__license__ = 'GPLv3'
+__description__ = 'Toggles the session'
+__long_description__ = """"""
+__pkg_data__ = {'deluge_' + __plugin_name__.lower(): ['data/*']}
+
+setup(
+ name=__plugin_name__,
+ version=__version__,
+ description=__description__,
+ author=__author__,
+ author_email=__author_email__,
+ url=__url__,
+ license=__license__,
+ long_description=__long_description__ if __long_description__ else __description__,
+ packages=find_packages(),
+ package_data=__pkg_data__,
+ entry_points="""
+ [deluge.plugin.core]
+ %s = deluge_%s:CorePlugin
+ [deluge.plugin.gtk3ui]
+ %s = deluge_%s:GtkUIPlugin
+ [deluge.plugin.web]
+ %s = deluge_%s:WebUIPlugin
+ """
+ % ((__plugin_name__, __plugin_name__.lower()) * 3),
+)