Load the system registry cache prior to the user one.
[platform/upstream/ibus.git] / src / ibusregistry.h
1 /* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil; -*- */
2 /* vim:set et sts=4: */
3 /* bus - The Input Bus
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.
7  *
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.
12  *
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.
17  *
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.
22  */
23
24 #if !defined (__IBUS_H_INSIDE__) && !defined (IBUS_COMPILATION)
25 #error "Only <ibus.h> can be included directly"
26 #endif
27
28 #ifndef __IBUS_REGISTRY_H_
29 #define __IBUS_REGISTRY_H_
30
31 /**
32  * SECTION: ibusregistry
33  * @short_description: Registry cache handling.
34  * @title: IBusRegistry
35  * @stability: Stable
36  *
37  * An #IBusRegistry loads IBus component files and generates the cache files.
38  *
39  * see_also: #IBusComponent
40  */
41
42 #include "ibuscomponent.h"
43
44 /*
45  * Type macros.
46  */
47
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))
61
62 G_BEGIN_DECLS
63
64 typedef struct _IBusRegistry IBusRegistry;
65 typedef struct _IBusRegistryPrivate IBusRegistryPrivate;
66 typedef struct _IBusRegistryClass IBusRegistryClass;
67
68 /**
69  * IBusRegistry:
70  *
71  * Registry cache handling.
72  * You can load the registry from compose files or a cache file.
73  */
74 struct _IBusRegistry {
75     /* instance members */
76     /*< private >*/
77     IBusObject parent;
78     IBusRegistryPrivate *priv;
79 };
80
81 struct _IBusRegistryClass {
82     /* class members */
83     /*< private >*/
84     IBusObjectClass parent;
85 };
86
87 GType            ibus_registry_get_type         (void);
88
89 /**
90  * ibus_registry_new:
91  * @returns: A newly allocated #IBusRegistry.
92  *
93  * New a #IBusRegistry
94  */
95 IBusRegistry    *ibus_registry_new              (void);
96
97 /**
98  * ibus_registry_load:
99  * @registry: An #IBusRegistry.
100  *
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 ':'.
105  */
106 void             ibus_registry_load             (IBusRegistry   *registry);
107
108 /**
109  * ibus_registry_load_in_dir:
110  * @registry: An #IBusRegistry.
111  * @dirname: IBus component directory which includes XML files.
112  *
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.
117  */
118 void             ibus_registry_load_in_dir      (IBusRegistry   *registry,
119                                                  const gchar    *dirname);
120
121 /**
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,
126  *           %FALSE otherwise.
127  *
128  * Load the user or system registry cache.
129  */
130 gboolean         ibus_registry_load_cache       (IBusRegistry   *registry,
131                                                  gboolean        is_user);
132
133 /**
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,
138  *           %FALSE otherwise.
139  *
140  * Load the registry cache @filename.
141  */
142 gboolean         ibus_registry_load_cache_file  (IBusRegistry   *registry,
143                                                  const gchar    *filename);
144
145 /**
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.
150  *
151  * Save the registry in a user directory or system directory.
152  */
153 gboolean         ibus_registry_save_cache       (IBusRegistry   *registry,
154                                                  gboolean        is_user);
155
156 /**
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.
161  *
162  * Save the registry cache @filename.
163  */
164 gboolean         ibus_registry_save_cache_file  (IBusRegistry   *registry,
165                                                  const gchar    *filename);
166
167 /**
168  * ibus_registry_output:
169  * @registry: An #IBusRegistry.
170  * @output: GString that holds the result.
171  * @indent: level of indent.
172  *
173  * Output #IBusRegistry as an XML-formatted string.
174  * The output string can be then shown on the screen or written to file.
175  */
176 void             ibus_registry_output           (IBusRegistry   *registry,
177                                                  GString        *output,
178                                                  int             indent);
179
180 /**
181  * ibus_registry_check_modification:
182  * @registry: An #IBusRegistry.
183  * @returns: %TRUE if mtime is changed; %FALSE otherwise.
184  *
185  * Check if the registry is updated.
186  */
187 gboolean         ibus_registry_check_modification
188                                                 (IBusRegistry   *registry);
189
190 /**
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.
196  *
197  * List components.
198  */
199 GList           *ibus_registry_get_components   (IBusRegistry   *registry);
200
201 /**
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.
207  *
208  * List observed paths.
209  */
210 GList           *ibus_registry_get_observed_paths
211                                                 (IBusRegistry   *registry);
212
213 /**
214  * ibus_registry_start_monitor_changes:
215  * @registry: An #IBusRegistry.
216  *
217  * Start to monitor observed paths.
218  */
219 void             ibus_registry_start_monitor_changes
220                                                 (IBusRegistry   *registry);
221
222 G_END_DECLS
223 #endif