mirror of
https://github.com/SoongNoonien/mpdevil.git
synced 2023-08-10 21:12:44 +03:00
fixed sorting in SelectionList (#32)
This commit is contained in:
parent
b7d027edf6
commit
734836711f
15
bin/mpdevil
15
bin/mpdevil
@ -29,6 +29,8 @@ import datetime
|
|||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import re
|
import re
|
||||||
|
import locale
|
||||||
|
locale.setlocale(locale.LC_ALL, "")
|
||||||
from gettext import gettext as _, ngettext, textdomain, bindtextdomain
|
from gettext import gettext as _, ngettext, textdomain, bindtextdomain
|
||||||
textdomain("mpdevil")
|
textdomain("mpdevil")
|
||||||
if os.path.isfile("/.flatpak-info"): # test for flatpak environment
|
if os.path.isfile("/.flatpak-info"): # test for flatpak environment
|
||||||
@ -2055,15 +2057,14 @@ class SelectionList(Gtk.TreeView):
|
|||||||
def set_items(self, items):
|
def set_items(self, items):
|
||||||
self.clear()
|
self.clear()
|
||||||
current_char=""
|
current_char=""
|
||||||
|
items.sort(key=locale.strxfrm)
|
||||||
|
items.sort(key=lambda item: locale.strxfrm(item[:1]))
|
||||||
for item in items:
|
for item in items:
|
||||||
try:
|
if current_char == item[:1].upper():
|
||||||
if current_char == item[0]:
|
|
||||||
self._store.append([item, Pango.Weight.BOOK, "", Pango.Weight.BOOK])
|
|
||||||
else:
|
|
||||||
self._store.append([item, Pango.Weight.BOOK, item[0], Pango.Weight.BOLD])
|
|
||||||
current_char=item[0]
|
|
||||||
except:
|
|
||||||
self._store.append([item, Pango.Weight.BOOK, "", Pango.Weight.BOOK])
|
self._store.append([item, Pango.Weight.BOOK, "", Pango.Weight.BOOK])
|
||||||
|
else:
|
||||||
|
self._store.append([item, Pango.Weight.BOOK, item[:1].upper(), Pango.Weight.BOLD])
|
||||||
|
current_char=item[:1].upper()
|
||||||
|
|
||||||
def get_item(self, path):
|
def get_item(self, path):
|
||||||
if path == Gtk.TreePath(0):
|
if path == Gtk.TreePath(0):
|
||||||
|
Loading…
Reference in New Issue
Block a user