PATCH: mblist fix, drag-and-drop, message filing



Hi,

here's a new patch:

Provides:
- New option in prefs-misc to set the default drag and drop action to "move"
- New "Move to" menu in message window, with MRU list

Fixes:
- segfault in libgtk when a mblist's parent is destroyed

Requires:
- current Balsa from CVS

This will also let Peter streamline some of his code, now.

Melanie
diff -b -B -r -u -P --exclude-from=ignore ../balsa-cvs/src/balsa-app.c ./src/balsa-app.c
--- ../balsa-cvs/src/balsa-app.c	Thu Aug 16 18:40:34 2001
+++ ./src/balsa-app.c	Thu Aug 16 18:42:04 2001
@@ -323,6 +323,10 @@
     /* IMAP */
     balsa_app.check_imap = 1;
     balsa_app.check_imap_inbox = 0;
+
+	/* Message filing */
+	balsa_app.folder_mru=NULL;
+	balsa_app.drag_default_is_move=0;
 }
 
 static gint
diff -b -B -r -u -P --exclude-from=ignore ../balsa-cvs/src/balsa-app.h ./src/balsa-app.h
--- ../balsa-cvs/src/balsa-app.h	Thu Aug 16 18:40:34 2001
+++ ./src/balsa-app.h	Thu Aug 16 18:42:04 2001
@@ -95,6 +95,8 @@
 #define DEFAULT_CHECK_SIG FALSE
 #define DEFAULT_CHECK_QUOTED FALSE
 
+/* Length of the folder MRU list */
+#define FOLDER_MRU_LENGTH	10
 
 enum {
     WHILERETR,
@@ -322,6 +324,9 @@
     BalsaMDNReply mdn_reply_clean;
     BalsaMDNReply mdn_reply_notclean;
 #endif
+
+	GList *folder_mru;
+	gint drag_default_is_move;
 
 } balsa_app;
 
diff -b -B -r -u -P --exclude-from=ignore ../balsa-cvs/src/balsa-index.c ./src/balsa-index.c
--- ../balsa-cvs/src/balsa-index.c	Thu Aug 16 18:40:34 2001
+++ ./src/balsa-index.c	Thu Aug 16 18:51:39 2001
@@ -450,12 +450,12 @@
     return t2-t1;
 }
 
-/* bi_get_largest_selected:
+/* balsa_index_get_largest_selected:
    helper function, finds the message with largest number among selected and
    fails with -1, if the selection is empty.
 */
-static gint
-bi_get_largest_selected(GtkCList * clist)
+gint
+balsa_index_get_largest_selected(GtkCList * clist)
 {
     GList *list;
     gint i = 0;
@@ -490,7 +490,7 @@
     gtk_clist_sort(clist);
     DO_CLIST_WORKAROUND(clist);
 
-    if ((h = bi_get_largest_selected(clist)) >= 0 &&
+    if ((h = balsa_index_get_largest_selected(clist)) >= 0 &&
 	gtk_clist_row_is_visible(clist, h) != GTK_VISIBILITY_FULL)
 	gtk_clist_moveto(clist, h, 0, 1.0, 0.0);
 }
@@ -860,7 +860,7 @@
     clist = GTK_CLIST(bindex->ctree);
 
     /* [MBG] check this part, it might need to be h - 2 instead */
-    if ((h = bi_get_largest_selected(clist)) < 0 || h + 1 >= clist->rows)
+    if ((h = balsa_index_get_largest_selected(clist)) < 0 || h + 1 >= clist->rows)
 	h = clist->rows - 1;
 
     balsa_index_select_row(bindex, h + 1);
@@ -908,7 +908,7 @@
     g_return_if_fail(bindex != NULL);
     clist = GTK_CLIST(bindex->ctree);
 
-    if ((h = bi_get_largest_selected(clist) + 1) <= 0)
+    if ((h = balsa_index_get_largest_selected(clist) + 1) <= 0)
 	h = 0;
 
     if (h >= clist->rows)
@@ -1332,7 +1332,7 @@
     gtk_clist_freeze(clist);
 
     old_message = 
-        gtk_clist_get_row_data(clist, bi_get_largest_selected(clist));
+        gtk_clist_get_row_data(clist, balsa_index_get_largest_selected(clist));
     gtk_clist_unselect_all(clist);
     gtk_clist_clear(clist);
 
@@ -1543,7 +1543,7 @@
 
     /* select the previous message if we're at the bottom of the index */
     if (GTK_CLIST(index->ctree)->rows - 1 == 
-        bi_get_largest_selected(GTK_CLIST(index->ctree)))
+        balsa_index_get_largest_selected(GTK_CLIST(index->ctree)))
         select_next = FALSE;
 
     
