diff options
author | Jeffrey Stedfast <fejj@ximian.com> | 2004-05-05 04:46:59 +0800 |
---|---|---|
committer | Jeffrey Stedfast <fejj@src.gnome.org> | 2004-05-05 04:46:59 +0800 |
commit | 07b89016f77b35049b8f5c1099fb0ba827f4015a (patch) | |
tree | 2e394a107d3d0fabd13fb58405eab131a70986db | |
parent | 7844d71521c917e28a0aa369f7881aeab9820604 (diff) | |
download | gsoc2013-evolution-07b89016f77b35049b8f5c1099fb0ba827f4015a.tar.gz gsoc2013-evolution-07b89016f77b35049b8f5c1099fb0ba827f4015a.tar.zst gsoc2013-evolution-07b89016f77b35049b8f5c1099fb0ba827f4015a.zip |
Fix for bug #55303, but ideally there would be a nicer way of doing this -
2004-05-04 Jeffrey Stedfast <fejj@ximian.com>
Fix for bug #55303, but ideally there would be a nicer way of
doing this - likely with some added ETree API but that's not
likely to happen anytime soon.
* em-folder-browser.c (scroll_idle_cb): Recall the saved scrollbar
position state and set it, then reconnect to the
message_list_scrolled signal.
(emfb_list_built): Calculate a default scrollbar position for
scroll_idle_cb to use if there's no saved state.
(emfb_set_folder): Disconnect from the message_list_scrolled
signal and the idle_scroll_id.
(emfb_list_scrolled): Save the scrollbar position state.
(emfb_destroy): Disconnect from list_scrolled_id and
idle_scroll_id.
svn path=/trunk/; revision=25794
-rw-r--r-- | mail/ChangeLog | 15 | ||||
-rw-r--r-- | mail/em-folder-browser.c | 96 | ||||
-rw-r--r-- | mail/em-folder-tree.c | 10 |
3 files changed, 103 insertions, 18 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog index 8ad0ad7749..f13d686e40 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,5 +1,20 @@ 2004-05-04 Jeffrey Stedfast <fejj@ximian.com> + Fix for bug #55303, but ideally there would be a nicer way of + doing this - likely with some added ETree API but that's not + likely to happen anytime soon. + + * em-folder-browser.c (scroll_idle_cb): Recall the saved scrollbar + position state and set it, then reconnect to the + message_list_scrolled signal. + (emfb_list_built): Calculate a default scrollbar position for + scroll_idle_cb to use if there's no saved state. + (emfb_set_folder): Disconnect from the message_list_scrolled + signal and the idle_scroll_id. + (emfb_list_scrolled): Save the scrollbar position state. + (emfb_destroy): Disconnect from list_scrolled_id and + idle_scroll_id. + Fix for bug #58004. * mail-account-gui.c (display_license): Fixed to compile. diff --git a/mail/em-folder-browser.c b/mail/em-folder-browser.c index 1943d99941..e3082509ca 100644 --- a/mail/em-folder-browser.c +++ b/mail/em-folder-browser.c @@ -49,14 +49,7 @@ #include <e-util/e-dialog-utils.h> #include <e-util/e-icon-factory.h> -/*#include <camel/camel-mime-message.h>*/ #include <camel/camel-stream.h> -/*#include <camel/camel-stream-filter.h> -#include <camel/camel-mime-filter.h> -#include <camel/camel-mime-filter-tohtml.h> -#include <camel/camel-mime-filter-enriched.h> -#include <camel/camel-multipart.h> -#include <camel/camel-stream-mem.h>*/ #include <camel/camel-url.h> #include <bonobo/bonobo-main.h> @@ -107,7 +100,11 @@ struct _EMFolderBrowserPrivate { guint search_menu_activated_id; guint search_activated_id; guint search_query_changed_id; - + + double default_scroll_position; + guint idle_scroll_id; + guint list_scrolled_id; + guint vpane_resize_id; guint list_built_id; /* hook onto list-built for delayed 'select first unread' stuff */ @@ -251,7 +248,17 @@ emfb_destroy(GtkObject *o) g_signal_handler_disconnect(((EMFolderView *)emfb)->list, emfb->priv->list_built_id); emfb->priv->list_built_id = 0; } - + + if (emfb->priv->list_scrolled_id) { + g_signal_handler_disconnect (((EMFolderView *) emfb)->list, emfb->priv->list_scrolled_id); + emfb->priv->list_scrolled_id = 0; + } + + if (emfb->priv->idle_scroll_id) { + g_source_remove (emfb->priv->idle_scroll_id); + emfb->priv->idle_scroll_id = 0; + } + ((GtkObjectClass *)emfb_parent)->destroy(o); } @@ -788,12 +795,52 @@ emfb_view_preview(BonoboUIComponent *uic, const char *path, Bonobo_UIComponent_E em_folder_browser_show_preview((EMFolderBrowser *)emfv, state[0] != '0'); } +static void +emfb_list_scrolled (MessageList *ml, EMFolderBrowser *emfb) +{ + EMFolderView *emfv = (EMFolderView *) emfb; + double position; + char *state; + + position = message_list_get_scrollbar_position (ml); + state = g_strdup_printf ("%f", position); + + if (camel_object_meta_set (emfv->folder, "evolution:list_scroll_position", state)) + camel_object_state_write (emfv->folder); + + g_free (state); +} + +static gboolean +scroll_idle_cb (EMFolderBrowser *emfb) +{ + EMFolderView *emfv = (EMFolderView *) emfb; + double position; + char *state; + + if ((state = camel_object_meta_get (emfv->folder, "evolution:list_scroll_position"))) { + position = strtod (state, NULL); + g_free (state); + } else { + position = emfb->priv->default_scroll_position; + } + + message_list_set_scrollbar_position (emfv->list, position); + + emfb->priv->list_scrolled_id = g_signal_connect (emfv->list, "message_list_scrolled", G_CALLBACK (emfb_list_scrolled), emfb); + + emfb->priv->idle_scroll_id = 0; + + return FALSE; +} + /* TODO: This should probably be handled by message-list, by storing/queueing up the select operation if its busy rebuilding the message-list */ static void emfb_list_built (MessageList *ml, EMFolderBrowser *emfb) { EMFolderView *emfv = (EMFolderView *) emfb; + double position = 0.0f; g_signal_handler_disconnect (ml, emfb->priv->list_built_id); emfb->priv->list_built_id = 0; @@ -803,12 +850,23 @@ emfb_list_built (MessageList *ml, EMFolderBrowser *emfb) message_list_select_uid (ml, emfb->priv->select_uid); g_free (emfb->priv->select_uid); emfb->priv->select_uid = NULL; + + /* change the default to the current position */ + position = message_list_get_scrollbar_position (ml); } else { /* NOTE: not all users want this, so we need a preference for it perhaps? see bug #52887 */ /* FIXME: if the 1st message in the list is unread, this will actually select the second unread msg */ /*message_list_select (ml, MESSAGE_LIST_SELECT_NEXT, 0, CAMEL_MESSAGE_SEEN, TRUE);*/ } } + + emfb->priv->default_scroll_position = position; + + /* FIXME: this is a gross workaround for an etable bug that I can't fix - bug #55303 */ + /* this needs to be a lower priority than anything in e-table-item/e-canvas, since + * e_canvas_item_region_show_relay() uses a timeout, we have to use a timeout of the + * same interval but a lower priority. */ + emfb->priv->idle_scroll_id = g_timeout_add_full (G_PRIORITY_LOW, 250, (GSourceFunc) scroll_idle_cb, emfb, NULL); } @@ -922,9 +980,19 @@ emfb_set_folder(EMFolderView *emfv, CamelFolder *folder, const char *uri) { EMFolderBrowser *emfb = (EMFolderBrowser *) emfv; struct _EMFolderBrowserPrivate *p = emfb->priv; - + message_list_freeze(emfv->list); - + + if (emfb->priv->list_scrolled_id) { + g_signal_handler_disconnect (emfv->list, emfb->priv->list_scrolled_id); + emfb->priv->list_scrolled_id = 0; + } + + if (emfb->priv->idle_scroll_id) { + g_source_remove (emfb->priv->idle_scroll_id); + emfb->priv->idle_scroll_id = 0; + } + emfb_parent->set_folder(emfv, folder, uri); /* This is required since we get activated the first time @@ -968,15 +1036,15 @@ emfb_set_folder(EMFolderView *emfv, CamelFolder *folder, const char *uri) message_list_set_search(emfb->view.list, sstate); g_free(sstate); - if ((sstate = camel_object_meta_get (folder, "evolution:selected_uid"))) + if ((sstate = camel_object_meta_get (folder, "evolution:selected_uid"))) { emfb->priv->select_uid = sstate; - else { + } else { g_free(p->select_uid); p->select_uid = NULL; } if (emfv->list->cursor_uid == NULL && emfb->priv->list_built_id == 0) - emfb->priv->list_built_id = g_signal_connect(emfv->list, "message_list_built", G_CALLBACK (emfb_list_built), emfv); + p->list_built_id = g_signal_connect(emfv->list, "message_list_built", G_CALLBACK (emfb_list_built), emfv); /*emfb_create_view_instance (emfb, folder, uri);*/ if (emfv->uic) diff --git a/mail/em-folder-tree.c b/mail/em-folder-tree.c index 714329327e..58d7bb1c44 100644 --- a/mail/em-folder-tree.c +++ b/mail/em-folder-tree.c @@ -46,6 +46,7 @@ #include <camel/camel-vtrash-folder.h> #include <camel/camel-stream-mem.h> #include <camel/camel-file-utils.h> +#include <camel/camel-stream-fs.h> #include "e-util/e-mktemp.h" #include "e-util/e-request.h" @@ -1404,6 +1405,7 @@ static gboolean tree_drag_motion (GtkWidget *widget, GdkDragContext *context, int x, int y, guint time, EMFolderTree *emft) { struct _EMFolderTreePrivate *priv = emft->priv; + GtkTreeModel *model = (GtkTreeModel *) priv->model; GtkTreeViewDropPosition pos; GdkDragAction action = 0; GtkTreePath *path; @@ -1417,9 +1419,9 @@ tree_drag_motion (GtkWidget *widget, GdkDragContext *context, int x, int y, guin if (priv->autoscroll_id == 0) priv->autoscroll_id = g_timeout_add (150, (GSourceFunc) tree_autoscroll, emft); - gtk_tree_model_get_iter (priv->model, &iter, path); + gtk_tree_model_get_iter (model, &iter, path); - if (gtk_tree_model_iter_has_child (priv->model, &iter) && !gtk_tree_view_row_expanded (priv->treeview, path)) { + if (gtk_tree_model_iter_has_child (model, &iter) && !gtk_tree_view_row_expanded (priv->treeview, path)) { if (priv->autoexpand_id != 0) { GtkTreePath *autoexpand_path; @@ -1427,7 +1429,7 @@ tree_drag_motion (GtkWidget *widget, GdkDragContext *context, int x, int y, guin if (gtk_tree_path_compare (autoexpand_path, path) != 0) { /* row changed, restart timer */ gtk_tree_row_reference_free (priv->autoexpand_row); - priv->autoexpand_row = gtk_tree_row_reference_new (priv->model, path); + priv->autoexpand_row = gtk_tree_row_reference_new (model, path); g_source_remove (priv->autoexpand_id); priv->autoexpand_id = g_timeout_add (600, (GSourceFunc) tree_autoexpand, emft); } @@ -1435,7 +1437,7 @@ tree_drag_motion (GtkWidget *widget, GdkDragContext *context, int x, int y, guin gtk_tree_path_free (autoexpand_path); } else { priv->autoexpand_id = g_timeout_add (600, (GSourceFunc) tree_autoexpand, emft); - priv->autoexpand_row = gtk_tree_row_reference_new (priv->model, path); + priv->autoexpand_row = gtk_tree_row_reference_new (model, path); } } else if (priv->autoexpand_id != 0) { gtk_tree_row_reference_free (priv->autoexpand_row); |