diff options
author | zhengqiang130 <qzheng@suse.com> | 2018-10-29 17:11:32 +0800 |
---|---|---|
committer | Ray Strode <rstrode@redhat.com> | 2019-01-07 14:10:01 -0500 |
commit | c98ea6a4dc807aaf261eab6025ba3c3e5662d51c (patch) | |
tree | 176e852ba0ad2ac3807b5d0fa7ed9e678335e06c /libgdm | |
parent | 4021902ddca604bc13e76df3c11743995811959b (diff) | |
download | gdm-c98ea6a4dc807aaf261eab6025ba3c3e5662d51c.tar.gz |
libgdm: filter out sessions with duplicate names
Right now if two session files have the same translated name, the login
screen will show both of them. There's no way the user can know which
session does which, so that's not a great user experience. Furthermore,
in the face of symlinks, both sessions truely could be identical.
This commit filters out the duplicates, so only one shows in the list.
Closes https://gitlab.gnome.org/GNOME/gdm/issues/437
Diffstat (limited to 'libgdm')
-rw-r--r-- | libgdm/gdm-sessions.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/libgdm/gdm-sessions.c b/libgdm/gdm-sessions.c index 7badafe1..afbc5c09 100644 --- a/libgdm/gdm-sessions.c +++ b/libgdm/gdm-sessions.c @@ -111,6 +111,14 @@ key_file_is_relevant (GKeyFile *key_file) return TRUE; } +static gboolean +find_session_with_same_name (const char *id, + GdmSessionFile *session, + const char *translated_name) +{ + return g_strcmp0 (session->translated_name, translated_name) == 0; +} + static void load_session_file (const char *id, const char *path) @@ -118,7 +126,7 @@ load_session_file (const char *id, GKeyFile *key_file; GError *error; gboolean res; - GdmSessionFile *session; + GdmSessionFile *session, *session_with_same_name; key_file = g_key_file_new (); @@ -154,6 +162,13 @@ load_session_file (const char *id, session->translated_name = g_key_file_get_locale_string (key_file, G_KEY_FILE_DESKTOP_GROUP, "Name", NULL, NULL); session->translated_comment = g_key_file_get_locale_string (key_file, G_KEY_FILE_DESKTOP_GROUP, "Comment", NULL, NULL); + session_with_same_name = g_hash_table_find (gdm_available_sessions_map, + (GHRFunc) find_session_with_same_name, + session->translated_name); + + if (session_with_same_name != NULL) + g_hash_table_remove (gdm_available_sessions_map, session_with_same_name->id); + g_hash_table_insert (gdm_available_sessions_map, g_strdup (id), session); |