2007-11-19 [wwp] 3.1.0cvs3
authorTristan Chabredier <wwp@claws-mail.org>
Mon, 19 Nov 2007 14:42:37 +0000 (14:42 +0000)
committerTristan Chabredier <wwp@claws-mail.org>
Mon, 19 Nov 2007 14:42:37 +0000 (14:42 +0000)
* src/addressbook.c
* src/addressbook.h
* src/editaddress.c
* src/editgroup.c
* src/addrduplicates.c
Minor improvements in the address book:
always accept new contacts provided that some
detail is set (instead of rejecting silently).
Better guessing of contact name from incomplete
name information. Better display of contacts with
no name, in contact lists, group contents, find
duplicate results.

ChangeLog
PATCHSETS
configure.ac
src/addrduplicates.c
src/addressbook.c
src/addressbook.h
src/editaddress.c
src/editgroup.c

index 79eb56355e00d3ef5bd2b9a663385ea655d17cbd..76ae7de831772afba9800827fad4fa531bbfcfa5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2007-11-19 [wwp]       3.1.0cvs3
+
+       * src/addressbook.c
+       * src/addressbook.h
+       * src/editaddress.c
+       * src/editgroup.c
+       * src/addrduplicates.c
+               Minor improvements in the address book:
+               always accept new contacts provided that some
+               detail is set (instead of rejecting silently).
+               Better guessing of contact name from incomplete
+               name information. Better display of contacts with
+               no name, in contact lists, group contents, find
+               duplicate results.
+               
+
 2007-11-19 [wwp]       3.1.0cvs2
 
        * src/compose.c
index 714cde2c4b8c52081aa31f10135da56bacf75f4d..6abfc691156d379c1fd92cce1c8a5f96bf0ede93 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.58.2.33 -r 1.58.2.34 po/de.po;  cvs diff -u -r 1.1.2.15 -r 1.1.2.16 po/fi.po;  cvs diff -u -r 1.42.2.33 -r 1.42.2.34 po/fr.po;  cvs diff -u -r 1.5.2.7 -r 1.5.2.8 po/hu.po;  cvs diff -u -r 1.34.2.23 -r 1.34.2.24 po/it.po;  cvs diff -u -r 1.10.2.14 -r 1.10.2.15 po/pl.po;  cvs diff -u -r 1.50.2.27 -r 1.50.2.28 po/pt_BR.po;  cvs diff -u -r 1.2.2.26 -r 1.2.2.27 po/sk.po;  cvs diff -u -r 1.5.2.25 -r 1.5.2.26 po/zh_CN.po;  ) > 3.0.2cvs145.patchset
 ( cvs diff -u -r 1.1.2.11 -r 1.1.2.12 src/edittags.c;  ) > 3.1.0cvs1.patchset
 ( cvs diff -u -r 1.382.2.421 -r 1.382.2.422 src/compose.c;  cvs diff -u -r 1.50.2.43 -r 1.50.2.44 src/compose.h;  cvs diff -u -r 1.1.2.9 -r 1.1.2.10 src/prefs_logging.c;  cvs diff -u -r 1.1.2.47 -r 1.1.2.48 src/prefs_summaries.c;  ) > 3.1.0cvs2.patchset
+( cvs diff -u -r 1.60.2.105 -r 1.60.2.106 src/addressbook.c;  cvs diff -u -r 1.18.2.11 -r 1.18.2.12 src/addressbook.h;  cvs diff -u -r 1.14.2.44 -r 1.14.2.45 src/editaddress.c;  cvs diff -u -r 1.11.2.17 -r 1.11.2.18 src/editgroup.c;  cvs diff -u -r 1.1.2.6 -r 1.1.2.7 src/addrduplicates.c;  ) > 3.1.0cvs3.patchset
index 3e09e90aeec756cf3737830259c36b062255ac82..f77a1a7519496c3adcbec45299e0a996fb7c2aca 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=1
 MICRO_VERSION=0
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=2
+EXTRA_VERSION=3
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
index aa4c09a2236172f0423ebf9d5afed7ea7060edfd..a009789ce1c76c29fc124d2ace9fb7686dc82ce1 100644 (file)
@@ -581,7 +581,7 @@ static void email_selection_changed(GtkTreeSelection *selection, gpointer data)
                        gtk_list_store_append(detail_store, &iter);
                        gtk_list_store_set(detail_store, &iter,
                                           COL_BOOKPATH, entry->book_path,
-                                          COL_NAME, ADDRITEM_NAME(entry->person),
+                                          COL_NAME, addressbook_set_col_name_guard(ADDRITEM_NAME(entry->person)),
                                           COL_ITEM, entry->person,
                                           COL_DS, entry->ds,
                                           -1);
