Change imports to use absolute paths

This commit is contained in:
Calum Lind 2014-09-19 12:03:40 +01:00
parent 45ef6ac56d
commit 08b61eb50b
39 changed files with 221 additions and 240 deletions

View File

@ -822,8 +822,9 @@ AUTH_LEVEL_DEFAULT = AUTH_LEVEL_NORMAL
def create_auth_file():
import stat
import configmanager
auth_file = configmanager.get_config_dir("auth")
import deluge.configmanager
auth_file = deluge.configmanager.get_config_dir("auth")
# Check for auth file and create if necessary
if not os.path.exists(auth_file):
fd = open(auth_file, "w")
@ -835,11 +836,11 @@ def create_auth_file():
def create_localclient_account(append=False):
import configmanager
import random
from hashlib import sha1 as sha
import deluge.configmanager
auth_file = configmanager.get_config_dir("auth")
auth_file = deluge.configmanager.get_config_dir("auth")
if not os.path.exists(auth_file):
create_auth_file()

View File

@ -16,7 +16,7 @@ from twisted.python.failure import Failure
from twisted.web import client, http
from twisted.web.error import PageRedirect
from common import get_version
from deluge.common import get_version
log = logging.getLogger(__name__)

View File

@ -33,5 +33,5 @@
#
#
UI_PATH = __path__[0]
from main import start
from deluge.ui.console.main import start
assert start # silence pyflakes

View File

@ -18,9 +18,9 @@ import sys
from twisted.internet import defer
import deluge.component as component
from colors import strip_colors
from deluge.error import DelugeError
from deluge.ui.client import client
from deluge.ui.console.colors import strip_colors
log = logging.getLogger(__name__)

View File

@ -10,10 +10,10 @@
import logging
import time
import colors
import deluge.component as component
from deluge.common import windows_check
from deluge.ui.client import client
from deluge.ui.console import colors
log = logging.getLogger(__name__)

View File

@ -20,11 +20,10 @@ import sys
from twisted.internet import defer, reactor
import colors
import deluge.common
import deluge.component as component
from deluge.ui.client import client
from deluge.ui.console import UI_PATH
from deluge.ui.console import colors, UI_PATH
from deluge.ui.console.eventlog import EventLog
from deluge.ui.console.statusbars import StatusBars
from deluge.ui.coreconfig import CoreConfig
@ -298,7 +297,7 @@ class ConsoleUI(component.Component):
print("Sorry, couldn't find any commands")
return
else:
from commander import Commander
from deluge.ui.console.commander import Commander
cmdr = Commander(cmds)
if daemon:
cmdr.exec_args(args, *daemon)
@ -334,7 +333,7 @@ Please use commands from the command line, eg:\n
# pass it the function that handles commands
colors.init_colors()
self.statusbars = StatusBars()
from modes.connectionmanager import ConnectionManager
from deluge.ui.console.modes.connectionmanager import ConnectionManager
self.stdscr = stdscr
self.screen = ConnectionManager(stdscr, self.encoding)
self.eventlog = EventLog()

View File

@ -13,11 +13,11 @@ import os
import deluge.common as common
import deluge.component as component
import format_utils
from basemode import BaseMode
from deluge.ui.client import client
from input_popup import InputPopup
from popup import MessagePopup
from deluge.ui.console import format_utils
from deluge.ui.console.basemode import BaseMode
from deluge.ui.console.input_popup import InputPopup
from deluge.ui.console.popup import MessagePopup
try:
import curses

View File

@ -10,21 +10,21 @@
import logging
from collections import deque
import column as console_column
import deluge.common
import deluge.component as component
import format_utils
from addtorrents import AddTorrents
from basemode import BaseMode
import deluge.ui.console.column
from deluge.configmanager import ConfigManager
from deluge.ui.client import client
from eventview import EventView
from input_popup import InputPopup
from legacy import Legacy
from popup import MessagePopup, Popup, SelectablePopup
from preferences import Preferences
from torrent_actions import ACTION, torrent_actions_popup
from torrentdetail import TorrentDetail
from deluge.ui.console import format_utils
from deluge.ui.console.addtorrents import AddTorrents
from deluge.ui.console.basemode import BaseMode
from deluge.ui.console.eventview import EventView
from deluge.ui.console.input_popup import InputPopup
from deluge.ui.console.legacy import Legacy
from deluge.ui.console.popup import MessagePopup, Popup, SelectablePopup
from deluge.ui.console.preferences import Preferences
from deluge.ui.console.torrent_actions import ACTION, torrent_actions_popup
from deluge.ui.console.torrentdetail import TorrentDetail
try:
import curses
@ -365,7 +365,7 @@ class AllTorrents(BaseMode, component.Component):
if ("show_%s" % pref) not in self.config or self.config["show_%s" % pref]]
self.__columns = [prefs_to_names[col] for col in self.__cols_to_show]
self.__status_fields = console_column.get_required_fields(self.__columns)
self.__status_fields = deluge.ui.console.column.get_required_fields(self.__columns)
# we always need these, even if we're not displaying them
for rf in ["state", "name", "queue", "progress"]:
@ -870,7 +870,7 @@ class AllTorrents(BaseMode, component.Component):
#Because dots are slow
sorted_ids = self._sorted_ids
curstate = self.curstate
gcv = console_column.get_column_value
gcv = deluge.ui.console.column.get_column_value
fr = format_utils.format_row
cols = self.__columns
colw = self.column_widths

View File

@ -10,7 +10,7 @@
import logging
import deluge.common
import format_utils
from deluge.ui.console import format_utils
log = logging.getLogger(__name__)

View File

@ -15,13 +15,12 @@ import time
from collections import deque
import deluge.component as component
import deluge.ui.client
from alltorrents import AllTorrents
from basemode import BaseMode
from deluge.configmanager import ConfigManager
from deluge.ui.client import client
from input_popup import InputPopup
from popup import MessagePopup, SelectablePopup
from deluge.ui.client import Client, client
from deluge.ui.console.alltorrents import AllTorrents
from deluge.ui.console.basemode import BaseMode
from deluge.ui.console.input_popup import InputPopup
from deluge.ui.console.popup import MessagePopup, SelectablePopup
try:
import curses
@ -83,7 +82,7 @@ class ConnectionManager(BaseMode):
del self.statuses[host_id]
for host in self.config["hosts"]:
c = deluge.ui.client.Client()
c = Client()
hadr = host[1]
port = host[2]
user = host[3]

View File

@ -10,9 +10,9 @@
import logging
import deluge.component as component
import format_utils
from basemode import BaseMode
from deluge.ui.client import client
from deluge.ui.console import format_utils
from deluge.ui.console.basemode import BaseMode
try:
import curses

View File