@@ -1764,7 +1764,7 @@
     GtkCList *list;
 
     list = GTK_CLIST(index->ctree);
-    row = bi_get_largest_selected (list);
+    row = balsa_index_get_largest_selected (list);
 
     if (row < 0)
 	message = NULL;
@@ -2040,7 +2040,7 @@
 	return;
 
     /* select the previous message if we're at the bottom of the index */
-    if (clist->rows - 1 == bi_get_largest_selected(clist))
+    if (clist->rows - 1 == balsa_index_get_largest_selected(clist))
         select_next = FALSE;
 
 
@@ -2068,6 +2068,8 @@
 
     libbalsa_mailbox_sync_backend(bindex->mailbox_node->mailbox);
 
+	balsa_remove_from_folder_mru(mbnode->mailbox->url);
+	balsa_add_to_folder_mru(mbnode->mailbox->url);
     gtk_object_set_data(GTK_OBJECT(bindex), "transferredp", (gpointer) 1);
 }
 
diff -b -B -r -u -P --exclude-from=ignore ../balsa-cvs/src/balsa-index.h ./src/balsa-index.h
--- ../balsa-cvs/src/balsa-index.h	Thu Aug 16 18:40:34 2001
+++ ./src/balsa-index.h	Thu Aug 16 18:42:04 2001
@@ -132,6 +132,7 @@
 				   gint, gpointer);
     void balsa_index_refresh_size (GtkNotebook *, GtkNotebookPage *,
 				   gint, gpointer);
+	gint balsa_index_get_largest_selected(GtkCList *clist);
 #ifdef __cplusplus
 }
 #endif				/* __cplusplus */
diff -b -B -r -u -P --exclude-from=ignore ../balsa-cvs/src/balsa-mblist.c ./src/balsa-mblist.c
--- ../balsa-cvs/src/balsa-mblist.c	Thu Aug 16 18:40:35 2001
+++ ./src/balsa-mblist.c	Thu Aug 16 18:42:04 2001
@@ -143,8 +143,16 @@
 balsa_mblist_destroy(GtkObject * obj)
 {
     BalsaMBList *del;
+    GtkCTree *ctree;
 
     del = BALSA_MBLIST(obj);
+
+    ctree = GTK_CTREE(del);
+
+    gtk_ctree_post_recursive(GTK_CTREE(del), NULL,
+			     balsa_mblist_disconnect_mailbox_signals,
+			     NULL); 
+
     /* chain up ... */
     if (GTK_OBJECT_CLASS(parent_class)->destroy)
 	(*GTK_OBJECT_CLASS(parent_class)->destroy) (GTK_OBJECT(del));
@@ -1516,17 +1524,15 @@
 
         /* cannot transfer to the originating mailbox */
         if (mailbox != orig_mailbox) {
-            switch (context->suggested_action) {
+            switch (context->action) {
             case GDK_ACTION_MOVE:
                 libbalsa_messages_move (messages, mailbox);
-                context->action = context->suggested_action;
                 break;
 
             case GDK_ACTION_DEFAULT:
             case GDK_ACTION_COPY:
             default:
                 libbalsa_messages_copy (messages, mailbox);
-		context->action = context->suggested_action;
                 break;
             }
             
@@ -1567,5 +1573,11 @@
 					   NULL);
     }
 #endif
+	if(balsa_app.drag_default_is_move) {
+		if(context->actions == GDK_ACTION_COPY)
+			gdk_drag_status(context, GDK_ACTION_COPY, time);
+		else
+			gdk_drag_status(context, GDK_ACTION_MOVE, time);
+	}
     return FALSE;
 }
