diff options
author | Justin Lewis <jtl1728@rit.edu> | 2010-01-19 17:17:21 (GMT) |
---|---|---|
committer | Justin Lewis <jtl1728@rit.edu> | 2010-01-19 17:17:21 (GMT) |
commit | 62aa66103fbf207e14861fec99273b91ccf53bdd (patch) | |
tree | ae73e6b3a83f50cb08d4c315504ec311dc676960 | |
parent | d99f604d1ae2f525d54509febc02f22082f9a8c8 (diff) |
Updated tree view, expanding only description.
Cleaned up code, now uses one clean loop
-rw-r--r-- | FileShare.activity/FileInfo.py | 2 | ||||
-rw-r--r-- | FileShare.activity/GuiView.py | 57 |
2 files changed, 22 insertions, 37 deletions
diff --git a/FileShare.activity/FileInfo.py b/FileShare.activity/FileInfo.py index a497a79..35f5ff6 100644 --- a/FileShare.activity/FileInfo.py +++ b/FileShare.activity/FileInfo.py @@ -29,7 +29,7 @@ class FileInfo(object): if have_file: self.aquired = size self.percent = 100 - self.status = _("File Shared") + self.status = _("Shared") else: self.aquired = 0 self.percent = 0 diff --git a/FileShare.activity/GuiView.py b/FileShare.activity/GuiView.py index ad4f21f..d0c0431 100644 --- a/FileShare.activity/GuiView.py +++ b/FileShare.activity/GuiView.py @@ -375,44 +375,29 @@ class GuiView(gtk.ScrolledWindow): # Create File Tree ################## - # create the TreeViewColumn to display the data - colName = gtk.TreeViewColumn(_('File Name')) - colDesc = gtk.TreeViewColumn(_('Description')) - colTags = gtk.TreeViewColumn(_('Tags')) - colSize = gtk.TreeViewColumn(_('File Size')) - colProg = gtk.TreeViewColumn('') - - self.treeview.append_column(colName) - self.treeview.append_column(colDesc) - self.treeview.append_column(colTags) - self.treeview.append_column(colSize) - self.treeview.append_column(colProg) - - # create a CellRendererText to render the data - cell = gtk.CellRendererText() - pbar = gtk.CellRendererProgress() - - # add the cell to the tvcolumn and allow it to expand - colName.pack_start(cell, True) - colDesc.pack_start(cell, True) - colTags.pack_start(cell, True) - colSize.pack_start(cell, True) - colProg.pack_start(pbar, True) - - # set the cell "text" attribute- retrieve text - # from that column in treestore - colName.set_cell_data_func(cell, FileInfo.file_name) - colDesc.set_cell_data_func(cell, FileInfo.file_desc) - colTags.set_cell_data_func(cell, FileInfo.file_tags) - colSize.set_cell_data_func(cell, FileInfo.file_size) - colProg.set_cell_data_func(pbar, FileInfo.load_bar) - - # make it searchable + # Name Cell_data_Func Expand Cell Renderer + text_cells = [ + [ _('File Name'), FileInfo.file_name, False, gtk.CellRendererText()], + [ _('Description'), FileInfo.file_desc, True, gtk.CellRendererText()], + [ _('Tags'), FileInfo.file_tags, False, gtk.CellRendererText()], + [ _('File Size'), FileInfo.file_size, False, gtk.CellRendererText()], + [ '', FileInfo.load_bar, False, gtk.CellRendererProgress()] + ] + + for col_data in text_cells: + cell = col_data[3] + colName = gtk.TreeViewColumn(col_data[0], cell) + colName.set_cell_data_func(cell, col_data[1]) + + # Should the col expand + colName.set_expand(col_data[2]) + + # Add to tree + self.treeview.append_column(colName) + + # make it searchable by name self.treeview.set_search_column(1) - # Allow sorting on the column - colName.set_sort_column_id(1) - # Allow Multiple Selections self.treeview.get_selection().set_mode( gtk.SELECTION_MULTIPLE ) self.treeview.get_selection().connect('changed', self.on_selection_changed ) |