After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 668088 - Possibly use NSUserDefaultsController in nextstep gsettings backend
Possibly use NSUserDefaultsController in nextstep gsettings backend
Status: RESOLVED OBSOLETE
Product: glib
Classification: Platform
Component: gsettings
unspecified
Other Mac OS
: Normal normal
: ---
Assigned To: Allison Karlitskaya (desrt)
gtkdev
Depends on:
Blocks:
 
 
Reported: 2012-01-17 12:06 UTC by jessevdk@gmail.com
Modified: 2018-05-24 13:43 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description jessevdk@gmail.com 2012-01-17 12:06:35 UTC
I looked a bit at the nextstep gsettings backend and it appeared that change notification would not work (empty subscribe/unsubscribe). Would it be possible to implement this using NSUserDefaultsController (which seems to support change notification).
Comment 1 Michael Natterer 2013-10-29 09:11:08 UTC
I am no expert here but i would *guess* that NSUserDefaultsController is
an objc wrapper around some plain C core foundation api. In the quartz
backend for example we use the following to get notified ok keymap changes:

CFNotificationCenterAddObserver
   (CFNotificationCenterGetDistributedCenter (),
    NULL,
    input_sources_changed_notification,
    CFSTR ("AppleSelectedInputSourcesChangedNotification"),
    NULL,
    CFNotificationSuspensionBehaviorDeliverImmediately);
Comment 2 jessevdk@gmail.com 2013-10-29 09:38:01 UTC
I'm not sure either, but the docs says that it's a cocoa bindings thingie, i.e. key/value observer. Some informative references:

https://developer.apple.com/library/mac/documentation/cocoa/Conceptual/CocoaBindings/Concepts/NSUserDefaultsController.html#//apple_ref/doc/uid/TP40001092-BCICADHC

http://stackoverflow.com/questions/1141388/cocoa-notification-on-nsuserdefaults-value-change
Comment 3 John Ralls 2013-10-29 14:10:28 UTC
You want to use https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSUserDefaults_Class/Reference/Reference.html#//apple_ref/c/data/NSUserDefaultsDidChangeNotification

The corresponding CF API is https://developer.apple.com/library/mac/documentation/CoreFoundation/Reference/CFPreferencesUtils/Reference/reference.html#//apple_ref/doc/uid/20001450 but it doesn't appear to support notification.


NSUserDefaultsController is for binding a Cocoa/UIKit widget to a particular defaults item. While it might be interesting to connect it to a Gtk Widget somehow, it's too high-level for GSettings.
Comment 4 jessevdk@gmail.com 2013-10-29 16:02:09 UTC
As I understood it, you don't get information on which key changed with NSUserDefaultsDidChangeNotification, only that something has changed, right? You can still observe keys using addObserver on the NSUserDefaults.values though.
Comment 5 jessevdk@gmail.com 2013-10-29 16:03:23 UTC
As I understood it, you don't get information on which key changed with NSUserDefaultsDidChangeNotification, only that something has changed, right? You can still observe keys using addObserver on the NSUserDefaults.values though.
Comment 6 John Ralls 2013-10-29 20:54:44 UTC
Yes, I think that's correct. You'd have to either have an observer (probably what NSUserDefaultsController abstracts) or iterate over the keys you're interested in.
Comment 7 jessevdk@gmail.com 2013-10-31 12:31:03 UTC
I took a stab at this, but while implementing I'm not sure anymore it's actually necessary at all. The only reason to implement subscribe/unsubscribe seems to be to be able to observe external changes. However, external changes are very uncommon on OS X, especially since settings are per app. The only practical limitation of not having subscribe seems to be if an application would instantiate several backends. This however is very uncommon too as far as I know.
Comment 8 GNOME Infrastructure Team 2018-05-24 13:43:14 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to GNOME's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/glib/issues/505.