2007-10-11 [wwp] 3.0.2cvs59
authorTristan Chabredier <wwp@claws-mail.org>
Thu, 11 Oct 2007 11:25:31 +0000 (11:25 +0000)
committerTristan Chabredier <wwp@claws-mail.org>
Thu, 11 Oct 2007 11:25:31 +0000 (11:25 +0000)
* src/pixmaps/anonymous.xpm
* src/editaddress.c
* src/Makefile.am
* src/stock_pixmap.c
* src/stock_pixmap.h
Fix a leak, gettext-ize the photo label.
Don't clear the existing picture if loading
a new one fails. Use a default 'anonymous'
picture (this new xpm has been added to the
internal stock_pixmap API). Add a
"Set picture" context menu entry.

ChangeLog
PATCHSETS
configure.ac
src/Makefile.am
src/editaddress.c
src/pixmaps/anonymous.xpm [new file with mode: 0644]
src/stock_pixmap.c
src/stock_pixmap.h

index 37e98c4b002553314ef3701057d315d74b3cbc92..149048acf805c49671224f8869e8aec8e5c0075a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2007-10-11 [wwp]       3.0.2cvs59
+
+       * src/pixmaps/anonymous.xpm
+       * src/editaddress.c
+       * src/Makefile.am
+       * src/stock_pixmap.c
+       * src/stock_pixmap.h
+               Fix a leak, gettext-ize the photo label.
+               Don't clear the existing picture if loading
+               a new one fails. Use a default 'anonymous'
+               picture (this new xpm has been added to the
+               internal stock_pixmap API). Add a
+               "Set picture" context menu entry.
+
 2007-10-11 [colin]     3.0.2cvs58
 
        * src/messageview.c
index 11832b741bd059bca5bf617605e3b573ea9770b6..42685de9d6e05a978d54108a37c908f3584ac6b1 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.382.2.415 -r 1.382.2.416 src/compose.c;  ) > 3.0.2cvs56.patchset
 ( cvs diff -u -r 1.12.2.49 -r 1.12.2.50 src/prefs_template.c;  ) > 3.0.2cvs57.patchset
 ( cvs diff -u -r 1.94.2.158 -r 1.94.2.159 src/messageview.c;  cvs diff -u -r 1.60.2.52 -r 1.60.2.53 src/prefs_actions.c;  cvs diff -u -r 1.12.2.50 -r 1.12.2.51 src/prefs_template.c;  cvs diff -u -r 1.13.2.32 -r 1.13.2.33 src/common/plugin.c;  cvs diff -u -r 1.2.4.21 -r 1.2.4.22 src/common/template.c;  ) > 3.0.2cvs58.patchset
+( diff -u /dev/null src/pixmaps/anonymous.xpm;  cvs diff -u -r 1.14.2.37 -r 1.14.2.38 src/editaddress.c;  cvs diff -u -r 1.155.2.78 -r 1.155.2.79 src/Makefile.am;  cvs diff -u -r 1.25.2.48 -r 1.25.2.49 src/stock_pixmap.c;  cvs diff -u -r 1.18.2.31 -r 1.18.2.32 src/stock_pixmap.h;  ) > 3.0.2cvs59.patchset
index 3a368cae9269e30c431f4b7a57c5c02b25965394..d8a00a0360c0799cda5e969fa45eb863c2140067 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=0
 MICRO_VERSION=2
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=58
+EXTRA_VERSION=59
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
index 3e1f1e03a97b4b462587a1477eccc2b3e2df10d6..928460087bb235826da7191913ba5456ee742589 100644 (file)
@@ -314,6 +314,7 @@ EXTRA_DIST = \
        pixmaps/address_book.xpm \
        pixmaps/address_search.xpm \
        pixmaps/address.xpm \
+       pixmaps/anonymous.xpm \
        pixmaps/book.xpm \
        pixmaps/category.xpm \
        pixmaps/checkbox_off.xpm \
