The Birdfont Source Code


All Repositories / birdfont.git / blob – RSS feed

ToolItem.vala in /libbirdfont

This file is a part of the Birdfont project.

Contributing

Send patches or pull requests to johan.mattsson.m@gmail.com.
Clone this repository: git clone https://github.com/johanmattssonm/birdfont.git
Circle boundaries heads/master
1 /* 2 Copyright (C) 2014 Johan Mattsson 3 4 This library is free software; you can redistribute it and/or modify 5 it under the terms of the GNU Lesser General Public License as 6 published by the Free Software Foundation; either version 3 of the 7 License, or (at your option) any later version. 8 9 This library is distributed in the hope that it will be useful, but 10 WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 Lesser General Public License for more details. 13 */ 14 15 namespace BirdFont { 16 17 public class ToolItem : MenuItem { 18 19 public Tool tool; 20 21 public override uint modifiers { 22 get { 23 return base.modifiers; 24 } 25 26 set { 27 base.modifiers = value; 28 } 29 } 30 31 public override unichar key { 32 get { 33 return base.key; 34 } 35 36 set { 37 base.key = value; 38 } 39 } 40 41 public ToolItem (Tool tool) { 42 base (tool.tip, tool.name); 43 44 this.tool = tool; 45 46 action.connect (() => { 47 tool.select_action (tool); 48 }); 49 } 50 51 public string get_key_binding () { 52 StringBuilder sb = new StringBuilder (); 53 54 if (key == '\0') { 55 return "".dup (); 56 } 57 58 if ((modifiers & CTRL) > 0) { 59 sb.append ("Ctrl"); 60 sb.append ("+"); 61 } 62 63 if ((modifiers & SHIFT) > 0) { 64 sb.append (t_("Shift")); 65 sb.append ("+"); 66 } 67 68 if ((modifiers & ALT) > 0) { 69 sb.append ("Alt"); 70 sb.append ("+"); 71 } 72 73 if ((modifiers & LOGO) > 0) { 74 sb.append ("Super"); 75 sb.append ("+"); 76 } 77 78 sb.append_unichar (key); 79 80 return sb.str; 81 } 82 } 83 84 } 85