2007-10-09 [iwkse] 3.0.2cvs39
authorSalvatore De Paolis <iwkse@claws-mail.org>
Tue, 9 Oct 2007 10:24:14 +0000 (10:24 +0000)
committerSalvatore De Paolis <iwkse@claws-mail.org>
Tue, 9 Oct 2007 10:24:14 +0000 (10:24 +0000)
* src/addressbook.c
* src/addritem.c
* src/addritem.h
* src/editaddress.c
* src/editaddress_other_attributes_ldap.h
* src/addrbook.c
* src/Makefile.am
add a contact's photo to the AddressBook

ChangeLog
PATCHSETS
src/Makefile.am
src/addrbook.c
src/addressbook.c
src/addritem.c
src/addritem.h
src/editaddress.c
src/editaddress_other_attributes_ldap.h

index 0cf2e4b7333e59f4ac098b1c2df4ac557e64b65f..52c1e92e6541fa1be4e71c7441668f31d1549afc 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2007-10-09 [iwkse]     3.0.2cvs39
+
+       * src/addressbook.c
+       * src/addritem.c
+       * src/addritem.h
+       * src/editaddress.c
+       * src/editaddress_other_attributes_ldap.h
+       * src/addrbook.c
+       * src/Makefile.am
+               add a contact's photo to the AddressBook
+
 2007-10-09 [iwkse]     3.0.2cvs39
 
        * src/addressbook.c
index f0857f75124fb3bfce2b1eff7a72e8f67c3cfa95..3b4cade500208c9fea65f95df2fa190a7117f579 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.60.2.100 -r 1.60.2.101 src/addressbook.c;  cvs diff -u -r 1.13.2.13 -r 1.13.2.14 src/addritem.c;  cvs diff -u -r 1.12.2.11 -r 1.12.2.12 src/addritem.h;  cvs diff -u -r 1.14.2.29 -r 1.14.2.30 src/editaddress.c;  cvs diff -u -r 1.1.2.3 -r 1.1.2.4 src/editaddress_other_attributes_ldap.h;  cvs diff -u -r 1.22.2.17 -r 1.22.2.18 src/addrbook.c;  cvs diff -u -r 1.155.2.77 -r 1.155.2.78 src/Makefile.am;  ) > 3.0.2cvs40.patchset
 ( cvs diff -u -r 1.60.2.100 -r 1.60.2.101 src/addressbook.c;  cvs diff -u -r 1.13.2.13 -r 1.13.2.14 src/addritem.c;  cvs diff -u -r 1.12.2.11 -r 1.12.2.12 src/addritem.h;  cvs diff -u -r 1.14.2.29 -r 1.14.2.30 src/editaddress.c;  cvs diff -u -r 1.1.2.3 -r 1.1.2.4 src/editaddress_other_attributes_ldap.h;  cvs diff -u -r 1.22.2.17 -r 1.22.2.18 src/addrbook.c;  cvs diff -u -r 1.155.2.77 -r 1.155.2.78 src/Makefile.am;  ) > 3.0.2cvs41.patchset
 ( cvs diff -u -r 1.60.2.100 -r 1.60.2.101 src/addressbook.c;  cvs diff -u -r 1.13.2.13 -r 1.13.2.14 src/addritem.c;  cvs diff -u -r 1.12.2.11 -r 1.12.2.12 src/addritem.h;  cvs diff -u -r 1.14.2.29 -r 1.14.2.30 src/editaddress.c;  cvs diff -u -r 1.1.2.3 -r 1.1.2.4 src/editaddress_other_attributes_ldap.h;  cvs diff -u -r 1.22.2.17 -r 1.22.2.18 src/addrbook.c;  cvs diff -u -r 1.155.2.77 -r 1.155.2.78 src/Makefile.am;  ) > 3.0.2cvs39.patchset
