aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mail/ChangeLog9
-rw-r--r--mail/em-folder-browser.c25
-rw-r--r--mail/em-folder-tree.c113
-rw-r--r--mail/em-folder-tree.h3
4 files changed, 142 insertions, 8 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog
index 05772d0f06..223cf3aeda 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,3 +1,12 @@
+2007-07-29 Johnny Jacob <jjohnny@novell.com>
+
+ ** Fix for bug #237989
+
+ * em-folder-browser.c : Adding more support for bkspace in magic
+ space bar feature.
+ * em-folder-tree.c (em_folder_tree_select_prev_path) :
+ Added. Select the previous folder.
+
2007-07-29 Srinivasa Ragavan <sragavan@novell.com>
** Fix for bug #458820 from Cosimo Cecchi
diff --git a/mail/em-folder-browser.c b/mail/em-folder-browser.c
index 30d755a20d..b0f467d313 100644
--- a/mail/em-folder-browser.c
+++ b/mail/em-folder-browser.c
@@ -58,6 +58,7 @@
#include <camel/camel-stream.h>
#include <camel/camel-url.h>
+#include <camel/camel-folder.h>
#include <camel/camel-vee-folder.h>
#include <camel/camel-vee-store.h>
@@ -1174,16 +1175,26 @@ emfb_list_key_press(ETree *tree, int row, ETreePath path, int col, GdkEvent *ev,
case GDK_space:
if (!emfb->view.preview->caret_mode) {
state = gtk_html_command(((EMFormatHTML *)((EMFolderView *) emfb)->preview)->html, "scroll-forward");
- if (!state)
+ if (!state) {
folder_choose = message_list_select(((EMFolderView *) emfb)->list, MESSAGE_LIST_SELECT_NEXT, 0, CAMEL_MESSAGE_SEEN);
+ if (!folder_choose)
+ folder_choose = message_list_select(((EMFolderView *) emfb)->list,
+ MESSAGE_LIST_SELECT_NEXT | MESSAGE_LIST_SELECT_WRAP, 0, CAMEL_MESSAGE_SEEN);
+ }
+
} else
em_utils_adjustment_page(gtk_scrolled_window_get_vadjustment((GtkScrolledWindow *)emfb->priv->scroll), TRUE);
break;
case GDK_BackSpace:
if (!emfb->view.preview->caret_mode) {
state = gtk_html_command(((EMFormatHTML *)((EMFolderView *) emfb)->preview)->html, "scroll-backward");
- if (!state)
+ if (!state) {
folder_choose = message_list_select(((EMFolderView *) emfb)->list, MESSAGE_LIST_SELECT_PREVIOUS, 0, CAMEL_MESSAGE_SEEN);
+ if (!folder_choose)
+ folder_choose = message_list_select(((EMFolderView *) emfb)->list,
+ MESSAGE_LIST_SELECT_PREVIOUS | MESSAGE_LIST_SELECT_WRAP, 0, CAMEL_MESSAGE_SEEN);
+ }
+
} else
em_utils_adjustment_page(gtk_scrolled_window_get_vadjustment((GtkScrolledWindow *)emfb->priv->scroll), FALSE);
break;
@@ -1192,8 +1203,16 @@ emfb_list_key_press(ETree *tree, int row, ETreePath path, int col, GdkEvent *ev,
}
if (!folder_choose && !emfb->view.preview->caret_mode) {
+ //check for unread messages. if yes .. rewindback to the folder
EMFolderTree *emft = g_object_get_data((GObject*)emfb, "foldertree");
- em_folder_tree_select_next_path (emft);
+ switch (ev->key.keyval) {
+ case GDK_space:
+ em_folder_tree_select_next_path (emft);
+ break;
+ case GDK_BackSpace:
+ em_folder_tree_select_prev_path (emft);
+ break;
+ }
gtk_widget_grab_focus ((GtkWidget *)((EMFolderView *) emfb)->list);
}
return TRUE;
diff --git a/mail/em-folder-tree.c b/mail/em-folder-tree.c
index 93666128df..e3eb4b8391 100644
--- a/mail/em-folder-tree.c
+++ b/mail/em-folder-tree.c
@@ -2318,22 +2318,29 @@ em_folder_tree_set_selected (EMFolderTree *emft, const char *uri)
g_list_free(l);
}
+
void
-em_folder_tree_select_next_path (EMFolderTree *emft)
+em_folder_tree_select_next_path (EMFolderTree *emft, gboolean skip_read_folders)
{
GtkTreeSelection *selection;
GtkTreeModel *model;
GtkTreeIter iter, parent, child;
- GtkTreePath *path = NULL;
+ GtkTreePath *current_path, *path = NULL;
+ unsigned int unread = 0;
struct _EMFolderTreePrivate *priv = emft->priv;
g_return_if_fail (EM_IS_FOLDER_TREE (emft));
selection = gtk_tree_view_get_selection(emft->priv->treeview);
if (gtk_tree_selection_get_selected(selection, &model, &iter)) {
+
+ current_path = gtk_tree_model_get_path (model, &iter);
+
+ do {
if (gtk_tree_model_iter_has_child (model, &iter)) {
gtk_tree_model_iter_children (model, &child, &iter);
path = gtk_tree_model_get_path (model, &child);
+ iter = child;
} else {
while (1) {
gboolean has_parent = gtk_tree_model_iter_parent (model, &parent, &iter);
@@ -2341,16 +2348,114 @@ em_folder_tree_select_next_path (EMFolderTree *emft)
path = gtk_tree_model_get_path (model, &iter);
break;
} else {
- if (has_parent)
+ if (has_parent) {
iter = parent;
- else
+ } else {
+ /* Reached end. Wrapup*/
+ gtk_tree_model_get_iter_first (model, &iter);
+ path = gtk_tree_model_get_path (model, &iter);
break;
+ }
}
}
}
+ gtk_tree_model_get (model, &iter, COL_UINT_UNREAD, &unread, -1);
+
+ /* TODO : Flags here for better options */
+ } while (skip_read_folders && unread <=0 && gtk_tree_path_compare (current_path, path));
+ }
+
+ if (path) {
+ if (!gtk_tree_view_row_expanded (emft->priv->treeview, path))
+ gtk_tree_view_expand_to_path (emft->priv->treeview, path);
+
+ gtk_tree_selection_select_path(selection, path);
+
+ if (!priv->cursor_set) {
+ gtk_tree_view_set_cursor (priv->treeview, path, NULL, FALSE);
+ priv->cursor_set = TRUE;
+ }
+ gtk_tree_view_scroll_to_cell (priv->treeview, path, NULL, TRUE, 0.5f, 0.0f);
+ }
+ return;
+}
+
+static GtkTreeIter
+get_last_child (GtkTreeModel *model, GtkTreeIter *iter)
+{
+ GtkTreeIter *child = g_new0 (GtkTreeIter, 1);
+ gboolean has_child = gtk_tree_model_iter_has_child (model, iter);
+
+ if (gtk_tree_model_iter_next (model, iter)) {
+ get_last_child (model, iter);
+ } else {
+
+ if (has_child) {
+ /* Pick the last one */
+ int nchildren = gtk_tree_model_iter_n_children (model, iter);
+ gtk_tree_model_iter_nth_child ( model, child, iter, nchildren-1);
+ get_last_child (model, child);
+ }
+ else {
+ return *iter;
+ }
+
+ }
+//TODO : The function should return the value here !!
+}
+
+void
+em_folder_tree_select_prev_path (EMFolderTree *emft, gboolean skip_read_folders)
+{
+ GtkTreeSelection *selection;
+ GtkTreeModel *model;
+ GtkTreeIter iter, parent, child;
+ GtkTreePath *path, *current_path = NULL;
+ unsigned int unread = 0;
+ struct _EMFolderTreePrivate *priv = emft->priv;
+
+ g_return_if_fail (EM_IS_FOLDER_TREE (emft));
+
+ selection = gtk_tree_view_get_selection(emft->priv->treeview);
+
+ if (gtk_tree_selection_get_selected(selection, &model, &iter)){
+
+ current_path = gtk_tree_model_get_path (model, &iter);
+ do {
+ path = gtk_tree_model_get_path (model, &iter);
+ if (!gtk_tree_path_prev (path)) {
+ gtk_tree_path_up (path);
+
+ if (!gtk_tree_path_compare (gtk_tree_path_new_first (), path))
+ {
+ gtk_tree_model_get_iter_first (model, &iter);
+ iter = get_last_child (model,&iter);
+ path = gtk_tree_model_get_path (model, &iter);
+ }
+ } else {
+ gtk_tree_model_get_iter (model, &iter, path);
+ if (gtk_tree_model_iter_has_child (model, &iter)) {
+ int nchildren = gtk_tree_model_iter_n_children (model, &iter);
+ gtk_tree_model_iter_nth_child ( model, &child, &iter, nchildren-1);
+ path = gtk_tree_model_get_path (model, &child);
+ }
+ }
+
+ /* TODO : Flags here for better options */
+ gtk_tree_model_get_iter_from_string (model, &iter, gtk_tree_path_to_string (path) );
+
+ gtk_tree_model_get (model, &iter, COL_UINT_UNREAD, &unread, -1);
+
+ } while (skip_read_folders && unread <=0 && gtk_tree_path_compare (current_path, path));
}
+
if (path) {
+ if (!gtk_tree_view_row_expanded (priv->treeview, path)) {
+ gtk_tree_view_expand_to_path (priv->treeview, path);
+ }
+
gtk_tree_selection_select_path(selection, path);
+
if (!priv->cursor_set) {
gtk_tree_view_set_cursor (priv->treeview, path, NULL, FALSE);
priv->cursor_set = TRUE;
diff --git a/mail/em-folder-tree.h b/mail/em-folder-tree.h
index c8bf089089..5af8284ea7 100644
--- a/mail/em-folder-tree.h
+++ b/mail/em-folder-tree.h
@@ -83,7 +83,8 @@ GList *em_folder_tree_get_selected_uris (EMFolderTree *emft);
GList *em_folder_tree_get_selected_paths (EMFolderTree *emft);
void em_folder_tree_set_selected (EMFolderTree *emft, const char *uri);
-void em_folder_tree_select_next_path (EMFolderTree *emft);
+void em_folder_tree_select_next_path (EMFolderTree *emft, gboolean skip_read_folders);
+void em_folder_tree_select_prev_path (EMFolderTree *emft, gboolean skip_read_folders);
char *em_folder_tree_get_selected_uri (EMFolderTree *emft);
char *em_folder_tree_get_selected_path (EMFolderTree *emft);
CamelFolder *em_folder_tree_get_selected_folder (EMFolderTree *emft);