aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--shell/ChangeLog60
-rw-r--r--shell/e-shell-folder-commands.c2
-rw-r--r--shell/e-shell-view.c5
-rw-r--r--shell/e-shortcuts-view-model.c101
-rw-r--r--shell/e-shortcuts-view.c18
-rw-r--r--shell/e-shortcuts.c304
-rw-r--r--shell/e-shortcuts.h70
7 files changed, 263 insertions, 297 deletions
diff --git a/shell/ChangeLog b/shell/ChangeLog
index 9d52e8fccd..348efdae13 100644
--- a/shell/ChangeLog
+++ b/shell/ChangeLog
@@ -1,3 +1,63 @@
+2001-06-29 Ettore Perazzoli <ettore@ximian.com>
+
+ This is a first shoot at making shortcuts renameable [#3719];
+ unfinished. Also, it causes the shortcut bar to stop displaying
+ message unread count, but this is unfixable until we get rid of
+ the ::LocalStorage interface, which should hopefully happen soon.
+
+ * e-shortcuts-view.c (icon_callback): Get the icon from the type
+ member of the shortcut item instead of going to the actual folder.
+
+ * e-shell-view.c (updated_folder_cb): Don't update the shortcuts
+ here for now.
+
+ * e-shortcuts-view.c (item_selected): Use
+ `e_shortcuts_get_shortcut()' instead of `e_shortcuts_get_uri()'.
+ (impl_shortcut_dropped): Pass a NULL @name and @type.
+
+ * e-shortcuts-view-model.c (load_group_into_model): Updated to
+ match the new `e_shortcuts_get_shortcuts_in_group()' function that
+ doesn't allocate the list anymore and returns a list of
+ EShortcutItems instead of a list of strings.
+ (load_group_into_model): Likewise.
+ (load_all_shortcuts_into_model): Likewise.
+ (shortcuts_new_shortcut_cb): Get the URI and the name from the
+ EShortcutItem instead of retrieving them from the storage.
+ (shortcuts_update_shortcut_cb): Likewise.
+ (get_storage_set_path_from_uri): Removed [now unused].
+
+ * e-shortcuts.c: Define the shortcuts to be EShortcutItems instead
+ of just strings.
+ (shortcut_new): New helper function to allocate a Shortcut.
+ (shortcut_free): New helper function to free a Shortcut.
+ (shortcut_group_new): New helper function to allocate a
+ ShortcutGroup.
+ (shortcut_group_free): New helper function to free a
+ ShortcutGroup.
+ (load_shortcuts): Use `shortcut_group_new()' here.
+ (e_shortcuts_add_group): Same here.
+ (unload_shortcuts): Use `shortcut_group_free()' here.
+ (e_shortcuts_remove_group): Here too.
+ (load_shortcuts): Update to handle `Shortcut's instead of simple
+ `char *'s representing the URIs.
+ (save_shortcuts): Likewise.
+ (e_shortcuts_get_shortcuts_in_group): Likewise. The returned list
+ now doesn't belong to the caller anymore; the return type is now
+ const.
+ (removed_folder_cb): Removed.
+ (e_shortcuts_construct): Don't connect.
+ (e_shortcuts_get_group_titles): Dont' re-allocate the string.
+ (e_shortcuts_get_uri): Removed.
+ (e_shortcuts_get_shortcut): New.
+ (e_shortcuts_add_shortcut): new args @name, @type.
+ (e_shortcuts_update_shortcut_by_uri): Remove.
+ (e_shortcuts_remove_shortcut_by_uri): Remove.
+ (get_item): New helper function.
+ (e_shortcuts_get_shortcut): Use it.
+ (find_positions_by_uri): Removed.
+
+ * e-shortcuts.h: New typedef EShortcutItem.
+
2001-06-29 Christopher James Lahey <clahey@ximian.com>
* e-shortcuts-view-model.c (load_all_shortcuts_into_model):
diff --git a/shell/e-shell-folder-commands.c b/shell/e-shell-folder-commands.c
index fbb562d81f..ba8f645c16 100644
--- a/shell/e-shell-folder-commands.c
+++ b/shell/e-shell-folder-commands.c
@@ -431,7 +431,7 @@ e_shell_command_add_to_shortcut_bar (EShell *shell,
group_num = e_shell_view_get_current_shortcuts_group_num (shell_view);
uri = e_shell_view_get_current_uri (shell_view);
- e_shortcuts_add_shortcut (shortcuts, group_num, -1, uri);
+ e_shortcuts_add_shortcut (shortcuts, group_num, -1, uri, NULL, NULL);
}
diff --git a/shell/e-shell-view.c b/shell/e-shell-view.c
index cf40178ddb..2c3a493c7f 100644
--- a/shell/e-shell-view.c
+++ b/shell/e-shell-view.c
@@ -1105,16 +1105,17 @@ updated_folder_cb (EStorageSet *storage_set,
{
EShellView *shell_view;
EShellViewPrivate *priv;
- char *uri;
shell_view = E_SHELL_VIEW (data);
priv = shell_view->priv;
- uri = g_strconcat (E_SHELL_URI_PREFIX, path, NULL);
+#if 0
+ char *uri = g_strconcat (E_SHELL_URI_PREFIX, path, NULL);
/* Update the shortcut bar */
e_shortcuts_update_shortcut_by_uri (e_shell_get_shortcuts (priv->shell), uri);
g_free (uri);
+#endif
/* Update the folder title bar and the window title bar */
update_for_current_uri (shell_view);
diff --git a/shell/e-shortcuts-view-model.c b/shell/e-shortcuts-view-model.c
index 6a171ff949..f13971ac9a 100644
--- a/shell/e-shortcuts-view-model.c
+++ b/shell/e-shortcuts-view-model.c
@@ -47,27 +47,6 @@ struct _EShortcutsViewModelPrivate {
/* View initialization. */
-static const char *
-get_storage_set_path_from_uri (const char *uri)
-{
- const char *colon;
-
- if (g_path_is_absolute (uri))
- return NULL;
-
- colon = strchr (uri, ':');
- if (colon == NULL || colon == uri || colon[1] == '\0')
- return NULL;
-
- if (! g_path_is_absolute (colon + 1))
- return NULL;
-
- if (g_strncasecmp (uri, "evolution", colon - uri) != 0)
- return NULL;
-
- return colon + 1;
-}
-
static void
load_group_into_model (EShortcutsViewModel *shortcuts_view_model,
const char *group_title,
@@ -75,8 +54,8 @@ load_group_into_model (EShortcutsViewModel *shortcuts_view_model,
{
EShortcutsViewModelPrivate *priv;
EStorageSet *storage_set;
- GSList *shortcut_list;
- GSList *p;
+ const GSList *shortcut_list;
+ const GSList *p;
priv = shortcuts_view_model->priv;
@@ -88,37 +67,19 @@ load_group_into_model (EShortcutsViewModel *shortcuts_view_model,
return;
for (p = shortcut_list; p != NULL; p = p->next) {
- EFolder *folder = NULL;
- const char *path;
- const char *uri;
- const char *name;
-
- uri = (const char *) p->data;
- path = get_storage_set_path_from_uri (uri);
-
- if (path == NULL) {
- name = _("Unknown link");
- } else {
- folder = e_storage_set_get_folder (storage_set, path);
-
- if (folder != NULL)
- name = e_folder_get_name (folder);
- else
- name = g_basename (path);
- }
-
- e_shortcut_model_add_item (E_SHORTCUT_MODEL (shortcuts_view_model), group_num, -1, uri, name);
- }
+ const EShortcutItem *item;
- e_free_string_slist (shortcut_list);
+ item = (const EShortcutItem *) p->data;
+ e_shortcut_model_add_item (E_SHORTCUT_MODEL (shortcuts_view_model), group_num, -1, item->uri, item->name);
+ }
}
static void
load_all_shortcuts_into_model (EShortcutsViewModel *shortcuts_view_model)
{
EShortcutsViewModelPrivate *priv;
- GSList *group_titles;
- GSList *p;
+ const GSList *group_titles;
+ const GSList *p;
int group_num;
priv = shortcuts_view_model->priv;
@@ -133,8 +94,6 @@ load_all_shortcuts_into_model (EShortcutsViewModel *shortcuts_view_model)
load_group_into_model (shortcuts_view_model, group_title, group_num);
}
-
- e_free_string_slist (group_titles);
}
@@ -175,28 +134,18 @@ shortcuts_new_shortcut_cb (EShortcuts *shortcuts,
{
EShortcutsViewModel *shortcuts_view_model;
EShortcutsViewModelPrivate *priv;
- EStorageSet *storage_set;
- EFolder *folder;
- const char *uri;
- const char *storage_set_path;
- const char *folder_name;
+ const EShortcutItem *shortcut_item;
shortcuts_view_model = E_SHORTCUTS_VIEW_MODEL (data);
priv = shortcuts_view_model->priv;
- uri = e_shortcuts_get_uri (priv->shortcuts, group_num, item_num);
- g_assert (uri != NULL);
-
- storage_set_path = get_storage_set_path_from_uri (uri);
- if (storage_set_path == NULL)
- return;
-
- storage_set = e_shortcuts_get_storage_set (priv->shortcuts);
- folder = e_storage_set_get_folder (storage_set, storage_set_path);
- folder_name = e_folder_get_name (folder);
+ shortcut_item = e_shortcuts_get_shortcut (priv->shortcuts, group_num, item_num);
+ g_assert (shortcut_item != NULL);
e_shortcut_model_add_item (E_SHORTCUT_MODEL (shortcuts_view_model),
- group_num, item_num, uri, folder_name);
+ group_num, item_num,
+ shortcut_item->uri,
+ shortcut_item->name);
}
static void
@@ -219,28 +168,18 @@ shortcuts_update_shortcut_cb (EShortcuts *shortcuts,
{
EShortcutsViewModel *shortcuts_view_model;
EShortcutsViewModelPrivate *priv;
- EStorageSet *storage_set;
- EFolder *folder;
- const char *uri;
- const char *storage_set_path;
- const char *folder_name;
+ const EShortcutItem *shortcut_item;
shortcuts_view_model = E_SHORTCUTS_VIEW_MODEL (data);
priv = shortcuts_view_model->priv;
- uri = e_shortcuts_get_uri (priv->shortcuts, group_num, item_num);
- g_assert (uri != NULL);
-
- storage_set_path = get_storage_set_path_from_uri (uri);
- if (storage_set_path == NULL)
- return;
-
- storage_set = e_shortcuts_get_storage_set (priv->shortcuts);
- folder = e_storage_set_get_folder (storage_set, storage_set_path);
- folder_name = e_folder_get_name (folder);
+ shortcut_item = e_shortcuts_get_shortcut (priv->shortcuts, group_num, item_num);
+ g_assert (shortcut_item != NULL);
e_shortcut_model_update_item (E_SHORTCUT_MODEL (shortcuts_view_model),
- group_num, item_num, uri, folder_name);
+ group_num, item_num,
+ shortcut_item->uri,
+ shortcut_item->name);
}
diff --git a/shell/e-shortcuts-view.c b/shell/e-shortcuts-view.c
index 3db7115ecb..bfde8d02c4 100644
--- a/shell/e-shortcuts-view.c
+++ b/shell/e-shortcuts-view.c
@@ -352,18 +352,18 @@ activate_shortcut_cb (GtkWidget *widget,
ShortcutRightClickMenuData *menu_data;
EShortcutsView *shortcuts_view;
EShortcuts *shortcuts;
- const char *uri;
+ const EShortcutItem *shortcut_item;
menu_data = (ShortcutRightClickMenuData *) data;
shortcuts_view = menu_data->shortcuts_view;
shortcuts = shortcuts_view->priv->shortcuts;
- uri = e_shortcuts_get_uri (shortcuts, menu_data->group_num, menu_data->item_num);
- if (uri == NULL)
+ shortcut_item = e_shortcuts_get_shortcut (shortcuts, menu_data->group_num, menu_data->item_num);
+ if (shortcut_item == NULL)
return;
gtk_signal_emit (GTK_OBJECT (shortcuts_view), signals[ACTIVATE_SHORTCUT],
- shortcuts, uri);
+ shortcuts, shortcut_item->uri);
}
static void
@@ -443,7 +443,7 @@ item_selected (EShortcutBar *shortcut_bar,
{
EShortcuts *shortcuts;
EShortcutsView *shortcuts_view;
- const char *uri;
+ const EShortcutItem *shortcut_item;
shortcuts_view = E_SHORTCUTS_VIEW (shortcut_bar);
shortcuts = shortcuts_view->priv->shortcuts;
@@ -463,12 +463,12 @@ item_selected (EShortcutBar *shortcut_bar,
if (item_num < 0)
return;
- uri = e_shortcuts_get_uri (shortcuts, group_num, item_num);
- if (uri == NULL)
+ shortcut_item = e_shortcuts_get_shortcut (shortcuts, group_num, item_num);
+ if (shortcut_item == NULL)
return;
gtk_signal_emit (GTK_OBJECT (shortcuts_view), signals[ACTIVATE_SHORTCUT],
- shortcuts, uri);
+ shortcuts, shortcut_item->uri);
}
static void
@@ -484,7 +484,7 @@ impl_shortcut_dropped (EShortcutBar *shortcut_bar,
shortcuts_view = E_SHORTCUTS_VIEW (shortcut_bar);
priv = shortcuts_view->priv;
- e_shortcuts_add_shortcut (priv->shortcuts, group_num, position, item_url);
+ e_shortcuts_add_shortcut (priv->shortcuts, group_num, position, item_url, NULL, NULL);
}
static void
diff --git a/shell/e-shortcuts.c b/shell/e-shortcuts.c
index 6dd54ba17a..18d79b330f 100644
--- a/shell/e-shortcuts.c
+++ b/shell/e-shortcuts.c
@@ -26,9 +26,9 @@
<?xml version="1.0"?>
<shortcuts>
<group title="Evolution shortcuts">
- <item>evolution:/local/Inbox</item>
- <item>evolution:/local/Trash</item>
- <item>evolution:/local/Calendar</item>
+ <item name="Inbox" type="mail">evolution:/local/Inbox</item>
+ <item name="Trash" type="vtrash">evolution:/local/Trash</item>
+ <item name="Calendar" type="calendar">evolution:/local/Calendar</item>
</group>
<group title="Personal shortcuts">
@@ -74,7 +74,7 @@ struct _ShortcutGroup {
/* Title of the group. */
char *title;
- /* A list of strings with the URI for the shortcut. */
+ /* A list of shortcuts. */
GSList *shortcuts;
};
typedef struct _ShortcutGroup ShortcutGroup;
@@ -119,12 +119,69 @@ enum {
static guint signals[LAST_SIGNAL] = { 0 };
+static EShortcutItem *
+shortcut_item_new (const char *uri,
+ const char *name,
+ const char *type)
+{
+ EShortcutItem *new;
+
+ if (name == NULL)
+ name = g_basename (uri);
+
+ new = g_new (EShortcutItem, 1);
+ new->uri = g_strdup (uri);
+ new->name = g_strdup (name);
+ new->type = g_strdup (type);
+
+ return new;
+}
+
+static void
+shortcut_item_free (EShortcutItem *shortcut_item)
+{
+ g_free (shortcut_item->uri);
+ g_free (shortcut_item->name);
+ g_free (shortcut_item->type);
+
+ g_free (shortcut_item);
+}
+
+static ShortcutGroup *
+shortcut_group_new (const char *title)
+{
+ ShortcutGroup *new;
+
+ new = g_new (ShortcutGroup, 1);
+ new->title = g_strdup (title);
+ new->shortcuts = NULL;
+
+ return new;
+}
+
+static void
+shortcut_group_free (ShortcutGroup *group)
+{
+ GSList *p;
+
+ g_free (group->title);
+
+ for (p = group->shortcuts; p != NULL; p = p->next)
+ shortcut_item_free ((EShortcutItem *) p->data);
+ g_slist_free (group->shortcuts);
+
+ g_free (group);
+}
+
+
+/* Utility functions. */
+
static void
unload_shortcuts (EShortcuts *shortcuts)
{
EShortcutsPrivate *priv;
GSList *orig_groups;
- GSList *p, *q;
+ GSList *p;
priv = shortcuts->priv;
orig_groups = priv->groups;
@@ -137,12 +194,7 @@ unload_shortcuts (EShortcuts *shortcuts)
group = (ShortcutGroup *) p->data;
g_hash_table_remove (priv->title_to_group, group->title);
-
- for (q = group->shortcuts; q != NULL; q = q->next)
- g_free (q->data);
- g_free (group->title);
-
- g_slist_free (group->shortcuts);
+ shortcut_group_free (group);
priv->groups = priv->groups->next;
}
@@ -192,8 +244,7 @@ load_shortcuts (EShortcuts *shortcuts,
if (shortcut_group_title == NULL)
continue;
- shortcut_group = g_hash_table_lookup (priv->title_to_group,
- shortcut_group_title);
+ shortcut_group = g_hash_table_lookup (priv->title_to_group, shortcut_group_title);
if (shortcut_group != NULL) {
g_warning ("Duplicate shortcut group title -- %s",
shortcut_group_title);
@@ -201,21 +252,19 @@ load_shortcuts (EShortcuts *shortcuts,
continue;
}
- shortcut_group = g_new (ShortcutGroup, 1);
- shortcut_group->title = g_strdup (shortcut_group_title);
+ shortcut_group = shortcut_group_new (shortcut_group_title);
xmlFree (shortcut_group_title);
- shortcut_group->shortcuts = NULL;
for (q = p->childs; q != NULL; q = q->next) {
- char *content;
+ xmlChar *uri;
if (strcmp ((char *) q->name, "item") != 0)
continue;
- content = xmlNodeListGetString (doc, q->childs, 1);
+ uri = xmlNodeListGetString (doc, q->childs, 1);
shortcut_group->shortcuts = g_slist_prepend (shortcut_group->shortcuts,
- g_strdup (content));
- xmlFree (content);
+ shortcut_item_new (uri, NULL, NULL));
+ xmlFree (uri);
}
shortcut_group->shortcuts = g_slist_reverse (shortcut_group->shortcuts);
@@ -255,10 +304,10 @@ save_shortcuts (EShortcuts *shortcuts,
xmlSetProp (group_node, (xmlChar *) "title", group->title);
for (q = group->shortcuts; q != NULL; q = q->next) {
- const char *shortcut;
+ EShortcutItem *shortcut;
- shortcut = (const char *) q->data;
- xmlNewChild (group_node, NULL, (xmlChar *) "item", (xmlChar *) shortcut);
+ shortcut = (EShortcutItem *) q->data;
+ xmlNewChild (group_node, NULL, (xmlChar *) "item", (xmlChar *) shortcut->uri);
}
}
@@ -271,6 +320,35 @@ save_shortcuts (EShortcuts *shortcuts,
return TRUE;
}
+
+static EShortcutItem *
+get_item (EShortcuts *shortcuts,
+ int group_num,
+ int num)
+{
+ EShortcutsPrivate *priv;
+ ShortcutGroup *group;
+ GSList *group_element;
+ GSList *shortcut_element;
+
+ g_return_val_if_fail (shortcuts != NULL, NULL);
+ g_return_val_if_fail (E_IS_SHORTCUTS (shortcuts), NULL);
+
+ priv = shortcuts->priv;
+
+ group_element = g_slist_nth (priv->groups, group_num);
+ if (group_element == NULL)
+ return NULL;
+
+ group = (ShortcutGroup *) group_element->data;
+
+ shortcut_element = g_slist_nth (group->shortcuts, num);
+ if (shortcut_element == NULL)
+ return NULL;
+
+ return (EShortcutItem *) shortcut_element->data;
+}
+
/* Idle function to update the file on disk. */
@@ -320,22 +398,6 @@ make_dirty (EShortcuts *shortcuts)
schedule_idle (shortcuts);
}
-/* Signal handlers for the storage set */
-static void
-removed_folder_cb (EStorageSet *storage_set,
- const char *path,
- void *data)
-{
- EShortcuts *shortcuts;
- char *tmp;
-
- shortcuts = E_SHORTCUTS (data);
-
- tmp = g_strconcat (E_SHELL_URI_PREFIX, path, NULL);
- e_shortcuts_remove_shortcut_by_uri (shortcuts, tmp);
- g_free (tmp);
-}
-
/* Signal handlers for the views. */
@@ -485,12 +547,10 @@ e_shortcuts_construct (EShortcuts *shortcuts,
priv = shortcuts->priv;
+ /* FIXME: Get rid of the storage set, we dont' need it here. */
gtk_object_ref (GTK_OBJECT (storage_set));
priv->storage_set = storage_set;
- gtk_signal_connect (GTK_OBJECT (priv->storage_set), "removed_folder",
- removed_folder_cb, shortcuts);
-
gtk_object_ref (GTK_OBJECT (folder_type_registry));
priv->folder_type_registry = folder_type_registry;
}
@@ -540,14 +600,12 @@ e_shortcuts_get_group_titles (EShortcuts *shortcuts)
return g_slist_reverse (list);
}
-GSList *
+const GSList *
e_shortcuts_get_shortcuts_in_group (EShortcuts *shortcuts,
const char *group_title)
{
EShortcutsPrivate *priv;
ShortcutGroup *shortcut_group;
- GSList *list;
- GSList *p;
priv = shortcuts->priv;
@@ -559,12 +617,7 @@ e_shortcuts_get_shortcuts_in_group (EShortcuts *shortcuts,
if (shortcut_group == NULL)
return NULL;
- list = NULL;
-
- for (p = shortcut_group->shortcuts; p != NULL; p = p->next)
- list = g_slist_prepend (list, g_strdup ((const char *) p->data));
-
- return g_slist_reverse (list);
+ return shortcut_group->shortcuts;
}
@@ -657,27 +710,15 @@ e_shortcuts_save (EShortcuts *shortcuts,
}
-const char *
-e_shortcuts_get_uri (EShortcuts *shortcuts, int group_num, int num)
+const EShortcutItem *
+e_shortcuts_get_shortcut (EShortcuts *shortcuts,
+ int group_num,
+ int num)
{
- EShortcutsPrivate *priv;
- ShortcutGroup *group;
- GSList *shortcut_element;
-
g_return_val_if_fail (shortcuts != NULL, NULL);
g_return_val_if_fail (E_IS_SHORTCUTS (shortcuts), NULL);
- priv = shortcuts->priv;
-
- group = g_slist_nth (priv->groups, group_num)->data;
- if (group == NULL)
- return NULL;
-
- shortcut_element = g_slist_nth (group->shortcuts, num);
- if (shortcut_element == NULL)
- return NULL;
-
- return shortcut_element->data;
+ return (const EShortcutItem *) get_item (shortcuts, group_num, num);
}
@@ -689,7 +730,7 @@ e_shortcuts_remove_shortcut (EShortcuts *shortcuts,
EShortcutsPrivate *priv;
ShortcutGroup *group;
GSList *p;
- char *uri;
+ EShortcutItem *item;
g_return_if_fail (shortcuts != NULL);
g_return_if_fail (E_IS_SHORTCUTS (shortcuts));
@@ -706,8 +747,8 @@ e_shortcuts_remove_shortcut (EShortcuts *shortcuts,
gtk_signal_emit (GTK_OBJECT (shortcuts), signals[REMOVE_SHORTCUT], group_num, num);
- uri = (char *) p->data;
- g_free (uri);
+ item = (EShortcutItem *) p->data;
+ shortcut_item_free (item);
group->shortcuts = g_slist_remove_link (group->shortcuts, p);
@@ -718,10 +759,13 @@ void
e_shortcuts_add_shortcut (EShortcuts *shortcuts,
int group_num,
int num,
- const char *uri)
+ const char *uri,
+ const char *name,
+ const char *type)
{
EShortcutsPrivate *priv;
ShortcutGroup *group;
+ EShortcutItem *item;
GSList *p;
g_return_if_fail (shortcuts != NULL);
@@ -737,7 +781,9 @@ e_shortcuts_add_shortcut (EShortcuts *shortcuts,
if (num == -1)
num = g_slist_length (group->shortcuts);
- group->shortcuts = g_slist_insert (group->shortcuts, g_strdup (uri), num);
+ item = shortcut_item_new (uri, name, type);
+
+ group->shortcuts = g_slist_insert (group->shortcuts, item, num);
gtk_signal_emit (GTK_OBJECT (shortcuts), signals[NEW_SHORTCUT], group_num, num);
@@ -748,110 +794,31 @@ void
e_shortcuts_update_shortcut (EShortcuts *shortcuts,
int group_num,
int num,
- const char *uri)
+ const char *uri,
+ const char *name,
+ const char *type)
{
+ EShortcutItem *shortcut_item;
+
g_return_if_fail (shortcuts != NULL);
g_return_if_fail (E_IS_SHORTCUTS (shortcuts));
- gtk_signal_emit (GTK_OBJECT (shortcuts), signals[UPDATE_SHORTCUT], group_num, num);
-}
-
-
-/* The shortcuts_by_uri functions */
-
-
-typedef struct {
- int group_num;
- int num;
-} EShortcutPosition;
-
-static GSList *
-find_positions_by_uri (EShortcuts *shortcuts,
- const char *uri)
-{
- EShortcutsPrivate *priv;
- GSList *p = NULL, *q = NULL;
- GSList *retval = NULL;
- int group_num = 0, num = 0;
-
- priv = shortcuts->priv;
-
- for (p = priv->groups; p != NULL; p = p->next) {
- ShortcutGroup *group;
-
- group = (ShortcutGroup *) p->data;
+ shortcut_item = get_item (shortcuts, group_num, num);
+ g_free (shortcut_item->uri);
- for (q = group->shortcuts; q != NULL; q = q->next) {
- char *listeduri = q->data;
-
- if (!strcmp (uri, listeduri)) {
- EShortcutPosition *position;
-
- position = g_new (EShortcutPosition, 1);
- position->group_num = group_num;
- position->num = num;
-
- retval = g_slist_prepend (retval, position);
- }
- num++;
- }
-
- group_num++;
- num = 0;
- }
+ shortcut_item->uri = g_strdup (uri);
+ shortcut_item->name = g_strdup (name);
+ shortcut_item->type = g_strdup (type);
- retval = g_slist_reverse (retval);
- return retval;
-}
-
-void
-e_shortcuts_remove_shortcut_by_uri (EShortcuts *shortcuts,
- const char *uri)
-{
- GSList *items = NULL;
-
- items = find_positions_by_uri (shortcuts, uri);
-
- while (items) {
- EShortcutPosition *pos = (EShortcutPosition *) items->data;
-
- if (pos) {
- e_shortcuts_remove_shortcut (shortcuts, pos->group_num, pos->num);
- g_free (pos);
- }
- items = g_slist_next (items);
- }
- g_slist_free (items);
-}
-
-void
-e_shortcuts_update_shortcut_by_uri (EShortcuts *shortcuts,
- const char *uri)
-{
- GSList *items = NULL;
-
- items = find_positions_by_uri (shortcuts, uri);
-
- while (items) {
- EShortcutPosition *pos = (EShortcutPosition *) items->data;
-
- if (pos) {
- e_shortcuts_update_shortcut (shortcuts,
- pos->group_num, pos->num,
- uri);
- g_free (pos);
- }
- items = g_slist_next (items);
- }
- g_slist_free (items);
+ gtk_signal_emit (GTK_OBJECT (shortcuts), signals[UPDATE_SHORTCUT], group_num, num);
}
+
void
e_shortcuts_remove_group (EShortcuts *shortcuts,
int group_num)
{
EShortcutsPrivate *priv;
- ShortcutGroup *group;
GSList *p;
g_return_if_fail (shortcuts != NULL);
@@ -864,9 +831,7 @@ e_shortcuts_remove_group (EShortcuts *shortcuts,
gtk_signal_emit (GTK_OBJECT (shortcuts), signals[REMOVE_GROUP], group_num);
- group = (ShortcutGroup *) p->data;
-
- e_free_string_slist (group->shortcuts);
+ shortcut_group_free ((ShortcutGroup *) p->data);
priv->groups = g_slist_remove_link (priv->groups, p);
@@ -886,9 +851,7 @@ e_shortcuts_add_group (EShortcuts *shortcuts,
priv = shortcuts->priv;
- group = g_new (ShortcutGroup, 1);
- group->title = g_strdup (group_name);
- group->shortcuts = NULL;
+ group = shortcut_group_new (group_name);
if (group_num == -1)
group_num = g_slist_length (priv->groups);
@@ -925,4 +888,3 @@ e_shortcuts_get_group_title (EShortcuts *shortcuts,
E_MAKE_TYPE (e_shortcuts, "EShortcuts", EShortcuts, class_init, init, PARENT_TYPE)
-
diff --git a/shell/e-shortcuts.h b/shell/e-shortcuts.h
index 4276c9a032..8ccd552f87 100644
--- a/shell/e-shortcuts.h
+++ b/shell/e-shortcuts.h
@@ -45,6 +45,13 @@ typedef struct _EShortcuts EShortcuts;
typedef struct _EShortcutsPrivate EShortcutsPrivate;
typedef struct _EShortcutsClass EShortcutsClass;
+struct _EShortcutItem {
+ char *uri;
+ char *name;
+ char *type;
+};
+typedef struct _EShortcutItem EShortcutItem;
+
struct _EShortcuts {
GtkObject parent;
@@ -73,46 +80,43 @@ EShortcuts *e_shortcuts_new (EStorageSet *storage_s
EFolderTypeRegistry *folder_type_registry,
const char *file_name);
-GSList *e_shortcuts_get_group_titles (EShortcuts *shortcuts);
-const char *e_shortcuts_get_group_title (EShortcuts *shortcuts,
- int group_num);
+GSList *e_shortcuts_get_group_titles (EShortcuts *shortcuts);
+const char *e_shortcuts_get_group_title (EShortcuts *shortcuts,
+ int group_num);
+const GSList *e_shortcuts_get_shortcuts_in_group (EShortcuts *shortcuts,
+ const char *group_title);
+const EShortcutItem *e_shortcuts_get_shortcut (EShortcuts *shortcuts,
+ int group_num,
+ int num);
-GSList *e_shortcuts_get_shortcuts_in_group (EShortcuts *shortcuts,
- const char *group_title);
-EStorageSet *e_shortcuts_get_storage_set (EShortcuts *shortcuts);
-GtkWidget *e_shortcuts_new_view (EShortcuts *shortcuts);
+EStorageSet *e_shortcuts_get_storage_set (EShortcuts *shortcuts);
+GtkWidget *e_shortcuts_new_view (EShortcuts *shortcuts);
gboolean e_shortcuts_load (EShortcuts *shortcuts,
const char *path);
gboolean e_shortcuts_save (EShortcuts *shortcuts,
const char *path);
-const char *e_shortcuts_get_uri (EShortcuts *shortcuts,
- int group_num,
- int num);
-
-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);
-void e_shortcuts_update_shortcut (EShortcuts *shortcuts,
- int group_num,
- int num,
- const char *uri);
-void e_shortcuts_remove_group (EShortcuts *shortcuts,
- int group_num);
-void e_shortcuts_add_group (EShortcuts *shortcuts,
- int group_num,
- const char *group_name);
-
-void e_shortcuts_remove_shortcut_by_uri (EShortcuts *shortcuts,
- const char *uri);
-
-void e_shortcuts_update_shortcut_by_uri (EShortcuts *shortcuts,
- const char *uri);
+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);
+void e_shortcuts_add_group (EShortcuts *shortcuts,
+ int group_num,
+ const char *group_name);
#ifdef __cplusplus
}