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-2010 Peng Huang <shawn.p.huang@gmail.com>
5 * Copyright (C) 2008-2010 Red Hat, Inc.
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 of the License, or (at your option) any later version.
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.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the
19 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 * Boston, MA 02111-1307, USA.
23 #if !defined (__IBUS_H_INSIDE__) && !defined (IBUS_COMPILATION)
24 #error "Only <ibus.h> can be included directly"
29 * @short_description: Hotkeys and associated events.
32 * An IBusHotkeyProfile associates a hotkey and an event.
34 #ifndef __IBUS_HOTKEY_H_
35 #define __IBUS_HOTKEY_H_
37 #include "ibusserializable.h"
42 /* define IBusHotkeyProfile macros */
43 #define IBUS_TYPE_HOTKEY_PROFILE \
44 (ibus_hotkey_profile_get_type ())
45 #define IBUS_HOTKEY_PROFILE(obj) \
46 (G_TYPE_CHECK_INSTANCE_CAST ((obj), IBUS_TYPE_HOTKEY_PROFILE, IBusHotkeyProfile))
47 #define IBUS_HOTKEY_PROFILE_CLASS(klass) \
48 (G_TYPE_CHECK_CLASS_CAST ((klass), IBUS_TYPE_HOTKEY_PROFILE, IBusHotkeyProfileClass))
49 #define IBUS_IS_HOTKEY_PROFILE(obj) \
50 (G_TYPE_CHECK_INSTANCE_TYPE ((obj), IBUS_TYPE_HOTKEY_PROFILE))
51 #define IBUS_IS_HOTKEY_PROFILE_CLASS(klass) \
52 (G_TYPE_CHECK_CLASS_TYPE ((klass), IBUS_TYPE_HOTKEY_PROFILE))
53 #define IBUS_HOTKEY_PROFILE_GET_CLASS(obj) \
54 (G_TYPE_INSTANCE_GET_CLASS ((obj), IBUS_TYPE_HOTKEY_PROFILE, IBusHotkeyProfileClass))
58 typedef struct _IBusHotkeyProfile IBusHotkeyProfile;
59 typedef struct _IBusHotkeyProfileClass IBusHotkeyProfileClass;
64 * An opaque data type representing an IBusHotkeyProfile.
66 struct _IBusHotkeyProfile {
67 IBusSerializable parent;
72 struct _IBusHotkeyProfileClass {
73 IBusSerializableClass parent;
75 void (* trigger) (IBusHotkeyProfile *profile,
80 /* hotkey profile functions */
81 GType ibus_hotkey_profile_get_type (void);
83 * ibus_hotkey_profile_new:
84 * @returns: A newly allocated IBusHotkeyProfile.
86 * New an IBusHotkeyProfile.
89 *ibus_hotkey_profile_new (void);
92 * ibus_hotkey_profile_add_hotkey :
93 * @profile: An IBusHotkeyProfile.
94 * @keyval: Keycode of the hotkey.
95 * @modifiers: Modifiers of the hotkey.
96 * @event: The event to be associated.
97 * @returns: Always TRUE.
99 * Add a hotkey and its associated event to an IBusHotkeyProfile.
101 gboolean ibus_hotkey_profile_add_hotkey (IBusHotkeyProfile *profile,
107 * ibus_hotkey_profile_add_hotkey_from_string:
108 * @profile: An IBusHotkeyProfile.
109 * @str: Key in string representation. '+' is the separator.
110 * @event: The event to be associated.
111 * @returns: FALSE if @str contains invalid symbol; TRUE otherwise.
113 * Add a hotkey and its associated event to an IBusHotkeyProfile.
114 * The hotkey is in string format, such like <constant>Control+Shift+A</constant>.
116 gboolean ibus_hotkey_profile_add_hotkey_from_string
117 (IBusHotkeyProfile *profile,
122 * ibus_hotkey_profile_remove_hotkey:
123 * @profile: An IBusHotkeyProfile.
124 * @keyval: Keycode of the hotkey.
125 * @modifiers: Modifiers of the hotkey.
126 * @returns: FALSE if the key is not in @profile, TRUE otherwise.
128 * Remove the hotkey for an IBusHotkeyProfile.
130 gboolean ibus_hotkey_profile_remove_hotkey
131 (IBusHotkeyProfile *profile,
136 * ibus_hotkey_profile_remove_hotkey_by_event:
137 * @profile: An IBusHotkeyProfile.
138 * @event: The associated event.
139 * @returns: FALSE if no such event in @profile, TRUE otherwise.
141 * Remove the hotkey for an IBusHotkeyProfile by event.
143 gboolean ibus_hotkey_profile_remove_hotkey_by_event
144 (IBusHotkeyProfile *profile,
148 * ibus_hotkey_profile_filter_key_event:
149 * @profile: An IBusHotkeyProfile.
150 * @keyval: Keycode of the hotkey.
151 * @modifiers: Modifiers of the hotkey.
152 * @prev_keyval: Keycode of the hotkey.
153 * @prev_modifiers: Modifiers of the hotkey.
154 * @user_data: user data for signal "trigger".
155 * @returns: 0 if releasing a hotkey and the hotkey is not in the profile ; an associated event otherwise.
157 * Emit a <constant>::trigger</constant> signal when a hotkey is in a profile.
159 * See also: ::trigger
161 GQuark ibus_hotkey_profile_filter_key_event
162 (IBusHotkeyProfile *profile,
166 guint prev_modifiers,
170 * ibus_hotkey_profile_lookup_hotkey:
171 * @profile: An IBusHotkeyProfile.
172 * @keyval: Keycode of the hotkey.
173 * @modifiers: Modifiers of the hotkey.
174 * @returns: The event associated to the hotkey or 0 if the hotkey is not in the
177 GQuark ibus_hotkey_profile_lookup_hotkey
178 (IBusHotkeyProfile *profile,