+( cvs diff -u -r 1.60.2.100 -r 1.60.2.101 src/addressbook.c;  cvs diff -u -r 1.13.2.13 -r 1.13.2.14 src/addritem.c;  cvs diff -u -r 1.12.2.11 -r 1.12.2.12 src/addritem.h;  cvs diff -u -r 1.14.2.29 -r 1.14.2.30 src/editaddress.c;  cvs diff -u -r 1.1.2.3 -r 1.1.2.4 src/editaddress_other_attributes_ldap.h;  cvs diff -u -r 1.22.2.17 -r 1.22.2.18 src/addrbook.c;  cvs diff -u -r 1.155.2.77 -r 1.155.2.78 src/Makefile.am;  ) > 3.0.2cvs39.patchset
index 4c884a0eedc7c6b08492f4c951c41212d11688cb..3e1f1e03a97b4b462587a1477eccc2b3e2df10d6 100644 (file)
@@ -491,9 +491,12 @@ claws_mail_LDADD = \
        $(MAEMO_LIBS) \
        $(CONIC_LIBS)
 
+pixmapdir=$(datadir)/icons/hicolor/48x48/apps
+
 AM_CPPFLAGS = \
        -DG_LOG_DOMAIN=\"Claws-Mail\" \
        -DLOCALEDIR=\""$(localedir)"\" \
+       -DPIXMAP_DIR=\""$(pixmapdir)"\" \
        -DMANUALDIR=\""$(manualdir)"\" \
        -DFAQDIR=\""$(faqdir)"\" \
        -DTARGET_ALIAS=\""$(target_triplet)"\" \
index 90f572e3338ef80a362539292f1ba322660b934b..c70e6bf719ea5b2906901fb1f786536be5917467 100644 (file)
@@ -500,8 +500,10 @@ static void addrbook_parse_person(AddressBookFile *book, XMLFile *file)
                value = ((XMLAttr *)attr->data)->value;
                if (!person) 
                        person = addritem_create_item_person();
-               if (strcmp(name, AB_ATTAG_UID) == 0)
+               if (strcmp(name, AB_ATTAG_UID) == 0) {
                        ADDRITEM_ID(person) = g_strdup(value);
+                       person->picture = g_strdup(value);
+               }
                else if (strcmp(name, AB_ATTAG_FIRST_NAME) == 0)
                        person->firstName = g_strdup(value);
                else if (strcmp(name, AB_ATTAG_LAST_NAME) == 0)
index 2eaadfdf84e36ac9e81f0fd880d3237d90d40e61..bc91430ed21f07bd6a195ec08268c3a4a59cfe9c 100644 (file)
@@ -44,6 +44,8 @@
 #include <gtk/gtkitemfactory.h>
 #include <string.h>
 #include <setjmp.h>
+#include <sys/types.h>
+#include <dirent.h>
 
 #include "main.h"
 #include "addressbook.h"
@@ -3915,9 +3917,61 @@ static gboolean addressbook_convert( AddressIndex *addrIndex ) {
        return retVal;
 }
 
