This commit is contained in:
Andrew Resch 2007-07-14 01:33:16 +00:00
parent 02b189f5a5
commit 9280781dd3
11 changed files with 646 additions and 126 deletions

View File

@ -32,9 +32,11 @@
# statement from all source files in the program, then also delete it here. # statement from all source files in the program, then also delete it here.
import logging import logging
import os
import pkg_resources import pkg_resources
import xdg, xdg.BaseDirectory import xdg, xdg.BaseDirectory
import os import gettext
# Get the logger # Get the logger
log = logging.getLogger("deluge") log = logging.getLogger("deluge")
@ -56,3 +58,74 @@ def get_config_dir(filename=None):
def get_default_download_dir(): def get_default_download_dir():
"""Returns the default download directory""" """Returns the default download directory"""
return os.environ.get("HOME") 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'

View File

@ -56,7 +56,6 @@ from deluge.core.torrent import Torrent
# Get the logger # Get the logger
log = logging.getLogger("deluge") log = logging.getLogger("deluge")
#_default_download_dir = deluge.common.get_default_download_dir()
DEFAULT_PREFS = { DEFAULT_PREFS = {
"listen_ports": [6881, 6891], "listen_ports": [6881, 6891],
"download_location": deluge.common.get_default_download_dir(), "download_location": deluge.common.get_default_download_dir(),

152
deluge/ui/gtkui/columns.py Normal file
View File

@ -0,0 +1,152 @@
#
# columns.py
#
# Copyright (C) Andrew Resch 2007 <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 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

View File

@ -23,7 +23,7 @@
<property name="label" translatable="yes">Add Torrent</property> <property name="label" translatable="yes">Add Torrent</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<property name="stock_id">gtk-add</property> <property name="stock_id">gtk-add</property>
<signal name="clicked" handler="add_torrent"/> <signal name="clicked" handler="on_toolbutton_add_clicked"/>
</widget> </widget>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
@ -37,20 +37,20 @@
<property name="label" translatable="yes">Remove Torrent</property> <property name="label" translatable="yes">Remove Torrent</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<property name="stock_id">gtk-remove</property> <property name="stock_id">gtk-remove</property>
<signal name="clicked" handler="remove_torrent"/> <signal name="clicked" handler="on_toolbutton_remove_clicked"/>
</widget> </widget>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
</packing> </packing>
</child> </child>
<child> <child>
<widget class="GtkToolButton" id="toolbutton3"> <widget class="GtkToolButton" id="toolbutton_clear">
<property name="visible">True</property> <property name="visible">True</property>
<property name="tooltip" translatable="yes">Clear Finished Torrents</property> <property name="tooltip" translatable="yes">Clear Finished Torrents</property>
<property name="label" translatable="yes">Clear Finished</property> <property name="label" translatable="yes">Clear Finished</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<property name="stock_id">gtk-clear</property> <property name="stock_id">gtk-clear</property>
<signal name="clicked" handler="clear_finished"/> <signal name="clicked" handler="on_toolbutton_clear_clicked"/>
</widget> </widget>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
@ -73,35 +73,35 @@
<property name="label" translatable="yes">Start</property> <property name="label" translatable="yes">Start</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<property name="stock_id">gtk-media-play</property> <property name="stock_id">gtk-media-play</property>
<signal name="clicked" handler="start_pause"/> <signal name="clicked" handler="on_toolbutton_pause_clicked"/>
</widget> </widget>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
</packing> </packing>
</child> </child>
<child> <child>
<widget class="GtkToolButton" id="toolbutton_up"> <widget class="GtkToolButton" id="toolbutton_queueup">
<property name="visible">True</property> <property name="visible">True</property>
<property name="sensitive">False</property> <property name="sensitive">False</property>
<property name="tooltip" translatable="yes">Queue Torrent Up</property> <property name="tooltip" translatable="yes">Queue Torrent Up</property>
<property name="label" translatable="yes">Move Up</property> <property name="label" translatable="yes">Move Up</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<property name="stock_id">gtk-go-up</property> <property name="stock_id">gtk-go-up</property>
<signal name="clicked" handler="queue_up"/> <signal name="clicked" handler="on_toolbutton_queueup_clicked"/>
</widget> </widget>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
</packing> </packing>
</child> </child>
<child> <child>
<widget class="GtkToolButton" id="toolbutton_down"> <widget class="GtkToolButton" id="toolbutton_queuedown">
<property name="visible">True</property> <property name="visible">True</property>
<property name="sensitive">False</property> <property name="sensitive">False</property>
<property name="tooltip" translatable="yes">Queue Torrent Down</property> <property name="tooltip" translatable="yes">Queue Torrent Down</property>
<property name="label" translatable="yes">Move Down</property> <property name="label" translatable="yes">Move Down</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<property name="stock_id">gtk-go-down</property> <property name="stock_id">gtk-go-down</property>
<signal name="clicked" handler="queue_down"/> <signal name="clicked" handler="on_toolbutton_queuedown_clicked"/>
</widget> </widget>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
@ -117,26 +117,26 @@
</packing> </packing>
</child> </child>
<child> <child>
<widget class="GtkToolButton" id="toolbutton1"> <widget class="GtkToolButton" id="toolbutton_preferences">
<property name="visible">True</property> <property name="visible">True</property>
<property name="tooltip" translatable="yes">Preferences</property> <property name="tooltip" translatable="yes">Preferences</property>
<property name="label" translatable="yes">Preferences</property> <property name="label" translatable="yes">Preferences</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<property name="stock_id">gtk-preferences</property> <property name="stock_id">gtk-preferences</property>
<signal name="clicked" handler="pref_clicked"/> <signal name="clicked" handler="on_toolbutton_preferences_clicked"/>
</widget> </widget>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
</packing> </packing>
</child> </child>
<child> <child>
<widget class="GtkToolButton" id="toolbutton2"> <widget class="GtkToolButton" id="toolbutton_plugins">
<property name="visible">True</property> <property name="visible">True</property>
<property name="tooltip" translatable="yes">Plugins</property> <property name="tooltip" translatable="yes">Plugins</property>
<property name="label" translatable="yes">Plugins</property> <property name="label" translatable="yes">Plugins</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<property name="stock_id">gtk-disconnect</property> <property name="stock_id">gtk-disconnect</property>
<signal name="clicked" handler="plugins_clicked"/> <signal name="clicked" handler="on_toolbutton_plugins_clicked"/>
</widget> </widget>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>

View File

@ -36,6 +36,8 @@ import logging
import pygtk import pygtk
pygtk.require('2.0') pygtk.require('2.0')
import gtk, gtk.glade import gtk, gtk.glade
import gettext
import pkg_resources
from mainwindow import MainWindow from mainwindow import MainWindow
@ -47,6 +49,17 @@ class GtkUI:
# Get the core proxy object from the args # Get the core proxy object from the args
self.core = core 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 # Initialize the main window
self.main_window = MainWindow(self.core) self.main_window = MainWindow(self.core)

View File

@ -1,5 +1,5 @@
# #
# gtkui_mainwindow.py # mainwindow.py
# #
# Copyright (C) Andrew Resch 2007 <andrewresch@gmail.com> # Copyright (C) Andrew Resch 2007 <andrewresch@gmail.com>
# #
@ -38,6 +38,10 @@ pygtk.require('2.0')
import gtk, gtk.glade import gtk, gtk.glade
import pkg_resources import pkg_resources
from menubar import MenuBar
from toolbar import ToolBar
from torrentview import TorrentView
# Get the logger # Get the logger
log = logging.getLogger("deluge") log = logging.getLogger("deluge")
@ -53,7 +57,9 @@ class MainWindow:
self.window = self.main_glade.get_widget("main_window") self.window = self.main_glade.get_widget("main_window")
# Initialize various components of the gtkui # 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): def show(self):
self.window.show_all() self.window.show_all()
@ -64,107 +70,3 @@ class MainWindow:
def quit(self): def quit(self):
self.hide() self.hide()
gtk.main_quit() 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

143
deluge/ui/gtkui/menubar.py Normal file
View File

@ -0,0 +1,143 @@
#
# menubar.py
#
# Copyright (C) Andrew Resch 2007 <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
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")

View File

View File

@ -0,0 +1,81 @@
#
# toolbar.py
#
# Copyright (C) Andrew Resch 2007 <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
# 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")

View File

@ -0,0 +1,158 @@
#
# torrentview.py
#
# Copyright (C) Andrew Resch 2007 <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
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")

View File

@ -85,9 +85,6 @@ libtorrent = Extension(
# Main setup # Main setup
_datafiles = [
]
setup( setup(
name = "deluge", name = "deluge",
fullname = "Deluge Bittorent Client", fullname = "Deluge Bittorent Client",
@ -102,7 +99,9 @@ setup(
include_package_data = True, include_package_data = True,
package_data = {"deluge": ["ui/gtkui/glade/*.glade", package_data = {"deluge": ["ui/gtkui/glade/*.glade",
"data/pixmaps/*.png"]}, "data/pixmaps/*.png",
"ui/gtkui/po/*.po?"
]},
ext_package = "deluge", ext_package = "deluge",
ext_modules = [libtorrent], ext_modules = [libtorrent],
packages = find_packages(), packages = find_packages(),