~ubuntu-branches/ubuntu/quantal/ibus/quantal

« back to all changes in this revision

Viewing changes to src/ibusconfigservice.c

  • Committer: Bazaar Package Importer
  • Author(s): Barry Warsaw
  • Date: 2011-08-11 17:00:57 UTC
  • mfrom: (6.2.14 sid)
  • Revision ID: james.westby@ubuntu.com-20110811170057-6dmbfs4s3cchzl7x
Tags: 1.3.99.20110419-1ubuntu1
* Merge with Debian unstable.  Remaining Ubuntu changes:
  - Indicator support:
    + Add 05_appindicator.patch: Use an indicator rather than a notification
      icon.
    + debian/control: Recommend python-appindicator.
  - debian/control: Install im-switch instead of im-config by default.
  - debian/README.source: Removed, it was outdated and no longer correct
  - debian/patches/01_ubuntu_desktop: Fix "Desktop entry needs the
    X-Ubuntu-Gettext-Domain key"  (LP: #457632)
  - debian/patches/02_title_update.patch: Rename "IBus Preferences" to
    "Keyboard Input Methods"
  - debian/patches/06_locale_parser.patch: Cherry-picked from upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20
20
 * Boston, MA 02111-1307, USA.
21
21
 */
22
 
#include <dbus/dbus.h>
23
22
#include "ibusshare.h"
24
23
#include "ibusconfigservice.h"
25
24
 
29
28
 
30
29
enum {
31
30
    PROP_0,
32
 
    PROP_CONNECTION,
33
31
};
34
32
 
35
33
// static guint            config_service_signals[LAST_SIGNAL] = { 0 };
36
34
 
37
35
/* functions prototype */
38
 
static void     ibus_config_service_class_init      (IBusConfigServiceClass *klass);
39
 
static void     ibus_config_service_init            (IBusConfigService      *config);
40
 
static void     ibus_config_service_set_property    (IBusConfigService      *config,
41
 
                                                     guint                   prop_id,
42
 
                                                     const GValue           *value,
43
 
                                                     GParamSpec             *pspec);
44
 
static void     ibus_config_service_get_property    (IBusConfigService      *config,
45
 
                                                     guint                   prop_id,
46
 
                                                     GValue                 *value,
47
 
                                                     GParamSpec             *pspec);
48
 
static void     ibus_config_service_destroy         (IBusConfigService      *config);
49
 
static gboolean ibus_config_service_ibus_message    (IBusConfigService      *config,
50
 
                                                     IBusConnection         *connection,
51
 
                                                     IBusMessage            *message);
52
 
static gboolean ibus_config_service_set_value       (IBusConfigService      *config,
53
 
                                                     const gchar            *section,
54
 
                                                     const gchar            *name,
55
 
                                                     const GValue           *value,
56
 
                                                     IBusError             **error);
57
 
static gboolean ibus_config_service_get_value       (IBusConfigService      *config,
58
 
                                                     const gchar            *section,
59
 
                                                     const gchar            *name,
60
 
                                                     GValue                 *value,
61
 
                                                     IBusError             **error);
62
 
static gboolean ibus_config_service_unset           (IBusConfigService      *config,
63
 
                                                     const gchar            *section,
64
 
                                                     const gchar            *name,
65
 
                                                     IBusError             **error);
66
 
 
67
 
static IBusServiceClass  *parent_class = NULL;
68
 
 
69
 
GType
70
 
ibus_config_service_get_type (void)
71
 
