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 689487 - WorldClock: port to GSettings
WorldClock: port to GSettings
Status: RESOLVED FIXED
Product: gnome-clocks
Classification: Applications
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: Clocks maintainer(s)
Clocks maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2012-12-02 17:06 UTC by Giovanni Campagna
Modified: 2013-02-01 21:25 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
WorldClock: port to GSettings (3.13 KB, patch)
2012-12-02 17:07 UTC, Giovanni Campagna
none Details | Review

Description Giovanni Campagna 2012-12-02 17:06:58 UTC
GWeatherLocations are serialized as GVariants, so it becomes natural to
store them in GSettings
Comment 1 Giovanni Campagna 2012-12-02 17:07:00 UTC
Created attachment 230446 [details] [review]
WorldClock: port to GSettings
Comment 2 Paolo Borelli 2013-01-05 16:27:26 UTC
Do you think gsetting would also be a good choice to store the list of alarms? Note that here it is a more complex structure and we may need to add new attributes to each alarm in the future. Can gvariant/gsettings be used to store this kind of information in a forward compatible way?
Comment 3 Giovanni Campagna 2013-01-05 16:30:56 UTC
(In reply to comment #2)
> Do you think gsetting would also be a good choice to store the list of alarms?
> Note that here it is a more complex structure and we may need to add new
> attributes to each alarm in the future. Can gvariant/gsettings be used to store
> this kind of information in a forward compatible way?

GVariant is very flexible in this regards. You can use a a{sv} and store what's basically JSON, or you can store (uv) and have a version number coupled with a nested variant whose type can change freely.
Comment 4 Paolo Borelli 2013-01-20 09:50:04 UTC
So we could have two settings:

 - world-clocks
 - alarms

each one of them an array of string-variant arrays, that is a(a{sv}) if I get the notation right.

For world clocks right now each item would be "location" -> variant returned by gweather. But this would leave us with the possibility to also add other attributes to the setting, like the picture to show.

For alarms each item would contain "time", "label", "repeat", etc
Comment 5 Giovanni Campagna 2013-01-20 12:40:40 UTC
Yes, that's a possibility.

The other way, which is more flexible because it gives you better change notifications, is to make alarms "ao", then store in there a dconf path, referring to a relocatable schema (one with Gio.Settings(schema=, path=)). Then properties of the alarm can be accessed individually, and can be watched with changed::property-name.

The downside of this other way (besides the book-keeping around the ao key) is that dconf-editor fails to associate schemas this way, so you don't see the key until it is changed. The gsettings command line client works fine, though.
Comment 6 Paolo Borelli 2013-01-20 14:33:30 UTC
Thanks for the interesting suggestion Giovanni.

I think we can stick to the simpler plan for now though
Comment 7 Allison Karlitskaya (desrt) 2013-01-20 15:37:20 UTC
(In reply to comment #4)
> each one of them an array of string-variant arrays, that is a(a{sv}) if I get
> the notation right.

aa{sv} rather


> For world clocks right now each item would be "location" -> variant returned by
> gweather. But this would leave us with the possibility to also add other
> attributes to the setting, like the picture to show.
> 
> For alarms each item would contain "time", "label", "repeat", etc

This is starting to feel only slightly better than how evolution used to store blobs of XML inside of gconf...
Comment 8 Paolo Borelli 2013-02-01 21:25:30 UTC
I have been pondering this, since storing such "composite" values in gsettings is a bit ugly (that's why I asked Ryan's opinion in the first place), but in the end I decided to go ahead and do it because of the following reasons:

 - this allows us to store serialized GWeather location, which fixes https://bugzilla.gnome.org/show_bug.cgi?id=685433

 - it drops dependency on json

 - it drops quite a bit of code (though I had to do some gymnastic to get pygobject and gweather to cooperate)

 - it is better to do it now while clocks is still a "prototype" (user data gets lost, but I do not want to carry json compat forever)

 - if something better comes along (e.g. gsettings list support, migrating should be easier)


http://git.gnome.org/browse/gnome-clocks/commit/?id=6dba72ecaac2254d7bc214825094bffc75a71ba4


testing and review are much appreciated