From 9280781dd38d434299425aa6aa02fe942af5b387 Mon Sep 17 00:00:00 2001 From: Andrew Resch Date: Sat, 14 Jul 2007 01:33:16 +0000 Subject: [PATCH] Updates --- deluge/common.py | 75 ++++++++++- deluge/core/core.py | 1 - deluge/ui/gtkui/columns.py | 152 +++++++++++++++++++++++ deluge/ui/gtkui/glade/main_window.glade | 26 ++-- deluge/ui/gtkui/gtkui.py | 13 ++ deluge/ui/gtkui/mainwindow.py | 114 ++--------------- deluge/ui/gtkui/menubar.py | 143 +++++++++++++++++++++ deluge/ui/gtkui/po/deluge.pot | 0 deluge/ui/gtkui/toolbar.py | 81 ++++++++++++ deluge/ui/gtkui/torrentview.py | 158 ++++++++++++++++++++++++ setup.py | 9 +- 11 files changed, 646 insertions(+), 126 deletions(-) create mode 100644 deluge/ui/gtkui/columns.py create mode 100644 deluge/ui/gtkui/menubar.py create mode 100644 deluge/ui/gtkui/po/deluge.pot create mode 100644 deluge/ui/gtkui/toolbar.py create mode 100644 deluge/ui/gtkui/torrentview.py diff --git a/deluge/common.py b/deluge/common.py index d8d6d139b..49ece9747 100644 --- a/deluge/common.py +++ b/deluge/common.py @@ -32,9 +32,11 @@ # statement from all source files in the program, then also delete it here. import logging +import os + import pkg_resources import xdg, xdg.BaseDirectory -import os +import gettext # Get the logger log = logging.getLogger("deluge") @@ -56,3 +58,74 @@ def get_config_dir(filename=None): def get_default_download_dir(): """Returns the default download directory""" return os.environ.get("HOME") + +## Formatting text functions + +def estimate_eta(total_size, total_done, download_rate): + """Returns a string with the estimated ETA and will return 'Unlimited' + if the torrent is complete + """ + try: + return ftime(get_eta(total_size, total_done, download_rate)) + except ZeroDivisionError: + return _("Infinity") + +def get_eta(size, done, speed): + """Returns the ETA in seconds + Will raise an exception if the torrent is completed + """ + if (size - done) == 0: + raise ZeroDivisionError + return (size - done) / speed + +def fsize(fsize_b): + """Returns formatted string describing filesize + fsize_b should be in bytes + Returned value will be in either KB, MB, or GB + """ + fsize_kb = float (fsize_b / 1024.0) + if fsize_kb < 1000: + return _("%.1f KiB")%fsize_kb + fsize_mb = float (fsize_kb / 1024.0) + if fsize_mb < 1000: + return _("%.1f MiB")%fsize_mb + fsize_gb = float (fsize_mb / 1024.0) + return _("%.1f GiB")%fsize_gb + +def fpcnt(dec): + """Returns a formatted string representing a percentage""" + return '%.2f%%'%(dec * 100) + +def fspeed(bps): + """Returns a formatted string representing transfer speed""" + return '%s/s'%(fsize(bps)) + +def fseed(num_seeds, total_seeds): + """Returns a formatted string num_seeds (total_seeds)""" + return str(str(num_seeds) + " (" + str(total_seeds) + ")") + +def fpeer(num_peers, total_peers): + """Returns a formatted string num_peers (total_peers)""" + return str(str(num_peers) + " (" + str(total_peers) + ")") + +def ftime(seconds): + """Returns a formatted time string""" + if seconds < 60: + return '%ds'%(seconds) + minutes = int(seconds/60) + seconds = seconds % 60 + if minutes < 60: + return '%dm %ds'%(minutes, seconds) + hours = int(minutes/60) + minutes = minutes % 60 + if hours < 24: + return '%dh %dm'%(hours, minutes) + days = int(hours/24) + hours = hours % 24 + if days < 7: + return '%dd %dh'%(days, hours) + weeks = int(days/7) + days = days % 7 + if weeks < 10: + return '%dw %dd'%(weeks, days) + return 'unknown' diff --git a/deluge/core/core.py b/deluge/core/core.py index 9d3873ec7..1ebe30539 100644 --- a/deluge/core/core.py +++ b/deluge/core/core.py @@ -56,7 +56,6 @@ from deluge.core.torrent import Torrent # Get the logger log = logging.getLogger("deluge") -#_default_download_dir = deluge.common.get_default_download_dir() DEFAULT_PREFS = { "listen_ports": [6881, 6891], "download_location": deluge.common.get_default_download_dir(), diff --git a/deluge/ui/gtkui/columns.py b/deluge/ui/gtkui/columns.py new file mode 100644 index 000000000..c6c2ac3e0 --- /dev/null +++ b/deluge/ui/gtkui/columns.py @@ -0,0 +1,152 @@ +# +# columns.py +# +# Copyright (C) Andrew Resch 2007 +# +# 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 pygtk +pygtk.require('2.0') +import gtk + +import deluge.common + +# Cell data functions to pass to add_func_column() + +def cell_data_speed(column, cell, model, iter, data): + speed = int(model.get_value(iter, data)) + speed_str = deluge.common.fspeed(speed) + cell.set_property('text', speed_str) + +def cell_data_size(column, cell, model, iter, data): + size = long(model.get_value(iter, data)) + size_str = deluge.common.fsize(size) + cell.set_property('text', size_str) + +def cell_data_peer(column, cell, model, iter, data): + c1, c2 = data + a = int(model.get_value(iter, c1)) + b = int(model.get_value(iter, c2)) + cell.set_property('text', '%d (%d)'%(a, b)) + +def cell_data_time(column, cell, model, iter, data): + time = int(model.get_value(iter, data)) + if time < 0 or time == 0: + time_str = _("Infinity") + else: + time_str = deluge.common.ftime(time) + cell.set_property('text', time_str) + +def cell_data_ratio(column, cell, model, iter, data): + ratio = float(model.get_value(iter, data)) + if ratio == -1: + ratio_str = _("Unknown") + else: + ratio_str = "%.3f"%ratio + cell.set_property('text', ratio_str) + +## Functions to create columns + +def add_func_column(view, header, func, data, sortid=None): + column = gtk.TreeViewColumn(header) + render = gtk.CellRendererText() + column.pack_start(render, True) + column.set_cell_data_func(render, func, data) + if sortid is not None: + column.set_clickable(True) + column.set_sort_column_id(sortid) + else: + try: + if len(data) == 1: + column.set_clickable(True) + column.set_sort_column_id(data[0]) + except TypeError: + column.set_clickable(True) + column.set_sort_column_id(data) + column.set_resizable(True) + column.set_expand(False) + column.set_min_width(10) + column.set_reorderable(True) + view.append_column(column) + return column + + +def add_text_column(view, header, cid): + render = gtk.CellRendererText() + column = gtk.TreeViewColumn(header, render, text=cid) + column.set_clickable(True) + column.set_sort_column_id(cid) + column.set_resizable(True) + column.set_expand(False) + column.set_min_width(10) + column.set_reorderable(True) + view.append_column(column) + return column + +def add_progress_column(view, header, pid, mid): + render = gtk.CellRendererProgress() + column = gtk.TreeViewColumn(header, render, value=pid, text=mid) + column.set_clickable(True) + column.set_sort_column_id(pid) + column.set_resizable(True) + column.set_expand(False) + column.set_min_width(10) + column.set_reorderable(True) + view.append_column(column) + return column + +def add_toggle_column(view, header, cid, toggled_signal=None): + render = gtk.CellRendererToggle() + render.set_property('activatable', True) + column = gtk.TreeViewColumn(header, render, active=cid) + column.set_clickable(True) + column.set_resizable(True) + column.set_expand(False) + column.set_min_width(10) + column.set_reorderable(True) + view.append_column(column) + if toggled_signal is not None: + render.connect("toggled", toggled_signal) + return column + +def add_texticon_column(view, header, icon_col, text_col): + column = gtk.TreeViewColumn(header) + column.set_clickable(True) + column.set_resizable(True) + column.set_expand(False) + column.set_min_width(10) + column.set_reorderable(True) + render = gtk.CellRendererPixbuf() + column.pack_start(render, expand=False) + column.add_attribute(render, 'pixbuf', icon_col) + render = gtk.CellRendererText() + column.pack_start(render, expand=True) + column.add_attribute(render, 'text', text_col) + view.append_column(column) + return column diff --git a/deluge/ui/gtkui/glade/main_window.glade b/deluge/ui/gtkui/glade/main_window.glade index 267b5c0f1..e29ef7cc4 100644 --- a/deluge/ui/gtkui/glade/main_window.glade +++ b/deluge/ui/gtkui/glade/main_window.glade @@ -23,7 +23,7 @@ Add Torrent True gtk-add - + False @@ -37,20 +37,20 @@ Remove Torrent True gtk-remove - + False - + True Clear Finished Torrents Clear Finished True gtk-clear - + False @@ -73,35 +73,35 @@ Start True gtk-media-play - + False - + True False Queue Torrent Up Move Up True gtk-go-up - + False - + True False Queue Torrent Down Move Down True gtk-go-down - + False @@ -117,26 +117,26 @@ - + True Preferences Preferences True gtk-preferences - + False - + True Plugins Plugins True gtk-disconnect - + False diff --git a/deluge/ui/gtkui/gtkui.py b/deluge/ui/gtkui/gtkui.py index 8dba0123a..ec3f5cd2c 100644 --- a/deluge/ui/gtkui/gtkui.py +++ b/deluge/ui/gtkui/gtkui.py @@ -36,6 +36,8 @@ import logging import pygtk pygtk.require('2.0') import gtk, gtk.glade +import gettext +import pkg_resources from mainwindow import MainWindow @@ -46,6 +48,17 @@ class GtkUI: def __init__(self, core): # Get the core proxy object from the args self.core = core + + # Initialize gettext + gettext.bindtextdomain("deluge", + pkg_resources.resource_filename( + "deluge.ui.gtkui", + "po")) + gettext.textdomain("deluge") + gettext.install("deluge", + pkg_resources.resource_filename( + "deluge.ui.gtkui", + "po")) # Initialize the main window self.main_window = MainWindow(self.core) diff --git a/deluge/ui/gtkui/mainwindow.py b/deluge/ui/gtkui/mainwindow.py index 2693c915f..8f39cf9c9 100644 --- a/deluge/ui/gtkui/mainwindow.py +++ b/deluge/ui/gtkui/mainwindow.py @@ -1,5 +1,5 @@ # -# gtkui_mainwindow.py +# mainwindow.py # # Copyright (C) Andrew Resch 2007 # @@ -38,6 +38,10 @@ pygtk.require('2.0') import gtk, gtk.glade import pkg_resources +from menubar import MenuBar +from toolbar import ToolBar +from torrentview import TorrentView + # Get the logger log = logging.getLogger("deluge") @@ -53,7 +57,9 @@ class MainWindow: self.window = self.main_glade.get_widget("main_window") # Initialize various components of the gtkui - self.menubar = MainWindowMenuBar(self) + self.menubar = MenuBar(self) + self.toolbar = ToolBar(self) + self.torrentview = TorrentView(self) def show(self): self.window.show_all() @@ -64,107 +70,3 @@ class MainWindow: def quit(self): self.hide() gtk.main_quit() - -class MainWindowMenuBar: - def __init__(self, mainwindow): - log.debug("MainWindowMenuBar init..") - self.mainwindow = mainwindow - self.torrentmenu = gtk.glade.XML( - pkg_resources.resource_filename("deluge.ui.gtkui", - "glade/torrent_menu.glade")) - - # Attach the torrent_menu to the Torrent file menu - self.mainwindow.main_glade.get_widget("menu_torrent").set_submenu( - self.torrentmenu.get_widget("torrent_menu")) - - ### Connect Signals ### - self.mainwindow.main_glade.signal_autoconnect({ - ## File Menu - "on_menuitem_addtorrent_activate": \ - self.on_menuitem_addtorrent_activate, - "on_menuitem_addurl_activate": self.on_menuitem_addurl_activate, - "on_menuitem_clear_activate": \ - self.on_menuitem_clear_activate, - "on_menuitem_quit_activate": self.on_menuitem_quit_activate, - - ## Edit Menu - "on_menuitem_preferences_activate": \ - self.on_menuitem_preferences_activate, - "on_menuitem_plugins_activate": self.on_menuitem_plugins_activate, - - ## View Menu - "on_menuitem_toolbar_toggled": self.on_menuitem_toolbar_toggled, - "on_menuitem_infopane_toggled": self.on_menuitem_infopane_toggled, - - ## Help Menu - "on_menuitem_about_activate": self.on_menuitem_about_activate - }) - - self.torrentmenu.signal_autoconnect({ - ## Torrent Menu - "on_menuitem_pause_activate": self.on_menuitem_pause_activate, - "on_menuitem_updatetracker_activate": \ - self.on_menuitem_updatetracker_activate, - "on_menuitem_edittrackers_activate": \ - self.on_menuitem_edittrackers_activate, - "on_menuitem_remove_activate": self.on_menuitem_remove_activate, - "on_menuitem_queuetop_activate": \ - self.on_menuitem_queuetop_activate, - "on_menuitem_queueup_activate": self.on_menuitem_queueup_activate, - "on_menuitem_queuedown_activate": \ - self.on_menuitem_queuedown_activate, - "on_menuitem_queuebottom_activate": \ - self.on_menuitem_queuebottom_activate - }) - - ### Callbacks ### - - ## File Menu ## - def on_menuitem_addtorrent_activate(self, data=None): - log.debug("on_menuitem_addtorrent_activate") - def on_menuitem_addurl_activate(self, data=None): - log.debug("on_menuitem_addurl_activate") - def on_menuitem_clear_activate(self, data=None): - log.debug("on_menuitem_clear_activate") - def on_menuitem_quit_activate(self, data=None): - log.debug("on_menuitem_quit_activate") - self.mainwindow.quit() - - ## Edit Menu ## - def on_menuitem_preferences_activate(self, data=None): - log.debug("on_menuitem_preferences_activate") - def on_menuitem_plugins_activate(self, data=None): - log.debug("on_menuitem_plugins_activate") - - ## Torrent Menu ## - def on_menuitem_pause_activate(self, data=None): - log.debug("on_menuitem_pause_activate") - def on_menuitem_updatetracker_activate(self, data=None): - log.debug("on_menuitem_updatetracker_activate") - def on_menuitem_edittrackers_activate(self, data=None): - log.debug("on_menuitem_edittrackers_activate") - def on_menuitem_remove_activate(self, data=None): - log.debug("on_menuitem_remove_activate") - def on_menuitem_queuetop_activate(self, data=None): - log.debug("on_menuitem_queuetop_activate") - def on_menuitem_queueup_activate(self, data=None): - log.debug("on_menuitem_queueup_activate") - def on_menuitem_queuedown_activate(self, data=None): - log.debug("on_menuitem_queuedown_activate") - def on_menuitem_queuebottom_activate(self, data=None): - log.debug("on_menuitem_queuebottom_activate") - - ## View Menu ## - def on_menuitem_toolbar_toggled(self, data=None): - log.debug("on_menuitem_toolbar_toggled") - def on_menuitem_infopane_toggled(self, data=None): - log.debug("on_menuitem_infopane_toggled") - - ## Help Menu ## - def on_menuitem_about_activate(self, data=None): - log.debug("on_menuitem_about_activate") - -class MainWindowToolBar: - def __init__(self, mainwindow): - self.mainwindow = mainwindow - diff --git a/deluge/ui/gtkui/menubar.py b/deluge/ui/gtkui/menubar.py new file mode 100644 index 000000000..15dbede6e --- /dev/null +++ b/deluge/ui/gtkui/menubar.py @@ -0,0 +1,143 @@ +# +# menubar.py +# +# Copyright (C) Andrew Resch 2007 +# +# 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 +import pkg_resources + +# Get the logger +log = logging.getLogger("deluge") + +class MenuBar: + def __init__(self, window): + log.debug("MenuBar init..") + self.window = window + # Get the torrent menu from the glade file + self.torrentmenu = gtk.glade.XML( + pkg_resources.resource_filename("deluge.ui.gtkui", + "glade/torrent_menu.glade")) + + # Attach the torrent_menu to the Torrent file menu + self.window.main_glade.get_widget("menu_torrent").set_submenu( + self.torrentmenu.get_widget("torrent_menu")) + + ### Connect Signals ### + self.window.main_glade.signal_autoconnect({ + ## File Menu + "on_menuitem_addtorrent_activate": \ + self.on_menuitem_addtorrent_activate, + "on_menuitem_addurl_activate": self.on_menuitem_addurl_activate, + "on_menuitem_clear_activate": \ + self.on_menuitem_clear_activate, + "on_menuitem_quit_activate": self.on_menuitem_quit_activate, + + ## Edit Menu + "on_menuitem_preferences_activate": \ + self.on_menuitem_preferences_activate, + "on_menuitem_plugins_activate": self.on_menuitem_plugins_activate, + + ## View Menu + "on_menuitem_toolbar_toggled": self.on_menuitem_toolbar_toggled, + "on_menuitem_infopane_toggled": self.on_menuitem_infopane_toggled, + + ## Help Menu + "on_menuitem_about_activate": self.on_menuitem_about_activate + }) + + self.torrentmenu.signal_autoconnect({ + ## Torrent Menu + "on_menuitem_pause_activate": self.on_menuitem_pause_activate, + "on_menuitem_updatetracker_activate": \ + self.on_menuitem_updatetracker_activate, + "on_menuitem_edittrackers_activate": \ + self.on_menuitem_edittrackers_activate, + "on_menuitem_remove_activate": self.on_menuitem_remove_activate, + "on_menuitem_queuetop_activate": \ + self.on_menuitem_queuetop_activate, + "on_menuitem_queueup_activate": self.on_menuitem_queueup_activate, + "on_menuitem_queuedown_activate": \ + self.on_menuitem_queuedown_activate, + "on_menuitem_queuebottom_activate": \ + self.on_menuitem_queuebottom_activate + }) + + ### Callbacks ### + + ## File Menu ## + def on_menuitem_addtorrent_activate(self, data=None): + log.debug("on_menuitem_addtorrent_activate") + def on_menuitem_addurl_activate(self, data=None): + log.debug("on_menuitem_addurl_activate") + def on_menuitem_clear_activate(self, data=None): + log.debug("on_menuitem_clear_activate") + def on_menuitem_quit_activate(self, data=None): + log.debug("on_menuitem_quit_activate") + self.window.quit() + + ## Edit Menu ## + def on_menuitem_preferences_activate(self, data=None): + log.debug("on_menuitem_preferences_activate") + def on_menuitem_plugins_activate(self, data=None): + log.debug("on_menuitem_plugins_activate") + + ## Torrent Menu ## + def on_menuitem_pause_activate(self, data=None): + log.debug("on_menuitem_pause_activate") + def on_menuitem_updatetracker_activate(self, data=None): + log.debug("on_menuitem_updatetracker_activate") + def on_menuitem_edittrackers_activate(self, data=None): + log.debug("on_menuitem_edittrackers_activate") + def on_menuitem_remove_activate(self, data=None): + log.debug("on_menuitem_remove_activate") + def on_menuitem_queuetop_activate(self, data=None): + log.debug("on_menuitem_queuetop_activate") + def on_menuitem_queueup_activate(self, data=None): + log.debug("on_menuitem_queueup_activate") + def on_menuitem_queuedown_activate(self, data=None): + log.debug("on_menuitem_queuedown_activate") + def on_menuitem_queuebottom_activate(self, data=None): + log.debug("on_menuitem_queuebottom_activate") + + ## View Menu ## + def on_menuitem_toolbar_toggled(self, data=None): + log.debug("on_menuitem_toolbar_toggled") + def on_menuitem_infopane_toggled(self, data=None): + log.debug("on_menuitem_infopane_toggled") + + ## Help Menu ## + def on_menuitem_about_activate(self, data=None): + log.debug("on_menuitem_about_activate") + diff --git a/deluge/ui/gtkui/po/deluge.pot b/deluge/ui/gtkui/po/deluge.pot new file mode 100644 index 000000000..e69de29bb diff --git a/deluge/ui/gtkui/toolbar.py b/deluge/ui/gtkui/toolbar.py new file mode 100644 index 000000000..2bb60891e --- /dev/null +++ b/deluge/ui/gtkui/toolbar.py @@ -0,0 +1,81 @@ +# +# toolbar.py +# +# Copyright (C) Andrew Resch 2007 +# +# 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 + +# Get the logger +log = logging.getLogger("deluge") + +class ToolBar: + def __init__(self, window): + log.debug("ToolBar Init..") + self.window = window + + ### Connect Signals ### + self.window.main_glade.signal_autoconnect({ + "on_toolbutton_add_clicked": self.on_toolbutton_add_clicked, + "on_toolbutton_remove_clicked": self.on_toolbutton_remove_clicked, + "on_toolbutton_clear_clicked": self.on_toolbutton_clear_clicked, + "on_toolbutton_pause_clicked": self.on_toolbutton_pause_clicked, + "on_toolbutton_queueup_clicked": \ + self.on_toolbutton_queueup_clicked, + "on_toolbutton_queuedown_clicked": \ + self.on_toolbutton_queuedown_clicked, + "on_toolbutton_preferences_clicked": \ + self.on_toolbutton_preferences_clicked, + "on_toolbutton_plugins_clicked": \ + self.on_toolbutton_plugins_clicked, + }) + + ### Callbacks ### + def on_toolbutton_add_clicked(self, data): + log.debug("on_toolbutton_add_clicked") + def on_toolbutton_remove_clicked(self, data): + log.debug("on_toolbutton_remove_clicked") + def on_toolbutton_clear_clicked(self, data): + log.debug("on_toolbutton_clear_clicked") + def on_toolbutton_pause_clicked(self, data): + log.debug("on_toolbutton_pause_clicked") + def on_toolbutton_queueup_clicked(self, data): + log.debug("on_toolbutton_queueup_clicked") + def on_toolbutton_queuedown_clicked(self, data): + log.debug("on_toolbutton_queuedown_clicked") + def on_toolbutton_preferences_clicked(self, data): + log.debug("on_toolbutton_preferences_clicked") + def on_toolbutton_plugins_clicked(self, data): + log.debug("on_toolbutton_plugins_clicked") + diff --git a/deluge/ui/gtkui/torrentview.py b/deluge/ui/gtkui/torrentview.py new file mode 100644 index 000000000..c34f4b054 --- /dev/null +++ b/deluge/ui/gtkui/torrentview.py @@ -0,0 +1,158 @@ +# +# torrentview.py +# +# Copyright (C) Andrew Resch 2007 +# +# 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 +import gobject +import gettext + +import columns + +# Get the logger +log = logging.getLogger("deluge") + +class TorrentView: + def __init__(self, window): + log.debug("TorrentView Init..") + self.window = window + # Get the torrent_view widget + self.torrent_view = self.window.main_glade.get_widget("torrent_view") + + ## TreeModel setup ## + # UID, Q#, Status Icon, Name, Size, Progress, Message, Seeders, Peers, + # DL, UL, ETA, Share + self.torrent_model = gtk.ListStore(int, gobject.TYPE_UINT, + gtk.gdk.Pixbuf, str, gobject.TYPE_UINT64, float, str, int, int, + int, int, int, int, gobject.TYPE_UINT, float) + + ## TreeView setup ## + self.torrent_view.set_model(self.torrent_model) + self.torrent_view.set_rules_hint(True) + self.torrent_view.set_reorderable(True) + self.torrent_view.get_selection().set_mode(gtk.SELECTION_MULTIPLE) + + # Initializes the columns for the torrent_view + (TORRENT_VIEW_COL_UID, + TORRENT_VIEW_COL_QUEUE, + TORRENT_VIEW_COL_STATUSICON, + TORRENT_VIEW_COL_NAME, + TORRENT_VIEW_COL_SIZE, + TORRENT_VIEW_COL_PROGRESS, + TORRENT_VIEW_COL_STATUS, + TORRENT_VIEW_COL_CONNECTED_SEEDS, + TORRENT_VIEW_COL_SEEDS, + TORRENT_VIEW_COL_CONNECTED_PEERS, + TORRENT_VIEW_COL_PEERS, + TORRENT_VIEW_COL_DOWNLOAD, + TORRENT_VIEW_COL_UPLOAD, + TORRENT_VIEW_COL_ETA, + TORRENT_VIEW_COL_RATIO) = range(15) + + self.queue_column = columns.add_text_column( + self.torrent_view, "#", + TORRENT_VIEW_COL_QUEUE) + self.name_column = columns.add_texticon_column( + self.torrent_view, + _("Name"), + TORRENT_VIEW_COL_STATUSICON, + TORRENT_VIEW_COL_NAME) + self.size_column = columns.add_func_column( + self.torrent_view, + _("Size"), + columns.cell_data_size, + TORRENT_VIEW_COL_SIZE) + self.status_column = columns.add_progress_column( + self.torrent_view, + _("Status"), + TORRENT_VIEW_COL_PROGRESS, + TORRENT_VIEW_COL_STATUS) + self.seed_column = columns.add_func_column( + self.torrent_view, + _("Seeders"), + columns.cell_data_peer, + (TORRENT_VIEW_COL_CONNECTED_SEEDS, TORRENT_VIEW_COL_SEEDS)) + self.peer_column = columns.add_func_column( + self.torrent_view, + _("Peers"), + columns.cell_data_peer, + (TORRENT_VIEW_COL_CONNECTED_PEERS, TORRENT_VIEW_COL_PEERS)) + self.dl_column = columns.add_func_column( + self.torrent_view, + _("Down Speed"), + columns.cell_data_speed, + TORRENT_VIEW_COL_DOWNLOAD) + self.ul_column = columns.add_func_column( + self.torrent_view, + _("Up Speed"), + columns.cell_data_speed, + TORRENT_VIEW_COL_UPLOAD) + self.eta_column = columns.add_func_column( + self.torrent_view, + _("ETA"), + columns.cell_data_time, + TORRENT_VIEW_COL_ETA) + self.share_column = columns.add_func_column( + self.torrent_view, + _("Ratio"), + columns.cell_data_ratio, + TORRENT_VIEW_COL_RATIO) + + # Set some column settings + self.status_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) + + ### Connect Signals ### + # Connect to the 'button-press-event' to know when to bring up the + # torrent menu popup. + self.torrent_view.connect("button-press-event", + self.on_button_press_event) + # Connect to the 'changed' event of TreeViewSelection to get selection + # changes. + self.torrent_view.get_selection().connect("changed", + self.on_selection_changed) + + ### Callbacks ### + def on_button_press_event(self, widget, event): + log.debug("on_button_press_event") + + def on_selection_changed(self, treeselection, data): + log.debug("on_selection_changed") + diff --git a/setup.py b/setup.py index de554e630..747ce88e8 100644 --- a/setup.py +++ b/setup.py @@ -84,10 +84,7 @@ libtorrent = Extension( ) # Main setup - -_datafiles = [ -] - + setup( name = "deluge", fullname = "Deluge Bittorent Client", @@ -102,7 +99,9 @@ setup( include_package_data = True, package_data = {"deluge": ["ui/gtkui/glade/*.glade", - "data/pixmaps/*.png"]}, + "data/pixmaps/*.png", + "ui/gtkui/po/*.po?" + ]}, ext_package = "deluge", ext_modules = [libtorrent], packages = find_packages(),