From 779e0f5058e089279c2851e18ef7003ec88bb61f Mon Sep 17 00:00:00 2001 From: Ettore Perazzoli Date: Tue, 9 Jul 2002 17:06:19 +0000 Subject: Call e_icon_factory_init(). * main.c (main): Call e_icon_factory_init(). * e-local-storage.c (setup_folder_as_stock): New arg @icon_name; if not NULL, set up a custom icon for the folder. (setup_stock_folders): Set up custom icons for inbox and outbox. * e-storage-set-view.c (get_pixbuf_for_folder): If the folder has a custom icon, return the custom icon. * e-folder.c: New member custom_icon_name. (init): Initialize to NULL. (destroy): Free. (e_folder_get_custom_icon): New. (e_folder_set_custom_icon): New. svn path=/trunk/; revision=17391 --- shell/e-folder.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 51 insertions(+), 4 deletions(-) (limited to 'shell/e-folder.c') diff --git a/shell/e-folder.c b/shell/e-folder.c index 6f78e48db3..0dd6c1ff10 100644 --- a/shell/e-folder.c +++ b/shell/e-folder.c @@ -49,6 +49,10 @@ struct _EFolderPrivate { unsigned int self_highlight : 1; unsigned int is_stock : 1; unsigned int can_sync_offline : 1; + + /* Custom icon for this folder; if NULL the folder will just use the + icon for its type. */ + char *custom_icon_name; }; #define EF_CLASS(obj) \ @@ -112,6 +116,8 @@ destroy (GtkObject *object) g_free (priv->description); g_free (priv->physical_uri); + g_free (priv->custom_icon_name); + g_free (priv); (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); @@ -158,6 +164,7 @@ init (EFolder *folder) priv->self_highlight = FALSE; priv->is_stock = FALSE; priv->can_sync_offline = FALSE; + priv->custom_icon_name = NULL; folder->priv = priv; } @@ -267,6 +274,29 @@ e_folder_get_is_stock (EFolder *folder) return folder->priv->is_stock; } +gboolean +e_folder_get_can_sync_offline (EFolder *folder) +{ + g_return_val_if_fail (E_IS_FOLDER (folder), FALSE); + + return folder->priv->can_sync_offline; +} + +/** + * e_folder_get_custom_icon: + * @folder: An EFolder + * + * Get the name of the custom icon for @folder, or NULL if no custom icon is + * associated with it + **/ +const char * +e_folder_get_custom_icon_name (EFolder *folder) +{ + g_return_val_if_fail (E_IS_FOLDER (folder), NULL); + + return folder->priv->custom_icon_name; +} + void e_folder_set_name (EFolder *folder, @@ -380,12 +410,29 @@ e_folder_set_can_sync_offline (EFolder *folder, gtk_signal_emit (GTK_OBJECT (folder), signals[CHANGED]); } -gboolean -e_folder_get_can_sync_offline (EFolder *folder) +/** + * e_folder_set_custom_icon_name: + * @folder: An EFolder + * @icon_name: Name of the icon to be set (to be found in the standard + * Evolution icon dir) + * + * Set a custom icon for @folder (thus overriding the default icon, which is + * the one associated to the type of the folder). + **/ +void +e_folder_set_custom_icon (EFolder *folder, + const char *icon_name) { - g_return_val_if_fail (E_IS_FOLDER (folder), FALSE); + g_return_if_fail (E_IS_FOLDER (folder)); - return folder->priv->can_sync_offline; + if (icon_name != folder->priv->custom_icon_name) { + g_free (folder->priv->custom_icon_name); + + if (icon_name == NULL) + folder->priv->custom_icon_name = NULL; + else + folder->priv->custom_icon_name = g_strdup (icon_name); + } } -- cgit v1.2.3