Can now add torrents from the UI.

Various other updates.
This commit is contained in:
Andrew Resch 2007-07-21 00:50:13 +00:00
commit be081ae103
16 changed files with 200 additions and 49 deletions

View file

@ -1,7 +1,7 @@
# #
# common.py # common.py
# #
# Copyright (C) Andrew Resch 2007 <andrewresch@gmail.com> # Copyright (C) 2007 Andrew Resch ('andar') <andrewresch@gmail.com>
# #
# Deluge is free software. # Deluge is free software.
# #

View file

@ -1,7 +1,7 @@
# #
# config.py # config.py
# #
# Copyright (C) Andrew Resch 2007 <andrewresch@gmail.com> # Copyright (C) 2007 Andrew Resch ('andar') <andrewresch@gmail.com>
# #
# Deluge is free software. # Deluge is free software.
# #
@ -52,6 +52,10 @@ class Config:
self.config_file = deluge.common.get_config_dir(filename) self.config_file = deluge.common.get_config_dir(filename)
self.load(self.config_file) self.load(self.config_file)
def __del__(self):
log.debug("Config object deconstructing..")
self.save()
def load(self, filename=None): def load(self, filename=None):
# Use self.config_file if filename is None # Use self.config_file if filename is None
if filename is None: if filename is None:

View file

@ -1,7 +1,7 @@
# #
# core.py # core.py
# #
# Copyright (C) Andrew Resch 2007 <andrewresch@gmail.com> # Copyright (C) 2007 Andrew Resch ('andar') <andrewresch@gmail.com>
# #
# Deluge is free software. # Deluge is free software.
# #
@ -118,4 +118,4 @@ class Core(dbus.service.Object):
signature="") signature="")
def torrent_added(self): def torrent_added(self):
"""Emitted when a new torrent is added to the core""" """Emitted when a new torrent is added to the core"""
pass log.debug("torrent_added signal emitted")

View file

@ -1,7 +1,7 @@
# #
# daemon.py # daemon.py
# #
# Copyright (C) Andrew Resch 2007 <andrewresch@gmail.com> # Copyright (C) 2007 Andrew Resch ('andar') <andrewresch@gmail.com>
# #
# Deluge is free software. # Deluge is free software.
# #

View file

@ -1,7 +1,7 @@
# #
# torrent.py # torrent.py
# #
# Copyright (C) Andrew Resch 2007 <andrewresch@gmail.com> # Copyright (C) 2007 Andrew Resch ('andar') <andrewresch@gmail.com>
# #
# Deluge is free software. # Deluge is free software.
# #

View file

@ -1,7 +1,7 @@
# #
# main.py # main.py
# #
# Copyright (C) Andrew Resch 2007 <andrewresch@gmail.com> # Copyright (C) 2007 Andrew Resch ('andar') <andrewresch@gmail.com>
# #
# Deluge is free software. # Deluge is free software.
# #

View 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

View file

@ -1,7 +1,8 @@
# #
# columns.py # 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. # Deluge is free software.
# #

View 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)

View file

@ -1,7 +1,7 @@
# #
# gtkui.py # gtkui.py
# #
# Copyright (C) Andrew Resch 2007 <andrewresch@gmail.com> # Copyright (C) 2007 Andrew Resch ('andar') <andrewresch@gmail.com>
# #
# Deluge is free software. # Deluge is free software.
# #
@ -45,10 +45,7 @@ from mainwindow import MainWindow
log = logging.getLogger("deluge") log = logging.getLogger("deluge")
class GtkUI: class GtkUI:
def __init__(self, core): def __init__(self):
# Get the core proxy object from the args
self.core = core
# Initialize gettext # Initialize gettext
gettext.bindtextdomain("deluge", gettext.bindtextdomain("deluge",
pkg_resources.resource_filename( pkg_resources.resource_filename(
@ -61,7 +58,7 @@ class GtkUI:
"po")) "po"))
# Initialize the main window # Initialize the main window
self.main_window = MainWindow(self.core) self.main_window = MainWindow()
# Show the main window # Show the main window
self.main_window.show() self.main_window.show()

View file

