diff options
author | Jason Leach <jleach@ximian.com> | 2001-08-04 07:08:38 +0800 |
---|---|---|
committer | Jacob Leach <jleach@src.gnome.org> | 2001-08-04 07:08:38 +0800 |
commit | 385ba85d425e59a0a254abef620a90bd563cdeb8 (patch) | |
tree | 53fd4b38568a19463f8c33d4706c729f4febb7f7 | |
parent | 308aaf47ea788683b47a600d6c6f31563d7ee070 (diff) | |
download | gsoc2013-evolution-385ba85d425e59a0a254abef620a90bd563cdeb8.tar.gz gsoc2013-evolution-385ba85d425e59a0a254abef620a90bd563cdeb8.tar.zst gsoc2013-evolution-385ba85d425e59a0a254abef620a90bd563cdeb8.zip |
[Removing Evolution::LocalStorage interface, abstracting the unread counts
2001-08-03 Jason Leach <jleach@ximian.com>
[Removing Evolution::LocalStorage interface, abstracting the
unread counts from a folder's name, also abstract unread counts
from a shortcut's name. Fixes #4489 and #5497]
* e-shortcuts.c (shortcut_item_new): Take an unread_count argument
now.
(shortcut_item_update): Ditto.
* e-shortcuts-view-model.c (get_name_with_unread): Get a string
containing a shortcut name and it's unread, because these are
abstracted now.
(load_group_into_model): Use the above function to make shortcuts
that have unread counts.
* e-storage-set-view.c (update_folder_with_unread_hash): Keep a
hash of folder names with unread counts, because the folder name
and it's unread count are to be separated, only the ETree is
supposed to present it as one string.
* e-shell-view.c: Renamed EShellView::view_title_bar to
folder_title_bar, to closer match the
* e-shell-view-menu.c (new_shortcut_dialog_folder_selected_cb):
Make a shortcut with the unread count.
* e-shell-folder-commands.c (e_shell_command_add_to_shortcut_bar):
Make a shortcut with the unread count.
* e-local-storage.c: Updated for API changes.
* e-folder.c (e_folder_get_unread_count): New function, does what
it says.
(e_folder_set_unread_count): Ditto.
* e-corba-storage.c (impl_StorageListener_new_folder): Renamed to
match the IDL function name.
(impl_StorageListener_update_folder): Ditto.
(impl_StorageListener_removed_folder): Ditto.
* Evolution-Storage.idl (struct Folder): Replace the boolean
highlighted with a long unread_count.
(updateFolder): Brought in from the now dead
Evolution::LocalStorage.
* Evolution-Shell.idl (getLocalStorage): Return a Storage instead
of a LocalStorage.
* Evolution-LocalStorage.idl: Removed, no longer needed, only used
function, updateFolder, has been moved into Evolution::Storage
interface.
* evolution-local-storage.[ch]: Ditto.
* evolution-storage.c (impl_Storage_updateFolder): Implementation
of the updateFolder taken from ::LocalStorage.
(class_init): New "update_folder" signal, taken from
evolution-local-storage.c too.
(evolution_storage_update_folder): Take an @unread_count int
instead of a @highlighted boolean.
(evolution_storage_new_folder): Same for here.
(evolution_storage_update_folder_by_uri): And here.
* evolution-storage-listener.h: "update_folder" signal no longer
sends a @highlighted boolean.
2001-08-03 Jason Leach <jleach@ximian.com>
* e-shell-view-menu.c (update_offline_menu_item): Use Jakub's new
"Work Online" icon and fix a typo.
svn path=/trunk/; revision=11633
31 files changed, 560 insertions, 493 deletions
diff --git a/shell/ChangeLog b/shell/ChangeLog index ab2b66a07f..f4e4a7b9a5 100644 --- a/shell/ChangeLog +++ b/shell/ChangeLog @@ -1,3 +1,75 @@ +2001-08-03 Jason Leach <jleach@ximian.com> + + [Removing Evolution::LocalStorage interface, abstracting the + unread counts from a folder's name, also abstract unread counts + from a shortcut's name. Fixes #4489 and #5497] + + * e-shortcuts.c (shortcut_item_new): Take an unread_count argument + now. + (shortcut_item_update): Ditto. + + * e-shortcuts-view-model.c (get_name_with_unread): Get a string + containing a shortcut name and it's unread, because these are + abstracted now. + (load_group_into_model): Use the above function to make shortcuts + that have unread counts. + + * e-storage-set-view.c (update_folder_with_unread_hash): Keep a + hash of folder names with unread counts, because the folder name + and it's unread count are to be separated, only the ETree is + supposed to present it as one string. + + * e-shell-view.c: Renamed EShellView::view_title_bar to + folder_title_bar, to closer match the + + * e-shell-view-menu.c (new_shortcut_dialog_folder_selected_cb): + Make a shortcut with the unread count. + + * e-shell-folder-commands.c (e_shell_command_add_to_shortcut_bar): + Make a shortcut with the unread count. + + * e-local-storage.c: Updated for API changes. + + * e-folder.c (e_folder_get_unread_count): New function, does what + it says. + (e_folder_set_unread_count): Ditto. + + * e-corba-storage.c (impl_StorageListener_new_folder): Renamed to + match the IDL function name. + (impl_StorageListener_update_folder): Ditto. + (impl_StorageListener_removed_folder): Ditto. + + * Evolution-Storage.idl (struct Folder): Replace the boolean + highlighted with a long unread_count. + (updateFolder): Brought in from the now dead + Evolution::LocalStorage. + + * Evolution-Shell.idl (getLocalStorage): Return a Storage instead + of a LocalStorage. + + * Evolution-LocalStorage.idl: Removed, no longer needed, only used + function, updateFolder, has been moved into Evolution::Storage + interface. + + * evolution-local-storage.[ch]: Ditto. + + * evolution-storage.c (impl_Storage_updateFolder): Implementation + of the updateFolder taken from ::LocalStorage. + (class_init): New "update_folder" signal, taken from + evolution-local-storage.c too. + (evolution_storage_update_folder): Take an @unread_count int + instead of a @highlighted boolean. + (evolution_storage_new_folder): Same for here. + (evolution_storage_update_folder_by_uri): And here. + + * evolution-storage-listener.h: "update_folder" signal no longer + sends a @highlighted boolean. + +2001-08-03 Jason Leach <jleach@ximian.com> + + * e-shell-view-menu.c (update_offline_menu_item): Use Jakub's new + "Work Online" icon and fix a typo. + 2001-08-03 Ettore Perazzoli <ettore@ximian.com> [Fix #6232, the thirty-four-splash-screens-at-startup bug.] diff --git a/shell/Evolution-LocalStorage.idl b/shell/Evolution-LocalStorage.idl deleted file mode 100644 index 859c618e48..0000000000 --- a/shell/Evolution-LocalStorage.idl +++ /dev/null @@ -1,31 +0,0 @@ -/* -*- Mode: IDL; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Interface for the Evolution local storage. - * - * Authors: - * Ettore Perazzoli <ettore@ximian.com> - * - * Copyright (C) 2000, 2001 Ximian, Inc. - */ - -#include <Bonobo.idl> - -module GNOME { -module Evolution { - interface LocalStorage : Evolution::Storage { - /** - * update_folder: - * @path: Path of a folder within the storage. - * @display_name: Name to be displayed in the tree view for - * this folder - * @highlighted: Whether or not to highlight the name. - * - * Set the name to display for the folder at the specified - * @path. - */ - void updateFolder (in string path, - in string display_name, - in boolean highlighted); - }; -}; -}; diff --git a/shell/Evolution-Shell.idl b/shell/Evolution-Shell.idl index b99f49abab..86d54741c9 100644 --- a/shell/Evolution-Shell.idl +++ b/shell/Evolution-Shell.idl @@ -87,7 +87,7 @@ module Evolution { * * Return value: the `Evolution::LocalStorage' interface for * the local storage. */ - LocalStorage getLocalStorage (); + Storage getLocalStorage (); /** * createStorageSetView: diff --git a/shell/Evolution-Storage.idl b/shell/Evolution-Storage.idl index 9681d32be1..2759ef3fbb 100644 --- a/shell/Evolution-Storage.idl +++ b/shell/Evolution-Storage.idl @@ -17,7 +17,7 @@ module Evolution { string description; string display_name; string physical_uri; - boolean highlighted; + long unread_count; }; interface Storage; @@ -62,6 +62,10 @@ module Evolution { in boolean remove_source, in Bonobo::Listener listener); + void updateFolder (in string path, + in string display_name, + in long unread_count); + void addListener (in StorageListener listener) raises (AlreadyListening); @@ -83,7 +87,7 @@ module Evolution { void notifyFolderUpdated (in string path, in string display_name, - in boolean highlighted) + in long unread_count) raises (NotFound); void notifyFolderRemoved (in string path) diff --git a/shell/Evolution.idl b/shell/Evolution.idl index 1408699c6b..79ae7b143a 100644 --- a/shell/Evolution.idl +++ b/shell/Evolution.idl @@ -19,5 +19,4 @@ #include <Evolution-ShellView.idl> #include <Evolution-Storage.idl> #include <Evolution-StorageSetView.idl> -#include <Evolution-LocalStorage.idl> #include <Evolution-Shell.idl> diff --git a/shell/Makefile.am b/shell/Makefile.am index 474d11210b..2b5f318b7e 100644 --- a/shell/Makefile.am +++ b/shell/Makefile.am @@ -20,7 +20,6 @@ INCLUDES = -O \ IDLS = \ Evolution-Activity.idl \ Evolution-Icon.idl \ - Evolution-LocalStorage.idl \ Evolution-Offline.idl \ Evolution-Session.idl \ Evolution-Shell.idl \ @@ -60,7 +59,6 @@ eshellinclude_HEADERS = \ Evolution.h \ e-folder-tree.h \ evolution-activity-client.h \ - evolution-local-storage.h \ evolution-session.h \ evolution-shell-client.h \ evolution-shell-component-client.h \ @@ -76,7 +74,6 @@ libeshell_la_SOURCES = \ $(IDL_GENERATED) \ e-folder-tree.c \ evolution-activity-client.c \ - evolution-local-storage.c \ evolution-session.c \ evolution-shell-client.c \ evolution-shell-component-client.c \ diff --git a/shell/e-corba-storage.c b/shell/e-corba-storage.c index b642848107..0805ccbff0 100644 --- a/shell/e-corba-storage.c +++ b/shell/e-corba-storage.c @@ -93,10 +93,10 @@ impl_StorageListener_destroy (PortableServer_Servant servant, #endif static void -impl_StorageListener_new_folder (PortableServer_Servant servant, - const CORBA_char *path, - const GNOME_Evolution_Folder *folder, - CORBA_Environment *ev) +impl_StorageListener_notifyFolderCreated (PortableServer_Servant servant, + const CORBA_char *path, + const GNOME_Evolution_Folder *folder, + CORBA_Environment *ev) { StorageListenerServant *storage_listener_servant; EStorage *storage; @@ -110,7 +110,6 @@ impl_StorageListener_new_folder (PortableServer_Servant servant, folder->description); e_folder_set_physical_uri (e_folder, folder->physical_uri); - e_folder_set_highlighted (e_folder, folder->highlighted); if (! e_storage_new_folder (storage, path, e_folder)) { g_print ("Cannot register folder -- %s %s\n", path, folder->display_name); @@ -126,11 +125,11 @@ impl_StorageListener_new_folder (PortableServer_Servant servant, } static void -impl_StorageListener_update_folder (PortableServer_Servant servant, - const CORBA_char *path, - const CORBA_char *display_name, - CORBA_boolean highlighted, - CORBA_Environment *ev) +impl_StorageListener_notifyFolderUpdated (PortableServer_Servant servant, + const CORBA_char *path, + const CORBA_char *display_name, + CORBA_long unread_count, + CORBA_Environment *ev) { StorageListenerServant *storage_listener_servant; EStorage *storage; @@ -149,13 +148,13 @@ impl_StorageListener_update_folder (PortableServer_Servant servant, } e_folder_set_name (e_folder, display_name); - e_folder_set_highlighted (e_folder, highlighted); + e_folder_set_unread_count (e_folder, unread_count); } static void -impl_StorageListener_removed_folder (PortableServer_Servant servant, - const CORBA_char *path, - CORBA_Environment *ev) +impl_StorageListener_notifyFolderRemoved (PortableServer_Servant servant, + const CORBA_char *path, + CORBA_Environment *ev) { StorageListenerServant *storage_listener_servant; EStorage *storage; @@ -266,7 +265,6 @@ get_name (EStorage *storage) return priv->name; } - static const char * get_display_name (EStorage *storage) { @@ -434,9 +432,9 @@ corba_class_init (void) base_epv->default_POA = NULL; epv = g_new0 (POA_GNOME_Evolution_StorageListener__epv, 1); - epv->notifyFolderCreated = impl_StorageListener_new_folder; - epv->notifyFolderUpdated = impl_StorageListener_update_folder; - epv->notifyFolderRemoved = impl_StorageListener_removed_folder; + epv->notifyFolderCreated = impl_StorageListener_notifyFolderCreated; + epv->notifyFolderUpdated = impl_StorageListener_notifyFolderUpdated; + epv->notifyFolderRemoved = impl_StorageListener_notifyFolderRemoved; vepv = &storage_listener_vepv; vepv->_base_epv = base_epv; diff --git a/shell/e-folder.c b/shell/e-folder.c index 86d2cf90f7..f582c9e40b 100644 --- a/shell/e-folder.c +++ b/shell/e-folder.c @@ -43,6 +43,7 @@ struct _EFolderPrivate { char *physical_uri; gboolean self_highlight; int child_highlight; + int unread_count; }; #define EF_CLASS(obj) \ @@ -149,6 +150,7 @@ init (EFolder *folder) priv->physical_uri = NULL; priv->self_highlight = FALSE; priv->child_highlight = 0; + priv->unread_count = 0; folder->priv = priv; } @@ -231,13 +233,22 @@ e_folder_get_physical_uri (EFolder *folder) return folder->priv->physical_uri; } +int +e_folder_get_unread_count (EFolder *folder) +{ + g_return_val_if_fail (folder != NULL, FALSE); + g_return_val_if_fail (E_IS_FOLDER (folder), FALSE); + + return folder->priv->unread_count; +} + gboolean e_folder_get_highlighted (EFolder *folder) { g_return_val_if_fail (folder != NULL, FALSE); g_return_val_if_fail (E_IS_FOLDER (folder), FALSE); - return folder->priv->self_highlight || folder->priv->child_highlight; + return folder->priv->child_highlight || folder->priv->unread_count; } @@ -298,13 +309,13 @@ e_folder_set_physical_uri (EFolder *folder, } void -e_folder_set_highlighted (EFolder *folder, - gboolean highlighted) +e_folder_set_unread_count (EFolder *folder, + gint unread_count) { g_return_if_fail (folder != NULL); g_return_if_fail (E_IS_FOLDER (folder)); - folder->priv->self_highlight = highlighted; + folder->priv->unread_count = unread_count; gtk_signal_emit (GTK_OBJECT (folder), signals[CHANGED]); } @@ -320,8 +331,6 @@ e_folder_set_child_highlight (EFolder *folder, folder->priv->child_highlight++; else folder->priv->child_highlight--; - - gtk_signal_emit (GTK_OBJECT (folder), signals[CHANGED]); } diff --git a/shell/e-folder.h b/shell/e-folder.h index 2eee4dad26..df4321f3f4 100644 --- a/shell/e-folder.h +++ b/shell/e-folder.h @@ -75,13 +75,14 @@ const char *e_folder_get_name (EFolder *folder); const char *e_folder_get_type_string (EFolder *folder); 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); void e_folder_set_name (EFolder *folder, const char *name); void e_folder_set_type_string (EFolder *folder, const char *type); 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_highlighted (EFolder *folder, gboolean highlighted); +void e_folder_set_unread_count (EFolder *folder, int unread_count); void e_folder_set_child_highlight (EFolder *folder, gboolean highlighted); #ifdef __cplusplus diff --git a/shell/e-local-storage.c b/shell/e-local-storage.c index cc92c43329..61bd85777e 100644 --- a/shell/e-local-storage.c +++ b/shell/e-local-storage.c @@ -28,9 +28,6 @@ * - If the LocalStorage is destroyed and an async operation on a shell component is * pending, we get a callback on a bogus object. We need support for cancelling * operations on the shell component. - * - * - The tree is kept both in the EStorage and the EvolutionStorage. Very - * bad design. */ #ifdef HAVE_CONFIG_H @@ -53,7 +50,7 @@ #include "e-util/e-path.h" #include "e-local-folder.h" -#include "evolution-local-storage.h" +#include "evolution-storage.h" #include "e-local-storage.h" @@ -64,7 +61,7 @@ static EStorageClass *parent_class = NULL; struct _ELocalStoragePrivate { EFolderTypeRegistry *folder_type_registry; char *base_path; - EvolutionLocalStorage *bonobo_interface; + EvolutionStorage *bonobo_interface; }; @@ -146,7 +143,7 @@ new_folder (ELocalStorage *local_storage, e_folder_get_type_string (folder), e_folder_get_physical_uri (folder), e_folder_get_description (folder), - e_folder_get_highlighted (folder)); + e_folder_get_unread_count (folder)); } static gboolean @@ -842,7 +839,7 @@ impl_async_xfer_folder (EStorage *storage, } -/* Callbacks for the `Evolution::LocalStorage' interface we are exposing to the outside world. */ +/* Callbacks for the `Evolution::Storage' interface we are exposing to the outside world. */ static int bonobo_interface_create_folder_cb (EvolutionStorage *storage, const char *path, @@ -872,10 +869,10 @@ bonobo_interface_remove_folder_cb (EvolutionStorage *storage, } static void -bonobo_interface_update_folder_cb (EvolutionLocalStorage *bonobo_local_storage, +bonobo_interface_update_folder_cb (EvolutionStorage *storage, const char *path, const char *display_name, - gboolean highlighted, + int unread_count, void *data) { ELocalStorage *local_storage; @@ -888,7 +885,7 @@ bonobo_interface_update_folder_cb (EvolutionLocalStorage *bonobo_local_storage, return; e_folder_set_name (folder, display_name); - e_folder_set_highlighted (folder, highlighted); + e_folder_set_unread_count (folder, unread_count); return; } @@ -956,7 +953,8 @@ construct (ELocalStorage *local_storage, priv->base_path = g_strndup (base_path, base_path_len); g_assert (priv->bonobo_interface == NULL); - priv->bonobo_interface = evolution_local_storage_new (E_LOCAL_STORAGE_NAME); + priv->bonobo_interface = evolution_storage_new (E_LOCAL_STORAGE_NAME, + NULL, NULL); gtk_signal_connect (GTK_OBJECT (priv->bonobo_interface), "create_folder", GTK_SIGNAL_FUNC (bonobo_interface_create_folder_cb), @@ -1001,11 +999,11 @@ e_local_storage_get_base_path (ELocalStorage *local_storage) } -const GNOME_Evolution_LocalStorage +const GNOME_Evolution_Storage e_local_storage_get_corba_interface (ELocalStorage *local_storage) { ELocalStoragePrivate *priv; - GNOME_Evolution_LocalStorage corba_interface; + GNOME_Evolution_Storage corba_interface; g_return_val_if_fail (local_storage != NULL, NULL); g_return_val_if_fail (E_IS_LOCAL_STORAGE (local_storage), NULL); diff --git a/shell/e-local-storage.h b/shell/e-local-storage.h index f844c34bb4..10ca804cb5 100644 --- a/shell/e-local-storage.h +++ b/shell/e-local-storage.h @@ -62,7 +62,7 @@ EStorage *e_local_storage_open (EFolderTypeR const char *base_path); const char *e_local_storage_get_base_path (ELocalStorage *storage); -const GNOME_Evolution_LocalStorage e_local_storage_get_corba_interface (ELocalStorage *storage); +const GNOME_Evolution_Storage e_local_storage_get_corba_interface (ELocalStorage *storage); #ifdef __cplusplus } diff --git a/shell/e-shell-folder-commands.c b/shell/e-shell-folder-commands.c index 1f4b473e17..bf9cda678b 100644 --- a/shell/e-shell-folder-commands.c +++ b/shell/e-shell-folder-commands.c @@ -37,6 +37,7 @@ #include <gtk/gtklabel.h> #include <gtk/gtksignal.h> +#include <gtk/gtkentry.h> #include "e-shell-constants.h" #include "e-shell-folder-creation-dialog.h" @@ -58,6 +59,19 @@ get_folder_name (EShell *shell, return e_folder_get_name (folder); } +static int +get_folder_unread (EShell *shell, + const char *path) +{ + EStorageSet *storage_set; + EFolder *folder; + + storage_set = e_shell_get_storage_set (shell); + folder = e_storage_set_get_folder (storage_set, path); + + return e_folder_get_unread_count (folder); +} + /* The data passed to the signals handled during the execution of the folder commands. */ @@ -348,7 +362,6 @@ delete_dialog (EShellView *shell_view, const char *utf8_folder) /* Popup a dialog asking if they are sure they want to delete the folder */ - folder_name = e_utf8_to_gtk_string (GTK_WIDGET (shell_view), (char *)utf8_folder); title = g_strdup_printf (_("Delete folder '%s'"), folder_name); @@ -360,6 +373,7 @@ delete_dialog (EShellView *shell_view, const char *utf8_folder) g_free (title); gnome_dialog_set_parent (dialog, GTK_WINDOW (shell_view)); + /* "Are you sure..." label */ question = g_strdup_printf (_("Are you sure you want to remove the '%s' folder?"), folder_name); question_label = gtk_label_new (question); @@ -407,6 +421,16 @@ e_shell_command_delete_folder (EShell *shell, g_free (path); } +static void +rename_clicked (GtkWidget *dialog, gint button_num, void *data) +{ + char **retval = data; + GtkWidget *entry; + + entry = gtk_object_get_data (GTK_OBJECT (dialog), "entry"); + *retval = g_strdup (gtk_entry_get_text (GTK_ENTRY (entry))); +} + #if 0 static char * rename_dialog (char *folder_name) @@ -414,35 +438,113 @@ rename_dialog (char *folder_name) GnomeDialog *dialog; int result; char *title; - GtkWidget *question_label; + GtkWidget *hbox; + char *label; + GtkWidget *prompt_label; GtkWidget *entry; char *question; + char *retval; - + /* Popup a dialog asking what the user would like to rename + the folder to */ title = g_strdup_printf (_("Rename folder '%s'"), folder_name); dialog = GNOME_DIALOG (gnome_dialog_new (title, - GNOME_STOCK_BUTTON_OK, + _("Rename"), GNOME_STOCK_BUTTON_CANCEL, NULL)); g_free (title); - /* FIXME: Finish then make command_rename_folder use it */ + hbox = gtk_hbox_new (FALSE, 2); + + /* Make, pack the label */ + label = g_strdup_printf (_("Folder name:")); + prompt_label = gtk_label_new (label); + gtk_box_pack_start (GTK_BOX (hbox), prompt_label, FALSE, TRUE, 2); + + /* Make, setup, pack the entry */ + entry = gtk_entry_new (); + gtk_entry_set_text (GTK_ENTRY (entry), folder_name); + gtk_box_pack_start (GTK_BOX (hbox), entry, FALSE, TRUE, 2); + + gtk_widget_show (GTK_WIDGET (prompt_label)); + gtk_widget_show (GTK_WIDGET (entry)); + gtk_widget_show (GTK_WIDGET (hbox)); + + gtk_box_pack_start (GTK_BOX (dialog->vbox), hbox, FALSE, TRUE, 2); + + gtk_object_set_data (GTK_OBJECT (dialog), "entry", entry); + + gtk_signal_connect (GTK_OBJECT (dialog), "clicked", + rename_clicked, &retval); + + gnome_dialog_set_default (dialog, 1); + + result = gnome_dialog_run_and_close (dialog); + + return retval; } #endif + +static void +rename_cb (EStorageSet *storage_set, + EStorageResult result, + void *data) +{ + /* FIXME: Do something? */ +} + void e_shell_command_rename_folder (EShell *shell, EShellView *shell_view) { + EStorageSet *storage_set; + char *oldname; + char *newname; + + char *path; + char *newpath; + g_return_if_fail (shell != NULL); g_return_if_fail (E_IS_SHELL (shell)); g_return_if_fail (shell_view != NULL); g_return_if_fail (E_IS_SHELL_VIEW (shell_view)); - g_warning ("To be implemented"); + storage_set = e_shell_get_storage_set (shell); + path = g_strdup (e_shell_view_get_current_path (shell_view)); + + oldname = get_folder_name (shell, path); + newname = rename_dialog (oldname); + + if (strcmp (oldname, newname)) { + /* FIXME: Doing strstr isn't robust enough, will fail + when path is /blah/blah, do looped strchr for '/' */ + char *tmp = strstr (path, oldname); + char *tmp2; + + tmp2 = g_strndup (path, strlen (path) - strlen (tmp)); + + newpath = g_strconcat (tmp2, newname, NULL); + + printf ("newpath: %s\n", newpath); + + g_free (tmp2); + g_free (tmp); + +/* FIXME: newpath needs to be correct + e_storage_set_async_xfer_folder (storage_set, + oldpath, + newpath, + TRUE, + rename_cb, + NULL); +*/ + } + + g_free (path); } @@ -453,6 +555,7 @@ e_shell_command_add_to_shortcut_bar (EShell *shell, EShortcuts *shortcuts; int group_num; const char *uri; + int unread_count; g_return_if_fail (shell != NULL); g_return_if_fail (E_IS_SHELL (shell)); @@ -463,5 +566,7 @@ e_shell_command_add_to_shortcut_bar (EShell *shell, group_num = e_shell_view_get_current_shortcuts_group_num (shell_view); uri = e_shell_view_get_current_uri (shell_view); - e_shortcuts_add_shortcut (shortcuts, group_num, -1, uri, NULL, NULL); + unread_count = get_folder_unread (shell, e_shell_view_get_current_path (shell_view)); + + e_shortcuts_add_shortcut (shortcuts, group_num, -1, uri, NULL, unread_count, NULL); } diff --git a/shell/e-shell-folder-title-bar.c b/shell/e-shell-folder-title-bar.c index 8219cc913c..d69d8d0884 100644 --- a/shell/e-shell-folder-title-bar.c +++ b/shell/e-shell-folder-title-bar.c @@ -580,8 +580,8 @@ e_shell_folder_title_bar_set_clickable (EShellFolderTitleBar *folder_title_bar, return; if (clickable) { - gtk_widget_show (priv->button); gtk_widget_hide (priv->label); + gtk_widget_show (priv->button); } else { gtk_widget_hide (priv->button); gtk_widget_show (priv->label); diff --git a/shell/e-shell-view-menu.c b/shell/e-shell-view-menu.c index 9e19ac310f..0a5c769bca 100644 --- a/shell/e-shell-view-menu.c +++ b/shell/e-shell-view-menu.c @@ -377,7 +377,7 @@ command_rename_folder (BonoboUIComponent *uih, EShellView *shell_view; shell_view = E_SHELL_VIEW (data); - e_shell_command_rename_folder (e_shell_view_get_shell (shell_view), shell_view); +/* e_shell_command_rename_folder (e_shell_view_get_shell (shell_view), shell_view); */ } static void @@ -562,7 +562,7 @@ new_shortcut_dialog_folder_selected_cb (EShellFolderSelectionDialog *folder_sele evolution_uri = g_strconcat (E_SHELL_URI_PREFIX, path, NULL); /* FIXME: I shouldn't have to set the type here. Maybe. */ - e_shortcuts_add_shortcut (shortcuts, group_num, -1, evolution_uri, NULL, e_folder_get_type_string (folder)); + e_shortcuts_add_shortcut (shortcuts, group_num, -1, evolution_uri, NULL, e_folder_get_unread_count (folder), e_folder_get_type_string (folder)); g_free (evolution_uri); @@ -651,6 +651,19 @@ static EPixmap pixmaps [] = { E_PIXMAP ("/menu/File/Folder/Folder", "folder.xpm"), E_PIXMAP ("/menu/File/FileImporter", "import.xpm"), E_PIXMAP ("/menu/File/ToggleOffline", "work_offline.xpm"), + + E_PIXMAP_END +}; + +static EPixmap offline_pixmaps [] = { + E_PIXMAP ("/menu/File/ToggleOffline", "work_offline.xpm"), + + E_PIXMAP_END +}; + +static EPixmap online_pixmaps [] = { + E_PIXMAP ("/menu/File/ToggleOffline", "work_online-16.png"), + E_PIXMAP_END }; @@ -691,8 +704,9 @@ update_offline_menu_item (EShellView *shell_view, "/menu/File/ToggleOffline", "verb", "WorkOnline", NULL); bonobo_ui_component_set_prop (ui_component, - "/commands/WorkOnline", + "/commands/ToggleOffline", "sensitive", "1", NULL); + e_pixmaps_update (ui_component, online_pixmaps); break; case E_SHELL_LINE_STATUS_ONLINE: @@ -705,6 +719,7 @@ update_offline_menu_item (EShellView *shell_view, bonobo_ui_component_set_prop (ui_component, "/commands/ToggleOffline", "sensitive", "1", NULL); + e_pixmaps_update (ui_component, offline_pixmaps); break; case E_SHELL_LINE_STATUS_GOING_OFFLINE: @@ -717,6 +732,7 @@ update_offline_menu_item (EShellView *shell_view, bonobo_ui_component_set_prop (ui_component, "/commands/ToggleOffline", "sensitive", "0", NULL); + e_pixmaps_update (ui_component, offline_pixmaps); break; default: diff --git a/shell/e-shell-view.c b/shell/e-shell-view.c index 809e9c1cbd..4e72bc1cf5 100644 --- a/shell/e-shell-view.c +++ b/shell/e-shell-view.c @@ -97,7 +97,7 @@ struct _EShellViewPrivate { GtkWidget *appbar; GtkWidget *hpaned; GtkWidget *view_vbox; - GtkWidget *view_title_bar; + GtkWidget *folder_title_bar; GtkWidget *view_hpaned; GtkWidget *contents; GtkWidget *notebook; @@ -255,7 +255,7 @@ popdown_transient_folder_bar (EShellView *shell_view) disconnect_popup_signals (shell_view); - e_shell_folder_title_bar_set_toggle_state (E_SHELL_FOLDER_TITLE_BAR (priv->view_title_bar), FALSE); + e_shell_folder_title_bar_set_toggle_state (E_SHELL_FOLDER_TITLE_BAR (priv->folder_title_bar), FALSE); } static int @@ -342,7 +342,7 @@ popup_storage_set_view_button_clicked (ETitleBar *title_bar, disconnect_popup_signals (shell_view); e_shell_view_set_folder_bar_mode (shell_view, E_SHELL_VIEW_SUBWINDOW_STICKY); - e_shell_folder_title_bar_set_toggle_state (E_SHELL_FOLDER_TITLE_BAR (priv->view_title_bar), FALSE); + e_shell_folder_title_bar_set_toggle_state (E_SHELL_FOLDER_TITLE_BAR (priv->folder_title_bar), FALSE); } static void @@ -631,15 +631,19 @@ setup_storage_set_subwindow (EShellView *shell_view) priv = shell_view->priv; - storage_set_view = e_storage_set_view_new (e_shell_get_storage_set (priv->shell), priv->ui_container); + storage_set_view = e_storage_set_view_new (e_shell_get_storage_set (priv->shell), + priv->ui_container); gtk_signal_connect (GTK_OBJECT (storage_set_view), "folder_selected", GTK_SIGNAL_FUNC (folder_selected_cb), shell_view); gtk_signal_connect (GTK_OBJECT (storage_set_view), "storage_selected", GTK_SIGNAL_FUNC (storage_selected_cb), shell_view); scroll_frame = e_scroll_frame_new (NULL, NULL); - e_scroll_frame_set_policy (E_SCROLL_FRAME (scroll_frame), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - e_scroll_frame_set_shadow_type (E_SCROLL_FRAME (scroll_frame), GTK_SHADOW_IN); + e_scroll_frame_set_policy (E_SCROLL_FRAME (scroll_frame), + GTK_POLICY_AUTOMATIC, + GTK_POLICY_AUTOMATIC); + e_scroll_frame_set_shadow_type (E_SCROLL_FRAME (scroll_frame), + GTK_SHADOW_IN); gtk_container_add (GTK_CONTAINER (scroll_frame), storage_set_view); @@ -827,16 +831,16 @@ setup_widgets (EShellView *shell_view) priv->view_vbox = gtk_vbox_new (FALSE, 0); - priv->view_title_bar = e_shell_folder_title_bar_new (); - gtk_signal_connect (GTK_OBJECT (priv->view_title_bar), "title_toggled", + priv->folder_title_bar = e_shell_folder_title_bar_new (); + gtk_signal_connect (GTK_OBJECT (priv->folder_title_bar), "title_toggled", GTK_SIGNAL_FUNC (title_bar_toggled_cb), shell_view); priv->view_hpaned = e_hpaned_new (); - e_paned_pack1 (E_PANED (priv->view_hpaned), priv->storage_set_view_box, FALSE, FALSE); + e_paned_pack1 (E_PANED (priv->view_hpaned), priv->storage_set_view_box, FALSE, TRUE); e_paned_pack2 (E_PANED (priv->view_hpaned), priv->notebook, TRUE, FALSE); e_paned_set_position (E_PANED (priv->view_hpaned), DEFAULT_TREE_WIDTH); - gtk_box_pack_start (GTK_BOX (priv->view_vbox), priv->view_title_bar, + gtk_box_pack_start (GTK_BOX (priv->view_vbox), priv->folder_title_bar, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (priv->view_vbox), priv->view_hpaned, TRUE, TRUE, 0); @@ -871,7 +875,7 @@ setup_widgets (EShellView *shell_view) gtk_widget_show (priv->hpaned); gtk_widget_show (priv->view_hpaned); gtk_widget_show (priv->view_vbox); - gtk_widget_show (priv->view_title_bar); + gtk_widget_show (priv->folder_title_bar); gtk_widget_show (priv->status_bar); /* By default, both the folder bar and shortcut bar are visible. */ @@ -942,18 +946,6 @@ destroy (GtkObject *object) (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); } -static int -delete_event (GtkWidget *widget, - GdkEventAny *event) -{ - EShell *shell; - - shell = e_shell_view_get_shell (E_SHELL_VIEW (widget)); - - /* FIXME: Is this right, or should it be FALSE? */ - return FALSE; -} - /* Initialization. */ @@ -1102,7 +1094,7 @@ corba_interface_set_folder_bar_label (EvolutionShellView *evolution_shell_view, shell_view = E_SHELL_VIEW (data); priv = shell_view->priv; - e_shell_folder_title_bar_set_folder_bar_label (E_SHELL_FOLDER_TITLE_BAR (priv->view_title_bar), + e_shell_folder_title_bar_set_folder_bar_label (E_SHELL_FOLDER_TITLE_BAR (priv->folder_title_bar), text); } @@ -1131,14 +1123,6 @@ updated_folder_cb (EStorageSet *storage_set, shell_view = E_SHELL_VIEW (data); priv = shell_view->priv; -#if 0 - char *uri = g_strconcat (E_SHELL_URI_PREFIX, path, NULL); - - /* Update the shortcut bar */ - e_shortcuts_update_shortcut_by_uri (e_shell_get_shortcuts (priv->shell), uri); - g_free (uri); -#endif - view_path = get_storage_set_path_from_uri (priv->uri); if (view_path && strcmp (path, view_path) != 0) return; @@ -1161,14 +1145,21 @@ shell_line_status_changed_cb (EShell *shell, update_offline_toggle_status (shell_view); } - +static int +delete_event_cb (GtkWidget *widget, + GdkEventAny *ev, + void *data) +{ + return FALSE; +} + + EShellView * e_shell_view_construct (EShellView *shell_view, EShell *shell) { EShellViewPrivate *priv; EShellView *view; - GtkObject *window; g_return_val_if_fail (shell != NULL, NULL); g_return_val_if_fail (shell_view != NULL, NULL); @@ -1184,19 +1175,18 @@ e_shell_view_construct (EShellView *shell_view, return NULL; } - window = GTK_OBJECT (view); - - gtk_signal_connect (window, "delete_event", GTK_SIGNAL_FUNC (delete_event), NULL); - + gtk_signal_connect (GTK_OBJECT (view), "delete_event", + GTK_SIGNAL_FUNC (delete_event_cb), NULL); priv->shell = shell; - gtk_signal_connect_while_alive (GTK_OBJECT (e_shell_get_storage_set (priv->shell)), "updated_folder", - updated_folder_cb, shell_view, GTK_OBJECT (shell_view)); + gtk_signal_connect_while_alive (GTK_OBJECT (e_shell_get_storage_set (priv->shell)), + "updated_folder", updated_folder_cb, shell_view, + GTK_OBJECT (shell_view)); priv->ui_container = bonobo_ui_container_new (); bonobo_ui_container_set_win (priv->ui_container, BONOBO_WINDOW (shell_view)); - gtk_signal_connect (GTK_OBJECT (priv->ui_container), - "system_exception", GTK_SIGNAL_FUNC (unmerge_on_error), NULL); + gtk_signal_connect (GTK_OBJECT (priv->ui_container), "system_exception", + GTK_SIGNAL_FUNC (unmerge_on_error), NULL); priv->ui_component = bonobo_ui_component_new ("evolution"); bonobo_ui_component_set_container (priv->ui_component, @@ -1346,11 +1336,11 @@ update_folder_title_bar (EShellView *shell_view, } if (folder_icon) - e_shell_folder_title_bar_set_icon (E_SHELL_FOLDER_TITLE_BAR (priv->view_title_bar), folder_icon); + e_shell_folder_title_bar_set_icon (E_SHELL_FOLDER_TITLE_BAR (priv->folder_title_bar), folder_icon); if (folder_name) { gchar * utf; - utf = e_utf8_to_gtk_string (GTK_WIDGET (priv->view_title_bar), folder_name); - e_shell_folder_title_bar_set_title (E_SHELL_FOLDER_TITLE_BAR (priv->view_title_bar), utf); + utf = e_utf8_to_gtk_string (GTK_WIDGET (priv->folder_title_bar), folder_name); + e_shell_folder_title_bar_set_title (E_SHELL_FOLDER_TITLE_BAR (priv->folder_title_bar), utf); g_free (utf); } } @@ -1689,7 +1679,6 @@ get_control_for_uri (EShellView *shell_view, return NULL; /* FIXME: This code needs to be made more robust. */ - slash = strchr (path + 1, G_DIR_SEPARATOR); if (slash == NULL || slash[1] == '\0') folder_type = get_type_for_storage (shell_view, path + 1, &physical_uri); @@ -1984,7 +1973,7 @@ e_shell_view_set_folder_bar_mode (EShellView *shell_view, e_title_bar_set_button_mode (E_TITLE_BAR (priv->storage_set_title_bar), E_TITLE_BAR_BUTTON_MODE_CLOSE); - e_shell_folder_title_bar_set_clickable (E_SHELL_FOLDER_TITLE_BAR (priv->view_title_bar), + e_shell_folder_title_bar_set_clickable (E_SHELL_FOLDER_TITLE_BAR (priv->folder_title_bar), FALSE); } else { if (GTK_WIDGET_VISIBLE (priv->storage_set_view_box)) { @@ -1997,7 +1986,7 @@ e_shell_view_set_folder_bar_mode (EShellView *shell_view, e_title_bar_set_button_mode (E_TITLE_BAR (priv->storage_set_title_bar), E_TITLE_BAR_BUTTON_MODE_PIN); - e_shell_folder_title_bar_set_clickable (E_SHELL_FOLDER_TITLE_BAR (priv->view_title_bar), + e_shell_folder_title_bar_set_clickable (E_SHELL_FOLDER_TITLE_BAR (priv->folder_title_bar), TRUE); } diff --git a/shell/e-shell.c b/shell/e-shell.c index c2aef7d71e..fb128c6081 100644 --- a/shell/e-shell.c +++ b/shell/e-shell.c @@ -356,12 +356,12 @@ impl_Shell_selectUserFolder (PortableServer_Servant servant, gtk_widget_show (folder_selection_dialog); } -static GNOME_Evolution_LocalStorage +static GNOME_Evolution_Storage impl_Shell_getLocalStorage (PortableServer_Servant servant, CORBA_Environment *ev) { BonoboObject *bonobo_object; - GNOME_Evolution_LocalStorage local_storage_interface; + GNOME_Evolution_Storage local_storage_interface; EShell *shell; EShellPrivate *priv; @@ -509,6 +509,9 @@ setup_components (EShell *shell, if (ev._major != CORBA_NO_EXCEPTION) g_error ("Eeek! Cannot perform OAF query for Evolution components."); + if (info_list->_length == 0) + g_warning ("No Evolution components installed."); + for (i = 0; i < info_list->_length; i++) { const OAF_ServerInfo *info; GdkPixbuf *icon_pixbuf; @@ -548,9 +551,6 @@ setup_components (EShell *shell, gtk_main_iteration (); } - if (info_list->_length == 0) - g_warning ("No Evolution components installed."); - CORBA_free (info_list); CORBA_exception_free (&ev); @@ -589,13 +589,13 @@ set_owner_on_components (EShell *shell) /* EShellView destruction callback. */ static int -view_deleted_cb (GtkObject *object, - GdkEvent *ev, - gpointer data) +view_delete_event_cb (GtkWidget *widget, + GdkEventAny *ev, + void *data) { EShell *shell; - g_assert (E_IS_SHELL_VIEW (object)); + g_assert (E_IS_SHELL_VIEW (widget)); shell = E_SHELL (data); e_shell_save_settings (shell); @@ -606,21 +606,21 @@ view_deleted_cb (GtkObject *object, static void view_destroy_cb (GtkObject *object, - gpointer data) + void *data) { EShell *shell; - int nviews; + int num_views; g_assert (E_IS_SHELL_VIEW (object)); shell = E_SHELL (data); - nviews = g_list_length (shell->priv->views); + num_views = g_list_length (shell->priv->views); /* If this is our last view, save settings now because in the callback for no_views_left shell->priv->views will be NULL and settings won't be saved because of that */ - if (nviews - 1 == 0) + if (num_views - 1 == 0) e_shell_save_settings (shell); shell->priv->views = g_list_remove (shell->priv->views, object); @@ -676,11 +676,11 @@ destroy (GtkObject *object) view = E_SHELL_VIEW (p->data); - gtk_signal_disconnect_by_func ( - GTK_OBJECT (view), - GTK_SIGNAL_FUNC (view_destroy_cb), shell); gtk_signal_disconnect_by_func (GTK_OBJECT (view), - GTK_SIGNAL_FUNC (view_deleted_cb), + GTK_SIGNAL_FUNC (view_delete_event_cb), + shell); + gtk_signal_disconnect_by_func (GTK_OBJECT (view), + GTK_SIGNAL_FUNC (view_destroy_cb), shell); gtk_object_destroy (GTK_OBJECT (view)); @@ -800,7 +800,6 @@ e_shell_construct (EShell *shell, CORBA_Object corba_object; CORBA_Environment ev; gchar *shortcut_path; - g_return_val_if_fail (shell != NULL, E_SHELL_CONSTRUCT_RESULT_INVALIDARG); g_return_val_if_fail (E_IS_SHELL (shell), E_SHELL_CONSTRUCT_RESULT_INVALIDARG); g_return_val_if_fail (local_directory != NULL, E_SHELL_CONSTRUCT_RESULT_INVALIDARG); @@ -966,13 +965,16 @@ e_shell_create_view (EShell *shell, view = e_shell_view_new (shell); gtk_widget_show (GTK_WIDGET (view)); - gtk_signal_connect (GTK_OBJECT (view), "delete-event", - GTK_SIGNAL_FUNC (view_deleted_cb), shell); + gtk_signal_connect (GTK_OBJECT (view), "delete_event", + GTK_SIGNAL_FUNC (view_delete_event_cb), shell); gtk_signal_connect (GTK_OBJECT (view), "destroy", GTK_SIGNAL_FUNC (view_destroy_cb), shell); if (uri != NULL) if (!e_shell_view_display_uri (E_SHELL_VIEW (view), uri)) + /* FIXME: Consider popping a dialog box up + about how the provided URI does not + exist/could not be displayed */ e_shell_view_display_uri (E_SHELL_VIEW (view), DEFAULT_URI); shell->priv->views = g_list_prepend (shell->priv->views, view); diff --git a/shell/e-shortcuts-view-model.c b/shell/e-shortcuts-view-model.c index 8936d24242..03fd22a239 100644 --- a/shell/e-shortcuts-view-model.c +++ b/shell/e-shortcuts-view-model.c @@ -47,6 +47,15 @@ struct _EShortcutsViewModelPrivate { /* View initialization. */ +static char * +get_name_with_unread (const EShortcutItem *item) +{ + if (item->unread_count > 0) + return g_strdup_printf ("%s (%d)", item->name, item->unread_count); + else + return g_strdup (item->name); +} + static void load_group_into_model (EShortcutsViewModel *shortcuts_view_model, int group_num) @@ -67,9 +76,12 @@ load_group_into_model (EShortcutsViewModel *shortcuts_view_model, for (p = shortcut_list; p != NULL; p = p->next) { const EShortcutItem *item; + char *name_with_unread; item = (const EShortcutItem *) p->data; - e_shortcut_model_add_item (E_SHORTCUT_MODEL (shortcuts_view_model), group_num, -1, item->uri, item->name); + 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); + g_free (name_with_unread); } } @@ -153,6 +165,7 @@ shortcuts_new_shortcut_cb (EShortcuts *shortcuts, EShortcutsViewModel *shortcuts_view_model; EShortcutsViewModelPrivate *priv; const EShortcutItem *shortcut_item; + char *name_with_unread; shortcuts_view_model = E_SHORTCUTS_VIEW_MODEL (data); priv = shortcuts_view_model->priv; @@ -160,10 +173,12 @@ shortcuts_new_shortcut_cb (EShortcuts *shortcuts, shortcut_item = e_shortcuts_get_shortcut (priv->shortcuts, group_num, item_num); g_assert (shortcut_item != NULL); + name_with_unread = get_name_with_unread (shortcut_item); e_shortcut_model_add_item (E_SHORTCUT_MODEL (shortcuts_view_model), group_num, item_num, shortcut_item->uri, - shortcut_item->name); + name_with_unread); + g_free (name_with_unread); } static void @@ -187,6 +202,7 @@ shortcuts_update_shortcut_cb (EShortcuts *shortcuts, EShortcutsViewModel *shortcuts_view_model; EShortcutsViewModelPrivate *priv; const EShortcutItem *shortcut_item; + char *name_with_unread; shortcuts_view_model = E_SHORTCUTS_VIEW_MODEL (data); priv = shortcuts_view_model->priv; @@ -194,10 +210,12 @@ shortcuts_update_shortcut_cb (EShortcuts *shortcuts, shortcut_item = e_shortcuts_get_shortcut (priv->shortcuts, group_num, item_num); g_assert (shortcut_item != NULL); + name_with_unread = get_name_with_unread (shortcut_item); e_shortcut_model_update_item (E_SHORTCUT_MODEL (shortcuts_view_model), group_num, item_num, shortcut_item->uri, - shortcut_item->name); + name_with_unread); + g_free (name_with_unread); } diff --git a/shell/e-shortcuts-view.c b/shell/e-shortcuts-view.c index ecc2b1487e..a1de0689ce 100644 --- a/shell/e-shortcuts-view.c +++ b/shell/e-shortcuts-view.c @@ -103,7 +103,6 @@ icon_callback (EShortcutBar *shortcut_bar, storage_set = e_shortcuts_get_storage_set (shortcuts); folder_type_registry = e_storage_set_get_folder_type_registry (storage_set); - folder = e_storage_set_get_folder (storage_set, get_storage_set_path_from_uri (uri)); @@ -461,8 +460,9 @@ rename_shortcut_cb (GtkWidget *widget, if (new_name == NULL) return; + e_shortcuts_update_shortcut (shortcuts, menu_data->group_num, menu_data->item_num, - shortcut_item->uri, new_name, shortcut_item->type); + shortcut_item->uri, new_name, shortcut_item->unread_count, shortcut_item->type); g_free (new_name); } @@ -560,6 +560,24 @@ item_selected (EShortcutBar *shortcut_bar, shortcuts, shortcut_item->uri, FALSE); } +static EFolder * +get_efolder_from_shortcut (EShortcuts *shortcuts, + char *item_url) +{ + EFolderTypeRegistry *folder_type_registry; + EStorageSet *storage_set; + EFolder *folder; + char *path; + + path = strchr (item_url, G_DIR_SEPARATOR); + storage_set = e_shortcuts_get_storage_set (shortcuts); + folder_type_registry = e_storage_set_get_folder_type_registry (storage_set); + + folder = e_storage_set_get_folder (storage_set, path); + + return folder; +} + static void impl_shortcut_dropped (EShortcutBar *shortcut_bar, int group_num, @@ -569,11 +587,35 @@ impl_shortcut_dropped (EShortcutBar *shortcut_bar, { EShortcutsView *shortcuts_view; EShortcutsViewPrivate *priv; + EFolder *folder; + int unread_count; + const char *type; + char *tmp; + char *tp; + char *name_without_unread; shortcuts_view = E_SHORTCUTS_VIEW (shortcut_bar); priv = shortcuts_view->priv; - e_shortcuts_add_shortcut (priv->shortcuts, group_num, position, item_url, NULL, NULL); + folder = get_efolder_from_shortcut (priv->shortcuts, item_url); + + unread_count = e_folder_get_unread_count (folder); + type = e_folder_get_type_string (folder); + + /* Looks funny, but keeps it from adding the unread count + repeatedly when dragging folders around */ + tmp = g_strdup_printf (" (%d)", unread_count); + if ((tp = strstr (item_name, tmp)) != NULL) + name_without_unread = g_strndup (item_name, strlen (item_name) - strlen (tp)); + else + name_without_unread = g_strdup (item_name); + + e_shortcuts_add_shortcut (priv->shortcuts, + group_num, position, + item_url, name_without_unread, unread_count, type); + + g_free (tmp); + g_free (name_without_unread); } static void diff --git a/shell/e-shortcuts.c b/shell/e-shortcuts.c index 1aaf8edd52..04899064f2 100644 --- a/shell/e-shortcuts.c +++ b/shell/e-shortcuts.c @@ -126,6 +126,7 @@ static void make_dirty (EShortcuts *shortcuts); static EShortcutItem * shortcut_item_new (const char *uri, const char *name, + int unread_count, const char *type) { EShortcutItem *new; @@ -137,6 +138,7 @@ shortcut_item_new (const char *uri, new->uri = g_strdup (uri); new->name = g_strdup (name); new->type = g_strdup (type); + new->unread_count = unread_count; return new; } @@ -145,6 +147,7 @@ static gboolean shortcut_item_update (EShortcutItem *shortcut_item, const char *uri, const char *name, + int unread_count, const char *type) { gboolean changed = FALSE; @@ -166,6 +169,11 @@ shortcut_item_update (EShortcutItem *shortcut_item, changed = TRUE; } + if (shortcut_item->unread_count != unread_count) { + shortcut_item->unread_count = unread_count; + changed = FALSE; + } + if (shortcut_item->type == NULL || type == NULL || strcmp (shortcut_item->type, type) != 0) { g_free (shortcut_item->type); @@ -222,12 +230,24 @@ update_shortcut_and_emit_signal (EShortcuts *shortcuts, int num, const char *uri, const char *name, + int unread_count, const char *type) { - if (shortcut_item_update (shortcut_item, uri, name, type)) { + /* Only thing that changed was the unread count */ + if (shortcut_item->unread_count != unread_count + && !shortcut_item_update (shortcut_item, uri, name, unread_count, type)) { + gtk_signal_emit (GTK_OBJECT (shortcuts), signals[UPDATE_SHORTCUT], group_num, num); + return FALSE; + } + + /* Unread count is the same, but other stuff changed */ + else if (shortcut_item_update (shortcut_item, uri, name, unread_count, type)) { gtk_signal_emit (GTK_OBJECT (shortcuts), signals[UPDATE_SHORTCUT], group_num, num); return TRUE; - } else + } + + /* Nothing at all changed, return false only */ + else return FALSE; } @@ -311,7 +331,7 @@ load_shortcuts (EShortcuts *shortcuts, name = xmlGetProp (q, "name"); type = xmlGetProp (q, "type"); - shortcut_item = shortcut_item_new (uri, name, type); + shortcut_item = shortcut_item_new (uri, name, 0, type); shortcut_group->shortcuts = g_slist_prepend (shortcut_group->shortcuts, shortcut_item); @@ -376,8 +396,10 @@ save_shortcuts (EShortcuts *shortcuts, if (shortcut->name != NULL) xmlSetProp (shortcut_node, (xmlChar *) "name", shortcut->name); + if (shortcut->type != NULL) xmlSetProp (shortcut_node, (xmlChar *) "type", shortcut->type); + } } @@ -466,14 +488,16 @@ update_shortcuts_by_path (EShortcuts *shortcuts, shortcut_item = (EShortcutItem *) q->data; - if (strcmp (shortcut_item->uri, evolution_uri) == 0) + if (strcmp (shortcut_item->uri, evolution_uri) == 0) { changed = update_shortcut_and_emit_signal (shortcuts, shortcut_item, group_num, num, evolution_uri, shortcut_item->name, + e_folder_get_unread_count (folder), e_folder_get_type_string (folder)); + } } } @@ -923,6 +947,7 @@ e_shortcuts_add_shortcut (EShortcuts *shortcuts, int num, const char *uri, const char *name, + int unread_count, const char *type) { EShortcutsPrivate *priv; @@ -943,7 +968,7 @@ e_shortcuts_add_shortcut (EShortcuts *shortcuts, if (num == -1) num = g_slist_length (group->shortcuts); - item = shortcut_item_new (uri, name, type); + item = shortcut_item_new (uri, name, unread_count, type); group->shortcuts = g_slist_insert (group->shortcuts, item, num); @@ -958,6 +983,7 @@ e_shortcuts_update_shortcut (EShortcuts *shortcuts, int num, const char *uri, const char *name, + int unread_count, const char *type) { EShortcutItem *shortcut_item; @@ -967,7 +993,7 @@ e_shortcuts_update_shortcut (EShortcuts *shortcuts, shortcut_item = get_item (shortcuts, group_num, num); - update_shortcut_and_emit_signal (shortcuts, shortcut_item, group_num, num, uri, name, type); + update_shortcut_and_emit_signal (shortcuts, shortcut_item, group_num, num, uri, name, unread_count, type); make_dirty (shortcuts); } @@ -981,10 +1007,12 @@ e_shortcuts_add_default_group (EShortcuts *shortcuts) e_shortcuts_add_group (shortcuts, -1, _("Shortcuts")); - e_shortcuts_add_shortcut (shortcuts, 0, -1, "evolution:/local/Inbox", _("Inbox"), "mail"); - e_shortcuts_add_shortcut (shortcuts, 0, -1, "evolution:/local/Calendar", _("Calendar"), "calendar"); - e_shortcuts_add_shortcut (shortcuts, 0, -1, "evolution:/local/Tasks", _("Tasks"), "tasks"); - e_shortcuts_add_shortcut (shortcuts, 0, -1, "evolution:/local/Contacts", _("Contacts"), "contacts"); + /* FIXME: Inbox shortcut should point to something else for + people who won't care about using /Local Folders/Inbox */ + e_shortcuts_add_shortcut (shortcuts, 0, -1, "evolution:/local/Inbox", _("Inbox"), 0, "mail"); + e_shortcuts_add_shortcut (shortcuts, 0, -1, "evolution:/local/Calendar", _("Calendar"), 0, "calendar"); + e_shortcuts_add_shortcut (shortcuts, 0, -1, "evolution:/local/Tasks", _("Tasks"), 0, "tasks"); + e_shortcuts_add_shortcut (shortcuts, 0, -1, "evolution:/local/Contacts", _("Contacts"), 0, "contacts"); } void diff --git a/shell/e-shortcuts.h b/shell/e-shortcuts.h index aea29de23d..2fc412dfa9 100644 --- a/shell/e-shortcuts.h +++ b/shell/e-shortcuts.h @@ -49,6 +49,7 @@ struct _EShortcutItem { char *uri; char *name; char *type; + int unread_count; }; typedef struct _EShortcutItem EShortcutItem; @@ -112,12 +113,14 @@ void e_shortcuts_add_shortcut (EShortcuts *shortcuts, int num, const char *uri, const char *name, + int unread_count, const char *type); void e_shortcuts_update_shortcut (EShortcuts *shortcuts, int group_num, int num, const char *uri, const char *name, + int unread_count, const char *type); void e_shortcuts_remove_group (EShortcuts *shortcuts, diff --git a/shell/e-splash.c b/shell/e-splash.c index cf1bbe5348..650d585344 100644 --- a/shell/e-splash.c +++ b/shell/e-splash.c @@ -416,7 +416,7 @@ e_splash_set_icon_highlight (ESplash *splash, priv = splash->priv; - icon = (Icon *) g_list_nth (priv->icons, num)->data; + icon = (Icon *) g_list_nth_data (priv->icons, num); gtk_object_set (GTK_OBJECT (icon->canvas_item), "pixbuf", highlight ? icon->light_pixbuf : icon->dark_pixbuf, diff --git a/shell/e-storage-set-view.c b/shell/e-storage-set-view.c index 1322cb60ef..9187e4bb81 100644 --- a/shell/e-storage-set-view.c +++ b/shell/e-storage-set-view.c @@ -1423,6 +1423,21 @@ etree_get_node_by_id (ETreeModel *etm, gchar *save_id, void *model_data) return g_hash_table_lookup (storage_set_view->priv->path_to_etree_node, save_id); } +GHashTable *folders_with_unread = NULL; + +static void +update_folder_with_unread_hash (char *folder_name, int unread_count) +{ + if (!folders_with_unread) + folders_with_unread = g_hash_table_new (g_str_hash, g_str_equal); + + g_hash_table_insert (folders_with_unread, + g_strdup (folder_name), + g_strdup_printf ("%s (%d)", + folder_name, + unread_count)); +} + static void * etree_value_at (ETreeModel *etree, ETreePath tree_path, int col, void *model_data) { @@ -1439,8 +1454,18 @@ etree_value_at (ETreeModel *etree, ETreePath tree_path, int col, void *model_dat folder = e_storage_set_get_folder (storage_set, path); if (folder != NULL) { + char *folder_name = e_folder_get_name (folder); + int unread_count = e_folder_get_unread_count (folder); + + update_folder_with_unread_hash (folder_name, unread_count); + if (col == 0) - return (void *) e_folder_get_name (folder); + if (unread_count > 0) + return (void *) g_hash_table_lookup (folders_with_unread, + folder_name); + else + return (void *) folder_name; + else return (void *) e_folder_get_highlighted (folder); } @@ -1988,7 +2013,7 @@ e_storage_set_view_set_current_folder (EStorageSetView *storage_set_view, return; } - e_tree_show_node (E_TREE(storage_set_view), node); + e_tree_show_node (E_TREE (storage_set_view), node); e_tree_set_cursor (E_TREE (storage_set_view), node); gtk_signal_emit (GTK_OBJECT (storage_set_view), signals[FOLDER_SELECTED], path); diff --git a/shell/e-storage-set-view.h b/shell/e-storage-set-view.h index 359759b37e..b5de34b2f1 100644 --- a/shell/e-storage-set-view.h +++ b/shell/e-storage-set-view.h @@ -69,6 +69,8 @@ struct _EStorageSetViewClass { GtkType e_storage_set_view_get_type (void); +GtkWidget *e_storage_set_view_new_partial_view (EStorageSet *storage_set, + GList *visible_types); GtkWidget *e_storage_set_view_new (EStorageSet *storage_set, BonoboUIContainer *container); void e_storage_set_view_construct (EStorageSetView *storage_set_view, diff --git a/shell/e-storage.c b/shell/e-storage.c index b6219605ab..00f07f0250 100644 --- a/shell/e-storage.c +++ b/shell/e-storage.c @@ -21,6 +21,10 @@ * Author: Ettore Perazzoli */ +/* FIXME: The EFolderTree is kept both in the EStorage and the + * EvolutionStorage. Bad design. + */ + #ifdef HAVE_CONFIG_H #include <config.h> #endif diff --git a/shell/evolution-local-storage.c b/shell/evolution-local-storage.c deleted file mode 100644 index 65017395b7..0000000000 --- a/shell/evolution-local-storage.c +++ /dev/null @@ -1,220 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* evolution-local-storage.c - * - * Copyright (C) 2000 Ximian, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Author: Ettore Perazzoli - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <glib.h> -#include <gtk/gtksignal.h> -#include <libgnome/gnome-defs.h> -#include <libgnome/gnome-util.h> - -#include <gal/util/e-util.h> - -#include "evolution-local-storage.h" - - -#define PARENT_TYPE evolution_storage_get_type () -static EvolutionStorageClass *parent_class = NULL; - -struct _EvolutionLocalStoragePrivate { - int dummy; -}; - - -enum { - UPDATE_FOLDER, - - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL] = { 0 }; - - -/* CORBA interface implementation. */ - -static POA_GNOME_Evolution_LocalStorage__vepv LocalStorage_vepv; - -static void -impl_GNOME_Evolution_LocalStorage_updateFolder (PortableServer_Servant servant, - const CORBA_char *path, - const CORBA_char *display_name, - CORBA_boolean highlighted, - CORBA_Environment *ev) -{ - BonoboObject *bonobo_object; - EvolutionLocalStorage *local_storage; - - bonobo_object = bonobo_object_from_servant (servant); - local_storage = EVOLUTION_LOCAL_STORAGE (bonobo_object); - - gtk_signal_emit (GTK_OBJECT (local_storage), signals[UPDATE_FOLDER], path, display_name, highlighted); -} - -static POA_GNOME_Evolution_LocalStorage * -create_servant (void) -{ - POA_GNOME_Evolution_LocalStorage *servant; - CORBA_Environment ev; - - servant = (POA_GNOME_Evolution_LocalStorage *) g_new0 (BonoboObjectServant, 1); - servant->vepv = &LocalStorage_vepv; - - CORBA_exception_init (&ev); - - POA_GNOME_Evolution_LocalStorage__init ((PortableServer_Servant) servant, &ev); - if (ev._major != CORBA_NO_EXCEPTION) { - g_free (servant); - CORBA_exception_free (&ev); - return NULL; - } - - CORBA_exception_free (&ev); - - return servant; -} - - -/* GtkObject methods. */ - -static void -impl_destroy (GtkObject *object) -{ - EvolutionLocalStorage *local_storage; - EvolutionLocalStoragePrivate *priv; - - local_storage = EVOLUTION_LOCAL_STORAGE (object); - priv = local_storage->priv; - - g_free (priv); - - (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); -} - - -static void -corba_class_init (void) -{ - POA_GNOME_Evolution_LocalStorage__vepv *vepv; - PortableServer_ServantBase__epv *base_epv; - - base_epv = g_new0 (PortableServer_ServantBase__epv, 1); - base_epv->_private = NULL; - base_epv->finalize = NULL; - base_epv->default_POA = NULL; - - vepv = &LocalStorage_vepv; - vepv->_base_epv = base_epv; - vepv->Bonobo_Unknown_epv = bonobo_object_get_epv (); - vepv->GNOME_Evolution_Storage_epv = evolution_storage_get_epv (); - vepv->GNOME_Evolution_LocalStorage_epv = evolution_local_storage_get_epv (); -} - -static void -class_init (EvolutionLocalStorageClass *klass) -{ - GtkObjectClass *object_class; - - object_class = GTK_OBJECT_CLASS (klass); - object_class->destroy = impl_destroy; - - parent_class = gtk_type_class (PARENT_TYPE); - - signals[UPDATE_FOLDER] = gtk_signal_new ("update_folder", - GTK_RUN_FIRST, - object_class->type, - GTK_SIGNAL_OFFSET (EvolutionLocalStorageClass, - update_folder), - e_marshal_NONE__POINTER_POINTER_INT, - GTK_TYPE_NONE, 3, - GTK_TYPE_STRING, - GTK_TYPE_STRING, - GTK_TYPE_BOOL); - - gtk_object_class_add_signals (object_class, signals, LAST_SIGNAL); - - corba_class_init (); -} - -static void -init (EvolutionLocalStorage *local_storage) -{ - EvolutionLocalStoragePrivate *priv; - - priv = g_new (EvolutionLocalStoragePrivate, 1); - - local_storage->priv = priv; -} - - -POA_GNOME_Evolution_LocalStorage__epv * -evolution_local_storage_get_epv (void) -{ - POA_GNOME_Evolution_LocalStorage__epv *epv; - - epv = g_new0 (POA_GNOME_Evolution_LocalStorage__epv, 1); - epv->updateFolder = impl_GNOME_Evolution_LocalStorage_updateFolder; - - return epv; -} - -void -evolution_local_storage_construct (EvolutionLocalStorage *local_storage, - GNOME_Evolution_LocalStorage corba_object, - const char *name) -{ - g_return_if_fail (local_storage != NULL); - g_return_if_fail (EVOLUTION_IS_LOCAL_STORAGE (local_storage)); - g_return_if_fail (corba_object != CORBA_OBJECT_NIL); - g_return_if_fail (name != NULL); - g_return_if_fail (name[0] != '\0'); - - evolution_storage_construct (EVOLUTION_STORAGE (local_storage), corba_object, name, NULL, NULL); -} - -EvolutionLocalStorage * -evolution_local_storage_new (const char *name) -{ - EvolutionLocalStorage *new; - POA_GNOME_Evolution_LocalStorage *servant; - GNOME_Evolution_LocalStorage corba_object; - - g_return_val_if_fail (name != NULL, NULL); - g_return_val_if_fail (name[0] != '\0', NULL); - - servant = create_servant (); - if (servant == NULL) - return NULL; - - new = gtk_type_new (evolution_local_storage_get_type ()); - - corba_object = bonobo_object_activate_servant (BONOBO_OBJECT (new), servant); - evolution_local_storage_construct (new, corba_object, name); - - return new; -} - - -E_MAKE_TYPE (evolution_local_storage, "EvolutionLocalStorage", EvolutionLocalStorage, - class_init, init, PARENT_TYPE) diff --git a/shell/evolution-local-storage.h b/shell/evolution-local-storage.h deleted file mode 100644 index e617e33a35..0000000000 --- a/shell/evolution-local-storage.h +++ /dev/null @@ -1,75 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* evolution-local-storage.h - * - * Copyright (C) 2000 Ximian, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Author: Ettore Perazzoli - */ - -#ifndef __EVOLUTION_LOCAL_STORAGE_H__ -#define __EVOLUTION_LOCAL_STORAGE_H__ - -#include <glib.h> - -#include "evolution-storage.h" - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - -#define EVOLUTION_TYPE_LOCAL_STORAGE (evolution_local_storage_get_type ()) -#define EVOLUTION_LOCAL_STORAGE(obj) (GTK_CHECK_CAST ((obj), EVOLUTION_TYPE_LOCAL_STORAGE, EvolutionLocalStorage)) -#define EVOLUTION_LOCAL_STORAGE_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), EVOLUTION_TYPE_LOCAL_STORAGE, EvolutionLocalStorageClass)) -#define EVOLUTION_IS_LOCAL_STORAGE(obj) (GTK_CHECK_TYPE ((obj), EVOLUTION_TYPE_LOCAL_STORAGE)) -#define EVOLUTION_IS_LOCAL_STORAGE_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), EVOLUTION_TYPE_LOCAL_STORAGE)) - - -typedef struct _EvolutionLocalStorage EvolutionLocalStorage; -typedef struct _EvolutionLocalStoragePrivate EvolutionLocalStoragePrivate; -typedef struct _EvolutionLocalStorageClass EvolutionLocalStorageClass; - -struct _EvolutionLocalStorage { - EvolutionStorage parent; - - EvolutionLocalStoragePrivate *priv; -}; - -struct _EvolutionLocalStorageClass { - EvolutionStorageClass parent_class; - - void (* update_folder) (EvolutionLocalStorage *local_storage, - const char *path, - const char *display_name, - gboolean highlighted); -}; - - -POA_GNOME_Evolution_LocalStorage__epv *evolution_local_storage_get_epv (void); - -GtkType evolution_local_storage_get_type (void); -void evolution_local_storage_construct (EvolutionLocalStorage *local_storage, - GNOME_Evolution_LocalStorage corba_object, - const char *name); -EvolutionLocalStorage *evolution_local_storage_new (const char *name); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* __EVOLUTION_LOCAL_STORAGE_H__ */ diff --git a/shell/evolution-shell-client.c b/shell/evolution-shell-client.c index 54df7eb981..ff737de4c5 100644 --- a/shell/evolution-shell-client.c +++ b/shell/evolution-shell-client.c @@ -394,11 +394,11 @@ evolution_shell_client_get_activity_interface (EvolutionShellClient *shell_clien * Return value: a pointer to the CORBA object implementing the local storage * in the shell associated with @shell_client. **/ -GNOME_Evolution_LocalStorage +GNOME_Evolution_Storage evolution_shell_client_get_local_storage (EvolutionShellClient *shell_client) { GNOME_Evolution_Shell corba_shell; - GNOME_Evolution_LocalStorage corba_local_storage; + GNOME_Evolution_Storage corba_local_storage; CORBA_Environment ev; g_return_val_if_fail (shell_client != NULL, CORBA_OBJECT_NIL); diff --git a/shell/evolution-shell-client.h b/shell/evolution-shell-client.h index aee891cc08..f770d39c84 100644 --- a/shell/evolution-shell-client.h +++ b/shell/evolution-shell-client.h @@ -67,9 +67,9 @@ void evolution_shell_client_user_select_folder (EvolutionShe char **uri_return, char **physical_uri_return); -GNOME_Evolution_Activity evolution_shell_client_get_activity_interface (EvolutionShellClient *shell_client); +GNOME_Evolution_Activity evolution_shell_client_get_activity_interface (EvolutionShellClient *shell_client); -GNOME_Evolution_LocalStorage evolution_shell_client_get_local_storage (EvolutionShellClient *shell_client); +GNOME_Evolution_Storage evolution_shell_client_get_local_storage (EvolutionShellClient *shell_client); #ifdef __cplusplus } diff --git a/shell/evolution-storage-listener.c b/shell/evolution-storage-listener.c index 233a3f1e7c..e5ac390f4a 100644 --- a/shell/evolution-storage-listener.c +++ b/shell/evolution-storage-listener.c @@ -96,7 +96,7 @@ static void impl_GNOME_Evolution_StorageListener_notifyFolderUpdated (PortableServer_Servant servant, const CORBA_char *path, const CORBA_char *display_name, - CORBA_boolean highlighted, + CORBA_long unread_count, CORBA_Environment *ev) { EvolutionStorageListener *listener; @@ -106,7 +106,7 @@ impl_GNOME_Evolution_StorageListener_notifyFolderUpdated (PortableServer_Servant priv = listener->priv; gtk_signal_emit (GTK_OBJECT (listener), signals[UPDATE_FOLDER], path, - display_name, highlighted); + display_name); } static void @@ -262,11 +262,10 @@ class_init (EvolutionStorageListenerClass *klass) GTK_RUN_FIRST, object_class->type, GTK_SIGNAL_OFFSET (EvolutionStorageListenerClass, update_folder), - e_marshal_NONE__POINTER_POINTER_INT, - GTK_TYPE_NONE, 3, - GTK_TYPE_STRING, + gtk_marshal_NONE__POINTER_POINTER, + GTK_TYPE_NONE, 2, GTK_TYPE_STRING, - GTK_TYPE_BOOL); + GTK_TYPE_STRING); signals[REMOVED_FOLDER] = gtk_signal_new ("removed_folder", GTK_RUN_FIRST, diff --git a/shell/evolution-storage.c b/shell/evolution-storage.c index ea8f1fd463..29afe24bd3 100644 --- a/shell/evolution-storage.c +++ b/shell/evolution-storage.c @@ -45,6 +45,9 @@ struct _EvolutionStoragePrivate { /* Name of the storage. */ char *name; + /* What we will display as the name of the storage. */ + char *display_name; + /* URI for the toplevel node of the storage. */ char *toplevel_node_uri; @@ -65,6 +68,7 @@ struct _EvolutionStoragePrivate { enum { CREATE_FOLDER, REMOVE_FOLDER, + UPDATE_FOLDER, LAST_SIGNAL }; @@ -360,6 +364,53 @@ impl_Storage_async_xfer_folder (PortableServer_Servant servant, } static void +impl_Storage_updateFolder (PortableServer_Servant servant, + const CORBA_char *path, + const CORBA_char *display_name, + CORBA_long unread_count, + CORBA_Environment *ev) +{ + BonoboObject *bonobo_object; + EvolutionStoragePrivate *priv; + EvolutionStorage *storage; + GList *p; + CORBA_Environment ev; + + bonobo_object = bonobo_object_from_servant (servant); + storage = EVOLUTION_STORAGE (bonobo_object); + + gtk_signal_emit (GTK_OBJECT (storage), signals[UPDATE_FOLDER], + path, display_name, unread_count); + + priv = storage->priv; + + if (priv->corba_storage_listeners == NULL) + return; + + CORBA_exception_init (&ev); + + for (p = priv->corba_storage_listeners; p != NULL; p = p->next) { + GNOME_Evolution_StorageListener listener; + + listener = p->data; + GNOME_Evolution_StorageListener_notifyFolderUpdated (listener, + path, + display_name, + unread_count, + &ev); + + if (ev._major != CORBA_NO_EXCEPTION) + continue; + + /* FIXME: Handle errors */ + + break; + } + + CORBA_exception_free (&ev); +} + +static void impl_Storage_add_listener (PortableServer_Servant servant, const GNOME_Evolution_StorageListener listener, CORBA_Environment *ev) @@ -492,6 +543,17 @@ class_init (EvolutionStorageClass *klass) GTK_TYPE_INT, 2, GTK_TYPE_STRING, GTK_TYPE_STRING); + + signals[UPDATE_FOLDER] = gtk_signal_new ("update_folder", + GTK_RUN_FIRST, + object_class->type, + GTK_SIGNAL_OFFSET (EvolutionStorageClass, + update_folder), + e_marshal_NONE__POINTER_POINTER_INT, + GTK_TYPE_NONE, 3, + GTK_TYPE_STRING, + GTK_TYPE_STRING, + GTK_TYPE_INT); gtk_object_class_add_signals (object_class, signals, LAST_SIGNAL); @@ -525,6 +587,7 @@ evolution_storage_get_epv (void) epv->asyncCreateFolder = impl_Storage_async_create_folder; epv->asyncRemoveFolder = impl_Storage_async_remove_folder; epv->asyncXferFolder = impl_Storage_async_xfer_folder; + epv->updateFolder = impl_Storage_updateFolder; epv->addListener = impl_Storage_add_listener; epv->removeListener = impl_Storage_remove_listener; @@ -583,6 +646,13 @@ evolution_storage_new (const char *name, return new; } +void +evolution_storage_rename (EvolutionStorage *evolution_storage, + const char *new_name) +{ + /* FIXME: Implement me */ +} + EvolutionStorageResult evolution_storage_register (EvolutionStorage *evolution_storage, GNOME_Evolution_StorageRegistry corba_storage_registry) @@ -728,7 +798,7 @@ evolution_storage_new_folder (EvolutionStorage *evolution_storage, const char *type, const char *physical_uri, const char *description, - gboolean highlighted) + int unread_count) { EvolutionStorageResult result; EvolutionStoragePrivate *priv; @@ -757,7 +827,7 @@ evolution_storage_new_folder (EvolutionStorage *evolution_storage, corba_folder->description = CORBA_string_dup (description); corba_folder->type = CORBA_string_dup (type); corba_folder->physical_uri = CORBA_string_dup (physical_uri); - corba_folder->highlighted = highlighted; + corba_folder->unread_count = 0; if (! e_folder_tree_add (priv->folder_tree, path, corba_folder)) { CORBA_free (corba_folder); @@ -793,8 +863,9 @@ evolution_storage_new_folder (EvolutionStorage *evolution_storage, EvolutionStorageResult evolution_storage_update_folder (EvolutionStorage *evolution_storage, - const char *path, const char *display_name, - gboolean highlighted) + const char *path, + const char *display_name, + int unread_count) { EvolutionStorageResult result; EvolutionStoragePrivate *priv; @@ -811,6 +882,9 @@ evolution_storage_update_folder (EvolutionStorage *evolution_storage, priv = evolution_storage->priv; + gtk_signal_emit (GTK_OBJECT (evolution_storage), signals[UPDATE_FOLDER], + path, display_name, unread_count); + if (priv->corba_storage_listeners == NULL) return EVOLUTION_STORAGE_ERROR_NOTREGISTERED; @@ -822,7 +896,7 @@ evolution_storage_update_folder (EvolutionStorage *evolution_storage, GNOME_Evolution_StorageListener listener; listener = p->data; - GNOME_Evolution_StorageListener_notifyFolderUpdated (listener, path, display_name, highlighted, &ev); + GNOME_Evolution_StorageListener_notifyFolderUpdated (listener, path, display_name, unread_count, &ev); if (ev._major != CORBA_NO_EXCEPTION) continue; @@ -844,7 +918,7 @@ evolution_storage_update_folder (EvolutionStorage *evolution_storage, if (corba_folder != NULL) { CORBA_free (corba_folder->display_name); corba_folder->display_name = CORBA_string_dup (display_name); - corba_folder->highlighted = highlighted; + corba_folder->unread_count = unread_count; } else result = EVOLUTION_STORAGE_ERROR_NOTFOUND; } @@ -854,9 +928,9 @@ evolution_storage_update_folder (EvolutionStorage *evolution_storage, EvolutionStorageResult evolution_storage_update_folder_by_uri (EvolutionStorage *evolution_storage, - const char *physical_uri, - const char *display_name, - gboolean highlighted) + const char *physical_uri, + const char *display_name, + int unread_count) { EvolutionStoragePrivate *priv; char *path; @@ -870,7 +944,7 @@ evolution_storage_update_folder_by_uri (EvolutionStorage *evolution_storage, priv = evolution_storage->priv; path = g_hash_table_lookup (priv->uri_to_path, physical_uri); - return evolution_storage_update_folder (evolution_storage, path, display_name, highlighted); + return evolution_storage_update_folder (evolution_storage, path, display_name, unread_count); } EvolutionStorageResult diff --git a/shell/evolution-storage.h b/shell/evolution-storage.h index b7339c615c..01aa2b018d 100644 --- a/shell/evolution-storage.h +++ b/shell/evolution-storage.h @@ -91,6 +91,11 @@ struct _EvolutionStorageClass { int (*remove_folder) (EvolutionStorage *storage, const char *path, const char *physical_uri); + + void (*update_folder) (EvolutionStorage *storage, + const char *path, + const char *display_name, + int unread_count); }; @@ -106,6 +111,9 @@ EvolutionStorage *evolution_storage_new (const char *name, const char *toplevel_node_uri, const char *toplevel_node_type); +void evolution_storage_rename (EvolutionStorage *storage, + const char *new_name); + EvolutionStorageResult evolution_storage_register (EvolutionStorage *storage, GNOME_Evolution_StorageRegistry corba_registry); EvolutionStorageResult evolution_storage_register_on_shell (EvolutionStorage *evolution_storage, @@ -118,15 +126,15 @@ EvolutionStorageResult evolution_storage_new_folder (EvolutionStorage const char *type, const char *physical_uri, const char *description, - gboolean highlighted); + int unread_count); EvolutionStorageResult evolution_storage_update_folder (EvolutionStorage *evolution_storage, const char *path, const char *display_name, - gboolean highlighted); + int unread_count); EvolutionStorageResult evolution_storage_update_folder_by_uri (EvolutionStorage *evolution_storage, const char *physical_uri, const char *display_name, - gboolean highlighted); + int unread_count); EvolutionStorageResult evolution_storage_removed_folder (EvolutionStorage *evolution_storage, const char *path); gboolean evolution_storage_folder_exists (EvolutionStorage *evolution_storage, |