diff -b -B -r -u -P --exclude-from=ignore ../balsa-cvs/src/message-window.c ./src/message-window.c
--- ../balsa-cvs/src/message-window.c	Thu Aug 16 18:40:35 2001
+++ ./src/message-window.c	Thu Aug 16 18:42:04 2001
@@ -25,14 +25,24 @@
 #include "balsa-app.h"
 #include "balsa-message.h"
 #include "balsa-icons.h"
+#include "balsa-index.h"
 #include "main-window.h"
 #include "sendmsg-window.h"
 #include "message-window.h"
 #include "print.h"
 #include "toolbar-factory.h"
+#include "mailbox-node.h"
 
 #include "libbalsa.h"
 
+struct BalsaMRUEntry
+{
+	LibBalsaMailbox *mailbox;
+	gchar *url;
+	char *name;
+	gpointer mw;
+};
+
 /* callbacks */
 static void destroy_message_window(GtkWidget * widget, gpointer data);
 static void close_message_window(GtkWidget * widget, gpointer data);
@@ -60,6 +70,9 @@
 static void print_cb(GtkWidget * widget, gpointer);
 static void trash_cb(GtkWidget * widget, gpointer);
 
+static gint find_url_cb(GNode *node, struct BalsaMRUEntry *data);
+static void mru_select_cb(GtkWidget *widget, struct BalsaMRUEntry *entry);
+
 /*
  * The list of messages which are being displayed.
  */
@@ -140,10 +153,16 @@
     GNOMEUIINFO_END
 };
 
+static GnomeUIInfo move_menu[]={
+	GNOMEUIINFO_END
+};
+
 static GnomeUIInfo main_menu[] = {
     GNOMEUIINFO_MENU_FILE_TREE(file_menu),
     GNOMEUIINFO_MENU_EDIT_TREE(edit_menu),
     GNOMEUIINFO_MENU_VIEW_TREE(view_menu),
+#define MAIN_MENU_MOVE_POS 3
+    GNOMEUIINFO_SUBTREE("Move _To", move_menu),
     GNOMEUIINFO_SUBTREE("_Message", message_menu),
     GNOMEUIINFO_END
 };
@@ -157,9 +176,18 @@
     LibBalsaMessage *message;
     int show_all_headers_save;
 	int headers_shown;
+	GtkWidget *move_menu;
+	gint transferred;
+	GList *mru_list;
 };
 
 void reset_show_all_headers(MessageWindow *mw);
+static void populate_move_menu(MessageWindow *mw);
+static gint close_if_transferred_cb(BalsaMBList * bmbl, GdkEvent * event,
+            MessageWindow * mw);
+static void transfer_message_cb(GtkCTree * ctree, GtkCTreeNode * row,
+			 gint column, MessageWindow * mw);
+static void load_mru(MessageWindow * mw);
 
 void
 message_window_new(LibBalsaMessage * message)
@@ -200,6 +228,8 @@
 
     mw->message = message;
 
+	mw->mru_list=NULL;
+
     mw->window = gnome_app_new("balsa", "Message");
 
     mw->show_all_headers_save=-1;
@@ -244,6 +274,9 @@
 		       GTK_SIGNAL_FUNC(destroy_message_window), mw);
     
     gnome_app_create_menus_with_data(GNOME_APP(mw->window), main_menu, mw);
+	mw->move_menu=main_menu[MAIN_MENU_MOVE_POS].widget;
+    
+	populate_move_menu(mw);
     
     scroll = gtk_scrolled_window_new(NULL, NULL);
     gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll),