{
72
 
    static GType type = 0;
73
 
 
74
 
    static const GTypeInfo type_info = {
75
 
        sizeof (IBusConfigServiceClass),
76
 
        (GBaseInitFunc)     NULL,
77
 
        (GBaseFinalizeFunc) NULL,
78
 
        (GClassInitFunc)    ibus_config_service_class_init,
79
 
        NULL,               /* class finalize */
80
 
        NULL,               /* class data */
81
 
        sizeof (IBusConfigService),
82
 
        0,
83
 
        (GInstanceInitFunc) ibus_config_service_init,
84
 
    };
85
 
 
86
 
    if (type == 0) {
87
 
        type = g_type_register_static (IBUS_TYPE_SERVICE,
88
 
                                       "IBusConfigService",
89
 
                                       &type_info,
90
 
                                       (GTypeFlags) 0);
91
 
    }
92
 
    return type;
93
 
}
94
 
 
95
 
IBusConfigService *
96
 
ibus_config_service_new (IBusConnection *connection)
97
 
{
98
 
    g_assert (IBUS_IS_CONNECTION (connection));
99
 
 
100
 
    IBusConfigService *config;
101
 
 
102
 
    config = (IBusConfigService *) g_object_new (IBUS_TYPE_CONFIG_SERVICE,
103
 
                                                 "path", IBUS_PATH_CONFIG,
104
 
                                                 "connection", connection,
105
 
                                                 NULL);
106
 
 
107
 
    return config;
108
 
}
 
36
static void      ibus_config_service_class_init      (IBusConfigServiceClass *class);
 
37
static void      ibus_config_service_init            (IBusConfigService      *config);
 
38
static void      ibus_config_service_set_property    (IBusConfigService      *config,
 
39
                                                      guint                   prop_id,
 
40
                                                      const GValue           *value,
 
41
                                                      GParamSpec             *pspec);
 
42
static void      ibus_config_service_get_property    (IBusConfigService      *config,
 
43
                                                      guint                   prop_id,
 
44
                                                      GValue                 *value,
 
45
                                                      GParamSpec             *pspec);
 
46
static void      ibus_config_service_destroy         (IBusConfigService      *config);
 
47
static void      ibus_config_service_service_method_call
 
48
                                                     (IBusService            *service,
 
49
                                                      GDBusConnection        *connection,
 
50
                                                      const gchar            *sender,
 
51
                                                      const gchar            *object_path,
 
52
                                                      const gchar            *interface_name,
 
53
                                                      const gchar            *method_name,
 
54
                                                      GVariant               *parameters,
 
55
                                                      GDBusMethodInvocation  *invocation);
 
56
static GVariant *ibus_config_service_service_get_property
 
57
                                                     (IBusService            *service,
 
58
                                                      GDBusConnection        *connection,
 
59
                                                      const gchar            *sender,
 
60
                                                      const gchar            *object_path,
 
61
                                                      const gchar            *interface_name,
 
62
                                                      const gchar            *property_name,
 
63
                                                      GError                **error);
 
64
static gboolean  ibus_config_service_service_set_property
 
65
                                                     (IBusService            *service,
 
66
                                                      GDBusConnection        *connection,
 
67
                                                      const gchar            *sender,
 
68
                                                      const gchar            *object_path,
 
69
                                                      const gchar            *interface_name,
 
70
                                                      const gchar            *property_name,
 
71
                                                      GVariant               *value,
 
72
                                                      GError                **error);
 
73
static gboolean  ibus_config_service_set_value       (IBusConfigService      *config,
 
74
                                                      const gchar            *section,
 
75
                                                      const gchar            *name,
 
76
                                                      GVariant               *value,
 
77
                                                      GError                **error);
 
78
static GVariant *ibus_config_service_get_value       (IBusConfigService      *config,
 
79
                                                      const gchar            *section,
 
80
                                                      const gchar            *name,
 
81
                                                      GError                **error);
 
82
static gboolean  ibus_config_service_unset_value     (IBusConfigService      *config,
 
83
                                                      const gchar            *section,
 
84
                                                      const gchar            *name,
 
85
                                                      GError                **error);
 
86
 
 
87
G_DEFINE_TYPE (IBusConfigService, ibus_config_service, IBUS_TYPE_SERVICE)
 
88
 
 
89
static const gchar introspection_xml[] =
 
