e-mail-notebook-view.c 38.5 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12
/*
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) version 3.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
13
 * License along with the program; if not, see <http://www.gnu.org/licenses/>
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
 *
 *
 * Authors:
 *		Srinivasa Ragavan <sragavan@gnome.org>
 *
 * Copyright (C) 2010 Intel corporation. (www.intel.com)
 *
 */

#ifdef HAVE_CONFIG_H
#  include <config.h>
#endif

#include <glib.h>
#include <glib/gi18n.h>

30
#include "mail/e-mail-reader.h"
31
#include "mail/message-list.h"
32
#include "mail/em-folder-tree.h"
33
#include "e-mail-notebook-view.h"
34
#include "e-mail-folder-pane.h"
35
#include "e-mail-folder-utils.h"
36
#include "e-mail-message-pane.h"
37

38
#include <shell/e-shell-window-actions.h>
39

40
#if HAVE_CLUTTER
41 42 43
#include <clutter/clutter.h>
#include <mx/mx.h>
#include <clutter-gtk/clutter-gtk.h>
44
#include <math.h>
45

46 47 48
#include "e-mail-tab-picker.h"
#endif

49 50 51 52
struct _EMailNotebookViewPrivate {
	GtkNotebook *book;
	EMailView *current_view;
	GHashTable *views;
53
	gboolean inited;
54

55
#if HAVE_CLUTTER
56
	EMailTabPicker *tab_picker;
57
	GtkWidget *embed;
58 59
	ClutterActor *actor;
	ClutterActor *stage;
60
#endif
61 62
};

63 64
enum {
	PROP_0,
65
	PROP_FORWARD_STYLE,
66
	PROP_GROUP_BY_THREADS,
67
	PROP_REPLY_STYLE
68 69
};

70 71 72
#define E_SHELL_WINDOW_ACTION_GROUP_MAIL(window) \
	E_SHELL_WINDOW_ACTION_GROUP ((window), "mail")

Matthew Barnes's avatar
Matthew Barnes committed
73
/* Forward Declarations */
74
static void e_mail_notebook_view_reader_init (EMailReaderInterface *interface);
Matthew Barnes's avatar
Matthew Barnes committed
75 76 77 78 79

G_DEFINE_TYPE_WITH_CODE (
	EMailNotebookView, e_mail_notebook_view, E_TYPE_MAIL_VIEW,
	G_IMPLEMENT_INTERFACE (
		E_TYPE_MAIL_READER, e_mail_notebook_view_reader_init))
80

81 82 83
#if HAVE_CLUTTER
static void
mnv_set_current_tab (EMailNotebookView *view,
Matthew Barnes's avatar
Matthew Barnes committed
84
                     gint page)
85 86 87
{
	ClutterAnimation *animation;

88 89 90
	clutter_actor_set_opacity (view->priv->actor, 0);
	gtk_notebook_set_current_page (view->priv->book, page);

91 92 93
	animation = clutter_actor_animate (
		(ClutterActor *)view->priv->actor,
		CLUTTER_EASE_IN_SINE, 500, "opacity", 255, NULL);
94 95 96
}
#endif

97
static gint
98
emnv_get_page_num (EMailNotebookView *view,
Matthew Barnes's avatar
Matthew Barnes committed
99
                   GtkWidget *widget)
100 101
{
	EMailNotebookViewPrivate *priv = view->priv;
102 103
	gint i, n;

104 105 106 107 108 109 110 111
	n = gtk_notebook_get_n_pages (priv->book);

	for (i=0; i<n; i++) {
		GtkWidget *curr = gtk_notebook_get_nth_page (priv->book, i);
		if (curr == widget)
			return i;
	}

112
	return 0;
113 114
}

115
static void
Matthew Barnes's avatar
Matthew Barnes committed
116 117 118 119
mnv_page_changed (GtkNotebook *book,
                  GtkWidget *page,
                  guint page_num,
                  EMailView *view)
120
{
Matthew Barnes's avatar
Matthew Barnes committed
121 122 123 124 125
	EMailNotebookViewPrivate *priv;
	EShellView *shell_view;
	EShellSidebar *shell_sidebar;
	EMFolderTree *folder_tree;
	EMailView *mview;
126
	CamelFolder *folder;
Matthew Barnes's avatar
Matthew Barnes committed
127

128
	priv = E_MAIL_NOTEBOOK_VIEW (view)->priv;
Matthew Barnes's avatar
Matthew Barnes committed
129 130 131 132 133

	shell_view = e_mail_view_get_shell_view (view);
	shell_sidebar = e_shell_view_get_shell_sidebar (shell_view);

	page = gtk_notebook_get_nth_page (book, page_num);
134
	folder = e_mail_reader_get_folder (E_MAIL_READER (page));
Matthew Barnes's avatar
Matthew Barnes committed
135 136 137 138
	mview = E_MAIL_VIEW (page);

	g_object_get (shell_sidebar, "folder-tree", &folder_tree, NULL);

139 140 141 142 143 144 145
	if (folder != NULL && E_IS_MAIL_FOLDER_PANE (mview)) {
		gchar *folder_uri;

		folder_uri = e_mail_folder_uri_from_folder (folder);
		em_folder_tree_set_selected (folder_tree, folder_uri, FALSE);
		g_free (folder_uri);
	}
146

Matthew Barnes's avatar
Matthew Barnes committed
147
	if (mview != priv->current_view) {
148
		e_mail_view_set_previous_view (mview, priv->current_view);
Matthew Barnes's avatar
Matthew Barnes committed
149
		priv->current_view = mview;
150 151
	}

Matthew Barnes's avatar
Matthew Barnes committed
152
	/* For EMailReader related changes to EShellView */
153
	g_signal_emit_by_name (view, "changed");
154
	g_signal_emit_by_name (view, "folder-loaded");
155

156 157 158
	/* For EMailShellContent related changes */
	g_signal_emit_by_name (view, "view-changed");

Matthew Barnes's avatar
Matthew Barnes committed
159
	g_object_unref (folder_tree);
160 161
}

162
#if HAVE_CLUTTER
163
static void
164 165 166
fix_tab_picker_width (GtkWidget *widget,
                      GtkAllocation *allocation,
                      ClutterActor *actor)
167 168
{
	ClutterActor *stage = g_object_get_data ((GObject *)actor, "stage");
169

170 171 172 173 174 175 176
	clutter_actor_set_size (actor, allocation->width-1, -1);
	clutter_actor_set_size (stage, allocation->width-1, -1);
}