@@ -251,6 +284,7 @@
 				   GTK_POLICY_AUTOMATIC);
 
     mw->bmessage = balsa_message_new();
+	mw->transferred=0;
 
     gtk_signal_connect(GTK_OBJECT(mw->bmessage), "select-part",
 		       GTK_SIGNAL_FUNC(select_part_cb), mw);
@@ -299,6 +333,8 @@
 static void
 destroy_message_window(GtkWidget * widget, gpointer data)
 {
+	GList *tmp;
+
     MessageWindow *mw = (MessageWindow *) data;
 
     release_toolbars(mw->window);
@@ -307,6 +343,12 @@
     gtk_widget_destroy(mw->window);
     gtk_widget_destroy(mw->bmessage);
 
+	if(mw->mru_list) {
+		for(tmp=mw->mru_list;tmp;tmp=g_list_next(tmp))
+			g_free(tmp->data);
+		g_list_free(mw->mru_list);
+	}
+
     g_free(mw);
 }
 
@@ -583,3 +625,262 @@
     if(btn)
         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(btn), FALSE);
 }
+
+static void populate_move_menu(MessageWindow *mw)
+{
+	GtkWidget *item;
+	GtkWidget *scroller;
+	GtkWidget *bmbl;
+	GtkWidget *submenu, *smenuitem;
+	GtkRequisition req;
+
+	if(mw->message->mailbox->readonly)
+	{
+		gtk_widget_set_sensitive(mw->move_menu, FALSE);
+		return;
+	}
+
+	/* Load Folder MRU */
+	load_mru(mw);
+
+	item=gtk_menu_item_new();
+	gtk_menu_append(GTK_MENU(GTK_MENU_ITEM(mw->move_menu)->submenu), item);
+	gtk_widget_show(item);
+
+	/* Create standard entry */
+	item=gtk_menu_item_new_with_label(_("Folder"));
+
+	gtk_menu_append(GTK_MENU(GTK_MENU_ITEM(mw->move_menu)->submenu), item);
+	gtk_widget_show(item);
+
+	submenu=gtk_menu_new();
+	smenuitem=gtk_menu_item_new();
+
+	scroller=gtk_scrolled_window_new(NULL, NULL);
+    gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW(scroller),
+                                    GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+    bmbl = balsa_mblist_new();
+
+    gtk_widget_size_request(bmbl, &req);
+
+    if ( req.height > balsa_app.mw_height )
+    req.height = balsa_app.mw_height;
+
+    req.width=balsa_app.mblist_width;
+    gtk_widget_set_usize(GTK_WIDGET(bmbl), req.width, req.height);
+
+    gtk_container_add(GTK_CONTAINER(scroller), bmbl);
+    gtk_container_add(GTK_CONTAINER(smenuitem), scroller);
+
+    gtk_menu_append(GTK_MENU(submenu), smenuitem);
+    gtk_widget_show(bmbl);
+    gtk_widget_show(scroller);
+    gtk_widget_show(smenuitem);
+	gtk_widget_show(submenu);
+
+	gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu);
+
+    gtk_signal_connect (GTK_OBJECT(smenuitem), "button_release_event",
+                        (GtkSignalFunc) close_if_transferred_cb,
+                        (gpointer) mw);
+
+    gtk_signal_connect(GTK_OBJECT(bmbl), "tree_select_row",
+               (GtkSignalFunc) transfer_message_cb,
+               (gpointer) mw);
+
+
+}
+
+static gint
+close_if_transferred_cb(BalsaMBList * bmbl, GdkEvent * event,
+            MessageWindow * mw)
+{
+    if (mw->transferred) {
+        return FALSE;
+    } else {
+        return TRUE;
+    }
+}
+
+static void
+transfer_message_cb(GtkCTree * ctree, GtkCTreeNode * row, gint column,
+			 MessageWindow * mw)
+{
+    GtkCList* clist=NULL;
+    BalsaIndex* bindex = NULL;
+    BalsaMailboxNode *mbnode;
+    gboolean select_next = TRUE;
+
+    g_return_if_fail(mw != NULL);
+
+    bindex = balsa_find_index_by_mailbox(mw->message->mailbox);
+
+    mbnode = gtk_ctree_node_get_row_data(ctree, row);
+
+    if(mbnode->mailbox == NULL) return;
+
+   /*Transferring to same mailbox? */
+    if (mw->message->mailbox == mbnode->mailbox)
+    return;
+
+	if(bindex != NULL && bindex->ctree != NULL) {
+		clist = GTK_CLIST(bindex->ctree);
+
+		/* select the previous message if we're at the bottom of the index */
+		if (clist->rows - 1 == balsa_index_get_largest_selected(clist))
+			select_next = FALSE;
+	}
+
+	mw->transferred=1;
+	libbalsa_message_move(mw->message, mbnode->mailbox);
+
+	if(bindex != NULL && bindex->ctree != NULL) {
+		/* select another message depending on where we are in the list */
+		if (clist->rows > 1) {
+			if (select_next)
+				balsa_index_select_next(bindex);
+			else
+				balsa_index_select_previous(bindex);
+		}
+		libbalsa_mailbox_sync_backend(bindex->mailbox_node->mailbox);
+	}
+
+	balsa_remove_from_folder_mru(mbnode->mailbox->url);
+	balsa_add_to_folder_mru(mbnode->mailbox->url);
+
+	close_message_window(NULL, (gpointer) mw);
+}
+
+static gint
+find_url_cb(GNode *gnode, struct BalsaMRUEntry *data)
+{
+	BalsaMailboxNode *node;
+
+	node=gnode->data;
+	if(!node || !BALSA_IS_MAILBOX_NODE(node))
+		return(FALSE);
+
+	if(!node->mailbox)
+		return(FALSE);
+
+	if(!strcmp(LIBBALSA_MAILBOX(node->mailbox)->url, data->url)) {
+		data->url=LIBBALSA_MAILBOX(node->mailbox)->url;
+		data->name=LIBBALSA_MAILBOX(node->mailbox)->name;
+		data->mailbox=LIBBALSA_MAILBOX(node->mailbox);
+		return(TRUE);
+	}
+	
+	return(FALSE);
+}
+
+static void
+load_mru(MessageWindow * mw)
+{
+	GList *mru;
+	GList *tmp;
+	struct BalsaMRUEntry *mru_entry;
+	GtkWidget *item;
+
+	for(mru=balsa_app.folder_mru;mru != NULL;mru=g_list_next(mru)) {
+		while(mru) {
+			mru_entry=g_malloc(sizeof(struct BalsaMRUEntry));
+			if(!mru_entry)
+				return;
+
+			mru_entry->url=mru->data;
+			mru_entry->mailbox=NULL;
+			mru_entry->mw=mw;
+			g_node_traverse(balsa_app.mailbox_nodes, G_IN_ORDER, G_TRAVERSE_ALL,
+				-1, (gint (*)(GNode *, gpointer))find_url_cb, mru_entry);
+			if(mru_entry->mailbox == NULL) {
+				g_free(mru_entry);
+				tmp=g_list_next(mru);
+				g_free(mru->data);
+				balsa_app.folder_mru=g_list_remove(balsa_app.folder_mru,
+						mru->data);
+				mru=tmp;
+				continue;
+			}
+			break;
+		}
+
+		if(!mru)
+			break;
+
+		mw->mru_list=g_list_append(mw->mru_list, mru_entry);
+		item=gtk_menu_item_new_with_label(mru_entry->name);
+		gtk_widget_show(item);
+		gtk_menu_append(GTK_MENU(GTK_MENU_ITEM(mw->move_menu)->submenu), item);
+		gtk_signal_connect(GTK_OBJECT(item), "activate",
+				GTK_SIGNAL_FUNC(mru_select_cb), mru_entry);
+	}
+}
+
+static void
+mru_select_cb(GtkWidget *widget, struct BalsaMRUEntry *entry)
+{
+	MessageWindow *mw=entry->mw;
+
+	LibBalsaMailbox *mailbox=entry->mailbox;
+
+    GtkCList* clist=NULL;
+    BalsaIndex* bindex = NULL;
+    gboolean select_next = TRUE;
+
+    bindex = balsa_find_index_by_mailbox(mw->message->mailbox);
+
+   /*Transferring to same mailbox? */
+    if (mw->message->mailbox == mailbox)
+    return;
+
+	if(bindex != NULL && bindex->ctree != NULL) {
+		clist = GTK_CLIST(bindex->ctree);
+
+		/* select the previous message if we're at the bottom of the index */
+		if (clist->rows - 1 == balsa_index_get_largest_selected(clist))
+			select_next = FALSE;
+	}
+
+	mw->transferred=1;
+	libbalsa_message_move(mw->message, mailbox);
+
+	if(bindex != NULL && bindex->ctree != NULL) {
+		/* select another message depending on where we are in the list */
+		if (clist->rows > 1) {
+			if (select_next)
+				balsa_index_select_next(bindex);
+			else
+				balsa_index_select_previous(bindex);
+		}
+		libbalsa_mailbox_sync_backend(bindex->mailbox_node->mailbox);
+	}
+
+	balsa_remove_from_folder_mru(mailbox->url);
+	balsa_add_to_folder_mru(mailbox->url);
+
+	close_message_window(NULL, (gpointer) mw);
+}
+
+void
+balsa_add_to_folder_mru(gchar *url)
+{
+	if(g_list_length(balsa_app.folder_mru) >= FOLDER_MRU_LENGTH)
+		balsa_app.folder_mru=g_list_remove(balsa_app.folder_mru,
+				g_list_last(balsa_app.folder_mru)->data);
+	balsa_app.folder_mru=g_list_prepend(balsa_app.folder_mru, g_strdup(url));
+}
+
+void
+balsa_remove_from_folder_mru(gchar *url)
+{
+	GList *tmp;
+
+	for(tmp=balsa_app.folder_mru;tmp != NULL;tmp=g_list_next(tmp)) {
+		if(!strcmp((char *)tmp->data, url)) {
+			g_free(tmp->data);
+			balsa_app.folder_mru=g_list_remove(balsa_app.folder_mru, tmp->data);
+			break;
+		}
+	}
+}
+
diff -b -B -r -u -P --exclude-from=ignore ../balsa-cvs/src/message-window.h ./src/message-window.h
--- ../balsa-cvs/src/message-window.h	Thu Aug 16 18:40:35 2001
+++ ./src/message-window.h	Thu Aug 16 18:42:04 2001
@@ -25,5 +25,7 @@
 #include "libbalsa.h"
 
 void message_window_new(LibBalsaMessage * message);