@ -1,7 +1,7 @@
# #
# mainwindow.py # mainwindow.py
# #
# Copyright (C) Andrew Resch 2007 <andrewresch@gmail.com> # Copyright (C) 2007 Andrew Resch ('andar') <andrewresch@gmail.com>
# #
# Deluge is free software. # Deluge is free software.
# #
@ -46,9 +46,7 @@ from torrentview import TorrentView
log = logging.getLogger("deluge") log = logging.getLogger("deluge")
class MainWindow: class MainWindow:
def __init__(self, core): def __init__(self):
self.core = core
# Get the glade file for the main window # Get the glade file for the main window
self.main_glade = gtk.glade.XML( self.main_glade = gtk.glade.XML(
pkg_resources.resource_filename("deluge.ui.gtkui", pkg_resources.resource_filename("deluge.ui.gtkui",

View file

@ -1,7 +1,7 @@
# #
# menubar.py # menubar.py
# #
# Copyright (C) Andrew Resch 2007 <andrewresch@gmail.com> # Copyright (C) 2007 Andrew Resch ('andar') <andrewresch@gmail.com>
# #
# Deluge is free software. # Deluge is free software.
# #
@ -38,6 +38,8 @@ pygtk.require('2.0')
import gtk, gtk.glade import gtk, gtk.glade
import pkg_resources import pkg_resources
import functions
# Get the logger # Get the logger
log = logging.getLogger("deluge") log = logging.getLogger("deluge")
@ -99,6 +101,7 @@ class MenuBar:
## File Menu ## ## File Menu ##
def on_menuitem_addtorrent_activate(self, data=None): def on_menuitem_addtorrent_activate(self, data=None):
log.debug("on_menuitem_addtorrent_activate") log.debug("on_menuitem_addtorrent_activate")
functions.add_torrent_file()
def on_menuitem_addurl_activate(self, data=None): def on_menuitem_addurl_activate(self, data=None):
log.debug("on_menuitem_addurl_activate") log.debug("on_menuitem_addurl_activate")
def on_menuitem_clear_activate(self, data=None): def on_menuitem_clear_activate(self, data=None):

View file

@ -1,7 +1,7 @@
# #
# toolbar.py # toolbar.py
# #
# Copyright (C) Andrew Resch 2007 <andrewresch@gmail.com> # Copyright (C) 2007 Andrew Resch ('andar') <andrewresch@gmail.com>
# #
# Deluge is free software. # Deluge is free software.
# #
@ -37,6 +37,8 @@ import pygtk
pygtk.require('2.0') pygtk.require('2.0')
import gtk, gtk.glade import gtk, gtk.glade
import functions
# Get the logger # Get the logger
log = logging.getLogger("deluge") log = logging.getLogger("deluge")
@ -64,6 +66,7 @@ class ToolBar:
### Callbacks ### ### Callbacks ###
def on_toolbutton_add_clicked(self, data): def on_toolbutton_add_clicked(self, data):
log.debug("on_toolbutton_add_clicked") log.debug("on_toolbutton_add_clicked")
functions.add_torrent_file()
def on_toolbutton_remove_clicked(self, data): def on_toolbutton_remove_clicked(self, data):
log.debug("on_toolbutton_remove_clicked") log.debug("on_toolbutton_remove_clicked")
def on_toolbutton_clear_clicked(self, data): def on_toolbutton_clear_clicked(self, data):

View file

@ -1,7 +1,7 @@
# #
# torrentview.py # torrentview.py
# #
# Copyright (C) Andrew Resch 2007 <andrewresch@gmail.com> # Copyright (C) 2007 Andrew Resch ('andar') <andrewresch@gmail.com>
# #
# Deluge is free software. # Deluge is free software.
# #
@ -94,9 +94,9 @@ class TorrentView:
_("Size"), _("Size"),
columns.cell_data_size, columns.cell_data_size,
TORRENT_VIEW_COL_SIZE) TORRENT_VIEW_COL_SIZE)
self.status_column = columns.add_progress_column( self.progress_column = columns.add_progress_column(
self.torrent_view, self.torrent_view,
_("Status"), _("Progress"),
TORRENT_VIEW_COL_PROGRESS, TORRENT_VIEW_COL_PROGRESS,
TORRENT_VIEW_COL_STATUS) TORRENT_VIEW_COL_STATUS)
self.seed_column = columns.add_func_column( self.seed_column = columns.add_func_column(
@ -131,13 +131,14 @@ class TorrentView:
TORRENT_VIEW_COL_RATIO) TORRENT_VIEW_COL_RATIO)
# Set some column settings # 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.name_column.set_sort_column_id(TORRENT_VIEW_COL_NAME)
self.seed_column.set_sort_column_id(TORRENT_VIEW_COL_CONNECTED_SEEDS) self.seed_column.set_sort_column_id(TORRENT_VIEW_COL_CONNECTED_SEEDS)
self.peer_column.set_sort_column_id(TORRENT_VIEW_COL_CONNECTED_PEERS) self.peer_column.set_sort_column_id(TORRENT_VIEW_COL_CONNECTED_PEERS)
# Set the default sort column to the queue column # 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 Signals ###
# Connect to the 'button-press-event' to know when to bring up the # Connect to the 'button-press-event' to know when to bring up the

View file

@ -1,7 +1,7 @@
# #
# ui.py # ui.py
# #
# Copyright (C) Andrew Resch 2007 <andrewresch@gmail.com> # Copyright (C) 2007 Andrew Resch ('andar') <andrewresch@gmail.com>
# #
# Deluge is free software. # Deluge is free software.
# #
@ -33,19 +33,6 @@
import logging 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 import time
from deluge.config import Config from deluge.config import Config
@ -61,16 +48,8 @@ class UI:
def __init__(self): def __init__(self):
log.debug("UI init..") log.debug("UI init..")
self.config = Config("ui.conf", DEFAULT_PREFS) 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": if self.config["selected_ui"] == "gtk":
log.info("Starting GtkUI..") log.info("Starting GtkUI..")
from deluge.ui.gtkui.gtkui import GtkUI from deluge.ui.gtkui.gtkui import GtkUI
ui = GtkUI(self.core) ui = GtkUI()

View file

@ -1,6 +1,6 @@
# setup.py # 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 # 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 # it under the terms of the GNU General Public License as published by