static void
fix_height_cb (ClutterActor *actor,
               GParamSpec *pspec,
177
               ClutterActor *table)
178 179 180
{
	GtkWidget *embed = (GtkWidget *)g_object_get_data ((GObject *)actor, "embed");
	ClutterActor *stage = g_object_get_data ((GObject *)actor, "stage");
181

Matthew Barnes's avatar
Matthew Barnes committed
182 183
	clutter_actor_set_height (stage, clutter_actor_get_height (actor));
	gtk_widget_set_size_request (embed, -1, (gint) clutter_actor_get_height (actor));
184 185 186
}

static void
187 188
chooser_clicked_cb (EMailTabPicker *picker,
                    EMailNotebookView *view)
189
{
190 191 192 193
	EMailNotebookViewPrivate *priv;

	gboolean preview_mode;

194
	priv = view->priv;
195
	preview_mode = !e_mail_tab_picker_get_preview_mode (priv->tab_picker);
196 197 198 199 200 201

	e_mail_tab_picker_set_preview_mode (priv->tab_picker , preview_mode);
}

static void
tab_picker_preview_mode_notify (EMailTabPicker *picker,
202
                                GParamSpec *pspec,
203 204 205 206 207
                                EMailNotebookView *view)
{
	GList *tabs, *t;
	gboolean preview_mode = e_mail_tab_picker_get_preview_mode (picker);

208 209 210
	clutter_actor_set_name (
		CLUTTER_ACTOR (picker),
		preview_mode ? "tab-picker-preview" : NULL);
211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226

	tabs = e_mail_tab_picker_get_tabs (picker);
	for (t = tabs; t; t = t->next) {
		EMailTab *tab;
		ClutterActor *preview;
		tab = E_MAIL_TAB (t->data);

		preview = e_mail_tab_get_preview_actor (tab);

		if (!preview)
			continue;

		if (preview_mode) {
			/* Show all pages so that the preview clones work correctly */
			clutter_actor_set_opacity (preview, 255);
			clutter_actor_show (preview);
227 228 229
		} else {
			clutter_actor_hide (preview);
		}
230 231 232 233 234
	}
	g_list_free (tabs);
}

static void
235
mnv_tab_anim_frame_cb (ClutterTimeline *timeline,
236 237 238
                               gint             frame_num,
                               EMailTab          *tab)
{
239
	if (!clutter_actor_get_parent (CLUTTER_ACTOR (tab))) {
240 241 242 243 244 245 246 247 248 249 250
		clutter_timeline_stop (timeline);
		g_object_unref (timeline);
		g_object_unref (tab);

		return;
	}

	e_mail_tab_set_width (tab, 200 * clutter_timeline_get_progress (timeline));
}

static void
251
mnv_tab_anim_complete_cb (ClutterTimeline *timeline,
252 253 254 255 256 257 258
                                  EMailTab          *tab)
{
	e_mail_tab_set_width (tab, 200);
	g_object_unref (tab);
	g_object_unref (timeline);
}

259 260 261 262 263 264 265 266 267 268 269
struct _tab_data {
	gboolean select;
	EMailNotebookView *view;
	EMailTab *tab;
};

static void
mnv_tab_closed_cb (ClutterTimeline *timeline,
		struct _tab_data *data)
{
	EMailView *page = g_object_get_data ((GObject *)data->tab, "page");
270
	EMailView *prev;
271 272
	gint num;

273 274 275 276 277 278
	if (E_IS_MAIL_FOLDER_PANE (page)) {
		CamelFolder *folder;
		gchar *folder_uri;

		folder = e_mail_reader_get_folder (E_MAIL_READER (page));
		folder_uri = e_mail_folder_uri_from_folder (folder);
279
		g_hash_table_remove (data->view->priv->views, folder_uri);
280 281 282
		g_free (folder_uri);
	}

283
	prev = e_mail_view_get_previous_view (page);
284 285 286 287 288 289
	if (prev) {
		num = emnv_get_page_num (data->view, (GtkWidget *)prev);
		mnv_set_current_tab (data->view, num);
		e_mail_tab_picker_set_current_tab (data->view->priv->tab_picker, num);
	}

290 291
	e_mail_tab_picker_remove_tab (data->view->priv->tab_picker, data->tab);
	gtk_notebook_remove_page (data->view->priv->book,
292 293 294 295 296 297 298 299
			gtk_notebook_page_num (data->view->priv->book, (GtkWidget *)page));

}

static void
mnv_tab_closed (EMailTab *tab, EMailNotebookView *view)
{
	EMailNotebookViewPrivate *priv = view->priv;
300
	gint page, cur;
301 302 303 304
	gboolean select = FALSE;
	ClutterTimeline *timeline;
	struct _tab_data *data = g_new0 (struct _tab_data, 1);

305 306 307
	if (e_mail_tab_picker_get_n_tabs (priv->tab_picker) == 1)
		return;

308 309 310 311 312 313 314 315 316 317 318 319
	page = e_mail_tab_picker_get_tab_no (priv->tab_picker,
					     tab);
	cur = e_mail_tab_picker_get_current_tab (priv->tab_picker);

	if (cur == page)
		select = TRUE;

	data->select  = select;
	data->tab = tab;
	data->view = view;

	clutter_actor_set_reactive (CLUTTER_ACTOR (tab), FALSE);
320
	timeline = clutter_timeline_new (150);
321
	clutter_timeline_set_direction (timeline, CLUTTER_TIMELINE_BACKWARD);
322 323 324 325 326 327 328
	g_signal_connect (
		timeline, "new-frame",
		G_CALLBACK (mnv_tab_anim_frame_cb), tab);
	g_signal_connect (
		timeline, "completed",
		G_CALLBACK (mnv_tab_closed_cb), data);
	clutter_timeline_start (timeline);
329 330
}

331 332 333 334 335
static void
tab_activated_cb (EMailTabPicker *picker,
		  EMailTab	 *tab,
		  EMailNotebookView *view)
{
336
	EMailView *page = g_object_get_data ((GObject *)tab, "page");
337
	gint num = emnv_get_page_num (view, (GtkWidget *)page);
338

339
	mnv_set_current_tab (view, num);
340
}
341
#endif
342

343
static void
344 345
tab_remove_gtk_cb (GtkWidget *button,
		   EMailNotebookView *view)
