diff options
Diffstat (limited to 'src/utilities/key.vala')
-rw-r--r-- | src/utilities/key.vala | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/src/utilities/key.vala b/src/utilities/key.vala index 6700b16..5f27a1e 100644 --- a/src/utilities/key.vala +++ b/src/utilities/key.vala @@ -55,10 +55,21 @@ public class Key : GLib.Object { private Gdk.ModifierType modifiers; ///////////////////////////////////////////////////////////////////// + /// C'tor, initializes all members to defaults. + ///////////////////////////////////////////////////////////////////// + + public Key() { + this.accelerator = ""; + this.modifiers = 0; + this.key_code = 0; + this.label = _("Not bound"); + } + + ///////////////////////////////////////////////////////////////////// /// C'tor, initializes all members. ///////////////////////////////////////////////////////////////////// - public Key(string stroke) { + public Key.from_string(string stroke) { this.accelerator = stroke; uint keysym; @@ -68,6 +79,17 @@ public class Key : GLib.Object { } ///////////////////////////////////////////////////////////////////// + /// C'tor, initializes all members. + ///////////////////////////////////////////////////////////////////// + + public Key.from_values(uint keysym, Gdk.ModifierType modifiers) { + this.accelerator = Gtk.accelerator_name(keysym, modifiers); + this.label = Gtk.accelerator_get_label(keysym, modifiers); + this.key_code = display.keysym_to_keycode(keysym); + this.modifiers = modifiers; + } + + ///////////////////////////////////////////////////////////////////// /// Initializes static members. ///////////////////////////////////////////////////////////////////// @@ -113,7 +135,7 @@ public class Key : GLib.Object { private Gdk.ModifierType get_modifiers() { Gdk.ModifierType modifiers; - Gdk.Display.get_default().get_pointer(null, null, null, out modifiers); + Gtk.get_current_event_state(out modifiers); return modifiers; } |