/* Properties dialog
 */
static void
save_macros_to_gconf (MCData *mc)
{
    MCPrefsDialog *dialog;
    GtkTreeIter    iter;
    GConfValue    *patterns;
    GConfValue    *commands;
    GSList        *pattern_list = NULL;
    GSList        *command_list = NULL;
    GConfClient   *client;

    dialog = &mc->prefs_dialog;

    if (!gtk_tree_model_get_iter_first  (GTK_TREE_MODEL (dialog->macros_store), &iter))
	return;

    patterns = gconf_value_new (GCONF_VALUE_LIST);
    gconf_value_set_list_type (patterns, GCONF_VALUE_STRING);

    commands = gconf_value_new (GCONF_VALUE_LIST);
    gconf_value_set_list_type (commands, GCONF_VALUE_STRING);

    do {
	char *pattern = NULL;
	char *command = NULL;

	gtk_tree_model_get (
		GTK_TREE_MODEL (dialog->macros_store), &iter,
		0, &pattern,
		1, &command,
		-1);

	pattern_list = g_slist_prepend (pattern_list,
					gconf_value_new_from_string (GCONF_VALUE_STRING, pattern, NULL));
	command_list = g_slist_prepend (command_list,
					gconf_value_new_from_string (GCONF_VALUE_STRING, command, NULL));
    } while (gtk_tree_model_iter_next (GTK_TREE_MODEL (dialog->macros_store), &iter));

    pattern_list = g_slist_reverse (pattern_list);
    command_list = g_slist_reverse (command_list);

    gconf_value_set_list_nocopy (patterns, pattern_list); pattern_list = NULL;
    gconf_value_set_list_nocopy (commands, command_list); command_list = NULL;
    
    client = gconf_client_get_default ();
    gconf_client_set (client, "/apps/mini-commander/macro_patterns",
		    patterns, NULL);
    gconf_client_set (client, "/apps/mini-commander/macro_commands",
		    commands, NULL);

    gconf_value_free (patterns);
    gconf_value_free (commands);
}
Exemple #2
0
static gboolean
ibus_config_gconf_set_value (IBusConfigService      *config,
                             const gchar            *section,
                             const gchar            *name,
                             const GValue           *value,
                             IBusError             **error)
{
    gchar *key;
    GConfValue *gv;
    GError *gerror = NULL;

    gv = _to_gconf_value (value);

    key = g_strdup_printf (GCONF_PREFIX"/%s/%s", section, name);

    gconf_client_set (((IBusConfigGConf *)config)->client, key, gv, &gerror);
    g_free (key);
    gconf_value_free (gv);

    if (gerror != NULL) {
        if (error) {
            *error = ibus_error_new_from_text (DBUS_ERROR_FAILED, gerror->message);
            g_error_free (gerror);
        }
        return FALSE;
    }

    return TRUE;
}
Exemple #3
0
static gboolean
gconf_settings_backend_write (GSettingsBackend *backend,
                              const gchar      *key,
                              GVariant         *value,
                              gpointer          origin_tag)
{
  GConfSettingsBackend *gconf = GCONF_SETTINGS_BACKEND (backend);
  GConfValue           *gconf_value;
  GError               *error;

  g_variant_ref_sink (value);
  gconf_value = gconf_settings_backend_gvariant_to_gconf_value (value);
  g_variant_unref (value);
  if (gconf_value == NULL)
    return FALSE;

  error = NULL;
  gconf_client_set (gconf->priv->client, key, gconf_value, &error);
  gconf_value_free (gconf_value);

  if (error != NULL)
    {
      g_error_free (error);
      return FALSE;
    }

  g_settings_backend_changed (backend, key, origin_tag);

  g_hash_table_replace (gconf->priv->ignore_notifications,
                        g_strdup (key), GINT_TO_POINTER (1));

  return TRUE;
}
Exemple #4
0
int
config_write (const GConfValueType data_type, const char *key,
	      const gpointer data_value)
{
  GConfValue *temp_value;

  config_open_close (CONFIG_OP_OPEN);

  temp_value = gconf_value_new (data_type);
  switch (data_type)
    {
    case GCONF_VALUE_STRING:
	gconf_value_set_string (temp_value, (char *) data_value);
	break;
    case GCONF_VALUE_INT:
	gconf_value_set_int (temp_value, (gint) data_value);
	break;
    case GCONF_VALUE_BOOL:
	gconf_value_set_bool (temp_value, (gboolean) data_value);
	break;
    case GCONF_VALUE_FLOAT:
    case GCONF_VALUE_SCHEMA:
    case GCONF_VALUE_LIST:
    case GCONF_VALUE_PAIR:
    case GCONF_VALUE_INVALID:
      {
	error (0, 0, _("Error writing to GConf database: Key type is not supported"));
	return FALSE;
      }
    }

  gconf_client_set (conf_client, key, temp_value, NULL);

  return TRUE;
}
Exemple #5
0
/* Sets a GConf value to the contents of a GtkListStore */
static gboolean
list_store_binding_sync_store_to_pref (ListStoreBinding *binding)
{
        GtkTreeModel *tree_model;
        GtkTreeIter iter;
        GSList *list;
        int res;
        GConfValue *gconf_value;

        tree_model = GTK_TREE_MODEL (binding->list_store);

        /* Build list */
        list = NULL;
        res = gtk_tree_model_get_iter_first (tree_model, &iter);
        while (res) {
                char *string;
                GConfValue *tmp_value;

                gtk_tree_model_get (tree_model, &iter,
                                    0, &string, -1);

                tmp_value = gconf_value_new (GCONF_VALUE_STRING);
                gconf_value_set_string (tmp_value, string);

                list = g_slist_append (list, tmp_value);

                res = gtk_tree_model_iter_next (tree_model, &iter);
        }

        /* Create value */
        gconf_value = gconf_value_new (GCONF_VALUE_LIST);
        gconf_value_set_list_type (gconf_value, GCONF_VALUE_STRING);
        gconf_value_set_list_nocopy (gconf_value, list);

        /* Set */
        gconf_client_set (bridge->client, binding->key, gconf_value, NULL);

        /* Store until change notification comes in, so that we are able
         * to ignore it */
        binding->val_changes = g_slist_append (binding->val_changes,
                                               gconf_value);

        binding->sync_idle_id = 0;

        g_object_unref (binding->list_store);

        return FALSE;
}
void
eel_gconf_set_value (const char *key, GConfValue *value)
{
	GConfClient *client;
	GError *error = NULL;

	g_return_if_fail (key != NULL);

	client = eel_gconf_client_get_global ();
	g_return_if_fail (client != NULL);

	gconf_client_set (client, key, value, &error);
	
	if (eel_gconf_handle_error (&error)) {
		return;
	}
}
/**
 * panel_applet_gconf_set_value:
 * @applet: a #PanelApplet.
 * @key: a GConf key name.
 * @value: new value for @key.
 * @error: a #GError, or %NULL.
 *
 * Convenience wrapper around gconf_client_set_value() to update @key in the
 * per-instance GConf directory of @applet.
 *
 * Deprecated: 3.0: Use #GSettings to store per-instance settings.
 **/
