aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEttore Perazzoli <ettore@src.gnome.org>2001-08-20 09:22:09 +0800
committerEttore Perazzoli <ettore@src.gnome.org>2001-08-20 09:22:09 +0800
commit6bf0ba97e25261e2efc5c685c08cf52a75816d3b (patch)
tree120c8f1df9cfb71890d4c708a4ba878a8ac35e7f
parentee70366b8e7092300fff8a421efa3ff84c5bcf7a (diff)
downloadgsoc2013-evolution-6bf0ba97e25261e2efc5c685c08cf52a75816d3b.tar.gz
gsoc2013-evolution-6bf0ba97e25261e2efc5c685c08cf52a75816d3b.tar.zst
gsoc2013-evolution-6bf0ba97e25261e2efc5c685c08cf52a75816d3b.zip
Use xmlMemStrdup() to override the type as it's expected to be allocated
* e-shortcuts.c (load_shortcuts): Use xmlMemStrdup() to override the type as it's expected to be allocated by libxml later on. Also, get the icon for the storage if the shortcut points to a storage. * e-storage-set-view.c (etree_icon_at): Don't special case the Summary storage. Rather, use `e_storage_get_toplevel_node_type()' for getting the type of the node. * e-shortcuts-view-model.c (get_icon_for_item): New helper function. (shortcuts_update_shortcut_cb): Use it. (shortcuts_new_shortcut_cb): Use it. (load_group_into_model): Use it. svn path=/trunk/; revision=12232
-rw-r--r--shell/ChangeLog17
-rw-r--r--shell/e-shortcuts-view-model.c60
-rw-r--r--shell/e-shortcuts.c17
-rw-r--r--shell/e-shortcuts.h8
-rw-r--r--shell/e-storage-set-view.c38
5 files changed, 97 insertions, 43 deletions
diff --git a/shell/ChangeLog b/shell/ChangeLog
index 908e628587..11ae22875f 100644
--- a/shell/ChangeLog
+++ b/shell/ChangeLog
@@ -1,3 +1,20 @@
+2001-08-19 Ettore Perazzoli <ettore@ximian.com>
+
+ * e-shortcuts.c (load_shortcuts): Use xmlMemStrdup() to override
+ the type as it's expected to be allocated by libxml later on.
+ Also, get the icon for the storage if the shortcut points to a
+ storage.
+
+ * e-storage-set-view.c (etree_icon_at): Don't special case the
+ Summary storage. Rather, use `e_storage_get_toplevel_node_type()'
+ for getting the type of the node.
+
+ * e-shortcuts-view-model.c (get_icon_for_item): New helper
+ function.
+ (shortcuts_update_shortcut_cb): Use it.
+ (shortcuts_new_shortcut_cb): Use it.
+ (load_group_into_model): Use it.
+
2001-08-18 Ettore Perazzoli <ettore@ximian.com>
* e-shell-view.c: New constant `MIN_POPUP_TREE_WIDTH'.
diff --git a/shell/e-shortcuts-view-model.c b/shell/e-shortcuts-view-model.c
index dde93676cf..bc672a7c0f 100644
--- a/shell/e-shortcuts-view-model.c
+++ b/shell/e-shortcuts-view-model.c
@@ -45,6 +45,35 @@ struct _EShortcutsViewModelPrivate {
};
+/* Utility functions. */
+
+static GdkPixbuf *
+get_icon_for_item (EShortcutsViewModel *shortcuts_view_model,
+ const EShortcutItem *item,
+ gboolean want_mini)
+{
+ EShortcutsViewModelPrivate *priv;
+
+ priv = shortcuts_view_model->priv;
+
+ if (item->type != NULL) {
+ EStorageSet *storage_set;
+ EFolderTypeRegistry *folder_type_registry;
+
+ storage_set = e_shortcuts_get_storage_set (priv->shortcuts);
+ folder_type_registry = e_storage_set_get_folder_type_registry (storage_set);
+
+ return e_folder_type_registry_get_icon_for_type (folder_type_registry,
+ item->type,
+ want_mini);
+ }
+
+ g_print ("(%s is not a folder!)\n", item->name);
+
+ return NULL;
+}
+
+
/* View initialization. */
static char *
@@ -61,16 +90,11 @@ load_group_into_model (EShortcutsViewModel *shortcuts_view_model,
int group_num)
{
EShortcutsViewModelPrivate *priv;
- EStorageSet *storage_set;
- EFolderTypeRegistry *folder_type_registry;
const GSList *shortcut_list;
const GSList *p;
priv = shortcuts_view_model->priv;
- storage_set = e_shortcuts_get_storage_set (priv->shortcuts);
- folder_type_registry = e_storage_set_get_folder_type_registry (storage_set);
-
shortcut_list = e_shortcuts_get_shortcuts_in_group (priv->shortcuts, group_num);
if (shortcut_list == NULL)
return;
@@ -81,13 +105,13 @@ load_group_into_model (EShortcutsViewModel *shortcuts_view_model,
item = (const EShortcutItem *) p->data;
name_with_unread = get_name_with_unread (item);
+
e_shortcut_model_add_item (E_SHORTCUT_MODEL (shortcuts_view_model),
group_num, -1,
item->uri,
name_with_unread,
- e_folder_type_registry_get_icon_for_type (folder_type_registry,
- item->type,
- FALSE));
+ get_icon_for_item (shortcuts_view_model, item, FALSE));
+
g_free (name_with_unread);
}
}
@@ -172,16 +196,11 @@ shortcuts_new_shortcut_cb (EShortcuts *shortcuts,
EShortcutsViewModel *shortcuts_view_model;
EShortcutsViewModelPrivate *priv;
const EShortcutItem *shortcut_item;
- EStorageSet *storage_set;
- EFolderTypeRegistry *folder_type_registry;
char *name_with_unread;
shortcuts_view_model = E_SHORTCUTS_VIEW_MODEL (data);
priv = shortcuts_view_model->priv;
- storage_set = e_shortcuts_get_storage_set (priv->shortcuts);
- folder_type_registry = e_storage_set_get_folder_type_registry (storage_set);
-
shortcut_item = e_shortcuts_get_shortcut (priv->shortcuts, group_num, item_num);
g_assert (shortcut_item != NULL);
@@ -190,9 +209,8 @@ shortcuts_new_shortcut_cb (EShortcuts *shortcuts,
group_num, item_num,
shortcut_item->uri,
name_with_unread,
- e_folder_type_registry_get_icon_for_type (folder_type_registry,
- shortcut_item->type,
- FALSE));
+ get_icon_for_item (shortcuts_view_model, shortcut_item, FALSE));
+
g_free (name_with_unread);
}
@@ -216,17 +234,12 @@ shortcuts_update_shortcut_cb (EShortcuts *shortcuts,
{
EShortcutsViewModel *shortcuts_view_model;
EShortcutsViewModelPrivate *priv;
- EFolderTypeRegistry *folder_type_registry;
- EStorageSet *storage_set;
const EShortcutItem *shortcut_item;
char *name_with_unread;
shortcuts_view_model = E_SHORTCUTS_VIEW_MODEL (data);
priv = shortcuts_view_model->priv;
- storage_set = e_shortcuts_get_storage_set (shortcuts);
- folder_type_registry = e_storage_set_get_folder_type_registry (storage_set);
-
shortcut_item = e_shortcuts_get_shortcut (priv->shortcuts, group_num, item_num);
g_assert (shortcut_item != NULL);
@@ -235,9 +248,8 @@ shortcuts_update_shortcut_cb (EShortcuts *shortcuts,
group_num, item_num,
shortcut_item->uri,
name_with_unread,
- e_folder_type_registry_get_icon_for_type (folder_type_registry,
- shortcut_item->type,
- FALSE));
+ get_icon_for_item (shortcuts_view_model, shortcut_item, FALSE));
+
g_free (name_with_unread);
}
diff --git a/shell/e-shortcuts.c b/shell/e-shortcuts.c
index 7dbeaecc9b..5572207e60 100644
--- a/shell/e-shortcuts.c
+++ b/shell/e-shortcuts.c
@@ -338,7 +338,22 @@ load_shortcuts (EShortcuts *shortcuts,
if (folder != NULL) {
if (type != NULL)
xmlFree (type);
- type = g_strdup (e_folder_get_type_string (folder));
+ type = xmlMemStrdup (e_folder_get_type_string (folder));
+ } else {
+ EStorage *storage;
+ const char *storage_type;
+
+ storage = e_storage_set_get_storage (priv->storage_set,
+ uri + E_SHELL_URI_PREFIX_LEN + 1);
+ if (type != NULL)
+ xmlFree (type);
+
+ storage_type = e_storage_get_toplevel_node_type (storage);
+
+ if (storage_type == NULL)
+ type = NULL;
+ else
+ type = xmlMemStrdup (storage_type);
}
}
diff --git a/shell/e-shortcuts.h b/shell/e-shortcuts.h
index 2fc412dfa9..2173b4457a 100644
--- a/shell/e-shortcuts.h
+++ b/shell/e-shortcuts.h
@@ -46,9 +46,17 @@ typedef struct _EShortcutsPrivate EShortcutsPrivate;
typedef struct _EShortcutsClass EShortcutsClass;
struct _EShortcutItem {
+ /* URI of the shortcut. */
char *uri;
+
+ /* Name of the shortcut. */
char *name;
+
+ /* Folder type for the shortcut. If the shortcut doesn't point to a
+ folder, this is NULL. */
char *type;
+
+ /* Number of unread items in the folder. Zero if not a folder. */
int unread_count;
};
typedef struct _EShortcutItem EShortcutItem;
diff --git a/shell/e-storage-set-view.c b/shell/e-storage-set-view.c
index 6a6cbd88b7..a49e00f3bb 100644
--- a/shell/e-storage-set-view.c
+++ b/shell/e-storage-set-view.c
@@ -1350,7 +1350,6 @@ etree_icon_at (ETreeModel *etree,
EFolderTypeRegistry *folder_type_registry;
EStorageSetView *storage_set_view;
EStorageSet *storage_set;
- GdkPixbuf *icon_pixbuf;
EFolder *folder;
char *path;
int depth;
@@ -1361,28 +1360,31 @@ etree_icon_at (ETreeModel *etree,
/* Tree depth will indicate storages or folders */
depth = e_tree_model_node_depth (etree, tree_path);
- path = (char*)e_tree_memory_node_get_data (E_TREE_MEMORY(etree), tree_path);
+ path = (char*) e_tree_memory_node_get_data (E_TREE_MEMORY(etree), tree_path);
+
+ /* Is this a storage? */
+
+ if (depth == 1) {
+ EStorage *storage;
+ const char *storage_type;
+
+ storage = e_storage_set_get_storage (storage_set, path + 1);
- /* Storages, Summary (nee My Evolution) is the only special case for now */
- if (depth == 1 && !strcmp (path, "/summary")) { /* Storages */
-
folder_type_registry = e_storage_set_get_folder_type_registry (storage_set);
-
- icon_pixbuf = e_folder_type_registry_get_icon_for_type (folder_type_registry,
- "Summary", TRUE);
- return icon_pixbuf;
- }
- /* Folders */
- else if (depth >= 2) {
-
- folder = e_storage_set_get_folder (storage_set, path);
- if (folder == NULL)
+ storage_type = e_storage_get_toplevel_node_type (storage);
+ if (storage_type != NULL)
+ return e_folder_type_registry_get_icon_for_type (folder_type_registry, storage_type, TRUE);
+ else
return NULL;
-
- return get_pixbuf_for_folder (storage_set_view, folder);
}
- return NULL;
+ /* Folder. */
+
+ folder = e_storage_set_get_folder (storage_set, path);
+ if (folder == NULL)
+ return NULL;
+
+ return get_pixbuf_for_folder (storage_set_view, folder);
}
/* This function returns the number of columns in our ETreeModel. */