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 633983 - 'picture-filename' should be "ay", not "s"
'picture-filename' should be "ay", not "s"
Status: RESOLVED FIXED
Product: gsettings-desktop-schemas
Classification: Core
Component: general
git master
Other Linux
: Normal normal
: ---
Assigned To: gsettings-desktop-schemas-maint
gsettings-desktop-schemas-maint
: 644019 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2010-11-04 12:31 UTC by Tomas Bzatek
Modified: 2011-03-09 14:08 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
schemas: Use picture-uri instead of picture-filename (2.25 KB, patch)
2011-03-09 13:10 UTC, Bastien Nocera
none Details | Review
gnome-bg: Use picture-uri GSettings key (2.48 KB, patch)
2011-03-09 13:28 UTC, Bastien Nocera
none Details | Review
background: Use new picture-uri GSettings key (3.32 KB, patch)
2011-03-09 13:33 UTC, Bastien Nocera
committed Details | Review
schemas: Use picture-uri instead of picture-filename (2.25 KB, patch)
2011-03-09 13:40 UTC, Bastien Nocera
committed Details | Review
gnome-bg: Use picture-uri GSettings key (2.50 KB, patch)
2011-03-09 13:43 UTC, Bastien Nocera
committed Details | Review

Description Tomas Bzatek 2010-11-04 12:31:47 UTC
(In reply to bug 626021 comment #14)
> Also, I think all the UTF-8 checks should go away and the setting itself (in
> gsettings-desktop-schemas) should become an array of bytes instead of a string,
> as it stores a filename (see
> http://mail.gnome.org/archives/desktop-devel-list/2010-July/msg00047.html for
> previous discussions).

The key "picture-filename" in org.gnome.desktop.background should be type "ay" instead of "s". The only fallout to make this happen is the way default value is specified. For array types, we cannot use simple <default>'stripes.jpg'</default> syntax and breaking down string to characters is not an option. Moreover this particular schema file is meant to be processed, replacing '@datadir@' with real path.

So we need to find a way how to specify 
> <default>'@datadir@/themes/Adwaita/backgrounds/stripes.jpg'</default>
as "ay" byte string.
Comment 1 Christian Persch 2011-02-04 21:40:11 UTC
I think it would be better instead to store it as an URI which are of type "s".
Comment 2 Bastien Nocera 2011-03-06 14:29:42 UTC
*** Bug 644019 has been marked as a duplicate of this bug. ***
Comment 3 Christian Persch 2011-03-06 14:40:24 UTC
Oops, sorry about the dup! :/

So, do we use "ay" here, or just change the meaning of the key from 'filename' to 'URI' (URIs are UTF-8) ?
Comment 4 Vincent Untz 2011-03-06 18:07:31 UTC
I'd think changing to URI is better/simpler.
Comment 5 Bastien Nocera 2011-03-09 13:10:08 UTC
Created attachment 182954 [details] [review]
schemas: Use picture-uri instead of picture-filename

picture-filename was of type string, which can only be used for
UTF-8 strings, and some filenames are not, dependending on the
locale used.

Instead we switch to using a URI, and picture-uri as the key name,
as URIs are UTF-8 compliant strings.
Comment 6 Bastien Nocera 2011-03-09 13:28:48 UTC
Created attachment 182956 [details] [review]
gnome-bg: Use picture-uri GSettings key
Comment 7 Bastien Nocera 2011-03-09 13:33:39 UTC
Created attachment 182959 [details] [review]
background: Use new picture-uri GSettings key
Comment 8 Christian Persch 2011-03-09 13:36:42 UTC
+	tmp = g_settings_get_string (settings, BG_KEY_PICTURE_URI);
+	if (tmp != NULL && *tmp != '\0') {

tmp is always != NULL here.

+	if (bg->filename != NULL)
+		uri = g_filename_to_uri (bg->filename, NULL, NULL);
+	else
+		uri = NULL;
 	g_settings_set_boolean (settings, BG_KEY_DRAW_BACKGROUND, bg->is_enabled);
-	g_settings_set_string (settings, BG_KEY_PICTURE_FILENAME, bg->filename);
+	g_settings_set_string (settings, BG_KEY_PICTURE_URI, uri);

g_settings_set_string doesn't allow NULL.
Comment 9 Bastien Nocera 2011-03-09 13:40:11 UTC
Created attachment 182960 [details] [review]
schemas: Use picture-uri instead of picture-filename

picture-filename was of type string, which can only be used for
UTF-8 strings, and some filenames are not, dependending on the
locale used.

Instead we switch to using a URI, and picture-uri as the key name,
as URIs are UTF-8 compliant strings.
Comment 10 Bastien Nocera 2011-03-09 13:40:44 UTC
Comment on attachment 182954 [details] [review]
schemas: Use picture-uri instead of picture-filename

Broken quoting.
Comment 11 Bastien Nocera 2011-03-09 13:43:10 UTC
Created attachment 182961 [details] [review]
gnome-bg: Use picture-uri GSettings key
Comment 12 Bastien Nocera 2011-03-09 13:43:41 UTC
Comment on attachment 182956 [details] [review]
gnome-bg: Use picture-uri GSettings key

Fixed chpe's comments in newer patch
Comment 13 Christian Persch 2011-03-09 13:49:25 UTC
+    <key name="picture-uri" type="s">
+      <default>'file://@datadir@/themes/Adwaita/backgrounds/stripes.jpg'</default>

If someone sets destdir to some non-UTF-8 path, this will break. I guess they're on their own then :)
Comment 14 Tomas Bzatek 2011-03-09 13:56:38 UTC
(In reply to comment #13)
> +    <key name="picture-uri" type="s">
> +     
> <default>'file://@datadir@/themes/Adwaita/backgrounds/stripes.jpg'</default>
> 
> If someone sets destdir to some non-UTF-8 path, this will break. I guess
> they're on their own then :)

This is coming from automake rules. A single unescaped character would make trouble, this includes even a space. Any hint for a simple shell/sed/awk command escaping URIs?
Comment 15 Bastien Nocera 2011-03-09 14:04:18 UTC
(In reply to comment #13)
> +    <key name="picture-uri" type="s">
> +     
> <default>'file://@datadir@/themes/Adwaita/backgrounds/stripes.jpg'</default>
> 
> If someone sets destdir to some non-UTF-8 path, this will break. I guess
> they're on their own then :)

gschema-validate will barf before installation when you do that.

(In reply to comment #14)
> (In reply to comment #13)
> > +    <key name="picture-uri" type="s">
> > +     
> > <default>'file://@datadir@/themes/Adwaita/backgrounds/stripes.jpg'</default>
> > 
> > If someone sets destdir to some non-UTF-8 path, this will break. I guess
> > they're on their own then :)
> 
> This is coming from automake rules. A single unescaped character would make
> trouble, this includes even a space. Any hint for a simple shell/sed/awk
> command escaping URIs?

Feel free to file a separate bug and handle that. I'm really not interested in spending time on supporting something like that.
Comment 16 Bastien Nocera 2011-03-09 14:07:12 UTC
Comment on attachment 182960 [details] [review]
schemas: Use picture-uri instead of picture-filename

Attachment 182960 [details] pushed as 70eb510 - schemas: Use picture-uri instead of picture-filename
Comment 17 Bastien Nocera 2011-03-09 14:07:53 UTC
Comment on attachment 182959 [details] [review]
background: Use new picture-uri GSettings key

Attachment 182959 [details] pushed as 73f9bff - background: Use new picture-uri GSettings key
Comment 18 Bastien Nocera 2011-03-09 14:08:11 UTC
Attachment 182961 [details] pushed as 7f3e3d5 - gnome-bg: Use picture-uri GSettings key