+void balsa_remove_from_folder_mru(gchar *url);
+void balsa_add_to_folder_mru(gchar *url);
 
 #endif				/* __MESSAGE_WINDOW_H__ */
diff -b -B -r -u -P --exclude-from=ignore ../balsa-cvs/src/pref-manager.c ./src/pref-manager.c
--- ../balsa-cvs/src/pref-manager.c	Thu Aug 16 18:40:35 2001
+++ ./src/pref-manager.c	Thu Aug 16 18:42:04 2001
@@ -63,6 +63,7 @@
 #endif
 
     GtkWidget *close_mailbox_auto;
+	GtkWidget *drag_default_is_move;
     GtkWidget *close_mailbox_minutes;
 
     GtkWidget *previewpane;
@@ -349,6 +350,9 @@
     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->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);
 
@@ -566,6 +570,8 @@
 
     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));
@@ -766,6 +772,8 @@
 
     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);
 
@@ -1862,6 +1870,11 @@
     label33 = gtk_label_new(_("minutes"));
     gtk_widget_show(label33);
     gtk_box_pack_start(GTK_BOX(hbox1), label33, FALSE, TRUE, 0);
+
+    pui->drag_default_is_move =
+	gtk_check_button_new_with_label(_("Drag-and-drop moves messages by default"));
+    gtk_widget_show(pui->drag_default_is_move);
+    gtk_box_pack_start(GTK_BOX(vbox10), pui->drag_default_is_move, FALSE, FALSE, 0);
 
     return vbox9;
 }