90
    "<node>"
 
91
    "  <interface name='org.freedesktop.IBus.Config'>"
 
92
    "    <method name='SetValue'>"
 
93
    "      <arg direction='in'  type='s' name='section' />"
 
94
    "      <arg direction='in'  type='s' name='name' />"
 
95
    "      <arg direction='in'  type='v' name='value' />"
 
96
    "    </method>"
 
97
    "    <method name='GetValue'>"
 
98
    "      <arg direction='in'  type='s' name='section' />"
 
99
    "      <arg direction='in'  type='s' name='name' />"
 
100
    "      <arg direction='out' type='v' name='value' />"
 
101
    "    </method>"
 
102
    "    <method name='UnsetValue'>"
 
103
    "      <arg direction='in'  type='s' name='section' />"
 
104
    "      <arg direction='in'  type='s' name='name' />"
 
105
    "    </method>"
 
106
    "    <signal name='ValueChanged'>"
 
107
    "      <arg type='s' name='section' />"
 
108
    "      <arg type='s' name='name' />"
 
109
    "      <arg type='v' name='value' />"
 
110
    "    </signal>"
 
111
    "  </interface>"
 
112
    "</node>";
109
113
 
110
114
static void
111
 
ibus_config_service_class_init (IBusConfigServiceClass *klass)
 
115
ibus_config_service_class_init (IBusConfigServiceClass *class)
112
116
{
113
 
    GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
114
 
 
115
 
    parent_class = (IBusServiceClass *) g_type_class_peek_parent (klass);
 
117
    GObjectClass *gobject_class = G_OBJECT_CLASS (class);
116
118
 
117
119
    gobject_class->set_property = (GObjectSetPropertyFunc) ibus_config_service_set_property;
118
120
    gobject_class->get_property = (GObjectGetPropertyFunc) ibus_config_service_get_property;
119
121
 
120
122
    IBUS_OBJECT_CLASS (gobject_class)->destroy = (IBusObjectDestroyFunc) ibus_config_service_destroy;
121
123
 
122
 
    IBUS_SERVICE_CLASS (klass)->ibus_message = (ServiceIBusMessageFunc) ibus_config_service_ibus_message;
123
 
 
124
 
    klass->set_value = ibus_config_service_set_value;
125
 
    klass->get_value = ibus_config_service_get_value;
126
 
    klass->unset = ibus_config_service_unset;
127
 
 
128
 
    /* install properties */
129
 
    /**
130
 
     * IBusConfigService:connection:
131
 
     *
132
 
     * Connection of this IBusConfigService.
133
 
     */
134
 
    g_object_class_install_property (gobject_class,
135
 
                    PROP_CONNECTION,
136
 
                    g_param_spec_object ("connection",
137
 
                        "connection",
138
 
                        "The connection of config object",
139
 
                        IBUS_TYPE_CONNECTION,
140
 
                        G_PARAM_READWRITE |  G_PARAM_CONSTRUCT_ONLY));
 
124
    IBUS_SERVICE_CLASS (class)->service_method_call  = ibus_config_service_service_method_call;
 
125
    IBUS_SERVICE_CLASS (class)->service_get_property = ibus_config_service_service_get_property;
 
126
    IBUS_SERVICE_CLASS (class)->service_set_property = ibus_config_service_service_set_property;
 
127
 
 
128
    ibus_service_class_add_interfaces (IBUS_SERVICE_CLASS (class), introspection_xml);
 
129
 
 
130
    class->set_value   = ibus_config_service_set_value;
 
131
    class->get_value   = ibus_config_service_get_value;
 
132
    class->unset_value = ibus_config_service_unset_value;
141
133
}
142
134
 
143
135
static void
152
144
                                  GParamSpec        *pspec)