index ef17f600cd5fba48cf2f4f0badfd8c5b546b241d..05c0777ec4f08a94592626b76e9d10afc3a67550 100644 (file)
@@ -698,57 +698,79 @@ void addressbook_edit_person_widgetset_hide( void )
                gtk_widget_hide( personeditdlg.container );
 }
 
-static void addressbook_edit_person_unset_picture (void *obj, guint action, void *data)
+void addressbook_edit_person_set_picture(void)
 {
-       GdkPixbuf *pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, 48, 48);
-       gdk_pixbuf_fill(pixbuf, 0xffffff00);
+       GError *error = NULL;
+       gchar *filename;
+       int width, height, scalewidth, scaleheight;
+
+       if ( (filename = filesel_select_file_open(_("Choose a picture"), NULL)) ) {
+               GdkPixbuf *pixbuf = NULL;
+               gdk_pixbuf_get_file_info(filename, &width, &height);
+
+               if ( width > 128 || height > 128 ) {
+                       if (width > height) {
+                               scaleheight = (height * 128) / width;
+                               scalewidth = 128;
+                       }
+                       else {
+                               scalewidth = (width * 128) / height;
+                               scaleheight = 128;
+                       }
+                       pixbuf = gdk_pixbuf_new_from_file_at_scale(filename, 
+                                       scalewidth, scaleheight, TRUE, &error);
+               } else {
+                       pixbuf = gdk_pixbuf_new_from_file(filename, &error);
+               }
+               if (error) {
+                       alertpanel_error(_("Failed to import image: \n%s"),
+                                       error->message);
+                       g_error_free(error);
+                       error = NULL;
+                       /* keep the previous picture if any */
+                       g_free(filename);
+                       if (pixbuf)
+                               g_object_unref(pixbuf);
+                       return;
+               }
+               personeditdlg.picture_set = TRUE;
+               g_free(filename);
+               gtk_image_set_from_pixbuf(GTK_IMAGE(personeditdlg.image), pixbuf);
+               g_object_unref(pixbuf);
+       }
+}      
+
+static void addressbook_edit_person_clear_picture(void)
+{
+       GdkPixbuf *pixbuf;
+
+       stock_pixbuf_gdk(NULL, STOCK_PIXMAP_ANONYMOUS, &pixbuf);
        personeditdlg.picture_set = FALSE;
        gtk_image_set_from_pixbuf(GTK_IMAGE(personeditdlg.image), pixbuf);
        g_object_unref(pixbuf);
 }
 
+static void addressbook_edit_person_set_picture_menu_cb (void *obj, guint action, void *data)
+{
+       addressbook_edit_person_set_picture();
+}
+
+static void addressbook_edit_person_unset_picture_menu_cb (void *obj, guint action, void *data)
+{
+       addressbook_edit_person_clear_picture();
+}
+
 static GtkItemFactoryEntry editaddr_popup_entries[] =
 {
-       {N_("/_Unset picture"),         NULL, addressbook_edit_person_unset_picture, 0, NULL},
+       {N_("/_Set picture"),           NULL, addressbook_edit_person_set_picture_menu_cb, 0, NULL},
+       {N_("/_Unset picture"),         NULL, addressbook_edit_person_unset_picture_menu_cb, 0, NULL},
 };
 