diff -b -B -r -u -P --exclude-from=ignore ../balsa-cvs/src/save-restore.c ./src/save-restore.c
--- ../balsa-cvs/src/save-restore.c	Thu Aug 16 18:40:35 2001
+++ ./src/save-restore.c	Thu Aug 16 18:42:04 2001
@@ -26,6 +26,7 @@
 #include "save-restore.h"
 #include "quote-color.h"
 #include "toolbar-prefs.h"
+#include "balsa-message.h"
 
 #define BALSA_CONFIG_PREFIX "balsa/"
 #define FOLDER_SECTION_PREFIX "folder-"
@@ -43,6 +44,8 @@
 static gchar **mailbox_list_to_vector(GList * mailbox_list);
 static void save_color(gchar * key, GdkColor * color);
 static void load_color(gchar * key, GdkColor * color);
+static void save_mru(GList *mru);
+static void load_mru(GList **mru);
 
 static void config_address_books_load(void);
 static void config_address_books_save(void);
@@ -547,6 +550,8 @@
     /* ... Progress Window Dialog */
     balsa_app.pwindow_option = d_get_gint("ProgressWindow", WHILERETR);
 
+	balsa_app.drag_default_is_move = d_get_gint("DragDefaultIsMove", 0);
+
     gnome_config_pop_prefix();
 
     /* Printing options ... */
