Fix sorting by size on the Files tab - plisk

This commit is contained in:
Marcos Pinto 2007-07-11 05:30:49 +00:00
commit 623c1c8dfc
3 changed files with 14 additions and 9 deletions

View file

@ -957,9 +957,9 @@ static PyObject *torrent_get_file_info(PyObject *self, PyObject *args)
file_entry const &currFile = (*i); file_entry const &currFile = (*i);
file_info = Py_BuildValue( file_info = Py_BuildValue(
"{s:s,s:d,s:f}", "{s:s,s:L,s:f}",
"path", currFile.path.string().c_str(), "path", currFile.path.string().c_str(),
"size", double(currFile.size), "size", currFile.size,
"progress", progresses[i - start]*100.0 "progress", progresses[i - start]*100.0
); );

View file

@ -54,6 +54,11 @@ def cell_data_speed(column, cell, model, iter, data):
speed_str = common.fspeed(speed) speed_str = common.fspeed(speed)
cell.set_property('text', speed_str) cell.set_property('text', speed_str)
def cell_data_size(column, cell, model, iter, data):
size = long(model.get_value(iter, data))
size_str = common.fsize(size)
cell.set_property('text', size_str)
## Functions to create columns ## Functions to create columns
def add_func_column(view, header, func, data, sortid=None): def add_func_column(view, header, func, data, sortid=None):

View file

@ -459,7 +459,7 @@ class DelugeGTK:
self.queue_column = dgtk.add_text_column(self.torrent_view, "#", TORRENT_VIEW_COL_QUEUE) self.queue_column = dgtk.add_text_column(self.torrent_view, "#", TORRENT_VIEW_COL_QUEUE)
self.name_column = dgtk.add_texticon_column(self.torrent_view, _("Name"), TORRENT_VIEW_COL_STATUSICON, TORRENT_VIEW_COL_NAME) self.name_column = dgtk.add_texticon_column(self.torrent_view, _("Name"), TORRENT_VIEW_COL_STATUSICON, TORRENT_VIEW_COL_NAME)
self.size_column = dgtk.add_func_column(self.torrent_view, _("Size"), size, TORRENT_VIEW_COL_SIZE) self.size_column = dgtk.add_func_column(self.torrent_view, _("Size"), dgtk.cell_data_size, TORRENT_VIEW_COL_SIZE)
self.status_column = dgtk.add_progress_column(self.torrent_view, _("Status"), TORRENT_VIEW_COL_PROGRESS, TORRENT_VIEW_COL_STATUS) self.status_column = dgtk.add_progress_column(self.torrent_view, _("Status"), TORRENT_VIEW_COL_PROGRESS, TORRENT_VIEW_COL_STATUS)
self.seed_column = dgtk.add_func_column(self.torrent_view, _("Seeders"), peer, (TORRENT_VIEW_COL_CONNECTED_SEEDS, TORRENT_VIEW_COL_SEEDS)) self.seed_column = dgtk.add_func_column(self.torrent_view, _("Seeders"), peer, (TORRENT_VIEW_COL_CONNECTED_SEEDS, TORRENT_VIEW_COL_SEEDS))
self.peer_column = dgtk.add_func_column(self.torrent_view, _("Peers"), peer, (TORRENT_VIEW_COL_CONNECTED_PEERS, TORRENT_VIEW_COL_PEERS)) self.peer_column = dgtk.add_func_column(self.torrent_view, _("Peers"), peer, (TORRENT_VIEW_COL_CONNECTED_PEERS, TORRENT_VIEW_COL_PEERS))
@ -518,9 +518,9 @@ class DelugeGTK:
assert(len(all_files) == len(file_filter)) assert(len(all_files) == len(file_filter))
i=0 i=0
for f in all_files: for f in all_files:
self.file_store.append([not file_filter[i], f['path'], common.fsize(f['size']), self.file_store.append([not file_filter[i], f['path'], f['size'],
round(f['progress'],2)]) round(f['progress'], 2)])
i=i+1 i=i+1
return True return True
@ -642,7 +642,7 @@ class DelugeGTK:
"check_selected": self.file_check_selected, "check_selected": self.file_check_selected,
"uncheck_selected": self.file_uncheck_selected, "uncheck_selected": self.file_uncheck_selected,
}) })
self.file_store = gtk.ListStore(bool, str, str, float) self.file_store = gtk.ListStore(bool, str, gobject.TYPE_UINT64, float)
self.file_view.set_model(self.file_store) self.file_view.set_model(self.file_store)
self.file_view.get_selection().set_mode(gtk.SELECTION_MULTIPLE) self.file_view.get_selection().set_mode(gtk.SELECTION_MULTIPLE)
self.file_view.get_selection().set_select_function(self.file_clicked) self.file_view.get_selection().set_select_function(self.file_clicked)
@ -651,7 +651,7 @@ class DelugeGTK:
dgtk.add_toggle_column(self.file_view, _("Download"), 0, toggled_signal=self.file_toggled) dgtk.add_toggle_column(self.file_view, _("Download"), 0, toggled_signal=self.file_toggled)
dgtk.add_text_column(self.file_view, _("Filename"), 1).set_expand(True) dgtk.add_text_column(self.file_view, _("Filename"), 1).set_expand(True)
dgtk.add_text_column(self.file_view, _("Size"), 2) dgtk.add_func_column(self.file_view, _("Size"), dgtk.cell_data_size, 2)
dgtk.add_func_column(self.file_view, _("Progress"), percent, 3) dgtk.add_func_column(self.file_view, _("Progress"), percent, 3)
def file_select_all(self, widget): def file_select_all(self, widget):