preliminary columns work, tray icon, dgtk module

This commit is contained in:
Zach Tibbitts 2006-12-08 18:10:47 +00:00
parent cc0c804c77
commit 398b40dec9
4 changed files with 1356 additions and 672 deletions

View File

@ -1,10 +1,28 @@
#!/usr/bin/env python2.4
#
# Deluge common class
# For functions and variables that
# need to be accessed globally.
# delugegtk.py
#
# Copyright (C) Zach Tibbitts 2006 <zach@collegegeek.org>
#
# 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.
#
# delugegtk.py 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 main.py. If not, write to:
# The Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor
# Boston, MA 02110-1301, USA.
import deluge, dcommon
import deluge, dcommon, dgtk
import sys, os, gettext
import pygtk
@ -35,6 +53,9 @@ class DelugeGTK:
}
self.wtree.signal_autoconnect(actions)
## Create the system tray icon
self.tray = dgtk.TrayIcon(self)
## Create the about dialog
gtk.about_dialog_set_url_hook(dcommon.open_url_in_browser)
self.abt = gtk.AboutDialog()
@ -48,6 +69,14 @@ class DelugeGTK:
self.prf = self.wtree.get_widget("pref_dialog")
self.prf.set_icon_from_file(dcommon.get_pixmap("deluge32.png"))
## Create the torrent listview
self.torrent_view = self.wtree.get_widget("torrent_view")
self.torrent_list = gtk.ListStore(str)
self.torrent_view.set_model(self.torrent_list)
self.name_column = dgtk.TextColumn("Name")
self.torrent_view.append_column(self.name_column)
def new_torrent(self, obj):

78
dgtk.py Normal file
View File

@ -0,0 +1,78 @@
# dgtk.py
#
# Copyright (C) Zach Tibbitts 2006 <zach@collegegeek.org>
#
# 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.
#
# dgtk.py 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 main.py. If not, write to:
# The Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor
# Boston, MA 02110-1301, USA.
import dcommon
import pygtk
pygtk.require('2.0')
import gtk
import gtk.glade
## Right now this only supports PyGTK's native
## tray library. I will add egg support into
## this class at a later time.
class TrayIcon(gtk.StatusIcon):
def __init__(self, parent):
gtk.StatusIcon.__init__(self)
self.parent = parent
#self.gladefile = dcommon.get_glade("dgtkpopups.glade")
self.set_from_file(dcommon.get_pixmap("deluge32.png"))
self.set_tooltip("Deluge Bittorrent Client")
class AboutDialog(gtk.AboutDialog):
def __init__(self):
pass
class DelugeColumn(gtk.TreeViewColumn):
def __init__(self, title=None, renderer=None):
gtk.TreeViewColumn.__init__(self, title, renderer)
def set_value(self, arg):
pass
def show(self):
self.set_visible(True)
def hide(self):
self.set_visible(False)
class TextColumn(DelugeColumn):
def __init__(self, title=None):
DelugeColumn.__init__(self, title, gtk.CellRendererText())
def set_value(self, string):
pass
class ToggleColumn(DelugeColumn):
def __init__(self, title=None):
DelugeColumn.__init__(self, title, gtk.CellRendererToggle())
def set_value(self, value):
pass
class ProgressColumn(DelugeColumn):
def __init__(self, title=None):
DelugeColumn.__init__(self, title, gtk.CellRendererProgress())
def set_value(self, progress):
pass

File diff suppressed because it is too large Load Diff

577
glade/dgtkpref.glade Normal file
View File

