evolution-3.6.4/mail/e-mail-view.c

No issues found

Incomplete coverage

Tool Failure ID Location Function Message Data
clang-analyzer no-output-found e-mail-view.c Message(text='Unable to locate XML output from invoke-clang-analyzer') None
clang-analyzer no-output-found e-mail-view.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  * This program is free software; you can redistribute it and/or
  3  * modify it under the terms of the GNU Lesser General Public
  4  * License as published by the Free Software Foundation; either
  5  * version 2 of the License, or (at your option) version 3.
  6  *
  7  * This program is distributed in the hope that it will be useful,
  8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 10  * Lesser General Public License for more details.
 11  *
 12  * 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  * Authors:
 17  *		Srinivasa Ragavan <sragavan@gnome.org>
 18  *
 19  * Copyright (C) 2010 Intel corporation. (www.intel.com)
 20  *
 21  */
 22 
 23 #ifdef HAVE_CONFIG_H
 24 #include <config.h>
 25 #endif
 26 
 27 #include "e-mail-view.h"
 28 
 29 #include <glib/gi18n-lib.h>
 30 
 31 #define E_MAIL_VIEW_GET_PRIVATE(obj) \
 32 	(G_TYPE_INSTANCE_GET_PRIVATE \
 33 	((obj), E_TYPE_MAIL_VIEW, EMailViewPrivate))
 34 
 35 struct _EMailViewPrivate {
 36 	EShellView *shell_view;
 37 	GtkOrientation orientation;
 38 	EMailView *previous_view;
 39 
 40 	guint preview_visible : 1;
 41 	guint show_deleted    : 1;
 42 };
 43 
 44 enum {
 45 	PROP_0,
 46 	PROP_ORIENTATION,
 47 	PROP_PREVIEW_VISIBLE,
 48 	PROP_PREVIOUS_VIEW,
 49 	PROP_SHELL_VIEW,
 50 	PROP_SHOW_DELETED
 51 };
 52 
 53 enum {
 54 	PANE_CLOSE,
 55 	VIEW_CHANGED,
 56 	OPEN_MAIL,
 57 	LAST_SIGNAL
 58 };
 59 
 60 static guint signals[LAST_SIGNAL];
 61 
 62 G_DEFINE_TYPE (EMailView, e_mail_view, GTK_TYPE_VBOX)
 63 
 64 static void
 65 mail_view_set_shell_view (EMailView *view,
 66                           EShellView *shell_view)
 67 {
 68 	g_return_if_fail (E_IS_SHELL_VIEW (shell_view));
 69 	g_return_if_fail (view->priv->shell_view == NULL);
 70 
 71 	view->priv->shell_view = g_object_ref (shell_view);
 72 }
 73 
 74 static void
 75 mail_view_set_property (GObject *object,
 76                         guint property_id,
 77                         const GValue *value,
 78                         GParamSpec *pspec)
 79 {
 80 	switch (property_id) {
 81 		case PROP_ORIENTATION:
 82 			e_mail_view_set_orientation (
 83 				E_MAIL_VIEW (object),
 84 				g_value_get_enum (value));
 85 			return;
 86 
 87 		case PROP_PREVIEW_VISIBLE:
 88 			e_mail_view_set_preview_visible (
 89 				E_MAIL_VIEW (object),
 90 				g_value_get_boolean (value));
 91 			return;
 92 
 93 		case PROP_PREVIOUS_VIEW:
 94 			e_mail_view_set_previous_view (
 95 				E_MAIL_VIEW (object),
 96 				g_value_get_object (value));
 97 			return;
 98 
 99 		case PROP_SHELL_VIEW:
100 			mail_view_set_shell_view (
101 				E_MAIL_VIEW (object),
102 				g_value_get_object (value));
103 			return;
104 
105 		case PROP_SHOW_DELETED:
106 			e_mail_view_set_show_deleted (
107 				E_MAIL_VIEW (object),
108 				g_value_get_boolean (value));
109 			return;
110 	}
111 
112 	G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
113 }
114 
115 static void
116 mail_view_get_property (GObject *object,
117                         guint property_id,
118                         GValue *value,
119                         GParamSpec *pspec)
120 {
121 	switch (property_id) {
122 		case PROP_ORIENTATION:
123 			g_value_set_enum (
124 				value, e_mail_view_get_orientation (
125 				E_MAIL_VIEW (object)));
126 			return;
127 
128 		case PROP_PREVIEW_VISIBLE:
129 			g_value_set_boolean (
130 				value, e_mail_view_get_preview_visible (
131 				E_MAIL_VIEW (object)));
132 			return;
133 
134 		case PROP_PREVIOUS_VIEW:
135 			g_value_set_object (
136 				value, e_mail_view_get_previous_view (
137 				E_MAIL_VIEW (object)));
138 			return;
139 
140 		case PROP_SHELL_VIEW:
141 			g_value_set_object (
142 				value, e_mail_view_get_shell_view (
143 				E_MAIL_VIEW (object)));
144 			return;
145 
146 		case PROP_SHOW_DELETED:
147 			g_value_set_boolean (
148 				value, e_mail_view_get_show_deleted (
149 				E_MAIL_VIEW (object)));
150 			return;
151 	}
152 
153 	G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
154 }
155 
156 static void
157 mail_view_dispose (GObject *object)
158 {
159 	EMailViewPrivate *priv;
160 
161 	priv = E_MAIL_VIEW_GET_PRIVATE (object);
162 
163 	if (priv->shell_view != NULL) {
164 		g_object_unref (priv->shell_view);
165 		priv->shell_view = NULL;
166 	}
167 
168 	if (priv->previous_view != NULL) {
169 		g_object_unref (priv->previous_view);
170 		priv->previous_view = NULL;
171 	}
172 
173 	/* Chain up to parent's dispose() method. */
174 	G_OBJECT_CLASS (e_mail_view_parent_class)->dispose (object);
175 }
176 
177 static GtkOrientation
178 mail_view_get_orientation (EMailView *view)
179 {
180 	return view->priv->orientation;
181 }
182 
183 static void
184 mail_view_set_orientation (EMailView *view,
185                            GtkOrientation orientation)
186 {
187 	if (view->priv->orientation == orientation)
188 		return;
189 
190 	view->priv->orientation = orientation;
191 
192 	g_object_notify (G_OBJECT (view), "orientation");
193 
194 	e_mail_view_update_view_instance (view);
195 }
196 
197 static gboolean
198 mail_view_get_preview_visible (EMailView *view)
199 {
200 	return view->priv->preview_visible;
201 }
202 
203 static void
204 mail_view_set_preview_visible (EMailView *view,
205                                gboolean preview_visible)
206 {
207 	if (view->priv->preview_visible == preview_visible)
208 		return;
209 
210 	view->priv->preview_visible = preview_visible;
211 
212 	g_object_notify (G_OBJECT (view), "preview-visible");
213 }
214 
215 static gboolean
216 mail_view_get_show_deleted (EMailView *view)
217 {
218 	return view->priv->show_deleted;
219 }
220 
221 static void
222 mail_view_set_show_deleted (EMailView *view,
223                             gboolean show_deleted)
224 {
225 	if (view->priv->show_deleted == show_deleted)
226 		return;
227 
228 	view->priv->show_deleted = show_deleted;
229 
230 	g_object_notify (G_OBJECT (view), "show-deleted");
231 }
232 
233 static void
234 e_mail_view_class_init (EMailViewClass *class)
235 {
236 	GObjectClass *object_class;
237 
238 	g_type_class_add_private (class, sizeof (EMailViewPrivate));
239 
240 	object_class = G_OBJECT_CLASS (class);
241 	object_class->set_property = mail_view_set_property;
242 	object_class->get_property = mail_view_get_property;
243 	object_class->dispose = mail_view_dispose;
244 
245 	class->get_orientation = mail_view_get_orientation;
246 	class->set_orientation = mail_view_set_orientation;
247 	class->get_preview_visible = mail_view_get_preview_visible;
248 	class->set_preview_visible = mail_view_set_preview_visible;
249 	class->get_show_deleted = mail_view_get_show_deleted;
250 	class->set_show_deleted = mail_view_set_show_deleted;
251 
252 	signals[PANE_CLOSE] = g_signal_new (
253 		"pane-close",
254 		G_OBJECT_CLASS_TYPE (object_class),
255 		G_SIGNAL_RUN_FIRST,
256 		G_STRUCT_OFFSET (EMailViewClass , pane_close),
257 		NULL, NULL,
258 		g_cclosure_marshal_VOID__VOID,
259 		G_TYPE_NONE, 0);
260 
261 	signals[VIEW_CHANGED] = g_signal_new (
262 		"view-changed",
263 		G_OBJECT_CLASS_TYPE (object_class),
264 		G_SIGNAL_RUN_FIRST,
265 		G_STRUCT_OFFSET (EMailViewClass , view_changed),
266 		NULL, NULL,
267 		g_cclosure_marshal_VOID__VOID,
268 		G_TYPE_NONE, 0);
269 
270 	signals[OPEN_MAIL] = g_signal_new (
271 		"open-mail",
272 		G_OBJECT_CLASS_TYPE (object_class),
273 		G_SIGNAL_RUN_FIRST,
274 		G_STRUCT_OFFSET (EMailViewClass , open_mail),
275 		NULL, NULL,
276 		g_cclosure_marshal_VOID__STRING,
277 		G_TYPE_NONE, 1, G_TYPE_STRING);
278 
279 	g_object_class_install_property (
280 		object_class,
281 		PROP_ORIENTATION,
282 		g_param_spec_enum (
283 			"orientation",
284 			"Orientation",
285 			NULL,
286 			GTK_TYPE_ORIENTATION,
287 			GTK_ORIENTATION_HORIZONTAL,
288 			G_PARAM_READWRITE));
289 
290 	g_object_class_install_property (
291 		object_class,
292 		PROP_PREVIEW_VISIBLE,
293 		g_param_spec_boolean (
294 			"preview-visible",
295 			"Preview Visible",
296 			NULL,
297 			FALSE,
298 			G_PARAM_READWRITE));
299 
300 	g_object_class_install_property (
301 		object_class,
302 		PROP_PREVIOUS_VIEW,
303 		g_param_spec_object (
304 			"previous-view",
305 			"Previous View",
306 			NULL,
307 			E_TYPE_MAIL_VIEW,
308 			G_PARAM_READWRITE));
309 
310 	g_object_class_install_property (
311 		object_class,
312 		PROP_SHELL_VIEW,
313 		g_param_spec_object (
314 			"shell-view",
315 			"Shell View",
316 			NULL,
317 			E_TYPE_SHELL_VIEW,
318 			G_PARAM_READWRITE |
319 			G_PARAM_CONSTRUCT_ONLY));
320 
321 	g_object_class_install_property (
322 		object_class,
323 		PROP_SHOW_DELETED,
324 		g_param_spec_boolean (
325 			"show-deleted",
326 			"Show Deleted",
327 			NULL,
328 			FALSE,
329 			G_PARAM_READWRITE));
330 }
331 
332 static void
333 e_mail_view_init (EMailView *view)
334 {
335 	view->priv = E_MAIL_VIEW_GET_PRIVATE (view);
336 }
337 
338 EShellView *
339 e_mail_view_get_shell_view (EMailView *view)
340 {
341 	g_return_val_if_fail (E_IS_MAIL_VIEW (view), NULL);
342 
343 	return view->priv->shell_view;
344 }
345 
346 void
347 e_mail_view_update_view_instance (EMailView *view)
348 {
349 	EMailViewClass *class;
350 
351 	g_return_if_fail (E_IS_MAIL_VIEW (view));
352 
353 	class = E_MAIL_VIEW_GET_CLASS (view);
354 	g_return_if_fail (class->update_view_instance != NULL);
355 
356 	class->update_view_instance (view);
357 }
358 
359 GalViewInstance *
360 e_mail_view_get_view_instance (EMailView *view)
361 {
362 	EMailViewClass *class;
363 
364 	g_return_val_if_fail (E_IS_MAIL_VIEW (view), NULL);
365 
366 	class = E_MAIL_VIEW_GET_CLASS (view);
367 	g_return_val_if_fail (class->get_view_instance != NULL, NULL);
368 
369 	return class->get_view_instance (view);
370 }
371 
372 void
373 e_mail_view_set_search_strings (EMailView *view,
374                                 GSList *search_strings)
375 {
376 	EMailViewClass *class;
377 
378 	g_return_if_fail (E_IS_MAIL_VIEW (view));
379 
380 	class = E_MAIL_VIEW_GET_CLASS (view);
381 	g_return_if_fail (class->set_search_strings != NULL);
382 
383 	class->set_search_strings (view, search_strings);
384 }
385 
386 GtkOrientation
387 e_mail_view_get_orientation (EMailView *view)
388 {
389 	EMailViewClass *class;
390 
391 	g_return_val_if_fail (E_IS_MAIL_VIEW (view), 0);
392 
393 	class = E_MAIL_VIEW_GET_CLASS (view);
394 	g_return_val_if_fail (class->get_orientation != NULL, 0);
395 
396 	return class->get_orientation (view);
397 }
398 
399 void
400 e_mail_view_set_orientation (EMailView *view,
401                              GtkOrientation orientation)
402 {
403 	EMailViewClass *class;
404 
405 	g_return_if_fail (E_IS_MAIL_VIEW (view));
406 
407 	class = E_MAIL_VIEW_GET_CLASS (view);
408 	g_return_if_fail (class->set_orientation != NULL);
409 
410 	class->set_orientation (view, orientation);
411 }
412 
413 gboolean
414 e_mail_view_get_preview_visible (EMailView *view)
415 {
416 	EMailViewClass *class;
417 
418 	g_return_val_if_fail (E_IS_MAIL_VIEW (view), FALSE);
419 
420 	class = E_MAIL_VIEW_GET_CLASS (view);
421 	g_return_val_if_fail (class->get_preview_visible != NULL, FALSE);
422 
423 	return class->get_preview_visible (view);
424 }
425 
426 void
427 e_mail_view_set_preview_visible (EMailView *view,
428                                  gboolean visible)
429 {
430 	EMailViewClass *class;
431 
432 	g_return_if_fail (E_IS_MAIL_VIEW (view));
433 
434 	class = E_MAIL_VIEW_GET_CLASS (view);
435 	g_return_if_fail (class->set_preview_visible != NULL);
436 
437 	class->set_preview_visible (view, visible);
438 }
439 
440 EMailView *
441 e_mail_view_get_previous_view (EMailView *view)
442 {
443 	g_return_val_if_fail (E_IS_MAIL_VIEW (view), NULL);
444 
445 	return view->priv->previous_view;
446 }
447 
448 void
449 e_mail_view_set_previous_view (EMailView *view,
450                                EMailView *previous_view)
451 {
452 	g_return_if_fail (E_IS_MAIL_VIEW (view));
453 
454 	if (view->priv->previous_view == previous_view)
455 		return;
456 
457 	if (previous_view != NULL) {
458 		g_return_if_fail (E_IS_MAIL_VIEW (previous_view));
459 		g_object_ref (previous_view);
460 	}
461 
462 	if (view->priv->previous_view != NULL)
463 		g_object_unref (view->priv->previous_view);
464 
465 	view->priv->previous_view = previous_view;
466 
467 	g_object_notify (G_OBJECT (view), "previous-view");
468 }
469 
470 gboolean
471 e_mail_view_get_show_deleted (EMailView *view)
472 {
473 	EMailViewClass *class;
474 
475 	g_return_val_if_fail (E_IS_MAIL_VIEW (view), FALSE);
476 
477 	class = E_MAIL_VIEW_GET_CLASS (view);
478 	g_return_val_if_fail (class->get_show_deleted != NULL, FALSE);
479 
480 	return class->get_show_deleted (view);
481 }
482 
483 void
484 e_mail_view_set_show_deleted (EMailView *view,
485                               gboolean show_deleted)
486 {
487 	EMailViewClass *class;
488 
489 	g_return_if_fail (E_IS_MAIL_VIEW (view));
490 
491 	class = E_MAIL_VIEW_GET_CLASS (view);
492 	g_return_if_fail (class->set_show_deleted != NULL);
493 
494 	class->set_show_deleted (view, show_deleted);
495 }