[PATCH] Re: Handling of delete with IMAP



On 2001.12.15 06:53 Peter Bloomfield wrote:
[snip]
>   One problem arises: `Delete' immediately removes the message from 
> the index, so you don't get a chance to change your mind, as you 
> would if you moved the message to Trash.
>   Balsa seems to have been designed with something else in mind, 
> since the Message menu has an Undelete item, which currently isn't 
> much use. The attached patch gives the Undelete item something to do, 
> by leaving deleted messages in the index with the trashcan icon to 
> show that they've been deleted.
[snip]
> Comments or suggestions?

There's clearly room for more discussion of larger changes, but the 
need for user control over the action of `delete' is obvious. Here's a 
new patch, including pref-page stuff. All it does is give the user the 
choice of whether `delete' is immediate and irretrievable, or leaves 
the message(s) flagged for a short time.

Well, that's almost all. It also fixes the index context menu to show 
the `delete' item only if there's an undeleted message selected, the 
`undelete' item only if there's a deleted message selected, and the 
`move to trash' item only if the current mailbox isn't the Trash. 
There's also an update to the help file for the `Misc' pref page, 
including the new check-button.

Peter
diff -u -r1.38 balsa.sgml
--- help/C/balsa.sgml	2001/12/06 22:51:11	1.38
+++ help/C/balsa.sgml	2001/12/15 23:33:03
@@ -2564,6 +2564,37 @@
   </listitem>
 </varlistentry>
 
+<varlistentry>
+  <term><guilabel>Automatically close mailbox</guilabel></term>
+  <listitem>
+    <para>&Balsa; can close mailboxes for you after the specified time.</para>
+  </listitem>
+</varlistentry>
+
+<varlistentry>
+  <term><guilabel>Drag-and-drop moves messages by default</guilabel></term>
+  <listitem>
+    <para>When you drag and drop a message to a destination mailbox, it
+    may be moved (not leaving a copy in the source mailbox) or copied.
+    This option sets the default action; use the Control key when
+    dragging to have the opposite effect.</para>
+  </listitem>
+</varlistentry>
+
+<varlistentry>
+  <term><guilabel>Deleting messages</guilabel></term> <listitem>
+    <para>When you delete a message or messages, &Balsa; can either
+      delete them immediately, or flag them as deleted and actually delete
+      them later. If they are flagged as deleted, you can then go back
+      and Undelete them if you change your mind. Messages flagged as
+      deleted are removed when you close the mailbox, when you commit
+      changes, or when you move any messages out of the mailbox.</para>
+    <para>This has no effect on trashing messages by moving them to the
+      Trash folder; a message may always be retrieved from the Trash,
+      until the Trash folder is emptied.</para>
+  </listitem>
+</varlistentry>
+
 </variablelist>
 </sect1>
 
Index: libbalsa/mailbox.c
===================================================================
RCS file: /cvs/gnome/balsa/libbalsa/mailbox.c,v
retrieving revision 1.184
diff -u -r1.184 mailbox.c
--- libbalsa/mailbox.c	2001/11/25 22:42:09	1.184
+++ libbalsa/mailbox.c	2001/12/15 23:33:03
@@ -624,19 +624,19 @@
 	message = translate_message(cur);
 	message->mailbox = mailbox;
 
