1 /* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil; -*- */
2 /* vim:set et sts=4: */
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"
28 * SECTION: ibuscomponent
29 * @short_description: Component (executable) specification.
30 * @title: IBusComponent
33 * An IBusComponent is an executable program.
34 * It provides services such as user interface, configuration,
35 * and input method engine (IME).
37 * It is recommended that IME developers provide
38 * a component XML file and
39 * load the XML file by ibus_component_new_from_file().
41 * The format of a component XML file is described at
42 * <ulink url="http://code.google.com/p/ibus/wiki/DevXML">http://code.google.com/p/ibus/wiki/DevXML</ulink>
44 #ifndef __IBUS_COMPONENT_H_
45 #define __IBUS_COMPONENT_H_
47 #include "ibusserializable.h"
48 #include "ibusobservedpath.h"
49 #include "ibusenginedesc.h"
56 /* define GOBJECT macros */
57 #define IBUS_TYPE_COMPONENT \
58 (ibus_component_get_type ())
59 #define IBUS_COMPONENT(obj) \
60 (G_TYPE_CHECK_INSTANCE_CAST ((obj), IBUS_TYPE_COMPONENT, IBusComponent))
61 #define IBUS_COMPONENT_CLASS(klass) \
62 (G_TYPE_CHECK_CLASS_CAST ((klass), IBUS_TYPE_COMPONENT, IBusComponentClass))
63 #define IBUS_IS_COMPONENT(obj) \
64 (G_TYPE_CHECK_INSTANCE_TYPE ((obj), IBUS_TYPE_COMPONENT))
65 #define IBUS_IS_COMPONENT_CLASS(klass) \
66 (G_TYPE_CHECK_CLASS_TYPE ((klass), IBUS_TYPE_COMPONENT))
67 #define IBUS_COMPONENT_GET_CLASS(obj) \
68 (G_TYPE_INSTANCE_GET_CLASS ((obj), IBUS_TYPE_COMPONENT, IBusComponentClass))
72 typedef struct _IBusComponent IBusComponent;
73 typedef struct _IBusComponentClass IBusComponentClass;
74 typedef struct _IBusComponentPrivate IBusComponentPrivate;
79 * An IBusComponent stores component information.
80 * You can get extended values with g_object_get_properties.
81 * name: Name of the component.
82 * description: Detailed description of component.
83 * version: Component version.
84 * license: Distribution license of this component.
85 * author: Author(s) of the component.
86 * homepage: Homepage of the component.
87 * command_line: path to component executable.
88 * textdomain: Domain name for dgettext()
90 struct _IBusComponent {
92 IBusSerializable parent;
93 IBusComponentPrivate *priv;
94 /* instance members */
99 gpointer pdummy[7]; // We can add 7 pointers without breaking the ABI.
102 struct _IBusComponentClass {
103 IBusSerializableClass parent;
108 GType ibus_component_get_type (void);
111 * ibus_component_new:
112 * @name: Name of the component.
113 * @description: Detailed description of component.
114 * @version: Component version.
115 * @license: Distribution license of this component.
116 * @author: Author(s) of the component.
117 * @homepage: Homepage of the component.
118 * @command_line: path to component executable.
119 * @textdomain: Domain name for dgettext()
120 * @returns: A newly allocated IBusComponent.
122 * New an IBusComponent.
124 IBusComponent *ibus_component_new (const gchar *name,
125 const gchar *description,
126 const gchar *version,
127 const gchar *license,
129 const gchar *homepage,
130 const gchar *command_line,
131 const gchar *textdomain);
134 * ibus_component_new_varargs:
135 * @first_property_name: Name of the first property.
136 * @Varargs: the NULL-terminated arguments of the properties and values.
138 * New an IBusComponent.
139 * ibus_component_new_varargs() supports the va_list format.
140 * name property is required. e.g.
141 * IBusComponent *component = ibus_component_new_varargs ("name", "ibus-foo",
142 * "command_line", "/usr/libexec/ibus-engine-foo --ibus",
145 IBusComponent *ibus_component_new_varargs (const gchar *first_property_name,
149 * ibus_component_new_from_xml_node:
150 * @node: Root node of component XML tree.
151 * @returns: A newly allocated IBusComponent.
153 * New an IBusComponent from an XML tree.
155 IBusComponent *ibus_component_new_from_xml_node
159 * ibus_component_new_from_file:
160 * @filename: An XML file that contains component information.
161 * @returns: A newly allocated IBusComponent.
163 * New an IBusComponent from an XML file.
164 * Note that a component file usually contains engine descriptions,
165 * if it does, ibus_engine_desc_new_from_xml_node() will be called
166 * to load the engine descriptions.
168 IBusComponent *ibus_component_new_from_file (const gchar *filename);
171 * ibus_component_get_name:
172 * @component: An IBusComponent
173 * @returns: name property in IBusComponent
175 * Return the name property in IBusComponent. It should not be freed.
177 const gchar *ibus_component_get_name (IBusComponent *component);
180 * ibus_component_get_description:
181 * @component: An IBusComponent
182 * @returns: description property in IBusComponent
184 * Return the description property in IBusComponent. It should not be freed.
186 const gchar *ibus_component_get_description (IBusComponent *component);
189 * ibus_component_get_version:
190 * @component: An IBusComponent
191 * @returns: version property in IBusComponent
193 * Return the version property in IBusComponent. It should not be freed.
195 const gchar *ibus_component_get_version (IBusComponent *component);
198 * ibus_component_get_license:
199 * @component: An IBusComponent
200 * @returns: license property in IBusComponent
202 * Return the license property in IBusComponent. It should not be freed.
204 const gchar *ibus_component_get_license (IBusComponent *component);
207 * ibus_component_get_author:
208 * @component: An IBusComponent
209 * @returns: author property in IBusComponent
211 * Return the author property in IBusComponent. It should not be freed.
213 const gchar *ibus_component_get_author (IBusComponent *component);
216 * ibus_component_get_homepage:
217 * @component: An IBusComponent
218 * @returns: homepage property in IBusComponent
220 * Return the homepage property in IBusComponent. It should not be freed.
222 const gchar *ibus_component_get_homepage (IBusComponent *component);
225 * ibus_component_get_exec:
226 * @component: An IBusComponent
227 * @returns: exec property in IBusComponent
229 * Return the exec property in IBusComponent. It should not be freed.
231 const gchar *ibus_component_get_exec (IBusComponent *component);
234 * ibus_component_get_textdomain:
235 * @component: An IBusComponent
236 * @returns: textdomain property in IBusComponent
238 * Return the textdomain property in IBusComponent. It should not be freed.
240 const gchar *ibus_component_get_textdomain (IBusComponent *component);
243 * ibus_component_add_observed_path:
244 * @component: An IBusComponent
245 * @path: Observed path to be added.
246 * @access_fs: TRUE for filling the file status; FALSE otherwise.
248 * Add an observed path to IBusComponent.
250 void ibus_component_add_observed_path
251 (IBusComponent *component,
256 * ibus_component_add_engine:
257 * @component: An IBusComponent
258 * @engine: A description of an engine.
260 * Add an engine to IBusComponent according to the description in @engine.
262 void ibus_component_add_engine (IBusComponent *component,
263 IBusEngineDesc *engine);
266 * ibus_component_get_engines:
267 * @component: An IBusComponent.
268 * @returns: (transfer container) (element-type IBusEngineDesc): A newly allocated GList that contains engines.
270 * Get the engines of this component.
272 GList *ibus_component_get_engines (IBusComponent *component);
275 * ibus_component_output:
276 * @component: An IBusComponent.
277 * @output: GString that holds the result.
278 * @indent: level of indent.
280 * Output IBusComponent as an XML-formatted string.
281 * The output string can be then shown on the screen or written to file.
283 void ibus_component_output (IBusComponent *component,
288 * ibus_component_output_engines:
289 * @component: An IBusComponent.
290 * @output: GString that holds the result.
291 * @indent: level of indent.
293 * Output engine description as an XML-formatted string.
294 * The output string can be then shown on the screen or written to file.
296 void ibus_component_output_engines (IBusComponent *component,
301 * ibus_component_check_modification:
302 * @component: An IBusComponent.
303 * @returns: TRUE if at least one of the observed paths is modified; FALSE otherwise.
305 * Check whether the observed paths of component is modified.
307 gboolean ibus_component_check_modification
308 (IBusComponent *component);