aboutsummaryrefslogtreecommitdiffstats
path: root/shell
diff options
context:
space:
mode:
Diffstat (limited to 'shell')
-rw-r--r--shell/ChangeLog20
-rw-r--r--shell/e-shell.c5
-rw-r--r--shell/e-shortcuts.c34
-rw-r--r--shell/e-shortcuts.h34
4 files changed, 72 insertions, 21 deletions
diff --git a/shell/ChangeLog b/shell/ChangeLog
index 92a2fa48c6..8ea78b2d3d 100644
--- a/shell/ChangeLog
+++ b/shell/ChangeLog
@@ -1,5 +1,25 @@
2001-07-03 Ettore Perazzoli <ettore@ximian.com>
+ [The following makes the shell able to create the `shortcuts.xml'
+ file by itself when the file is not present or corrupted. Fixes
+ #3668, failure to handle malformed shortcuts.xml file.]
+
+ * e-shell.c (e_shell_construct): If the `e_shortcuts_new()'
+ returns an object with no shortcuts in it, fill it in with
+ `e_shortcuts_add_default_group()'.
+
+ * e-shortcuts.c: New member `num_groups' in EShortcutsPrivate.
+ (init): Init to zero.
+ (e_shortcuts_add_group): Increment.
+ (e_shortcuts_remove_group): Decrement.
+ (e_shortcuts_get_num_groups): New.
+ (e_shortcuts_add_default_group): New function to set up the
+ default shortcuts.
+ (e_shortcuts_new): Return an empty EShortcuts object if loading
+ the file files, instead of returning NULL.
+
+2001-07-03 Ettore Perazzoli <ettore@ximian.com>
+
* e-shell-offline-handler.c
(e_shell_offline_handler_put_components_offline): Ref/unref the
handler so the signal handlers can unref it safely. Also, if
diff --git a/shell/e-shell.c b/shell/e-shell.c
index 69ed651448..02b3cde7b2 100644
--- a/shell/e-shell.c
+++ b/shell/e-shell.c
@@ -826,9 +826,10 @@ e_shell_construct (EShell *shell,
priv->shortcuts = e_shortcuts_new (priv->storage_set,
priv->folder_type_registry,
shortcut_path);
+ g_assert (priv->shortcuts != NULL);
- if (priv->shortcuts == NULL)
- g_warning ("Cannot load shortcuts -- %s", shortcut_path);
+ if (e_shortcuts_get_num_groups (priv->shortcuts) == 0)
+ e_shortcuts_add_default_group (priv->shortcuts);
g_free (shortcut_path);
diff --git a/shell/e-shortcuts.c b/shell/e-shortcuts.c
index 5f1614a964..8c708254c8 100644
--- a/shell/e-shortcuts.c
+++ b/shell/e-shortcuts.c
@@ -97,6 +97,9 @@ struct _EShortcutsPrivate {
/* The folder type registry. */
EFolderTypeRegistry *folder_type_registry;
+ /* Total number of groups. */
+ int num_groups;
+
/* A list of ShortcutGroups. */
GSList *groups;
@@ -681,6 +684,7 @@ init (EShortcuts *shortcuts)
priv->file_name = NULL;
priv->storage_set = NULL;
+ priv->num_groups = 0;
priv->groups = NULL;
priv->views = NULL;
priv->dirty = 0;
@@ -731,15 +735,21 @@ e_shortcuts_new (EStorageSet *storage_set,
new = gtk_type_new (e_shortcuts_get_type ());
e_shortcuts_construct (new, storage_set, folder_type_registry);
- if (! e_shortcuts_load (new, file_name)) {
- gtk_object_unref (GTK_OBJECT (new));
- return NULL;
- }
+ e_shortcuts_load (new, file_name);
return new;
}
+int
+e_shortcuts_get_num_groups (EShortcuts *shortcuts)
+{
+ g_return_val_if_fail (shortcuts != NULL, 0);
+ g_return_val_if_fail (E_IS_SHORTCUTS (shortcuts), 0);
+
+ return shortcuts->priv->num_groups;
+}
+
GSList *
e_shortcuts_get_group_titles (EShortcuts *shortcuts)
{
@@ -977,6 +987,20 @@ e_shortcuts_update_shortcut (EShortcuts *shortcuts,
void
+e_shortcuts_add_default_group (EShortcuts *shortcuts)
+{
+ g_return_if_fail (shortcuts != NULL);
+ g_return_if_fail (E_IS_SHORTCUTS (shortcuts));
+
+ e_shortcuts_add_group (shortcuts, -1, _("Shortcuts"));
+
+ e_shortcuts_add_shortcut (shortcuts, 0, -1, "evolution:/local/Inbox", _("Inbox"), "mail");
+ e_shortcuts_add_shortcut (shortcuts, 0, -1, "evolution:/local/Calendar", _("Calendar"), "calendar");
+ e_shortcuts_add_shortcut (shortcuts, 0, -1, "evolution:/local/Tasks", _("Tasks"), "tasks");
+ e_shortcuts_add_shortcut (shortcuts, 0, -1, "evolution:/local/Contacts", _("Contacts"), "contacts");
+}
+
+void
e_shortcuts_remove_group (EShortcuts *shortcuts,
int group_num)
{
@@ -996,6 +1020,7 @@ e_shortcuts_remove_group (EShortcuts *shortcuts,
shortcut_group_free ((ShortcutGroup *) p->data);
priv->groups = g_slist_remove_link (priv->groups, p);
+ priv->num_groups --;
make_dirty (shortcuts);
}
@@ -1047,6 +1072,7 @@ e_shortcuts_add_group (EShortcuts *shortcuts,
group_num = g_slist_length (priv->groups);
priv->groups = g_slist_insert (priv->groups, group, group_num);
+ priv->num_groups ++;
gtk_signal_emit (GTK_OBJECT (shortcuts), signals[NEW_GROUP], group_num);
diff --git a/shell/e-shortcuts.h b/shell/e-shortcuts.h
index 2a9836e2a0..aea29de23d 100644
--- a/shell/e-shortcuts.h
+++ b/shell/e-shortcuts.h
@@ -82,6 +82,8 @@ EShortcuts *e_shortcuts_new (EStorageSet *storage_s
EFolderTypeRegistry *folder_type_registry,
const char *file_name);
+int e_shortcuts_get_num_groups (EShortcuts *shortcuts);
+
GSList *e_shortcuts_get_group_titles (EShortcuts *shortcuts);
const char *e_shortcuts_get_group_title (EShortcuts *shortcuts,
int group_num);
@@ -100,21 +102,23 @@ gboolean e_shortcuts_load (EShortcuts *shortcuts
gboolean e_shortcuts_save (EShortcuts *shortcuts,
const char *path);
-void e_shortcuts_remove_shortcut (EShortcuts *shortcuts,
- int group_num,
- int num);
-void e_shortcuts_add_shortcut (EShortcuts *shortcuts,
- int group_num,
- int num,
- const char *uri,
- const char *name,
- const char *type);
-void e_shortcuts_update_shortcut (EShortcuts *shortcuts,
- int group_num,
- int num,
- const char *uri,
- const char *name,
- const char *type);
+void e_shortcuts_add_default_group (EShortcuts *shortcuts);
+
+void e_shortcuts_remove_shortcut (EShortcuts *shortcuts,
+ int group_num,
+ int num);
+void e_shortcuts_add_shortcut (EShortcuts *shortcuts,
+ int group_num,
+ int num,
+ const char *uri,
+ const char *name,
+ const char *type);
+void e_shortcuts_update_shortcut (EShortcuts *shortcuts,
+ int group_num,
+ int num,
+ const char *uri,
+ const char *name,
+ const char *type);
void e_shortcuts_remove_group (EShortcuts *shortcuts,
int group_num);