Writing to dconf using the Gio binding does not work



I'm currently trying to write an application which should change the background-image. For this purpose, I set the "org.gnome.desktop.background.picture-uri"-key, as suggested here [1]

To do so, I'm using the Gio.Settings-class[2] from the Gio-library binding as follows:

var gio = imports.gi.Gio;

// Get the GSettings-object for the background-schema:
var background = "" gio.Settings({schema: "org.gnome.desktop.background"});

// Read the current Background-Image:
print( "Current Background-Image: "+background.get_string("picture-uri") );

if (background.is_writable("picture-uri")){
    // Set a new Background-Image (should show up immediately):
    if (background.set_string("picture-uri", "file:///path/to/some/pic.jpg")){
        print("Success!");
    }
    else throw "Couldn't set the key!";
} else throw "The key is not writable";

Reading the value does work as expected, the is_writable()-method returns true and the set_string()-method also returns true (indicating that the writing-process was successful). But the writing-operation does not change the value of the key.

I have checked that I'm not in "delay-apply" mode (hence I don't need to call apply() ) and the key has a GVariantType of string, so the set_string()-method should work.

Using the normal gsettings command-line tool (as explained in [1]) works just fine.

I'm not sure what I'm not seeing here.

[1] - http://lists.fedoraproject.org/pipermail/users/2011-August/402603.html
[2] - http://www.roojs.com/seed/gir-1.2-gtk-3.0/gjs/Gio.Settings.html


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]