evolution-3.6.4/modules/calendar/e-memo-shell-content.c

No issues found

Incomplete coverage

Tool Failure ID Location Function Message Data
clang-analyzer no-output-found e-memo-shell-content.c Message(text='Unable to locate XML output from invoke-clang-analyzer') None
clang-analyzer no-output-found e-memo-shell-content.c Message(text='Unable to locate XML output from invoke-clang-analyzer') None
Failure running clang-analyzer ('no-output-found')
Message
Unable to locate XML output from invoke-clang-analyzer
Failure running clang-analyzer ('no-output-found')
Message
Unable to locate XML output from invoke-clang-analyzer
  1 /*
  2  * e-memo-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-memo-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/menus/gal-view-etable.h"
 33 #include "widgets/misc/e-paned.h"
 34 #include "widgets/misc/e-preview-pane.h"
 35 
 36 #include "calendar/gui/comp-util.h"
 37 #include "calendar/gui/e-cal-component-preview.h"
 38 #include "calendar/gui/e-cal-model-memos.h"
 39 #include "calendar/gui/e-memo-table.h"
 40 
 41 #define E_MEMO_SHELL_CONTENT_GET_PRIVATE(obj) \
 42 	(G_TYPE_INSTANCE_GET_PRIVATE \
 43 	((obj), E_TYPE_MEMO_SHELL_CONTENT, EMemoShellContentPrivate))
 44 
 45 #define E_MEMO_TABLE_DEFAULT_STATE \
 46 	"<?xml version=\"1.0\"?>" \
 47 	"<ETableState>" \
 48 	"  <column source=\"1\"/>" \
 49 	"  <column source=\"0\"/>" \
 50 	"  <column source=\"2\"/>" \
 51 	"  <grouping/>" \
 52 	"</ETableState>"
 53 
 54 struct _EMemoShellContentPrivate {
 55 	GtkWidget *paned;
 56 	GtkWidget *memo_table;
 57 	GtkWidget *preview_pane;
 58 
 59 	ECalModel *memo_model;
 60 	GalViewInstance *view_instance;
 61 	GtkOrientation orientation;
 62 
 63 	gchar *current_uid;
 64 
 65 	guint preview_visible	: 1;
 66 };
 67 
 68 enum {
 69 	PROP_0,
 70 	PROP_MODEL,
 71 	PROP_ORIENTATION,
 72 	PROP_PREVIEW_VISIBLE
 73 };
 74 
 75 G_DEFINE_DYNAMIC_TYPE_EXTENDED (
 76 	EMemoShellContent,
 77 	e_memo_shell_content,
 78 	E_TYPE_SHELL_CONTENT,
 79 	0,
 80 	G_IMPLEMENT_INTERFACE_DYNAMIC (
 81 		GTK_TYPE_ORIENTABLE, NULL))
 82 
 83 static void
 84 memo_shell_content_display_view_cb (EMemoShellContent *memo_shell_content,
 85                                     GalView *gal_view)
 86 {
 87 	EMemoTable *memo_table;
 88 
 89 	if (!GAL_IS_VIEW_ETABLE (gal_view))
 90 		return;
 91 
 92 	memo_table = e_memo_shell_content_get_memo_table (memo_shell_content);
 93 
 94 	gal_view_etable_attach_table (
 95 		GAL_VIEW_ETABLE (gal_view), E_TABLE (memo_table));
 96 }
 97 
 98 static void
 99 memo_shell_content_table_foreach_cb (gint model_row,
100                                      gpointer user_data)
101 {
102 	ECalModelComponent *comp_data;
103 	icalcomponent *clone;
104 	icalcomponent *vcal;
105 	gchar *string;
106 
107 	struct {
108 		ECalModel *model;
109 		GSList *list;
110 	} *foreach_data = user_data;
111 
112 	comp_data = e_cal_model_get_component_at (
113 		foreach_data->model, model_row);
114 
115 	vcal = e_cal_util_new_top_level ();
116 	clone = icalcomponent_new_clone (comp_data->icalcomp);
117 	e_cal_util_add_timezones_from_component (vcal, comp_data->icalcomp);
118 	icalcomponent_add_component (vcal, clone);
119 
120 	/* String is owned by libical; do not free. */
121 	string = icalcomponent_as_ical_string (vcal);
122 	if (string != NULL) {
123 		ESource *source;
124 		const gchar *source_uid;
125 
126 		source = e_client_get_source (E_CLIENT (comp_data->client));
127 		source_uid = e_source_get_uid (source);
128 
129 		foreach_data->list = g_slist_prepend (
130 			foreach_data->list,
131 			g_strdup_printf ("%s\n%s", source_uid, string));
132 	}
133 
134 	icalcomponent_free (vcal);
135 }
136 
137 static void
138 memo_shell_content_table_drag_data_get_cb (EMemoShellContent *memo_shell_content,
139                                            gint row,
140                                            gint col,
141                                            GdkDragContext *context,
142                                            GtkSelectionData *selection_data,
143                                            guint info,
144                                            guint time)
145 {
146 	EMemoTable *memo_table;
147 	GdkAtom target;
148 
149 	struct {
150 		ECalModel *model;
151 		GSList *list;
152 	} foreach_data;
153 
154 	/* Sanity check the selection target. */
155 	target = gtk_selection_data_get_target (selection_data);
156 	if (!e_targets_include_calendar (&target, 1))
157 		return;
158 
159 	memo_table = e_memo_shell_content_get_memo_table (memo_shell_content);
160 
161 	foreach_data.model = e_memo_table_get_model (memo_table);
162 	foreach_data.list = NULL;
163 
164 	e_table_selected_row_foreach (
165 		E_TABLE (memo_table),
166 		memo_shell_content_table_foreach_cb,
167 		&foreach_data);
168 
169 	if (foreach_data.list != NULL) {
170 		cal_comp_selection_set_string_list (
171 			selection_data, foreach_data.list);
172 		g_slist_foreach (foreach_data.list, (GFunc) g_free, NULL);
173 		g_slist_free (foreach_data.list);
174 	}
175 }
176 
177 static void
178 memo_shell_content_table_drag_data_delete_cb (EMemoShellContent *memo_shell_content,
179                                               gint row,
180                                               gint col,
181                                               GdkDragContext *context)
182 {
183 	/* Moved components are deleted from source immediately when moved,
184 	 * because some of them can be part of destination source, and we
185 	 * don't want to delete not-moved memos.  There is no such information
186 	 * which event has been moved and which not, so skip this method. */
187 }
188 
189 static void
190 memo_shell_content_cursor_change_cb (EMemoShellContent *memo_shell_content,
191                                      gint row,
192                                      ETable *table)
193 {
194 	ECalComponentPreview *memo_preview;
195 	ECalModel *memo_model;
196 	ECalModelComponent *comp_data;
197 	EPreviewPane *preview_pane;
198 	EWebView *web_view;
199 	const gchar *uid;
200 
201 	memo_model = e_memo_shell_content_get_memo_model (memo_shell_content);
202 	preview_pane = e_memo_shell_content_get_preview_pane (memo_shell_content);
203 
204 	web_view = e_preview_pane_get_web_view (preview_pane);
205 	memo_preview = E_CAL_COMPONENT_PREVIEW (web_view);
206 
207 	if (e_table_selected_count (table) != 1) {
208 		if (memo_shell_content->priv->preview_visible)
209 			e_cal_component_preview_clear (memo_preview);
210 		return;
211 	}
212 
213 	row = e_table_get_cursor_row (table);
214 	comp_data = e_cal_model_get_component_at (memo_model, row);
215 
216 	if (memo_shell_content->priv->preview_visible) {
217 		ECalComponent *comp;
218 
219 		comp = e_cal_component_new_from_icalcomponent (
220 			icalcomponent_new_clone (comp_data->icalcomp));
221 
222 		e_cal_component_preview_display (
223 			memo_preview, comp_data->client, comp,
224 			e_cal_model_get_timezone (memo_model),
225 			e_cal_model_get_use_24_hour_format (memo_model));
226 
227 		g_object_unref (comp);
228 	}
229 
230 	uid = icalcomponent_get_uid (comp_data->icalcomp);
231 	g_free (memo_shell_content->priv->current_uid);
232 	memo_shell_content->priv->current_uid = g_strdup (uid);
233 }
234 
235 static void
236 memo_shell_content_selection_change_cb (EMemoShellContent *memo_shell_content,
237                                         ETable *table)
238 {
239 	ECalComponentPreview *memo_preview;
240 	EPreviewPane *preview_pane;
241 	EWebView *web_view;
242 
243 	preview_pane = e_memo_shell_content_get_preview_pane (memo_shell_content);
244 
245 	web_view = e_preview_pane_get_web_view (preview_pane);
246 	memo_preview = E_CAL_COMPONENT_PREVIEW (web_view);
247 
248 	/* XXX Old code emits a "selection-changed" signal here. */
249 
250 	if (e_table_selected_count (table) != 1)
251 		e_cal_component_preview_clear (memo_preview);
252 }
253 
254 static void
255 memo_shell_content_model_row_changed_cb (EMemoShellContent *memo_shell_content,
256                                          gint row,
257                                          ETableModel *model)
258 {
259 	ECalModelComponent *comp_data;
260 	EMemoTable *memo_table;
261 	const gchar *current_uid;
262 	const gchar *uid;
263 
264 	current_uid = memo_shell_content->priv->current_uid;
265 	if (current_uid == NULL)
266 		return;
267 
268 	comp_data = e_cal_model_get_component_at (E_CAL_MODEL (model), row);
269 	if (comp_data == NULL)
270 		return;
271 
272 	uid = icalcomponent_get_uid (comp_data->icalcomp);
273 	if (g_strcmp0 (uid, current_uid) != 0)
274 		return;
275 
276 	memo_table = e_memo_shell_content_get_memo_table (memo_shell_content);
277 
278 	memo_shell_content_cursor_change_cb (
279 		memo_shell_content, 0, E_TABLE (memo_table));
280 }
281 
282 static void
283 memo_shell_content_restore_state_cb (EShellWindow *shell_window,
284                                      EShellView *shell_view,
285                                      EShellContent *shell_content)
286 {
287 	EMemoShellContentPrivate *priv;
288 	GSettings *settings;
289 
290 	priv = E_MEMO_SHELL_CONTENT_GET_PRIVATE (shell_content);
291 
292 	/* Bind GObject properties to settings keys. */
293 
294 	settings = g_settings_new ("org.gnome.evolution.calendar");
295 
296 	g_settings_bind (
297 		settings, "memo-hpane-position",
298 		priv->paned, "hposition",
299 		G_SETTINGS_BIND_DEFAULT);
300 
301 	g_settings_bind (
302 		settings, "memo-vpane-position",
303 		priv->paned, "vposition",
304 		G_SETTINGS_BIND_DEFAULT);
305 }
306 
307 static GtkOrientation
308 memo_shell_content_get_orientation (EMemoShellContent *memo_shell_content)
309 {
310 	return memo_shell_content->priv->orientation;
311 }
312 
313 static void
314 memo_shell_content_set_orientation (EMemoShellContent *memo_shell_content,
315                                     GtkOrientation orientation)
316 {
317 	if (memo_shell_content->priv->orientation == orientation)
318 		return;
319 
320 	memo_shell_content->priv->orientation = orientation;
321 
322 	g_object_notify (G_OBJECT (memo_shell_content), "orientation");
323 }
324 
325 static void
326 memo_shell_content_set_property (GObject *object,
327                                  guint property_id,
328                                  const GValue *value,
329                                  GParamSpec *pspec)
330 {
331 	switch (property_id) {
332 		case PROP_ORIENTATION:
333 			memo_shell_content_set_orientation (
334 				E_MEMO_SHELL_CONTENT (object),
335 				g_value_get_enum (value));
336 			return;
337 
338 		case PROP_PREVIEW_VISIBLE:
339 			e_memo_shell_content_set_preview_visible (
340 				E_MEMO_SHELL_CONTENT (object),
341 				g_value_get_boolean (value));
342 			return;
343 	}
344 
345 	G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
346 }
347 
348 static void
349 memo_shell_content_get_property (GObject *object,
350                                  guint property_id,
351                                  GValue *value,
352                                  GParamSpec *pspec)
353 {
354 	switch (property_id) {
355 		case PROP_MODEL:
356 			g_value_set_object (
357 				value,
358 				e_memo_shell_content_get_memo_model (
359 				E_MEMO_SHELL_CONTENT (object)));
360 			return;
361 
362 		case PROP_ORIENTATION:
363 			g_value_set_enum (
364 				value,
365 				memo_shell_content_get_orientation (
366 				E_MEMO_SHELL_CONTENT (object)));
367 			return;
368 
369 		case PROP_PREVIEW_VISIBLE:
370 			g_value_set_boolean (
371 				value,
372 				e_memo_shell_content_get_preview_visible (
373 				E_MEMO_SHELL_CONTENT (object)));
374 			return;
375 	}
376 
377 	G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
378 }
379 
380 static void
381 memo_shell_content_dispose (GObject *object)
382 {
383 	EMemoShellContentPrivate *priv;
384 
385 	priv = E_MEMO_SHELL_CONTENT_GET_PRIVATE (object);
386 
387 	if (priv->paned != NULL) {
388 		g_object_unref (priv->paned);
389 		priv->paned = NULL;
390 	}
391 
392 	if (priv->memo_table != NULL) {
393 		g_object_unref (priv->memo_table);
394 		priv->memo_table = NULL;
395 	}
396 
397 	if (priv->preview_pane != NULL) {
398 		g_object_unref (priv->preview_pane);
399 		priv->preview_pane = NULL;
400 	}
401 
402 	if (priv->memo_model != NULL) {
403 		g_object_unref (priv->memo_model);
404 		priv->memo_model = NULL;
405 	}
406 
407 	if (priv->view_instance != NULL) {
408 		g_object_unref (priv->view_instance);
409 		priv->view_instance = NULL;
410 	}
411 
412 	/* Chain up to parent's dispose() method. */
413 	G_OBJECT_CLASS (e_memo_shell_content_parent_class)->dispose (object);
414 }
415 
416 static void
417 memo_shell_content_finalize (GObject *object)
418 {
419 	EMemoShellContentPrivate *priv;
420 
421 	priv = E_MEMO_SHELL_CONTENT_GET_PRIVATE (object);
422 
423 	g_free (priv->current_uid);
424 
425 	/* Chain up to parent's finalize() method. */
426 	G_OBJECT_CLASS (e_memo_shell_content_parent_class)->finalize (object);
427 }
428 
429 static void
430 memo_shell_content_constructed (GObject *object)
431 {
432 	EMemoShellContentPrivate *priv;
433 	EShell *shell;
434 	EShellView *shell_view;
435 	EShellContent *shell_content;
436 	EShellTaskbar *shell_taskbar;
437 	EShellWindow *shell_window;
438 	ESourceRegistry *registry;
439 	GalViewInstance *view_instance;
440 	GtkTargetList *target_list;
441 	GtkTargetEntry *targets;
442 	GtkWidget *container;
443 	GtkWidget *widget;
444 	gint n_targets;
445 
446 	priv = E_MEMO_SHELL_CONTENT_GET_PRIVATE (object);
447 
448 	/* Chain up to parent's constructed() method. */
449 	G_OBJECT_CLASS (e_memo_shell_content_parent_class)->constructed (object);
450 
451 	shell_content = E_SHELL_CONTENT (object);
452 	shell_view = e_shell_content_get_shell_view (shell_content);
453 	shell_taskbar = e_shell_view_get_shell_taskbar (shell_view);
454 	shell_window = e_shell_view_get_shell_window (shell_view);
455 	shell = e_shell_window_get_shell (shell_window);
456 
457 	registry = e_shell_get_registry (shell);
458 	priv->memo_model = e_cal_model_memos_new (registry);
459 
460 	/* Build content widgets. */
461 
462 	container = GTK_WIDGET (object);
463 
464 	widget = e_paned_new (GTK_ORIENTATION_VERTICAL);
465 	gtk_container_add (GTK_CONTAINER (container), widget);
466 	priv->paned = g_object_ref (widget);
467 	gtk_widget_show (widget);
468 
469 	g_object_bind_property (
470 		object, "orientation",
471 		widget, "orientation",
472 		G_BINDING_SYNC_CREATE);
473 
474 	container = priv->paned;
475 
476 	widget = gtk_scrolled_window_new (NULL, NULL);
477 	gtk_scrolled_window_set_policy (
478 		GTK_SCROLLED_WINDOW (widget),
479 		GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
480 	gtk_scrolled_window_set_shadow_type (
481 		GTK_SCROLLED_WINDOW (widget), GTK_SHADOW_IN);
482 	gtk_paned_pack1 (GTK_PANED (container), widget, TRUE, FALSE);
483 	gtk_widget_show (widget);
484 
485 	container = widget;
486 
487 	widget = e_memo_table_new (shell_view, priv->memo_model);
488 	gtk_container_add (GTK_CONTAINER (container), widget);
489 	priv->memo_table = g_object_ref (widget);
490 	gtk_widget_show (widget);
491 
492 	container = priv->paned;
493 
494 	widget = e_cal_component_preview_new ();
495 	gtk_widget_show (widget);
496 
497 	g_signal_connect_swapped (
498 		widget, "status-message",
499 		G_CALLBACK (e_shell_taskbar_set_message),
500 		shell_taskbar);
501 
502 	widget = e_preview_pane_new (E_WEB_VIEW (widget));
503 	gtk_paned_pack2 (GTK_PANED (container), widget, FALSE, FALSE);
504 	priv->preview_pane = g_object_ref (widget);
505 	gtk_widget_show (widget);
506 
507 	g_object_bind_property (
508 		object, "preview-visible",
509 		widget, "visible",
510 		G_BINDING_SYNC_CREATE);
511 
512 	/* Configure the memo table. */
513 
514 	e_table_set_state (
515 		E_TABLE (priv->memo_table), E_MEMO_TABLE_DEFAULT_STATE);
516 
517 	target_list = gtk_target_list_new (NULL, 0);
518 	e_target_list_add_calendar_targets (target_list, 0);
519 	targets = gtk_target_table_new_from_list (target_list, &n_targets);
520 
521 	e_table_drag_source_set (
522 		E_TABLE (priv->memo_table),
523 		GDK_BUTTON1_MASK, targets, n_targets,
524 		GDK_ACTION_MOVE | GDK_ACTION_COPY | GDK_ACTION_ASK);
525 
526 	gtk_target_table_free (targets, n_targets);
527 	gtk_target_list_unref (target_list);
528 
529 	g_signal_connect_swapped (
530 		priv->memo_table, "table-drag-data-get",
531 		G_CALLBACK (memo_shell_content_table_drag_data_get_cb),
532 		object);
533 
534 	g_signal_connect_swapped (
535 		priv->memo_table, "table-drag-data-delete",
536 		G_CALLBACK (memo_shell_content_table_drag_data_delete_cb),
537 		object);
538 
539 	g_signal_connect_swapped (
540 		priv->memo_table, "cursor-change",
541 		G_CALLBACK (memo_shell_content_cursor_change_cb),
542 		object);
543 
544 	g_signal_connect_swapped (
545 		priv->memo_table, "selection-change",
546 		G_CALLBACK (memo_shell_content_selection_change_cb),
547 		object);
548 
549 	g_signal_connect_swapped (
550 		priv->memo_model, "model-row-changed",
551 		G_CALLBACK (memo_shell_content_model_row_changed_cb),
552 		object);
553 
554 	/* Load the view instance. */
555 
556 	view_instance = e_shell_view_new_view_instance (shell_view, NULL);
557 	g_signal_connect_swapped (
558 		view_instance, "display-view",
559 		G_CALLBACK (memo_shell_content_display_view_cb),
560 		object);
561 	priv->view_instance = view_instance;
562 
563 	/* Do this last so e_memo_shell_content_get_view_instance() returns
564 	 * the correct instance in GalViewInstance::loaded signal handlers. */
565 	gal_view_instance_load (view_instance);
566 
567 	/* Restore pane positions from the last session once
568 	 * the shell view is fully initialized and visible. */
569 	g_signal_connect (
570 		shell_window, "shell-view-created::memos",
571 		G_CALLBACK (memo_shell_content_restore_state_cb),
572 		shell_content);
573 }
574 
575 static guint32
576 memo_shell_content_check_state (EShellContent *shell_content)
577 {
578 	EMemoShellContent *memo_shell_content;
579 	EMemoTable *memo_table;
580 	GSList *list, *iter;
581 	gboolean editable = TRUE;
582 	gboolean has_url = FALSE;
583 	gint n_selected;
584 	guint32 state = 0;
585 
586 	memo_shell_content = E_MEMO_SHELL_CONTENT (shell_content);
587 	memo_table = e_memo_shell_content_get_memo_table (memo_shell_content);
588 
589 	n_selected = e_table_selected_count (E_TABLE (memo_table));
590 
591 	list = e_memo_table_get_selected (memo_table);
592 	for (iter = list; iter != NULL; iter = iter->next) {
593 		ECalModelComponent *comp_data = iter->data;
594 		icalproperty *prop;
595 		gboolean read_only;
596 
597 		read_only = e_client_is_readonly (E_CLIENT (comp_data->client));
598 		editable &= !read_only;
599 
600 		prop = icalcomponent_get_first_property (
601 			comp_data->icalcomp, ICAL_URL_PROPERTY);
602 		has_url |= (prop != NULL);
603 	}
604 	g_slist_free (list);
605 
606 	if (n_selected == 1)
607 		state |= E_MEMO_SHELL_CONTENT_SELECTION_SINGLE;
608 	if (n_selected > 1)
609 		state |= E_MEMO_SHELL_CONTENT_SELECTION_MULTIPLE;
610 	if (editable)
611 		state |= E_MEMO_SHELL_CONTENT_SELECTION_CAN_EDIT;
612 	if (has_url)
613 		state |= E_MEMO_SHELL_CONTENT_SELECTION_HAS_URL;
614 
615 	return state;
616 }
617 
618 static void
619 memo_shell_content_focus_search_results (EShellContent *shell_content)
620 {
621 	EMemoShellContentPrivate *priv;
622 
623 	priv = E_MEMO_SHELL_CONTENT_GET_PRIVATE (shell_content);
624 
625 	gtk_widget_grab_focus (priv->memo_table);
626 }
627 
628 static void
629 e_memo_shell_content_class_init (EMemoShellContentClass *class)
630 {
631 	GObjectClass *object_class;
632 	EShellContentClass *shell_content_class;
633 
634 	g_type_class_add_private (class, sizeof (EMemoShellContentPrivate));
635 
636 	object_class = G_OBJECT_CLASS (class);
637 	object_class->set_property = memo_shell_content_set_property;
638 	object_class->get_property = memo_shell_content_get_property;
639 	object_class->dispose = memo_shell_content_dispose;
640 	object_class->finalize = memo_shell_content_finalize;
641 	object_class->constructed = memo_shell_content_constructed;
642 
643 	shell_content_class = E_SHELL_CONTENT_CLASS (class);
644 	shell_content_class->check_state = memo_shell_content_check_state;
645 	shell_content_class->focus_search_results =
646 		memo_shell_content_focus_search_results;
647 
648 	g_object_class_install_property (
649 		object_class,
650 		PROP_MODEL,
651 		g_param_spec_object (
652 			"model",
653 			"Model",
654 			"The memo table model",
655 			E_TYPE_CAL_MODEL,
656 			G_PARAM_READABLE));
657 
658 	g_object_class_install_property (
659 		object_class,
660 		PROP_PREVIEW_VISIBLE,
661 		g_param_spec_boolean (
662 			"preview-visible",
663 			"Preview is Visible",
664 			"Whether the preview pane is visible",
665 			TRUE,
666 			G_PARAM_READWRITE |
667 			G_PARAM_CONSTRUCT));
668 
669 	g_object_class_override_property (
670 		object_class, PROP_ORIENTATION, "orientation");
671 }
672 
673 static void
674 e_memo_shell_content_class_finalize (EMemoShellContentClass *class)
675 {
676 }
677 
678 static void
679 e_memo_shell_content_init (EMemoShellContent *memo_shell_content)
680 {
681 	memo_shell_content->priv =
682 		E_MEMO_SHELL_CONTENT_GET_PRIVATE (memo_shell_content);
683 
684 	/* Postpone widget construction until we have a shell view. */
685 }
686 
687 void
688 e_memo_shell_content_type_register (GTypeModule *type_module)
689 {
690 	/* XXX G_DEFINE_DYNAMIC_TYPE declares a static type registration
691 	 *     function, so we have to wrap it with a public function in
692 	 *     order to register types from a separate compilation unit. */
693 	e_memo_shell_content_register_type (type_module);
694 }
695 
696 GtkWidget *
697 e_memo_shell_content_new (EShellView *shell_view)
698 {
699 	g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL);
700 
701 	return g_object_new (
702 		E_TYPE_MEMO_SHELL_CONTENT,
703 		"shell-view", shell_view, NULL);
704 }
705 
706 ECalModel *
707 e_memo_shell_content_get_memo_model (EMemoShellContent *memo_shell_content)
708 {
709 	g_return_val_if_fail (
710 		E_IS_MEMO_SHELL_CONTENT (memo_shell_content), NULL);
711 
712 	return memo_shell_content->priv->memo_model;
713 }
714 
715 EMemoTable *
716 e_memo_shell_content_get_memo_table (EMemoShellContent *memo_shell_content)
717 {
718 	g_return_val_if_fail (
719 		E_IS_MEMO_SHELL_CONTENT (memo_shell_content), NULL);
720 
721 	return E_MEMO_TABLE (memo_shell_content->priv->memo_table);
722 }
723 
724 EPreviewPane *
725 e_memo_shell_content_get_preview_pane (EMemoShellContent *memo_shell_content)
726 {
727 	g_return_val_if_fail (
728 		E_IS_MEMO_SHELL_CONTENT (memo_shell_content), NULL);
729 
730 	return E_PREVIEW_PANE (memo_shell_content->priv->preview_pane);
731 }
732 
733 gboolean
734 e_memo_shell_content_get_preview_visible (EMemoShellContent *memo_shell_content)
735 {
736 	g_return_val_if_fail (
737 		E_IS_MEMO_SHELL_CONTENT (memo_shell_content), FALSE);
738 
739 	return memo_shell_content->priv->preview_visible;
740 }
741 
742 void
743 e_memo_shell_content_set_preview_visible (EMemoShellContent *memo_shell_content,
744                                           gboolean preview_visible)
745 {
746 	g_return_if_fail (E_IS_MEMO_SHELL_CONTENT (memo_shell_content));
747 
748 	if (memo_shell_content->priv->preview_visible == preview_visible)
749 		return;
750 
751 	memo_shell_content->priv->preview_visible = preview_visible;
752 
753 	if (preview_visible && memo_shell_content->priv->preview_pane) {
754 		memo_shell_content_cursor_change_cb (
755 			memo_shell_content, 0,
756 			E_TABLE (memo_shell_content->priv->memo_table));
757 	}
758 
759 	g_object_notify (G_OBJECT (memo_shell_content), "preview-visible");
760 }
761 
762 EShellSearchbar *
763 e_memo_shell_content_get_searchbar (EMemoShellContent *memo_shell_content)
764 {
765 	EShellView *shell_view;
766 	EShellContent *shell_content;
767 	GtkWidget *widget;
768 
769 	g_return_val_if_fail (
770 		E_IS_MEMO_SHELL_CONTENT (memo_shell_content), NULL);
771 
772 	shell_content = E_SHELL_CONTENT (memo_shell_content);
773 	shell_view = e_shell_content_get_shell_view (shell_content);
774 	widget = e_shell_view_get_searchbar (shell_view);
775 
776 	return E_SHELL_SEARCHBAR (widget);
777 }
778 
779 GalViewInstance *
780 e_memo_shell_content_get_view_instance (EMemoShellContent *memo_shell_content)
781 {
782 	g_return_val_if_fail (
783 		E_IS_MEMO_SHELL_CONTENT (memo_shell_content), NULL);
784 
785 	return memo_shell_content->priv->view_instance;
786 }