summaryrefslogtreecommitdiff
path: root/src/utilities/key.vala
diff options
context:
space:
mode:
authorAlessandro Ghedini <al3xbio@gmail.com>2012-01-21 19:07:09 +0100
committerAlessandro Ghedini <al3xbio@gmail.com>2012-01-21 19:07:09 +0100
commit60560a030fda3c539ff9dc1563b9926414a193da (patch)
tree77590b395685a8d48d3615e45629a1610d08c071 /src/utilities/key.vala
parentd6b2677825cbb423e2099563c16321c3e23d7899 (diff)
Imported Upstream version 0.4.0upstream/0.4.0
Diffstat (limited to 'src/utilities/key.vala')
-rw-r--r--src/utilities/key.vala26
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;
}