Re: Writing to dconf using the Gio binding does not work



On Tue, Apr 3, 2012 at 8:27 AM, Lukas Knuth <mr luke 187 googlemail com> wrote:
> 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 = new 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.

Does calling settings.sync(); after the set_string() call work better?

http://developer.gnome.org/gio/2.32/GSettings.html#g-settings-sync

-- 
Johan Dahlin


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