evolution-3.6.4/widgets/misc/e-source-config-backend.c

No issues found

  1 /*
  2  * e-source-config-backend.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-source-config-backend.h"
 20 
 21 G_DEFINE_TYPE (
 22 	ESourceConfigBackend,
 23 	e_source_config_backend,
 24 	E_TYPE_EXTENSION)
 25 
 26 static gboolean
 27 source_config_backend_allow_creation (ESourceConfigBackend *backend)
 28 {
 29 	return TRUE;
 30 }
 31 
 32 static void
 33 source_config_backend_insert_widgets (ESourceConfigBackend *backend,
 34                                       ESource *scratch_source)
 35 {
 36 	/* does nothing */
 37 }
 38 
 39 static gboolean
 40 source_config_backend_check_complete (ESourceConfigBackend *backend,
 41                                       ESource *scratch_source)
 42 {
 43 	return TRUE;
 44 }
 45 
 46 static void
 47 source_config_backend_commit_changes (ESourceConfigBackend *backend,
 48                                       ESource *scratch_source)
 49 {
 50 	/* does nothing */
 51 }
 52 
 53 static void
 54 e_source_config_backend_class_init (ESourceConfigBackendClass *class)
 55 {
 56 	EExtensionClass *extension_class;
 57 
 58 	extension_class = E_EXTENSION_CLASS (class);
 59 	extension_class->extensible_type = E_TYPE_SOURCE_CONFIG;
 60 
 61 	class->allow_creation = source_config_backend_allow_creation;
 62 	class->insert_widgets = source_config_backend_insert_widgets;
 63 	class->check_complete = source_config_backend_check_complete;
 64 	class->commit_changes = source_config_backend_commit_changes;
 65 }
 66 
 67 static void
 68 e_source_config_backend_init (ESourceConfigBackend *backend)
 69 {
 70 }
 71 
 72 ESourceConfig *
 73 e_source_config_backend_get_config (ESourceConfigBackend *backend)
 74 {
 75 	EExtensible *extensible;
 76 
 77 	g_return_val_if_fail (E_IS_SOURCE_CONFIG_BACKEND (backend), NULL);
 78 
 79 	extensible = e_extension_get_extensible (E_EXTENSION (backend));
 80 
 81 	return E_SOURCE_CONFIG (extensible);
 82 }
 83 
 84 gboolean
 85 e_source_config_backend_allow_creation (ESourceConfigBackend *backend)
 86 {
 87 	ESourceConfigBackendClass *class;
 88 
 89 	g_return_val_if_fail (E_IS_SOURCE_CONFIG_BACKEND (backend), FALSE);
 90 
 91 	class = E_SOURCE_CONFIG_BACKEND_GET_CLASS (backend);
 92 	g_return_val_if_fail (class->allow_creation != NULL, FALSE);
 93 
 94 	return class->allow_creation (backend);
 95 }
 96 
 97 void
 98 e_source_config_backend_insert_widgets (ESourceConfigBackend *backend,
 99                                         ESource *scratch_source)
100 {
101 	ESourceConfigBackendClass *class;
102 
103 	g_return_if_fail (E_IS_SOURCE_CONFIG_BACKEND (backend));
104 	g_return_if_fail (E_IS_SOURCE (scratch_source));
105 
106 	class = E_SOURCE_CONFIG_BACKEND_GET_CLASS (backend);
107 	g_return_if_fail (class->insert_widgets != NULL);
108 
109 	class->insert_widgets (backend, scratch_source);
110 }
111 
112 gboolean
113 e_source_config_backend_check_complete (ESourceConfigBackend *backend,
114                                         ESource *scratch_source)
115 {
116 	ESourceConfigBackendClass *class;
117 
118 	g_return_val_if_fail (E_IS_SOURCE_CONFIG_BACKEND (backend), FALSE);
119 	g_return_val_if_fail (E_IS_SOURCE (scratch_source), FALSE);
120 
121 	class = E_SOURCE_CONFIG_BACKEND_GET_CLASS (backend);
122 	g_return_val_if_fail (class->check_complete != NULL, FALSE);
123 
124 	return class->check_complete (backend, scratch_source);
125 }
126 
127 void
128 e_source_config_backend_commit_changes (ESourceConfigBackend *backend,
129                                         ESource *scratch_source)
130 {
131 	ESourceConfigBackendClass *class;
132 
133 	g_return_if_fail (E_IS_SOURCE_CONFIG_BACKEND (backend));
134 	g_return_if_fail (E_IS_SOURCE (scratch_source));
135 
136 	class = E_SOURCE_CONFIG_BACKEND_GET_CLASS (backend);
137 	g_return_if_fail (class->commit_changes != NULL);
138 
139 	class->commit_changes (backend, scratch_source);
140 }