aesthete-team team mailing list archive
-
aesthete-team team
-
Mailing list archive
-
Message #00044
Patch to sanely order Toolbox entities
Hi all,
Please find attached a patch which should order Toolbox entities in a
sane manner. For example, without this patch the trigonometry functions
are displayed in essentially a random order, but with the patch the
first displayed is sin, then cos, ...
Let me know if you find any problems with this.
Regards,
Chris.
=== modified file 'aesthete/glypher/Toolbox.py'
--- aesthete/glypher/Toolbox.py 2011-10-26 19:06:26 +0000
+++ aesthete/glypher/Toolbox.py 2011-11-16 00:31:27 +0000
@@ -4,31 +4,32 @@
from ..paths import *
from ..utils import *
from Parser import *
+from operator import itemgetter
# Tool tuple description using "field [to_ignore1 or to_ignore2]"
-# (unicode symbol, name, shortcut (or None), properties [omittable or None], entity [omittable or False])
+# (unicode symbol, name, shortcut (or None), properties [omittable or None], entity [omittable or False], priority [omittable or 0])
toolbar_dictionary = {\
'Functions' : ( \
- (u'f', 'function', 'Alt+f'), \
- (u'\u2111', 'im', None), \
- (u'\u211C', 're', None), \
- (u'Ylm', 'Ylm', None), \
- (u'\u0393', 'gamma', None), \
- (u'logn', 'logn', None), \
+ (u'f', 'function', 'Alt+f', None, False, 0), \
+ (u'\u2111', 'im', None, None, False, 0), \
+ (u'\u211C', 're', None, None, False, 0), \
+ (u'Ylm', 'Ylm', None, None, False, 0), \
+ (u'\u0393', 'gamma', None, None, False, 0), \
+ (u'logn', 'logn', None, None, False, 0), \
),
'Sets' : (
- (u'(,)', 'interval', None),
- (u'\u2205', 'empty_set', None),
- (u'\u2102', 'complexC', None), \
- (u'\u211A', 'rationalQ', None), \
- (u'\u211D', 'realR', None), \
+ (u'(,)', 'interval', None, None, False, 0),
+ (u'\u2205', 'empty_set', None, None, False, 0),
+ (u'\u2102', 'complexC', None, None, False, 0), \
+ (u'\u211A', 'rationalQ', None, None, False, 0), \
+ (u'\u211D', 'realR', None, None, False, 0), \
),
'Calculus' : ( \
- (u'\u222B', 'integral', 'Alt+i'), \
- (u'd/d', 'derivative', 'Alt+d') \
+ (u'\u222B', 'integral', 'Alt+i', None, False, 0), \
+ (u'd/d', 'derivative', 'Alt+d', None, False, 0) \
),
'Utilities' : ( \
- (u'\u2637', 'table', 'Alt+T'),
+ (u'\u2637', 'table', 'Alt+T', None, False, 0),
)
}
# Needs later version of sympy (and Interpret impl)
@@ -39,14 +40,14 @@
expanded_toolbar_dictionary = {\
'Utilities' : ( \
- (u'\u2318', 'phrasegroup', None, {'enterable':True}), \
- (u'\u2311', 'phrase', None), \
- (u'()', 'bracketed_phrase', None), \
+ (u'\u2318', 'phrasegroup', None, {'enterable':True}, False, 0), \
+ (u'\u2311', 'phrase', None, None, False, 0), \
+ (u'()', 'bracketed_phrase', None, None, False, 0), \
),
'Spacers' : ( \
- (u'\u2423', 'space', None, {'attachable':True,'blank':False,'show_decorated':True}, True), \
- (u'\u2015', 'horizontal_line', None),
- (u'|', 'vertical_line', None),
+ (u'\u2423', 'space', None, {'attachable':True,'blank':False,'show_decorated':True}, True, 0), \
+ (u'\u2015', 'horizontal_line', None, None, False, 0),
+ (u'|', 'vertical_line', None, None, False, 0),
)
}
@@ -63,9 +64,10 @@
sy = tree.find('symbol')
ca = tree.find('category')
sh = tree.find('shortcut')
+ pr = tree.find('priority')
if sy is not None and ca is not None :
add_toolbar_dictionary( { ca.text : ( \
- (sy.text, name, sh.text if sh is not None else None), ) }, tdict )
+ (sy.text, name, sh.text if sh is not None else None, None, False, int(pr.text) if pr is not None else 0), ) }, tdict )
if expanded :
add_toolbar_dictionary(expanded_toolbar_dictionary, tdict)
@@ -86,7 +88,7 @@
k = 0
for key in sorted(tdict.keys()) :
- items = tdict[key]
+ items = sorted(tdict[key], key=itemgetter(5), reverse=True)
menu_toob = gtk.MenuToolButton(gtk.Label(items[0][0] + ' ...'), key)
menu_toob.set_size_request(80, -1)
menu_toob.connect('clicked', self.do_m_clicked)
@@ -98,7 +100,7 @@
it_meni = gtk.MenuItem(it[0])
if n == 0 : menu_toob.active_item = it_meni
it_meni.item_index = n
- it_meni.set_tooltip_text(it[1] + ' ' + '[No shortcut]' if it[2] is None else it[2])
+ it_meni.set_tooltip_text(it[1] + ' ' + '[No shortcut]' if it[2] is None else it[2] + ' ' + str(it[5]))
menu_menu.attach(it_meni, n, n+1, 0, 1)
it_meni.glypher_name = (it[1], it[3] if len(it) > 3 else None, len(it) > 4 and it[4])
it_meni.connect('activate', self.do_mi_clicked, menu_toob)
Follow ups