Calum Lind 535b13b5f1 [Plugins] Convert plugins to deluge_ module prefix convention
This commit reverts namespace for the plugins and uses a module prefix
"deluge_" in it's place. The distribution package name remains the same
for now but will also be considered to use a prefix to help find the
third-party plugins e.g. Deluge-{Plugin} and the pluginmanager will
strip the prefix for displaying.

The change is a result of problems trying to package Deluge with
pyinstaller and the pkg_resources namespaces is not compatible.
Testing alternatives to using the pkgutil or PEP420 (native) namespaces
did not yield any joy either as importing eggs with namespaces does not
work. [1]

At this point importable eggs are considered deprecated but there is no
viable alternative yet. [2]

[1] https://github.com/pypa/packaging-problems/issues/212
[2] https://github.com/pypa/packaging-problems/issues/244
2019-05-15 19:20:08 +01:00

66 lines
1.8 KiB
Python

# -*- coding: utf-8 -*-
#
# Copyright (C) 2008 Martijn Voncken <mvoncken@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 __future__ import unicode_literals
import logging
from gi.repository.Gtk import Menu, MenuItem
from deluge import component # for systray
from deluge.ui.client import client
log = logging.getLogger(__name__)
# Deferred Translation
def _(message):
return message
NO_LABEL = _('No Label')
del _
class LabelMenu(MenuItem):
def __init__(self):
MenuItem.__init__(self, _('Label')) # noqa: F821
self.sub_menu = Menu()
self.set_submenu(self.sub_menu)
self.items = []
# attach..
self.sub_menu.connect('show', self.on_show, None)
def get_torrent_ids(self):
return component.get('TorrentView').get_selected_torrents()
def on_show(self, widget=None, data=None):
log.debug('label-on-show')
client.label.get_labels().addCallback(self.cb_labels)
def cb_labels(self, labels):
for child in self.sub_menu.get_children():
self.sub_menu.remove(child)
for label in [NO_LABEL] + list(labels):
if label == NO_LABEL:
item = MenuItem(_(NO_LABEL)) # noqa: F821
else:
item = MenuItem(label.replace('_', '__'))
item.connect('activate', self.on_select_label, label)
self.sub_menu.append(item)
self.show_all()
def on_select_label(self, widget=None, label_id=None):
log.debug('select label:%s,%s', label_id, self.get_torrent_ids())
for torrent_id in self.get_torrent_ids():
client.label.set_torrent(torrent_id, label_id)