153
145
{
154
146
    switch (prop_id) {
155
 
    case PROP_CONNECTION:
156
 
        ibus_service_add_to_connection ((IBusService *) config,
157
 
                                        g_value_get_object (value));
158
 
        break;
159
 
 
160
147
    default:
161
148
        G_OBJECT_WARN_INVALID_PROPERTY_ID (config, prop_id, pspec);
162
149
    }
169
156
                                  GParamSpec        *pspec)
170
157
{
171
158
    switch (prop_id) {
 
159
    #if 0
172
160
    case PROP_CONNECTION:
173
 
        {
174
 
            GList *connections = ibus_service_get_connections ((IBusService *) config);
175
 
            if (connections) {
176
 
                g_value_set_object (value, connections->data);
177
 
            }
178
 
            else {
179
 
                g_value_set_object (value, NULL);
180
 
            }
181
 
            g_list_free (connections);
182
 
        }
183
161
        break;
 
162
    #endif
184
163
    default:
185
164
        G_OBJECT_WARN_INVALID_PROPERTY_ID (config, prop_id, pspec);
186
165
    }
189
168
static void
190
169
ibus_config_service_destroy (IBusConfigService *config)
191
170
{
192
 
    IBUS_OBJECT_CLASS(parent_class)->destroy ((IBusObject *) config);
 
171
    IBUS_OBJECT_CLASS(ibus_config_service_parent_class)->destroy ((IBusObject *) config);
 
172
}
 
173
 
 
174
static void
 
175
ibus_config_service_service_method_call (IBusService           *service,
 
176
                                         GDBusConnection       *connection,
 
177
                                         const gchar           *sender,
 
178
                                         const gchar           *object_path,
 
179
                                         const gchar           *interface_name,
 
180
                                         const gchar           *method_name,
 
181
                                         GVariant              *parameters,
 
182
                                         GDBusMethodInvocation *invocation)
 
183
{
 
184
    IBusConfigService *config = IBUS_CONFIG_SERVICE (service);
 
185
 
 
186
    if (g_strcmp0 (interface_name, IBUS_INTERFACE_CONFIG) != 0) {
 
187
        IBUS_SERVICE_CLASS (ibus_config_service_parent_class)->
 
188
                service_method_call (service,
 
189
                                     connection,
 
190
                                     sender,
 
191
                                     object_path,
 
192
                                     interface_name,
 
193
                                     method_name,
 
194
                                     parameters,
 
195
                                     invocation);
 
196
        return;
 
197
    }
 
198
 
 
199
    if (g_strcmp0 (method_name, "SetValue") == 0) {
 
200
        gchar *section;
 
201
        gchar *name;
 
202
        GVariant *value;
 
203
        gboolean retval;
 
204
        GError *error = NULL;
 
205
 
 
206
        g_variant_get (parameters, "(&s&sv)", &section, &name, &value);
 
207
 
 
208
        retval = IBUS_CONFIG_SERVICE_GET_CLASS (config)->set_value (config, section, name, value, &error);
 
209
        if (retval) {
 
210
            g_dbus_method_invocation_return_value (invocation, NULL);
 
211
        }
 
212
        else {
 
213
            g_dbus_method_invocation_return_gerror (invocation, error);
 
214
            g_error_free (error);
 
215
        }
 
216
        return;
 
217
    }
 
218
 
 
219
    if (g_strcmp0 (method_name, "GetValue") == 0) {
 
220
        gchar *section;
 
221
        gchar *name;
 
222
        GVariant *value;
 
223
        GError *error = NULL;
 
224
 
 
225
        g_variant_get (parameters, "(&s&s)", &section, &name);
 
226
 
 
227
        value = IBUS_CONFIG_SERVICE_GET_CLASS (config)->get_value (config, section, name, &error);
 
228
        if (value != NULL) {
 
229
            g_dbus_method_invocation_return_value (invocation, g_variant_new ("(v)", value));
 
230
        }
 
231
        else {
 
232
            g_dbus_method_invocation_return_gerror (invocation, error);
 
233
            g_error_free (error);
 
234
        }
 
235
        return;
 
236
    }
 
237
 
 
238
    if (g_strcmp0 (method_name, "UnsetValue") == 0) {
 
239
        gchar *section;
 
240
        gchar *name;
 
241
        gboolean retval;
 
242
        GError *error = NULL;
 
243
 
 
244
        g_variant_get (parameters, "(&s&s)", &section, &name);
 
245
 
 
246
        retval = IBUS_CONFIG_SERVICE_GET_CLASS (config)->unset_value (config, section, name, &error);
 
247
        if (retval) {
 
248
            g_dbus_method_invocation_return_value (invocation, NULL);
 
249
        }
 
250
        else {
 
251
            g_dbus_method_invocation_return_gerror (invocation, error);
 
252
            g_error_free (error);
 
253
        }
 
254
        return;
 
255
    }
 
256
 
 
257
    /* should not be reached */
 
258
    g_return_if_reached ();
 
259
}
 
260
 
 
261
static GVariant *
 
262
ibus_config_service_service_get_property (IBusService        *service,
 
263
                                          GDBusConnection    *connection,
 
264
                                          const gchar        *sender,
 
265
                                          const gchar        *object_path,
 
266
                                          const gchar        *interface_name,
 
267
                                          const gchar        *property_name,
 
268
                                          GError            **error)
 
269
{
 
270
    return IBUS_SERVICE_CLASS (ibus_config_service_parent_class)->
 
271
                service_get_property (service,
 
272
                                      connection,
 
273
                                      sender,
 
274
                                      object_path,
 
275
                                      interface_name,
 
276
                                      property_name,
 
277
                                      error);
193
278
}
194
279
 
195
280
static gboolean
196
 
ibus_config_service_ibus_message (IBusConfigService     *config,
197
 
                                  IBusConnection        *connection,
198
 
                                  IBusMessage           *message)
 
281
ibus_config_service_service_set_property (IBusService        *service,
 
282
                                          GDBusConnection    *connection,
 
283
                                          const gchar        *sender,
 
284
                                          const gchar        *object_path,
 
285
                                          const gchar        *interface_name,
 
286
                                          const gchar        *property_name,
 
287
                                          GVariant           *value,
 
288
                                          GError            **error)
199
289
{
200
 
    g_assert (IBUS_IS_CONFIG_SERVICE (config));
201
 
    g_assert (IBUS_IS_CONNECTION (connection));
202
 
    g_assert (message != NULL);
203
 
 
204
 
    IBusMessage *reply = NULL;
205
 
 
206
 
    if (ibus_message_is_method_call (message, IBUS_INTERFACE_CONFIG, "SetValue")) {
207
 
        gchar *section;
208
 
        gchar *name;
209
 
        GValue value = { 0 };
210
 
        IBusError *error = NULL;
211
 
        gboolean retval;
212
 
 
213
 
        retval = ibus_message_get_args (message,
214
 
                                        &error,
215
 
                                        G_TYPE_STRING, &section,
216
 
                                        G_TYPE_STRING, &name,
217
 
                                        G_TYPE_VALUE, &value,
218
 
                                        G_TYPE_INVALID);
219
 
        if (!retval) {
220
 
            reply = ibus_message_new_error_printf (message,
221
 
                                                   DBUS_ERROR_INVALID_ARGS,
222
 
                                                   "Can not parse arguments 1 of SetValue");
223
 
            ibus_error_free (error);
224
 
        }
225
 
        else {
226
 
            if (!IBUS_CONFIG_SERVICE_GET_CLASS (config)->set_value (config, section, name, &value, &error)) {
227
 
                reply = ibus_message_new_error (message,
228
 
                                                error->name,
229
 
                                                error->message);
230
 
                ibus_error_free (error);
231
 
            }
232
 
            else {
233
 
                reply = ibus_message_new_method_return (message);
234
 
            }
235
 
            g_value_unset (&value);
236
 
        }
237
 
    }
238
 
    else if (ibus_message_is_method_call (message, IBUS_INTERFACE_CONFIG, "GetValue")) {
239
 
        gchar *section;
240
 
        gchar *name;
241
 
        GValue value = { 0 };
242
 
        IBusError *error = NULL;
243
 
        gboolean retval;
244
 
 
245
 
        retval = ibus_message_get_args (message,
246
 
                                        &error,
247
 
                                        G_TYPE_STRING, &section,
248
 
                                        G_TYPE_STRING, &name,
249
 
                                        G_TYPE_INVALID);
250
 
 
251
 
        if (!retval) {
252
 
            reply = ibus_message_new_error (message,
253
 
                                            error->name,
254
 
                                            error->message);
255
 
            ibus_error_free (error);
256
 
        }
257
 
        else if (!IBUS_CONFIG_SERVICE_GET_CLASS (config)->get_value (config, section, name, &value, &error)) {
258
 
            reply = ibus_message_new_error (message,
259
 
                                            error->name,
260
 
                                            error->message);
261
 
            ibus_error_free (error);
262
 
        }
263
 
        else {
264
 
            reply = ibus_message_new_method_return (message);
265
 
            ibus_message_append_args (reply,
266
 
                                      G_TYPE_VALUE, &value,
267
 
                                      G_TYPE_INVALID);
268
 
            g_value_unset (&value);
269
 
        }
270
 
    }
271
 
    else if (ibus_message_is_method_call (message, IBUS_INTERFACE_CONFIG, "Unset")) {
272
 
        gchar *section;
273
 
        gchar *name;
274
 
        IBusError *error = NULL;
275
 
        gboolean retval;
276
 
 
277
 
        retval = ibus_message_get_args (message,
278
 
                                        &error,
279
 
                                        G_TYPE_STRING, &section,
280
 
                                        G_TYPE_STRING, &name,
281
 
                                        G_TYPE_INVALID);
282
 
        if (!retval) {
283
 
            reply = ibus_message_new_error_printf (message,
284
 
                                                   DBUS_ERROR_INVALID_ARGS,
285
 
                                                   "Can not parse arguments 1 of Unset");
286
 
            ibus_error_free (error);
287
 
        }
288
 
        else if (!IBUS_CONFIG_SERVICE_GET_CLASS (config)->unset (config, section, name, &error)) {
289
 
            reply = ibus_message_new_error (message,
290
 
                                            error->name,
291
 
                                            error->message);
292
 
            ibus_error_free (error);
293
 
        }
294
 
        else {
295
 
            reply = ibus_message_new_method_return (message);
296
 
        }
297
 
    }
298
 
 
299
 
    if (reply) {
300
 
        ibus_connection_send (connection, reply);
301
 
        ibus_message_unref (reply);
302
 
        return TRUE;
303
 
    }
304
 
 
305
 
    return parent_class->ibus_message ((IBusService *) config, connection, message);
 
290
    return IBUS_SERVICE_CLASS (ibus_config_service_parent_class)->
 
291
                service_set_property (service,
 
292
                                      connection,
 
293
                                      sender,
 
294
                                      object_path,
 
295
                                      interface_name,
 
296
                                      property_name,
 
297
                                      value,
 
298
                                      error);
306
299
}
307
300
 
308
301
static gboolean
309
302
ibus_config_service_set_value (IBusConfigService *config,
310
303
                               const gchar       *section,
311
304
                               const gchar       *name,
312
 
                               const GValue      *value,
313
 
                               IBusError        **error)
 
305
                               GVariant          *value,
 
306
                               GError           **error)
