[gnome-control-center/wip/feborges/avatar-chooser: 90/90] user-accounts: Add current avatar line to avatar chooser
- From: Felipe Borges <felipeborges src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center/wip/feborges/avatar-chooser: 90/90] user-accounts: Add current avatar line to avatar chooser
- Date: Wed, 31 Jan 2018 14:58:26 +0000 (UTC)
commit 5f616a2981e5eef9f30e02aa48a6ae8eee2bac86
Author: Felipe Borges <felipeborges gnome org>
Date: Wed Jan 31 15:54:32 2018 +0100
user-accounts: Add current avatar line to avatar chooser
So pictures selected from the file chooser or taken from the
camera are also shown in the grid.
This is based on the wireframes available at
https://wiki.gnome.org/Design/OS/AvatarChooser#Tentative_Design
panels/user-accounts/data/avatar-chooser.ui | 18 +++++++++++++++++-
panels/user-accounts/um-photo-dialog.c | 17 +++++++++++++++++
2 files changed, 34 insertions(+), 1 deletions(-)
---
diff --git a/panels/user-accounts/data/avatar-chooser.ui b/panels/user-accounts/data/avatar-chooser.ui
index 6bd210c..0f65aee 100644
--- a/panels/user-accounts/data/avatar-chooser.ui
+++ b/panels/user-accounts/data/avatar-chooser.ui
@@ -9,9 +9,25 @@
<property name="visible">True</property>
<property name="orientation">GTK_ORIENTATION_VERTICAL</property>
<child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="border_width">5</property>
+ <property name="margin-start">20</property>
+ <property name="margin-top">20</property>
+ <property name="halign">start</property>
+ <child>
+ <object class="GtkImage" id="current_avatar">
+ <property name="visible">True</property>
+ <property name="icon-size">72</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
<object class="GtkFlowBox" id="flowbox">
<property name="visible">True</property>
- <property name="border-width">20</property>
+ <property name="margin">20</property>
+ <property name="margin-top">0</property>
</object>
</child>
<child>
diff --git a/panels/user-accounts/um-photo-dialog.c b/panels/user-accounts/um-photo-dialog.c
index f02f971..8285134 100644
--- a/panels/user-accounts/um-photo-dialog.c
+++ b/panels/user-accounts/um-photo-dialog.c
@@ -47,6 +47,7 @@ struct _UmPhotoDialog {
GtkWidget *popup_button;
GtkWidget *crop_area;
+ GtkWidget *current_avatar;
GtkWidget *flowbox;
GtkWidget *take_picture_button;
@@ -375,6 +376,7 @@ setup_photo_popup (UmPhotoDialog *um)
gboolean added_faces;
um->faces = g_list_store_new (G_TYPE_FILE);
+
gtk_flow_box_bind_model (GTK_FLOW_BOX (um->flowbox),
G_LIST_MODEL (um->faces),
create_face_widget,
@@ -502,6 +504,7 @@ um_photo_dialog_class_init (UmPhotoDialogClass *klass)
gtk_widget_class_set_template_from_resource (wclass,
"/org/gnome/control-center/user-accounts/avatar-chooser.ui");
+ gtk_widget_class_bind_template_child (wclass, UmPhotoDialog, current_avatar);
gtk_widget_class_bind_template_child (wclass, UmPhotoDialog, flowbox);
gtk_widget_class_bind_template_child (wclass, UmPhotoDialog, take_picture_button);
@@ -515,6 +518,10 @@ void
um_photo_dialog_set_user (UmPhotoDialog *um,
ActUser *user)
{
+ const gchar *avatar_path = NULL;
+ GFile *file;
+ GIcon *icon;
+
g_return_if_fail (um != NULL);
if (um->user) {
@@ -522,5 +529,15 @@ um_photo_dialog_set_user (UmPhotoDialog *um,
um->user = NULL;
}
um->user = user;
+
+ avatar_path = act_user_get_icon_file (user);
+ file = g_file_new_for_path (avatar_path);
+ icon = g_file_icon_new (file);
+
+ gtk_image_set_from_gicon (GTK_IMAGE (um->current_avatar), icon, GTK_ICON_SIZE_DIALOG);
+ gtk_image_set_pixel_size (GTK_IMAGE (um->current_avatar), AVATAR_PIXEL_SIZE);
+
+ g_object_unref (icon);
+ g_object_unref (file);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]