@@ -715,6 +720,11 @@
     balsa_app.save_dir = gnome_config_get_string("SavePartDir");
     gnome_config_pop_prefix();
 
+	/* Folder MRU */
+    gnome_config_push_prefix(BALSA_CONFIG_PREFIX "FolderMRU/");
+	load_mru(&balsa_app.folder_mru);
+    gnome_config_pop_prefix();
+
     return TRUE;
 }				/* config_global_load */
 
@@ -800,6 +810,7 @@
     gnome_config_set_bool("MsgSizeAsLines", balsa_app.line_length);
     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_pop_prefix();
 
@@ -940,6 +951,11 @@
 	gnome_config_set_string("SavePartDir", balsa_app.save_dir);
     gnome_config_pop_prefix();
 
+	
+    gnome_config_push_prefix(BALSA_CONFIG_PREFIX "FolderMRU/");
+	save_mru(balsa_app.folder_mru);
+    gnome_config_pop_prefix();
+
     gnome_config_sync();
     return TRUE;
 }				/* config_global_save */
@@ -1163,4 +1179,33 @@
     str = gnome_config_get_string(key);
     gdk_color_parse(str, color);
     g_free(str);
+}
+
+void
+load_mru(GList **mru)
+{
+	int count, i;
+	char tmpkey[32];
+
+	count=d_get_gint("MRUCount", 0);
+	for(i=0;i<count;i++)
+	{
+		sprintf(tmpkey, "MRU%d", i+1);
+		(*mru)=g_list_append((*mru), gnome_config_get_string(tmpkey));
+	}
+}
+
+void
+save_mru(GList *mru)
+{
+	int i;
+	char tmpkey[32];
+	GList *ltmp;
+
+	for(ltmp=g_list_first(balsa_app.folder_mru),i=0;ltmp != NULL;ltmp=g_list_next(ltmp),i++)
+	{
+		sprintf(tmpkey, "MRU%d", i+1);
+		gnome_config_set_string(tmpkey, (gchar *)(ltmp->data));
+	}
+	gnome_config_set_int("MRUCount", i);
 }


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