-static void addressbook_edit_person_set_picture(GtkWidget *widget, 
+static void addressbook_edit_person_set_picture_cb(GtkWidget *widget, 
                GdkEventButton *event, gpointer data)
-{
-       GError *error = NULL;
-       gchar *filename;
-       int width, height, scalewidth, scaleheight;
-       
+{      
        if (event->button == 1) {
-               if ( (filename = filesel_select_file_open(_("Choose a picture"), NULL)) ) {
-                       GdkPixbuf *pixbuf = NULL;
-                       gdk_pixbuf_get_file_info(filename, &width, &height);
-
-                       if ( width > 128 || height > 128 ) {
-                               if (width > height) {
-                                       scaleheight = (height * 128) / width;
-                                       scalewidth = 128;
-                               }
-                               else {
-                                       scalewidth = (width * 128) / height;
-                                       scaleheight = 128;
-                               }
-                               pixbuf = gdk_pixbuf_new_from_file_at_scale(filename, 
-                                               scalewidth, scaleheight, TRUE, &error);
-                       } else {
-                               pixbuf = gdk_pixbuf_new_from_file(filename, &error);
-                       }
-                       if (error) {
-                               alertpanel_error(_("Failed to import image: \n%s"),
-                                               error->message);
-                               g_error_free(error);
-                               error = NULL;
-                       }
-                       personeditdlg.picture_set = TRUE;
-                       g_free(filename);
-                       gtk_image_set_from_pixbuf(GTK_IMAGE(personeditdlg.image), pixbuf);
-                       g_object_unref(pixbuf);
-               }
+               addressbook_edit_person_set_picture();
        } else {
                gtk_menu_popup(GTK_MENU(personeditdlg.editaddr_popupmenu), 
                               NULL, NULL, NULL, NULL, 
@@ -770,7 +792,6 @@ 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 );
 
@@ -778,14 +799,11 @@ static void addressbook_edit_person_page_basic( gint pageNum, gchar *pageLbl ) {
        
        /* User's picture */
        ebox_picture = gtk_event_box_new();
-       frame_picture = gtk_frame_new("Photo");
+       frame_picture = gtk_frame_new(_("Photo"));
        
        /* Room for a photo */
-       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(pixbuf);
-       g_object_unref(pixbuf);
+       personeditdlg.image = gtk_image_new();
+       addressbook_edit_person_clear_picture();
 
        gtk_container_add(GTK_CONTAINER(ebox_picture), personeditdlg.image);
        gtk_container_add(GTK_CONTAINER(frame_picture), ebox_picture);  
@@ -803,7 +821,7 @@ static void addressbook_edit_person_page_basic( gint pageNum, gchar *pageLbl ) {
                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);
+                       G_CALLBACK(addressbook_edit_person_set_picture_cb), NULL);
 
        n_entries = sizeof(editaddr_popup_entries) /
                sizeof(editaddr_popup_entries[0]);
@@ -1497,7 +1515,7 @@ ItemPerson *addressbook_edit_person( AddressBookFile *abf, ItemFolder *parent_fo
                                                                         gboolean get_focus) {
        static gboolean cancelled;
        GError *error = NULL;
-       GdkPixbuf *pixbuf;
+       GdkPixbuf *pixbuf = NULL;
        /* set transient data */
        current_abf = abf;
        current_person = person;
@@ -1540,11 +1558,13 @@ ItemPerson *addressbook_edit_person( AddressBookFile *abf, ItemFolder *parent_fo
 
        personeditdlg.editNew = FALSE;
        if( current_person ) {
+               gchar *filename;
+
                if( ADDRITEM_NAME(current_person) )
                        gtk_entry_set_text(GTK_ENTRY(personeditdlg.entry_name), ADDRITEM_NAME(person) );
 
                if( current_person->picture ) { 
-                       gchar *filename = g_strconcat( get_rc_dir(), G_DIR_SEPARATOR_S, ADDRBOOK_DIR, G_DIR_SEPARATOR_S, 
+                       filename = g_strconcat( get_rc_dir(), G_DIR_SEPARATOR_S, ADDRBOOK_DIR, G_DIR_SEPARATOR_S, 
                                                        current_person->picture, ".png", NULL );
                        if (is_file_exist(filename)) {
                                pixbuf = gdk_pixbuf_new_from_file(filename, &error);
@@ -1558,16 +1578,16 @@ ItemPerson *addressbook_edit_person( AddressBookFile *abf, ItemFolder *parent_fo
                        } else {
                                goto no_img;
                        }
-                       g_free(filename);
+                       gtk_image_set_from_pixbuf(GTK_IMAGE(personeditdlg.image), pixbuf);
                } else {
 no_img:
-                       personeditdlg.picture_set = FALSE;
-                       pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, 48, 48);
-                       gdk_pixbuf_fill(pixbuf, 0xffffff00);
+                       addressbook_edit_person_clear_picture();
+               }
+               g_free(filename);
+               if (pixbuf) {
+                       g_object_unref(pixbuf);
+                       pixbuf = NULL;
                }
-               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 );
diff --git a/src/pixmaps/anonymous.xpm b/src/pixmaps/anonymous.xpm
new file mode 100644 (file)
index 0000000..a6755ad
--- /dev/null
@@ -0,0 +1,109 @@
+/* XPM */
+static char * anonymous_xpm[] = {
+"96 96 10 1",
+"      c None",
+".     c #565656",
+"+     c #333333",
+"@     c #272727",
+"#     c #1B1B1B",
+"$     c #666666",
+"%     c #383838",
+"&     c #434343",
+"*     c #747474",
+"=     c #898989",
+"                                                                                                ",
+"                                                                                                ",
+"                                                                                                ",
+"                                                                                                ",
+"                                                                                                ",
+"                                             .+@  .#.                                           ",
+"                                          @+++++++++++++@$                                      ",
+"                                       @++++++++++++++++++++@                                   ",
+"                                     %+++++++++++++++++++++++@$                                 ",
+"                                   .@++#+++++++++++++++++++++++@                                ",
+"                                  &+++++++++++++++++++++++++++++@&                              ",
+"                                 %+++++++++++++++++++++++++++++++#*                             ",
+"                                 +++++++++++++++++++++++++++++++++#$                            ",
+"                                %++++++++++++++++++++++++++++++++++#%                           ",
+"                                +++++++++++++++++++++++++++++++++++++.                          ",
+"                               @+++++++++++++++++++++++++++++++++++++#                          ",
+"                              .+++++++++++++++++++++++++++++++++++++++#                         ",
+"                              @++++++++++++++++++++++++++++++++++++++++@                        ",
+"                              ++++++++++++++++++++++++++++++++++++++++++                        ",
+"                              ++++++++++++++++++++++++++++++++++++++++++                        ",
+"                             %++++++++++++++++++++++++++++++++++++++++++@                       ",
+"                             @+++++++++++++++++++++++++++++++++++++++++++                       ",
+"                             ++++++++++++++++++++++++++++++++++++++++++++                       ",
+"                             ++++++++++++++++++++++++++++++++++++++++++++                       ",
+"                             ++++++++++++++++++++++++++++++++++++++++++++                       ",
+"                             ++++++++++++++++++++++++++++++++++++++++++++                       ",
+"                             ++++++++++++++++++++++++++++++++++++++++++++                       ",
+"                             ++++++++++++++++++++++++++++++++++++++++++++                       ",
+"                             ++++++++++++++++++++++++++++++++++++++++++++                       ",
+"                             #+++++++++++++++++++++++++++++++++++++++++++                       ",
+"                             +++++++++++++++++++++++++++++++++++++++++++%                       ",
+"                            .+++++++++++++++++++++++++++++++++++++++++++$                       ",
+"                            @+++++++++++++++++++++++++++++++++++++++++++                        ",
+"                            +++++++++++++++++++++++++++++++++++++++++++#                        ",
+"                            #++++++++++++++++++++++++++++++++++++++++++#                        ",
+"                            ++++++++++++++++++++++++++++++++++++++++++++                        ",
+"                            ++++++++++++++++++++++++++++++++++++++++++++*                       ",
+"                            #+++++++++++++++++++++++++++++++++++++++++++.                       ",
+"                            @+++++++++++++++++++++++++++++++++++++++++++*                       ",
+"                            &+++++++++++++++++++++++++++++++++++++++++++                        ",
+"                             +++++++++++++++++++++++++++++++++++++++++++                        ",
+"                             @+++++++++++++++++++++++++++++++++++++++++@                        ",
+"                              @++++++++++++++++++++++++++++++++++++++++                         ",
+"                               +++++++++++++++++++++++++++++++++++++++#                         ",
+"                               @++++++++++++++++++++++++++++++++++++++                          ",
+"                                +++++++++++++++++++++++++++++++++++++#                          ",
+"                                +++++++++++++++++++++++++++++++++++@&                           ",
+"                                ++++++++++++++++++++++++++++++++++@                             ",
+"                               $+++++++++++++++++++++++++++++++++@                              ",
+"                               $++++++++++++++++++++++++++++++++%                               ",
+"                                ++++++++++++++++++++++++++++++++                                ",
+"                                ++++++++++++++++++++++++++++++++                                ",
+"                                @++++++++++++++++++++++++++++++@                                ",
+"                                 ++++++++++++++++++++++++++++++                                 ",
+"                                 ++++++++++++++++++++++++++++++                                 ",
+"                                 ++++++++++++++++++++++++++++++                                 ",
+"                                 @+++++++++++++++++++++++++++++                                 ",
+"                                 #+++++++++++++++++++++++++++++                                 ",
+"                                &++++++++++++++++++++++++++++++.                                ",
+"                               &++++++++++++++++++++++++++++++++&                               ",
+"                              %++++++++++++++++++++++++++++++++++%                              ",
+"                              #++++++++++++++++++++++++++++++++++#                              ",
+"                              ++++++++++++++++++++++++++++++++++++                              ",
+"                             @++++++++++++++++++++++++++++++++++++@                             ",
+"                            %++++++++++++++++++++++++++++++++++++++&                            ",
+"                          &++++++++++++++++++++++++++++++++++++++++++&                          ",
+"                        ##++++++++++++++++++++++++++++++++++++++++++++##                        ",
+"                      %++++++++++++++++++++++++++++++++++++++++++++++++++%                      ",
+"                    &++++++++++++++++++++++++++++++++++++++++++++++++++++++&                    ",
+"                 %++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++%                 ",
+"               .++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.               ",
+"             .++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.             ",
+"            @++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++%            ",
+"         .#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#.         ",
+"       %++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++&       ",
+"    $#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#$    ",
+"  =#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#   ",
+"&#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++#%",
+"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++",
+"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++",
+"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++",
+"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++",
+"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++",
+"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++",
+"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++",
+"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++",
+"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++",
+"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++",
+"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++",
+"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++",
+"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++",
+"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++",
+"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++",
+"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++",
+"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++",
+"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"};
index 33addfe21383685a49dd7f06b3405b69b87037cf..a0c84fd3439ed26a37de1156601541eac8237d4f 100644 (file)
@@ -32,6 +32,7 @@
 #include "pixmaps/addr_one.xpm"
 #include "pixmaps/addr_two.xpm"
 #include "pixmaps/address.xpm"
+#include "pixmaps/anonymous.xpm"
 #include "pixmaps/book.xpm"
 #include "pixmaps/category.xpm"
 #include "pixmaps/checkbox_off.xpm"
@@ -214,6 +215,7 @@ static StockPixmapData pixmaps[] =
        {address_xpm                            , NULL, NULL, "address", NULL},
        {address_book_xpm                       , NULL, NULL, "address_book", NULL},
        {address_search_xpm                     , NULL, NULL, "address_search", NULL},
+       {anonymous_xpm                          , NULL, NULL, "anonymous", NULL},
        {book_xpm                               , NULL, NULL, "book", NULL},
        {category_xpm                           , NULL, NULL, "category", NULL},
        {checkbox_off_xpm                       , NULL, NULL, "checkbox_off", NULL},
index 821f8b4a589a59762b9956e8e1159f6795f93cb9..0e6ee52657a9cc243da09ad3d805a15c2f55e59b 100644 (file)
@@ -30,6 +30,7 @@ typedef enum
        STOCK_PIXMAP_ADDRESS,
        STOCK_PIXMAP_ADDRESS_BOOK,
        STOCK_PIXMAP_ADDRESS_SEARCH,
+       STOCK_PIXMAP_ANONYMOUS,
        STOCK_PIXMAP_BOOK,
        STOCK_PIXMAP_CATEGORY,
        STOCK_PIXMAP_CHECKBOX_OFF,