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

No issues found

  1 /*
  2  * e-task-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-task-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-tasks.h"
 39 
 40 #define E_TASK_SHELL_CONTENT_GET_PRIVATE(obj) \
 41 	(G_TYPE_INSTANCE_GET_PRIVATE \
 42 	((obj), E_TYPE_TASK_SHELL_CONTENT, ETaskShellContentPrivate))
 43 
 44 #define E_TASK_TABLE_DEFAULT_STATE \
 45 	"<?xml version=\"1.0\"?>" \
 46 	"<ETableState>" \
 47 	"  <column source=\"13\"/>" \
 48 	"  <column source=\"14\"/>" \
 49 	"  <column source=\"9\"/>" \
 50 	"  <column source=\"5\"/>" \
 51 	"  <grouping/>" \
 52 	"</ETableState>"
 53 
 54 struct _ETaskShellContentPrivate {
 55 	GtkWidget *paned;
 56 	GtkWidget *task_table;
 57 	GtkWidget *preview_pane;
 58 
 59 	ECalModel *task_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 	ETaskShellContent,
 77 	e_task_shell_content,
 78 	E_TYPE_SHELL_CONTENT,
 79 	0,
 80 	G_IMPLEMENT_INTERFACE_DYNAMIC (
 81 		GTK_TYPE_ORIENTABLE, NULL))
 82 
 83 static void
 84 task_shell_content_display_view_cb (ETaskShellContent *task_shell_content,
 85                                     GalView *gal_view)
 86 {
 87 	ETaskTable *task_table;
 88 
 89 	if (!GAL_IS_VIEW_ETABLE (gal_view))
 90 		return;
 91 
 92 	task_table = e_task_shell_content_get_task_table (task_shell_content);
 93 
 94 	gal_view_etable_attach_table (
 95 		GAL_VIEW_ETABLE (gal_view), E_TABLE (task_table));
 96 }
 97 
 98 static void
 99 task_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 task_shell_content_table_drag_data_get_cb (ETaskShellContent *task_shell_content,
139                                            gint row,
140                                            gint col,
141                                            GdkDragContext *context,
142                                            GtkSelectionData *selection_data,
143                                            guint info,
144                                            guint time)
145 {
146 	ETaskTable *task_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 	task_table = e_task_shell_content_get_task_table (task_shell_content);
160 
161 	foreach_data.model = e_task_table_get_model (task_table);
162 	foreach_data.list = NULL;
163 
164 	e_table_selected_row_foreach (
165 		E_TABLE (task_table),
166 		task_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 task_shell_content_table_drag_data_delete_cb (ETaskShellContent *task_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 tasks.  There is no such information
186 	 * which event has been moved and which not, so skip this method. */
187 }
188 
189 static void
190 task_shell_content_cursor_change_cb (ETaskShellContent *task_shell_content,
191                                      gint row,
192                                      ETable *table)
193 {
194 	ECalComponentPreview *task_preview;
195 	ECalModel *task_model;
196 	ECalModelComponent *comp_data;
197 	EPreviewPane *preview_pane;
198 	EWebView *web_view;
199 	const gchar *uid;
200 
201 	task_model = e_task_shell_content_get_task_model (task_shell_content);
202 	preview_pane = e_task_shell_content_get_preview_pane (task_shell_content);
203 
204 	web_view = e_preview_pane_get_web_view (preview_pane);
205 	task_preview = E_CAL_COMPONENT_PREVIEW (web_view);
206 
207 	if (e_table_selected_count (table) != 1) {
208 		if (task_shell_content->priv->preview_visible)
209 			e_cal_component_preview_clear (task_preview);
210 		return;
211 	}
212 
213 	row = e_table_get_cursor_row (table);
214 	comp_data = e_cal_model_get_component_at (task_model, row);
215 
216 	if (task_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 			task_preview, comp_data->client, comp,
224 			e_cal_model_get_timezone (task_model),
225 			e_cal_model_get_use_24_hour_format (task_model));
226 
227 		g_object_unref (comp);
228 	}
229 
230 	uid = icalcomponent_get_uid (comp_data->icalcomp);
231 	g_free (task_shell_content->priv->current_uid);
232 	task_shell_content->priv->current_uid = g_strdup (uid);
233 }
234 
235 static void
236 task_shell_content_selection_change_cb (ETaskShellContent *task_shell_content,
237                                         ETable *table)
238 {
239 	ECalComponentPreview *task_preview;
240 	EPreviewPane *preview_pane;
241 	EWebView *web_view;
242 
243 	preview_pane = e_task_shell_content_get_preview_pane (task_shell_content);
244 
245 	web_view = e_preview_pane_get_web_view (preview_pane);
246 	task_preview = E_CAL_COMPONENT_PREVIEW (web_view);
247 
248 	if (e_table_selected_count (table) != 1)
249 		e_cal_component_preview_clear (task_preview);
250 }
251 
252 static void
253 task_shell_content_model_row_changed_cb (ETaskShellContent *task_shell_content,
254                                          gint row,
255                                          ETableModel *model)
256 {
257 	ECalModelComponent *comp_data;
258 	ETaskTable *task_table;
259 	const gchar *current_uid;
260 	const gchar *uid;
261 
262 	current_uid = task_shell_content->priv->current_uid;
263 	if (current_uid == NULL)
264 		return;
265 
266 	comp_data = e_cal_model_get_component_at (E_CAL_MODEL (model), row);
267 	if (comp_data == NULL)
268 		return;
269 
270 	uid = icalcomponent_get_uid (comp_data->icalcomp);
271 	if (g_strcmp0 (uid, current_uid) != 0)
272 		return;
273 
274 	task_table = e_task_shell_content_get_task_table (task_shell_content);
275 
276 	task_shell_content_cursor_change_cb (
277 		task_shell_content, 0, E_TABLE (task_table));
278 }
279 
280 static void
281 task_shell_content_restore_state_cb (EShellWindow *shell_window,
282                                      EShellView *shell_view,
283                                      EShellContent *shell_content)
284 {
285 	ETaskShellContentPrivate *priv;
286 	GSettings *settings;
287 
288 	priv = E_TASK_SHELL_CONTENT_GET_PRIVATE (shell_content);
289 
290 	/* Bind GObject properties to settings keys. */
291 
292 	settings = g_settings_new ("org.gnome.evolution.calendar");
293 
294 	g_settings_bind (
295 		settings, "task-hpane-position",
296 		priv->paned, "hposition",
297 		G_SETTINGS_BIND_DEFAULT);
298 
299 	g_settings_bind (
300 		settings, "task-vpane-position",
301 		priv->paned, "vposition",
302 		G_SETTINGS_BIND_DEFAULT);
303 
304 	g_object_unref (settings);
305 }
306 
307 static GtkOrientation
308 task_shell_content_get_orientation (ETaskShellContent *task_shell_content)
309 {
310 	return task_shell_content->priv->orientation;
311 }
312 
313 static void
314 task_shell_content_set_orientation (ETaskShellContent *task_shell_content,
315                                     GtkOrientation orientation)
316 {
317 	if (task_shell_content->priv->orientation == orientation)
318 		return;
319 
320 	task_shell_content->priv->orientation = orientation;
321 
322 	g_object_notify (G_OBJECT (task_shell_content), "orientation");
323 }
324 
325 static void
326 task_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 			task_shell_content_set_orientation (
334 				E_TASK_SHELL_CONTENT (object),
335 				g_value_get_enum (value));
336 			return;
337 
338 		case PROP_PREVIEW_VISIBLE:
339 			e_task_shell_content_set_preview_visible (
340 				E_TASK_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 task_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_task_shell_content_get_task_model (
359 				E_TASK_SHELL_CONTENT (object)));
360 			return;
361 
362 		case PROP_ORIENTATION:
363 			g_value_set_enum (
364 				value,
365 				task_shell_content_get_orientation (
366 				E_TASK_SHELL_CONTENT (object)));
367 			return;
368 
369 		case PROP_PREVIEW_VISIBLE:
370 			g_value_set_boolean (
371 				value,
372 				e_task_shell_content_get_preview_visible (
373 				E_TASK_SHELL_CONTENT (object)));
374 			return;
375 	}
376 
377 	G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
378 }
379 
380 static void
381 task_shell_content_dispose (GObject *object)
382 {
383 	ETaskShellContentPrivate *priv;
384 
385 	priv = E_TASK_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->task_table != NULL) {
393 		g_object_unref (priv->task_table);
394 		priv->task_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->task_model != NULL) {
403 		g_object_unref (priv->task_model);
404 		priv->task_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_task_shell_content_parent_class)->dispose (object);
414 }
415 
416 static void
417 task_shell_content_finalize (GObject *object)
418 {
419 	ETaskShellContentPrivate *priv;
420 
421 	priv = E_TASK_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_task_shell_content_parent_class)->finalize (object);
427 }
428 
429 static void
430 task_shell_content_constructed (GObject *object)
431 {
432 	ETaskShellContentPrivate *priv;
433 	EShell *shell;
434 	EShellView *shell_view;
435 	EShellWindow *shell_window;
436 	EShellContent *shell_content;
437 	EShellTaskbar *shell_taskbar;
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_TASK_SHELL_CONTENT_GET_PRIVATE (object);
447 
448 	/* Chain up to parent's constructed() method. */
449 	G_OBJECT_CLASS (e_task_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->task_model = e_cal_model_tasks_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_task_table_new (shell_view, priv->task_model);
488 	gtk_container_add (GTK_CONTAINER (container), widget);
489 	priv->task_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 task table. */
513 
514 	e_table_set_state (
515 		E_TABLE (priv->task_table), E_TASK_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->task_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->task_table, "table-drag-data-get",
531 		G_CALLBACK (task_shell_content_table_drag_data_get_cb),
532 		object);
533 
534 	g_signal_connect_swapped (
535 		priv->task_table, "table-drag-data-delete",
536 		G_CALLBACK (task_shell_content_table_drag_data_delete_cb),
537 		object);
538 
539 	g_signal_connect_swapped (
540 		priv->task_table, "cursor-change",
541 		G_CALLBACK (task_shell_content_cursor_change_cb),
542 		object);
543 
544 	g_signal_connect_swapped (
545 		priv->task_table, "selection-change",
546 		G_CALLBACK (task_shell_content_selection_change_cb),
547 		object);
548 
549 	g_signal_connect_swapped (
550 		priv->task_model, "model-row-changed",
551 		G_CALLBACK (task_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 (task_shell_content_display_view_cb),
560 		object);
561 	priv->view_instance = view_instance;
562 
563 	/* Do this last so e_task_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::tasks",
571 		G_CALLBACK (task_shell_content_restore_state_cb),
572 		shell_content);
573 }
574 
575 static guint32
576 task_shell_content_check_state (EShellContent *shell_content)
577 {
578 	ETaskShellContent *task_shell_content;
579 	ETaskTable *task_table;
580 	GSList *list, *iter;
581 	gboolean assignable = TRUE;
582 	gboolean editable = TRUE;
583 	gboolean has_url = FALSE;
584 	gint n_selected;
585 	gint n_complete = 0;
586 	gint n_incomplete = 0;
587 	guint32 state = 0;
588 
589 	task_shell_content = E_TASK_SHELL_CONTENT (shell_content);
590 	task_table = e_task_shell_content_get_task_table (task_shell_content);
591 
592 	n_selected = e_table_selected_count (E_TABLE (task_table));
593 
594 	list = e_task_table_get_selected (task_table);
595 	for (iter = list; iter != NULL; iter = iter->next) {
596 		ECalModelComponent *comp_data = iter->data;
597 		icalproperty *prop;
598 		const gchar *cap;
599 		gboolean read_only;
600 
601 		read_only = e_client_is_readonly (E_CLIENT (comp_data->client));
602 		editable &= !read_only;
603 
604 		cap = CAL_STATIC_CAPABILITY_NO_TASK_ASSIGNMENT;
605 		if (e_client_check_capability (E_CLIENT (comp_data->client), cap))
606 			assignable = FALSE;
607 
608 		cap = CAL_STATIC_CAPABILITY_NO_CONV_TO_ASSIGN_TASK;
609 		if (e_client_check_capability (E_CLIENT (comp_data->client), cap))
610 			assignable = FALSE;
611 
612 		prop = icalcomponent_get_first_property (
613 			comp_data->icalcomp, ICAL_URL_PROPERTY);
614 		has_url |= (prop != NULL);
615 
616 		prop = icalcomponent_get_first_property (
617 			comp_data->icalcomp, ICAL_COMPLETED_PROPERTY);
618 		if (prop != NULL)
619 			n_complete++;
620 		else
621 			n_incomplete++;
622 	}
623 	g_slist_free (list);
624 
625 	if (n_selected == 1)
626 		state |= E_TASK_SHELL_CONTENT_SELECTION_SINGLE;
627 	if (n_selected > 1)
628 		state |= E_TASK_SHELL_CONTENT_SELECTION_MULTIPLE;
629 	if (assignable)
630 		state |= E_TASK_SHELL_CONTENT_SELECTION_CAN_ASSIGN;
631 	if (editable)
632 		state |= E_TASK_SHELL_CONTENT_SELECTION_CAN_EDIT;
633 	if (n_complete > 0)
634 		state |= E_TASK_SHELL_CONTENT_SELECTION_HAS_COMPLETE;
635 	if (n_incomplete > 0)
636 		state |= E_TASK_SHELL_CONTENT_SELECTION_HAS_INCOMPLETE;
637 	if (has_url)
638 		state |= E_TASK_SHELL_CONTENT_SELECTION_HAS_URL;
639 
640 	return state;
641 }
642 
643 static void
644 task_shell_content_focus_search_results (EShellContent *shell_content)
645 {
646 	ETaskShellContentPrivate *priv;
647 
648 	priv = E_TASK_SHELL_CONTENT_GET_PRIVATE (shell_content);
649 
650 	gtk_widget_grab_focus (priv->task_table);
651 }
652 
653 static void
654 e_task_shell_content_class_init (ETaskShellContentClass *class)
655 {
656 	GObjectClass *object_class;
657 	EShellContentClass *shell_content_class;
658 
659 	g_type_class_add_private (class, sizeof (ETaskShellContentPrivate));
660 
661 	object_class = G_OBJECT_CLASS (class);
662 	object_class->set_property = task_shell_content_set_property;
663 	object_class->get_property = task_shell_content_get_property;
664 	object_class->dispose = task_shell_content_dispose;
665 	object_class->finalize = task_shell_content_finalize;
666 	object_class->constructed = task_shell_content_constructed;
667 
668 	shell_content_class = E_SHELL_CONTENT_CLASS (class);
669 	shell_content_class->check_state = task_shell_content_check_state;
670 	shell_content_class->focus_search_results =
671 		task_shell_content_focus_search_results;
672 
673 	g_object_class_install_property (
674 		object_class,
675 		PROP_MODEL,
676 		g_param_spec_object (
677 			"model",
678 			"Model",
679 			"The task table model",
680 			E_TYPE_CAL_MODEL,
681 			G_PARAM_READABLE));
682 
683 	g_object_class_install_property (
684 		object_class,
685 		PROP_PREVIEW_VISIBLE,
686 		g_param_spec_boolean (
687 			"preview-visible",
688 			"Preview is Visible",
689 			"Whether the preview pane is visible",
690 			TRUE,
691 			G_PARAM_READWRITE |
692 			G_PARAM_CONSTRUCT));
693 
694 	g_object_class_override_property (
695 		object_class, PROP_ORIENTATION, "orientation");
696 }
697 
698 static void
699 e_task_shell_content_class_finalize (ETaskShellContentClass *class)
700 {
701 }
702 
703 static void
704 e_task_shell_content_init (ETaskShellContent *task_shell_content)
705 {
706 	task_shell_content->priv =
707 		E_TASK_SHELL_CONTENT_GET_PRIVATE (task_shell_content);
708 
709 	/* Postpone widget construction until we have a shell view. */
710 }
711 
712 void
713 e_task_shell_content_type_register (GTypeModule *type_module)
714 {
715 	/* XXX G_DEFINE_DYNAMIC_TYPE declares a static type registration
716 	 *     function, so we have to wrap it with a public function in
717 	 *     order to register types from a separate compilation unit. */
718 	e_task_shell_content_register_type (type_module);
719 }
720 
721 GtkWidget *
722 e_task_shell_content_new (EShellView *shell_view)
723 {
724 	g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL);
725 
726 	return g_object_new (
727 		E_TYPE_TASK_SHELL_CONTENT,
728 		"shell-view", shell_view, NULL);
729 }
730 
731 ECalModel *
732 e_task_shell_content_get_task_model (ETaskShellContent *task_shell_content)
733 {
734 	g_return_val_if_fail (
735 		E_IS_TASK_SHELL_CONTENT (task_shell_content), NULL);
736 
737 	return task_shell_content->priv->task_model;
738 }
739 
740 ETaskTable *
741 e_task_shell_content_get_task_table (ETaskShellContent *task_shell_content)
742 {
743 	g_return_val_if_fail (
744 		E_IS_TASK_SHELL_CONTENT (task_shell_content), NULL);
745 
746 	return E_TASK_TABLE (task_shell_content->priv->task_table);
747 }
748 
749 EPreviewPane *
750 e_task_shell_content_get_preview_pane (ETaskShellContent *task_shell_content)
751 {
752 	g_return_val_if_fail (
753 		E_IS_TASK_SHELL_CONTENT (task_shell_content), NULL);
754 
755 	return E_PREVIEW_PANE (task_shell_content->priv->preview_pane);
756 }
757 
758 gboolean
759 e_task_shell_content_get_preview_visible (ETaskShellContent *task_shell_content)
760 {
761 	g_return_val_if_fail (
762 		E_IS_TASK_SHELL_CONTENT (task_shell_content), FALSE);
763 
764 	return task_shell_content->priv->preview_visible;
765 }
766 
767 void
768 e_task_shell_content_set_preview_visible (ETaskShellContent *task_shell_content,
769                                           gboolean preview_visible)
770 {
771 	g_return_if_fail (E_IS_TASK_SHELL_CONTENT (task_shell_content));
772 
773 	if (task_shell_content->priv->preview_visible == preview_visible)
774 		return;
775 
776 	task_shell_content->priv->preview_visible = preview_visible;
777 
778 	if (preview_visible && task_shell_content->priv->preview_pane) {
779 		task_shell_content_cursor_change_cb (
780 			task_shell_content, 0,
781 			E_TABLE (task_shell_content->priv->task_table));
782 	}
783 
784 	g_object_notify (G_OBJECT (task_shell_content), "preview-visible");
785 }
786 
787 EShellSearchbar *
788 e_task_shell_content_get_searchbar (ETaskShellContent *task_shell_content)
789 {
790 	EShellView *shell_view;
791 	EShellContent *shell_content;
792 	GtkWidget *widget;
793 
794 	g_return_val_if_fail (
795 		E_IS_TASK_SHELL_CONTENT (task_shell_content), NULL);
796 
797 	shell_content = E_SHELL_CONTENT (task_shell_content);
798 	shell_view = e_shell_content_get_shell_view (shell_content);
799 	widget = e_shell_view_get_searchbar (shell_view);
800 
801 	return E_SHELL_SEARCHBAR (widget);
802 }
803 
804 GalViewInstance *
805 e_task_shell_content_get_view_instance (ETaskShellContent *task_shell_content)
806 {
807 	g_return_val_if_fail (
808 		E_IS_TASK_SHELL_CONTENT (task_shell_content), NULL);
809 
810 	return task_shell_content->priv->view_instance;
811 }