diff options
author | Ettore Perazzoli <ettore@src.gnome.org> | 2001-08-20 09:22:09 +0800 |
---|---|---|
committer | Ettore Perazzoli <ettore@src.gnome.org> | 2001-08-20 09:22:09 +0800 |
commit | 6bf0ba97e25261e2efc5c685c08cf52a75816d3b (patch) | |
tree | 120c8f1df9cfb71890d4c708a4ba878a8ac35e7f /shell/e-shortcuts-view-model.c | |
parent | ee70366b8e7092300fff8a421efa3ff84c5bcf7a (diff) | |
download | gsoc2013-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
Diffstat (limited to 'shell/e-shortcuts-view-model.c')
-rw-r--r-- | shell/e-shortcuts-view-model.c | 60 |
1 files changed, 36 insertions, 24 deletions
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); } |