void
panel_applet_gconf_set_value (PanelApplet  *applet,
			      const gchar  *key,
			      GConfValue   *value,
			      GError      **error)
{
	GConfClient  *client;
	gchar        *full_key;

	g_return_if_fail (PANEL_IS_APPLET (applet));

	full_key = panel_applet_gconf_get_full_key (applet, key);

	client = panel_applet_gconf_get_client ();

	gconf_client_set (client, full_key, value, error);

	g_free (full_key);
}
gboolean gconf2_backend_write_value(MkdgBackend * backend,
                                    GValue * value,
                                    const gchar * section,
                                    const gchar * key, gpointer userData)
{
    GConfClient *config = (GConfClient *) backend->config;
    GError *err = NULL;
    gchar confKey[KEY_BUFFER_SIZE];

    to_real_key(confKey, backend, section, key);
    GConfValue *confValue = gconf_value_new_g_value(value);

    gconf_client_set(config, confKey, confValue, &err);
    gconf_value_free(confValue);
    if (err != NULL) {
        mkdg_log(ERROR, "gconf2_backend_write_value(-,-,%s,%s,-): %s",
                 section, key, err->message);
        return FALSE;
    }
    return TRUE;
}
Exemple #9
0
/* Syncs an object property to GConf */
static void
prop_binding_sync_prop_to_pref (PropBinding *binding)
{
        GValue value;
        GConfValue *gconf_value;

        memset (&value, 0, sizeof (GValue));

        g_value_init (&value,
                      G_PARAM_SPEC_VALUE_TYPE (binding->prop));
        g_object_get_property (binding->object,
                               binding->prop->name,
                               &value);

        switch (value.g_type) {
        case G_TYPE_STRING:
                gconf_value = gconf_value_new (GCONF_VALUE_STRING);
                gconf_value_set_string (gconf_value,
                                        g_value_get_string (&value));
                break;
        case G_TYPE_INT:
                gconf_value = gconf_value_new (GCONF_VALUE_INT);
                gconf_value_set_int (gconf_value,
                                     g_value_get_int (&value));
                break;
        case G_TYPE_UINT:
                gconf_value = gconf_value_new (GCONF_VALUE_INT);
                gconf_value_set_int (gconf_value,
                                     g_value_get_uint (&value));
                break;
        case G_TYPE_LONG:
                gconf_value = gconf_value_new (GCONF_VALUE_INT);
                gconf_value_set_int (gconf_value,
                                     g_value_get_long (&value));
                break;
        case G_TYPE_ULONG:
                gconf_value = gconf_value_new (GCONF_VALUE_INT);
                gconf_value_set_int (gconf_value,
                                     g_value_get_ulong (&value));
                break;
        case G_TYPE_INT64:
                gconf_value = gconf_value_new (GCONF_VALUE_INT);
                gconf_value_set_int (gconf_value,
                                     g_value_get_int64 (&value));
                break;
        case G_TYPE_UINT64:
                gconf_value = gconf_value_new (GCONF_VALUE_INT);
                gconf_value_set_int (gconf_value,
                                     g_value_get_uint64 (&value));
                break;
        case G_TYPE_CHAR:
                gconf_value = gconf_value_new (GCONF_VALUE_INT);
                gconf_value_set_int (gconf_value,
                                     g_value_get_char (&value));
                break;
        case G_TYPE_UCHAR:
                gconf_value = gconf_value_new (GCONF_VALUE_INT);
                gconf_value_set_int (gconf_value,
                                     g_value_get_uchar (&value));
                break;
        case G_TYPE_ENUM:
                gconf_value = gconf_value_new (GCONF_VALUE_INT);
                gconf_value_set_int (gconf_value,
                                     g_value_get_enum (&value));
                break;
        case G_TYPE_BOOLEAN:
                gconf_value = gconf_value_new (GCONF_VALUE_BOOL);
                gconf_value_set_bool (gconf_value,
                                      g_value_get_boolean (&value));
                break;
        case G_TYPE_DOUBLE:
                gconf_value = gconf_value_new (GCONF_VALUE_FLOAT);
#ifdef HAVE_CORBA_GCONF
                /* FIXME we cast to a float explicitly as CORBA GConf
                 * uses doubles in its API, but treats them as floats
                 * when transporting them over CORBA. See #322837 */
                gconf_value_set_float (gconf_value,
                                       (float) g_value_get_double (&value));
#else
                gconf_value_set_float (gconf_value,
                                       g_value_get_double (&value));
#endif
                break;
        case G_TYPE_FLOAT:
                gconf_value = gconf_value_new (GCONF_VALUE_FLOAT);
                gconf_value_set_float (gconf_value,
                                       g_value_get_float (&value));
                break;
        default:
                if (g_type_is_a (value.g_type, G_TYPE_ENUM)) {
                        gconf_value = gconf_value_new (GCONF_VALUE_INT);
                        gconf_value_set_int (gconf_value,
                                             g_value_get_enum (&value));
                } else {
                        g_warning ("prop_binding_sync_prop_to_pref: "
                                   "Unhandled value type '%s'.\n",
                                   g_type_name (value.g_type));

                        goto done;
                }

                break;
        }

        /* Set to GConf */
        gconf_client_set (bridge->client, binding->key, gconf_value, NULL);

        /* Store until change notification comes in, so that we are able
         * to ignore it */
        binding->val_changes = g_slist_append (binding->val_changes,
                                               gconf_value);

done:
        g_value_unset (&value);
}