From 8e2d98ae449192c9112893d4ee563d19ec9da528 Mon Sep 17 00:00:00 2001 From: Bastien Nocera Date: Sun, 21 Nov 2010 03:07:37 +0000 Subject: [PATCH] user: Make it possible to disable the user icon Empty string is what the user-accounts panel currently uses to signify "remove the user icon". So let's do that. https://bugs.freedesktop.org/show_bug.cgi?id=31802 --- src/user.c | 25 +++++++++++++++++++++++++ 1 files changed, 25 insertions(+), 0 deletions(-) diff --git a/src/user.c b/src/user.c index b5d07dd..00af59f 100644 --- a/src/user.c +++ b/src/user.c @@ -1285,6 +1285,30 @@ user_change_icon_file_authorized_cb (Daemon *daemon, filename = g_strdup (data); + if (filename == NULL || + *filename == '\0') { + char *dest_path; + GFile *dest; + GError *error; + + g_free (filename); + filename = NULL; + + dest_path = g_build_filename (ICONDIR, user->user_name, NULL); + dest = g_file_new_for_path (dest_path); + g_free (dest_path); + + error = NULL; + if (!g_file_delete (dest, NULL, &error)) { + g_object_unref (dest); + throw_error (context, ERROR_FAILED, "failed to remove user icon, %s", error->message); + g_error_free (error); + return; + } + g_object_unref (dest); + goto icon_saved; + } + file = g_file_new_for_path (filename); info = g_file_query_info (file, G_FILE_ATTRIBUTE_UNIX_MODE "," G_FILE_ATTRIBUTE_STANDARD_SIZE, @@ -1380,6 +1404,7 @@ user_change_icon_file_authorized_cb (Daemon *daemon, filename = dest_path; } +icon_saved: g_free (user->icon_file); user->icon_file = filename; -- 1.7.3.2