+static gboolean migrate_addrbook(const gchar *origdir, const gchar *destdir)
+{
+       DIR *dp;
+       struct dirent *d;
+       gboolean failed = FALSE;
+
+       if( ( dp = opendir( origdir ) ) == NULL ) {
+               return FALSE;
+       }
+       
+       while( ( d = readdir( dp ) ) != NULL ) {
+               if (strncmp(d->d_name, "addrbook-", strlen("addrbook-")))
+                       continue;
+               else {
+                       gchar *orig_file = g_strconcat(origdir, G_DIR_SEPARATOR_S, 
+                                       d->d_name, NULL);
+                       gchar *dest_file = g_strconcat(destdir, G_DIR_SEPARATOR_S, 
+                                       d->d_name, NULL);
+                       if (copy_file(orig_file, dest_file, FALSE) < 0) {
+                               failed = TRUE;
+                       }
+                       g_free(orig_file);
+                       g_free(dest_file);
+                       if (failed) {
+                               break;
+                       }
+               }
+       }
+
+       closedir( dp );
+       if (!failed) {
+               /* all copies succeeded, we can remove source files */
+               if( ( dp = opendir( origdir ) ) == NULL ) {
+                       return FALSE;
+               }
+               while( ( d = readdir( dp ) ) != NULL ) {
+                       if (strncmp(d->d_name, "addrbook-", strlen("addrbook-")))
+                               continue;
+                       else {
+                               gchar *orig_file = g_strconcat(origdir, G_DIR_SEPARATOR_S, 
+                                               d->d_name, NULL);
+                               g_unlink(orig_file);
+                               g_free(orig_file);
+                       }
+               }
+               closedir( dp );
+       }
+       
+       return !failed;
+}
+
 void addressbook_read_file( void ) {
        AddressIndex *addrIndex = NULL;
-
+       gchar *indexdir = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, ADDRBOOK_DIR, NULL);
+       
        debug_print( "Reading address index...\n" );
        if( _addressIndex_ ) {
                debug_print( "address book already read!!!\n" );
@@ -3928,7 +3982,24 @@ void addressbook_read_file( void ) {
        addrindex_initialize();
 
        /* Use new address book index. */
-       addrindex_set_file_path( addrIndex, get_rc_dir() );
+       
+       if ( !is_dir_exist(indexdir) ) {
+               if ( make_dir(indexdir) < 0 ) {
+                       addrindex_set_file_path( addrIndex, get_rc_dir() );
+                       g_warning( "couldn't create dir %s\n", indexdir);
+               } else {
+                       if (!migrate_addrbook(get_rc_dir(), indexdir)) {
+                               remove_dir_recursive(indexdir);
+                               addrindex_set_file_path( addrIndex, get_rc_dir() );
+                               g_error("couldn't migrate dir %s", indexdir);
+                       } else {
+                               addrindex_set_file_path( addrIndex, indexdir);
+                       }
+               }
+       } else {
+               addrindex_set_file_path( addrIndex, indexdir);
+       }
+       g_free(indexdir);
        addrindex_set_file_name( addrIndex, ADDRESSBOOK_INDEX_FILE );
        addrindex_read_data( addrIndex );
        if( addrIndex->retVal == MGU_NO_FILE ) {
@@ -5350,11 +5421,11 @@ static void addressbook_drag_data_get(GtkWidget        *widget,
                if( ds && ds->interface && ds->interface->readOnly)
                        gtk_selection_data_set(selection_data,
                                       selection_data->target, 8,
-                                      "Dummy_addr_copy", 15);
+                                      (const guchar *)"Dummy_addr_copy", 15);
                else
                        gtk_selection_data_set(selection_data,
                                       selection_data->target, 8,
-                                      "Dummy_addr_move", 15);
+                                      (const guchar *)"Dummy_addr_move", 15);
        } 
 }
 
