Re: Gio::Settings get notified about changes



You can't use Glib::ObjectBase::connect_property_changed(). Your text-scaling-factor is s settings key, it's not a property in the GObject type system. You must use Gio::Settings::signal_changed(). There is an example at https://git.gnome.org/browse/glibmm/tree/examples/settings.

The signal_changed() overload that takes a key name as a parameter is brand new and so far exists only in the latest unstable version glibmm 2.45.2. If you use an earlier version, you must use signal_changed() without a parameter, and test the key parameter in the signal handler to see which value has changed.

Kjell

Den 2015-06-23 23:41, Kasper Peeters skrev:
I am trying to use Gio::Settings to get notified about changes to a
particular property value, doing something like

    class X {
       public:
          X();  
       private:
          Glib::RefPtr<Gio::Settings> settings;
          void                        handler();
    }

    X::X()
       {
       settings =
          Gio::Settings::create("org.cinnamon.desktop.interface");
settings->connect_property_changed("text-scaling-factor",
                               sigc::mem_fun(*this, &X::handler));
       }

    void X::handler()
       {
       // do something with changed setting.
       }

However, the X::handler() is never called when I change the setting.

I did check that if I monitor the setting with

   gsettings monitor org.cinnamon.desktop.interface text-scaling-factor

and make a change using e.g. dconf-editor I can see that the value
changes.

Any ideas on what I'm doing wrong? Or is there someone with a simple
Gio::Settings example able to help me out? (Would, incidentally, make a
good addition to the gtkmm book.) Thanks!

Cheers,
Kasper




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