This commit is contained in:
Zach Tibbitts 2006-12-08 20:26:35 +00:00
parent 1ae9201eb6
commit 7d2b0a4e8c
2 changed files with 57 additions and 42 deletions

View File

@ -48,15 +48,14 @@ class DelugeGTK:
self.abt = dgtk.AboutDialog()
## Create the preferences dialog
self.prf = self.wtree.get_widget("pref_dialog")
self.prf.set_icon_from_file(dcommon.get_pixmap("deluge32.png"))
self.prf = dgtk.PreferencesDialog()
actions = {
## File Menu
"new_torrent": self.new_torrent,
"add_torrent": self.add_torrent,
"pref_clicked": self.show_preferences_dialog,
"plugins_clicked": self.show_plugins_dialog,
"pref_clicked": self.prf.show_pref,
"plugins_clicked": self.prf.show_plugins,
## Torrent Menu
"show_info": self.show_info_pane,
## Help Menu
@ -82,8 +81,13 @@ class DelugeGTK:
## because that was one of the main places
## Deluge's code (up to 0.4) got way out of
## hand.
self.name_column = dgtk.TextColumn("Name")
self.torrent_view.append_column(self.name_column)
self.progress_column = dgtk.ProgressColumn("Progress")
self.torrent_view.append_column(self.progress_column)
self.check_column = dgtk.ToggleColumn("Enabled")
self.torrent_view.append_column(self.check_column)
@ -92,18 +96,6 @@ class DelugeGTK:
def add_torrent(self, obj):
pass
def show_preferences_dialog(self, obj):
self.prf.show_all()
self.wtree.get_widget("pref_notebook").set_current_page(0)
self.prf.run()
self.prf.hide_all()
def show_plugins_dialog(self, obj):
self.prf.show_all()
self.wtree.get_widget("pref_notebook").set_current_page(2)
self.prf.run()
self.prf.hide_all()
def show_info_pane(self, obj):
if(obj.get_active()):
@ -111,13 +103,7 @@ class DelugeGTK:
else:
self.wtree.get_widget("torrent_info").hide()
def show_about_dialog(self, obj):
self.abt.show()
## For testing purposes, create a copy of the interface
if __name__ == "__main__":
dgtk = DelugeGTK()
gtk.main()

67
dgtk.py
View File

@ -19,6 +19,10 @@
# The Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor
# Boston, MA 02110-1301, USA.
#
#
# Similar to dcommon, this contains any common functions
# related to gtk
import dcommon
import gettext
@ -56,12 +60,32 @@ class AboutDialog:
self.abt.show_all()
self.abt.run()
self.abt.hide_all()
class DelugeColumn(gtk.TreeViewColumn):
def __init__(self, title=None, renderer=None):
gtk.TreeViewColumn.__init__(self, title, renderer)
class PreferencesDialog:
def __init__(self):
self.gladefile = dcommon.get_glade_file("dgtkpref.glade")
self.wtree = gtk.glade.XML(self.gladefile)
self.prf = self.wtree.get_widget("pref_dialog")
self.notebook = self.wtree.get_widget("pref_notebook")
self.prf.set_icon_from_file(dcommon.get_pixmap("deluge32.png"))
def set_value(self, arg):
def show_pref(self, arg=None):
self.prf.show_all()
self.notebook.set_current_page(0)
self.prf.run()
self.prf.hide_all()
def show_plugins(self, arg=None):
self.prf.show_all()
self.notebook.set_current_page(2)
self.prf.run()
self.prf.hide_all()
class TextColumn(gtk.TreeViewColumn):
def __init__(self, title):
gtk.TreeViewColumn.__init__(self, title, gtk.CellRendererText())
def set_value(self, string):
pass
def show(self):
@ -69,24 +93,29 @@ class DelugeColumn(gtk.TreeViewColumn):
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())
class ToggleColumn(gtk.TreeViewColumn):
def __init__(self, title):
gtk.TreeViewColumn.__init__(self, title, gtk.CellRendererToggle())
def set_value(self, value):
pass
def show(self):
self.set_visible(True)
def hide(self):
self.set_visible(False)
class ProgressColumn(DelugeColumn):
def __init__(self, title=None):
DelugeColumn.__init__(self, title, gtk.CellRendererProgress())
class ProgressColumn(gtk.TreeViewColumn):
def __init__(self, title):
gtk.TreeViewColumn.__init__(self, title, gtk.CellRendererProgress())
def set_value(self, progress):
pass
pass
def show(self):
self.set_visible(True)
def hide(self):
self.set_visible(False)