aboutsummaryrefslogtreecommitdiffstats
path: root/modules/calendar/e-memo-shell-backend.c
diff options
context:
space:
mode:
Diffstat (limited to 'modules/calendar/e-memo-shell-backend.c')
-rw-r--r--modules/calendar/e-memo-shell-backend.c68
1 files changed, 22 insertions, 46 deletions
diff --git a/modules/calendar/e-memo-shell-backend.c b/modules/calendar/e-memo-shell-backend.c
index 6c6a36491c..90ecc916b1 100644
--- a/modules/calendar/e-memo-shell-backend.c
+++ b/modules/calendar/e-memo-shell-backend.c
@@ -69,18 +69,15 @@ memo_shell_backend_ensure_sources (EShellBackend *shell_backend)
EMemoShellBackendPrivate *priv;
ESourceGroup *on_this_computer;
- ESourceGroup *on_the_web;
ESource *personal;
EShell *shell;
EShellSettings *shell_settings;
- GSList *groups, *iter;
const gchar *data_dir;
const gchar *name;
- gchar *base_uri;
+ gchar *base_uri, base_uri_seventh;
gchar *filename;
+ gboolean save_list = FALSE;
- on_this_computer = NULL;
- on_the_web = NULL;
personal = NULL;
priv = E_MEMO_SHELL_BACKEND_GET_PRIVATE (shell_backend);
@@ -98,33 +95,26 @@ memo_shell_backend_ensure_sources (EShellBackend *shell_backend)
base_uri = g_filename_to_uri (filename, NULL, NULL);
g_free (filename);
- groups = e_source_list_peek_groups (priv->source_list);
- for (iter = groups; iter != NULL; iter = iter->next) {
- ESourceGroup *source_group = iter->data;
- const gchar *group_base_uri;
-
- group_base_uri = e_source_group_peek_base_uri (source_group);
+ if (strlen (base_uri) > 7) {
+ /* compare only file:// part. If user home dir name changes we do not want to create
+ one more group */
+ base_uri_seventh = base_uri[7];
+ base_uri[7] = 0;
+ } else {
+ base_uri_seventh = -1;
+ }
- /* Compare only "file://" part. If the user's home
- * changes, we do not want to create another group. */
- if (on_this_computer == NULL &&
- strncmp (base_uri, group_base_uri, 7) == 0)
- on_this_computer = source_group;
+ on_this_computer = e_source_list_ensure_group (priv->source_list, _("On This Computer"), base_uri, TRUE);
+ e_source_list_ensure_group (priv->source_list, _("On The Web"), WEB_BASE_URI, FALSE);
- else if (on_the_web == NULL &&
- strcmp (WEB_BASE_URI, group_base_uri) == 0)
- on_the_web = source_group;
+ if (base_uri_seventh != -1) {
+ base_uri[7] = base_uri_seventh;
}
- name = _("On This Computer");
-
if (on_this_computer != NULL) {
- GSList *sources;
+ GSList *sources, *iter;
const gchar *group_base_uri;
- /* Force the group name to the current locale. */
- e_source_group_set_name (on_this_computer, name);
-
sources = e_source_group_peek_sources (on_this_computer);
group_base_uri = e_source_group_peek_base_uri (on_this_computer);
@@ -155,15 +145,8 @@ memo_shell_backend_ensure_sources (EShellBackend *shell_backend)
* but that happens in an idle loop and too late
* to prevent the user from seeing a "Cannot
* Open ... because of invalid URI" error. */
- e_source_list_sync (priv->source_list, NULL);
+ save_list = TRUE;
}
-
- } else {
- ESourceGroup *source_group;
-
- source_group = e_source_group_new (name, base_uri);
- e_source_list_add_group (priv->source_list, source_group, -1);
- g_object_unref (source_group);
}
name = _("Personal");
@@ -174,8 +157,10 @@ memo_shell_backend_ensure_sources (EShellBackend *shell_backend)
gchar *primary;
source = e_source_new (name, PERSONAL_RELATIVE_URI);
+ e_source_set_color_spec (source, "#BECEDD");
e_source_group_add_source (on_this_computer, source, -1);
g_object_unref (source);
+ save_list = TRUE;
primary = e_shell_settings_get_string (
shell_settings, "cal-primary-memo-list");
@@ -201,20 +186,11 @@ memo_shell_backend_ensure_sources (EShellBackend *shell_backend)
e_source_set_name (personal, name);
}
- name = _("On The Web");
-
- if (on_the_web == NULL) {
- ESourceGroup *source_group;
-
- source_group = e_source_group_new (name, WEB_BASE_URI);
- e_source_list_add_group (priv->source_list, source_group, -1);
- g_object_unref (source_group);
- } else {
- /* Force the group name to the current locale. */
- e_source_group_set_name (on_the_web, name);
- }
-
+ g_object_unref (on_this_computer);
g_free (base_uri);
+
+ if (save_list)
+ e_source_list_sync (priv->source_list, NULL);
}
static void