The Birdfont Source Code


All Repositories / birdfont.git / commitdiff – 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
[Thu, 25 Jun 2015 07:19:55 +0000]

Updated Files

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; } } }