This commit is contained in:
parent
1ae9201eb6
commit
7d2b0a4e8c
32
delugegtk.py
32
delugegtk.py
|
@ -48,15 +48,14 @@ class DelugeGTK:
|
||||||
self.abt = dgtk.AboutDialog()
|
self.abt = dgtk.AboutDialog()
|
||||||
|
|
||||||
## Create the preferences dialog
|
## Create the preferences dialog
|
||||||
self.prf = self.wtree.get_widget("pref_dialog")
|
self.prf = dgtk.PreferencesDialog()
|
||||||
self.prf.set_icon_from_file(dcommon.get_pixmap("deluge32.png"))
|
|
||||||
|
|
||||||
actions = {
|
actions = {
|
||||||
## File Menu
|
## File Menu
|
||||||
"new_torrent": self.new_torrent,
|
"new_torrent": self.new_torrent,
|
||||||
"add_torrent": self.add_torrent,
|
"add_torrent": self.add_torrent,
|
||||||
"pref_clicked": self.show_preferences_dialog,
|
"pref_clicked": self.prf.show_pref,
|
||||||
"plugins_clicked": self.show_plugins_dialog,
|
"plugins_clicked": self.prf.show_plugins,
|
||||||
## Torrent Menu
|
## Torrent Menu
|
||||||
"show_info": self.show_info_pane,
|
"show_info": self.show_info_pane,
|
||||||
## Help Menu
|
## Help Menu
|
||||||
|
@ -82,8 +81,13 @@ class DelugeGTK:
|
||||||
## because that was one of the main places
|
## because that was one of the main places
|
||||||
## Deluge's code (up to 0.4) got way out of
|
## Deluge's code (up to 0.4) got way out of
|
||||||
## hand.
|
## hand.
|
||||||
|
|
||||||
self.name_column = dgtk.TextColumn("Name")
|
self.name_column = dgtk.TextColumn("Name")
|
||||||
self.torrent_view.append_column(self.name_column)
|
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)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -93,31 +97,13 @@ class DelugeGTK:
|
||||||
def add_torrent(self, obj):
|
def add_torrent(self, obj):
|
||||||
pass
|
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):
|
def show_info_pane(self, obj):
|
||||||
if(obj.get_active()):
|
if(obj.get_active()):
|
||||||
self.wtree.get_widget("torrent_info").show()
|
self.wtree.get_widget("torrent_info").show()
|
||||||
else:
|
else:
|
||||||
self.wtree.get_widget("torrent_info").hide()
|
self.wtree.get_widget("torrent_info").hide()
|
||||||
|
|
||||||
|
## For testing purposes, create a copy of the interface
|
||||||
|
|
||||||
def show_about_dialog(self, obj):
|
|
||||||
self.abt.show()
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
dgtk = DelugeGTK()
|
dgtk = DelugeGTK()
|
||||||
gtk.main()
|
gtk.main()
|
63
dgtk.py
63
dgtk.py
|
@ -19,6 +19,10 @@
|
||||||
# The Free Software Foundation, Inc.,
|
# The Free Software Foundation, Inc.,
|
||||||
# 51 Franklin Street, Fifth Floor
|
# 51 Franklin Street, Fifth Floor
|
||||||
# Boston, MA 02110-1301, USA.
|
# Boston, MA 02110-1301, USA.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# Similar to dcommon, this contains any common functions
|
||||||
|
# related to gtk
|
||||||
|
|
||||||
import dcommon
|
import dcommon
|
||||||
import gettext
|
import gettext
|
||||||
|
@ -57,11 +61,31 @@ class AboutDialog:
|
||||||
self.abt.run()
|
self.abt.run()
|
||||||
self.abt.hide_all()
|
self.abt.hide_all()
|
||||||
|
|
||||||
class DelugeColumn(gtk.TreeViewColumn):
|
class PreferencesDialog:
|
||||||
def __init__(self, title=None, renderer=None):
|
def __init__(self):
|
||||||
gtk.TreeViewColumn.__init__(self, title, renderer)
|
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
|
pass
|
||||||
|
|
||||||
def show(self):
|
def show(self):
|
||||||
|
@ -70,23 +94,28 @@ class DelugeColumn(gtk.TreeViewColumn):
|
||||||
def hide(self):
|
def hide(self):
|
||||||
self.set_visible(False)
|
self.set_visible(False)
|
||||||
|
|
||||||
class TextColumn(DelugeColumn):
|
class ToggleColumn(gtk.TreeViewColumn):
|
||||||
def __init__(self, title=None):
|
def __init__(self, title):
|
||||||
DelugeColumn.__init__(self, title, gtk.CellRendererText())
|
gtk.TreeViewColumn.__init__(self, title, gtk.CellRendererToggle())
|
||||||
|
|
||||||
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):
|
def set_value(self, value):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
class ProgressColumn(DelugeColumn):
|
def show(self):
|
||||||
def __init__(self, title=None):
|
self.set_visible(True)
|
||||||
DelugeColumn.__init__(self, title, gtk.CellRendererProgress())
|
|
||||||
|
def hide(self):
|
||||||
|
self.set_visible(False)
|
||||||
|
|
||||||
|
class ProgressColumn(gtk.TreeViewColumn):
|
||||||
|
def __init__(self, title):
|
||||||
|
gtk.TreeViewColumn.__init__(self, title, gtk.CellRendererProgress())
|
||||||
|
|
||||||
def set_value(self, progress):
|
def set_value(self, progress):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def show(self):
|
||||||
|
self.set_visible(True)
|
||||||
|
|
||||||
|
def hide(self):
|
||||||
|
self.set_visible(False)
|
Loading…
Reference in New Issue