1 /* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil; -*- */
2 /* vim:set et sts=4: */
4 * Copyright (C) 2013 Peng Huang <shawn.p.huang@gmail.com>
5 * Copyright (C) 2013 Takao Fujiwara <takao.fujiwara1@gmail.com>
6 * Copyright (C) 2013 Red Hat, Inc.
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the
20 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 * Boston, MA 02111-1307, USA.
24 #if !defined (__IBUS_H_INSIDE__) && !defined (IBUS_COMPILATION)
25 #error "Only <ibus.h> can be included directly"
28 #ifndef __IBUS_REGISTRY_H_
29 #define __IBUS_REGISTRY_H_
32 * SECTION: ibusregistry
33 * @short_description: Registry cache handling.
34 * @title: IBusRegistry
37 * An #IBusRegistry loads IBus component files and generates the cache files.
39 * see_also: #IBusComponent
42 #include "ibuscomponent.h"
48 /* define GOBJECT macros */
49 #define IBUS_TYPE_REGISTRY \
50 (ibus_registry_get_type ())
51 #define IBUS_REGISTRY(obj) \
52 (G_TYPE_CHECK_INSTANCE_CAST ((obj), IBUS_TYPE_REGISTRY, IBusRegistry))
53 #define IBUS_REGISTRY_CLASS(klass) \
54 (G_TYPE_CHECK_CLASS_CAST ((klass), IBUS_TYPE_REGISTRY, IBusRegistryClass))
55 #define IBUS_IS_REGISTRY(obj) \
56 (G_TYPE_CHECK_INSTANCE_TYPE ((obj), IBUS_TYPE_REGISTRY))
57 #define IBUS_IS_REGISTRY_CLASS(klass) \
58 (G_TYPE_CHECK_CLASS_TYPE ((klass), IBUS_TYPE_REGISTRY))
59 #define IBUS_REGISTRY_GET_CLASS(obj) \
60 (G_TYPE_INSTANCE_GET_CLASS ((obj), IBUS_TYPE_REGISTRY, IBusRegistryClass))
64 typedef struct _IBusRegistry IBusRegistry;
65 typedef struct _IBusRegistryPrivate IBusRegistryPrivate;
66 typedef struct _IBusRegistryClass IBusRegistryClass;
71 * Registry cache handling.
72 * You can load the registry from compose files or a cache file.
74 struct _IBusRegistry {
75 /* instance members */
78 IBusRegistryPrivate *priv;
81 struct _IBusRegistryClass {
84 IBusObjectClass parent;
87 GType ibus_registry_get_type (void);
91 * @returns: A newly allocated #IBusRegistry.
95 IBusRegistry *ibus_registry_new (void);
99 * @registry: An #IBusRegistry.
101 * Read all XML files in a IBus component directory (typically
102 * /usr/share/ibus/component/ *.xml) and update the registry object.
103 * IBUS_COMPONENT_PATH environment valuable is also available for
104 * the custom component directories, whose delimiter is ':'.
106 void ibus_registry_load (IBusRegistry *registry);
109 * ibus_registry_load_in_dir:
110 * @registry: An #IBusRegistry.
111 * @dirname: IBus component directory which includes XML files.
113 * Read all XML files in @dirname, create a #IBusComponent object for each file,
114 * and add the component objects to the registry.
115 * If @dirname is "/usr/share/ibus/component", this API and
116 * ibus_registry_load() are same.
118 void ibus_registry_load_in_dir (IBusRegistry *registry,
119 const gchar *dirname);
122 * ibus_registry_load_cache:
123 * @registry: An #IBusRegistry.
124 * @is_user: %TRUE if the registry cache is loaded in the user directory.
125 * @returns: %TRUE if the cache exists and is loaded successfully,
128 * Load the user or system registry cache.
130 gboolean ibus_registry_load_cache (IBusRegistry *registry,
134 * ibus_registry_load_cache_file:
135 * @registry: An #IBusRegistry.
136 * @filename: The file path of the registry cache
137 * @returns: %TRUE if the cache exists and is loaded successfully,
140 * Load the registry cache @filename.
142 gboolean ibus_registry_load_cache_file (IBusRegistry *registry,
143 const gchar *filename);
146 * ibus_registry_save_cache:
147 * @registry: An #IBusRegistry.
148 * @is_user: %TRUE if the registry cache is saved in the user directory.
149 * @returns: %TRUE if the cache is saved successfully, %FALSE otherwise.
151 * Save the registry in a user directory or system directory.
153 gboolean ibus_registry_save_cache (IBusRegistry *registry,
157 * ibus_registry_save_cache_file:
158 * @registry: An #IBusRegistry.
159 * @filename: The file path of the registry cache
160 * @returns: %TRUE if the cache is saved successfully, %FALSE otherwise.
162 * Save the registry cache @filename.
164 gboolean ibus_registry_save_cache_file (IBusRegistry *registry,
165 const gchar *filename);
168 * ibus_registry_output:
169 * @registry: An #IBusRegistry.
170 * @output: GString that holds the result.
171 * @indent: level of indent.
173 * Output #IBusRegistry as an XML-formatted string.
174 * The output string can be then shown on the screen or written to file.
176 void ibus_registry_output (IBusRegistry *registry,
181 * ibus_registry_check_modification:
182 * @registry: An #IBusRegistry.
183 * @returns: %TRUE if mtime is changed; %FALSE otherwise.
185 * Check if the registry is updated.
187 gboolean ibus_registry_check_modification
188 (IBusRegistry *registry);
191 * ibus_registry_get_components:
192 * @registry: An #IBusRegistry.
193 * @returns: (transfer container) (element-type IBusComponent):
194 * a list of #IBusComponent objects.
195 * The caller has to call g_list_free() for the returned list.
199 GList *ibus_registry_get_components (IBusRegistry *registry);
202 * ibus_registry_get_observed_paths:
203 * @registry: An #IBusRegistry.
204 * @returns: (transfer container) (element-type IBusObservedPath):
205 * a list of #IBusObservedPath objects.
206 * The caller has to call g_list_free() for the returned list.
208 * List observed paths.
210 GList *ibus_registry_get_observed_paths
211 (IBusRegistry *registry);
214 * ibus_registry_start_monitor_changes:
215 * @registry: An #IBusRegistry.
217 * Start to monitor observed paths.
219 void ibus_registry_start_monitor_changes
220 (IBusRegistry *registry);