@ -11,14 +11,9 @@ import re
from collections import deque
import deluge.common
from unicodedata import normalize as ud_normalize
from unicodedata import east_asian_width
try:
import unicodedata
haveud = True
except:
haveud = False
def format_speed(speed):
if (speed > 0):
@ -94,7 +89,7 @@ def trim_string(string, w, have_dbls):
idx = 0
while width < w:
chrs.append(string[idx])
if unicodedata.east_asian_width(string[idx]) in ["W", "F"]:
if east_asian_width(string[idx]) in ["W", "F"]:
width += 2
else:
width += 1
@ -106,20 +101,16 @@ def trim_string(string, w, have_dbls):
else:
return u"%s " % (string[0:w - 1])
#Dots are slow
eaw = unicodedata.east_asian_width
ud_normalize = unicodedata.normalize
def format_column(col, lim):
dbls = 0
#Chosen over isinstance(col, unicode) and col.__class__ == unicode
# for speed - it's ~3 times faster for non-unicode strings and ~1.5
# for unicode strings.
if haveud and col.__class__ is unicode:
if col.__class__ is unicode:
# might have some double width chars
col = ud_normalize("NFC", col)
dbls = sum(eaw(c) in "WF" for c in col)
dbls = sum(east_asian_width(c) in "WF" for c in col)
size = len(col) + dbls
if (size >= lim - 1):
return trim_string(col, lim, dbls > 0)

View File

@ -19,7 +19,7 @@ import os
import os.path
from deluge.ui.console import colors
from popup import ALIGN, Popup
from deluge.ui.console.popup import ALIGN, Popup
log = logging.getLogger(__name__)

View File

@ -23,8 +23,8 @@ from twisted.internet import defer
import deluge.component as component
import deluge.configmanager
import deluge.ui.console.colors as colors
from basemode import BaseMode
from deluge.ui.client import client
from deluge.ui.console.basemode import BaseMode
from deluge.ui.console.modes import format_utils
strwidth = format_utils.strwidth

View File

@ -14,7 +14,7 @@ except ImportError:
import logging
import format_utils
from deluge.ui.console import format_utils
log = logging.getLogger(__name__)

View File

@ -11,12 +11,13 @@ import logging
from collections import deque
import deluge.component as component
from basemode import BaseMode
from deluge.ui.client import client
from popup import MessagePopup
from input_popup import Popup, SelectInput
from preference_panes import (BandwidthPane, CachePane, ColumnsPane, DaemonPane, DownloadsPane, InterfacePane,
NetworkPane, OtherPane, ProxyPane, QueuePane)
from deluge.ui.console.basemode import BaseMode
from deluge.ui.console.input_popup import Popup, SelectInput
from deluge.ui.console.popup import MessagePopup
from deluge.ui.console.preference_panes import (BandwidthPane, CachePane, ColumnsPane, DaemonPane,
DownloadsPane, InterfacePane, NetworkPane, OtherPane,
ProxyPane, QueuePane)
try:
import curses

View File

@ -14,8 +14,8 @@ from twisted.internet import defer
import deluge.component as component
from deluge.ui.client import client
from deluge.ui.console import colors
from input_popup import InputPopup
from popup import Popup, SelectablePopup
from deluge.ui.console.input_popup import InputPopup
from deluge.ui.console.popup import Popup, SelectablePopup
log = logging.getLogger(__name__)

View File

@ -12,14 +12,13 @@ from collections import deque
from sys import maxint
import deluge.component as component
import deluge.ui.console.colors as colors
import format_utils
from basemode import BaseMode
from deluge.common import fdate, FILE_PRIORITY, fsize, ftime
from deluge.ui.client import client
from deluge.common import fsize, fdate, ftime, FILE_PRIORITY
from input_popup import InputPopup
from popup import MessagePopup, SelectablePopup
from torrent_actions import ACTION, torrent_actions_popup
from deluge.ui.console import colors, format_utils
from deluge.ui.console.basemode import BaseMode
from deluge.ui.console.input_popup import InputPopup
from deluge.ui.console.popup import MessagePopup, SelectablePopup
from deluge.ui.console.torrent_actions import ACTION, torrent_actions_popup
try:
import curses

View File

@ -1,2 +1,2 @@
from gtkui import start
from deluge.ui.gtkui.gtkui import start
assert start # silence pyflakes

View File