346
{
347
	EMailView *page = g_object_get_data ((GObject *)button, "page");
348
	EMailView *prev;
349 350
	gint num;

Matthew Barnes's avatar
Matthew Barnes committed
351
	if (gtk_notebook_get_n_pages (view->priv->book) == 1)
352
		return;
353

354 355 356 357 358 359
	if (E_IS_MAIL_FOLDER_PANE (page)) {
		CamelFolder *folder;
		gchar *folder_uri;

		folder = e_mail_reader_get_folder (E_MAIL_READER (page));
		folder_uri = e_mail_folder_uri_from_folder (folder);
360
		g_hash_table_remove (view->priv->views, folder_uri);
361 362
		g_free (folder_uri);
	}
363

364
	prev = e_mail_view_get_previous_view (page);
365 366 367 368
	if (prev) {
		num = emnv_get_page_num (view, (GtkWidget *)prev);
		gtk_notebook_set_current_page (view->priv->book, num);
	}
369
	gtk_notebook_remove_page (view->priv->book,
370
			gtk_notebook_page_num (view->priv->book, (GtkWidget *)page));
371

372 373 374
}

static GtkWidget *
375
create_tab_label (EMailNotebookView *view,
376
		  EMailView *page,
377
		  const gchar *str)
378 379 380 381 382 383 384 385 386
{
	GtkWidget *container, *widget;

	widget = gtk_hbox_new (FALSE, 0);
	gtk_widget_show (widget);
	container = widget;

	widget = gtk_label_new (str);
	gtk_widget_show (widget);
Matthew Barnes's avatar
Matthew Barnes committed
387
	gtk_box_pack_start (GTK_BOX (container), widget, TRUE, FALSE, 0);
388 389 390

	widget = gtk_button_new ();
	gtk_button_set_relief (GTK_BUTTON (widget), GTK_RELIEF_NONE);
391 392 393
	gtk_button_set_image (
		GTK_BUTTON (widget), gtk_image_new_from_stock (
		"gtk-close", GTK_ICON_SIZE_MENU));
394
	gtk_widget_show_all (widget);
Matthew Barnes's avatar
Matthew Barnes committed
395
	gtk_box_pack_end (GTK_BOX (container), widget, FALSE, FALSE, 0);
396
	g_object_set_data ((GObject *)widget, "page", page);
397
	g_object_set_data ((GObject *)page, "close-button", widget);
398

399 400 401
	g_signal_connect (
		widget, "clicked",
		G_CALLBACK (tab_remove_gtk_cb), view);
402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417

	return container;
}

#if HAVE_CLUTTER

static ClutterActor *
create_gtk_actor (GtkWidget *vbox)
{
  GtkWidget       *bin;
  ClutterActor    *gtk_actor;

  gtk_actor = gtk_clutter_actor_new ();
  bin = gtk_clutter_actor_get_widget (GTK_CLUTTER_ACTOR (gtk_actor));

  gtk_container_add (GTK_CONTAINER (bin), vbox);
418

419
  gtk_widget_show (bin);
Matthew Barnes's avatar
Matthew Barnes committed
420
  gtk_widget_show (vbox);
421 422 423 424
  return gtk_actor;
}

static void
425 426 427
fix_clutter_embed_width (GtkWidget *widget,
                         GtkAllocation *allocation,
                         ClutterActor *actor)
428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448
{
	GtkWidget *embed = (GtkWidget *)g_object_get_data ((GObject *)actor, "embed");
	GtkAllocation galoc;

	gtk_widget_get_allocation (embed, &galoc);
	clutter_actor_set_size (actor, allocation->width-1, galoc.height);
}

static GtkWidget *
create_under_clutter (GtkWidget *widget, GtkWidget *paned)
{
	GtkWidget *embed;
	ClutterActor *stage, *actor;

	embed = gtk_clutter_embed_new ();
	gtk_widget_show (embed);

	actor = create_gtk_actor (widget);
	clutter_actor_show (actor);
	stage = gtk_clutter_embed_get_stage ((GtkClutterEmbed *)embed);
	clutter_container_add_actor ((ClutterContainer *)stage, actor);
449

450 451 452 453 454 455
	g_object_set_data ((GObject *)actor, "embed", embed);
	g_object_set_data ((GObject *)actor, "stage", stage);
	g_object_set_data ((GObject *)actor, "widget", widget);
	g_object_set_data ((GObject *)widget, "actor", actor);
	g_object_set_data ((GObject *)embed, "actor", actor);

456 457 458
	g_signal_connect (
		paned, "size-allocate",
		G_CALLBACK (fix_clutter_embed_width), actor);
Matthew Barnes's avatar
Matthew Barnes committed
459
	clutter_actor_show (stage);
460

461 462 463 464 465
	return embed;
}

#endif

466 467 468 469
static void
mail_notebook_view_constructed (GObject *object)
{
	EMailNotebookViewPrivate *priv;
Matthew Barnes's avatar
Matthew Barnes committed
470 471 472
	EShellView *shell_view;
	GtkWidget *container;
	GtkWidget *widget;
473 474 475
#if HAVE_CLUTTER
	EMailTab *tab;
	ClutterActor *stage, *clone;
476
	ClutterTimeline *timeline;
477
#endif
478 479 480

	priv = E_MAIL_NOTEBOOK_VIEW (object)->priv;

Matthew Barnes's avatar
Matthew Barnes committed
481
	container = GTK_WIDGET (object);
482

483
#if HAVE_CLUTTER
484 485
	widget = gtk_clutter_embed_new ();
	gtk_widget_show (widget);
Matthew Barnes's avatar
Matthew Barnes committed
486
	gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0);
487 488

	stage = gtk_clutter_embed_get_stage ((GtkClutterEmbed *)widget);
Matthew Barnes's avatar
Matthew Barnes committed
489
	clutter_actor_show (stage);
490 491
	clutter_actor_set_reactive (stage, TRUE);

492 493
	priv->tab_picker = (EMailTabPicker *)e_mail_tab_picker_new ();
	clutter_actor_show ((ClutterActor *)priv->tab_picker);
494 495 496 497 498 499 500 501 502 503 504
	g_signal_connect (
		priv->tab_picker, "tab-activated",
		G_CALLBACK (tab_activated_cb), object);
	g_signal_connect (
		priv->tab_picker, "chooser-clicked",
		G_CALLBACK (chooser_clicked_cb), object);
	g_signal_connect (
		priv->tab_picker, "notify::preview-mode",
		G_CALLBACK (tab_picker_preview_mode_notify), object);
	g_signal_connect (
		priv->tab_picker, "notify::height",
Matthew Barnes's avatar
Matthew Barnes committed
505
		G_CALLBACK (fix_height_cb), widget);
