Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(177)

Side by Side Diff: src/ibusconfigservice.c

Issue 2860022: Add api to ibus for retreiving unused config values. (Closed) Base URL: ssh://gitrw.chromium.org/ibus.git
Patch Set: Code review changes Created 10 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/ibusconfigservice.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* vim:set et sts=4: */ 1 /* vim:set et sts=4: */
2 /* ibus - The Input Bus 2 /* ibus - The Input Bus
3 * Copyright (C) 2008-2010 Peng Huang <shawn.p.huang@gmail.com> 3 * Copyright (C) 2008-2010 Peng Huang <shawn.p.huang@gmail.com>
4 * Copyright (C) 2008-2010 Red Hat, Inc. 4 * Copyright (C) 2008-2010 Red Hat, Inc.
5 * 5 *
6 * This library is free software; you can redistribute it and/or 6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public 7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either 8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version. 9 * version 2 of the License, or (at your option) any later version.
10 * 10 *
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 IBusError **err or); 55 IBusError **err or);
56 static gboolean ibus_config_service_get_value (IBusConfigService *con fig, 56 static gboolean ibus_config_service_get_value (IBusConfigService *con fig,
57 const gchar *sec tion, 57 const gchar *sec tion,
58 const gchar *nam e, 58 const gchar *nam e,
59 GValue *val ue, 59 GValue *val ue,
60 IBusError **err or); 60 IBusError **err or);
61 static gboolean ibus_config_service_unset (IBusConfigService *con fig, 61 static gboolean ibus_config_service_unset (IBusConfigService *con fig,
62 const gchar *sec tion, 62 const gchar *sec tion,
63 const gchar *nam e, 63 const gchar *nam e,
64 IBusError **err or); 64 IBusError **err or);
65 static gboolean ibus_config_service_get_unused (IBusConfigService *con fig,
66 GValue *unr ead,
67 GValue *unw ritten,
68 IBusError **err or);
65 69
66 static IBusServiceClass *parent_class = NULL; 70 static IBusServiceClass *parent_class = NULL;
67 71
68 GType 72 GType
69 ibus_config_service_get_type (void) 73 ibus_config_service_get_type (void)
70 { 74 {
71 static GType type = 0; 75 static GType type = 0;
72 76
73 static const GTypeInfo type_info = { 77 static const GTypeInfo type_info = {
74 sizeof (IBusConfigServiceClass), 78 sizeof (IBusConfigServiceClass),
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 gobject_class->set_property = (GObjectSetPropertyFunc) ibus_config_service_s et_property; 120 gobject_class->set_property = (GObjectSetPropertyFunc) ibus_config_service_s et_property;
117 gobject_class->get_property = (GObjectGetPropertyFunc) ibus_config_service_g et_property; 121 gobject_class->get_property = (GObjectGetPropertyFunc) ibus_config_service_g et_property;
118 122
119 IBUS_OBJECT_CLASS (gobject_class)->destroy = (IBusObjectDestroyFunc) ibus_co nfig_service_destroy; 123 IBUS_OBJECT_CLASS (gobject_class)->destroy = (IBusObjectDestroyFunc) ibus_co nfig_service_destroy;
120 124
121 IBUS_SERVICE_CLASS (klass)->ibus_message = (ServiceIBusMessageFunc) ibus_con fig_service_ibus_message; 125 IBUS_SERVICE_CLASS (klass)->ibus_message = (ServiceIBusMessageFunc) ibus_con fig_service_ibus_message;
122 126
123 klass->set_value = ibus_config_service_set_value; 127 klass->set_value = ibus_config_service_set_value;
124 klass->get_value = ibus_config_service_get_value; 128 klass->get_value = ibus_config_service_get_value;
125 klass->unset = ibus_config_service_unset; 129 klass->unset = ibus_config_service_unset;
130 klass->get_unused = ibus_config_service_get_unused;
126 131
127 /* install properties */ 132 /* install properties */
128 /** 133 /**
129 * IBusConfigService:connection: 134 * IBusConfigService:connection:
130 * 135 *
131 * Connection of this IBusConfigService. 136 * Connection of this IBusConfigService.
132 */ 137 */
133 g_object_class_install_property (gobject_class, 138 g_object_class_install_property (gobject_class,
134 PROP_CONNECTION, 139 PROP_CONNECTION,
135 g_param_spec_object ("connection", 140 g_param_spec_object ("connection",
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 else if (!IBUS_CONFIG_SERVICE_GET_CLASS (config)->unset (config, section , name, &error)) { 289 else if (!IBUS_CONFIG_SERVICE_GET_CLASS (config)->unset (config, section , name, &error)) {
285 reply = ibus_message_new_error (message, 290 reply = ibus_message_new_error (message,
286 error->name, 291 error->name,
287 error->message); 292 error->message);
288 ibus_error_free (error); 293 ibus_error_free (error);
289 } 294 }
290 else { 295 else {
291 reply = ibus_message_new_method_return (message); 296 reply = ibus_message_new_method_return (message);
292 } 297 }
293 } 298 }
299 else if (ibus_message_is_method_call (message, IBUS_INTERFACE_CONFIG, "GetUn used")) {
300 GValue unread = { 0 };
301 GValue unwritten = { 0 };
302 IBusError *error = NULL;
303 gboolean retval;
304
305 if (!IBUS_CONFIG_SERVICE_GET_CLASS (config)->get_unused (config, &unread , &unwritten, &error)) {
306 reply = ibus_message_new_error (message,
307 error->name,
308 error->message);
309 ibus_error_free (error);
310 }
311 else {
312 reply = ibus_message_new_method_return (message);
313 ibus_message_append_args (reply,
314 G_TYPE_VALUE, &unread,
315 G_TYPE_VALUE, &unwritten,
316 G_TYPE_INVALID);
317 g_value_unset (&unread);
318 g_value_unset (&unwritten);
319 }
320 }
294 321
295 if (reply) { 322 if (reply) {
296 ibus_connection_send (connection, reply); 323 ibus_connection_send (connection, reply);
297 ibus_message_unref (reply); 324 ibus_message_unref (reply);
298 return TRUE; 325 return TRUE;
299 } 326 }
300 327
301 return parent_class->ibus_message ((IBusService *) config, connection, messa ge); 328 return parent_class->ibus_message ((IBusService *) config, connection, messa ge);
302 } 329 }
303 330
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 IBusError **error) 365 IBusError **error)
339 { 366 {
340 if (error) { 367 if (error) {
341 *error = ibus_error_new_from_printf (DBUS_ERROR_FAILED, 368 *error = ibus_error_new_from_printf (DBUS_ERROR_FAILED,
342 "Can not unset [%s, %s]", 369 "Can not unset [%s, %s]",
343 section, name); 370 section, name);
344 } 371 }
345 return FALSE; 372 return FALSE;
346 } 373 }
347 374
375 static gboolean
376 ibus_config_service_get_unused (IBusConfigService *config,
377 GValue *unread,
378 GValue *unwritten,
379 IBusError **error)
380 {
381 if (error) {
382 *error = ibus_error_new_from_printf (DBUS_ERROR_FAILED,
383 "Can not get unused values");
384 }
385 return FALSE;
386 }
387
348 void 388 void
349 ibus_config_service_value_changed (IBusConfigService *config, 389 ibus_config_service_value_changed (IBusConfigService *config,
350 const gchar *section, 390 const gchar *section,
351 const gchar *name, 391 const gchar *name,
352 const GValue *value) 392 const GValue *value)
353 { 393 {
354 g_assert (IBUS_IS_CONFIG_SERVICE (config)); 394 g_assert (IBUS_IS_CONFIG_SERVICE (config));
355 g_assert (section); 395 g_assert (section);
356 g_assert (name); 396 g_assert (name);
357 g_assert (G_IS_VALUE (value)); 397 g_assert (G_IS_VALUE (value));
358 398
359 ibus_service_send_signal ((IBusService *) config, 399 ibus_service_send_signal ((IBusService *) config,
360 IBUS_INTERFACE_CONFIG, 400 IBUS_INTERFACE_CONFIG,
361 "ValueChanged", 401 "ValueChanged",
362 G_TYPE_STRING, &section, 402 G_TYPE_STRING, &section,
363 G_TYPE_STRING, &name, 403 G_TYPE_STRING, &name,
364 G_TYPE_VALUE, value, 404 G_TYPE_VALUE, value,
365 G_TYPE_INVALID); 405 G_TYPE_INVALID);
366 } 406 }
OLDNEW
« no previous file with comments | « src/ibusconfigservice.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698