[gnome-initial-setup/wip/feborges/generate-user-pics: 3/3] accounts: Set generated user pic when no pic is set
- From: Felipe Borges <felipeborges src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-initial-setup/wip/feborges/generate-user-pics: 3/3] accounts: Set generated user pic when no pic is set
- Date: Mon, 21 Jan 2019 13:28:14 +0000 (UTC)
commit 02a35cb85512aabc1c0b3b04d0fc2b45f58854be
Author: Felipe Borges <felipeborges gnome org>
Date: Tue Oct 23 12:15:12 2018 +0200
accounts: Set generated user pic when no pic is set
The default user picture is blank.
https://wiki.gnome.org/Design/OS/AvatarChooser#Tentative_Design
Fixes #6
gnome-initial-setup/pages/account/gis-account-page-local.c | 1 +
gnome-initial-setup/pages/account/um-photo-dialog.c | 8 ++++++++
gnome-initial-setup/pages/account/um-utils.c | 13 ++++++++++---
3 files changed, 19 insertions(+), 3 deletions(-)
---
diff --git a/gnome-initial-setup/pages/account/gis-account-page-local.c
b/gnome-initial-setup/pages/account/gis-account-page-local.c
index d8273a9..70a8242 100644
--- a/gnome-initial-setup/pages/account/gis-account-page-local.c
+++ b/gnome-initial-setup/pages/account/gis-account-page-local.c
@@ -433,6 +433,7 @@ gis_account_page_local_constructed (GObject *object)
priv->photo_dialog = um_photo_dialog_new (priv->avatar_button,
avatar_callback,
page);
+ um_photo_dialog_generate_avatar (priv->photo_dialog, "");
validate (page);
diff --git a/gnome-initial-setup/pages/account/um-photo-dialog.c
b/gnome-initial-setup/pages/account/um-photo-dialog.c
index e4ac51b..85f6b01 100644
--- a/gnome-initial-setup/pages/account/um-photo-dialog.c
+++ b/gnome-initial-setup/pages/account/um-photo-dialog.c
@@ -56,6 +56,7 @@ struct _UmPhotoDialog {
GListStore *recent_faces;
GListStore *faces;
GFile *generated_avatar;
+ gboolean custom_avatar_was_chosen;
SelectAvatarCallback *callback;
gpointer data;
@@ -83,6 +84,7 @@ webcam_response_cb (GtkDialog *dialog,
pb2 = gdk_pixbuf_scale_simple (pb, 96, 96, GDK_INTERP_BILINEAR);
um->callback (pb2, NULL, um->data);
+ um->custom_avatar_was_chosen = TRUE;
g_object_unref (pb2);
g_object_unref (pb);
@@ -146,6 +148,7 @@ face_widget_activated (GtkFlowBox *flowbox,
filename = g_object_get_data (G_OBJECT (image), "filename");
um->callback (NULL, filename, um->data);
+ um->custom_avatar_was_chosen = FALSE;
gtk_popover_popdown (GTK_POPOVER (um));
}
@@ -198,6 +201,7 @@ setup_photo_popup (UmPhotoDialog *um)
NULL);
g_signal_connect (um->recent_pictures, "child-activated",
G_CALLBACK (face_widget_activated), um);
+ um->custom_avatar_was_chosen = FALSE;
dirs = g_get_system_data_dirs ();
for (i = 0; dirs[i] != NULL; i++) {
@@ -301,6 +305,10 @@ um_photo_dialog_generate_avatar (UmPhotoDialog *um,
g_list_store_insert (um->recent_faces, 0,
um->generated_avatar);
gtk_widget_show_all (um->recent_pictures);
+
+ if (!um->custom_avatar_was_chosen) {
+ um->callback (NULL, g_file_get_path (um->generated_avatar), um->data);
+ }
}
UmPhotoDialog *
diff --git a/gnome-initial-setup/pages/account/um-utils.c b/gnome-initial-setup/pages/account/um-utils.c
index ff45488..2fbbd3f 100644
--- a/gnome-initial-setup/pages/account/um-utils.c
+++ b/gnome-initial-setup/pages/account/um-utils.c
@@ -534,9 +534,16 @@ get_color_for_name (const gchar *name)
};
GdkRGBA color = { 255, 255, 255, 1.0 };
- guint hash = g_str_hash (name);
- gint number_of_colors = G_N_ELEMENTS (gnome_color_palette);
- gint idx = hash % number_of_colors;
+ guint hash;
+ gint number_of_colors;
+ gint idx;
+
+ if (name == NULL || strlen (name) == 0)
+ return color;
+
+ hash = g_str_hash (name);
+ number_of_colors = G_N_ELEMENTS (gnome_color_palette);
+ idx = hash % number_of_colors;
color.red = gnome_color_palette[idx][0];
color.green = gnome_color_palette[idx][1];
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]