[gnome-control-center] user-accounts: Simplify render_user_icon function
- From: Robert Ancell <rancell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center] user-accounts: Simplify render_user_icon function
- Date: Fri, 8 Jan 2021 02:32:28 +0000 (UTC)
commit c86d1c09c8e49b6bd0480f6bdb9bb01be85d338a
Author: Robert Ancell <robert ancell canonical com>
Date: Fri Jan 8 15:26:25 2021 +1300
user-accounts: Simplify render_user_icon function
panels/user-accounts/cc-user-image.c | 46 ++++++++++++++++++------------------
1 file changed, 23 insertions(+), 23 deletions(-)
---
diff --git a/panels/user-accounts/cc-user-image.c b/panels/user-accounts/cc-user-image.c
index fe535edee..8c6d16d93 100644
--- a/panels/user-accounts/cc-user-image.c
+++ b/panels/user-accounts/cc-user-image.c
@@ -32,44 +32,44 @@ struct _CcUserImage {
G_DEFINE_TYPE (CcUserImage, cc_user_image, GTK_TYPE_IMAGE)
+static cairo_surface_t *
+render_rounded (GdkPixbuf *source, gint scale)
+{
+ g_autoptr(GdkPixbuf) rounded_pixbuf = NULL;
+ rounded_pixbuf = round_image (source);
+ return gdk_cairo_surface_create_from_pixbuf (rounded_pixbuf, scale, NULL);
+}
+
static cairo_surface_t *
render_user_icon (ActUser *user,
gint icon_size,
gint scale)
{
- g_autoptr(GdkPixbuf) source_pixbuf = NULL;
- g_autoptr(GdkPixbuf) avatar_pixbuf = NULL;
- g_autoptr(GdkPixbuf) pixbuf = NULL;
- const gchar *icon_file;
- cairo_surface_t *surface = NULL;
+ const gchar *icon_file;
+ g_autoptr(GdkPixbuf) default_pixbuf = NULL;
g_return_val_if_fail (ACT_IS_USER (user), NULL);
g_return_val_if_fail (icon_size > 12, NULL);
icon_file = act_user_get_icon_file (user);
if (icon_file) {
- source_pixbuf = gdk_pixbuf_new_from_file_at_size (icon_file,
- icon_size * scale,
- icon_size * scale,
- NULL);
- if (source_pixbuf)
- pixbuf = round_image (source_pixbuf);
+ g_autoptr(GdkPixbuf) icon_pixbuf = NULL;
+
+ icon_pixbuf = gdk_pixbuf_new_from_file_at_size (icon_file,
+ icon_size * scale,
+ icon_size * scale,
+ NULL);
+ if (icon_pixbuf) {
+ return render_rounded (icon_pixbuf, scale);
+ }
}
- if (pixbuf != NULL) {
- goto out;
- }
-
- avatar_pixbuf = generate_default_avatar (user, icon_size * scale);
- if (avatar_pixbuf)
- pixbuf = round_image (avatar_pixbuf);
- out:
-
- if (pixbuf != NULL) {
- surface = gdk_cairo_surface_create_from_pixbuf (pixbuf, scale, NULL);
+ default_pixbuf = generate_default_avatar (user, icon_size * scale);
+ if (default_pixbuf) {
+ return render_rounded (default_pixbuf, scale);
}
- return surface;
+ return NULL;
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]