506

507 508 509
	clutter_container_add_actor (
		(ClutterContainer *) stage,
		(ClutterActor *) priv->tab_picker);
510

511 512
	e_mail_tab_picker_enable_drop (priv->tab_picker, TRUE);

513 514 515
	g_object_set_data ((GObject *)priv->tab_picker, "embed", widget);
	g_object_set_data ((GObject *)priv->tab_picker, "stage", stage);

516 517
	g_signal_connect (
		object, "size-allocate",
Matthew Barnes's avatar
Matthew Barnes committed
518
		G_CALLBACK (fix_tab_picker_width), priv->tab_picker);
519

520 521 522 523 524 525
	clutter_actor_set_height (
		stage, clutter_actor_get_height (
		(ClutterActor *) priv->tab_picker));
	gtk_widget_set_size_request (
		widget, -1, (gint) clutter_actor_get_height (
		(ClutterActor *) priv->tab_picker));
526

527
	tab = (EMailTab *) e_mail_tab_new_full ("", NULL, 1);
528
	clone = e_mail_tab_new_full ("", NULL, 200);
529

530
	e_mail_tab_set_can_close ((EMailTab *)clone, FALSE);
531 532 533
	clutter_actor_set_reactive (clone, FALSE);
	clutter_actor_show (clone);

534
	e_mail_tab_set_preview_actor ((EMailTab *)tab, clone);
535 536 537
	e_mail_tab_set_can_close (tab, TRUE);

	e_mail_tab_picker_add_tab (priv->tab_picker, tab, -1);
Matthew Barnes's avatar
Matthew Barnes committed
538
	clutter_actor_show ((ClutterActor *)tab);
539
	e_mail_tab_picker_set_current_tab (priv->tab_picker, 0);
540
	e_mail_tab_enable_drag (tab, TRUE);
541 542

	g_object_ref (tab);
543 544 545 546 547 548 549
	timeline = clutter_timeline_new (150);
	g_signal_connect (
		timeline, "new-frame",
		G_CALLBACK (mnv_tab_anim_frame_cb), tab);
	g_signal_connect (
		timeline, "completed",
		G_CALLBACK (mnv_tab_anim_complete_cb), tab);
550
	clutter_timeline_start (timeline);
551
#endif
552 553 554 555

	widget = gtk_notebook_new ();
	priv->book = (GtkNotebook *)widget;
	gtk_widget_show (widget);
556 557 558 559 560
#if HAVE_CLUTTER
	priv->embed = create_under_clutter (widget, container);
	gtk_box_pack_start (GTK_BOX (container), priv->embed, TRUE, TRUE, 0);
	priv->actor = g_object_get_data((GObject *)priv->embed, "actor");
	priv->stage = g_object_get_data((GObject *)priv->actor, "stage");
561
#else
Matthew Barnes's avatar
Matthew Barnes committed
562
	gtk_box_pack_start (GTK_BOX (container), widget, TRUE, TRUE, 0);
563
#endif
564

565
#if HAVE_CLUTTER
566
	gtk_notebook_set_show_tabs ((GtkNotebook *)widget, FALSE);
567
#else
568 569 570
	gtk_notebook_set_scrollable ((GtkNotebook *)widget, TRUE);
#endif

571
	gtk_notebook_set_show_border ((GtkNotebook *)widget, FALSE);
572

Matthew Barnes's avatar
Matthew Barnes committed
573 574
	shell_view = e_mail_view_get_shell_view (E_MAIL_VIEW (object));
	priv->current_view = e_mail_folder_pane_new (shell_view);
575
	e_mail_view_set_preview_visible (priv->current_view, FALSE);
Matthew Barnes's avatar
Matthew Barnes committed
576
	gtk_widget_show (GTK_WIDGET (priv->current_view));
577

Matthew Barnes's avatar
Matthew Barnes committed
578 579 580 581
	gtk_notebook_append_page (
		priv->book, GTK_WIDGET (priv->current_view),
		create_tab_label (E_MAIL_NOTEBOOK_VIEW (object),
		priv->current_view, _("Please select a folder")));
582

Matthew Barnes's avatar
Matthew Barnes committed
583 584 585
	g_signal_connect (
		priv->book, "switch-page",
		G_CALLBACK (mnv_page_changed), object);
586

587 588
	/* Chain up to parent's constructed() method. */
	G_OBJECT_CLASS (e_mail_notebook_view_parent_class)->constructed (object);
589 590
}

591 592 593 594 595 596
static void
mail_notebook_view_set_property (GObject *object,
                                 guint property_id,
                                 const GValue *value,
                                 GParamSpec *pspec)
{
597 598
	EMailNotebookViewPrivate *priv;

599
	priv = E_MAIL_NOTEBOOK_VIEW (object)->priv;
600

601
	switch (property_id) {
602 603 604 605 606 607
		case PROP_FORWARD_STYLE:
			e_mail_reader_set_forward_style (
				E_MAIL_READER (priv->current_view),
				g_value_get_enum (value));
			return;

608 609
		case PROP_GROUP_BY_THREADS:
			e_mail_reader_set_group_by_threads (
610
				E_MAIL_READER (priv->current_view),
611 612
				g_value_get_boolean (value));
			return;
613 614 615 616 617 618

		case PROP_REPLY_STYLE:
			e_mail_reader_set_reply_style (
				E_MAIL_READER (priv->current_view),
				g_value_get_enum (value));
			return;
619 620 621 622 623 624 625 626 627 628 629
	}

	G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
}

static void
mail_notebook_view_get_property (GObject *object,
                                 guint property_id,
                                 GValue *value,
                                 GParamSpec *pspec)
{
630 631
	EMailNotebookViewPrivate *priv;

632
	priv = E_MAIL_NOTEBOOK_VIEW (object)->priv;
633

634
	switch (property_id) {
635 636 637 638 639 640 641
		case PROP_FORWARD_STYLE:
			g_value_set_enum (
				value,
				e_mail_reader_get_forward_style (
				E_MAIL_READER (priv->current_view)));
			return;

642 643 644 645
		case PROP_GROUP_BY_THREADS:
			g_value_set_boolean (
				value,
				e_mail_reader_get_group_by_threads (
646
				E_MAIL_READER (priv->current_view)));
647 648
			return;

649 650 651 652 653 654
		case PROP_REPLY_STYLE:
			g_value_set_enum (
				value,
				e_mail_reader_get_reply_style (
				E_MAIL_READER (priv->current_view)));
			return;
655 656 657 658 659
	}

	G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
}

