mirror of
https://github.com/codex-storage/deluge.git
synced 2025-01-11 03:55:43 +00:00
Can now add torrents from the UI.
Various other updates.
This commit is contained in:
parent
9280781dd3
commit
be081ae103
@ -1,7 +1,7 @@
|
||||
#
|
||||
# common.py
|
||||
#
|
||||
# Copyright (C) Andrew Resch 2007 <andrewresch@gmail.com>
|
||||
# Copyright (C) 2007 Andrew Resch ('andar') <andrewresch@gmail.com>
|
||||
#
|
||||
# Deluge is free software.
|
||||
#
|
||||
|
@ -1,7 +1,7 @@
|
||||
#
|
||||
# config.py
|
||||
#
|
||||
# Copyright (C) Andrew Resch 2007 <andrewresch@gmail.com>
|
||||
# Copyright (C) 2007 Andrew Resch ('andar') <andrewresch@gmail.com>
|
||||
#
|
||||
# Deluge is free software.
|
||||
#
|
||||
@ -52,6 +52,10 @@ class Config:
|
||||
self.config_file = deluge.common.get_config_dir(filename)
|
||||
self.load(self.config_file)
|
||||
|
||||
def __del__(self):
|
||||
log.debug("Config object deconstructing..")
|
||||
self.save()
|
||||
|
||||
def load(self, filename=None):
|
||||
# Use self.config_file if filename is None
|
||||
if filename is None:
|
||||
|
@ -1,7 +1,7 @@
|
||||
#
|
||||
# core.py
|
||||
#
|
||||
# Copyright (C) Andrew Resch 2007 <andrewresch@gmail.com>
|
||||
# Copyright (C) 2007 Andrew Resch ('andar') <andrewresch@gmail.com>
|
||||
#
|
||||
# Deluge is free software.
|
||||
#
|
||||
@ -118,4 +118,4 @@ class Core(dbus.service.Object):
|
||||
signature="")
|
||||
def torrent_added(self):
|
||||
"""Emitted when a new torrent is added to the core"""
|
||||
pass
|
||||
log.debug("torrent_added signal emitted")
|
||||
|
@ -1,7 +1,7 @@
|
||||
#
|
||||
# daemon.py
|
||||
#
|
||||
# Copyright (C) Andrew Resch 2007 <andrewresch@gmail.com>
|
||||
# Copyright (C) 2007 Andrew Resch ('andar') <andrewresch@gmail.com>
|
||||
#
|
||||
# Deluge is free software.
|
||||
#
|
||||
|
@ -1,7 +1,7 @@
|
||||
#
|
||||
# torrent.py
|
||||
#
|
||||
# Copyright (C) Andrew Resch 2007 <andrewresch@gmail.com>
|
||||
# Copyright (C) 2007 Andrew Resch ('andar') <andrewresch@gmail.com>
|
||||
#
|
||||
# Deluge is free software.
|
||||
#
|
||||
|
@ -1,7 +1,7 @@
|
||||
#
|
||||
# main.py
|
||||
#
|
||||
# Copyright (C) Andrew Resch 2007 <andrewresch@gmail.com>
|
||||
# Copyright (C) 2007 Andrew Resch ('andar') <andrewresch@gmail.com>
|
||||
#
|
||||
# Deluge is free software.
|
||||
#
|
||||
|
88
deluge/ui/gtkui/addtorrentdialog.py
Normal file
88
deluge/ui/gtkui/addtorrentdialog.py
Normal file
@ -0,0 +1,88 @@
|
||||
#
|
||||
# addtorrentdialog.py
|
||||
#
|
||||
# Copyright (C) 2007 Andrew Resch ('andar') <andrewresch@gmail.com>
|
||||
#
|
||||
# Deluge is free software.
|
||||
#
|
||||
# You may redistribute it and/or modify it under the terms of the
|
||||
# GNU General Public License, as published by the Free Software
|
||||
# Foundation; either version 2 of the License, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# deluge is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with deluge. If not, write to:
|
||||
# The Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Fifth Floor
|
||||
# Boston, MA 02110-1301, USA.
|
||||
#
|
||||
# In addition, as a special exception, the copyright holders give
|
||||
# permission to link the code of portions of this program with the OpenSSL
|
||||
# library.
|
||||
# You must obey the GNU General Public License in all respects for all of
|
||||
# the code used other than OpenSSL. If you modify file(s) with this
|
||||
# exception, you may extend this exception to your version of the file(s),
|
||||
# but you are not obligated to do so. If you do not wish to do so, delete
|
||||
# this exception statement from your version. If you delete this exception
|
||||
# statement from all source files in the program, then also delete it here.
|
||||
|
||||
import logging
|
||||
|
||||
import pygtk
|
||||
pygtk.require('2.0')
|
||||
import gtk, gtk.glade
|
||||
|
||||
from deluge.config import Config
|
||||
|
||||
# Get the logger
|
||||
log = logging.getLogger("deluge")
|
||||
|
||||
class AddTorrentDialog:
|
||||
def __init__(self, parent=None):
|
||||
# Setup the filechooserdialog
|
||||
self.chooser = gtk.FileChooserDialog(_("Choose a .torrent file"),
|
||||
parent,
|
||||
gtk.FILE_CHOOSER_ACTION_OPEN,
|
||||
buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OPEN,
|
||||
gtk.RESPONSE_OK))
|
||||
|
||||
self.chooser.set_select_multiple(True)
|
||||
self.chooser.set_property("skip-taskbar-hint", True)
|
||||
|
||||
# Add .torrent and * file filters
|
||||
f0 = gtk.FileFilter()
|
||||
f0.set_name(_("Torrent files"))
|
||||
f0.add_pattern("*." + "torrent")
|
||||
self.chooser.add_filter(f0)
|
||||
f1 = gtk.FileFilter()
|
||||
f1.set_name(_("All files"))
|
||||
f1.add_pattern("*")
|
||||
self.chooser.add_filter(f1)
|
||||
|
||||
# Load the 'default_load_path' from the config
|
||||
self.config = Config("gtkui.conf")
|
||||
if self.config.get("default_load_path") is not None:
|
||||
self.chooser.set_current_folder(
|
||||
self.config.get("default_load_path"))
|
||||
|
||||
|
||||
def run(self):
|
||||
"""Returns a list of selected files or None if no files were selected.
|
||||
"""
|
||||
# Run the dialog
|
||||
response = self.chooser.run()
|
||||
|
||||
if response == gtk.RESPONSE_OK:
|
||||
result = self.chooser.get_filenames()
|
||||
self.config.set("default_load_path",
|
||||
self.chooser.get_current_folder())
|
||||
else:
|
||||
result = None
|
||||
|
||||
self.chooser.destroy()
|
||||
return result
|
@ -1,7 +1,8 @@
|
||||
#
|
||||
# columns.py
|
||||
#
|
||||
# Copyright (C) Andrew Resch 2007 <andrewresch@gmail.com>
|
||||
# Copyright (C) 2006 Zach Tibbitts ('zachtib') <zach@collegegeek.org>
|
||||
# Copyright (C) 2007 Andrew Resch ('andar') <andrewresch@gmail.com>
|
||||
#
|
||||
# Deluge is free software.
|
||||
#
|
||||
|
77
deluge/ui/gtkui/functions.py
Normal file
77
deluge/ui/gtkui/functions.py
Normal file
@ -0,0 +1,77 @@
|
||||
#
|
||||
# functions.py
|
||||
#
|
||||
# Copyright (C) 2007 Andrew Resch ('andar') <andrewresch@gmail.com>
|
||||
#
|
||||
# Deluge is free software.
|
||||
#
|
||||
# You may redistribute it and/or modify it under the terms of the
|
||||
# GNU General Public License, as published by the Free Software
|
||||
# Foundation; either version 2 of the License, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# deluge is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with deluge. If not, write to:
|
||||
# The Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Fifth Floor
|
||||
# Boston, MA 02110-1301, USA.
|
||||
#
|
||||
# In addition, as a special exception, the copyright holders give
|
||||
# permission to link the code of portions of this program with the OpenSSL
|
||||
# library.
|
||||
# You must obey the GNU General Public License in all respects for all of
|
||||
# the code used other than OpenSSL. If you modify file(s) with this
|
||||
# exception, you may extend this exception to your version of the file(s),
|
||||
# but you are not obligated to do so. If you do not wish to do so, delete
|
||||
# this exception statement from your version. If you delete this exception
|
||||
# statement from all source files in the program, then also delete it here.
|
||||
|
||||
import logging
|
||||
|
||||
try:
|
||||
import dbus, dbus.service
|
||||
dbus_version = getattr(dbus, "version", (0,0,0))
|
||||
if dbus_version >= (0,41,0) and dbus_version < (0,80,0):
|
||||
import dbus.glib
|
||||
elif dbus_version >= (0,80,0):
|
||||
from dbus.mainloop.glib import DBusGMainLoop
|
||||
DBusGMainLoop(set_as_default=True)
|
||||
else:
|
||||
pass
|
||||
except: dbus_imported = False
|
||||
else: dbus_imported = True
|
||||
|
||||
import pygtk
|
||||
pygtk.require('2.0')
|
||||
import gtk, gtk.glade
|
||||
|
||||
from addtorrentdialog import AddTorrentDialog
|
||||
from deluge.ui.ui import UI
|
||||
|
||||
# Get the logger
|
||||
log = logging.getLogger("deluge")
|
||||
|
||||
def get_core():
|
||||
"""Get the core object and return it"""
|
||||
log.debug("Getting core proxy object from DBUS..")
|
||||
# Get the proxy object from DBUS
|
||||
bus = dbus.SessionBus()
|
||||
proxy = bus.get_object("org.deluge_torrent.Deluge",
|
||||
"/org/deluge_torrent/Core")
|
||||
core = dbus.Interface(proxy, "org.deluge_torrent.Deluge")
|
||||
log.debug("Got core proxy object..")
|
||||
return core
|
||||
|
||||
def add_torrent_file():
|
||||
"""Opens a file chooser dialog and adds any files selected to the core"""
|
||||
at_dialog = AddTorrentDialog()
|
||||
torrent_files = at_dialog.run()
|
||||
log.debug("Attempting to add torrent files: %s", torrent_files)
|
||||
core = get_core()
|
||||
for torrent_file in torrent_files:
|
||||
core.add_torrent_file(torrent_file)
|
@ -1,7 +1,7 @@
|
||||
#
|
||||
# gtkui.py
|
||||
#
|
||||
# Copyright (C) Andrew Resch 2007 <andrewresch@gmail.com>
|
||||
# Copyright (C) 2007 Andrew Resch ('andar') <andrewresch@gmail.com>
|
||||
#
|
||||
# Deluge is free software.
|
||||
#
|
||||
@ -45,10 +45,7 @@ from mainwindow import MainWindow
|
||||
log = logging.getLogger("deluge")
|
||||
|
||||
class GtkUI:
|
||||
def __init__(self, core):
|
||||
# Get the core proxy object from the args
|
||||
self.core = core
|
||||
|
||||
def __init__(self):
|
||||
# Initialize gettext
|
||||
gettext.bindtextdomain("deluge",
|
||||
pkg_resources.resource_filename(
|
||||
@ -61,7 +58,7 @@ class GtkUI:
|
||||
"po"))
|
||||
|
||||
# Initialize the main window
|
||||
self.main_window = MainWindow(self.core)
|
||||
self.main_window = MainWindow()
|
||||
|
||||
# Show the main window
|
||||
self.main_window.show()
|
||||
|
@ -1,7 +1,7 @@
|
||||
#
|
||||
# mainwindow.py
|
||||
#
|
||||
# Copyright (C) Andrew Resch 2007 <andrewresch@gmail.com>
|
||||
# Copyright (C) 2007 Andrew Resch ('andar') <andrewresch@gmail.com>
|
||||
#
|
||||
# Deluge is free software.
|
||||
#
|
||||
@ -46,9 +46,7 @@ from torrentview import TorrentView
|
||||
log = logging.getLogger("deluge")
|
||||
|
||||
class MainWindow:
|
||||
def __init__(self, core):
|
||||
self.core = core
|
||||
|
||||
def __init__(self):
|
||||
# Get the glade file for the main window
|
||||
self.main_glade = gtk.glade.XML(
|
||||
pkg_resources.resource_filename("deluge.ui.gtkui",
|
||||
|
@ -1,7 +1,7 @@
|
||||
#
|
||||
# menubar.py
|
||||
#
|
||||
# Copyright (C) Andrew Resch 2007 <andrewresch@gmail.com>
|
||||
# Copyright (C) 2007 Andrew Resch ('andar') <andrewresch@gmail.com>
|
||||
#
|
||||
# Deluge is free software.
|
||||
#
|
||||
@ -38,6 +38,8 @@ pygtk.require('2.0')
|
||||
import gtk, gtk.glade
|
||||
import pkg_resources
|
||||
|
||||
import functions
|
||||
|
||||
# Get the logger
|
||||
log = logging.getLogger("deluge")
|
||||
|
||||
@ -99,6 +101,7 @@ class MenuBar:
|
||||
## File Menu ##
|
||||
def on_menuitem_addtorrent_activate(self, data=None):
|
||||
log.debug("on_menuitem_addtorrent_activate")
|
||||
functions.add_torrent_file()
|
||||
def on_menuitem_addurl_activate(self, data=None):
|
||||
log.debug("on_menuitem_addurl_activate")
|
||||
def on_menuitem_clear_activate(self, data=None):
|
||||
|
@ -1,7 +1,7 @@
|
||||
#
|
||||
# toolbar.py
|
||||
#
|
||||
# Copyright (C) Andrew Resch 2007 <andrewresch@gmail.com>
|
||||
# Copyright (C) 2007 Andrew Resch ('andar') <andrewresch@gmail.com>
|
||||
#
|
||||
# Deluge is free software.
|
||||
#
|
||||
@ -37,6 +37,8 @@ import pygtk
|
||||
pygtk.require('2.0')
|
||||
import gtk, gtk.glade
|
||||
|
||||
import functions
|
||||
|
||||
# Get the logger
|
||||
log = logging.getLogger("deluge")
|
||||
|
||||
@ -64,6 +66,7 @@ class ToolBar:
|
||||
### Callbacks ###
|
||||
def on_toolbutton_add_clicked(self, data):
|
||||
log.debug("on_toolbutton_add_clicked")
|
||||
functions.add_torrent_file()
|
||||
def on_toolbutton_remove_clicked(self, data):
|
||||
log.debug("on_toolbutton_remove_clicked")
|
||||
def on_toolbutton_clear_clicked(self, data):
|
||||
|
@ -1,7 +1,7 @@
|
||||
#
|
||||
# torrentview.py
|
||||
#
|
||||
# Copyright (C) Andrew Resch 2007 <andrewresch@gmail.com>
|
||||
# Copyright (C) 2007 Andrew Resch ('andar') <andrewresch@gmail.com>
|
||||
#
|
||||
# Deluge is free software.
|
||||
#
|
||||
@ -94,9 +94,9 @@ class TorrentView:
|
||||
_("Size"),
|
||||
columns.cell_data_size,
|
||||
TORRENT_VIEW_COL_SIZE)
|
||||
self.status_column = columns.add_progress_column(
|
||||
self.progress_column = columns.add_progress_column(
|
||||
self.torrent_view,
|
||||
_("Status"),
|
||||
_("Progress"),
|
||||
TORRENT_VIEW_COL_PROGRESS,
|
||||
TORRENT_VIEW_COL_STATUS)
|
||||
self.seed_column = columns.add_func_column(
|
||||
@ -131,13 +131,14 @@ class TorrentView:
|
||||
TORRENT_VIEW_COL_RATIO)
|
||||
|
||||
# Set some column settings
|
||||
self.status_column.set_expand(True)
|
||||
self.progress_column.set_expand(True)
|
||||
self.name_column.set_sort_column_id(TORRENT_VIEW_COL_NAME)
|
||||
self.seed_column.set_sort_column_id(TORRENT_VIEW_COL_CONNECTED_SEEDS)
|
||||
self.peer_column.set_sort_column_id(TORRENT_VIEW_COL_CONNECTED_PEERS)
|
||||
|
||||
# Set the default sort column to the queue column
|
||||
self.torrent_model.set_sort_column_id(TORRENT_VIEW_COL_QUEUE, gtk.SORT_ASCENDING)
|
||||
self.torrent_model.set_sort_column_id(TORRENT_VIEW_COL_QUEUE,
|
||||
gtk.SORT_ASCENDING)
|
||||
|
||||
### Connect Signals ###
|
||||
# Connect to the 'button-press-event' to know when to bring up the
|
||||
|
@ -1,7 +1,7 @@
|
||||
#
|
||||
# ui.py
|
||||
#
|
||||
# Copyright (C) Andrew Resch 2007 <andrewresch@gmail.com>
|
||||
# Copyright (C) 2007 Andrew Resch ('andar') <andrewresch@gmail.com>
|
||||
#
|
||||
# Deluge is free software.
|
||||
#
|
||||
@ -33,19 +33,6 @@
|
||||
|
||||
import logging
|
||||
|
||||
try:
|
||||
import dbus, dbus.service
|
||||
dbus_version = getattr(dbus, "version", (0,0,0))
|
||||
if dbus_version >= (0,41,0) and dbus_version < (0,80,0):
|
||||
import dbus.glib
|
||||
elif dbus_version >= (0,80,0):
|
||||
from dbus.mainloop.glib import DBusGMainLoop
|
||||
DBusGMainLoop(set_as_default=True)
|
||||
else:
|
||||
pass
|
||||
except: dbus_imported = False
|
||||
else: dbus_imported = True
|
||||
|
||||
import time
|
||||
|
||||
from deluge.config import Config
|
||||
@ -61,16 +48,8 @@ class UI:
|
||||
def __init__(self):
|
||||
log.debug("UI init..")
|
||||
self.config = Config("ui.conf", DEFAULT_PREFS)
|
||||
log.debug("Getting core proxy object from DBUS..")
|
||||
# Get the proxy object from DBUS
|
||||
bus = dbus.SessionBus()
|
||||
proxy = bus.get_object("org.deluge_torrent.Deluge",
|
||||
"/org/deluge_torrent/Core")
|
||||
self.core = dbus.Interface(proxy, "org.deluge_torrent.Deluge")
|
||||
log.debug("Got core proxy object..")
|
||||
|
||||
if self.config["selected_ui"] == "gtk":
|
||||
log.info("Starting GtkUI..")
|
||||
from deluge.ui.gtkui.gtkui import GtkUI
|
||||
ui = GtkUI(self.core)
|
||||
|
||||
ui = GtkUI()
|
||||
|
2
setup.py
2
setup.py
@ -1,6 +1,6 @@
|
||||
# setup.py
|
||||
#
|
||||
# Copyright (c) 2007 Andrew Resch ('andar') <andrewresch@gmail.com>
|
||||
# Copyright (C) 2007 Andrew Resch ('andar') <andrewresch@gmail.com>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
|
Loading…
x
Reference in New Issue
Block a user