From 51f77f649b27e6013038c642c532d0547c7fdddd Mon Sep 17 00:00:00 2001 From: Ettore Perazzoli Date: Sun, 12 Aug 2001 14:00:02 +0000 Subject: [Finally! Fix #413, "Support for stock folders", and #786, "i18n: default folder names are not translated".] * e-local-storage.c (setup_folder_as_stock): New helper function. (setup_stock_folders): Use it to set the default folders as "stock" folders. This will give them a translated name and also make them unmodifiable. (load_all_folders): Call `setup_stock_folders()' here. * e-shell-folder-commands.c (delete_cb): Display an error dialog if the deletion fails. (e_shell_command_delete_folder): Pass the shell view to the delete callback. * e-storage.c (e_storage_result_to_string): Add a string for `E_STORAGE_CANTCHANGESTOCKFOLDER' as well. * e-local-storage.c (remove_folder): Don't allow a stock folder to be removed. (impl_async_xfer_folder): Don't allow a stock folder to be moved. * e-corba-storage.c (async_remove_folder): Don't allow a stock folder to be removed. * e-storage.h: New enum value `E_STORAGE_CANTCHANGESTOCKFOLDER' in `EStorageResult'. * e-folder.c: Make member `self_highlight' a :1 int. New :1 int member `is_stock'. (init): Init `is_stock' to %FALSE. (e_folder_set_is_stock): New. (e_folder_get_is_stock): New. * e-local-storage.c (bonobo_interface_update_folder_cb): For now, don't set the display name. svn path=/trunk/; revision=11931 --- shell/ChangeLog | 51 +++++++++++++++++++++++++++++++++++++++++ shell/Evolution-Storage.idl | 8 ------- shell/Evolution-common.idl | 31 +++++++++++++++++++++++++ shell/Evolution.idl | 3 ++- shell/Makefile.am | 1 - shell/e-corba-storage.c | 2 ++ shell/e-folder.c | 31 +++++++++++++++++++++++-- shell/e-folder.h | 2 ++ shell/e-local-folder.c | 9 ++++++-- shell/e-local-storage.c | 45 ++++++++++++++++++++++++++++++++++-- shell/e-shell-folder-commands.c | 10 ++++++-- shell/e-storage-set-view.c | 2 ++ shell/e-storage.c | 2 ++ shell/e-storage.h | 1 + 14 files changed, 180 insertions(+), 18 deletions(-) create mode 100644 shell/Evolution-common.idl diff --git a/shell/ChangeLog b/shell/ChangeLog index a495ccea3a..c99e2c0207 100644 --- a/shell/ChangeLog +++ b/shell/ChangeLog @@ -1,3 +1,54 @@ +2001-08-12 Ettore Perazzoli + + [Finally! Fix #413, "Support for stock folders", and #786, "i18n: + default folder names are not translated".] + + * e-local-storage.c (setup_folder_as_stock): New helper function. + (setup_stock_folders): Use it to set the default folders as + "stock" folders. This will give them a translated name and also + make them unmodifiable. + (load_all_folders): Call `setup_stock_folders()' here. + + * e-shell-folder-commands.c (delete_cb): Display an error dialog + if the deletion fails. + (e_shell_command_delete_folder): Pass the shell view to the delete + callback. + + * e-storage.c (e_storage_result_to_string): Add a string for + `E_STORAGE_CANTCHANGESTOCKFOLDER' as well. + + * e-local-storage.c (remove_folder): Don't allow a stock folder to + be removed. + (impl_async_xfer_folder): Don't allow a stock folder to be moved. + + * e-corba-storage.c (async_remove_folder): Don't allow a stock + folder to be removed. + + * e-storage.h: New enum value `E_STORAGE_CANTCHANGESTOCKFOLDER' in + `EStorageResult'. + + * e-folder.c: Make member `self_highlight' a :1 int. New :1 int + member `is_stock'. + (init): Init `is_stock' to %FALSE. + (e_folder_set_is_stock): New. + (e_folder_get_is_stock): New. + + * e-local-storage.c (bonobo_interface_update_folder_cb): For now, + don't set the display name. + +2001-08-10 Ettore Perazzoli + + * Evolution-common.idl: Add Folder struct here. + + * Evolution-Storage.idl: Removed Folder struct. + + * Evolution.idl: #include , not + . + + * Evolution-common.idl: New. + + * Evolution-Icon.idl: Removed. + 2001-08-10 Ettore Perazzoli * e-shell-folder-commands.c (rename_clicked): `#if 0'ed out. diff --git a/shell/Evolution-Storage.idl b/shell/Evolution-Storage.idl index 2759ef3fbb..6d648b2938 100644 --- a/shell/Evolution-Storage.idl +++ b/shell/Evolution-Storage.idl @@ -12,14 +12,6 @@ module GNOME { module Evolution { - struct Folder { - string type; - string description; - string display_name; - string physical_uri; - long unread_count; - }; - interface Storage; interface StorageListener; diff --git a/shell/Evolution-common.idl b/shell/Evolution-common.idl new file mode 100644 index 0000000000..25f824f612 --- /dev/null +++ b/shell/Evolution-common.idl @@ -0,0 +1,31 @@ +/* -*- Mode: IDL; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* + * Common definitions for the CORBA interface for the Evolution shell. + * + * Authors: + * Ettore Perazzoli + * + * Copyright (C) 2000, 2001 Ximian, Inc. + */ + +module GNOME { +module Evolution { + +struct Folder { + string type; + string description; + string display_name; + string physical_uri; + long unread_count; +}; + +struct Icon { + short width, height; + boolean hasAlpha; + sequence rgba_data; // Row-by-row, left-to-right, top-to-bottom RGBA bytes +}; +typedef sequence AnimatedIcon; + +}; +}; + diff --git a/shell/Evolution.idl b/shell/Evolution.idl index f653d8244f..229b56abaf 100644 --- a/shell/Evolution.idl +++ b/shell/Evolution.idl @@ -10,7 +10,8 @@ #include -#include +#include + #include #include #include diff --git a/shell/Makefile.am b/shell/Makefile.am index b5904ef965..a85307efae 100644 --- a/shell/Makefile.am +++ b/shell/Makefile.am @@ -19,7 +19,6 @@ INCLUDES = -O \ IDLS = \ Evolution-Activity.idl \ - Evolution-Icon.idl \ Evolution-Offline.idl \ Evolution-Session.idl \ Evolution-Shell.idl \ diff --git a/shell/e-corba-storage.c b/shell/e-corba-storage.c index 0805ccbff0..5745ee8fcf 100644 --- a/shell/e-corba-storage.c +++ b/shell/e-corba-storage.c @@ -395,6 +395,8 @@ async_remove_folder (EStorage *storage, const char *path, priv = corba_storage->priv; folder = e_storage_get_folder (storage, path); + if (e_folder_get_is_stock (folder)) + (* callback) (storage, E_STORAGE_CANTCHANGESTOCKFOLDER, data); closure = g_new (struct async_folder_closure, 1); closure->callback = callback; diff --git a/shell/e-folder.c b/shell/e-folder.c index f582c9e40b..017b258766 100644 --- a/shell/e-folder.c +++ b/shell/e-folder.c @@ -41,9 +41,12 @@ struct _EFolderPrivate { char *type; char *description; char *physical_uri; - gboolean self_highlight; + int child_highlight; int unread_count; + + int self_highlight : 1; + int is_stock : 1; }; #define EF_CLASS(obj) \ @@ -148,9 +151,10 @@ init (EFolder *folder) priv->name = NULL; priv->description = NULL; priv->physical_uri = NULL; - priv->self_highlight = FALSE; priv->child_highlight = 0; priv->unread_count = 0; + priv->self_highlight = FALSE; + priv->is_stock = FALSE; folder->priv = priv; } @@ -251,6 +255,15 @@ e_folder_get_highlighted (EFolder *folder) return folder->priv->child_highlight || folder->priv->unread_count; } +gboolean +e_folder_get_is_stock (EFolder *folder) +{ + g_return_val_if_fail (folder != NULL, FALSE); + g_return_val_if_fail (E_IS_FOLDER (folder), FALSE); + + return folder->priv->is_stock; +} + void e_folder_set_name (EFolder *folder, @@ -327,11 +340,25 @@ e_folder_set_child_highlight (EFolder *folder, g_return_if_fail (folder != NULL); g_return_if_fail (E_IS_FOLDER (folder)); + /* FIXME: Doesn't emit CHANGED. */ + if (highlighted) folder->priv->child_highlight++; else folder->priv->child_highlight--; } +void +e_folder_set_is_stock (EFolder *folder, + gboolean is_stock) +{ + g_return_if_fail (folder != NULL); + g_return_if_fail (E_IS_FOLDER (folder)); + + folder->priv->is_stock = !! is_stock; + + gtk_signal_emit (GTK_OBJECT (folder), signals[CHANGED]); +} + E_MAKE_TYPE (e_folder, "EFolder", EFolder, class_init, init, PARENT_TYPE) diff --git a/shell/e-folder.h b/shell/e-folder.h index df4321f3f4..45e86c4064 100644 --- a/shell/e-folder.h +++ b/shell/e-folder.h @@ -77,6 +77,7 @@ const char *e_folder_get_description (EFolder *folder); const char *e_folder_get_physical_uri (EFolder *folder); int e_folder_get_unread_count (EFolder *folder); gboolean e_folder_get_highlighted (EFolder *folder); +gboolean e_folder_get_is_stock (EFolder *folder); void e_folder_set_name (EFolder *folder, const char *name); void e_folder_set_type_string (EFolder *folder, const char *type); @@ -84,6 +85,7 @@ void e_folder_set_description (EFolder *folder, const char *description); void e_folder_set_physical_uri (EFolder *folder, const char *physical_uri); void e_folder_set_unread_count (EFolder *folder, int unread_count); void e_folder_set_child_highlight (EFolder *folder, gboolean highlighted); +void e_folder_set_is_stock (EFolder *folder, gboolean is_stock); #ifdef __cplusplus } diff --git a/shell/e-local-folder.c b/shell/e-local-folder.c index 2b79820da3..49fdc0ff22 100644 --- a/shell/e-local-folder.c +++ b/shell/e-local-folder.c @@ -26,12 +26,17 @@ mail - This is the folder where I store mail from my gf + + Inbox + Posta in Arrivo + + This is the default folder for incoming messages + Cartella che contiene i messaggi in arrivo + http://www.somewhere.net FIXME: Do we want to use a namespace for this? - FIXME: Do we want to have an internationalized description? */ #ifdef HAVE_CONFIG_H diff --git a/shell/e-local-storage.c b/shell/e-local-storage.c index 61bd85777e..3281f0bb58 100644 --- a/shell/e-local-storage.c +++ b/shell/e-local-storage.c @@ -146,6 +146,36 @@ new_folder (ELocalStorage *local_storage, e_folder_get_unread_count (folder)); } +static gboolean +setup_folder_as_stock (ELocalStorage *local_storage, + const char *path, + const char *name) +{ + EFolder *folder; + + folder = e_storage_get_folder (E_STORAGE (local_storage), path); + if (folder == NULL) + return FALSE; + + e_folder_set_name (folder, name); + e_folder_set_is_stock (folder, TRUE); + + return TRUE; +} + +static void +setup_stock_folders (ELocalStorage *local_storage) +{ + setup_folder_as_stock (local_storage, "/Calendar", _("Calendar")); + setup_folder_as_stock (local_storage, "/Contacts", _("Contacts")); + setup_folder_as_stock (local_storage, "/Drafts", _("Drafts")); + setup_folder_as_stock (local_storage, "/Inbox", _("Inbox")); + setup_folder_as_stock (local_storage, "/Outbox", _("Outbox")); + setup_folder_as_stock (local_storage, "/Sent", _("Sent")); + setup_folder_as_stock (local_storage, "/Tasks", _("Tasks")); + setup_folder_as_stock (local_storage, "/Trash", _("Trash")); +} + static gboolean load_folder (const char *physical_path, const char *path, gpointer data) { @@ -169,7 +199,12 @@ load_all_folders (ELocalStorage *local_storage) base_path = e_local_storage_get_base_path (local_storage); - return e_path_find_folders (base_path, load_folder, local_storage); + if (! e_path_find_folders (base_path, load_folder, local_storage)) + return FALSE; + + setup_stock_folders (local_storage); + + return TRUE; } @@ -472,6 +507,9 @@ remove_folder (ELocalStorage *local_storage, storage = E_STORAGE (local_storage); folder = e_storage_get_folder (storage, path); + if (e_folder_get_is_stock (folder)) + return E_STORAGE_CANTCHANGESTOCKFOLDER; + component_client = e_folder_type_registry_get_handler_for_type (priv->folder_type_registry, e_folder_get_type_string (folder)); if (component_client == NULL) @@ -816,6 +854,9 @@ impl_async_xfer_folder (EStorage *storage, local_storage = E_LOCAL_STORAGE (storage); priv = local_storage->priv; + if (remove_source && e_folder_get_is_stock (e_storage_get_folder (storage, source_path))) + (* callback) (storage, E_STORAGE_CANTCHANGESTOCKFOLDER, callback_data); + folder_items = NULL; append_xfer_item_list (storage, g_strdup (source_path), g_strdup (destination_path), &folder_items); folder_items = g_list_reverse (folder_items); /* lame */ @@ -884,7 +925,7 @@ bonobo_interface_update_folder_cb (EvolutionStorage *storage, if (folder == NULL) return; - e_folder_set_name (folder, display_name); + /* e_folder_set_name (folder, display_name); */ e_folder_set_unread_count (folder, unread_count); return; diff --git a/shell/e-shell-folder-commands.c b/shell/e-shell-folder-commands.c index 831a2458d5..5eed7fcc3e 100644 --- a/shell/e-shell-folder-commands.c +++ b/shell/e-shell-folder-commands.c @@ -348,7 +348,13 @@ delete_cb (EStorageSet *storage_set, EStorageResult result, void *data) { - /* FIXME: Do something? */ + EShellView *shell_view; + + shell_view = E_SHELL_VIEW (data); + + if (result != E_STORAGE_OK) + e_notice (GTK_WINDOW (shell_view), GNOME_MESSAGE_BOX_ERROR, + _("Cannot delete folder:\n%s"), e_storage_result_to_string (result)); } static int @@ -412,7 +418,7 @@ e_shell_command_delete_folder (EShell *shell, e_storage_set_async_remove_folder (storage_set, path, delete_cb, - NULL); + shell_view); /* Select another folder to prevent bad things from happening */ e_shell_view_display_uri (shell_view, DEFAULT_URI); diff --git a/shell/e-storage-set-view.c b/shell/e-storage-set-view.c index 461b05411d..a333b9eb7b 100644 --- a/shell/e-storage-set-view.c +++ b/shell/e-storage-set-view.c @@ -1438,6 +1438,8 @@ etree_value_at (ETreeModel *etree, ETreePath tree_path, int col, void *model_dat const char *folder_name = e_folder_get_name (folder); int unread_count = e_folder_get_unread_count (folder); + g_print ("Display: %s (%p) -- %s\n", path, folder, folder_name); + if (unread_count > 0) gtk_object_set_data_full (GTK_OBJECT (folder), "name_with_unread", g_strdup_printf ("%s (%d)", folder_name, unread_count), g_free); diff --git a/shell/e-storage.c b/shell/e-storage.c index 00f07f0250..3ef8041d8a 100644 --- a/shell/e-storage.c +++ b/shell/e-storage.c @@ -497,6 +497,8 @@ e_storage_result_to_string (EStorageResult result) return _("Operation not supported"); case E_STORAGE_UNSUPPORTEDTYPE: return _("The specified type is not supported in this storage"); + case E_STORAGE_CANTCHANGESTOCKFOLDER: + return _("The specified folder cannot be modified or removed"); default: return _("Unknown error"); } diff --git a/shell/e-storage.h b/shell/e-storage.h index 91afa759f5..ea3ab52ea1 100644 --- a/shell/e-storage.h +++ b/shell/e-storage.h @@ -57,6 +57,7 @@ enum _EStorageResult { E_STORAGE_PERMISSIONDENIED, E_STORAGE_UNSUPPORTEDOPERATION, E_STORAGE_UNSUPPORTEDTYPE, + E_STORAGE_CANTCHANGESTOCKFOLDER, E_STORAGE_INVALIDNAME }; typedef enum _EStorageResult EStorageResult; -- cgit