improvements to cut/copy/paste addresses
authorMatch Grun <match@dimensional.com>
Tue, 6 Aug 2002 06:35:04 +0000 (06:35 +0000)
committerMatch Grun <match@dimensional.com>
Tue, 6 Aug 2002 06:35:04 +0000 (06:35 +0000)
ChangeLog.claws
configure.in
src/addrclip.c

index ae039bb5c89375ced5bb4ef3b1e8a13a04bd4760..1100d65e2c6d7d82d9820e9912e1a8a5e5ba7e1b 100644 (file)
@@ -1,3 +1,8 @@
+2002-08-06 [match]     0.8.0claws21
+
+       * src/addrclip.c
+               improvements to cut/copy/paste address
+
 2002-08-05 [match]     0.8.0claws20
 
        * src/addritem.[ch]
index 6fa504d8b95dbf36db4843c085fc272364e6b649..59323adb92f5db87495d6e39530dcd4e515c2db5 100644 (file)
@@ -8,7 +8,7 @@ MINOR_VERSION=8
 MICRO_VERSION=1
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=claws20
+EXTRA_VERSION=claws21
 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
 
 dnl set $target
index 5e86739d2d9970d003e6daa8c0250e6bdf8172ee..4fd7896374680568eaf9069a6435cea24b8472e6 100644 (file)
@@ -161,6 +161,13 @@ void addrclip_add_item(
        }
 }
 
+static void addrclip_print( AddrSelectItem *item, FILE *stream ) {
+       fprintf( stream, "Select Record\n" );
+       fprintf( stream, "obj type: %d\n", item->objectType );
+       fprintf( stream, "     uid: %s\n", item->uid );
+       fprintf( stream, "---\n" );
+}
+
 /*
 * Show clipboard contents.
 * Enter: clipBoard Clipboard.
@@ -172,7 +179,6 @@ void addrclip_list_show( AddressClipboard *clipBoard, FILE *stream ) {
        AddressCache *cache;
 
        g_return_if_fail( clipBoard != NULL );
-       fprintf( stream, "clipboard show selection...>>>\n" );
        node = clipBoard->objectList;
        while( node != NULL ) {
                AddrSelectItem *item;
@@ -198,7 +204,6 @@ void addrclip_list_show( AddressClipboard *clipBoard, FILE *stream ) {
                }
                node = g_list_next( node );
        }
-       fprintf( stream, "clipboard show selection...<<<\n" );
 }
 
 /* Pasted address pointers */
@@ -279,6 +284,79 @@ static GList *addrclip_cache_add_person(
        return copyList;
 }
 
+/*
+ * Paste unattached email into cache.
+ * Enter: cache    Address cache to paste into.
+ *        folder   Folder to store
+ *        email    EMail to add.
+ *        copyList List of email addresses pasted.
+ * Return: Update list of email addresses pasted.
+ */
+static GList *addrclip_cache_add_email(
+       AddressCache *cache, ItemFolder *folder, ItemEMail *email,
+       GList *copyList )
+{
+       ItemPerson *newPerson;
+       ItemEMail *newEMail;
+       AddrClip_EMail *em;
+
+       /* Create a person */
+       newPerson = addritem_create_item_person();
+       addritem_person_set_common_name( newPerson, "" );
+       addrcache_id_person( cache, newPerson );
+       addrcache_folder_add_person( cache, folder, newPerson );
+
+       /* Copy email addresses */
+       newEMail = addritem_copy_item_email( email );
+       addrcache_id_email( cache, newEMail );
+       addrcache_person_add_email( cache, newPerson, newEMail );
+
+       /* Take a copy of the original */
+       em = g_new0( AddrClip_EMail, 1 );
+       em->original = email;
+       em->copy = newEMail;
+       copyList = g_list_append( copyList, em );
+
+       return copyList;
+}
+
+/*
+ * Test whether specified E-Mail address object is already in clipboard and
+ * owned by an ItemPerson objects.
+ * Enter: email  E-Mail to test.
+ * Return: TRUE if duplicate found.
+ */
+static gboolean addrclip_test_email(
+       AddressClipboard *clipBoard, ItemEMail *testEMail )
+{
+       ItemPerson *person;
+       ItemEMail *email;
+       GList *node, *nodeMail;
+       AddrSelectItem *item;
+       AddrItemObject *aio;
+       AddressCache *cache;
+
+       node = clipBoard->objectList;
+       while( node ) {
+               item = node->data;
+               cache = addrindex_get_cache( clipBoard->addressIndex, item->cacheID );
+               aio = addrcache_get_object( cache, item->uid );
+               if( aio ) {
+                       if( ADDRITEM_TYPE(aio) == ITEMTYPE_PERSON ) {
+                               person = ( ItemPerson * ) aio;
+                               nodeMail = person->listEMail;
+                               while( nodeMail ) {
+                                       email = nodeMail->data;
+                                       if( email == testEMail ) return TRUE;
+                                       nodeMail = g_list_next( nodeMail );
+                               }
+                       }
+               }
+               node = g_list_next( node );
+       }
+       return FALSE;
+}
+
 /*
  * Search for new email record in copied email list.
  * Enter: copyList  List of copied email address mappings.
@@ -895,7 +973,7 @@ static gint addrclip_person_move_email(
        GList *node;
 
        cnt = 0;
-       while((node = fromPerson->listEMail) != NULL) {
+       while( node = fromPerson->listEMail ) {
                ItemEMail *email;
 
                email = node->data;
@@ -938,6 +1016,16 @@ static gint addrclip_paste_person_move(
                                fromPerson = ( ItemPerson * ) aio;
                                cnt += addrclip_person_move_email(
                                        cache, fromPerson, person );
+
+                               if( addritem_person_empty( fromPerson ) ) {
+                                       fromPerson =
+                                               addrcache_remove_person(
+                                                       cacheFrom, fromPerson );
+                                       if( fromPerson != NULL ) {
+                                               addritem_free_item_person( fromPerson );
+                                       }
+                               }
+                               fromPerson = NULL;
                        }
                        else if( ADDRITEM_TYPE(aio) == ITEMTYPE_EMAIL ) {
                                ItemEMail *email;
@@ -982,7 +1070,6 @@ gint addrclip_paste_person_cut(
                clipBoard->moveFlag = FALSE;
                cacheFrom = addrclip_list_get_cache( clipBoard );
                if( cacheFrom && cacheFrom == cache ) {
-                       /* Move items between folders in same book */
                        cnt = addrclip_paste_person_move(
                                clipBoard, cache, person );
                        clipBoard->moveFlag = TRUE;