2828#include <unistd.h>
2929#include <dbus/dbus-glib-bindings.h>
3030
31+ #if HAVE_ACCOUNTSSERVICE
32+ #include <act/act.h>
33+ #endif
34+
3135#define MATE_DESKTOP_USE_UNSTABLE_API
3236#include <libmate-desktop/mate-desktop-thumbnail.h>
3337
@@ -48,6 +52,9 @@ typedef struct {
4852 GtkWidget * disable_fingerprint_button ;
4953 GtkWidget * image_chooser ;
5054 GdkPixbuf * image ;
55+ #if HAVE_ACCOUNTSSERVICE
56+ ActUser * user ;
57+ #endif
5158
5259 GdkScreen * screen ;
5360 GtkIconTheme * theme ;
@@ -84,10 +91,20 @@ about_me_destroy (void)
8491static void
8592about_me_load_photo (MateAboutMe * me )
8693{
87- gchar * file ;
94+ gchar * file = NULL ;
8895 GError * error = NULL ;
96+ #if HAVE_ACCOUNTSSERVICE
97+ const gchar * act_file ;
98+
99+ act_file = act_user_get_icon_file (me -> user );
100+ if ( act_file != NULL && strlen (act_file ) > 1 ) {
101+ file = g_strdup (act_file );
102+ }
103+ #endif
104+ if (file == NULL ) {
105+ file = g_build_filename (g_get_home_dir (), ".face" , NULL );
106+ }
89107
90- file = g_build_filename (g_get_home_dir (), ".face" , NULL );
91108 me -> image = gdk_pixbuf_new_from_file (file , & error );
92109
93110 if (me -> image != NULL ) {
@@ -96,9 +113,9 @@ about_me_load_photo (MateAboutMe *me)
96113 } else {
97114 me -> have_image = FALSE;
98115 g_warning ("Could not load %s: %s" , file , error -> message );
116+ e_image_chooser_set_from_file (E_IMAGE_CHOOSER (me -> image_chooser ), me -> person );
99117 g_error_free (error );
100118 }
101-
102119 g_free (file );
103120}
104121
@@ -172,6 +189,9 @@ about_me_update_photo (MateAboutMe *me)
172189 file = g_build_filename (g_get_home_dir (), ".face" , NULL );
173190 if (g_file_set_contents (file , (gchar * )data , length , & error ) == TRUE) {
174191 g_chmod (file , 0644 );
192+ #if HAVE_ACCOUNTSSERVICE
193+ act_user_set_icon_file (me -> user , file );
194+ #endif
175195 } else {
176196 g_warning ("Could not create %s: %s" , file , error -> message );
177197 g_error_free (error );
@@ -186,6 +206,9 @@ about_me_update_photo (MateAboutMe *me)
186206 g_unlink (file );
187207
188208 g_free (file );
209+ #if HAVE_ACCOUNTSSERVICE
210+ act_user_set_icon_file (me -> user , "" );
211+ #endif
189212 }
190213}
191214
@@ -341,15 +364,19 @@ about_me_icon_theme_changed (GtkWindow *window,
341364{
342365 GtkIconInfo * icon ;
343366
344- icon = gtk_icon_theme_lookup_icon (me -> theme , "stock_person " , 80 , 0 );
367+ icon = gtk_icon_theme_lookup_icon (me -> theme , "avatar-default " , 80 , 0 );
345368 if (icon != NULL ) {
346369 g_free (me -> person );
347370 me -> person = g_strdup (gtk_icon_info_get_filename (icon ));
348371 g_object_unref (icon );
349372 }
350373
351- if (me -> have_image )
374+ if (me -> have_image ) {
375+ #if HAVE_ACCOUNTSSERVICE
376+ act_user_set_icon_file (me -> user , me -> person );
377+ #endif
352378 e_image_chooser_set_from_file (E_IMAGE_CHOOSER (me -> image_chooser ), me -> person );
379+ }
353380}
354381
355382static void
@@ -380,6 +407,18 @@ about_me_fingerprint_button_clicked_cb (GtkWidget *button, MateAboutMe *me)
380407 me -> disable_fingerprint_button );
381408}
382409
410+ #if HAVE_ACCOUNTSSERVICE
411+ static void on_user_is_loaded_changed (ActUser * user , GParamSpec * pspec , MateAboutMe * me )
412+ {
413+ if (act_user_is_loaded (user )) {
414+ about_me_load_photo (me );
415+ g_signal_handlers_disconnect_by_func (G_OBJECT (user ),
416+ G_CALLBACK (on_user_is_loaded_changed ),
417+ me );
418+ }
419+ }
420+ #endif
421+
383422static gint
384423about_me_setup_dialog (void )
385424{
@@ -388,6 +427,10 @@ about_me_setup_dialog (void)
388427 GtkIconInfo * icon ;
389428 GtkBuilder * dialog ;
390429 gchar * str ;
430+ #if HAVE_ACCOUNTSSERVICE
431+ ActUserManager * manager ;
432+ gboolean loaded ;
433+ #endif
391434
392435 me = g_new0 (MateAboutMe , 1 );
393436 me -> image = NULL ;
@@ -417,7 +460,7 @@ about_me_setup_dialog (void)
417460 me -> screen = gtk_window_get_screen (GTK_WINDOW (main_dialog ));
418461 me -> theme = gtk_icon_theme_get_for_screen (me -> screen );
419462
420- icon = gtk_icon_theme_lookup_icon (me -> theme , "stock_person " , 80 , 0 );
463+ icon = gtk_icon_theme_lookup_icon (me -> theme , "avatar-default " , 80 , 0 );
421464 if (icon != NULL ) {
422465 me -> person = g_strdup (gtk_icon_info_get_filename (icon ));
423466 g_object_unref (icon );
@@ -431,6 +474,15 @@ about_me_setup_dialog (void)
431474 me -> login = g_strdup (g_get_user_name ());
432475 me -> username = g_strdup (g_get_real_name ());
433476
477+ #if HAVE_ACCOUNTSSERVICE
478+ manager = act_user_manager_get_default ();
479+ me -> user = act_user_manager_get_user (manager , me -> login );
480+ g_object_get (manager , "is-loaded" , & loaded , NULL );
481+ if (!loaded ) {
482+ g_signal_connect (me -> user , "notify::is-loaded" , G_CALLBACK (on_user_is_loaded_changed ), me );
483+ }
484+ #endif
485+
434486 /* Contact Tab */
435487 about_me_load_photo (me );
436488
0 commit comments