660
static void
661 662
mail_notebook_view_set_search_strings (EMailView *view,
                                       GSList *search_strings)
663
{
664 665
	EMailNotebookViewPrivate *priv;

666
	priv = E_MAIL_NOTEBOOK_VIEW (view)->priv;
667 668

	e_mail_view_set_search_strings (priv->current_view, search_strings);
669
}
670

671 672 673
static GalViewInstance *
mail_notebook_view_get_view_instance (EMailView *view)
{
674 675
	EMailNotebookViewPrivate *priv;

676
	priv = E_MAIL_NOTEBOOK_VIEW (view)->priv;
677 678

	if (priv->current_view == NULL)
679 680
		return NULL;

681
	return e_mail_view_get_view_instance (priv->current_view);
682 683 684 685 686
}

static void
mail_notebook_view_update_view_instance (EMailView *view)
{
687 688
	EMailNotebookViewPrivate *priv;

689
	priv = E_MAIL_NOTEBOOK_VIEW (view)->priv;
690 691 692 693 694

	if (priv->current_view == NULL)
		return;

	e_mail_view_update_view_instance (priv->current_view);
695 696 697 698 699 700 701 702
}

static void
mail_notebook_view_set_orientation (EMailView *view,
                                    GtkOrientation orientation)
{
	EMailNotebookViewPrivate *priv;

703
	priv = E_MAIL_NOTEBOOK_VIEW (view)->priv;
704

705
	if (priv->current_view == NULL)
706 707 708 709 710 711 712 713 714 715
		return;

	e_mail_view_set_orientation (priv->current_view, orientation);
}

static GtkOrientation
mail_notebook_view_get_orientation (EMailView *view)
{
	EMailNotebookViewPrivate *priv;

716
	priv = E_MAIL_NOTEBOOK_VIEW (view)->priv;
717

718
	if (priv->current_view == NULL)
719 720 721 722 723 724 725 726 727 728
		return GTK_ORIENTATION_VERTICAL;

	return e_mail_view_get_orientation (priv->current_view);
}

static gboolean
mail_notebook_view_get_show_deleted (EMailView *view)
{
	EMailNotebookViewPrivate *priv;

729
	priv = E_MAIL_NOTEBOOK_VIEW (view)->priv;
730

731
	if (priv->current_view == NULL)
732 733 734 735 736 737
		return FALSE;

	return e_mail_view_get_show_deleted (priv->current_view);
}

static void
Matthew Barnes's avatar
Matthew Barnes committed
738 739
mail_notebook_view_set_show_deleted (EMailView *view,
                                     gboolean show_deleted)
740 741 742
{
	EMailNotebookViewPrivate *priv;

743
	priv = E_MAIL_NOTEBOOK_VIEW (view)->priv;
744

745
	if (priv->current_view == NULL)
746 747
		return;

Matthew Barnes's avatar
Matthew Barnes committed
748
	e_mail_view_set_show_deleted (priv->current_view, show_deleted);
749 750 751 752 753 754 755
}

static gboolean
mail_notebook_view_get_preview_visible (EMailView *view)
{
	EMailNotebookViewPrivate *priv;

756
	priv = E_MAIL_NOTEBOOK_VIEW (view)->priv;
757

758
	if (priv->current_view == NULL)
759 760 761 762 763 764
		return FALSE;

	return e_mail_view_get_preview_visible (priv->current_view);
}

static void
Matthew Barnes's avatar
Matthew Barnes committed
765 766
mail_notebook_view_set_preview_visible (EMailView *view,
                                        gboolean preview_visible)
767
{
Matthew Barnes's avatar
Matthew Barnes committed
768
	EMailNotebookViewPrivate *priv;
769

770
	priv = E_MAIL_NOTEBOOK_VIEW (view)->priv;
771

772
	if (priv->current_view == NULL)
Matthew Barnes's avatar
Matthew Barnes committed
773
		return;
774

Matthew Barnes's avatar
Matthew Barnes committed
775
	e_mail_view_set_preview_visible (priv->current_view, preview_visible);
776 777 778 779 780
}

static GtkActionGroup *
mail_notebook_view_get_action_group (EMailReader *reader)
{
Matthew Barnes's avatar
Matthew Barnes committed
781
	EMailView *view;
782 783 784
	EShellWindow *shell_window;
	EShellView *shell_view;

Matthew Barnes's avatar
Matthew Barnes committed
785 786
	view = E_MAIL_VIEW (reader);
	shell_view = e_mail_view_get_shell_view (view);
787 788
	shell_window = e_shell_view_get_shell_window (shell_view);

789
	return E_SHELL_WINDOW_ACTION_GROUP_MAIL (shell_window);
790 791
}

792 793 794 795 796 797 798 799 800 801 802 803 804 805
static EAlertSink *
mail_notebook_view_get_alert_sink (EMailReader *reader)
{
	EMailView *view;
	EShellView *shell_view;
	EShellContent *shell_content;

	view = E_MAIL_VIEW (reader);
	shell_view = e_mail_view_get_shell_view (view);
	shell_content = e_shell_view_get_shell_content (shell_view);

	return E_ALERT_SINK (shell_content);
}

806 807 808 809 810 811 812 813 814 815 816 817 818 819
static EMailBackend *
mail_notebook_view_get_backend (EMailReader *reader)
{
	EMailView *view;
	EShellView *shell_view;
	EShellBackend *shell_backend;

	view = E_MAIL_VIEW (reader);
	shell_view = e_mail_view_get_shell_view (view);
	shell_backend = e_shell_view_get_shell_backend (shell_view);

	return E_MAIL_BACKEND (shell_backend);
}

820 821 822
static EMFormatHTML *
mail_notebook_view_get_formatter (EMailReader *reader)
{
823
	EMailNotebookViewPrivate *priv;
824

825
	priv = E_MAIL_NOTEBOOK_VIEW (reader)->priv;
826 827

	if (priv->current_view == NULL)
828 829
		return NULL;

Matthew Barnes's avatar
Matthew Barnes committed
830
	return e_mail_reader_get_formatter (E_MAIL_READER (priv->current_view));
831 832 833 834 835
}

