[anjal] Revamp tabs
- From: Srinivasa Ragavan <sragavan src gnome org>
- To: svn-commits-list gnome org
- Subject: [anjal] Revamp tabs
- Date: Sat, 28 Mar 2009 02:08:13 -0400 (EDT)
commit 93e07607fbc1d9c14f31b6a12724ebbcea050bff
Author: Srinivasa Ragavan <sragavan novell com>
Date: Sat Mar 28 11:33:19 2009 +0530
Revamp tabs
---
src/mail-folder-view.c | 18 ++++++--------
src/mail-folder-view.h | 1 +
src/mail-shell.c | 2 +-
src/mail-view.c | 61 +++++++++++++++++++++++++++++++++++++++++------
src/mail-view.h | 2 +-
5 files changed, 64 insertions(+), 20 deletions(-)
diff --git a/src/mail-folder-view.c b/src/mail-folder-view.c
index 8e9e20e..0759e1f 100644
--- a/src/mail-folder-view.c
+++ b/src/mail-folder-view.c
@@ -49,7 +49,6 @@ struct _MailFolderViewPrivate {
GtkWidget *tab_str;
CamelFolder *folder;
- char *uri;
char *uid;
int sort_selected;
@@ -192,7 +191,7 @@ mail_folder_view_init (MailFolderView *shell)
img = gtk_image_new_from_pixbuf (pbuf);
g_object_set_data (img, "pbuf", pbuf);
g_signal_connect (img, "expose-event", mfv_btn_expose, shell);
-
+ shell->uri = g_strdup("folder://");
tool = gtk_button_new ();
gtk_button_set_relief(tool, GTK_RELIEF_NONE);
gtk_button_set_focus_on_click (tool, FALSE);
@@ -228,7 +227,6 @@ mail_folder_view_init (MailFolderView *shell)
g_object_unref (pbuf);
shell->priv->uid = NULL;
shell->priv->folder = NULL;
- shell->priv->uri = NULL;
shell->priv->sort_selected = 1;
shell->priv->sort_ascending = FALSE;
}
@@ -243,7 +241,7 @@ mail_folder_view_finalize (GObject *object)
}
g_object_unref (mfv->model);
- g_free (mfv->priv->uri);
+ g_free (mfv->uri);
g_free (mfv->priv);
G_OBJECT_CLASS (mail_folder_view_parent_class)->finalize (object);
}
@@ -328,8 +326,6 @@ mfv_got_folder(char *uri, CamelFolder *folder, void *data)
gtk_tree_view_set_model (GTK_TREE_VIEW (mfv->tree), NULL);
camel_object_unref (mfv->priv->folder);
mfv->priv->folder= NULL;
- g_free(mfv->priv->uri);
- mfv->priv->uri = NULL;
g_object_unref (mfv->model);
if (mfv->priv->light)
mfv->model = mail_sqlite_store_new ();
@@ -349,9 +345,12 @@ mail_folder_view_set_folder_uri (MailFolderView *mfv, const char *uri)
{
char *str=NULL;
- if (uri && mfv->priv->uri && !strcmp(uri, mfv->priv->uri))
+ if (uri && mfv->uri && !strcmp(uri, mfv->uri))
return;
-
+
+ if (mfv->uri)
+ g_free(mfv->uri);
+ mfv->uri = g_strdup(uri);
gtk_widget_show (mfv->priv->info_spinner);
gtk_widget_hide (mfv->mail);
gtk_widget_show (mfv->priv->info_bar);
@@ -387,7 +386,6 @@ mail_folder_view_set_folder (MailFolderView *mfv, CamelFolder *folder, const cha
double pos = 0;
GtkTreeIter iter;
gtk_tree_view_set_model (GTK_TREE_VIEW (mfv->tree), mfv->model);
- mfv->priv->uri = g_strdup(uri);
mfv->priv->folder = folder;
gtk_widget_hide (mfv->mail);
gtk_widget_hide (mfv->priv->info_spinner);
@@ -1248,7 +1246,7 @@ mail_folder_view_activate (MailFolderView *mfv, GtkWidget *tree, GtkWidget *fold
gtk_widget_set_sensitive (check_mail, act);
gtk_widget_set_sensitive (sort_by, act);
if (mfv->priv->folder) {
- em_folder_tree_set_selected (tree, mfv->priv->uri, FALSE);
+ em_folder_tree_set_selected (tree, mfv->uri, FALSE);
}
}
diff --git a/src/mail-folder-view.h b/src/mail-folder-view.h
index 987cdce..21909ea 100644
--- a/src/mail-folder-view.h
+++ b/src/mail-folder-view.h
@@ -39,6 +39,7 @@ typedef struct _MailFolderViewPrivate MailFolderViewPrivate;
typedef struct _MailFolderView {
GtkVBox parent;
int type;
+ char *uri;
/* Base class ends */
GtkTreeView *tree;
diff --git a/src/mail-shell.c b/src/mail-shell.c
index 9a2288a..608269d 100644
--- a/src/mail-shell.c
+++ b/src/mail-shell.c
@@ -349,7 +349,7 @@ mail_shell_construct (MailShell *shell)
gtk_paned_add2 (priv->side_pane, box);
gtk_box_pack_start ((GtkBox *)priv->box, priv->side_pane, TRUE, TRUE, 6);
- mail_view_add_page (shell->mail_component->mail_view, MAIL_VIEW_FOLDER);
+// mail_view_add_page (shell->mail_component->mail_view, MAIL_VIEW_FOLDER);
g_signal_connect (priv->new_mail, "clicked", G_CALLBACK (new_email_btn_clicked),
shell);
mail_view_set_slider (shell->mail_component->mail_view, priv->slider);
diff --git a/src/mail-view.c b/src/mail-view.c
index c99ef13..e7d4d7f 100644
--- a/src/mail-view.c
+++ b/src/mail-view.c
@@ -40,8 +40,10 @@ struct _MailViewPrivate {
GtkWidget *new;
};
-G_DEFINE_TYPE (MailView, mail_view, GTK_TYPE_NOTEBOOK)
+#undef MV_NEW_TAB
+G_DEFINE_TYPE (MailView, mail_view, GTK_TYPE_NOTEBOOK)
+
static void
mail_view_init (MailView *shell)
{
@@ -87,27 +89,33 @@ mv_switch (GtkNotebook *notebook,GtkNotebookPage *page, guint page_num, gpoi
{
MailView *shell = (MailView *)notebook;
MailViewPrivate *priv = shell->priv;
-
+
+#ifdef MV_NEW_TAB
if (page_num == g_list_length(priv->children) && shell->priv->new) {
mail_view_add_page (shell, MAIL_VIEW_FOLDER);
gtk_notebook_set_current_page (shell, g_list_length (shell->priv->children)-1);
} else {
+#endif
MailViewChild *child;
- if (page_num == 0 || !g_list_nth (priv->children, page_num))
+ GList *node = g_list_nth (priv->children, page_num);
+
+ if (!node)
priv->current_view = priv->children->data;
else
- priv->current_view = g_list_nth (priv->children, page_num)->data;
+ priv->current_view = node->data;
child = (MailViewChild *)priv->current_view;
-
+
if (child->type == MAIL_VIEW_COMPOSER)
mail_composer_view_activate (child, shell->folder_tree, shell->check_mail, shell->sort_by, TRUE);
- else if (child->type == MAIL_VIEW_FOLDER)
- mail_folder_view_activate (child, shell->tree, shell->folder_tree, shell->check_mail, shell->sort_by, TRUE);
else if (child->type == MAIL_VIEW_MESSAGE)
mail_conv_view_activate (child, shell->tree, shell->folder_tree, shell->check_mail, shell->sort_by, FALSE);
+ else //if (child->type == MAIL_VIEW_FOLDER) /* For some reason, Im not able to get right type */
+ mail_folder_view_activate (child, shell->tree, shell->folder_tree, shell->check_mail, shell->sort_by, TRUE);
+#ifdef MV_NEW_TAB
}
+#endif
}
static gboolean
@@ -160,7 +168,9 @@ mail_view_construct (MailView *shell)
gtk_notebook_set_show_tabs (shell, TRUE);
gtk_notebook_set_scrollable (shell, TRUE);
gtk_notebook_popup_enable (shell);
+#ifdef MV_NEW_TAB
mv_new_tab_button (shell);
+#endif
g_signal_connect_after (shell, "switch-page", G_CALLBACK(mv_switch), shell);
}
@@ -201,6 +211,7 @@ mv_close_mcv (MailFolderView *mfv, MailView *mv)
{
int n = list_data_pos (mv->priv->children, mfv);
int pos = gtk_notebook_get_current_page (mv);
+ MailViewChild *child;
if (g_list_length(mv->priv->children) == 1)
return;
@@ -210,6 +221,16 @@ mv_close_mcv (MailFolderView *mfv, MailView *mv)
if (pos == g_list_length(mv->priv->children) -1)
gtk_notebook_set_current_page (mv, pos -1);
mv->priv->children = g_list_remove (mv->priv->children, mfv);
+ pos = gtk_notebook_get_current_page (mv);
+ child = g_list_nth_data(mv->priv->children, pos);
+ if (child->type == MAIL_VIEW_COMPOSER)
+ mail_composer_view_activate (child, mv->folder_tree, mv->check_mail, mv->sort_by, TRUE);
+ else if (child->type == MAIL_VIEW_MESSAGE)
+ mail_conv_view_activate (child, mv->tree, mv->folder_tree, mv->check_mail, mv->sort_by, FALSE);
+ else //if (child->type == MAIL_VIEW_FOLDER) /* For some reason, the child type for mfv isn't getting right: FIXME later*/
+ mail_folder_view_activate (child, mv->tree, mv->folder_tree, mv->check_mail, mv->sort_by, TRUE);
+
+
}
static void
@@ -300,17 +321,41 @@ mail_view_add_page (MailView *mv, guint16 type)
child = mail_view_add_message (mv);
break;
}
+ gtk_widget_grab_focus(child);
+ child->type = type;
+#ifdef MV_NEW_TAB
gtk_notebook_reorder_child (mv, mv->priv->new, -1);
gtk_notebook_set_current_page (mv, g_list_length (mv->priv->children)-1);
+#endif
g_signal_handlers_unblock_by_func(mv, mv_switch, mv);
return child;
}
+static void
+mv_switch_folder_view (MailView *mv, const char *uri)
+{
+ int i=0;
+ GList *tmp = mv->priv->children;
+ while (tmp) {
+ MailViewChild *child = tmp->data;
+ if (child->type = MAIL_VIEW_FOLDER && !strcmp (uri, child->uri)) {
+ gtk_notebook_set_current_page (mv, i);
+ return;
+ }
+ i++;
+ tmp = tmp->next;
+ }
+
+ mail_view_add_page (mv, MAIL_VIEW_FOLDER);
+ mail_folder_view_set_folder_uri (mv->priv->current_view, uri);
+}
+
void
mail_view_set_folder_uri (MailView *mv, const char *uri)
{
- mail_folder_view_set_folder_uri (mv->priv->current_view, uri);
+ mv_switch_folder_view (mv, uri);
+ //mail_folder_view_set_folder_uri (mv->priv->current_view, uri);
}
void
diff --git a/src/mail-view.h b/src/mail-view.h
index 4420118..f431570 100644
--- a/src/mail-view.h
+++ b/src/mail-view.h
@@ -59,7 +59,7 @@ typedef struct _MailViewClass {
typedef struct _MailViewChild {
GtkVBox parent;
int type;
-
+ char *uri;
}MailViewChild;
MailView * mail_view_new (void);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]