[PATCH] Re: Some suggestions



On 2001.10.22 08:53 Peter Bloomfield wrote:
> On 2001.10.22 02:48 Petter Sundlöf wrote:
>> Hi. Just a few quick suggestions/issues:
> ...
>> 2) When setting up a remote IMAP folder, also include the INBOX in 
>> the tree (in spite of it not being in the ~/.mailboxlist -- Netscape 
>> and Mozilla does it this way, and it makes sense)
> ...
> RFC 2060 is a more-than-averagely ambiguous mess, but I read this 
> behavior as non-conformant.  Balsa could perhaps support it by having 
> another checkbox on the `Remote IMAP folder' configuration window, 
> labeled `Always show INBOX', sensitive only when `Subscribed folders 
> only' is checked.  Any thoughts?

This patch adds such a checkbox, below `Subscribed folders only', and 
labeled `...but always show INBOX'.  The properties box is starting to 
look cluttered--perhaps the entries should be regrouped.

I've checked this out only with a Cyrus server.  It's not clear how it 
could be affected by server quirks, but IMAP has so many :)

Affected files:
libbalsa/folder-scanners.h:
  - new argument to libbalsa_scanner_imap_dir.
libbalsa/folder-scanners.c:
  - new argument to libbalsa_scanner_imap_dir;
  - force "INBOX" into the mailbox list when asked to.
src/folder-conf.c:
  - add the checkbox, and make it sensitive only when `subscribe' is 
checked;
  - add a `toggled' callback to the `subscribe' checkbox;
  - minor cleanup in imap_use_ssl_cb.