@ -10,9 +10,9 @@
import gtk
import pygtk
import common
import deluge.common
from deluge.common import get_pixmap, get_version, open_url_in_browser
from deluge.ui.client import client
from deluge.ui.gtkui.common import get_deluge_icon
pygtk.require('2.0')
@ -20,14 +20,14 @@ pygtk.require('2.0')
class AboutDialog:
def __init__(self):
def url_hook(dialog, url):
deluge.common.open_url_in_browser(url)
open_url_in_browser(url)
gtk.about_dialog_set_url_hook(url_hook)
self.about = gtk.AboutDialog()
self.about.set_position(gtk.WIN_POS_CENTER)
self.about.set_name("Deluge")
self.about.set_program_name(_("Deluge"))
version = deluge.common.get_version()
version = get_version()
self.about.set_copyright(_('Copyright 2007-2011 Deluge Team'))
self.about.set_comments(
@ -249,10 +249,8 @@ class AboutDialog:
self.about.set_website("http://deluge-torrent.org")
self.about.set_website_label("deluge-torrent.org")
self.about.set_icon(common.get_deluge_icon())
self.about.set_logo(gtk.gdk.pixbuf_new_from_file(
deluge.common.get_pixmap("deluge-about.png")
))
self.about.set_icon(get_deluge_icon())
self.about.set_logo(gtk.gdk.pixbuf_new_from_file(get_pixmap("deluge-about.png")))
if client.connected():
if not client.is_classicmode():

View File

@ -18,16 +18,16 @@ import pygtk
import twisted.web.client
import twisted.web.error
import common
import deluge.common
import deluge.component as component
import deluge.ui.common
import dialogs
from deluge.configmanager import ConfigManager
from deluge.httpdownloader import download_file
from deluge.ui.client import client
from deluge.ui.common import TorrentInfo
from deluge.ui.gtkui.common import reparent_iter
from deluge.ui.gtkui.dialogs import ErrorDialog
from deluge.ui.gtkui.path_chooser import PathChooser
from torrentview_data_funcs import cell_data_size
from deluge.ui.gtkui.torrentview_data_funcs import cell_data_size
pygtk.require('2.0')
@ -186,15 +186,15 @@ class AddTorrentDialog(component.Component):
for filename in filenames:
# Get the torrent data from the torrent file
try:
info = deluge.ui.common.TorrentInfo(filename)
info = TorrentInfo(filename)
except Exception as ex:
log.debug("Unable to open torrent file: %s", ex)
dialogs.ErrorDialog(_("Invalid File"), ex, self.dialog).run()
ErrorDialog(_("Invalid File"), ex, self.dialog).run()
continue
if info.info_hash in self.files:
log.debug("Trying to add a duplicate torrent!")
dialogs.ErrorDialog(
ErrorDialog(
_("Duplicate Torrent"),
_("You cannot add the same torrent twice."),
self.dialog
@ -607,7 +607,7 @@ class AddTorrentDialog(component.Component):
elif deluge.common.is_magnet(url):
self.add_from_magnets([url])
else:
dialogs.ErrorDialog(
ErrorDialog(
_("Invalid URL"),
"%s %s" % (url, _("is not a valid URL.")),
self.dialog
@ -656,7 +656,7 @@ class AddTorrentDialog(component.Component):
else:
log.debug("Download failed: %s", result)
dialog.destroy()
dialogs.ErrorDialog(
ErrorDialog(
_("Download Failed"), "%s %s" % (_("Failed to download:"), url),
details=result.getErrorMessage(), parent=self.dialog
).run()
@ -830,7 +830,7 @@ class AddTorrentDialog(component.Component):
parent = self.files_treestore.append(parent, [True, s, 0, -1, False, gtk.STOCK_DIRECTORY])
self.files_treestore[itr][1] = split_text[-1]
common.reparent_iter(self.files_treestore, itr, parent)
reparent_iter(self.files_treestore, itr, parent)
else:
# Update the row's text
self.files_treestore[itr][1] = new_text
@ -891,7 +891,7 @@ class AddTorrentDialog(component.Component):
self.files_treestore[itr][1] = split_text[-1] + os.path.sep
# Now re-parent itr to parent
common.reparent_iter(self.files_treestore, itr, parent)
reparent_iter(self.files_treestore, itr, parent)
itr = parent
# We need to re-expand the view because it might contracted

View File

@ -15,16 +15,14 @@ import time
import gtk
from twisted.internet import reactor
import common
import deluge.common
import deluge.component as component
import deluge.configmanager
import deluge.ui.client
import dialogs
from deluge.configmanager import ConfigManager
from deluge.common import resource_filename
from deluge.configmanager import ConfigManager, get_config_dir
from deluge.error import AuthenticationRequired, BadLoginError, IncompatibleClient
from deluge.ui.client import client
from deluge.ui.client import Client, client
from deluge.ui.common import get_localhost_auth
from deluge.ui.gtkui.common import get_deluge_icon, get_logo
from deluge.ui.gtkui.dialogs import AuthenticationDialog, ErrorDialog
log = logging.getLogger(__name__)
@ -88,7 +86,7 @@ class ConnectionManager(component.Component):
pass
def __load_config(self):
auth_file = deluge.configmanager.get_config_dir("auth")
auth_file = get_config_dir("auth")
if not os.path.exists(auth_file):
from deluge.common import create_localclient_account
create_localclient_account()
@ -116,15 +114,15 @@ class ConnectionManager(component.Component):
# Get the gtk builder file for the connection manager
self.builder = gtk.Builder()
# The main dialog
self.builder.add_from_file(deluge.common.resource_filename(
self.builder.add_from_file(resource_filename(
"deluge.ui.gtkui", os.path.join("glade", "connection_manager.ui")
))
# The add host dialog
self.builder.add_from_file(deluge.common.resource_filename(
self.builder.add_from_file(resource_filename(
"deluge.ui.gtkui", os.path.join("glade", "connection_manager.addhost.ui")
))
# The ask password dialog
self.builder.add_from_file(deluge.common.resource_filename(
self.builder.add_from_file(resource_filename(
"deluge.ui.gtkui", os.path.join("glade", "connection_manager.askpassword.ui")
))
self.window = component.get("MainWindow")
@ -133,13 +131,13 @@ class ConnectionManager(component.Component):
self.connection_manager = self.builder.get_object("connection_manager")
self.connection_manager.set_transient_for(self.window.window)
self.connection_manager.set_icon(common.get_deluge_icon())
self.connection_manager.set_icon(get_deluge_icon())
self.builder.get_object("image1").set_from_pixbuf(common.get_logo(32))
self.builder.get_object("image1").set_from_pixbuf(get_logo(32))
self.askpassword_dialog = self.builder.get_object("askpassword_dialog")
self.askpassword_dialog.set_transient_for(self.connection_manager)
self.askpassword_dialog.set_icon(common.get_deluge_icon())
self.askpassword_dialog.set_icon(get_deluge_icon())
self.askpassword_dialog_entry = self.builder.get_object("askpassword_dialog_entry")
self.hostlist = self.builder.get_object("hostlist")
@ -342,7 +340,7 @@ class ConnectionManager(component.Component):
continue
# Create a new Client instance
c = deluge.ui.client.Client()
c = Client()
d = c.connect(host, port, skip_authentication=True)
d.addCallback(on_connect, c, host_id)
d.addErrback(on_connect_failed, host_id)
@ -456,7 +454,7 @@ class ConnectionManager(component.Component):
except OSError as ex:
from errno import ENOENT
if ex.errno == ENOENT:
dialogs.ErrorDialog(
ErrorDialog(
_("Unable to start daemon!"),
_("Deluge cannot find the 'deluged' executable, it is "
"likely that you forgot to install the deluged package "
@ -468,7 +466,7 @@ class ConnectionManager(component.Component):
import traceback
import sys
tb = sys.exc_info()
dialogs.ErrorDialog(
ErrorDialog(
_("Unable to start daemon!"),
_("Please examine the details for more information."),
details=traceback.format_exc(tb[2])).run()
@ -505,7 +503,7 @@ class ConnectionManager(component.Component):
if reason.check(AuthenticationRequired, BadLoginError):
log.debug("PasswordRequired exception")
dialog = dialogs.AuthenticationDialog(reason.value.message, reason.value.username)
dialog = AuthenticationDialog(reason.value.message, reason.value.username)
def dialog_finished(response_id, host, port, user):
if response_id == gtk.RESPONSE_OK:
@ -516,7 +514,7 @@ class ConnectionManager(component.Component):
return d
elif reason.trap(IncompatibleClient):
dialog = dialogs.ErrorDialog(
dialog = ErrorDialog(
_("Incompatible Client"), reason.value.message
)
return dialog.run()
@ -532,7 +530,7 @@ class ConnectionManager(component.Component):
if not self.builder.get_object("chk_autostart").get_active():
msg += '\n' + _("Auto-starting the daemon locally is not enabled. "
"See \"Options\" on the \"Connection Manager\".")
dialogs.ErrorDialog(_("Failed To Connect"), msg).run()
ErrorDialog(_("Failed To Connect"), msg).run()
def on_button_connect_clicked(self, widget=None):
model, row = self.hostlist.get_selection().get_selected()
@ -553,7 +551,7 @@ class ConnectionManager(component.Component):
if (status == "Offline" and self.builder.get_object("chk_autostart").get_active() and
host in ("127.0.0.1", "localhost")):
if not self.start_daemon(port, deluge.configmanager.get_config_dir()):
if not self.start_daemon(port, get_config_dir()):
log.debug("Failed to auto-start daemon")
return
return self.__connect(
@ -591,7 +589,6 @@ class ConnectionManager(component.Component):
self.add_host(hostname, port_spinbutton.get_value_as_int(),
username, password)
except Exception as ex:
from deluge.ui.gtkui.dialogs import ErrorDialog
ErrorDialog(_("Error Adding Host"), ex).run()
username_entry.set_text("")
@ -675,7 +672,7 @@ class ConnectionManager(component.Component):
self.add_host(DEFAULT_HOST, DEFAULT_PORT, *get_localhost_auth())
# ..and start the daemon.
self.start_daemon(
DEFAULT_PORT, deluge.configmanager.get_config_dir()
DEFAULT_PORT, get_config_dir()
)
return
@ -702,7 +699,7 @@ class ConnectionManager(component.Component):
client.daemon.shutdown().addCallback(on_daemon_shutdown)
elif user and password:
# Create a new client instance
c = deluge.ui.client.Client()
c = Client()
def on_connect(d, c):
log.debug("on_connect")
@ -711,7 +708,7 @@ class ConnectionManager(component.Component):
c.connect(host, port, user, password).addCallback(on_connect, c)
elif status == "Offline":
self.start_daemon(port, deluge.configmanager.get_config_dir())
self.start_daemon(port, get_config_dir())
reactor.callLater(0.8, self.__update_list)
def on_button_refresh_clicked(self, widget):

View File

@ -15,8 +15,8 @@ import gobject
import gtk
from twisted.internet.threads import deferToThread
import deluge.common
import deluge.component as component
from deluge.common import get_path_size, is_url, resource_filename
from deluge.configmanager import ConfigManager
from deluge.ui.client import client
from deluge.ui.gtkui.torrentview_data_funcs import cell_data_size
@ -29,19 +29,19 @@ class CreateTorrentDialog:
self.builder = gtk.Builder()
# The main dialog
self.builder.add_from_file(deluge.common.resource_filename(
self.builder.add_from_file(resource_filename(
"deluge.ui.gtkui", os.path.join("glade", "create_torrent_dialog.ui")
))
# The remote path dialog
self.builder.add_from_file(deluge.common.resource_filename(
self.builder.add_from_file(resource_filename(
"deluge.ui.gtkui", os.path.join("glade", "create_torrent_dialog.remote_path.ui")
))
# The remote save dialog
self.builder.add_from_file(deluge.common.resource_filename(
self.builder.add_from_file(resource_filename(
"deluge.ui.gtkui", os.path.join("glade", "create_torrent_dialog.remote_save.ui")
))
# The progress dialog
self.builder.add_from_file(deluge.common.resource_filename(
self.builder.add_from_file(resource_filename(
"deluge.ui.gtkui", os.path.join("glade", "create_torrent_dialog.progress.ui")
))
@ -150,7 +150,7 @@ class CreateTorrentDialog:
path = result.decode('utf-8')
self.files_treestore.clear()
self.files_treestore.append(None, [result, gtk.STOCK_FILE, deluge.common.get_path_size(path)])
self.files_treestore.append(None, [result, gtk.STOCK_FILE, get_path_size(path)])
self.adjust_piece_size()
chooser.destroy()
@ -178,7 +178,7 @@ class CreateTorrentDialog:
path = result.decode('utf-8')
self.files_treestore.clear()
self.files_treestore.append(None, [result, gtk.STOCK_OPEN, deluge.common.get_path_size(path)])
self.files_treestore.append(None, [result, gtk.STOCK_OPEN, get_path_size(path)])
self.adjust_piece_size()
chooser.destroy()
@ -289,9 +289,8 @@ class CreateTorrentDialog:
webseeds = []
b = self.builder.get_object("textview_webseeds").get_buffer()
lines = b.get_text(b.get_start_iter(), b.get_end_iter()).strip().split("\n")
import deluge.common
for l in lines:
if deluge.common.is_url(l):
if is_url(l):
webseeds.append(l)
# Get the piece length in bytes
combo = self.builder.get_object("combo_piece_size")
@ -406,7 +405,7 @@ class CreateTorrentDialog:
def _on_button_add_clicked(self, widget):
log.debug("_on_button_add_clicked")
builder = gtk.Builder()
builder.add_from_file(deluge.common.resource_filename(
builder.add_from_file(resource_filename(
"deluge.ui.gtkui", os.path.join("glade", "edit_trackers.add.ui")
))
dialog = builder.get_object("add_tracker_dialog")
@ -427,7 +426,7 @@ class CreateTorrentDialog:
self.config["createtorrent.trackers"] = lines
log.debug("lines: %s", lines)
for l in lines:
if deluge.common.is_url(l):
if is_url(l):
trackers.append(l)
# We are going to add these trackers to the highest tier + 1

View File

@ -10,9 +10,9 @@
import gtk
from twisted.internet import defer
import deluge.common
import deluge.component as component
from deluge.ui.gtkui import common
from deluge.common import get_pixmap, osx_check, windows_check
from deluge.ui.gtkui.common import get_deluge_icon
class BaseDialog(gtk.Dialog):
@ -34,7 +34,7 @@ class BaseDialog(gtk.Dialog):
flags=gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT | gtk.DIALOG_NO_SEPARATOR,
buttons=buttons)
self.set_icon(common.get_deluge_icon())
self.set_icon(get_deluge_icon())
self.connect("delete-event", self._on_delete_event)
self.connect("response", self._on_response)
@ -46,9 +46,9 @@ class BaseDialog(gtk.Dialog):
image = gtk.Image()
if not gtk.stock_lookup(icon) and (icon.endswith(".svg") or icon.endswith(".png")):
# Hack for Windows since it doesn't support svg
if icon.endswith(".svg") and (deluge.common.windows_check() or deluge.common.osx_check()):
if icon.endswith(".svg") and (windows_check() or osx_check()):
icon = icon.rpartition(".svg")[0] + "16.png"
pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(deluge.common.get_pixmap(icon), 32, 32)
pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(get_pixmap(icon), 32, 32)
image.set_from_pixbuf(pixbuf)
else:
image.set_from_stock(icon, gtk.ICON_SIZE_DIALOG)

View File

@ -13,10 +13,10 @@ import os.path
import gtk
from twisted.internet import defer
import common
import deluge.common
import deluge.component as component
from deluge.common import is_url, resource_filename
from deluge.ui.client import client
from deluge.ui.gtkui.common import get_deluge_icon
log = logging.getLogger(__name__)
@ -26,15 +26,15 @@ class EditTrackersDialog:
self.torrent_id = torrent_id
self.builder = gtk.Builder()
# Main dialog
self.builder.add_from_file(deluge.common.resource_filename(
self.builder.add_from_file(resource_filename(
"deluge.ui.gtkui", os.path.join("glade", "edit_trackers.ui")
))
# add tracker dialog
self.builder.add_from_file(deluge.common.resource_filename(
self.builder.add_from_file(resource_filename(
"deluge.ui.gtkui", os.path.join("glade", "edit_trackers.add.ui")
))
# edit tracker dialog
self.builder.add_from_file(deluge.common.resource_filename(
self.builder.add_from_file(resource_filename(
"deluge.ui.gtkui", os.path.join("glade", "edit_trackers.edit.ui")
))
@ -44,7 +44,7 @@ class EditTrackersDialog:
self.add_tracker_dialog.set_transient_for(self.dialog)
self.edit_tracker_entry = self.builder.get_object("edit_tracker_entry")
self.edit_tracker_entry.set_transient_for(self.dialog)
self.dialog.set_icon(common.get_deluge_icon())
self.dialog.set_icon(get_deluge_icon())
if parent is not None:
self.dialog.set_transient_for(parent)
@ -195,7 +195,7 @@ class EditTrackersDialog:
b = textview.get_buffer()
lines = b.get_text(b.get_start_iter(), b.get_end_iter()).strip().split("\n")
for l in lines:
if deluge.common.is_url(l):
if is_url(l):
trackers.append(l)
for tracker in trackers:

View File

@ -15,11 +15,12 @@ import gobject
import gtk
import gtk.gdk
import deluge.common
import deluge.component as component
from deluge.common import FILE_PRIORITY, open_file, show_file
from deluge.ui.client import client
from deluge.ui.gtkui.common import load_pickled_state_file, reparent_iter, save_pickled_state_file
from deluge.ui.gtkui.torrentdetails import Tab
from deluge.ui.gtkui.torrentview_data_funcs import cell_data_size
log = logging.getLogger(__name__)
@ -49,7 +50,7 @@ def cell_priority(column, cell, model, row, data):
cell.set_property("text", "")
return
priority = model.get_value(row, data)
cell.set_property("text", _t(deluge.common.FILE_PRIORITY[priority]))
cell.set_property("text", _t(FILE_PRIORITY[priority]))
def cell_priority_icon(column, cell, model, row, data):
@ -58,13 +59,13 @@ def cell_priority_icon(column, cell, model, row, data):
cell.set_property("stock-id", None)
return
priority = model.get_value(row, data)
if deluge.common.FILE_PRIORITY[priority] == "Do Not Download":
if FILE_PRIORITY[priority] == "Do Not Download":
cell.set_property("stock-id", gtk.STOCK_NO)
elif deluge.common.FILE_PRIORITY[priority] == "Normal Priority":
elif FILE_PRIORITY[priority] == "Normal Priority":
cell.set_property("stock-id", gtk.STOCK_YES)
elif deluge.common.FILE_PRIORITY[priority] == "High Priority":
elif FILE_PRIORITY[priority] == "High Priority":
cell.set_property("stock-id", gtk.STOCK_GO_UP)
elif deluge.common.FILE_PRIORITY[priority] == "Highest Priority":
elif FILE_PRIORITY[priority] == "Highest Priority":
cell.set_property("stock-id", gtk.STOCK_GOTO_TOP)
@ -124,7 +125,7 @@ class FilesTab(Tab):
column = gtk.TreeViewColumn(_("Size"))
render = gtk.CellRendererText()
column.pack_start(render, False)
column.set_cell_data_func(render, deluge.ui.gtkui.torrentview_data_funcs.cell_data_size, 1)
column.set_cell_data_func(render, cell_data_size, 1)
column.set_sort_column_id(1)
column.set_clickable(True)
column.set_resizable(True)
@ -324,7 +325,7 @@ class FilesTab(Tab):
filepath = os.path.join(status["download_location"], *path)
log.debug("Open file '%s'", filepath)
timestamp = gtk.get_current_event_time()
deluge.common.open_file(filepath, timestamp=timestamp)
open_file(filepath, timestamp=timestamp)
def _on_show_file(self, status):
paths = self.listview.get_selection().get_selected_rows()[1]
@ -337,7 +338,7 @@ class FilesTab(Tab):
filepath = os.path.join(status["download_location"], *path)
log.debug("Show file '%s'", filepath)
timestamp = gtk.get_current_event_time()
deluge.common.show_file(filepath, timestamp=timestamp)
show_file(filepath, timestamp=timestamp)
## The following 3 methods create the folder/file view in the treeview
def prepare_file_store(self, files):
@ -551,22 +552,22 @@ class FilesTab(Tab):
def _on_menuitem_donotdownload_activate(self, menuitem):
self._set_file_priorities_on_user_change(
self.get_selected_files(),
deluge.common.FILE_PRIORITY["Do Not Download"])
FILE_PRIORITY["Do Not Download"])
def _on_menuitem_normal_activate(self, menuitem):
self._set_file_priorities_on_user_change(
self.get_selected_files(),
deluge.common.FILE_PRIORITY["Normal Priority"])
FILE_PRIORITY["Normal Priority"])
def _on_menuitem_high_activate(self, menuitem):
self._set_file_priorities_on_user_change(
self.get_selected_files(),
deluge.common.FILE_PRIORITY["High Priority"])
FILE_PRIORITY["High Priority"])
def _on_menuitem_highest_activate(self, menuitem):
self._set_file_priorities_on_user_change(
self.get_selected_files(),
deluge.common.FILE_PRIORITY["Highest Priority"])
FILE_PRIORITY["Highest Priority"])
def _on_menuitem_expand_all_activate(self, menuitem):
self.listview.expand_all()

View File

@ -21,28 +21,29 @@ reactor = gtk2reactor.install()
import deluge.common
import deluge.component as component
import deluge.error
import dialogs
from addtorrentdialog import AddTorrentDialog
from deluge.configmanager import ConfigManager, get_config_dir
from deluge.error import AuthenticationRequired, BadLoginError, DaemonRunningError
from deluge.ui.client import client
from deluge.ui.gtkui.addtorrentdialog import AddTorrentDialog
from deluge.ui.gtkui.common import associate_magnet_links
from deluge.ui.gtkui.dialogs import AuthenticationDialog, ErrorDialog, YesNoDialog
from deluge.ui.gtkui.filtertreeview import FilterTreeView
from deluge.ui.gtkui.ipcinterface import IPCInterface
from deluge.ui.gtkui.mainwindow import MainWindow
from deluge.ui.gtkui.menubar import MenuBar
from deluge.ui.gtkui.pluginmanager import PluginManager
from deluge.ui.gtkui.preferences import Preferences
from deluge.ui.gtkui.queuedtorrents import QueuedTorrents
from deluge.ui.gtkui.sidebar import SideBar
from deluge.ui.gtkui.statusbar import StatusBar
from deluge.ui.gtkui.systemtray import SystemTray
from deluge.ui.gtkui.toolbar import ToolBar
from deluge.ui.gtkui.torrentdetails import TorrentDetails
from deluge.ui.gtkui.torrentview import TorrentView
from deluge.ui.sessionproxy import SessionProxy
from deluge.ui.tracker_icons import TrackerIcons
from deluge.ui.ui import _UI
from filtertreeview import FilterTreeView
from ipcinterface import IPCInterface
from mainwindow import MainWindow
from menubar import MenuBar
from pluginmanager import PluginManager
from preferences import Preferences
from queuedtorrents import QueuedTorrents
from sidebar import SideBar
from statusbar import StatusBar
from systemtray import SystemTray
from toolbar import ToolBar
from torrentdetails import TorrentDetails
from torrentview import TorrentView
gobject.set_prgname("deluge")
@ -235,7 +236,7 @@ class GtkUI(object):
from deluge.ui.gtkui.ipcinterface import process_args
process_args([filename])
self.osxapp.connect("NSApplicationOpenFile", nsapp_open_file)
from menubar_osx import menubar_osx
from deluge.ui.gtkui.menubar_osx import menubar_osx
menubar_osx(self, self.osxapp)
self.osxapp.ready()
@ -243,7 +244,7 @@ class GtkUI(object):
self.plugins = PluginManager()
# Late import because of setting up translations
from connectionmanager import ConnectionManager
from deluge.ui.gtkui.connectionmanager import ConnectionManager
# Show the connection manager
self.connectionmanager = ConnectionManager()
@ -310,8 +311,8 @@ class GtkUI(object):
try:
try:
client.start_classic_mode()
except deluge.error.DaemonRunningError:
d = dialogs.YesNoDialog(
except DaemonRunningError:
d = YesNoDialog(
_("Switch to Thin Client Mode?"),
_("A Deluge daemon process (deluged) is already running. "
"To use Standalone mode, stop this daemon and restart Deluge."
@ -321,7 +322,7 @@ class GtkUI(object):
d.addCallback(on_dialog_response)
except ImportError as ex:
if "No module named libtorrent" in ex.message:
d = dialogs.YesNoDialog(
d = YesNoDialog(
_("Switch to Thin Client Mode?"),
_("Only Thin Client mode is available because libtorrent is not installed."
"\n\n"
@ -336,14 +337,14 @@ class GtkUI(object):
except Exception:
import traceback
tb = sys.exc_info()
ed = dialogs.ErrorDialog(
ed = ErrorDialog(
_("Error Starting Core"),
_("An error occurred starting the core component required to run Deluge in Standalone mode."
"\n\n"
"Please see the details below for more information."), details=traceback.format_exc(tb[2])).run()
def on_ed_response(response):
d = dialogs.YesNoDialog(
d = YesNoDialog(
_("Switch to Thin Client Mode?"),
_("Unable to start Standalone mode would you like to continue in Thin Client mode?")
).run()
@ -379,7 +380,7 @@ class GtkUI(object):
)
log.debug("Localhost started: %s", try_connect)
if not try_connect:
dialogs.ErrorDialog(
ErrorDialog(
_("Error Starting Daemon"),
_("There was an error starting the daemon "
"process. Try running it from a console "
@ -399,12 +400,9 @@ class GtkUI(object):
if not try_counter:
return
if reason.check(deluge.error.AuthenticationRequired,
deluge.error.BadLoginError):
if reason.check(AuthenticationRequired, BadLoginError):
log.debug("PasswordRequired exception")
dialog = dialogs.AuthenticationDialog(
reason.value.message, reason.value.username
)
dialog = AuthenticationDialog(reason.value.message, reason.value.username)
def dialog_finished(response_id, host, port):
if response_id == gtk.RESPONSE_OK:
@ -412,8 +410,7 @@ class GtkUI(object):
0.5, do_connect, try_counter - 1,
host, port, dialog.get_username(),
dialog.get_password())
dialog.run().addCallback(dialog_finished,
host, port)
dialog.run().addCallback(dialog_finished, host, port)
return
log.info("Connection to host failed..")

View File

@ -20,9 +20,9 @@ import twisted.internet.error
from twisted.internet import reactor
from twisted.internet.protocol import ClientFactory, Factory, Protocol
import deluge.common
import deluge.component as component
from deluge.configmanager import ConfigManager
from deluge.common import is_magnet, is_url, windows_check
from deluge.configmanager import ConfigManager, get_config_dir
from deluge.ui.client import client
try:
@ -66,11 +66,11 @@ class IPCClientFactory(ClientFactory):
class IPCInterface(component.Component):
def __init__(self, args):
component.Component.__init__(self, "IPCInterface")
ipc_dir = deluge.configmanager.get_config_dir("ipc")
ipc_dir = get_config_dir("ipc")
if not os.path.exists(ipc_dir):
os.makedirs(ipc_dir)
socket = os.path.join(ipc_dir, "deluge-gtk")
if deluge.common.windows_check():
if windows_check():
# If we're on windows we need to check the global mutex to see if deluge is
# already running.
import win32event
@ -145,7 +145,7 @@ class IPCInterface(component.Component):
process_args(args)
def shutdown(self):
if deluge.common.windows_check():
if windows_check():
import win32api
win32api.CloseHandle(self.mutex)
@ -167,7 +167,7 @@ def process_args(args):
continue
log.debug("arg: %s", arg)
if deluge.common.is_url(arg):
if is_url(arg):
log.debug("Attempting to add url (%s) from external source...", arg)
if config["interactive_add"]:
component.get("AddTorrentDialog").add_from_url(arg)
@ -175,7 +175,7 @@ def process_args(args):
else:
client.core.add_torrent_url(arg, None)
elif deluge.common.is_magnet(arg):
elif is_magnet(arg):
log.debug("Attempting to add magnet (%s) from external source...", arg)
if config["interactive_add"]:
component.get("AddTorrentDialog").add_from_magnets([arg])

View File

@ -17,10 +17,9 @@ import pygtk
import deluge.common
import deluge.component as component
import deluge.error
import dialogs
from deluge.configmanager import ConfigManager
from deluge.ui.client import client
from deluge.ui.gtkui.dialogs import ErrorDialog, OtherDialog
from deluge.ui.gtkui.path_chooser import PathChooser
pygtk.require('2.0')
@ -242,7 +241,7 @@ class MenuBar(component.Component):
def on_menuitem_createtorrent_activate(self, data=None):
log.debug("on_menuitem_createtorrent_activate")
from createtorrentdialog import CreateTorrentDialog
from deluge.ui.gtkui.createtorrentdialog import CreateTorrentDialog
CreateTorrentDialog().show()
def on_menuitem_quitdaemon_activate(self, data=None):
@ -280,7 +279,7 @@ class MenuBar(component.Component):
def on_menuitem_edittrackers_activate(self, data=None):
log.debug("on_menuitem_edittrackers_activate")
from edittrackersdialog import EditTrackersDialog
from deluge.ui.gtkui.edittrackersdialog import EditTrackersDialog
dialog = EditTrackersDialog(
component.get("TorrentView").get_selected_torrent(),
component.get("MainWindow").window)
@ -290,7 +289,7 @@ class MenuBar(component.Component):
log.debug("on_menuitem_remove_activate")
torrent_ids = component.get("TorrentView").get_selected_torrents()
if torrent_ids:
from removetorrentdialog import RemoveTorrentDialog
from deluge.ui.gtkui.removetorrentdialog import RemoveTorrentDialog
RemoveTorrentDialog(torrent_ids).run()
def on_menuitem_recheck_activate(self, data=None):
@ -393,7 +392,7 @@ class MenuBar(component.Component):
def on_menuitem_about_activate(self, data=None):
log.debug("on_menuitem_about_activate")
from aboutdialog import AboutDialog
from deluge.ui.gtkui.aboutdialog import AboutDialog
AboutDialog().run()
def on_menuitem_set_unlimited(self, widget):
@ -448,7 +447,7 @@ class MenuBar(component.Component):
options["stop_at_ratio"] = True
client.core.set_torrent_options(torrent_ids, options)
dialog = dialogs.OtherDialog(*other_dialog)
dialog = OtherDialog(*other_dialog)
dialog.run().addCallback(set_value)
torrent_ids = component.get("TorrentView").get_selected_torrents()
@ -542,7 +541,7 @@ class MenuBar(component.Component):
log.debug("Setting torrent owner \"%s\" on %s", username, update_torrents)
def failed_change_owner(failure):
dialogs.ErrorDialog(
ErrorDialog(
_("Ownership Change Error"),
_("There was an error while trying changing ownership."),
self.window.window, details=failure.value.logable()

View File

@ -9,10 +9,10 @@
import logging
import common
import deluge.common
import deluge.component as component
from deluge.configmanager import ConfigManager
from deluge.ui.gtkui.common import get_logo
log = logging.getLogger(__name__)
@ -58,7 +58,7 @@ class Notification:
message = deluge.common.xml_encode("%s\n%s %i %s" % (status["name"],
_("Including"), status["num_files"], _("files")))
self.note = pynotify.Notification(title, message)
self.note.set_icon_from_pixbuf(common.get_logo(48))
self.note.set_icon_from_pixbuf(get_logo(48))
if not self.note.show():
log.warning("pynotify failed to show notification")

View File

@ -15,14 +15,13 @@ from hashlib import sha1 as sha
import gtk
import pygtk
import common
import deluge.common
import deluge.component as component
import deluge.configmanager
import dialogs
from deluge.configmanager import ConfigManager
from deluge.configmanager import ConfigManager, get_config_dir
from deluge.error import AuthManagerError, NotAuthorizedError
from deluge.ui.client import client
from deluge.ui.gtkui.common import associate_magnet_links, get_deluge_icon
from deluge.ui.gtkui.dialogs import AccountDialog, ErrorDialog, InformationDialog, YesNoDialog
from deluge.ui.gtkui.path_chooser import PathChooser
pygtk.require('2.0')
@ -50,7 +49,7 @@ class Preferences(component.Component):
))
self.pref_dialog = self.builder.get_object("pref_dialog")
self.pref_dialog.set_transient_for(component.get("MainWindow").window)
self.pref_dialog.set_icon(common.get_deluge_icon())
self.pref_dialog.set_icon(get_deluge_icon())
self.treeview = self.builder.get_object("treeview")
self.notebook = self.builder.get_object("notebook")
self.gtkui_config = ConfigManager("gtkui.conf")
@ -728,7 +727,7 @@ class Preferences(component.Component):
else:
active = self.language_combo.get_active()
if active == -1:
dialog = dialogs.InformationDialog(
dialog = InformationDialog(
_("Attention"),
_("You must choose a language")
)
@ -739,7 +738,7 @@ class Preferences(component.Component):
new_gtkui_config["language"] = model.get(model.get_iter(active), 0)[0]
if new_gtkui_config["language"] != self.gtkui_config["language"]:
dialog = dialogs.InformationDialog(
dialog = InformationDialog(
_("Attention"),
_("You must now restart the deluge UI for the changes to take effect.")
)
@ -784,7 +783,7 @@ class Preferences(component.Component):
self.gtkui_config["classic_mode"] = not new_gtkui_in_classic_mode
self.builder.get_object("radio_classic").set_active(self.gtkui_config["classic_mode"])
self.builder.get_object("radio_thinclient").set_active(not self.gtkui_config["classic_mode"])
dialog = dialogs.YesNoDialog(
dialog = YesNoDialog(
_("Switching client mode..."),
_("Your current session will be stopped. Do you wish to continue?")
)
@ -984,7 +983,7 @@ class Preferences(component.Component):
filename = os.path.split(filepath)[1]
shutil.copyfile(
filepath,
os.path.join(deluge.configmanager.get_config_dir(), "plugins", filename))
os.path.join(get_config_dir(), "plugins", filename))
component.get("PluginManager").scan_for_plugins()
@ -1047,7 +1046,7 @@ class Preferences(component.Component):
self.builder.get_object(show_entry).show()
def _on_button_associate_magnet_clicked(self, widget):
common.associate_magnet_links(True)
associate_magnet_links(True)
def _get_accounts_tab_data(self):
def on_ok(accounts):
@ -1058,7 +1057,7 @@ class Preferences(component.Component):
if failure.type == NotAuthorizedError:
self.accounts_frame.hide()
else:
dialogs.ErrorDialog(
ErrorDialog(
_("Server Side Error"),
_("An error ocurred on the server"),
parent=self.pref_dialog, details=failure.getErrorMessage()
@ -1104,7 +1103,7 @@ class Preferences(component.Component):
self.builder.get_object("accounts_delete").set_sensitive(False)
def _on_accounts_add_clicked(self, widget):
dialog = dialogs.AccountDialog(
dialog = AccountDialog(
levels_mapping=client.auth_levels_mapping,
parent=self.pref_dialog
)
@ -1128,13 +1127,13 @@ class Preferences(component.Component):
def add_fail(failure):
if failure.type == AuthManagerError:
dialogs.ErrorDialog(
ErrorDialog(
_("Error Adding Account"),
_("Authentication failed"),
parent=self.pref_dialog, details=failure.getErrorMessage()
).run()
else:
dialogs.ErrorDialog(
ErrorDialog(
_("Error Adding Account"),
_("An error ocurred while adding account"),
parent=self.pref_dialog, details=failure.getErrorMessage()
@ -1152,7 +1151,7 @@ class Preferences(component.Component):
if not itr:
return
dialog = dialogs.AccountDialog(
dialog = AccountDialog(
model[itr][ACCOUNTS_USERNAME],
model[itr][ACCOUNTS_PASSWORD],
model[itr][ACCOUNTS_LEVEL],
@ -1167,7 +1166,7 @@ class Preferences(component.Component):
model.set_value(itr, ACCOUNTS_LEVEL, dialog.get_authlevel())
def update_fail(failure):
dialogs.ErrorDialog(
ErrorDialog(
_("Error Updating Account"),
_("An error ocurred while updating account"),
parent=self.pref_dialog, details=failure.getErrorMessage()
@ -1191,7 +1190,7 @@ class Preferences(component.Component):
header = _("Remove Account")
text = _("Are you sure you wan't do remove the account with the "
"username \"%(username)s\"?" % dict(username=username))
dialog = dialogs.YesNoDialog(header, text, parent=self.pref_dialog)
dialog = YesNoDialog(header, text, parent=self.pref_dialog)
def dialog_finished(response_id):
def remove_ok(rc):
@ -1199,13 +1198,13 @@ class Preferences(component.Component):
def remove_fail(failure):
if failure.type == AuthManagerError:
dialogs.ErrorDialog(
ErrorDialog(
_("Error Removing Account"),
_("Auhentication failed"),
parent=self.pref_dialog, details=failure.getErrorMessage()
).run()
else:
dialogs.ErrorDialog(
ErrorDialog(
_("Error Removing Account"),
_("An error ocurred while removing account"),
parent=self.pref_dialog, details=failure.getErrorMessage()

View File

@ -13,10 +13,10 @@ import os.path
import gobject
import gtk
import common
import deluge.common
import deluge.component as component
from deluge.configmanager import ConfigManager
from deluge.ui.gtkui.common import get_logo
from deluge.ui.gtkui.ipcinterface import process_args
log = logging.getLogger(__name__)
@ -35,7 +35,7 @@ class QueuedTorrents(component.Component):
)
self.builder.get_object("chk_autoadd").set_active(self.config["autoadd_queued"])
self.dialog = self.builder.get_object("queued_torrents_dialog")
self.dialog.set_icon(common.get_logo(32))
self.dialog.set_icon(get_logo(32))
self.builder.connect_signals({
"on_button_remove_clicked": self.on_button_remove_clicked,

View File

@ -12,12 +12,12 @@ import os
import gtk
import common
import deluge.common
import deluge.component as component
from deluge.configmanager import ConfigManager
from deluge.ui.client import client
from deluge.ui.gtkui import dialogs
from deluge.ui.gtkui.common import build_menu_radio_list, get_logo
try:
import appindicator
@ -104,7 +104,7 @@ class SystemTray(component.Component):
else:
log.debug("Enabling the system tray icon..")
if deluge.common.windows_check() or deluge.common.osx_check():
self.tray = gtk.status_icon_new_from_pixbuf(common.get_logo(32))
self.tray = gtk.status_icon_new_from_pixbuf(get_logo(32))
else:
try:
self.tray = gtk.status_icon_new_from_icon_name("deluge")
@ -237,14 +237,14 @@ class SystemTray(component.Component):
def build_tray_bwsetsubmenu(self):
# Create the Download speed list sub-menu
submenu_bwdownset = common.build_menu_radio_list(
submenu_bwdownset = build_menu_radio_list(
self.config["tray_download_speed_list"], self.on_tray_setbwdown,
self.max_download_speed,
_("KiB/s"), show_notset=True, show_other=True
)
# Create the Upload speed list sub-menu
submenu_bwupset = common.build_menu_radio_list(
submenu_bwupset = build_menu_radio_list(
self.config["tray_upload_speed_list"], self.on_tray_setbwup,
self.max_upload_speed,
_("KiB/s"), show_notset=True, show_other=True

View File

@ -63,12 +63,12 @@ class TorrentDetails(component.Component):
self.tabs = {}
# Add the default tabs
from status_tab import StatusTab
from details_tab import DetailsTab
from files_tab import FilesTab
from peers_tab import PeersTab
from options_tab import OptionsTab
from trackers_tab import TrackersTab
from deluge.ui.gtkui.status_tab import StatusTab
from deluge.ui.gtkui.details_tab import DetailsTab
from deluge.ui.gtkui.files_tab import FilesTab
from deluge.ui.gtkui.peers_tab import PeersTab
from deluge.ui.gtkui.options_tab import OptionsTab
from deluge.ui.gtkui.trackers_tab import TrackersTab
default_tabs = {
"Status": StatusTab,

View File

@ -17,10 +17,10 @@ import pygtk
from twisted.internet import reactor
import deluge.component as component
import listview
import torrentview_data_funcs as funcs
from deluge.ui.client import client
from removetorrentdialog import RemoveTorrentDialog
from deluge.ui.gtkui import torrentview_data_funcs as funcs
from deluge.ui.gtkui.listview import ListView
from deluge.ui.gtkui.removetorrentdialog import RemoveTorrentDialog
pygtk.require('2.0')
@ -199,13 +199,13 @@ class SearchBox(object):
self.search_pending = reactor.callLater(0.7, self.torrentview.update)
class TorrentView(listview.ListView, component.Component):
class TorrentView(ListView, component.Component):
"""TorrentView handles the listing of torrents."""
def __init__(self):
component.Component.__init__(self, "TorrentView", interval=2, depend=["SessionProxy"])
self.window = component.get("MainWindow")
# Call the ListView constructor
listview.ListView.__init__(self, self.window.main_builder.get_object("torrent_view"), "torrentview.state")
ListView.__init__(self, self.window.main_builder.get_object("torrent_view"), "torrentview.state")
log.debug("TorrentView Init..")
# If we have gotten the state yet
@ -352,12 +352,12 @@ class TorrentView(listview.ListView, component.Component):
"""
Saves the state of the torrent view.
"""
listview.ListView.save_state(self, "torrentview.state")
ListView.save_state(self, "torrentview.state")
def remove_column(self, header):
"""Removes the column with the name 'header' from the torrentview"""
self.save_state()
listview.ListView.remove_column(self, header)
ListView.remove_column(self, header)
def set_filter(self, filter_dict):
"""

View File

@ -91,6 +91,6 @@ class TrackersTab(Tab):
def _on_button_edit_trackers_clicked(self, button):
torrent_id = component.get("TorrentView").get_selected_torrent()
if torrent_id:
from edittrackersdialog import EditTrackersDialog
from deluge.ui.gtkui.edittrackersdialog import EditTrackersDialog
dialog = EditTrackersDialog(torrent_id, component.get("MainWindow").window)
dialog.run()

View File

@ -1,2 +1,2 @@
from web import start
from deluge.ui.web.web import start
assert start # silence pyflakes

View File

@ -40,6 +40,7 @@ class AuthError(Exception):
# Import after as json_api imports the above AuthError and AUTH_LEVEL_DEFAULT
from deluge.ui.web.json_api import export, JSONComponent # isort:skip
def make_checksum(session_id):
return reduce(lambda x, y: x + y, map(ord, session_id))

View File

@ -18,7 +18,7 @@ from deluge.ui.ui import _UI, UI
class WebUI(UI):
def __init__(self, args):
import server
from deluge.ui.web import server
deluge_web = server.DelugeWeb()
deluge_web.start()
@ -111,7 +111,7 @@ class Web(_UI):
self.options.user = pwd.getpwnam(self.options.user)[2]
os.setuid(self.options.user)
import server
from deluge.ui.web import server
self.__server = server.DelugeWeb()
if self.options.base: