[anjal] Add flags support and ability to steal/hold focus.
- From: Srinivasa Ragavan <sragavan src gnome org>
- To: svn-commits-list gnome org
- Subject: [anjal] Add flags support and ability to steal/hold focus.
- Date: Wed, 10 Jun 2009 09:28:21 -0400 (EDT)
commit 4b8ed8d4fe917890f1d9e6ae061ca877ab39c151
Author: Srinivasa Ragavan <sragavan novell com>
Date: Wed Jun 10 18:28:06 2009 +0530
Add flags support and ability to steal/hold focus.
---
src/mail-account-view.h | 2 +
src/mail-composer-view.h | 4 ++-
src/mail-folder-view.h | 3 +-
src/mail-message-view.h | 1 +
src/mail-settings-view.h | 2 +
src/mail-view.c | 57 ++++++++++++++++++++++++++++++---------------
src/mail-view.h | 5 ++++
7 files changed, 53 insertions(+), 21 deletions(-)
diff --git a/src/mail-account-view.h b/src/mail-account-view.h
index fef02a0..4942641 100644
--- a/src/mail-account-view.h
+++ b/src/mail-account-view.h
@@ -28,6 +28,7 @@
#include "mail/em-account-editor.h"
#include <libedataserver/e-account-list.h>
#include <camel/camel-provider.h>
+#include "mail-view.h"
#define MAIL_ACCOUNT_VIEW_TYPE (mail_account_view_get_type ())
#define MAIL_ACCOUNT_VIEW(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), MAIL_ACCOUNT_VIEW_TYPE, MailFolderView))
@@ -64,6 +65,7 @@ typedef struct _MailAccountView {
GtkVBox parent;
int type;
char *uri;
+ MailViewFlags flags;
/* Base class of MailChildView ends */
GtkWidget *scroll;
diff --git a/src/mail-composer-view.h b/src/mail-composer-view.h
index 4bf2528..8a2f707 100644
--- a/src/mail-composer-view.h
+++ b/src/mail-composer-view.h
@@ -25,6 +25,7 @@
#include <gtk/gtk.h>
#include <camel/camel.h>
+#include "mail-view.h"
#define MAIL_COMPOSER_VIEW_TYPE (mail_composer_view_get_type ())
#define MAIL_COMPOSER_VIEW(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), MAIL_COMPOSER_VIEW_TYPE, MailFolderView))
@@ -39,7 +40,8 @@ typedef struct _MailComposerView {
GtkVBox parent;
int type;
char *uri;
-
+ MailViewFlags flags;
+
/* Base class ends */
GtkWidget *tab_label;
diff --git a/src/mail-folder-view.h b/src/mail-folder-view.h
index 6a0746c..47f60fd 100644
--- a/src/mail-folder-view.h
+++ b/src/mail-folder-view.h
@@ -40,7 +40,8 @@ typedef struct _MailFolderView {
GtkVBox parent;
int type;
char *uri;
-
+ MailViewFlags flags;
+
/* Base class ends */
GtkTreeView *tree;
GtkTreeModel *model;
diff --git a/src/mail-message-view.h b/src/mail-message-view.h
index 47dd233..1b630ff 100644
--- a/src/mail-message-view.h
+++ b/src/mail-message-view.h
@@ -41,6 +41,7 @@ typedef struct _MailMessageView {
GtkVBox parent;
int type;
char *uri;
+ MailViewFlags flags;
GtkWidget *short_header;
GtkWidget *details_event;
diff --git a/src/mail-settings-view.h b/src/mail-settings-view.h
index 241415d..359d688 100644
--- a/src/mail-settings-view.h
+++ b/src/mail-settings-view.h
@@ -25,6 +25,7 @@
#include <gtk/gtk.h>
#include <webkit/webkit.h>
+#include "mail-view.h"
#define MAIL_SETTINGS_VIEW_TYPE (mail_settings_view_get_type ())
#define MAIL_SETTINGS_VIEW(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), MAIL_SETTINGS_VIEW_TYPE, MailFolderView))
@@ -40,6 +41,7 @@ typedef struct _MailSettingsView {
GtkVBox parent;
int type;
char *uri;
+ MailViewFlags flags;
/* Base class of MailChildView ends */
MailSettingsViewPrivate *priv;
diff --git a/src/mail-view.c b/src/mail-view.c
index a5b6cc0..a6dbc0b 100644
--- a/src/mail-view.c
+++ b/src/mail-view.c
@@ -96,7 +96,10 @@ mv_switch (GtkNotebook *notebook,GtkNotebookPage *page, guint page_num, gpoi
{
MailView *shell = (MailView *)notebook;
MailViewPrivate *priv = shell->priv;
+ MailViewChild *curr = priv->current_view;
+ curr->flags &= ~MAIL_VIEW_HOLD_FOCUS;
+
#ifdef MV_NEW_TAB
if (page_num == g_list_length(priv->children) && shell->priv->new) {
mail_view_add_page (shell, MAIL_VIEW_FOLDER, NULL);
@@ -270,7 +273,7 @@ mv_search_set (MailFolderView *mfv, MailView *mv)
}
static MailViewChild *
-mail_view_add_folder (MailView *mv, gpointer data)
+mail_view_add_folder (MailView *mv, gpointer data, gboolean block)
{
MailFolderView *mfv = mail_folder_view_new ();
gint position = 0;
@@ -282,19 +285,21 @@ mail_view_add_folder (MailView *mv, gpointer data)
gtk_notebook_set_tab_detachable (GTK_NOTEBOOK (mv), (GtkWidget *)mfv, FALSE);
g_signal_connect (mfv, "view-close", G_CALLBACK(mv_close_mcv), mv);
- gtk_notebook_set_current_page ((GtkNotebook *)mv, position);
+ if (!block)
+ gtk_notebook_set_current_page ((GtkNotebook *)mv, position);
gtk_notebook_set_tab_label_packing ((GtkNotebook *)mv, (GtkWidget *)mfv, FALSE, FALSE, 0);
g_signal_connect (mfv, "message-shown", G_CALLBACK(mv_message_shown), mv);
g_signal_connect (mfv, "message-new", G_CALLBACK(mv_message_new), mv);
g_signal_connect (mfv, "search-set", G_CALLBACK(mv_search_set), mv);
- mail_folder_view_activate (mfv, mv->tree, mv->folder_tree, mv->check_mail, mv->sort_by, TRUE);
+ if (!block)
+ mail_folder_view_activate (mfv, mv->tree, mv->folder_tree, mv->check_mail, mv->sort_by, TRUE);
return (MailViewChild *)mfv;
}
static MailViewChild *
-mail_view_add_composer (MailView *mv, gpointer data)
+mail_view_add_composer (MailView *mv, gpointer data, gboolean block)
{
MailComposerView *mcv;
gint position = 0;
@@ -310,9 +315,11 @@ mail_view_add_composer (MailView *mv, gpointer data)
position = gtk_notebook_append_page ((GtkNotebook *)mv, (GtkWidget *)mcv, mcv->tab_label);
gtk_notebook_set_tab_reorderable (GTK_NOTEBOOK (mv), (GtkWidget *)mcv, FALSE);
gtk_notebook_set_tab_detachable (GTK_NOTEBOOK (mv), (GtkWidget *)mcv, FALSE);
- gtk_notebook_set_current_page ((GtkNotebook *)mv, position);
+ if (!block)
+ gtk_notebook_set_current_page ((GtkNotebook *)mv, position);
gtk_notebook_set_tab_label_packing ((GtkNotebook *)mv, (GtkWidget *)mcv, FALSE, FALSE, 0);
- mail_composer_view_activate (mcv, mv->folder_tree, mv->check_mail, mv->sort_by, FALSE);
+ if (!block)
+ mail_composer_view_activate (mcv, mv->folder_tree, mv->check_mail, mv->sort_by, FALSE);
g_signal_connect (mcv, "view-close", G_CALLBACK(mv_close_mcv), mv);
@@ -320,7 +327,7 @@ mail_view_add_composer (MailView *mv, gpointer data)
}
static MailViewChild *
-mail_view_add_message (MailView *mv, gpointer data)
+mail_view_add_message (MailView *mv, gpointer data, gboolean block)
{
MailConvView *mcv = mail_conv_view_new ();
gint position = 0;
@@ -333,9 +340,11 @@ mail_view_add_message (MailView *mv, gpointer data)
position = gtk_notebook_append_page ((GtkNotebook *)mv, (GtkWidget *)mcv, mail_conv_view_get_tab_widget(mcv));
gtk_notebook_set_tab_reorderable (GTK_NOTEBOOK (mv), (GtkWidget *)mcv, FALSE);
gtk_notebook_set_tab_detachable (GTK_NOTEBOOK (mv), (GtkWidget *)mcv, FALSE);
+ if (!block)
gtk_notebook_set_current_page ((GtkNotebook *)mv, position);
gtk_notebook_set_tab_label_packing ((GtkNotebook *)mv, (GtkWidget *)mcv, FALSE, FALSE, 0);
- mail_conv_view_activate (mcv, mv->tree, mv->folder_tree, mv->check_mail, mv->sort_by, FALSE);
+ if (!block)
+ mail_conv_view_activate (mcv, mv->tree, mv->folder_tree, mv->check_mail, mv->sort_by, FALSE);
g_signal_connect (mcv, "view-close", G_CALLBACK(mv_close_mcv), mv);
@@ -349,7 +358,7 @@ mv_show_acc_mcv (MailFolderView *mfv, MailView *mv)
}
static MailViewChild *
-mail_view_add_settings (MailView *mv, gpointer data)
+mail_view_add_settings (MailView *mv, gpointer data, gboolean block)
{
MailSettingsView *msv = mail_settings_view_new ();
gint position = 0;
@@ -362,6 +371,7 @@ mail_view_add_settings (MailView *mv, gpointer data)
g_signal_connect (msv, "show-account", G_CALLBACK(mv_show_acc_mcv), mv);
gtk_notebook_set_tab_reorderable (GTK_NOTEBOOK (mv), (GtkWidget *)msv, FALSE);
gtk_notebook_set_tab_detachable (GTK_NOTEBOOK (mv), (GtkWidget *)msv, FALSE);
+ if (!block)
gtk_notebook_set_current_page ((GtkNotebook *)mv, position);
gtk_notebook_set_tab_label_packing ((GtkNotebook *)mv, (GtkWidget *)msv, FALSE, FALSE, 0);
@@ -369,7 +379,7 @@ mail_view_add_settings (MailView *mv, gpointer data)
}
static MailViewChild *
-mail_view_add_account (MailView *mv, gpointer data)
+mail_view_add_account (MailView *mv, gpointer data, gboolean block)
{
MailAccountView *msv = mail_account_view_new (NULL);
gint position = 0;
@@ -381,9 +391,11 @@ mail_view_add_account (MailView *mv, gpointer data)
g_signal_connect_after (msv, "view-close", G_CALLBACK(mv_close_mcv), mv);
gtk_notebook_set_tab_reorderable (GTK_NOTEBOOK (mv), (GtkWidget *)msv, FALSE);
gtk_notebook_set_tab_detachable (GTK_NOTEBOOK (mv), (GtkWidget *)msv, FALSE);
- gtk_notebook_set_current_page ((GtkNotebook *)mv, position);
+ if(!block)
+ gtk_notebook_set_current_page ((GtkNotebook *)mv, position);
gtk_notebook_set_tab_label_packing ((GtkNotebook *)mv, (GtkWidget *)msv, FALSE, FALSE, 0);
- mail_account_view_activate (msv, mv->tree, mv->folder_tree, mv->check_mail, mv->sort_by, FALSE);
+ if(!block)
+ mail_account_view_activate (msv, mv->tree, mv->folder_tree, mv->check_mail, mv->sort_by, FALSE);
return (MailViewChild *)msv;
}
@@ -391,25 +403,30 @@ mail_view_add_account (MailView *mv, gpointer data)
MailViewChild *
mail_view_add_page (MailView *mv, guint16 type, gpointer data)
{
- MailViewChild *child = NULL;
-
+ MailViewChild *child = NULL, *current_child;
+ gboolean block = FALSE;
+
+ current_child = mv->priv->current_view;
+ if (current_child && (current_child->flags & MAIL_VIEW_HOLD_FOCUS))
+ block = TRUE;
+
g_signal_handlers_block_by_func(mv, mv_switch, mv);
switch (type){
case MAIL_VIEW_FOLDER:
- child = mail_view_add_folder (mv, data);
+ child = mail_view_add_folder (mv, data, block);
break;
case MAIL_VIEW_COMPOSER:
- child = mail_view_add_composer (mv, data);
+ child = mail_view_add_composer (mv, data, block);
break;
case MAIL_VIEW_MESSAGE:
- child = mail_view_add_message (mv, data);
+ child = mail_view_add_message (mv, data, block);
break;
case MAIL_VIEW_SETTINGS:
- child = mail_view_add_settings (mv, data);
+ child = mail_view_add_settings (mv, data, block);
break;
case MAIL_VIEW_ACCOUNT:
- child = mail_view_add_account (mv, data);
+ child = mail_view_add_account (mv, data, block);
break;
}
gtk_widget_grab_focus((GtkWidget *)child);
@@ -420,6 +437,8 @@ mail_view_add_page (MailView *mv, guint16 type, gpointer data)
#endif
g_signal_handlers_unblock_by_func(mv, mv_switch, mv);
+ child->flags = 0;
+
return child;
}
diff --git a/src/mail-view.h b/src/mail-view.h
index 1b09180..734f0f8 100644
--- a/src/mail-view.h
+++ b/src/mail-view.h
@@ -58,10 +58,15 @@ typedef struct _MailViewClass {
} MailViewClass;
+typedef enum {
+ MAIL_VIEW_HOLD_FOCUS=1,
+} MailViewFlags;
+
typedef struct _MailViewChild {
GtkVBox parent;
int type;
char *uri;
+ MailViewFlags flags;
}MailViewChild;
MailView * mail_view_new (void);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]