-	gtk_signal_connect(GTK_OBJECT(message), "clear-flags",
+	gtk_signal_connect_after(GTK_OBJECT(message), "clear-flags",
 			   GTK_SIGNAL_FUNC(message_status_changed_cb),
 			   mailbox);
-	gtk_signal_connect(GTK_OBJECT(message), "set-answered",
+	gtk_signal_connect_after(GTK_OBJECT(message), "set-answered",
 			   GTK_SIGNAL_FUNC(message_status_changed_cb),
 			   mailbox);
-	gtk_signal_connect(GTK_OBJECT(message), "set-read",
+	gtk_signal_connect_after(GTK_OBJECT(message), "set-read",
 			   GTK_SIGNAL_FUNC(message_status_changed_cb),
 			   mailbox);
-	gtk_signal_connect(GTK_OBJECT(message), "set-deleted",
+	gtk_signal_connect_after(GTK_OBJECT(message), "set-deleted",
 			   GTK_SIGNAL_FUNC(message_status_changed_cb),
 			   mailbox);
-	gtk_signal_connect(GTK_OBJECT(message), "set-flagged",
+	gtk_signal_connect_after(GTK_OBJECT(message), "set-flagged",
 			   GTK_SIGNAL_FUNC(message_status_changed_cb),
 			   mailbox);
 
@@ -742,6 +742,8 @@
 	return FALSE;
 
     LOCK_MAILBOX_RETURN_VAL(mailbox, FALSE);
+    /* really delete messages before committing: */
+    libbalsa_mailbox_sync_backend_real(mailbox);
     libbalsa_lock_mutt();
     index_hint = CLIENT_CONTEXT(mailbox)->vcount;
     rc = mx_sync_mailbox(CLIENT_CONTEXT(mailbox), &index_hint);
Index: src/balsa-app.h
===================================================================
RCS file: /cvs/gnome/balsa/src/balsa-app.h,v
retrieving revision 1.163
diff -u -r1.163 balsa-app.h
--- src/balsa-app.h	2001/12/05 22:49:11	1.163
+++ src/balsa-app.h	2001/12/15 23:33:04
@@ -345,6 +345,7 @@
 
     GList *folder_mru;
     gint drag_default_is_move;
+    gboolean delete_immediately;
 
 } balsa_app;
 
Index: src/balsa-index.c
===================================================================
RCS file: /cvs/gnome/balsa/src/balsa-index.c,v
retrieving revision 1.218
diff -u -r1.218 balsa-index.c
--- src/balsa-index.c	2001/11/25 22:42:13	1.218
+++ src/balsa-index.c	2001/12/15 23:33:04
@@ -1113,6 +1113,7 @@
                            struct BalsaIndexScanInfo *b)
 {
     GList *list;
+    LibBalsaMessage *message;
 
     for (list = b->selection; list; list = g_list_next(list)) {
         if (list->data == node) {
@@ -1128,6 +1129,11 @@
     }
 
     /* this node isn't selected */
+    message = LIBBALSA_MESSAGE(gtk_ctree_node_get_row_data(ctree, node));
+    /* skip any DELETED message, as it may really be deleted before we
+     * get a chance to show it */
+    if (message->flags & LIBBALSA_MESSAGE_FLAG_DELETED)
+        return;
 
     if (b->next == NULL)
         /* save it whether or not it's viewable */
@@ -1799,7 +1805,8 @@
 
         /* sync with backend AFTER adjacent message is selected.
          * Update the style and message counts in the mailbox list */
-        libbalsa_mailbox_sync_backend(index->mailbox_node->mailbox);
+        if (move_to_trash || balsa_app.delete_immediately)
+            libbalsa_mailbox_sync_backend(index->mailbox_node->mailbox);
         balsa_mblist_update_mailbox(balsa_app.mblist,
                                     index->mailbox_node->mailbox);
         // balsa_index_redraw_current(index);
@@ -1841,12 +1848,15 @@
 	list = list->next;
     }
 
+#if 0
 /* XXX - Not sure this is relevant - this function apparently clears
  * the 'Status: D' flag, but doesn't appear to move messages around.
  */
     enable_empty_trash(TRASH_CHECK);
 
+    /* why move? */
     balsa_index_select_next(index);
+#endif
 }
 
 gint
@@ -2077,6 +2087,9 @@
     GtkRequisition req;
     LibBalsaMailbox* mailbox;
     unsigned i;
+    GList *list;
+    gboolean any_deleted = FALSE;
+    gboolean any_not_deleted = FALSE;
  
     BALSA_DEBUG();
     mailbox = bindex->mailbox_node->mailbox;
@@ -2087,14 +2100,27 @@
         create_stock_menu_item(menu, entries[i].icon, _(entries[i].label),
                                entries[i].func, bindex, TRUE);
 
-    create_stock_menu_item(menu, GNOME_STOCK_MENU_TRASH,
-			   _("Delete"), balsa_message_delete, bindex,
-			   !mailbox->readonly);
-    if (mailbox == balsa_app.trash) {
+    for (list = GTK_CLIST(bindex->ctree)->selection; list;
+         list = g_list_next(list)) {
+        LibBalsaMessage *message =
+            LIBBALSA_MESSAGE(gtk_ctree_node_get_row_data
+                             (GTK_CTREE(bindex->ctree), list->data));
+        if (message->flags & LIBBALSA_MESSAGE_FLAG_DELETED)
+            any_deleted = TRUE;
+        else
+            any_not_deleted = TRUE;
+    }
+    if (any_not_deleted) {
+        create_stock_menu_item(menu, GNOME_STOCK_MENU_TRASH,
+                               _("Delete"), balsa_message_delete, bindex,
+                               !mailbox->readonly);
+    }
+    if (any_deleted) {
 	create_stock_menu_item(menu, GNOME_STOCK_MENU_UNDELETE,
 			       _("Undelete"), balsa_message_undelete,
 			       bindex, !mailbox->readonly);
-    } else {
+    }
+    if (mailbox != balsa_app.trash) {
 	create_stock_menu_item(menu, GNOME_STOCK_MENU_TRASH,
 			       _("Move To Trash"), balsa_message_move_to_trash,
 			       bindex, !mailbox->readonly);
Index: src/pref-manager.c
===================================================================
RCS file: /cvs/gnome/balsa/src/pref-manager.c,v
retrieving revision 1.185
diff -u -r1.185 pref-manager.c
--- src/pref-manager.c	2001/12/08 15:04:20	1.185
+++ src/pref-manager.c	2001/12/15 23:33:05
@@ -1,5 +1,4 @@
 /* -*-mode:c; c-style:k&r; c-basic-offset:4; -*- */
-/* vim:set ts=4 sw=4 ai et: */
 /* Balsa E-Mail Client
  * Copyright (C) 1997-2001 Stuart Parmenter and others,
  *                         See the file AUTHORS for a list.
@@ -70,8 +69,9 @@
     GtkWidget *mdn_reply_clean_menu, *mdn_reply_notclean_menu;
 
     GtkWidget *close_mailbox_auto;
-    GtkWidget *drag_default_is_move;
     GtkWidget *close_mailbox_minutes;
+    GtkWidget *drag_default_is_move;
+    GtkWidget *delete_immediately;
 
     GtkWidget *previewpane;
     GtkWidget *alternative_layout;
@@ -381,11 +381,14 @@
     gtk_signal_connect(GTK_OBJECT(pui->close_mailbox_auto), "toggled",
 		       GTK_SIGNAL_FUNC(mailbox_timer_modified_cb), property_box);
 
+    gtk_signal_connect(GTK_OBJECT(pui->close_mailbox_minutes), "changed",
+		       GTK_SIGNAL_FUNC(mailbox_timer_modified_cb), property_box);
+
     gtk_signal_connect(GTK_OBJECT(pui->drag_default_is_move), "toggled",
 		       GTK_SIGNAL_FUNC(properties_modified_cb), property_box);
 
-    gtk_signal_connect(GTK_OBJECT(pui->close_mailbox_minutes), "changed",
-		       GTK_SIGNAL_FUNC(mailbox_timer_modified_cb), property_box);
+    gtk_signal_connect(GTK_OBJECT(pui->delete_immediately), "toggled",
+		       GTK_SIGNAL_FUNC(properties_modified_cb), property_box);
 
     gtk_signal_connect(GTK_OBJECT(pui->browse_wrap), "toggled",
 		       GTK_SIGNAL_FUNC(browse_modified_cb), property_box);
@@ -643,11 +646,14 @@
 
     balsa_app.close_mailbox_auto =
 	GTK_TOGGLE_BUTTON(pui->close_mailbox_auto)->active;
-    balsa_app.drag_default_is_move =
-	GTK_TOGGLE_BUTTON(pui->drag_default_is_move)->active;
     balsa_app.close_mailbox_timeout =
 	gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON
 					 (pui->close_mailbox_minutes));
+    balsa_app.drag_default_is_move =
+	GTK_TOGGLE_BUTTON(pui->drag_default_is_move)->active;
+    balsa_app.delete_immediately =
+        gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON
+                                     (pui->delete_immediately));
 
     /* arp */
     g_free(balsa_app.quote_str);
@@ -865,11 +871,15 @@
 
     gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(pui->close_mailbox_auto),
 				 balsa_app.close_mailbox_auto);
-    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(pui->drag_default_is_move),
-				 balsa_app.drag_default_is_move);
     gtk_spin_button_set_value(GTK_SPIN_BUTTON(pui->close_mailbox_minutes),
 			      (float) balsa_app.close_mailbox_timeout);
+    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(pui->drag_default_is_move),
+				 balsa_app.drag_default_is_move);
 
+    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON
+                                 (pui->delete_immediately),
+                                 balsa_app.delete_immediately);
+
     gtk_widget_set_sensitive(pui->close_mailbox_minutes,
 			     GTK_TOGGLE_BUTTON(pui->close_mailbox_auto)->
     		    	    active);
@@ -2106,6 +2116,22 @@
     gtk_widget_show(pui->drag_default_is_move);
     gtk_box_pack_start(GTK_BOX(vbox10), pui->drag_default_is_move, 
 		       FALSE, FALSE, 0);
+
+    {
+        GtkWidget *frame = gtk_frame_new(_("Deleting Messages"));
+        GtkWidget *vbox = vbox_in_container(frame);
+
+        gtk_container_set_border_width(GTK_CONTAINER(frame), 5);
+        gtk_box_pack_start(GTK_BOX(vbox9), frame, FALSE, FALSE, 0);
+
+        pui->delete_immediately =
+            gtk_check_button_new_with_label(_("Delete immediately "
+                                              "and irretrievably"));
+        gtk_box_pack_start(GTK_BOX(vbox), pui->delete_immediately, FALSE,
+                           FALSE, 0);
+
+        gtk_widget_show_all(frame);
+    }
 
     return vbox9;
 }
Index: src/save-restore.c
===================================================================
RCS file: /cvs/gnome/balsa/src/save-restore.c,v
retrieving revision 1.223
diff -u -r1.223 save-restore.c
--- src/save-restore.c	2001/12/05 22:49:12	1.223
+++ src/save-restore.c	2001/12/15 23:33:06
@@ -608,6 +608,8 @@
     /* ... Progress Window Dialog */
     balsa_app.pwindow_option = d_get_gint("ProgressWindow", WHILERETR);
     balsa_app.drag_default_is_move = d_get_gint("DragDefaultIsMove", 0);
+    balsa_app.delete_immediately =
+        gnome_config_get_bool("DeleteImmediately=false");
 
     gnome_config_pop_prefix();
 
@@ -889,6 +891,8 @@
     gnome_config_set_bool("PageDownMod", balsa_app.pgdownmod);
     gnome_config_set_int("PageDownPercent", balsa_app.pgdown_percent);
     gnome_config_set_int("DragDefaultIsMove", balsa_app.drag_default_is_move);
+    gnome_config_set_bool("DeleteImmediately",
+                          balsa_app.delete_immediately);
 
     gnome_config_pop_prefix();
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]