evolution-3.6.4/modules/itip-formatter/e-conflict-search-selector.c

No issues found

  1 /*
  2  * e-conflict-search-selector.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 
 19 #include "e-conflict-search-selector.h"
 20 
 21 #include "e-source-conflict-search.h"
 22 
 23 /* This forces the GType to be registered in a way that
 24  * avoids a "statement with no effect" compiler warning. */
 25 #define REGISTER_TYPE(type) \
 26 	(g_type_class_unref (g_type_class_ref (type)))
 27 
 28 G_DEFINE_TYPE (
 29 	EConflictSearchSelector,
 30 	e_conflict_search_selector,
 31 	E_TYPE_SOURCE_SELECTOR)
 32 
 33 static gboolean
 34 conflict_search_selector_get_source_selected (ESourceSelector *selector,
 35                                            ESource *source)
 36 {
 37 	ESourceConflictSearch *extension;
 38 	const gchar *extension_name;
 39 
 40 	/* Make sure this source is a calendar. */
 41 	extension_name = e_source_selector_get_extension_name (selector);
 42 	if (!e_source_has_extension (source, extension_name))
 43 		return FALSE;
 44 
 45 	extension_name = E_SOURCE_EXTENSION_CONFLICT_SEARCH;
 46 	extension = e_source_get_extension (source, extension_name);
 47 	g_return_val_if_fail (E_IS_SOURCE_CONFLICT_SEARCH (extension), FALSE);
 48 
 49 	return e_source_conflict_search_get_include_me (extension);
 50 }
 51 
 52 static void
 53 conflict_search_selector_set_source_selected (ESourceSelector *selector,
 54                                            ESource *source,
 55                                            gboolean selected)
 56 {
 57 	ESourceConflictSearch *extension;
 58 	const gchar *extension_name;
 59 
 60 	/* Make sure this source is a calendar. */
 61 	extension_name = e_source_selector_get_extension_name (selector);
 62 	if (!e_source_has_extension (source, extension_name))
 63 		return;
 64 
 65 	extension_name = E_SOURCE_EXTENSION_CONFLICT_SEARCH;
 66 	extension = e_source_get_extension (source, extension_name);
 67 	g_return_if_fail (E_IS_SOURCE_CONFLICT_SEARCH (extension));
 68 
 69 	if (selected != e_source_conflict_search_get_include_me (extension)) {
 70 		e_source_conflict_search_set_include_me (extension, selected);
 71 		e_source_selector_queue_write (selector, source);
 72 	}
 73 }
 74 
 75 static void
 76 e_conflict_search_selector_class_init (EConflictSearchSelectorClass *class)
 77 {
 78 	ESourceSelectorClass *source_selector_class;
 79 
 80 	source_selector_class = E_SOURCE_SELECTOR_CLASS (class);
 81 	source_selector_class->get_source_selected =
 82 				conflict_search_selector_get_source_selected;
 83 	source_selector_class->set_source_selected =
 84 				conflict_search_selector_set_source_selected;
 85 
 86 	REGISTER_TYPE (E_TYPE_SOURCE_CONFLICT_SEARCH);
 87 }
 88 
 89 static void
 90 e_conflict_search_selector_init (EConflictSearchSelector *selector)
 91 {
 92 }
 93 
 94 GtkWidget *
 95 e_conflict_search_selector_new (ESourceRegistry *registry)
 96 {
 97 	g_return_val_if_fail (E_IS_SOURCE_REGISTRY (registry), NULL);
 98 
 99 	return g_object_new (
100 		E_TYPE_CONFLICT_SEARCH_SELECTOR,
101 		"extension-name", E_SOURCE_EXTENSION_CALENDAR,
102 		"registry", registry, NULL);
103 }