On 09/22/2009 07:07:51 PM Tue, Jack wrote:
As Alice said: Curiouser and curiouser.
Indeed!
On 2009.09.22 09:00, Peter Bloomfield wrote:On 09/21/2009 06:23:26 PM Mon, Jack Ostroff wrote:
[ snip ]
As it stands, "open inbox on startup" trumps the current mailbox code. It runs after the task for "remember open mailboxes", and forces a switch-page to the inbox. That was an oversight--but I guess it might also be the preferred action for a use who sets both options.
Perhaps if "open inbox on startup" but not if that is not set and the Inbox just happens to be open.
Nah--it really was an oversight. Anyone would expect the combination of "remember open mailboxes" and "open inbox on startup" to mean "add inbox to the list of open mailboxes, even if it wasn't"! I'll fix it...
I'm not sure why Inbox is always the visible mailbox. Perhaps it's always the first mailbox in the list of open mailboxes--that's the one that's shown by the "remember open mailboxes" code; when CurrentMailboxURL is set to something non-NULL, it gets forced to the front of the list and hence is (supposed to be) shown.
I have yet to figure out how it chooses which mailbox to display. It is NOT consistently the first or last mailbox marked as open in the config file. (I am assuming that is done by the "Open=true' in the viewByUrl-file section for that mailbox, since the OpenMailboxes= seems to list the URL for every mailbox, not just the open ones.
?? Current code doesn't use "OpenMailboxes" (except as a substring of "RememberOpenMailboxes"). That must be a leftover from way back :)
Yes, it's "Open=true" in the viewByUrl-file section that Balsa currently uses to track open mailboxes. The list is put together by traversing the internal representation of the folder tree and noting which mailboxes have "Open=true", so the order is determined by all sorts of file-system issues, and network latency if you have IMAP folders. But having Inbox first may be a sure thing.
[ snip ]
I'm also still curious about something I mentioned in an email off-list: in main-window.c, in the function bw_notebook_switch_page_cb, the last two lines areg_free(balsa_app.current_mailbox_url); balsa_app.current_mailbox_url = g_strdup(mailbox->url);Am I missing something, or is it strange to set a value right after you have freed it?
That's just Balsa keeping track of the currently visible mailbox, using its own allocated copy of the URL: deallocate the memory holding the string identifying the previous mailbox, allocate memory for the URL of the new mailbox, and save it in BalsaApp.
I wonder if I would find anything by running balsa under a debugger, and putting a trace on balsa_app.current_mailbox_url.
Yes, that would be really helpful! It /should/ be set each time you select a new mailbox, and then saved in the config file on exit. If you apply the attached patch, it should save you the trouble--it'll record changes on the console, and also the value that gets saved to the config file. It also fixes the "open inbox on startup" oversight and puts mailboxes listed with "-o" on the same footing as remembered open mailboxes, which might fix some of the issues you're seeing.
Thanks for helping out with this one! Peter
diff --git a/src/balsa-app.c b/src/balsa-app.c index 1330d44..3c08313 100644 --- a/src/balsa-app.c +++ b/src/balsa-app.c @@ -518,11 +518,40 @@ append_url_if_open(const gchar * url, LibBalsaMailboxView * view, } } +static void +open_mailbox_by_url(const gchar * url) +{ + LibBalsaMailbox *mailbox; + + mailbox = balsa_find_mailbox_by_url(url); + if (balsa_app.debug) + fprintf(stderr, "open_mailboxes_idle_cb: opening %s => %p..\n", + url, mailbox); + if (mailbox) + /* The first mailbox we open will be shown; later mailboxes will + * have notebook pages, but will not be shown. */ + balsa_mblist_open_mailbox_hidden(mailbox); + else { + /* Do not try to open it next time. */ + LibBalsaMailboxView *view = + g_hash_table_lookup(libbalsa_mailbox_view_table, url); + /* The mailbox may have been requested to be open because its + * stored view might say so or the user requested it from the + * command line - in which case, view may or may not be present. + * We will be careful here. */ + if (view) { + view->open = FALSE; + view->in_sync = FALSE; + } + balsa_information(LIBBALSA_INFORMATION_WARNING, + _("Couldn't open mailbox \"%s\""), url); + } +} + gboolean open_mailboxes_idle_cb(gchar ** urls) { gchar **tmp; - LibBalsaMailbox *mbox; gdk_threads_enter(); @@ -534,38 +563,18 @@ open_mailboxes_idle_cb(gchar ** urls) return FALSE; } - str = g_string_new(balsa_app.current_mailbox_url); + str = g_string_new(NULL); g_hash_table_foreach(libbalsa_mailbox_view_table, (GHFunc) append_url_if_open, str); urls = g_strsplit(str->str, ";", 0); g_string_free(str, TRUE); } - for (tmp = urls; *tmp; ++tmp) { - mbox = balsa_find_mailbox_by_url(*tmp); - if (balsa_app.debug) - fprintf(stderr, "open_mailboxes_idle_cb: opening %s => %p..\n", - *tmp, mbox); - if (mbox) - /* The first mailbox we open will be shown; the others will - * have notebook pages, but will not be shown. */ - balsa_mblist_open_mailbox_hidden(mbox); - else { - /* Do not try to open it next time. */ - LibBalsaMailboxView *view = - g_hash_table_lookup(libbalsa_mailbox_view_table, *tmp); - /* The mailbox may have bee requested to be open because - its stored view might say so or the user requested it - from the command line - in which case, view may or may - not be present. We will be careful here. */ - if(view) { - view->open = FALSE; - view->in_sync = FALSE; - } - balsa_information(LIBBALSA_INFORMATION_WARNING, - _("Couldn't open mailbox \"%s\""), *tmp); - } - } + open_mailbox_by_url(balsa_app.current_mailbox_url); + + for (tmp = urls; *tmp; ++tmp) + open_mailbox_by_url(*tmp); + g_strfreev(urls); gdk_threads_leave(); diff --git a/src/main-window.c b/src/main-window.c index 2e4cd1b..fcbc016 100644 --- a/src/main-window.c +++ b/src/main-window.c @@ -2450,8 +2450,10 @@ balsa_window_real_close_mbnode(BalsaWindow * window, /* Just in case... */ g_object_set_data(G_OBJECT(window), BALSA_INDEX_GRAB_FOCUS, NULL); +g_print("%s from %s", __func__, balsa_app.current_mailbox_url); g_free(balsa_app.current_mailbox_url); balsa_app.current_mailbox_url = NULL; +g_print(" to NULL\n"); } } @@ -4731,8 +4733,10 @@ bw_notebook_switch_page_cb(GtkWidget * notebook, bw_enable_part_menu_items(window); #endif /*ENABLE_TOUCH_UI */ +g_print("%s from %s", __func__, balsa_app.current_mailbox_url); g_free(balsa_app.current_mailbox_url); balsa_app.current_mailbox_url = g_strdup(mailbox->url); +g_print(" to %s\n", balsa_app.current_mailbox_url); } static void diff --git a/src/main.c b/src/main.c index cef3448..7f7be0c 100644 --- a/src/main.c +++ b/src/main.c @@ -723,7 +723,7 @@ initial_open_inbox() printf("opening %s..\n", balsa_app.inbox->name); gdk_threads_enter(); - balsa_mblist_open_mailbox(balsa_app.inbox); + balsa_mblist_open_mailbox_hidden(balsa_app.inbox); gdk_threads_leave(); return FALSE; diff --git a/src/save-restore.c b/src/save-restore.c index 7a32df9..d5e4ade 100644 --- a/src/save-restore.c +++ b/src/save-restore.c @@ -1448,6 +1448,7 @@ config_save(void) libbalsa_conf_set_bool("RememberOpenMailboxes", balsa_app.remember_open_mboxes); +g_print("%s saving CurrentMailboxURL = %s\n", __func__, balsa_app.current_mailbox_url); libbalsa_conf_set_string("CurrentMailboxURL", balsa_app.current_mailbox_url);
Attachment:
pgpCyCKSqUnh5.pgp
Description: PGP signature