index befb06845ed3509930f5f802badf2c41805c7479..4da7edd6843481c2c141f15511089ba040a18c2c 100644 (file)
@@ -217,6 +217,7 @@ ItemPerson *addritem_create_item_person( void ) {
        ADDRITEM_NAME(person) = NULL;
        ADDRITEM_PARENT(person) = NULL;
        ADDRITEM_SUBTYPE(person) = 0;
+       person->picture = NULL;
        person->firstName = NULL;
        person->lastName = NULL;
        person->nickName = NULL;
@@ -240,6 +241,7 @@ ItemPerson *addritem_copy_item_person( ItemPerson *item ) {
        if( item ) {
                itemNew = addritem_create_item_person();
                ADDRITEM_NAME(itemNew) = g_strdup( ADDRITEM_NAME(item) );
+               itemNew->picture = g_strdup( item->picture );
                itemNew->firstName = g_strdup( item->firstName );
                itemNew->lastName = g_strdup( item->lastName );
                itemNew->nickName = g_strdup( item->nickName );
@@ -249,6 +251,23 @@ ItemPerson *addritem_copy_item_person( ItemPerson *item ) {
        return itemNew;
 }
 
+/**
+ * Specify picture for person object.
+ * \param person Person object.
+ * \param value Picture.
+ */
+void addritem_person_set_picture( ItemPerson *person, const gchar *value ) {
+       if (!value || g_utf8_validate(value, -1, NULL))
+               person->picture = mgu_replace_string( person->picture, value );
+       else {
+               gchar *out = conv_codeset_strdup(value, 
+                               conv_get_locale_charset_str_no_utf8(),
+                               CS_INTERNAL);
+               if (out)
+                       person->picture = mgu_replace_string( person->picture, out );
+               g_free(out);
+       }
+}
 /**
  * Specify first name for person object.
  * \param person Person object.
@@ -385,6 +404,7 @@ void addritem_free_item_person( ItemPerson *person ) {
        /* Free internal stuff */
        g_free( ADDRITEM_ID(person) );
        g_free( ADDRITEM_NAME(person) );
+       g_free( person->picture );
        g_free( person->firstName );
        g_free( person->lastName );
        g_free( person->nickName );
@@ -397,6 +417,7 @@ void addritem_free_item_person( ItemPerson *person ) {
        ADDRITEM_NAME(person) = NULL;
        ADDRITEM_PARENT(person) = NULL;
        ADDRITEM_SUBTYPE(person) = 0;
+       person->picture = NULL;
        person->firstName = NULL;
        person->lastName = NULL;
        person->nickName = NULL;
@@ -447,6 +468,7 @@ void addritem_print_item_person( ItemPerson *person, FILE *stream ) {
        fprintf( stream, "\tt/uid: %d : '%s'\n", ADDRITEM_TYPE(person), ADDRITEM_ID(person) );
        fprintf( stream, "\tsubty: %d\n", ADDRITEM_SUBTYPE(person) );
        fprintf( stream, "\tcommn: '%s'\n", ADDRITEM_NAME(person) );
+       fprintf( stream, "\tphoto: '%s'\n", person->picture );
        fprintf( stream, "\tfirst: '%s'\n", person->firstName );
        fprintf( stream, "\tlast : '%s'\n", person->lastName );
        fprintf( stream, "\tnick : '%s'\n", person->nickName );
index 2fecd53dcfa7ee5adc99db277f40238d5051de57..1e79755aad9d8a30c17f8d02ee70c6868452f993 100644 (file)
@@ -72,13 +72,14 @@ struct _AddrItemObject {
 typedef struct _ItemPerson ItemPerson;
 struct _ItemPerson {
        AddrItemObject obj;
-       gchar    *firstName;
-       gchar    *lastName;
-       gchar    *nickName;
-       gchar    *externalID;
-       GList    *listEMail;
-       GList    *listAttrib;
-       gboolean isOpened;
+       gchar           *picture;
+       gchar           *firstName;
+       gchar           *lastName;
+       gchar           *nickName;
+       gchar           *externalID;
+       GList           *listEMail;
+       GList           *listAttrib;
+       gboolean        isOpened;
        ContactStatus status;
 };
 
@@ -135,6 +136,7 @@ void addritem_free_attribute                ( UserAttribute *item );
 
 ItemPerson *addritem_create_item_person        ( void );
 ItemPerson *addritem_copy_item_person  ( ItemPerson *item );
+void addritem_person_set_picture       ( ItemPerson *person, const gchar *value );
 void addritem_person_set_first_name    ( ItemPerson *person, const gchar *value );
 void addritem_person_set_last_name     ( ItemPerson *person, const gchar *value );
 void addritem_person_set_nick_name     ( ItemPerson *person, const gchar *value );
index 03700b3fe11e7754fc7d22cad389e24cb90ca22c..5a986090ae8ba07f8b13b1da698147ee9daa3418 100644 (file)
@@ -40,6 +40,7 @@
 #include "addrbook.h"
 #include "manage_window.h"
 #include "gtkutils.h"
+#include "filesel.h"
 #include "codeconv.h"
 #include "editaddress.h"
 #include "editaddress_other_attributes_ldap.h"
@@ -437,6 +438,7 @@ static void edit_person_load_attrib( ItemPerson *person ) {
                UserAttribute *atorig = ( UserAttribute * ) node->data;
                UserAttribute *attrib = addritem_copy_attribute( atorig );
                gint row;
+               debug_print("name: %s value: %s\n", attrib->name, attrib->value);
                text[ ATTRIB_COL_NAME  ] = attrib->name;
                text[ ATTRIB_COL_VALUE ] = attrib->value;
 
@@ -572,7 +574,7 @@ static GtkWidget* addressbook_edit_person_widgets_create( GtkWidget* container,
        GtkWidget *cancel_btn;
 
        vbox = gtk_vbox_new(FALSE, 4);
-       /* gtk_container_set_border_width(GTK_CONTAINER(vbox), BORDER_WIDTH); */
+        gtk_container_set_border_width(GTK_CONTAINER(vbox), BORDER_WIDTH); 
        gtk_widget_show(vbox);
        gtk_container_add(GTK_CONTAINER(container), vbox);
 
@@ -694,10 +696,42 @@ void addressbook_edit_person_widgetset_hide( void )
                gtk_widget_hide( personeditdlg.container );
 }
 
+GtkWidget *picture;
+
+static void addressbook_edit_person_set_picture(gpointer data)
+{
+               GError *error = NULL;
+               gchar *filename;
+               int width, height, scalewidth, scaleheight;
+               if ( (filename = filesel_select_file_open(_("Choose a picture"), NULL)) ) {
+                       personeditdlg.picture = gdk_pixbuf_new_from_file(filename, &error);
+                       personeditdlg.picture_set = TRUE;
+                       g_free(filename);
+                       width = gdk_pixbuf_get_width(personeditdlg.picture);
+                       height = gdk_pixbuf_get_height(personeditdlg.picture);
+                       
+                       if ( width > 128 || height > 128 ) {
+                               if (width > height) {
+                                       scaleheight = (height * 128) / width;
+                                       scalewidth = 128;
+                               }
+                               else {
+                                       scalewidth = (width * 128) / height;
+                                       scaleheight = 128;
+                               }
+                               personeditdlg.picture = gdk_pixbuf_scale_simple(personeditdlg.picture, scalewidth, scaleheight, GDK_INTERP_BILINEAR);
+                       }
+               gtk_image_set_from_pixbuf(GTK_IMAGE(picture), personeditdlg.picture);
+               }
+}
+
 static void addressbook_edit_person_page_basic( gint pageNum, gchar *pageLbl ) {
        GtkWidget *vbox;
+       GtkWidget *hbox;
        GtkWidget *table;
        GtkWidget *label;
+       GtkWidget *ebox_picture;
+       GtkWidget *frame_picture;
        GtkWidget *entry_name;
        GtkWidget *entry_fn;
        GtkWidget *entry_ln;
@@ -705,22 +739,39 @@ static void addressbook_edit_person_page_basic( gint pageNum, gchar *pageLbl ) {
        const gchar *locale;
        gint top = 0;
 
-       vbox = gtk_vbox_new( FALSE, 8 );
-       gtk_widget_show( vbox );
-       gtk_container_add( GTK_CONTAINER( personeditdlg.notebook ), vbox );
+       vbox = gtk_vbox_new( FALSE, 20 );
+       hbox = gtk_hbox_new( FALSE, 8 );
+
+       gtk_widget_show( vbox );        
+       
+       /* User's picture */
+       ebox_picture = gtk_event_box_new();
+       frame_picture = gtk_frame_new("Photo");
+       
+       /* Room for a photo */
+       personeditdlg.picture = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, 128, 128);
+       personeditdlg.picture_set = FALSE;
+       picture = gtk_image_new_from_pixbuf(personeditdlg.picture);
+       
+       gtk_container_add(GTK_CONTAINER(ebox_picture), picture);
+       gtk_container_add(GTK_CONTAINER(frame_picture), ebox_picture);  
+       gtk_container_add(GTK_CONTAINER( personeditdlg.notebook ), hbox );
        gtk_container_set_border_width( GTK_CONTAINER (vbox), BORDER_WIDTH );
+       gtk_container_set_border_width( GTK_CONTAINER (hbox), BORDER_WIDTH );
 
        label = gtk_label_new_with_mnemonic( pageLbl );
        gtk_widget_show( label );
+       
+       gtk_box_pack_start(GTK_BOX(hbox), frame_picture, TRUE, TRUE, 0);
+       
        gtk_notebook_set_tab_label(
                GTK_NOTEBOOK( personeditdlg.notebook ),
                gtk_notebook_get_nth_page( GTK_NOTEBOOK( personeditdlg.notebook ), pageNum ), label );
+       
+       g_signal_connect(G_OBJECT(ebox_picture), "button_press_event", 
+                       G_CALLBACK(addressbook_edit_person_set_picture), NULL);
 
-       table = gtk_table_new( 4, 3, FALSE);
-       gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0);
-       gtk_container_set_border_width( GTK_CONTAINER(table), 8 );
-       gtk_table_set_row_spacings(GTK_TABLE(table), 8);
-       gtk_table_set_col_spacings(GTK_TABLE(table), 8);
+       table = gtk_table_new( 3, 3, FALSE);
 
 #define ATTACH_ROW(text, entry) \
 { \
@@ -764,9 +815,13 @@ static void addressbook_edit_person_page_basic( gint pageNum, gchar *pageLbl ) {
 
 #undef ATTACH_ROW
 #undef ATTACH_HIDDEN_ROW
+       gtk_box_pack_start(GTK_BOX(vbox), table, TRUE, TRUE, 0);
+       gtk_box_pack_end(GTK_BOX(hbox), vbox, TRUE, TRUE, 0);
+       gtk_container_set_border_width( GTK_CONTAINER(table), 8 );
+       gtk_table_set_row_spacings(GTK_TABLE(table), 15);
+       gtk_table_set_col_spacings(GTK_TABLE(table), 8);
 
        gtk_widget_show_all(vbox);
-
        personeditdlg.entry_name  = entry_name;
        personeditdlg.entry_first = entry_fn;
        personeditdlg.entry_last  = entry_ln;
@@ -938,6 +993,7 @@ static void addressbook_edit_person_page_email( gint pageNum, gchar *pageLbl ) {
        buttonDel = gtk_button_new_from_stock(GTK_STOCK_DELETE);
        buttonMod = gtk_button_new_from_stock(GTK_STOCK_SAVE);
        buttonAdd = gtk_button_new_from_stock(GTK_STOCK_ADD);
+       
 
 #ifndef MAEMO
        gtk_container_add( GTK_CONTAINER(vbuttonbox), buttonUp );
@@ -1288,6 +1344,7 @@ static gboolean addressbook_edit_person_close( gboolean cancelled )
 {
        GList *listEMail = NULL;
        GList *listAttrib = NULL;
+       GError *error;
        gchar *cn = NULL;
 
        listEMail = edit_person_build_email_list();
@@ -1341,9 +1398,17 @@ static gboolean addressbook_edit_person_close( gboolean cancelled )
        listAttrib = NULL;
 
        if( ! cancelled ) {
-               /* Set current_person stuff */
+               /* Set current_person stuff */          
+
                gchar *name;
                addritem_person_set_common_name( current_person, cn );
+               if (personeditdlg.picture_set) {
+                       name = g_strconcat( get_rc_dir(), G_DIR_SEPARATOR_S, ADDRBOOK_DIR, G_DIR_SEPARATOR_S, 
+                                                       ADDRITEM_ID(current_person), NULL );
+                       gdk_pixbuf_save(personeditdlg.picture, name, "png", &error, NULL);
+                       addritem_person_set_picture( current_person, ADDRITEM_ID(current_person) ) ;
+                       g_free( name );
+               }
                name = gtk_editable_get_chars( GTK_EDITABLE(personeditdlg.entry_first), 0, -1 );
                addritem_person_set_first_name( current_person, name );
                g_free( name );
@@ -1374,13 +1439,13 @@ static gboolean addressbook_edit_person_close( gboolean cancelled )
 *               only required for new objects).
 *        person Person to edit, or NULL for a new person object.
 *        pgMail If TRUE, E-Mail page will be activated.
-* Return: Edited object, or NULL if cancelled.
-*/
+* Return: Edited object, or NULL if cancelled.*/
 ItemPerson *addressbook_edit_person( AddressBookFile *abf, ItemFolder *parent_folder, ItemPerson *person,
                                                                         gboolean pgMail, GtkWidget *parent_container,
                                                                         void (*post_update_cb) (ItemPerson *person),
                                                                         gboolean get_focus) {
        static gboolean cancelled;
+       GError *error = NULL;
 
        /* set transient data */
        current_abf = abf;
@@ -1388,7 +1453,6 @@ ItemPerson *addressbook_edit_person( AddressBookFile *abf, ItemFolder *parent_fo
        current_parent_folder = parent_folder;
        edit_person_close_post_update_cb = post_update_cb;
        personeditdlg.ldap = (abf && abf->type == ADBOOKTYPE_LDAP)? TRUE : FALSE;
-
        if( !personeditdlg.container )
                addressbook_edit_person_create(parent_container, &cancelled);
 
@@ -1420,17 +1484,31 @@ ItemPerson *addressbook_edit_person( AddressBookFile *abf, ItemFolder *parent_fo
        gtk_entry_set_text(GTK_ENTRY(personeditdlg.entry_nick), "" );
 
        personeditdlg.editNew = FALSE;
-       if( person ) {
-               if( ADDRITEM_NAME(person) )
+       if( current_person ) {
+               if( ADDRITEM_NAME(current_person) )
                        gtk_entry_set_text(GTK_ENTRY(personeditdlg.entry_name), ADDRITEM_NAME(person) );
-               if( person->firstName )
-                       gtk_entry_set_text(GTK_ENTRY(personeditdlg.entry_first), person->firstName );
-               if( person->lastName )
-                       gtk_entry_set_text(GTK_ENTRY(personeditdlg.entry_last), person->lastName );
-               if( person->nickName )
-                       gtk_entry_set_text(GTK_ENTRY(personeditdlg.entry_nick), person->nickName );
-               edit_person_load_email( person );
-               edit_person_load_attrib( person );
+               else
+                       personeditdlg.picture = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, 128, 128);
+               if( current_person->picture ) { 
+                       gchar *filename = g_strconcat( get_rc_dir(), G_DIR_SEPARATOR_S, ADDRBOOK_DIR, G_DIR_SEPARATOR_S, 
+                                                       current_person->picture, NULL );
+                       personeditdlg.picture = gdk_pixbuf_new_from_file(filename, &error);
+                       personeditdlg.picture_set = TRUE;
+                       g_free(filename);
+               } else {
+                       personeditdlg.picture_set = FALSE;
+                       personeditdlg.picture = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, 128, 128);
+               }
+               gtk_image_set_from_pixbuf(GTK_IMAGE(picture), personeditdlg.picture);
+
+               if( current_person->firstName )
+                       gtk_entry_set_text(GTK_ENTRY(personeditdlg.entry_first), current_person->firstName );
+               if( current_person->lastName )
+                       gtk_entry_set_text(GTK_ENTRY(personeditdlg.entry_last), current_person->lastName );
+               if( current_person->nickName )
+                       gtk_entry_set_text(GTK_ENTRY(personeditdlg.entry_nick), current_person->nickName );
+               edit_person_load_email( current_person );
+               edit_person_load_attrib( current_person );
                gtk_entry_set_text(GTK_ENTRY(personeditdlg.entry_atvalue), "");
        }
        else {
@@ -1448,7 +1526,7 @@ ItemPerson *addressbook_edit_person( AddressBookFile *abf, ItemFolder *parent_fo
        gtk_clist_select_row( GTK_CLIST(personeditdlg.clist_email), 0, 0 );
        gtk_clist_select_row( GTK_CLIST(personeditdlg.clist_attrib), 0, 0 );
        edit_person_email_clear( NULL );
-       if (person)
+       if (current_person)
                edit_person_email_list_selected(GTK_CLIST(personeditdlg.clist_email), 0, 0, NULL, NULL);
 
        edit_person_attrib_clear( NULL );
@@ -1462,7 +1540,7 @@ ItemPerson *addressbook_edit_person( AddressBookFile *abf, ItemFolder *parent_fo
                        return NULL;
        }
 
-       return person;
+       return current_person;
 }
 
 /*
index 8cc1c0060cdcd5a3182a7955017461756e2465ba..c369cac520b90b7f08159be519a72dfcf7b188e9 100644 (file)
@@ -45,6 +45,8 @@ struct _PersonEdit_dlg {
        gint status_cid;
 
        /* User data tab */
+       GdkPixbuf *picture;
+       gboolean picture_set;
        GtkWidget *entry_name;
        GtkWidget *entry_first;
        GtkWidget *entry_last;