From 27bc3a482d85cdfa0aeb489488f6495874b2ccd1 Mon Sep 17 00:00:00 2001 From: Ryo Nakano Date: Sat, 27 Jan 2024 12:57:15 +0900 Subject: [PATCH] DesktopFileOperator: Fix a regression that unlocalized Comment key no longer loaded (#120) --- src/Backend/DesktopFileOperator.vala | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Backend/DesktopFileOperator.vala b/src/Backend/DesktopFileOperator.vala index 55ab8bce..9b1d92df 100644 --- a/src/Backend/DesktopFileOperator.vala +++ b/src/Backend/DesktopFileOperator.vala @@ -193,8 +193,6 @@ public class DesktopFileOperator : GLib.Object { * Load the content of the desktop file at `path` and construct new DesktopFile through KeyFile object. */ public DesktopFile? load_from_file (string path) { - string locale; - string file_name = ""; string app_name = ""; string comment = ""; @@ -214,11 +212,13 @@ public class DesktopFileOperator : GLib.Object { // Get the filename without the .desktop suffix file_name = basename.slice (0, basename.length - DESKTOP_SUFFIX.length); - locale = keyfile.get_locale_for_key (KeyFileDesktop.GROUP, KeyFileDesktop.KEY_NAME, preferred_language); + string locale = keyfile.get_locale_for_key (KeyFileDesktop.GROUP, KeyFileDesktop.KEY_NAME, preferred_language); app_name = keyfile.get_locale_string (KeyFileDesktop.GROUP, KeyFileDesktop.KEY_NAME, locale); locale = keyfile.get_locale_for_key (KeyFileDesktop.GROUP, KeyFileDesktop.KEY_COMMENT, preferred_language); - if (locale != null) { + bool has_key = keyfile.has_key (KeyFileDesktop.GROUP, KeyFileDesktop.KEY_COMMENT); + // Either has a localized or unlocalized Comment key + if (locale != null || has_key) { comment = keyfile.get_locale_string (KeyFileDesktop.GROUP, KeyFileDesktop.KEY_COMMENT, locale); }