user-accounts: Remove unused icon style code

This commit is contained in:
Robert Ancell 2018-11-09 09:14:58 +13:00
parent feaa29bfc0
commit 96b6ae98d0
3 changed files with 3 additions and 169 deletions

View file

@ -43,7 +43,6 @@ render_image (CcUserImage *image)
pixel_size = gtk_image_get_pixel_size (GTK_IMAGE (image));
scale = gtk_widget_get_scale_factor (GTK_WIDGET (image));
surface = render_user_icon (image->user,
UM_ICON_STYLE_NONE,
pixel_size > 0 ? pixel_size : 48,
scale);
gtk_image_set_from_surface (GTK_IMAGE (image), surface);

View file

@ -362,49 +362,6 @@ popup_menu_below_button (GtkMenu *menu,
*push_in = TRUE;
}
void
rounded_rectangle (cairo_t *cr,
gdouble aspect,
gdouble x,
gdouble y,
gdouble corner_radius,
gdouble width,
gdouble height)
{
gdouble radius;
gdouble degrees;
radius = corner_radius / aspect;
degrees = G_PI / 180.0;
cairo_new_sub_path (cr);
cairo_arc (cr,
x + width - radius,
y + radius,
radius,
-90 * degrees,
0 * degrees);
cairo_arc (cr,
x + width - radius,
y + height - radius,
radius,
0 * degrees,
90 * degrees);
cairo_arc (cr,
x + radius,
y + height - radius,
radius,
90 * degrees,
180 * degrees);
cairo_arc (cr,
x + radius,
y + radius,
radius,
180 * degrees,
270 * degrees);
cairo_close_path (cr);
}
/* Taken from defines.h in shadow-utils. On Linux, this value is much smaller
* than the sysconf limit LOGIN_NAME_MAX, and values larger than this will
* result in failure when running useradd. We could check UT_NAMESIZE instead,
@ -768,105 +725,14 @@ check_user_file (const char *filename,
return TRUE;
}
static GdkPixbuf *
frame_pixbuf (GdkPixbuf *source, gint scale)
{
GdkPixbuf *dest;
cairo_t *cr;
cairo_surface_t *surface;
guint w;
guint h;
int frame_width;
double radius;
frame_width = 2 * scale;
w = gdk_pixbuf_get_width (source) + frame_width * 2;
h = gdk_pixbuf_get_height (source) + frame_width * 2;
radius = w / 10;
surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
w, h);
cr = cairo_create (surface);
cairo_surface_destroy (surface);
/* set up image */
cairo_rectangle (cr, 0, 0, w, h);
cairo_set_source_rgba (cr, 1.0, 1.0, 1.0, 0.0);
cairo_fill (cr);
rounded_rectangle (cr, 1.0, 0.5, 0.5, radius, w - 1, h - 1);
cairo_set_source_rgba (cr, 0.5, 0.5, 0.5, 0.3);
cairo_fill_preserve (cr);
gdk_cairo_set_source_pixbuf (cr, source, frame_width, frame_width);
cairo_fill (cr);
dest = gdk_pixbuf_get_from_surface (surface, 0, 0, w, h);
cairo_destroy (cr);
return dest;
}
static GdkPixbuf *
logged_in_pixbuf (GdkPixbuf *pixbuf, gint scale)
{
cairo_format_t format;
cairo_surface_t *surface;
cairo_pattern_t *pattern;
cairo_t *cr;
gint width, height;
GdkRGBA color;
width = gdk_pixbuf_get_width (pixbuf);
height = gdk_pixbuf_get_height (pixbuf);
g_return_val_if_fail (width > 15 && height > 15, pixbuf);
format = gdk_pixbuf_get_has_alpha (pixbuf) ? CAIRO_FORMAT_ARGB32 : CAIRO_FORMAT_RGB24;
surface = cairo_image_surface_create (format, width, height);
cr = cairo_create (surface);
gdk_cairo_set_source_pixbuf (cr, pixbuf, 0, 0);
cairo_paint (cr);
/* Draw pattern */
cairo_rectangle (cr, 0, 0, width, height);
pattern = cairo_pattern_create_radial (width - 9.5 * scale, height - 10 * scale, 0,
width - 8.5 * scale, height - 7.5 * scale, 7.7 * scale);
cairo_pattern_add_color_stop_rgb (pattern, 0, 0.4, 0.9, 0);
cairo_pattern_add_color_stop_rgb (pattern, 0.7, 0.3, 0.6, 0);
cairo_pattern_add_color_stop_rgb (pattern, 0.8, 0.4, 0.4, 0.4);
cairo_pattern_add_color_stop_rgba (pattern, 1.0, 0, 0, 0, 0);
cairo_set_source (cr, pattern);
cairo_fill (cr);
/* Draw border */
cairo_set_line_width (cr, 0.9 * scale);
cairo_arc (cr, width - 8.5 * scale, height - 8.5 * scale, 6 * scale, 0, 2 * G_PI);
gdk_rgba_parse (&color, "#ffffff");
gdk_cairo_set_source_rgba (cr, &color);
cairo_stroke (cr);
pixbuf = gdk_pixbuf_get_from_surface (surface, 0, 0, width, height);
cairo_surface_finish (surface);
cairo_destroy (cr);
return pixbuf;
}
#define MAX_FILE_SIZE 65536
cairo_surface_t *
render_user_icon (ActUser *user,
UmIconStyle style,
gint icon_size,
gint scale)
render_user_icon (ActUser *user,
gint icon_size,
gint scale)
{
GdkPixbuf *pixbuf;
GdkPixbuf *framed;
gboolean res;
GError *error;
const gchar *icon_file;
@ -908,22 +774,6 @@ render_user_icon (ActUser *user,
out:
if (pixbuf != NULL && (style & UM_ICON_STYLE_FRAME)) {
framed = frame_pixbuf (pixbuf, scale);
if (framed != NULL) {
g_object_unref (pixbuf);
pixbuf = framed;
}
}
if (pixbuf != NULL && (style & UM_ICON_STYLE_STATUS) && act_user_is_logged_in (user)) {
framed = logged_in_pixbuf (pixbuf, scale);
if (framed != NULL) {
g_object_unref (pixbuf);
pixbuf = framed;
}
}
if (pixbuf != NULL) {
surface = gdk_cairo_surface_create_from_pixbuf (pixbuf, scale, NULL);
g_object_unref (pixbuf);

View file

@ -25,12 +25,6 @@
G_BEGIN_DECLS
typedef enum {
UM_ICON_STYLE_NONE = 0,
UM_ICON_STYLE_FRAME = 1 << 0,
UM_ICON_STYLE_STATUS = 1 << 1
} UmIconStyle;
void setup_tooltip_with_embedded_icon (GtkWidget *widget,
const gchar *text,
const gchar *placeholder,
@ -50,14 +44,6 @@ void popup_menu_below_button (GtkMenu *menu,
gboolean *push_in,
GtkWidget *button);
void rounded_rectangle (cairo_t *cr,
gdouble aspect,
gdouble x,
gdouble y,
gdouble corner_radius,
gdouble width,
gdouble height);
gboolean is_valid_name (const gchar *name);
gboolean is_valid_username (const gchar *name,
gchar **tip);
@ -66,7 +52,6 @@ void generate_username_choices (const gchar *name,
GtkListStore *store);
cairo_surface_t *render_user_icon (ActUser *user,
UmIconStyle style,
gint icon_size,
gint scale);