Skip to content
  • Will Thompson's avatar
    gdesktopappinfo: add get_string_list() function · 5ca9eca6
    Will Thompson authored and Philip Withnall's avatar Philip Withnall committed
    The X-Flatpak-RenamedFrom key is used in .desktop files to identify past
    names for the desktop file. It is defined to be a list of strings.
    However, there was previously no correct way to retrieve a list of
    strings from the GKeyFile wrapped by GDesktopAppInfo, short of
    re-parsing the file with GKeyFile.
    
    Note that doing something like:
    
        g_strsplit (g_desktop_app_info_get_string (...), ";", -1)
    
    is not correct: the raw value "a\;b;" represents the one-element list
    ["a;b"], but g_key_file_get_string() rejects the sequence "\;", and so
    g_desktop_app_info_get_string() returns NULL in this case. (Of course, a
    .desktop file with a semicolon in its name is a pathological case.)
    
    Add g_desktop_app_info_get_string_list(), a trivial wrapper around
    g_key_file_get_string_list(), similar to g_desktop_app_info_get_string()
    and co.
    
    The change from g_key_file_free() to g_key_file_unref() in the test is
    needed because g_key_file_free() clears the contents of the keyfile.
    This is fine for all the fields which are eagerly loaded and copied into
    GDesktopAppInfo, but not when we want to access arbitrary stuff from the
    keyfile.
    5ca9eca6