0

Im doing some C coding but im unable to store g_settings permanently!

#include <stdlib.h>
#include <locale.h>


#include <gio/gio.h>
int main(int argc, char **argv)
{
  GSettings *settings;
  g_type_init();
  settings = g_settings_new ("org.nemo.desktop");
  printf("%s\n", g_settings_get_string(settings, "font"));
  g_settings_set (settings, "font", "s", "Arial");
  if (g_settings_get_has_unapplied (settings)) printf("X");
  printf("%s\n", g_settings_get_string(settings, "font"));
  return 0;
}

Trying on Linux Mint 13 Cinnamon (paths,etc. are correct).

Ondřej Kolín
  • 1,348
  • 1
  • 11
  • 15

2 Answers2

1

This isn’t a minimal working example. Could you provide the schema file you’re using?

Compiling your code with gcc `pkg-config --cflags --libs gio-2.0` -o temp temp.c and using the following schema:

<?xml version="1.0" encoding="UTF-8"?>
<schemalist>
    <schema id="org.nemo.desktop" path="/org/nemo/desktop/">
        <key name="font" type="s">
            <default>''</default>
            <summary>Summary</summary>
            <description>Description.</description>
        </key>
    </schema>
</schemalist>

which I installed with:

sudo cp org.nemo.desktop.gschema.xml /usr/share/glib-2.0/schemas/
sudo glib-compile-schemas /usr/share/glib-2.0/schemas/

I get the following output, which seems to be correct:

Arial
Philip Withnall
  • 5,293
  • 14
  • 28
  • Output is correct, but the change is not permanently ... Try if it changes your permanently ... (or with org.gnome.background) (picture-uri) ... Output is correct, but problem is, that it doesnt affect the background (which gets affected by python script) – Ondřej Kolín Nov 05 '13 at 09:57
  • `code` '' Desktop font The font _description used for the icons on the desktop. `code` This is that schema... As said before, it is working only temporary – Ondřej Kolín Nov 05 '13 at 10:25
1

Oh, I misread your code at first... I believe you should call g_settings_sync () if you want to ensure your changes are written to disk. Apparently if you run without a mainloop (like in your example case) this is really required to get things on disk at all.

So, just to be clear: a normal application with a glib mainloop will not need (and shouldn't really use) a sync-call.

Jussi Kukkonen
  • 13,857
  • 1
  • 37
  • 54