Skip to content

Commit

Permalink
- Add Deluge 2.0 support
Browse files Browse the repository at this point in the history
  • Loading branch information
bdutro committed Oct 24, 2019
1 parent 763a0c1 commit c5dd42e
Show file tree
Hide file tree
Showing 7 changed files with 311 additions and 54 deletions.
10 changes: 5 additions & 5 deletions movetools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,20 @@

class CorePlugin(PluginInitBase):
def __init__(self, plugin_name):
from core import Core as _plugin_cls
from .core import Core as _plugin_cls
self._plugin_cls = _plugin_cls
super(CorePlugin, self).__init__(plugin_name)


class GtkUIPlugin(PluginInitBase):
class Gtk3UIPlugin(PluginInitBase):
def __init__(self, plugin_name):
from gtkui import GtkUI as _plugin_cls
from .gtkui import GtkUI as _plugin_cls
self._plugin_cls = _plugin_cls
super(GtkUIPlugin, self).__init__(plugin_name)
super(Gtk3UIPlugin, self).__init__(plugin_name)


class WebUIPlugin(PluginInitBase):
def __init__(self, plugin_name):
from webui import WebUI as _plugin_cls
from .webui import WebUI as _plugin_cls
self._plugin_cls = _plugin_cls
super(WebUIPlugin, self).__init__(plugin_name)
4 changes: 3 additions & 1 deletion movetools/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@
import copy
import os
import pkg_resources
import gettext

_ = gettext.gettext

PLUGIN_NAME = "MoveTools"
MODULE_NAME = "movetools"
Expand All @@ -58,7 +60,7 @@ def get_resource(filename):

def normalize_dict(dict_in, template):

for key in dict_in.keys():
for key in list(dict_in.keys()):
if key not in template:
del dict_in[key]

Expand Down
19 changes: 10 additions & 9 deletions movetools/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@
from deluge.core.rpcserver import export
from deluge.core.torrent import Torrent

from common import PLUGIN_NAME
from common import MODULE_NAME
from common import STATUS_NAME
from common import STATUS_MESSAGE
from common import normalize_dict
from .common import PLUGIN_NAME
from .common import MODULE_NAME
from .common import STATUS_NAME
from .common import STATUS_MESSAGE
from .common import normalize_dict


CONFIG_FILE = "%s.conf" % MODULE_NAME
Expand Down Expand Up @@ -176,7 +176,7 @@ def enable(self):

self.initialized = False

if not deluge.component.get("TorrentManager").session_started:
if deluge.component.get("TorrentManager").get_state() != 'Started':
deluge.component.get("EventManager").register_event_handler(
"SessionStartedEvent", self._on_session_started)
log.debug("[%s] Waiting for session to start...", PLUGIN_NAME)
Expand Down Expand Up @@ -237,6 +237,7 @@ def move_storage(torrent, dest_path):
component.get("CorePluginManager").register_status_field(STATUS_MESSAGE,
self.get_move_message)

log.debug("Registering filter %s: %s", STATUS_NAME, str(INIT_FILTERS()))
component.get("FilterManager").register_tree_field(STATUS_NAME,
INIT_FILTERS)

Expand Down Expand Up @@ -307,7 +308,7 @@ def clear_selected(self, ids):
@export
def clear_all_status(self):
log.debug("[%s] Clearing all status results", PLUGIN_NAME)
for id in self.torrents.keys():
for id in list(self.torrents.keys()):
if self.torrents[id].status not in ALIVE_STATUS:
self._remove_job(id)

Expand Down Expand Up @@ -360,13 +361,13 @@ def on_storage_moved_failed(self, alert):

def get_move_status(self, id):
if id not in self.torrents:
return None
return 'Done'

return self.torrents[id].status

def get_move_message(self, id):
if id not in self.torrents:
return None
return 'Done'

return self.torrents[id].message

Expand Down
252 changes: 252 additions & 0 deletions movetools/data/wnd_preferences.ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,252 @@
<?xml version="1.0"?>
<interface>
<object class="GtkAdjustment" id="adjustment1">
<property name="upper">10000000000</property>
<property name="lower">1</property>
<property name="page_increment">10</property>
<property name="step_increment">1</property>
<property name="page_size">0</property>
<property name="value">1</property>
</object>
<object class="GtkAdjustment" id="adjustment2">
<property name="upper">100000</property>
<property name="lower">-1</property>
<property name="page_increment">10</property>
<property name="step_increment">1</property>
<property name="page_size">0</property>
<property name="value">0</property>
</object>
<object class="GtkAdjustment" id="adjustment3">
<property name="upper">100000</property>
<property name="lower">-1</property>
<property name="page_increment">10</property>
<property name="step_increment">1</property>
<property name="page_size">0</property>
<property name="value">0</property>
</object>
<!-- interface-requires gtk+ 2.16 -->
<!-- interface-naming-policy toplevel-contextual -->
<object class="GtkWindow" id="wnd_preferences">
<child>
<object class="GtkAlignment" id="blk_preferences">
<property name="visible">True</property>
<property name="top_padding">5</property>
<property name="bottom_padding">5</property>
<property name="left_padding">5</property>
<property name="right_padding">5</property>
<child>
<object class="GtkVBox" id="vbox1">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<property name="spacing">16</property>
<child>
<object class="GtkVBox" id="vbox3">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<property name="spacing">5</property>
<child>
<object class="GtkLabel" id="lbl_general">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">General</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkAlignment" id="alignment2">
<property name="visible">True</property>
<property name="left_padding">4</property>
<child>
<object class="GtkTable" id="table2">
<property name="visible">True</property>
<property name="n_columns">3</property>
<property name="column_spacing">5</property>
<property name="row_spacing">3</property>
<child>
<object class="GtkLabel" id="label1">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Estimated move speed:</property>
</object>
<packing>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_SHRINK | GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkSpinButton" id="spn_estimated_speed">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">&#x25CF;</property>
<property name="xalign">1</property>
<property name="adjustment">adjustment1</property>
<property name="numeric">True</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="y_options">GTK_SHRINK | GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label13">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">B/s</property>
</object>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
<property name="y_options">GTK_SHRINK | GTK_FILL</property>
</packing>
</child>
</object>
</child>
</object>
<packing>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="chk_remove_empty">
<property name="label" translatable="yes">Remove empty folders on move</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkVBox" id="vbox2">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<property name="spacing">5</property>
<child>
<object class="GtkLabel" id="lbl_timeout">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Status Timeout</property>
</object>
<packing>
<property name="expand">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkTable" id="table1">
<property name="visible">True</property>
<property name="n_rows">2</property>
<property name="n_columns">3</property>
<property name="column_spacing">10</property>
<property name="row_spacing">5</property>
<child>
<object class="GtkLabel" id="label2">
<property name="visible">True</property>
<property name="xalign">1</property>
<property name="label" translatable="yes">Success</property>
</object>
<packing>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label3">
<property name="visible">True</property>
<property name="xalign">1</property>
<property name="label" translatable="yes">Error</property>
</object>
<packing>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkSpinButton" id="spn_success_timeout">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">&#x25CF;</property>
<property name="adjustment">adjustment2</property>
<property name="numeric">True</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkSpinButton" id="spn_error_timeout">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">&#x25CF;</property>
<property name="adjustment">adjustment3</property>
<property name="numeric">True</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label5">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">seconds</property>
</object>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label6">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">seconds</property>
</object>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
</object>
</child>
</object>
</interface>
Loading

0 comments on commit c5dd42e

Please sign in to comment.