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
This commit is contained in:
@ -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'.
|
||||
|
||||
@ -44,6 +44,35 @@ struct _EShortcutsViewModelPrivate {
|
||||
EShortcuts *shortcuts;
|
||||
};
|
||||
|
||||
|
||||
/* 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. */
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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. */
|
||||
|
||||
Reference in New Issue
Block a user