summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMatias De lellis <mati86dl@gmail.com>2021-08-06 09:31:27 -0300
committerMatias De lellis <mati86dl@gmail.com>2021-08-06 09:31:27 -0300
commitfc6390c61edf16954a7e41f6fb96481323ade9e6 (patch)
treea6a565863c53baaa9ca010bf326d27bfeff5e184 /src
parentff843ff6c16f552cb2a7d594bcd100490f7e45f1 (diff)
downloadlightdm-gtk-greeter-git-fc6390c61edf16954a7e41f6fb96481323ade9e6.tar.gz
Add a couple of macros to improve the readability of the code.
When I just started this PR, I don't understand why these comparisons, and with this it is clearer.
Diffstat (limited to 'src')
-rw-r--r--src/greeteruserimage.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/greeteruserimage.c b/src/greeteruserimage.c
index 5ce7ad4..838707c 100644
--- a/src/greeteruserimage.c
+++ b/src/greeteruserimage.c
@@ -21,6 +21,13 @@
#define USER_IMAGE_SIZE 80
+#define VALUE_IS_ICON_PATH(v) (v[0] == '/')
+#define VALUE_ICON_PATH(v) (v)
+
+#define VALUE_IS_ICON_NAME(v) (v[0] == '#')
+#define VALUE_ICON_NAME(v) (v + 1)
+
+
static GdkPixbuf *
round_image (GdkPixbuf *pixbuf)
{
@@ -59,9 +66,9 @@ get_default_user_image_from_settings (void)
if (!value)
return NULL;
- if (value[0] == '/')
+ if (VALUE_IS_ICON_PATH(value))
{
- image = gdk_pixbuf_new_from_file_at_scale (value,
+ image = gdk_pixbuf_new_from_file_at_scale (VALUE_ICON_PATH(value),
USER_IMAGE_SIZE,
USER_IMAGE_SIZE,
FALSE,
@@ -73,10 +80,10 @@ get_default_user_image_from_settings (void)
g_clear_error (&error);
}
}
- else if (value[0] == '#')
+ else if (VALUE_IS_ICON_NAME(value))
{
image = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
- value + 1,
+ VALUE_ICON_NAME(value),
USER_IMAGE_SIZE,
GTK_ICON_LOOKUP_FORCE_SIZE,
&error);