From: Jonathan Maw Date: Tue, 12 Jun 2012 16:16:51 +0000 (+0100) Subject: Bind GSetting key to D-Bus property X-Git-Tag: boot-manager-0.1.0~44 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6aca942bc9929edeb454960408a7a1952dfd2d97;p=profile%2Fivi%2Fnode-startup-controller.git Bind GSetting key to D-Bus property Modifications made to luc-handler/luc-handler-service.c In struct _LUCHandlerService: - Added GSettings object to store the settings with the handler. In luc_handler_service_init: - Initialized the GSettings object. - Bound the last-user-context of the settings to the last-user-context of the interface. In luc_handler_service_finalize: - Finalize the GSettings object (It is unnecessary to unbind the settings because they belong to the object they are bound to, and are unbound when the object is finalized) --- diff --git a/luc-handler/luc-handler-service.c b/luc-handler/luc-handler-service.c index 0c7de47..275bb27 100644 --- a/luc-handler/luc-handler-service.c +++ b/luc-handler/luc-handler-service.c @@ -59,6 +59,7 @@ struct _LUCHandlerService GDBusConnection *connection; LUCHandler *interface; + GSettings *settings; }; @@ -94,8 +95,13 @@ luc_handler_service_init (LUCHandlerService *service) { service->interface = luc_handler_skeleton_new (); - /* TODO read LastUserContext from disk and set the "last-user-context" property - * of the skeleton instance */ + service->settings = g_settings_new ("org.genivi.LUCHandler1"); + + /* bind the settings key to the D-Bus property so changes are automatically + * synchronised */ + g_settings_bind (service->settings, "last-user-context", + service->interface, "last-user-context", + G_SETTINGS_BIND_DEFAULT); g_signal_connect (service->interface, "handle-register", G_CALLBACK (luc_handler_service_handle_register), @@ -122,6 +128,9 @@ luc_handler_service_finalize (GObject *object) G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, service); g_object_unref (service->interface); + + /* release the settings object */ + g_object_unref (service->settings); (*G_OBJECT_CLASS (luc_handler_service_parent_class)->finalize) (object); }