/* Writes a schema, which is a struct. */ static void utils_append_schema (DBusMessageIter *main_iter, const GConfSchema *schema) { DBusMessageIter struct_iter; gint32 i; const gchar *s; GConfValue *default_value; dbus_message_iter_open_container (main_iter, DBUS_TYPE_STRUCT, NULL, /* for structs */ &struct_iter); i = gconf_schema_get_type (schema); dbus_message_iter_append_basic (&struct_iter, DBUS_TYPE_INT32, &i); i = gconf_schema_get_list_type (schema); dbus_message_iter_append_basic (&struct_iter, DBUS_TYPE_INT32, &i); i = gconf_schema_get_car_type (schema); dbus_message_iter_append_basic (&struct_iter, DBUS_TYPE_INT32, &i); i = gconf_schema_get_cdr_type (schema); dbus_message_iter_append_basic (&struct_iter, DBUS_TYPE_INT32, &i); s = gconf_schema_get_locale (schema); utils_append_optional_string (&struct_iter, s); s = gconf_schema_get_short_desc (schema); utils_append_optional_string (&struct_iter, s); s = gconf_schema_get_long_desc (schema); utils_append_optional_string (&struct_iter, s); s = gconf_schema_get_owner (schema); utils_append_optional_string (&struct_iter, s); default_value = gconf_schema_get_default_value (schema); /* We don't need to do this, but it's much simpler */ if (default_value) { gchar *encoded; encoded = gconf_value_encode (default_value); g_assert (encoded != NULL); dbus_message_iter_append_basic (&struct_iter, DBUS_TYPE_STRING, &encoded); g_free (encoded); } else { s = ""; dbus_message_iter_append_basic (&struct_iter, DBUS_TYPE_STRING, &s); } if (!dbus_message_iter_close_container (main_iter, &struct_iter)) g_error ("Out of memory"); }
/* Writes an entry, which is a struct. */ static void utils_append_entry_values_stringified (DBusMessageIter *main_iter, const gchar *key, const GConfValue *value, gboolean is_default, gboolean is_writable, const gchar *schema_name) { DBusMessageIter struct_iter; gchar *value_str; d(g_print ("Appending entry %s\n", key)); dbus_message_iter_open_container (main_iter, DBUS_TYPE_STRUCT, NULL, /* for structs */ &struct_iter); dbus_message_iter_append_basic (&struct_iter, DBUS_TYPE_STRING, &key); value_str = NULL; if (value) value_str = gconf_value_encode ((GConfValue *) value); if (!value_str) value_str = g_strdup (""); dbus_message_iter_append_basic (&struct_iter, DBUS_TYPE_STRING, &value_str); g_free (value_str); utils_append_optional_string (&struct_iter, schema_name); dbus_message_iter_append_basic (&struct_iter, DBUS_TYPE_BOOLEAN, &is_default); dbus_message_iter_append_basic (&struct_iter, DBUS_TYPE_BOOLEAN, &is_writable); if (!dbus_message_iter_close_container (main_iter, &struct_iter)) g_error ("Out of memory"); }
static void update_login_options (GtkWidget *widget, UmLoginOptions *d) { GError *error; gboolean active; GConfValue *value; const gchar *key = NULL; gchar *value_string; if (widget == d->userlist_check || widget == d->power_check) { active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)); key = g_object_get_data (G_OBJECT (widget), "gconf-key"); } else { g_warning ("unhandled option in update_login_options"); return; } error = NULL; value = gconf_value_new (GCONF_VALUE_BOOL); gconf_value_set_bool (value, !active); value_string = gconf_value_encode (value); if (!dbus_g_proxy_call (d->proxy, "SetMandatoryValue", &error, G_TYPE_STRING, key, G_TYPE_STRING, value_string, G_TYPE_INVALID, G_TYPE_INVALID)) { g_warning ("error calling SetMandatoryValue: %s\n", error->message); g_error_free (error); } g_free (value_string); gconf_value_free (value); update_boolean_from_gconf (widget, d); }