proper column implementation :D
This commit is contained in:
parent
520a819ae4
commit
337b55ce9d
51
delugegtk.py
51
delugegtk.py
|
@ -36,6 +36,7 @@ class DelugeGTK:
|
|||
self.gladefile = dcommon.get_glade_file("delugegtk.glade")
|
||||
self.wtree = gtk.glade.XML(self.gladefile)
|
||||
self.window = self.wtree.get_widget("main_window")
|
||||
self.toolbar = self.wtree.get_widget("tb_middle")
|
||||
if(self.window):
|
||||
self.window.connect("destroy", gtk.main_quit)
|
||||
self.window.set_title(dcommon.PROGRAM_NAME + " " + dcommon.PROGRAM_VERSION)
|
||||
|
@ -54,6 +55,7 @@ class DelugeGTK:
|
|||
## File Menu
|
||||
"new_torrent": self.new_torrent,
|
||||
"add_torrent": self.add_torrent,
|
||||
"menu_quit": self.quit,
|
||||
## Edit Menu
|
||||
"pref_clicked": self.prf.show_pref,
|
||||
"plugins_clicked": self.prf.show_plugins,
|
||||
|
@ -63,12 +65,11 @@ class DelugeGTK:
|
|||
}
|
||||
self.wtree.signal_autoconnect(actions)
|
||||
|
||||
|
||||
|
||||
## Create the torrent listview
|
||||
self.torrent_view = self.wtree.get_widget("torrent_view")
|
||||
self.store = gtk.ListStore(str)
|
||||
self.torrent_view.set_model(self.store)
|
||||
self.view = self.wtree.get_widget("torrent_view")
|
||||
# UID, Q#, Name, Size, Progress, Message, Seeders, Peers, DL, UL, ETA, Share
|
||||
self.store = gtk.ListStore(int, int, str, str, int, str, str, str, str, str, str, str)
|
||||
self.view.set_model(self.store)
|
||||
|
||||
|
||||
## Still a lot of work to be done here,
|
||||
|
@ -82,23 +83,43 @@ class DelugeGTK:
|
|||
## Deluge's code (up to 0.4) got way out of
|
||||
## hand.
|
||||
|
||||
self.name_column = dgtk.TextColumn("Name", 0)
|
||||
self.torrent_view.append_column(self.name_column)
|
||||
self.progress_column = dgtk.ProgressColumn("Progress", 1)
|
||||
self.torrent_view.append_column(self.progress_column)
|
||||
self.check_column = dgtk.ToggleColumn("Enabled", 2)
|
||||
self.torrent_view.append_column(self.check_column)
|
||||
|
||||
self.queue_column = dgtk.add_text_column(self.view, "#", 1)
|
||||
self.name_column = dgtk.add_text_column(self.view, "Name", 2)
|
||||
self.size_column = dgtk.add_text_column(self.view, "Size", 3)
|
||||
self.status_column = dgtk.add_progress_column(self.view, "Status", 4, 5)
|
||||
self.seed_column = dgtk.add_text_column(self.view, "Seeders", 6)
|
||||
self.peer_column = dgtk.add_text_column(self.view, "Peers", 7)
|
||||
self.dl_column = dgtk.add_text_column(self.view, "Download", 8)
|
||||
self.ul_column = dgtk.add_text_column(self.view, "Upload", 9)
|
||||
self.eta_column = dgtk.add_text_column(self.view, "Time Remaining", 10)
|
||||
self.share_column = dgtk.add_text_column(self.view, "Share Ratio", 11)
|
||||
|
||||
## Interface created
|
||||
|
||||
def new_torrent(self, obj):
|
||||
def start(self):
|
||||
pass
|
||||
|
||||
def add_torrent(self, obj):
|
||||
def new_torrent(self, obj=None):
|
||||
pass
|
||||
|
||||
def add_torrent(self, obj=None):
|
||||
pass
|
||||
|
||||
def quit(self, obj=None):
|
||||
self.window.destroy()
|
||||
|
||||
## Call via a timer to update the interface
|
||||
def update(self):
|
||||
pass
|
||||
|
||||
|
||||
## For testing purposes, create a copy of the interface
|
||||
if __name__ == "__main__":
|
||||
dgtk = DelugeGTK()
|
||||
d = DelugeGTK()
|
||||
## Add an example line
|
||||
|
||||
## Test the interface by adding a few fake torrents
|
||||
d.store.append([0,1,"Deluge Torrent","700MB",50,"Downloading","10 (50)", "15 (30)", "50 KB/s", "10 KB/s", "2 h", "100%"])
|
||||
d.store.append([1,2,"Sample Torrent","350MB",75,"Queued","10 (20)","20 (20)","0 KB/s", "0 KB/s", "und", "0%"])
|
||||
|
||||
gtk.main()
|
99
dgtk.py
99
dgtk.py
|
@ -40,10 +40,56 @@ class TrayIcon:
|
|||
self.parent = parent
|
||||
self.tray = gtk.StatusIcon()
|
||||
## uncomment later
|
||||
##self.gladefile = dcommon.get_glade("dgtkpopups.glade")
|
||||
##self.gladefile = dcommon.get_glade_file("dgtkpopups.glade")
|
||||
self.tray.set_from_file(dcommon.get_pixmap("deluge32.png"))
|
||||
self.tray.set_tooltip("Deluge Bittorrent Client")
|
||||
|
||||
class TorrentPopup:
|
||||
def __init__(self, parent):
|
||||
self.parent = parent
|
||||
self.gladefile = dcommon.get_glade_file("dgtkpopups.glade")
|
||||
self.wtree = gtk.glade.XML(self.gladefile)
|
||||
self.menu = self.wtree.get_widget("torrent_popup")
|
||||
dic = {
|
||||
"size_toggle": self.size,
|
||||
"status_toggle": self.status,
|
||||
"seeders_toggle": self.seeders,
|
||||
"peers_toggle": self.peers,
|
||||
"dl_toggle": self.dl,
|
||||
"ul_toggle": self.ul,
|
||||
"eta_toggle": self.eta,
|
||||
"share_toggle": self.share
|
||||
|
||||
}
|
||||
self.wtree.signal_autoconnect(dic)
|
||||
|
||||
def popup(self):
|
||||
pass
|
||||
|
||||
## Toggle functions
|
||||
def size(self, obj):
|
||||
pass
|
||||
|
||||
def status(self, obj):
|
||||
pass
|
||||
|
||||
def seeders(self, obj):
|
||||
pass
|
||||
|
||||
def peers(self, obj):
|
||||
pass
|
||||
|
||||
def dl(self, obj):
|
||||
pass
|
||||
|
||||
def ul(self, obj):
|
||||
pass
|
||||
|
||||
def eta(self, obj):
|
||||
pass
|
||||
|
||||
def share(self, obj):
|
||||
pass
|
||||
|
||||
class AboutDialog:
|
||||
def __init__(self):
|
||||
|
@ -87,42 +133,19 @@ class PreferencesDialog:
|
|||
## a more organized form of the old add_column method, which will properly
|
||||
## create and add the column and in addition, return that column to the
|
||||
## calling function.
|
||||
|
||||
class TextColumn(gtk.TreeViewColumn):
|
||||
def __init__(self, title, cid):
|
||||
gtk.TreeViewColumn.__init__(self, title, gtk.CellRendererText())
|
||||
|
||||
def show(self):
|
||||
self.set_visible(True)
|
||||
|
||||
def hide(self):
|
||||
self.set_visible(False)
|
||||
|
||||
class ToggleColumn(gtk.TreeViewColumn):
|
||||
def __init__(self, title, cid):
|
||||
self.renderer = gtk.CellRendererToggle()
|
||||
gtk.TreeViewColumn.__init__(self, title, self.renderer, value=cid)
|
||||
self.set_resizable(True)
|
||||
self.set_sort_column_id(cid)
|
||||
self.set_expand(False)
|
||||
#renderer.connect("toggled", toggledSignal, cid)
|
||||
def add_text_column(view, header, cid):
|
||||
render = gtk.CellRendererText()
|
||||
column = gtk.TreeViewColumn(header, render, text=cid)
|
||||
column.set_resizable(True)
|
||||
column.set_expand(False)
|
||||
view.append_column(column)
|
||||
return column
|
||||
|
||||
def show(self):
|
||||
self.set_visible(True)
|
||||
|
||||
def hide(self):
|
||||
self.set_visible(False)
|
||||
|
||||
class ProgressColumn(gtk.TreeViewColumn):
|
||||
def __init__(self, title, cid):
|
||||
self.renderer = gtk.CellRendererProgress()
|
||||
gtk.TreeViewColumn.__init__(self, title, self.renderer, value=cid)
|
||||
self.set_resizable(True)
|
||||
self.set_sort_column_id(cid)
|
||||
self.set_expand(True)
|
||||
|
||||
def show(self):
|
||||
self.set_visible(True)
|
||||
|
||||
def hide(self):
|
||||
self.set_visible(False)
|
||||
def add_progress_column(view, header, pid, mid):
|
||||
render = gtk.CellRendererProgress()
|
||||
column = gtk.TreeViewColumn(header, render, value=pid, text=mid)
|
||||
column.set_resizable(True)
|
||||
column.set_expand(True)
|
||||
view.append_column(column)
|
||||
return column
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue