2007-10-10 [claws] 3.0.2cvs49
authorColin Leroy <colin@colino.net>
Wed, 10 Oct 2007 09:48:41 +0000 (09:48 +0000)
committerColin Leroy <colin@colino.net>
Wed, 10 Oct 2007 09:48:41 +0000 (09:48 +0000)
* src/summaryview.c
* src/messageview.c
Fix crash on Add sender to addressbook when
From is null
* src/addressadd.c
* src/addrindex.c
* src/editaddress.c
* src/editaddress_other_attributes_ldap.h
Fix leaks
Rename images to .png in addrbook/
* src/headerview.c
* src/textview.c
Fix Face/X-Face being used if adding another
address than sender to addressbook
Thanks to Colin

ChangeLog
PATCHSETS
configure.ac
src/addressadd.c
src/addrindex.c
src/editaddress.c
src/editaddress_other_attributes_ldap.h
src/headerview.c
src/messageview.c
src/summaryview.c
src/textview.c

index 05678a3da82917b488021e692f6146d9dc8a394f..a25d17e13f1f7e11e550908702c7c7b0001bbffd 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+2007-10-10 [claws]     3.0.2cvs49
+
+       * src/summaryview.c
+       * src/messageview.c
+               Fix crash on Add sender to addressbook when
+               From is null
+       * src/addressadd.c
+       * src/addrindex.c
+       * src/editaddress.c
+       * src/editaddress_other_attributes_ldap.h
+               Fix leaks 
+               Rename images to .png in addrbook/
+       * src/headerview.c
+       * src/textview.c
+               Fix Face/X-Face being used if adding another
+               address than sender to addressbook
+               Thanks to Colin
+
 2007-10-10 [holger]    3.0.2cvs48
 
        * src/addrduplicates.c
index 256a05d90c962975c7389d91087e418615412f0c..9009350823d03eb61969935007f832197e9c97fa 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.94.2.156 -r 1.94.2.157 src/messageview.c;  cvs diff -u -r 1.395.2.328 -r 1.395.2.329 src/summaryview.c;  cvs diff -u -r 1.96.2.184 -r 1.96.2.185 src/textview.c;  ) > 3.0.2cvs46.patchset
 ( cvs diff -u -r 1.28.2.34 -r 1.28.2.35 src/addrindex.c;  ) > 3.0.2cvs47.patchset
 ( cvs diff -u -r 1.1.2.3 -r 1.1.2.4 src/addrduplicates.c;  cvs diff -u -r 1.14.2.32 -r 1.14.2.33 src/editaddress.c;  ) > 3.0.2cvs48.patchset
+( cvs diff -u -r 1.9.2.17 -r 1.9.2.18 src/addressadd.c;  cvs diff -u -r 1.28.2.35 -r 1.28.2.36 src/addrindex.c;  cvs diff -u -r 1.14.2.33 -r 1.14.2.34 src/editaddress.c;  cvs diff -u -r 1.1.2.5 -r 1.1.2.6 src/editaddress_other_attributes_ldap.h;  cvs diff -u -r 1.8.2.24 -r 1.8.2.25 src/headerview.c;  cvs diff -u -r 1.94.2.157 -r 1.94.2.158 src/messageview.c;  cvs diff -u -r 1.395.2.329 -r 1.395.2.330 src/summaryview.c;  cvs diff -u -r 1.96.2.185 -r 1.96.2.186 src/textview.c;  ) > 3.0.2cvs49.patchset
index c5d65f3ceae2c2f1a518cc67ce9f76f3ec3f41d3..688bc1d5a4fd8bb37be2bde8aba9d3df1507a78f 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=0
 MICRO_VERSION=2
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=48
+EXTRA_VERSION=49
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
index 4f0df55fcf420a61a17beb61853d949674bbd650..82924d1c6287fb2c336cb8dd677a8338a9fa7953 100644 (file)
@@ -439,7 +439,7 @@ gboolean addressadd_selection( AddressIndex *addrIndex, const gchar *name,
                        if (picture) {
                                GError *error = NULL;
                                gchar *name = g_strconcat( get_rc_dir(), G_DIR_SEPARATOR_S, ADDRBOOK_DIR, G_DIR_SEPARATOR_S, 
-                                                       ADDRITEM_ID(person), NULL );
+                                                       ADDRITEM_ID(person), NULL, ".png" );
                                gdk_pixbuf_save(picture, name, "png", &error, NULL);
                                addritem_person_set_picture( person, ADDRITEM_ID(person) ) ;
                                g_free( name );
index 32542f92f6f7e05c448da5e5bc1d216a7c2822de..454fd9ab26a7530b7d003f01fd44e75ba1084104 100644 (file)
@@ -3220,7 +3220,7 @@ gchar *addrindex_get_picture_file(const gchar *emailaddr)
                                                found = TRUE;
                                                filename = g_strconcat( get_rc_dir(), G_DIR_SEPARATOR_S, 
                                                        ADDRBOOK_DIR, G_DIR_SEPARATOR_S, 
-                                                       person->picture, NULL );
+                                                       person->picture, NULL, ".png" );
                                                break;
                                        }
                                        nodeM = nodeM->next;
