diff --git a/deluge/common.py b/deluge/common.py index 49ece9747..36e249496 100644 --- a/deluge/common.py +++ b/deluge/common.py @@ -1,7 +1,7 @@ # # common.py # -# Copyright (C) Andrew Resch 2007 +# Copyright (C) 2007 Andrew Resch ('andar') # # Deluge is free software. # diff --git a/deluge/config.py b/deluge/config.py index b89ac210f..4981a1775 100644 --- a/deluge/config.py +++ b/deluge/config.py @@ -1,7 +1,7 @@ # # config.py # -# Copyright (C) Andrew Resch 2007 +# Copyright (C) 2007 Andrew Resch ('andar') # # Deluge is free software. # @@ -51,6 +51,10 @@ class Config: # Load the config from file in the config_dir 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 diff --git a/deluge/core/core.py b/deluge/core/core.py index 1ebe30539..05b2a07c6 100644 --- a/deluge/core/core.py +++ b/deluge/core/core.py @@ -1,7 +1,7 @@ # # core.py # -# Copyright (C) Andrew Resch 2007 +# Copyright (C) 2007 Andrew Resch ('andar') # # 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") diff --git a/deluge/core/daemon.py b/deluge/core/daemon.py index d9f171eab..710947fcb 100644 --- a/deluge/core/daemon.py +++ b/deluge/core/daemon.py @@ -1,7 +1,7 @@ # # daemon.py # -# Copyright (C) Andrew Resch 2007 +# Copyright (C) 2007 Andrew Resch ('andar') # # Deluge is free software. # diff --git a/deluge/core/torrent.py b/deluge/core/torrent.py index c164e906a..c9c5d6019 100644 --- a/deluge/core/torrent.py +++ b/deluge/core/torrent.py @@ -1,7 +1,7 @@ # # torrent.py # -# Copyright (C) Andrew Resch 2007 +# Copyright (C) 2007 Andrew Resch ('andar') # # Deluge is free software. # diff --git a/deluge/main.py b/deluge/main.py index fa09278a7..393cd9f02 100644 --- a/deluge/main.py +++ b/deluge/main.py @@ -1,7 +1,7 @@ # # main.py # -# Copyright (C) Andrew Resch 2007 +# Copyright (C) 2007 Andrew Resch ('andar') # # Deluge is free software. # diff --git a/deluge/ui/gtkui/addtorrentdialog.py b/deluge/ui/gtkui/addtorrentdialog.py new file mode 100644 index 000000000..7cde8358e --- /dev/null +++ b/deluge/ui/gtkui/addtorrentdialog.py @@ -0,0 +1,88 @@ +# +# addtorrentdialog.py +# +# Copyright (C) 2007 Andrew Resch ('andar') +# +# 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 diff --git a/deluge/ui/gtkui/columns.py b/deluge/ui/gtkui/columns.py index c6c2ac3e0..23ceeda12 100644 --- a/deluge/ui/gtkui/columns.py +++ b/deluge/ui/gtkui/columns.py @@ -1,7 +1,8 @@ # # columns.py # -# Copyright (C) Andrew Resch 2007 +# Copyright (C) 2006 Zach Tibbitts ('zachtib') +# Copyright (C) 2007 Andrew Resch ('andar') # # Deluge is free software. # diff --git a/deluge/ui/gtkui/functions.py b/deluge/ui/gtkui/functions.py new file mode 100644 index 000000000..750e0e210 --- /dev/null +++ b/deluge/ui/gtkui/functions.py @@ -0,0 +1,77 @@ +# +# functions.py +# +# Copyright (C) 2007 Andrew Resch ('andar') +# +# 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) diff --git a/deluge/ui/gtkui/gtkui.py b/deluge/ui/gtkui/gtkui.py index ec3f5cd2c..62e231983 100644 --- a/deluge/ui/gtkui/gtkui.py +++ b/deluge/ui/gtkui/gtkui.py @@ -1,7 +1,7 @@ # # gtkui.py # -# Copyright (C) Andrew Resch 2007 +# Copyright (C) 2007 Andrew Resch ('andar') # # 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() diff --git a/deluge/ui/gtkui/mainwindow.py b/deluge/ui/gtkui/mainwindow.py index 8f39cf9c9..f9641954c 100644 --- a/deluge/ui/gtkui/mainwindow.py +++ b/deluge/ui/gtkui/mainwindow.py @@ -1,7 +1,7 @@ # # mainwindow.py # -# Copyright (C) Andrew Resch 2007 +# Copyright (C) 2007 Andrew Resch ('andar') # # 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", diff --git a/deluge/ui/gtkui/menubar.py b/deluge/ui/gtkui/menubar.py index 15dbede6e..0b3e6a036 100644 --- a/deluge/ui/gtkui/menubar.py +++ b/deluge/ui/gtkui/menubar.py @@ -1,7 +1,7 @@ # # menubar.py # -# Copyright (C) Andrew Resch 2007 +# Copyright (C) 2007 Andrew Resch ('andar') # # 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): diff --git a/deluge/ui/gtkui/toolbar.py b/deluge/ui/gtkui/toolbar.py index 2bb60891e..305f2faa4 100644 --- a/deluge/ui/gtkui/toolbar.py +++ b/deluge/ui/gtkui/toolbar.py @@ -1,7 +1,7 @@ # # toolbar.py # -# Copyright (C) Andrew Resch 2007 +# Copyright (C) 2007 Andrew Resch ('andar') # # 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): diff --git a/deluge/ui/gtkui/torrentview.py b/deluge/ui/gtkui/torrentview.py index c34f4b054..cab25c937 100644 --- a/deluge/ui/gtkui/torrentview.py +++ b/deluge/ui/gtkui/torrentview.py @@ -1,7 +1,7 @@ # # torrentview.py # -# Copyright (C) Andrew Resch 2007 +# Copyright (C) 2007 Andrew Resch ('andar') # # 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 diff --git a/deluge/ui/ui.py b/deluge/ui/ui.py index d9b2a6d96..24edba815 100644 --- a/deluge/ui/ui.py +++ b/deluge/ui/ui.py @@ -1,7 +1,7 @@ # # ui.py # -# Copyright (C) Andrew Resch 2007 +# Copyright (C) 2007 Andrew Resch ('andar') # # 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() diff --git a/setup.py b/setup.py index 747ce88e8..4f14bfcba 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,6 @@ # setup.py # -# Copyright (c) 2007 Andrew Resch ('andar') +# Copyright (C) 2007 Andrew Resch ('andar') # # 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