static gboolean
mail_notebook_view_get_hide_deleted (EMailReader *reader)
{
836 837
	EMailNotebookViewPrivate *priv;

838
	priv = E_MAIL_NOTEBOOK_VIEW (reader)->priv;
839

840
	if (priv->current_view == NULL)
841 842
		return FALSE;

843 844 845
	reader = E_MAIL_READER (priv->current_view);

	return e_mail_reader_get_hide_deleted (reader);
846 847 848 849 850
}

static GtkWidget *
mail_notebook_view_get_message_list (EMailReader *reader)
{
851
	EMailNotebookViewPrivate *priv;
852

853
	priv = E_MAIL_NOTEBOOK_VIEW (reader)->priv;
854 855

	if (priv->current_view == NULL)
856 857
		return NULL;

858 859 860
	reader = E_MAIL_READER (priv->current_view);

	return e_mail_reader_get_message_list (reader);
861 862 863 864 865
}

static GtkMenu *
mail_notebook_view_get_popup_menu (EMailReader *reader)
{
866
	EMailNotebookViewPrivate *priv;
867

868
	priv = E_MAIL_NOTEBOOK_VIEW (reader)->priv;
869 870

	if (priv->current_view == NULL)
871 872
		return NULL;

873 874 875
	reader = E_MAIL_READER (priv->current_view);

	return e_mail_reader_get_popup_menu (reader);
876 877 878 879 880
}

static GtkWindow *
mail_notebook_view_get_window (EMailReader *reader)
{
Matthew Barnes's avatar
Matthew Barnes committed
881
	EMailView *view;
882 883 884
	EShellWindow *shell_window;
	EShellView *shell_view;

Matthew Barnes's avatar
Matthew Barnes committed
885 886
	view = E_MAIL_VIEW (reader);
	shell_view = e_mail_view_get_shell_view (view);
887 888 889 890 891
	shell_window = e_shell_view_get_shell_window (shell_view);

	return GTK_WINDOW (shell_window);
}

892 893 894 895 896 897 898
static void
reconnect_changed_event (EMailReader *child, EMailReader *parent)
{
	g_signal_emit_by_name (parent, "changed");
}

static void
Matthew Barnes's avatar
Matthew Barnes committed
899 900
reconnect_folder_loaded_event (EMailReader *child,
                               EMailReader *parent)
901 902 903 904
{
	g_signal_emit_by_name (parent, "folder-loaded");
}

905
static void
Matthew Barnes's avatar
Matthew Barnes committed
906 907 908
mail_netbook_view_open_mail (EMailView *view,
                             const gchar *uid,
                             EMailNotebookView *nview)
909
{
Matthew Barnes's avatar
Matthew Barnes committed
910 911
	EMailNotebookViewPrivate *priv;
	EShellView *shell_view;
912
	CamelFolder *folder;
Matthew Barnes's avatar
Matthew Barnes committed
913
	EMailView *pane;
914
	gint page;
915
	CamelMessageInfo *info;
916
	gint pos;
917

918 919 920 921
#if HAVE_CLUTTER
	EMailTab *tab;
	ClutterActor *clone;
	ClutterTimeline *timeline;
922
	GtkWidget *mlist;
Matthew Barnes's avatar
Matthew Barnes committed
923
#endif
924

925
	priv = nview->priv;
Matthew Barnes's avatar
Matthew Barnes committed
926 927 928 929 930

#if HAVE_CLUTTER
	e_mail_tab_set_active (
		e_mail_tab_picker_get_tab (priv->tab_picker,
		e_mail_tab_picker_get_current_tab (priv->tab_picker)), FALSE);
931 932
#endif

Matthew Barnes's avatar
Matthew Barnes committed
933 934 935
	shell_view = e_mail_view_get_shell_view (E_MAIL_VIEW (nview));
	pos = emnv_get_page_num (nview, GTK_WIDGET (priv->current_view));
	pane = e_mail_message_pane_new (shell_view);
936
	e_mail_view_set_previous_view (pane, priv->current_view);
Matthew Barnes's avatar
Matthew Barnes committed
937
	E_MAIL_MESSAGE_PANE (pane)->parent_folder_view = priv->current_view;
Matthew Barnes's avatar
Matthew Barnes committed
938 939 940
	priv->current_view = pane;

	gtk_widget_show (GTK_WIDGET (pane));
941

Matthew Barnes's avatar
Matthew Barnes committed
942
	folder = e_mail_reader_get_folder (E_MAIL_READER (view));
943

944 945
	info = camel_folder_get_message_info (folder, uid);

Matthew Barnes's avatar
Matthew Barnes committed
946 947 948 949
	page = gtk_notebook_insert_page (
		priv->book, GTK_WIDGET (pane),
		create_tab_label (nview, priv->current_view,
		camel_message_info_subject (info)), pos + 1);
950

951
#if HAVE_CLUTTER
Matthew Barnes's avatar
Matthew Barnes committed
952
	mlist = e_mail_reader_get_message_list (E_MAIL_READER (pane));
953
	mnv_set_current_tab (nview, page);
954 955 956 957
	g_object_set_data ((GObject *)priv->current_view, "stage", priv->stage);
	g_object_set_data ((GObject *)mlist, "stage", priv->stage);
	g_object_set_data ((GObject *)mlist, "preview-actor", priv->actor);
#else
958 959
	gtk_notebook_set_current_page (priv->book, page);
#endif
960

961
#if HAVE_CLUTTER
Matthew Barnes's avatar
Matthew Barnes committed
962
	tab = (EMailTab *)e_mail_tab_new_full (camel_message_info_subject (info), NULL, 1);
963
	g_object_set_data ((GObject *)tab, "page", pane);
964
	g_object_set_data ((GObject *)pane, "tab", tab);
965

Matthew Barnes's avatar
Matthew Barnes committed
966
	clutter_actor_show ((ClutterActor *)tab);
967

Matthew Barnes's avatar
Matthew Barnes committed
968
	clone = e_mail_tab_new_full (camel_message_info_subject (info), NULL, 200);
969
	clutter_actor_set_reactive (clone, FALSE);
970 971 972 973
	clutter_actor_show (clone);

	e_mail_tab_set_preview_actor (tab, clone);
	e_mail_tab_set_can_close (tab, TRUE);
974
	e_mail_tab_picker_add_tab (priv->tab_picker, tab, pos+1);
975
	e_mail_tab_enable_drag (tab, TRUE);
976

977 978 979
	page = e_mail_tab_picker_get_tab_no (priv->tab_picker, tab);
	e_mail_tab_picker_set_current_tab (priv->tab_picker, page);

980
	g_signal_connect (tab , "closed",
981 982
			  G_CALLBACK (mnv_tab_closed), nview);

983 984
	g_object_ref (tab);
	timeline = clutter_timeline_new (150);
985 986 987 988 989 990
	g_signal_connect (
		timeline, "new-frame",
		G_CALLBACK (mnv_tab_anim_frame_cb), tab);
	g_signal_connect (
		timeline, "completed",
		G_CALLBACK (mnv_tab_anim_complete_cb), tab);
991
	clutter_timeline_start (timeline);
992 993
#endif

994 995 996 997 998 999
	g_signal_connect (
		E_MAIL_READER(pane), "changed",
		G_CALLBACK (reconnect_changed_event), nview);
	g_signal_connect (
		E_MAIL_READER (pane), "folder-loaded",
		G_CALLBACK (reconnect_folder_loaded_event), nview);
1000
	e_mail_reader_set_folder (
1001
		E_MAIL_READER (pane), folder);
1002 1003
	e_mail_reader_set_group_by_threads (
		E_MAIL_READER (pane),
Matthew Barnes's avatar
Matthew Barnes committed
1004
		e_mail_reader_get_group_by_threads (E_MAIL_READER (view)));
1005

Matthew Barnes's avatar
Matthew Barnes committed
1006
	e_mail_reader_enable_show_folder (E_MAIL_READER (pane));
1007
	e_mail_reader_set_message (E_MAIL_READER (pane), uid);
1008
	camel_message_info_free (info);
1009 1010
}

