Skip to content

Commit

Permalink
Read toggle shortcut from IBus.Config.
Browse files Browse the repository at this point in the history
  • Loading branch information
ueno committed Feb 9, 2012
1 parent 2c5cea2 commit 56b882d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
21 changes: 19 additions & 2 deletions src/client.vala
Expand Up @@ -158,8 +158,8 @@ class Client : Fep.GClient {
}

public override bool filter_key_event (uint keyval, uint modifiers) {
if (keyval == IBus.backslash &&
(modifiers & IBus.ModifierType.CONTROL_MASK) != 0) {
if (keyval == toggle_keyval &&
(modifiers & toggle_modifiers) != 0) {
if (enabled)
context.disable ();
else
Expand All @@ -173,10 +173,27 @@ class Client : Fep.GClient {
return true;
}

IBus.Config config;

uint toggle_keyval = IBus.backslash;
uint toggle_modifiers = IBus.ModifierType.CONTROL_MASK;

public Client (IBus.Bus bus) throws Error {
Object (address: null);
init (null);

config = bus.get_config ();
var values = config.get_values ("fep");
if (values != null) {
var value = values.lookup_value ("toggle_shortcut",
VariantType.STRING);
if (value != null) {
IBus.key_event_from_string (value.get_string (),
out toggle_keyval,
out toggle_modifiers);
}
}

context = bus.create_input_context ("ibus-fep");
context.commit_text.connect (_ibus_commit_text);
context.show_preedit_text.connect (_ibus_show_preedit_text);
Expand Down
2 changes: 1 addition & 1 deletion src/ibus-1.0.vapi
Expand Up @@ -4709,7 +4709,7 @@ namespace IBus {
[CCode (cheader_filename = "ibus.h")]
public static void init ();
[CCode (cheader_filename = "ibus.h")]
public static bool key_event_from_string (string str, uint keyval, uint modifiers);
public static bool key_event_from_string (string str, out uint keyval, out uint modifiers);
[CCode (cheader_filename = "ibus.h")]
public static unowned string key_event_to_string (uint keyval, uint modifiers);
[CCode (cheader_filename = "ibus.h")]
Expand Down

0 comments on commit 56b882d

Please sign in to comment.