314
307
{
315
308
    if (error) {
316
 
        *error = ibus_error_new_from_printf (DBUS_ERROR_FAILED,
317
 
                                             "Can not set value [%s, %s]",
318
 
                                             section, name);
 
309
        gchar *str = g_variant_print (value, TRUE);
 
310
        *error = g_error_new (G_DBUS_ERROR, G_DBUS_ERROR_FAILED,
 
311
                              "Cannot set value %s::%s to %s", section, name, str);
 
312
        g_free (str);
319
313
    }
320
314
    return FALSE;
321
315
}
322
316
 
323
 
static gboolean
 
317
static GVariant *
324
318
ibus_config_service_get_value (IBusConfigService *config,
325
319
                               const gchar       *section,
326
320
                               const gchar       *name,
327
 
                               GValue            *value,
328
 
                               IBusError        **error)
 
321
                               GError           **error)
329
322
{
330
323
    if (error) {
331
 
        *error = ibus_error_new_from_printf (DBUS_ERROR_FAILED,
332
 
                                             "Can not get value [%s, %s]",
333
 
                                             section, name);
 
324
        *error = g_error_new (G_DBUS_ERROR, G_DBUS_ERROR_FAILED,
 
325
                              "Cannot get value %s::%s", section, name);
334
326
    }
335
 
    return FALSE;
 
327
    return NULL;
336
328
}
337
329
 
