The Birdfont Source Code


All Repositories / birdfont.git / commit – RSS feed

Move key binding string to tool item

These changes was commited to the Birdfont repository Thu, 25 Jun 2015 07:19:55 +0000.

Contributing

Send patches or pull requests to johan.mattsson.m@gmail.com.
Clone this repository: git clone https://github.com/johanmattssonm/birdfont.git
author Johan Mattsson <johan.mattsson.m@gmail.com>
Thu, 25 Jun 2015 07:19:55 +0000 (09:19 +0200)
committer Johan Mattsson <johan.mattsson.m@gmail.com>
Thu, 25 Jun 2015 07:19:55 +0000 (09:19 +0200)
commit 5c473cfcc0b19d6eaf755e0026e314f0f1fae76a
tree de2a668202dd3cc79646327fcc76fcbfcdff1f2c
parent b5e7c8abb6385b4938dce9dc05d1b30321655d84
Move key binding string to tool item

libbirdfont/Tool.vala
libbirdfont/ToolItem.vala
--- a/libbirdfont/Tool.vala +++ b/libbirdfont/Tool.vala @@ -217,43 +217,16 @@ } public string get_key_binding () { - StringBuilder sb = new StringBuilder (); ToolItem? ti = MainWindow.get_menu ().get_item_for_tool (this); ToolItem t; if (ti == null) { + warning ("No key binding for tool."); return ""; } t = (!) ti; - - if (t.key == '\0') { - return ""; - } - - if ((t.modifiers & CTRL) > 0) { - sb.append ("Ctrl"); - sb.append ("+"); - } - - if ((t.modifiers & SHIFT) > 0) { - sb.append (t_("Shift")); - sb.append ("+"); - } - - if ((t.modifiers & ALT) > 0) { - sb.append ("Alt"); - sb.append ("+"); - } - - if ((t.modifiers & LOGO) > 0) { - sb.append ("Super"); - sb.append ("+"); - } - - sb.append_unichar (t.key); - - return sb.str; + return t.get_key_binding (); } public void set_icon (string name) {
--- a/libbirdfont/ToolItem.vala +++ b/libbirdfont/ToolItem.vala @@ -26,8 +26,40 @@ action.connect (() => { tool.select_action (tool); }); + } + + public string get_key_binding () { + StringBuilder sb = new StringBuilder (); + + if (key == '\0') { + return "".dup (); + } + + if ((modifiers & CTRL) > 0) { + sb.append ("Ctrl"); + sb.append ("+"); + } + + if ((modifiers & SHIFT) > 0) { + sb.append (t_("Shift")); + sb.append ("+"); + } + + if ((modifiers & ALT) > 0) { + sb.append ("Alt"); + sb.append ("+"); + } + + if ((modifiers & LOGO) > 0) { + sb.append ("Super"); + sb.append ("+"); + } + + sb.append_unichar (key); + + return sb.str; } } }