diff --git a/deluge/tests/test_files_tab.py b/deluge/tests/test_files_tab.py index 8e522aa1d..a205fb218 100644 --- a/deluge/tests/test_files_tab.py +++ b/deluge/tests/test_files_tab.py @@ -37,7 +37,7 @@ class FilesTabTestCase(BaseTestCase): raise unittest.SkipTest('GTKUI dependencies not available') common.set_tmp_config_dir() - ConfigManager('gtkui.conf', defaults=DEFAULT_PREFS) + ConfigManager('gtk3ui.conf', defaults=DEFAULT_PREFS) self.mainwindow = MainWindow() self.filestab = FilesTab() self.t_id = '1' diff --git a/deluge/tests/test_torrentview.py b/deluge/tests/test_torrentview.py index 6ff95c8f6..dc7dd1350 100644 --- a/deluge/tests/test_torrentview.py +++ b/deluge/tests/test_torrentview.py @@ -111,7 +111,7 @@ class TorrentviewTestCase(BaseTestCase): common.set_tmp_config_dir() # MainWindow loads this config file, so lets make sure it contains the defaults - ConfigManager('gtkui.conf', defaults=DEFAULT_PREFS) + ConfigManager('gtk3ui.conf', defaults=DEFAULT_PREFS) self.mainwindow = MainWindow() self.torrentview = TorrentView() self.torrentdetails = TorrentDetails() diff --git a/deluge/ui/gtkui/__init__.py b/deluge/ui/gtk3/__init__.py similarity index 97% rename from deluge/ui/gtkui/__init__.py rename to deluge/ui/gtk3/__init__.py index c57c468f0..3b9d2b123 100644 --- a/deluge/ui/gtkui/__init__.py +++ b/deluge/ui/gtk3/__init__.py @@ -40,7 +40,7 @@ class Gtk(UI): def start(self): super(Gtk, self).start() - from deluge.ui.gtkui.gtkui import GtkUI + from .gtkui import GtkUI import deluge.common def run(options): diff --git a/deluge/ui/gtkui/aboutdialog.py b/deluge/ui/gtk3/aboutdialog.py similarity index 99% rename from deluge/ui/gtkui/aboutdialog.py rename to deluge/ui/gtk3/aboutdialog.py index cb3ed43c8..a7dff4948 100644 --- a/deluge/ui/gtkui/aboutdialog.py +++ b/deluge/ui/gtk3/aboutdialog.py @@ -14,7 +14,8 @@ from gi.repository import Gtk import deluge.component as component from deluge.common import get_version, open_url_in_browser, windows_check from deluge.ui.client import client -from deluge.ui.gtkui.common import get_deluge_icon, get_pixbuf + +from .common import get_deluge_icon, get_pixbuf class AboutDialog(object): diff --git a/deluge/ui/gtkui/addtorrentdialog.py b/deluge/ui/gtk3/addtorrentdialog.py similarity index 98% rename from deluge/ui/gtkui/addtorrentdialog.py rename to deluge/ui/gtk3/addtorrentdialog.py index 7c6843ffa..6c5f81a55 100644 --- a/deluge/ui/gtkui/addtorrentdialog.py +++ b/deluge/ui/gtk3/addtorrentdialog.py @@ -24,15 +24,12 @@ 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 ( - get_clipboard_text, - listview_replace_treestore, - reparent_iter, -) -from deluge.ui.gtkui.dialogs import ErrorDialog -from deluge.ui.gtkui.edittrackersdialog import trackers_tiers_from_text -from deluge.ui.gtkui.path_chooser import PathChooser -from deluge.ui.gtkui.torrentview_data_funcs import cell_data_size + +from .common import get_clipboard_text, listview_replace_treestore, reparent_iter +from .dialogs import ErrorDialog +from .edittrackersdialog import trackers_tiers_from_text +from .path_chooser import PathChooser +from .torrentview_data_funcs import cell_data_size log = logging.getLogger(__name__) @@ -44,20 +41,19 @@ class AddTorrentDialog(component.Component): # The base dialog self.builder.add_from_file( deluge.common.resource_filename( - 'deluge.ui.gtkui', os.path.join('glade', 'add_torrent_dialog.ui') + __package__, os.path.join('glade', 'add_torrent_dialog.ui') ) ) # The infohash dialog self.builder.add_from_file( deluge.common.resource_filename( - 'deluge.ui.gtkui', - os.path.join('glade', 'add_torrent_dialog.infohash.ui'), + __package__, os.path.join('glade', 'add_torrent_dialog.infohash.ui') ) ) # The url dialog self.builder.add_from_file( deluge.common.resource_filename( - 'deluge.ui.gtkui', os.path.join('glade', 'add_torrent_dialog.url.ui') + __package__, os.path.join('glade', 'add_torrent_dialog.url.ui') ) ) @@ -679,7 +675,7 @@ class AddTorrentDialog(component.Component): chooser.add_filter(file_filter) # Load the 'default_load_path' from the config - self.config = ConfigManager('gtkui.conf') + self.config = ConfigManager('gtk3ui.conf') if self.config['default_load_path'] is not None: chooser.set_current_folder(self.config['default_load_path']) diff --git a/deluge/ui/gtkui/common.py b/deluge/ui/gtk3/common.py similarity index 97% rename from deluge/ui/gtkui/common.py rename to deluge/ui/gtk3/common.py index 57e309c80..2fd8fde83 100644 --- a/deluge/ui/gtkui/common.py +++ b/deluge/ui/gtk3/common.py @@ -284,7 +284,7 @@ def save_pickled_state_file(filename, state): """ from deluge.configmanager import get_config_dir - filepath = os.path.join(get_config_dir(), 'gtkui_state', filename) + filepath = os.path.join(get_config_dir(), 'gtk3ui_state', filename) filepath_bak = filepath + '.bak' filepath_tmp = filepath + '.tmp' @@ -321,11 +321,10 @@ def load_pickled_state_file(filename): """ from deluge.configmanager import get_config_dir - filepath = os.path.join(get_config_dir(), 'gtkui_state', filename) + filepath = os.path.join(get_config_dir(), 'gtk3ui_state', filename) filepath_bak = filepath + '.bak' - old_data_filepath = os.path.join(get_config_dir(), filename) - for _filepath in (filepath, filepath_bak, old_data_filepath): + for _filepath in (filepath, filepath_bak): log.info('Opening %s for load: %s', filename, _filepath) try: with open(_filepath, 'rb') as _file: diff --git a/deluge/ui/gtkui/connectionmanager.py b/deluge/ui/gtk3/connectionmanager.py similarity index 98% rename from deluge/ui/gtkui/connectionmanager.py rename to deluge/ui/gtk3/connectionmanager.py index 915c9046b..614758b09 100644 --- a/deluge/ui/gtkui/connectionmanager.py +++ b/deluge/ui/gtk3/connectionmanager.py @@ -21,10 +21,11 @@ from deluge.common import resource_filename, windows_check from deluge.configmanager import ConfigManager, get_config_dir from deluge.error import AuthenticationRequired, BadLoginError, IncompatibleClient from deluge.ui.client import Client, client -from deluge.ui.gtkui.common import get_clipboard_text -from deluge.ui.gtkui.dialogs import AuthenticationDialog, ErrorDialog from deluge.ui.hostlist import DEFAULT_PORT, LOCALHOST, HostList +from .common import get_clipboard_text +from .dialogs import AuthenticationDialog, ErrorDialog + try: from urllib.parse import urlparse except ImportError: @@ -68,7 +69,7 @@ def cell_render_status(column, cell, model, row, data): class ConnectionManager(component.Component): def __init__(self): component.Component.__init__(self, 'ConnectionManager') - self.gtkui_config = ConfigManager('gtkui.conf') + self.gtkui_config = ConfigManager('gtk3ui.conf') self.hostlist = HostList() self.running = False @@ -90,7 +91,7 @@ class ConnectionManager(component.Component): self.builder = Gtk.Builder() self.builder.add_from_file( resource_filename( - 'deluge.ui.gtkui', os.path.join('glade', 'connection_manager.ui') + __package__, os.path.join('glade', 'connection_manager.ui') ) ) self.connection_manager = self.builder.get_object('connection_manager') @@ -387,8 +388,7 @@ class ConnectionManager(component.Component): """ self.builder.add_from_file( resource_filename( - 'deluge.ui.gtkui', - os.path.join('glade', 'connection_manager.addhost.ui'), + __package__, os.path.join('glade', 'connection_manager.addhost.ui') ) ) dialog = self.builder.get_object('addhost_dialog') diff --git a/deluge/ui/gtkui/createtorrentdialog.py b/deluge/ui/gtk3/createtorrentdialog.py similarity index 93% rename from deluge/ui/gtkui/createtorrentdialog.py rename to deluge/ui/gtk3/createtorrentdialog.py index 224bea0ef..e9339634b 100644 --- a/deluge/ui/gtkui/createtorrentdialog.py +++ b/deluge/ui/gtk3/createtorrentdialog.py @@ -21,11 +21,12 @@ 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.edittrackersdialog import ( + +from .edittrackersdialog import ( last_tier_trackers_from_liststore, trackers_tiers_from_text, ) -from deluge.ui.gtkui.torrentview_data_funcs import cell_data_size +from .torrentview_data_funcs import cell_data_size log = logging.getLogger(__name__) @@ -37,35 +38,18 @@ class CreateTorrentDialog(object): def show(self): self.builder = Gtk.Builder() - # The main dialog - self.builder.add_from_file( - resource_filename( - 'deluge.ui.gtkui', os.path.join('glade', 'create_torrent_dialog.ui') + ui_filenames = [ + 'create_torrent_dialog.ui', + 'create_torrent_dialog.remote_path.ui', + 'create_torrent_dialog.remote_save.ui', + 'create_torrent_dialog.progress.ui', + ] + for filename in ui_filenames: + self.builder.add_from_file( + resource_filename(__package__, os.path.join('glade', filename)) ) - ) - # The remote path dialog - 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( - resource_filename( - 'deluge.ui.gtkui', - os.path.join('glade', 'create_torrent_dialog.remote_save.ui'), - ) - ) - # The progress dialog - self.builder.add_from_file( - resource_filename( - 'deluge.ui.gtkui', - os.path.join('glade', 'create_torrent_dialog.progress.ui'), - ) - ) - self.config = ConfigManager('gtkui.conf') + self.config = ConfigManager('gtk3ui.conf') self.dialog = self.builder.get_object('create_torrent_dialog') self.dialog.set_transient_for(component.get('MainWindow').window) @@ -478,7 +462,7 @@ class CreateTorrentDialog(object): builder = Gtk.Builder() builder.add_from_file( resource_filename( - 'deluge.ui.gtkui', os.path.join('glade', 'edit_trackers.add.ui') + __package__, os.path.join('glade', 'edit_trackers.add.ui') ) ) dialog = builder.get_object('add_tracker_dialog') diff --git a/deluge/ui/gtkui/details_tab.py b/deluge/ui/gtk3/details_tab.py similarity index 95% rename from deluge/ui/gtkui/details_tab.py rename to deluge/ui/gtk3/details_tab.py index 06f9e944d..98a60ceb5 100644 --- a/deluge/ui/gtkui/details_tab.py +++ b/deluge/ui/gtk3/details_tab.py @@ -14,8 +14,9 @@ from xml.sax.saxutils import escape as xml_escape import deluge.component as component from deluge.common import fdate, fsize, is_url -from deluge.ui.gtkui.tab_data_funcs import fdate_or_dash, fpieces_num_size -from deluge.ui.gtkui.torrentdetails import Tab + +from .tab_data_funcs import fdate_or_dash, fpieces_num_size +from .torrentdetails import Tab log = logging.getLogger(__name__) diff --git a/deluge/ui/gtkui/dialogs.py b/deluge/ui/gtk3/dialogs.py similarity index 99% rename from deluge/ui/gtkui/dialogs.py rename to deluge/ui/gtk3/dialogs.py index 36015486e..f310ce53a 100644 --- a/deluge/ui/gtkui/dialogs.py +++ b/deluge/ui/gtk3/dialogs.py @@ -16,7 +16,8 @@ from twisted.internet import defer import deluge.component as component from deluge.common import windows_check -from deluge.ui.gtkui.common import get_deluge_icon, get_pixbuf_at_size + +from .common import get_deluge_icon, get_pixbuf_at_size class BaseDialog(Gtk.Dialog): diff --git a/deluge/ui/gtkui/edittrackersdialog.py b/deluge/ui/gtk3/edittrackersdialog.py similarity index 96% rename from deluge/ui/gtkui/edittrackersdialog.py rename to deluge/ui/gtk3/edittrackersdialog.py index 2a4bb7494..8ea2c726d 100644 --- a/deluge/ui/gtkui/edittrackersdialog.py +++ b/deluge/ui/gtk3/edittrackersdialog.py @@ -19,7 +19,8 @@ import deluge.component as component from deluge.common import is_url, resource_filename from deluge.configmanager import ConfigManager from deluge.ui.client import client -from deluge.ui.gtkui.common import get_deluge_icon + +from .common import get_deluge_icon log = logging.getLogger(__name__) @@ -80,24 +81,22 @@ class EditTrackersDialog(object): def __init__(self, torrent_id, parent=None): self.torrent_id = torrent_id self.builder = Gtk.Builder() - self.gtkui_config = ConfigManager('gtkui.conf') + self.gtkui_config = ConfigManager('gtk3ui.conf') # Main dialog self.builder.add_from_file( - resource_filename( - 'deluge.ui.gtkui', os.path.join('glade', 'edit_trackers.ui') - ) + resource_filename(__package__, os.path.join('glade', 'edit_trackers.ui')) ) # add tracker dialog self.builder.add_from_file( resource_filename( - 'deluge.ui.gtkui', os.path.join('glade', 'edit_trackers.add.ui') + __package__, os.path.join('glade', 'edit_trackers.add.ui') ) ) # edit tracker dialog self.builder.add_from_file( resource_filename( - 'deluge.ui.gtkui', os.path.join('glade', 'edit_trackers.edit.ui') + __package__, os.path.join('glade', 'edit_trackers.edit.ui') ) ) diff --git a/deluge/ui/gtkui/files_tab.py b/deluge/ui/gtk3/files_tab.py similarity index 99% rename from deluge/ui/gtkui/files_tab.py rename to deluge/ui/gtk3/files_tab.py index fb8e347bf..c5db59061 100644 --- a/deluge/ui/gtkui/files_tab.py +++ b/deluge/ui/gtk3/files_tab.py @@ -21,14 +21,15 @@ import deluge.component as component from deluge.common import open_file, show_file from deluge.ui.client import client from deluge.ui.common import FILE_PRIORITY -from deluge.ui.gtkui.common import ( + +from .common import ( listview_replace_treestore, 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 +from .torrentdetails import Tab +from .torrentview_data_funcs import cell_data_size log = logging.getLogger(__name__) diff --git a/deluge/ui/gtkui/filtertreeview.py b/deluge/ui/gtk3/filtertreeview.py similarity index 98% rename from deluge/ui/gtkui/filtertreeview.py rename to deluge/ui/gtk3/filtertreeview.py index d761a22d5..dbbdd2c15 100644 --- a/deluge/ui/gtkui/filtertreeview.py +++ b/deluge/ui/gtk3/filtertreeview.py @@ -23,7 +23,8 @@ import deluge.component as component from deluge.common import TORRENT_STATE, resource_filename from deluge.configmanager import ConfigManager from deluge.ui.client import client -from deluge.ui.gtkui.common import get_pixbuf, get_pixbuf_at_size + +from .common import get_pixbuf, get_pixbuf_at_size log = logging.getLogger(__name__) @@ -48,7 +49,7 @@ FILTER_COLUMN = 5 class FilterTreeView(component.Component): def __init__(self): component.Component.__init__(self, 'FilterTreeView', interval=2) - self.config = ConfigManager('gtkui.conf') + self.config = ConfigManager('gtk3ui.conf') self.tracker_icons = component.get('TrackerIcons') @@ -107,9 +108,7 @@ class FilterTreeView(component.Component): # filtertree menu builder = Gtk.Builder() builder.add_from_file( - resource_filename( - 'deluge.ui.gtkui', os.path.join('glade', 'filtertree_menu.ui') - ) + resource_filename(__package__, os.path.join('glade', 'filtertree_menu.ui')) ) self.menu = builder.get_object('filtertree_menu') builder.connect_signals(self) diff --git a/deluge/ui/gtkui/glade/add_torrent_dialog.infohash.ui b/deluge/ui/gtk3/glade/add_torrent_dialog.infohash.ui similarity index 100% rename from deluge/ui/gtkui/glade/add_torrent_dialog.infohash.ui rename to deluge/ui/gtk3/glade/add_torrent_dialog.infohash.ui diff --git a/deluge/ui/gtkui/glade/add_torrent_dialog.ui b/deluge/ui/gtk3/glade/add_torrent_dialog.ui similarity index 100% rename from deluge/ui/gtkui/glade/add_torrent_dialog.ui rename to deluge/ui/gtk3/glade/add_torrent_dialog.ui diff --git a/deluge/ui/gtkui/glade/add_torrent_dialog.url.ui b/deluge/ui/gtk3/glade/add_torrent_dialog.url.ui similarity index 100% rename from deluge/ui/gtkui/glade/add_torrent_dialog.url.ui rename to deluge/ui/gtk3/glade/add_torrent_dialog.url.ui diff --git a/deluge/ui/gtkui/glade/connect_peer_dialog.ui b/deluge/ui/gtk3/glade/connect_peer_dialog.ui similarity index 100% rename from deluge/ui/gtkui/glade/connect_peer_dialog.ui rename to deluge/ui/gtk3/glade/connect_peer_dialog.ui diff --git a/deluge/ui/gtkui/glade/connection_manager.addhost.ui b/deluge/ui/gtk3/glade/connection_manager.addhost.ui similarity index 100% rename from deluge/ui/gtkui/glade/connection_manager.addhost.ui rename to deluge/ui/gtk3/glade/connection_manager.addhost.ui diff --git a/deluge/ui/gtkui/glade/connection_manager.ui b/deluge/ui/gtk3/glade/connection_manager.ui similarity index 100% rename from deluge/ui/gtkui/glade/connection_manager.ui rename to deluge/ui/gtk3/glade/connection_manager.ui diff --git a/deluge/ui/gtkui/glade/create_torrent_dialog.progress.ui b/deluge/ui/gtk3/glade/create_torrent_dialog.progress.ui similarity index 100% rename from deluge/ui/gtkui/glade/create_torrent_dialog.progress.ui rename to deluge/ui/gtk3/glade/create_torrent_dialog.progress.ui diff --git a/deluge/ui/gtkui/glade/create_torrent_dialog.remote_path.ui b/deluge/ui/gtk3/glade/create_torrent_dialog.remote_path.ui similarity index 100% rename from deluge/ui/gtkui/glade/create_torrent_dialog.remote_path.ui rename to deluge/ui/gtk3/glade/create_torrent_dialog.remote_path.ui diff --git a/deluge/ui/gtkui/glade/create_torrent_dialog.remote_save.ui b/deluge/ui/gtk3/glade/create_torrent_dialog.remote_save.ui similarity index 100% rename from deluge/ui/gtkui/glade/create_torrent_dialog.remote_save.ui rename to deluge/ui/gtk3/glade/create_torrent_dialog.remote_save.ui diff --git a/deluge/ui/gtkui/glade/create_torrent_dialog.ui b/deluge/ui/gtk3/glade/create_torrent_dialog.ui similarity index 100% rename from deluge/ui/gtkui/glade/create_torrent_dialog.ui rename to deluge/ui/gtk3/glade/create_torrent_dialog.ui diff --git a/deluge/ui/gtkui/glade/edit_trackers.add.ui b/deluge/ui/gtk3/glade/edit_trackers.add.ui similarity index 100% rename from deluge/ui/gtkui/glade/edit_trackers.add.ui rename to deluge/ui/gtk3/glade/edit_trackers.add.ui diff --git a/deluge/ui/gtkui/glade/edit_trackers.edit.ui b/deluge/ui/gtk3/glade/edit_trackers.edit.ui similarity index 100% rename from deluge/ui/gtkui/glade/edit_trackers.edit.ui rename to deluge/ui/gtk3/glade/edit_trackers.edit.ui diff --git a/deluge/ui/gtkui/glade/edit_trackers.ui b/deluge/ui/gtk3/glade/edit_trackers.ui similarity index 100% rename from deluge/ui/gtkui/glade/edit_trackers.ui rename to deluge/ui/gtk3/glade/edit_trackers.ui diff --git a/deluge/ui/gtkui/glade/filtertree_menu.ui b/deluge/ui/gtk3/glade/filtertree_menu.ui similarity index 100% rename from deluge/ui/gtkui/glade/filtertree_menu.ui rename to deluge/ui/gtk3/glade/filtertree_menu.ui diff --git a/deluge/ui/gtkui/glade/main_window.new_release.ui b/deluge/ui/gtk3/glade/main_window.new_release.ui similarity index 100% rename from deluge/ui/gtkui/glade/main_window.new_release.ui rename to deluge/ui/gtk3/glade/main_window.new_release.ui diff --git a/deluge/ui/gtkui/glade/main_window.tabs.menu_file.ui b/deluge/ui/gtk3/glade/main_window.tabs.menu_file.ui similarity index 100% rename from deluge/ui/gtkui/glade/main_window.tabs.menu_file.ui rename to deluge/ui/gtk3/glade/main_window.tabs.menu_file.ui diff --git a/deluge/ui/gtkui/glade/main_window.tabs.menu_peer.ui b/deluge/ui/gtk3/glade/main_window.tabs.menu_peer.ui similarity index 100% rename from deluge/ui/gtkui/glade/main_window.tabs.menu_peer.ui rename to deluge/ui/gtk3/glade/main_window.tabs.menu_peer.ui diff --git a/deluge/ui/gtkui/glade/main_window.tabs.ui b/deluge/ui/gtk3/glade/main_window.tabs.ui similarity index 100% rename from deluge/ui/gtkui/glade/main_window.tabs.ui rename to deluge/ui/gtk3/glade/main_window.tabs.ui diff --git a/deluge/ui/gtkui/glade/main_window.ui b/deluge/ui/gtk3/glade/main_window.ui similarity index 100% rename from deluge/ui/gtkui/glade/main_window.ui rename to deluge/ui/gtk3/glade/main_window.ui diff --git a/deluge/ui/gtkui/glade/move_storage_dialog.ui b/deluge/ui/gtk3/glade/move_storage_dialog.ui similarity index 100% rename from deluge/ui/gtkui/glade/move_storage_dialog.ui rename to deluge/ui/gtk3/glade/move_storage_dialog.ui diff --git a/deluge/ui/gtkui/glade/other_dialog.ui b/deluge/ui/gtk3/glade/other_dialog.ui similarity index 100% rename from deluge/ui/gtkui/glade/other_dialog.ui rename to deluge/ui/gtk3/glade/other_dialog.ui diff --git a/deluge/ui/gtkui/glade/path_combo_chooser.ui b/deluge/ui/gtk3/glade/path_combo_chooser.ui similarity index 100% rename from deluge/ui/gtkui/glade/path_combo_chooser.ui rename to deluge/ui/gtk3/glade/path_combo_chooser.ui diff --git a/deluge/ui/gtkui/glade/preferences_dialog.ui b/deluge/ui/gtk3/glade/preferences_dialog.ui similarity index 100% rename from deluge/ui/gtkui/glade/preferences_dialog.ui rename to deluge/ui/gtk3/glade/preferences_dialog.ui diff --git a/deluge/ui/gtkui/glade/queuedtorrents.ui b/deluge/ui/gtk3/glade/queuedtorrents.ui similarity index 100% rename from deluge/ui/gtkui/glade/queuedtorrents.ui rename to deluge/ui/gtk3/glade/queuedtorrents.ui diff --git a/deluge/ui/gtkui/glade/remove_torrent_dialog.ui b/deluge/ui/gtk3/glade/remove_torrent_dialog.ui similarity index 100% rename from deluge/ui/gtkui/glade/remove_torrent_dialog.ui rename to deluge/ui/gtk3/glade/remove_torrent_dialog.ui diff --git a/deluge/ui/gtkui/glade/torrent_menu.options.ui b/deluge/ui/gtk3/glade/torrent_menu.options.ui similarity index 100% rename from deluge/ui/gtkui/glade/torrent_menu.options.ui rename to deluge/ui/gtk3/glade/torrent_menu.options.ui diff --git a/deluge/ui/gtkui/glade/torrent_menu.queue.ui b/deluge/ui/gtk3/glade/torrent_menu.queue.ui similarity index 100% rename from deluge/ui/gtkui/glade/torrent_menu.queue.ui rename to deluge/ui/gtk3/glade/torrent_menu.queue.ui diff --git a/deluge/ui/gtkui/glade/torrent_menu.ui b/deluge/ui/gtk3/glade/torrent_menu.ui similarity index 100% rename from deluge/ui/gtkui/glade/torrent_menu.ui rename to deluge/ui/gtk3/glade/torrent_menu.ui diff --git a/deluge/ui/gtkui/glade/tray_menu.ui b/deluge/ui/gtk3/glade/tray_menu.ui similarity index 100% rename from deluge/ui/gtkui/glade/tray_menu.ui rename to deluge/ui/gtk3/glade/tray_menu.ui diff --git a/deluge/ui/gtkui/gtkui.py b/deluge/ui/gtk3/gtkui.py similarity index 91% rename from deluge/ui/gtkui/gtkui.py rename to deluge/ui/gtk3/gtkui.py index 5f3a115c1..f4b38fcb8 100644 --- a/deluge/ui/gtkui/gtkui.py +++ b/deluge/ui/gtk3/gtkui.py @@ -48,28 +48,30 @@ from deluge.common import ( from deluge.configmanager import ConfigManager, get_config_dir from deluge.error import 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.connectionmanager import ConnectionManager -from deluge.ui.gtkui.dialogs import YesNoDialog -from deluge.ui.gtkui.filtertreeview import FilterTreeView -from deluge.ui.gtkui.ipcinterface import IPCInterface, process_args -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.hostlist import LOCALHOST from deluge.ui.sessionproxy import SessionProxy from deluge.ui.tracker_icons import TrackerIcons from deluge.ui.translations_util import set_language, setup_translations +# isort:imports-localfolder +from .addtorrentdialog import AddTorrentDialog +from .common import associate_magnet_links +from .connectionmanager import ConnectionManager +from .dialogs import YesNoDialog +from .filtertreeview import FilterTreeView +from .ipcinterface import IPCInterface, process_args +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 + set_prgname('deluge') log = logging.getLogger(__name__) @@ -175,12 +177,12 @@ class GtkUI(object): # if already set by another program. associate_magnet_links(False) - # Make sure gtkui.conf has at least the defaults set - self.config = ConfigManager('gtkui.conf', DEFAULT_PREFS) + # Make sure gtk3ui.conf has at least the defaults set + self.config = ConfigManager('gtk3ui.conf', DEFAULT_PREFS) # Make sure the gtkui state folder has been created - if not os.path.exists(os.path.join(get_config_dir(), 'gtkui_state')): - os.makedirs(os.path.join(get_config_dir(), 'gtkui_state')) + if not os.path.exists(os.path.join(get_config_dir(), 'gtk3ui_state')): + os.makedirs(os.path.join(get_config_dir(), 'gtk3ui_state')) # Set language if self.config['language'] is not None: @@ -222,7 +224,7 @@ class GtkUI(object): process_args([filename]) self.osxapp.connect('NSApplicationOpenFile', nsapp_open_file) - from deluge.ui.gtkui.menubar_osx import menubar_osx + from .menubar_osx import menubar_osx menubar_osx(self, self.osxapp) self.osxapp.ready() diff --git a/deluge/ui/gtkui/ipcinterface.py b/deluge/ui/gtk3/ipcinterface.py similarity index 98% rename from deluge/ui/gtkui/ipcinterface.py rename to deluge/ui/gtk3/ipcinterface.py index 175d0ccfa..90207d392 100644 --- a/deluge/ui/gtkui/ipcinterface.py +++ b/deluge/ui/gtk3/ipcinterface.py @@ -46,7 +46,7 @@ class IPCProtocolServer(Protocol): pass def dataReceived(self, data): # NOQA: N802 - config = ConfigManager('gtkui.conf') + config = ConfigManager('gtk3ui.conf') data = rencode.loads(data, decode_utf8=True) if not data or config['focus_main_window_on_add']: component.get('MainWindow').present() @@ -192,7 +192,7 @@ def process_args(args): log.debug('Not connected to host.. Adding to queue.') component.get('QueuedTorrents').add_to_queue(args) return - config = ConfigManager('gtkui.conf') + config = ConfigManager('gtk3ui.conf') for arg in args: if not arg.strip(): diff --git a/deluge/ui/gtkui/listview.py b/deluge/ui/gtk3/listview.py similarity index 99% rename from deluge/ui/gtkui/listview.py rename to deluge/ui/gtk3/listview.py index 1968e61b9..fed84c7ab 100644 --- a/deluge/ui/gtkui/listview.py +++ b/deluge/ui/gtk3/listview.py @@ -16,7 +16,8 @@ from gi.repository.Gdk import Event # pylint: disable=ungrouped-imports from gi.repository.GObject import SIGNAL_RUN_LAST, TYPE_NONE, signal_new from deluge.common import decode_bytes -from deluge.ui.gtkui.common import load_pickled_state_file, save_pickled_state_file + +from .common import load_pickled_state_file, save_pickled_state_file # FIXME: ? signal_new( @@ -26,12 +27,8 @@ signal_new( log = logging.getLogger(__name__) -class ListViewColumnState: # pylint: disable=old-style-class - """ - Class used for saving/loading column state. - - Note: This must be old style class to avoid breaking existing user state file. - """ +class ListViewColumnState(object): + """Class used for saving/loading column state.""" def __init__(self, name, position, width, visible, sort, sort_order): self.name = name diff --git a/deluge/ui/gtkui/mainwindow.py b/deluge/ui/gtk3/mainwindow.py similarity index 96% rename from deluge/ui/gtkui/mainwindow.py rename to deluge/ui/gtk3/mainwindow.py index 9403916e0..e5534c0c6 100644 --- a/deluge/ui/gtkui/mainwindow.py +++ b/deluge/ui/gtk3/mainwindow.py @@ -19,12 +19,13 @@ from twisted.internet import reactor from twisted.internet.error import ReactorNotRunning import deluge.component as component -import deluge.ui.gtkui.common from deluge.common import fspeed, resource_filename from deluge.configmanager import ConfigManager from deluge.ui.client import client -from deluge.ui.gtkui.dialogs import PasswordDialog -from deluge.ui.gtkui.ipcinterface import process_args + +from .common import get_deluge_icon +from .dialogs import PasswordDialog +from .ipcinterface import process_args try: import gi @@ -66,7 +67,7 @@ class MainWindow(component.Component): if Wnck: self.screen = Wnck.Screen.get_default() component.Component.__init__(self, 'MainWindow', interval=2) - self.config = ConfigManager('gtkui.conf') + self.config = ConfigManager('gtk3ui.conf') self.main_builder = Gtk.Builder() # Patch this GtkBuilder to avoid connecting signals from elsewhere @@ -86,19 +87,20 @@ class MainWindow(component.Component): self.main_builder.connect_signals = patched_connect_signals # Get Gtk Builder files Main Window, New release dialog, and Tabs. - for filename in ( + ui_filenames = [ 'main_window.ui', 'main_window.new_release.ui', 'main_window.tabs.ui', 'main_window.tabs.menu_file.ui', 'main_window.tabs.menu_peer.ui', - ): + ] + for filename in ui_filenames: self.main_builder.add_from_file( - resource_filename('deluge.ui.gtkui', os.path.join('glade', filename)) + resource_filename(__package__, os.path.join('glade', filename)) ) self.window = self.main_builder.get_object('main_window') - self.window.set_icon(deluge.ui.gtkui.common.get_deluge_icon()) + self.window.set_icon(get_deluge_icon()) self.vpaned = self.main_builder.get_object('vpaned') self.initial_vpaned_position = self.config['window_pane_position'] @@ -330,7 +332,7 @@ class MainWindow(component.Component): def on_newversionavailable_event(self, new_version): if self.config['show_new_releases']: - from deluge.ui.gtkui.new_release_dialog import NewReleaseDialog + from .new_release_dialog import NewReleaseDialog reactor.callLater(5.0, NewReleaseDialog().show, new_version) diff --git a/deluge/ui/gtkui/menubar.py b/deluge/ui/gtk3/menubar.py similarity index 96% rename from deluge/ui/gtkui/menubar.py rename to deluge/ui/gtk3/menubar.py index 35eea9b91..d94d1a950 100644 --- a/deluge/ui/gtkui/menubar.py +++ b/deluge/ui/gtk3/menubar.py @@ -20,8 +20,9 @@ import deluge.common import deluge.component as component 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 + +from .dialogs import ErrorDialog, OtherDialog +from .path_chooser import PathChooser log = logging.getLogger(__name__) @@ -32,25 +33,25 @@ class MenuBar(component.Component): component.Component.__init__(self, 'MenuBar') self.mainwindow = component.get('MainWindow') self.main_builder = self.mainwindow.get_builder() - self.config = ConfigManager('gtkui.conf') + self.config = ConfigManager('gtk3ui.conf') self.builder = Gtk.Builder() # Get the torrent menu from the gtk builder file self.builder.add_from_file( deluge.common.resource_filename( - 'deluge.ui.gtkui', os.path.join('glade', 'torrent_menu.ui') + __package__, os.path.join('glade', 'torrent_menu.ui') ) ) # Get the torrent options menu from the gtk builder file self.builder.add_from_file( deluge.common.resource_filename( - 'deluge.ui.gtkui', os.path.join('glade', 'torrent_menu.options.ui') + __package__, os.path.join('glade', 'torrent_menu.options.ui') ) ) # Get the torrent queue menu from the gtk builder file self.builder.add_from_file( deluge.common.resource_filename( - 'deluge.ui.gtkui', os.path.join('glade', 'torrent_menu.queue.ui') + __package__, os.path.join('glade', 'torrent_menu.queue.ui') ) ) @@ -249,7 +250,7 @@ class MenuBar(component.Component): def on_menuitem_createtorrent_activate(self, data=None): log.debug('on_menuitem_createtorrent_activate') - from deluge.ui.gtkui.createtorrentdialog import CreateTorrentDialog + from .createtorrentdialog import CreateTorrentDialog CreateTorrentDialog().show() @@ -287,7 +288,7 @@ class MenuBar(component.Component): def on_menuitem_edittrackers_activate(self, data=None): log.debug('on_menuitem_edittrackers_activate') - from deluge.ui.gtkui.edittrackersdialog import EditTrackersDialog + from .edittrackersdialog import EditTrackersDialog dialog = EditTrackersDialog( component.get('TorrentView').get_selected_torrent(), self.mainwindow.window @@ -298,7 +299,7 @@ class MenuBar(component.Component): log.debug('on_menuitem_remove_activate') torrent_ids = component.get('TorrentView').get_selected_torrents() if torrent_ids: - from deluge.ui.gtkui.removetorrentdialog import RemoveTorrentDialog + from .removetorrentdialog import RemoveTorrentDialog RemoveTorrentDialog(torrent_ids).run() @@ -332,7 +333,7 @@ class MenuBar(component.Component): builder = Gtk.Builder() builder.add_from_file( deluge.common.resource_filename( - 'deluge.ui.gtkui', os.path.join('glade', 'move_storage_dialog.ui') + __package__, os.path.join('glade', 'move_storage_dialog.ui') ) ) # Keep it referenced: @@ -411,7 +412,7 @@ class MenuBar(component.Component): def on_menuitem_about_activate(self, data=None): log.debug('on_menuitem_about_activate') - from deluge.ui.gtkui.aboutdialog import AboutDialog + from .aboutdialog import AboutDialog AboutDialog().run() diff --git a/deluge/ui/gtkui/menubar_osx.py b/deluge/ui/gtk3/menubar_osx.py similarity index 98% rename from deluge/ui/gtkui/menubar_osx.py rename to deluge/ui/gtk3/menubar_osx.py index 2f282cbcd..1df6fab08 100644 --- a/deluge/ui/gtkui/menubar_osx.py +++ b/deluge/ui/gtk3/menubar_osx.py @@ -31,7 +31,7 @@ def menubar_osx(gtkui, osxapp): menubar = main_builder.get_object('menubar') group = accel_groups_from_object(gtkui.mainwindow.window)[0] - config = ConfigManager('gtkui.conf') + config = ConfigManager('gtk3ui.conf') # NOTE: accel maps doesn't work with glade file format # because of libglade not setting MenuItem accel groups diff --git a/deluge/ui/gtkui/new_release_dialog.py b/deluge/ui/gtk3/new_release_dialog.py similarity index 98% rename from deluge/ui/gtkui/new_release_dialog.py rename to deluge/ui/gtk3/new_release_dialog.py index 246fc0ec8..dffff61e8 100644 --- a/deluge/ui/gtkui/new_release_dialog.py +++ b/deluge/ui/gtk3/new_release_dialog.py @@ -20,7 +20,7 @@ class NewReleaseDialog(object): pass def show(self, available_version): - self.config = ConfigManager('gtkui.conf') + self.config = ConfigManager('gtk3ui.conf') main_builder = component.get('MainWindow').get_builder() self.dialog = main_builder.get_object('new_release_dialog') # Set the version labels diff --git a/deluge/ui/gtkui/options_tab.py b/deluge/ui/gtk3/options_tab.py similarity index 98% rename from deluge/ui/gtkui/options_tab.py rename to deluge/ui/gtk3/options_tab.py index 0e75fabdb..d088ef429 100644 --- a/deluge/ui/gtkui/options_tab.py +++ b/deluge/ui/gtk3/options_tab.py @@ -14,8 +14,9 @@ from gi.repository.Gdk import keyval_name import deluge.component as component from deluge.ui.client import client -from deluge.ui.gtkui.path_chooser import PathChooser -from deluge.ui.gtkui.torrentdetails import Tab + +from .path_chooser import PathChooser +from .torrentdetails import Tab class OptionsTab(Tab): diff --git a/deluge/ui/gtkui/path_chooser.py b/deluge/ui/gtk3/path_chooser.py similarity index 99% rename from deluge/ui/gtkui/path_chooser.py rename to deluge/ui/gtk3/path_chooser.py index 7bf081de0..798a02a7d 100644 --- a/deluge/ui/gtkui/path_chooser.py +++ b/deluge/ui/gtk3/path_chooser.py @@ -13,7 +13,8 @@ import logging import deluge.component as component from deluge.ui.client import client -from deluge.ui.gtkui.path_combo_chooser import PathChooserComboBox + +from .path_combo_chooser import PathChooserComboBox log = logging.getLogger(__name__) diff --git a/deluge/ui/gtkui/path_combo_chooser.py b/deluge/ui/gtk3/path_combo_chooser.py similarity index 99% rename from deluge/ui/gtkui/path_combo_chooser.py rename to deluge/ui/gtk3/path_combo_chooser.py index 0dc0b7383..754240c44 100755 --- a/deluge/ui/gtkui/path_combo_chooser.py +++ b/deluge/ui/gtk3/path_combo_chooser.py @@ -1141,7 +1141,7 @@ class PathChooserComboBox(GtkGI.Box, StoredValuesPopup, GObject.GObject): self.popup_buttonbox = self.builder.get_object('buttonbox') self.builder.add_from_file( resource_filename( - 'deluge.ui.gtkui', os.path.join('glade', 'path_combo_chooser.ui') + __package__, os.path.join('glade', 'path_combo_chooser.ui') ) ) self.button_toggle = self.builder.get_object('button_toggle_dropdown') diff --git a/deluge/ui/gtkui/peers_tab.py b/deluge/ui/gtk3/peers_tab.py similarity index 98% rename from deluge/ui/gtkui/peers_tab.py rename to deluge/ui/gtk3/peers_tab.py index dc729911a..46f8bb4d7 100644 --- a/deluge/ui/gtkui/peers_tab.py +++ b/deluge/ui/gtk3/peers_tab.py @@ -27,14 +27,15 @@ import deluge.common import deluge.component as component from deluge.ui.client import client from deluge.ui.countries import COUNTRIES -from deluge.ui.gtkui.common import ( + +from .common import ( icon_downloading, icon_seeding, load_pickled_state_file, save_pickled_state_file, ) -from deluge.ui.gtkui.torrentdetails import Tab -from deluge.ui.gtkui.torrentview_data_funcs import ( +from .torrentdetails import Tab +from .torrentview_data_funcs import ( cell_data_peer_progress, cell_data_speed_down, cell_data_speed_up, @@ -369,7 +370,7 @@ class PeersTab(Tab): builder = Builder() builder.add_from_file( deluge.common.resource_filename( - 'deluge.ui.gtkui', os.path.join('glade', 'connect_peer_dialog.ui') + __package__, os.path.join('glade', 'connect_peer_dialog.ui') ) ) peer_dialog = builder.get_object('connect_peer_dialog') diff --git a/deluge/ui/gtkui/piecesbar.py b/deluge/ui/gtk3/piecesbar.py similarity index 99% rename from deluge/ui/gtkui/piecesbar.py rename to deluge/ui/gtk3/piecesbar.py index 5e6e259fb..389f2e1f8 100644 --- a/deluge/ui/gtkui/piecesbar.py +++ b/deluge/ui/gtk3/piecesbar.py @@ -41,7 +41,7 @@ class PiecesBar(DrawingArea): del pb, pb_style self.set_size_request(-1, 25) - self.gtkui_config = ConfigManager('gtkui.conf') + self.gtkui_config = ConfigManager('gtk3ui.conf') self.width = self.prev_width = 0 self.height = self.prev_height = 0 diff --git a/deluge/ui/gtkui/pluginmanager.py b/deluge/ui/gtk3/pluginmanager.py similarity index 97% rename from deluge/ui/gtkui/pluginmanager.py rename to deluge/ui/gtk3/pluginmanager.py index 986a60aa5..75a62f825 100644 --- a/deluge/ui/gtkui/pluginmanager.py +++ b/deluge/ui/gtk3/pluginmanager.py @@ -22,9 +22,9 @@ log = logging.getLogger(__name__) class PluginManager(deluge.pluginmanagerbase.PluginManagerBase, component.Component): def __init__(self): component.Component.__init__(self, 'PluginManager') - self.config = ConfigManager('gtkui.conf') + self.config = ConfigManager('gtk3ui.conf') deluge.pluginmanagerbase.PluginManagerBase.__init__( - self, 'gtkui.conf', 'deluge.plugin.gtkui' + self, 'gtk3ui.conf', 'deluge.plugin.gtk3' ) self.hooks = {'on_apply_prefs': [], 'on_show_prefs': []} diff --git a/deluge/ui/gtkui/preferences.py b/deluge/ui/gtk3/preferences.py similarity index 99% rename from deluge/ui/gtkui/preferences.py rename to deluge/ui/gtk3/preferences.py index 3f697df54..d3a1c77b7 100644 --- a/deluge/ui/gtkui/preferences.py +++ b/deluge/ui/gtk3/preferences.py @@ -23,20 +23,12 @@ from deluge.configmanager import ConfigManager, get_config_dir from deluge.error import AuthManagerError, NotAuthorizedError from deluge.ui.client import client from deluge.ui.common import DISK_CACHE_KEYS, PREFS_CATOG_TRANS -from deluge.ui.gtkui.common import ( - associate_magnet_links, - get_clipboard_text, - get_deluge_icon, -) -from deluge.ui.gtkui.dialogs import ( - AccountDialog, - ErrorDialog, - InformationDialog, - YesNoDialog, -) -from deluge.ui.gtkui.path_chooser import PathChooser from deluge.ui.translations_util import get_languages +from .common import associate_magnet_links, get_clipboard_text, get_deluge_icon +from .dialogs import AccountDialog, ErrorDialog, InformationDialog, YesNoDialog +from .path_chooser import PathChooser + try: from urllib.parse import urlparse except ImportError: @@ -67,7 +59,7 @@ class Preferences(component.Component): self.builder = Gtk.Builder() self.builder.add_from_file( deluge.common.resource_filename( - 'deluge.ui.gtkui', os.path.join('glade', 'preferences_dialog.ui') + __package__, os.path.join('glade', 'preferences_dialog.ui') ) ) self.pref_dialog = self.builder.get_object('pref_dialog') @@ -75,7 +67,7 @@ class Preferences(component.Component): 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') + self.gtkui_config = ConfigManager('gtk3ui.conf') self.window_open = False self.load_pref_dialog_state() @@ -178,7 +170,7 @@ class Preferences(component.Component): # Radio buttons to choose between systray and appindicator self.builder.get_object('alignment_tray_type').set_visible(bool(appindicator)) - from deluge.ui.gtkui.gtkui import DEFAULT_PREFS + from .gtkui import DEFAULT_PREFS self.COLOR_DEFAULTS = {} for key in ('missing', 'waiting', 'downloading', 'completed'): diff --git a/deluge/ui/gtkui/queuedtorrents.py b/deluge/ui/gtk3/queuedtorrents.py similarity index 96% rename from deluge/ui/gtkui/queuedtorrents.py rename to deluge/ui/gtk3/queuedtorrents.py index 38ce1bcc7..6babfa6f4 100644 --- a/deluge/ui/gtkui/queuedtorrents.py +++ b/deluge/ui/gtk3/queuedtorrents.py @@ -24,8 +24,9 @@ from gi.repository.Gtk import ( 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 + +from .common import get_logo +from .ipcinterface import process_args log = logging.getLogger(__name__) @@ -38,11 +39,11 @@ class QueuedTorrents(component.Component): self.queue = [] self.status_item = None - self.config = ConfigManager('gtkui.conf') + self.config = ConfigManager('gtk3ui.conf') self.builder = Builder() self.builder.add_from_file( deluge.common.resource_filename( - 'deluge.ui.gtkui', os.path.join('glade', 'queuedtorrents.ui') + __package__, os.path.join('glade', 'queuedtorrents.ui') ) ) self.builder.get_object('chk_autoadd').set_active(self.config['autoadd_queued']) diff --git a/deluge/ui/gtkui/removetorrentdialog.py b/deluge/ui/gtk3/removetorrentdialog.py similarity index 97% rename from deluge/ui/gtkui/removetorrentdialog.py rename to deluge/ui/gtk3/removetorrentdialog.py index d5d627a2a..48806a5d5 100644 --- a/deluge/ui/gtkui/removetorrentdialog.py +++ b/deluge/ui/gtk3/removetorrentdialog.py @@ -45,7 +45,7 @@ class RemoveTorrentDialog(object): self.builder = Gtk.Builder() self.builder.add_from_file( deluge.common.resource_filename( - 'deluge.ui.gtkui', os.path.join('glade', 'remove_torrent_dialog.ui') + __package__, os.path.join('glade', 'remove_torrent_dialog.ui') ) ) diff --git a/deluge/ui/gtkui/sidebar.py b/deluge/ui/gtk3/sidebar.py similarity index 98% rename from deluge/ui/gtkui/sidebar.py rename to deluge/ui/gtk3/sidebar.py index 8d2a8fed4..47d9ebdc4 100644 --- a/deluge/ui/gtkui/sidebar.py +++ b/deluge/ui/gtk3/sidebar.py @@ -31,7 +31,7 @@ class SideBar(component.Component): main_builder = component.get('MainWindow').get_builder() self.notebook = main_builder.get_object('sidebar_notebook') self.hpaned = main_builder.get_object('main_window_hpaned') - self.config = ConfigManager('gtkui.conf') + self.config = ConfigManager('gtk3ui.conf') # self.hpaned_position = self.hpaned.get_position() # Tabs holds references to the Tab widgets by their name diff --git a/deluge/ui/gtkui/status_tab.py b/deluge/ui/gtk3/status_tab.py similarity index 96% rename from deluge/ui/gtkui/status_tab.py rename to deluge/ui/gtk3/status_tab.py index 8a70aa1ec..4dfba392d 100644 --- a/deluge/ui/gtkui/status_tab.py +++ b/deluge/ui/gtk3/status_tab.py @@ -14,8 +14,9 @@ import logging import deluge.component as component from deluge.common import fpeer from deluge.configmanager import ConfigManager -from deluge.ui.gtkui.piecesbar import PiecesBar -from deluge.ui.gtkui.tab_data_funcs import ( + +from .piecesbar import PiecesBar +from .tab_data_funcs import ( fdate_or_never, fpcnt, fratio, @@ -24,7 +25,7 @@ from deluge.ui.gtkui.tab_data_funcs import ( ftime_or_dash, ftotal_sized, ) -from deluge.ui.gtkui.torrentdetails import Tab, TabWidget +from .torrentdetails import Tab, TabWidget log = logging.getLogger(__name__) @@ -33,7 +34,7 @@ class StatusTab(Tab): def __init__(self): super(StatusTab, self).__init__('Status', 'status_tab', 'status_tab_label') - self.config = ConfigManager('gtkui.conf') + self.config = ConfigManager('gtk3ui.conf') self.progressbar = self.main_builder.get_object('progressbar') self.piecesbar = None diff --git a/deluge/ui/gtkui/statusbar.py b/deluge/ui/gtk3/statusbar.py similarity index 98% rename from deluge/ui/gtkui/statusbar.py rename to deluge/ui/gtk3/statusbar.py index 834d84d7b..7834da0a2 100644 --- a/deluge/ui/gtkui/statusbar.py +++ b/deluge/ui/gtk3/statusbar.py @@ -18,7 +18,9 @@ import deluge.component as component from deluge.common import fsize, fspeed, get_pixmap from deluge.configmanager import ConfigManager from deluge.ui.client import client -from deluge.ui.gtkui import common, dialogs + +from .common import build_menu_radio_list +from .dialogs import OtherDialog log = logging.getLogger(__name__) @@ -111,7 +113,7 @@ class StatusBar(component.Component): component.Component.__init__(self, 'StatusBar', interval=3) main_builder = component.get('MainWindow').get_builder() self.statusbar = main_builder.get_object('statusbar') - self.config = ConfigManager('gtkui.conf') + self.config = ConfigManager('gtk3ui.conf') # Status variables that are updated via callback self.max_connections_global = -1 @@ -495,14 +497,14 @@ class StatusBar(component.Component): if response_id == Gtk.ResponseType.OK: set_value(dialog.get_value()) - dialog = dialogs.OtherDialog(*other_dialog_info[core_key]) + dialog = OtherDialog(*other_dialog_info[core_key]) dialog.run().addCallback(set_value) else: value = widget.get_children()[0].get_text().split(' ')[0] set_value(value) def _on_download_item_clicked(self, widget, event): - menu = common.build_menu_radio_list( + menu = build_menu_radio_list( self.config['tray_download_speed_list'], self._on_set_download_speed, self.max_download_speed, @@ -518,7 +520,7 @@ class StatusBar(component.Component): self.set_limit_value(widget, 'max_download_speed') def _on_upload_item_clicked(self, widget, event): - menu = common.build_menu_radio_list( + menu = build_menu_radio_list( self.config['tray_upload_speed_list'], self._on_set_upload_speed, self.max_upload_speed, @@ -534,7 +536,7 @@ class StatusBar(component.Component): self.set_limit_value(widget, 'max_upload_speed') def _on_connection_item_clicked(self, widget, event): - menu = common.build_menu_radio_list( + menu = build_menu_radio_list( self.config['connection_limit_list'], self._on_set_connection_limit, self.max_connections_global, diff --git a/deluge/ui/gtkui/systemtray.py b/deluge/ui/gtk3/systemtray.py similarity index 98% rename from deluge/ui/gtkui/systemtray.py rename to deluge/ui/gtk3/systemtray.py index f8dcc8252..4709c3502 100644 --- a/deluge/ui/gtkui/systemtray.py +++ b/deluge/ui/gtk3/systemtray.py @@ -24,8 +24,9 @@ from deluge.common import ( ) 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 + +from .common import build_menu_radio_list, get_logo +from .dialogs import OtherDialog try: import appindicator @@ -39,7 +40,7 @@ class SystemTray(component.Component): def __init__(self): component.Component.__init__(self, 'SystemTray', interval=4) self.mainwindow = component.get('MainWindow') - self.config = ConfigManager('gtkui.conf') + self.config = ConfigManager('gtk3ui.conf') # List of widgets that need to be hidden when not connected to a host self.hide_widget_list = [ 'menuitem_add_torrent', @@ -76,7 +77,7 @@ class SystemTray(component.Component): """Enables the system tray icon.""" self.builder = Builder() self.builder.add_from_file( - resource_filename('deluge.ui.gtkui', os.path.join('glade', 'tray_menu.ui')) + resource_filename(__package__, os.path.join('glade', 'tray_menu.ui')) ) self.builder.connect_signals(self) @@ -436,7 +437,7 @@ class SystemTray(component.Component): if widget.get_name() == 'unlimited': set_value(-1) elif widget.get_name() == 'other': - dialog = dialogs.OtherDialog(header, text, _('K/s'), image, default) + dialog = OtherDialog(header, text, _('K/s'), image, default) dialog.run().addCallback(set_value) else: set_value(widget.get_children()[0].get_text().split(' ')[0]) diff --git a/deluge/ui/gtkui/tab_data_funcs.py b/deluge/ui/gtk3/tab_data_funcs.py similarity index 100% rename from deluge/ui/gtkui/tab_data_funcs.py rename to deluge/ui/gtk3/tab_data_funcs.py diff --git a/deluge/ui/gtkui/toolbar.py b/deluge/ui/gtk3/toolbar.py similarity index 98% rename from deluge/ui/gtkui/toolbar.py rename to deluge/ui/gtk3/toolbar.py index 98fe7459f..7bc029e4b 100644 --- a/deluge/ui/gtkui/toolbar.py +++ b/deluge/ui/gtk3/toolbar.py @@ -26,7 +26,7 @@ class ToolBar(component.Component): mainwindow = component.get('MainWindow') self.main_builder = mainwindow.get_builder() self.toolbar = self.main_builder.get_object('toolbar') - self.config = ConfigManager('gtkui.conf') + self.config = ConfigManager('gtk3ui.conf') # Connect main window Signals # mainwindow.connect_signals(self) self.change_sensitivity = [ diff --git a/deluge/ui/gtkui/torrentdetails.py b/deluge/ui/gtk3/torrentdetails.py similarity index 97% rename from deluge/ui/gtkui/torrentdetails.py rename to deluge/ui/gtk3/torrentdetails.py index 35c220f2a..6bfa4668a 100644 --- a/deluge/ui/gtkui/torrentdetails.py +++ b/deluge/ui/gtk3/torrentdetails.py @@ -18,7 +18,8 @@ from gi.repository.Gtk import CheckMenuItem, Menu, SeparatorMenuItem import deluge.component as component from deluge.ui.client import client -from deluge.ui.gtkui.common import load_pickled_state_file, save_pickled_state_file + +from .common import load_pickled_state_file, save_pickled_state_file log = logging.getLogger(__name__) @@ -111,12 +112,12 @@ class TorrentDetails(component.Component): self.tabs = {} # Add the default tabs - 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 + 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 default_tabs = { 'Status': StatusTab, diff --git a/deluge/ui/gtkui/torrentview.py b/deluge/ui/gtk3/torrentview.py similarity index 99% rename from deluge/ui/gtkui/torrentview.py rename to deluge/ui/gtk3/torrentview.py index 2443c7f7a..9eef68d9d 100644 --- a/deluge/ui/gtkui/torrentview.py +++ b/deluge/ui/gtk3/torrentview.py @@ -20,9 +20,10 @@ from twisted.internet import reactor import deluge.component as component from deluge.ui.client import client -from deluge.ui.gtkui import torrentview_data_funcs as funcs -from deluge.ui.gtkui.listview import ListView -from deluge.ui.gtkui.removetorrentdialog import RemoveTorrentDialog + +from . import torrentview_data_funcs as funcs +from .listview import ListView +from .removetorrentdialog import RemoveTorrentDialog log = logging.getLogger(__name__) diff --git a/deluge/ui/gtkui/torrentview_data_funcs.py b/deluge/ui/gtk3/torrentview_data_funcs.py similarity index 99% rename from deluge/ui/gtkui/torrentview_data_funcs.py rename to deluge/ui/gtk3/torrentview_data_funcs.py index d4da75831..8bd1f9c51 100644 --- a/deluge/ui/gtkui/torrentview_data_funcs.py +++ b/deluge/ui/gtk3/torrentview_data_funcs.py @@ -14,7 +14,8 @@ from functools import partial import deluge.common as common import deluge.component as component -from deluge.ui.gtkui.common import ( + +from .common import ( create_blank_pixbuf, get_pixbuf_at_size, icon_alert, diff --git a/deluge/ui/gtkui/trackers_tab.py b/deluge/ui/gtk3/trackers_tab.py similarity index 92% rename from deluge/ui/gtkui/trackers_tab.py rename to deluge/ui/gtk3/trackers_tab.py index 55999761b..d83b9956c 100644 --- a/deluge/ui/gtkui/trackers_tab.py +++ b/deluge/ui/gtk3/trackers_tab.py @@ -13,8 +13,9 @@ import logging import deluge.component as component from deluge.common import ftime -from deluge.ui.gtkui.tab_data_funcs import fcount, ftranslate, fyes_no -from deluge.ui.gtkui.torrentdetails import Tab + +from .tab_data_funcs import fcount, ftranslate, fyes_no +from .torrentdetails import Tab log = logging.getLogger(__name__) @@ -67,7 +68,7 @@ class TrackersTab(Tab): def on_button_edit_trackers_clicked(self, button): torrent_id = component.get('TorrentView').get_selected_torrent() if torrent_id: - from deluge.ui.gtkui.edittrackersdialog import EditTrackersDialog + from .edittrackersdialog import EditTrackersDialog dialog = EditTrackersDialog(torrent_id, component.get('MainWindow').window) dialog.run() diff --git a/docs/source/conf.py b/docs/source/conf.py index e1a60a14a..7c57e058e 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -101,6 +101,7 @@ autodoc_mock_imports = [ 'pango', 'cairo', 'pangocairo', + 'gi', 'curses', 'win32api', 'win32file', diff --git a/setup.cfg b/setup.cfg index 521a15dd2..4f15bcef5 100644 --- a/setup.cfg +++ b/setup.cfg @@ -22,7 +22,7 @@ known_third_party = # Ignore Windows specific modules. bbfreeze, win32verstamp, # Ignore gtk modules, primarily for tox testing. - pygtk, gtk, gobject, gtk.gdk, pango, cairo, pangocairo, + pygtk, gtk, gobject, gtk.gdk, pango, cairo, pangocairo, gi # Ignore other module dependencies for pre-commit isort. twisted, OpenSSL, pytest, recommonmark, chardet, pkg_resources, zope, mock, sphinx @@ -39,7 +39,7 @@ use_parentheses=True [flake8] max-line-length = 120 builtins = _,_n,__request__ -exclude = .git,.tox,dist,build +exclude = .git,.tox,.eggs,dist,build ignore = # A003 Class attribute is a python builtin. A003, diff --git a/setup.py b/setup.py index df8d966a4..041617bc7 100755 --- a/setup.py +++ b/setup.py @@ -502,16 +502,16 @@ if windows_check(): ) _entry_points['gui_scripts'] = [ 'deluge = deluge.ui.ui_entry:start_ui', - 'deluge-gtk = deluge.ui.gtkui:start', + 'deluge-gtk = deluge.ui.gtk3:start', ] _entry_points['deluge.ui'] = [ 'console = deluge.ui.console:Console', 'web = deluge.ui.web:Web', - 'gtk = deluge.ui.gtkui:Gtk', + 'gtk = deluge.ui.gtk3:Gtk', ] -_package_data['deluge'] = [ +_package_data['deluge.ui'] = [ 'ui/data/pixmaps/*.png', 'ui/data/pixmaps/*.svg', 'ui/data/pixmaps/*.ico', @@ -535,7 +535,7 @@ _package_data['deluge.ui.web'] = [ 'themes/images/*/*/*.gif', 'themes/images/*/*/*.png', ] -_package_data['deluge.ui.gtkui'] = ['glade/*.ui'] +_package_data['deluge.ui.gtk3'] = ['glade/*.ui'] setup_requires = ['setuptools', 'wheel'] install_requires = [