Unverified Commit 63e5bc85 authored by Julian Sparber's avatar Julian Sparber
Browse files

Add HdyAvatar


Signed-off-by: Julian Sparber's avatarJulian Sparber <julian@sparber.net>
parent a9bd1eba
This diff is collapsed.
/*
* Copyright (C) 2020 Purism SPC
*
* SPDX-License-Identifier: LGPL-2.1+
*/
#pragma once
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <gtk/gtk.h>
G_BEGIN_DECLS
#define HDY_TYPE_AVATAR (hdy_avatar_get_type())
G_DECLARE_DERIVABLE_TYPE (HdyAvatar, hdy_avatar, HDY, AVATAR, GtkDrawingArea)
/**
* HdyAvatarClass:
* @parent_class: The parent class
*/
struct _HdyAvatarClass
{
GtkDrawingAreaClass parent_class;
};
/**
* HdyAvatarImageLoadFunc:
* @size: the required size of the avatar
* @user_data: (closure): user data
*
* The returned #GdkPixbuf is expected to be square with width and height set
* to @size. The image is cropped to a circle without any scaling or transformation.
*
* Returns: (nullable) (transfer full): the #GdkPixbuf to use as a custom avatar
* or %NULL to fallback to the generated avatar.
*/
typedef GdkPixbuf *(*HdyAvatarImageLoadFunc) (gint size,
gpointer user_data);
GtkWidget *hdy_avatar_new (gint size,
const gchar *text,
gboolean show_initials);
const gchar *hdy_avatar_get_text (HdyAvatar *self);
void hdy_avatar_set_text (HdyAvatar *self,
const gchar *text);
gboolean hdy_avatar_get_show_initials (HdyAvatar *self);
void hdy_avatar_set_show_initials (HdyAvatar *self,
gboolean show_initials);
void hdy_avatar_set_image_load_func (HdyAvatar *self,
HdyAvatarImageLoadFunc load_image,
gpointer user_data,
GDestroyNotify destroy);
gint hdy_avatar_get_size (HdyAvatar *self);
void hdy_avatar_set_size (HdyAvatar *self,
gint size);
G_END_DECLS
...@@ -88,6 +88,7 @@ calls_sources = files(['calls-message-source.c', 'calls-message-source.h', ...@@ -88,6 +88,7 @@ calls_sources = files(['calls-message-source.c', 'calls-message-source.h',
'calls-best-match.c', 'calls-best-match.h', 'calls-best-match.c', 'calls-best-match.h',
'calls-in-app-notification.c', 'calls-in-app-notification.h', 'calls-in-app-notification.c', 'calls-in-app-notification.h',
'calls-manager.c', 'calls-manager.h', 'calls-manager.c', 'calls-manager.h',
'contrib/hdy-avatar.c', 'contrib/hdy-avatar.h',
]) ])
calls_config_data = config_data calls_config_data = config_data
......
...@@ -21,3 +21,27 @@ hdykeypad > button, .dial-button, .delete-button { ...@@ -21,3 +21,27 @@ hdykeypad > button, .dial-button, .delete-button {
color: @theme_base_color; color: @theme_base_color;
padding: 6px; padding: 6px;
} }
/* HdyAvatar */
avatar { border-radius: 9999px; -gtk-outline-radius: 9999px; font-weight: bold; }
avatar.color1 { background-image: linear-gradient(#ffbe6f, #ed6f00); color: #ffe5c5; }
avatar.color2 { background-image: linear-gradient(#f8e45c, #e5a50a); color: #f9f4e1; }
avatar.color3 { background-image: linear-gradient(#dc8add, #8a3ea3); color: #e7c2e8; }
avatar.color4 { background-image: linear-gradient(#99c1f1, #337fdc); color: #cfe1f5; }
avatar.color5 { background-image: linear-gradient(#c0bfbc, #6e6d71); color: #d8d7d3; }
avatar.color6 { background-image: linear-gradient(#8de6ae, #29ae71); color: #cbf7d5; }
avatar.color7 { background-image: linear-gradient(#f67365, #d91a23); color: #f6c8c4; }
avatar.color8 { background-image: linear-gradient(#cdab8f, #865d3c); color: #e5d6ca; }
avatar.contrasted { color: #fff; }
/* End HdyAvatar */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment