From 7d2b0a4e8cffe566b4fece81a4030e85ca13869c Mon Sep 17 00:00:00 2001 From: Zach Tibbitts Date: Fri, 8 Dec 2006 20:26:35 +0000 Subject: [PATCH] - --- delugegtk.py | 32 +++++++------------------ dgtk.py | 67 +++++++++++++++++++++++++++++++++++++--------------- 2 files changed, 57 insertions(+), 42 deletions(-) diff --git a/delugegtk.py b/delugegtk.py index e312db904..12bab83a7 100755 --- a/delugegtk.py +++ b/delugegtk.py @@ -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() \ No newline at end of file diff --git a/dgtk.py b/dgtk.py index 8c35ade89..fc8ecd942 100644 --- a/dgtk.py +++ b/dgtk.py @@ -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 \ No newline at end of file + pass + + def show(self): + self.set_visible(True) + + def hide(self): + self.set_visible(False) \ No newline at end of file