1 /* vim:set et sts=4: */
2 /* ibus - The Input Bus
3 * Copyright (C) 2008-2009 Peng Huang <shawn.p.huang@gmail.com>
4 * Copyright (C) 2008-2009 Red Hat, Inc.
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
23 * @short_description: Shared utility functions and definition.
26 * This file defines some utility functions and definition
27 * which are shared among ibus component and services.
30 #ifndef __IBUS_SHARE_H_
31 #define __IBUS_SHARE_H_
38 * Address of IBus service.
40 #define IBUS_SERVICE_IBUS "org.freedesktop.IBus"
45 * Address of IBus panel service.
47 #define IBUS_SERVICE_PANEL "org.freedesktop.IBus.Panel"
50 * IBUS_SERVICE_CONFIG:
52 * Address of IBus config service.
54 #define IBUS_SERVICE_CONFIG "org.freedesktop.IBus.Config"
57 * IBUS_SERVICE_NOTIFICATIONS:
59 * Address of IBus notification service.
61 #define IBUS_SERVICE_NOTIFICATIONS "org.freedesktop.IBus.Notifications"
68 #define IBUS_PATH_IBUS "/org/freedesktop/IBus"
73 * D-Bus path for IBus factory.
75 #define IBUS_PATH_FACTORY "/org/freedesktop/IBus/Factory"
80 * D-Bus path for IBus panel.
82 #define IBUS_PATH_PANEL "/org/freedesktop/IBus/Panel"
87 * D-Bus path for IBus config.
89 #define IBUS_PATH_CONFIG "/org/freedesktop/IBus/Config"
92 * IBUS_PATH_NOTIFICATIONS:
94 * D-Bus path for IBus notifications.
96 #define IBUS_PATH_NOTIFICATIONS "/org/freedesktop/IBus/Notifications"
99 * IBUS_PATH_INPUT_CONTEXT:
101 * Template of D-Bus path for IBus input context.
103 #define IBUS_PATH_INPUT_CONTEXT "/org/freedesktop/IBus/InputContext_%d"
106 * IBUS_INTERFACE_IBUS:
108 * D-Bus interface for IBus.
110 #define IBUS_INTERFACE_IBUS "org.freedesktop.IBus"
113 * IBUS_INTERFACE_INPUT_CONTEXT:
115 * D-Bus interface for IBus input context.
117 #define IBUS_INTERFACE_INPUT_CONTEXT \
118 "org.freedesktop.IBus.InputContext"
121 * IBUS_INTERFACE_FACTORY:
123 * D-Bus interface for IBus factory.
125 #define IBUS_INTERFACE_FACTORY "org.freedesktop.IBus.Factory"
128 * IBUS_INTERFACE_ENGINE:
130 * D-Bus interface for IBus engine.
132 #define IBUS_INTERFACE_ENGINE "org.freedesktop.IBus.Engine"
135 * IBUS_INTERFACE_PANEL:
137 * D-Bus interface for IBus panel.
139 #define IBUS_INTERFACE_PANEL "org.freedesktop.IBus.Panel"
142 * IBUS_INTERFACE_CONFIG:
144 * D-Bus interface for IBus config.
146 #define IBUS_INTERFACE_CONFIG "org.freedesktop.IBus.Config"
149 * IBUS_INTERFACE_NOTIFICATIONS:
151 * D-Bus interface for IBus notifications.
153 #define IBUS_INTERFACE_NOTIFICATIONS "org.freedesktop.IBus.Notifications"
158 * ibus_get_local_machine_id:
159 * @returns: A newly allocated string that shows the UUID of the machine.
161 * Obtains the machine UUID of the machine this process is running on.
163 const gchar *ibus_get_local_machine_id
168 * @display: Display address, as in DISPLAY environment for X.
170 * Set the display address.
172 void ibus_set_display (const gchar *display);
176 * @returns: D-Bus address of IBus. %NULL for not found.
178 * Return the D-Bus address of IBus.
179 * It will find the address from following source:
181 * <listitem><para>Environment variable IBUS_ADDRESS</para></listitem>
182 * <listitem><para>Socket file under ~/.config/ibus/bus/</para></listitem>
185 * @see_also: ibus_write_address().
187 const gchar *ibus_get_address (void);
190 * ibus_write_address:
191 * @address: D-Bus address of IBus.
193 * Write D-Bus address to socket file.
195 * @see_also: ibus_get_address().
197 void ibus_write_address (const gchar *address);
200 * ibus_get_user_name:
201 * @returns: A newly allocated string that stores current user name.
203 * Get the current user name.
204 * It is determined by:
206 * <listitem><para>getlogin()</para></listitem>
207 * <listitem><para>Environment variable SUDO_USER</para></listitem>
208 * <listitem><para>Environment variable USERHELPER_UID</para></listitem>
209 * <listitem><para>Environment variable USERNAME</para></listitem>
210 * <listitem><para>Environment variable LOGNAME</para></listitem>
211 * <listitem><para>Environment variable USER</para></listitem>
212 * <listitem><para>Environment variable LNAME</para></listitem>
215 const gchar *ibus_get_user_name (void);
218 * ibus_get_daemon_uid:
219 * @returns: UID of ibus-daemon; or 0 if UID is not available.
221 * Get UID of ibus-daemon.
223 glong ibus_get_daemon_uid (void);
226 * ibus_get_socket_path:
227 * @returns: A newly allocated string that stores the path of socket file.
229 * Get the path of socket file.
231 const gchar *ibus_get_socket_path (void);
235 * @keyval: Key symbol.
236 * @returns: Corresponding key name. %NULL if no such key symbol.
238 * Return the name of a key symbol.
240 * Note that the returned string is used internally, so don't free it.
242 const gchar *ibus_keyval_name (guint keyval);
245 * ibus_keyval_from_name:
246 * @keyval_name: Key name in #gdk_keys_by_name.
247 * @returns: Corresponding key symbol.
249 * Return the key symbol that associate with the key name.
251 guint ibus_keyval_from_name (const gchar *keyval_name);
255 * @strv: List of strings.
257 * Free a list of strings.
259 void ibus_free_strv (gchar **strv);
262 * ibus_key_event_to_string:
263 * @keyval: Key symbol.
264 * @modifiers: Modifiers such as Ctrl or Shift.
265 * @returns: The name of a key symbol and modifier.
267 * Return the name of a key symbol and modifiers.
269 * For example, if press ctrl, shift, and enter, then this function returns:
270 * Shift+Control+enter.
272 const gchar *ibus_key_event_to_string
277 * ibus_key_event_from_string:
278 * @string: Key event string.
279 * @keyval: Variable that hold key symbol result.
280 * @modifiers: Variable that hold modifiers result.
281 * @returns: TRUE for succeed; FALSE if failed.
283 * Parse key event string and return key symbol and modifiers.
285 gboolean ibus_key_event_from_string
286 (const gchar *string,
293 * Init the ibus types.
295 * It is actually a wrapper of g_type_init().
297 void ibus_init (void);
302 * Runs an IBus main loop until ibus_quit() is called in the loop.
304 * @see_also: ibus_quit().
306 void ibus_main (void);
311 * Stops an IBus from running.
313 * Any calls to ibus_quit() for the loop will return.
314 * @see_also: ibus_main().
316 void ibus_quit (void);