From e8a9581535be2b6691ef32228245145e780628b4 Mon Sep 17 00:00:00 2001 From: Thomas Lange Date: Thu, 31 May 2018 22:08:35 +0200 Subject: [PATCH 1/2] Allow language-specific keys before language-neutral ones (Bug #13979) The order of lines in a .desktop file should be irrelevant. The two examples below should give the same result. [Desktop Entry] Name[en]=Foo Name=Bar [Desktop Entry] Name=Bar Name[en]=Foo However all localized entries were ignored for example one. Fix this by using the approach mentioned in the comment: Set the language-neutral value to the first language-specific value and overwrite it later. --- libxfce4util/xfce-rc-simple.c | 25 ++----------------------- 1 file changed, 2 insertions(+), 23 deletions(-) diff --git a/libxfce4util/xfce-rc-simple.c b/libxfce4util/xfce-rc-simple.c index af98987..fbc4db3 100644 --- a/libxfce4util/xfce-rc-simple.c +++ b/libxfce4util/xfce-rc-simple.c @@ -184,28 +184,6 @@ simple_add_entry (XfceRcSimple *simple, if (G_UNLIKELY (entry == NULL)) { - if (locale != NULL) { - /* this point is reached when there is a .desktop file that lists a language specific key for something that had no language-neutral key yet. - Example: - b.desktop - - [Desktop Entry] - Version=1.0 - Name=xyz - GenericName[de_AT]=Test - - here GenericName[de_AT] will end up here. - The previous way with g_return_val_if_fail would call an assertion failure and terminate the _whole application_(!!). - - Saner ways to react are either just ignoring GenericName[de_AT] altogether, or, alternatively, just set the normal GenericName - to Test too (i.e. imply GenericName=Test). - - For now, we are just ignoring the line altogether. But we aren't assert-failing anymore and the apps dont crash anymore. - */ - return NULL; - } - /* why you annoying macro, will you stop borking libxfceutil? thanks. DO NOT DO THAT: g_return_val_if_fail (locale == NULL, NULL); */ - entry = g_slice_new (Entry); entry->key = g_string_chunk_insert (simple->string_chunk, key); entry->value = g_string_chunk_insert (simple->string_chunk, value); @@ -225,7 +203,8 @@ simple_add_entry (XfceRcSimple *simple, simple->group->elast = entry; } - return entry; + if (locale == NULL) + return entry; } if (G_UNLIKELY (locale == NULL)) -- 2.17.1