From e7439e6e23a3bc057506002196456e35cf539ee8 Mon Sep 17 00:00:00 2001 From: Paul Franklin Date: Wed, 11 Jul 2012 15:39:24 +0000 Subject: [PATCH] show the paragraph styles sorted, in the style editor (e.g. the 65 of them in the text descendant report) svn: r19989 --- src/gui/plug/report/_styleeditor.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/gui/plug/report/_styleeditor.py b/src/gui/plug/report/_styleeditor.py index 506da3268..d23a50006 100644 --- a/src/gui/plug/report/_styleeditor.py +++ b/src/gui/plug/report/_styleeditor.py @@ -5,6 +5,7 @@ # Copyright (C) 2007-2008 Brian G. Matherly # Copyright (C) 2008 Peter Landgren # Copyright (C) 2010 Jakim Friant +# Copyright (C) 2012 Paul Franklin # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -35,6 +36,7 @@ Paragraph/Font style editor from gen.ggettext import sgettext as _ import logging log = logging.getLogger(".") +import re #------------------------------------------------------------------------ # @@ -216,8 +218,13 @@ class StyleEditor(object): self.top.get_object('bgcolor').connect('color-set', self.bg_color_set) self.top.get_object("style_name").set_text(name) - names = self.style.get_paragraph_style_names() - names.reverse() + def _alphanumeric_sort(iterable): + """ sort the given iterable in the way that humans expect """ + convert = lambda text: int(text) if text.isdigit() else text + sort_key = lambda k: [convert(c) for c in re.split('([0-9]+)', k)] + return sorted(iterable, key=sort_key) + + names = _alphanumeric_sort(self.style.get_paragraph_style_names()) for p_name in names: self.plist.add([p_name], self.style.get_paragraph_style(p_name)) self.plist.select_row(0)