GNOME Bugzilla – Bug 633983
'picture-filename' should be "ay", not "s"
Last modified: 2011-03-09 14:08:13 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.
I think it would be better instead to store it as an URI which are of type "s".
*** Bug 644019 has been marked as a duplicate of this bug. ***
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) ?
I'd think changing to URI is better/simpler.
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.
Created attachment 182956 [details] [review] gnome-bg: Use picture-uri GSettings key
Created attachment 182959 [details] [review] background: Use new picture-uri GSettings key
+ 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.
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 on attachment 182954 [details] [review] schemas: Use picture-uri instead of picture-filename Broken quoting.
Created attachment 182961 [details] [review] gnome-bg: Use picture-uri GSettings key
Comment on attachment 182956 [details] [review] gnome-bg: Use picture-uri GSettings key Fixed chpe's comments in newer patch
+ <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 :)
(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?
(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 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 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
Attachment 182961 [details] pushed as 7f3e3d5 - gnome-bg: Use picture-uri GSettings key