1011 1012 1013 1014
#if HAVE_CLUTTER
static ClutterActor *
build_histogram (GtkWidget *widget, CamelFolder *folder)
{
1015 1016 1017
	gint week_time = 60 * 60 * 24 * 7;
	gint weeks[54];
	gint i;
1018
	GPtrArray *uids;
1019
	gint max = 1;
1020 1021
	ClutterActor *texture;
	cairo_t *cr;
1022 1023
	gfloat ratio;
	gint x = 0;
Matthew Barnes's avatar
Matthew Barnes committed
1024
	time_t now = time (NULL);
1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039
	GtkStyle *style;
	GdkColor *color;

	for (i=0; i<54; i++)
		weeks[i] = 0;

	style = gtk_widget_get_style (GTK_WIDGET (widget));
	color = &style->mid[GTK_STATE_NORMAL];

	uids = camel_folder_get_uids (folder);
	camel_folder_summary_prepare_fetch_all (folder->summary, NULL);
	for (i = 0; i < uids->len; i++) {
		CamelMessageInfo *info = camel_folder_get_message_info (folder, uids->pdata[i]);
		if (info) {
			time_t dreceived = now - camel_message_info_date_received (info);
1040
			gint week;
1041 1042 1043 1044 1045 1046 1047 1048

			week = (dreceived / week_time) - 1;
			if (week > 52)
				weeks[53]++;
			else
				weeks[week]++;

			camel_message_info_free (info);
1049
		}
1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060
	}

	for (i=0; i< 53; i++) {
		if (weeks[i] > max)
			max = weeks[i];
	}

	ratio = 50.0/max;

	camel_folder_free_uids (folder, uids);

1061
	texture = clutter_cairo_texture_new (200, 50);
1062
	clutter_actor_set_size (texture, 200, 50);
1063
	cr = clutter_cairo_texture_create (CLUTTER_CAIRO_TEXTURE (texture));
1064 1065 1066 1067 1068

	clutter_actor_show_all (texture);

	cairo_save (cr);
	cairo_new_path (cr);
1069
	cairo_move_to (cr, x, 50 - (weeks[52] * ratio));
1070 1071 1072

	cairo_set_source_rgba (cr, 0.3, 0.2, 0.4, 1.0);

1073
	for (i=51; i>=0; i--) {
1074
		x+=3;
1075 1076 1077 1078 1079 1080 1081
		cairo_line_to (cr, x, 50 - (weeks[i]*ratio));

	}

	cairo_stroke (cr);
	cairo_restore (cr);

1082 1083 1084 1085 1086 1087 1088 1089
	cairo_save (cr);

	cairo_set_source_rgba (cr, 0.8, 0.5, 0.3, 1.0);
	cairo_arc (cr, x,  50 - (weeks[0] * ratio), 3, 0, 2*M_PI);

	cairo_fill (cr);
	cairo_restore (cr);

Matthew Barnes's avatar
Matthew Barnes committed
1090
	cairo_destroy (cr);
1091 1092 1093 1094 1095

	return texture;
}
#endif

1096 1097
static void
mail_notebook_view_set_folder (EMailReader *reader,
1098
                               CamelFolder *folder)
