[gnome-control-center/wip/um-avatar-picker: 69/69] user-accounts: Replace um-photo-dialog with new um-avatar-picker



commit ba8301f92fd2b6f3601b34c49236918d33e35e3a
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Wed Oct 23 12:13:51 2013 -0400

    user-accounts: Replace um-photo-dialog with new um-avatar-picker

 panels/user-accounts/Makefile.am       |    2 -
 panels/user-accounts/um-photo-dialog.c |  716 --------------------------------
 panels/user-accounts/um-photo-dialog.h |   39 --
 panels/user-accounts/um-user-panel.c   |   39 ++-
 4 files changed, 28 insertions(+), 768 deletions(-)
---
diff --git a/panels/user-accounts/Makefile.am b/panels/user-accounts/Makefile.am
index f2e8157..d370931 100644
--- a/panels/user-accounts/Makefile.am
+++ b/panels/user-accounts/Makefile.am
@@ -42,8 +42,6 @@ libuser_accounts_la_SOURCES =         \
        um-password-dialog.c            \
        pw-utils.h                      \
        pw-utils.c                      \
-       um-photo-dialog.h               \
-       um-photo-dialog.c               \
        um-crop-area.h                  \
        um-crop-area.c                  \
        um-fingerprint-dialog.h         \
diff --git a/panels/user-accounts/um-user-panel.c b/panels/user-accounts/um-user-panel.c
index 516d96d..9b5b06b 100644
--- a/panels/user-accounts/um-user-panel.c
+++ b/panels/user-accounts/um-user-panel.c
@@ -46,7 +46,7 @@
 #include "um-account-dialog.h"
 #include "cc-language-chooser.h"
 #include "um-password-dialog.h"
-#include "um-photo-dialog.h"
+#include "um-avatar-picker.h"
 #include "um-fingerprint-dialog.h"
 #include "um-utils.h"
 #include "um-resources.h"
@@ -70,7 +70,6 @@ struct _CcUserPanelPrivate {
         GtkWidget *language_chooser;
 
         UmPasswordDialog *password_dialog;
-        UmPhotoDialog *photo_dialog;
         UmHistoryDialog *history_dialog;
 
         gint other_accounts;
@@ -676,8 +675,6 @@ show_user (ActUser *user, CcUserPanelPrivate *d)
         gtk_image_set_from_pixbuf (GTK_IMAGE (image), pixbuf);
         g_object_unref (pixbuf);
 
-        um_photo_dialog_set_user (d->photo_dialog, user);
-
         widget = get_widget (d, "full-name-entry");
         cc_editable_entry_set_text (CC_EDITABLE_ENTRY (widget), act_user_get_real_name (user));
         gtk_widget_set_tooltip_text (widget, act_user_get_user_name (user));
@@ -1395,12 +1392,35 @@ setup_main_window (CcUserPanelPrivate *d)
 }
 
 static void
+pick_avatar (GtkWidget   *button,
+             CcUserPanel *self)
+{
+        CcUserPanelPrivate *d = self->priv;
+        GtkWidget *picker;
+        int response;
+
+        picker = um_avatar_picker_new ();
+        gtk_window_set_transient_for (GTK_WINDOW (picker), GTK_WINDOW (gtk_widget_get_toplevel 
(d->main_box)));
+        response = gtk_dialog_run (GTK_DIALOG (picker));
+
+        if (response == GTK_RESPONSE_ACCEPT) {
+                GdkPixbuf *pixbuf;
+                ActUser *user;
+
+                user = get_selected_user (d);
+                pixbuf = um_avatar_picker_get_avatar (UM_AVATAR_PICKER (picker));
+                set_user_icon_data (user, pixbuf);
+        }
+
+        gtk_widget_destroy (picker);
+}
+
+static void
 cc_user_panel_init (CcUserPanel *self)
 {
         CcUserPanelPrivate *d;
         GError *error;
         volatile GType type G_GNUC_UNUSED;
-        GtkWidget *button;
         GtkStyleContext *context;
 
         d = self->priv = UM_USER_PANEL_PRIVATE (self);
@@ -1426,13 +1446,14 @@ cc_user_panel_init (CcUserPanel *self)
         }
 
         d->password_dialog = um_password_dialog_new ();
-        button = get_widget (d, "user-icon-button");
-        d->photo_dialog = um_photo_dialog_new (button);
         d->main_box = get_widget (d, "accounts-vbox");
         gtk_container_add (GTK_CONTAINER (self), d->main_box);
         d->history_dialog = um_history_dialog_new ();
         setup_main_window (d);
 
+        g_signal_connect (get_widget (d, "user-icon-button"), "clicked",
+                          G_CALLBACK (pick_avatar), self);
+
         context = gtk_widget_get_style_context (get_widget (d, "list-scrolledwindow"));
         gtk_style_context_set_junction_sides (context, GTK_JUNCTION_BOTTOM);
         context = gtk_widget_get_style_context (get_widget (d, "add-remove-toolbar"));
@@ -1456,10 +1477,6 @@ cc_user_panel_dispose (GObject *object)
                 um_password_dialog_free (priv->password_dialog);
                 priv->password_dialog = NULL;
         }
-        if (priv->photo_dialog) {
-                um_photo_dialog_free (priv->photo_dialog);
-                priv->photo_dialog = NULL;
-        }
         if (priv->history_dialog) {
                 um_history_dialog_free (priv->history_dialog);
                 priv->history_dialog = NULL;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]