evolution-3.6.4/modules/addressbook/e-book-shell-content.c

No issues found

  1 /*
  2  * e-book-shell-content.c
  3  *
  4  * This program is free software; you can redistribute it and/or
  5  * modify it under the terms of the GNU Lesser General Public
  6  * License as published by the Free Software Foundation; either
  7  * version 2 of the License, or (at your option) version 3.
  8  *
  9  * This program is distributed in the hope that it will be useful,
 10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 12  * Lesser General Public License for more details.
 13  *
 14  * You should have received a copy of the GNU Lesser General Public
 15  * License along with the program; if not, see <http://www.gnu.org/licenses/>
 16  *
 17  *
 18  * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
 19  *
 20  */
 21 
 22 #ifdef HAVE_CONFIG_H
 23 #include <config.h>
 24 #endif
 25 
 26 #include "e-book-shell-content.h"
 27 
 28 #include <glib/gi18n.h>
 29 
 30 #include "e-util/e-selection.h"
 31 #include "shell/e-shell-utils.h"
 32 #include "widgets/misc/e-paned.h"
 33 #include "widgets/misc/e-preview-pane.h"
 34 #include "e-book-shell-view.h"
 35 
 36 #define E_BOOK_SHELL_CONTENT_GET_PRIVATE(obj) \
 37 	(G_TYPE_INSTANCE_GET_PRIVATE \
 38 	((obj), E_TYPE_BOOK_SHELL_CONTENT, EBookShellContentPrivate))
 39 
 40 struct _EBookShellContentPrivate {
 41 	GtkWidget *paned;
 42 	GtkWidget *notebook;
 43 	GtkWidget *preview_pane;
 44 
 45 	GtkOrientation orientation;
 46 
 47 	gboolean preview_show_maps;
 48 	guint preview_visible	: 1;
 49 };
 50 
 51 enum {
 52 	PROP_0,
 53 	PROP_CURRENT_VIEW,
 54 	PROP_ORIENTATION,
 55 	PROP_PREVIEW_CONTACT,
 56 	PROP_PREVIEW_VISIBLE,
 57 	PROP_PREVIEW_SHOW_MAPS
 58 };
 59 
 60 G_DEFINE_DYNAMIC_TYPE_EXTENDED (
 61 	EBookShellContent,
 62 	e_book_shell_content,
 63 	E_TYPE_SHELL_CONTENT,
 64 	0,
 65 	G_IMPLEMENT_INTERFACE_DYNAMIC (
 66 		GTK_TYPE_ORIENTABLE, NULL))
 67 
 68 static void
 69 book_shell_content_send_message_cb (EBookShellContent *book_shell_content,
 70                                     EDestination *destination,
 71                                     EABContactDisplay *display)
 72 {
 73 	EShell *shell;
 74 	EShellContent *shell_content;
 75 	EShellWindow *shell_window;
 76 	EShellView *shell_view;
 77 	GSList node = { destination, NULL };
 78 
 79 	shell_content = E_SHELL_CONTENT (book_shell_content);
 80 	shell_view = e_shell_content_get_shell_view (shell_content);
 81 	shell_window = e_shell_view_get_shell_window (shell_view);
 82 	shell = e_shell_window_get_shell (shell_window);
 83 
 84 	eab_send_as_to (shell, &node);
 85 }
 86 
 87 static void
 88 book_shell_content_restore_state_cb (EShellWindow *shell_window,
 89                                      EShellView *shell_view,
 90                                      EShellContent *shell_content)
 91 {
 92 	EBookShellContentPrivate *priv;
 93 	GSettings *settings;
 94 
 95 	priv = E_BOOK_SHELL_CONTENT_GET_PRIVATE (shell_content);
 96 
 97 	/* Bind GObject properties to GSettings keys. */
 98 
 99 	settings = g_settings_new ("org.gnome.evolution.addressbook");
100 
101 	g_settings_bind (
102 		settings, "hpane-position",
103 		priv->paned, "hposition",
104 		G_SETTINGS_BIND_DEFAULT);
105 
106 	g_settings_bind (
107 		settings, "vpane-position",
108 		priv->paned, "vposition",
109 		G_SETTINGS_BIND_DEFAULT);
110 
111 	g_object_unref (settings);
112 }
113 
114 static GtkOrientation
115 book_shell_content_get_orientation (EBookShellContent *book_shell_content)
116 {
117 	return book_shell_content->priv->orientation;
118 }
119 
120 static void
121 book_shell_content_set_orientation (EBookShellContent *book_shell_content,
122                                     GtkOrientation orientation)
123 {
124 	if (book_shell_content->priv->orientation == orientation)
125 		return;
126 
127 	book_shell_content->priv->orientation = orientation;
128 
129 	g_object_notify (G_OBJECT (book_shell_content), "orientation");
130 }
131 
132 static void
133 book_shell_content_set_property (GObject *object,
134                                  guint property_id,
135                                  const GValue *value,
136                                  GParamSpec *pspec)
137 {
138 	switch (property_id) {
139 		case PROP_CURRENT_VIEW:
140 			e_book_shell_content_set_current_view (
141 				E_BOOK_SHELL_CONTENT (object),
142 				g_value_get_object (value));
143 			return;
144 
145 		case PROP_ORIENTATION:
146 			book_shell_content_set_orientation (
147 				E_BOOK_SHELL_CONTENT (object),
148 				g_value_get_enum (value));
149 			return;
150 
151 		case PROP_PREVIEW_CONTACT:
152 			e_book_shell_content_set_preview_contact (
153 				E_BOOK_SHELL_CONTENT (object),
154 				g_value_get_object (value));
155 			return;
156 
157 		case PROP_PREVIEW_VISIBLE:
158 			e_book_shell_content_set_preview_visible (
159 				E_BOOK_SHELL_CONTENT (object),
160 				g_value_get_boolean (value));
161 			return;
162 
163 		case PROP_PREVIEW_SHOW_MAPS:
164 			e_book_shell_content_set_preview_show_maps (
165 				E_BOOK_SHELL_CONTENT (object),
166 				g_value_get_boolean (value));
167 			return;
168 	}
169 
170 	G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
171 }
172 
173 static void
174 book_shell_content_get_property (GObject *object,
175                                  guint property_id,
176                                  GValue *value,
177                                  GParamSpec *pspec)
178 {
179 	switch (property_id) {
180 		case PROP_CURRENT_VIEW:
181 			g_value_set_object (
182 				value,
183 				e_book_shell_content_get_current_view (
184 				E_BOOK_SHELL_CONTENT (object)));
185 			return;
186 
187 		case PROP_ORIENTATION:
188 			g_value_set_enum (
189 				value,
190 				book_shell_content_get_orientation (
191 				E_BOOK_SHELL_CONTENT (object)));
192 			return;
193 
194 		case PROP_PREVIEW_CONTACT:
195 			g_value_set_object (
196 				value,
197 				e_book_shell_content_get_preview_contact (
198 				E_BOOK_SHELL_CONTENT (object)));
199 			return;
200 
201 		case PROP_PREVIEW_VISIBLE:
202 			g_value_set_boolean (
203 				value,
204 				e_book_shell_content_get_preview_visible (
205 				E_BOOK_SHELL_CONTENT (object)));
206 			return;
207 
208 		case PROP_PREVIEW_SHOW_MAPS:
209 			g_value_set_boolean (
210 				value,
211 				e_book_shell_content_get_preview_show_maps (
212 				E_BOOK_SHELL_CONTENT (object)));
213 			return;
214 	}
215 
216 	G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
217 }
218 
219 static void
220 book_shell_content_dispose (GObject *object)
221 {
222 	EBookShellContentPrivate *priv;
223 
224 	priv = E_BOOK_SHELL_CONTENT_GET_PRIVATE (object);
225 
226 	if (priv->paned != NULL) {
227 		g_object_unref (priv->paned);
228 		priv->paned = NULL;
229 	}
230 
231 	if (priv->notebook != NULL) {
232 		g_object_unref (priv->notebook);
233 		priv->notebook = NULL;
234 	}
235 
236 	if (priv->preview_pane != NULL) {
237 		g_object_unref (priv->preview_pane);
238 		priv->preview_pane = NULL;
239 	}
240 
241 	/* Chain up to parent's dispose() method. */
242 	G_OBJECT_CLASS (e_book_shell_content_parent_class)->dispose (object);
243 }
244 
245 static void
246 book_shell_content_constructed (GObject *object)
247 {
248 	EBookShellContentPrivate *priv;
249 	EShellView *shell_view;
250 	EShellWindow *shell_window;
251 	EShellContent *shell_content;
252 	EShellTaskbar *shell_taskbar;
253 	GtkWidget *container;
254 	GtkWidget *widget;
255 
256 	priv = E_BOOK_SHELL_CONTENT_GET_PRIVATE (object);
257 
258 	/* Chain up to parent's constructed() method. */
259 	G_OBJECT_CLASS (e_book_shell_content_parent_class)->constructed (object);
260 
261 	shell_content = E_SHELL_CONTENT (object);
262 	shell_view = e_shell_content_get_shell_view (shell_content);
263 	shell_window = e_shell_view_get_shell_window (shell_view);
264 	shell_taskbar = e_shell_view_get_shell_taskbar (shell_view);
265 
266 	container = GTK_WIDGET (object);
267 
268 	widget = e_paned_new (GTK_ORIENTATION_VERTICAL);
269 	gtk_container_add (GTK_CONTAINER (container), widget);
270 	priv->paned = g_object_ref (widget);
271 	gtk_widget_show (widget);
272 
273 	g_object_bind_property (
274 		object, "orientation",
275 		widget, "orientation",
276 		G_BINDING_SYNC_CREATE);
277 
278 	container = widget;
279 
280 	widget = gtk_notebook_new ();
281 	gtk_notebook_set_show_tabs (GTK_NOTEBOOK (widget), FALSE);
282 	gtk_notebook_set_show_border (GTK_NOTEBOOK (widget), FALSE);
283 	gtk_paned_pack1 (GTK_PANED (container), widget, TRUE, FALSE);
284 	priv->notebook = g_object_ref (widget);
285 	gtk_widget_show (widget);
286 
287 	widget = eab_contact_display_new ();
288 	eab_contact_display_set_mode (
289 		EAB_CONTACT_DISPLAY (widget),
290 		EAB_CONTACT_DISPLAY_RENDER_NORMAL);
291 
292 	eab_contact_display_set_show_maps (
293 		EAB_CONTACT_DISPLAY (widget),
294 		priv->preview_show_maps);
295 
296 	g_object_bind_property (
297 		object, "preview-show-maps",
298 		widget, "show-maps",
299 		G_BINDING_SYNC_CREATE);
300 
301 	gtk_widget_show (widget);
302 
303 	g_signal_connect_swapped (
304 		widget, "send-message",
305 		G_CALLBACK (book_shell_content_send_message_cb), object);
306 
307 	g_signal_connect_swapped (
308 		widget, "status-message",
309 		G_CALLBACK (e_shell_taskbar_set_message),
310 		shell_taskbar);
311 
312 	widget = e_preview_pane_new (E_WEB_VIEW (widget));
313 	gtk_paned_pack2 (GTK_PANED (container), widget, FALSE, FALSE);
314 	priv->preview_pane = g_object_ref (widget);
315 	gtk_widget_show (widget);
316 
317 	g_object_bind_property (
318 		object, "preview-visible",
319 		widget, "visible",
320 		G_BINDING_SYNC_CREATE);
321 
322 	/* Restore pane positions from the last session once
323 	 * the shell view is fully initialized and visible. */
324 	g_signal_connect (
325 		shell_window, "shell-view-created::addressbook",
326 		G_CALLBACK (book_shell_content_restore_state_cb),
327 		shell_content);
328 }
329 
330 static void
331 book_shell_content_check_state_foreach (gint row,
332                                         gpointer user_data)
333 {
334 	EContact *contact;
335 
336 	struct {
337 		EAddressbookModel *model;
338 		GList *list;
339 	} *foreach_data = user_data;
340 
341 	contact = e_addressbook_model_get_contact (foreach_data->model, row);
342 	g_return_if_fail (E_IS_CONTACT (contact));
343 
344 	foreach_data->list = g_list_prepend (foreach_data->list, contact);
345 }
346 
347 static guint32
348 book_shell_content_check_state (EShellContent *shell_content)
349 {
350 	EBookShellContent *book_shell_content;
351 	ESelectionModel *selection_model;
352 	EAddressbookModel *model;
353 	EAddressbookView *view;
354 	GtkNotebook *notebook;
355 	gboolean has_email = TRUE;
356 	gboolean is_contact_list = TRUE;
357 	guint32 state = 0;
358 	gint n_selected;
359 
360 	struct {
361 		EAddressbookModel *model;
362 		GList *list;
363 	} foreach_data;
364 
365 	book_shell_content = E_BOOK_SHELL_CONTENT (shell_content);
366 
367 	/* This function may be triggered at startup before any address
368 	 * book views are added.  Check for that and return silently. */
369 	notebook = GTK_NOTEBOOK (book_shell_content->priv->notebook);
370 	if (gtk_notebook_get_n_pages (notebook) == 0)
371 		return 0;
372 
373 	view = e_book_shell_content_get_current_view (book_shell_content);
374 	model = e_addressbook_view_get_model (view);
375 
376 	selection_model = e_addressbook_view_get_selection_model (view);
377 	n_selected = (selection_model != NULL) ?
378 		e_selection_model_selected_count (selection_model) : 0;
379 
380 	foreach_data.model = model;
381 	foreach_data.list = NULL;
382 
383 	if (selection_model != NULL)
384 		e_selection_model_foreach (
385 			selection_model, (EForeachFunc)
386 			book_shell_content_check_state_foreach,
387 			&foreach_data);
388 
389 	while (foreach_data.list != NULL) {
390 		EContact *contact = E_CONTACT (foreach_data.list->data);
391 		GList *email_list;
392 
393 		email_list = e_contact_get (contact, E_CONTACT_EMAIL);
394 		has_email &= (email_list != NULL);
395 		g_list_foreach (email_list, (GFunc) g_free, NULL);
396 		g_list_free (email_list);
397 
398 		is_contact_list &=
399 			(e_contact_get (contact, E_CONTACT_IS_LIST) != NULL);
400 
401 		g_object_unref (contact);
402 
403 		foreach_data.list = g_list_delete_link (
404 			foreach_data.list, foreach_data.list);
405 	}
406 
407 	if (n_selected == 1)
408 		state |= E_BOOK_SHELL_CONTENT_SELECTION_SINGLE;
409 	if (n_selected > 1)
410 		state |= E_BOOK_SHELL_CONTENT_SELECTION_MULTIPLE;
411 	if (n_selected > 0 && has_email)
412 		state |= E_BOOK_SHELL_CONTENT_SELECTION_HAS_EMAIL;
413 	if (n_selected == 1 && is_contact_list)
414 		state |= E_BOOK_SHELL_CONTENT_SELECTION_IS_CONTACT_LIST;
415 	if (e_addressbook_model_can_stop (model))
416 		state |= E_BOOK_SHELL_CONTENT_SOURCE_IS_BUSY;
417 	if (e_addressbook_model_get_editable (model))
418 		state |= E_BOOK_SHELL_CONTENT_SOURCE_IS_EDITABLE;
419 
420 	return state;
421 }
422 
423 static void
424 book_shell_content_focus_search_results (EShellContent *shell_content)
425 {
426 	EBookShellContent *book_shell_content;
427 	EAddressbookView *view;
428 
429 	book_shell_content = E_BOOK_SHELL_CONTENT (shell_content);
430 	view = e_book_shell_content_get_current_view (book_shell_content);
431 
432 	gtk_widget_grab_focus (GTK_WIDGET (view));
433 }
434 
435 static void
436 e_book_shell_content_class_init (EBookShellContentClass *class)
437 {
438 	GObjectClass *object_class;
439 	EShellContentClass *shell_content_class;
440 
441 	g_type_class_add_private (class, sizeof (EBookShellContentPrivate));
442 
443 	object_class = G_OBJECT_CLASS (class);
444 	object_class->set_property = book_shell_content_set_property;
445 	object_class->get_property = book_shell_content_get_property;
446 	object_class->dispose = book_shell_content_dispose;
447 	object_class->constructed = book_shell_content_constructed;
448 
449 	shell_content_class = E_SHELL_CONTENT_CLASS (class);
450 	shell_content_class->check_state = book_shell_content_check_state;
451 	shell_content_class->focus_search_results =
452 		book_shell_content_focus_search_results;
453 
454 	g_object_class_install_property (
455 		object_class,
456 		PROP_CURRENT_VIEW,
457 		g_param_spec_object (
458 			"current-view",
459 			"Current View",
460 			"The currently selected address book view",
461 			E_TYPE_ADDRESSBOOK_VIEW,
462 			G_PARAM_READWRITE));
463 
464 	g_object_class_install_property (
465 		object_class,
466 		PROP_PREVIEW_CONTACT,
467 		g_param_spec_object (
468 			"preview-contact",
469 			"Previewed Contact",
470 			"The contact being shown in the preview pane",
471 			E_TYPE_CONTACT,
472 			G_PARAM_READWRITE));
473 
474 	g_object_class_install_property (
475 		object_class,
476 		PROP_PREVIEW_VISIBLE,
477 		g_param_spec_boolean (
478 			"preview-visible",
479 			"Preview is Visible",
480 			"Whether the preview pane is visible",
481 			TRUE,
482 			G_PARAM_READWRITE |
483 			G_PARAM_CONSTRUCT));
484 
485 	g_object_class_override_property (
486 		object_class, PROP_ORIENTATION, "orientation");
487 
488 	g_object_class_install_property (
489 		object_class,
490 		PROP_PREVIEW_SHOW_MAPS,
491 		g_param_spec_boolean (
492 			"preview-show-maps",
493 			NULL,
494 			NULL,
495 			FALSE,
496 			G_PARAM_READWRITE));
497 }
498 
499 static void
500 e_book_shell_content_class_finalize (EBookShellContentClass *class)
501 {
502 }
503 
504 static void
505 e_book_shell_content_init (EBookShellContent *book_shell_content)
506 {
507 	book_shell_content->priv =
508 		E_BOOK_SHELL_CONTENT_GET_PRIVATE (book_shell_content);
509 
510 	/* Postpone widget construction until we have a shell view. */
511 }
512 
513 void
514 e_book_shell_content_type_register (GTypeModule *type_module)
515 {
516 	/* XXX G_DEFINE_DYNAMIC_TYPE declares a static type registration
517 	 *     function, so we have to wrap it with a public function in
518 	 *     order to register types from a separate compilation unit. */
519 	e_book_shell_content_register_type (type_module);
520 }
521 
522 GtkWidget *
523 e_book_shell_content_new (EShellView *shell_view)
524 {
525 	g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL);
526 
527 	return g_object_new (
528 		E_TYPE_BOOK_SHELL_CONTENT,
529 		"shell-view", shell_view, NULL);
530 }
531 
532 void
533 e_book_shell_content_insert_view (EBookShellContent *book_shell_content,
534                                   EAddressbookView *addressbook_view)
535 {
536 	GtkNotebook *notebook;
537 	GtkWidget *child;
538 
539 	g_return_if_fail (E_IS_BOOK_SHELL_CONTENT (book_shell_content));
540 	g_return_if_fail (E_IS_ADDRESSBOOK_VIEW (addressbook_view));
541 
542 	notebook = GTK_NOTEBOOK (book_shell_content->priv->notebook);
543 	child = GTK_WIDGET (addressbook_view);
544 	gtk_notebook_append_page (notebook, child, NULL);
545 }
546 
547 void
548 e_book_shell_content_remove_view (EBookShellContent *book_shell_content,
549                                   EAddressbookView *addressbook_view)
550 {
551 	GtkNotebook *notebook;
552 	GtkWidget *child;
553 	gint page_num;
554 
555 	g_return_if_fail (E_IS_BOOK_SHELL_CONTENT (book_shell_content));
556 	g_return_if_fail (E_IS_ADDRESSBOOK_VIEW (addressbook_view));
557 
558 	notebook = GTK_NOTEBOOK (book_shell_content->priv->notebook);
559 	child = GTK_WIDGET (addressbook_view);
560 	page_num = gtk_notebook_page_num (notebook, child);
561 	g_return_if_fail (page_num >= 0);
562 
563 	gtk_notebook_remove_page (notebook, page_num);
564 }
565 
566 EAddressbookView *
567 e_book_shell_content_get_current_view (EBookShellContent *book_shell_content)
568 {
569 	GtkNotebook *notebook;
570 	GtkWidget *widget;
571 	gint page_num;
572 
573 	g_return_val_if_fail (
574 		E_IS_BOOK_SHELL_CONTENT (book_shell_content), NULL);
575 
576 	notebook = GTK_NOTEBOOK (book_shell_content->priv->notebook);
577 	page_num = gtk_notebook_get_current_page (notebook);
578 	widget = gtk_notebook_get_nth_page (notebook, page_num);
579 	g_return_val_if_fail (widget != NULL, NULL);
580 
581 	return E_ADDRESSBOOK_VIEW (widget);
582 }
583 
584 void
585 e_book_shell_content_set_current_view (EBookShellContent *book_shell_content,
586                                        EAddressbookView *addressbook_view)
587 {
588 	EShellView *shell_view;
589 	EShellContent *shell_content;
590 	EShellSearchbar *searchbar;
591 	EBookShellView *book_shell_view;
592 	GtkNotebook *notebook;
593 	GtkWidget *child;
594 	gint page_num, old_page_num;
595 
596 	g_return_if_fail (E_IS_BOOK_SHELL_CONTENT (book_shell_content));
597 	g_return_if_fail (E_IS_ADDRESSBOOK_VIEW (addressbook_view));
598 
599 	shell_content = E_SHELL_CONTENT (book_shell_content);
600 	shell_view = e_shell_content_get_shell_view (shell_content);
601 
602 	book_shell_view = E_BOOK_SHELL_VIEW (shell_view);
603 	searchbar = e_book_shell_content_get_searchbar (book_shell_content);
604 
605 	notebook = GTK_NOTEBOOK (book_shell_content->priv->notebook);
606 	child = GTK_WIDGET (addressbook_view);
607 	page_num = gtk_notebook_page_num (notebook, child);
608 	g_return_if_fail (page_num >= 0);
609 
610 	old_page_num = gtk_notebook_get_current_page (notebook);
611 	gtk_notebook_set_current_page (notebook, page_num);
612 
613 	if (old_page_num != page_num) {
614 		EActionComboBox *combo_box;
615 		GtkRadioAction *action;
616 		gint filter_id = 0, search_id = 0;
617 		gchar *search_text = NULL;
618 		EFilterRule *advanced_search = NULL;
619 
620 		e_book_shell_view_disable_searching (book_shell_view);
621 
622 		e_addressbook_view_get_search (
623 			addressbook_view, &filter_id, &search_id,
624 			&search_text, &advanced_search);
625 
626 		combo_box = e_shell_searchbar_get_filter_combo_box (searchbar);
627 		e_action_combo_box_set_current_value (combo_box, filter_id);
628 
629 		action = e_shell_searchbar_get_search_option (searchbar);
630 		gtk_radio_action_set_current_value (action, search_id);
631 
632 		e_shell_searchbar_set_search_text (searchbar, search_text);
633 
634 		e_shell_view_set_search_rule (shell_view, advanced_search);
635 
636 		g_free (search_text);
637 
638 		if (advanced_search)
639 			g_object_unref (advanced_search);
640 
641 		e_book_shell_view_enable_searching (book_shell_view);
642 	}
643 
644 	g_object_notify (G_OBJECT (book_shell_content), "current-view");
645 }
646 
647 EContact *
648 e_book_shell_content_get_preview_contact (EBookShellContent *book_shell_content)
649 {
650 	EPreviewPane *preview_pane;
651 	EABContactDisplay *display;
652 	EWebView *web_view;
653 
654 	g_return_val_if_fail (
655 		E_IS_BOOK_SHELL_CONTENT (book_shell_content), NULL);
656 
657 	preview_pane = E_PREVIEW_PANE (book_shell_content->priv->preview_pane);
658 	web_view = e_preview_pane_get_web_view (preview_pane);
659 	display = EAB_CONTACT_DISPLAY (web_view);
660 
661 	return eab_contact_display_get_contact (display);
662 }
663 
664 void
665 e_book_shell_content_set_preview_contact (EBookShellContent *book_shell_content,
666                                           EContact *preview_contact)
667 {
668 	EPreviewPane *preview_pane;
669 	EABContactDisplay *display;
670 	EWebView *web_view;
671 
672 	g_return_if_fail (E_IS_BOOK_SHELL_CONTENT (book_shell_content));
673 
674 	preview_pane = E_PREVIEW_PANE (book_shell_content->priv->preview_pane);
675 	web_view = e_preview_pane_get_web_view (preview_pane);
676 	display = EAB_CONTACT_DISPLAY (web_view);
677 
678 	eab_contact_display_set_contact (display, preview_contact);
679 	g_object_notify (G_OBJECT (book_shell_content), "preview-contact");
680 }
681 
682 EPreviewPane *
683 e_book_shell_content_get_preview_pane (EBookShellContent *book_shell_content)
684 {
685 	g_return_val_if_fail (
686 		E_IS_BOOK_SHELL_CONTENT (book_shell_content), NULL);
687 
688 	return E_PREVIEW_PANE (book_shell_content->priv->preview_pane);
689 }
690 
691 gboolean
692 e_book_shell_content_get_preview_visible (EBookShellContent *book_shell_content)
693 {
694 	g_return_val_if_fail (
695 		E_IS_BOOK_SHELL_CONTENT (book_shell_content), FALSE);
696 
697 	return book_shell_content->priv->preview_visible;
698 }
699 
700 void
701 e_book_shell_content_set_preview_visible (EBookShellContent *book_shell_content,
702                                           gboolean preview_visible)
703 {
704 	g_return_if_fail (E_IS_BOOK_SHELL_CONTENT (book_shell_content));
705 
706 	if (book_shell_content->priv->preview_visible == preview_visible)
707 		return;
708 
709 	book_shell_content->priv->preview_visible = preview_visible;
710 
711 	g_object_notify (G_OBJECT (book_shell_content), "preview-visible");
712 }
713 
714 gboolean
715 e_book_shell_content_get_preview_show_maps (EBookShellContent *book_shell_content)
716 {
717 	g_return_val_if_fail (
718 		E_IS_BOOK_SHELL_CONTENT (book_shell_content), FALSE);
719 
720 	return book_shell_content->priv->preview_show_maps;
721 }
722 
723 void
724 e_book_shell_content_set_preview_show_maps (EBookShellContent *book_shell_content,
725                                             gboolean show_maps)
726 {
727 	g_return_if_fail (E_IS_BOOK_SHELL_CONTENT (book_shell_content));
728 
729 	if (book_shell_content->priv->preview_show_maps == show_maps)
730 		return;
731 
732 	book_shell_content->priv->preview_show_maps = show_maps;
733 
734 	g_object_notify (G_OBJECT (book_shell_content), "preview-show-maps");
735 }
736 
737 EShellSearchbar *
738 e_book_shell_content_get_searchbar (EBookShellContent *book_shell_content)
739 {
740 	EShellView *shell_view;
741 	EShellContent *shell_content;
742 	GtkWidget *widget;
743 
744 	g_return_val_if_fail (
745 		E_IS_BOOK_SHELL_CONTENT (book_shell_content), NULL);
746 
747 	shell_content = E_SHELL_CONTENT (book_shell_content);
748 	shell_view = e_shell_content_get_shell_view (shell_content);
749 	widget = e_shell_view_get_searchbar (shell_view);
750 
751 	return E_SHELL_SEARCHBAR (widget);
752 }