338
330
static gboolean
339
 
ibus_config_service_unset (IBusConfigService *config,
340
 
                           const gchar       *section,
341
 
                           const gchar       *name,
342
 
                           IBusError        **error)
 
331
ibus_config_service_unset_value (IBusConfigService *config,
 
332
                                 const gchar       *section,
 
333
                                 const gchar       *name,
 
334
                                 GError           **error)
343
335
{
344
336
    if (error) {
345
 
        *error = ibus_error_new_from_printf (DBUS_ERROR_FAILED,
346
 
                                             "Can not unset [%s, %s]",
347
 
                                             section, name);
 
337
        *error = g_error_new (G_DBUS_ERROR, G_DBUS_ERROR_FAILED,
 
338
                              "Cannot unset value %s::%s", section, name);
348
339
    }
349
340
    return FALSE;
350
341
}
351
342
 
 
343
IBusConfigService *
 
344
ibus_config_service_new (GDBusConnection *connection)
 
345
{
 
346
    g_return_val_if_fail (G_IS_DBUS_CONNECTION (connection), NULL);
 
347
 
 
348
    GObject *object = g_object_new (IBUS_TYPE_CONFIG_SERVICE,
 
349
                                    "object-path", IBUS_PATH_CONFIG,
 
350
                                    "connection", connection,
 
351
                                    NULL);
 
352
    return IBUS_CONFIG_SERVICE (object);
 
353
}
 
