mirror of
https://git.deluge-torrent.org/deluge
synced 2025-08-02 22:48:40 +00:00
[#2783] [GTKUI] Case insensitive sort for name column
This commit is contained in:
parent
e28954f63e
commit
be7ad16a3f
2 changed files with 16 additions and 4 deletions
|
@ -652,7 +652,7 @@ class ListView:
|
||||||
|
|
||||||
def add_texticon_column(self, header, col_types=[str, str], sortid=1,
|
def add_texticon_column(self, header, col_types=[str, str], sortid=1,
|
||||||
hidden=False, position=None, status_field=None,
|
hidden=False, position=None, status_field=None,
|
||||||
column_type="texticon", function=None,
|
column_type="texticon", function=None, sort_func=None,
|
||||||
default=True):
|
default=True):
|
||||||
"""Adds a texticon column to the listview."""
|
"""Adds a texticon column to the listview."""
|
||||||
render1 = gtk.CellRendererPixbuf()
|
render1 = gtk.CellRendererPixbuf()
|
||||||
|
@ -660,8 +660,8 @@ class ListView:
|
||||||
|
|
||||||
self.add_column(header, (render1, render2), col_types, hidden, position,
|
self.add_column(header, (render1, render2), col_types, hidden, position,
|
||||||
status_field, sortid, column_type=column_type,
|
status_field, sortid, column_type=column_type,
|
||||||
function=function, pixbuf=0, text=1, default=default)
|
function=function, sort_func=sort_func, pixbuf=0,
|
||||||
|
text=1, default=default)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def on_keypress_search_by_name(self, model, columnn, key, iter):
|
def on_keypress_search_by_name(self, model, columnn, key, iter):
|
||||||
|
|
|
@ -42,6 +42,7 @@ import gtk, gtk.glade
|
||||||
import gettext
|
import gettext
|
||||||
import gobject
|
import gobject
|
||||||
import warnings
|
import warnings
|
||||||
|
from locale import strcoll
|
||||||
from urlparse import urlparse
|
from urlparse import urlparse
|
||||||
|
|
||||||
import deluge.common
|
import deluge.common
|
||||||
|
@ -169,6 +170,16 @@ def cell_data_queue(column, cell, model, row, data):
|
||||||
else:
|
else:
|
||||||
cell.set_property("text", str(value + 1))
|
cell.set_property("text", str(value + 1))
|
||||||
|
|
||||||
|
def str_nocase_sort(model, iter1, iter2, data):
|
||||||
|
"""
|
||||||
|
Sort string column data with locale.strcoll which (allegedly)
|
||||||
|
uses ISO 14651.
|
||||||
|
|
||||||
|
"""
|
||||||
|
v1 = model[iter1][data].lower()
|
||||||
|
v2 = model[iter2][data].lower()
|
||||||
|
return strcoll(v1, v2)
|
||||||
|
|
||||||
def queue_peer_seed_sort_function(v1, v2):
|
def queue_peer_seed_sort_function(v1, v2):
|
||||||
if v1 == v2:
|
if v1 == v2:
|
||||||
return 0
|
return 0
|
||||||
|
@ -254,7 +265,8 @@ class TorrentView(listview.ListView, component.Component):
|
||||||
sort_func=queue_column_sort)
|
sort_func=queue_column_sort)
|
||||||
self.add_texticon_column(_("Name"),
|
self.add_texticon_column(_("Name"),
|
||||||
status_field=["state", "name"],
|
status_field=["state", "name"],
|
||||||
function=cell_data_statusicon)
|
function=cell_data_statusicon,
|
||||||
|
sort_func=str_nocase_sort)
|
||||||
self.add_func_column(_("Size"), listview.cell_data_size,
|
self.add_func_column(_("Size"), listview.cell_data_size,
|
||||||
[gobject.TYPE_UINT64],
|
[gobject.TYPE_UINT64],
|
||||||
status_field=["total_wanted"])
|
status_field=["total_wanted"])
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue