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.
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.
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/>
19 #include "e-system-source.h"
22 #include <glib/gi18n-lib.h>
24 #include "e-data-server-util.h"
32 system_source_notify (GObject *object,
35 ESource *source = E_SOURCE (object);
37 /* GObject does not allow subclasses to override property flags,
38 * so we'll keep the "backend-name" and "display-name" properties
39 * fixed by intercepting attempts to change them and setting them
40 * back to their proper values. Hokey but works. */
42 if (g_strcmp0 (pspec->name, "backend-name") == 0) {
43 if (e_source_get_backend_name (source) != NULL) {
44 e_source_set_backend_name (source, NULL);
49 if (g_strcmp0 (pspec->name, "display-name") == 0) {
50 const gchar *display_name;
51 const gchar *proper_value;
53 display_name = e_source_get_display_name (source);
54 proper_value = _("Personal");
56 if (g_strcmp0 (display_name, proper_value) != 0) {
57 e_source_set_display_name (source, proper_value);
62 /* Chain up to parent's notify() method. */
63 G_OBJECT_CLASS (e_system_source_parent_class)->notify (object, pspec);
67 e_system_source_class_init (ESystemSourceClass *class)
69 GObjectClass *object_class;
71 object_class = G_OBJECT_CLASS (class);
72 object_class->notify = system_source_notify;
76 e_system_source_init (ESystemSource *source)
81 e_system_source_new (void)
86 const gchar *data_dir;
89 data_dir = e_get_user_data_dir ();
90 path = g_build_filename (data_dir, "sources", "system", NULL);
91 file = g_file_new_for_path (path);
94 /* This function must not fail, so if a "system" key file
95 * exists and fails to load, delete it and try again. */
96 source = g_initable_new (
97 E_TYPE_SYSTEM_SOURCE, NULL, NULL, "file", file, NULL);
99 g_file_delete (file, NULL, NULL);
100 source = g_initable_new (
101 E_TYPE_SYSTEM_SOURCE, NULL, NULL, "file", file, NULL);
104 g_object_unref (file);
106 g_return_val_if_fail (E_IS_SYSTEM_SOURCE (source), NULL);
108 /* Set the "parent" key directly through its GSettings.
110 * XXX To set this during object construction we would have
111 * to override the GInitable interface. Too much hassle
112 * for now. Maybe revisit this in the future. */
113 settings = e_source_get_settings (source);
114 g_settings_set_string (settings, "parent", "local");