diff --git a/src/__init__.py b/src/__init__.py index 8b1378917..1c955a98c 100644 --- a/src/__init__.py +++ b/src/__init__.py @@ -1 +1,14 @@ +import gettext +import locale +import os +from common import INSTALL_PREFIX + +APP = 'deluge' +DIR = os.path.join(INSTALL_PREFIX, 'share', 'locale') +locale.setlocale(locale.LC_ALL, '') +locale.bindtextdomain(APP, DIR) +locale.textdomain(APP) +gettext.bindtextdomain(APP, DIR) +gettext.textdomain(APP) +gettext.install(APP, DIR) diff --git a/src/common.py b/src/common.py index 7c7efb52b..2da70dab8 100644 --- a/src/common.py +++ b/src/common.py @@ -107,6 +107,8 @@ def ftime(seconds): return 'unknown' def fpriority(priority): + from core import PRIORITY_DICT + return PRIORITY_DICT[priority] def get_glade_file(fname): @@ -147,9 +149,6 @@ def fetch_url(url): return None -def N_(arg): - return arg - # Encryption States class EncState: forced, enabled, disabled = range(3) @@ -159,14 +158,3 @@ class EncLevel: class ProxyType: none, socks4, socks5, socks5_pw, http, http_pw = range(6) - -# Priorities -PRIORITY_DONT_DOWNLOAD = 0 -PRIORITY_NORMAL = 1 -PRIORITY_HIGH = 2 -PRIORITY_HIGHEST = 5 - -PRIORITY_DICT = {PRIORITY_DONT_DOWNLOAD: N_("Don't download"), - PRIORITY_NORMAL: N_("Normal"), - PRIORITY_HIGH: N_("High"), - PRIORITY_HIGHEST: N_("Highest")} diff --git a/src/core.py b/src/core.py index b9c15c3a4..e3eff7cef 100644 --- a/src/core.py +++ b/src/core.py @@ -55,11 +55,9 @@ import re import shutil import statvfs import time -import gettext + import deluge_core import pref -import common -import locale # Constants @@ -82,14 +80,6 @@ PREF_FUNCTIONS = { "use_natpmp" : deluge_core.use_natpmp, "use_utpex" : deluge_core.use_utpex, } -APP = 'deluge' -DIR = os.path.join(common.INSTALL_PREFIX, 'share', 'locale') -locale.setlocale(locale.LC_ALL, '') -locale.bindtextdomain(APP, DIR) -locale.textdomain(APP) -gettext.bindtextdomain(APP, DIR) -gettext.textdomain(APP) -gettext.install(APP, DIR) STATE_MESSAGES = (_("Queued"), _("Checking"), @@ -99,6 +89,18 @@ STATE_MESSAGES = (_("Queued"), _("Finished"), _("Seeding"), _("Allocating")) + +# Priorities +PRIORITY_DONT_DOWNLOAD = 0 +PRIORITY_NORMAL = 1 +PRIORITY_HIGH = 2 +PRIORITY_HIGHEST = 5 + +PRIORITY_DICT = {PRIORITY_DONT_DOWNLOAD: _("Don't download"), + PRIORITY_NORMAL: _("Normal"), + PRIORITY_HIGH: _("High"), + PRIORITY_HIGHEST: _("Highest")} + # Exceptions class DelugeError(Exception): diff --git a/src/interface.py b/src/interface.py index 03cf98e25..3d1bdfcf3 100644 --- a/src/interface.py +++ b/src/interface.py @@ -34,10 +34,8 @@ import os.path from itertools import izip -import gettext import gobject import gtk -import locale import pygtk pygtk.require('2.0') @@ -52,15 +50,6 @@ import tab_files class DelugeGTK: def __init__(self): - APP = 'deluge' - DIR = os.path.join(common.INSTALL_PREFIX, 'share', 'locale') - locale.setlocale(locale.LC_ALL, '') - locale.bindtextdomain(APP, DIR) - locale.textdomain(APP) - gettext.bindtextdomain(APP, DIR) - gettext.textdomain(APP) - gettext.install(APP, DIR) - self.ipc_manager = ipc_manager.Manager(self) #Start the Deluge Manager: self.manager = core.Manager(common.CLIENT_CODE, common.CLIENT_VERSION, @@ -72,7 +61,7 @@ class DelugeGTK: self.plugins.scan_for_plugins() self.config = self.manager.get_config() #Set up the interface: - self.wtree = gtk.glade.XML(common.get_glade_file("delugegtk.glade"), domain=APP) + self.wtree = gtk.glade.XML(common.get_glade_file("delugegtk.glade"), domain='deluge') self.window = self.wtree.get_widget("main_window") self.toolbar = self.wtree.get_widget("tb_middle") self.window.drag_dest_set(gtk.DEST_DEFAULT_ALL,[('text/uri-list', 0, 80)], gtk.gdk.ACTION_COPY) diff --git a/src/tab_files.py b/src/tab_files.py index dd7ce155d..7c8732a7a 100644 --- a/src/tab_files.py +++ b/src/tab_files.py @@ -35,9 +35,9 @@ from itertools import izip import gobject import gtk -import gtk.glade import common +import core import dgtk import pref @@ -102,10 +102,10 @@ class FilesBaseManager(object): def priority_clicked(self, widget): widget_name = widget.get_name() - priority = {'priority_dont_download': common.PRIORITY_DONT_DOWNLOAD, - 'priority_normal': common.PRIORITY_NORMAL, - 'priority_high': common.PRIORITY_HIGH, - 'priority_highest': common.PRIORITY_HIGHEST}[widget_name] + priority = {'priority_dont_download': core.PRIORITY_DONT_DOWNLOAD, + 'priority_normal': core.PRIORITY_NORMAL, + 'priority_high': core.PRIORITY_HIGH, + 'priority_highest': core.PRIORITY_HIGHEST}[widget_name] selected_paths = self.file_view.get_selection().get_selected_rows()[1] for path in selected_paths: @@ -205,7 +205,7 @@ class FilesDialogManager(FilesBaseManager): def prepare_file_store(self): for file in self.dumped_torrent: self.file_store.append([file['path'], file['size'], - common.PRIORITY_NORMAL]) + core.PRIORITY_NORMAL]) def priority_clicked(self, widget): if self.config.get("use_compact_storage"):