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 709116 - Settings: add a Gio.Settings wrapper.
Settings: add a Gio.Settings wrapper.
Status: RESOLVED FIXED
Product: gnome-maps
Classification: Applications
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: gnome-maps-maint
gnome-maps-maint
Depends on:
Blocks:
 
 
Reported: 2013-09-30 16:57 UTC by Mattias Bengtsson
Modified: 2013-11-01 22:42 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Settings: add a Gio.Settings wrapper. (9.47 KB, patch)
2013-09-30 16:58 UTC, Mattias Bengtsson
none Details | Review
Settings: add a Gio.Settings wrapper. (9.25 KB, patch)
2013-09-30 17:04 UTC, Mattias Bengtsson
needs-work Details | Review
Settings: add a Gio.Settings wrapper. (9.17 KB, patch)
2013-10-26 03:39 UTC, Mattias Bengtsson
accepted-commit_now Details | Review
Settings: add a Gio.Settings wrapper. (9.15 KB, patch)
2013-11-01 22:35 UTC, Mattias Bengtsson
committed Details | Review

Description Mattias Bengtsson 2013-09-30 16:57:59 UTC
This adds a GSettings helper class that should make it more fun to work
with settings. 
Ryan asked me to try to get this into gjs, but I feel it's good to start
here first.
Comment 1 Mattias Bengtsson 2013-09-30 16:58:02 UTC
Created attachment 256115 [details] [review]
Settings: add a Gio.Settings wrapper.

The Settings class wraps a Gio.Settings object, but takes care of all
GVariant (un)boxing. This should make working with settings a much
less verbose experience.
Comment 2 Mattias Bengtsson 2013-09-30 17:04:38 UTC
Created attachment 256117 [details] [review]
Settings: add a Gio.Settings wrapper.

The Settings class wraps a Gio.Settings object, but takes care of all
GVariant (un)boxing. This should make working with settings a much
less verbose experience.
Comment 3 Zeeshan Ali 2013-10-02 14:23:41 UTC
Review of attachment 256117 [details] [review]:

Looks good apart from these nitpicks.

::: src/settings.js
@@ +30,3 @@
+    Extends: Gio.Settings,
+
+    _types: {},

i'd name it '_key_types' or even '_key_types_dict'

@@ +40,3 @@
+                                   .get_type()
+                                   .dup_string()
+                                   .slice(1);

woo! such a long chain of calls. Can we break it with variables please.

@@ +45,3 @@
+
+    get: function(name) {
+        return this.get_value(name).deep_unpack();

is 'deep_unpack' something very new? I can't find it in GVariant docs on F20.

@@ +46,3 @@
+    get: function(name) {
+        return this.get_value(name).deep_unpack();
+    },

newline btw function bodies.
Comment 4 Mattias Bengtsson 2013-10-19 15:39:39 UTC
Review of attachment 256117 [details] [review]:

Sorry for the late reply. :)

::: src/settings.js
@@ +30,3 @@
+    Extends: Gio.Settings,
+
+    _types: {},

"keys" in list_keys refers to the names of the settings. So if we want a more descriptive name I think it would be _setting_types but that seems redundant given that we are already in a Settings class. 
Would a small comment like this suffice:

// The GVariant type formats of the settings
_types: {}

or just _typeFormats?

@@ +40,3 @@
+                                   .get_type()
+                                   .dup_string()
+                                   .slice(1);

Yeah, and I should add a comment on what I'm actually doing and why. The way to get the type of a setting is a bit uncomfortable, but well documented. So a link to the relevant documentation also I guess. Will add that and do 1 or 2 variable breakups (even though I much prefer the js chaining style).

@@ +45,3 @@
+
+    get: function(name) {
+        return this.get_value(name).deep_unpack();

It's in GJS, they have some custom monkey patches there, deep_unpack is one of them. Jasper is (understandably) not too keen on adding more, for the reason of documentation.

@@ +46,3 @@
+    get: function(name) {
+        return this.get_value(name).deep_unpack();
+    },

True!
Comment 5 Mattias Bengtsson 2013-10-26 03:39:19 UTC
Created attachment 258154 [details] [review]
Settings: add a Gio.Settings wrapper.

The Settings class wraps a Gio.Settings object, but takes care of all
GVariant (un)boxing. This should make working with settings a much
less verbose experience.

This version incorporates stuff from the discussion above, plus I found
a shorter way to list the types.
Comment 6 Zeeshan Ali 2013-11-01 16:44:57 UTC
Review of attachment 258154 [details] [review]:

ack /w that changed.

::: src/settings.js
@@ +31,3 @@
+
+    // The GVariant type formats of the settings
+    _typeFormats: {},

Formats? I don't think anyone calls it that. Its just types. Since we are mapping keys of types, just key_types is good as I suggested before. or call it 'types_hash' or 'types_map'.
Comment 7 Mattias Bengtsson 2013-11-01 22:35:39 UTC
Created attachment 258789 [details] [review]
Settings: add a Gio.Settings wrapper.

The Settings class wraps a Gio.Settings object, but takes care of all
GVariant (un)boxing. This should make working with settings a much
less verbose experience.
Comment 8 Mattias Bengtsson 2013-11-01 22:42:07 UTC
Review of attachment 258789 [details] [review]:

COmmited.