1099
{
1100
	EMailNotebookViewPrivate *priv;
1101
	GtkWidget *new_view;
1102
	gchar *folder_uri;
1103
#if HAVE_CLUTTER
1104 1105
	EMailTab *tab;
	ClutterActor *clone;
1106
	ClutterTimeline *timeline;
1107
#endif
1108

1109
	if (folder == NULL)
1110 1111
		return;

1112
	priv = E_MAIL_NOTEBOOK_VIEW (reader)->priv;
1113

1114
	folder_uri = e_mail_folder_uri_from_folder (folder);
1115
	new_view = g_hash_table_lookup (priv->views, folder_uri);
1116 1117
	g_free (folder_uri);

1118
	if (new_view) {
1119 1120
		gint curr = emnv_get_page_num (E_MAIL_NOTEBOOK_VIEW (reader), new_view);
#if HAVE_CLUTTER
1121
		EMailTab *tab;
1122 1123 1124

		if (curr == e_mail_tab_picker_get_current_tab (priv->tab_picker))
			return;
1125

1126
		e_mail_tab_set_active (e_mail_tab_picker_get_tab (priv->tab_picker,
1127 1128
						e_mail_tab_picker_get_current_tab (priv->tab_picker)),
					FALSE);
1129 1130
#endif

1131
		priv->current_view = (EMailView *)new_view;
1132
#if HAVE_CLUTTER
Matthew Barnes's avatar
Matthew Barnes committed
1133
		mnv_set_current_tab (E_MAIL_NOTEBOOK_VIEW (reader), curr);
1134
#else
Srinivasa Ragavan's avatar
Srinivasa Ragavan committed
1135
		gtk_notebook_set_current_page (priv->book, curr);
1136
#endif
1137

1138
#if HAVE_CLUTTER
1139
		tab = (EMailTab *)g_object_get_data ((GObject *)priv->current_view, "page");
1140 1141
		curr = e_mail_tab_picker_get_tab_no (priv->tab_picker, tab);
		e_mail_tab_picker_set_current_tab (priv->tab_picker, curr);
1142
#endif
1143 1144 1145
		return;
	}

1146 1147
	/* FIXME Redundant NULL check. */
	if (folder != NULL) {
1148
		gint page;
1149
#if HAVE_CLUTTER
1150
		GtkWidget *list;
1151
#endif
1152

1153
		if (priv->inited) {
1154
			EMailView *old_view = priv->current_view;
Matthew Barnes's avatar
Matthew Barnes committed
1155
			EShellView *shell_view;
1156

Matthew Barnes's avatar
Matthew Barnes committed
1157 1158
			shell_view = e_mail_view_get_shell_view (E_MAIL_VIEW (reader));
			priv->current_view = e_mail_folder_pane_new (shell_view);
1159
			gtk_widget_show ((GtkWidget *)priv->current_view);
1160
			e_mail_view_set_previous_view (priv->current_view, old_view);
1161 1162 1163 1164 1165 1166 1167
			page = gtk_notebook_append_page (
				priv->book, (GtkWidget *)priv->current_view,
				create_tab_label (
					E_MAIL_NOTEBOOK_VIEW (reader),
					priv->current_view,
					camel_folder_get_full_name (folder)));
#if HAVE_CLUTTER
Matthew Barnes's avatar
Matthew Barnes committed
1168
			mnv_set_current_tab (E_MAIL_NOTEBOOK_VIEW (reader), page);
1169
#else
1170
			gtk_notebook_set_current_page (priv->book, page);
1171
#endif
1172

1173
#if HAVE_CLUTTER
1174 1175 1176 1177 1178 1179 1180
			e_mail_tab_set_active (
				e_mail_tab_picker_get_tab (
					priv->tab_picker,
					e_mail_tab_picker_get_current_tab (
						priv->tab_picker)),
				FALSE);

1181 1182
			tab = (EMailTab *) e_mail_tab_new_full (
				camel_folder_get_full_name (folder), NULL, 1);
1183
			g_object_set_data ((GObject *)tab, "page", priv->current_view);
1184
			g_object_set_data ((GObject *)priv->current_view, "page", tab);
1185 1186
			g_object_set_data ((GObject *)priv->current_view, "tab", tab);

Matthew Barnes's avatar
Matthew Barnes committed
1187
			clutter_actor_show ((ClutterActor *)tab);
1188

1189
			clone = build_histogram ((GtkWidget *)reader, folder);
1190 1191 1192 1193
			clutter_actor_set_reactive (clone, FALSE);
			clutter_actor_show (clone);

			e_mail_tab_set_preview_actor (tab, clone);
1194
			e_mail_tab_set_can_close (tab, TRUE);
1195 1196 1197
			e_mail_tab_set_preview_mode (
				tab, e_mail_tab_picker_get_preview_mode (
				priv->tab_picker));
1198

1199
			e_mail_tab_picker_add_tab (priv->tab_picker, tab, -1);
1200 1201 1202
			page = e_mail_tab_picker_get_tab_no (priv->tab_picker, tab);
			e_mail_tab_picker_set_current_tab (priv->tab_picker, page);

1203
			e_mail_tab_enable_drag (tab, TRUE);
1204
			g_object_ref (tab);
1205 1206 1207 1208 1209 1210 1211 1212 1213
			timeline = clutter_timeline_new (150);
			g_signal_connect (
				timeline, "new-frame",
				G_CALLBACK (mnv_tab_anim_frame_cb), tab);
			g_signal_connect (
				timeline, "completed",
				G_CALLBACK (mnv_tab_anim_complete_cb), tab);
			clutter_timeline_start (timeline);
#endif
1214
		} else {
1215
			priv->inited = TRUE;
1216
			gtk_notebook_set_tab_label (priv->book, (GtkWidget *)priv->current_view,
Matthew Barnes's avatar
Matthew Barnes committed
1217
						create_tab_label (E_MAIL_NOTEBOOK_VIEW (reader),
1218
								  priv->current_view,
1219 1220
								  camel_folder_get_full_name (folder)));

1221
#if HAVE_CLUTTER
Matthew Barnes's avatar
Matthew Barnes committed
1222
			tab = e_mail_tab_picker_get_tab (priv->tab_picker,
1223
						e_mail_tab_picker_get_current_tab (priv->tab_picker));
1224
			g_object_set_data ((GObject *)tab, "page", priv->current_view);
1225
			g_object_set_data ((GObject *)priv->current_view, "page", tab);
1226
			g_object_set_data ((GObject *)priv->current_view, "tab", tab);
1227

Matthew Barnes's avatar
Matthew Barnes committed
1228
			e_mail_tab_set_text (tab, camel_folder_get_full_name (folder));
1229 1230
			clone = build_histogram ((GtkWidget *)reader, folder);
			clutter_actor_set_reactive (clone, FALSE);
1231
			clutter_actor_show (clone);
1232
			e_mail_tab_set_preview_actor (tab, clone);
1233
#endif
1234
		}
1235 1236

#if HAVE_CLUTTER
1237
		list = e_mail_reader_get_message_list (E_MAIL_READER (priv->current_view));
1238
		g_signal_connect (tab , "closed",
1239
				   G_CALLBACK (mnv_tab_closed), reader);
1240 1241 1242 1243 1244
		g_object_set_data ((GObject *)priv->current_view, "stage", priv->stage);
		g_object_set_data ((GObject *)list, "stage", priv->stage);
		g_object_set_data ((GObject *)list, "actor", priv->actor);

#endif
1245
		e_mail_reader_set_folder (E_MAIL_READER (priv->current_view), folder);
1246 1247 1248

		folder_uri = e_mail_folder_uri_from_folder (folder);
		g_hash_table_insert (priv->views, folder_uri, priv->current_view);
Matthew Barnes's avatar
Matthew Barnes committed
1249 1250 1251 1252 1253 1254 1255 1256 1257
		g_signal_connect (
			priv->current_view, "changed",
			G_CALLBACK (reconnect_changed_event), reader);
		g_signal_connect (
			priv->current_view, "folder-loaded",
			G_CALLBACK (reconnect_folder_loaded_event), reader);
		g_signal_connect (
			priv->current_view, "open-mail",
			G_CALLBACK