-1

I'm trying to write an application in Vala, and have looked up in the Vala documentation how to work with GLib.Settings (dconf). Getting and setting values works. However, when I try to detect changes to the schema or a specific key using the changed event, the event simply does not fire.

Example: http://pastebin.com/dGuP9GyX

The changed event will never fire for some reason. The bind () method does not work either (only in one direction).

Forget the example below... It actually does work when you add \n, for some reason...

Here's a small example to illustrate. Compile with the following command; valac --pkg gio-2.0 --pkg gtk+-3.0 main.vala

int main (string[] args)
{
    Gtk.init (ref args);

    GLib.Settings settings = new GLib.Settings ("org.pantheon.terminal.settings");
    settings.changed["allow-bold"].connect (somethingChanged);

    Gtk.main ();

    return 0;
}

void somethingChanged ()
{
    stdout.printf ("Something changed");
}

When running this small example, in my case anyway, the program will just keep running. No matter how many settings I change in the specified dconf schema, it will not output anything.

Hoping someone can help me get past this barrier.

robin@RobinJ:~$ valac --version
Vala 0.20.1
RobinJ
  • 5,022
  • 7
  • 32
  • 61

1 Answers1

2

The issue here isn't Vala or Glib, but how standard out works. A printf will print nothing to the screen unless there's a newline character in there.

Just change the printf line to:

stdout.printf ("Something changed\n");

And you should be good to go!

MrEricSir
  • 8,044
  • 4
  • 30
  • 35
  • Someone on IRC found that out, too. So basically I'm stumped now. The example works, while my main application, which does things the same way, still doesn't >. – RobinJ Aug 13 '13 at 19:15
  • 1
    Since you have a new question, please post it separately. – MrEricSir Aug 13 '13 at 21:01
  • Same question, man. Only it would appear my initial example was not ideal. – RobinJ Aug 14 '13 at 06:31