[anjal] Save/restore cursor/scroll position. On folder switch, close and load on
- From: Srinivasa Ragavan <sragavan src gnome org>
- To: svn-commits-list gnome org
- Subject: [anjal] Save/restore cursor/scroll position. On folder switch, close and load on
- Date: Tue, 24 Mar 2009 02:54:04 -0400 (EDT)
commit 5c011380e1f9c004de5077f5e5079bee4b2c9fb6
Author: Srinivasa Ragavan <sragavan novell com>
Date: Tue Mar 24 12:19:10 2009 +0530
Save/restore cursor/scroll position. On folder switch, close and load on
folder load
---
src/mail-folder-view.c | 31 +++++++++++++++++++++++++------
1 files changed, 25 insertions(+), 6 deletions(-)
diff --git a/src/mail-folder-view.c b/src/mail-folder-view.c
index e4d914b..6bb773b 100644
--- a/src/mail-folder-view.c
+++ b/src/mail-folder-view.c
@@ -152,13 +152,26 @@ mfv_btn_expose (GtkWidget *w, GdkEventExpose *event, MailFolderView *mfv)
}
static void
-mfv_close (GtkButton *w, MailFolderView *mfv)
+mfv_save (MailFolderView *mfv)
{
const char *uid = mfv_get_selected_uid (mfv->tree, mfv);
- if (uid && *uid && mfv->priv->folder) {
+ double pos;
+ char *state;
+
+ if (uid && *uid && mfv->priv->folder)
camel_object_meta_set (mfv->priv->folder, "anjal:selected_uid", uid);
- camel_object_state_write(mfv->priv->folder);
- }
+
+ pos = gtk_adjustment_get_value(gtk_scrolled_window_get_vadjustment (mfv->priv->view_scroller));
+ state = g_strdup_printf ("%lf", pos);
+ camel_object_meta_set (mfv->priv->folder, "anjal:scroll_position", state);
+ camel_object_state_write(mfv->priv->folder);
+ g_free(state);
+}
+
+static void
+mfv_close (GtkButton *w, MailFolderView *mfv)
+{
+ mfv_save(mfv);
g_signal_emit (mfv, signals[VIEW_CLOSE], 0);
}
@@ -303,9 +316,9 @@ mfv_got_folder(char *uri, CamelFolder *folder, void *data)
{
MailFolderView *mfv = data;
struct _db_read_msg *m;
-// mail_folder_view_set_folder(mfv, folder, uri);
if (mfv->priv->folder) {
+ mfv_save(mfv);
gtk_tree_view_set_model (GTK_TREE_VIEW (mfv->tree), NULL);
camel_object_unref (mfv->priv->folder);
mfv->priv->folder= NULL;
@@ -364,7 +377,8 @@ mail_folder_view_set_folder (MailFolderView *mfv, CamelFolder *folder, const cha
}
if (folder) {
/* Load cursor based or folder based */
- char *last_sel_uid;
+ char *last_sel_uid, *spos;
+ double pos = 0;
GtkTreeIter iter;
gtk_tree_view_set_model (GTK_TREE_VIEW (mfv->tree), mfv->model);
mfv->priv->uri = g_strdup(uri);
@@ -375,6 +389,10 @@ mail_folder_view_set_folder (MailFolderView *mfv, CamelFolder *folder, const cha
gtk_widget_show (mfv->priv->view_scroller);
gtk_widget_show (mfv->tree);
last_sel_uid = camel_object_meta_get (folder, "anjal:selected_uid");
+ spos = camel_object_meta_get (folder, "anjal:scroll_position");
+ if (spos && *spos) {
+ pos = strtod(spos, NULL);
+ }
gtk_label_set_text (mfv->priv->tab_str, folder->full_name);
if (last_sel_uid && *last_sel_uid) {
GtkTreeSelection *sel = gtk_tree_view_get_selection (mfv->tree);
@@ -388,6 +406,7 @@ mail_folder_view_set_folder (MailFolderView *mfv, CamelFolder *folder, const cha
gtk_tree_path_free (path);
}
}
+ gtk_adjustment_set_value(gtk_scrolled_window_get_vadjustment (mfv->priv->view_scroller), pos);
/* FIXME: Set a signal emit and listen for it at note book and set the title appropriately */
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]