[anjal: 1/2] Message list keyboard shortcuts implemented.
- From: Srinivasa Ragavan <sragavan src gnome org>
- To: svn-commits-list gnome org
- Subject: [anjal: 1/2] Message list keyboard shortcuts implemented.
- Date: Wed, 25 Mar 2009 01:01:34 -0400 (EDT)
commit 62dd4da82c824d5390c06cec7d1d553df6d7ae22
Author: Srinivasa Ragavan <sragavan novell com>
Date: Wed Mar 25 10:22:28 2009 +0530
Message list keyboard shortcuts implemented.
http://live.gnome.org/Anjal/KeyboardShortcuts
---
src/em-tree-store.c | 22 +++++++++++
src/em-tree-store.h | 3 +-
src/mail-folder-view.c | 96 +++++++++++++++++++++++++++++++++++++++++++++++-
3 files changed, 118 insertions(+), 3 deletions(-)
diff --git a/src/em-tree-store.c b/src/em-tree-store.c
index 861ec1f..ac942a0 100644
--- a/src/em-tree-store.c
+++ b/src/em-tree-store.c
@@ -1292,6 +1292,20 @@ em_tree_store_get_child_sorted_tree (EMTreeStore *emts, GtkTreeIter *iter)
return nodes;
}
+GPtrArray *
+em_tree_store_get_child_infos (EMTreeStore *emts, GtkTreeIter *iter)
+{
+ EMTreeNode *node = (EMTreeNode *) iter->user_data, *tnode;;
+ GPtrArray *nodes = g_ptr_array_new ();
+ int i;
+
+ emts_child_tree (emts, node, nodes);
+ for (i=0; i<nodes->len; i++) {
+ nodes->pdata[i] = ((EMTreeNode *)nodes->pdata[i])->info;
+ }
+ return nodes;
+}
+
const char *
em_tree_store_get_uid_from_iter (EMTreeStore *emts, GtkTreeIter *iter)
{
@@ -1300,6 +1314,14 @@ em_tree_store_get_uid_from_iter (EMTreeStore *emts, GtkTreeIter *iter)
return node->info->uid;
}
+const CamelMessageInfo *
+em_tree_store_get_info_from_iter (EMTreeStore *emts, GtkTreeIter *iter)
+{
+ EMTreeNode *node = (EMTreeNode *) iter->user_data;
+
+ return node->info;
+}
+
CamelMessageInfo *
em_tree_store_get_info_from_path_string (EMTreeStore *emts, const char *path)
{
diff --git a/src/em-tree-store.h b/src/em-tree-store.h
index 68fdafc..1d38e9b 100644
--- a/src/em-tree-store.h
+++ b/src/em-tree-store.h
@@ -112,5 +112,6 @@ GPtrArray * em_tree_store_get_child_sorted_tree (EMTreeStore *emts, GtkTreeIter
CamelMessageInfo * em_tree_store_get_info_from_path_string (EMTreeStore *emts, const char *path);
const char * em_tree_store_get_uid_from_iter (EMTreeStore *emts, GtkTreeIter *iter);
int em_tree_store_get_iter(EMTreeStore *emts, GtkTreeIter *iter, const char *uid);
-
+const CamelMessageInfo * em_tree_store_get_info_from_iter (EMTreeStore *emts, GtkTreeIter *iter);
+GPtrArray * em_tree_store_get_child_infos (EMTreeStore *emts, GtkTreeIter *iter);
#endif /* _EM_TREE_STORE_H */
diff --git a/src/mail-folder-view.c b/src/mail-folder-view.c
index 6aded2e..8e9e20e 100644
--- a/src/mail-folder-view.c
+++ b/src/mail-folder-view.c
@@ -37,6 +37,8 @@
#include <e-util/e-icon-factory.h>
#include <e-util/e-util.h>
+#include <gdk/gdkkeysyms.h>
+
struct _MailFolderViewPrivate {
guint light:1;
guint show_thread:1;
@@ -398,6 +400,7 @@ mail_folder_view_set_folder (MailFolderView *mfv, CamelFolder *folder, const cha
pos = strtod(spos, NULL);
}
gtk_label_set_text (mfv->priv->tab_str, folder->full_name);
+ gtk_adjustment_set_value(gtk_scrolled_window_get_vadjustment (mfv->priv->view_scroller), pos);
if (last_sel_uid && *last_sel_uid) {
GtkTreeSelection *sel = gtk_tree_view_get_selection (mfv->tree);
GtkTreePath *path;
@@ -410,7 +413,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 */
}
}
@@ -754,6 +757,20 @@ mfv_get_selected_uid (GtkTreeView *tree, MailFolderView *mfv)
return em_tree_store_get_uid_from_iter (mfv->model, &iter);
}
+static const CamelMessageInfo *
+mfv_get_selected_info (GtkTreeView *tree, MailFolderView *mfv)
+{
+ GtkTreeSelection *sel = gtk_tree_view_get_selection (tree);
+ GtkTreeIter iter;
+ gboolean selected;
+
+ selected = gtk_tree_selection_get_selected (sel, NULL, &iter);
+ if(!selected)
+ return NULL;
+
+ return em_tree_store_get_info_from_iter(mfv->model, &iter);
+}
+
static gboolean
mfv_button_clicked (GtkWidget *w, GdkEventButton *event, MailFolderView *mfv)
{
@@ -848,6 +865,80 @@ mfv_msg_junk (GtkCellRenderer *cell, GdkEvent *event,GtkWidget *widget,const gch
return TRUE;
}
+static void
+mfv_selection_mark (MailFolderView *mfv, guint32 mask, guint32 set)
+{
+ GtkTreeSelection *sel = gtk_tree_view_get_selection (mfv->tree);
+ GtkTreeIter iter;
+ gboolean selected;
+ CamelMessageInfo *info = (CamelMessageInfo *) mfv_get_selected_info (mfv->tree, mfv);
+ GPtrArray *msgs = NULL;
+ int i;
+
+ selected = gtk_tree_selection_get_selected (sel, NULL, &iter);
+ if(!selected)
+ return;
+
+ camel_message_info_set_flags (info, mask, set);
+ msgs = em_tree_store_get_child_infos (mfv, &iter);
+ for (i=0; i<msgs->len; i++)
+ camel_message_info_set_flags ((CamelMessageInfo *)msgs->pdata[i], mask, set);
+}
+
+static void
+mfv_delete (MailFolderView *mfv, gboolean del)
+{
+ if (del)
+ mfv_selection_mark (mfv, CAMEL_MESSAGE_SEEN|CAMEL_MESSAGE_DELETED, CAMEL_MESSAGE_SEEN|CAMEL_MESSAGE_DELETED );
+ else
+ mfv_selection_mark (mfv, CAMEL_MESSAGE_DELETED, 0 );
+}
+
+static void
+mfv_junk (MailFolderView *mfv, gboolean junk)
+{
+ if (junk)
+ mfv_selection_mark (mfv, CAMEL_MESSAGE_SEEN|CAMEL_MESSAGE_JUNK|CAMEL_MESSAGE_NOTJUNK|CAMEL_MESSAGE_JUNK_LEARN, CAMEL_MESSAGE_SEEN|CAMEL_MESSAGE_JUNK|CAMEL_MESSAGE_JUNK_LEARN);
+ else
+ mfv_selection_mark (mfv, CAMEL_MESSAGE_JUNK|CAMEL_MESSAGE_NOTJUNK|CAMEL_MESSAGE_JUNK_LEARN, CAMEL_MESSAGE_NOTJUNK|CAMEL_MESSAGE_JUNK_LEARN);
+}
+
+static void
+mfv_read (MailFolderView *mfv, gboolean read)
+{
+ if (read)
+ mfv_selection_mark (mfv, CAMEL_MESSAGE_SEEN, CAMEL_MESSAGE_SEEN);
+ else
+ mfv_selection_mark (mfv, CAMEL_MESSAGE_SEEN|CAMEL_MESSAGE_DELETED, 0);
+}
+
+static gboolean
+mfv_key_pressed (GtkWidget *w, GdkEventKey *event, MailFolderView *mfv)
+{
+ gboolean shift = event->state & GDK_SHIFT_MASK ? TRUE : FALSE;
+
+ switch (event->keyval) {
+ case GDK_D:
+ case GDK_d:
+ if (!(event->state & GDK_CONTROL_MASK))
+ return FALSE;
+ case GDK_Delete:
+ mfv_delete (mfv, !shift);
+ break;
+ case GDK_J:
+ case GDK_j:
+ mfv_junk (mfv, !shift);
+ break;
+ case GDK_M:
+ case GDK_m:
+ mfv_read(mfv, !shift);
+ break;
+ default:
+ return FALSE;
+ }
+
+ return TRUE;
+}
void
mail_folder_view_construct (MailFolderView *shell)
@@ -895,7 +986,8 @@ mail_folder_view_construct (MailFolderView *shell)
g_signal_connect (shell->tree, "row-activated", G_CALLBACK (mfv_message_activated), shell);
g_signal_connect (shell->tree, "button-press-event", G_CALLBACK(mfv_button_clicked), shell);
-
+ g_signal_connect (shell->tree, "key-press-event", G_CALLBACK(mfv_key_pressed), shell);
+
/* Create the single column */
column = gtk_tree_view_column_new ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]