index 9b24078e2a0338aa118563e20a015fa1df599dc8..1b27317b569af3fec0e845ba581c3dd6519fb223 100644 (file)
@@ -700,10 +700,11 @@ void addressbook_edit_person_widgetset_hide( void )
 
 static void addressbook_edit_person_unset_picture (void *obj, guint action, void *data)
 {
-       personeditdlg.pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, 48, 48);
-       gdk_pixbuf_fill(personeditdlg.pixbuf, 0xffffff00);
+       GdkPixbuf *pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, 48, 48);
+       gdk_pixbuf_fill(pixbuf, 0xffffff00);
        personeditdlg.picture_set = FALSE;
-       gtk_image_set_from_pixbuf(GTK_IMAGE(personeditdlg.image), personeditdlg.pixbuf);
+       gtk_image_set_from_pixbuf(GTK_IMAGE(personeditdlg.image), pixbuf);
+       g_object_unref(pixbuf);
 }
 
 static GtkItemFactoryEntry editaddr_popup_entries[] =
@@ -720,16 +721,8 @@ static void addressbook_edit_person_set_picture(GtkWidget *widget,
        
        if (event->button == 1) {
                if ( (filename = filesel_select_file_open(_("Choose a picture"), NULL)) ) {
-                       personeditdlg.pixbuf = gdk_pixbuf_new_from_file(filename, &error);
-                       if (error) {
-                               alertpanel_error(_("Failed to import image: \n%s"),
-                                               error->message);
-                               g_error_free(error);
-                       }
-                       personeditdlg.picture_set = TRUE;
-                       g_free(filename);
-                       width = gdk_pixbuf_get_width(personeditdlg.pixbuf);
-                       height = gdk_pixbuf_get_height(personeditdlg.pixbuf);
+                       GdkPixbuf *pixbuf = NULL;
+                       gdk_pixbuf_get_file_info(filename, &width, &height);
 
                        if ( width > 128 || height > 128 ) {
                                if (width > height) {
@@ -740,9 +733,20 @@ static void addressbook_edit_person_set_picture(GtkWidget *widget,
                                        scalewidth = (width * 128) / height;
                                        scaleheight = 128;
                                }
-                               personeditdlg.pixbuf = gdk_pixbuf_scale_simple(personeditdlg.pixbuf, scalewidth, scaleheight, GDK_INTERP_BILINEAR);
+                               pixbuf = gdk_pixbuf_new_from_file_at_scale(filename, 
+                                               scalewidth, scaleheight, TRUE, &error);
+                       } else {
+                               pixbuf = gdk_pixbuf_new_from_file(filename, &error);
                        }
-               gtk_image_set_from_pixbuf(GTK_IMAGE(personeditdlg.image), personeditdlg.pixbuf);
+                       if (error) {
+                               alertpanel_error(_("Failed to import image: \n%s"),
+                                               error->message);
+                               g_error_free(error);
+                       }
+                       personeditdlg.picture_set = TRUE;
+                       g_free(filename);
+                       gtk_image_set_from_pixbuf(GTK_IMAGE(personeditdlg.image), pixbuf);
+                       g_object_unref(pixbuf);
                }
        } else {
                gtk_menu_popup(GTK_MENU(personeditdlg.editaddr_popupmenu), 
@@ -765,7 +769,7 @@ static void addressbook_edit_person_page_basic( gint pageNum, gchar *pageLbl ) {
        const gchar *locale;
        gint top = 0;
        gint n_entries;
-
+       GdkPixbuf *pixbuf;
        vbox = gtk_vbox_new( FALSE, 20 );
        hbox = gtk_hbox_new( FALSE, 8 );
 
@@ -776,11 +780,12 @@ static void addressbook_edit_person_page_basic( gint pageNum, gchar *pageLbl ) {
        frame_picture = gtk_frame_new("Photo");
        
        /* Room for a photo */
-       personeditdlg.pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, 48, 48);
-       gdk_pixbuf_fill(personeditdlg.pixbuf, 0xffffff00);
+       pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, 48, 48);
+       gdk_pixbuf_fill(pixbuf, 0xffffff00);
        personeditdlg.picture_set = FALSE;
-       personeditdlg.image = gtk_image_new_from_pixbuf(personeditdlg.pixbuf);
-       
+       personeditdlg.image = gtk_image_new_from_pixbuf(pixbuf);
+       g_object_unref(pixbuf);
+
        gtk_container_add(GTK_CONTAINER(ebox_picture), personeditdlg.image);
        gtk_container_add(GTK_CONTAINER(frame_picture), ebox_picture);  
        gtk_container_add(GTK_CONTAINER( personeditdlg.notebook ), hbox );
@@ -1437,14 +1442,15 @@ static gboolean addressbook_edit_person_close( gboolean cancelled )
                gchar *name;
                addritem_person_set_common_name( current_person, cn );
                if (personeditdlg.picture_set) {
+                       GdkPixbuf * pixbuf = gtk_image_get_pixbuf(GTK_IMAGE(personeditdlg.image));
                        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.pixbuf, name, "png", &error, NULL);
+                                                       ADDRITEM_ID(current_person), NULL, ".png" );
+                       gdk_pixbuf_save(pixbuf, name, "png", &error, NULL);
                        addritem_person_set_picture( current_person, ADDRITEM_ID(current_person) ) ;
                        g_free( name );
                } else {
                        name = g_strconcat( get_rc_dir(), G_DIR_SEPARATOR_S, ADDRBOOK_DIR, G_DIR_SEPARATOR_S, 
-                                                       ADDRITEM_ID(current_person), NULL );
+                                                       ADDRITEM_ID(current_person), NULL, ".png" );
                        g_unlink(name);
                        g_free(name);
                }
@@ -1485,7 +1491,7 @@ ItemPerson *addressbook_edit_person( AddressBookFile *abf, ItemFolder *parent_fo
                                                                         gboolean get_focus) {
        static gboolean cancelled;
        GError *error = NULL;
-
+       GdkPixbuf *pixbuf;
        /* set transient data */
        current_abf = abf;
        current_person = person;
@@ -1533,9 +1539,9 @@ ItemPerson *addressbook_edit_person( AddressBookFile *abf, ItemFolder *parent_fo
 
                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 );
+                                                       current_person->picture, NULL, ".png" );
                        if (is_file_exist(filename)) {
-                               personeditdlg.pixbuf = gdk_pixbuf_new_from_file(filename, &error);
+                               pixbuf = gdk_pixbuf_new_from_file(filename, &error);
                                if (error) {
                                        debug_print("Failed to import image: \n%s",
                                                        error->message);
@@ -1550,10 +1556,12 @@ ItemPerson *addressbook_edit_person( AddressBookFile *abf, ItemFolder *parent_fo
                } else {
 no_img:
                        personeditdlg.picture_set = FALSE;
-                       personeditdlg.pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, 48, 48);
-                       gdk_pixbuf_fill(personeditdlg.pixbuf, 0xffffff00);
+                       pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, 48, 48);
+                       gdk_pixbuf_fill(pixbuf, 0xffffff00);
                }
-               gtk_image_set_from_pixbuf(GTK_IMAGE(personeditdlg.image), personeditdlg.pixbuf);
+               gtk_image_set_from_pixbuf(GTK_IMAGE(personeditdlg.image), pixbuf);
+               g_object_unref(pixbuf);
+               pixbuf = NULL;
 
                if( current_person->firstName )
                        gtk_entry_set_text(GTK_ENTRY(personeditdlg.entry_first), current_person->firstName );
index 1e9cd5581c071c89acdf9c6d902087bf3fffbf56..2c1c4d6cb16dec8ea0b742a028936e1a9d942e0d 100644 (file)
@@ -46,7 +46,6 @@ struct _PersonEdit_dlg {
        gint status_cid;
 
        /* User data tab */
-       GdkPixbuf *pixbuf;
        GtkWidget *image;
        gboolean picture_set;
        GtkWidget *entry_name;
index 4d8e2a1d36fdcb721b0d25bcdf9e03278859680b..a9621ac314edb31974d910c21943173c712bdd43 100644 (file)
@@ -392,6 +392,7 @@ static gint headerview_show_contact_pic (HeaderView *headerview, MsgInfo *msginf
        else 
                return -1;
 
+       g_object_unref(picture);
        if (image) {
                gtk_box_pack_start(GTK_BOX(hbox), image, FALSE, FALSE, 0);
                gtk_widget_show(image);
index ab3ff1f37d1cc241ebc218da42335a172c13c20b..19f8db7f3f976e6186d9dc2b5b4d887c22733c03 100644 (file)
@@ -2265,7 +2265,9 @@ static void add_address_cb(gpointer data, guint action, GtkWidget *widget)
        GtkWidget *image = NULL;
        GdkPixbuf *picture = NULL;
 
-       if (!messageview->msginfo) return;
+       if (!messageview->msginfo || !messageview->msginfo->from) 
+               return;
+
        msginfo = messageview->msginfo;
        Xstrdup_a(from, msginfo->from, return);
        eliminate_address_comment(from);
index 44f2e412e8ce56856f02075bc446ab5c6ca7f7f6..1e82ab728879cdf2db1966f3e6f5a51242c9a8e7 100644 (file)
@@ -4314,7 +4314,8 @@ void summary_add_address(SummaryView *summaryview)
 
        msginfo = gtk_ctree_node_get_row_data(GTK_CTREE(summaryview->ctree),
                                              summaryview->selected);
-       if (!msginfo) return;
+       if (!msginfo || !msginfo->from) 
+               return;
 
        Xstrdup_a(from, msginfo->from, return);
        eliminate_address_comment(from);
index 41736fb754e9c07f6435be38ddc941e3d5f7a5da..60169413f81fca250a84a9c4208d85832aa62c90 100644 (file)
@@ -1971,9 +1971,10 @@ static void textview_show_contact_pic(TextView *textview)
        }
        g_free(filename);
 
-       if (picture)
+       if (picture) {
                textview->image = gtk_image_new_from_pixbuf(picture);
-
+               g_object_unref(picture);
+       }
        g_return_if_fail(textview->image != NULL);
 
        gtk_widget_show(textview->image);
@@ -2905,23 +2906,29 @@ static void add_uri_to_addrbook_cb (TextView *textview, guint action, void *data
                                           "menu_button");
        GtkWidget *image = NULL;
        GdkPixbuf *picture = NULL;
-
+       gboolean use_picture = FALSE;
        if (uri == NULL)
                return;
 
        /* extract url */
        fromaddress = g_strdup(uri->uri + 7);
-       /* Hiroyuki: please put this function in utils.c! */
+       
+       if (textview->messageview->msginfo &&
+          !strcmp2(fromaddress, textview->messageview->msginfo->from))
+               use_picture = TRUE;
+
        fromname = procheader_get_fromname(fromaddress);
        extract_address(fromaddress);
 
-       if (textview->messageview->msginfo &&
+       if (use_picture && 
+           textview->messageview->msginfo &&
            textview->messageview->msginfo->extradata &&
            textview->messageview->msginfo->extradata->face) {
                image = face_get_from_header(textview->messageview->msginfo->extradata->face);
        }
 #if HAVE_LIBCOMPFACE 
-       else if (textview->messageview->msginfo &&
+       else if (use_picture && 
+                textview->messageview->msginfo &&
                 textview->messageview->msginfo->extradata &&
                 textview->messageview->msginfo->extradata->xface) {
                image = xface_get_from_header(textview->messageview->msginfo->extradata->xface,