@ -0,0 +1,577 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
<!--*- mode: xml -*-->
<glade-interface>
<widget class="GtkDialog" id="pref_dialog">
<property name="width_request">480</property>
<property name="border_width">5</property>
<property name="title" translatable="yes">Preferences Dialog</property>
<property name="has_separator">False</property>
<child internal-child="vbox">
<widget class="GtkVBox" id="dialog-vbox1">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_ENTER_NOTIFY_MASK</property>
<property name="spacing">2</property>
<child>
<widget class="GtkNotebook" id="pref_notebook">
<property name="visible">True</property>
<child>
<widget class="GtkScrolledWindow" id="gen_options">
<property name="visible">True</property>
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<child>
<widget class="GtkViewport" id="viewport2">
<property name="visible">True</property>
<child>
<widget class="GtkVBox" id="vbox1">
<property name="visible">True</property>
<property name="resize_mode">GTK_RESIZE_IMMEDIATE</property>
<child>
<widget class="GtkExpander" id="expander6">
<property name="visible">True</property>
<child>
<widget class="GtkTable" id="table5">
<property name="visible">True</property>
<property name="n_rows">3</property>
<property name="n_columns">2</property>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<widget class="GtkCheckButton" id="chk_min_on_close">
<property name="visible">True</property>
<property name="label" translatable="yes">Minimize to tray on close</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
<property name="right_attach">2</property>
</packing>
</child>
</widget>
</child>
<child>
<widget class="GtkLabel" id="label29">
<property name="visible">True</property>
<property name="label" translatable="yes">Options</property>
</widget>
<packing>
<property name="type">label_item</property>
</packing>
</child>
</widget>
<packing>
<property name="expand">False</property>
</packing>
</child>
<child>
<widget class="GtkExpander" id="expander1">
<property name="visible">True</property>
<child>
<widget class="GtkTable" id="table3">
<property name="visible">True</property>
<property name="n_rows">2</property>
<property name="n_columns">2</property>
<child>
<widget class="GtkRadioButton" id="radio_ask_save">
<property name="visible">True</property>
<property name="label" translatable="yes">Ask me where to save each download</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
<property name="right_attach">2</property>
</packing>
</child>
<child>
<widget class="GtkRadioButton" id="radio_save_all_too">
<property name="visible">True</property>
<property name="label" translatable="yes">Save all downloads to:</property>
<property name="draw_indicator">True</property>
<property name="group">radio_ask_save</property>
</widget>
<packing>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
</packing>
</child>
<child>
<widget class="GtkFileChooserButton" id="filechooserbutton1">
<property name="action">GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER</property>
<property name="visible">True</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
</packing>
</child>
</widget>
</child>
<child>
<widget class="GtkLabel" id="label16">
<property name="visible">True</property>
<property name="label" translatable="yes">Save Location</property>
</widget>
<packing>
<property name="type">label_item</property>
</packing>
</child>
</widget>
<packing>
<property name="expand">False</property>
<property name="position">1</property>
</packing>
</child>
<child>
<widget class="GtkExpander" id="expander2">
<property name="visible">True</property>
<property name="expanded">True</property>
<child>
<widget class="GtkTable" id="table4">
<property name="visible">True</property>
<property name="n_rows">1</property>
<property name="n_columns">2</property>
<child>
<widget class="GtkCheckButton" id="checkbutton1">
<property name="visible">True</property>
<property name="label" translatable="yes">Stop seeding torrents when
their share ratio reaches:</property>
<property name="draw_indicator">True</property>
</widget>
</child>
<child>
<widget class="GtkSpinButton" id="spinbutton1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="adjustment">0.10000000000000001 0 10 0.10000000000000001 10 10</property>
<property name="climb_rate">0.10000000149011612</property>
<property name="digits">2</property>
<property name="snap_to_ticks">True</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
</packing>
</child>
</widget>
</child>
<child>
<widget class="GtkLabel" id="label21">
<property name="visible">True</property>
<property name="label" translatable="yes">Seeding</property>
</widget>
<packing>
<property name="type">label_item</property>
</packing>
</child>
</widget>
<packing>
<property name="expand">False</property>
<property name="position">2</property>
</packing>
</child>
<child>
<widget class="GtkExpander" id="expander3">
<property name="visible">True</property>
<property name="expanded">True</property>
<child>
<widget class="GtkCheckButton" id="checkbutton2">
<property name="visible">True</property>
<property name="label" translatable="yes">Use compact storage allocation</property>
<property name="draw_indicator">True</property>
</widget>
</child>
<child>
<widget class="GtkLabel" id="label22">
<property name="visible">True</property>
<property name="label" translatable="yes">Storage</property>
</widget>
<packing>
<property name="type">label_item</property>
</packing>
</child>
</widget>
<packing>
<property name="expand">False</property>
<property name="position">3</property>
</packing>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</widget>
</child>
</widget>
</child>
</widget>
<packing>
<property name="tab_expand">False</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label13">
<property name="visible">True</property>
<property name="label" translatable="yes">General</property>
</widget>
<packing>
<property name="type">tab</property>
<property name="tab_expand">False</property>
<property name="tab_fill">False</property>
</packing>
</child>
<child>
<widget class="GtkScrolledWindow" id="net_options">
<property name="visible">True</property>
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<child>
<widget class="GtkViewport" id="viewport3">
<property name="visible">True</property>
<child>
<widget class="GtkVBox" id="vbox2">
<property name="visible">True</property>
<child>
<widget class="GtkExpander" id="expander5">
<property name="visible">True</property>
<child>
<widget class="GtkTable" id="table6">
<property name="visible">True</property>
<property name="n_rows">2</property>
<property name="n_columns">4</property>
<child>
<placeholder/>
</child>
<child>
<widget class="GtkButton" id="button6">
<property name="visible">True</property>
<property name="label" translatable="yes">Test Port</property>
</widget>
<packing>
<property name="left_attach">3</property>
<property name="right_attach">4</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label28">
<property name="visible">True</property>
<property name="label" translatable="yes">label</property>
</widget>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label27">
<property name="visible">True</property>
<property name="label" translatable="yes">Active port:</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
</packing>
</child>
<child>
<widget class="GtkSpinButton" id="spinbutton3">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="adjustment">0 0 100 1 10 10</property>
</widget>
<packing>
<property name="left_attach">3</property>
<property name="right_attach">4</property>
</packing>
</child>
<child>
<widget class="GtkSpinButton" id="spinbutton2">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="adjustment">0 0 100 1 10 10</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label26">
<property name="visible">True</property>
<property name="label" translatable="yes">to:</property>
</widget>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label25">
<property name="visible">True</property>
<property name="label" translatable="yes">Try from:</property>
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkLabel" id="label24">
<property name="visible">True</property>
<property name="label" translatable="yes">TCP Port</property>
</widget>
<packing>
<property name="type">label_item</property>
</packing>
</child>
</widget>
<packing>
<property name="expand">False</property>
</packing>
</child>
<child>
<widget class="GtkExpander" id="expander4">
<property name="visible">True</property>
<child>
<widget class="GtkTable" id="table7">
<property name="visible">True</property>
<property name="n_rows">4</property>
<property name="n_columns">2</property>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<widget class="GtkSpinButton" id="spinbutton7">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="adjustment">0 0 100 1 10 10</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
</packing>
</child>
<child>
<widget class="GtkSpinButton" id="spinbutton6">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="adjustment">0 0 100 1 10 10</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
</packing>
</child>
<child>
<widget class="GtkSpinButton" id="spinbutton5">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="adjustment">0 0 100 1 10 10</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
</packing>
</child>
<child>
<widget class="GtkSpinButton" id="spinbutton4">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="adjustment">0 0 100 1 10 10</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
</packing>
</child>
</widget>
</child>
<child>
<widget class="GtkLabel" id="label23">
<property name="visible">True</property>
<property name="label" translatable="yes">Bandwidth</property>
</widget>
<packing>
<property name="type">label_item</property>
</packing>
</child>
</widget>
<packing>
<property name="expand">False</property>
<property name="position">1</property>
</packing>
</child>
<child>
<placeholder/>
</child>
</widget>
</child>
</widget>
</child>
</widget>
<packing>
<property name="position">1</property>
<property name="tab_expand">False</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label17">
<property name="visible">True</property>
<property name="label" translatable="yes">Network</property>
</widget>
<packing>
<property name="type">tab</property>
<property name="position">1</property>
<property name="tab_expand">False</property>
<property name="tab_fill">False</property>
</packing>
</child>
<child>
<widget class="GtkTable" id="plugins_options">
<property name="visible">True</property>
<property name="n_rows">2</property>
<property name="n_columns">2</property>
<child>
<widget class="GtkTextView" id="textview1">
<property name="visible">True</property>
<property name="editable">False</property>
<property name="wrap_mode">GTK_WRAP_WORD</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="x_padding">10</property>
<property name="y_padding">10</property>
</packing>
</child>
<child>
<widget class="GtkHButtonBox" id="hbuttonbox1">
<property name="visible">True</property>
<property name="layout_style">GTK_BUTTONBOX_SPREAD</property>
<child>
<widget class="GtkButton" id="button1">
<property name="visible">True</property>
<property name="label" translatable="yes">button</property>
</widget>
</child>
<child>
<widget class="GtkButton" id="button2">
<property name="visible">True</property>
<property name="label" translatable="yes">button</property>
</widget>
<packing>
<property name="position">1</property>
</packing>
</child>
<child>
<widget class="GtkButton" id="button3">
<property name="visible">True</property>
<property name="label" translatable="yes">button</property>
</widget>
<packing>
<property name="position">2</property>
</packing>
</child>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
<child>
<widget class="GtkTreeView" id="treeview1">
<property name="visible">True</property>
</widget>
<packing>
<property name="bottom_attach">2</property>
</packing>
</child>
</widget>
<packing>
<property name="position">2</property>
<property name="tab_expand">False</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label20">
<property name="visible">True</property>
<property name="label" translatable="yes">Plugins</property>
</widget>
<packing>
<property name="type">tab</property>
<property name="position">2</property>
<property name="tab_expand">False</property>
<property name="tab_fill">False</property>
</packing>
</child>
</widget>
<packing>
<property name="position">1</property>
</packing>
</child>
<child internal-child="action_area">
<widget class="GtkHButtonBox" id="dialog-action_area1">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_ENTER_NOTIFY_MASK</property>
<property name="layout_style">GTK_BUTTONBOX_END</property>
<child>
<widget class="GtkButton" id="button5">
<property name="visible">True</property>
<property name="label" translatable="yes">gtk-cancel</property>
<property name="use_stock">True</property>
</widget>
</child>
<child>
<widget class="GtkButton" id="button4">
<property name="visible">True</property>
<property name="label" translatable="yes">gtk-ok</property>
<property name="use_stock">True</property>
</widget>
<packing>
<property name="position">1</property>
</packing>
</child>
</widget>
<packing>
<property name="expand">False</property>
<property name="pack_type">GTK_PACK_END</property>
</packing>
</child>
</widget>
</child>
</widget>
</glade-interface>