src/mailbox-node.h:
  - new member `list_inbox' in the BalsaMailboxNode structure;
src/mailbox-node.c:
  - save and restore the new member;
  - change the call to libbalsa_scanner_imap_dir.

Enjoy!

Peter
diff -Nur --exclude=CVS --exclude=gtkhtml balsa-cvs/libbalsa/folder-scanners.c balsa-temp/libbalsa/folder-scanners.c
--- balsa-cvs/libbalsa/folder-scanners.c	Thu Oct 18 21:09:44 2001
+++ balsa-temp/libbalsa/folder-scanners.c	Tue Oct 23 00:12:42 2001
@@ -141,7 +141,8 @@
 		      struct browser_state *state, short isparent);
 void
 libbalsa_scanner_imap_dir(GNode *rnode, LibBalsaServer * server, 
-			  const gchar* path, gboolean subscribed, int depth,
+			  const gchar* path, gboolean subscribed, 
+                          gboolean list_inbox, int depth,
 			  ImapHandler folder_handler, 
 			  ImapHandler mailbox_handler)
 {
@@ -172,7 +173,13 @@
 
     /* subscribed triggers a bug in libmutt, disable it now */
     if(subscribed)
+    {
 	set_option(OPTIMAPLSUB);
+        if (list_inbox)
+            /* force INBOX into the mailbox list
+             * delim doesn't matter, so we'll give it '/' */
+            mailbox_handler(rnode, "INBOX", '/');
+    }
     else
 	unset_option(OPTIMAPLSUB);
     state.subfolders = g_list_append(NULL, g_strdup(path));
diff -Nur --exclude=CVS --exclude=gtkhtml balsa-cvs/libbalsa/folder-scanners.h balsa-temp/libbalsa/folder-scanners.h
--- balsa-cvs/libbalsa/folder-scanners.h	Thu Oct 18 21:09:44 2001
+++ balsa-temp/libbalsa/folder-scanners.h	Tue Oct 23 00:24:22 2001
@@ -32,7 +32,7 @@
 
 void libbalsa_scanner_imap_dir(GNode *rnode, LibBalsaServer* server, 
 			       const gchar* path, gboolean subscribed,
-			       int depth,
+                               gboolean list_inbox, int depth,
 			       ImapHandler folder_handler, 
 			       ImapHandler mailbox_handler);
 
diff -Nur --exclude=CVS --exclude=gtkhtml balsa-cvs/src/folder-conf.c balsa-temp/src/folder-conf.c
--- balsa-cvs/src/folder-conf.c	Thu Oct 18 21:09:51 2001
+++ balsa-temp/src/folder-conf.c	Tue Oct 23 00:20:34 2001
@@ -31,7 +31,7 @@
 typedef struct {
     GnomeDialog *dialog;
     GtkWidget * folder_name, *server, *port, *username, *password, 
-	*subscribed, *prefix;
+	*subscribed, *list_inbox, *prefix;
 #ifdef USE_SSL
     GtkWidget *use_ssl;
 #endif
@@ -54,20 +54,39 @@
 }
 
 #ifdef USE_SSL
-static void imap_use_ssl_cb(GtkWidget * w, FolderDialogData * fcw);
+static void imap_use_ssl_cb(GtkToggleButton * button,
+                            FolderDialogData * fcw);
 
+/* imap_use_ssl_cb:
+ * set default text in the `port' entry box according to the state of
+ * the `Use SSL' checkbox
+ *
+ * callback on toggling fcw->use_ssl
+ * */
 static void
-imap_use_ssl_cb(GtkWidget * w, FolderDialogData * fcw)
+imap_use_ssl_cb(GtkToggleButton * button, FolderDialogData * fcw)
 {
     gint zero = 0;
     GtkEditable *port = GTK_EDITABLE(fcw->port);
-    GtkToggleButton *button = GTK_TOGGLE_BUTTON(fcw->use_ssl);
     gboolean use_ssl = gtk_toggle_button_get_active(button);
     gtk_editable_delete_text(port, 0, -1);
     gtk_editable_insert_text(port, use_ssl ? "993" : "143", 3, &zero);
 }
 #endif
 
+/* imap_subcribe_cb:
+ * set the sensitivity of the `...but show INBOX' toggle button, which
+ * is meaningless when `Subscribed folders only' is unchecked
+ *
+ * callback on toggling fcw->subscribed
+ * */
+static void
+imap_subscribe_cb(GtkToggleButton * button, FolderDialogData * fcw)
+{
+    gtk_widget_set_sensitive(fcw->list_inbox,
+                             gtk_toggle_button_get_active(button));
+}
+
 /* folder_conf_imap_node:
    show the IMAP Folder configuration dialog for given mailbox node.
    If mn is NULL, setup it with default values for folder creation.
@@ -98,7 +117,7 @@
     frame = gtk_frame_new(_("Remote IMAP folder set"));
     gtk_box_pack_start(GTK_BOX(fcw.dialog->vbox),
                        frame, TRUE, TRUE, 0);
-    table = gtk_table_new(7, 2, FALSE);
+    table = gtk_table_new(8, 2, FALSE);
     gtk_container_add(GTK_CONTAINER(frame), table);
  
     /* INPUT FIELD CREATION */
@@ -134,15 +153,19 @@
 
     fcw.subscribed = create_check(fcw.dialog, _("_Subscribed folders only"), 
 				  table, 5, FALSE);
+    gtk_signal_connect(GTK_OBJECT(fcw.subscribed), "toggled",
+                       imap_subscribe_cb, &fcw);
+    fcw.list_inbox = create_check(fcw.dialog, _("...but always show _INBOX"), 
+				  table, 6, FALSE);
 
-    create_label(_("_Prefix"), table, 6, &keyval);
-    fcw.prefix = create_entry(fcw.dialog, table, NULL, NULL, 6, 
+    create_label(_("_Prefix"), table, 7, &keyval);
+    fcw.prefix = create_entry(fcw.dialog, table, NULL, NULL, 7, 
 			      mn ? mn->dir : NULL, keyval);
     
 #ifdef USE_SSL
     fcw.use_ssl = create_check(fcw.dialog,
 			       _("Use SSL (IMAPS)"),
-			       table, 7, s ? s->use_ssl : FALSE);
+			       table, 8, s ? s->use_ssl : FALSE);
     gtk_signal_connect(GTK_OBJECT(fcw.use_ssl), "toggled", imap_use_ssl_cb, &fcw);
 #endif
 
@@ -151,7 +174,12 @@
 
     /* all the widgets are ready, set the values */
     if(mn && mn->subscribed)
+    {
 	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(fcw.subscribed), TRUE);
+        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(fcw.list_inbox),
+                                     mn->list_inbox);
+    } else
+        gtk_widget_set_sensitive(fcw.list_inbox, FALSE);
     validate_folder(NULL, &fcw);
     gtk_widget_grab_focus(fcw.folder_name);
 
@@ -187,6 +215,8 @@
 	mn->name = g_strdup(gtk_entry_get_text(GTK_ENTRY(fcw.folder_name)));
 	mn->subscribed = 
 	    gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(fcw.subscribed));
+	mn->list_inbox = 
+	    gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(fcw.list_inbox));
 	
 	if(insert) {
 	    g_node_append(balsa_app.mailbox_nodes, gnode = g_node_new(mn));
diff -Nur --exclude=CVS --exclude=gtkhtml balsa-cvs/src/mailbox-node.c balsa-temp/src/mailbox-node.c
--- balsa-cvs/src/mailbox-node.c	Thu Oct 18 21:09:51 2001
+++ balsa-temp/src/mailbox-node.c	Mon Oct 22 19:23:47 2001
@@ -172,6 +172,7 @@
     gnome_config_set_string("Name",      mn->name);
     gnome_config_set_string("Directory", mn->dir);
     gnome_config_set_bool("Subscribed",  mn->subscribed);
+    gnome_config_set_bool("ListInbox",   mn->list_inbox);
     gnome_config_set_int("Threading",    mn->threading_type);
     gnome_config_set_int("SortType",     mn->sort_type);
     gnome_config_set_int("SortField",    mn->sort_field);
@@ -228,7 +229,8 @@
 imap_dir_cb(BalsaMailboxNode* mb, GNode* r)
 {
     g_return_if_fail(mb->server);
-    libbalsa_scanner_imap_dir(r, mb->server, mb->dir, mb->subscribed, 7,
+    libbalsa_scanner_imap_dir(r, mb->server, mb->dir, mb->subscribed,
+                              mb->list_inbox, 7,
 			      add_imap_folder, add_imap_mailbox);
     /* register whole tree */
     printf("imap_dir_cb:  main mailbox node %s mailbox is %p\n", 
@@ -307,6 +309,8 @@
     folder->dir = gnome_config_get_string("Directory");
     folder->subscribed =
 	gnome_config_get_bool("Subscribed"); 
+    folder->list_inbox =
+	gnome_config_get_bool("ListInbox=false"); 
     folder->threading_type = gnome_config_get_int_with_default("Threading", &def);
     if(def) folder->threading_type = BALSA_INDEX_THREADING_SIMPLE;
     folder->sort_type = gnome_config_get_int_with_default("SortType", &def);
diff -Nur --exclude=CVS --exclude=gtkhtml balsa-cvs/src/mailbox-node.h balsa-temp/src/mailbox-node.h
--- balsa-cvs/src/mailbox-node.h	Thu Oct 18 21:09:51 2001
+++ balsa-temp/src/mailbox-node.h	Mon Oct 22 17:13:11 2001
@@ -72,6 +72,7 @@
     GtkSortType sort_type;
     LibBalsaServer * server; /* Used only by remote; is referenced */
     gboolean subscribed;     /* Used only by remote */
+    gboolean list_inbox;     /* Used only by remote */
 };
 
 struct _BalsaMailboxNodeClass {


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