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-2013 Peng Huang <shawn.p.huang@gmail.com>
5  * Copyright (C) 2008-2013 Red Hat, Inc.
6  *
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.1 of the License, or (at your option) any later version.
11  *
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.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301
20  * USA
21  */
22 
23 #if !defined (__IBUS_H_INSIDE__) && !defined (IBUS_COMPILATION)
24 #error "Only <ibus.h> can be included directly"
25 #endif
26 
27 #ifndef __IBUS_CONFIG_SERVICE_H_
28 #define __IBUS_CONFIG_SERVICE_H_
29 
30 /**
31  * SECTION: ibusconfigservice
32  * @short_description: Configuration service back-end.
33  * @stability: Stable
34  *
35  * An IBusConfigService is a base class for other configuration services such as GConf.
36  * Currently, directly known sub class is IBusConfigGConf.
37  *
38  * IBusConfigServiceClass has following member functions:
39  * <itemizedlist>
40  *     <listitem>
41  *         <para>gboolean set_value(IBusConfigService *config, const gchar *section, const gchar *name,
42  *             const GValue *value, IBusError **error)
43  *         </para>
44  *         <variablelist>
45  *             <varlistentry>
46  *                 <term>config:</term>
47  *                 <listitem>A configure service</listitem>
48  *             </varlistentry>
49  *             <varlistentry>
50  *                 <term>section:</term>
51  *                 <listitem>Section name of the configuration option.</listitem>
52  *             </varlistentry>
53  *             <varlistentry>
54  *                 <term>name:</term>
55  *                 <listitem>Name of the configuration option.</listitem>
56  *             </varlistentry>
57  *             <varlistentry>
58  *                 <term>value:</term>
59  *                 <listitem>GValue that holds the value.</listitem>
60  *             </varlistentry>
61  *             <varlistentry>
62  *                 <term>error:</term>
63  *                 <listitem>Error outputs here.</listitem>
64  *             </varlistentry>
65  *             <varlistentry>
66  *                 <term>Returns:</term>
67  *                 <listitem>TRUE if succeed; FALSE otherwise.</listitem>
68  *             </varlistentry>
69  *         </variablelist>
70  *         <para>Set a value to a configuration option.
71  *         </para>
72  *     </listitem>
73  *     <listitem>
74  *         <para>gboolean get_value(IBusConfigService *config, const gchar *section, const gchar *name,
75  *             GValue *value, IBusError **error)
76  *         </para>
77  *         <variablelist>
78  *             <varlistentry>
79  *                 <term>config:</term>
80  *                 <listitem>A configure service</listitem>
81  *             </varlistentry>
82  *             <varlistentry>
83  *                 <term>section:</term>
84  *                 <listitem>Section name of the configuration option.</listitem>
85  *             </varlistentry>
86  *             <varlistentry>
87  *                 <term>name:</term>
88  *                 <listitem>Name of the configuration option.</listitem>
89  *             </varlistentry>
90  *             <varlistentry>
91  *                 <term>value:</term>
92  *                 <listitem>GValue that holds the value.</listitem>
93  *             </varlistentry>
94  *             <varlistentry>
95  *                 <term>error:</term>
96  *                 <listitem>Error outputs here.</listitem>
97  *             </varlistentry>
98  *             <varlistentry>
99  *                 <term>Returns:</term>
100  *                 <listitem>TRUE if succeed; FALSE otherwise.</listitem>
101  *             </varlistentry>
102  *        </variablelist>
103  *        <para>Get value of a configuration option.
104  *        </para>
105  *     </listitem>
106  *     <listitem>
107  *         <para>gboolean unset(IBusConfigService *config, const gchar *section, const gchar *name,
108  *             IBusError **error)
109  *         </para>
110  *         <variablelist>
111  *             <varlistentry>
112  *                 <term>config:</term>
113  *                 <listitem>A configure service</listitem>
114  *             </varlistentry>
115  *             <varlistentry>
116  *                 <term>section:</term>
117  *                 <listitem>Section name of the configuration option.</listitem>
118  *             </varlistentry>
119  *             <varlistentry>
120  *                 <term>name:</term>
121  *                 <listitem>Name of the configuration option.</listitem>
122  *             </varlistentry>
123  *             <varlistentry>
124  *                 <term>error:</term>
125  *                 <listitem>Error outputs here.</listitem>
126  *             </varlistentry>
127  *             <varlistentry>
128  *                 <term>Returns:</term>
129  *                 <listitem>TRUE if succeed; FALSE otherwise.</listitem>
130  *             </varlistentry>
131  *         </variablelist>
132  *         <para>Remove an entry to a configuration option.
133  *         </para>
134  *     </listitem>
135  * </itemizedlist>
136  */
137 
138 #include "ibusservice.h"
139 
140 /*
141  * Type macros.
142  */
143 
144 /* define GOBJECT macros */
145 #define IBUS_TYPE_CONFIG_SERVICE             \
146     (ibus_config_service_get_type ())
147 #define IBUS_CONFIG_SERVICE(obj)             \
148     (G_TYPE_CHECK_INSTANCE_CAST ((obj), IBUS_TYPE_CONFIG_SERVICE, IBusConfigService))
149 #define IBUS_CONFIG_SERVICE_CLASS(klass)     \
150     (G_TYPE_CHECK_CLASS_CAST ((klass), IBUS_TYPE_CONFIG_SERVICE, IBusConfigServiceClass))
151 #define IBUS_IS_CONFIG_SERVICE(obj)          \
152     (G_TYPE_CHECK_INSTANCE_TYPE ((obj), IBUS_TYPE_CONFIG_SERVICE))
153 #define IBUS_IS_CONFIG_SERVICE_CLASS(klass)  \
154     (G_TYPE_CHECK_CLASS_TYPE ((klass), IBUS_TYPE_CONFIG_SERVICE))
155 #define IBUS_CONFIG_SERVICE_GET_CLASS(obj)   \
156     (G_TYPE_INSTANCE_GET_CLASS ((obj), IBUS_TYPE_CONFIG_SERVICE, IBusConfigServiceClass))
157 
158 G_BEGIN_DECLS
159 
160 typedef struct _IBusConfigService IBusConfigService;
161 typedef struct _IBusConfigServiceClass IBusConfigServiceClass;
162 
163 /**
164  * IBusConfigService:
165  *
166  * An opaque data type representing a configure service.
167  */
168 struct _IBusConfigService {
169     /*< private >*/
170     IBusService parent;
171     /* IBusConfigServicePriv *priv */
172 
173     /* instance members */
174 };
175 
176 struct _IBusConfigServiceClass {
177     /*< private >*/
178     IBusServiceClass parent;
179 
180     /*< public >*/
181     /* class members */
182     gboolean    (* set_value)   (IBusConfigService    *config,
183                                  const gchar          *section,
184                                  const gchar          *name,
185                                  GVariant             *value,
186                                  GError              **error);
187     /**
188      * get_value:
189      * @config: An #IBusConfig.
190      * @section: section name
191      * @name: value name
192      *
193      * Returns: (transfer full): The value in config associated with section
194      *         and name.
195      */
196     GVariant *  (* get_value)   (IBusConfigService    *config,
197                                  const gchar          *section,
198                                  const gchar          *name,
199                                  GError              **error);
200     gboolean    (* unset_value) (IBusConfigService    *config,
201                                  const gchar          *section,
202                                  const gchar          *name,
203                                  GError              **error);
204     GVariant *  (* get_values)  (IBusConfigService    *config,
205                                  const gchar          *section,
206                                  GError              **error);
207 
208     /*< private >*/
209     /* padding */
210     gpointer pdummy[12];
211 };
212 
213 GType                ibus_config_service_get_type   (void);
214 
215 /**
216  * ibus_config_service_new:
217  * @connection: An #GDBusConnection.
218  *
219  * Creates an new #IBusConfigService from an #GDBusConnection.
220  *
221  * Returns: A newly allocated #IBusConfigServices.
222  */
223 IBusConfigService   *ibus_config_service_new        (GDBusConnection     *connection);
224 
225 /**
226  * ibus_config_service_value_changed:
227  * @config: An IBusConfigService.
228  * @section: Section name of the configuration option.
229  * @name: Name of the configure option.
230  * @value: GVariant that holds the value.
231  *
232  * Change a value of a configuration option
233  * by sending a "ValueChanged" message to IBus service.
234  */
235 void                 ibus_config_service_value_changed
236                                                     (IBusConfigService  *config,
237                                                      const gchar        *section,
238                                                      const gchar        *name,
239                                                      GVariant           *value);
240 
241 G_END_DECLS
242 #endif
243 
244