index f308bcc386ebd0772e180f148f9c893ee9f8f943..0e02007e264133b11fbe468070c11b552e907a9a 100644 (file)
@@ -3390,10 +3390,10 @@ static void addressbook_load_group( GtkCTree *clist, ItemGroup *itemGroup ) {
                person = ( ItemPerson * ) ADDRITEM_PARENT(email);
                str = addressbook_format_item_clist( person, email );
                if( str ) {
-                       text[COL_NAME] = str;
+                       text[COL_NAME] = addressbook_set_col_name_guard(str);
                }
                else {
-                       text[COL_NAME] = ADDRITEM_NAME(person);
+                       text[COL_NAME] = addressbook_set_col_name_guard(ADDRITEM_NAME(person));
                }
                text[COL_ADDRESS] = email->address;
                text[COL_REMARKS] = email->remarks;
@@ -3409,6 +3409,17 @@ static void addressbook_load_group( GtkCTree *clist, ItemGroup *itemGroup ) {
        }
 }
 
+gchar *addressbook_set_col_name_guard(gchar *value)
+{
+       gchar *ret = "<not set>";
+       gchar *tmp = g_strdup(value);
+       g_strstrip(tmp);
+       if (tmp !=NULL && *tmp != '\0')
+               ret = value;
+       g_free(tmp);
+       return ret;
+}
+
 static void addressbook_folder_load_one_person(
                GtkCTree *clist, ItemPerson *person,
                AddressTypeControlItem *atci,
@@ -3440,23 +3451,23 @@ static void addressbook_folder_load_one_person(
                        /* First email belongs with person */
                        gchar *str = addressbook_format_item_clist( person, email );
                        if( str ) {
-                               text[COL_NAME] = str;
+                               text[COL_NAME] = addressbook_set_col_name_guard(str);
                        }
 #ifdef USE_LDAP
                        else if( abf && abf->type == ADDR_IF_LDAP && 
                                 person && person->nickName ) {
                                if (person->nickName) {
                                        if (strcmp(person->nickName, "") != 0) {
-                                               text[COL_NAME] = person->nickName;
+                                               text[COL_NAME] = addressbook_set_col_name_guard(person->nickName);
                                        }
                                        else {
-                                               text[COL_NAME] = ADDRITEM_NAME(person);
+                                               text[COL_NAME] = addressbook_set_col_name_guard(ADDRITEM_NAME(person));
                                        }
                                }
                        }
 #endif
                        else {
-                               text[COL_NAME] = ADDRITEM_NAME(person);
+                               text[COL_NAME] = addressbook_set_col_name_guard(ADDRITEM_NAME(person));
                        }
                        nodePerson = gtk_sctree_insert_node(
                                        clist, NULL, NULL,
@@ -3484,7 +3495,7 @@ static void addressbook_folder_load_one_person(
        }
        if( ! haveAddr ) {
                /* Have name without EMail */
-               text[COL_NAME] = ADDRITEM_NAME(person);
+               text[COL_NAME] = addressbook_set_col_name_guard(ADDRITEM_NAME(person));
                text[COL_ADDRESS] = "";
                text[COL_REMARKS] = "";
                nodePerson = gtk_sctree_insert_node(
index 94fa204516db213f6c4babb41254fb5598e46808..c79fe5cb1ef9260dca9a41036708977527289ff9 100644 (file)
@@ -62,6 +62,7 @@ void addressbook_read_all             ( void );
 void addressbook_address_list_set_focus( void );
 void addressbook_address_list_disable_some_actions( void );
 void addressbook_refresh( void );
+gchar *addressbook_set_col_name_guard(gchar *value);
 
 #endif /* __ADDRESSBOOK_H__ */
 
index ff241d799801b49a803fa17e82a432e871a5419e..7b6e40a0efdd85cfab327a9d8137339ebd967a0e 100644 (file)
@@ -94,6 +94,41 @@ typedef enum {
 #define PAGE_ATTRIBUTES        2
 
 static gboolean addressbook_edit_person_close( gboolean cancelled );
+static GList *edit_person_build_email_list();
+static GList *edit_person_build_attrib_list();
+
+static gchar* edit_person_get_common_name_from_widgets(void)
+{
+       gchar *cn = NULL; /* cn must be freed by caller */
+
+#ifndef MAEMO
+       {
+               cn = gtk_editable_get_chars( GTK_EDITABLE(personeditdlg.entry_name), 0, -1 );
+               if ( cn == NULL || *cn == '\0' ) {
+                       gchar *first = gtk_editable_get_chars( GTK_EDITABLE(personeditdlg.entry_first), 0, -1 );
+                       gchar *last = gtk_editable_get_chars( GTK_EDITABLE(personeditdlg.entry_last), 0, -1 );
+                       cn = g_strdup_printf("%s%s%s", first?first:"", (first && last && *first && *last)?" ":"", last?last:"");
+                       g_free(first);
+                       g_free(last);
+               }
+               if ( cn == NULL || *cn == '\0' ) {
+                       g_free(cn);
+                       cn = gtk_editable_get_chars( GTK_EDITABLE(personeditdlg.entry_nick), 0, -1 );;
+               }
+       }
+#else
+       {
+               gchar *first = gtk_editable_get_chars( GTK_EDITABLE(personeditdlg.entry_first), 0, -1 );
+               gchar *last = gtk_editable_get_chars( GTK_EDITABLE(personeditdlg.entry_last), 0, -1 );
+               cn = g_strdup_printf("%s%s%s", first?first:"", (first && last && *first && *last)?" ":"", last?last:"");
+               g_free(first);
+               g_free(last);
+       }
+#endif
+       if ( cn != NULL )
+               g_strstrip(cn);
+       return cn;
+}
 
 static void edit_person_status_show( gchar *msg ) {
        if( personeditdlg.statusbar != NULL ) {
@@ -104,16 +139,47 @@ static void edit_person_status_show( gchar *msg ) {
        }
 }
 
-static void edit_person_ok(GtkWidget *widget, gboolean *cancelled) {
-       *cancelled = FALSE;
+static void edit_person_cancel(GtkWidget *widget, gboolean *cancelled) {
+       *cancelled = TRUE;
        if (prefs_common.addressbook_use_editaddress_dialog)
                gtk_main_quit();
        else
                addressbook_edit_person_close( *cancelled );
 }
 
-static void edit_person_cancel(GtkWidget *widget, gboolean *cancelled) {
-       *cancelled = TRUE;
+static void edit_person_ok(GtkWidget *widget, gboolean *cancelled) {
+       GList *listEMail = edit_person_build_email_list();
+       GList *listAttrib = edit_person_build_attrib_list();
+       gchar *cn = edit_person_get_common_name_from_widgets();
+
+       if( (cn == NULL || *cn == '\0') && listEMail == NULL && listAttrib == NULL ) {
+               gint val;
+
+               val = alertpanel( _("Add New Person"),
+                               _("Adding a new person requires at least one of the\n"
+                                 "information above to be set:\n"
+#ifndef MAEMO
+                                 " - Display Name\n"
+#endif
+                                 " - First Name\n"
+                                 " - Last Name\n"
+#ifndef MAEMO
+                                 " - Nickname\n"
+#endif
+                                 " - any email address\n"
+                                 " - any additional attribute\n\n"
+                                 "Click OK to keep editing this contact.\n"
+                                 "Click Cancel to close without saving."),
+                               GTK_STOCK_CANCEL, "+"GTK_STOCK_OK, NULL );
+               if( val == G_ALERTALTERNATE ) {
+                       edit_person_cancel(widget, cancelled);
+               }
+               g_free( cn );
+               return;
+       }
+       g_free( cn );
+
+       *cancelled = FALSE;
        if (prefs_common.addressbook_use_editaddress_dialog)
                gtk_main_quit();
        else
@@ -183,7 +249,11 @@ static void edit_person_set_window_title( gint pageNum ) {
                else {
                        gchar *name;
                        name = gtk_editable_get_chars( GTK_EDITABLE(personeditdlg.entry_name), 0, -1 );
-                       sTitle = g_strdup_printf( "%s - %s", _title_edit_, name );
+                       g_strstrip(name);
+                       if ( *name != '\0' )
+                               sTitle = g_strdup_printf( "%s - %s", _title_edit_, name );
+                       else
+                               sTitle = g_strdup( _title_edit_ );
                        g_free( name );
                }
                if (prefs_common.addressbook_use_editaddress_dialog)
@@ -1431,7 +1501,6 @@ static gboolean addressbook_edit_person_close( gboolean cancelled )
        GList *listEMail = NULL;
        GList *listAttrib = NULL;
        GError *error = NULL;
-       gchar *cn = NULL;
 
        listEMail = edit_person_build_email_list();
        listAttrib = edit_person_build_attrib_list();
@@ -1454,17 +1523,6 @@ static gboolean addressbook_edit_person_close( gboolean cancelled )
                return FALSE;
        }
 
-#ifndef MAEMO
-       cn = gtk_editable_get_chars( GTK_EDITABLE(personeditdlg.entry_name), 0, -1 );
-#else
-       {
-               gchar *first = gtk_editable_get_chars( GTK_EDITABLE(personeditdlg.entry_first), 0, -1 );
-               gchar *last = gtk_editable_get_chars( GTK_EDITABLE(personeditdlg.entry_last), 0, -1 );
-               cn = g_strdup_printf("%s%s%s", first?first:"", (first && last && *first && *last)?" ":"", last?last:"");
-               g_free(first);
-               g_free(last);
-       }
-#endif
        if( current_person && current_abf ) {
                /* Update email/attribute list for existing current_person */
                addrbook_update_address_list( current_abf, current_person, listEMail );
@@ -1472,10 +1530,6 @@ static gboolean addressbook_edit_person_close( gboolean cancelled )
        }
        else {
                /* Create new current_person and email/attribute list */
-               if( cn == NULL || *cn == '\0' ) {
-                       /* Wasting our time */
-                       if( listEMail == NULL && listAttrib == NULL ) cancelled = TRUE;
-               }
                if( ! cancelled && current_abf ) {
                        current_person = addrbook_add_address_list( current_abf, current_parent_folder, listEMail );
                        addrbook_add_attrib_list( current_abf, current_person, listAttrib );
@@ -1488,7 +1542,11 @@ static gboolean addressbook_edit_person_close( gboolean cancelled )
                /* Set current_person stuff */          
 
                gchar *name;
+               gchar *cn = edit_person_get_common_name_from_widgets();
+
                addritem_person_set_common_name( current_person, cn );
+               g_free( cn );
+
                if (personeditdlg.picture_set) { 
                        GdkPixbuf * pixbuf = gtk_image_get_pixbuf(GTK_IMAGE(personeditdlg.image));
 
@@ -1530,7 +1588,6 @@ static gboolean addressbook_edit_person_close( gboolean cancelled )
                addritem_person_set_nick_name( current_person, name );
                g_free( name );
        }
-       g_free( cn );
 
        gtk_clist_clear( GTK_CLIST(personeditdlg.clist_email) );
        gtk_clist_clear( GTK_CLIST(personeditdlg.clist_attrib) );
index 7697340ca0b02de0433ce917da6c24d26fbe317e..2d86d3ea6248a4946297270c6eb2c40397842949 100644 (file)
@@ -140,10 +140,10 @@ static gint edit_group_clist_add_email( GtkCList *clist, ItemEMail *email ) {
        gchar *text[ GROUP_N_COLS ];
        gint row;
        if( str ) {
-               text[ GROUP_COL_NAME ] = str;
+               text[ GROUP_COL_NAME ] = addressbook_set_col_name_guard(str);
        }
        else {
-               text[ GROUP_COL_NAME ] = ADDRITEM_NAME(person);
+               text[ GROUP_COL_NAME ] = addressbook_set_col_name_guard(ADDRITEM_NAME(person));
        }
        text[ GROUP_COL_EMAIL   ] = email->address;
        text[ GROUP_COL_REMARKS ] = email->remarks;