354
 
352
355
void
353
356
ibus_config_service_value_changed (IBusConfigService  *config,
354
357
                                   const gchar        *section,
355
358
                                   const gchar        *name,
356
 
                                   const GValue       *value)
 
359
                                   GVariant           *value)
357
360
{
358
 
    g_assert (IBUS_IS_CONFIG_SERVICE (config));
359
 
    g_assert (section);
360
 
    g_assert (name);
361
 
    g_assert (G_IS_VALUE (value));
 
361
    g_return_if_fail (IBUS_IS_CONFIG_SERVICE (config));
 
362
    g_return_if_fail (section != NULL);
 
363
    g_return_if_fail (name != NULL);
 
364
    g_return_if_fail (value != NULL);
362
365
 
363
 
    ibus_service_send_signal ((IBusService *) config,
 
366
    ibus_service_emit_signal ((IBusService *) config,
 
367
                              NULL,
364
368
                              IBUS_INTERFACE_CONFIG,
365
369
                              "ValueChanged",
366
 
                              G_TYPE_STRING, &section,
367
 
                              G_TYPE_STRING, &name,
368
 
                              G_TYPE_VALUE, value,
369
 
                              G_TYPE_INVALID);
 
370
                              g_variant_new ("(ssv)", section, name, value),
 
371
                              NULL);
370
372
}