[anjal/anjal-0-1] Handle Ctrl+W to close tabs in composer, conv and folder view. (ported from commit ce6de058f277edcce



commit c3b8e2bbc2632e59160aa7e933ba2326660fe757
Author: Srinivasa Ragavan <sragavan gnome org>
Date:   Wed Dec 2 18:50:05 2009 +0530

    Handle Ctrl+W to close tabs in composer, conv and folder view.
    (ported from commit ce6de058f277edcce30e47702ca3b5db0ff68e65)

 src/mail-composer-view.c |   24 ++++++++++++++++++++++++
 src/mail-conv-view.c     |   10 ++++++++++
 src/mail-folder-view.c   |    9 ++++++++-
 3 files changed, 42 insertions(+), 1 deletions(-)
---
diff --git a/src/mail-composer-view.c b/src/mail-composer-view.c
index aab908c..5c927b7 100644
--- a/src/mail-composer-view.c
+++ b/src/mail-composer-view.c
@@ -27,6 +27,7 @@
 #endif
 
 #include <glib/gi18n.h>
+#include <gdk/gdkkeysyms.h>
 
 #include <e-util/e-error.h>
 
@@ -135,6 +136,28 @@ composer_send_close_cb (struct _EMsgComposer *composer, MailComposerView *mcv)
 		g_signal_emit (mcv, signals[VIEW_CLOSE], 0);
 }
 
+static gboolean
+mcv_key_pressed (GtkWidget *w, GdkEventKey *event, MailComposerView *mcv)
+{
+	gboolean ctrl = event->state & GDK_CONTROL_MASK ? TRUE : FALSE;
+	switch (event->keyval) {
+	case GDK_w:
+	case GDK_W:
+	{
+		if (!ctrl)
+			return FALSE;
+		g_signal_emit (mcv, signals[VIEW_CLOSE], 0);			
+
+		return TRUE;
+	}
+	
+	default:
+		return FALSE;
+	}
+
+	return TRUE;	
+}
+
 void
 mail_composer_view_construct (MailComposerView *shell, struct _EMsgComposer *new_composer)
 {
@@ -162,6 +185,7 @@ mail_composer_view_construct (MailComposerView *shell, struct _EMsgComposer *new
 	
 	g_object_set_data ((GObject *)img, "pbuf", icon);
 	g_signal_connect (img, "expose-event", G_CALLBACK(mcv_btn_expose), shell);
+	g_signal_connect (shell, "key-press-event", G_CALLBACK(mcv_key_pressed), shell);
 
 	shell->tab_label = gtk_hbox_new (FALSE, 0);
 	w = gtk_label_new (_("New email"));
diff --git a/src/mail-conv-view.c b/src/mail-conv-view.c
index a592e31..2fe6961 100644
--- a/src/mail-conv-view.c
+++ b/src/mail-conv-view.c
@@ -91,6 +91,7 @@ mcv_key_press (GtkWidget  *widget, GdkEventKey *event)
 {
 	MailConvView *shell = (MailConvView *)widget;
 	MailConvViewPrivate *priv = shell->priv;
+	gboolean ctrl = event->state & GDK_CONTROL_MASK ? TRUE : FALSE;
 
 	switch (event->keyval) {
 /*	case GDK_KP_Right:
@@ -164,6 +165,15 @@ mcv_key_press (GtkWidget  *widget, GdkEventKey *event)
 		
 		return TRUE;
 	}
+	case GDK_w:
+	case GDK_W:
+	{
+		if (!ctrl)
+			return FALSE;
+		g_signal_emit (shell, signals[VIEW_CLOSE], 0);			
+
+		return TRUE;
+	}
 	default:
 		return FALSE;
 	};
diff --git a/src/mail-folder-view.c b/src/mail-folder-view.c
index 3ee3aa6..31f7287 100644
--- a/src/mail-folder-view.c
+++ b/src/mail-folder-view.c
@@ -1458,7 +1458,8 @@ static gboolean
 mfv_key_pressed (GtkWidget *w, GdkEventKey *event, MailFolderView *mfv)
 {
 	 gboolean shift = event->state & GDK_SHIFT_MASK ? TRUE : FALSE;
-	 
+	 gboolean ctrl = event->state & GDK_CONTROL_MASK ? TRUE : FALSE;
+
 	 switch (event->keyval) {
 	 case GDK_D:
 	 case GDK_d:		  
@@ -1475,6 +1476,12 @@ mfv_key_pressed (GtkWidget *w, GdkEventKey *event, MailFolderView *mfv)
 	 case GDK_m:
 		  mfv_read(mfv, !shift);
 		  break;
+	case GDK_w:
+	case GDK_W:
+		if (!ctrl)
+			return FALSE;
+		g_signal_emit (mfv, signals[VIEW_CLOSE], 0);			
+		break;
 	 default:
 		  return FALSE;
 	 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]