| 1 | /* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil; -*- */ |
| 2 | /* vim:set et sts=4: */ |
| 3 | /* IBus - The Input Bus |
| 4 | * Copyright (C) 2008-2013 Peng Huang <shawn.p.huang@gmail.com> |
| 5 | * Copyright (C) 2008-2013 Red Hat, Inc. |
| 6 | * |
| 7 | * This library is free software; you can redistribute it and/or |
| 8 | * modify it under the terms of the GNU Lesser General Public |
| 9 | * License as published by the Free Software Foundation; either |
| 10 | * version 2.1 of the License, or (at your option) any later version. |
| 11 | * |
| 12 | * This library is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 | * Lesser General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU Lesser General Public |
| 18 | * License along with this library; if not, write to the Free Software |
| 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 |
| 20 | * USA |
| 21 | */ |
| 22 | |
| 23 | #if !defined (__IBUS_H_INSIDE__) && !defined (IBUS_COMPILATION) |
| 24 | #error "Only <ibus.h> can be included directly" |
| 25 | #endif |
| 26 | |
| 27 | #ifndef __IBUS_HOTKEY_H_ |
| 28 | #define __IBUS_HOTKEY_H_ |
| 29 | |
| 30 | /** |
| 31 | * SECTION: ibushotkey |
| 32 | * @short_description: Hotkeys and associated events. |
| 33 | * @stability: Stable |
| 34 | * |
| 35 | * An IBusHotkeyProfile associates a hotkey and an event. |
| 36 | */ |
| 37 | |
| 38 | #include "ibusserializable.h" |
| 39 | |
| 40 | /* |
| 41 | * Type macros. |
| 42 | */ |
| 43 | /* define IBusHotkeyProfile macros */ |
| 44 | #define IBUS_TYPE_HOTKEY_PROFILE \ |
| 45 | (ibus_hotkey_profile_get_type ()) |
| 46 | #define IBUS_HOTKEY_PROFILE(obj) \ |
| 47 | (G_TYPE_CHECK_INSTANCE_CAST ((obj), IBUS_TYPE_HOTKEY_PROFILE, IBusHotkeyProfile)) |
| 48 | #define IBUS_HOTKEY_PROFILE_CLASS(klass) \ |
| 49 | (G_TYPE_CHECK_CLASS_CAST ((klass), IBUS_TYPE_HOTKEY_PROFILE, IBusHotkeyProfileClass)) |
| 50 | #define IBUS_IS_HOTKEY_PROFILE(obj) \ |
| 51 | (G_TYPE_CHECK_INSTANCE_TYPE ((obj), IBUS_TYPE_HOTKEY_PROFILE)) |
| 52 | #define IBUS_IS_HOTKEY_PROFILE_CLASS(klass) \ |
| 53 | (G_TYPE_CHECK_CLASS_TYPE ((klass), IBUS_TYPE_HOTKEY_PROFILE)) |
| 54 | #define IBUS_HOTKEY_PROFILE_GET_CLASS(obj) \ |
| 55 | (G_TYPE_INSTANCE_GET_CLASS ((obj), IBUS_TYPE_HOTKEY_PROFILE, IBusHotkeyProfileClass)) |
| 56 | |
| 57 | G_BEGIN_DECLS |
| 58 | |
| 59 | typedef struct _IBusHotkeyProfile IBusHotkeyProfile; |
| 60 | typedef struct _IBusHotkeyProfileClass IBusHotkeyProfileClass; |
| 61 | |
| 62 | /** |
| 63 | * IBusHotkeyProfile: |
| 64 | * |
| 65 | * An opaque data type representing an IBusHotkeyProfile. |
| 66 | */ |
| 67 | struct _IBusHotkeyProfile { |
| 68 | IBusSerializable parent; |
| 69 | |
| 70 | /* members */ |
| 71 | }; |
| 72 | |
| 73 | struct _IBusHotkeyProfileClass { |
| 74 | IBusSerializableClass parent; |
| 75 | |
| 76 | void (* trigger) (IBusHotkeyProfile *profile, |
| 77 | GQuark event, |
| 78 | gpointer user_data); |
| 79 | }; |
| 80 | |
| 81 | /* hotkey profile functions */ |
| 82 | GType ibus_hotkey_profile_get_type (void); |
| 83 | /** |
| 84 | * ibus_hotkey_profile_new: |
| 85 | * |
| 86 | * Creates a new #IBusHotkeyProfile. |
| 87 | * |
| 88 | * Returns: A newly allocated #IBusHotkeyProfile. |
| 89 | */ |
| 90 | IBusHotkeyProfile |
| 91 | *ibus_hotkey_profile_new (void); |
| 92 | |
| 93 | /** |
| 94 | * ibus_hotkey_profile_add_hotkey : |
| 95 | * @profile: An IBusHotkeyProfile. |
| 96 | * @keyval: Keycode of the hotkey. |
| 97 | * @modifiers: Modifiers of the hotkey. |
| 98 | * @event: The event to be associated. |
| 99 | * |
| 100 | * Adds a hotkey and its associated event to an #IBusHotkeyProfile. |
| 101 | * |
| 102 | * Returns: Always %TRUE. |
| 103 | */ |
| 104 | gboolean ibus_hotkey_profile_add_hotkey (IBusHotkeyProfile *profile, |
| 105 | guint keyval, |
| 106 | guint modifiers, |
| 107 | GQuark event); |
| 108 | |
| 109 | /** |
| 110 | * ibus_hotkey_profile_add_hotkey_from_string: |
| 111 | * @profile: An IBusHotkeyProfile. |
| 112 | * @str: Key in string representation. '+' is the separator. |
| 113 | * @event: The event to be associated. |
| 114 | * |
| 115 | * Adds a hotkey and its associated event to an #IBusHotkeyProfile. |
| 116 | * The hotkey is in string format, such like |
| 117 | * <constant>Control+Shift+A</constant>. |
| 118 | * |
| 119 | * Returns: FALSE if @str contains invalid symbol; TRUE otherwise. |
| 120 | */ |
| 121 | gboolean ibus_hotkey_profile_add_hotkey_from_string |
| 122 | (IBusHotkeyProfile *profile, |
| 123 | const gchar *str, |
| 124 | GQuark event); |
| 125 | |
| 126 | /** |
| 127 | * ibus_hotkey_profile_remove_hotkey: |
| 128 | * @profile: An IBusHotkeyProfile. |
| 129 | * @keyval: Keycode of the hotkey. |
| 130 | * @modifiers: Modifiers of the hotkey. |
| 131 | * |
| 132 | * Removes the hotkey for an #IBusHotkeyProfile. |
| 133 | * |
| 134 | * Returns: %FALSE if the key is not in @profile, %TRUE otherwise. |
| 135 | */ |
| 136 | gboolean ibus_hotkey_profile_remove_hotkey |
| 137 | (IBusHotkeyProfile *profile, |
| 138 | guint keyval, |
| 139 | guint modifiers); |
| 140 | |
| 141 | /** |
| 142 | * ibus_hotkey_profile_remove_hotkey_by_event: |
| 143 | * @profile: An IBusHotkeyProfile. |
| 144 | * @event: The associated event. |
| 145 | * |
| 146 | * Removes the hotkey for an #IBusHotkeyProfile by event. |
| 147 | * |
| 148 | * Returns: %FALSE if no such event in @profile, %TRUE otherwise. |
| 149 | */ |
| 150 | gboolean ibus_hotkey_profile_remove_hotkey_by_event |
| 151 | (IBusHotkeyProfile *profile, |
| 152 | GQuark event); |
| 153 | |
| 154 | /** |
| 155 | * ibus_hotkey_profile_filter_key_event: |
| 156 | * @profile: An IBusHotkeyProfile. |
| 157 | * @keyval: Keycode of the hotkey. |
| 158 | * @modifiers: Modifiers of the hotkey. |
| 159 | * @prev_keyval: Keycode of the hotkey. |
| 160 | * @prev_modifiers: Modifiers of the hotkey. |
| 161 | * @user_data: user data for signal "trigger". |
| 162 | * |
| 163 | * Emits a <constant>::trigger</constant> signal when a hotkey is in a profile. |
| 164 | * |
| 165 | * Returns: 0 if releasing a hotkey and the hotkey is not in the profile; |
| 166 | * an associated event otherwise. |
| 167 | * |
| 168 | * See also: ::trigger |
| 169 | */ |
| 170 | GQuark ibus_hotkey_profile_filter_key_event |
| 171 | (IBusHotkeyProfile *profile, |
| 172 | guint keyval, |
| 173 | guint modifiers, |
| 174 | guint prev_keyval, |
| 175 | guint prev_modifiers, |
| 176 | gpointer user_data); |
| 177 | |
| 178 | /** |
| 179 | * ibus_hotkey_profile_lookup_hotkey: |
| 180 | * @profile: An IBusHotkeyProfile. |
| 181 | * @keyval: Keycode of the hotkey. |
| 182 | * @modifiers: Modifiers of the hotkey. |
| 183 | * |
| 184 | * Returns: The event associated to the hotkey or 0 if the hotkey is not in the |
| 185 | * profile. |
| 186 | */ |
| 187 | GQuark ibus_hotkey_profile_lookup_hotkey |
| 188 | (IBusHotkeyProfile *profile, |
| 189 | guint keyval, |
| 190 | guint modifiers); |
| 191 | |
| 192 | G_END_DECLS |
| 193 | #endif |
| 194 | |