diff options
author | Ettore Perazzoli <ettore@src.gnome.org> | 2003-11-18 03:12:04 +0800 |
---|---|---|
committer | Ettore Perazzoli <ettore@src.gnome.org> | 2003-11-18 03:12:04 +0800 |
commit | 8f502cffbc35cc4eabf91903fc30cdee5b42aaef (patch) | |
tree | e6401d90189f05b5fe3f52b35522a150f1362449 /shell | |
parent | f9cf09a8bdb53d025026e7ec0a7c8588b4528491 (diff) | |
download | gsoc2013-evolution-8f502cffbc35cc4eabf91903fc30cdee5b42aaef.tar gsoc2013-evolution-8f502cffbc35cc4eabf91903fc30cdee5b42aaef.tar.gz gsoc2013-evolution-8f502cffbc35cc4eabf91903fc30cdee5b42aaef.tar.bz2 gsoc2013-evolution-8f502cffbc35cc4eabf91903fc30cdee5b42aaef.tar.lz gsoc2013-evolution-8f502cffbc35cc4eabf91903fc30cdee5b42aaef.tar.xz gsoc2013-evolution-8f502cffbc35cc4eabf91903fc30cdee5b42aaef.tar.zst gsoc2013-evolution-8f502cffbc35cc4eabf91903fc30cdee5b42aaef.zip |
Do not #include "e-local-folder.h".
* e-setup.c: Do not #include "e-local-folder.h".
* Makefile.am: Don't build evolution-test-component for now since
it's all out of date.
* main.c (evolution_debug_log): Make static instead of extern.
* e-user-creatable-items-handler.c: #include
<bonobo/bonobo-control.h>.
* e-shell.h: Do not include "e-uri-schema-registry.h" or
"evolution-shell-component-client.h".
* e-shell.c: Likewise.
* e-shell.c (struct _EShellPrivate): Removed member
uri_schema_registry.
(impl_Shell_handleURI): #if 0 it out for now.
(e_shell_peek_uri_schema_registry): Disabled for now.
* e-corba-storage-registry.c: Remove.
* e-corba-storage-registry.h: Remove.
* e-corba-storage.c: Remove.
* e-corba-storage.h: Remove.
* e-folder-dnd-bridge.c: Remove.
* e-folder-dnd-bridge.h: Remove.
* e-folder-selection-dialog.c: Remove.
* e-folder-selection-dialog.h: Remove.
* e-folder-type-registry.c: Remove.
* e-folder-type-registry.h: Remove.
* e-local-folder.c: Remove.
* e-local-folder.h: Remove.
* e-local-storage.c: Remove.
* e-local-storage.h: Remove.
* e-shell-folder-selection-dialog.c: Remove.
* e-shell-folder-selection-dialog.h: Remove.
* e-shell-view.c: Remove.
* e-shell-view.h: Remove.
* e-storage-browser.c: Remove.
* e-storage-browser.h: Remove.
* e-storage-set-view.c: Remove.
* e-storage-set-view.h: Remove.
* e-storage-set.c: Remove.
* e-storage-set.h: Remove.
* e-storage.c: Remove.
* e-storage.h: Remove.
* evolution-shell-component-client.c: Remove.
* evolution-shell-component-client.h: Remove.
* evolution-shell-component-dnd.c: Remove.
* evolution-shell-component-dnd.h: Remove.
* evolution-storage-listener.c: Remove.
* evolution-storage-listener.h: Remove.
* evolution-storage-set-view-listener.c: Remove.
* evolution-storage-set-view-listener.h: Remove.
svn path=/trunk/; revision=23396
Diffstat (limited to 'shell')
43 files changed, 83 insertions, 16605 deletions
diff --git a/shell/ChangeLog b/shell/ChangeLog index 60a2d1ac5d..500d363e3f 100644 --- a/shell/ChangeLog +++ b/shell/ChangeLog @@ -1,3 +1,61 @@ +2003-11-17 Ettore Perazzoli <ettore@ximian.com> + + * e-setup.c: Do not #include "e-local-folder.h". + + * Makefile.am: Don't build evolution-test-component for now since + it's all out of date. + + * main.c (evolution_debug_log): Make static instead of extern. + + * e-user-creatable-items-handler.c: #include + <bonobo/bonobo-control.h>. + + * e-shell.h: Do not include "e-uri-schema-registry.h" or + "evolution-shell-component-client.h". + * e-shell.c: Likewise. + + * e-shell.c (struct _EShellPrivate): Removed member + uri_schema_registry. + (impl_Shell_handleURI): #if 0 it out for now. + (e_shell_peek_uri_schema_registry): Disabled for now. + + * e-uri-schema-registry.c: Don't compile for now. + + * e-corba-storage-registry.c: Remove. + * e-corba-storage-registry.h: Remove. + * e-corba-storage.c: Remove. + * e-corba-storage.h: Remove. + * e-folder-dnd-bridge.c: Remove. + * e-folder-dnd-bridge.h: Remove. + * e-folder-selection-dialog.c: Remove. + * e-folder-selection-dialog.h: Remove. + * e-folder-type-registry.c: Remove. + * e-folder-type-registry.h: Remove. + * e-local-folder.c: Remove. + * e-local-folder.h: Remove. + * e-local-storage.c: Remove. + * e-local-storage.h: Remove. + * e-shell-folder-selection-dialog.c: Remove. + * e-shell-folder-selection-dialog.h: Remove. + * e-shell-view.c: Remove. + * e-shell-view.h: Remove. + * e-storage-browser.c: Remove. + * e-storage-browser.h: Remove. + * e-storage-set-view.c: Remove. + * e-storage-set-view.h: Remove. + * e-storage-set.c: Remove. + * e-storage-set.h: Remove. + * e-storage.c: Remove. + * e-storage.h: Remove. + * evolution-shell-component-client.c: Remove. + * evolution-shell-component-client.h: Remove. + * evolution-shell-component-dnd.c: Remove. + * evolution-shell-component-dnd.h: Remove. + * evolution-storage-listener.c: Remove. + * evolution-storage-listener.h: Remove. + * evolution-storage-set-view-listener.c: Remove. + * evolution-storage-set-view-listener.h: Remove. + 2003-11-13 Ettore Perazzoli <ettore@ximian.com> * main.c (DEVELOPMENT_WARNING): Define. diff --git a/shell/Makefile.am b/shell/Makefile.am index a83991a00b..729b1d2544 100644 --- a/shell/Makefile.am +++ b/shell/Makefile.am @@ -21,7 +21,7 @@ INCLUDES = \ $(TZDIALOG_CFLAGS) \ $(SHELL_CFLAGS) -noinst_PROGRAMS = evolution evolution-test-component +noinst_PROGRAMS = evolution # Shell CORBA stuff @@ -109,64 +109,40 @@ eshellincludedir = $(privincludedir)/shell eshellinclude_HEADERS = \ Evolution.h \ - e-corba-storage.h \ - e-folder-dnd-bridge.h \ e-folder-list.h \ - e-folder-selection-dialog.h \ e-folder-tree.h \ - e-folder-type-registry.h \ e-folder.h \ e-icon-factory.h \ e-shell-corba-icon-utils.h \ e-shell-utils.h \ - e-storage-browser.h \ - e-storage-set-view.h \ - e-storage-set.h \ - e-storage.h \ evolution-activity-client.h \ evolution-config-control.h \ evolution-folder-selector-button.h \ evolution-session.h \ evolution-shell-client.h \ - evolution-shell-component-client.h \ - evolution-shell-component-dnd.h \ - evolution-shell-component-utils.h \ evolution-shell-component.h \ + evolution-shell-component-utils.h \ evolution-shell-view.h \ - evolution-storage-listener.h \ - evolution-storage-set-view-listener.h \ evolution-storage.h \ evolution-wizard.h libeshell_la_SOURCES = \ $(IDL_GENERATED) \ $(MARSHAL_GENERATED) \ - e-corba-storage.c \ - e-folder-dnd-bridge.c \ e-folder-list.c \ - e-folder-selection-dialog.c \ e-folder-tree.c \ - e-folder-type-registry.c \ e-folder.c \ e-icon-factory.c \ e-shell-corba-icon-utils.c \ e-shell-utils.c \ - e-storage-browser.c \ - e-storage-set-view.c \ - e-storage-set.c \ - e-storage.c \ evolution-activity-client.c \ evolution-config-control.c \ evolution-folder-selector-button.c \ evolution-session.c \ evolution-shell-client.c \ - evolution-shell-component-client.c \ - evolution-shell-component-dnd.c \ - evolution-shell-component-utils.c \ evolution-shell-component.c \ + evolution-shell-component-utils.c \ evolution-shell-view.c \ - evolution-storage-listener.c \ - evolution-storage-set-view-listener.c \ evolution-storage.c \ evolution-wizard.c \ $(eshellinclude_HEADERS) @@ -185,14 +161,8 @@ evolution_SOURCES = \ e-config-upgrade.h \ e-corba-config-page.c \ e-corba-config-page.h \ - e-corba-storage-registry.c \ - e-corba-storage-registry.h \ e-history.c \ e-history.h \ - e-local-folder.c \ - e-local-folder.h \ - e-local-storage.c \ - e-local-storage.h \ e-setup.c \ e-setup.h \ e-shell-about-box.c \ @@ -204,7 +174,6 @@ evolution_SOURCES = \ e-shell-settings-dialog.h \ e-shell-startup-wizard.c \ e-shell-startup-wizard.h \ - e-shell-view.h \ e-shell-window-commands.c \ e-shell-window-commands.h \ e-shell-window.c \ @@ -219,8 +188,6 @@ evolution_SOURCES = \ e-task-bar.h \ e-task-widget.c \ e-task-widget.h \ - e-uri-schema-registry.c \ - e-uri-schema-registry.h \ main.c evolution_LDADD = \ @@ -234,17 +201,17 @@ evolution_LDADD = \ # Test component -evolution_test_component_SOURCES = \ - evolution-test-component.c +# evolution_test_component_SOURCES = \ +# evolution-test-component.c -evolution_test_component_LDADD = \ - libeshell.la \ - $(SHELL_LIBS) +# evolution_test_component_LDADD = \ +# libeshell.la \ +# $(SHELL_LIBS) -install-test-component: evolution-test-component - $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) evolution-test-component $(DESTDIR)$(bindir)/evolution-test-component - $(mkinstalldirs) $(DESTDIR)$(serverdir) - $(INSTALL_DATA) $(srcdir)/GNOME_Evolution_TestComponent.server $(DESTDIR)$(serverdir)/GNOME_Evolution_TestComponent.server +# install-test-component: evolution-test-component +# $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) evolution-test-component $(DESTDIR)$(bindir)/evolution-test-component +# $(mkinstalldirs) $(DESTDIR)$(serverdir) +# $(INSTALL_DATA) $(srcdir)/GNOME_Evolution_TestComponent.server $(DESTDIR)$(serverdir)/GNOME_Evolution_TestComponent.server # Misc stuff diff --git a/shell/e-corba-shortcuts.c b/shell/e-corba-shortcuts.c deleted file mode 100644 index 46bebb2249..0000000000 --- a/shell/e-corba-shortcuts.c +++ /dev/null @@ -1,349 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-corba-shortcuts.c - * - * Copyright (C) 2001 Ximian, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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 <ettore@ximian.com> - */ - -/* FIXME: Doesn't throw exceptions properly. */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include "e-corba-shortcuts.h" - -#include "e-util/e-corba-utils.h" - -#include <gal/util/e-util.h> - - -#define PARENT_TYPE bonobo_object_get_type () -static BonoboObjectClass *parent_class = NULL; - -struct _ECorbaShortcutsPrivate { - EShortcuts *shortcuts; -}; - - -/* Utility functions. */ - -static const char * -string_from_corba (CORBA_char *corba_string) -{ - if (corba_string[0] == '\0') - return NULL; - - return corba_string; -} - -static void -shortcut_list_to_corba (const GSList *shortcut_list, - GNOME_Evolution_Shortcuts_ShortcutList *shortcut_list_return) -{ - GNOME_Evolution_Shortcuts_Shortcut *buffer; - const GSList *p; - int num_shortcuts; - int i; - - num_shortcuts = g_slist_length ((GSList *) shortcut_list); /* safe cast, GLib sucks */ - - shortcut_list_return->_maximum = num_shortcuts; - shortcut_list_return->_length = num_shortcuts; - - buffer = CORBA_sequence_GNOME_Evolution_Shortcuts_Shortcut_allocbuf (num_shortcuts); - shortcut_list_return->_buffer = buffer; - - for (p = shortcut_list, i = 0; p != NULL; p = p->next, i++) { - const EShortcutItem *item; - - item = (const EShortcutItem *) p->data; - - buffer[i].uri = CORBA_string_dup (e_safe_corba_string (item->uri)); - buffer[i].name = CORBA_string_dup (e_safe_corba_string (item->name)); - buffer[i].type = CORBA_string_dup (e_safe_corba_string (item->type)); - buffer[i].customIconName = CORBA_string_dup (e_safe_corba_string (item->custom_icon_name)); - } - - CORBA_sequence_set_release (shortcut_list_return, TRUE); -} - - -/* GObject methods. */ - -static void -impl_dispose (GObject *object) -{ - ECorbaShortcuts *corba_shortcuts; - ECorbaShortcutsPrivate *priv; - - corba_shortcuts = E_CORBA_SHORTCUTS (object); - priv = corba_shortcuts->priv; - - if (priv->shortcuts != NULL) { - g_object_unref (priv->shortcuts); - priv->shortcuts = NULL; - } - - (* G_OBJECT_CLASS (parent_class)->dispose) (object); -} - -static void -impl_finalize (GObject *object) -{ - ECorbaShortcuts *corba_shortcuts; - - corba_shortcuts = E_CORBA_SHORTCUTS (object); - - g_free (corba_shortcuts->priv); - - (* G_OBJECT_CLASS (parent_class)->finalize) (object); -} - - -/* Evolution::Shortcuts CORBA methods. */ - -static void -impl_add (PortableServer_Servant servant, - const CORBA_short group_num, - const CORBA_short position, - const GNOME_Evolution_Shortcuts_Shortcut *shortcut, - CORBA_Environment *ev) -{ - ECorbaShortcuts *corba_shortcuts; - ECorbaShortcutsPrivate *priv; - - corba_shortcuts = E_CORBA_SHORTCUTS (bonobo_object_from_servant (servant)); - priv = corba_shortcuts->priv; - - e_shortcuts_add_shortcut (priv->shortcuts, group_num, position, - string_from_corba (shortcut->uri), - string_from_corba (shortcut->name), - 0, - string_from_corba (shortcut->type), - string_from_corba (shortcut->customIconName)); -} - -static void -impl_remove (PortableServer_Servant servant, - const CORBA_short group_num, - const CORBA_short item_num, - CORBA_Environment *ev) -{ - ECorbaShortcuts *corba_shortcuts; - ECorbaShortcutsPrivate *priv; - - corba_shortcuts = E_CORBA_SHORTCUTS (bonobo_object_from_servant (servant)); - priv = corba_shortcuts->priv; - - e_shortcuts_remove_shortcut (priv->shortcuts, group_num, item_num); -} - -static GNOME_Evolution_Shortcuts_Shortcut * -impl_get (PortableServer_Servant servant, - const CORBA_short group_num, - const CORBA_short item_num, - CORBA_Environment *ev) -{ - ECorbaShortcuts *corba_shortcuts; - ECorbaShortcutsPrivate *priv; - GNOME_Evolution_Shortcuts_Shortcut *retval; - const EShortcutItem *item; - - corba_shortcuts = E_CORBA_SHORTCUTS (bonobo_object_from_servant (servant)); - priv = corba_shortcuts->priv; - - item = e_shortcuts_get_shortcut (priv->shortcuts, group_num, item_num); - if (item == NULL) { - CORBA_exception_set (ev, CORBA_USER_EXCEPTION, - ex_GNOME_Evolution_Shortcuts_NotFound, NULL); - return NULL; - } - - retval = GNOME_Evolution_Shortcuts_Shortcut__alloc (); - retval->uri = CORBA_string_dup (e_safe_corba_string (item->uri)); - retval->name = CORBA_string_dup (e_safe_corba_string (item->name)); - retval->type = CORBA_string_dup (e_safe_corba_string (item->type)); - retval->customIconName = CORBA_string_dup (e_safe_corba_string (item->custom_icon_name)); - - return retval; -} - -static void -impl_addGroup (PortableServer_Servant servant, - const CORBA_short position, - const CORBA_char *name, - CORBA_Environment *ev) -{ - ECorbaShortcuts *corba_shortcuts; - ECorbaShortcutsPrivate *priv; - - corba_shortcuts = E_CORBA_SHORTCUTS (bonobo_object_from_servant (servant)); - priv = corba_shortcuts->priv; - - if (position == 0) { - CORBA_exception_set (ev, CORBA_USER_EXCEPTION, - ex_GNOME_Evolution_Shortcuts_InvalidPosition, NULL); - return; - } - - e_shortcuts_add_group (priv->shortcuts, position, name); -} - -static void -impl_removeGroup (PortableServer_Servant servant, - const CORBA_short group_num, - CORBA_Environment *ev) -{ - ECorbaShortcuts *corba_shortcuts; - ECorbaShortcutsPrivate *priv; - - corba_shortcuts = E_CORBA_SHORTCUTS (bonobo_object_from_servant (servant)); - priv = corba_shortcuts->priv; - - if (group_num == 0) { - CORBA_exception_set (ev, CORBA_USER_EXCEPTION, - ex_GNOME_Evolution_Shortcuts_CannotRemove, NULL); - return; - } - - e_shortcuts_remove_group (priv->shortcuts, group_num); -} - -static GNOME_Evolution_Shortcuts_Group * -impl_getGroup (PortableServer_Servant servant, - const CORBA_short group_num, - CORBA_Environment *ev) -{ - ECorbaShortcuts *corba_shortcuts; - ECorbaShortcutsPrivate *priv; - GNOME_Evolution_Shortcuts_Group *group; - const GSList *list; - - corba_shortcuts = E_CORBA_SHORTCUTS (bonobo_object_from_servant (servant)); - priv = corba_shortcuts->priv; - - list = e_shortcuts_get_shortcuts_in_group (priv->shortcuts, group_num); - - group = GNOME_Evolution_Shortcuts_Group__alloc (); - - group->name = CORBA_string_dup (e_shortcuts_get_group_title (priv->shortcuts, group_num)); - - shortcut_list_to_corba (list, & group->shortcuts); - - return group; -} - -static CORBA_sequence_GNOME_Evolution_Shortcuts_Group * -impl__get_groups (PortableServer_Servant servant, - CORBA_Environment *ev) -{ - GNOME_Evolution_Shortcuts_GroupList *list; - ECorbaShortcuts *corba_shortcuts; - ECorbaShortcutsPrivate *priv; - GSList *group_titles; - const GSList *p; - int i; - - corba_shortcuts = E_CORBA_SHORTCUTS (bonobo_object_from_servant (servant)); - priv = corba_shortcuts->priv; - - list = GNOME_Evolution_Shortcuts_GroupList__alloc (); - list->_length = e_shortcuts_get_num_groups (priv->shortcuts); - list->_maximum = list->_length; - list->_buffer = CORBA_sequence_GNOME_Evolution_Shortcuts_Group_allocbuf (list->_maximum); - - CORBA_sequence_set_release (list, TRUE); - - group_titles = e_shortcuts_get_group_titles (priv->shortcuts); - for (p = group_titles, i = 0; p != NULL; p = p->next, i ++) { - char *group_title; - const GSList *shortcuts; - - group_title = (char *) p->data; - - shortcuts = e_shortcuts_get_shortcuts_in_group (priv->shortcuts, i); - - list->_buffer[i].name = CORBA_string_dup (group_title); - shortcut_list_to_corba (shortcuts, &list->_buffer[i].shortcuts); - - g_free (group_title); - } - - g_slist_free (group_titles); - - return list; -} - - -static void -e_corba_shortcuts_class_init (GObjectClass *object_class) -{ - ECorbaShortcutsClass *corba_shortcuts_class; - POA_GNOME_Evolution_Shortcuts__epv *epv; - - parent_class = g_type_class_ref(PARENT_TYPE); - - object_class->dispose = impl_dispose; - object_class->finalize = impl_finalize; - - corba_shortcuts_class = E_CORBA_SHORTCUTS_CLASS (object_class); - - epv = & corba_shortcuts_class->epv; - epv->add = impl_add; - epv->remove = impl_remove; - epv->get = impl_get; - epv->addGroup = impl_addGroup; - epv->removeGroup = impl_removeGroup; - epv->getGroup = impl_getGroup; - epv->_get_groups = impl__get_groups; -} - -static void -e_corba_shortcuts_init (ECorbaShortcuts *corba_shortcuts) -{ - ECorbaShortcutsPrivate *priv; - - priv = g_new (ECorbaShortcutsPrivate, 1); - priv->shortcuts = NULL; - - corba_shortcuts->priv = priv; -} - - -ECorbaShortcuts * -e_corba_shortcuts_new (EShortcuts *shortcuts) -{ - ECorbaShortcuts *corba_shortcuts; - - g_return_val_if_fail (shortcuts != NULL, NULL); - g_return_val_if_fail (E_IS_SHORTCUTS (shortcuts), NULL); - - corba_shortcuts = g_object_new (e_corba_shortcuts_get_type (), NULL); - - g_object_ref (shortcuts); - corba_shortcuts->priv->shortcuts = shortcuts; - - return corba_shortcuts; -} - - -BONOBO_TYPE_FUNC_FULL (ECorbaShortcuts, - GNOME_Evolution_Shortcuts, - PARENT_TYPE, - e_corba_shortcuts) diff --git a/shell/e-corba-shortcuts.h b/shell/e-corba-shortcuts.h deleted file mode 100644 index 8d6ff97adc..0000000000 --- a/shell/e-corba-shortcuts.h +++ /dev/null @@ -1,66 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-corba-shortcuts.h - * - * Copyright (C) 2001 Ximian, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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 <ettore@ximian.com> - */ - -#ifndef _E_CORBA_SHORTCUTS_H_ -#define _E_CORBA_SHORTCUTS_H_ - -#include "e-shortcuts.h" - -#include <bonobo/bonobo-object.h> - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - -#define E_TYPE_CORBA_SHORTCUTS (e_corba_shortcuts_get_type ()) -#define E_CORBA_SHORTCUTS(obj) (GTK_CHECK_CAST ((obj), E_TYPE_CORBA_SHORTCUTS, ECorbaShortcuts)) -#define E_CORBA_SHORTCUTS_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_TYPE_CORBA_SHORTCUTS, ECorbaShortcutsClass)) -#define E_IS_CORBA_SHORTCUTS(obj) (GTK_CHECK_TYPE ((obj), E_TYPE_CORBA_SHORTCUTS)) -#define E_IS_CORBA_SHORTCUTS_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), E_TYPE_CORBA_SHORTCUTS)) - - -typedef struct _ECorbaShortcuts ECorbaShortcuts; -typedef struct _ECorbaShortcutsPrivate ECorbaShortcutsPrivate; -typedef struct _ECorbaShortcutsClass ECorbaShortcutsClass; - -struct _ECorbaShortcuts { - BonoboObject parent; - - ECorbaShortcutsPrivate *priv; -}; - -struct _ECorbaShortcutsClass { - BonoboObjectClass parent_class; - - POA_GNOME_Evolution_Shortcuts__epv epv; -}; - - -GtkType e_corba_shortcuts_get_type (void); -ECorbaShortcuts *e_corba_shortcuts_new (EShortcuts *shortcuts); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _E_CORBA_SHORTCUTS_H_ */ diff --git a/shell/e-corba-storage-registry.c b/shell/e-corba-storage-registry.c deleted file mode 100644 index c774d94326..0000000000 --- a/shell/e-corba-storage-registry.c +++ /dev/null @@ -1,494 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-corba-storage-registry.c - * - * Copyright (C) 2000 Ximian, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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 "e-local-storage.h" -#include "e-corba-storage.h" -#include "e-corba-storage-registry.h" -#include "e-shell-constants.h" - -#include "e-util/e-corba-utils.h" - -#include <bonobo/bonobo-exception.h> -#include <gal/util/e-util.h> - -#include <string.h> - - -#define PARENT_TYPE BONOBO_OBJECT_TYPE -static BonoboObjectClass *parent_class = NULL; - -struct _ECorbaStorageRegistryPrivate { - EStorageSet *storage_set; - - GSList *listeners; -}; - - -/* CORBA interface implementation. */ - -static void -listener_notify (Bonobo_Listener listener, - GNOME_Evolution_StorageRegistry_MessageType type, - const char *name) -{ - CORBA_any any; - GNOME_Evolution_StorageRegistry_NotifyResult nr; - CORBA_Environment ev; - - nr.type = type; - nr.name = CORBA_string_dup (name ? name : ""); - - any._type = (CORBA_TypeCode) TC_GNOME_Evolution_StorageRegistry_NotifyResult; - any._value = &nr; - - CORBA_exception_init (&ev); - Bonobo_Listener_event (listener, - "Evolution::StorageRegistry::NotifyResult", - &any, &ev); - if (BONOBO_EX (&ev)) { - g_warning ("Could not send notify event for %s\n%s", name, - CORBA_exception_id (&ev)); - } - - CORBA_exception_free (&ev); - CORBA_free (nr.name); -} - -static GNOME_Evolution_StorageListener -impl_StorageRegistry_addStorage (PortableServer_Servant servant, - const GNOME_Evolution_Storage storage_interface, - const CORBA_char *name, - CORBA_Environment *ev) -{ - BonoboObject *bonobo_object; - ECorbaStorageRegistry *storage_registry; - ECorbaStorageRegistryPrivate *priv; - EStorage *storage; - GNOME_Evolution_StorageListener listener_interface; - GSList *iter; - - bonobo_object = bonobo_object_from_servant (servant); - storage_registry = E_CORBA_STORAGE_REGISTRY (bonobo_object); - priv = storage_registry->priv; - - storage = e_corba_storage_new (storage_interface, name); - - if (! e_storage_set_add_storage (priv->storage_set, storage)) { - CORBA_exception_set (ev, - CORBA_USER_EXCEPTION, - ex_GNOME_Evolution_StorageRegistry_Exists, - NULL); - return CORBA_OBJECT_NIL; - } - - g_object_unref (storage); - - - /* FIXME: if we remove a listener while looping through the list we can - * crash. Yay CORBA reentrancy. */ - for (iter = priv->listeners; iter; iter = iter->next) { - listener_notify (iter->data, - GNOME_Evolution_StorageRegistry_STORAGE_CREATED, - name); - } - - listener_interface = CORBA_Object_duplicate (e_corba_storage_get_StorageListener - (E_CORBA_STORAGE (storage)), ev); - - return listener_interface; -} - -static GNOME_Evolution_StorageRegistry_StorageList * -impl_StorageRegistry_getStorageList (PortableServer_Servant servant, - CORBA_Environment *ev) -{ - BonoboObject *bonobo_object; - ECorbaStorageRegistry *storage_registry; - ECorbaStorageRegistryPrivate *priv; - GNOME_Evolution_StorageRegistry_StorageList *storage_list; - GList *sl, *l; - - bonobo_object = bonobo_object_from_servant (servant); - storage_registry = E_CORBA_STORAGE_REGISTRY (bonobo_object); - priv = storage_registry->priv; - - sl = e_storage_set_get_storage_list (priv->storage_set); - - storage_list = GNOME_Evolution_StorageRegistry_StorageList__alloc (); - storage_list->_maximum = g_list_length (sl); - storage_list->_length = 0; - storage_list->_buffer = CORBA_sequence_GNOME_Evolution_Storage_allocbuf (storage_list->_maximum); - for (l = sl; l != NULL; l = l->next) { - EStorage *storage; - GNOME_Evolution_Storage corba_storage; - CORBA_Environment ev2; - - CORBA_exception_init (&ev2); - - storage = l->data; - if (E_IS_LOCAL_STORAGE (storage)) { - corba_storage = e_local_storage_get_corba_interface (E_LOCAL_STORAGE (storage)); - } else if (E_IS_CORBA_STORAGE (storage)) { - corba_storage = e_corba_storage_get_corba_objref (E_CORBA_STORAGE (storage)); - } else { - continue; - } - - corba_storage = CORBA_Object_duplicate (corba_storage, &ev2); - if (BONOBO_EX (&ev2)) { - CORBA_exception_free (&ev2); - continue; - } - storage_list->_buffer[storage_list->_length] = corba_storage; - storage_list->_length++; - } - - CORBA_sequence_set_release (storage_list, TRUE); - - return storage_list; -} - -static GNOME_Evolution_Storage -impl_StorageRegistry_getStorageByName (PortableServer_Servant servant, - const CORBA_char *name, - CORBA_Environment *ev) -{ - BonoboObject *bonobo_object; - ECorbaStorageRegistry *storage_registry; - ECorbaStorageRegistryPrivate *priv; - GNOME_Evolution_Storage corba_storage; - EStorage *storage; - - bonobo_object = bonobo_object_from_servant (servant); - storage_registry = E_CORBA_STORAGE_REGISTRY (bonobo_object); - priv = storage_registry->priv; - - storage = e_storage_set_get_storage (priv->storage_set, name); - if (storage == NULL) { - CORBA_exception_set (ev, CORBA_USER_EXCEPTION, - ex_GNOME_Evolution_StorageRegistry_NotFound, - NULL); - return CORBA_OBJECT_NIL; - } - - corba_storage = e_corba_storage_get_corba_objref (E_CORBA_STORAGE (storage)); - - return bonobo_object_dup_ref (corba_storage, NULL); -} - -static void -impl_StorageRegistry_removeStorageByName (PortableServer_Servant servant, - const CORBA_char *name, - CORBA_Environment *ev) -{ - BonoboObject *bonobo_object; - ECorbaStorageRegistry *storage_registry; - ECorbaStorageRegistryPrivate *priv; - EStorage *storage; - - bonobo_object = bonobo_object_from_servant (servant); - storage_registry = E_CORBA_STORAGE_REGISTRY (bonobo_object); - priv = storage_registry->priv; - - storage = e_storage_set_get_storage (priv->storage_set, name); - if (storage == NULL) { - CORBA_exception_set (ev, CORBA_USER_EXCEPTION, - ex_GNOME_Evolution_StorageRegistry_NotFound, - NULL); - return; - } - - /* FIXME: Yucky to get the storage by name and then remove it. */ - /* FIXME: Check failure. */ - e_storage_set_remove_storage (priv->storage_set, storage); -} - -static void -storage_set_foreach (EStorageSet *set, - Bonobo_Listener listener) -{ - GList *storage_list, *p; - - storage_list = e_storage_set_get_storage_list (set); - for (p = storage_list; p; p = p->next) { - const char *name; - - name = e_storage_get_name (E_STORAGE (p->data)); - - listener_notify (listener, GNOME_Evolution_StorageRegistry_STORAGE_CREATED, name); - g_object_unref (p->data); - } - - g_list_free (storage_list); -} - -static GSList * -find_listener (GSList *p, - Bonobo_Listener listener) -{ - CORBA_Environment ev; - - CORBA_exception_init (&ev); - for (; p; p = p->next) { - if (CORBA_Object_is_equivalent (p->data, listener, &ev) == TRUE) { - CORBA_exception_free (&ev); - return p; - } - } - - CORBA_exception_free (&ev); - return NULL; -} - -static void -impl_StorageRegistry_addListener (PortableServer_Servant servant, - Bonobo_Listener listener, - CORBA_Environment *ev) -{ - BonoboObject *bonobo_object; - ECorbaStorageRegistry *storage_registry; - ECorbaStorageRegistryPrivate *priv; - Bonobo_Listener listener_copy; - CORBA_Environment ev2; - - bonobo_object = bonobo_object_from_servant (servant); - storage_registry = E_CORBA_STORAGE_REGISTRY (bonobo_object); - priv = storage_registry->priv; - - if (find_listener (priv->listeners, listener) != NULL) { - CORBA_exception_set (ev, CORBA_USER_EXCEPTION, - ex_GNOME_Evolution_StorageRegistry_AlreadyListening, - NULL); - return; - } - - CORBA_exception_init (&ev2); - listener_copy = CORBA_Object_duplicate ((CORBA_Object) listener, &ev2); - if (BONOBO_EX (&ev2)) { - g_warning ("EvolutionStorageRegistry -- Cannot duplicate listener."); - CORBA_exception_free (&ev2); - return; - } - - CORBA_exception_free (&ev2); - priv->listeners = g_slist_prepend (priv->listeners, listener_copy); - storage_set_foreach (priv->storage_set, listener_copy); -} - -static void -impl_StorageRegistry_removeListener (PortableServer_Servant servant, - Bonobo_Listener listener, - CORBA_Environment *ev) -{ - BonoboObject *bonobo_object; - ECorbaStorageRegistry *storage_registry; - ECorbaStorageRegistryPrivate *priv; - CORBA_Environment ev2; - GSList *p; - - bonobo_object = bonobo_object_from_servant (servant); - storage_registry = E_CORBA_STORAGE_REGISTRY (bonobo_object); - priv = storage_registry->priv; - - p = find_listener (priv->listeners, listener); - if (p == NULL) { - CORBA_exception_set (ev, CORBA_USER_EXCEPTION, - ex_GNOME_Evolution_StorageRegistry_NotFound, - NULL); - return; - } - - CORBA_exception_init (&ev2); - CORBA_Object_release ((CORBA_Object) p->data, &ev2); - CORBA_exception_free (&ev2); - - priv->listeners = g_slist_remove_link (priv->listeners, p); - g_slist_free (p); -} - -static GNOME_Evolution_Folder * -impl_StorageRegistry_getFolderByUri (PortableServer_Servant servant, - const CORBA_char *uri, - CORBA_Environment *ev) -{ - BonoboObject *bonobo_object; - ECorbaStorageRegistry *storage_registry; - GNOME_Evolution_Folder *corba_folder; - EStorageSet *storage_set; - EFolder *folder; - char *path; - CORBA_char *corba_evolution_uri; - - bonobo_object = bonobo_object_from_servant (servant); - storage_registry = E_CORBA_STORAGE_REGISTRY (bonobo_object); - storage_set = storage_registry->priv->storage_set; - - if (!strncmp (uri, E_SHELL_URI_PREFIX, E_SHELL_URI_PREFIX_LEN)) { - corba_evolution_uri = CORBA_string_dup (uri); - path = (char *)uri + E_SHELL_URI_PREFIX_LEN; - folder = e_storage_set_get_folder (storage_set, path); - } else { - path = e_storage_set_get_path_for_physical_uri (storage_set, uri); - if (path) { - corba_evolution_uri = CORBA_string_alloc (strlen (path) + E_SHELL_URI_PREFIX_LEN + 1); - strcpy (corba_evolution_uri, E_SHELL_URI_PREFIX); - strcat (corba_evolution_uri, path); - folder = e_storage_set_get_folder (storage_set, path); - g_free (path); - } else { - corba_evolution_uri = NULL; - folder = NULL; - } - } - - if (!folder) { - CORBA_exception_set (ev, CORBA_USER_EXCEPTION, - ex_GNOME_Evolution_StorageRegistry_NotFound, - NULL); - return CORBA_OBJECT_NIL; - } - - corba_folder = GNOME_Evolution_Folder__alloc (); - - corba_folder->displayName = CORBA_string_dup (e_folder_get_name (folder)); - - corba_folder->description = CORBA_string_dup (e_safe_corba_string (e_folder_get_description (folder))); - corba_folder->type = CORBA_string_dup (e_folder_get_type_string (folder)); - corba_folder->physicalUri = CORBA_string_dup (e_safe_corba_string (e_folder_get_physical_uri (folder))); - corba_folder->customIconName = CORBA_string_dup (e_safe_corba_string (e_folder_get_custom_icon_name (folder))); - corba_folder->evolutionUri = corba_evolution_uri; - corba_folder->unreadCount = e_folder_get_unread_count (folder); - corba_folder->sortingPriority = e_folder_get_sorting_priority (folder); - - return corba_folder; -} - - -/* GObject methods. */ - -static void -impl_dispose (GObject *object) -{ - ECorbaStorageRegistry *corba_storage_registry; - ECorbaStorageRegistryPrivate *priv; - - corba_storage_registry = E_CORBA_STORAGE_REGISTRY (object); - priv = corba_storage_registry->priv; - - if (priv->storage_set != NULL) { - g_object_unref (priv->storage_set); - priv->storage_set = NULL; - } - - (* G_OBJECT_CLASS (parent_class)->dispose) (object); -} - -static void -impl_finalize (GObject *object) -{ - ECorbaStorageRegistry *corba_storage_registry; - ECorbaStorageRegistryPrivate *priv; - - corba_storage_registry = E_CORBA_STORAGE_REGISTRY (object); - priv = corba_storage_registry->priv; - - g_free (priv); - - (* G_OBJECT_CLASS (parent_class)->finalize) (object); -} - - -/* Initialization. */ - -static void -e_corba_storage_registry_class_init (ECorbaStorageRegistryClass *klass) -{ - GObjectClass *object_class; - POA_GNOME_Evolution_StorageRegistry__epv *epv; - - object_class = G_OBJECT_CLASS (klass); - object_class->dispose = impl_dispose; - object_class->finalize = impl_finalize; - - epv = & klass->epv; - epv->addStorage = impl_StorageRegistry_addStorage; - epv->getStorageList = impl_StorageRegistry_getStorageList; - epv->getStorageByName = impl_StorageRegistry_getStorageByName; - epv->removeStorageByName = impl_StorageRegistry_removeStorageByName; - epv->addListener = impl_StorageRegistry_addListener; - epv->removeListener = impl_StorageRegistry_removeListener; - epv->getFolderByUri = impl_StorageRegistry_getFolderByUri; - - parent_class = g_type_class_ref(PARENT_TYPE); -} - -static void -e_corba_storage_registry_init (ECorbaStorageRegistry *corba_storage_registry) -{ - ECorbaStorageRegistryPrivate *priv; - - priv = g_new (ECorbaStorageRegistryPrivate, 1); - priv->storage_set = NULL; - priv->listeners = NULL; - - corba_storage_registry->priv = priv; -} - - -void -e_corba_storage_registry_construct (ECorbaStorageRegistry *corba_storage_registry, - EStorageSet *storage_set) -{ - ECorbaStorageRegistryPrivate *priv; - - g_return_if_fail (E_IS_CORBA_STORAGE_REGISTRY (corba_storage_registry)); - - priv = corba_storage_registry->priv; - - g_object_ref (storage_set); - priv->storage_set = storage_set; -} - -ECorbaStorageRegistry * -e_corba_storage_registry_new (EStorageSet *storage_set) -{ - ECorbaStorageRegistry *corba_storage_registry; - - g_return_val_if_fail (storage_set != NULL, NULL); - g_return_val_if_fail (E_IS_STORAGE_SET (storage_set), NULL); - - corba_storage_registry = g_object_new (e_corba_storage_registry_get_type (), NULL); - - e_corba_storage_registry_construct (corba_storage_registry, storage_set); - - return corba_storage_registry; -} - - -BONOBO_TYPE_FUNC_FULL (ECorbaStorageRegistry, - GNOME_Evolution_StorageRegistry, - PARENT_TYPE, - e_corba_storage_registry) diff --git a/shell/e-corba-storage-registry.h b/shell/e-corba-storage-registry.h deleted file mode 100644 index f75db6dd90..0000000000 --- a/shell/e-corba-storage-registry.h +++ /dev/null @@ -1,69 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-corba-storage-registry.h - * - * Copyright (C) 2000 Ximian, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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 __E_CORBA_STORAGE_REGISTRY_H__ -#define __E_CORBA_STORAGE_REGISTRY_H__ - -#include <bonobo/bonobo-object.h> - -#include "Evolution.h" -#include "e-storage-set.h" - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - -#define E_TYPE_CORBA_STORAGE_REGISTRY (e_corba_storage_registry_get_type ()) -#define E_CORBA_STORAGE_REGISTRY(obj) (GTK_CHECK_CAST ((obj), E_TYPE_CORBA_STORAGE_REGISTRY, ECorbaStorageRegistry)) -#define E_CORBA_STORAGE_REGISTRY_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_TYPE_CORBA_STORAGE_REGISTRY, ECorbaStorageRegistryClass)) -#define E_IS_CORBA_STORAGE_REGISTRY(obj) (GTK_CHECK_TYPE ((obj), E_TYPE_CORBA_STORAGE_REGISTRY)) -#define E_IS_CORBA_STORAGE_REGISTRY_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), E_TYPE_CORBA_STORAGE_REGISTRY)) - - -typedef struct _ECorbaStorageRegistry ECorbaStorageRegistry; -typedef struct _ECorbaStorageRegistryPrivate ECorbaStorageRegistryPrivate; -typedef struct _ECorbaStorageRegistryClass ECorbaStorageRegistryClass; - -struct _ECorbaStorageRegistry { - BonoboObject parent; - - ECorbaStorageRegistryPrivate *priv; -}; - -struct _ECorbaStorageRegistryClass { - BonoboObjectClass parent_class; - - POA_GNOME_Evolution_StorageRegistry__epv epv; -}; - - -GtkType e_corba_storage_registry_get_type (void); -void e_corba_storage_registry_construct (ECorbaStorageRegistry *corba_storage_registry, - EStorageSet *storage_set); -ECorbaStorageRegistry *e_corba_storage_registry_new (EStorageSet *storage_set); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* __E_CORBA_STORAGE_REGISTRY_H__ */ diff --git a/shell/e-corba-storage.c b/shell/e-corba-storage.c deleted file mode 100644 index 185b4093a9..0000000000 --- a/shell/e-corba-storage.c +++ /dev/null @@ -1,1072 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-corba-storage.c - * - * Copyright (C) 2000, 2001 Ximian, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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 "e-corba-storage.h" - -#include "e-shell-constants.h" - -#include "Evolution.h" - -#include <glib.h> -#include <gal/util/e-util.h> - -#include <bonobo/bonobo-main.h> -#include <bonobo/bonobo-exception.h> -#include <bonobo/bonobo-listener.h> - -#include <gdk/gdkx.h> -#include <gtk/gtkmain.h> - -#include <string.h> - - -#define PARENT_TYPE E_TYPE_STORAGE -static EStorageClass *parent_class = NULL; - -typedef struct _StorageListenerServant StorageListenerServant; - -struct _ECorbaStoragePrivate { - GNOME_Evolution_Storage storage_interface; - - /* The Evolution::StorageListener interface we expose. */ - GNOME_Evolution_StorageListener storage_listener_interface; - StorageListenerServant *storage_listener_servant; - - GList *pending_opens; -}; - - -/* Implementation of the CORBA Evolution::StorageListener interface. */ - -static POA_GNOME_Evolution_StorageListener__vepv storage_listener_vepv; - -struct _StorageListenerServant { - POA_GNOME_Evolution_StorageListener servant; - EStorage *storage; -}; - -static StorageListenerServant * -storage_listener_servant_new (ECorbaStorage *corba_storage) -{ - StorageListenerServant *servant; - - servant = g_new0 (StorageListenerServant, 1); - - servant->servant.vepv = &storage_listener_vepv; - - servant->storage = E_STORAGE (corba_storage); - - return servant; -} - -static void -storage_listener_servant_free (StorageListenerServant *servant) -{ - g_free (servant); -} - -#if 0 -static void -impl_StorageListener_destroy (PortableServer_Servant servant, - CORBA_Environment *ev) -{ - /* FIXME */ -} -#endif - -static void -impl_StorageListener_notifyFolderCreated (PortableServer_Servant servant, - const CORBA_char *path, - const GNOME_Evolution_Folder *folder, - CORBA_Environment *ev) -{ - StorageListenerServant *storage_listener_servant; - EStorage *storage; - EFolder *e_folder; - - storage_listener_servant = (StorageListenerServant *) servant; - storage = storage_listener_servant->storage; - - e_folder = e_folder_new (folder->displayName, folder->type, folder->description); - - e_folder_set_physical_uri (e_folder, folder->physicalUri); - e_folder_set_unread_count (e_folder, folder->unreadCount); - e_folder_set_can_sync_offline (e_folder, folder->canSyncOffline); - e_folder_set_sorting_priority (e_folder, folder->sortingPriority); - - if (folder->customIconName[0] != '\0') - e_folder_set_custom_icon (e_folder, folder->customIconName); - - if (! e_storage_new_folder (storage, path, e_folder)) { - g_warning ("Cannot register folder -- %s %s\n", path, folder->displayName); - CORBA_exception_set (ev, - CORBA_USER_EXCEPTION, - ex_GNOME_Evolution_StorageListener_Exists, - NULL); - g_object_unref (e_folder); - return; - } -} - -static void -impl_StorageListener_notifyFolderUpdated (PortableServer_Servant servant, - const CORBA_char *path, - CORBA_long unread_count, - CORBA_Environment *ev) -{ - StorageListenerServant *storage_listener_servant; - EStorage *storage; - EFolder *e_folder; - - storage_listener_servant = (StorageListenerServant *) servant; - storage = storage_listener_servant->storage; - - e_folder = e_storage_get_folder (storage, path); - if (e_folder == NULL) { - CORBA_exception_set (ev, - CORBA_USER_EXCEPTION, - ex_GNOME_Evolution_StorageListener_NotFound, - NULL); - return; - } - - e_folder_set_unread_count (e_folder, unread_count); -} - -static void -impl_StorageListener_notifyFolderRemoved (PortableServer_Servant servant, - const CORBA_char *path, - CORBA_Environment *ev) -{ - StorageListenerServant *storage_listener_servant; - EStorage *storage; - - storage_listener_servant = (StorageListenerServant *) servant; - storage = storage_listener_servant->storage; - - if (! e_storage_removed_folder (storage, path)) - CORBA_exception_set (ev, - CORBA_USER_EXCEPTION, - ex_GNOME_Evolution_StorageListener_NotFound, - NULL); -} - -static void -impl_StorageListener_notifyHasSubfolders (PortableServer_Servant servant, - const CORBA_char *path, - const CORBA_char *message, - CORBA_Environment *ev) -{ - StorageListenerServant *storage_listener_servant; - EStorage *storage; - - storage_listener_servant = (StorageListenerServant *) servant; - storage = storage_listener_servant->storage; - - if (! e_storage_declare_has_subfolders (storage, path, message)) { - g_warning ("Cannot register subfolder tree -- %s\n", path); - CORBA_exception_set (ev, - CORBA_USER_EXCEPTION, - ex_GNOME_Evolution_StorageListener_Exists, - NULL); - } -} - - -static gboolean -setup_storage_listener (ECorbaStorage *corba_storage) -{ - StorageListenerServant *servant; - ECorbaStoragePrivate *priv; - GNOME_Evolution_StorageListener storage_listener_interface; - CORBA_Environment ev; - - priv = corba_storage->priv; - - servant = storage_listener_servant_new (corba_storage); - - CORBA_exception_init (&ev); - - POA_GNOME_Evolution_StorageListener__init (servant, &ev); - if (ev._major != CORBA_NO_EXCEPTION) - goto error; - - CORBA_free (PortableServer_POA_activate_object (bonobo_poa (), servant, &ev)); - if (ev._major != CORBA_NO_EXCEPTION) - goto error; - - storage_listener_interface = PortableServer_POA_servant_to_reference (bonobo_poa (), - servant, &ev); - if (ev._major != CORBA_NO_EXCEPTION) - goto error; - - priv->storage_listener_interface = storage_listener_interface; - priv->storage_listener_servant = servant; - - return TRUE; - - error: - storage_listener_servant_free (servant); - CORBA_exception_free (&ev); - return FALSE; -} - - -/* GObject methods. */ - -static void -impl_dispose (GObject *object) -{ - CORBA_Environment ev; - ECorbaStorage *corba_storage; - ECorbaStoragePrivate *priv; - - corba_storage = E_CORBA_STORAGE (object); - priv = corba_storage->priv; - - CORBA_exception_init (&ev); - - if (priv->storage_interface != CORBA_OBJECT_NIL) { - Bonobo_Unknown_unref (priv->storage_interface, &ev); - CORBA_Object_release (priv->storage_interface, &ev); - priv->storage_interface = CORBA_OBJECT_NIL; - } - - if (priv->storage_listener_interface != CORBA_OBJECT_NIL) { - CORBA_Object_release (priv->storage_listener_interface, &ev); - priv->storage_listener_interface = CORBA_OBJECT_NIL; - } - - if (priv->storage_listener_servant != NULL) { - PortableServer_ObjectId *object_id; - - object_id = PortableServer_POA_servant_to_id (bonobo_poa (), priv->storage_listener_servant, - &ev); - PortableServer_POA_deactivate_object (bonobo_poa (), object_id, &ev); - - CORBA_free (object_id); - - storage_listener_servant_free (priv->storage_listener_servant); - priv->storage_listener_servant = NULL; - } - - CORBA_exception_free (&ev); - - if (priv->pending_opens != NULL) { - g_warning ("destroying ECorbaStorage with pending async ops"); - priv->pending_opens = NULL; - } - - (* G_OBJECT_CLASS (parent_class)->dispose) (object); -} - -static void -impl_finalize (GObject *object) -{ - ECorbaStorage *corba_storage; - - corba_storage = E_CORBA_STORAGE (object); - - g_free (corba_storage->priv); - - (* G_OBJECT_CLASS (parent_class)->finalize) (object); -} - - -/* EStorage methods. */ - -static void -get_folder_cb (EStorage *storage, EStorageResult result, - const char *path, gpointer data) -{ - gboolean *done = data; - - *done = TRUE; -} - -static EFolder * -get_folder (EStorage *storage, const char *path) -{ - EFolder *folder; - char *path_dup, *p; - - folder = (* E_STORAGE_CLASS (parent_class)->get_folder) (storage, path); - if (folder) - return folder; - - /* If @path points to a part of the storage that hasn't been - * opened yet, do that. - */ - path_dup = g_strdup (path); - p = strchr (path_dup + 1, '/'); - while (p) { - *p = '\0'; - if (e_storage_get_has_subfolders (storage, path_dup)) { - gboolean done = FALSE; - - e_storage_async_open_folder (storage, path_dup, - get_folder_cb, &done); - while (!done) - gtk_main_iteration (); - } - *p = '/'; - p = strchr (p + 1, '/'); - } - - return (* E_STORAGE_CLASS (parent_class)->get_folder) (storage, path); -} - -struct async_folder_closure { - EStorageResultCallback callback; - EStorage *storage; - void *data; -}; - -static void -async_folder_cb (BonoboListener *listener, - const char *event_name, - const CORBA_any *any, - CORBA_Environment *ev, - gpointer user_data) -{ - struct async_folder_closure *closure = user_data; - GNOME_Evolution_Storage_Result *corba_result; - EStorageResult result; - - corba_result = any->_value; - result = e_corba_storage_corba_result_to_storage_result (*corba_result); - - (* closure->callback) (closure->storage, result, closure->data); - bonobo_object_unref (BONOBO_OBJECT (listener)); - - g_object_unref (closure->storage); - g_free (closure); -} - - -struct async_create_open_closure { - EStorage *storage; - char *path, *type, *description; - EStorageResultCallback callback; - void *data; -}; - -static void -async_create_open_cb (EStorage *storage, EStorageResult result, - const char *path, void *data) -{ - struct async_create_open_closure *closure = data; - - if (result != E_STORAGE_OK) { - (* closure->callback) (closure->storage, result, - closure->data); - } else { - e_storage_async_create_folder (closure->storage, - closure->path, closure->type, - closure->description, - closure->callback, - closure->data); - } - - g_object_unref (closure->storage); - g_free (closure->path); - g_free (closure->type); - g_free (closure->description); - g_free (closure); -} - -static void -async_create_folder (EStorage *storage, const char *path, - const char *type, const char *description, - EStorageResultCallback callback, void *data) -{ - ECorbaStorage *corba_storage; - ECorbaStoragePrivate *priv; - const char *parent_uri; - char *p; - BonoboListener *listener; - Bonobo_Listener corba_listener; - CORBA_Environment ev; - struct async_folder_closure *closure; - - corba_storage = E_CORBA_STORAGE (storage); - priv = corba_storage->priv; - - p = strrchr (path, '/'); - if (p && p != path) { - EFolder *parent; - char *parent_path; - - parent_path = g_strndup (path, p - path); - parent = e_storage_get_folder (storage, parent_path); - parent_uri = e_folder_get_physical_uri (parent); - - if (e_folder_get_has_subfolders (parent)) { - struct async_create_open_closure *open_closure; - - /* Force the parent folder to resolve its - * children before creating the new folder. - */ - open_closure = g_new (struct async_create_open_closure, 1); - open_closure->storage = storage; - g_object_ref (storage); - open_closure->path = g_strdup (path); - open_closure->type = g_strdup (type); - open_closure->description = g_strdup (description); - open_closure->callback = callback; - open_closure->data = data; - e_storage_async_open_folder (storage, parent_path, - async_create_open_cb, - open_closure); - return; - } - } else - parent_uri = ""; - - closure = g_new (struct async_folder_closure, 1); - closure->callback = callback; - closure->storage = storage; - g_object_ref (storage); - closure->data = data; - listener = bonobo_listener_new (async_folder_cb, closure); - corba_listener = bonobo_object_corba_objref (BONOBO_OBJECT (listener)); - - CORBA_exception_init (&ev); - GNOME_Evolution_Storage_asyncCreateFolder (priv->storage_interface, - path, type, description, - parent_uri, - corba_listener, &ev); - - if (ev._major != CORBA_NO_EXCEPTION) { - (* callback) (storage, E_STORAGE_GENERICERROR, data); - bonobo_object_unref (BONOBO_OBJECT (listener)); - g_object_unref (storage); - g_free (closure); - } - CORBA_exception_free (&ev); -} - -static void -async_remove_folder (EStorage *storage, - const char *path, - EStorageResultCallback callback, - void *data) -{ - ECorbaStorage *corba_storage; - ECorbaStoragePrivate *priv; - EFolder *folder; - BonoboListener *listener; - Bonobo_Listener corba_listener; - CORBA_Environment ev; - struct async_folder_closure *closure; - - corba_storage = E_CORBA_STORAGE (storage); - priv = corba_storage->priv; - - folder = e_storage_get_folder (storage, path); - if (e_folder_get_is_stock (folder)) { - (* callback) (storage, E_STORAGE_CANTCHANGESTOCKFOLDER, data); - return; - } - if (e_folder_get_physical_uri (folder) == NULL) { - (* callback) (storage, E_STORAGE_GENERICERROR, data); - return; - } - - closure = g_new (struct async_folder_closure, 1); - closure->callback = callback; - closure->storage = storage; - g_object_ref (storage); - closure->data = data; - listener = bonobo_listener_new (async_folder_cb, closure); - corba_listener = bonobo_object_corba_objref (BONOBO_OBJECT (listener)); - - CORBA_exception_init (&ev); - GNOME_Evolution_Storage_asyncRemoveFolder (priv->storage_interface, - path, - e_folder_get_physical_uri (folder), - corba_listener, &ev); - - if (ev._major != CORBA_NO_EXCEPTION) { - (* callback) (storage, E_STORAGE_GENERICERROR, data); - bonobo_object_unref (BONOBO_OBJECT (listener)); - g_object_unref (storage); - g_free (closure); - } - CORBA_exception_free (&ev); -} - -static void -async_xfer_folder (EStorage *storage, - const char *source_path, - const char *destination_path, - gboolean remove_source, - EStorageResultCallback callback, - void *data) -{ - ECorbaStorage *corba_storage; - ECorbaStoragePrivate *priv; - EFolder *folder; - BonoboListener *listener; - Bonobo_Listener corba_listener; - CORBA_Environment ev; - struct async_folder_closure *closure; - - corba_storage = E_CORBA_STORAGE (storage); - priv = corba_storage->priv; - - folder = e_storage_get_folder (storage, source_path); - if (e_folder_get_is_stock (folder) && remove_source) - (* callback) (storage, E_STORAGE_CANTCHANGESTOCKFOLDER, data); - - closure = g_new (struct async_folder_closure, 1); - closure->callback = callback; - closure->storage = storage; - g_object_ref (storage); - closure->data = data; - listener = bonobo_listener_new (async_folder_cb, closure); - corba_listener = bonobo_object_corba_objref (BONOBO_OBJECT (listener)); - - CORBA_exception_init (&ev); - GNOME_Evolution_Storage_asyncXferFolder (priv->storage_interface, - source_path, destination_path, - remove_source, corba_listener, &ev); - - if (ev._major != CORBA_NO_EXCEPTION) { - (* callback) (storage, E_STORAGE_GENERICERROR, data); - bonobo_object_unref (BONOBO_OBJECT (listener)); - g_object_unref (storage); - g_free (closure); - } - CORBA_exception_free (&ev); -} - -struct async_open_closure { - EStorageDiscoveryCallback callback; - EStorage *storage; - void *data; - char *path; -}; - -static void -async_open_cb (BonoboListener *listener, const char *event_name, - const CORBA_any *any, CORBA_Environment *ev, - gpointer user_data) -{ - struct async_open_closure *orig_closure = user_data, *closure; - GNOME_Evolution_Storage_Result *corba_result; - ECorbaStoragePrivate *priv; - EStorageResult result; - GList *p; - - corba_result = any->_value; - result = e_corba_storage_corba_result_to_storage_result (*corba_result); - bonobo_object_unref (BONOBO_OBJECT (listener)); - - priv = E_CORBA_STORAGE (orig_closure->storage)->priv; - p = priv->pending_opens; - while (p) { - closure = p->data; - if (!strcmp (closure->path, orig_closure->path)) { - (* closure->callback) (closure->storage, result, - closure->path, closure->data); - if (closure != orig_closure) { - g_object_unref (orig_closure->storage); - g_free (closure->path); - g_free (closure); - } - priv->pending_opens = g_list_remove (priv->pending_opens, p->data); - p = priv->pending_opens; - } else - p = p->next; - } - - g_object_unref (orig_closure->storage); - g_free (orig_closure->path); - g_free (orig_closure); -} - -static gboolean -async_open_folder_idle (gpointer data) -{ - struct async_open_closure *closure = data, *old_closure; - EStorage *storage = closure->storage; - ECorbaStorage *corba_storage; - ECorbaStoragePrivate *priv; - BonoboListener *listener; - Bonobo_Listener corba_listener; - CORBA_Environment ev; - GList *p; - - corba_storage = E_CORBA_STORAGE (storage); - priv = corba_storage->priv; - - for (p = priv->pending_opens; p; p = p->next) { - old_closure = p->data; - if (!strcmp (closure->path, old_closure->path)) { - priv->pending_opens = g_list_prepend (priv->pending_opens, closure); - return FALSE; - } - } - - listener = bonobo_listener_new (async_open_cb, closure); - corba_listener = bonobo_object_corba_objref (BONOBO_OBJECT (listener)); - - priv->pending_opens = g_list_prepend (priv->pending_opens, closure); - - CORBA_exception_init (&ev); - GNOME_Evolution_Storage_asyncOpenFolder (priv->storage_interface, - closure->path, - corba_listener, &ev); - if (ev._major != CORBA_NO_EXCEPTION) { - (* closure->callback) (storage, E_STORAGE_GENERICERROR, - closure->path, closure->data); - bonobo_object_unref (BONOBO_OBJECT (listener)); - g_object_unref (closure->storage); - g_free (closure->path); - g_free (closure); - - priv->pending_opens = g_list_delete_link (priv->pending_opens, - priv->pending_opens); - } - CORBA_exception_free (&ev); - - return FALSE; -} - -static void -async_open_folder (EStorage *storage, - const char *path, - EStorageDiscoveryCallback callback, - void *data) -{ - struct async_open_closure *closure; - - closure = g_new (struct async_open_closure, 1); - closure->callback = callback; - closure->storage = storage; - g_object_ref (storage); - closure->data = data; - closure->path = g_strdup (path); - - g_idle_add (async_open_folder_idle, closure); -} - - -/* Shared folders. */ - -static gboolean -supports_shared_folders (EStorage *storage) -{ - GNOME_Evolution_Storage storage_iface; - CORBA_boolean has_shared_folders; - CORBA_Environment ev; - - CORBA_exception_init (&ev); - - storage_iface = e_corba_storage_get_corba_objref (E_CORBA_STORAGE (storage)); - g_assert (storage_iface != CORBA_OBJECT_NIL); - - has_shared_folders = GNOME_Evolution_Storage__get_hasSharedFolders (storage_iface, &ev); - if (BONOBO_EX (&ev)) - has_shared_folders = FALSE; - - CORBA_exception_free (&ev); - - return has_shared_folders; -} - -static void -async_folder_discovery_cb (BonoboListener *listener, - const char *event_name, - const CORBA_any *any, - CORBA_Environment *ev, - gpointer user_data) -{ - struct async_folder_closure *closure = user_data; - GNOME_Evolution_Storage_FolderResult *corba_result; - EStorageDiscoveryCallback callback; - EStorageResult result; - char *path; - - corba_result = any->_value; - result = e_corba_storage_corba_result_to_storage_result (corba_result->result); - if (result == E_STORAGE_OK) - path = corba_result->path; - else - path = NULL; - - callback = (EStorageDiscoveryCallback)closure->callback; - (* callback) (closure->storage, result, path, closure->data); - - bonobo_object_unref (BONOBO_OBJECT (listener)); - g_object_unref (closure->storage); - g_free (closure); -} - -static void -async_discover_shared_folder (EStorage *storage, - const char *owner, - const char *folder_name, - EStorageDiscoveryCallback callback, - void *data) -{ - ECorbaStorage *corba_storage; - ECorbaStoragePrivate *priv; - BonoboListener *listener; - Bonobo_Listener corba_listener; - CORBA_Environment ev; - struct async_folder_closure *closure; - - corba_storage = E_CORBA_STORAGE (storage); - priv = corba_storage->priv; - - closure = g_new (struct async_folder_closure, 1); - closure->callback = (EStorageResultCallback)callback; - closure->storage = storage; - g_object_ref (storage); - closure->data = data; - listener = bonobo_listener_new (async_folder_discovery_cb, closure); - corba_listener = bonobo_object_corba_objref (BONOBO_OBJECT (listener)); - - CORBA_exception_init (&ev); - GNOME_Evolution_Storage_asyncDiscoverSharedFolder (priv->storage_interface, - owner, folder_name, - corba_listener, &ev); - if (ev._major != CORBA_NO_EXCEPTION) { - (* callback) (storage, E_STORAGE_GENERICERROR, NULL, data); - bonobo_object_unref (BONOBO_OBJECT (listener)); - g_object_unref (storage); - g_free (closure); - } - CORBA_exception_free (&ev); -} - -static void -cancel_discover_shared_folder (EStorage *storage, - const char *owner, - const char *folder_name) -{ - ECorbaStorage *corba_storage; - ECorbaStoragePrivate *priv; - CORBA_Environment ev; - - corba_storage = E_CORBA_STORAGE (storage); - priv = corba_storage->priv; - - CORBA_exception_init (&ev); - GNOME_Evolution_Storage_cancelDiscoverSharedFolder (priv->storage_interface, - owner, folder_name, &ev); - if (BONOBO_EX (&ev)) - g_warning ("Error invoking cancelDiscoverSharedFolder -- %s", BONOBO_EX_REPOID (&ev)); - CORBA_exception_free (&ev); -} - -static void -async_remove_shared_folder (EStorage *storage, - const char *path, - EStorageResultCallback callback, - void *data) -{ - ECorbaStorage *corba_storage; - ECorbaStoragePrivate *priv; - BonoboListener *listener; - Bonobo_Listener corba_listener; - CORBA_Environment ev; - struct async_folder_closure *closure; - - corba_storage = E_CORBA_STORAGE (storage); - priv = corba_storage->priv; - - closure = g_new (struct async_folder_closure, 1); - closure->callback = callback; - closure->storage = storage; - g_object_ref (storage); - closure->data = data; - listener = bonobo_listener_new (async_folder_cb, closure); - corba_listener = bonobo_object_corba_objref (BONOBO_OBJECT (listener)); - - CORBA_exception_init (&ev); - GNOME_Evolution_Storage_asyncRemoveSharedFolder (priv->storage_interface, - path, corba_listener, - &ev); - if (ev._major != CORBA_NO_EXCEPTION) { - (* callback) (storage, E_STORAGE_GENERICERROR, data); - bonobo_object_unref (BONOBO_OBJECT (listener)); - g_object_unref (storage); - g_free (closure); - } - CORBA_exception_free (&ev); -} - - -static void -corba_class_init (void) -{ - POA_GNOME_Evolution_StorageListener__vepv *vepv; - POA_GNOME_Evolution_StorageListener__epv *epv; - 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; - - epv = g_new0 (POA_GNOME_Evolution_StorageListener__epv, 1); - epv->notifyFolderCreated = impl_StorageListener_notifyFolderCreated; - epv->notifyFolderUpdated = impl_StorageListener_notifyFolderUpdated; - epv->notifyFolderRemoved = impl_StorageListener_notifyFolderRemoved; - epv->notifyHasSubfolders = impl_StorageListener_notifyHasSubfolders; - - vepv = &storage_listener_vepv; - vepv->_base_epv = base_epv; - vepv->GNOME_Evolution_StorageListener_epv = epv; -} - -static void -class_init (ECorbaStorageClass *klass) -{ - GObjectClass *object_class; - EStorageClass *storage_class; - - object_class = G_OBJECT_CLASS (klass); - object_class->dispose = impl_dispose; - object_class->finalize = impl_finalize; - - storage_class = E_STORAGE_CLASS (klass); - storage_class->get_folder = get_folder; - storage_class->async_create_folder = async_create_folder; - storage_class->async_remove_folder = async_remove_folder; - storage_class->async_xfer_folder = async_xfer_folder; - storage_class->async_open_folder = async_open_folder; - storage_class->supports_shared_folders = supports_shared_folders; - storage_class->async_discover_shared_folder = async_discover_shared_folder; - storage_class->cancel_discover_shared_folder = cancel_discover_shared_folder; - storage_class->async_remove_shared_folder = async_remove_shared_folder; - - corba_class_init (); - - parent_class = g_type_class_ref(PARENT_TYPE); -} - -static void -init (ECorbaStorage *corba_storage) -{ - ECorbaStoragePrivate *priv; - - priv = g_new (ECorbaStoragePrivate, 1); - priv->storage_interface = CORBA_OBJECT_NIL; - priv->pending_opens = NULL; - - corba_storage->priv = priv; -} - - -/* FIXME: OK to have a boolean construct function? */ -void -e_corba_storage_construct (ECorbaStorage *corba_storage, - const GNOME_Evolution_Storage storage_interface, - const char *name) -{ - ECorbaStoragePrivate *priv; - CORBA_Environment ev; - EFolder *root_folder; - - g_return_if_fail (corba_storage != NULL); - g_return_if_fail (E_IS_CORBA_STORAGE (corba_storage)); - g_return_if_fail (storage_interface != CORBA_OBJECT_NIL); - g_return_if_fail (name != NULL); - - /* FIXME: Need separate name and display name. */ - root_folder = e_folder_new (name, "noselect", ""); - e_storage_construct (E_STORAGE (corba_storage), name, root_folder); - - priv = corba_storage->priv; - - CORBA_exception_init (&ev); - - Bonobo_Unknown_ref (storage_interface, &ev); - if (ev._major != CORBA_NO_EXCEPTION) - g_warning ("e_corba_storage_construct() -- Cannot reference Bonobo object"); - else - priv->storage_interface = CORBA_Object_duplicate (storage_interface, &ev); - - CORBA_exception_free (&ev); - - setup_storage_listener (corba_storage); -} - -EStorage * -e_corba_storage_new (const GNOME_Evolution_Storage storage_interface, - const char *name) -{ - EStorage *new; - - g_return_val_if_fail (storage_interface != CORBA_OBJECT_NIL, NULL); - g_return_val_if_fail (name != NULL, NULL); - - new = g_object_new (e_corba_storage_get_type (), NULL); - - e_corba_storage_construct (E_CORBA_STORAGE (new), - storage_interface, name); - - return new; -} - - -const GNOME_Evolution_StorageListener -e_corba_storage_get_StorageListener (ECorbaStorage *corba_storage) -{ - g_return_val_if_fail (corba_storage != NULL, NULL); - g_return_val_if_fail (E_IS_CORBA_STORAGE (corba_storage), NULL); - - return corba_storage->priv->storage_listener_interface; -} - -GNOME_Evolution_Storage -e_corba_storage_get_corba_objref (ECorbaStorage *corba_storage) -{ - g_return_val_if_fail (corba_storage != NULL, CORBA_OBJECT_NIL); - g_return_val_if_fail (E_IS_CORBA_STORAGE (corba_storage), CORBA_OBJECT_NIL); - - return corba_storage->priv->storage_interface; -} - - -GSList * -e_corba_storage_get_folder_property_items (ECorbaStorage *corba_storage) -{ - GNOME_Evolution_Storage_FolderPropertyItemList *corba_items; - CORBA_Environment ev; - GSList *list; - int i; - - g_return_val_if_fail (E_IS_CORBA_STORAGE (corba_storage), NULL); - - CORBA_exception_init (&ev); - - corba_items = GNOME_Evolution_Storage__get_folderPropertyItems (corba_storage->priv->storage_interface, - &ev); - - if (BONOBO_EX (&ev)) { - CORBA_exception_free (&ev); - return NULL; - } - - list = NULL; - for (i = 0; i < corba_items->_length; i ++) { - ECorbaStoragePropertyItem *item; - - item = g_new (ECorbaStoragePropertyItem, 1); - item->label = g_strdup (corba_items->_buffer[i].label); - item->tooltip = g_strdup (corba_items->_buffer[i].tooltip); - item->icon = NULL; /* We don't care for now -- FIXME */ - - list = g_slist_prepend (list, item); - } - list = g_slist_reverse (list); - - CORBA_free (corba_items); - CORBA_exception_free (&ev); - - return list; -} - -void -e_corba_storage_free_property_items_list (GSList *list) -{ - GSList *p; - - for (p = list; p != NULL; p = p->next) { - ECorbaStoragePropertyItem *item; - - item = (ECorbaStoragePropertyItem *) p->data; - - if (item->icon != NULL) - g_object_unref (item->icon); - g_free (item->label); - g_free (item->tooltip); - g_free (item); - } - - g_slist_free (list); -} - -void -e_corba_storage_show_folder_properties (ECorbaStorage *corba_storage, - const char *path, - int property_item_id, - GdkWindow *parent_window) -{ - CORBA_Environment ev; - - g_return_if_fail (E_IS_CORBA_STORAGE (corba_storage)); - g_return_if_fail (path != NULL && path[0] == E_PATH_SEPARATOR); - - CORBA_exception_init (&ev); - - GNOME_Evolution_Storage_showFolderProperties (corba_storage->priv->storage_interface, - path, property_item_id, - GDK_WINDOW_XWINDOW (parent_window), - &ev); - if (BONOBO_EX (&ev)) - g_warning ("Error in Storage::showFolderProperties -- %s", BONOBO_EX_REPOID (&ev)); - - CORBA_exception_free (&ev); -} - -EStorageResult -e_corba_storage_corba_result_to_storage_result (GNOME_Evolution_Storage_Result corba_result) -{ - switch (corba_result) { - case GNOME_Evolution_Storage_OK: - return E_STORAGE_OK; - case GNOME_Evolution_Storage_UNSUPPORTED_OPERATION: - return E_STORAGE_UNSUPPORTEDOPERATION; - case GNOME_Evolution_Storage_UNSUPPORTED_TYPE: - return E_STORAGE_UNSUPPORTEDTYPE; - case GNOME_Evolution_Storage_INVALID_URI: - return E_STORAGE_INVALIDNAME; - case GNOME_Evolution_Storage_ALREADY_EXISTS: - return E_STORAGE_EXISTS; - case GNOME_Evolution_Storage_DOES_NOT_EXIST: - return E_STORAGE_NOTFOUND; - case GNOME_Evolution_Storage_PERMISSION_DENIED: - return E_STORAGE_PERMISSIONDENIED; - case GNOME_Evolution_Storage_NO_SPACE: - return E_STORAGE_NOSPACE; - case GNOME_Evolution_Storage_NOT_EMPTY: - return E_STORAGE_NOTEMPTY; - case GNOME_Evolution_Storage_NOT_ONLINE: - return E_STORAGE_NOTONLINE; - case GNOME_Evolution_Storage_GENERIC_ERROR: - default: - return E_STORAGE_GENERICERROR; - } -} - - -E_MAKE_TYPE (e_corba_storage, "ECorbaStorage", ECorbaStorage, class_init, init, PARENT_TYPE) diff --git a/shell/e-corba-storage.h b/shell/e-corba-storage.h deleted file mode 100644 index da62ab628b..0000000000 --- a/shell/e-corba-storage.h +++ /dev/null @@ -1,89 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-corba-storage.h - * - * Copyright (C) 2000 Ximian, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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 __E_CORBA_STORAGE_H__ -#define __E_CORBA_STORAGE_H__ - -#include "e-storage.h" - -#include "Evolution.h" - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - -#define E_TYPE_CORBA_STORAGE (e_corba_storage_get_type ()) -#define E_CORBA_STORAGE(obj) (GTK_CHECK_CAST ((obj), E_TYPE_CORBA_STORAGE, ECorbaStorage)) -#define E_CORBA_STORAGE_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_TYPE_CORBA_STORAGE, ECorbaStorageClass)) -#define E_IS_CORBA_STORAGE(obj) (GTK_CHECK_TYPE ((obj), E_TYPE_CORBA_STORAGE)) -#define E_IS_CORBA_STORAGE_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), E_TYPE_CORBA_STORAGE)) - - -typedef struct _ECorbaStorage ECorbaStorage; -typedef struct _ECorbaStoragePrivate ECorbaStoragePrivate; -typedef struct _ECorbaStorageClass ECorbaStorageClass; - -struct _ECorbaStorage { - EStorage parent; - - ECorbaStoragePrivate *priv; -}; - -struct _ECorbaStorageClass { - EStorageClass parent_class; -}; - - -struct _ECorbaStoragePropertyItem { - char *label; - char *tooltip; - GdkPixbuf *icon; -}; -typedef struct _ECorbaStoragePropertyItem ECorbaStoragePropertyItem; - - -GtkType e_corba_storage_get_type (void); -void e_corba_storage_construct (ECorbaStorage *corba_storage, - const GNOME_Evolution_Storage storage_interface, - const char *name); -EStorage *e_corba_storage_new (const GNOME_Evolution_Storage storage_interface, - const char *name); - -GNOME_Evolution_Storage e_corba_storage_get_corba_objref (ECorbaStorage *corba_storage); - -const GNOME_Evolution_StorageListener e_corba_storage_get_StorageListener (ECorbaStorage *corba_storage); - -GSList *e_corba_storage_get_folder_property_items (ECorbaStorage *corba_storage); -void e_corba_storage_free_property_items_list (GSList *list); - -void e_corba_storage_show_folder_properties (ECorbaStorage *corba_storage, - const char *path, - int property_item_id, - GdkWindow *parent_window); -EStorageResult e_corba_storage_corba_result_to_storage_result (GNOME_Evolution_Storage_Result corba_result); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* __E_CORBA_STORAGE_H__ */ diff --git a/shell/e-folder-dnd-bridge.c b/shell/e-folder-dnd-bridge.c deleted file mode 100644 index c72322f476..0000000000 --- a/shell/e-folder-dnd-bridge.c +++ /dev/null @@ -1,487 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-folder-dnd-bridge.c - Utility functions for handling dnd to Evolution - * folders using the ShellComponentDnd interface. - * - * Copyright (C) 2002 Ximian, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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 <ettore@ximian.com> - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include "e-folder-dnd-bridge.h" - -#include "Evolution.h" -#include "e-storage-set-view.h" -#include "e-shell-constants.h" - -#include "e-util/e-dialog-utils.h" - -#include <libgnome/gnome-i18n.h> -#include <libgnome/gnome-util.h> - -#include <string.h> - - -/* Callbacks for folder operations. */ - -static void -folder_xfer_callback (EStorageSet *storage_set, - EStorageResult result, - void *data) -{ - GtkWindow *parent; - - if (result == E_STORAGE_OK) - return; - - parent = GTK_WINDOW (data); - e_notice (parent, GTK_MESSAGE_ERROR, _("Cannot transfer folder:\n%s"), - e_storage_result_to_string (result)); -} - - -/* Utility functions. */ - -static GNOME_Evolution_ShellComponentDnd_ActionSet -convert_gdk_drag_action_set_to_corba (GdkDragAction action) -{ - GNOME_Evolution_ShellComponentDnd_Action retval; - - retval = GNOME_Evolution_ShellComponentDnd_ACTION_DEFAULT; - - if (action & GDK_ACTION_COPY) - retval |= GNOME_Evolution_ShellComponentDnd_ACTION_COPY; - if (action & GDK_ACTION_MOVE) - retval |= GNOME_Evolution_ShellComponentDnd_ACTION_MOVE; - if (action & GDK_ACTION_LINK) - retval |= GNOME_Evolution_ShellComponentDnd_ACTION_LINK; - if (action & GDK_ACTION_ASK) - retval |= GNOME_Evolution_ShellComponentDnd_ACTION_ASK; - - return retval; -} - -static GNOME_Evolution_ShellComponentDnd_ActionSet -convert_gdk_drag_action_to_corba (GdkDragAction action) -{ - if (action == GDK_ACTION_COPY) - return GNOME_Evolution_ShellComponentDnd_ACTION_COPY; - else if (action == GDK_ACTION_MOVE) - return GNOME_Evolution_ShellComponentDnd_ACTION_MOVE; - else if (action == GDK_ACTION_LINK) - return GNOME_Evolution_ShellComponentDnd_ACTION_LINK; - else if (action == GDK_ACTION_ASK) - return GNOME_Evolution_ShellComponentDnd_ACTION_ASK; - else { - g_warning ("Unknown GdkDragAction %d", action); - return GNOME_Evolution_ShellComponentDnd_ACTION_DEFAULT; - } -} - -static GdkDragAction -convert_corba_drag_action_to_gdk (GNOME_Evolution_ShellComponentDnd_ActionSet action) -{ - if (action == GNOME_Evolution_ShellComponentDnd_ACTION_COPY) - return GDK_ACTION_COPY; - else if (action == GNOME_Evolution_ShellComponentDnd_ACTION_MOVE) - return GDK_ACTION_MOVE; - else if (action == GNOME_Evolution_ShellComponentDnd_ACTION_LINK) - return GDK_ACTION_LINK; - else if (action == GNOME_Evolution_ShellComponentDnd_ACTION_ASK) - return GDK_ACTION_ASK; - else { - g_warning ("unknown GNOME_Evolution_ShellComponentDnd_ActionSet %d", action); - return GDK_ACTION_DEFAULT; - } -} - -static EvolutionShellComponentClient * -get_component_at_path (EStorageSet *storage_set, - const char *path) -{ - EvolutionShellComponentClient *component_client; - EFolderTypeRegistry *folder_type_registry; - EFolder *folder; - - folder = e_storage_set_get_folder (storage_set, path); - if (folder == NULL) - return NULL; - - folder_type_registry = e_storage_set_get_folder_type_registry (storage_set); - g_assert (folder_type_registry != NULL); - - component_client = e_folder_type_registry_get_handler_for_type (folder_type_registry, - e_folder_get_type_string (folder)); - - return component_client; -} - -/* This will look for the targets in @drag_context, choose one that matches - with the allowed types at @path, and return its name. The EVOLUTION_PATH - type always matches. */ -static const char * -find_matching_target_for_drag_context (EStorageSet *storage_set, - const char *path, - GdkDragContext *drag_context, - GdkAtom *atom_return) -{ - EFolderTypeRegistry *folder_type_registry; - EFolder *folder; - GList *accepted_types; - GList *p, *q; - - folder_type_registry = e_storage_set_get_folder_type_registry (storage_set); - - folder = e_storage_set_get_folder (storage_set, path); - if (folder == NULL) - return E_FOLDER_DND_PATH_TARGET_TYPE; - - accepted_types = e_folder_type_registry_get_accepted_dnd_types_for_type (folder_type_registry, - e_folder_get_type_string (folder)); - - for (p = drag_context->targets; p != NULL; p = p->next) { - char *possible_type; - - possible_type = gdk_atom_name (p->data); - if (strcmp (possible_type, E_FOLDER_DND_PATH_TARGET_TYPE) == 0) { - g_free (possible_type); - - if (atom_return != NULL) - *atom_return = p->data; - - return E_FOLDER_DND_PATH_TARGET_TYPE; - } - - for (q = accepted_types; q != NULL; q = q->next) { - const char *accepted_type; - - accepted_type = (const char *) q->data; - if (strcmp (possible_type, accepted_type) == 0) { - g_free (possible_type); - - if (atom_return != NULL) - *atom_return = p->data; - - return accepted_type; - } - } - - g_free (possible_type); - } - - if (atom_return != NULL) - *atom_return = 0; - - return NULL; -} - -static gboolean -handle_evolution_path_drag_motion (EStorageSet *storage_set, - const char *path, - GdkDragContext *context, - unsigned int time) -{ - GdkModifierType modifiers; - GdkDragAction action; - - gdk_window_get_pointer (NULL, NULL, NULL, &modifiers); - - if ((modifiers & GDK_CONTROL_MASK) != 0) { - action = GDK_ACTION_COPY; - } else { - GtkWidget *source_widget; - - action = GDK_ACTION_MOVE; - - source_widget = gtk_drag_get_source_widget (context); - if (source_widget != NULL - && E_IS_STORAGE_SET_VIEW (source_widget)) { - const char *source_path; - - source_path = e_storage_set_view_get_current_folder (E_STORAGE_SET_VIEW (source_widget)); - if (source_path != NULL) { - EFolder *folder; - int source_path_len; - char *destination_path; - char *base_name; - - folder = e_storage_set_get_folder (storage_set, source_path); - if (folder != NULL && e_folder_get_is_stock (folder)) - return FALSE; - - source_path_len = strlen (path); - if (strcmp (path, source_path) == 0) - return FALSE; - - base_name = g_path_get_basename (source_path); - destination_path = g_strconcat (path, "/", base_name, NULL); - g_free (base_name); - - if (strncmp (destination_path, source_path, source_path_len) == 0) { - g_free (destination_path); - return FALSE; - } - - g_free (destination_path); - } - } - } - - gdk_drag_status (context, action, time); - return TRUE; -} - - -/* Bridge for the DnD motion event. */ - -gboolean -e_folder_dnd_bridge_motion (GtkWidget *widget, - GdkDragContext *context, - unsigned int time, - EStorageSet *storage_set, - const char *path) -{ - EvolutionShellComponentClient *component_client; - GNOME_Evolution_ShellComponentDnd_DestinationFolder destination_folder_interface; - GNOME_Evolution_ShellComponentDnd_DestinationFolder_Context corba_context; - GNOME_Evolution_ShellComponentDnd_Action suggested_action; - CORBA_Environment ev; - CORBA_boolean can_handle; - EFolder *folder; - const char *dnd_type; - - g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE); - g_return_val_if_fail (context != NULL, FALSE); - g_return_val_if_fail (E_IS_STORAGE_SET (storage_set), FALSE); - g_return_val_if_fail (path != NULL, FALSE); - - dnd_type = find_matching_target_for_drag_context (storage_set, path, context, NULL); - if (dnd_type == NULL) - return FALSE; - - if (strcmp (dnd_type, E_FOLDER_DND_PATH_TARGET_TYPE) == 0) - return handle_evolution_path_drag_motion (storage_set, path, context, time); - - component_client = get_component_at_path (storage_set, path); - if (component_client == NULL) - return FALSE; - - destination_folder_interface = evolution_shell_component_client_get_dnd_destination_interface (component_client); - if (destination_folder_interface == NULL) - return FALSE; - - CORBA_exception_init (&ev); - - corba_context.dndType = (char *) dnd_type; /* (Safe cast, as we don't actually free the corba_context.) */ - corba_context.possibleActions = convert_gdk_drag_action_set_to_corba (context->actions); - corba_context.suggestedAction = convert_gdk_drag_action_to_corba (context->suggested_action); - - folder = e_storage_set_get_folder (storage_set, path); - - can_handle = GNOME_Evolution_ShellComponentDnd_DestinationFolder_handleMotion (destination_folder_interface, - e_folder_get_physical_uri (folder), - e_folder_get_type_string (folder), - &corba_context, - &suggested_action, - &ev); - if (ev._major != CORBA_NO_EXCEPTION || ! can_handle) { - CORBA_exception_free (&ev); - return FALSE; - } - - CORBA_exception_free (&ev); - - gdk_drag_status (context, convert_corba_drag_action_to_gdk (suggested_action), time); - return TRUE; -} - - -/* Bridge for the drop event. */ - -gboolean -e_folder_dnd_bridge_drop (GtkWidget *widget, - GdkDragContext *context, - unsigned int time, - EStorageSet *storage_set, - const char *path) -{ - GdkAtom atom; - - g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE); - g_return_val_if_fail (context != NULL, FALSE); - g_return_val_if_fail (E_IS_STORAGE_SET (storage_set), FALSE); - g_return_val_if_fail (path != NULL, FALSE); - - if (context->targets == NULL) - return FALSE; - - if (find_matching_target_for_drag_context (storage_set, path, context, &atom) == NULL) - return FALSE; - - gtk_drag_get_data (widget, context, atom, time); - - return FALSE; -} - - -/* Bridge for the data_received event. */ - -static gboolean -handle_data_received_path (GdkDragContext *context, - GtkSelectionData *selection_data, - EStorageSet *storage_set, - const char *path, - GtkWindow *toplevel_window) -{ - const char *source_path; - char *destination_path; - char *base_name; - gboolean handled; - - source_path = (const char *) selection_data->data; - - /* (Basic sanity checks.) */ - if (source_path == NULL || source_path[0] != E_PATH_SEPARATOR || source_path[1] == '\0') - return FALSE; - - base_name = g_path_get_basename (source_path); - destination_path = g_build_filename (path, base_name, NULL); - g_free (base_name); - - switch (context->action) { - case GDK_ACTION_MOVE: - e_storage_set_async_xfer_folder (storage_set, - source_path, - destination_path, - TRUE, - folder_xfer_callback, - toplevel_window); - handled = TRUE; - break; - case GDK_ACTION_COPY: - e_storage_set_async_xfer_folder (storage_set, - source_path, - destination_path, - FALSE, - folder_xfer_callback, - toplevel_window); - handled = TRUE; - break; - default: - handled = FALSE; - g_warning ("EStorageSetView: Unknown action %d", context->action); - } - - g_free (destination_path); - - return handled; -} - -static gboolean -handle_data_received_non_path (GdkDragContext *context, - GtkSelectionData *selection_data, - EStorageSet *storage_set, - const char *path, - const char *target_type) -{ - GNOME_Evolution_ShellComponentDnd_DestinationFolder destination_folder_interface; - GNOME_Evolution_ShellComponentDnd_DestinationFolder_Context corba_context; - GNOME_Evolution_ShellComponentDnd_Data corba_data; - EvolutionShellComponentClient *component_client; - EFolder *folder; - CORBA_Environment ev; - - component_client = get_component_at_path (storage_set, path); - if (component_client == NULL) - return FALSE; - - destination_folder_interface = evolution_shell_component_client_get_dnd_destination_interface (component_client); - if (destination_folder_interface == NULL) - return FALSE; - - CORBA_exception_init (&ev); - - folder = e_storage_set_get_folder (storage_set, path); - - corba_context.dndType = (char *) target_type; - corba_context.possibleActions = convert_gdk_drag_action_set_to_corba (context->actions); - corba_context.suggestedAction = convert_gdk_drag_action_to_corba (context->suggested_action); - - corba_data.format = selection_data->format; - corba_data.target = gdk_atom_name (selection_data->target); - - corba_data.bytes._release = FALSE; - - if (selection_data->data == NULL) { - /* If data is NULL the length is -1 and this would mess things - up so we handle it separately. */ - corba_data.bytes._length = 0; - corba_data.bytes._buffer = NULL; - } else { - corba_data.bytes._length = selection_data->length; - corba_data.bytes._buffer = selection_data->data; - } - - /* pass off the data to the component's DestinationFolderInterface */ - return GNOME_Evolution_ShellComponentDnd_DestinationFolder_handleDrop (destination_folder_interface, - e_folder_get_physical_uri (folder), - e_folder_get_type_string (folder), - &corba_context, - convert_gdk_drag_action_to_corba (context->action), - &corba_data, - &ev); -} - -void -e_folder_dnd_bridge_data_received (GtkWidget *widget, - GdkDragContext *context, - GtkSelectionData *selection_data, - unsigned int time, - EStorageSet *storage_set, - const char *path) -{ - char *target_type; - gboolean handled; - - g_return_if_fail (GTK_IS_WIDGET (widget)); - g_return_if_fail (context != NULL); - g_return_if_fail (E_IS_STORAGE_SET (storage_set)); - g_return_if_fail (path != NULL); - - if (selection_data->data == NULL && selection_data->length == -1) - return; - - target_type = gdk_atom_name (selection_data->target); - - if (strcmp (target_type, E_FOLDER_DND_PATH_TARGET_TYPE) != 0) { - handled = handle_data_received_non_path (context, selection_data, storage_set, - path, target_type); - } else { - GtkWindow *toplevel_window; - - toplevel_window = GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (widget))); - handled = handle_data_received_path (context, selection_data, storage_set, path, - toplevel_window); - } - - g_free (target_type); - gtk_drag_finish (context, handled, FALSE, time); -} - diff --git a/shell/e-folder-dnd-bridge.h b/shell/e-folder-dnd-bridge.h deleted file mode 100644 index 77cfcd5181..0000000000 --- a/shell/e-folder-dnd-bridge.h +++ /dev/null @@ -1,55 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-component-dnd-bridge.h - Utility functions for handling dnd to Evolution - * folders using the ShellComponentDnd interface. - * - * Copyright (C) 2002 Ximian, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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 <ettore@ximian.com> - */ - -/* The purpose of this file is to share the logic for dropping objects into - folders between different widgets that handle the display of EStorageSets - (namely, the shortcut bar and the folder bar). */ - -#ifndef E_FOLDER_BAR_DND_BRIDGE_H -#define E_FOLDER_BAR_DND_BRIDGE_H - -#include "e-storage-set.h" - -#include <gtk/gtkwidget.h> -#include <gtk/gtkdnd.h> - -#define E_FOLDER_DND_PATH_TARGET_TYPE "_EVOLUTION_PRIVATE_PATH" - -gboolean e_folder_dnd_bridge_motion (GtkWidget *widget, - GdkDragContext *context, - unsigned int time, - EStorageSet *storage_set, - const char *path); -gboolean e_folder_dnd_bridge_drop (GtkWidget *widget, - GdkDragContext *context, - unsigned int time, - EStorageSet *storage_set, - const char *path); -void e_folder_dnd_bridge_data_received (GtkWidget *widget, - GdkDragContext *context, - GtkSelectionData *selection_data, - unsigned int time, - EStorageSet *storage_set, - const char *path); - -#endif /* E_FOLDER_BAR_DND_BRIDGE_H */ diff --git a/shell/e-folder-selection-dialog.c b/shell/e-folder-selection-dialog.c deleted file mode 100644 index 42a881e113..0000000000 --- a/shell/e-folder-selection-dialog.c +++ /dev/null @@ -1,479 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-folder-selection-dialog.c - * - * Copyright (C) 2000, 2001, 2002, 2003 Ximian, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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 "e-folder-selection-dialog.h" - -#include "e-shell-marshal.h" -#include "e-storage-set-view.h" -#include "e-storage-set.h" - -#include <libgnome/gnome-i18n.h> - -#include <gal/util/e-util.h> -#include <gal/widgets/e-gui-utils.h> - -#include <gtk/gtkbox.h> -#include <gtk/gtklabel.h> -#include <gtk/gtkscrolledwindow.h> -#include <gtk/gtksignal.h> -#include <gtk/gtkstock.h> - -#include <string.h> - - -#define PARENT_TYPE (gtk_dialog_get_type ()) -static GtkDialogClass *parent_class = NULL; - -struct _EFolderSelectionDialogPrivate { - GList *allowed_types; - EStorageSet *storage_set; - GtkWidget *storage_set_view; - - gboolean allow_creation; -}; - -enum { - FOLDER_SELECTED, - CANCELLED, - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL] = { 0 }; - -enum { - RESPONSE_NEW -}; - - -/* Utility functions. */ - -static gboolean -check_folder_type_valid (EFolderSelectionDialog *folder_selection_dialog) -{ - EFolderSelectionDialogPrivate *priv; - const char *selected_path; - EFolder *folder; - const char *folder_type; - GList *p; - - priv = folder_selection_dialog->priv; - if (priv->allowed_types == NULL) - return TRUE; - - selected_path = e_folder_selection_dialog_get_selected_path (folder_selection_dialog); - if (selected_path == NULL) - return FALSE; - - folder = e_storage_set_get_folder (priv->storage_set, selected_path); - if (folder == NULL) - return FALSE; - - folder_type = e_folder_get_type_string (folder); - - for (p = priv->allowed_types; p != NULL; p = p->next) { - const char *type, *slash; - - type = (const char *) p->data; - if (strcmp (folder_type, type) == 0) - return TRUE; - slash = strchr (type, '/'); - if (slash && slash[1] == '*' && strncmp (folder_type, type, slash - type) == 0) - return TRUE; - } - - return FALSE; -} - - -/* Folder creation dialog callback. */ - -#if 0 /* EPFIXME */ -static void -folder_creation_dialog_result_cb (EShell *shell, - EShellFolderCreationDialogResult result, - const char *path, - void *data) -{ - EFolderSelectionDialog *dialog; - EFolderSelectionDialogPrivate *priv; - - dialog = E_FOLDER_SELECTION_DIALOG (data); - priv = dialog->priv; - - if (priv == NULL) { - g_warning ("dialog->priv is NULL, and should not be"); - return; - } - - if (result == E_SHELL_FOLDER_CREATION_DIALOG_RESULT_SUCCESS) - e_storage_set_view_set_current_folder (E_STORAGE_SET_VIEW (priv->storage_set_view), - path); -} -#endif - - -/* GtkObject methods. */ - -static void -impl_dispose (GObject *object) -{ - EFolderSelectionDialog *folder_selection_dialog; - EFolderSelectionDialogPrivate *priv; - - folder_selection_dialog = E_FOLDER_SELECTION_DIALOG (object); - priv = folder_selection_dialog->priv; - - if (priv->storage_set != NULL) { - g_object_unref (priv->storage_set); - priv->storage_set = NULL; - } - - (* G_OBJECT_CLASS (parent_class)->dispose) (object); -} - -static void -impl_finalize (GObject *object) -{ - EFolderSelectionDialog *folder_selection_dialog; - EFolderSelectionDialogPrivate *priv; - - folder_selection_dialog = E_FOLDER_SELECTION_DIALOG (object); - priv = folder_selection_dialog->priv; - - e_free_string_list (priv->allowed_types); - - g_free (priv); - - (* G_OBJECT_CLASS (parent_class)->finalize) (object); -} - - -/* GtkDialog methods. */ - -static void -impl_response (GtkDialog *dialog, - int response) -{ - EFolderSelectionDialog *folder_selection_dialog; - EFolderSelectionDialogPrivate *priv; - EStorageSetView *storage_set_view; - const char *default_parent_folder; - const char *default_subtype; - char *default_type; - - folder_selection_dialog = E_FOLDER_SELECTION_DIALOG (dialog); - priv = folder_selection_dialog->priv; - - switch (response) { - case GTK_RESPONSE_OK: - if (check_folder_type_valid (folder_selection_dialog)) { - g_signal_emit (folder_selection_dialog, signals[FOLDER_SELECTED], 0, - e_folder_selection_dialog_get_selected_path (folder_selection_dialog)); - } - break; - - case GTK_RESPONSE_CANCEL: - case GTK_RESPONSE_DELETE_EVENT: - g_signal_emit (folder_selection_dialog, signals[CANCELLED], 0); - break; - - case RESPONSE_NEW: - storage_set_view = E_STORAGE_SET_VIEW (priv->storage_set_view); - default_parent_folder = e_storage_set_view_get_current_folder (storage_set_view); - - /* The default type in the folder creation dialog will be the - first of the allowed types. If all types are allowed, - hardcode to "mail". */ - if (priv->allowed_types == NULL) - default_type = g_strdup ("mail"); - else { - default_subtype = (const char *) priv->allowed_types->data; - default_type = g_strndup (default_subtype, - strcspn (default_subtype, "/")); - } - -#if 0 /* EPFIXME */ - e_shell_show_folder_creation_dialog (priv->shell, GTK_WINDOW (dialog), - default_parent_folder, - default_type, - folder_creation_dialog_result_cb, - dialog); -#endif - - g_free (default_type); - - break; - } -} - - -/* GTK+ type initialization. */ - -static void -class_init (EFolderSelectionDialogClass *klass) -{ - GObjectClass *object_class; - GtkDialogClass *dialog_class; - - parent_class = g_type_class_ref(PARENT_TYPE); - object_class = G_OBJECT_CLASS (klass); - dialog_class = GTK_DIALOG_CLASS (klass); - - object_class->dispose = impl_dispose; - object_class->finalize = impl_finalize; - - dialog_class->response = impl_response; - - signals[FOLDER_SELECTED] - = g_signal_new ("folder_selected", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (EFolderSelectionDialogClass, folder_selected), - NULL, NULL, - e_shell_marshal_NONE__STRING, - G_TYPE_NONE, 1, - G_TYPE_STRING); - - signals[CANCELLED] - = g_signal_new ("cancelled", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (EFolderSelectionDialogClass, cancelled), - NULL, NULL, - e_shell_marshal_NONE__NONE, - G_TYPE_NONE, 0); -} - -static void -init (EFolderSelectionDialog *folder_selection_dialog) -{ - EFolderSelectionDialogPrivate *priv; - - priv = g_new (EFolderSelectionDialogPrivate, 1); - priv->storage_set = NULL; - priv->storage_set_view = NULL; - priv->allowed_types = NULL; - priv->allow_creation = TRUE; - - folder_selection_dialog->priv = priv; -} - - -/* ETable callbacks. */ - -static void -folder_selected_cb (EStorageSetView *storage_set_view, - const char *path, - void *data) -{ - EFolderSelectionDialog *dialog; - - dialog = E_FOLDER_SELECTION_DIALOG (data); - - if (check_folder_type_valid (dialog)) - gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog), GTK_RESPONSE_OK, TRUE); - else - gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog), GTK_RESPONSE_OK, FALSE); -} - -static void -double_click_cb (EStorageSetView *essv, - int row, - ETreePath path, - int col, - GdkEvent *event, - EFolderSelectionDialog *folder_selection_dialog) -{ - g_return_if_fail (folder_selection_dialog != NULL); - - if (check_folder_type_valid (folder_selection_dialog)) { - g_signal_emit (folder_selection_dialog, signals[FOLDER_SELECTED], 0, - e_folder_selection_dialog_get_selected_path (folder_selection_dialog)); - } -} - - -/** - * e_folder_selection_dialog_construct: - * @folder_selection_dialog: A folder selection dialog widget - * @storage_set: The storage set this folder selection dialog is for - * @title: Title of the window - * @caption: A brief text to be put on top of the storage view - * @default_path: The path of the folder to be selected by default - * @allowed_types: List of the names of the allowed types - * - * Construct @folder_selection_dialog. - **/ -/* EPFIXME: Should be allowed to get the expanded state from a model - EStorageSetView. */ -void -e_folder_selection_dialog_construct (EFolderSelectionDialog *folder_selection_dialog, - EStorageSet *storage_set, - const char *title, - const char *caption, - const char *default_path, - const char *allowed_types[], - gboolean allow_creation) -{ - EFolderSelectionDialogPrivate *priv; - GtkWidget *scrolled_window; - GtkWidget *caption_label; - int i; - - g_return_if_fail (E_IS_FOLDER_SELECTION_DIALOG (folder_selection_dialog)); - g_return_if_fail (E_IS_STORAGE_SET (storage_set)); - - priv = folder_selection_dialog->priv; - - /* Basic dialog setup. */ - - gtk_window_set_default_size (GTK_WINDOW (folder_selection_dialog), 350, 300); - gtk_window_set_modal (GTK_WINDOW (folder_selection_dialog), TRUE); - gtk_window_set_title (GTK_WINDOW (folder_selection_dialog), title); - gtk_container_set_border_width (GTK_CONTAINER (folder_selection_dialog), 6); - - if (allow_creation) - gtk_dialog_add_buttons (GTK_DIALOG (folder_selection_dialog), - GTK_STOCK_NEW, RESPONSE_NEW, - NULL); - - gtk_dialog_add_buttons (GTK_DIALOG (folder_selection_dialog), - GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, - GTK_STOCK_OK, GTK_RESPONSE_OK, - NULL); - - gtk_dialog_set_response_sensitive (GTK_DIALOG (folder_selection_dialog), GTK_RESPONSE_OK, FALSE); - gtk_dialog_set_default_response (GTK_DIALOG (folder_selection_dialog), GTK_RESPONSE_OK); - - /* Set up the label. */ - - if (caption != NULL) { - caption_label = gtk_label_new (caption); - gtk_label_set_justify (GTK_LABEL (caption_label), GTK_JUSTIFY_LEFT); - gtk_widget_show (caption_label); - - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (folder_selection_dialog)->vbox), - caption_label, FALSE, TRUE, 6); - gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (folder_selection_dialog)->vbox), - 6); - - - } - - /* Set up the storage set and its view. */ - - priv->storage_set = storage_set; - g_object_ref (storage_set); - - priv->storage_set_view = e_storage_set_create_new_view (priv->storage_set, NULL); - e_storage_set_view_set_allow_dnd (E_STORAGE_SET_VIEW (priv->storage_set_view), FALSE); - e_storage_set_view_enable_search (E_STORAGE_SET_VIEW (priv->storage_set_view), TRUE); - - g_signal_connect (priv->storage_set_view, "double_click", G_CALLBACK (double_click_cb), folder_selection_dialog); - g_signal_connect (priv->storage_set_view, "folder_selected", G_CALLBACK (folder_selected_cb), folder_selection_dialog); - - g_assert (priv->allowed_types == NULL); - if (allowed_types != NULL) { - for (i = 0; allowed_types[i] != NULL; i++) - priv->allowed_types = g_list_prepend (priv->allowed_types, - g_strdup (allowed_types[i])); - - /* Preserve the order so we can use the first type listed as - the default for the folder creation dialog invoked by the - "New..." button. */ - priv->allowed_types = g_list_reverse (priv->allowed_types); - } - - if (default_path != NULL) - e_storage_set_view_set_current_folder (E_STORAGE_SET_VIEW (priv->storage_set_view), default_path); - - scrolled_window = gtk_scrolled_window_new (NULL, NULL); - gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_window), GTK_SHADOW_IN); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), - GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - - gtk_container_add (GTK_CONTAINER (scrolled_window), priv->storage_set_view); - - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (folder_selection_dialog)->vbox), - scrolled_window, TRUE, TRUE, 6); - gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (folder_selection_dialog)->vbox), 6); - - gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (folder_selection_dialog)->vbox), 6); - - gtk_widget_show (priv->storage_set_view); - gtk_widget_show (scrolled_window); - - GTK_WIDGET_SET_FLAGS (priv->storage_set_view, GTK_CAN_FOCUS); - gtk_widget_grab_focus (priv->storage_set_view); -} - -/** - * e_folder_selection_dialog_new: - * @storage_set: The storage set this folder selection dialog is for - * @title: Title of the window - * @caption: A brief text to be put on top of the storage view - * @default_path: The path of the folder to be selected by default - * @allowed_types: List of the names of the allowed types - * - * Create a new folder selection dialog widget. - * - * Return value: - **/ -GtkWidget * -e_folder_selection_dialog_new (EStorageSet *storage_set, - const char *title, - const char *caption, - const char *default_path, - const char *allowed_types[], - gboolean allow_creation) -{ - EFolderSelectionDialog *folder_selection_dialog; - - g_return_val_if_fail (E_IS_STORAGE_SET (storage_set), NULL); - - folder_selection_dialog = g_object_new (e_folder_selection_dialog_get_type (), NULL); - e_folder_selection_dialog_construct (folder_selection_dialog, storage_set, - title, caption, default_path, allowed_types, - allow_creation); - - return GTK_WIDGET (folder_selection_dialog); -} - - -const char * -e_folder_selection_dialog_get_selected_path (EFolderSelectionDialog *folder_selection_dialog) -{ - EFolderSelectionDialogPrivate *priv; - - g_return_val_if_fail (E_IS_FOLDER_SELECTION_DIALOG (folder_selection_dialog), NULL); - - priv = folder_selection_dialog->priv; - - return e_storage_set_view_get_current_folder (E_STORAGE_SET_VIEW (priv->storage_set_view)); -} - - -E_MAKE_TYPE (e_folder_selection_dialog, "EFolderSelectionDialog", EFolderSelectionDialog, class_init, init, PARENT_TYPE) diff --git a/shell/e-folder-selection-dialog.h b/shell/e-folder-selection-dialog.h deleted file mode 100644 index bc263d46a8..0000000000 --- a/shell/e-folder-selection-dialog.h +++ /dev/null @@ -1,82 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-folder-selection-dialog.h - * - * Copyright (C) 2000, 2001, 2002, 2003 Ximian, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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 E_FOLDER_SELECTION_DIALOG_H -#define E_FOLDER_SELECTION_DIALOG_H - -#include "e-storage-set.h" - -#include <gtk/gtkdialog.h> - -#ifdef cplusplus -extern "C" { -#pragma } -#endif /* cplusplus */ - -#define E_TYPE_FOLDER_SELECTION_DIALOG (e_folder_selection_dialog_get_type ()) -#define E_FOLDER_SELECTION_DIALOG(obj) (GTK_CHECK_CAST ((obj), E_TYPE_FOLDER_SELECTION_DIALOG, EFolderSelectionDialog)) -#define E_FOLDER_SELECTION_DIALOG_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_TYPE_FOLDER_SELECTION_DIALOG, EFolderSelectionDialogClass)) -#define E_IS_FOLDER_SELECTION_DIALOG(obj) (GTK_CHECK_TYPE ((obj), E_TYPE_FOLDER_SELECTION_DIALOG)) -#define E_IS_FOLDER_SELECTION_DIALOG_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), E_TYPE_FOLDER_SELECTION_DIALOG)) - - -typedef struct _EFolderSelectionDialog EFolderSelectionDialog; -typedef struct _EFolderSelectionDialogPrivate EFolderSelectionDialogPrivate; -typedef struct _EFolderSelectionDialogClass EFolderSelectionDialogClass; - -struct _EFolderSelectionDialog { - GtkDialog parent; - - EFolderSelectionDialogPrivate *priv; -}; - -struct _EFolderSelectionDialogClass { - GtkDialogClass parent_class; - - void (* folder_selected) (EFolderSelectionDialog *folder_selection_dialog, - const char *path); - void (* cancelled) (EFolderSelectionDialog *folder_selection_dialog); -}; - - -GtkType e_folder_selection_dialog_get_type (void); -void e_folder_selection_dialog_construct (EFolderSelectionDialog *folder_selection_dialog, - EStorageSet *storage_set, - const char *title, - const char *caption, - const char *default_path, - const char *allowed_types[], - gboolean allow_creation); -GtkWidget *e_folder_selection_dialog_new (EStorageSet *storage_set, - const char *title, - const char *caption, - const char *default_path, - const char *allowed_types[], - gboolean allow_creation); - -const char *e_folder_selection_dialog_get_selected_path (EFolderSelectionDialog *folder_selection_dialog); - -#ifdef cplusplus -} -#endif /* cplusplus */ - -#endif /* E_FOLDER_SELECTION_DIALOG_H */ diff --git a/shell/e-folder-type-registry.c b/shell/e-folder-type-registry.c deleted file mode 100644 index 81cb18796e..0000000000 --- a/shell/e-folder-type-registry.c +++ /dev/null @@ -1,536 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-folder-type-registry.c - * - * Copyright (C) 2000, 2001 Ximian, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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/gtktypeutils.h> - -#include <gal/util/e-util.h> - -#include "e-shell-utils.h" - -#include "e-folder-type-registry.h" - - -#define PARENT_TYPE GTK_TYPE_OBJECT -static GtkObjectClass *parent_class = NULL; - -struct _FolderType { - char *name; - char *icon_name; - - char *display_name; - char *description; - - gboolean user_creatable; - - GList *exported_dnd_types; /* char * */ - GList *accepted_dnd_types; /* char * */ - - EvolutionShellComponentClient *handler; - - /* The icon, standard (48x48) and mini (16x16) versions. */ - GdkPixbuf *icon_pixbuf; - GdkPixbuf *mini_icon_pixbuf; -}; -typedef struct _FolderType FolderType; - -struct _EFolderTypeRegistryPrivate { - GHashTable *name_to_type; -}; - - -/* FolderType handling. */ - -static FolderType * -folder_type_new (const char *name, - const char *icon_name, - const char *display_name, - const char *description, - gboolean user_creatable, - int num_exported_dnd_types, - const char **exported_dnd_types, - int num_accepted_dnd_types, - const char **accepted_dnd_types) -{ - FolderType *new; - char *icon_path; - int i; - - new = g_new (FolderType, 1); - - new->name = g_strdup (name); - new->icon_name = g_strdup (icon_name); - new->display_name = g_strdup (display_name); - new->description = g_strdup (description); - - new->user_creatable = user_creatable; - - new->exported_dnd_types = NULL; - for (i = 0; i < num_exported_dnd_types; i++) - new->exported_dnd_types = g_list_prepend (new->exported_dnd_types, - g_strdup (exported_dnd_types[i])); - new->exported_dnd_types = g_list_reverse (new->exported_dnd_types); - - new->accepted_dnd_types = NULL; - for (i = 0; i < num_accepted_dnd_types; i++) - new->accepted_dnd_types = g_list_prepend (new->accepted_dnd_types, - g_strdup (accepted_dnd_types[i])); - new->accepted_dnd_types = g_list_reverse (new->accepted_dnd_types); - - new->handler = NULL; - - icon_path = e_shell_get_icon_path (icon_name, FALSE); - if (icon_path == NULL) - new->icon_pixbuf = NULL; - else - new->icon_pixbuf = gdk_pixbuf_new_from_file (icon_path, NULL); - - g_free (icon_path); - - icon_path = e_shell_get_icon_path (icon_name, TRUE); - if (icon_path != NULL) { - new->mini_icon_pixbuf = gdk_pixbuf_new_from_file (icon_path, NULL); - } else { - if (new->icon_pixbuf != NULL) - new->mini_icon_pixbuf = g_object_ref (new->icon_pixbuf); - else - new->mini_icon_pixbuf = NULL; - } - - g_free (icon_path); - - return new; -} - -static void -folder_type_free (FolderType *folder_type) -{ - g_free (folder_type->name); - g_free (folder_type->icon_name); - g_free (folder_type->display_name); - g_free (folder_type->description); - - if (folder_type->icon_pixbuf != NULL) - g_object_unref (folder_type->icon_pixbuf); - if (folder_type->mini_icon_pixbuf != NULL) - g_object_unref (folder_type->mini_icon_pixbuf); - - if (folder_type->handler != NULL) - g_object_unref (folder_type->handler); - - g_free (folder_type); -} - -static FolderType * -get_folder_type (EFolderTypeRegistry *folder_type_registry, - const char *type_name) -{ - EFolderTypeRegistryPrivate *priv; - - priv = folder_type_registry->priv; - - return g_hash_table_lookup (priv->name_to_type, type_name); -} - -static gboolean -register_folder_type (EFolderTypeRegistry *folder_type_registry, - const char *name, - const char *icon_name, - const char *display_name, - const char *description, - gboolean user_creatable, - int num_exported_dnd_types, - const char **exported_dnd_types, - int num_accepted_dnd_types, - const char **accepted_dnd_types) -{ - EFolderTypeRegistryPrivate *priv; - FolderType *folder_type; - - priv = folder_type_registry->priv; - - /* Make sure we don't add the same type twice. */ - if (get_folder_type (folder_type_registry, name) != NULL) - return FALSE; - - folder_type = folder_type_new (name, icon_name, - display_name, description, - user_creatable, - num_exported_dnd_types, exported_dnd_types, - num_accepted_dnd_types, accepted_dnd_types); - g_hash_table_insert (priv->name_to_type, folder_type->name, folder_type); - - return TRUE; -} - -static gboolean -set_handler (EFolderTypeRegistry *folder_type_registry, - const char *name, - EvolutionShellComponentClient *handler) -{ - EFolderTypeRegistryPrivate *priv; - FolderType *folder_type; - - priv = folder_type_registry->priv; - - folder_type = get_folder_type (folder_type_registry, name); - if (folder_type == NULL) - return FALSE; - if (folder_type->handler != NULL) - return FALSE; - - g_object_ref (handler); - folder_type->handler = handler; - - return TRUE; -} - - -/* GtkObject methods. */ - -static void -hash_forall_free_folder_type (gpointer key, - gpointer value, - gpointer data) -{ - FolderType *folder_type; - - folder_type = (FolderType *) value; - folder_type_free (folder_type); -} - -static void -impl_finalize (GObject *object) -{ - EFolderTypeRegistry *folder_type_registry; - EFolderTypeRegistryPrivate *priv; - - folder_type_registry = E_FOLDER_TYPE_REGISTRY (object); - priv = folder_type_registry->priv; - - g_hash_table_foreach (priv->name_to_type, hash_forall_free_folder_type, NULL); - g_hash_table_destroy (priv->name_to_type); - - g_free (priv); - - (* G_OBJECT_CLASS (parent_class)->finalize) (object); -} - - -static void -class_init (EFolderTypeRegistryClass *class) -{ - GObjectClass *object_class; - - object_class = G_OBJECT_CLASS (class); - object_class->finalize = impl_finalize; - - parent_class = g_type_class_ref(gtk_object_get_type ()); -} - -static void -init (EFolderTypeRegistry *folder_type_registry) -{ - EFolderTypeRegistryPrivate *priv; - - priv = g_new (EFolderTypeRegistryPrivate, 1); - priv->name_to_type = g_hash_table_new (g_str_hash, g_str_equal); - - folder_type_registry->priv = priv; -} - - -void -e_folder_type_registry_construct (EFolderTypeRegistry *folder_type_registry) -{ - g_return_if_fail (folder_type_registry != NULL); - g_return_if_fail (E_IS_FOLDER_TYPE_REGISTRY (folder_type_registry)); - - GTK_OBJECT_UNSET_FLAGS (GTK_OBJECT (folder_type_registry), GTK_FLOATING); -} - -EFolderTypeRegistry * -e_folder_type_registry_new (void) -{ - EFolderTypeRegistry *new; - - new = g_object_new (e_folder_type_registry_get_type (), NULL); - - e_folder_type_registry_construct (new); - - return new; -} - - -gboolean -e_folder_type_registry_register_type (EFolderTypeRegistry *folder_type_registry, - const char *type_name, - const char *icon_name, - const char *display_name, - const char *description, - gboolean user_creatable, - int num_exported_dnd_types, - const char **exported_dnd_types, - int num_accepted_dnd_types, - const char **accepted_dnd_types) -{ - g_return_val_if_fail (folder_type_registry != NULL, FALSE); - g_return_val_if_fail (E_IS_FOLDER_TYPE_REGISTRY (folder_type_registry), FALSE); - g_return_val_if_fail (type_name != NULL, FALSE); - g_return_val_if_fail (icon_name != NULL, FALSE); - - return register_folder_type (folder_type_registry, type_name, icon_name, - display_name, description, user_creatable, - num_exported_dnd_types, exported_dnd_types, - num_accepted_dnd_types, accepted_dnd_types); -} - -gboolean -e_folder_type_registry_set_handler_for_type (EFolderTypeRegistry *folder_type_registry, - const char *type_name, - EvolutionShellComponentClient *handler) -{ - g_return_val_if_fail (E_IS_FOLDER_TYPE_REGISTRY (folder_type_registry), FALSE); - g_return_val_if_fail (EVOLUTION_IS_SHELL_COMPONENT_CLIENT (handler), FALSE); - - return set_handler (folder_type_registry, type_name, handler); -} - - -gboolean -e_folder_type_registry_type_registered (EFolderTypeRegistry *folder_type_registry, - const char *type_name) -{ - EFolderTypeRegistryPrivate *priv; - - g_return_val_if_fail (folder_type_registry != NULL, FALSE); - g_return_val_if_fail (E_IS_FOLDER_TYPE_REGISTRY (folder_type_registry), FALSE); - g_return_val_if_fail (type_name != NULL, FALSE); - - priv = folder_type_registry->priv; - - if (get_folder_type (folder_type_registry, type_name) == NULL) - return FALSE; - - return TRUE; -} - -void -e_folder_type_registry_unregister_type (EFolderTypeRegistry *folder_type_registry, - const char *type_name) -{ - EFolderTypeRegistryPrivate *priv; - FolderType *folder_type; - - g_return_if_fail (folder_type_registry != NULL); - g_return_if_fail (E_IS_FOLDER_TYPE_REGISTRY (folder_type_registry)); - g_return_if_fail (type_name != NULL); - - priv = folder_type_registry->priv; - - folder_type = get_folder_type (folder_type_registry, type_name); - if (folder_type == NULL) - return; - - g_hash_table_remove (priv->name_to_type, folder_type->name); - folder_type_free (folder_type); -} - - -static void -get_type_names_hash_forall (void *key, - void *value, - void *data) -{ - GList **type_name_list; - - type_name_list = (GList **) data; - - *type_name_list = g_list_prepend (*type_name_list, g_strdup ((const char *) key)); -} - -GList * -e_folder_type_registry_get_type_names (EFolderTypeRegistry *folder_type_registry) -{ - GList *type_name_list; - EFolderTypeRegistryPrivate *priv; - - g_return_val_if_fail (folder_type_registry != NULL, NULL); - g_return_val_if_fail (E_IS_FOLDER_TYPE_REGISTRY (folder_type_registry), NULL); - - priv = folder_type_registry->priv; - - type_name_list = NULL; - g_hash_table_foreach (priv->name_to_type, get_type_names_hash_forall, &type_name_list); - - return type_name_list; -} - - -const char * -e_folder_type_registry_get_icon_name_for_type (EFolderTypeRegistry *folder_type_registry, - const char *type_name) -{ - const FolderType *folder_type; - - g_return_val_if_fail (folder_type_registry != NULL, NULL); - g_return_val_if_fail (E_IS_FOLDER_TYPE_REGISTRY (folder_type_registry), NULL); - g_return_val_if_fail (type_name != NULL, NULL); - - folder_type = get_folder_type (folder_type_registry, type_name); - if (folder_type == NULL) - return NULL; - - return folder_type->icon_name; -} - -GdkPixbuf * -e_folder_type_registry_get_icon_for_type (EFolderTypeRegistry *folder_type_registry, - const char *type_name, - gboolean mini) -{ - const FolderType *folder_type; - - g_return_val_if_fail (folder_type_registry != NULL, NULL); - g_return_val_if_fail (E_IS_FOLDER_TYPE_REGISTRY (folder_type_registry), NULL); - g_return_val_if_fail (type_name != NULL, NULL); - - folder_type = get_folder_type (folder_type_registry, type_name); - if (folder_type == NULL) - return NULL; - - if (mini) - return folder_type->mini_icon_pixbuf; - else - return folder_type->icon_pixbuf; -} - -EvolutionShellComponentClient * -e_folder_type_registry_get_handler_for_type (EFolderTypeRegistry *folder_type_registry, - const char *type_name) -{ - const FolderType *folder_type; - - g_return_val_if_fail (folder_type_registry != NULL, NULL); - g_return_val_if_fail (E_IS_FOLDER_TYPE_REGISTRY (folder_type_registry), NULL); - g_return_val_if_fail (type_name != NULL, NULL); - - folder_type = get_folder_type (folder_type_registry, type_name); - if (folder_type == NULL) - return NULL; - - return folder_type->handler; -} - -gboolean -e_folder_type_registry_type_is_user_creatable (EFolderTypeRegistry *folder_type_registry, - const char *type_name) -{ - const FolderType *folder_type; - - g_return_val_if_fail (folder_type_registry != NULL, FALSE); - g_return_val_if_fail (E_IS_FOLDER_TYPE_REGISTRY (folder_type_registry), FALSE); - g_return_val_if_fail (type_name != NULL, FALSE); - - folder_type = get_folder_type (folder_type_registry, type_name); - if (folder_type == NULL) - return FALSE; - - return folder_type->user_creatable; -} - -const char * -e_folder_type_registry_get_display_name_for_type (EFolderTypeRegistry *folder_type_registry, - const char *type_name) -{ - const FolderType *folder_type; - - g_return_val_if_fail (folder_type_registry != NULL, NULL); - g_return_val_if_fail (E_IS_FOLDER_TYPE_REGISTRY (folder_type_registry), NULL); - g_return_val_if_fail (type_name != NULL, NULL); - - folder_type = get_folder_type (folder_type_registry, type_name); - if (folder_type == NULL) - return FALSE; - - return folder_type->display_name; -} - -const char * -e_folder_type_registry_get_description_for_type (EFolderTypeRegistry *folder_type_registry, - const char *type_name) -{ - const FolderType *folder_type; - - g_return_val_if_fail (folder_type_registry != NULL, NULL); - g_return_val_if_fail (E_IS_FOLDER_TYPE_REGISTRY (folder_type_registry), NULL); - g_return_val_if_fail (type_name != NULL, NULL); - - folder_type = get_folder_type (folder_type_registry, type_name); - if (folder_type == NULL) - return FALSE; - - return folder_type->description; -} - - -GList * -e_folder_type_registry_get_exported_dnd_types_for_type (EFolderTypeRegistry *folder_type_registry, - const char *type_name) -{ - const FolderType *folder_type; - - g_return_val_if_fail (folder_type_registry != NULL, NULL); - g_return_val_if_fail (E_IS_FOLDER_TYPE_REGISTRY (folder_type_registry), NULL); - g_return_val_if_fail (type_name != NULL, NULL); - - folder_type = get_folder_type (folder_type_registry, type_name); - if (folder_type == NULL) - return NULL; - - return folder_type->exported_dnd_types; -} - -GList * -e_folder_type_registry_get_accepted_dnd_types_for_type (EFolderTypeRegistry *folder_type_registry, - const char *type_name) -{ - const FolderType *folder_type; - - g_return_val_if_fail (folder_type_registry != NULL, NULL); - g_return_val_if_fail (E_IS_FOLDER_TYPE_REGISTRY (folder_type_registry), NULL); - g_return_val_if_fail (type_name != NULL, NULL); - - folder_type = get_folder_type (folder_type_registry, type_name); - if (folder_type == NULL) - return NULL; - - return folder_type->accepted_dnd_types; -} - - -E_MAKE_TYPE (e_folder_type_registry, "EFolderTypeRegistry", EFolderTypeRegistry, - class_init, init, PARENT_TYPE) diff --git a/shell/e-folder-type-registry.h b/shell/e-folder-type-registry.h deleted file mode 100644 index 628a5d7d39..0000000000 --- a/shell/e-folder-type-registry.h +++ /dev/null @@ -1,107 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-folder-type-registry.h - * - * Copyright (C) 2000 Ximian, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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 _E_FOLDER_TYPE_REGISTRY_H_ -#define _E_FOLDER_TYPE_REGISTRY_H_ - -#include <gtk/gtkobject.h> -#include <gdk-pixbuf/gdk-pixbuf.h> - -#include "evolution-shell-component-client.h" - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - -#define E_TYPE_FOLDER_TYPE_REGISTRY (e_folder_type_registry_get_type ()) -#define E_FOLDER_TYPE_REGISTRY(obj) (GTK_CHECK_CAST ((obj), E_TYPE_FOLDER_TYPE_REGISTRY, EFolderTypeRegistry)) -#define E_FOLDER_TYPE_REGISTRY_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_TYPE_FOLDER_TYPE_REGISTRY, EFolderTypeRegistryClass)) -#define E_IS_FOLDER_TYPE_REGISTRY(obj) (GTK_CHECK_TYPE ((obj), E_TYPE_FOLDER_TYPE_REGISTRY)) -#define E_IS_FOLDER_TYPE_REGISTRY_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), E_TYPE_FOLDER_TYPE_REGISTRY)) - - -typedef struct _EFolderTypeRegistry EFolderTypeRegistry; -typedef struct _EFolderTypeRegistryPrivate EFolderTypeRegistryPrivate; -typedef struct _EFolderTypeRegistryClass EFolderTypeRegistryClass; - -struct _EFolderTypeRegistry { - GtkObject parent; - - EFolderTypeRegistryPrivate *priv; -}; - -struct _EFolderTypeRegistryClass { - GtkObjectClass parent_class; -}; - - -GtkType e_folder_type_registry_get_type (void); -void e_folder_type_registry_construct (EFolderTypeRegistry *folder_type_registry); -EFolderTypeRegistry *e_folder_type_registry_new (void); - -gboolean e_folder_type_registry_register_type (EFolderTypeRegistry *folder_type_registry, - const char *type_name, - const char *icon_name, - const char *display_name, - const char *description, - gboolean user_creatable, - int num_exported_dnd_types, - const char **exported_dnd_types, - int num_accepted_dnd_types, - const char **accepted_dnd_types); -gboolean e_folder_type_registry_set_handler_for_type (EFolderTypeRegistry *folder_type_registry, - const char *type_name, - EvolutionShellComponentClient *handler); - -GList *e_folder_type_registry_get_type_names (EFolderTypeRegistry *folder_type_registry); - -gboolean e_folder_type_registry_type_registered (EFolderTypeRegistry *folder_type_registry, - const char *type_name); -void e_folder_type_registry_unregister_type (EFolderTypeRegistry *folder_type_registry, - const char *type_name); - -GdkPixbuf *e_folder_type_registry_get_icon_for_type (EFolderTypeRegistry *folder_type_registry, - const char *type_name, - gboolean mini); -const char *e_folder_type_registry_get_icon_name_for_type (EFolderTypeRegistry *folder_type_registry, - const char *type_name); -EvolutionShellComponentClient *e_folder_type_registry_get_handler_for_type (EFolderTypeRegistry *folder_type_registry, - const char *type_name); -gboolean e_folder_type_registry_type_is_user_creatable (EFolderTypeRegistry *folder_type_registry, - const char *type_name); -const char *e_folder_type_registry_get_display_name_for_type (EFolderTypeRegistry *folder_type_registry, - const char *type_name); -const char *e_folder_type_registry_get_description_for_type (EFolderTypeRegistry *folder_type_registry, - const char *type_name); - -GList *e_folder_type_registry_get_exported_dnd_types_for_type (EFolderTypeRegistry *folder_type_registry, - const char *type_name); -GList *e_folder_type_registry_get_accepted_dnd_types_for_type (EFolderTypeRegistry *folder_type_registry, - const char *type_name); - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _E_FOLDER_TYPE_REGISTRY_H_ */ diff --git a/shell/e-local-folder.c b/shell/e-local-folder.c deleted file mode 100644 index 1df96734f9..0000000000 --- a/shell/e-local-folder.c +++ /dev/null @@ -1,560 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-local-folder.c - * - * Copyright (C) 2000 Ximian, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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 - */ - -/* The metafile goes like this: - - <?xml version="1.0"?> - <efolder> - <type>mail</type> - - <name>Inbox</name> - <name locale="it">Posta in Arrivo</name> - - <description>This is the default folder for incoming messages</description> - <description locale="it">Cartella che contiene i messaggi in arrivo</description> - - <homepage>http://www.somewhere.net</homepage> - </efolder> - - FIXME: Do we want to use a namespace for this? - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <string.h> -#include <unistd.h> - -#include <libxml/parser.h> -#include <libxml/xmlmemory.h> - -#include <libgnome/gnome-util.h> - -#include <gal/util/e-util.h> -#include <gal/util/e-xml-utils.h> - -#include <libgnome/gnome-util.h> - -#include "e-local-folder.h" - - -#define PARENT_TYPE E_TYPE_FOLDER -static EFolderClass *parent_class = NULL; - -#define URI_PREFIX "file://" -#define URI_PREFIX_LEN 7 - -/* This provides the name and the description for a specific locale. */ -struct _I18nInfo { - char *language_id; - char *name; - char *description; -}; -typedef struct _I18nInfo I18nInfo; - -struct _ELocalFolderPrivate { - GHashTable *language_id_to_i18n_info; -}; - - -/* Locale information. */ - -static char *global_language_id = NULL; - - -/* I18nInfo handling. */ - -static I18nInfo * -i18n_info_new (const char *language_id, - const char *name, - const char *description) -{ - I18nInfo *info; - - info = g_new (I18nInfo, 1); - info->language_id = g_strdup (language_id); - info->name = g_strdup (name); - info->description = g_strdup (description); - - return info; -} - -static void -i18n_info_free (I18nInfo *info) -{ - g_free (info->language_id); - g_free (info->name); - g_free (info->description); - - g_free (info); -} - - -/* Language ID -> I18nInfo hash table handling. */ - -static void -add_i18n_info_to_hash (GHashTable *language_id_to_i18n_info_hash, - I18nInfo *i18n_info) -{ - I18nInfo *existing_i18n_info; - - existing_i18n_info = (I18nInfo *) g_hash_table_lookup (language_id_to_i18n_info_hash, - i18n_info->language_id); - if (existing_i18n_info != NULL) { - g_hash_table_remove (language_id_to_i18n_info_hash, - i18n_info->language_id); - i18n_info_free (existing_i18n_info); - } - - g_hash_table_insert (language_id_to_i18n_info_hash, i18n_info->language_id, i18n_info); -} - -static void -language_id_to_i18n_info_hash_foreach_free (void *key, - void *value, - void *data) -{ - i18n_info_free ((I18nInfo *) value); -} - -static I18nInfo * -get_i18n_info_for_language (ELocalFolder *local_folder, - const char *language_id) -{ - ELocalFolderPrivate *priv; - I18nInfo *i18n_info; - - priv = local_folder->priv; - - if (language_id == NULL) - language_id = global_language_id; - - i18n_info = g_hash_table_lookup (priv->language_id_to_i18n_info, language_id); - - /* For locale info like `en_UK@yadda', we try to use `en' as a backup. */ - /* Note: this is exactly the same thing that gnome-config does with the - I18N value handling. I hope it works. */ - if (i18n_info == NULL) { - size_t n; - - n = strcspn (language_id, "@_"); - if (language_id[n] != '\0') { - char *simplified_language_id; - - simplified_language_id = g_strndup (language_id, n); - i18n_info = g_hash_table_lookup (priv->language_id_to_i18n_info, - simplified_language_id); - } - } - - return i18n_info; -} - - -/* Locale handling. */ - -static void -setup_global_language_id (void) -{ - /* FIXME: Implement. */ - global_language_id = "C"; -} - -/* Update the EFolder attributes according to the current locale. */ -static void -update_for_global_locale (ELocalFolder *local_folder) -{ - I18nInfo *i18n_info; - - i18n_info = get_i18n_info_for_language (local_folder, NULL); - - if (i18n_info == NULL) - i18n_info = get_i18n_info_for_language (local_folder, "C"); - - g_assert (i18n_info != NULL); - - e_folder_set_name (E_FOLDER (local_folder), i18n_info->name); - e_folder_set_description (E_FOLDER (local_folder), i18n_info->description); -} - - -/* XML tree handling. */ - -static char * -get_string_value (xmlNode *node, - const char *name) -{ - xmlNode *p; - xmlChar *xml_string; - char *retval; - - p = e_xml_get_child_by_name (node, (xmlChar *) name); - if (p == NULL) - return NULL; - - p = e_xml_get_child_by_name (p, (xmlChar *) "text"); - if (p == NULL) - return NULL; - - xml_string = xmlNodeListGetString (node->doc, p, TRUE); - retval = g_strdup ((char *) xml_string); - xmlFree (xml_string); - - return retval; -} - -static void -retrieve_info_item (ELocalFolder *local_folder, - xmlNode *node) -{ - xmlChar *lang; - char *name; - char *description; - - lang = xmlGetProp (node, "lang"); - name = get_string_value (node, "name"); - description = get_string_value (node, "description"); - - if (lang == NULL) { - e_local_folder_add_i18n_info (local_folder, "C", name, description); - } else { - e_local_folder_add_i18n_info (local_folder, lang, name, description); - xmlFree (lang); - } - - g_free (name); - g_free (description); -} - -static void -retrieve_info (ELocalFolder *local_folder, - xmlNode *root_xml_node) -{ - ELocalFolderPrivate *priv; - xmlNode *p; - - priv = local_folder->priv; - - for (p = root_xml_node->children; p != NULL; p = p->next) { - if (xmlStrcmp (p->name, "info") == 0) - retrieve_info_item (local_folder, p); - } -} - -static gboolean -construct_loading_metadata (ELocalFolder *local_folder, - const char *path) -{ - EFolder *folder; - xmlDoc *doc; - xmlNode *root; - char *base_name; - char *type; - char *metadata_path; - char *physical_uri; - - folder = E_FOLDER (local_folder); - - metadata_path = g_build_filename (path, E_LOCAL_FOLDER_METADATA_FILE_NAME, NULL); - - doc = xmlParseFile (metadata_path); - if (doc == NULL) { - g_free (metadata_path); - return FALSE; - } - - root = xmlDocGetRootElement (doc); - if (root == NULL || root->name == NULL || strcmp (root->name, "efolder") != 0) { - g_free (metadata_path); - xmlFreeDoc (doc); - return FALSE; - } - - type = get_string_value (root, "type"); - if (type == NULL) { - g_free (metadata_path); - xmlFreeDoc (doc); - return FALSE; - } - - base_name = g_path_get_basename (path); - e_local_folder_construct (local_folder, base_name, type, NULL); - g_free (base_name); - g_free (type); - - retrieve_info (local_folder, root); - - xmlFreeDoc (doc); - - physical_uri = g_strconcat (URI_PREFIX, path, NULL); - e_folder_set_physical_uri (folder, physical_uri); - g_free (physical_uri); - - g_free (metadata_path); - - return TRUE; -} - -static gboolean -save_metadata (ELocalFolder *local_folder) -{ - EFolder *folder; - xmlDoc *doc; - xmlNode *root; - const char *physical_directory; - char *physical_path; - - folder = E_FOLDER (local_folder); - - doc = xmlNewDoc ((xmlChar *) "1.0"); - root = xmlNewDocNode (doc, NULL, (xmlChar *) "efolder", NULL); - xmlDocSetRootElement (doc, root); - - xmlNewChild (root, NULL, (xmlChar *) "type", - (xmlChar *) e_folder_get_type_string (folder)); - - if (e_folder_get_description (folder) != NULL) - xmlNewTextChild (root, NULL, (xmlChar *) "description", - (xmlChar *) e_folder_get_description (folder)); - - physical_directory = e_folder_get_physical_uri (folder) + URI_PREFIX_LEN - 1; - physical_path = g_build_filename (physical_directory, E_LOCAL_FOLDER_METADATA_FILE_NAME, NULL); - - if (xmlSaveFile (physical_path, doc) < 0) { - unlink (physical_path); - g_free (physical_path); - xmlFreeDoc (doc); - return FALSE; - } - - g_free (physical_path); - - xmlFreeDoc (doc); - return TRUE; -} - - -/* GtkObject methods. */ - -static void -impl_finalize (GObject *object) -{ - ELocalFolder *local_folder; - ELocalFolderPrivate *priv; - - local_folder = E_LOCAL_FOLDER (object); - priv = local_folder->priv; - - g_hash_table_foreach (priv->language_id_to_i18n_info, - language_id_to_i18n_info_hash_foreach_free, - NULL); - g_hash_table_destroy (priv->language_id_to_i18n_info); - - g_free (priv); - - (* G_OBJECT_CLASS (parent_class)->finalize) (object); -} - - -static void -class_init (ELocalFolderClass *klass) -{ - GObjectClass *object_class; - - parent_class = g_type_class_ref(e_folder_get_type ()); - - object_class = G_OBJECT_CLASS (klass); - object_class->finalize = impl_finalize; - - setup_global_language_id (); -} - -static void -init (ELocalFolder *local_folder) -{ - ELocalFolderPrivate *priv; - - priv = g_new (ELocalFolderPrivate, 1); - priv->language_id_to_i18n_info = g_hash_table_new (g_str_hash, g_str_equal); - - local_folder->priv = priv; -} - - -void -e_local_folder_construct (ELocalFolder *local_folder, - const char *name, - const char *type, - const char *description) -{ - ELocalFolderPrivate *priv; - I18nInfo *i18n_info; - - g_return_if_fail (local_folder != NULL); - g_return_if_fail (E_IS_LOCAL_FOLDER (local_folder)); - g_return_if_fail (name != NULL); - g_return_if_fail (type != NULL); - - priv = local_folder->priv; - - e_folder_construct (E_FOLDER (local_folder), name, type, description); - - i18n_info = i18n_info_new ("C", name, description); - add_i18n_info_to_hash (priv->language_id_to_i18n_info, i18n_info); -} - -EFolder * -e_local_folder_new (const char *name, - const char *type, - const char *description) -{ - ELocalFolder *local_folder; - - g_return_val_if_fail (name != NULL, NULL); - g_return_val_if_fail (type != NULL, NULL); - - local_folder = g_object_new (e_local_folder_get_type (), NULL); - - e_local_folder_construct (local_folder, name, type, description); - - return E_FOLDER (local_folder); -} - -EFolder * -e_local_folder_new_from_path (const char *path) -{ - EFolder *folder; - - g_return_val_if_fail (g_path_is_absolute (path), NULL); - - folder = g_object_new (e_local_folder_get_type (), NULL); - - if (! construct_loading_metadata (E_LOCAL_FOLDER (folder), path)) { - g_object_unref (folder); - return NULL; - } - - return folder; -} - -gboolean -e_local_folder_save (ELocalFolder *local_folder) -{ - g_return_val_if_fail (local_folder != NULL, FALSE); - g_return_val_if_fail (E_IS_LOCAL_FOLDER (local_folder), FALSE); - g_return_val_if_fail (e_folder_get_physical_uri (E_FOLDER (local_folder)) != NULL, FALSE); - - return save_metadata (local_folder); -} - - -/** - * e_local_folder_add_i18n_info: - * @local_folder: A pointer to an ELocalFolder object - * @language_id: An I1I8N locale ID - * @name: Name for @local_folder in the specified @language_id - * @description: Description for @local_folder in the specified @language_id - * - * Set the @name and @description for the specified @language_id locale. - **/ -void -e_local_folder_add_i18n_info (ELocalFolder *local_folder, - const char *language_id, - const char *name, - const char *description) -{ - ELocalFolderPrivate *priv; - I18nInfo *info; - - g_return_if_fail (local_folder != NULL); - g_return_if_fail (E_IS_LOCAL_FOLDER (local_folder)); - g_return_if_fail (language_id != NULL); - g_return_if_fail (name != NULL || description != NULL); - - priv = local_folder->priv; - - info = i18n_info_new (language_id, name, description); - add_i18n_info_to_hash (priv->language_id_to_i18n_info, info); - - update_for_global_locale (local_folder); -} - -/** - * e_local_folder_get_i18n_info: - * @local_folder: A pointer to an ELocalFolder object - * @language_id: The ID of the language whose locale we want to retrieve name - * and description for - * @language_id_return: The actual locale ID that the name and description are - * saved under (e.g. if you ask for an "en_UK@yadda", we might give you the - * info for just "en") - * @name_return: A pointer to a pointer that will point to the i18nized name on - * return. Can be NULL. - * @description_return: A pointer to a pointer that will point to the i18n - * description on return. Can be NULL. - * - * Retrieve the name and description for @local_folder in the specified locale. - * - * Return value: %TRUE if some info is found for that @language_id, %FALSE - * otherwise. - **/ -gboolean -e_local_folder_get_i18n_info (ELocalFolder *local_folder, - const char *language_id, - const char **language_id_return, - const char **name_return, - const char **description_return) -{ - ELocalFolderPrivate *priv; - I18nInfo *i18n_info; - - g_return_val_if_fail (local_folder != NULL, FALSE); - g_return_val_if_fail (E_IS_LOCAL_FOLDER (local_folder), FALSE); - g_return_val_if_fail (language_id != NULL, FALSE); - - priv = local_folder->priv; - - i18n_info = get_i18n_info_for_language (local_folder, language_id); - - if (i18n_info == NULL) { - if (language_id_return != NULL) - *language_id_return = NULL; - if (name_return != NULL) - *name_return = NULL; - if (description_return != NULL) - *description_return = NULL; - - return FALSE; - } - - if (language_id_return != NULL) - *language_id_return = i18n_info->language_id; - if (name_return != NULL) - *name_return = i18n_info->name; - if (description_return != NULL) - *description_return = i18n_info->description; - - return TRUE; -} - - -E_MAKE_TYPE (e_local_folder, "ELocalFolder", ELocalFolder, class_init, init, PARENT_TYPE) diff --git a/shell/e-local-folder.h b/shell/e-local-folder.h deleted file mode 100644 index ca3cf6c364..0000000000 --- a/shell/e-local-folder.h +++ /dev/null @@ -1,84 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-local-folder.h - * - * Copyright (C) 2000, 2001 Ximian, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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 _E_LOCAL_FOLDER_H_ -#define _E_LOCAL_FOLDER_H_ - -#include <gtk/gtkobject.h> - -#include "e-folder.h" - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - -#define E_TYPE_LOCAL_FOLDER (e_local_folder_get_type ()) -#define E_LOCAL_FOLDER(obj) (GTK_CHECK_CAST ((obj), E_TYPE_LOCAL_FOLDER, ELocalFolder)) -#define E_LOCAL_FOLDER_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_TYPE_LOCAL_FOLDER, ELocalFolderClass)) -#define E_IS_LOCAL_FOLDER(obj) (GTK_CHECK_TYPE ((obj), E_TYPE_LOCAL_FOLDER)) -#define E_IS_LOCAL_FOLDER_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), E_TYPE_LOCAL_FOLDER)) - -#define E_LOCAL_FOLDER_METADATA_FILE_NAME "folder-metadata.xml" -#define E_LOCAL_FOLDER_METADATA_FILE_NAME_LEN 19 - -typedef struct _ELocalFolder ELocalFolder; -typedef struct _ELocalFolderClass ELocalFolderClass; -typedef struct _ELocalFolderPrivate ELocalFolderPrivate; - -struct _ELocalFolder { - EFolder parent; - - ELocalFolderPrivate *priv; -}; - -struct _ELocalFolderClass { - EFolderClass parent_class; -}; - - -GtkType e_local_folder_get_type (void); -void e_local_folder_construct (ELocalFolder *local_folder, - const char *name, - const char *type, - const char *description); -EFolder *e_local_folder_new (const char *name, - const char *type, - const char *description); -EFolder *e_local_folder_new_from_path (const char *physical_path); -gboolean e_local_folder_save (ELocalFolder *local_folder); - -void e_local_folder_add_i18n_info (ELocalFolder *local_folder, - const char *language_id, - const char *name, - const char *description); -gboolean e_local_folder_get_i18n_info (ELocalFolder *local_folder, - const char *language_id, - const char **language_id_return, - const char **name_return, - const char **description_return); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* __E_LOCAL_FOLDER_H__ */ diff --git a/shell/e-local-storage.c b/shell/e-local-storage.c deleted file mode 100644 index 01009cb805..0000000000 --- a/shell/e-local-storage.c +++ /dev/null @@ -1,1237 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-local-storage.c - * - * Copyright (C) 2000, 2001 Ximian, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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 - */ - -/* FIXMEs: - * - * - If we have `.' or `..' as path elements, we lose. - * - * - 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. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <errno.h> -#include <string.h> -#include <sys/param.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <unistd.h> -#include <dirent.h> - -#include <gtk/gtksignal.h> - -#include <libgnome/gnome-i18n.h> -#include <libgnome/gnome-util.h> - -#include <gal/util/e-util.h> - -#include "e-util/e-path.h" -#include "e-local-folder.h" -#include "e-shell-constants.h" - -#include "evolution-storage.h" - -#include "e-local-storage.h" - -#include <bonobo/bonobo-exception.h> - -#define PARENT_TYPE E_TYPE_STORAGE -static EStorageClass *parent_class = NULL; - -struct _ELocalStoragePrivate { - EFolderTypeRegistry *folder_type_registry; - char *base_path; - EvolutionStorage *bonobo_interface; -}; - - -/* EStorageResult <-> errno mapping. */ - -static EStorageResult -errno_to_storage_result (void) -{ - EStorageResult storage_result; - - switch (errno) { - case EACCES: - case EROFS: - storage_result = E_STORAGE_PERMISSIONDENIED; - break; - case EEXIST: - storage_result = E_STORAGE_EXISTS; - break; - case ENOSPC: - storage_result = E_STORAGE_NOSPACE; - break; - default: - storage_result = E_STORAGE_GENERICERROR; - } - - return storage_result; -} - -static EStorageResult -shell_component_result_to_storage_result (EvolutionShellComponentResult result) -{ - /* FIXME: Maybe we need better mapping here. */ - switch (result) { - case EVOLUTION_SHELL_COMPONENT_OK: - return E_STORAGE_OK; - case EVOLUTION_SHELL_COMPONENT_NOTFOUND: - return E_STORAGE_NOTFOUND; - case EVOLUTION_SHELL_COMPONENT_UNSUPPORTEDTYPE: - return E_STORAGE_UNSUPPORTEDTYPE; - case EVOLUTION_SHELL_COMPONENT_UNSUPPORTEDOPERATION: - return E_STORAGE_UNSUPPORTEDOPERATION; - case EVOLUTION_SHELL_COMPONENT_EXISTS: - return E_STORAGE_EXISTS; - case EVOLUTION_SHELL_COMPONENT_PERMISSIONDENIED: - return E_STORAGE_PERMISSIONDENIED; - case EVOLUTION_SHELL_COMPONENT_ALREADYOWNED: - case EVOLUTION_SHELL_COMPONENT_BUSY: - case EVOLUTION_SHELL_COMPONENT_CORBAERROR: - case EVOLUTION_SHELL_COMPONENT_HASSUBFOLDERS: - case EVOLUTION_SHELL_COMPONENT_INTERNALERROR: - case EVOLUTION_SHELL_COMPONENT_INTERRUPTED: - case EVOLUTION_SHELL_COMPONENT_INVALIDARG: - case EVOLUTION_SHELL_COMPONENT_INVALIDURI: - case EVOLUTION_SHELL_COMPONENT_NOSPACE: - case EVOLUTION_SHELL_COMPONENT_NOTOWNED: - case EVOLUTION_SHELL_COMPONENT_UNKNOWNERROR: - default: - return E_STORAGE_GENERICERROR; - } -} - - -/* Utility functions. */ - -static void -new_folder (ELocalStorage *local_storage, - const char *path, - EFolder *folder) -{ - ELocalStoragePrivate *priv; - - priv = local_storage->priv; - - e_storage_new_folder (E_STORAGE (local_storage), path, folder); - - evolution_storage_new_folder (EVOLUTION_STORAGE (priv->bonobo_interface), - path, - e_folder_get_name (folder), - e_folder_get_type_string (folder), - e_folder_get_physical_uri (folder), - e_folder_get_description (folder), - e_folder_get_custom_icon_name (folder), - e_folder_get_unread_count (folder), - FALSE, - 0); -} - -static gboolean -setup_folder_as_stock (ELocalStorage *local_storage, - const char *path, - const char *name, - const char *custom_icon_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); - e_folder_set_custom_icon (folder, custom_icon_name); - - return TRUE; -} - -static void -setup_stock_folders (ELocalStorage *local_storage) -{ - setup_folder_as_stock (local_storage, "/Calendar", _("Calendar"), NULL); - setup_folder_as_stock (local_storage, "/Contacts", _("Contacts"), NULL); - setup_folder_as_stock (local_storage, "/Drafts", _("Drafts"), NULL); - setup_folder_as_stock (local_storage, "/Inbox", _("Inbox"), "inbox"); - setup_folder_as_stock (local_storage, "/Outbox", _("Outbox"), "outbox"); - setup_folder_as_stock (local_storage, "/Sent", _("Sent"), NULL); - setup_folder_as_stock (local_storage, "/Tasks", _("Tasks"), NULL); - setup_folder_as_stock (local_storage, "/Trash", _("Trash"), NULL); - setup_folder_as_stock (local_storage, "/Spam", _("Spam"), NULL); -} - -static gboolean -load_folder (const char *physical_path, - const char *path, - void *data) -{ - ELocalStorage *local_storage; - EFolder *folder; - - local_storage = E_LOCAL_STORAGE (data); - - folder = e_local_folder_new_from_path (physical_path); - if (folder == NULL) { - /* g_warning ("No folder metadata in %s... ignoring", physical_path); FIXME */ - return TRUE; - } - - e_storage_new_folder ((EStorage *)local_storage, path, folder); - return TRUE; -} - -static void -setup_corba_storage (ELocalStorage *local_storage, - const char *path) -{ - GList *subfolder_paths; - EFolder *folder; - GList *p; - - folder = e_storage_get_folder (E_STORAGE (local_storage), path); - - if (folder != NULL) - evolution_storage_new_folder (EVOLUTION_STORAGE (local_storage->priv->bonobo_interface), - path, - e_folder_get_name (folder), - e_folder_get_type_string (folder), - e_folder_get_physical_uri (folder), - e_folder_get_description (folder), - e_folder_get_custom_icon_name (folder), - e_folder_get_unread_count (folder), - FALSE, - 0); - - subfolder_paths = e_storage_get_subfolder_paths (E_STORAGE (local_storage), path); - - for (p = subfolder_paths; p != NULL; p = p->next) - setup_corba_storage (local_storage, (const char *) p->data); - - e_free_string_list (subfolder_paths); -} - -static gboolean -load_all_folders (ELocalStorage *local_storage) -{ - const char *base_path; - - base_path = e_local_storage_get_base_path (local_storage); - - /* Ignore errors, so we set up the local storage even if there is stale - data that we don't understand in ~/evolution. */ - e_path_find_folders (base_path, load_folder, local_storage); - - setup_stock_folders (local_storage); - - setup_corba_storage (local_storage, "/"); - - return TRUE; -} - -static EStorageResult -storage_result_from_component_result (EvolutionShellComponentResult result) -{ - switch (result) { - case EVOLUTION_SHELL_COMPONENT_PERMISSIONDENIED: - return E_STORAGE_PERMISSIONDENIED; - case EVOLUTION_SHELL_COMPONENT_NOSPACE: - return E_STORAGE_NOSPACE; - default: - return E_STORAGE_GENERICERROR; - } -} - - -/* Callbacks for the async methods invoked on the `Evolution::ShellComponent's. */ - -static void -notify_listener (const Bonobo_Listener listener, - EStorageResult result, - const char *physical_path) -{ - CORBA_any any; - GNOME_Evolution_Storage_FolderResult folder_result; - CORBA_Environment ev; - - folder_result.result = result; - folder_result.path = CORBA_string_dup (physical_path ? physical_path : ""); - any._type = TC_GNOME_Evolution_Storage_FolderResult; - any._value = &folder_result; - - CORBA_exception_init (&ev); - Bonobo_Listener_event (listener, "evolution-shell:folder_created", - &any, &ev); - if (BONOBO_EX (&ev)) { - g_warning ("Exception notifing listener: %s\n", - CORBA_exception_id (&ev)); - } - CORBA_exception_free (&ev); -} - -struct _AsyncCreateFolderCallbackData { - EStorage *storage; - Bonobo_Listener listener; - - char *path; - char *display_name; - char *type; - char *description; - char *physical_uri; - char *physical_path; - - EStorageResultCallback callback; - void *callback_data; -}; -typedef struct _AsyncCreateFolderCallbackData AsyncCreateFolderCallbackData; - -static void -component_async_create_folder_callback (EvolutionShellComponentClient *shell_component_client, - EvolutionShellComponentResult result, - void *data) -{ - AsyncCreateFolderCallbackData *callback_data; - EStorageResult storage_result; - - callback_data = (AsyncCreateFolderCallbackData *) data; - - storage_result = shell_component_result_to_storage_result (result); - - if (result != EVOLUTION_SHELL_COMPONENT_OK) { - /* XXX: This assumes the component won't leave any files in the directory. */ - rmdir (callback_data->physical_path); - } else { - EFolder *folder; - - folder = e_local_folder_new (callback_data->display_name, - callback_data->type, - callback_data->description); - - e_folder_set_physical_uri (folder, callback_data->physical_uri); - - if (e_local_folder_save (E_LOCAL_FOLDER (folder))) { - new_folder (E_LOCAL_STORAGE (callback_data->storage), - callback_data->path, folder); - } else { - rmdir (callback_data->physical_path); - g_object_unref (folder); - storage_result = E_STORAGE_IOERROR; - } - } - - g_object_unref (shell_component_client); - - if (callback_data->listener != CORBA_OBJECT_NIL) - notify_listener (callback_data->listener, storage_result, - callback_data->physical_path); - - if (callback_data->callback != NULL) - (* callback_data->callback) (callback_data->storage, - storage_result, - callback_data->callback_data); - - g_free (callback_data->path); - g_free (callback_data->display_name); - g_free (callback_data->type); - g_free (callback_data->description); - g_free (callback_data->physical_uri); - g_free (callback_data->physical_path); - g_free (callback_data); -} - - -/* Implementation for the folder operations. */ - -static EStorageResult -create_folder_directory (ELocalStorage *local_storage, - const char *path, - const char *type, - const char *description, - char **physical_path_return) -{ - EStorage *storage; - ELocalStoragePrivate *priv; - char *parent_path; - char *physical_path; - - storage = E_STORAGE (local_storage); - priv = local_storage->priv; - - *physical_path_return = NULL; - g_assert (g_path_is_absolute (path)); - - parent_path = g_path_get_dirname(path); - - if (strlen(parent_path) > 1) { - char *subfolders_directory_physical_path; - char *parent; - - /* Create the `subfolders' subdirectory under the parent. */ - parent = g_strdup_printf ("%s/", parent_path); - subfolders_directory_physical_path = e_path_to_physical (priv->base_path, parent); - - if (mkdir (subfolders_directory_physical_path, 0700) == -1 && errno != EEXIST) { - g_free (subfolders_directory_physical_path); - g_free (parent); - return errno_to_storage_result (); - } - - g_free (subfolders_directory_physical_path); - g_free (parent); - } - - g_free (parent_path); - - physical_path = e_path_to_physical (priv->base_path, path); - - /* Create the directory that holds the folder. */ - - *physical_path_return = physical_path; - if (mkdir (physical_path, 0700) == -1) { - return errno_to_storage_result (); - } - - return E_STORAGE_OK; -} - -static void -create_folder (ELocalStorage *local_storage, - const Bonobo_Listener listener, - const char *path, - const char *type, - const char *description, - EStorageResultCallback callback, - void *data) -{ - EStorage *storage; - ELocalStoragePrivate *priv; - EvolutionShellComponentClient *component_client; - AsyncCreateFolderCallbackData *callback_data; - EStorageResult result; - char *folder_name; - char *physical_path; - char *physical_uri; - - storage = E_STORAGE (local_storage); - priv = local_storage->priv; - component_client = e_folder_type_registry_get_handler_for_type (priv->folder_type_registry, - type); - if (component_client == NULL) { - if (listener != CORBA_OBJECT_NIL) - notify_listener (listener, E_STORAGE_INVALIDTYPE, NULL); - if (callback != NULL) - (* callback) (storage, E_STORAGE_INVALIDTYPE, data); - return; - } - - g_assert (g_path_is_absolute (path)); - - result = create_folder_directory (local_storage, path, type, description, &physical_path); - if (result != E_STORAGE_OK) { - if (callback != NULL) - (* callback) (storage, result, data); - if (listener != CORBA_OBJECT_NIL) - notify_listener (listener, result, NULL); - - g_free (physical_path); - return; - } - - folder_name = g_path_get_basename (path); - - /* Finally tell the component to do the job of creating the physical files in it. */ - - /* FIXME: We should put the operations on a queue so that we can cancel them when - the ELocalStorage is destroyed. */ - - physical_uri = g_strconcat ("file://", physical_path, NULL); - - callback_data = g_new (AsyncCreateFolderCallbackData, 1); - callback_data->storage = E_STORAGE (local_storage); - callback_data->path = g_strdup (path); - callback_data->display_name = g_strdup (folder_name); - callback_data->type = g_strdup (type); - callback_data->description = g_strdup (description); - callback_data->physical_uri = physical_uri; - callback_data->physical_path = physical_path; - callback_data->listener = listener; - callback_data->callback = callback; - callback_data->callback_data = data; - - g_object_ref (component_client); - - evolution_shell_component_client_async_create_folder (component_client, - physical_uri, - type, - component_async_create_folder_callback, - callback_data); - - g_free (folder_name); -} - -struct _AsyncRemoveFolderCallbackData { - EStorage *storage; - GList *next_paths_to_delete; -}; -typedef struct _AsyncRemoveFolderCallbackData AsyncRemoveFolderCallbackData; - -static EStorageResult -remove_folder_directory (ELocalStorage *local_storage, - const char *path) -{ - EStorage *storage; - ELocalStoragePrivate *priv; - char *folder_name; - char *file_name; - char *physical_path; - - priv = local_storage->priv; - - storage = E_STORAGE (local_storage); - folder_name = g_path_get_basename (path); - - /* Delete the metadata file associated with this folder. */ - physical_path = e_path_to_physical (priv->base_path, path); - file_name = g_build_filename (physical_path, E_LOCAL_FOLDER_METADATA_FILE_NAME, NULL); - unlink (file_name); - g_free (file_name); - - /* Delete the physical directory. */ - if (rmdir (physical_path) == -1) { - g_free (physical_path); - g_free (folder_name); - return E_STORAGE_GENERICERROR; - } - - g_free (physical_path); - - /* Delete the 'subfolders' directory that this folder lies in */ - if (folder_name != path + 1) { - char *subfolders_directory_physical_path; - char *parent_path; - - parent_path = g_strndup (path, strlen (path) - strlen (folder_name)); - subfolders_directory_physical_path = e_path_to_physical (priv->base_path, parent_path); - g_free (parent_path); - - rmdir (subfolders_directory_physical_path); - g_free (subfolders_directory_physical_path); - } - - g_free (folder_name); - return E_STORAGE_OK; -} - -static gboolean remove_folder_step (AsyncRemoveFolderCallbackData *callback_data); - -static void -component_async_remove_folder_callback (EvolutionShellComponentClient *shell_component_client, - EvolutionShellComponentResult result, - void *data) -{ - ELocalStoragePrivate *priv; - AsyncRemoveFolderCallbackData *callback_data; - EStorageResult storage_result; - gboolean success; - const char *path; - - callback_data = (AsyncRemoveFolderCallbackData *) data; - priv = E_LOCAL_STORAGE (callback_data->storage)->priv; - path = (const char *) callback_data->next_paths_to_delete->data; - - storage_result = shell_component_result_to_storage_result (result); - - if (result == EVOLUTION_SHELL_COMPONENT_OK) { - result = remove_folder_directory (E_LOCAL_STORAGE (callback_data->storage), path); - e_storage_removed_folder (E_STORAGE (callback_data->storage), path); - evolution_storage_removed_folder (EVOLUTION_STORAGE (priv->bonobo_interface), path); - } else { - /* FIXME: Handle errors. */ - g_print ("...Error removing %s!\n", path); - } - - g_object_unref (shell_component_client); - - /* Now go on and delete the next subfolder in the list that still - exists, deallocating the elements in the list in the process. */ - do { - char *path; - - path = callback_data->next_paths_to_delete->data; - g_free (path); - - callback_data->next_paths_to_delete - = g_list_remove_link (callback_data->next_paths_to_delete, - callback_data->next_paths_to_delete); - - /* Check if we are done. */ - if (callback_data->next_paths_to_delete == NULL) { - g_free (callback_data); - return; - } - - /* Remove the folder; if the folder has disappeared from the - tree for some reason (this is an async callback!), just go - on with the next one. */ - success = remove_folder_step (callback_data); - } while (! success); -} - -static gboolean -remove_folder_step (AsyncRemoveFolderCallbackData *callback_data) -{ - EvolutionShellComponentClient *client; - ELocalStoragePrivate *priv; - EFolder *folder; - const char *path; - const char *type; - char *physical_path; - char *physical_uri; - - g_assert (callback_data->next_paths_to_delete != NULL); - path = (const char *) callback_data->next_paths_to_delete->data; - - folder = e_storage_get_folder (callback_data->storage, path); - if (folder == NULL) - return FALSE; - - priv = E_LOCAL_STORAGE (callback_data->storage)->priv; - - physical_path = e_path_to_physical (priv->base_path, path); - physical_uri = g_strconcat ("file://", physical_path, NULL); - - type = e_folder_get_type_string (folder); - client = e_folder_type_registry_get_handler_for_type (priv->folder_type_registry, type); - - g_object_ref (client); - - evolution_shell_component_client_async_remove_folder (client, physical_uri, type, - component_async_remove_folder_callback, - callback_data); - - g_free (physical_path); - g_free (physical_uri); - - return TRUE; -} - -static GList * -create_subfolder_list (ELocalStorage *local_storage, - const char *path) -{ - GList *subfolders; - GList *list; - GList *p; - - subfolders = e_storage_get_subfolder_paths (E_STORAGE (local_storage), path); - - list = NULL; - for (p = subfolders; p != NULL; p = p->next) { - char *path; - - path = (char *) p->data; - - list = g_list_concat (list, create_subfolder_list (local_storage, path)); - list = g_list_append (list, path); - } - - g_list_free (subfolders); - - return list; -} - -static EStorageResult -remove_folder (ELocalStorage *local_storage, - const char *path) -{ - ELocalStoragePrivate *priv; - EStorage *storage; - AsyncRemoveFolderCallbackData *callback_data; - EvolutionShellComponentClient *component_client; - EFolder *folder; - GList *next_paths_to_delete; - - priv = local_storage->priv; - - 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) - return E_STORAGE_INVALIDTYPE; - - next_paths_to_delete = create_subfolder_list (E_LOCAL_STORAGE (storage), path); - next_paths_to_delete = g_list_append (next_paths_to_delete, g_strdup (path)); - - callback_data = g_new (AsyncRemoveFolderCallbackData, 1); - callback_data->storage = E_STORAGE (local_storage); - callback_data->next_paths_to_delete = next_paths_to_delete; - - if (! remove_folder_step (callback_data)) { - /* Eek, something wacky happened. */ - return EVOLUTION_SHELL_COMPONENT_UNKNOWNERROR; - } - - return EVOLUTION_SHELL_COMPONENT_OK; -} - - -/* GtkObject methods. */ - -static void -impl_dispose (GObject *object) -{ - ELocalStorage *local_storage; - ELocalStoragePrivate *priv; - CORBA_Environment ev; - - local_storage = E_LOCAL_STORAGE (object); - priv = local_storage->priv; - - CORBA_exception_init (&ev); - - if (priv->folder_type_registry != NULL) { - g_object_unref (priv->folder_type_registry); - priv->folder_type_registry = NULL; - } - - if (priv->bonobo_interface != NULL) { - bonobo_object_unref (BONOBO_OBJECT (priv->bonobo_interface)); - priv->bonobo_interface = NULL; - } - - CORBA_exception_free (&ev); - - (* G_OBJECT_CLASS (parent_class)->dispose) (object); -} - -static void -impl_finalize (GObject *object) -{ - ELocalStorage *local_storage; - ELocalStoragePrivate *priv; - - local_storage = E_LOCAL_STORAGE (object); - priv = local_storage->priv; - - g_free (priv->base_path); - g_free (priv); - - (* G_OBJECT_CLASS (parent_class)->finalize) (object); -} - - -/* Creating folders. */ - -static void -impl_async_create_folder (EStorage *storage, - const char *path, - const char *type, - const char *description, - EStorageResultCallback callback, - void *data) -{ - ELocalStorage *local_storage; - - local_storage = E_LOCAL_STORAGE (storage); - - create_folder (local_storage, CORBA_OBJECT_NIL, path, type, description, callback, data); -} - - -/* Removing folders. */ - -static void -impl_async_remove_folder (EStorage *storage, - const char *path, - EStorageResultCallback callback, - void *data) -{ - ELocalStorage *local_storage; - EStorageResult result; - - local_storage = E_LOCAL_STORAGE (storage); - - result = remove_folder (local_storage, path); - - if (callback != NULL) - (* callback) (E_STORAGE (local_storage), result, data); -} - - - -/* Transferring folders. */ - -struct _XferItem { - char *source_path; - char *destination_path; -}; -typedef struct _XferItem XferItem; - -static XferItem * -xfer_item_new (char *source_path, - char *destination_path) -{ - XferItem *new; - - new = g_new (XferItem, 1); - new->source_path = source_path; - new->destination_path = destination_path; - - return new; -} - -static void -xfer_item_free (XferItem *item) -{ - g_free (item->source_path); - g_free (item->destination_path); - g_free (item); -} - -static void -append_xfer_item_list (EStorage *storage, - char *source_path, - char *destination_path, - GList **list) -{ - GList *subfolders; - GList *p; - - *list = g_list_prepend (*list, xfer_item_new (source_path, destination_path)); - - subfolders = e_storage_get_subfolder_paths (storage, source_path); - for (p = subfolders; p != NULL; p = p->next) { - char *base_name; - char *source_subpath; - char *destination_subpath; - - source_subpath = g_strdup ((const char *) p->data); - base_name = g_path_get_basename (source_subpath); - destination_subpath = g_build_filename (destination_path, base_name, NULL); - append_xfer_item_list (storage, source_subpath, destination_subpath, list); - g_free (base_name); - } - - e_free_string_list (subfolders); -} - -struct _XferData { - /* The storage on which we are performing the xfer operation. */ - ELocalStorage *local_storage; - - /* List of source/destination path couples to copy, in the right - order. */ - GList *folder_items; - - /* Pointer into `folder_items'. The folder item pointed by this is the - one handled by the previous CORBA invocation. */ - GList *current_folder_item; - - /* Whether we want to remove the source too. */ - gboolean remove_source; - - /* The callback, with its data. */ - EStorageResultCallback callback; - void *callback_data; -}; -typedef struct _XferData XferData; - -static void -async_xfer_folder_step (ELocalStorage *local_storage, - const char *source_path, - const char *destination_path, - gboolean remove_source, - EvolutionShellComponentClientCallback component_client_callback, - void *component_client_callback_data) -{ - ELocalStoragePrivate *priv; - EFolder *source_folder; - EvolutionShellComponentClient *component_client; - char *physical_path; - char *physical_uri; - - priv = local_storage->priv; - - source_folder = e_storage_get_folder (E_STORAGE (local_storage), source_path); - g_assert (source_folder != NULL); - - create_folder_directory (local_storage, destination_path, - e_folder_get_type_string (source_folder), - e_folder_get_description (source_folder), - &physical_path); - - physical_uri = g_strconcat ("file://", physical_path, NULL); - g_free (physical_path); - - component_client = e_folder_type_registry_get_handler_for_type (priv->folder_type_registry, - e_folder_get_type_string (source_folder)); - g_assert (component_client != NULL); - - evolution_shell_component_client_async_xfer_folder (component_client, - e_folder_get_physical_uri (source_folder), - physical_uri, - e_folder_get_type_string (source_folder), - remove_source, - component_client_callback, - component_client_callback_data); - g_free (physical_uri); -} - -static void -async_xfer_folder_complete (XferData *xfer_data, - gboolean success) -{ - ELocalStorage *local_storage; - GList *p; - - local_storage = xfer_data->local_storage; - - if (success && xfer_data->remove_source) { - EStorageResult result; - - /* Remove all the source physical directories, and also the - corresponding folders from the folder tree. */ - - for (p = g_list_last (xfer_data->folder_items); p != NULL; p = p->prev) { - XferItem *item; - - item = (XferItem *) p->data; - - result = remove_folder_directory (local_storage, item->source_path); - - /* FIXME handle failure differently? This should be n - unlikely situation. */ - if (result == E_STORAGE_OK) { - e_storage_removed_folder (E_STORAGE (local_storage), item->source_path); - - evolution_storage_removed_folder (EVOLUTION_STORAGE (local_storage->priv->bonobo_interface), - item->source_path); - } - } - } - - /* Free the data. */ - - for (p = xfer_data->folder_items; p != NULL; p = p->next) { - XferItem *item; - - item = (XferItem *) p->data; - xfer_item_free (item); - } - g_list_free (xfer_data->folder_items); - - g_free (xfer_data); -} - -static void -async_xfer_folder_callback (EvolutionShellComponentClient *shell_component_client, - EvolutionShellComponentResult result, - void *callback_data) -{ - XferData *xfer_data; - XferItem *item; - EFolder *source_folder; - EFolder *destination_folder; - char *dest_physical_path; - char *new_physical_uri; - - xfer_data = (XferData *) callback_data; - - item = (XferItem *) xfer_data->current_folder_item->data; - - if (result != EVOLUTION_SHELL_COMPONENT_OK) { - (* xfer_data->callback) (E_STORAGE (xfer_data->local_storage), - storage_result_from_component_result (result), - xfer_data->callback_data); - async_xfer_folder_complete (xfer_data, FALSE); - return; - } - - source_folder = e_storage_get_folder (E_STORAGE (xfer_data->local_storage), item->source_path); - destination_folder = e_local_folder_new (e_folder_get_name (source_folder), - e_folder_get_type_string (source_folder), - e_folder_get_description (source_folder)); - - dest_physical_path = e_path_to_physical (xfer_data->local_storage->priv->base_path, item->destination_path); - new_physical_uri = g_strconcat ("file://", dest_physical_path, NULL); - g_free (dest_physical_path); - e_folder_set_physical_uri (destination_folder, new_physical_uri); - g_free (new_physical_uri); - - e_local_folder_save (E_LOCAL_FOLDER (destination_folder)); /* FIXME check for errors */ - new_folder (xfer_data->local_storage, item->destination_path, destination_folder); - - xfer_data->current_folder_item = xfer_data->current_folder_item->next; - if (xfer_data->current_folder_item == NULL) { - (* xfer_data->callback) (E_STORAGE (xfer_data->local_storage), E_STORAGE_OK, xfer_data->callback_data); - async_xfer_folder_complete (xfer_data, TRUE); - return; - } - - item = (XferItem *) xfer_data->current_folder_item->data; - - async_xfer_folder_step (xfer_data->local_storage, - item->source_path, - item->destination_path, - xfer_data->remove_source, - async_xfer_folder_callback, - xfer_data); -} - -static void -impl_async_xfer_folder (EStorage *storage, - const char *source_path, - const char *destination_path, - gboolean remove_source, - EStorageResultCallback callback, - void *callback_data) -{ - ELocalStorage *local_storage; - ELocalStoragePrivate *priv; - XferData *xfer_data; - GList *folder_items; /* <XferItem> */ - XferItem *first_item; - - 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); - return; - } - - 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 */ - - xfer_data = g_new (XferData, 1); - xfer_data->local_storage = local_storage; - xfer_data->folder_items = folder_items; - xfer_data->current_folder_item = folder_items; - xfer_data->remove_source = remove_source; - xfer_data->callback = callback; - xfer_data->callback_data = callback_data; - - first_item = (XferItem *) xfer_data->folder_items->data; - - async_xfer_folder_step (E_LOCAL_STORAGE (storage), - first_item->source_path, - first_item->destination_path, - remove_source, - async_xfer_folder_callback, - xfer_data); -} - - -/* Callbacks for the `Evolution::Storage' interface we are exposing to the outside world. */ -static void -bonobo_interface_create_folder_cb (EvolutionStorage *storage, - const Bonobo_Listener listener, - const char *path, - const char *type, - const char *description, - const char *parent_physical_uri, - void *data) -{ - ELocalStorage *local_storage; - - local_storage = E_LOCAL_STORAGE (data); - - create_folder (local_storage, listener, path, type, description, NULL, NULL); -} - -static int -bonobo_interface_remove_folder_cb (EvolutionStorage *storage, - const Bonobo_Listener listener, - const char *path, - const char *physical_uri, - void *data) -{ - ELocalStorage *local_storage; - - local_storage = E_LOCAL_STORAGE (data); - - return remove_folder (local_storage, path); -} - -static void -bonobo_interface_update_folder_cb (EvolutionStorage *storage, - const char *path, - int unread_count, - void *data) -{ - ELocalStorage *local_storage; - EFolder *folder; - - local_storage = E_LOCAL_STORAGE (data); - - folder = e_storage_get_folder (E_STORAGE (local_storage), path); - if (folder == NULL) - return; - - e_folder_set_unread_count (folder, unread_count); - return; -} - - -/* Initialization. */ - -static void -class_init (ELocalStorageClass *class) -{ - EStorageClass *storage_class; - GObjectClass *object_class; - - parent_class = g_type_class_ref(e_storage_get_type ()); - - object_class = G_OBJECT_CLASS (class); - storage_class = E_STORAGE_CLASS (class); - - object_class->finalize = impl_finalize; - object_class->dispose = impl_dispose; - - storage_class->async_create_folder = impl_async_create_folder; - storage_class->async_remove_folder = impl_async_remove_folder; - storage_class->async_xfer_folder = impl_async_xfer_folder; -} - -static void -init (ELocalStorage *local_storage) -{ - ELocalStoragePrivate *priv; - - priv = g_new (ELocalStoragePrivate, 1); - - priv->base_path = NULL; - priv->folder_type_registry = NULL; - priv->bonobo_interface = NULL; - - local_storage->priv = priv; -} - - -static gboolean -construct (ELocalStorage *local_storage, - EFolderTypeRegistry *folder_type_registry, - const char *base_path) -{ - ELocalStoragePrivate *priv; - EFolder *root_folder; - int base_path_len; - char *uri; - - root_folder = e_folder_new (_("Local Folders"), "noselect", ""); - uri = g_strdup_printf("file://%s;noselect", base_path); - e_folder_set_physical_uri(root_folder, uri); - g_free(uri); - e_storage_construct (E_STORAGE (local_storage), - E_LOCAL_STORAGE_NAME, - root_folder); - - priv = local_storage->priv; - - base_path_len = strlen (base_path); - while (base_path_len > 0 && base_path[base_path_len - 1] == E_PATH_SEPARATOR) - base_path_len--; - - g_return_val_if_fail (base_path_len != 0, FALSE); - - g_assert (priv->folder_type_registry == NULL); - g_object_ref (folder_type_registry); - priv->folder_type_registry = folder_type_registry; - - g_assert (priv->base_path == NULL); - priv->base_path = g_strndup (base_path, base_path_len); - - g_assert (priv->bonobo_interface == NULL); - priv->bonobo_interface = evolution_storage_new (E_LOCAL_STORAGE_NAME, FALSE); - - g_signal_connect (priv->bonobo_interface, "create_folder", - G_CALLBACK (bonobo_interface_create_folder_cb), - local_storage); - g_signal_connect (priv->bonobo_interface, "remove_folder", - G_CALLBACK (bonobo_interface_remove_folder_cb), - local_storage); - g_signal_connect (priv->bonobo_interface, "update_folder", - G_CALLBACK (bonobo_interface_update_folder_cb), - local_storage); - - return load_all_folders (local_storage); -} - -EStorage * -e_local_storage_open (EFolderTypeRegistry *folder_type_registry, - const char *base_path) -{ - EStorage *new; - - g_return_val_if_fail (folder_type_registry != NULL, NULL); - g_return_val_if_fail (E_IS_FOLDER_TYPE_REGISTRY (folder_type_registry), NULL); - g_return_val_if_fail (base_path != NULL, NULL); - - new = g_object_new (e_local_storage_get_type (), NULL); - - if (! construct (E_LOCAL_STORAGE (new), folder_type_registry, base_path)) { - g_object_unref (new); - return NULL; - } - - return new; -} - -const char * -e_local_storage_get_base_path (ELocalStorage *local_storage) -{ - g_return_val_if_fail (local_storage != NULL, NULL); - g_return_val_if_fail (E_IS_LOCAL_STORAGE (local_storage), NULL); - - return local_storage->priv->base_path; -} - - -const GNOME_Evolution_Storage -e_local_storage_get_corba_interface (ELocalStorage *local_storage) -{ - ELocalStoragePrivate *priv; - 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); - - priv = local_storage->priv; - corba_interface = bonobo_object_corba_objref (BONOBO_OBJECT (priv->bonobo_interface)); - - return corba_interface; -} - - -E_MAKE_TYPE (e_local_storage, "ELocalStorage", ELocalStorage, class_init, init, PARENT_TYPE) diff --git a/shell/e-local-storage.h b/shell/e-local-storage.h deleted file mode 100644 index c640c29b70..0000000000 --- a/shell/e-local-storage.h +++ /dev/null @@ -1,67 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-local-storage.h - * - * Copyright (C) 2000, 2001 Ximian, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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 _E_LOCAL_STORAGE_H_ -#define _E_LOCAL_STORAGE_H_ - -#include "e-folder-type-registry.h" -#include "e-storage.h" - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - -#define E_TYPE_LOCAL_STORAGE (e_local_storage_get_type ()) -#define E_LOCAL_STORAGE(obj) (GTK_CHECK_CAST ((obj), E_TYPE_LOCAL_STORAGE, ELocalStorage)) -#define E_LOCAL_STORAGE_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_TYPE_LOCAL_STORAGE, ELocalStorageClass)) -#define E_IS_LOCAL_STORAGE(obj) (GTK_CHECK_TYPE ((obj), E_TYPE_LOCAL_STORAGE)) -#define E_IS_LOCAL_STORAGE_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), E_TYPE_LOCAL_STORAGE)) - -typedef struct _ELocalStorage ELocalStorage; -typedef struct _ELocalStoragePrivate ELocalStoragePrivate; -typedef struct _ELocalStorageClass ELocalStorageClass; - -struct _ELocalStorage { - EStorage parent; - - ELocalStoragePrivate *priv; -}; - -struct _ELocalStorageClass { - EStorageClass parent_class; -}; - - -GtkType e_local_storage_get_type (void); - -EStorage *e_local_storage_open (EFolderTypeRegistry *folder_type_registry, - const char *base_path); -const char *e_local_storage_get_base_path (ELocalStorage *storage); - -const GNOME_Evolution_Storage e_local_storage_get_corba_interface (ELocalStorage *storage); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* __E_LOCAL_STORAGE_H__ */ diff --git a/shell/e-setup.c b/shell/e-setup.c index b152afb5ac..200528e6b7 100644 --- a/shell/e-setup.c +++ b/shell/e-setup.c @@ -27,7 +27,6 @@ #include "e-setup.h" -#include "e-local-folder.h" #include "e-shell-constants.h" #include "e-util/e-dialog-utils.h" diff --git a/shell/e-shell-folder-selection-dialog.c b/shell/e-shell-folder-selection-dialog.c deleted file mode 100644 index 0715a1d9ae..0000000000 --- a/shell/e-shell-folder-selection-dialog.c +++ /dev/null @@ -1,548 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-shell-folder-selection-dialog.c - * - * Copyright (C) 2000, 2001 Ximian, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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 "e-shell-folder-selection-dialog.h" - -#include "e-shell-constants.h" -#include "e-shell-marshal.h" -#include "e-storage-set-view.h" -#include "e-storage-set.h" - -#include "e-shell-folder-creation-dialog.h" - -#include <libgnome/gnome-i18n.h> - -#include <gal/util/e-util.h> -#include <gal/widgets/e-gui-utils.h> - -#include <gtk/gtksignal.h> -#include <gtk/gtklabel.h> -#include <gtk/gtkstock.h> -#include <gtk/gtkscrolledwindow.h> - -#include <string.h> - - -#define PARENT_TYPE (gtk_dialog_get_type ()) -static GtkDialogClass *parent_class = NULL; - -struct _EShellFolderSelectionDialogPrivate { - EShell *shell; - GList *allowed_types; - EStorageSet *storage_set; - GtkWidget *storage_set_view; - - gboolean allow_creation; -}; - -enum { - FOLDER_SELECTED, - CANCELLED, - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL] = { 0 }; - -enum { - RESPONSE_NEW -}; - - -/* Utility functions. */ - -static gboolean -check_folder_type_valid (EShellFolderSelectionDialog *folder_selection_dialog) -{ - EShellFolderSelectionDialogPrivate *priv; - const char *selected_path; - EFolder *folder; - const char *folder_type; - GList *p; - - priv = folder_selection_dialog->priv; - if (priv->allowed_types == NULL) - return TRUE; - - selected_path = e_shell_folder_selection_dialog_get_selected_path (folder_selection_dialog); - if (selected_path == NULL) - return FALSE; - - folder = e_storage_set_get_folder (priv->storage_set, selected_path); - if (folder == NULL) - return FALSE; - - folder_type = e_folder_get_type_string (folder); - - for (p = priv->allowed_types; p != NULL; p = p->next) { - const char *type, *slash; - - type = (const char *) p->data; - if (strcmp (folder_type, type) == 0) - return TRUE; - slash = strchr (type, '/'); - if (slash && slash[1] == '*' && strncmp (folder_type, type, slash - type) == 0) - return TRUE; - } - - return FALSE; -} - -static void -set_default_folder (EShellFolderSelectionDialog *shell_folder_selection_dialog, - const char *default_uri) -{ - EShellFolderSelectionDialogPrivate *priv; - char *default_path; - - g_assert (default_uri != NULL); - - priv = shell_folder_selection_dialog->priv; - - if (strncmp (default_uri, E_SHELL_URI_PREFIX, E_SHELL_URI_PREFIX_LEN) == 0) { - /* `evolution:' URI. */ - default_path = g_strdup (default_uri + E_SHELL_URI_PREFIX_LEN); - } else { - /* Physical URI. */ - default_path = e_storage_set_get_path_for_physical_uri (priv->storage_set, - default_uri); - } - - e_storage_set_view_set_current_folder (E_STORAGE_SET_VIEW (priv->storage_set_view), - default_path); - - g_free (default_path); -} - - -/* Folder creation dialog callback. */ - -static void -folder_creation_dialog_result_cb (EShell *shell, - EShellFolderCreationDialogResult result, - const char *path, - void *data) -{ - EShellFolderSelectionDialog *dialog; - EShellFolderSelectionDialogPrivate *priv; - - dialog = E_SHELL_FOLDER_SELECTION_DIALOG (data); - priv = dialog->priv; - - if (priv == NULL) { - g_warning ("dialog->priv is NULL, and should not be"); - return; - } - - if (result == E_SHELL_FOLDER_CREATION_DIALOG_RESULT_SUCCESS) - e_storage_set_view_set_current_folder (E_STORAGE_SET_VIEW (priv->storage_set_view), - path); -} - - -/* GtkObject methods. */ - -/* Saves the expanded state of the tree to a common filename */ -static void -save_expanded_state (EShellFolderSelectionDialog *folder_selection_dialog) -{ - EShellFolderSelectionDialogPrivate *priv; - char *filename; - - priv = folder_selection_dialog->priv; - - filename = g_strdup_printf ("%s/config/storage-set-view-expanded:folder-selection-dialog", - e_shell_get_local_directory (priv->shell)); - e_tree_save_expanded_state (E_TREE (priv->storage_set_view), filename); - g_free (filename); -} - -static void -impl_dispose (GObject *object) -{ - EShellFolderSelectionDialog *folder_selection_dialog; - EShellFolderSelectionDialogPrivate *priv; - - folder_selection_dialog = E_SHELL_FOLDER_SELECTION_DIALOG (object); - priv = folder_selection_dialog->priv; - - if (priv->storage_set != NULL) { - save_expanded_state (folder_selection_dialog); - g_object_unref (priv->storage_set); - priv->storage_set = NULL; - } - - if (priv->shell != NULL) { - g_object_weak_unref (G_OBJECT (priv->shell), (GWeakNotify) gtk_widget_destroy, folder_selection_dialog); - priv->shell = NULL; - } - - (* G_OBJECT_CLASS (parent_class)->dispose) (object); -} - -static void -impl_finalize (GObject *object) -{ - EShellFolderSelectionDialog *folder_selection_dialog; - EShellFolderSelectionDialogPrivate *priv; - - folder_selection_dialog = E_SHELL_FOLDER_SELECTION_DIALOG (object); - priv = folder_selection_dialog->priv; - - e_free_string_list (priv->allowed_types); - - g_free (priv); - - (* G_OBJECT_CLASS (parent_class)->finalize) (object); -} - - -/* GtkDialog methods. */ - -static void -impl_response (GtkDialog *dialog, - int response) -{ - EShellFolderSelectionDialog *folder_selection_dialog; - EShellFolderSelectionDialogPrivate *priv; - EStorageSetView *storage_set_view; - const char *default_parent_folder; - const char *default_subtype; - char *default_type; - - folder_selection_dialog = E_SHELL_FOLDER_SELECTION_DIALOG (dialog); - priv = folder_selection_dialog->priv; - - switch (response) { - case GTK_RESPONSE_OK: - if (check_folder_type_valid (folder_selection_dialog)) { - g_signal_emit (folder_selection_dialog, signals[FOLDER_SELECTED], 0, - e_shell_folder_selection_dialog_get_selected_path (folder_selection_dialog)); - gtk_widget_destroy (GTK_WIDGET (dialog)); - } - break; - - case GTK_RESPONSE_CANCEL: - case GTK_RESPONSE_DELETE_EVENT: - g_signal_emit (folder_selection_dialog, signals[CANCELLED], 0); - gtk_widget_destroy (GTK_WIDGET (dialog)); - break; - - case RESPONSE_NEW: - storage_set_view = E_STORAGE_SET_VIEW (priv->storage_set_view); - default_parent_folder = e_storage_set_view_get_current_folder (storage_set_view); - - /* The default type in the folder creation dialog will be the - first of the allowed types. If all types are allowed, - hardcode to "mail". */ - if (priv->allowed_types == NULL) - default_type = g_strdup ("mail"); - else { - default_subtype = (const char *) priv->allowed_types->data; - default_type = g_strndup (default_subtype, - strcspn (default_subtype, "/")); - } - - e_shell_show_folder_creation_dialog (priv->shell, GTK_WINDOW (dialog), - default_parent_folder, - default_type, - folder_creation_dialog_result_cb, - dialog); - g_free (default_type); - - break; - } -} - - -/* GTK+ type initialization. */ - -static void -class_init (EShellFolderSelectionDialogClass *klass) -{ - GObjectClass *object_class; - GtkDialogClass *dialog_class; - - parent_class = g_type_class_ref(PARENT_TYPE); - object_class = G_OBJECT_CLASS (klass); - dialog_class = GTK_DIALOG_CLASS (klass); - - object_class->dispose = impl_dispose; - object_class->finalize = impl_finalize; - - dialog_class->response = impl_response; - - signals[FOLDER_SELECTED] - = g_signal_new ("folder_selected", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (EShellFolderSelectionDialogClass, folder_selected), - NULL, NULL, - e_shell_marshal_NONE__STRING, - G_TYPE_NONE, 1, - G_TYPE_STRING); - - signals[CANCELLED] - = g_signal_new ("cancelled", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (EShellFolderSelectionDialogClass, cancelled), - NULL, NULL, - e_shell_marshal_NONE__NONE, - G_TYPE_NONE, 0); -} - -static void -init (EShellFolderSelectionDialog *shell_folder_selection_dialog) -{ - EShellFolderSelectionDialogPrivate *priv; - - priv = g_new (EShellFolderSelectionDialogPrivate, 1); - priv->shell = NULL; - priv->storage_set = NULL; - priv->storage_set_view = NULL; - priv->allowed_types = NULL; - priv->allow_creation = TRUE; - - shell_folder_selection_dialog->priv = priv; -} - - -/* ETable callbacks. */ - -static void -folder_selected_cb (EStorageSetView *storage_set_view, - const char *path, - void *data) -{ - EShellFolderSelectionDialog *dialog; - - dialog = E_SHELL_FOLDER_SELECTION_DIALOG (data); - - if (check_folder_type_valid (dialog)) - gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog), GTK_RESPONSE_OK, TRUE); - else - gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog), GTK_RESPONSE_OK, FALSE); -} - -static void -double_click_cb (EStorageSetView *essv, - int row, - ETreePath path, - int col, - GdkEvent *event, - EShellFolderSelectionDialog *folder_selection_dialog) -{ - g_return_if_fail (folder_selection_dialog != NULL); - - if (check_folder_type_valid (folder_selection_dialog)) { - g_signal_emit (folder_selection_dialog, signals[FOLDER_SELECTED], 0, - e_shell_folder_selection_dialog_get_selected_path (folder_selection_dialog)); - gtk_widget_destroy (GTK_WIDGET (folder_selection_dialog)); - } -} - - -/** - * e_shell_folder_selection_dialog_construct: - * @folder_selection_dialog: A folder selection dialog widget - * @shell: The this folder selection dialog is for - * @title: Title of the window - * @caption: A brief text to be put on top of the storage view - * @default_uri: The URI of the folder to be selected by default - * @allowed_types: List of the names of the allowed types - * - * Construct @folder_selection_dialog. - **/ -void -e_shell_folder_selection_dialog_construct (EShellFolderSelectionDialog *folder_selection_dialog, - EShell *shell, - const char *title, - const char *caption, - const char *default_uri, - const char *allowed_types[], - gboolean allow_creation) -{ - EShellFolderSelectionDialogPrivate *priv; - GtkWidget *scrolled_window; - GtkWidget *caption_label; - int i; - char *filename; - - g_return_if_fail (folder_selection_dialog != NULL); - g_return_if_fail (E_IS_SHELL_FOLDER_SELECTION_DIALOG (folder_selection_dialog)); - g_return_if_fail (shell != NULL); - g_return_if_fail (E_IS_SHELL (shell)); - - priv = folder_selection_dialog->priv; - - /* Basic dialog setup. */ - - gtk_window_set_default_size (GTK_WINDOW (folder_selection_dialog), 350, 300); - gtk_window_set_modal (GTK_WINDOW (folder_selection_dialog), TRUE); - gtk_window_set_title (GTK_WINDOW (folder_selection_dialog), title); - gtk_container_set_border_width (GTK_CONTAINER (folder_selection_dialog), 6); - - if (allow_creation) - gtk_dialog_add_buttons (GTK_DIALOG (folder_selection_dialog), - GTK_STOCK_NEW, RESPONSE_NEW, - NULL); - - gtk_dialog_add_buttons (GTK_DIALOG (folder_selection_dialog), - GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, - GTK_STOCK_OK, GTK_RESPONSE_OK, - NULL); - - gtk_dialog_set_response_sensitive (GTK_DIALOG (folder_selection_dialog), GTK_RESPONSE_OK, FALSE); - gtk_dialog_set_default_response (GTK_DIALOG (folder_selection_dialog), GTK_RESPONSE_OK); - - /* Make sure we get destroyed if the shell gets destroyed. */ - - priv->shell = shell; - g_object_weak_ref (G_OBJECT (shell), (GWeakNotify) gtk_widget_destroy, folder_selection_dialog); - - /* Set up the label. */ - - if (caption != NULL) { - caption_label = gtk_label_new (caption); - gtk_label_set_justify (GTK_LABEL (caption_label), GTK_JUSTIFY_LEFT); - gtk_widget_show (caption_label); - - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (folder_selection_dialog)->vbox), - caption_label, FALSE, TRUE, 6); - gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (folder_selection_dialog)->vbox), - 6); - - - } - - /* Set up the storage set and its view. */ - - priv->storage_set = e_shell_get_storage_set (shell); - g_object_ref (priv->storage_set); - - priv->storage_set_view = e_storage_set_create_new_view (priv->storage_set, NULL); - e_storage_set_view_set_allow_dnd (E_STORAGE_SET_VIEW (priv->storage_set_view), FALSE); - e_storage_set_view_enable_search (E_STORAGE_SET_VIEW (priv->storage_set_view), TRUE); - - /* Load the expanded state for this StorageSetView */ - filename = g_strdup_printf ("%s/config/storage-set-view-expanded:folder-selection-dialog", - e_shell_get_local_directory (priv->shell)); - - e_tree_load_expanded_state (E_TREE (priv->storage_set_view), - filename); - - g_free (filename); - - g_signal_connect (priv->storage_set_view, "double_click", G_CALLBACK (double_click_cb), folder_selection_dialog); - g_signal_connect (priv->storage_set_view, "folder_selected", G_CALLBACK (folder_selected_cb), folder_selection_dialog); - - g_assert (priv->allowed_types == NULL); - if (allowed_types != NULL) { - for (i = 0; allowed_types[i] != NULL; i++) - priv->allowed_types = g_list_prepend (priv->allowed_types, - g_strdup (allowed_types[i])); - - /* Preserve the order so we can use the first type listed as - the default for the folder creation dialog invoked by the - "New..." button. */ - priv->allowed_types = g_list_reverse (priv->allowed_types); - } - - if (default_uri != NULL) - set_default_folder (folder_selection_dialog, default_uri); - - scrolled_window = gtk_scrolled_window_new (NULL, NULL); - gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_window), GTK_SHADOW_IN); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), - GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - - gtk_container_add (GTK_CONTAINER (scrolled_window), priv->storage_set_view); - - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (folder_selection_dialog)->vbox), - scrolled_window, TRUE, TRUE, 6); - gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (folder_selection_dialog)->vbox), 6); - - gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (folder_selection_dialog)->vbox), 6); - - gtk_widget_show (priv->storage_set_view); - gtk_widget_show (scrolled_window); - - GTK_WIDGET_SET_FLAGS (priv->storage_set_view, GTK_CAN_FOCUS); - gtk_widget_grab_focus (priv->storage_set_view); -} - -/** - * e_shell_folder_selection_dialog_new: - * @shell: The this folder selection dialog is for - * @title: Title of the window - * @caption: A brief text to be put on top of the storage view - * @default_uri: The URI of the folder to be selected by default - * @allowed_types: List of the names of the allowed types - * - * Create a new folder selection dialog widget. @default_uri can be either an - * `evolution:' URI or a physical URI (all the non-`evolution:' URIs are - * considered to be physical URIs). - * - * Return value: - **/ -GtkWidget * -e_shell_folder_selection_dialog_new (EShell *shell, - const char *title, - const char *caption, - const char *default_uri, - const char *allowed_types[], - gboolean allow_creation) -{ - EShellFolderSelectionDialog *folder_selection_dialog; - - g_return_val_if_fail (shell != NULL, NULL); - g_return_val_if_fail (E_IS_SHELL (shell), NULL); - - folder_selection_dialog = g_object_new (e_shell_folder_selection_dialog_get_type (), NULL); - e_shell_folder_selection_dialog_construct (folder_selection_dialog, shell, - title, caption, default_uri, allowed_types, - allow_creation); - - return GTK_WIDGET (folder_selection_dialog); -} - - -const char * -e_shell_folder_selection_dialog_get_selected_path (EShellFolderSelectionDialog *folder_selection_dialog) -{ - EShellFolderSelectionDialogPrivate *priv; - - g_return_val_if_fail (folder_selection_dialog != NULL, NULL); - g_return_val_if_fail (E_IS_SHELL_FOLDER_SELECTION_DIALOG (folder_selection_dialog), NULL); - - priv = folder_selection_dialog->priv; - - return e_storage_set_view_get_current_folder (E_STORAGE_SET_VIEW (priv->storage_set_view)); -} - - -E_MAKE_TYPE (e_shell_folder_selection_dialog, "EShellFolderSelectionDialog", EShellFolderSelectionDialog, - class_init, init, PARENT_TYPE) diff --git a/shell/e-shell-folder-selection-dialog.h b/shell/e-shell-folder-selection-dialog.h deleted file mode 100644 index 05b1e46281..0000000000 --- a/shell/e-shell-folder-selection-dialog.h +++ /dev/null @@ -1,82 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-shell-folder-selection-dialog.h - * - * Copyright (C) 2000 Ximian, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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 E_SHELL_FOLDER_SELECTION_DIALOG_H -#define E_SHELL_FOLDER_SELECTION_DIALOG_H - -#include <gtk/gtkdialog.h> - -#include "e-shell.h" - -#ifdef cplusplus -extern "C" { -#pragma } -#endif /* cplusplus */ - -#define E_TYPE_SHELL_FOLDER_SELECTION_DIALOG (e_shell_folder_selection_dialog_get_type ()) -#define E_SHELL_FOLDER_SELECTION_DIALOG(obj) (GTK_CHECK_CAST ((obj), E_TYPE_SHELL_FOLDER_SELECTION_DIALOG, EShellFolderSelectionDialog)) -#define E_SHELL_FOLDER_SELECTION_DIALOG_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_TYPE_SHELL_FOLDER_SELECTION_DIALOG, EShellFolderSelectionDialogClass)) -#define E_IS_SHELL_FOLDER_SELECTION_DIALOG(obj) (GTK_CHECK_TYPE ((obj), E_TYPE_SHELL_FOLDER_SELECTION_DIALOG)) -#define E_IS_SHELL_FOLDER_SELECTION_DIALOG_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), E_TYPE_SHELL_FOLDER_SELECTION_DIALOG)) - - -typedef struct _EShellFolderSelectionDialog EShellFolderSelectionDialog; -typedef struct _EShellFolderSelectionDialogPrivate EShellFolderSelectionDialogPrivate; -typedef struct _EShellFolderSelectionDialogClass EShellFolderSelectionDialogClass; - -struct _EShellFolderSelectionDialog { - GtkDialog parent; - - EShellFolderSelectionDialogPrivate *priv; -}; - -struct _EShellFolderSelectionDialogClass { - GtkDialogClass parent_class; - - void (* folder_selected) (EShellFolderSelectionDialog *folder_selection_dialog, - const char *path); - void (* cancelled) (EShellFolderSelectionDialog *folder_selection_dialog); -}; - - -GtkType e_shell_folder_selection_dialog_get_type (void); -void e_shell_folder_selection_dialog_construct (EShellFolderSelectionDialog *folder_selection_dialog, - EShell *shell, - const char *title, - const char *caption, - const char *default_uri, - const char *allowed_types[], - gboolean allow_creation); -GtkWidget *e_shell_folder_selection_dialog_new (EShell *shell, - const char *title, - const char *caption, - const char *default_uri, - const char *allowed_types[], - gboolean allow_creation); - -const char *e_shell_folder_selection_dialog_get_selected_path (EShellFolderSelectionDialog *folder_selection_dialog); - -#ifdef cplusplus -} -#endif /* cplusplus */ - -#endif /* E_SHELL_FOLDER_SELECTION_DIALOG_H */ diff --git a/shell/e-shell-view.c b/shell/e-shell-view.c deleted file mode 100644 index ba94aa0ed3..0000000000 --- a/shell/e-shell-view.c +++ /dev/null @@ -1,2948 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-shell-view.c - * - * Copyright (C) 2000, 2001, 2002 Ximian, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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. - * - * Authors: - * Ettore Perazzoli <ettore@ximian.com> - * Miguel de Icaza <miguel@ximian.com> - * Matt Loper <matt@ximian.com> - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include "e-shell-view.h" - -#include "evolution-shell-view.h" - -#include "e-shell-marshal.h" - -#include "e-history.h" -#include "e-icon-factory.h" -#include "e-shell-constants.h" -#include "e-shell-folder-title-bar.h" -#include "e-shell-utils.h" -#include "e-shell-view-menu.h" -#include "e-shell.h" -#include "e-shortcuts-view.h" -#include "e-storage-set-view.h" -#include "e-title-bar.h" - -#include "e-util/e-gtk-utils.h" - -#include "widgets/misc/e-clipped-label.h" - -#include <gtk/gtkwidget.h> - -#include <sys/stat.h> -#include <sys/types.h> -#include <fcntl.h> -#include <ctype.h> -#include <string.h> - -#include <glib.h> - -#include <libgnome/libgnome.h> -#include <libgnomeui/gnome-window.h> -#include <libgnomeui/gnome-window-icon.h> -#include <libgnomeui/gnome-app.h> - -#include <gtk/gtkscrolledwindow.h> -#include <gconf/gconf-client.h> - -#include <bonobo/bonobo-exception.h> -#include <bonobo/bonobo-socket.h> -#include <bonobo/bonobo-ui-util.h> -#include <bonobo/bonobo-ui-container.h> -#include <bonobo/bonobo-ui-engine.h> -#include <bonobo/bonobo-widget.h> -#include <bonobo/bonobo-window.h> - -#include <gal/util/e-util.h> -#include <gal/widgets/e-gui-utils.h> - -static BonoboWindowClass *parent_class = NULL; - -struct _View { - char *uri; - GtkWidget *control; - EFolder *folder; -}; -typedef struct _View View; - -struct _EShellViewPrivate { - /* The shell. */ - EShell *shell; - - /* EvolutionShellView Bonobo object for implementing the - Evolution::ShellView interface. */ - GNOME_Evolution_ShellView corba_interface; - - /* The UI handler & container. */ - BonoboUIComponent *ui_component; - BonoboUIContainer *ui_container; - - /* History of visited (evolution:) URIs. */ - EHistory *history; - - /* Currently displayed URI. */ - char *uri; - - /* Delayed selection, used when a path doesn't exist in an EStorage. - Cleared when we're signaled with "folder_selected". */ - char *delayed_selection; - - /* uri to go to at timeout */ - unsigned int set_folder_timeout; - char *set_folder_uri; - - /* Tooltips. */ - GtkTooltips *tooltips; - - /* The widgetry. */ - GtkWidget *appbar; - GtkWidget *hpaned; - GtkWidget *view_vbox; - GtkWidget *folder_title_bar; - GtkWidget *view_hpaned; - GtkWidget *contents; - GtkWidget *notebook; - GtkWidget *shortcut_frame; - GtkWidget *shortcut_bar; - GtkWidget *storage_set_title_bar; - GtkWidget *storage_set_view; - GtkWidget *storage_set_view_box; - - /* The status bar widgetry. */ - GtkWidget *status_bar; - GtkWidget *offline_toggle; - GtkWidget *offline_toggle_image; - GtkWidget *menu_hint_label; - GtkWidget *task_bar; - - /* The pop-up window for the folder-tree (i.e. the one we create when - the user clicks on the folder title. */ - GtkWidget *folder_bar_popup; - - /* The views we have already open. */ - GHashTable *uri_to_view; - - /* Position of the handles in the paneds, to be restored when we show elements - after hiding them. */ - unsigned int hpaned_position; - unsigned int view_hpaned_position; - - /* Whether the shortcut and folder bars are visible or not. */ - unsigned int shortcut_bar_shown : 1; - unsigned int folder_bar_shown : 1; - - /* List of sockets we created. */ - GList *sockets; -}; - -enum { - SHORTCUT_BAR_VISIBILITY_CHANGED, - FOLDER_BAR_VISIBILITY_CHANGED, - VIEW_CHANGED, - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL] = { 0 }; - -#define DEFAULT_SHORTCUT_BAR_WIDTH 100 - -#define DEFAULT_TREE_WIDTH 130 -#define MIN_POPUP_TREE_WIDTH 130 - -#define DEFAULT_WIDTH 705 -#define DEFAULT_HEIGHT 550 - -#define SET_FOLDER_DELAY 250 - -/* URI to display when the currently displayed folder is removed from the - storage. */ -#define FALLBACK_URI E_SUMMARY_URI - - -/* The icons for the offline/online status. */ - -static GdkPixmap *offline_pixmap = NULL; -static GdkBitmap *offline_mask = NULL; - -static GdkPixmap *online_pixmap = NULL; -static GdkBitmap *online_mask = NULL; - - -static void update_for_current_uri (EShellView *shell_view); -static void update_offline_toggle_status (EShellView *shell_view); -static void update_send_receive_sensitivity (EShellView *shell_view); -static const char *get_storage_set_path_from_uri (const char *uri); - - -/* Boo. */ -static void new_folder_cb (EStorageSet *storage_set, const char *path, void *data); -static gboolean display_uri (EShellView *shell_view, const char *uri, - gboolean add_to_history, gboolean queue); - - -/* View handling. */ - -static View * -view_new (const char *uri, - GtkWidget *control) -{ - View *new; - - new = g_new (View, 1); - new->uri = g_strdup (uri); - new->control = control; - - return new; -} - -static void -view_destroy (View *view) -{ - g_free (view->uri); - g_free (view); -} - - -/* Utility functions. */ - -static void -update_other_users_folder_items_sensitivity (EShellView *shell_view) -{ - EShellViewPrivate *priv = shell_view->priv; - gboolean a_storage_supports_shared_folders; - GList *storage_list, *p; - - storage_list = e_storage_set_get_storage_list (e_shell_get_storage_set (priv->shell)); - a_storage_supports_shared_folders = FALSE; - for (p = storage_list; p != NULL; p = p->next) { - if (e_storage_supports_shared_folders (E_STORAGE (p->data))) - a_storage_supports_shared_folders = TRUE; - } - - if (a_storage_supports_shared_folders) { - bonobo_ui_component_set_prop (priv->ui_component, "/commands/FileOpenOtherUsersFolder", - "sensitive", "1", NULL); - bonobo_ui_component_set_prop (priv->ui_component, "/commands/FileRemoveOtherUsersFolder", - "sensitive", "1", NULL); - } else { - bonobo_ui_component_set_prop (priv->ui_component, "/commands/FileOpenOtherUsersFolder", - "sensitive", "0", NULL); - bonobo_ui_component_set_prop (priv->ui_component, "/commands/FileRemoveOtherUsersFolder", - "sensitive", "0", NULL); - } - - g_list_foreach (storage_list, (GFunc) g_object_unref, NULL); - g_list_free (storage_list); -} - -static GtkWidget * -create_label_for_empty_page (void) -{ - GtkWidget *label; - - label = e_clipped_label_new (_("(No folder displayed)"), PANGO_WEIGHT_NORMAL, 1.0); - gtk_widget_show (label); - - return label; -} - -/* Initialize the icons. */ -static void -load_images (void) -{ - GdkPixbuf *pixbuf; - - pixbuf = gdk_pixbuf_new_from_file (EVOLUTION_IMAGES "/offline.png", NULL); - if (pixbuf == NULL) { - g_warning ("Cannot load `%s'", EVOLUTION_IMAGES "/offline.png"); - } else { - gdk_pixbuf_render_pixmap_and_mask (pixbuf, &offline_pixmap, &offline_mask, 128); - g_object_unref (pixbuf); - } - - pixbuf = gdk_pixbuf_new_from_file (EVOLUTION_IMAGES "/online.png", NULL); - if (pixbuf == NULL) { - g_warning ("Cannot load `%s'", EVOLUTION_IMAGES "/online.png"); - } else { - gdk_pixbuf_render_pixmap_and_mask (pixbuf, &online_pixmap, &online_mask, 128); - g_object_unref (pixbuf); - } -} - -static void -cleanup_delayed_selection (EShellView *shell_view) -{ - EShellViewPrivate *priv; - - priv = shell_view->priv; - - if (priv->delayed_selection != NULL) { - g_free (priv->delayed_selection); - priv->delayed_selection = NULL; - g_signal_handlers_disconnect_by_func (e_shell_get_storage_set (priv->shell), - G_CALLBACK (new_folder_cb), shell_view); - } -} - -static GtkWidget * -find_socket (GtkContainer *container) -{ - GList *children, *tmp; - - children = gtk_container_get_children(container); - while (children) { - if (BONOBO_IS_SOCKET (children->data)) - return children->data; - else if (GTK_IS_CONTAINER (children->data)) { - GtkWidget *socket = find_socket (children->data); - if (socket) - return socket; - } - tmp = children->next; - g_list_free_1 (children); - children = tmp; - } - return NULL; -} - -static void -setup_verb_sensitivity_for_folder (EShellView *shell_view, - const char *path) -{ - EShellViewPrivate *priv; - BonoboUIComponent *ui_component; - EFolder *folder; - const char *prop; - - priv = shell_view->priv; - - ui_component = e_shell_view_get_bonobo_ui_component (shell_view); - - if (path == NULL) - folder = NULL; - else - folder = e_storage_set_get_folder (e_shell_get_storage_set (priv->shell), path); - - /* Adjust sensitivity for menu options depending on whether the folder - selected can actually be manipulated or not. */ - - if (folder != NULL - && ! e_folder_get_is_stock (folder) - && e_folder_get_physical_uri (folder) != NULL) - prop = "1"; - else - prop = "0"; - bonobo_ui_component_set_prop (ui_component, "/commands/MoveFolder", "sensitive", prop, NULL); - bonobo_ui_component_set_prop (ui_component, "/commands/CopyFolder", "sensitive", prop, NULL); - bonobo_ui_component_set_prop (ui_component, "/commands/DeleteFolder", "sensitive", prop, NULL); - bonobo_ui_component_set_prop (ui_component, "/commands/RenameFolder", "sensitive", prop, NULL); - - /* Adjust sensitivity for menu options depending on whether the user - right-clicked a folder whose contents can be viewed. */ - - if (folder != NULL - && e_folder_type_registry_get_handler_for_type (e_shell_get_folder_type_registry (e_shell_view_get_shell (shell_view)), - e_folder_get_type_string (folder)) != NULL) - prop = "1"; - else - prop = "0"; - bonobo_ui_component_set_prop (ui_component, "/commands/ActivateView", "sensitive", prop, NULL); - bonobo_ui_component_set_prop (ui_component, "/commands/OpenFolderInNewWindow", "sensitive", prop, NULL); - bonobo_ui_component_set_prop (ui_component, "/commands/AddFolderToShortcutBar", "sensitive", prop, NULL); -} - - -static void -update_navigation_buttons (EShellView *shell_view) -{ - EShellViewPrivate *priv; - - priv = shell_view->priv; - - e_shell_folder_title_bar_update_navigation_buttons (E_SHELL_FOLDER_TITLE_BAR (priv->folder_title_bar), - e_history_has_prev (priv->history), - e_history_has_next (priv->history)); -} - -static int -history_uri_matching_func (const void *a, - const void *b) -{ - const char *s1, *s2; - - s1 = (const char *) a; - s2 = (const char *) b; - - return strcmp (s1, s2); -} - -static void -remove_uri_from_history (EShellView *shell_view, - const char *uri) -{ - EShellViewPrivate *priv; - - priv = shell_view->priv; - - e_history_remove_matching (priv->history, uri, history_uri_matching_func); -} - - -static void -setup_defaults (EShellView *shell_view) -{ - EShellViewPrivate *priv; - EShortcutBar *shortcut_bar; - GConfClient *client; - char *file_name; - int shortcut_group; - int width; - - g_return_if_fail (shell_view != NULL); - g_return_if_fail (E_IS_SHELL_VIEW (shell_view)); - - priv = shell_view->priv; - shortcut_bar = E_SHORTCUT_BAR (priv->shortcut_bar); - - client = gconf_client_get_default (); - - gtk_window_set_default_size (GTK_WINDOW (shell_view), - gconf_client_get_int (client, "/apps/evolution/shell/view_defaults/width", NULL), - gconf_client_get_int (client, "/apps/evolution/shell/view_defaults/height", NULL)); - - shortcut_group = gconf_client_get_int (client, "/apps/evolution/shell/view_defaults/selected_shortcut_group", NULL); - e_shell_view_set_current_shortcuts_group_num (shell_view, shortcut_group); - - e_shell_view_show_folder_bar (shell_view, - gconf_client_get_bool (client, "/apps/evolution/shell/view_defaults/show_folder_bar", NULL)); - e_shell_view_show_shortcut_bar (shell_view, - gconf_client_get_bool (client, "/apps/evolution/shell/view_defaults/show_shortcut_bar", NULL)); - - width = gconf_client_get_int (client, "/apps/evolution/shell/view_defaults/shortcut_bar/width", NULL); - if (priv->shortcut_bar_shown) - gtk_paned_set_position (GTK_PANED (priv->hpaned), width); - priv->hpaned_position = width; - - width = gconf_client_get_int (client, "/apps/evolution/shell/view_defaults/folder_bar/width", NULL); - if (priv->folder_bar_shown) - gtk_paned_set_position (GTK_PANED (priv->view_hpaned), width); - priv->view_hpaned_position = width; - - /* Load the expanded state for the ShellView's StorageSetView */ - file_name = g_strdup_printf ("%s/config/storage-set-view-expanded:default", - e_shell_get_local_directory (priv->shell)); - e_tree_load_expanded_state (E_TREE (priv->storage_set_view), - file_name); - g_free (file_name); -} - - -/* This implements the behavior for when the folder which is currently displayed - gets deleted. */ - -/* Find the path for an Inbox in the specified storage. This is not really - 100% correct, but should work for most cases. */ -static char * -find_inbox_in_storage (EShellView *shell_view, - const char *storage_name) -{ - EShellViewPrivate *priv; - EStorageSet *storage_set; - EStorage *storage; - char *casefold_i18n_inbox_name; - GList *subfolder_paths; - GList *p; - - priv = shell_view->priv; - storage_set = e_shell_get_storage_set (priv->shell); - storage = e_storage_set_get_storage (storage_set, storage_name); - - casefold_i18n_inbox_name = g_utf8_casefold (_("Inbox"), -1); - - subfolder_paths = e_storage_get_subfolder_paths (storage, "/"); - for (p = subfolder_paths; p != NULL; p = p->next) { - const char *path; - char *casefold_path; - - path = (const char *) p->data; - - casefold_path = g_utf8_casefold (path, -1); - - if (g_utf8_collate (casefold_path, "/inbox") == 0 - || g_utf8_collate (casefold_path + 1, casefold_i18n_inbox_name) == 0) { - char *return_path; - - return_path = g_strconcat ("/", storage_name, path, NULL); - e_free_string_list (subfolder_paths); - - g_free (casefold_i18n_inbox_name); - g_free (casefold_path); - return return_path; - } - - g_free (casefold_path); - } - - g_free (casefold_i18n_inbox_name); - e_free_string_list (subfolder_paths); - - return NULL; -} - -static void -handle_current_folder_removed (EShellView *shell_view) -{ - EShellViewPrivate *priv; - const char *current_path; - const char *p; - char *new_path; - - /* Note: we assume that priv->uri is an evolution: URI. */ - - priv = shell_view->priv; - - current_path = priv->uri + E_SHELL_URI_PREFIX_LEN; - - g_assert (*current_path == E_PATH_SEPARATOR); - - new_path = NULL; - - /* If we have a parent folder (not a parent storage), try to display - that one. */ - - p = strrchr (current_path + 1, E_PATH_SEPARATOR); - if (p != NULL && p[1] != '\0' && strchr (current_path + 1, E_PATH_SEPARATOR) != p) { - new_path = g_strndup (current_path, p - current_path); - } else { - /* We don't have a parent folder, so try to see if there is an - Inbox folder in the same storage. */ - - /* Extract the storage name. */ - p = strchr (current_path + 1, E_PATH_SEPARATOR); - if (p == NULL) { - /* The URL points itself to a storage, so just redirect - to the default case. */ - new_path = NULL; - } else { - char *storage_name; - - storage_name = g_strndup (current_path + 1, p - current_path - 1); - - new_path = find_inbox_in_storage (shell_view, storage_name); - if (new_path == NULL) { - char *storage_uri; - - /* No Inbox in this storage -- fallback to the storage. */ - storage_uri = g_strconcat (E_SHELL_URI_PREFIX, "/", storage_name, NULL); - e_shell_view_display_uri (shell_view, storage_uri, TRUE); - - g_free (storage_uri); - g_free (storage_name); - return; - } - - g_free (storage_name); - } - } - - if (new_path == NULL) { - e_shell_view_display_uri (shell_view, FALLBACK_URI, TRUE); - } else { - EFolder *folder; - - /* Check that the folder we have chosen exists; if it doesn't, - we just use the fallback URI. */ - - folder = e_storage_set_get_folder (e_shell_get_storage_set (priv->shell), new_path); - if (folder == NULL) { - e_shell_view_display_uri (shell_view, FALLBACK_URI, TRUE); - } else { - char *new_uri; - - new_uri = g_strconcat (E_SHELL_URI_PREFIX, new_path, NULL); - e_shell_view_display_uri (shell_view, new_uri, TRUE); - g_free (new_uri); - } - - g_free (new_path); - } -} - - -/* Callbacks for the EStorageSet. */ - -static void -storage_set_new_storage_callback (EStorageSet *storage_set, - EStorage *storage, - void *data) -{ - if (e_storage_supports_shared_folders (storage)) - update_other_users_folder_items_sensitivity (E_SHELL_VIEW (data)); -} - -static void -storage_set_removed_storage_callback (EStorageSet *storage_set, - EStorage *storage, - void *data) -{ - EShellView *shell_view = E_SHELL_VIEW (data); - - if (! e_storage_supports_shared_folders (storage)) - return; - - update_other_users_folder_items_sensitivity (shell_view); -} - -static void -storage_set_removed_folder_callback (EStorageSet *storage_set, - const char *path, - void *data) -{ - EShellView *shell_view; - EShellViewPrivate *priv; - GtkWidget *socket; - View *view; - int destroy_connection_id; - int page_num; - char *uri; - - shell_view = E_SHELL_VIEW (data); - priv = shell_view->priv; - - uri = g_strconcat (E_SHELL_URI_PREFIX, path, NULL); - - remove_uri_from_history (shell_view, uri); - update_navigation_buttons (shell_view); - - /* (Note that at this point the current URI in the history might have - been changed and not match the current view. But we catch this case - when checking if this was the current view, below.) */ - - view = g_hash_table_lookup (priv->uri_to_view, uri); - - g_free (uri); - - if (view == NULL) - return; - - socket = find_socket (GTK_CONTAINER (view->control)); - priv->sockets = g_list_remove (priv->sockets, socket); - - destroy_connection_id = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (socket), "e_shell_view_destroy_connection_id")); - g_signal_handler_disconnect((socket), destroy_connection_id); - - page_num = gtk_notebook_page_num (GTK_NOTEBOOK (priv->notebook), view->control); - - bonobo_control_frame_control_deactivate (BONOBO_CONTROL_FRAME (bonobo_widget_get_control_frame (BONOBO_WIDGET (view->control)))); - gtk_widget_destroy (view->control); - - g_hash_table_remove (priv->uri_to_view, view->uri); - view_destroy (view); - - gtk_notebook_remove_page (GTK_NOTEBOOK (priv->notebook), page_num); - - /* Check if it was the URI that was being displayed. */ - if (strncmp (priv->uri, E_SHELL_URI_PREFIX, E_SHELL_URI_PREFIX_LEN) == 0 - && strcmp (priv->uri + E_SHELL_URI_PREFIX_LEN, path) == 0) { - handle_current_folder_removed (shell_view); - } -} - - -/* Folder bar pop-up handling. */ - -static void -reparent (GtkWidget *widget, - GtkContainer *new_container) -{ - gtk_widget_ref (widget); - gtk_container_remove (GTK_CONTAINER (widget->parent), widget); - gtk_container_add (GTK_CONTAINER (new_container), widget); - gtk_widget_unref (widget); -} - -static void -reparent_storage_set_view_box_and_destroy_popup (EShellView *shell_view) -{ - EShellViewPrivate *priv; - - priv = shell_view->priv; - - if (priv->folder_bar_popup == NULL) - return; - - gtk_widget_ref (priv->storage_set_view_box); - gtk_container_remove (GTK_CONTAINER (priv->folder_bar_popup), priv->storage_set_view_box); - gtk_paned_pack1 (GTK_PANED (priv->view_hpaned), priv->storage_set_view_box, FALSE, FALSE); - gtk_widget_unref (priv->storage_set_view_box); - - gtk_widget_destroy (priv->folder_bar_popup); - priv->folder_bar_popup = NULL; - - /* Re-enable DnD on the StorageSetView (it got disabled when displaying - the pop-up). */ - e_storage_set_view_set_allow_dnd (E_STORAGE_SET_VIEW (priv->storage_set_view), TRUE); -} - -static void -popdown_transient_folder_bar (EShellView *shell_view) -{ - EShellViewPrivate *priv; - - priv = shell_view->priv; - - gdk_pointer_ungrab (GDK_CURRENT_TIME); - gdk_keyboard_ungrab (GDK_CURRENT_TIME); - gtk_grab_remove (priv->storage_set_view_box); - - reparent_storage_set_view_box_and_destroy_popup (shell_view); - gtk_widget_hide (priv->storage_set_view_box); - - e_shell_folder_title_bar_set_toggle_state (E_SHELL_FOLDER_TITLE_BAR (priv->folder_title_bar), FALSE); - - /* Re-enable DnD on the StorageSetView (it got disabled when displaying - the pop-up). */ - e_storage_set_view_set_allow_dnd (E_STORAGE_SET_VIEW (priv->storage_set_view), TRUE); -} - -static int -storage_set_view_box_button_release_event_cb (GtkWidget *widget, - GdkEventButton *button_event, - void *data) -{ - EShellView *shell_view; - EShellViewPrivate *priv; - - shell_view = E_SHELL_VIEW (data); - priv = shell_view->priv; - - if (button_event->window == GTK_PANED (priv->view_hpaned)->handle - || button_event->button != 1) - return FALSE; - - popdown_transient_folder_bar (shell_view); - return TRUE; -} - -static void -storage_set_view_folder_opened_cb (EStorageSetView *storage_set_view, - const char *path, - void *data) -{ - /* Pop down for top level nodes, see #31303. */ - if (strchr (path + 1, E_PATH_SEPARATOR) == NULL) - popdown_transient_folder_bar (E_SHELL_VIEW (data)); -} - -static void -popup_storage_set_view_button_clicked (ETitleBar *title_bar, - void *data) -{ - EShellView *shell_view; - EShellViewPrivate *priv; - - shell_view = E_SHELL_VIEW (data); - priv = shell_view->priv; - - g_assert (priv->folder_bar_popup != NULL); - - reparent_storage_set_view_box_and_destroy_popup (shell_view); - - e_shell_view_show_folder_bar (shell_view, TRUE); - e_shell_folder_title_bar_set_toggle_state (E_SHELL_FOLDER_TITLE_BAR (priv->folder_title_bar), FALSE); -} - -static void -folder_bar_popup_map_callback (GtkWidget *widget, - void *data) -{ - EShellView *shell_view; - EShellViewPrivate *priv; - guint32 current_time; - - shell_view = E_SHELL_VIEW (data); - priv = shell_view->priv; - - current_time = GDK_CURRENT_TIME; - - if (gdk_pointer_grab (widget->window, TRUE, - (GDK_BUTTON_PRESS_MASK - | GDK_BUTTON_RELEASE_MASK - | GDK_ENTER_NOTIFY_MASK - | GDK_LEAVE_NOTIFY_MASK - | GDK_POINTER_MOTION_MASK), - NULL, NULL, current_time) != 0) { - g_warning ("e-shell-view.c:folder_bar_popup_map_callback() -- pointer grab failed."); - return; - } - - if (gdk_keyboard_grab (widget->window, TRUE, 0) != 0) { - g_warning ("e-shell-view.c:folder_bar_popup_map_callback() -- keyboard grab failed."); - gdk_pointer_ungrab (current_time); - return; - } - - gtk_grab_add (widget); - - e_signal_connect_while_alive (widget, "button_release_event", - G_CALLBACK (storage_set_view_box_button_release_event_cb), - shell_view, priv->folder_bar_popup); - e_signal_connect_while_alive (priv->storage_set_view, "folder_opened", - G_CALLBACK (storage_set_view_folder_opened_cb), - shell_view, priv->folder_bar_popup); - e_signal_connect_while_alive (priv->storage_set_view, "button_release_event", - G_CALLBACK (storage_set_view_box_button_release_event_cb), - shell_view, priv->folder_bar_popup); - e_signal_connect_while_alive (priv->storage_set_title_bar, "button_clicked", - G_CALLBACK (popup_storage_set_view_button_clicked), - shell_view, priv->folder_bar_popup); -} - -static void -pop_up_folder_bar (EShellView *shell_view) -{ - EShellViewPrivate *priv; - int x, y; - int orig_x, orig_y; - - priv = shell_view->priv; - - g_assert (! priv->folder_bar_shown); - - e_title_bar_set_button_mode (E_TITLE_BAR (priv->storage_set_title_bar), - E_TITLE_BAR_BUTTON_MODE_PIN); - - priv->folder_bar_popup = gtk_window_new (GTK_WINDOW_POPUP); - - /* We need to show the storage set view box and do a pointer grab to catch the - mouse clicks. But until the box is shown, we cannot grab. So we connect to - the "map" signal; `storage_set_view_box_map_cb()' will do the grab. */ - g_signal_connect (priv->folder_bar_popup, "map", - G_CALLBACK (folder_bar_popup_map_callback), shell_view); - - x = priv->folder_title_bar->allocation.x; - y = priv->folder_title_bar->allocation.y + priv->folder_title_bar->allocation.height; - - gdk_window_get_origin (priv->folder_title_bar->window, &orig_x, &orig_y); - x += orig_x; - y += orig_y + 2; - - priv->view_hpaned_position = MAX (priv->view_hpaned_position, MIN_POPUP_TREE_WIDTH); - - gtk_window_set_default_size (GTK_WINDOW (priv->folder_bar_popup), - priv->view_hpaned_position, - priv->view_hpaned->allocation.height); - - reparent (priv->storage_set_view_box, GTK_CONTAINER (priv->folder_bar_popup)); - - gtk_widget_show (priv->storage_set_view_box); - - gtk_window_move (GTK_WINDOW (priv->folder_bar_popup), x, y); - gtk_widget_show (priv->folder_bar_popup); - - /* Disable DnD or "interesting" things will happen. */ - e_storage_set_view_set_allow_dnd (E_STORAGE_SET_VIEW (priv->storage_set_view), FALSE); -} - - - -/* Switching views on a tree view click. */ - -static int -set_folder_timeout (gpointer data) -{ - EShellView *shell_view; - EShellViewPrivate *priv; - - shell_view = E_SHELL_VIEW (data); - priv = shell_view->priv; - - /* Set to 0 so we don't remove it in _display_uri(). */ - priv->set_folder_timeout = 0; - e_shell_view_display_uri (shell_view, priv->set_folder_uri, TRUE); - - return FALSE; -} - -static int -popdown_transient_folder_bar_idle (void *data) -{ - EShellView *shell_view; - - shell_view = E_SHELL_VIEW (data); - - popdown_transient_folder_bar (shell_view); - - g_object_unref (shell_view); - - return FALSE; -} - -static void -switch_on_folder_tree_click (EShellView *shell_view, - const char *path) -{ - EShellViewPrivate *priv; - char *uri; - - priv = shell_view->priv; - - gdk_pointer_ungrab (GDK_CURRENT_TIME); - gdk_keyboard_ungrab (GDK_CURRENT_TIME); - gtk_grab_remove (priv->storage_set_view_box); - - uri = g_strconcat (E_SHELL_URI_PREFIX, path, NULL); - if (priv->uri != NULL && !strcmp (uri, priv->uri)) { - g_free (uri); - return; - } - - if (priv->set_folder_timeout != 0) - gtk_timeout_remove (priv->set_folder_timeout); - - g_free (priv->set_folder_uri); - priv->set_folder_uri = NULL; - - cleanup_delayed_selection (shell_view); - - if (priv->folder_bar_popup != NULL) { - e_shell_view_display_uri (shell_view, uri, TRUE); - g_free (uri); - - g_object_ref (shell_view); - gtk_idle_add (popdown_transient_folder_bar_idle, shell_view); - return; - } - - priv->set_folder_uri = uri; - - priv->set_folder_timeout = gtk_timeout_add (SET_FOLDER_DELAY, set_folder_timeout, shell_view); -} - - -/* Callbacks. */ - -/* Callback when a new folder is added. Removed when we clear the - delayed_selection. */ -static void -new_folder_cb (EStorageSet *storage_set, - const char *path, - void *data) -{ - EShellView *shell_view; - EShellViewPrivate *priv; - char *delayed_path; - - shell_view = E_SHELL_VIEW (data); - priv = shell_view->priv; - - delayed_path = strchr (priv->delayed_selection, ':'); - if (delayed_path) { - delayed_path ++; - if (!strcmp(path, delayed_path)) { - char *uri; - - uri = g_strdup (priv->delayed_selection); - cleanup_delayed_selection (shell_view); - e_shell_view_display_uri (shell_view, uri, FALSE); - g_free (uri); - } - } -} - -/* Callback called when an icon on the shortcut bar gets clicked. */ -static void -activate_shortcut_cb (EShortcutsView *shortcut_view, - EShortcuts *shortcuts, - const char *uri, - gboolean in_new_window, - void *data) -{ - EShellView *shell_view; - - shell_view = E_SHELL_VIEW (data); - - if (in_new_window) { - EShellView *new_view; - - new_view = e_shell_create_view (e_shell_view_get_shell (shell_view), uri, shell_view); - e_shell_view_show_shortcut_bar (new_view, FALSE); - e_shell_view_show_folder_bar (new_view, FALSE); - } else { - e_shell_view_display_uri (shell_view, uri, TRUE); - } -} - -/* Callback when user chooses "Hide shortcut bar" via a right click */ -static void -hide_requested_cb (EShortcutsView *shortcut_view, - void *data) -{ - EShellView *shell_view; - - shell_view = E_SHELL_VIEW (data); - - e_shell_view_show_shortcut_bar (shell_view, FALSE); -} - -/* Callback called when a folder on the tree view gets clicked. */ -static void -folder_selected_cb (EStorageSetView *storage_set_view, - const char *path, - void *data) -{ - EShellView *shell_view; - - shell_view = E_SHELL_VIEW (data); - - setup_verb_sensitivity_for_folder (shell_view, path); - switch_on_folder_tree_click (shell_view, path); -} - -/* Callbacks for the folder context menu in the folder bar. */ - -static void -folder_context_menu_popping_up_cb (EStorageSetView *storage_set_view, - const char *path, - void *data) -{ - EShellView *shell_view; - - shell_view = E_SHELL_VIEW (data); - - setup_verb_sensitivity_for_folder (shell_view, path); -} - -static void -folder_context_menu_popped_down_cb (EStorageSetView *storage_set_view, - void *data) -{ - EShellView *shell_view; - - shell_view = E_SHELL_VIEW (data); - - setup_verb_sensitivity_for_folder (shell_view, e_shell_view_get_current_path (shell_view)); - - if (shell_view->priv->folder_bar_popup != NULL) - popdown_transient_folder_bar (shell_view); -} - -/* Callback called when the button on the tree's title bar is clicked. */ -static void -storage_set_view_button_clicked_cb (ETitleBar *title_bar, - void *data) -{ - EShellView *shell_view; - - shell_view = E_SHELL_VIEW (data); - - if (shell_view->priv->folder_bar_popup == NULL) - e_shell_view_show_folder_bar (shell_view, FALSE); -} - -/* Callback called when the title bar button is clicked. */ -static void -title_bar_toggled_cb (EShellFolderTitleBar *title_bar, - gboolean state, - void *data) -{ - EShellView *shell_view; - - shell_view = E_SHELL_VIEW (data); - - if (! state) - return; - - if (shell_view->priv->folder_bar_popup == NULL) - pop_up_folder_bar (shell_view); -} - -/* Callback called when the offline toggle button is clicked. */ -static void -offline_toggle_clicked_cb (GtkButton *button, - void *data) -{ - EShellView *shell_view; - EShellViewPrivate *priv; - - shell_view = E_SHELL_VIEW (data); - priv = shell_view->priv; - - switch (e_shell_get_line_status (priv->shell)) { - case E_SHELL_LINE_STATUS_ONLINE: - e_shell_go_offline (priv->shell, shell_view); - break; - case E_SHELL_LINE_STATUS_OFFLINE: - e_shell_go_online (priv->shell, shell_view); - break; - default: - g_assert_not_reached (); - } -} - - -/* Navigation button callbacks. */ - -static void -back_clicked_callback (EShellFolderTitleBar *title_bar, - void *data) -{ - EShellView *shell_view; - EShellViewPrivate *priv; - const char *new_uri; - - shell_view = E_SHELL_VIEW (data); - priv = shell_view->priv; - - if (! e_history_has_prev (priv->history)) - return; - - new_uri = (const char *) e_history_prev (priv->history); - - display_uri (shell_view, new_uri, FALSE, TRUE); -} - -static void -forward_clicked_callback (EShellFolderTitleBar *title_bar, - void *data) -{ - EShellView *shell_view; - EShellViewPrivate *priv; - const char *new_uri; - - shell_view = E_SHELL_VIEW (data); - priv = shell_view->priv; - - if (! e_history_has_next (priv->history)) - return; - - new_uri = (const char *) e_history_next (priv->history); - - display_uri (shell_view, new_uri, FALSE, TRUE); -} - - -/* Widget setup. */ - -static void -setup_storage_set_subwindow (EShellView *shell_view) -{ - EShellViewPrivate *priv; - GtkWidget *storage_set_view; - GtkWidget *vbox; - GtkWidget *scrolled_window; - - priv = shell_view->priv; - - storage_set_view = e_storage_set_create_new_view (e_shell_get_storage_set (priv->shell), - priv->ui_container); - g_signal_connect (storage_set_view, "folder_selected", - G_CALLBACK (folder_selected_cb), shell_view); - g_signal_connect (storage_set_view, "folder_context_menu_popping_up", - G_CALLBACK (folder_context_menu_popping_up_cb), shell_view); - g_signal_connect (storage_set_view, "folder_context_menu_popped_down", - G_CALLBACK (folder_context_menu_popped_down_cb), shell_view); - - scrolled_window = gtk_scrolled_window_new (NULL, NULL); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), - GTK_POLICY_AUTOMATIC, - GTK_POLICY_AUTOMATIC); - gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_window), - GTK_SHADOW_IN); - - gtk_container_add (GTK_CONTAINER (scrolled_window), storage_set_view); - - vbox = gtk_vbox_new (FALSE, 0); - - priv->storage_set_title_bar = e_title_bar_new (_("Folders")); - - gtk_box_pack_start (GTK_BOX (vbox), priv->storage_set_title_bar, FALSE, FALSE, 0); - gtk_box_pack_start (GTK_BOX (vbox), scrolled_window, TRUE, TRUE, 0); - - g_signal_connect (priv->storage_set_title_bar, "button_clicked", - G_CALLBACK (storage_set_view_button_clicked_cb), shell_view); - - gtk_widget_show (storage_set_view); - gtk_widget_show (priv->storage_set_title_bar); - gtk_widget_show (scrolled_window); - - priv->storage_set_view_box = vbox; - priv->storage_set_view = storage_set_view; - - /* Notice we don't show the vbox here yet. By default it's hidden. */ -} - -static void -setup_offline_toggle (EShellView *shell_view) -{ - EShellViewPrivate *priv; - GtkWidget *toggle; - GtkWidget *image; - - priv = shell_view->priv; - - toggle = gtk_button_new (); - GTK_WIDGET_UNSET_FLAGS (toggle, GTK_CAN_FOCUS); - gtk_button_set_relief (GTK_BUTTON (toggle), GTK_RELIEF_NONE); - - g_signal_connect (toggle, "clicked", - G_CALLBACK (offline_toggle_clicked_cb), shell_view); - - image = gtk_image_new_from_pixmap (offline_pixmap, offline_mask); - - gtk_container_add (GTK_CONTAINER (toggle), image); - - gtk_widget_show (toggle); - gtk_widget_show (image); - - priv->offline_toggle = toggle; - priv->offline_toggle_image = image; - - update_offline_toggle_status (shell_view); - - g_assert (priv->status_bar != NULL); - - gtk_box_pack_start (GTK_BOX (priv->status_bar), priv->offline_toggle, FALSE, TRUE, 0); -} - -static void -setup_menu_hint_label (EShellView *shell_view) -{ - EShellViewPrivate *priv; - - priv = shell_view->priv; - - priv->menu_hint_label = gtk_label_new (""); - gtk_misc_set_alignment (GTK_MISC (priv->menu_hint_label), 0.0, 0.5); - - gtk_box_pack_start (GTK_BOX (priv->status_bar), priv->menu_hint_label, TRUE, TRUE, 0); -} - -static void -setup_task_bar (EShellView *shell_view) -{ - EShellViewPrivate *priv; - - priv = shell_view->priv; - - priv->task_bar = e_task_bar_new (); - - g_assert (priv->status_bar != NULL); - - gtk_box_pack_start (GTK_BOX (priv->status_bar), priv->task_bar, TRUE, TRUE, 0); - gtk_widget_show (priv->task_bar); -} - -static void -create_status_bar (EShellView *shell_view) -{ - EShellViewPrivate *priv; - - priv = shell_view->priv; - - priv->status_bar = gtk_hbox_new (FALSE, 2); - gtk_widget_show (priv->status_bar); - - setup_offline_toggle (shell_view); - setup_menu_hint_label (shell_view); - setup_task_bar (shell_view); -} - - -/* Menu hints for the status bar. */ - -static void -ui_engine_add_hint_callback (BonoboUIEngine *engine, - const char *hint, - void *data) -{ - EShellView *shell_view; - EShellViewPrivate *priv; - - shell_view = E_SHELL_VIEW (data); - priv = shell_view->priv; - - gtk_label_set_text (GTK_LABEL (priv->menu_hint_label), hint); - gtk_widget_show (priv->menu_hint_label); - gtk_widget_hide (priv->task_bar); -} - -static void -ui_engine_remove_hint_callback (BonoboUIEngine *engine, - void *data) -{ - EShellView *shell_view; - EShellViewPrivate *priv; - - shell_view = E_SHELL_VIEW (data); - priv = shell_view->priv; - - gtk_widget_hide (priv->menu_hint_label); - gtk_widget_show (priv->task_bar); -} - -static void -setup_statusbar_hints (EShellView *shell_view) -{ - EShellViewPrivate *priv; - BonoboUIEngine *ui_engine; - - priv = shell_view->priv; - - g_assert (priv->status_bar != NULL); - - ui_engine = bonobo_window_get_ui_engine (BONOBO_WINDOW (shell_view)); - - g_signal_connect (ui_engine, "add_hint", - G_CALLBACK (ui_engine_add_hint_callback), shell_view); - g_signal_connect (ui_engine, "remove_hint", - G_CALLBACK (ui_engine_remove_hint_callback), shell_view); -} - - -static void -setup_widgets (EShellView *shell_view) -{ - EShellViewPrivate *priv; - GtkWidget *contents_vbox; - GtkWidget *gray_bar; - - priv = shell_view->priv; - - /* The shortcut bar. */ - - priv->shortcut_bar = e_shortcuts_new_view (e_shell_get_shortcuts (priv->shell)); - g_signal_connect (priv->shortcut_bar, "activate_shortcut", - G_CALLBACK (activate_shortcut_cb), shell_view); - - g_signal_connect (priv->shortcut_bar, "hide_requested", - G_CALLBACK (hide_requested_cb), shell_view); - - priv->shortcut_frame = gtk_frame_new (NULL); - gtk_frame_set_shadow_type (GTK_FRAME (priv->shortcut_frame), GTK_SHADOW_IN); - - /* The storage set view. */ - - setup_storage_set_subwindow (shell_view); - - /* The tabless notebook which we used to contain the views. */ - - priv->notebook = gtk_notebook_new (); - gtk_notebook_set_show_border (GTK_NOTEBOOK (priv->notebook), FALSE); - gtk_notebook_set_show_tabs (GTK_NOTEBOOK (priv->notebook), FALSE); - - /* Page for "No URL displayed" message. */ - - gtk_notebook_append_page (GTK_NOTEBOOK (priv->notebook), create_label_for_empty_page (), NULL); - - /* Put things into a paned and the paned into the GnomeApp. */ - - priv->view_vbox = gtk_vbox_new (FALSE, 0); - - priv->folder_title_bar = e_shell_folder_title_bar_new (); - g_signal_connect (priv->folder_title_bar, "title_toggled", - G_CALLBACK (title_bar_toggled_cb), shell_view); - g_signal_connect (priv->folder_title_bar, "back_clicked", - G_CALLBACK (back_clicked_callback), shell_view); - g_signal_connect (priv->folder_title_bar, "forward_clicked", - G_CALLBACK (forward_clicked_callback), shell_view); - - priv->view_hpaned = gtk_hpaned_new (); - gtk_paned_pack1 (GTK_PANED (priv->view_hpaned), priv->storage_set_view_box, TRUE, FALSE); - gtk_paned_pack2 (GTK_PANED (priv->view_hpaned), priv->notebook, TRUE, FALSE); - - gray_bar = gtk_event_box_new (); - gtk_container_add (GTK_CONTAINER (gray_bar), priv->folder_title_bar); - gtk_box_pack_start (GTK_BOX (priv->view_vbox), gray_bar, FALSE, FALSE, 2); - - gtk_box_pack_start (GTK_BOX (priv->view_vbox), priv->view_hpaned, TRUE, TRUE, 0); - - priv->hpaned = gtk_hpaned_new (); - gtk_container_add (GTK_CONTAINER (priv->shortcut_frame), priv->shortcut_bar); - gtk_paned_pack1 (GTK_PANED (priv->hpaned), priv->shortcut_frame, TRUE, FALSE); - gtk_paned_pack2 (GTK_PANED (priv->hpaned), priv->view_vbox, TRUE, FALSE); - gtk_paned_set_position (GTK_PANED (priv->hpaned), DEFAULT_SHORTCUT_BAR_WIDTH); - - /* The status bar. */ - - create_status_bar (shell_view); - setup_statusbar_hints (shell_view); - - /* The contents. */ - - contents_vbox = gtk_vbox_new (FALSE, 0); - gtk_box_pack_start (GTK_BOX (contents_vbox), priv->hpaned, TRUE, TRUE, 0); - gtk_box_pack_start (GTK_BOX (contents_vbox), priv->status_bar, FALSE, TRUE, 0); - gtk_widget_show (contents_vbox); - - bonobo_window_set_contents (BONOBO_WINDOW (shell_view), contents_vbox); - - /* Show stuff. */ - - gtk_widget_show (priv->shortcut_frame); - gtk_widget_show (priv->shortcut_bar); - gtk_widget_show (priv->storage_set_view); - gtk_widget_show (priv->notebook); - gtk_widget_show (priv->hpaned); - gtk_widget_show (priv->view_hpaned); - gtk_widget_show (priv->view_vbox); - gtk_widget_show (priv->folder_title_bar); - gtk_widget_show (priv->status_bar); - - gtk_widget_show (gray_bar); - - priv->shortcut_bar_shown = TRUE; - priv->folder_bar_shown = FALSE; - - /* FIXME: Session management and stuff? */ - gtk_window_set_default_size (GTK_WINDOW (shell_view), DEFAULT_WIDTH, DEFAULT_HEIGHT); -} - - -/* GObject methods. */ - -static void -hash_foreach_destroy_view (void *name, - void *value, - void *data) -{ - View *view; - - view = (View *) value; - - gtk_widget_destroy (view->control); - - view_destroy (view); -} - -static void -impl_dispose (GObject *object) -{ - EShellView *shell_view; - EShellViewPrivate *priv; - GList *p; - - shell_view = E_SHELL_VIEW (object); - priv = shell_view->priv; - - /* This is necessary to remove the signal handler for folder_new on the - storage set used for the delayed selection mechanism. */ - cleanup_delayed_selection (shell_view); - - if (priv->tooltips != NULL) { - g_object_unref (priv->tooltips); - priv->tooltips = NULL; - } - - if (priv->history != NULL) { - g_object_unref (priv->history); - priv->history = NULL; - } - - if (priv->shell != NULL) { - bonobo_object_unref (BONOBO_OBJECT (priv->shell)); - priv->shell = NULL; - } - - if (priv->corba_interface != CORBA_OBJECT_NIL) { - bonobo_object_release_unref (priv->corba_interface, NULL); - priv->corba_interface = CORBA_OBJECT_NIL; - } - - if (priv->folder_bar_popup != NULL) { - gtk_widget_destroy (priv->folder_bar_popup); - priv->folder_bar_popup = NULL; - } - - for (p = priv->sockets; p != NULL; p = p->next) { - GtkWidget *socket_widget; - int destroy_connection_id; - - socket_widget = GTK_WIDGET (p->data); - destroy_connection_id = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (socket_widget), - "e_shell_view_destroy_connection_id")); - g_signal_handler_disconnect((socket_widget), destroy_connection_id); - } - g_list_free (priv->sockets); - priv->sockets = NULL; - - if (priv->uri_to_view != NULL) { - g_hash_table_foreach (priv->uri_to_view, hash_foreach_destroy_view, NULL); - g_hash_table_destroy (priv->uri_to_view); - priv->uri_to_view = NULL; - } - - if (priv->ui_component != NULL) { - bonobo_object_unref (BONOBO_OBJECT (priv->ui_component)); - priv->ui_component = NULL; - } - - if (priv->set_folder_timeout != 0) { - gtk_timeout_remove (priv->set_folder_timeout); - priv->set_folder_timeout = 0; - } - - (* G_OBJECT_CLASS (parent_class)->dispose) (object); -} - -static void -impl_finalize (GObject *object) -{ - EShellView *shell_view; - EShellViewPrivate *priv; - - shell_view = E_SHELL_VIEW (object); - priv = shell_view->priv; - - g_free (priv->uri); - g_free (priv->set_folder_uri); - g_free (priv->delayed_selection); - - g_free (priv); - - (* G_OBJECT_CLASS (parent_class)->finalize) (object); -} - - -/* Initialization. */ - -static void -class_init (EShellViewClass *klass) -{ - GObjectClass *object_class; - - object_class = G_OBJECT_CLASS (klass); - - object_class->dispose = impl_dispose; - object_class->finalize = impl_finalize; - - parent_class = g_type_class_ref(BONOBO_TYPE_WINDOW); - - signals[SHORTCUT_BAR_VISIBILITY_CHANGED] - = g_signal_new ("shortcut_bar_visibility_changed", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (EShellViewClass, shortcut_bar_visibility_changed), - NULL, NULL, - e_shell_marshal_NONE__INT, - G_TYPE_NONE, 1, - G_TYPE_INT); - - signals[FOLDER_BAR_VISIBILITY_CHANGED] - = g_signal_new ("folder_bar_visibility_changed", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (EShellViewClass, folder_bar_visibility_changed), - NULL, NULL, - e_shell_marshal_NONE__INT, - G_TYPE_NONE, 1, - G_TYPE_INT); - - signals[VIEW_CHANGED] - = g_signal_new ("view_changed", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (EShellViewClass, view_changed), - NULL, NULL, - e_shell_marshal_NONE__STRING_STRING_STRING_STRING, - G_TYPE_NONE, 4, - G_TYPE_STRING, - G_TYPE_STRING, - G_TYPE_STRING, - G_TYPE_STRING); - - load_images (); -} - -static void -init (EShellView *shell_view) -{ - EShellViewPrivate *priv; - - priv = g_new (EShellViewPrivate, 1); - - priv->shell = NULL; - priv->corba_interface = CORBA_OBJECT_NIL; - priv->ui_component = NULL; - priv->history = e_history_new ((EHistoryItemFreeFunc) g_free); - priv->uri = NULL; - priv->delayed_selection = NULL; - - priv->tooltips = gtk_tooltips_new (); - g_object_ref (priv->tooltips); - gtk_object_sink (GTK_OBJECT (priv->tooltips)); - - priv->appbar = NULL; - priv->hpaned = NULL; - priv->view_hpaned = NULL; - priv->contents = NULL; - priv->notebook = NULL; - - priv->storage_set_title_bar = NULL; - priv->storage_set_view = NULL; - priv->storage_set_view_box = NULL; - priv->shortcut_bar = NULL; - - priv->status_bar = NULL; - priv->offline_toggle = NULL; - priv->offline_toggle_image = NULL; - priv->menu_hint_label = NULL; - priv->task_bar = NULL; - - priv->folder_bar_popup = NULL; - - priv->shortcut_bar_shown = FALSE; - priv->folder_bar_shown = FALSE; - - priv->hpaned_position = 0; - priv->view_hpaned_position = 0; - - priv->uri_to_view = g_hash_table_new (g_str_hash, g_str_equal); - - priv->sockets = NULL; - - priv->set_folder_timeout = 0; - priv->set_folder_uri = NULL; - - shell_view->priv = priv; -} - - -/* EvolutionShellView interface callbacks. */ - -static void -corba_interface_set_message_cb (EvolutionShellView *shell_view, - const char *message, - gboolean busy, - void *data) -{ - /* Don't do anything here anymore. The interface is going to be - deprecated soon. */ -} - -static void -corba_interface_unset_message_cb (EvolutionShellView *shell_view, - void *data) -{ - /* Don't do anything here anymore. The interface is going to be - deprecated soon. */ -} - -static void -corba_interface_change_current_view_cb (EvolutionShellView *shell_view, - const char *uri, - void *data) -{ - EShellView *view; - - view = E_SHELL_VIEW (data); - - g_return_if_fail (view != NULL); - - e_shell_view_display_uri (view, uri, TRUE); -} - -static void -corba_interface_set_title (EvolutionShellView *shell_view, - const char *title, - void *data) -{ - EShellView *view; - - view = E_SHELL_VIEW (data); - - g_return_if_fail (view != NULL); - - gtk_window_set_title (GTK_WINDOW (view), title); -} - -static void -corba_interface_set_folder_bar_label (EvolutionShellView *evolution_shell_view, - const char *text, - void *data) -{ - EShellView *shell_view; - EShellViewPrivate *priv; - - g_return_if_fail (data != NULL); - g_return_if_fail (E_IS_SHELL_VIEW (data)); - - 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->folder_title_bar), - text); -} - -static void -corba_interface_show_settings (EvolutionShellView *evolution_shell_view, - void *data) -{ - EShellView *shell_view; - EShellViewPrivate *priv; - - g_return_if_fail (data != NULL); - g_return_if_fail (E_IS_SHELL_VIEW (data)); - - shell_view = E_SHELL_VIEW (data); - priv = shell_view->priv; - - e_shell_view_show_settings (shell_view); -} - -static void -unmerge_on_error (BonoboObject *object, - CORBA_Object cobject, - CORBA_Environment *ev) -{ -#if 0 - BonoboWindow *window; - BonoboUIEngine *ui_engine; - - /* FIXME changes.txt says we should be able to do this but bonobo_ui_engine_get_view() - is marked as internal in bonoob-ui-engine.h! */ - ui_engine = bonobo_ui_container_get_engine (BONOBO_UI_CONTAINER (object)); - window = BONOBO_WINDOW (bonobo_ui_engine_get_view (ui_engine)); - - if (window != NULL) - bonobo_ui_engine_deregister_component_by_ref (ui_engine, cobject); -#endif -} - -static void -updated_folder_cb (EStorageSet *storage_set, - const char *path, - void *data) -{ - EShellView *shell_view; - EShellViewPrivate *priv; - const char *view_path; - - shell_view = E_SHELL_VIEW (data); - priv = shell_view->priv; - - view_path = get_storage_set_path_from_uri (priv->uri); - if (view_path && strcmp (path, view_path) != 0) - return; - - /* Update the folder title bar and the window title bar */ - update_for_current_uri (shell_view); -} - - -/* Shell callbacks. */ - -static void -shell_line_status_changed_cb (EShell *shell, - EShellLineStatus new_status, - void *data) -{ - EShellView *shell_view; - - shell_view = E_SHELL_VIEW (data); - update_offline_toggle_status (shell_view); - update_send_receive_sensitivity (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, - const char *uri) -{ - EShellViewPrivate *priv; - EStorageSet *storage_set; - EShellView *view; - char *uri_to_load; - - g_return_val_if_fail (shell != NULL, NULL); - g_return_val_if_fail (shell_view != NULL, NULL); - g_return_val_if_fail (E_IS_SHELL (shell), NULL); - g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL); - - priv = shell_view->priv; - - view = E_SHELL_VIEW (bonobo_window_construct (BONOBO_WINDOW (shell_view), - bonobo_ui_container_new (), - "evolution", "Ximian Evolution")); - - if (!view) { - g_object_unref (shell_view); - return NULL; - } - - priv->shell = shell; - bonobo_object_ref (BONOBO_OBJECT (priv->shell)); - - g_signal_connect (view, "delete_event", - G_CALLBACK (delete_event_cb), NULL); - - priv->ui_container = bonobo_window_get_ui_container (BONOBO_WINDOW (view)); - g_signal_connect (priv->ui_container, "system_exception", - G_CALLBACK (unmerge_on_error), NULL); - - priv->ui_component = bonobo_ui_component_new ("evolution"); - bonobo_ui_component_set_container (priv->ui_component, - bonobo_object_corba_objref (BONOBO_OBJECT (priv->ui_container)), - NULL); - - bonobo_ui_component_freeze (priv->ui_component, NULL); - - bonobo_ui_util_set_ui (priv->ui_component, PREFIX, - EVOLUTION_UIDIR "/evolution.xml", - "evolution-1.4", NULL); - - setup_widgets (shell_view); - - bonobo_ui_engine_config_set_path (bonobo_window_get_ui_engine (BONOBO_WINDOW (shell_view)), - "/evolution/UIConf/kvps"); - e_shell_view_menu_setup (shell_view); - - e_shell_view_show_folder_bar (shell_view, FALSE); - - bonobo_ui_component_thaw (priv->ui_component, NULL); - - g_signal_connect_object (shell, "line_status_changed", - G_CALLBACK (shell_line_status_changed_cb), shell_view, 0); - - storage_set = e_shell_get_storage_set (shell); - e_signal_connect_while_alive (storage_set, "updated_folder", - G_CALLBACK (updated_folder_cb), shell_view, shell_view); - g_signal_connect_object (storage_set, "new_storage", - G_CALLBACK (storage_set_new_storage_callback), shell_view, 0); - g_signal_connect_object (storage_set, "removed_storage", - G_CALLBACK (storage_set_removed_storage_callback), shell_view, 0); - g_signal_connect_object (storage_set, "removed_folder", - G_CALLBACK (storage_set_removed_folder_callback), shell_view, 0); - - e_shell_user_creatable_items_handler_attach_menus (e_shell_get_user_creatable_items_handler (priv->shell), - shell_view); - - setup_defaults (view); - update_other_users_folder_items_sensitivity (view); - update_send_receive_sensitivity (view); - - if (uri != NULL) { - uri_to_load = g_strdup (uri); - } else { - GConfClient *client = gconf_client_get_default (); - char *path = gconf_client_get_string (client, "/apps/evolution/shell/view_defaults/folder_path", NULL); - - uri_to_load = g_strconcat (E_SHELL_URI_PREFIX, path, NULL); - g_free (path); - g_object_unref (client); - } - - if (! e_shell_view_display_uri (shell_view, uri_to_load, FALSE)) { - e_shell_view_display_uri (shell_view, E_SHELL_VIEW_DEFAULT_URI, FALSE); - e_shell_view_display_uri (shell_view, uri_to_load, TRUE); - } - - g_free (uri_to_load); - - return view; -} - -/* WARNING: Don't use `e_shell_view_new()' to create new views for the shell - unless you know what you are doing; this is just the standard GTK+ - constructor thing and it won't allow the shell to do the required - bookkeeping for the created views. Instead, the right way to create a new - view is calling `e_shell_create_view()'. */ -EShellView * -e_shell_view_new (EShell *shell, - const char *uri) -{ - GtkWidget *new; - - g_return_val_if_fail (shell != NULL, NULL); - g_return_val_if_fail (E_IS_SHELL (shell), NULL); - - new = g_object_new (e_shell_view_get_type (), NULL); - - return e_shell_view_construct (E_SHELL_VIEW (new), shell, uri); -} - -const GNOME_Evolution_ShellView -e_shell_view_get_corba_interface (EShellView *shell_view) -{ - EShellViewPrivate *priv; - - g_return_val_if_fail (shell_view != NULL, CORBA_OBJECT_NIL); - g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), CORBA_OBJECT_NIL); - - priv = shell_view->priv; - - return priv->corba_interface; -} - - -static const char * -get_storage_set_path_from_uri (const char *uri) -{ - const char *colon; - - if (uri == NULL) - return NULL; - - if (g_path_is_absolute (uri)) - return NULL; - - colon = strchr (uri, ':'); - if (colon == NULL || colon == uri || colon[1] == '\0') - return NULL; - - if (! g_path_is_absolute (colon + 1)) - return NULL; - - if (g_ascii_strncasecmp (uri, E_SHELL_URI_PREFIX, colon - uri) != 0) - return NULL; - - return colon + 1; -} - -static void -update_window_icon (EShellView *shell_view, - const char *type) -{ - EShellViewPrivate *priv; - const char *icon_name; - char *icon_path; - - priv = shell_view->priv; - - if (type == NULL) { - icon_path = NULL; - } else { - EFolderTypeRegistry *folder_type_registry; - - folder_type_registry = e_shell_get_folder_type_registry (priv->shell); - icon_name = e_folder_type_registry_get_icon_name_for_type (folder_type_registry, type); - if (icon_name == NULL) - icon_path = NULL; - else - icon_path = e_shell_get_icon_path (icon_name, FALSE); - } - - if (icon_path == NULL) { - gnome_window_icon_set_from_default (GTK_WINDOW (shell_view)); - } else { - gnome_window_icon_set_from_file (GTK_WINDOW (shell_view), icon_path); - g_free (icon_path); - } -} - -static void -update_folder_title_bar (EShellView *shell_view, - const char *title, - EFolder *folder) -{ - EShellViewPrivate *priv; - GdkPixbuf *folder_icon; - - priv = shell_view->priv; - - if (folder == NULL) { - folder_icon = NULL; - } else { - const char *icon_name; - - icon_name = e_folder_get_custom_icon_name (folder); - if (icon_name != NULL) { - folder_icon = e_icon_factory_get_icon (icon_name, TRUE); - } else { - EFolderTypeRegistry *folder_type_registry; - - folder_type_registry = e_shell_get_folder_type_registry (priv->shell); - folder_icon = e_folder_type_registry_get_icon_for_type (folder_type_registry, - e_folder_get_type_string (folder), - TRUE); - g_object_ref (folder_icon); - } - } - - e_shell_folder_title_bar_set_icon (E_SHELL_FOLDER_TITLE_BAR (priv->folder_title_bar), - folder_icon); - - if (folder_icon != NULL) - g_object_unref (folder_icon); - - if (title != NULL) - e_shell_folder_title_bar_set_title (E_SHELL_FOLDER_TITLE_BAR (priv->folder_title_bar), title); -} - -static void -update_for_current_uri (EShellView *shell_view) -{ - EShellViewPrivate *priv; - EFolder *folder; - const char *path; - const char *curr_path; - const char *type; - const char *folder_name; - char *title; - char *window_title; - int unread_count; - - priv = shell_view->priv; - - /* If we update when there is a timeout set, the selection will jump - around against the user's wishes. So we just return. */ - if (priv->set_folder_timeout != 0) - return; - - path = get_storage_set_path_from_uri (priv->uri); - - folder = NULL; - folder_name = NULL; - type = NULL; - unread_count = 0; - - if (path != NULL) { - folder = e_storage_set_get_folder (e_shell_get_storage_set (priv->shell), path); - - if (folder != NULL) { - folder_name = e_folder_get_name (folder); - type = e_folder_get_type_string (folder); - unread_count = e_folder_get_unread_count (folder); - } - } - - if (unread_count > 0) - title = g_strdup_printf (_("%s (%d)"), folder_name, unread_count); - else if (folder_name == NULL) - title = g_strdup (_("(None)")); - else - title = g_strdup (folder_name); - - window_title = g_strdup_printf ("%s - Ximian Evolution", title); - - gtk_window_set_title (GTK_WINDOW (shell_view), window_title); - - update_folder_title_bar (shell_view, title, folder); - update_window_icon (shell_view, type); - - g_free (window_title); - g_free (title); - - g_signal_handlers_block_by_func (priv->storage_set_view, - G_CALLBACK (folder_selected_cb), shell_view); - - curr_path = e_storage_set_view_get_current_folder (E_STORAGE_SET_VIEW (priv->storage_set_view)); - if (path != NULL && (curr_path == NULL || strcmp(path, curr_path))) - e_storage_set_view_set_current_folder (E_STORAGE_SET_VIEW (priv->storage_set_view), path); - - g_signal_handlers_unblock_by_func (priv->storage_set_view, - G_CALLBACK (folder_selected_cb), shell_view); -} - -static void -update_offline_toggle_status (EShellView *shell_view) -{ - EShellViewPrivate *priv; - GdkPixmap *icon_pixmap; - GdkBitmap *icon_mask; - const char *tooltip; - gboolean sensitive; - - priv = shell_view->priv; - - switch (e_shell_get_line_status (priv->shell)) { - case E_SHELL_LINE_STATUS_ONLINE: - icon_pixmap = online_pixmap; - icon_mask = online_mask; - sensitive = TRUE; - tooltip = _("Ximian Evolution is currently online. " - "Click on this button to work offline."); - break; - case E_SHELL_LINE_STATUS_GOING_OFFLINE: - icon_pixmap = online_pixmap; - icon_mask = online_mask; - sensitive = FALSE; - tooltip = _("Ximian Evolution is in the process of going offline."); - break; - case E_SHELL_LINE_STATUS_OFFLINE: - icon_pixmap = offline_pixmap; - icon_mask = offline_mask; - sensitive = TRUE; - tooltip = _("Ximian Evolution is currently offline. " - "Click on this button to work online."); - break; - default: - g_assert_not_reached (); - return; - } - - gtk_image_set_from_pixmap (GTK_IMAGE (priv->offline_toggle_image), icon_pixmap, icon_mask); - gtk_widget_set_sensitive (priv->offline_toggle, sensitive); - gtk_tooltips_set_tip (priv->tooltips, priv->offline_toggle, tooltip, NULL); -} - -static void -update_send_receive_sensitivity (EShellView *shell_view) -{ - if (e_shell_get_line_status (shell_view->priv->shell) == E_SHELL_LINE_STATUS_OFFLINE) - bonobo_ui_component_set_prop (shell_view->priv->ui_component, - "/commands/SendReceive", - "sensitive", "0", NULL); - else - bonobo_ui_component_set_prop (shell_view->priv->ui_component, - "/commands/SendReceive", - "sensitive", "1", NULL); -} - - -/* This displays the specified page, doing the appropriate Bonobo activation/deactivation - magic to make sure things work nicely. FIXME: Crappy way to solve the issue. */ -static void -set_current_notebook_page (EShellView *shell_view, - int page_num) -{ - EShellViewPrivate *priv; - GtkNotebook *notebook; - GtkWidget *current; - BonoboControlFrame *old_control_frame = NULL; - BonoboControlFrame *new_control_frame; - int current_page; - - priv = shell_view->priv; - notebook = GTK_NOTEBOOK (priv->notebook); - - current_page = gtk_notebook_get_current_page (notebook); - if (current_page == page_num) - return; - - if (current_page != -1 && current_page != 0) { - current = gtk_notebook_get_nth_page (notebook, current_page); - old_control_frame = bonobo_widget_get_control_frame (BONOBO_WIDGET (current)); - bonobo_control_frame_set_autoactivate (old_control_frame, FALSE); - } - - e_shell_folder_title_bar_set_folder_bar_label (E_SHELL_FOLDER_TITLE_BAR (priv->folder_title_bar), ""); - gtk_notebook_set_current_page (notebook, page_num); - - if (page_num == -1 || page_num == 0) - return; - - current = gtk_notebook_get_nth_page (notebook, page_num); - new_control_frame = bonobo_widget_get_control_frame (BONOBO_WIDGET (current)); - bonobo_control_frame_set_autoactivate (new_control_frame, FALSE); - - bonobo_control_frame_control_activate (new_control_frame); - if (old_control_frame) - bonobo_control_frame_control_deactivate (old_control_frame); -} - -static void -setup_corba_interface (EShellView *shell_view, - GtkWidget *control) -{ - EShellViewPrivate *priv; - BonoboControlFrame *control_frame; - EvolutionShellView *corba_interface; - CORBA_Environment ev; - - g_return_if_fail (control != NULL); - - priv = shell_view->priv; - - control_frame = bonobo_widget_get_control_frame (BONOBO_WIDGET (control)); - corba_interface = evolution_shell_view_new (); - - g_signal_connect_object (corba_interface, "set_message", - G_CALLBACK (corba_interface_set_message_cb), shell_view, 0); - g_signal_connect_object (corba_interface, "unset_message", - G_CALLBACK (corba_interface_unset_message_cb), shell_view, 0); - g_signal_connect_object (corba_interface, "change_current_view", - G_CALLBACK (corba_interface_change_current_view_cb), shell_view, 0); - g_signal_connect_object (corba_interface, "set_title", - G_CALLBACK (corba_interface_set_title), shell_view, 0); - g_signal_connect_object (corba_interface, "set_folder_bar_label", - G_CALLBACK (corba_interface_set_folder_bar_label), shell_view, 0); - g_signal_connect_object (corba_interface, "show_settings", - G_CALLBACK (corba_interface_show_settings), shell_view, 0); - - bonobo_object_add_interface (BONOBO_OBJECT (control_frame), - BONOBO_OBJECT (corba_interface)); - - - /* Get rid of the existing one first */ - bonobo_object_release_unref (priv->corba_interface, NULL); - - /* Now find the existing one */ - CORBA_exception_init (&ev); - priv->corba_interface = Bonobo_Unknown_queryInterface (BONOBO_OBJREF (control_frame), - "IDL:GNOME/Evolution/ShellView:1.0", - &ev); - if (BONOBO_EX (&ev)) - priv->corba_interface = CORBA_OBJECT_NIL; - CORBA_exception_free (&ev); -} - - -/* Socket destruction handling. */ - -static void -socket_destroy_cb (GtkWidget *socket_widget, gpointer data) -{ - EShellView *shell_view; - EShellViewPrivate *priv; - EFolder *folder; - View *view; - const char *uri; - gboolean viewing_closed_uri; - const char *current_uri; - const char *path; - const char *folder_type; - - shell_view = E_SHELL_VIEW (data); - priv = shell_view->priv; - - uri = (const char *) g_object_get_data (G_OBJECT (socket_widget), "e_shell_view_folder_uri"); - - view = g_hash_table_lookup (priv->uri_to_view, uri); - if (view == NULL) { - g_warning ("What?! Destroyed socket for non-existing URI? -- %s", uri); - return; - } - - priv->sockets = g_list_remove (priv->sockets, socket_widget); - - gtk_widget_destroy (view->control); - - g_hash_table_remove (priv->uri_to_view, view->uri); - view_destroy (view); - - path = get_storage_set_path_from_uri (uri); - folder = e_storage_set_get_folder (e_shell_get_storage_set (priv->shell), path); - - if (folder != NULL) - folder_type = e_folder_get_type_string (folder); - else - folder_type = NULL; - - /* See if we were actively viewing the uri for the socket that's being closed */ - current_uri = e_shell_view_get_current_uri (shell_view); - if (current_uri == NULL) { - viewing_closed_uri = FALSE; - } else { - if (strcmp (uri, current_uri) == 0) - viewing_closed_uri = TRUE; - else - viewing_closed_uri = FALSE; - } - - if (viewing_closed_uri) - e_shell_view_display_uri (shell_view, NULL, TRUE); - - e_shell_component_maybe_crashed (priv->shell, uri, folder_type, shell_view); - - /* We were actively viewing the component that just crashed, so flip to the default URI */ - if (viewing_closed_uri) - e_shell_view_display_uri (shell_view, E_SHELL_VIEW_DEFAULT_URI, TRUE); -} - - -static const char * -get_type_for_folder (EShellView *shell_view, - const char *path, - const char **physical_uri_return) -{ - EShellViewPrivate *priv; - EStorageSet *storage_set; - EFolder *folder; - - priv = shell_view->priv; - - storage_set = e_shell_get_storage_set (priv->shell); - folder = e_storage_set_get_folder (storage_set, path); - if (!folder) - return NULL; - - if (physical_uri_return != NULL) - *physical_uri_return = e_folder_get_physical_uri (folder); - - return e_folder_get_type_string (folder); -} - -/* Create a new view for @uri with @control. It assumes a view for @uri does not exist yet. */ -static View * -get_view_for_uri (EShellView *shell_view, - const char *uri, - const char *view_info) -{ - EShellViewPrivate *priv; - CORBA_Environment ev; - EvolutionShellComponentClient *handler_client; - EFolderTypeRegistry *folder_type_registry; - GNOME_Evolution_ShellComponent handler; - Bonobo_UIContainer container; - GtkWidget *control; - GtkWidget *socket; - Bonobo_Control corba_control; - const char *path; - const char *physical_uri; - const char *folder_type; - int destroy_connection_id; - - priv = shell_view->priv; - - path = strchr (uri, ':'); - if (path == NULL) - return NULL; - - path++; - if (*path == '\0') - return NULL; - - folder_type = get_type_for_folder (shell_view, path, &physical_uri); - if (folder_type == NULL || physical_uri == NULL) - return NULL; - - folder_type_registry = e_shell_get_folder_type_registry (e_shell_view_get_shell (shell_view)); - - handler_client = e_folder_type_registry_get_handler_for_type (folder_type_registry, folder_type); - if (handler_client == CORBA_OBJECT_NIL) - return NULL; - - handler = evolution_shell_component_client_corba_objref (handler_client); - - CORBA_exception_init (&ev); - - corba_control = GNOME_Evolution_ShellComponent_createView (handler, physical_uri, folder_type, view_info, &ev); - - if (ev._major != CORBA_NO_EXCEPTION) { - CORBA_exception_free (&ev); - return NULL; - } - - CORBA_exception_free (&ev); - - if (corba_control == CORBA_OBJECT_NIL) - return NULL; - - container = bonobo_ui_component_get_container (priv->ui_component); - control = bonobo_widget_new_control_from_objref (corba_control, container); - bonobo_object_release_unref (corba_control, NULL); - - socket = find_socket (GTK_CONTAINER (control)); - destroy_connection_id = g_signal_connect (socket, "destroy", - G_CALLBACK (socket_destroy_cb), - shell_view); - g_object_set_data (G_OBJECT (socket), "e_shell_view_destroy_connection_id", GINT_TO_POINTER (destroy_connection_id)); - g_object_set_data_full (G_OBJECT (socket), "e_shell_view_folder_uri", g_strdup (uri), g_free); - - priv->sockets = g_list_prepend (priv->sockets, socket); - - setup_corba_interface (shell_view, control); - - return view_new (uri, control); -} - -static gboolean -show_existing_view (EShellView *shell_view, - const char *uri, - View *view) -{ - EShellViewPrivate *priv; - int notebook_page; - - priv = shell_view->priv; - - notebook_page = gtk_notebook_page_num (GTK_NOTEBOOK (priv->notebook), view->control); - g_assert (notebook_page != -1); - - g_free (priv->uri); - priv->uri = g_strdup (uri); - - set_current_notebook_page (shell_view, notebook_page); - - return TRUE; -} - -static gboolean -create_new_view_for_uri (EShellView *shell_view, - const char *uri, - const char *view_info) -{ - View *view; - EShellViewPrivate *priv; - int page_num; - - priv = shell_view->priv; - - view = get_view_for_uri (shell_view, uri, view_info); - if (view == NULL) - return FALSE; - - g_free (priv->uri); - priv->uri = g_strdup (uri); - - gtk_widget_show (view->control); - - gtk_notebook_append_page (GTK_NOTEBOOK (priv->notebook), view->control, NULL); - - page_num = gtk_notebook_page_num (GTK_NOTEBOOK (priv->notebook), view->control); - g_assert (page_num != -1); - set_current_notebook_page (shell_view, page_num); - - g_hash_table_insert (priv->uri_to_view, view->uri, view); - - return TRUE; -} - -static char * -evolution_uri_for_default_uri (EShell *shell, - const char *default_uri) -{ - char *uri; - char *path; - char *extra; - - if (! e_shell_parse_uri (shell, default_uri, &path, &extra)) - return NULL; - - uri = g_strconcat (E_SHELL_URI_PREFIX, path, "#", extra, NULL); - - g_free (path); - g_free (extra); - - return uri; -} - -static gboolean -display_uri (EShellView *shell_view, - const char *uri, - gboolean add_to_history, - gboolean queue) -{ - EShellViewPrivate *priv; - View *view; - gboolean retval; - const char *view_info; - char *real_uri = NULL; - char *allocated_uri = NULL; - - priv = shell_view->priv; - - if (uri == NULL && priv->uri == NULL) - return TRUE; - - if (priv->uri != NULL && uri != NULL && strcmp (priv->uri, uri) == 0) - return TRUE; - - bonobo_ui_engine_freeze (bonobo_window_get_ui_engine (BONOBO_WINDOW (shell_view))); - - if (uri == NULL) { - gtk_notebook_remove_page (GTK_NOTEBOOK (priv->notebook), 0); - gtk_notebook_prepend_page (GTK_NOTEBOOK (priv->notebook), create_label_for_empty_page (), NULL); - - set_current_notebook_page (shell_view, 0); - - g_free (priv->uri); - priv->uri = real_uri = NULL; - - retval = TRUE; - goto end; - } - - if (strncmp (uri, E_SHELL_DEFAULTURI_PREFIX, E_SHELL_DEFAULTURI_PREFIX_LEN) == 0) { - allocated_uri = evolution_uri_for_default_uri (e_shell_view_get_shell (shell_view), uri); - if (allocated_uri == NULL) { - retval = FALSE; - goto end; - } - - uri = allocated_uri; - } - - view_info = strchr (uri, '#'); - if (view_info) { - real_uri = g_strndup (uri, view_info - uri); - view_info++; - } else { - view_info = ""; - real_uri = g_strdup (uri); - } - - if (strncmp (uri, E_SHELL_URI_PREFIX, E_SHELL_URI_PREFIX_LEN) != 0) { - retval = FALSE; - goto end; - } - - view = g_hash_table_lookup (priv->uri_to_view, real_uri); - if (view != NULL) { - show_existing_view (shell_view, real_uri, view); - } else if (! create_new_view_for_uri (shell_view, real_uri, view_info)) { - if (! queue) { - retval = FALSE; - goto end; - } - - cleanup_delayed_selection (shell_view); - priv->delayed_selection = g_strdup (real_uri); - g_signal_connect_after (e_shell_get_storage_set (priv->shell), - "new_folder", G_CALLBACK (new_folder_cb), shell_view); - retval = TRUE; - goto end; - } - - retval = TRUE; - - end: - g_free (real_uri); - - if (add_to_history && retval == TRUE && priv->uri != NULL) - e_history_add (priv->history, g_strdup (priv->uri)); - - update_navigation_buttons (shell_view); - - g_free (priv->set_folder_uri); - priv->set_folder_uri = NULL; - - if (priv->set_folder_timeout != 0) { - gtk_timeout_remove (priv->set_folder_timeout); - priv->set_folder_timeout = 0; - } - - update_for_current_uri (shell_view); - - bonobo_ui_engine_thaw (bonobo_window_get_ui_engine (BONOBO_WINDOW (shell_view))); - - g_signal_emit (shell_view, signals[VIEW_CHANGED], 0, - e_shell_view_get_current_path (shell_view), - e_shell_view_get_current_uri (shell_view), - e_shell_view_get_current_folder_type (shell_view), - e_shell_view_get_current_component_id (shell_view)); - - g_free (allocated_uri); - - return retval; -} - -gboolean -e_shell_view_display_uri (EShellView *shell_view, - const char *uri, - gboolean queue) -{ - g_return_val_if_fail (shell_view != NULL, FALSE); - g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), FALSE); - - return display_uri (shell_view, uri, TRUE, queue); -} - - -void -e_shell_view_show_shortcut_bar (EShellView *shell_view, - gboolean show) -{ - EShellViewPrivate *priv; - - g_return_if_fail (shell_view != NULL); - g_return_if_fail (E_IS_SHELL_VIEW (shell_view)); - - priv = shell_view->priv; - - if (!! show == priv->shortcut_bar_shown) - return; - - if (show) { - if (! GTK_WIDGET_VISIBLE (priv->shortcut_frame)) { - gtk_widget_show (priv->shortcut_frame); - gtk_paned_set_position (GTK_PANED (priv->hpaned), priv->hpaned_position); - } - } else { - if (GTK_WIDGET_VISIBLE (priv->shortcut_frame)) { - /* FIXME this is a private field! */ - priv->hpaned_position = GTK_PANED (priv->hpaned)->child1_size; - - gtk_widget_hide (priv->shortcut_frame); - } - gtk_paned_set_position (GTK_PANED (priv->hpaned), 0); - } - - priv->shortcut_bar_shown = !! show; - - g_signal_emit (shell_view, signals[SHORTCUT_BAR_VISIBILITY_CHANGED], 0, - priv->shortcut_bar_shown); -} - -void -e_shell_view_show_folder_bar (EShellView *shell_view, - gboolean show) -{ - EShellViewPrivate *priv; - - g_return_if_fail (shell_view != NULL); - g_return_if_fail (E_IS_SHELL_VIEW (shell_view)); - - priv = shell_view->priv; - - if (!! show == priv->folder_bar_shown) - return; - - if (show) { - gtk_widget_show (priv->storage_set_view_box); - gtk_paned_set_position (GTK_PANED (priv->view_hpaned), priv->view_hpaned_position); - - 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_title_clickable (E_SHELL_FOLDER_TITLE_BAR (priv->folder_title_bar), - FALSE); - } else { - if (GTK_WIDGET_VISIBLE (priv->storage_set_view_box)) { - /* FIXME this is a private field! */ - priv->view_hpaned_position = GTK_PANED (priv->view_hpaned)->child1_size; - gtk_widget_hide (priv->storage_set_view_box); - } - - gtk_paned_set_position (GTK_PANED (priv->view_hpaned), 0); - - 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_title_clickable (E_SHELL_FOLDER_TITLE_BAR (priv->folder_title_bar), - TRUE); - } - - priv->folder_bar_shown = !! show; - - g_signal_emit (shell_view, signals[FOLDER_BAR_VISIBILITY_CHANGED], 0, - priv->folder_bar_shown); -} - -void -e_shell_view_show_settings (EShellView *shell_view) -{ - EShellViewPrivate *priv; - const char *type; - - g_return_if_fail (shell_view != NULL); - g_return_if_fail (E_IS_SHELL_VIEW (shell_view)); - - priv = shell_view->priv; - - type = e_shell_view_get_current_folder_type (shell_view); - e_shell_show_settings (priv->shell, type, shell_view); -} - -gboolean -e_shell_view_shortcut_bar_shown (EShellView *shell_view) -{ - g_return_val_if_fail (shell_view != NULL, FALSE); - g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), FALSE); - - return shell_view->priv->shortcut_bar_shown; -} - -gboolean -e_shell_view_folder_bar_shown (EShellView *shell_view) -{ - g_return_val_if_fail (shell_view != NULL, FALSE); - g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), FALSE); - - return shell_view->priv->folder_bar_shown; -} - - -ETaskBar * -e_shell_view_get_task_bar (EShellView *shell_view) -{ - g_return_val_if_fail (shell_view != NULL, NULL); - g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL); - - return E_TASK_BAR (shell_view->priv->task_bar); -} - -EShell * -e_shell_view_get_shell (EShellView *shell_view) -{ - g_return_val_if_fail (shell_view != NULL, NULL); - g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL); - - return shell_view->priv->shell; -} - -BonoboUIComponent * -e_shell_view_get_bonobo_ui_component (EShellView *shell_view) -{ - g_return_val_if_fail (shell_view != NULL, NULL); - g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL); - - return shell_view->priv->ui_component; -} - -BonoboUIContainer * -e_shell_view_get_bonobo_ui_container (EShellView *shell_view) -{ - g_return_val_if_fail (shell_view != NULL, NULL); - g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL); - - return shell_view->priv->ui_container; -} - -GtkWidget * -e_shell_view_get_appbar (EShellView *shell_view) -{ - g_return_val_if_fail (shell_view != NULL, NULL); - g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL); - - return shell_view->priv->appbar; -} - -/** - * e_shell_view_get_current_uri: - * @shell_view: A pointer to an EShellView object - * - * Get the URI currently displayed by this shell view. - * - * Return value: - **/ -const char * -e_shell_view_get_current_uri (EShellView *shell_view) -{ - g_return_val_if_fail (shell_view != NULL, NULL); - g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL); - - return shell_view->priv->uri; -} - -/** - * e_shell_view_get_current_path: - * @shell_view: A pointer to an EShellView object - * - * Get the path of the current displayed folder. - * - * Return value: - **/ -const char * -e_shell_view_get_current_path (EShellView *shell_view) -{ - const char *current_uri; - const char *current_path; - - current_uri = e_shell_view_get_current_uri (shell_view); - if (current_uri == NULL) - return NULL; - - if (strncmp (current_uri, E_SHELL_URI_PREFIX, E_SHELL_URI_PREFIX_LEN) == 0) - current_path = current_uri + E_SHELL_URI_PREFIX_LEN; - else - current_path = NULL; - - return current_path; -} - -const char * -e_shell_view_get_current_physical_uri (EShellView *shell_view) -{ - const char *current_path; - const char *physical_uri; - - g_return_val_if_fail (shell_view != NULL, NULL); - g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL); - - current_path = e_shell_view_get_current_path (shell_view); - if (current_path == NULL) - return NULL; - - if (get_type_for_folder (shell_view, current_path, &physical_uri) == NULL) - return NULL; - else - return physical_uri; -} - -const char * -e_shell_view_get_current_folder_type (EShellView *shell_view) -{ - const char *current_path; - - g_return_val_if_fail (shell_view != NULL, NULL); - g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL); - - current_path = e_shell_view_get_current_path (shell_view); - if (current_path == NULL) - return NULL; - - return get_type_for_folder (shell_view, current_path, NULL); -} - -const char * -e_shell_view_get_current_component_id (EShellView *shell_view) -{ - EShellViewPrivate *priv; - EFolderTypeRegistry *type_registry; - EvolutionShellComponentClient *component_client; - const char *current_folder_type; - - priv = shell_view->priv; - - type_registry = e_shell_get_folder_type_registry (priv->shell); - - current_folder_type = e_shell_view_get_current_folder_type (shell_view); - if (current_folder_type == NULL) - return NULL; - - component_client = e_folder_type_registry_get_handler_for_type (type_registry, current_folder_type); - if (component_client == NULL) - return NULL; - - return evolution_shell_component_client_get_id (component_client); -} - - -/** - * e_shell_view_save_defaults: - * @shell_view: - **/ -void -e_shell_view_save_defaults (EShellView *shell_view) -{ - GConfClient *client; - EShellViewPrivate *priv; - EShortcutBar *shortcut_bar; - const char *uri; - char *file_name; - struct stat temp; - - g_return_if_fail (shell_view != NULL); - g_return_if_fail (E_IS_SHELL_VIEW (shell_view)); - - priv = shell_view->priv; - shortcut_bar = E_SHORTCUT_BAR (priv->shortcut_bar); - - client = gconf_client_get_default (); - - gconf_client_set_int (client, "/apps/evolution/shell/view_defaults/width", - GTK_WIDGET (shell_view)->allocation.width, NULL); - gconf_client_set_int (client, "/apps/evolution/shell/view_defaults/height", - GTK_WIDGET (shell_view)->allocation.height, NULL); - - gconf_client_set_int (client, "/apps/evolution/shell/view_defaults/selected_shortcut_group", - e_shell_view_get_current_shortcuts_group_num (shell_view), NULL); - - gconf_client_set_bool (client, "/apps/evolution/shell/view_defaults/show_folder_bar", - e_shell_view_folder_bar_shown (shell_view), NULL); - gconf_client_set_bool (client, "/apps/evolution/shell/view_defaults/show_shortcut_bar", - e_shell_view_shortcut_bar_shown (shell_view), NULL); - - if (priv->shortcut_bar_shown) - gconf_client_set_int (client, "/apps/evolution/shell/view_defaults/shortcut_bar/width", - GTK_PANED (priv->hpaned)->child1_size, NULL); - else - gconf_client_set_int (client, "/apps/evolution/shell/view_defaults/shortcut_bar/width", - priv->hpaned_position, NULL); - - if (priv->folder_bar_shown) - gconf_client_set_int (client, "/apps/evolution/shell/view_defaults/folder_bar/width", - GTK_PANED (priv->view_hpaned)->child1_size, NULL); - else - gconf_client_set_int (client, "/apps/evolution/shell/view_defaults/folder_bar/width", - priv->view_hpaned_position, NULL); - - uri = e_shell_view_get_current_uri (shell_view); - if (uri != NULL) - gconf_client_set_string (client, "/apps/evolution/shell/view_defaults/folder_path", - uri + E_SHELL_URI_PREFIX_LEN, NULL); - else - gconf_client_unset (client, "/apps/evolution/shell/view_defaults/folder_path", NULL); - - /* If ~/evolution/config/ doesn't exist yet, make it */ - file_name = g_strdup_printf ("%s/config/", e_shell_get_local_directory (priv->shell)); - if (stat (file_name, &temp) != 0) - mkdir (file_name, S_IRWXU); - g_free (file_name); - - /* Save the expanded state for the StorageSetView. */ - - file_name = g_strdup_printf ("%s/config/storage-set-view-expanded:default", - e_shell_get_local_directory (priv->shell)); - e_tree_save_expanded_state (E_TREE (priv->storage_set_view), - file_name); - g_free (file_name); - - g_object_unref (client); -} - - -/* FIXME: This function could become static */ -void -e_shell_view_set_current_shortcuts_group_num (EShellView *shell_view, int group_num) -{ - EShellViewPrivate *priv; - EShortcutsView *shortcuts_view; - - g_return_if_fail (shell_view != NULL); - g_return_if_fail (E_IS_SHELL_VIEW (shell_view)); - - priv = shell_view->priv; - - shortcuts_view = E_SHORTCUTS_VIEW (priv->shortcut_bar); - - e_group_bar_set_current_group_num (E_GROUP_BAR (E_SHORTCUT_BAR (shortcuts_view)), group_num, FALSE); -} - -int -e_shell_view_get_current_shortcuts_group_num (EShellView *shell_view) -{ - EShellViewPrivate *priv; - EShortcutsView *shortcuts_view; - int group; - - g_return_val_if_fail (shell_view != NULL, -1); - g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), -1); - - priv = shell_view->priv; - - shortcuts_view = E_SHORTCUTS_VIEW (priv->shortcut_bar); - - group = e_group_bar_get_current_group_num (E_GROUP_BAR (E_SHORTCUT_BAR (shortcuts_view))); - - return group; -} - - -const char * -e_shell_view_get_folder_bar_right_click_path (EShellView *shell_view) -{ - EShellViewPrivate *priv; - - g_return_val_if_fail (shell_view != NULL, NULL); - g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL); - - priv = shell_view->priv; - - return e_storage_set_view_get_right_click_path (E_STORAGE_SET_VIEW (priv->storage_set_view)); -} - - -E_MAKE_TYPE (e_shell_view, "EShellView", EShellView, class_init, init, BONOBO_TYPE_WINDOW) diff --git a/shell/e-shell-view.h b/shell/e-shell-view.h deleted file mode 100644 index 7e3ec94806..0000000000 --- a/shell/e-shell-view.h +++ /dev/null @@ -1,128 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-shell-view.h - * - * Copyright (C) 2000 Ximian, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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 _E_SHELL_VIEW_H_ -#define _E_SHELL_VIEW_H_ - -#include "e-task-bar.h" - -#include <bonobo/bonobo-window.h> -#include <bonobo/bonobo-ui-component.h> -#include <bonobo/bonobo-ui-container.h> - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - - -#define E_TYPE_SHELL_VIEW (e_shell_view_get_type ()) -#define E_SHELL_VIEW(obj) (GTK_CHECK_CAST ((obj), E_TYPE_SHELL_VIEW, EShellView)) -#define E_SHELL_VIEW_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_TYPE_SHELL_VIEW, EShellViewClass)) -#define E_IS_SHELL_VIEW(obj) (GTK_CHECK_TYPE ((obj), E_TYPE_SHELL_VIEW)) -#define E_IS_SHELL_VIEW_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), E_TYPE_SHELL_VIEW)) - -typedef struct _EShellView EShellView; -typedef struct _EShellViewPrivate EShellViewPrivate; -typedef struct _EShellViewClass EShellViewClass; - -#include "e-shell.h" - -#define E_SHELL_VIEW_DEFAULT_URI "evolution:/summary" - -struct _EShellView { - BonoboWindow parent; - - EShellViewPrivate *priv; -}; - -struct _EShellViewClass { - BonoboWindowClass parent_class; - - /* Signals. */ - - void (* shortcut_bar_visibility_changed) (EShellView *shell_view, - gboolean visible); - void (* folder_bar_visibility_changed) (EShellView *shell_view, - gboolean visible); - - void (* view_changed) (EShellView *shell_view, - const char *evolution_path, - const char *physical_uri, - const char *folder_type, - const char *component_id); -}; - - -/* WARNING: Don't use `e_shell_view_new()' to create new views for the shell - unless you know what you are doing; this is just the standard GTK+ - constructor thing and it won't allow the shell to do the required - bookkeeping for the created views. Instead, the right way to create a new - view is calling `e_shell_new_view()'. */ - -GtkType e_shell_view_get_type (void); -EShellView *e_shell_view_construct (EShellView *shell_view, - EShell *shell, - const char *uri); -EShellView *e_shell_view_new (EShell *shell, - const char *uri); - -const GNOME_Evolution_ShellView e_shell_view_get_corba_interface (EShellView *view); - -gboolean e_shell_view_display_uri (EShellView *shell_view, - const char *uri, - gboolean queue); - -void e_shell_view_show_shortcut_bar (EShellView *shell_view, - gboolean show); -gboolean e_shell_view_shortcut_bar_shown (EShellView *shell_view); -void e_shell_view_show_folder_bar (EShellView *shell_view, - gboolean show); -gboolean e_shell_view_folder_bar_shown (EShellView *shell_view); - -void e_shell_view_show_settings (EShellView *shell_view); - -ETaskBar *e_shell_view_get_task_bar (EShellView *shell_view); -EShell *e_shell_view_get_shell (EShellView *shell_view); -BonoboUIComponent *e_shell_view_get_bonobo_ui_component (EShellView *shell_view); -BonoboUIContainer *e_shell_view_get_bonobo_ui_container (EShellView *shell_view); -GtkWidget *e_shell_view_get_appbar (EShellView *shell_view); -const char *e_shell_view_get_current_uri (EShellView *shell_view); -const char *e_shell_view_get_current_physical_uri (EShellView *shell_view); -const char *e_shell_view_get_current_folder_type (EShellView *shell_view); -const char *e_shell_view_get_current_component_id (EShellView *shell_view); -const char *e_shell_view_get_current_path (EShellView *shell_view); - -void e_shell_view_save_defaults (EShellView *shell_view); - -int e_shell_view_get_current_shortcuts_group_num (EShellView *shell_view); -void e_shell_view_set_current_shortcuts_group_num (EShellView *shell_view, - int group_num); - -/* Private -- */ -const char *e_shell_view_get_folder_bar_right_click_path (EShellView *shell_view); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _E_SHELL_VIEW_H_ */ diff --git a/shell/e-shell.c b/shell/e-shell.c index 9b803efb2a..22cb17e7b4 100644 --- a/shell/e-shell.c +++ b/shell/e-shell.c @@ -32,11 +32,9 @@ #include "e-shell-constants.h" #include "e-shell-settings-dialog.h" #include "e-shell-startup-wizard.h" -#include "e-uri-schema-registry.h" #include "e-shell-marshal.h" -#include "evolution-shell-component-client.h" #include "evolution-shell-component-utils.h" #include "importer/intelligent.h" @@ -79,7 +77,7 @@ struct _EShellPrivate { GList *windows; EUserCreatableItemsHandler *user_creatable_items_handler; - EUriSchemaRegistry *uri_schema_registry; + /* EUriSchemaRegistry *uri_schema_registry; FIXME */ EComponentRegistry *component_registry; /* Names for the types of the folders that have maybe crashed. */ @@ -195,6 +193,7 @@ impl_Shell_handleURI (PortableServer_Servant servant, const CORBA_char *uri, CORBA_Environment *ev) { +#if 0 EvolutionShellComponentClient *schema_handler; EShell *shell; EShellPrivate *priv; @@ -239,6 +238,7 @@ impl_Shell_handleURI (PortableServer_Servant servant, ex_GNOME_Evolution_Shell_NotFound, NULL); return; } +#endif } static void @@ -360,10 +360,12 @@ impl_dispose (GObject *object) priv->user_creatable_items_handler = NULL; } +#if 0 /* FIXME */ if (priv->uri_schema_registry != NULL) { g_object_unref (priv->uri_schema_registry); priv->uri_schema_registry = NULL; } +#endif for (p = priv->windows; p != NULL; p = p->next) { EShellWindow *window; @@ -644,6 +646,7 @@ e_shell_request_close_window (EShell *shell, } +#if 0 /* FIXME */ /** * e_shell_peek_uri_schema_registry: * @shell: An EShell object. @@ -659,6 +662,8 @@ e_shell_peek_uri_schema_registry (EShell *shell) return shell->priv->uri_schema_registry; } +#endif + /** * e_shell_peek_component_registry: diff --git a/shell/e-shell.h b/shell/e-shell.h index 84f73f3b1d..712fda8033 100644 --- a/shell/e-shell.h +++ b/shell/e-shell.h @@ -39,7 +39,6 @@ typedef struct _EShellClass EShellClass; #include "e-component-registry.h" #include "e-shell-window.h" -#include "e-uri-schema-registry.h" #include "e-user-creatable-items-handler.h" @@ -108,7 +107,10 @@ gboolean e_shell_request_close_window (EShell *shell, EShellWindow *window); +#if 0 EUriSchemaRegistry *e_shell_peek_uri_schema_registry (EShell *shell); +#endif + EComponentRegistry *e_shell_peek_component_registry (EShell *shell); gboolean e_shell_save_settings (EShell *shell); diff --git a/shell/e-storage-browser.c b/shell/e-storage-browser.c deleted file mode 100644 index d487144b83..0000000000 --- a/shell/e-storage-browser.c +++ /dev/null @@ -1,347 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-storage-browser.c - * - * Copyright (C) 2003 Ximian, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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 <ettore@ximian.com> - */ - -/* TODO: - - - Currently it assumes that the starting path always exists, and you - can't remove it. It might be a limitation, but it makes the logic - very simple and robust. - - - Doesn't save expansion state for nodes. - - - Context menu handling? - -*/ - -#include <config.h> - -#include "e-storage-browser.h" - -#include "e-shell-marshal.h" -#include "e-storage-set-view.h" - -#include <gal/util/e-util.h> - -#include <gtk/gtknotebook.h> -#include <gtk/gtkscrolledwindow.h> -#include <string.h> - - -#define PARENT_TYPE G_TYPE_OBJECT -static GObjectClass *parent_class = NULL; - - -struct _EStorageBrowserPrivate { - char *starting_path; - char *current_path; - - GtkWidget *view_notebook; - GtkWidget *storage_set_view; - GtkWidget *storage_set_view_scrolled; - - GHashTable *path_to_view; /* (char *, GtkWidget *) */ - - EStorageBrowserCreateViewCallback create_view_callback; - void *create_view_callback_data; -}; - - -enum { - WIDGETS_GONE, - PAGE_SWITCHED, - NUM_SIGNALS -}; - -static unsigned int signals[NUM_SIGNALS] = { 0 }; - - -/* Callbacks. */ - -static void -storage_set_view_folder_selected_callback (EStorageSetView *storage_set_view, - const char *path, - EStorageBrowser *browser) -{ - if (! e_storage_browser_show_path (browser, path)) { - /* Make the selection go back to where it was. */ - e_storage_browser_show_path (browser, browser->priv->current_path); - } -} - -static void -storage_set_removed_folder_callback (EStorageSet *storage_set, - const char *path, - EStorageBrowser *browser) -{ - if (g_hash_table_lookup (browser->priv->path_to_view, path) != NULL) - e_storage_browser_remove_view_for_path (browser, path); -} - -static void -view_notebook_weak_notify (EStorageBrowser *browser) -{ - browser->priv->view_notebook = NULL; - - if (browser->priv->storage_set_view == NULL) - g_signal_emit (browser, signals[WIDGETS_GONE], 0); -} - -static void -storage_set_view_weak_notify (EStorageBrowser *browser) -{ - browser->priv->storage_set_view = NULL; - - if (browser->priv->view_notebook == NULL) - g_signal_emit (browser, signals[WIDGETS_GONE], 0); -} - - -/* GObject methods. */ - -static void -impl_dispose (GObject *object) -{ - EStorageBrowserPrivate *priv = E_STORAGE_BROWSER (object)->priv; - - if (priv->view_notebook != NULL) { - g_object_weak_unref (G_OBJECT (priv->view_notebook), - (GWeakNotify) view_notebook_weak_notify, - object); - priv->view_notebook = NULL; - } - - if (priv->storage_set_view != NULL) { - g_object_weak_unref (G_OBJECT (priv->storage_set_view), - (GWeakNotify) storage_set_view_weak_notify, - object); - priv->storage_set_view = NULL; - } - - (* G_OBJECT_CLASS (parent_class)->dispose) (object); -} - -static void -impl_finalize (GObject *object) -{ - EStorageBrowserPrivate *priv = E_STORAGE_BROWSER (object)->priv; - - g_free (priv->starting_path); - g_free (priv->current_path); - - g_hash_table_destroy (priv->path_to_view); - - g_free (priv); - - (* G_OBJECT_CLASS (parent_class)->finalize) (object); -} - - -/* Initialization. */ - -static void -class_init (EStorageBrowserClass *class) -{ - GObjectClass *object_class = G_OBJECT_CLASS (class); - - object_class->dispose = impl_dispose; - object_class->finalize = impl_finalize; - - parent_class = g_type_class_peek_parent (class); - - signals[WIDGETS_GONE] - = g_signal_new ("widgets_gone", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (EStorageBrowserClass, widgets_gone), - NULL, NULL, - e_shell_marshal_NONE__NONE, - G_TYPE_NONE, 0); - - signals[PAGE_SWITCHED] - = g_signal_new ("page_switched", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (EStorageBrowserClass, page_switched), - NULL, NULL, - e_shell_marshal_NONE__POINTER_POINTER, - G_TYPE_NONE, 2, - G_TYPE_POINTER, G_TYPE_POINTER); -} - -static void -init (EStorageBrowser *browser) -{ - EStorageBrowserPrivate *priv; - - priv = g_new0 (EStorageBrowserPrivate, 1); - - priv->path_to_view = g_hash_table_new_full (g_str_hash, g_str_equal, - (GDestroyNotify) g_free, - (GDestroyNotify) g_object_unref); - - priv->view_notebook = gtk_notebook_new (); - g_object_weak_ref (G_OBJECT (priv->view_notebook), (GWeakNotify) view_notebook_weak_notify, browser); - - gtk_notebook_set_show_border (GTK_NOTEBOOK (priv->view_notebook), FALSE); - gtk_notebook_set_show_tabs (GTK_NOTEBOOK (priv->view_notebook), FALSE); - - browser->priv = priv; -} - - -EStorageBrowser * -e_storage_browser_new (EStorageSet *storage_set, - const char *starting_path, - EStorageBrowserCreateViewCallback create_view_callback, - void *callback_data) -{ - EStorageBrowser *new; - - g_return_val_if_fail (create_view_callback != NULL, NULL); - - new = g_object_new (e_storage_browser_get_type (), NULL); - - new->priv->create_view_callback = create_view_callback; - new->priv->create_view_callback_data = callback_data; - new->priv->starting_path = g_strdup (starting_path); - - new->priv->storage_set_view = e_storage_set_create_new_view (storage_set, NULL); - gtk_widget_show (new->priv->storage_set_view); - - new->priv->storage_set_view_scrolled = gtk_scrolled_window_new (NULL, NULL); - gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (new->priv->storage_set_view_scrolled), GTK_SHADOW_IN); - gtk_container_add (GTK_CONTAINER (new->priv->storage_set_view_scrolled), new->priv->storage_set_view); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (new->priv->storage_set_view_scrolled), - GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - - g_object_weak_ref (G_OBJECT (new->priv->storage_set_view), (GWeakNotify) storage_set_view_weak_notify, new); - - g_signal_connect_object (new->priv->storage_set_view, - "folder_selected", G_CALLBACK (storage_set_view_folder_selected_callback), - G_OBJECT (new), 0); - g_signal_connect_object (e_storage_set_view_get_storage_set (E_STORAGE_SET_VIEW (new->priv->storage_set_view)), - "removed_folder", G_CALLBACK (storage_set_removed_folder_callback), - G_OBJECT (new), 0); - - if (! e_storage_browser_show_path (new, starting_path)) { - g_object_unref (new); - return NULL; - } - - return new; -} - - -GtkWidget * -e_storage_browser_peek_tree_widget (EStorageBrowser *browser) -{ - return browser->priv->storage_set_view; -} - -GtkWidget * -e_storage_browser_peek_tree_widget_scrolled (EStorageBrowser *browser) -{ - return browser->priv->storage_set_view_scrolled; -} - -GtkWidget * -e_storage_browser_peek_view_widget (EStorageBrowser *browser) -{ - return browser->priv->view_notebook; -} - -EStorageSet * -e_storage_browser_peek_storage_set (EStorageBrowser *browser) -{ - return e_storage_set_view_get_storage_set (E_STORAGE_SET_VIEW (browser->priv->storage_set_view)); -} - -gboolean -e_storage_browser_show_path (EStorageBrowser *browser, - const char *path) -{ - EStorageBrowserPrivate *priv = browser->priv; - GtkWidget *current_view; - GtkWidget *existing_view; - GtkWidget *new_view; - GtkNotebook *notebook; - - notebook = GTK_NOTEBOOK (priv->view_notebook); - - current_view = gtk_notebook_get_nth_page (GTK_NOTEBOOK (priv->view_notebook), - gtk_notebook_get_current_page (GTK_NOTEBOOK (priv->view_notebook))); - - existing_view = g_hash_table_lookup (priv->path_to_view, path); - if (existing_view != NULL) { - gtk_notebook_set_current_page (notebook, gtk_notebook_page_num (notebook, existing_view)); - g_print ("page switched\n"); - g_signal_emit (browser, signals[PAGE_SWITCHED], 0, current_view, existing_view); - return TRUE; - } - - new_view = (* priv->create_view_callback) (browser, path, priv->create_view_callback_data); - if (new_view == NULL) - return FALSE; - - gtk_widget_show (new_view); - gtk_notebook_append_page (notebook, new_view, NULL); - gtk_notebook_set_current_page (notebook, gtk_notebook_page_num (notebook, new_view)); - - g_print ("page switched\n"); - g_signal_emit (browser, signals[PAGE_SWITCHED], 0, current_view, new_view); - - g_object_ref(new_view); - g_hash_table_insert (priv->path_to_view, g_strdup (path), new_view); - - g_free (priv->current_path); - priv->current_path = g_strdup (path); - - e_storage_set_view_set_current_folder (E_STORAGE_SET_VIEW (priv->storage_set_view), path); - - return TRUE; -} - -void -e_storage_browser_remove_view_for_path (EStorageBrowser *browser, - const char *path) -{ - GtkWidget *view; - - if (strcmp (path, browser->priv->starting_path) == 0) { - g_warning (G_GNUC_FUNCTION ": cannot remove starting view"); - return; - } - - view = g_hash_table_lookup (browser->priv->path_to_view, path); - if (view == NULL) { - g_warning (G_GNUC_FUNCTION ": no view for %s", path); - return; - } - - g_hash_table_remove (browser->priv->path_to_view, path); - gtk_widget_destroy (view); - - e_storage_browser_show_path (browser, browser->priv->starting_path); -} - - -E_MAKE_TYPE (e_storage_browser, "EStorageBrowser", EStorageBrowser, class_init, init, PARENT_TYPE) diff --git a/shell/e-storage-browser.h b/shell/e-storage-browser.h deleted file mode 100644 index f500134704..0000000000 --- a/shell/e-storage-browser.h +++ /dev/null @@ -1,84 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-storage-browser.h - * - * Copyright (C) 2003 Ximian, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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 <ettore@ximian.com> - */ - -#ifndef _E_STORAGE_BROWSER_H_ -#define _E_STORAGE_BROWSER_H_ - -#include "e-storage-set.h" - -#include <glib-object.h> -#include <gtk/gtkwidget.h> - - -#define E_TYPE_STORAGE_BROWSER (e_storage_browser_get_type ()) -#define E_STORAGE_BROWSER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_STORAGE_BROWSER, EStorageBrowser)) -#define E_STORAGE_BROWSER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_STORAGE_BROWSER, EStorageBrowserClass)) -#define E_IS_BROWSER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_STORAGE_BROWSER)) -#define E_IS_BROWSER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), E_TYPE_STORAGE_BROWSER)) - - -typedef struct _EStorageBrowser EStorageBrowser; -typedef struct _EStorageBrowserPrivate EStorageBrowserPrivate; -typedef struct _EStorageBrowserClass EStorageBrowserClass; - -/* FIXME: Use a GClosure instead of void *? */ -typedef GtkWidget * (* EStorageBrowserCreateViewCallback) (EStorageBrowser *browser, - const char *path, - void *data); - - -struct _EStorageBrowser { - GObject parent; - - EStorageBrowserPrivate *priv; -}; - -struct _EStorageBrowserClass { - GObjectClass parent_class; - - void (* widgets_gone) (EStorageBrowser *browser); - - void (* page_switched) (EStorageBrowser *browser, - GtkWidget *old_page, - GtkWidget *new_page); -}; - - -GType e_storage_browser_get_type (void); - -EStorageBrowser *e_storage_browser_new (EStorageSet *storage_set, - const char *starting_path, - EStorageBrowserCreateViewCallback create_view_callback, - void *create_view_callback_data); - -GtkWidget *e_storage_browser_peek_tree_widget (EStorageBrowser *browser); -GtkWidget *e_storage_browser_peek_tree_widget_scrolled (EStorageBrowser *browser); -GtkWidget *e_storage_browser_peek_view_widget (EStorageBrowser *browser); -EStorageSet *e_storage_browser_peek_storage_set (EStorageBrowser *browser); - -gboolean e_storage_browser_show_path (EStorageBrowser *browser, - const char *path); -void e_storage_browser_remove_view_for_path (EStorageBrowser *browser, - const char *path); - - -#endif /* _E_STORAGE_BROWSER_H_ */ diff --git a/shell/e-storage-set-view.c b/shell/e-storage-set-view.c deleted file mode 100644 index 1738836216..0000000000 --- a/shell/e-storage-set-view.c +++ /dev/null @@ -1,2042 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-storage-set-view.c - * - * Copyright (C) 2000, 2001, 2002 Ximian, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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 - * Etree-ification: Chris Toshok - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include "e-storage-set-view.h" - -#include "e-util/e-gtk-utils.h" - -#include "e-corba-storage.h" -#include "e-icon-factory.h" -#include "e-folder-dnd-bridge.h" -#include "e-shell-constants.h" -#include "e-shell-marshal.h" - -#include <gal/util/e-util.h> -#include <gal/widgets/e-gui-utils.h> -#include <gal/e-table/e-tree-memory-callbacks.h> -#include <gal/e-table/e-cell-text.h> -#include <gal/e-table/e-cell-toggle.h> -#include <gal/e-table/e-cell-tree.h> - -#include <libgnome/gnome-util.h> -#include <libgnomeui/gnome-popup-menu.h> - -#include <bonobo/bonobo-window.h> -#include <bonobo/bonobo-ui-util.h> - -#include <gtk/gtksignal.h> - -#include <string.h> - -#include "check-empty.xpm" -#include "check-filled.xpm" -#include "check-missing.xpm" - - -static GdkPixbuf *checks [3]; - -/*#define DEBUG_XML*/ - -#define ROOT_NODE_NAME "/RootNode" - -#define PARENT_TYPE E_TREE_TYPE -static ETreeClass *parent_class = NULL; - -struct _EStorageSetViewPrivate { - EStorageSet *storage_set; - - BonoboUIComponent *ui_component; - BonoboUIContainer *ui_container; - - ETreeModel *etree_model; - ETreePath root_node; - - GHashTable *path_to_etree_node; - - GHashTable *type_name_to_pixbuf; - - const GtkTargetEntry *drag_types; - int num_drag_types; - - const GtkTargetEntry *drop_types; - int num_drop_types; - - /* Path of the row selected by the latest "cursor_activated" signal. */ - char *selected_row_path; - - /* Path of the row selected by a right click. */ - char *right_click_row_path; - - unsigned int show_folders : 1; - unsigned int show_checkboxes : 1; - unsigned int allow_dnd : 1; - unsigned int search_enabled : 1; - - /* The `Evolution::ShellComponentDnd::SourceFolder' interface for the - folder we are dragging from, or CORBA_OBJECT_NIL if no dragging is - happening. */ - GNOME_Evolution_ShellComponentDnd_SourceFolder drag_corba_source_interface; - - /* Source context information. NULL if no dragging is in progress. */ - GNOME_Evolution_ShellComponentDnd_SourceFolder_Context *drag_corba_source_context; - - /* The data. */ - GNOME_Evolution_ShellComponentDnd_Data *drag_corba_data; - - GHashTable *checkboxes; - - /* Callback to determine whether the row should have a checkbox or - not, when show_checkboxes is TRUE. */ - EStorageSetViewHasCheckBoxFunc has_checkbox_func; - void *has_checkbox_func_data; -}; - - -enum { - FOLDER_SELECTED, - FOLDER_OPENED, - FOLDER_DRAGGED, - FOLDER_RECEIVE_DROP, - FOLDER_CONTEXT_MENU_POPPING_UP, - FOLDER_CONTEXT_MENU_POPPED_DOWN, - CHECKBOXES_CHANGED, - LAST_SIGNAL -}; - -static unsigned int signals[LAST_SIGNAL] = { 0 }; - - -/* Forward declarations. */ - -static void setup_folder_changed_callbacks (EStorageSetView *storage_set_view, - EFolder *folder, - const char *path); -/* Sorting callbacks. */ - -static int -storage_sort_callback (ETreeMemory *etmm, - ETreePath node1, - ETreePath node2, - void *closure) -{ - char *folder_path_1; - char *folder_path_2; - gboolean path_1_local; - gboolean path_2_local; - - folder_path_1 = e_tree_memory_node_get_data(etmm, node1); - folder_path_2 = e_tree_memory_node_get_data(etmm, node2); - - /* FIXME bad hack to put the "my evolution" and "local" storages on - top. */ - - if (strcmp (folder_path_1, E_PATH_SEPARATOR_S E_SUMMARY_STORAGE_NAME) == 0) - return -1; - if (strcmp (folder_path_2, E_PATH_SEPARATOR_S E_SUMMARY_STORAGE_NAME) == 0) - return +1; - - path_1_local = ! strcmp (folder_path_1, E_PATH_SEPARATOR_S E_LOCAL_STORAGE_NAME); - path_2_local = ! strcmp (folder_path_2, E_PATH_SEPARATOR_S E_LOCAL_STORAGE_NAME); - - if (path_1_local && path_2_local) - return 0; - if (path_1_local) - return -1; - if (path_2_local) - return 1; - - return g_utf8_collate (e_tree_model_value_at (E_TREE_MODEL (etmm), node1, 0), - e_tree_model_value_at (E_TREE_MODEL (etmm), node2, 0)); -} - -static int -folder_sort_callback (ETreeMemory *etmm, - ETreePath node1, - ETreePath node2, - void *closure) -{ - EStorageSetViewPrivate *priv; - EFolder *folder_1, *folder_2; - const char *folder_path_1, *folder_path_2; - int priority_1, priority_2; - - priv = E_STORAGE_SET_VIEW (closure)->priv; - - folder_path_1 = e_tree_memory_node_get_data(etmm, node1); - folder_path_2 = e_tree_memory_node_get_data(etmm, node2); - - folder_1 = e_storage_set_get_folder (priv->storage_set, folder_path_1); - folder_2 = e_storage_set_get_folder (priv->storage_set, folder_path_2); - - priority_1 = e_folder_get_sorting_priority (folder_1); - priority_2 = e_folder_get_sorting_priority (folder_2); - - if (priority_1 == priority_2) - return g_utf8_collate (e_tree_model_value_at (E_TREE_MODEL (etmm), node1, 0), - e_tree_model_value_at (E_TREE_MODEL (etmm), node2, 0)); - else if (priority_1 < priority_2) - return -1; - else /* priority_1 > priority_2 */ - return +1; -} - - -/* Helper functions. */ - -static gboolean -add_node_to_hash (EStorageSetView *storage_set_view, - const char *path, - ETreePath node) -{ - EStorageSetViewPrivate *priv; - char *hash_path; - - g_return_val_if_fail (g_path_is_absolute (path), FALSE); - - priv = storage_set_view->priv; - - if (g_hash_table_lookup (priv->path_to_etree_node, path) != NULL) { - g_warning ("EStorageSetView: Node already existing while adding -- %s", path); - return FALSE; - } - - hash_path = g_strdup (path); - - g_hash_table_insert (priv->path_to_etree_node, hash_path, node); - - return TRUE; -} - -static ETreePath -lookup_node_in_hash (EStorageSetView *storage_set_view, - const char *path) -{ - EStorageSetViewPrivate *priv; - ETreePath node; - - priv = storage_set_view->priv; - - node = g_hash_table_lookup (priv->path_to_etree_node, path); - if (node == NULL) - g_warning ("EStorageSetView: Node not found while updating -- %s", path); - - return node; -} - -static ETreePath -remove_node_from_hash (EStorageSetView *storage_set_view, - const char *path) -{ - EStorageSetViewPrivate *priv; - ETreePath node; - - priv = storage_set_view->priv; - - node = g_hash_table_lookup (priv->path_to_etree_node, path); - if (node == NULL) { - g_warning ("EStorageSetView: Node not found while removing -- %s", path); - return NULL; - } - - g_hash_table_remove (priv->path_to_etree_node, path); - - return node; -} - -static GdkPixbuf * -get_pixbuf_for_folder (EStorageSetView *storage_set_view, - EFolder *folder) -{ - const char *type_name; - EStorageSetViewPrivate *priv; - EFolderTypeRegistry *folder_type_registry; - EStorageSet *storage_set; - GdkPixbuf *icon_pixbuf; - GdkPixbuf *scaled_pixbuf; - const char *custom_icon_name; - int icon_pixbuf_width, icon_pixbuf_height; - - priv = storage_set_view->priv; - - custom_icon_name = e_folder_get_custom_icon_name (folder); - if (custom_icon_name != NULL) - return e_icon_factory_get_icon (custom_icon_name, TRUE); - - type_name = e_folder_get_type_string (folder); - - scaled_pixbuf = g_hash_table_lookup (priv->type_name_to_pixbuf, type_name); - if (scaled_pixbuf != NULL) - return scaled_pixbuf; - - storage_set = priv->storage_set; - folder_type_registry = e_storage_set_get_folder_type_registry (storage_set); - - icon_pixbuf = e_folder_type_registry_get_icon_for_type (folder_type_registry, - type_name, TRUE); - - if (icon_pixbuf == NULL) - return NULL; - - icon_pixbuf_width = gdk_pixbuf_get_width (icon_pixbuf); - icon_pixbuf_height = gdk_pixbuf_get_height (icon_pixbuf); - - if (icon_pixbuf_width == E_SHELL_MINI_ICON_SIZE && icon_pixbuf_height == E_SHELL_MINI_ICON_SIZE) { - scaled_pixbuf = g_object_ref (icon_pixbuf); - } else { - scaled_pixbuf = gdk_pixbuf_new (gdk_pixbuf_get_colorspace (icon_pixbuf), - gdk_pixbuf_get_has_alpha (icon_pixbuf), - gdk_pixbuf_get_bits_per_sample (icon_pixbuf), - E_SHELL_MINI_ICON_SIZE, E_SHELL_MINI_ICON_SIZE); - - gdk_pixbuf_scale (icon_pixbuf, scaled_pixbuf, - 0, 0, E_SHELL_MINI_ICON_SIZE, E_SHELL_MINI_ICON_SIZE, - 0.0, 0.0, - (double) E_SHELL_MINI_ICON_SIZE / gdk_pixbuf_get_width (icon_pixbuf), - (double) E_SHELL_MINI_ICON_SIZE / gdk_pixbuf_get_height (icon_pixbuf), - GDK_INTERP_HYPER); - } - - g_hash_table_insert (priv->type_name_to_pixbuf, g_strdup (type_name), scaled_pixbuf); - - return scaled_pixbuf; -} - -/* The weakref callback for priv->ui_component. */ - -static void -ui_container_destroy_notify (void *data, GObject *deadbeef) -{ - EStorageSetViewPrivate *priv = (EStorageSetViewPrivate *) data; - - priv->ui_container = NULL; -} - -static GtkTargetList * -create_target_list_for_node (EStorageSetView *view, ETreePath node) -{ - EStorageSetViewPrivate *priv = view->priv; - GtkTargetList *target_list; - - target_list = gtk_target_list_new (priv->drag_types, priv->num_drag_types); - - return target_list; -} - -/* Folder context menu. */ - -struct _FolderPropertyItemsData { - EStorageSetView *storage_set_view; - ECorbaStorage *corba_storage; - int num_items; -}; -typedef struct _FolderPropertyItemsData FolderPropertyItemsData; - -static void -folder_property_item_verb_callback (BonoboUIComponent *component, - void *user_data, - const char *cname) -{ - FolderPropertyItemsData *data; - GtkWidget *toplevel_widget; - const char *p, *path; - int item_number; - - data = (FolderPropertyItemsData *) user_data; - - p = strrchr (cname, ':'); - g_assert (p != NULL); - - item_number = atoi (p + 1) - 1; - g_assert (item_number >= 0); - - toplevel_widget = gtk_widget_get_toplevel (GTK_WIDGET (data->storage_set_view)); - - path = strchr (data->storage_set_view->priv->right_click_row_path + 1, E_PATH_SEPARATOR); - if (path == NULL) - path = "/"; - e_corba_storage_show_folder_properties (data->corba_storage, path, - item_number, toplevel_widget->window); -} - -static FolderPropertyItemsData * -setup_folder_properties_items_if_corba_storage_clicked (EStorageSetView *storage_set_view) -{ - EStorageSetViewPrivate *priv; - EStorage *storage; - GSList *items, *p; - GString *xml; - FolderPropertyItemsData *data; - const char *slash; - char *storage_name; - int num_property_items; - int i; - - priv = storage_set_view->priv; - - slash = strchr (priv->right_click_row_path + 1, E_PATH_SEPARATOR); - if (slash == NULL) - storage_name = g_strdup (priv->right_click_row_path + 1); - - else - storage_name = g_strndup (priv->right_click_row_path + 1, - slash - (priv->right_click_row_path + 1)); - - storage = e_storage_set_get_storage (priv->storage_set, storage_name); - g_free (storage_name); - - if (storage == NULL || ! E_IS_CORBA_STORAGE (storage)) - return 0; - - items = e_corba_storage_get_folder_property_items (E_CORBA_STORAGE (storage)); - if (items == NULL) - return 0; - - xml = g_string_new ("<placeholder name=\"StorageFolderPropertiesPlaceholder\">"); - g_string_append (xml, "<separator f=\"\" name=\"EStorageSetViewFolderPropertiesSeparator\"/>"); - - num_property_items = 0; - for (p = items; p != NULL; p = p->next) { - const ECorbaStoragePropertyItem *item; - char *encoded_label; - char *encoded_tooltip; - - item = (const ECorbaStoragePropertyItem *) p->data; - num_property_items ++; - - g_string_append_printf (xml, "<menuitem name=\"EStorageSetView:FolderPropertyItem:%d\"", - num_property_items); - g_string_append_printf (xml, " verb=\"EStorageSetView:FolderPropertyItem:%d\"", - num_property_items); - - encoded_tooltip = bonobo_ui_util_encode_str (item->tooltip); - g_string_append_printf (xml, " tip=\"%s\"", encoded_tooltip); - - encoded_label = bonobo_ui_util_encode_str (item->label); - g_string_append_printf (xml, " label=\"%s\"/>", encoded_label); - - g_free (encoded_tooltip); - g_free (encoded_label); - } - - g_string_append (xml, "</placeholder>"); - - data = g_new (FolderPropertyItemsData, 1); - data->storage_set_view = storage_set_view; - data->corba_storage = E_CORBA_STORAGE (storage); - data->num_items = num_property_items; - - g_object_ref (data->storage_set_view); - g_object_ref (data->corba_storage); - - for (i = 1; i <= num_property_items; i ++) { - char *verb; - - verb = g_strdup_printf ("EStorageSetView:FolderPropertyItem:%d", i); - bonobo_ui_component_add_verb (priv->ui_component, verb, - folder_property_item_verb_callback, - data); - } - - bonobo_ui_component_set (priv->ui_component, "/popups/FolderPopup", xml->str, NULL); - - g_string_free (xml, TRUE); - e_corba_storage_free_property_items_list (items); - - return data; -} - -static void -remove_property_items (EStorageSetView *storage_set_view, - FolderPropertyItemsData *data) -{ - EStorageSetViewPrivate *priv; - - priv = storage_set_view->priv; - - if (data->num_items > 0) { - int i; - - bonobo_ui_component_rm (priv->ui_component, - "/popups/FolderPopup/StorageFolderPropertiesPlaceholder/EStorageSetViewFolderPropertiesSeparator", - NULL); - - for (i = 1; i <= data->num_items; i ++) { - char *path; - char *verb; - - path = g_strdup_printf ("/popups/FolderPopup/StorageFolderPropertiesPlaceholder/EStorageSetView:FolderPropertyItem:%d", i); - bonobo_ui_component_rm (priv->ui_component, path, NULL); - g_free (path); - - verb = g_strdup_printf ("EStorageSetView:FolderPropertyItem:%d", i); - bonobo_ui_component_remove_verb (priv->ui_component, verb); - g_free (verb); - } - } - - g_object_unref (data->storage_set_view); - g_object_unref (data->corba_storage); - - g_free (data); -} - -static void -popup_folder_menu (EStorageSetView *storage_set_view, - GdkEventButton *event) -{ - EvolutionShellComponentClient *handler; - EStorageSetViewPrivate *priv; - EFolderTypeRegistry *folder_type_registry; - EFolder *folder; - GtkWidget *menu, *window; - FolderPropertyItemsData *folder_property_items_data; - - priv = storage_set_view->priv; - - folder = e_storage_set_get_folder (priv->storage_set, priv->right_click_row_path); - g_object_ref (folder); - - folder_type_registry = e_storage_set_get_folder_type_registry (priv->storage_set); - g_assert (folder_type_registry != NULL); - - handler = e_folder_type_registry_get_handler_for_type (folder_type_registry, - e_folder_get_type_string (folder)); - menu = gtk_menu_new (); - - window = gtk_widget_get_ancestor (GTK_WIDGET (storage_set_view), - BONOBO_TYPE_WINDOW); - bonobo_window_add_popup (BONOBO_WINDOW (window), - GTK_MENU (menu), "/popups/FolderPopup"); - - bonobo_ui_component_set (priv->ui_component, - "/popups/FolderPopup/ComponentPlaceholder", - "<placeholder name=\"Items\"/>", NULL); - - if (handler != NULL) - evolution_shell_component_client_populate_folder_context_menu (handler, - priv->ui_container, - e_folder_get_physical_uri (folder), - e_folder_get_type_string (folder)); - - folder_property_items_data = setup_folder_properties_items_if_corba_storage_clicked (storage_set_view); - - gtk_widget_show (GTK_WIDGET (menu)); - - gnome_popup_menu_do_popup_modal (GTK_WIDGET (menu), NULL, NULL, event, NULL, - GTK_WIDGET (storage_set_view)); - - if (folder_property_items_data != NULL) - remove_property_items (storage_set_view, folder_property_items_data); - - if (handler != NULL) - evolution_shell_component_client_unpopulate_folder_context_menu (handler, - priv->ui_container, - e_folder_get_physical_uri (folder), - e_folder_get_type_string (folder)); - - g_object_unref (folder); - gtk_widget_destroy (GTK_WIDGET (menu)); - - e_tree_right_click_up (E_TREE (storage_set_view)); -} - - -/* GtkObject methods. */ - -static void -pixbuf_free_func (gpointer key, gpointer value, gpointer user_data) -{ - g_free (key); - g_object_unref ((GdkPixbuf*)value); -} - -static void -impl_dispose (GObject *object) -{ - EStorageSetView *storage_set_view; - EStorageSetViewPrivate *priv; - - storage_set_view = E_STORAGE_SET_VIEW (object); - priv = storage_set_view->priv; - - if (priv->etree_model != NULL) { - /* Destroy the tree. */ - e_tree_memory_node_remove (E_TREE_MEMORY(priv->etree_model), priv->root_node); - g_object_unref (priv->etree_model); - priv->etree_model = NULL; - - /* (The data in the hash table was all freed by freeing the tree.) */ - g_hash_table_destroy (priv->path_to_etree_node); - priv->path_to_etree_node = NULL; - } - - if (priv->storage_set != NULL) { - g_object_unref (priv->storage_set); - priv->storage_set = NULL; - } - - if (priv->drag_corba_source_interface != CORBA_OBJECT_NIL) { - CORBA_Environment ev; - - CORBA_exception_init (&ev); - - g_assert (priv->drag_corba_source_context != NULL); - - GNOME_Evolution_ShellComponentDnd_SourceFolder_endDrag (priv->drag_corba_source_interface, - priv->drag_corba_source_context, - &ev); - - Bonobo_Unknown_unref (priv->drag_corba_source_interface, &ev); - CORBA_Object_release (priv->drag_corba_source_interface, &ev); - - CORBA_exception_free (&ev); - - priv->drag_corba_source_interface = CORBA_OBJECT_NIL; - } - - if (priv->ui_component != NULL) { - bonobo_object_unref (BONOBO_OBJECT (priv->ui_component)); - priv->ui_component = NULL; - } - - /* (No unreffing for priv->ui_container since we use a weakref.) */ - - (* G_OBJECT_CLASS (parent_class)->dispose) (object); -} - -static void -impl_finalize (GObject *object) -{ - EStorageSetView *storage_set_view; - EStorageSetViewPrivate *priv; - - storage_set_view = E_STORAGE_SET_VIEW (object); - priv = storage_set_view->priv; - - g_hash_table_foreach (priv->type_name_to_pixbuf, pixbuf_free_func, NULL); - g_hash_table_destroy (priv->type_name_to_pixbuf); - - if (priv->checkboxes != NULL) { - g_hash_table_foreach (priv->checkboxes, (GHFunc) g_free, NULL); - g_hash_table_destroy (priv->checkboxes); - } - - if (priv->drag_corba_source_context != NULL) - CORBA_free (priv->drag_corba_source_context); - - if (priv->drag_corba_data != NULL) - CORBA_free (priv->drag_corba_data); - - g_free (priv->selected_row_path); - g_free (priv->right_click_row_path); - - g_free (priv); - - (* G_OBJECT_CLASS (parent_class)->finalize) (object); -} - - -/* ETree methods. */ - -/* -- Source-side DnD. */ - -static gint -impl_tree_start_drag (ETree *tree, int row, ETreePath path, int col, GdkEvent *event) -{ - EStorageSetView *view = (EStorageSetView *) tree; - GdkDragContext *context; - GtkTargetList *target_list; - GdkDragAction actions; - - if (!view->priv->allow_dnd) - return FALSE; - - target_list = create_target_list_for_node (view, path); - if (target_list == NULL) - return FALSE; - - actions = GDK_ACTION_MOVE | GDK_ACTION_COPY; - - context = e_tree_drag_begin (tree, row, col, target_list, actions, 1, event); - - gtk_drag_set_icon_default (context); - - gtk_target_list_unref (target_list); - - return TRUE; -} - -static void -impl_tree_drag_begin (ETree *etree, int row, ETreePath path, int col, GdkDragContext *context) -{ - EStorageSetView *view = (EStorageSetView *) etree; - EStorageSetViewPrivate *priv = view->priv; - - g_free (priv->selected_row_path); - priv->selected_row_path = g_strdup (e_tree_memory_node_get_data (E_TREE_MEMORY (priv->etree_model), path)); -} - -static void -impl_tree_drag_data_get (ETree *etree, int drag_row, ETreePath drag_path, int drag_col, - GdkDragContext *context, GtkSelectionData *selection, guint info, guint time) -{ - EStorageSetView *view = (EStorageSetView *) etree; - EStorageSetViewPrivate *priv = view->priv; - const char *path; - - path = e_tree_memory_node_get_data (E_TREE_MEMORY (priv->etree_model), - e_tree_node_at_row (E_TREE (view), drag_row)); - - g_assert (path != NULL); - - g_signal_emit (view, signals[FOLDER_DRAGGED], 0, path, context, selection, info, time); -} - -/* -- Destination-side DnD. */ - -static gboolean -find_target_drop_type (EStorageSetViewPrivate *priv, GdkDragContext *context, GdkAtom *atom) -{ - char *target; - GList *t; - int i; - - for (t = context->targets; t != NULL; t = t->next) { - target = gdk_atom_name (t->data); - for (i = 0; i < priv->num_drop_types; i++) { - if (!strcmp (target, priv->drop_types[i].target)) { - g_free (target); - - if (atom) - *atom = t->data; - - return TRUE; - } - } - - g_free (target); - } - - return FALSE; -} - -static gboolean -impl_tree_drag_motion (ETree *etree, int row, ETreePath path, int col, - GdkDragContext *context, int x, int y, guint time) -{ - EStorageSetView *view = (EStorageSetView *) etree; - EStorageSetViewPrivate *priv = view->priv; - - if (!priv->allow_dnd) - return FALSE; - - e_tree_drag_highlight (E_TREE (view), row, -1); - - if (find_target_drop_type (priv, context, NULL)) { - gdk_drag_status (context, context->suggested_action, time); - - return TRUE; - } - - gdk_drag_status (context, 0, time); - - return FALSE; -} - -static void -impl_tree_drag_leave (ETree *etree, int row, ETreePath path, int col, GdkDragContext *context, guint time) -{ - e_tree_drag_unhighlight (etree); -} - -static gboolean -impl_tree_drag_drop (ETree *etree, int row, ETreePath path, int col, GdkDragContext *context, - int x, int y, guint time) -{ - EStorageSetView *view = (EStorageSetView *) etree; - EStorageSetViewPrivate *priv = view->priv; - GdkAtom atom; - - e_tree_drag_unhighlight (etree); - - if (!find_target_drop_type (priv, context, &atom)) - return FALSE; - - gtk_drag_get_data ((GtkWidget *) etree, context, atom, time); - - return FALSE; -} - -static void -impl_tree_drag_data_received (ETree *etree, int row, ETreePath path, int col, - GdkDragContext *context, int x, int y, - GtkSelectionData *selection, guint info, guint time) -{ - EStorageSetView *view = (EStorageSetView *) etree; - EStorageSetViewPrivate *priv = view->priv; - const char *folder_path; - - folder_path = e_tree_memory_node_get_data (E_TREE_MEMORY (priv->etree_model), - e_tree_node_at_row (E_TREE (view), row)); - - g_assert (folder_path != NULL); - - g_signal_emit (view, signals[FOLDER_RECEIVE_DROP], 0, folder_path, context, selection, info, time); -} - -static gboolean -impl_right_click (ETree *etree, - int row, - ETreePath path, - int col, - GdkEvent *event) -{ - EStorageSetView *storage_set_view; - EStorageSetViewPrivate *priv; - - storage_set_view = E_STORAGE_SET_VIEW (etree); - priv = storage_set_view->priv; - - /* Avoid recursion which would lock up the event loop (#48388). */ - if (priv->right_click_row_path != NULL) - return TRUE; - - priv->right_click_row_path = g_strdup (e_tree_memory_node_get_data (E_TREE_MEMORY(priv->etree_model), path)); - - if (priv->ui_container) { - g_signal_emit (storage_set_view, signals[FOLDER_CONTEXT_MENU_POPPING_UP], 0, priv->right_click_row_path); - - popup_folder_menu (storage_set_view, (GdkEventButton *) event); - - g_signal_emit (storage_set_view, signals[FOLDER_CONTEXT_MENU_POPPED_DOWN], 0); - } - - g_free (priv->right_click_row_path); - priv->right_click_row_path = NULL; - - return TRUE; -} - -static void -impl_cursor_activated (ETree *tree, - int row, - ETreePath path) -{ - EStorageSetView *storage_set_view; - EStorageSetViewPrivate *priv; - - storage_set_view = E_STORAGE_SET_VIEW (tree); - - priv = storage_set_view->priv; - - g_free (priv->selected_row_path); - if (path) { - priv->selected_row_path = g_strdup (e_tree_memory_node_get_data (E_TREE_MEMORY (priv->etree_model), path)); - - g_signal_emit (storage_set_view, signals[FOLDER_SELECTED], 0, - priv->selected_row_path); - } - else - priv->selected_row_path = NULL; -} - - -/* ETreeModel Methods */ - -static gboolean -path_is_storage (ETreeModel *etree, - ETreePath tree_path) -{ - return e_tree_model_node_depth (etree, tree_path) == 1; -} - -static GdkPixbuf* -etree_icon_at (ETreeModel *etree, - ETreePath tree_path, - void *model_data) -{ - EStorageSetView *storage_set_view; - EStorageSet *storage_set; - EFolder *folder; - char *path; - - storage_set_view = E_STORAGE_SET_VIEW (model_data); - storage_set = storage_set_view->priv->storage_set; - - path = (char*) e_tree_memory_node_get_data (E_TREE_MEMORY(etree), tree_path); - - folder = e_storage_set_get_folder (storage_set, path); - if (folder == NULL) - return NULL; - - /* No icon for a storage with children (or with no real root folder) */ - if (path_is_storage (etree, tree_path)) { - EStorage *storage; - GList *subfolder_paths; - - if (! strcmp (e_folder_get_type_string (folder), "noselect")) - return NULL; - - storage = e_storage_set_get_storage (storage_set, path + 1); - subfolder_paths = e_storage_get_subfolder_paths (storage, "/"); - if (subfolder_paths != NULL) { - e_free_string_list (subfolder_paths); - return NULL; - } - } - - return get_pixbuf_for_folder (storage_set_view, folder); -} - -/* This function returns the number of columns in our ETreeModel. */ -static int -etree_column_count (ETreeModel *etc, - void *data) -{ - return 3; -} - -static gboolean -etree_has_save_id (ETreeModel *etm, - void *data) -{ - return TRUE; -} - -static gchar * -etree_get_save_id (ETreeModel *etm, - ETreePath node, - void *model_data) -{ - return g_strdup(e_tree_memory_node_get_data (E_TREE_MEMORY(etm), node)); -} - -static gboolean -etree_has_get_node_by_id (ETreeModel *etm, - void *data) -{ - return TRUE; -} - -static ETreePath -etree_get_node_by_id (ETreeModel *etm, - const char *save_id, - void *model_data) -{ - EStorageSetView *storage_set_view; - storage_set_view = E_STORAGE_SET_VIEW (model_data); - - return g_hash_table_lookup (storage_set_view->priv->path_to_etree_node, save_id); -} - -static gboolean -has_checkbox (EStorageSetView *storage_set_view, ETreePath tree_path) -{ - EStorageSetViewPrivate *priv; - const char *folder_path; - - priv = storage_set_view->priv; - - folder_path = e_tree_memory_node_get_data (E_TREE_MEMORY(storage_set_view->priv->etree_model), - tree_path); - g_assert (folder_path != NULL); - - if (strchr (folder_path + 1, '/') == NULL) { - /* If it's a toplevel, never allow checking it. */ - return FALSE; - } - - if (priv->has_checkbox_func) - return (* priv->has_checkbox_func) (priv->storage_set, - folder_path, - priv->has_checkbox_func_data); - - return TRUE; -} - -static void * -etree_value_at (ETreeModel *etree, - ETreePath tree_path, - int col, - void *model_data) -{ - EStorageSetView *storage_set_view; - EStorageSetViewPrivate *priv; - EStorageSet *storage_set; - EFolder *folder; - char *path; - const char *folder_name; - int unread_count; - - storage_set_view = E_STORAGE_SET_VIEW (model_data); - priv = storage_set_view->priv; - storage_set = priv->storage_set; - - /* Storages are always highlighted. */ - if (col == 1 && path_is_storage (etree, tree_path)) - return (void *) TRUE; - - path = (char *) e_tree_memory_node_get_data (E_TREE_MEMORY(etree), tree_path); - - folder = e_storage_set_get_folder (storage_set, path); - - switch (col) { - case 0: /* Title */ - if (folder == NULL) - return (void *) "?"; - folder_name = e_folder_get_name (folder); - unread_count = e_folder_get_unread_count (folder); - - if (unread_count > 0) { - char *name_with_unread; - - name_with_unread = g_strdup_printf ("%s (%d)", folder_name, - unread_count); - g_object_set_data_full (G_OBJECT (folder), "name_with_unread", name_with_unread, g_free); - - return (void *) name_with_unread; - } else - return (void *) folder_name; - case 1: /* bold */ - if (folder == NULL) - return GINT_TO_POINTER (FALSE); - return GINT_TO_POINTER (e_folder_get_highlighted (folder)); - case 2: /* checkbox */ - if (!has_checkbox (storage_set_view, tree_path)) - return GINT_TO_POINTER (2); - if (priv->checkboxes == NULL) - return GINT_TO_POINTER (0); - return GINT_TO_POINTER(g_hash_table_lookup (priv->checkboxes, - path) ? 1 : 0); - default: - return NULL; - } - -} - -static void -etree_fill_in_children (ETreeModel *etree, - ETreePath tree_path, - void *model_data) -{ - EStorageSetView *storage_set_view; - EStorageSet *storage_set; - ETreePath *parent; - char *path; - - storage_set_view = E_STORAGE_SET_VIEW (model_data); - storage_set = storage_set_view->priv->storage_set; - - parent = e_tree_model_node_get_parent (etree, tree_path); - path = (char *) e_tree_memory_node_get_data (E_TREE_MEMORY(etree), parent); - if (tree_path == e_tree_model_node_get_first_child (etree, parent)) { - g_signal_emit (storage_set_view, signals[FOLDER_OPENED], 0, path); - } -} - -static void -etree_set_value_at (ETreeModel *etree, - ETreePath tree_path, - int col, - const void *val, - void *model_data) -{ - gboolean value; - char *path; - EStorageSetView *storage_set_view; - EStorageSetViewPrivate *priv; - char *old_path; - - storage_set_view = E_STORAGE_SET_VIEW (model_data); - priv = storage_set_view->priv; - - switch (col) { - case 2: /* checkbox */ - if (!has_checkbox (storage_set_view, tree_path)) - return; - - e_tree_model_pre_change (etree); - - value = GPOINTER_TO_INT (val); - path = (char *) e_tree_memory_node_get_data (E_TREE_MEMORY(etree), tree_path); - if (!priv->checkboxes) { - priv->checkboxes = g_hash_table_new (g_str_hash, g_str_equal); - } - - old_path = g_hash_table_lookup (priv->checkboxes, path); - - if (old_path) { - g_hash_table_remove (priv->checkboxes, path); - g_free (old_path); - } else { - path = g_strdup (path); - g_hash_table_insert (priv->checkboxes, path, path); - } - - e_tree_model_node_col_changed (etree, tree_path, col); - g_signal_emit (storage_set_view, signals[CHECKBOXES_CHANGED], 0); - break; - } -} - -static gboolean -etree_is_editable (ETreeModel *etree, - ETreePath path, - int col, - void *model_data) -{ - if (col == 2) - return TRUE; - else - return FALSE; -} - - -/* This function duplicates the value passed to it. */ -static void * -etree_duplicate_value (ETreeModel *etc, - int col, - const void *value, - void *data) -{ - if (col == 0) - return (void *)g_strdup (value); - else - return (void *)value; -} - -/* This function frees the value passed to it. */ -static void -etree_free_value (ETreeModel *etc, - int col, - void *value, - void *data) -{ - if (col == 0) - g_free (value); -} - -/* This function creates an empty value. */ -static void * -etree_initialize_value (ETreeModel *etc, - int col, - void *data) -{ - if (col == 0) - return g_strdup (""); - else - return NULL; -} - -/* This function reports if a value is empty. */ -static gboolean -etree_value_is_empty (ETreeModel *etc, - int col, - const void *value, - void *data) -{ - if (col == 0) - return !(value && *(char *)value); - else - return !value; -} - -/* This function reports if a value is empty. */ -static char * -etree_value_to_string (ETreeModel *etc, - int col, - const void *value, - void *data) -{ - if (col == 0) - return g_strdup(value); - else - return g_strdup(value ? "Yes" : "No"); -} - -static void -etree_node_destroy_func (void *data, - void *user_data) -{ - EStorageSetView *storage_set_view; - char *path; - - path = (char *) data; - storage_set_view = E_STORAGE_SET_VIEW (user_data); - - if (strcmp (path, ROOT_NODE_NAME)) - remove_node_from_hash (storage_set_view, path); - g_free (path); -} - - -/* StorageSet signal handling. */ - -static void -new_storage_cb (EStorageSet *storage_set, - EStorage *storage, - void *data) -{ - EStorageSetView *storage_set_view; - EStorageSetViewPrivate *priv; - ETreePath node; - char *path; - - storage_set_view = E_STORAGE_SET_VIEW (data); - priv = storage_set_view->priv; - - path = g_strconcat (E_PATH_SEPARATOR_S, e_storage_get_name (storage), NULL); - - node = e_tree_memory_node_insert (E_TREE_MEMORY(priv->etree_model), priv->root_node, -1, path); - e_tree_memory_sort_node (E_TREE_MEMORY(priv->etree_model), priv->root_node, - storage_sort_callback, storage_set_view); - - if (! add_node_to_hash (storage_set_view, path, node)) { - e_tree_memory_node_remove (E_TREE_MEMORY(priv->etree_model), node); - return; - } -} - -static void -removed_storage_cb (EStorageSet *storage_set, - EStorage *storage, - void *data) -{ - EStorageSetView *storage_set_view; - EStorageSetViewPrivate *priv; - ETreeModel *etree; - ETreePath node; - char *path; - - storage_set_view = E_STORAGE_SET_VIEW (data); - priv = storage_set_view->priv; - etree = priv->etree_model; - - path = g_strconcat (E_PATH_SEPARATOR_S, e_storage_get_name (storage), NULL); - node = lookup_node_in_hash (storage_set_view, path); - g_free (path); - - e_tree_memory_node_remove (E_TREE_MEMORY(etree), node); -} - -static void -new_folder_cb (EStorageSet *storage_set, - const char *path, - void *data) -{ - EStorageSetView *storage_set_view; - EStorageSetViewPrivate *priv; - ETreeModel *etree; - ETreePath parent_node; - ETreePath new_node; - const char *last_separator; - char *parent_path; - char *copy_of_path; - - g_return_if_fail (g_path_is_absolute (path)); - - storage_set_view = E_STORAGE_SET_VIEW (data); - priv = storage_set_view->priv; - etree = priv->etree_model; - - last_separator = strrchr (path, E_PATH_SEPARATOR); - - parent_path = g_strndup (path, last_separator - path); - parent_node = g_hash_table_lookup (priv->path_to_etree_node, parent_path); - if (parent_node == NULL) { - g_warning ("EStorageSetView: EStorageSet reported new subfolder for non-existing folder -- %s", - parent_path); - g_free (parent_path); - return; - } - - g_free (parent_path); - - copy_of_path = g_strdup (path); - new_node = e_tree_memory_node_insert (E_TREE_MEMORY(etree), parent_node, -1, copy_of_path); - e_tree_memory_sort_node (E_TREE_MEMORY(etree), parent_node, folder_sort_callback, storage_set_view); - - if (! add_node_to_hash (storage_set_view, path, new_node)) { - e_tree_memory_node_remove (E_TREE_MEMORY(etree), new_node); - return; - } - - setup_folder_changed_callbacks (storage_set_view, - e_storage_set_get_folder (storage_set, path), - path); -} - -static void -updated_folder_cb (EStorageSet *storage_set, - const char *path, - void *data) -{ - EStorageSetView *storage_set_view; - EStorageSetViewPrivate *priv; - ETreeModel *etree; - ETreePath node; - - storage_set_view = E_STORAGE_SET_VIEW (data); - priv = storage_set_view->priv; - etree = priv->etree_model; - - node = lookup_node_in_hash (storage_set_view, path); - e_tree_model_pre_change (etree); - e_tree_model_node_data_changed (etree, node); -} - -static void -removed_folder_cb (EStorageSet *storage_set, - const char *path, - void *data) -{ - EStorageSetView *storage_set_view; - EStorageSetViewPrivate *priv; - ETreeModel *etree; - ETreePath node; - - storage_set_view = E_STORAGE_SET_VIEW (data); - priv = storage_set_view->priv; - etree = priv->etree_model; - - node = lookup_node_in_hash (storage_set_view, path); - e_tree_memory_node_remove (E_TREE_MEMORY(etree), node); -} - -static void -close_folder_cb (EStorageSet *storage_set, - const char *path, - void *data) -{ - EStorageSetView *storage_set_view; - EStorageSetViewPrivate *priv; - ETreeModel *etree; - ETreePath node; - - storage_set_view = E_STORAGE_SET_VIEW (data); - priv = storage_set_view->priv; - etree = priv->etree_model; - - node = lookup_node_in_hash (storage_set_view, path); - e_tree_model_node_request_collapse (priv->etree_model, node); -} - - -static void -class_init (EStorageSetViewClass *klass) -{ - GObjectClass *object_class; - ETreeClass *etree_class; - - parent_class = g_type_class_ref(PARENT_TYPE); - - object_class = G_OBJECT_CLASS (klass); - object_class->dispose = impl_dispose; - object_class->finalize = impl_finalize; - - etree_class = E_TREE_CLASS (klass); - etree_class->right_click = impl_right_click; - etree_class->cursor_activated = impl_cursor_activated; - etree_class->start_drag = impl_tree_start_drag; - etree_class->tree_drag_begin = impl_tree_drag_begin; - etree_class->tree_drag_data_get = impl_tree_drag_data_get; - etree_class->tree_drag_motion = impl_tree_drag_motion; - etree_class->tree_drag_drop = impl_tree_drag_drop; - etree_class->tree_drag_leave = impl_tree_drag_leave; - etree_class->tree_drag_data_received = impl_tree_drag_data_received; - - signals[FOLDER_SELECTED] - = g_signal_new ("folder_selected", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (EStorageSetViewClass, folder_selected), - NULL, NULL, - e_shell_marshal_NONE__STRING, - G_TYPE_NONE, 1, - G_TYPE_STRING); - - signals[FOLDER_OPENED] - = g_signal_new ("folder_opened", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (EStorageSetViewClass, folder_opened), - NULL, NULL, - e_shell_marshal_NONE__STRING, - G_TYPE_NONE, 1, - G_TYPE_STRING); - - signals[FOLDER_DRAGGED] - = g_signal_new ("folder_dragged", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (EStorageSetViewClass, folder_dragged), - NULL, NULL, - e_shell_marshal_NONE__STRING_POINTER_POINTER_UINT_UINT, - G_TYPE_NONE, 5, - G_TYPE_STRING, - G_TYPE_POINTER, - G_TYPE_POINTER, - G_TYPE_UINT, - G_TYPE_UINT); - - signals[FOLDER_RECEIVE_DROP] - = g_signal_new ("folder_receive_drop", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (EStorageSetViewClass, folder_receive_drop), - NULL, NULL, - e_shell_marshal_NONE__STRING_POINTER_POINTER_UINT_UINT, - G_TYPE_NONE, 5, - G_TYPE_STRING, - G_TYPE_POINTER, - G_TYPE_POINTER, - G_TYPE_UINT, - G_TYPE_UINT); - - signals[FOLDER_CONTEXT_MENU_POPPING_UP] - = g_signal_new ("folder_context_menu_popping_up", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (EStorageSetViewClass, folder_context_menu_popping_up), - NULL, NULL, - e_shell_marshal_NONE__STRING, - G_TYPE_NONE, 1, - G_TYPE_STRING); - - signals[FOLDER_CONTEXT_MENU_POPPED_DOWN] - = g_signal_new ("folder_context_menu_popped_down", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (EStorageSetViewClass, folder_context_menu_popped_down), - NULL, NULL, - e_shell_marshal_NONE__NONE, - G_TYPE_NONE, 0); - - signals[CHECKBOXES_CHANGED] - = g_signal_new ("checkboxes_changed", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (EStorageSetViewClass, checkboxes_changed), - NULL, NULL, - e_shell_marshal_NONE__NONE, - G_TYPE_NONE, 0); - - checks [0] = gdk_pixbuf_new_from_xpm_data (check_empty_xpm); - checks [1] = gdk_pixbuf_new_from_xpm_data (check_filled_xpm); - checks [2] = gdk_pixbuf_new_from_xpm_data (check_missing_xpm); -} - -static void -init (EStorageSetView *storage_set_view) -{ - EStorageSetViewPrivate *priv; - - priv = g_new (EStorageSetViewPrivate, 1); - - priv->storage_set = NULL; - priv->path_to_etree_node = g_hash_table_new (g_str_hash, g_str_equal); - priv->type_name_to_pixbuf = g_hash_table_new (g_str_hash, g_str_equal); - - priv->ui_component = NULL; - priv->ui_container = NULL; - - priv->selected_row_path = NULL; - priv->right_click_row_path = NULL; - - priv->show_folders = TRUE; - priv->show_checkboxes = FALSE; - priv->allow_dnd = TRUE; - priv->search_enabled = FALSE; - - priv->drag_corba_source_interface = CORBA_OBJECT_NIL; - - priv->drag_corba_source_context = NULL; - priv->drag_corba_data = NULL; - - priv->checkboxes = NULL; - - priv->has_checkbox_func = NULL; - priv->has_checkbox_func_data = NULL; - - storage_set_view->priv = priv; -} - - -/* Handling of the "changed" signal in EFolders displayed in the EStorageSetView. */ - -struct _FolderChangedCallbackData { - EStorageSetView *storage_set_view; - char *path; -}; -typedef struct _FolderChangedCallbackData FolderChangedCallbackData; - -static void -folder_changed_callback_data_destroy_notify (void *data) -{ - FolderChangedCallbackData *callback_data; - - callback_data = (FolderChangedCallbackData *) data; - - g_free (callback_data->path); - g_free (callback_data); -} - -static void -folder_changed_cb (EFolder *folder, - void *data) -{ - EStorageSetView *storage_set_view; - EStorageSetViewPrivate *priv; - FolderChangedCallbackData *callback_data; - ETreePath node; - - callback_data = (FolderChangedCallbackData *) data; - - storage_set_view = callback_data->storage_set_view; - priv = callback_data->storage_set_view->priv; - - node = g_hash_table_lookup (priv->path_to_etree_node, callback_data->path); - if (node == NULL) { - g_warning ("EStorageSetView -- EFolder::changed emitted for a folder whose path I don't know."); - return; - } - - e_tree_model_pre_change (priv->etree_model); - e_tree_model_node_data_changed (priv->etree_model, node); -} - -static void -folder_name_changed_cb (EFolder *folder, - void *data) -{ - EStorageSetView *storage_set_view; - EStorageSetViewPrivate *priv; - FolderChangedCallbackData *callback_data; - ETreePath parent_node; - const char *last_separator; - char *parent_path; - - callback_data = (FolderChangedCallbackData *) data; - - storage_set_view = callback_data->storage_set_view; - priv = storage_set_view->priv; - - last_separator = strrchr (callback_data->path, E_PATH_SEPARATOR); - - parent_path = g_strndup (callback_data->path, last_separator - callback_data->path); - parent_node = g_hash_table_lookup (priv->path_to_etree_node, parent_path); - g_free (parent_path); - - if (parent_node == NULL) { - g_warning ("EStorageSetView -- EFolder::name_changed emitted for a folder whose path I don't know."); - return; - } - - e_tree_memory_sort_node (E_TREE_MEMORY (priv->etree_model), parent_node, - folder_sort_callback, storage_set_view); -} - -static void -setup_folder_changed_callbacks (EStorageSetView *storage_set_view, - EFolder *folder, - const char *path) -{ - FolderChangedCallbackData *folder_changed_callback_data; - - folder_changed_callback_data = g_new (FolderChangedCallbackData, 1); - folder_changed_callback_data->storage_set_view = storage_set_view; - folder_changed_callback_data->path = g_strdup (path); - - e_signal_connect_while_alive (folder, "name_changed", - G_CALLBACK (folder_name_changed_cb), - folder_changed_callback_data, - storage_set_view); - - e_signal_connect_full_while_alive (folder, "changed", - G_CALLBACK (folder_changed_cb), - NULL, - folder_changed_callback_data, - folder_changed_callback_data_destroy_notify, - FALSE, FALSE, - storage_set_view); -} - - -static void -insert_folders (EStorageSetView *storage_set_view, - ETreePath parent, - EStorage *storage, - const char *path) -{ - EStorageSetViewPrivate *priv; - ETreeModel *etree; - ETreePath node; - GList *folder_path_list; - GList *p; - const char *storage_name; - - priv = storage_set_view->priv; - etree = priv->etree_model; - - storage_name = e_storage_get_name (storage); - - folder_path_list = e_storage_get_subfolder_paths (storage, path); - if (folder_path_list == NULL) - return; - - for (p = folder_path_list; p != NULL; p = p->next) { - EFolder *folder; - const char *folder_name; - const char *folder_path; - char *full_path; - - folder_path = (const char *) p->data; - folder = e_storage_get_folder (storage, folder_path); - folder_name = e_folder_get_name (folder); - - full_path = g_strconcat ("/", storage_name, folder_path, NULL); - - setup_folder_changed_callbacks (storage_set_view, folder, full_path); - - node = e_tree_memory_node_insert (E_TREE_MEMORY(etree), parent, -1, (void *) full_path); - e_tree_memory_sort_node(E_TREE_MEMORY(etree), parent, folder_sort_callback, storage_set_view); - add_node_to_hash (storage_set_view, full_path, node); - - insert_folders (storage_set_view, node, storage, folder_path); - } - - e_free_string_list (folder_path_list); -} - -static void -insert_storages (EStorageSetView *storage_set_view) -{ - EStorageSetViewPrivate *priv; - EStorageSet *storage_set; - GList *storage_list; - GList *p; - - priv = storage_set_view->priv; - - storage_set = priv->storage_set; - - storage_list = e_storage_set_get_storage_list (storage_set); - - for (p = storage_list; p != NULL; p = p->next) { - EStorage *storage = E_STORAGE (p->data); - const char *name; - char *path; - ETreePath parent; - - name = e_storage_get_name (storage); - path = g_strconcat ("/", name, NULL); - - parent = e_tree_memory_node_insert (E_TREE_MEMORY(priv->etree_model), priv->root_node, -1, path); - e_tree_memory_sort_node (E_TREE_MEMORY(priv->etree_model), - priv->root_node, - storage_sort_callback, storage_set_view); - - g_hash_table_insert (priv->path_to_etree_node, path, parent); - - if (priv->show_folders) - insert_folders (storage_set_view, parent, storage, "/"); - } - - e_free_object_list (storage_list); -} - -void -e_storage_set_view_construct (EStorageSetView *storage_set_view, - EStorageSet *storage_set, - BonoboUIContainer *ui_container) -{ - EStorageSetViewPrivate *priv; - ETableExtras *extras; - ECell *cell; - - g_return_if_fail (E_IS_STORAGE_SET_VIEW (storage_set_view)); - g_return_if_fail (E_IS_STORAGE_SET (storage_set)); - - priv = storage_set_view->priv; - - priv->ui_container = ui_container; - if (ui_container != NULL) { - g_object_weak_ref (G_OBJECT (ui_container), ui_container_destroy_notify, priv); - - priv->ui_component = bonobo_ui_component_new_default (); - bonobo_ui_component_set_container (priv->ui_component, - bonobo_object_corba_objref (BONOBO_OBJECT (ui_container)), - NULL); - } - - priv->etree_model = e_tree_memory_callbacks_new (etree_icon_at, - - etree_column_count, - - etree_has_save_id, - etree_get_save_id, - etree_has_get_node_by_id, - etree_get_node_by_id, - - etree_value_at, - etree_set_value_at, - etree_is_editable, - - etree_duplicate_value, - etree_free_value, - etree_initialize_value, - etree_value_is_empty, - etree_value_to_string, - - storage_set_view); - - e_tree_memory_set_node_destroy_func (E_TREE_MEMORY (priv->etree_model), - etree_node_destroy_func, storage_set_view); - e_tree_memory_set_expanded_default (E_TREE_MEMORY (priv->etree_model), FALSE); - - priv->root_node = e_tree_memory_node_insert (E_TREE_MEMORY(priv->etree_model), NULL, -1, - g_strdup (ROOT_NODE_NAME)); - add_node_to_hash (storage_set_view, ROOT_NODE_NAME, priv->root_node); - - extras = e_table_extras_new (); - cell = e_cell_text_new (NULL, GTK_JUSTIFY_LEFT); - g_object_set((cell), "bold_column", 1, NULL); - e_table_extras_add_cell (extras, "render_tree", - e_cell_tree_new (NULL, NULL, TRUE, cell)); - - e_table_extras_add_cell (extras, "optional_checkbox", - e_cell_toggle_new (2, 3, checks)); - - e_tree_construct_from_spec_file (E_TREE (storage_set_view), priv->etree_model, extras, - EVOLUTION_ETSPECDIR "/e-storage-set-view.etspec", NULL); - - e_tree_root_node_set_visible (E_TREE(storage_set_view), FALSE); - - g_object_unref (extras); - - g_object_ref (storage_set); - priv->storage_set = storage_set; - - e_tree_drag_dest_set (E_TREE (storage_set_view), 0, NULL, 0, GDK_ACTION_MOVE | GDK_ACTION_COPY); - - g_signal_connect_object (storage_set, "new_storage", G_CALLBACK (new_storage_cb), storage_set_view, 0); - g_signal_connect_object (storage_set, "removed_storage", G_CALLBACK (removed_storage_cb), storage_set_view, 0); - g_signal_connect_object (storage_set, "new_folder", G_CALLBACK (new_folder_cb), storage_set_view, 0); - g_signal_connect_object (storage_set, "updated_folder", G_CALLBACK (updated_folder_cb), storage_set_view, 0); - g_signal_connect_object (storage_set, "removed_folder", G_CALLBACK (removed_folder_cb), storage_set_view, 0); - g_signal_connect_object (storage_set, "close_folder", G_CALLBACK (close_folder_cb), storage_set_view, 0); - - g_signal_connect_object (priv->etree_model, "fill_in_children", G_CALLBACK (etree_fill_in_children), storage_set_view, 0); - - insert_storages (storage_set_view); -} - -/* DON'T USE THIS. Use e_storage_set_new_view() instead. */ -GtkWidget * -e_storage_set_view_new (EStorageSet *storage_set, - BonoboUIContainer *ui_container) -{ - GtkWidget *new; - - g_return_val_if_fail (E_IS_STORAGE_SET (storage_set), NULL); - - new = g_object_new (e_storage_set_view_get_type (), NULL); - - e_storage_set_view_construct (E_STORAGE_SET_VIEW (new), storage_set, ui_container); - - return new; -} - - -EStorageSet * -e_storage_set_view_get_storage_set (EStorageSetView *storage_set_view) -{ - EStorageSetViewPrivate *priv; - - g_return_val_if_fail (E_IS_STORAGE_SET_VIEW (storage_set_view), NULL); - - priv = storage_set_view->priv; - return priv->storage_set; -} - -void -e_storage_set_view_set_drag_types (EStorageSetView *view, const GtkTargetEntry *drag_types, int ntypes) -{ - g_return_if_fail (E_IS_STORAGE_SET_VIEW (view)); - - view->priv->drag_types = drag_types; - view->priv->num_drag_types = ntypes; - - e_tree_drag_source_set ((ETree *) view, GDK_BUTTON1_MASK, drag_types, - ntypes, GDK_ACTION_MOVE | GDK_ACTION_COPY); -} - -void -e_storage_set_view_set_drop_types (EStorageSetView *view, const GtkTargetEntry *drop_types, int ntypes) -{ - g_return_if_fail (E_IS_STORAGE_SET_VIEW (view)); - - view->priv->drop_types = drop_types; - view->priv->num_drop_types = ntypes; - - e_tree_drag_dest_set ((ETree *) view, GTK_DEST_DEFAULT_ALL, drop_types, - ntypes, GDK_ACTION_MOVE | GDK_ACTION_COPY); -} - -void -e_storage_set_view_set_current_folder (EStorageSetView *storage_set_view, - const char *path) -{ - EStorageSetViewPrivate *priv; - ETreePath node; - - g_return_if_fail (E_IS_STORAGE_SET_VIEW (storage_set_view)); - g_return_if_fail (path != NULL && g_path_is_absolute (path)); - - priv = storage_set_view->priv; - - node = g_hash_table_lookup (priv->path_to_etree_node, path); - if (node == NULL) - return; - - e_tree_show_node (E_TREE (storage_set_view), node); - e_tree_set_cursor (E_TREE (storage_set_view), node); - - g_free (priv->selected_row_path); - priv->selected_row_path = g_strdup (path); - - g_signal_emit (storage_set_view, signals[FOLDER_SELECTED], 0, path); -} - -const char * -e_storage_set_view_get_current_folder (EStorageSetView *storage_set_view) -{ - EStorageSetViewPrivate *priv; - ETreePath etree_node; - const char *path; - - g_return_val_if_fail (E_IS_STORAGE_SET_VIEW (storage_set_view), NULL); - - priv = storage_set_view->priv; - - if (!priv->show_folders) - return NULL; /* Mmh! */ - - etree_node = e_tree_get_cursor (E_TREE (storage_set_view)); - - if (etree_node == NULL) - return NULL; /* Mmh? */ - - path = (char*)e_tree_memory_node_get_data(E_TREE_MEMORY(priv->etree_model), etree_node); - - return path; -} - -void -e_storage_set_view_set_show_folders (EStorageSetView *storage_set_view, - gboolean show) -{ - EStorageSetViewPrivate *priv; - - g_return_if_fail (E_IS_STORAGE_SET_VIEW (storage_set_view)); - - priv = storage_set_view->priv; - - if (show == priv->show_folders) - return; - - /* tear down existing tree and hash table mappings */ - e_tree_memory_node_remove (E_TREE_MEMORY(priv->etree_model), priv->root_node); - - /* now re-add the root node */ - priv->root_node = e_tree_memory_node_insert (E_TREE_MEMORY(priv->etree_model), NULL, -1, - g_strdup (ROOT_NODE_NAME)); - add_node_to_hash (storage_set_view, ROOT_NODE_NAME, priv->root_node); - - /* then reinsert the storages after setting the "show_folders" - flag. insert_storages will call insert_folders if - show_folders is TRUE */ - - priv->show_folders = show; - insert_storages (storage_set_view); -} - -gboolean -e_storage_set_view_get_show_folders (EStorageSetView *storage_set_view) -{ - return storage_set_view->priv->show_folders; -} - - - -void -e_storage_set_view_set_show_checkboxes (EStorageSetView *storage_set_view, - gboolean show, - EStorageSetViewHasCheckBoxFunc has_checkbox_func, - void *func_data) -{ - EStorageSetViewPrivate *priv; - ETableState *state; - - g_return_if_fail (E_IS_STORAGE_SET_VIEW (storage_set_view)); - - priv = storage_set_view->priv; - - show = !! show; - - if (show == priv->show_checkboxes) - return; - - priv->show_checkboxes = show; - - state = e_tree_get_state_object (E_TREE (storage_set_view)); - state->col_count = show ? 2 : 1; - state->columns = g_renew (int, state->columns, state->col_count); - state->columns [state->col_count - 1] = 0; - if (show) - state->columns [0] = 1; - - state->expansions = g_renew (double, state->expansions, state->col_count); - state->expansions [0] = 1.0; - if (show) - state->expansions [1] = 1.0; - - e_tree_set_state_object (E_TREE (storage_set_view), state); - - priv->has_checkbox_func = has_checkbox_func; - priv->has_checkbox_func_data = func_data; -} - -gboolean -e_storage_set_view_get_show_checkboxes (EStorageSetView *storage_set_view) -{ - g_return_val_if_fail (E_IS_STORAGE_SET_VIEW (storage_set_view), FALSE); - - return storage_set_view->priv->show_checkboxes; -} - -void -e_storage_set_view_enable_search (EStorageSetView *storage_set_view, - gboolean enable) -{ - g_return_if_fail (E_IS_STORAGE_SET_VIEW (storage_set_view)); - - enable = !! enable; - - if (enable == storage_set_view->priv->search_enabled) - return; - - storage_set_view->priv->search_enabled = enable; - e_tree_set_search_column (E_TREE (storage_set_view), enable ? 0 : -1); -} - -void -e_storage_set_view_set_checkboxes_list (EStorageSetView *storage_set_view, - GSList *checkboxes) -{ - gboolean changed = FALSE; - EStorageSetViewPrivate *priv = storage_set_view->priv; - - e_tree_model_pre_change (priv->etree_model); - if (priv->checkboxes) { - g_hash_table_foreach (priv->checkboxes, (GHFunc) g_free, NULL); - g_hash_table_destroy (priv->checkboxes); - changed = TRUE; - } - - if (checkboxes) { - priv->checkboxes = g_hash_table_new (g_str_hash, g_str_equal); - for (; checkboxes; checkboxes = g_slist_next (checkboxes)) { - char *path = checkboxes->data; - - if (g_hash_table_lookup (priv->checkboxes, path)) - continue; - path = g_strdup (path); - g_hash_table_insert (priv->checkboxes, path, path); - } - changed = TRUE; - } - - if (changed) - e_tree_model_node_changed (priv->etree_model, - e_tree_model_get_root (priv->etree_model)); - else - e_tree_model_no_change (priv->etree_model); -} - -static void -essv_add_to_list (gpointer key, - gpointer value, - gpointer user_data) -{ - GSList **list = user_data; - - *list = g_slist_prepend (*list, g_strdup (key)); -} - -GSList * -e_storage_set_view_get_checkboxes_list (EStorageSetView *storage_set_view) -{ - GSList *list = NULL; - - if (storage_set_view->priv->checkboxes) { - g_hash_table_foreach (storage_set_view->priv->checkboxes, essv_add_to_list, &list); - - list = g_slist_reverse (list); - } - - return list; -} - - -void -e_storage_set_view_set_allow_dnd (EStorageSetView *storage_set_view, - gboolean allow_dnd) -{ - g_return_if_fail (E_IS_STORAGE_SET_VIEW (storage_set_view)); - - storage_set_view->priv->allow_dnd = allow_dnd; -} - -gboolean -e_storage_set_view_get_allow_dnd (EStorageSetView *storage_set_view) -{ - g_return_val_if_fail (E_IS_STORAGE_SET_VIEW (storage_set_view), FALSE); - - return storage_set_view->priv->allow_dnd; -} - -const char * -e_storage_set_view_get_right_click_path (EStorageSetView *storage_set_view) -{ - g_return_val_if_fail (E_IS_STORAGE_SET_VIEW (storage_set_view), NULL); - - return storage_set_view->priv->right_click_row_path; -} - - -E_MAKE_TYPE (e_storage_set_view, "EStorageSetView", EStorageSetView, class_init, init, PARENT_TYPE) diff --git a/shell/e-storage-set-view.h b/shell/e-storage-set-view.h deleted file mode 100644 index 1cbb5bfde4..0000000000 --- a/shell/e-storage-set-view.h +++ /dev/null @@ -1,124 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-storage-set-view.h - * - * Copyright (C) 2000 Ximian, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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 __E_STORAGE_SET_VIEW_H__ -#define __E_STORAGE_SET_VIEW_H__ - -#include <gal/e-table/e-tree.h> -#include <bonobo/bonobo-ui-container.h> -#include "e-storage-set.h" - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - -#define E_TYPE_STORAGE_SET_VIEW (e_storage_set_view_get_type ()) -#define E_STORAGE_SET_VIEW(obj) (GTK_CHECK_CAST ((obj), E_TYPE_STORAGE_SET_VIEW, EStorageSetView)) -#define E_STORAGE_SET_VIEW_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_TYPE_STORAGE_SET_VIEW, EStorageSetViewClass)) -#define E_IS_STORAGE_SET_VIEW(obj) (GTK_CHECK_TYPE ((obj), E_TYPE_STORAGE_SET_VIEW)) -#define E_IS_STORAGE_SET_VIEW_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), E_TYPE_STORAGE_SET_VIEW)) - - -typedef gboolean (* EStorageSetViewHasCheckBoxFunc) (EStorageSet *storage_set, - const char *path, - void *data); - -typedef struct _EStorageSetView EStorageSetView; -typedef struct _EStorageSetViewPrivate EStorageSetViewPrivate; -typedef struct _EStorageSetViewClass EStorageSetViewClass; - -struct _EStorageSetView { - ETree parent; - - EStorageSetViewPrivate *priv; -}; - -struct _EStorageSetViewClass { - ETreeClass parent_class; - - /* Signals. */ - - void (* folder_selected) (EStorageSetView *storage_set_view, - const char *path); - void (* folder_opened) (EStorageSetView *storage_set_view, - const char *path); - - void (* folder_dragged) (EStorageSetView *view, const char *path, GdkDragContext *context, - GtkSelectionData *selection, guint info, guint time); - void (* folder_receive_drop) (EStorageSetView *view, const char *path, GdkDragContext *context, - GtkSelectionData *selection, guint info, guint time); - - void (* folder_context_menu_popping_up) (EStorageSetView *storage_set_view, - const char *path); - void (* folder_context_menu_popped_down) (EStorageSetView *storage_set_view); - void (* checkboxes_changed) (EStorageSetView *storage_set_view); -}; - - -GtkType e_storage_set_view_get_type (void); - -/* DON'T USE THIS. Use e_storage_set_new_view() instead. */ -GtkWidget *e_storage_set_view_new (EStorageSet *storage_set, - BonoboUIContainer *ui_container); -void e_storage_set_view_construct (EStorageSetView *storage_set_view, - EStorageSet *storage_set, - BonoboUIContainer *ui_container); - -EStorageSet *e_storage_set_view_get_storage_set (EStorageSetView *storage_set_view); - -void e_storage_set_view_set_drag_types (EStorageSetView *view, const GtkTargetEntry *drag_types, int ntypes); -void e_storage_set_view_set_drop_types (EStorageSetView *view, const GtkTargetEntry *drop_types, int ntypes); - -void e_storage_set_view_set_current_folder (EStorageSetView *storage_set_view, - const char *path); -const char *e_storage_set_view_get_current_folder (EStorageSetView *storage_set_view); - -void e_storage_set_view_set_show_folders (EStorageSetView *storage_set_view, - gboolean show); -gboolean e_storage_set_view_get_show_folders (EStorageSetView *storage_set_view); - -void e_storage_set_view_set_show_checkboxes (EStorageSetView *storage_set_view, - gboolean show, - EStorageSetViewHasCheckBoxFunc has_checkbox_func, - void *func_data); -gboolean e_storage_set_view_get_show_checkboxes (EStorageSetView *storage_set_view); - -void e_storage_set_view_enable_search (EStorageSetView *storage_set_view, - gboolean enable); - -void e_storage_set_view_set_checkboxes_list (EStorageSetView *storage_set_view, - GSList *checkboxes); -GSList *e_storage_set_view_get_checkboxes_list (EStorageSetView *storage_set_view); - -void e_storage_set_view_set_allow_dnd (EStorageSetView *storage_set_view, - gboolean allow_dnd); -gboolean e_storage_set_view_get_allow_dnd (EStorageSetView *storage_set_view); - -const char *e_storage_set_view_get_right_click_path (EStorageSetView *storage_set_view); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - - -#endif /* __E_STORAGE_SET_VIEW_H__ */ diff --git a/shell/e-storage-set.c b/shell/e-storage-set.c deleted file mode 100644 index 2978ea7572..0000000000 --- a/shell/e-storage-set.c +++ /dev/null @@ -1,885 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-storage-set.c - * - * Copyright (C) 2000 Ximian, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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 "e-storage-set.h" - -#include "e-storage-set-view.h" -#include "e-shell-constants.h" -#include "e-shell-marshal.h" - -#include <glib.h> -#include <gtk/gtkobject.h> -#include <gtk/gtksignal.h> -#include <gtk/gtktypeutils.h> - -#include <gal/util/e-util.h> - -#include <string.h> - - -#define PARENT_TYPE GTK_TYPE_OBJECT - -static GtkObjectClass *parent_class = NULL; - -/* This is just to make GHashTable happy. */ -struct _NamedStorage { - char *name; - EStorage *storage; -}; -typedef struct _NamedStorage NamedStorage; - -struct _EStorageSetPrivate { - GList *storages; /* EStorage */ - GHashTable *name_to_named_storage; - - EFolderTypeRegistry *folder_type_registry; -}; - -enum { - NEW_STORAGE, - REMOVED_STORAGE, - NEW_FOLDER, - UPDATED_FOLDER, - REMOVED_FOLDER, - MOVED_FOLDER, - CLOSE_FOLDER, - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL] = { 0 }; - - -static NamedStorage * -named_storage_new (EStorage *storage) -{ - NamedStorage *new; - - new = g_new (NamedStorage, 1); - new->name = g_strdup (e_storage_get_name (storage)); - new->storage = storage; - - return new; -} - -static void -named_storage_destroy (NamedStorage *named_storage) -{ - g_free (named_storage->name); - g_free (named_storage); -} - -static gboolean -name_to_named_storage_foreach_destroy (void *key, - void *value, - void *user_data) -{ - NamedStorage *named_storage; - - named_storage = (NamedStorage *) value; - named_storage_destroy (named_storage); - - return TRUE; -} - - -/* "Callback converter", from `EStorageResultCallback' to - `EStorageSetResultCallback'. */ - -enum _StorageOperation { - OPERATION_COPY, - OPERATION_MOVE, - OPERATION_REMOVE, - OPERATION_CREATE -}; -typedef enum _StorageOperation StorageOperation; - -struct _StorageCallbackData { - EStorageSet *storage_set; - EStorageSetResultCallback storage_set_result_callback; - char *source_path; - char *destination_path; - StorageOperation operation; - void *data; -}; -typedef struct _StorageCallbackData StorageCallbackData; - -static StorageCallbackData * -storage_callback_data_new (EStorageSet *storage_set, - EStorageSetResultCallback callback, - const char *source_path, - const char *destination_path, - StorageOperation operation, - void *data) -{ - StorageCallbackData *new; - - new = g_new (StorageCallbackData, 1); - new->storage_set = storage_set; - new->storage_set_result_callback = callback; - new->source_path = g_strdup (source_path); - new->destination_path = g_strdup (destination_path); - new->operation = operation; - new->data = data; - - return new; -} - -static void -storage_callback_data_free (StorageCallbackData *data) -{ - g_free (data->source_path); - g_free (data->destination_path); - - g_free (data); -} - -static void -storage_callback (EStorage *storage, - EStorageResult result, - void *data) -{ - StorageCallbackData *storage_callback_data; - - storage_callback_data = (StorageCallbackData *) data; - - (* storage_callback_data->storage_set_result_callback) (storage_callback_data->storage_set, - result, - storage_callback_data->data); - - if (storage_callback_data->operation == OPERATION_MOVE) - g_signal_emit (storage_callback_data->storage_set, signals[MOVED_FOLDER], 0, - storage_callback_data->source_path, storage_callback_data->destination_path); - - storage_callback_data_free (storage_callback_data); -} - - -/* Handling for signals coming from the EStorages. */ - -static char * -make_full_path (EStorage *storage, - const char *path) -{ - const char *storage_name; - char *full_path; - - storage_name = e_storage_get_name (storage); - - if (strcmp (path, E_PATH_SEPARATOR_S) == 0) - full_path = g_strconcat (E_PATH_SEPARATOR_S, storage_name, - NULL); - else if (! g_path_is_absolute (path)) - full_path = g_strconcat (E_PATH_SEPARATOR_S, storage_name, - E_PATH_SEPARATOR_S, path, NULL); - else - full_path = g_strconcat (E_PATH_SEPARATOR_S, storage_name, - path, NULL); - - return full_path; -} - -static void -storage_new_folder_cb (EStorage *storage, - const char *path, - void *data) -{ - EStorageSet *storage_set; - char *full_path; - - storage_set = E_STORAGE_SET (data); - - full_path = make_full_path (storage, path); - g_signal_emit (storage_set, signals[NEW_FOLDER], 0, full_path); - g_free (full_path); -} - -static void -storage_updated_folder_cb (EStorage *storage, - const char *path, - void *data) -{ - EStorageSet *storage_set; - char *full_path; - - storage_set = E_STORAGE_SET (data); - - full_path = make_full_path (storage, path); - g_signal_emit (storage_set, signals[UPDATED_FOLDER], 0, full_path); - g_free (full_path); -} - -static void -storage_removed_folder_cb (EStorage *storage, - const char *path, - void *data) -{ - EStorageSet *storage_set; - char *full_path; - - storage_set = E_STORAGE_SET (data); - - full_path = make_full_path (storage, path); - g_signal_emit (storage_set, signals[REMOVED_FOLDER], 0, full_path); - g_free (full_path); -} - - -static EStorage * -get_storage_for_path (EStorageSet *storage_set, - const char *path, - const char **subpath_return) -{ - EStorage *storage; - char *storage_name; - const char *first_separator; - - g_return_val_if_fail (g_path_is_absolute (path), NULL); - g_return_val_if_fail (path[1] != E_PATH_SEPARATOR, NULL); - - /* Skip initial separator. */ - path++; - - first_separator = strchr (path, E_PATH_SEPARATOR); - - if (first_separator == NULL || first_separator[1] == 0) { - storage = e_storage_set_get_storage (storage_set, path); - *subpath_return = E_PATH_SEPARATOR_S; - } else { - storage_name = g_strndup (path, first_separator - path); - storage = e_storage_set_get_storage (storage_set, storage_name); - g_free (storage_name); - - *subpath_return = first_separator; - } - - return storage; -} - -static void -signal_new_folder_for_all_folders_under_paths (EStorageSet *storage_set, - EStorage *storage, - GList *path_list) -{ - GList *p; - - for (p = path_list; p != NULL; p = p->next) { - GList *sub_path_list; - const char *path; - char *path_with_storage; - - path = (const char *) p->data; - - path_with_storage = g_strconcat (E_PATH_SEPARATOR_S, e_storage_get_name (storage), path, NULL); - g_signal_emit (storage_set, signals[NEW_FOLDER], 0, path_with_storage); - g_free (path_with_storage); - - sub_path_list = e_storage_get_subfolder_paths (storage, path); - - signal_new_folder_for_all_folders_under_paths (storage_set, storage, sub_path_list); - - e_free_string_list (sub_path_list); - } -} - -static void -signal_new_folder_for_all_folders_in_storage (EStorageSet *storage_set, - EStorage *storage) -{ - GList *path_list; - - path_list = e_storage_get_subfolder_paths (storage, E_PATH_SEPARATOR_S); - - signal_new_folder_for_all_folders_under_paths (storage_set, storage, path_list); - - e_free_string_list (path_list); -} - - -/* GtkObject methods. */ - -static void -impl_dispose (GObject *object) -{ - EStorageSet *storage_set; - EStorageSetPrivate *priv; - - storage_set = E_STORAGE_SET (object); - priv = storage_set->priv; - - if (priv->storages != NULL) { - e_free_object_list (priv->storages); - priv->storages = NULL; - } - - if (priv->folder_type_registry != NULL) { - g_object_unref (priv->folder_type_registry); - priv->folder_type_registry = NULL; - } - - (* G_OBJECT_CLASS (parent_class)->dispose) (object); -} - -static void -impl_finalize (GObject *object) -{ - EStorageSet *storage_set; - EStorageSetPrivate *priv; - - storage_set = E_STORAGE_SET (object); - priv = storage_set->priv; - - g_hash_table_foreach (priv->name_to_named_storage, (GHFunc) name_to_named_storage_foreach_destroy, NULL); - g_hash_table_destroy (priv->name_to_named_storage); - - g_free (priv); - - (* G_OBJECT_CLASS (parent_class)->finalize) (object); -} - - -static void -class_init (EStorageSetClass *klass) -{ - GObjectClass *object_class; - - parent_class = g_type_class_ref(gtk_object_get_type ()); - object_class = G_OBJECT_CLASS (klass); - - object_class->dispose = impl_dispose; - object_class->finalize = impl_finalize; - - signals[NEW_STORAGE] = - g_signal_new ("new_storage", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (EStorageSetClass, new_storage), - NULL, NULL, - e_shell_marshal_NONE__POINTER, - G_TYPE_NONE, 1, - G_TYPE_POINTER); - signals[REMOVED_STORAGE] = - g_signal_new ("removed_storage", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (EStorageSetClass, removed_storage), - NULL, NULL, - e_shell_marshal_NONE__POINTER, - G_TYPE_NONE, 1, - G_TYPE_POINTER); - signals[NEW_FOLDER] = - g_signal_new ("new_folder", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (EStorageSetClass, new_folder), - NULL, NULL, - e_shell_marshal_NONE__STRING, - G_TYPE_NONE, 1, - G_TYPE_STRING); - signals[UPDATED_FOLDER] = - g_signal_new ("updated_folder", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (EStorageSetClass, updated_folder), - NULL, NULL, - e_shell_marshal_NONE__STRING, - G_TYPE_NONE, 1, - G_TYPE_STRING); - signals[REMOVED_FOLDER] = - g_signal_new ("removed_folder", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (EStorageSetClass, removed_folder), - NULL, NULL, - e_shell_marshal_NONE__STRING, - G_TYPE_NONE, 1, - G_TYPE_STRING); - signals[MOVED_FOLDER] = - g_signal_new ("moved_folder", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (EStorageSetClass, moved_folder), - NULL, NULL, - e_shell_marshal_NONE__STRING_STRING, - G_TYPE_NONE, 2, - G_TYPE_STRING, - G_TYPE_STRING); - signals[CLOSE_FOLDER] = - g_signal_new ("close_folder", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (EStorageSetClass, close_folder), - NULL, NULL, - e_shell_marshal_NONE__STRING, - G_TYPE_NONE, 1, - G_TYPE_STRING); -} - -static void -init (EStorageSet *storage_set) -{ - EStorageSetPrivate *priv; - - g_return_if_fail (E_IS_STORAGE_SET (storage_set)); - - priv = g_new (EStorageSetPrivate, 1); - priv->storages = NULL; - priv->name_to_named_storage = g_hash_table_new (g_str_hash, g_str_equal); - priv->folder_type_registry = NULL; - - storage_set->priv = priv; -} - - -void -e_storage_set_construct (EStorageSet *storage_set, - EFolderTypeRegistry *folder_type_registry) -{ - g_return_if_fail (storage_set != NULL); - g_return_if_fail (E_IS_STORAGE_SET (storage_set)); - - GTK_OBJECT_UNSET_FLAGS (storage_set, GTK_FLOATING); - - g_object_ref (folder_type_registry); - storage_set->priv->folder_type_registry = folder_type_registry; -} - -EStorageSet * -e_storage_set_new (EFolderTypeRegistry *folder_type_registry) -{ - EStorageSet *new; - - new = g_object_new (e_storage_set_get_type (), NULL); - - e_storage_set_construct (new, folder_type_registry); - - return new; -} - - -GList * -e_storage_set_get_storage_list (EStorageSet *storage_set) -{ - EStorageSetPrivate *priv; - GList *list; - GList *p; - - g_return_val_if_fail (storage_set != NULL, NULL); - g_return_val_if_fail (E_IS_STORAGE_SET (storage_set), NULL); - - priv = storage_set->priv; - - list = NULL; - for (p = priv->storages; p != NULL; p = p->next) { - g_object_ref (p->data); - list = g_list_prepend (list, p->data); - } - - return g_list_reverse (list); /* Lame. */ -} - -/** - * e_storage_set_add_storage: - * @storage_set: - * @storage: - * - * Add @storage to @storage_set. Notice that will ref the storage. - **/ -gboolean -e_storage_set_add_storage (EStorageSet *storage_set, - EStorage *storage) -{ - EStorageSetPrivate *priv; - const char *storage_name; - NamedStorage *named_storage; - - g_return_val_if_fail (storage_set != NULL, FALSE); - g_return_val_if_fail (E_IS_STORAGE_SET (storage_set), FALSE); - g_return_val_if_fail (storage != NULL, FALSE); - g_return_val_if_fail (E_IS_STORAGE (storage), FALSE); - - priv = storage_set->priv; - - storage_name = e_storage_get_name (storage); - if (g_hash_table_lookup (priv->name_to_named_storage, storage_name) != NULL) - return FALSE; - - g_object_ref (storage); - - g_signal_connect (storage, "new_folder", - G_CALLBACK (storage_new_folder_cb), storage_set); - g_signal_connect (storage, "updated_folder", - G_CALLBACK (storage_updated_folder_cb), storage_set); - g_signal_connect (storage, "removed_folder", - G_CALLBACK (storage_removed_folder_cb), storage_set); - - priv->storages = g_list_append (priv->storages, storage); - - named_storage = named_storage_new (storage); - g_hash_table_insert (priv->name_to_named_storage, named_storage->name, named_storage); - - g_signal_emit (storage_set, signals[NEW_STORAGE], 0, storage); - - signal_new_folder_for_all_folders_in_storage (storage_set, storage); - - return TRUE; -} - -gboolean -e_storage_set_remove_storage (EStorageSet *storage_set, - EStorage *storage) -{ - EStorageSetPrivate *priv; - NamedStorage *named_storage; - - g_return_val_if_fail (storage_set != NULL, FALSE); - g_return_val_if_fail (E_IS_STORAGE_SET (storage_set), FALSE); - g_return_val_if_fail (storage != NULL, FALSE); - g_return_val_if_fail (E_IS_STORAGE (storage), FALSE); - - priv = storage_set->priv; - - named_storage = g_hash_table_lookup (priv->name_to_named_storage, - e_storage_get_name (storage)); - if (named_storage == NULL) - return FALSE; - - g_hash_table_remove (priv->name_to_named_storage, named_storage->name); - named_storage_destroy (named_storage); - - priv->storages = g_list_remove (priv->storages, storage); - - g_signal_emit (storage_set, signals[REMOVED_STORAGE], 0, storage); - g_object_unref (storage); - - return TRUE; -} - -void -e_storage_set_remove_all_storages (EStorageSet *storage_set) -{ - EStorageSetPrivate *priv; - GList *p; - - g_return_if_fail (storage_set != NULL); - g_return_if_fail (E_IS_STORAGE_SET (storage_set)); - - priv = storage_set->priv; - - for (p = priv->storages; p != NULL; p = p->next) { - EStorage *storage; - - storage = E_STORAGE (p->data); - - g_signal_emit (storage_set, signals[REMOVED_STORAGE], 0, storage); - g_object_unref (storage); - } - - g_hash_table_foreach_remove (priv->name_to_named_storage, - name_to_named_storage_foreach_destroy, - NULL); - - g_list_free (priv->storages); - priv->storages = NULL; -} - - -EStorage * -e_storage_set_get_storage (EStorageSet *storage_set, - const char *name) -{ - EStorageSetPrivate *priv; - NamedStorage *named_storage; - - g_return_val_if_fail (storage_set != NULL, NULL); - g_return_val_if_fail (E_IS_STORAGE_SET (storage_set), NULL); - g_return_val_if_fail (name != NULL, NULL); - - priv = storage_set->priv; - - named_storage = g_hash_table_lookup (priv->name_to_named_storage, name); - if (named_storage == NULL) - return NULL; - else - return named_storage->storage; -} - -EFolder * -e_storage_set_get_folder (EStorageSet *storage_set, - const char *path) -{ - EStorage *storage; - const char *subpath; - - g_return_val_if_fail (storage_set != NULL, NULL); - g_return_val_if_fail (E_IS_STORAGE_SET (storage_set), NULL); - g_return_val_if_fail (path != NULL, NULL); - g_return_val_if_fail (g_path_is_absolute (path), NULL); - - storage = get_storage_for_path (storage_set, path, &subpath); - if (storage == NULL) - return NULL; - - return e_storage_get_folder (storage, subpath); -} - - -static void -async_open_cb (EStorage *storage, EStorageResult result, - const char *path, gpointer storage_set) -{ - if (result != E_STORAGE_OK) { - char *full_path; - - full_path = make_full_path (storage, path); - g_signal_emit (storage_set, signals[CLOSE_FOLDER], 0, full_path); - g_free (full_path); - } -} - -static void -storage_set_view_folder_opened (EStorageSetView *storage_set_view, - const char *path, - EStorageSet *storage_set) -{ - EStorage *storage; - const char *subpath; - - storage = get_storage_for_path (storage_set, path, &subpath); - if (storage == NULL) - return; - - e_storage_async_open_folder (storage, subpath, - async_open_cb, storage_set); -} - -GtkWidget * -e_storage_set_create_new_view (EStorageSet *storage_set, - BonoboUIContainer *ui_container) -{ - GtkWidget *storage_set_view; - - g_return_val_if_fail (storage_set != NULL, NULL); - g_return_val_if_fail (E_IS_STORAGE_SET (storage_set), NULL); - - storage_set_view = e_storage_set_view_new (storage_set, ui_container); - g_signal_connect (storage_set_view, "folder_opened", - G_CALLBACK (storage_set_view_folder_opened), - storage_set); - - return storage_set_view; -} - - -void -e_storage_set_async_create_folder (EStorageSet *storage_set, - const char *path, - const char *type, - const char *description, - EStorageSetResultCallback callback, - void *data) -{ - EStorage *storage; - const char *subpath; - StorageCallbackData *storage_callback_data; - - g_return_if_fail (storage_set != NULL); - g_return_if_fail (E_IS_STORAGE_SET (storage_set)); - g_return_if_fail (path != NULL); - g_return_if_fail (g_path_is_absolute (path)); - g_return_if_fail (type != NULL); - g_return_if_fail (description != NULL); - g_return_if_fail (callback != NULL); - - storage = get_storage_for_path (storage_set, path, &subpath); - - storage_callback_data = storage_callback_data_new (storage_set, callback, - path, NULL, OPERATION_CREATE, - data); - - e_storage_async_create_folder (storage, subpath, type, description, - storage_callback, storage_callback_data); -} - -void -e_storage_set_async_remove_folder (EStorageSet *storage_set, - const char *path, - EStorageSetResultCallback callback, - void *data) -{ - EStorage *storage; - const char *subpath; - StorageCallbackData *storage_callback_data; - - g_return_if_fail (storage_set != NULL); - g_return_if_fail (E_IS_STORAGE_SET (storage_set)); - g_return_if_fail (path != NULL); - g_return_if_fail (g_path_is_absolute (path)); - g_return_if_fail (callback != NULL); - - storage = get_storage_for_path (storage_set, path, &subpath); - - storage_callback_data = storage_callback_data_new (storage_set, callback, - path, NULL, OPERATION_REMOVE, - data); - - e_storage_async_remove_folder (storage, subpath, - storage_callback, storage_callback_data); -} - -void -e_storage_set_async_xfer_folder (EStorageSet *storage_set, - const char *source_path, - const char *destination_path, - gboolean remove_source, - EStorageSetResultCallback callback, - void *data) -{ - EStorage *source_storage; - EStorage *destination_storage; - const char *source_subpath; - const char *destination_subpath; - StorageCallbackData *storage_callback_data; - - g_return_if_fail (storage_set != NULL); - g_return_if_fail (E_IS_STORAGE_SET (storage_set)); - g_return_if_fail (source_path != NULL); - g_return_if_fail (g_path_is_absolute (source_path)); - g_return_if_fail (destination_path != NULL); - g_return_if_fail (g_path_is_absolute (destination_path)); - g_return_if_fail (callback != NULL); - - source_storage = get_storage_for_path (storage_set, source_path, &source_subpath); - destination_storage = get_storage_for_path (storage_set, destination_path, &destination_subpath); - - if (source_storage != destination_storage) { - g_warning ("e_storage_set_async_xfer_folder(): " - "Attempt to xfer folders between different storages -- not supported yet."); - (* callback) (storage_set, E_STORAGE_UNSUPPORTEDOPERATION, data); - return; - } - - storage_callback_data = storage_callback_data_new (storage_set, - callback, - source_path, - destination_path, - remove_source ? OPERATION_MOVE : OPERATION_COPY, - data); - - e_storage_async_xfer_folder (source_storage, - source_subpath, destination_subpath, remove_source, - storage_callback, storage_callback_data); -} - -void -e_storage_set_async_remove_shared_folder (EStorageSet *storage_set, - const char *path, - EStorageSetResultCallback callback, - void *data) -{ - EStorage *storage; - const char *subpath; - StorageCallbackData *storage_callback_data; - - g_return_if_fail (storage_set != NULL); - g_return_if_fail (E_IS_STORAGE_SET (storage_set)); - g_return_if_fail (path != NULL); - g_return_if_fail (g_path_is_absolute (path)); - g_return_if_fail (callback != NULL); - - storage = get_storage_for_path (storage_set, path, &subpath); - - if (!e_storage_supports_shared_folders (storage)) { - (* callback) (storage_set, E_STORAGE_NOTIMPLEMENTED, data); - return; - } - - storage_callback_data = storage_callback_data_new (storage_set, callback, - path, NULL, OPERATION_REMOVE, - data); - - e_storage_async_remove_shared_folder (storage, subpath, - storage_callback, - storage_callback_data); -} - - -EFolderTypeRegistry * -e_storage_set_get_folder_type_registry (EStorageSet *storage_set) -{ - g_return_val_if_fail (storage_set != NULL, NULL); - g_return_val_if_fail (E_IS_STORAGE_SET (storage_set), NULL); - - return storage_set->priv->folder_type_registry; -} - - -/** - * e_storage_set_get_path_for_physical_uri: - * @storage_set: A storage set - * @physical_uri: A physical URI - * - * Retrieve the path of the folder whose physical URI matches @physical_uri. - * - * Return value: - **/ -char * -e_storage_set_get_path_for_physical_uri (EStorageSet *storage_set, - const char *physical_uri) -{ - EStorageSetPrivate *priv; - GList *p; - - g_return_val_if_fail (storage_set != NULL, NULL); - g_return_val_if_fail (E_IS_STORAGE_SET (storage_set), NULL); - g_return_val_if_fail (physical_uri != NULL, NULL); - - priv = storage_set->priv; - - for (p = priv->storages; p != NULL; p = p->next) { - EStorage *storage; - char *storage_path; - - storage = E_STORAGE (p->data); - - storage_path = e_storage_get_path_for_physical_uri (storage, physical_uri); - if (storage_path != NULL) { - char *storage_set_path; - - storage_set_path = g_strconcat (E_PATH_SEPARATOR_S, - e_storage_get_name (storage), - storage_path, - NULL); - g_free (storage_path); - - return storage_set_path; - } - } - - return NULL; -} - - -E_MAKE_TYPE (e_storage_set, "EStorageSet", EStorageSet, class_init, init, PARENT_TYPE) diff --git a/shell/e-storage-set.h b/shell/e-storage-set.h deleted file mode 100644 index 35c83a3eb5..0000000000 --- a/shell/e-storage-set.h +++ /dev/null @@ -1,123 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-storage-set.h - * - * Copyright (C) 2000 Ximian, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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 _E_STORAGE_SET_H_ -#define _E_STORAGE_SET_H_ - -#include <gtk/gtkwidget.h> - -#include <bonobo/bonobo-ui-container.h> - -#include "e-folder-type-registry.h" -#include "e-storage.h" - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - -#define E_TYPE_STORAGE_SET (e_storage_set_get_type ()) -#define E_STORAGE_SET(obj) (GTK_CHECK_CAST ((obj), E_TYPE_STORAGE_SET, EStorageSet)) -#define E_STORAGE_SET_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_TYPE_STORAGE_SET, EStorageSetClass)) -#define E_IS_STORAGE_SET(obj) (GTK_CHECK_TYPE ((obj), E_TYPE_STORAGE_SET)) -#define E_IS_STORAGE_SET_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), E_TYPE_STORAGE_SET)) - - -typedef struct _EStorageSet EStorageSet; -typedef struct _EStorageSetPrivate EStorageSetPrivate; -typedef struct _EStorageSetClass EStorageSetClass; - -typedef void (* EStorageSetResultCallback) (EStorageSet *storage_set, EStorageResult result, void *data); - -struct _EStorageSet { - GtkObject parent; - - EStorageSetPrivate *priv; -}; - -struct _EStorageSetClass { - GtkObjectClass parent_class; - - /* Signals. */ - - void (* new_storage) (EStorageSet *storage_set, EStorage *storage); - void (* removed_storage) (EStorageSet *storage_set, EStorage *storage); - /* FIXME? Inconsistency between storage and folders. */ - void (* new_folder) (EStorageSet *storage_set, const char *path); - void (* updated_folder) (EStorageSet *storage_set, const char *path); - void (* removed_folder) (EStorageSet *storage_set, const char *path); - void (* moved_folder) (EStorageSet *storage_set, const char *source_path, const char *destination_path); - void (* close_folder) (EStorageSet *storage_set, const char *path); -}; - - -GtkType e_storage_set_get_type (void); -void e_storage_set_construct (EStorageSet *storage_set, - EFolderTypeRegistry *folder_type_registry); -EStorageSet *e_storage_set_new (EFolderTypeRegistry *folder_type_registry); -gboolean e_storage_set_add_storage (EStorageSet *storage_set, - EStorage *storage); -gboolean e_storage_set_remove_storage (EStorageSet *storage_set, - EStorage *storage); -void e_storage_set_remove_all_storages (EStorageSet *storage_set); -GList *e_storage_set_get_storage_list (EStorageSet *storage_set); -EStorage *e_storage_set_get_storage (EStorageSet *storage_set, - const char *storage_name); -EFolder *e_storage_set_get_folder (EStorageSet *storage_set, - const char *path); -GtkWidget *e_storage_set_create_new_view (EStorageSet *storage_set, - BonoboUIContainer *container); - -void e_storage_set_async_create_folder (EStorageSet *storage_set, - const char *path, - const char *type, - const char *description, - EStorageSetResultCallback callback, - void *data); -void e_storage_set_async_remove_folder (EStorageSet *storage_set, - const char *path, - EStorageSetResultCallback callback, - void *data); -void e_storage_set_async_xfer_folder (EStorageSet *storage_set, - const char *source_path, - const char *destination_path, - gboolean remove_source, - EStorageSetResultCallback callback, - void *data); - -void e_storage_set_async_remove_shared_folder (EStorageSet *storage_set, - const char *path, - EStorageSetResultCallback callback, - void *data); - -EFolderTypeRegistry *e_storage_set_get_folder_type_registry (EStorageSet *storage_set); - -/* Utility functions. */ - -char *e_storage_set_get_path_for_physical_uri (EStorageSet *storage_set, - const char *physical_uri); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _E_STORAGE_SET_H_ */ diff --git a/shell/e-storage.c b/shell/e-storage.c deleted file mode 100644 index 0a56e3569f..0000000000 --- a/shell/e-storage.c +++ /dev/null @@ -1,851 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-storage.c - * - * Copyright (C) 2000, 2001 Ximian, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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 - */ - -/* FIXME: The EFolderTree is kept both in the EStorage and the - * EvolutionStorage. Bad design. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include "e-storage.h" - -#include "e-folder-tree.h" -#include "e-shell-constants.h" -#include "e-shell-marshal.h" - -#include <gtk/gtkobject.h> -#include <gtk/gtksignal.h> - -#include <libgnome/gnome-i18n.h> -#include <gal/util/e-util.h> - -#include <string.h> - - -#define PARENT_TYPE GTK_TYPE_OBJECT -static GtkObjectClass *parent_class = NULL; - -#define ES_CLASS(obj) \ - E_STORAGE_CLASS (GTK_OBJECT_GET_CLASS (obj)) - -struct _EStoragePrivate { - /* The set of folders we have in this storage. */ - EFolderTree *folder_tree; - - /* Internal name of the storage */ - char *name; -}; - -enum { - NEW_FOLDER, - UPDATED_FOLDER, - REMOVED_FOLDER, - ASYNC_OPEN_FOLDER, - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL] = { 0 }; - - -/* Destroy notification function for the folders in the tree. */ - -static void -folder_destroy_notify (EFolderTree *tree, - const char *path, - void *data, - void *closure) -{ - EFolder *e_folder; - - if (data == NULL) { - /* The root folder has no EFolder associated to it. */ - return; - } - - e_folder = E_FOLDER (data); - g_object_unref (e_folder); -} - - -/* Signal callbacks for the EFolders. */ - -static void -folder_changed_cb (EFolder *folder, - void *data) -{ - EStorage *storage; - EStoragePrivate *priv; - const char *path, *p; - gboolean highlight; - - g_assert (E_IS_STORAGE (data)); - - storage = E_STORAGE (data); - priv = storage->priv; - - path = e_folder_tree_get_path_for_data (priv->folder_tree, folder); - g_assert (path != NULL); - - g_signal_emit (storage, signals[UPDATED_FOLDER], 0, path); - - highlight = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (folder), "last_highlight")); - if (highlight != e_folder_get_highlighted (folder)) { - highlight = !highlight; - g_object_set_data (G_OBJECT (folder), "last_highlight", GINT_TO_POINTER (highlight)); - p = strrchr (path, '/'); - if (p && p != path) { - char *name; - - name = g_strndup (path, p - path); - folder = e_folder_tree_get_folder (priv->folder_tree, name); - g_free (name); - if (folder) - e_folder_set_child_highlight (folder, highlight); - } - } -} - - -/* GObject methods. */ - -static void -impl_finalize (GObject *object) -{ - EStorage *storage; - EStoragePrivate *priv; - - storage = E_STORAGE (object); - priv = storage->priv; - - if (priv->folder_tree != NULL) - e_folder_tree_destroy (priv->folder_tree); - - g_free (priv->name); - - g_free (priv); - - (* G_OBJECT_CLASS (parent_class)->finalize) (object); -} - - -/* EStorage methods. */ - -static GList * -impl_get_subfolder_paths (EStorage *storage, - const char *path) -{ - EStoragePrivate *priv; - - priv = storage->priv; - - return e_folder_tree_get_subfolders (priv->folder_tree, path); -} - -static EFolder * -impl_get_folder (EStorage *storage, - const char *path) -{ - EStoragePrivate *priv; - EFolder *e_folder; - - priv = storage->priv; - - e_folder = (EFolder *) e_folder_tree_get_folder (priv->folder_tree, path); - - return e_folder; -} - -static const char * -impl_get_name (EStorage *storage) -{ - return storage->priv->name; -} - -static void -impl_async_create_folder (EStorage *storage, - const char *path, - const char *type, - const char *description, - EStorageResultCallback callback, - void *data) -{ - (* callback) (storage, E_STORAGE_NOTIMPLEMENTED, data); -} - -static void -impl_async_remove_folder (EStorage *storage, - const char *path, - EStorageResultCallback callback, - void *data) -{ - (* callback) (storage, E_STORAGE_NOTIMPLEMENTED, data); -} - -static void -impl_async_xfer_folder (EStorage *storage, - const char *source_path, - const char *destination_path, - gboolean remove_source, - EStorageResultCallback callback, - void *data) -{ - (* callback) (storage, E_STORAGE_NOTIMPLEMENTED, data); -} - -static gboolean -impl_supports_shared_folders (EStorage *storage) -{ - return FALSE; -} - -static void -impl_async_discover_shared_folder (EStorage *storage, - const char *owner, - const char *folder_name, - EStorageDiscoveryCallback callback, - void *data) -{ - (* callback) (storage, E_STORAGE_NOTIMPLEMENTED, NULL, data); -} - -static void -impl_async_remove_shared_folder (EStorage *storage, - const char *path, - EStorageResultCallback callback, - void *data) -{ - (* callback) (storage, E_STORAGE_NOTIMPLEMENTED, data); -} - - -/* Initialization. */ - -static void -class_init (EStorageClass *class) -{ - GObjectClass *object_class; - - object_class = G_OBJECT_CLASS (class); - parent_class = g_type_class_ref(gtk_object_get_type ()); - - object_class->finalize = impl_finalize; - - class->get_subfolder_paths = impl_get_subfolder_paths; - class->get_folder = impl_get_folder; - class->get_name = impl_get_name; - class->async_create_folder = impl_async_create_folder; - class->async_remove_folder = impl_async_remove_folder; - class->async_xfer_folder = impl_async_xfer_folder; - - class->supports_shared_folders = impl_supports_shared_folders; - class->async_discover_shared_folder = impl_async_discover_shared_folder; - class->async_remove_shared_folder = impl_async_remove_shared_folder; - - signals[NEW_FOLDER] = - g_signal_new ("new_folder", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (EStorageClass, new_folder), - NULL, NULL, - e_shell_marshal_NONE__STRING, - G_TYPE_NONE, 1, - G_TYPE_STRING); - signals[UPDATED_FOLDER] = - g_signal_new ("updated_folder", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (EStorageClass, updated_folder), - NULL, NULL, - e_shell_marshal_NONE__STRING, - G_TYPE_NONE, 1, - G_TYPE_STRING); - signals[REMOVED_FOLDER] = - g_signal_new ("removed_folder", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (EStorageClass, removed_folder), - NULL, NULL, - e_shell_marshal_NONE__STRING, - G_TYPE_NONE, 1, - G_TYPE_STRING); - signals[ASYNC_OPEN_FOLDER] = - g_signal_new ("async_open_folder", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (EStorageClass, async_open_folder), - NULL, NULL, - e_shell_marshal_NONE__STRING_POINTER_POINTER, - G_TYPE_NONE, 3, - G_TYPE_STRING, - G_TYPE_POINTER, - G_TYPE_POINTER); -} - -static void -init (EStorage *storage) -{ - EStoragePrivate *priv; - - priv = g_new (EStoragePrivate, 1); - - priv->folder_tree = e_folder_tree_new (folder_destroy_notify, NULL); - priv->name = NULL; - - storage->priv = priv; -} - - -/* Creation. */ - -void -e_storage_construct (EStorage *storage, - const char *name, - EFolder *root_folder) -{ - EStoragePrivate *priv; - - g_return_if_fail (storage != NULL); - g_return_if_fail (E_IS_STORAGE (storage)); - - priv = storage->priv; - - priv->name = g_strdup (name); - - e_storage_new_folder (storage, "/", root_folder); - - GTK_OBJECT_UNSET_FLAGS (GTK_OBJECT (storage), GTK_FLOATING); -} - -EStorage * -e_storage_new (const char *name, - EFolder *root_folder) -{ - EStorage *new; - - new = g_object_new (e_storage_get_type (), NULL); - - e_storage_construct (new, name, root_folder); - - return new; -} - - -gboolean -e_storage_path_is_absolute (const char *path) -{ - g_return_val_if_fail (path != NULL, FALSE); - - return *path == E_PATH_SEPARATOR; -} - -gboolean -e_storage_path_is_relative (const char *path) -{ - g_return_val_if_fail (path != NULL, FALSE); - - return *path != E_PATH_SEPARATOR; -} - - -GList * -e_storage_get_subfolder_paths (EStorage *storage, - const char *path) -{ - g_return_val_if_fail (storage != NULL, NULL); - g_return_val_if_fail (E_IS_STORAGE (storage), NULL); - g_return_val_if_fail (path != NULL, NULL); - g_return_val_if_fail (g_path_is_absolute (path), NULL); - - return (* ES_CLASS (storage)->get_subfolder_paths) (storage, path); -} - -EFolder * -e_storage_get_folder (EStorage *storage, - const char *path) -{ - g_return_val_if_fail (storage != NULL, NULL); - g_return_val_if_fail (E_IS_STORAGE (storage), NULL); - g_return_val_if_fail (path != NULL, NULL); - g_return_val_if_fail (e_storage_path_is_absolute (path), NULL); - - return (* ES_CLASS (storage)->get_folder) (storage, path); -} - -const char * -e_storage_get_name (EStorage *storage) -{ - g_return_val_if_fail (storage != NULL, NULL); - g_return_val_if_fail (E_IS_STORAGE (storage), NULL); - - return (* ES_CLASS (storage)->get_name) (storage); -} - - -/* Folder operations. */ - -void -e_storage_async_create_folder (EStorage *storage, - const char *path, - const char *type, - const char *description, - EStorageResultCallback callback, - void *data) -{ - g_return_if_fail (storage != NULL); - g_return_if_fail (E_IS_STORAGE (storage)); - g_return_if_fail (path != NULL); - g_return_if_fail (g_path_is_absolute (path)); - g_return_if_fail (type != NULL); - g_return_if_fail (callback != NULL); - - (* ES_CLASS (storage)->async_create_folder) (storage, path, type, description, callback, data); -} - -void -e_storage_async_remove_folder (EStorage *storage, - const char *path, - EStorageResultCallback callback, - void *data) -{ - g_return_if_fail (storage != NULL); - g_return_if_fail (E_IS_STORAGE (storage)); - g_return_if_fail (path != NULL); - g_return_if_fail (g_path_is_absolute (path)); - g_return_if_fail (callback != NULL); - - (* ES_CLASS (storage)->async_remove_folder) (storage, path, callback, data); -} - -void -e_storage_async_xfer_folder (EStorage *storage, - const char *source_path, - const char *destination_path, - const gboolean remove_source, - EStorageResultCallback callback, - void *data) -{ - g_return_if_fail (storage != NULL); - g_return_if_fail (E_IS_STORAGE (storage)); - g_return_if_fail (source_path != NULL); - g_return_if_fail (g_path_is_absolute (source_path)); - g_return_if_fail (destination_path != NULL); - g_return_if_fail (g_path_is_absolute (destination_path)); - - if (strcmp (source_path, destination_path) == 0) { - (* callback) (storage, E_STORAGE_OK, data); - return; - } - - if (remove_source) { - int destination_len; - int source_len; - - source_len = strlen (source_path); - destination_len = strlen (destination_path); - - if (source_len < destination_len - && destination_path[source_len] == E_PATH_SEPARATOR - && strncmp (destination_path, source_path, source_len) == 0) { - (* callback) (storage, E_STORAGE_CANTMOVETODESCENDANT, data); - return; - } - } - - (* ES_CLASS (storage)->async_xfer_folder) (storage, source_path, destination_path, remove_source, callback, data); -} - -void -e_storage_async_open_folder (EStorage *storage, - const char *path, - EStorageDiscoveryCallback callback, - void *data) -{ - EStoragePrivate *priv; - EFolder *folder; - - g_return_if_fail (storage != NULL); - g_return_if_fail (E_IS_STORAGE (storage)); - g_return_if_fail (path != NULL); - g_return_if_fail (g_path_is_absolute (path)); - - priv = storage->priv; - - folder = e_folder_tree_get_folder (priv->folder_tree, path); - if (folder == NULL) { - (* callback) (storage, E_STORAGE_NOTFOUND, path, data); - return; - } - - if (! e_folder_get_has_subfolders (folder)) { - (* callback) (storage, E_STORAGE_OK, path, data); - return; - } - - g_signal_emit (storage, signals[ASYNC_OPEN_FOLDER], 0, - path, callback, data); -} - - -/* Shared folders. */ - -gboolean -e_storage_supports_shared_folders (EStorage *storage) -{ - g_return_val_if_fail (storage != NULL, FALSE); - g_return_val_if_fail (E_IS_STORAGE (storage), FALSE); - - return (* ES_CLASS (storage)->supports_shared_folders) (storage); -} - -void -e_storage_async_discover_shared_folder (EStorage *storage, - const char *owner, - const char *folder_name, - EStorageDiscoveryCallback callback, - void *data) -{ - g_return_if_fail (storage != NULL); - g_return_if_fail (E_IS_STORAGE (storage)); - g_return_if_fail (owner != NULL); - g_return_if_fail (folder_name != NULL); - - (* ES_CLASS (storage)->async_discover_shared_folder) (storage, owner, folder_name, callback, data); -} - -void -e_storage_cancel_discover_shared_folder (EStorage *storage, - const char *owner, - const char *folder_name) -{ - g_return_if_fail (E_IS_STORAGE (storage)); - g_return_if_fail (owner != NULL); - g_return_if_fail (folder_name != NULL); - g_return_if_fail (ES_CLASS (storage)->cancel_discover_shared_folder != NULL); - - (* ES_CLASS (storage)->cancel_discover_shared_folder) (storage, owner, folder_name); -} - -void -e_storage_async_remove_shared_folder (EStorage *storage, - const char *path, - EStorageResultCallback callback, - void *data) -{ - g_return_if_fail (storage != NULL); - g_return_if_fail (E_IS_STORAGE (storage)); - g_return_if_fail (path != NULL); - g_return_if_fail (g_path_is_absolute (path)); - - (* ES_CLASS (storage)->async_remove_shared_folder) (storage, path, callback, data); -} - - -const char * -e_storage_result_to_string (EStorageResult result) -{ - switch (result) { - case E_STORAGE_OK: - return _("No error"); - case E_STORAGE_GENERICERROR: - return _("Generic error"); - case E_STORAGE_EXISTS: - return _("A folder with the same name already exists"); - case E_STORAGE_INVALIDTYPE: - return _("The specified folder type is not valid"); - case E_STORAGE_IOERROR: - return _("I/O error"); - case E_STORAGE_NOSPACE: - return _("Not enough space to create the folder"); - case E_STORAGE_NOTEMPTY: - return _("The folder is not empty"); - case E_STORAGE_NOTFOUND: - return _("The specified folder was not found"); - case E_STORAGE_NOTIMPLEMENTED: - return _("Function not implemented in this storage"); - case E_STORAGE_PERMISSIONDENIED: - return _("Permission denied"); - case E_STORAGE_UNSUPPORTEDOPERATION: - 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"); - case E_STORAGE_CANTMOVETODESCENDANT: - return _("Cannot make a folder a child of one of its descendants"); - case E_STORAGE_INVALIDNAME: - return _("Cannot create a folder with that name"); - case E_STORAGE_NOTONLINE: - return _("This operation cannot be performed in off-line mode"); - default: - return _("Unknown error"); - } -} - - -/* Public utility functions. */ - -struct _GetPathForPhysicalUriForeachData { - const char *physical_uri; - char *retval; -}; -typedef struct _GetPathForPhysicalUriForeachData GetPathForPhysicalUriForeachData; - -static void -get_path_for_physical_uri_foreach (EFolderTree *folder_tree, - const char *path, - void *path_data, - void *user_data) -{ - GetPathForPhysicalUriForeachData *foreach_data; - const char *physical_uri; - EFolder *e_folder; - - foreach_data = (GetPathForPhysicalUriForeachData *) user_data; - if (foreach_data->retval != NULL) - return; - - e_folder = (EFolder *) path_data; - if (e_folder == NULL) - return; - - physical_uri = e_folder_get_physical_uri (e_folder); - if (physical_uri == NULL) - return; - - if (strcmp (foreach_data->physical_uri, physical_uri) == 0) - foreach_data->retval = g_strdup (path); -} - -/** - * e_storage_get_path_for_physical_uri: - * @storage: A storage - * @physical_uri: A physical URI - * - * Look for the folder having the specified @physical_uri. - * - * Return value: The path of the folder having the specified @physical_uri in - * @storage. If such a folder does not exist, just return NULL. The return - * value must be freed by the caller. - **/ -char * -e_storage_get_path_for_physical_uri (EStorage *storage, - const char *physical_uri) -{ - GetPathForPhysicalUriForeachData foreach_data; - EStoragePrivate *priv; - - g_return_val_if_fail (storage != NULL, NULL); - g_return_val_if_fail (E_IS_STORAGE (storage), NULL); - g_return_val_if_fail (physical_uri != NULL, NULL); - - priv = storage->priv; - - foreach_data.physical_uri = physical_uri; - foreach_data.retval = NULL; - - e_folder_tree_foreach (priv->folder_tree, get_path_for_physical_uri_foreach, &foreach_data); - - return foreach_data.retval; -} - - -/* Protected functions. */ - -/* These functions are used by subclasses to add and remove folders from the - state stored in the storage object. */ - -static void -remove_subfolders_except (EStorage *storage, const char *path, const char *except) -{ - EStoragePrivate *priv; - GList *subfolders, *f; - const char *folder_path; - - priv = storage->priv; - - subfolders = e_folder_tree_get_subfolders (priv->folder_tree, path); - for (f = subfolders; f; f = f->next) { - folder_path = f->data; - if (!except || strcmp (folder_path, except) != 0) - e_storage_removed_folder (storage, folder_path); - } - e_free_string_list (subfolders); -} - -gboolean -e_storage_new_folder (EStorage *storage, - const char *path, - EFolder *e_folder) -{ - EStoragePrivate *priv; - char *parent_path, *p; - EFolder *parent; - - g_return_val_if_fail (storage != NULL, FALSE); - g_return_val_if_fail (E_IS_STORAGE (storage), FALSE); - g_return_val_if_fail (path != NULL, FALSE); - g_return_val_if_fail (g_path_is_absolute (path), FALSE); - g_return_val_if_fail (e_folder != NULL, FALSE); - g_return_val_if_fail (E_IS_FOLDER (e_folder), FALSE); - - priv = storage->priv; - - if (! e_folder_tree_add (priv->folder_tree, path, e_folder)) - return FALSE; - - /* If this is the child of a folder that has a pseudo child, - * remove the pseudo child now. - */ - p = strrchr (path, '/'); - if (p && p != path) - parent_path = g_strndup (path, p - path); - else - parent_path = g_strdup ("/"); - parent = e_folder_tree_get_folder (priv->folder_tree, parent_path); - if (parent && e_folder_get_has_subfolders (parent)) { - remove_subfolders_except (storage, parent_path, path); - e_folder_set_has_subfolders (parent, FALSE); - } - g_free (parent_path); - - g_signal_connect_object (e_folder, "changed", G_CALLBACK (folder_changed_cb), storage, 0); - - g_signal_emit (storage, signals[NEW_FOLDER], 0, path); - - folder_changed_cb (e_folder, storage); - - return TRUE; -} - -/* This really should be called e_storage_set_has_subfolders, but then - * it would look like it was an EStorageSet function. (Fact o' the - * day: The word "set" has more distinct meanings than any other word - * in the English language.) Anyway, we now return you to your - * regularly scheduled source code, already in progress. - */ -gboolean -e_storage_declare_has_subfolders (EStorage *storage, - const char *path, - const char *message) -{ - EStoragePrivate *priv; - EFolder *parent, *pseudofolder; - char *pseudofolder_path; - gboolean ok; - - g_return_val_if_fail (storage != NULL, FALSE); - g_return_val_if_fail (E_IS_STORAGE (storage), FALSE); - g_return_val_if_fail (path != NULL, FALSE); - g_return_val_if_fail (g_path_is_absolute (path), FALSE); - g_return_val_if_fail (message != NULL, FALSE); - - priv = storage->priv; - - parent = e_folder_tree_get_folder (priv->folder_tree, path); - if (parent == NULL) - return FALSE; - if (e_folder_get_has_subfolders (parent)) - return TRUE; - - remove_subfolders_except (storage, path, NULL); - - pseudofolder = e_folder_new (message, "working", ""); - if (strcmp (path, "/") == 0) - pseudofolder_path = g_strdup_printf ("/%s", message); - else - pseudofolder_path = g_strdup_printf ("%s/%s", path, message); - e_folder_set_physical_uri (pseudofolder, pseudofolder_path); - - ok = e_storage_new_folder (storage, pseudofolder_path, pseudofolder); - g_free (pseudofolder_path); - if (!ok) { - g_object_unref (pseudofolder); - return FALSE; - } - - e_folder_set_has_subfolders (parent, TRUE); - return TRUE; -} - -gboolean -e_storage_get_has_subfolders (EStorage *storage, - const char *path) -{ - EStoragePrivate *priv; - EFolder *folder; - - g_return_val_if_fail (storage != NULL, FALSE); - g_return_val_if_fail (E_IS_STORAGE (storage), FALSE); - g_return_val_if_fail (path != NULL, FALSE); - g_return_val_if_fail (g_path_is_absolute (path), FALSE); - - priv = storage->priv; - - folder = e_folder_tree_get_folder (priv->folder_tree, path); - - return folder && e_folder_get_has_subfolders (folder); -} - -gboolean -e_storage_removed_folder (EStorage *storage, - const char *path) -{ - EStoragePrivate *priv; - EFolder *folder; - const char *p; - - g_return_val_if_fail (storage != NULL, FALSE); - g_return_val_if_fail (E_IS_STORAGE (storage), FALSE); - g_return_val_if_fail (path != NULL, FALSE); - g_return_val_if_fail (g_path_is_absolute (path), FALSE); - - priv = storage->priv; - - folder = e_folder_tree_get_folder (priv->folder_tree, path); - if (folder == NULL) - return FALSE; - - p = strrchr (path, '/'); - if (p != NULL && p != path) { - EFolder *parent_folder; - char *parent_path; - - parent_path = g_strndup (path, p - path); - parent_folder = e_folder_tree_get_folder (priv->folder_tree, parent_path); - - if (e_folder_get_highlighted (folder)) - e_folder_set_child_highlight (parent_folder, FALSE); - - g_free (parent_path); - } - - g_signal_emit (storage, signals[REMOVED_FOLDER], 0, path); - - e_folder_tree_remove (priv->folder_tree, path); - - return TRUE; -} - - -E_MAKE_TYPE (e_storage, "EStorage", EStorage, class_init, init, PARENT_TYPE) diff --git a/shell/e-storage.h b/shell/e-storage.h deleted file mode 100644 index 1015290b6a..0000000000 --- a/shell/e-storage.h +++ /dev/null @@ -1,215 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-storage.h - * - * Copyright (C) 2000 Ximian, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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 _E_STORAGE_H_ -#define _E_STORAGE_H_ - -#include <gtk/gtkobject.h> - -#include "evolution-shell-component-client.h" - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - -#define E_TYPE_STORAGE (e_storage_get_type ()) -#define E_STORAGE(obj) (GTK_CHECK_CAST ((obj), E_TYPE_STORAGE, EStorage)) -#define E_STORAGE_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_TYPE_STORAGE, EStorageClass)) -#define E_IS_STORAGE(obj) (GTK_CHECK_TYPE ((obj), E_TYPE_STORAGE)) -#define E_IS_STORAGE_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), E_TYPE_STORAGE)) - - -typedef struct _EStorage EStorage; -typedef struct _EStoragePrivate EStoragePrivate; -typedef struct _EStorageClass EStorageClass; - -enum _EStorageResult { - E_STORAGE_OK, - E_STORAGE_GENERICERROR, - E_STORAGE_EXISTS, - E_STORAGE_INVALIDTYPE, - E_STORAGE_IOERROR, - E_STORAGE_NOSPACE, - E_STORAGE_NOTEMPTY, - E_STORAGE_NOTFOUND, - E_STORAGE_NOTIMPLEMENTED, - E_STORAGE_PERMISSIONDENIED, - E_STORAGE_UNSUPPORTEDOPERATION, - E_STORAGE_UNSUPPORTEDTYPE, - E_STORAGE_CANTCHANGESTOCKFOLDER, - E_STORAGE_CANTMOVETODESCENDANT, - E_STORAGE_NOTONLINE, - E_STORAGE_INVALIDNAME -}; -typedef enum _EStorageResult EStorageResult; - -typedef void (* EStorageResultCallback) (EStorage *storage, EStorageResult result, void *data); -typedef void (* EStorageDiscoveryCallback) (EStorage *storage, EStorageResult result, const char *path, void *data); - -#include "e-folder.h" - -struct _EStorage { - GtkObject parent; - - EStoragePrivate *priv; -}; - -struct _EStorageClass { - GtkObjectClass parent_class; - - /* Signals. */ - - void (* new_folder) (EStorage *storage, const char *path); - void (* updated_folder) (EStorage *storage, const char *path); - void (* removed_folder) (EStorage *storage, const char *path); - - /* FIXME: This should NOT be a signal. */ - void (* async_open_folder) (EStorage *storage, - const char *path, - EStorageDiscoveryCallback callback, - void *data); - - /* Virtual methods. */ - - GList * (* get_subfolder_paths) (EStorage *storage, - const char *path); - EFolder * (* get_folder) (EStorage *storage, - const char *path); - const char * (* get_name) (EStorage *storage); - - void (* async_create_folder) (EStorage *storage, - const char *path, - const char *type, - const char *description, - EStorageResultCallback callback, - void *data); - - void (* async_remove_folder) (EStorage *storage, - const char *path, - EStorageResultCallback callback, - void *data); - - void (* async_xfer_folder) (EStorage *storage, - const char *source_path, - const char *destination_path, - const gboolean remove_source, - EStorageResultCallback callback, - void *data); - - gboolean (* supports_shared_folders) (EStorage *storage); - void (* async_discover_shared_folder) (EStorage *storage, - const char *owner, - const char *folder_name, - EStorageDiscoveryCallback callback, - void *data); - void (* cancel_discover_shared_folder) (EStorage *storage, - const char *owner, - const char *folder_name); - void (* async_remove_shared_folder) (EStorage *storage, - const char *path, - EStorageResultCallback callback, - void *data); -}; - - -GtkType e_storage_get_type (void); -void e_storage_construct (EStorage *storage, - const char *name, - EFolder *root_folder); -EStorage *e_storage_new (const char *name, - EFolder *root_folder); - -gboolean e_storage_path_is_relative (const char *path); -gboolean e_storage_path_is_absolute (const char *path); - -GList *e_storage_get_subfolder_paths (EStorage *storage, - const char *path); -EFolder *e_storage_get_folder (EStorage *storage, - const char *path); - -const char *e_storage_get_name (EStorage *storage); - -/* Folder operations. */ - -void e_storage_async_create_folder (EStorage *storage, - const char *path, - const char *type, - const char *description, - EStorageResultCallback callback, - void *data); -void e_storage_async_remove_folder (EStorage *storage, - const char *path, - EStorageResultCallback callback, - void *data); -void e_storage_async_xfer_folder (EStorage *storage, - const char *source_path, - const char *destination_path, - const gboolean remove_source, - EStorageResultCallback callback, - void *data); -void e_storage_async_open_folder (EStorage *storage, - const char *path, - EStorageDiscoveryCallback callback, - void *data); - -const char *e_storage_result_to_string (EStorageResult result); - -/* Shared folders. */ -gboolean e_storage_supports_shared_folders (EStorage *storage); -void e_storage_async_discover_shared_folder (EStorage *storage, - const char *owner, - const char *folder_name, - EStorageDiscoveryCallback callback, - void *data); -void e_storage_cancel_discover_shared_folder (EStorage *storage, - const char *owner, - const char *folder_name); -void e_storage_async_remove_shared_folder (EStorage *storage, - const char *path, - EStorageResultCallback callback, - void *data); - -/* Utility functions. */ - -char *e_storage_get_path_for_physical_uri (EStorage *storage, - const char *physical_uri); - -/* FIXME: Need to rename these. */ - -gboolean e_storage_new_folder (EStorage *storage, - const char *path, - EFolder *folder); -gboolean e_storage_removed_folder (EStorage *storage, - const char *path); - -gboolean e_storage_declare_has_subfolders (EStorage *storage, - const char *path, - const char *message); -gboolean e_storage_get_has_subfolders (EStorage *storage, - const char *path); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _E_STORAGE_H_ */ diff --git a/shell/e-user-creatable-items-handler.c b/shell/e-user-creatable-items-handler.c index dabbe8381a..91ab84647c 100644 --- a/shell/e-user-creatable-items-handler.c +++ b/shell/e-user-creatable-items-handler.c @@ -36,6 +36,7 @@ #include <bonobo/bonobo-ui-util.h> #include <bonobo/bonobo-exception.h> +#include <bonobo/bonobo-control.h> #include <libgnome/gnome-i18n.h> diff --git a/shell/evolution-shell-component-client.c b/shell/evolution-shell-component-client.c deleted file mode 100644 index 621741a66f..0000000000 --- a/shell/evolution-shell-component-client.c +++ /dev/null @@ -1,924 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* evolution-shell-component-client.c - * - * Copyright (C) 2000, 2001 Ximian, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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 <string.h> -#include <glib.h> -#include <gtk/gtksignal.h> -#include <gtk/gtktypeutils.h> - -#include <bonobo-activation/bonobo-activation.h> - -#include <bonobo/bonobo-exception.h> -#include <bonobo/bonobo-main.h> -#include <bonobo/bonobo-widget.h> - -#include <gal/util/e-util.h> - -#include "evolution-shell-component-client.h" - - -char *evolution_debug_log; - -#define PARENT_TYPE G_TYPE_OBJECT -static GObjectClass *parent_class = NULL; - -struct _EvolutionShellComponentClientPrivate { - GNOME_Evolution_ShellComponent corba_objref; - - char *id; - - EvolutionShellComponentClientCallback callback; - void *callback_data; - - GNOME_Evolution_ShellComponentListener listener_interface; - PortableServer_Servant listener_servant; - - GNOME_Evolution_ShellComponentDnd_SourceFolder dnd_source_folder_interface; - GNOME_Evolution_ShellComponentDnd_DestinationFolder dnd_destination_folder_interface; - GNOME_Evolution_Offline offline_interface; -}; - - -#define RETURN_ERROR_IF_FAIL(cond) \ - g_return_val_if_fail ((cond), EVOLUTION_SHELL_COMPONENT_INVALIDARG) - - -/* Utility functions. */ - -static EvolutionShellComponentResult -corba_exception_to_result (const CORBA_Environment *ev) -{ - if (ev->_major == CORBA_NO_EXCEPTION) - return EVOLUTION_SHELL_COMPONENT_OK; - - if (ev->_major == CORBA_USER_EXCEPTION) { - if (strcmp (BONOBO_EX_REPOID (ev), ex_GNOME_Evolution_ShellComponent_AlreadyOwned) == 0) - return EVOLUTION_SHELL_COMPONENT_ALREADYOWNED; - if (strcmp (BONOBO_EX_REPOID (ev), ex_GNOME_Evolution_ShellComponent_OldOwnerHasDied) == 0) - return EVOLUTION_SHELL_COMPONENT_OLDOWNERHASDIED; - if (strcmp (BONOBO_EX_REPOID (ev), ex_GNOME_Evolution_ShellComponent_NotOwned) == 0) - return EVOLUTION_SHELL_COMPONENT_NOTOWNED; - if (strcmp (BONOBO_EX_REPOID (ev), ex_GNOME_Evolution_ShellComponent_NotFound) == 0) - return EVOLUTION_SHELL_COMPONENT_NOTFOUND; - if (strcmp (BONOBO_EX_REPOID (ev), ex_GNOME_Evolution_ShellComponent_UnsupportedType) == 0) - return EVOLUTION_SHELL_COMPONENT_UNSUPPORTEDTYPE; - if (strcmp (BONOBO_EX_REPOID (ev), ex_GNOME_Evolution_ShellComponent_InternalError) == 0) - return EVOLUTION_SHELL_COMPONENT_INTERNALERROR; - if (strcmp (BONOBO_EX_REPOID (ev), ex_GNOME_Evolution_ShellComponent_Busy) == 0) - return EVOLUTION_SHELL_COMPONENT_BUSY; - if (strcmp (BONOBO_EX_REPOID (ev), ex_GNOME_Evolution_ShellComponent_UnsupportedSchema) == 0) - return EVOLUTION_SHELL_COMPONENT_UNSUPPORTEDSCHEMA; - - return EVOLUTION_SHELL_COMPONENT_UNKNOWNERROR; - } else { - /* FIXME maybe we need something more specific here. */ - return EVOLUTION_SHELL_COMPONENT_CORBAERROR; - } -} - -static EvolutionShellComponentResult -shell_component_result_from_corba_exception (const CORBA_Environment *ev) -{ - if (ev->_major == CORBA_NO_EXCEPTION) - return EVOLUTION_SHELL_COMPONENT_OK; - if (ev->_major == CORBA_SYSTEM_EXCEPTION) - return EVOLUTION_SHELL_COMPONENT_CORBAERROR; - return EVOLUTION_SHELL_COMPONENT_CORBAERROR; /* FIXME? */ -} - - -/* CORBA listener interface implementation. */ - -static PortableServer_ServantBase__epv ShellComponentListener_base_epv; -static POA_GNOME_Evolution_ShellComponentListener__epv ShellComponentListener_epv; -static POA_GNOME_Evolution_ShellComponentListener__vepv ShellComponentListener_vepv; -static gboolean ShellComponentListener_vepv_initialized = FALSE; - -static void ShellComponentListener_vepv_initialize (void); -static void dispatch_callback (EvolutionShellComponentClient *shell_component_client, - EvolutionShellComponentResult result); - -struct _ShellComponentListenerServant { - POA_GNOME_Evolution_ShellComponentListener servant; - EvolutionShellComponentClient *component_client; -}; -typedef struct _ShellComponentListenerServant ShellComponentListenerServant; - -static PortableServer_Servant * -create_ShellComponentListener_servant (EvolutionShellComponentClient *component_client) -{ - ShellComponentListenerServant *servant; - - if (! ShellComponentListener_vepv_initialized) - ShellComponentListener_vepv_initialize (); - - servant = g_new0 (ShellComponentListenerServant, 1); - servant->servant.vepv = &ShellComponentListener_vepv; - servant->component_client = component_client; - - return (PortableServer_Servant) servant; -} - -static void -free_ShellComponentListener_servant (PortableServer_Servant servant) -{ - g_free (servant); -} - -static EvolutionShellComponentClient * -component_client_from_ShellComponentListener_servant (PortableServer_Servant servant) -{ - ShellComponentListenerServant *listener_servant; - - listener_servant = (ShellComponentListenerServant *) servant; - return listener_servant->component_client; -} - -static EvolutionShellComponentResult -result_from_async_corba_result (GNOME_Evolution_ShellComponentListener_Result async_corba_result) -{ - switch (async_corba_result) { - case GNOME_Evolution_ShellComponentListener_OK: - return EVOLUTION_SHELL_COMPONENT_OK; - case GNOME_Evolution_ShellComponentListener_CANCEL: - return EVOLUTION_SHELL_COMPONENT_CANCEL; - case GNOME_Evolution_ShellComponentListener_UNSUPPORTED_OPERATION: - return EVOLUTION_SHELL_COMPONENT_UNSUPPORTEDOPERATION; - case GNOME_Evolution_ShellComponentListener_EXISTS: - return EVOLUTION_SHELL_COMPONENT_EXISTS; - case GNOME_Evolution_ShellComponentListener_INVALID_URI: - return EVOLUTION_SHELL_COMPONENT_INVALIDURI; - case GNOME_Evolution_ShellComponentListener_PERMISSION_DENIED: - return EVOLUTION_SHELL_COMPONENT_PERMISSIONDENIED; - case GNOME_Evolution_ShellComponentListener_HAS_SUBFOLDERS: - return EVOLUTION_SHELL_COMPONENT_HASSUBFOLDERS; - case GNOME_Evolution_ShellComponentListener_NO_SPACE: - return EVOLUTION_SHELL_COMPONENT_NOSPACE; - default: - return EVOLUTION_SHELL_COMPONENT_UNKNOWNERROR; - } -} - -static void -impl_ShellComponentListener_report_result (PortableServer_Servant servant, - const GNOME_Evolution_ShellComponentListener_Result result, - CORBA_Environment *ev) -{ - EvolutionShellComponentClient *component_client; - - component_client = component_client_from_ShellComponentListener_servant (servant); - dispatch_callback (component_client, result_from_async_corba_result (result)); -} - -static void -ShellComponentListener_vepv_initialize (void) -{ - ShellComponentListener_base_epv._private = NULL; - ShellComponentListener_base_epv.finalize = NULL; - ShellComponentListener_base_epv.default_POA = NULL; - - ShellComponentListener_epv.notifyResult = impl_ShellComponentListener_report_result; - - ShellComponentListener_vepv._base_epv = & ShellComponentListener_base_epv; - ShellComponentListener_vepv.GNOME_Evolution_ShellComponentListener_epv = & ShellComponentListener_epv; - - ShellComponentListener_vepv_initialized = TRUE; -} - -static void -create_listener_interface (EvolutionShellComponentClient *shell_component_client) -{ - EvolutionShellComponentClientPrivate *priv; - PortableServer_Servant listener_servant; - GNOME_Evolution_ShellComponentListener corba_interface; - CORBA_Environment ev; - - priv = shell_component_client->priv; - - listener_servant = create_ShellComponentListener_servant (shell_component_client); - - CORBA_exception_init (&ev); - - POA_GNOME_Evolution_ShellComponentListener__init (listener_servant, &ev); - if (ev._major != CORBA_NO_EXCEPTION) { - free_ShellComponentListener_servant (listener_servant); - return; - } - - CORBA_free (PortableServer_POA_activate_object (bonobo_poa (), listener_servant, &ev)); - - corba_interface = PortableServer_POA_servant_to_reference (bonobo_poa (), listener_servant, &ev); - if (ev._major != CORBA_NO_EXCEPTION) { - corba_interface = CORBA_OBJECT_NIL; - free_ShellComponentListener_servant (listener_servant); - } - - CORBA_exception_free (&ev); - - priv->listener_servant = listener_servant; - priv->listener_interface = corba_interface; -} - -static void -destroy_listener_interface (EvolutionShellComponentClient *client) -{ - EvolutionShellComponentClientPrivate *priv; - CORBA_Environment ev; - PortableServer_ObjectId *oid; - - priv = client->priv; - CORBA_exception_init (&ev); - - oid = PortableServer_POA_servant_to_id (bonobo_poa (), priv->listener_servant, &ev); - PortableServer_POA_deactivate_object (bonobo_poa (), oid, &ev); - CORBA_free (oid); - - CORBA_Object_release (priv->listener_interface, &ev); - /* free_ShellComponentListener_servant (priv->listener_servant); */ - - CORBA_exception_free (&ev); -} - -static void -dispatch_callback (EvolutionShellComponentClient *shell_component_client, - EvolutionShellComponentResult result) -{ - EvolutionShellComponentClientPrivate *priv; - EvolutionShellComponentClientCallback callback; - void *callback_data; - - priv = shell_component_client->priv; - - g_return_if_fail (priv->callback != NULL); - g_return_if_fail (priv->listener_servant != NULL); - - /* Notice that we destroy the interface and reset the callback information before - dispatching the callback so that the callback can generate another request. */ - - destroy_listener_interface (shell_component_client); - - priv->listener_servant = NULL; - priv->listener_interface = CORBA_OBJECT_NIL; - - callback = priv->callback; - callback_data = priv->callback_data; - - priv->callback = NULL; - priv->callback_data = NULL; - - (* callback) (shell_component_client, result, callback_data); -} - - -/* GObject methods. */ - -static void -impl_dispose (GObject *object) -{ - EvolutionShellComponentClient *shell_component_client; - EvolutionShellComponentClientPrivate *priv; - CORBA_Environment ev; - - shell_component_client = EVOLUTION_SHELL_COMPONENT_CLIENT (object); - priv = shell_component_client->priv; - - if (priv == NULL) - return; - - g_free (priv->id); - priv->id = NULL; - - if (priv->callback != NULL) { - dispatch_callback (shell_component_client, EVOLUTION_SHELL_COMPONENT_INTERRUPTED); - priv->callback = NULL; - } - - CORBA_exception_init (&ev); - - if (priv->corba_objref != CORBA_OBJECT_NIL) { - Bonobo_Unknown_unref (priv->corba_objref, &ev); - CORBA_Object_release (priv->corba_objref, &ev); - priv->corba_objref = CORBA_OBJECT_NIL; - } - - if (priv->dnd_source_folder_interface != CORBA_OBJECT_NIL) { - Bonobo_Unknown_unref (priv->dnd_source_folder_interface, &ev); - CORBA_Object_release (priv->dnd_source_folder_interface, &ev); - priv->dnd_source_folder_interface = CORBA_OBJECT_NIL; - } - - if (priv->dnd_destination_folder_interface != CORBA_OBJECT_NIL) { - Bonobo_Unknown_unref (priv->dnd_destination_folder_interface, &ev); - CORBA_Object_release (priv->dnd_destination_folder_interface, &ev); - priv->dnd_destination_folder_interface = CORBA_OBJECT_NIL; - } - - if (priv->offline_interface != CORBA_OBJECT_NIL) { - Bonobo_Unknown_unref (priv->offline_interface, &ev); - CORBA_Object_release (priv->offline_interface, &ev); - priv->offline_interface = CORBA_OBJECT_NIL; - } - - if (priv->listener_interface != CORBA_OBJECT_NIL) { - destroy_listener_interface (shell_component_client); - priv->listener_interface = CORBA_OBJECT_NIL; - } - - CORBA_exception_free (&ev); - - (* G_OBJECT_CLASS (parent_class)->dispose) (object); -} - -static void -impl_finalize (GObject *object) -{ - EvolutionShellComponentClient *client; - - client = EVOLUTION_SHELL_COMPONENT_CLIENT (object); - - g_free (client->priv); - - (* G_OBJECT_CLASS (parent_class)->finalize) (object); -} - - -static void -class_init (EvolutionShellComponentClientClass *klass) -{ - GObjectClass *object_class; - - object_class = G_OBJECT_CLASS (klass); - parent_class = g_type_class_ref(PARENT_TYPE); - - object_class->dispose = impl_dispose; - object_class->finalize = impl_finalize; -} - -static void -init (EvolutionShellComponentClient *shell_component_client) -{ - EvolutionShellComponentClientPrivate *priv; - - priv = g_new (EvolutionShellComponentClientPrivate, 1); - - priv->corba_objref = CORBA_OBJECT_NIL; - - priv->id = NULL; - - priv->listener_interface = CORBA_OBJECT_NIL; - priv->listener_servant = NULL; - - priv->callback = NULL; - priv->callback_data = NULL; - - priv->dnd_source_folder_interface = CORBA_OBJECT_NIL; - priv->dnd_destination_folder_interface = CORBA_OBJECT_NIL; - priv->offline_interface = CORBA_OBJECT_NIL; - - shell_component_client->priv = priv; -} - - -/* Construction. */ - -void -evolution_shell_component_client_construct (EvolutionShellComponentClient *shell_component_client, - const char *id, - CORBA_Object corba_object) -{ - EvolutionShellComponentClientPrivate *priv; - - g_return_if_fail (shell_component_client != NULL); - g_return_if_fail (EVOLUTION_IS_SHELL_COMPONENT_CLIENT (shell_component_client)); - g_return_if_fail (corba_object != CORBA_OBJECT_NIL); - - priv = shell_component_client->priv; - priv->corba_objref = corba_object; - priv->id = g_strdup (id); -} - -EvolutionShellComponentClient * -evolution_shell_component_client_new (const char *id, - CORBA_Environment *ev) -{ - EvolutionShellComponentClient *new; - CORBA_Object corba_object; - CORBA_Environment *local_ev; - CORBA_Environment static_ev; - - g_return_val_if_fail (id != NULL, NULL); - - CORBA_exception_init (&static_ev); - - if (ev == NULL) - local_ev = &static_ev; - else - local_ev = ev; - - corba_object = bonobo_activation_activate_from_id ((char *) id, 0, NULL, ev); - if (ev->_major != CORBA_NO_EXCEPTION || corba_object == NULL) { - CORBA_exception_free (&static_ev); - return NULL; - } - - CORBA_exception_free (&static_ev); - - new = g_object_new (evolution_shell_component_client_get_type (), NULL); - evolution_shell_component_client_construct (new, id, corba_object); - - return new; -} - -GNOME_Evolution_ShellComponent -evolution_shell_component_client_corba_objref (EvolutionShellComponentClient *component_client) -{ - g_return_val_if_fail (EVOLUTION_IS_SHELL_COMPONENT_CLIENT (component_client), NULL); - - return component_client->priv->corba_objref; -} - - -/* Properties. */ - -const char * -evolution_shell_component_client_get_id (EvolutionShellComponentClient *shell_component_client) -{ - EvolutionShellComponentClientPrivate *priv; - - g_return_val_if_fail (shell_component_client != NULL, NULL); - g_return_val_if_fail (EVOLUTION_IS_SHELL_COMPONENT_CLIENT (shell_component_client), NULL); - - priv = shell_component_client->priv; - - return priv->id; -} - - -/* Querying DnD interfaces. */ - -GNOME_Evolution_ShellComponentDnd_SourceFolder -evolution_shell_component_client_get_dnd_source_interface (EvolutionShellComponentClient *shell_component_client) -{ - EvolutionShellComponentClientPrivate *priv; - GNOME_Evolution_ShellComponentDnd_SourceFolder interface; - CORBA_Environment ev; - - g_return_val_if_fail (shell_component_client != NULL, CORBA_OBJECT_NIL); - g_return_val_if_fail (EVOLUTION_IS_SHELL_COMPONENT_CLIENT (shell_component_client), CORBA_OBJECT_NIL); - - priv = shell_component_client->priv; - - if (priv->dnd_source_folder_interface != CORBA_OBJECT_NIL) - return priv->dnd_source_folder_interface; - - CORBA_exception_init (&ev); - - interface = Bonobo_Unknown_queryInterface (priv->corba_objref, - "IDL:GNOME/Evolution/ShellComponentDnd/SourceFolder:1.0", - &ev); - - if (ev._major != CORBA_NO_EXCEPTION) - interface = CORBA_OBJECT_NIL; - - CORBA_exception_free (&ev); - - priv->dnd_source_folder_interface = interface; - return interface; -} - -GNOME_Evolution_ShellComponentDnd_DestinationFolder -evolution_shell_component_client_get_dnd_destination_interface (EvolutionShellComponentClient *shell_component_client) -{ - EvolutionShellComponentClientPrivate *priv; - GNOME_Evolution_ShellComponentDnd_DestinationFolder interface; - CORBA_Environment ev; - - g_return_val_if_fail (shell_component_client != NULL, CORBA_OBJECT_NIL); - g_return_val_if_fail (EVOLUTION_IS_SHELL_COMPONENT_CLIENT (shell_component_client), CORBA_OBJECT_NIL); - - priv = shell_component_client->priv; - - if (priv->dnd_destination_folder_interface != CORBA_OBJECT_NIL) - return priv->dnd_destination_folder_interface; - - CORBA_exception_init (&ev); - - interface = Bonobo_Unknown_queryInterface (priv->corba_objref, - "IDL:GNOME/Evolution/ShellComponentDnd/DestinationFolder:1.0", - &ev); - - if (ev._major != CORBA_NO_EXCEPTION) - interface = CORBA_OBJECT_NIL; - - CORBA_exception_free (&ev); - - priv->dnd_destination_folder_interface = interface; - return interface; -} - - -/* Querying the offline interface. */ - -GNOME_Evolution_Offline -evolution_shell_component_client_get_offline_interface (EvolutionShellComponentClient *shell_component_client) -{ - EvolutionShellComponentClientPrivate *priv; - GNOME_Evolution_Offline interface; - CORBA_Environment ev; - - priv = shell_component_client->priv; - - if (priv->offline_interface != CORBA_OBJECT_NIL) - return priv->offline_interface; - - CORBA_exception_init (&ev); - - interface = Bonobo_Unknown_queryInterface (priv->corba_objref, "IDL:GNOME/Evolution/Offline:1.0", &ev); - - if (ev._major != CORBA_NO_EXCEPTION) - interface = CORBA_OBJECT_NIL; - - CORBA_exception_free (&ev); - - priv->offline_interface = interface; - return interface; -} - - -/* Synchronous operations. */ - -EvolutionShellComponentResult -evolution_shell_component_client_set_owner (EvolutionShellComponentClient *shell_component_client, - GNOME_Evolution_Shell shell, - const char *evolution_homedir) -{ - EvolutionShellComponentResult result; - EvolutionShellComponentClientPrivate *priv; - CORBA_Environment ev; - - RETURN_ERROR_IF_FAIL (shell_component_client != NULL); - RETURN_ERROR_IF_FAIL (EVOLUTION_IS_SHELL_COMPONENT_CLIENT (shell_component_client)); - RETURN_ERROR_IF_FAIL (shell != CORBA_OBJECT_NIL); - - priv = shell_component_client->priv; - - CORBA_exception_init (&ev); - - GNOME_Evolution_ShellComponent_setOwner (priv->corba_objref, shell, evolution_homedir, &ev); - - result = corba_exception_to_result (&ev); - - if (result == EVOLUTION_SHELL_COMPONENT_OK && evolution_debug_log) - GNOME_Evolution_ShellComponent_debug (priv->corba_objref, evolution_debug_log, &ev); - - CORBA_exception_free (&ev); - - return result; -} - -EvolutionShellComponentResult -evolution_shell_component_client_unset_owner (EvolutionShellComponentClient *shell_component_client, - GNOME_Evolution_Shell shell) -{ - EvolutionShellComponentResult result; - CORBA_Environment ev; - - RETURN_ERROR_IF_FAIL (shell_component_client != NULL); - RETURN_ERROR_IF_FAIL (EVOLUTION_IS_SHELL_COMPONENT_CLIENT (shell_component_client)); - RETURN_ERROR_IF_FAIL (shell != CORBA_OBJECT_NIL); - - CORBA_exception_init (&ev); - - GNOME_Evolution_ShellComponent_unsetOwner (shell_component_client->priv->corba_objref, &ev); - - result = corba_exception_to_result (&ev); - - CORBA_exception_free (&ev); - - return result; -} - -EvolutionShellComponentResult -evolution_shell_component_client_create_view (EvolutionShellComponentClient *shell_component_client, - BonoboUIComponent *uih, - const char *physical_uri, - const char *type_string, - const char *view_info, - BonoboControl **control_return) -{ - EvolutionShellComponentResult result; - CORBA_Environment ev; - EvolutionShellComponentClientPrivate *priv; - Bonobo_Control corba_control; - - RETURN_ERROR_IF_FAIL (shell_component_client != NULL); - RETURN_ERROR_IF_FAIL (EVOLUTION_IS_SHELL_COMPONENT_CLIENT (shell_component_client)); - RETURN_ERROR_IF_FAIL (uih != NULL); - RETURN_ERROR_IF_FAIL (BONOBO_IS_UI_COMPONENT (uih)); - RETURN_ERROR_IF_FAIL (physical_uri != NULL); - RETURN_ERROR_IF_FAIL (type_string != NULL); - RETURN_ERROR_IF_FAIL (view_info != NULL); - RETURN_ERROR_IF_FAIL (control_return != NULL); - - priv = shell_component_client->priv; - - CORBA_exception_init (&ev); - - corba_control = GNOME_Evolution_ShellComponent_createView (priv->corba_objref, physical_uri, type_string, view_info, &ev); - - result = corba_exception_to_result (&ev); - - if (result != EVOLUTION_SHELL_COMPONENT_OK) { - *control_return = NULL; - } else { - Bonobo_UIContainer corba_uih; - - corba_uih = bonobo_object_corba_objref (BONOBO_OBJECT (uih)); - *control_return = BONOBO_CONTROL (bonobo_widget_new_control_from_objref (corba_control, corba_uih)); - } - - CORBA_exception_free (&ev); - - return result; -} - -EvolutionShellComponentResult -evolution_shell_component_client_handle_external_uri (EvolutionShellComponentClient *shell_component_client, - const char *uri) -{ - EvolutionShellComponentResult result; - EvolutionShellComponentClientPrivate *priv; - CORBA_Environment ev; - - RETURN_ERROR_IF_FAIL (shell_component_client != NULL); - RETURN_ERROR_IF_FAIL (EVOLUTION_IS_SHELL_COMPONENT_CLIENT (shell_component_client)); - RETURN_ERROR_IF_FAIL (uri != NULL); - - CORBA_exception_init (&ev); - - priv = shell_component_client->priv; - - GNOME_Evolution_ShellComponent_handleExternalURI (priv->corba_objref, uri, &ev); - - result = corba_exception_to_result (&ev); - - CORBA_exception_free (&ev); - - return result; -} - - -/* Asyncronous operations. */ - -void -evolution_shell_component_client_async_create_folder (EvolutionShellComponentClient *shell_component_client, - const char *physical_uri, - const char *type, - EvolutionShellComponentClientCallback callback, - void *data) -{ - EvolutionShellComponentClientPrivate *priv; - CORBA_Environment ev; - - g_return_if_fail (shell_component_client != NULL); - g_return_if_fail (EVOLUTION_IS_SHELL_COMPONENT_CLIENT (shell_component_client)); - g_return_if_fail (physical_uri != NULL); - g_return_if_fail (type != NULL); - g_return_if_fail (callback != NULL); - - priv = shell_component_client->priv; - - if (priv->callback != NULL) { - (* callback) (shell_component_client, EVOLUTION_SHELL_COMPONENT_BUSY, data); - return; - } - - create_listener_interface (shell_component_client); - - CORBA_exception_init (&ev); - - priv->callback = callback; - priv->callback_data = data; - - GNOME_Evolution_ShellComponent_createFolderAsync (priv->corba_objref, priv->listener_interface, physical_uri, type, &ev); - - if (ev._major != CORBA_NO_EXCEPTION && priv->callback != NULL) { - (* callback) (shell_component_client, - shell_component_result_from_corba_exception (&ev), - data); - priv->callback = NULL; - priv->callback_data = NULL; - } - - CORBA_exception_free (&ev); -} - -void -evolution_shell_component_client_async_remove_folder (EvolutionShellComponentClient *shell_component_client, - const char *physical_uri, - const char *type, - EvolutionShellComponentClientCallback callback, - void *data) -{ - EvolutionShellComponentClientPrivate *priv; - CORBA_Environment ev; - - g_return_if_fail (shell_component_client != NULL); - g_return_if_fail (EVOLUTION_IS_SHELL_COMPONENT_CLIENT (shell_component_client)); - g_return_if_fail (physical_uri != NULL); - g_return_if_fail (callback != NULL); - - priv = shell_component_client->priv; - - if (priv->callback != NULL) { - (* callback) (shell_component_client, EVOLUTION_SHELL_COMPONENT_BUSY, data); - return; - } - - create_listener_interface (shell_component_client); - - CORBA_exception_init (&ev); - - priv->callback = callback; - priv->callback_data = data; - - GNOME_Evolution_ShellComponent_removeFolderAsync (priv->corba_objref, priv->listener_interface, physical_uri, type, &ev); - - if (ev._major != CORBA_NO_EXCEPTION && priv->callback != NULL) { - (* callback) (shell_component_client, - shell_component_result_from_corba_exception (&ev), - data); - priv->callback = NULL; - priv->callback_data = NULL; - } - - CORBA_exception_free (&ev); -} - -void -evolution_shell_component_client_async_xfer_folder (EvolutionShellComponentClient *shell_component_client, - const char *source_physical_uri, - const char *destination_physical_uri, - const char *type, - gboolean remove_source, - EvolutionShellComponentClientCallback callback, - void *data) -{ - EvolutionShellComponentClientPrivate *priv; - CORBA_Environment ev; - - g_return_if_fail (shell_component_client != NULL); - g_return_if_fail (EVOLUTION_IS_SHELL_COMPONENT_CLIENT (shell_component_client)); - g_return_if_fail (source_physical_uri != NULL); - g_return_if_fail (destination_physical_uri != NULL); - g_return_if_fail (data != NULL); - - priv = shell_component_client->priv; - - if (priv->callback != NULL) { - (* callback) (shell_component_client, EVOLUTION_SHELL_COMPONENT_BUSY, data); - return; - } - - create_listener_interface (shell_component_client); - - CORBA_exception_init (&ev); - - priv->callback = callback; - priv->callback_data = data; - - GNOME_Evolution_ShellComponent_xferFolderAsync (priv->corba_objref, priv->listener_interface, - source_physical_uri, destination_physical_uri, type, remove_source, - &ev); - - if (ev._major != CORBA_NO_EXCEPTION && priv->callback != NULL) { - (* callback) (shell_component_client, - shell_component_result_from_corba_exception (&ev), - data); - priv->callback = NULL; - priv->callback_data = NULL; - } - - CORBA_exception_free (&ev); -} - -void -evolution_shell_component_client_populate_folder_context_menu (EvolutionShellComponentClient *shell_component_client, - BonoboUIContainer *container, - const char *physical_uri, - const char *type) -{ - Bonobo_UIContainer corba_container; - EvolutionShellComponentClientPrivate *priv; - CORBA_Environment ev; - - g_return_if_fail (shell_component_client != NULL); - g_return_if_fail (EVOLUTION_IS_SHELL_COMPONENT_CLIENT (shell_component_client)); - g_return_if_fail (physical_uri != NULL); - g_return_if_fail (type != NULL); - - priv = shell_component_client->priv; - - CORBA_exception_init (&ev); - - corba_container = bonobo_object_corba_objref (BONOBO_OBJECT (container)); - - GNOME_Evolution_ShellComponent_populateFolderContextMenu (priv->corba_objref, corba_container, physical_uri, type, &ev); - - CORBA_exception_free (&ev); -} - -void -evolution_shell_component_client_unpopulate_folder_context_menu (EvolutionShellComponentClient *shell_component_client, - BonoboUIContainer *container, - const char *physical_uri, - const char *type) -{ - Bonobo_UIContainer corba_container; - EvolutionShellComponentClientPrivate *priv; - CORBA_Environment ev; - - g_return_if_fail (shell_component_client != NULL); - g_return_if_fail (EVOLUTION_IS_SHELL_COMPONENT_CLIENT (shell_component_client)); - g_return_if_fail (physical_uri != NULL); - g_return_if_fail (type != NULL); - - priv = shell_component_client->priv; - - CORBA_exception_init (&ev); - - corba_container = bonobo_object_corba_objref (BONOBO_OBJECT (container)); - - GNOME_Evolution_ShellComponent_unpopulateFolderContextMenu (priv->corba_objref, corba_container, physical_uri, type, &ev); - - CORBA_exception_free (&ev); -} - - -void -evolution_shell_component_client_request_quit (EvolutionShellComponentClient *shell_component_client, - EvolutionShellComponentClientCallback callback, - void *data) -{ - EvolutionShellComponentClientPrivate *priv; - GNOME_Evolution_ShellComponent corba_shell_component; - CORBA_Environment ev; - - g_return_if_fail (EVOLUTION_IS_SHELL_COMPONENT_CLIENT (shell_component_client)); - g_return_if_fail (callback != NULL); - - priv = shell_component_client->priv; - - if (priv->callback != NULL) { - (* callback) (shell_component_client, EVOLUTION_SHELL_COMPONENT_BUSY, data); - return; - } - - create_listener_interface (shell_component_client); - - CORBA_exception_init (&ev); - - corba_shell_component = evolution_shell_component_client_corba_objref (shell_component_client); - - priv->callback = callback; - priv->callback_data = data; - - GNOME_Evolution_ShellComponent_requestQuit (corba_shell_component, priv->listener_interface, &ev); - - if (ev._major != CORBA_NO_EXCEPTION && priv->callback != NULL) { - (* callback) (shell_component_client, - shell_component_result_from_corba_exception (&ev), - data); - priv->callback = NULL; - priv->callback_data = NULL; - } - - CORBA_exception_free (&ev); -} - - -E_MAKE_TYPE (evolution_shell_component_client, "EvolutionShellComponentClient", - EvolutionShellComponentClient, class_init, init, PARENT_TYPE) diff --git a/shell/evolution-shell-component-client.h b/shell/evolution-shell-component-client.h deleted file mode 100644 index e396b17082..0000000000 --- a/shell/evolution-shell-component-client.h +++ /dev/null @@ -1,142 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* evolution-shell-component-client.h - * - * Copyright (C) 2000 Ximian, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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_SHELL_COMPONENT_CLIENT_H -#define EVOLUTION_SHELL_COMPONENT_CLIENT_H - -#include <glib-object.h> - -#include <bonobo/bonobo-ui-container.h> -#include <bonobo/bonobo-ui-component.h> - -#include "evolution-shell-component.h" - -#ifdef cplusplus -extern "C" { -#pragma } -#endif /* cplusplus */ - -#define EVOLUTION_TYPE_SHELL_COMPONENT_CLIENT (evolution_shell_component_client_get_type ()) -#define EVOLUTION_SHELL_COMPONENT_CLIENT(obj) (GTK_CHECK_CAST ((obj), EVOLUTION_TYPE_SHELL_COMPONENT_CLIENT, EvolutionShellComponentClient)) -#define EVOLUTION_SHELL_COMPONENT_CLIENT_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), EVOLUTION_TYPE_SHELL_COMPONENT_CLIENT, EvolutionShellComponentClientClass)) -#define EVOLUTION_IS_SHELL_COMPONENT_CLIENT(obj) (GTK_CHECK_TYPE ((obj), EVOLUTION_TYPE_SHELL_COMPONENT_CLIENT)) -#define EVOLUTION_IS_SHELL_COMPONENT_CLIENT_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), EVOLUTION_TYPE_SHELL_COMPONENT_CLIENT)) - - -typedef struct _EvolutionShellComponentClient EvolutionShellComponentClient; -typedef struct _EvolutionShellComponentClientPrivate EvolutionShellComponentClientPrivate; -typedef struct _EvolutionShellComponentClientClass EvolutionShellComponentClientClass; - -struct _EvolutionShellComponentClient { - GObject parent; - - EvolutionShellComponentClientPrivate *priv; -}; - -struct _EvolutionShellComponentClientClass { - GObjectClass parent_class; -}; - -typedef void (* EvolutionShellComponentClientCallback) (EvolutionShellComponentClient *shell_component_client, - EvolutionShellComponentResult result, - void *data); - - -/* Construction. */ -GtkType evolution_shell_component_client_get_type (void); -void evolution_shell_component_client_construct (EvolutionShellComponentClient *shell_component_client, - const char *id, - CORBA_Object corba_object); -EvolutionShellComponentClient *evolution_shell_component_client_new (const char *id, - CORBA_Environment *optional_ev); - -GNOME_Evolution_ShellComponent evolution_shell_component_client_corba_objref (EvolutionShellComponentClient *client); - -/* Properties. */ - -const char *evolution_shell_component_client_get_id (EvolutionShellComponentClient *shell_component_client); - -/* Querying DnD interfaces. */ - -GNOME_Evolution_ShellComponentDnd_SourceFolder -evolution_shell_component_client_get_dnd_source_interface (EvolutionShellComponentClient *shell_component_client); -GNOME_Evolution_ShellComponentDnd_DestinationFolder -evolution_shell_component_client_get_dnd_destination_interface (EvolutionShellComponentClient *shell_component_client); - -/* Querying the offline interface. */ -GNOME_Evolution_Offline -evolution_shell_component_client_get_offline_interface (EvolutionShellComponentClient *shell_component_client); - -/* Synchronous operations. */ - -EvolutionShellComponentResult evolution_shell_component_client_set_owner (EvolutionShellComponentClient *shell_component_client, - GNOME_Evolution_Shell shell, - const char *evolution_homedir); -EvolutionShellComponentResult evolution_shell_component_client_unset_owner (EvolutionShellComponentClient *shell_component_client, - GNOME_Evolution_Shell shell); -EvolutionShellComponentResult evolution_shell_component_client_create_view (EvolutionShellComponentClient *shell_component_client, - BonoboUIComponent *uih, - const char *physical_uri, - const char *type_string, - const char *view_info, - BonoboControl **control_return); - -EvolutionShellComponentResult evolution_shell_component_client_handle_external_uri (EvolutionShellComponentClient *shell_component_client, - const char *uri); - -/* Asyncronous operations. */ -void evolution_shell_component_client_async_create_folder (EvolutionShellComponentClient *shell_component_client, - const char *physical_uri, - const char *type, - EvolutionShellComponentClientCallback callback, - void *data); -void evolution_shell_component_client_async_remove_folder (EvolutionShellComponentClient *shell_component_client, - const char *physical_uri, - const char *type, - EvolutionShellComponentClientCallback callback, - void *data); -void evolution_shell_component_client_async_xfer_folder (EvolutionShellComponentClient *shell_component_client, - const char *source_physical_uri, - const char *destination_physical_uri, - const char *type, - gboolean remove_source, - EvolutionShellComponentClientCallback callback, - void *data); - -void evolution_shell_component_client_populate_folder_context_menu (EvolutionShellComponentClient *shell_component_client, - BonoboUIContainer *container, - const char *physical_uri, - const char *type); -void evolution_shell_component_client_unpopulate_folder_context_menu (EvolutionShellComponentClient *shell_component_client, - BonoboUIContainer *container, - const char *physical_uri, - const char *type); - -void evolution_shell_component_client_request_quit (EvolutionShellComponentClient *shell_component_client, - EvolutionShellComponentClientCallback callback, - void *data); - -#ifdef cplusplus -} -#endif /* cplusplus */ - -#endif /* EVOLUTION_SHELL_COMPONENT_CLIENT_H */ diff --git a/shell/evolution-shell-component-dnd.c b/shell/evolution-shell-component-dnd.c deleted file mode 100644 index 61bb3565e1..0000000000 --- a/shell/evolution-shell-component-dnd.c +++ /dev/null @@ -1,294 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* evolution-shell-component-dnd.c - * - * Copyright (C) 2000, 2001 Ximian, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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: Chris Toshok - */ - -#include "Evolution.h" -#include "evolution-shell-component-dnd.h" - -#include <gal/util/e-util.h> - -#include <gtk/gtkobject.h> - -#define PARENT_TYPE (bonobo_object_get_type ()) - -static BonoboObjectClass *parent_class; - -/* Source Folder stuff */ - -struct _DndSourceFolderPrivate { - DndSourceFolderBeginDragFn begin_drag; - DndSourceFolderGetDataFn get_data; - DndSourceFolderDeleteDataFn delete_data; - DndSourceFolderEndDragFn end_drag; - gpointer user_data; -}; - -/* GObject methods */ -static void -dnd_source_finalize (GObject *object) -{ - EvolutionShellComponentDndSourceFolder *folder; - DndSourceFolderPrivate *priv; - - folder = EVOLUTION_SHELL_COMPONENT_DND_SOURCE_FOLDER (object); - priv = folder->priv; - - g_return_if_fail (priv != NULL); - - g_free (priv); - - (* G_OBJECT_CLASS (parent_class)->finalize) (object); -} - -static void -impl_GNOME_Evolution_ShellComponentDnd_SourceFolder_beginDrag (PortableServer_Servant servant, const CORBA_char * physical_uri, - const CORBA_char * folder_type, GNOME_Evolution_ShellComponentDnd_ActionSet * possible_actions, - GNOME_Evolution_ShellComponentDnd_Action * suggested_action, CORBA_Environment * ev) -{ - BonoboObject *bonobo_object; - EvolutionShellComponentDndSourceFolder *folder; - DndSourceFolderPrivate *priv; - - bonobo_object = bonobo_object_from_servant (servant); - folder = EVOLUTION_SHELL_COMPONENT_DND_SOURCE_FOLDER (bonobo_object); - priv = folder->priv; - - priv->begin_drag (folder, physical_uri, folder_type, possible_actions, suggested_action, priv->user_data); -} - -static void -impl_GNOME_Evolution_ShellComponentDnd_SourceFolder_getData (PortableServer_Servant servant, - const GNOME_Evolution_ShellComponentDnd_SourceFolder_Context * source_context, - const GNOME_Evolution_ShellComponentDnd_Action action, const CORBA_char * dnd_type, - GNOME_Evolution_ShellComponentDnd_Data ** data, CORBA_Environment * ev) -{ - BonoboObject *bonobo_object; - EvolutionShellComponentDndSourceFolder *folder; - DndSourceFolderPrivate *priv; - - bonobo_object = bonobo_object_from_servant (servant); - folder = EVOLUTION_SHELL_COMPONENT_DND_SOURCE_FOLDER (bonobo_object); - priv = folder->priv; - - priv->get_data (folder, source_context, action, dnd_type, data, ev, priv->user_data); -} - -static void -impl_GNOME_Evolution_ShellComponentDnd_SourceFolder_deleteData (PortableServer_Servant servant, - const GNOME_Evolution_ShellComponentDnd_SourceFolder_Context * source_context, - CORBA_Environment * ev) -{ - BonoboObject *bonobo_object; - EvolutionShellComponentDndSourceFolder *folder; - DndSourceFolderPrivate *priv; - - bonobo_object = bonobo_object_from_servant (servant); - folder = EVOLUTION_SHELL_COMPONENT_DND_SOURCE_FOLDER (bonobo_object); - priv = folder->priv; - - priv->delete_data (folder, source_context, priv->user_data); -} - -static void -impl_GNOME_Evolution_ShellComponentDnd_SourceFolder_endDrag (PortableServer_Servant servant, - const GNOME_Evolution_ShellComponentDnd_SourceFolder_Context * source_context, - CORBA_Environment * ev) -{ - BonoboObject *bonobo_object; - EvolutionShellComponentDndSourceFolder *folder; - DndSourceFolderPrivate *priv; - - bonobo_object = bonobo_object_from_servant (servant); - folder = EVOLUTION_SHELL_COMPONENT_DND_SOURCE_FOLDER (bonobo_object); - priv = folder->priv; - - priv->end_drag (folder, source_context, priv->user_data); -} - -static void -evolution_shell_component_dnd_source_folder_class_init (EvolutionShellComponentDndSourceFolderClass *klass) -{ - GObjectClass *object_class; - - object_class = G_OBJECT_CLASS (klass); - object_class->finalize = dnd_source_finalize; - - klass->epv.beginDrag = impl_GNOME_Evolution_ShellComponentDnd_SourceFolder_beginDrag; - klass->epv.getData = impl_GNOME_Evolution_ShellComponentDnd_SourceFolder_getData; - klass->epv.deleteData = impl_GNOME_Evolution_ShellComponentDnd_SourceFolder_deleteData; - klass->epv.endDrag = impl_GNOME_Evolution_ShellComponentDnd_SourceFolder_endDrag; - - parent_class = g_type_class_ref(PARENT_TYPE); -} - -static void -evolution_shell_component_dnd_source_folder_init (EvolutionShellComponentDndSourceFolder *folder) -{ - DndSourceFolderPrivate *priv; - - priv = g_new (DndSourceFolderPrivate, 1); - - folder->priv = priv; -} - -BONOBO_TYPE_FUNC_FULL (EvolutionShellComponentDndSourceFolder, - GNOME_Evolution_ShellComponentDnd_SourceFolder, - PARENT_TYPE, - evolution_shell_component_dnd_source_folder) - -EvolutionShellComponentDndSourceFolder* -evolution_shell_component_dnd_source_folder_new (DndSourceFolderBeginDragFn begin_drag, - DndSourceFolderGetDataFn get_data, - DndSourceFolderDeleteDataFn delete_data, - DndSourceFolderEndDragFn end_drag, - gpointer user_data) -{ - EvolutionShellComponentDndSourceFolder *dnd_source; - - g_return_val_if_fail (begin_drag != NULL, NULL); - g_return_val_if_fail (get_data != NULL, NULL); - g_return_val_if_fail (delete_data != NULL, NULL); - g_return_val_if_fail (end_drag != NULL, NULL); - - dnd_source = g_object_new (evolution_shell_component_dnd_source_folder_get_type (), NULL); - - dnd_source->priv->begin_drag = begin_drag; - dnd_source->priv->get_data = get_data; - dnd_source->priv->delete_data = delete_data; - dnd_source->priv->end_drag = end_drag; - dnd_source->priv->user_data = user_data; - - return dnd_source; -} - - - -/* Destination Folder stuff */ - -struct _DndDestinationFolderPrivate { - DndDestinationFolderHandleMotionFn handle_motion; - DndDestinationFolderHandleDropFn handle_drop; - gpointer user_data; -}; - -/* GtkObject methods */ -static void -dnd_destination_finalize (GObject *object) -{ - EvolutionShellComponentDndDestinationFolder *folder; - DndDestinationFolderPrivate *priv; - - folder = EVOLUTION_SHELL_COMPONENT_DND_DESTINATION_FOLDER (object); - priv = folder->priv; - - g_return_if_fail (priv != NULL); - - g_free (priv); - - (* G_OBJECT_CLASS (parent_class)->finalize) (object); -} - -/* CORBA interface */ -static CORBA_boolean -impl_GNOME_Evolution_ShellComponentDnd_DestinationFolder_handleMotion (PortableServer_Servant servant, - const CORBA_char* physical_uri, - const CORBA_char *folder_type, - const GNOME_Evolution_ShellComponentDnd_DestinationFolder_Context * destination_context, - GNOME_Evolution_ShellComponentDnd_Action * suggested_action, CORBA_Environment * ev) -{ - BonoboObject *bonobo_object; - EvolutionShellComponentDndDestinationFolder *folder; - DndDestinationFolderPrivate *priv; - - bonobo_object = bonobo_object_from_servant (servant); - folder = EVOLUTION_SHELL_COMPONENT_DND_DESTINATION_FOLDER (bonobo_object); - priv = folder->priv; - - return priv->handle_motion (folder, physical_uri, folder_type, destination_context, suggested_action, priv->user_data); -} - -static CORBA_boolean -impl_GNOME_Evolution_ShellComponentDnd_DestinationFolder_handleDrop (PortableServer_Servant servant, - const CORBA_char *physical_uri, - const CORBA_char *folder_type, - const GNOME_Evolution_ShellComponentDnd_DestinationFolder_Context * destination_context, - const GNOME_Evolution_ShellComponentDnd_Action action, - const GNOME_Evolution_ShellComponentDnd_Data * data, CORBA_Environment * ev) -{ - BonoboObject *bonobo_object; - EvolutionShellComponentDndDestinationFolder *folder; - DndDestinationFolderPrivate *priv; - - bonobo_object = bonobo_object_from_servant (servant); - folder = EVOLUTION_SHELL_COMPONENT_DND_DESTINATION_FOLDER (bonobo_object); - priv = folder->priv; - - return priv->handle_drop (folder, physical_uri, folder_type, destination_context, action, data, priv->user_data); -} - -static void -evolution_shell_component_dnd_destination_folder_class_init (EvolutionShellComponentDndDestinationFolderClass *klass) -{ - GObjectClass *object_class; - - object_class = G_OBJECT_CLASS (klass); - object_class->finalize = dnd_destination_finalize; - - klass->epv.handleMotion = impl_GNOME_Evolution_ShellComponentDnd_DestinationFolder_handleMotion; - klass->epv.handleDrop = impl_GNOME_Evolution_ShellComponentDnd_DestinationFolder_handleDrop; - - parent_class = g_type_class_ref(PARENT_TYPE); -} - -static void -evolution_shell_component_dnd_destination_folder_init (EvolutionShellComponentDndDestinationFolder *folder) -{ - DndDestinationFolderPrivate *priv; - - priv = g_new (DndDestinationFolderPrivate, 1); - - folder->priv = priv; -} - -BONOBO_TYPE_FUNC_FULL (EvolutionShellComponentDndDestinationFolder, - GNOME_Evolution_ShellComponentDnd_DestinationFolder, - PARENT_TYPE, - evolution_shell_component_dnd_destination_folder) - -EvolutionShellComponentDndDestinationFolder * -evolution_shell_component_dnd_destination_folder_new (DndDestinationFolderHandleMotionFn handle_motion, - DndDestinationFolderHandleDropFn handle_drop, - gpointer user_data) -{ - EvolutionShellComponentDndDestinationFolder *dnd_destination; - - g_return_val_if_fail (handle_motion != NULL, NULL); - g_return_val_if_fail (handle_drop != NULL, NULL); - - dnd_destination = g_object_new (evolution_shell_component_dnd_destination_folder_get_type (), NULL); - - dnd_destination->priv->handle_motion = handle_motion; - dnd_destination->priv->handle_drop = handle_drop; - dnd_destination->priv->user_data = user_data; - - return dnd_destination; -} - diff --git a/shell/evolution-shell-component-dnd.h b/shell/evolution-shell-component-dnd.h deleted file mode 100644 index 25922bca97..0000000000 --- a/shell/evolution-shell-component-dnd.h +++ /dev/null @@ -1,136 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* evolution-shell-component-dnd.h - * - * Copyright (C) 2000, 2001 Ximian, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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: Chris Toshok - */ - -#ifndef EVOLUTION_SHELL_COMPONENT_DND_H -#define EVOLUTION_SHELL_COMPONENT_DND_H - -#include <bonobo/bonobo-object.h> -#include <gtk/gtktypeutils.h> - -#include "Evolution.h" - -#ifdef cplusplus -extern "C" { -#pragma } -#endif /* cplusplus */ - -/* Source Folder stuff */ -#define EVOLUTION_SHELL_COMPONENT_DND_SOURCE_FOLDER_TYPE (evolution_shell_component_dnd_source_folder_get_type ()) -#define EVOLUTION_SHELL_COMPONENT_DND_SOURCE_FOLDER(obj) (GTK_CHECK_CAST ((obj), EVOLUTION_SHELL_COMPONENT_DND_SOURCE_FOLDER_TYPE, EvolutionShellComponentDndSourceFolder)) -#define EVOLUTION_SHELL_COMPONENT_DND_SOURCE_FOLDER_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), EVOLUTION_SHELL_COMPONENT_DND_SOURCE_FOLDER_TYPE, EvolutionShellComponentDndSourceFolderClass)) -#define IS_EVOLUTION_SHELL_COMPONENT_DND_SOURCE_FOLDER(obj) (GTK_CHECK_TYPE ((obj), EVOLUTION_SHELL_COMPONENT_DND_SOURCE_FOLDER_TYPE)) -#define IS_EVOLUTION_SHELL_COMPONENT_DND_SOURCE_FOLDER_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), EVOLUTION_SHELL_COMPONENT_DND_SOURCE_FOLDER_TYPE)) - -typedef struct _DndSourceFolderPrivate DndSourceFolderPrivate; -typedef struct _EvolutionShellComponentDndSourceFolder EvolutionShellComponentDndSourceFolder; -typedef struct _EvolutionShellComponentDndSourceFolderClass EvolutionShellComponentDndSourceFolderClass; - -typedef void (*DndSourceFolderBeginDragFn)(EvolutionShellComponentDndSourceFolder *folder, - const char *physical_uri, - const char *folder_type, - GNOME_Evolution_ShellComponentDnd_ActionSet *possible_actions_return, - GNOME_Evolution_ShellComponentDnd_Action *suggested_action_return, - gpointer closure); -typedef void (*DndSourceFolderGetDataFn)(EvolutionShellComponentDndSourceFolder *folder, - const GNOME_Evolution_ShellComponentDnd_SourceFolder_Context * source_context, - const GNOME_Evolution_ShellComponentDnd_Action action, - const char * dnd_type, - GNOME_Evolution_ShellComponentDnd_Data ** data_return, - CORBA_Environment *ev, - gpointer closure); -typedef void (*DndSourceFolderDeleteDataFn)(EvolutionShellComponentDndSourceFolder *folder, - const GNOME_Evolution_ShellComponentDnd_SourceFolder_Context *source_context, - gpointer closure); -typedef void (*DndSourceFolderEndDragFn)(EvolutionShellComponentDndSourceFolder *folder, - const GNOME_Evolution_ShellComponentDnd_SourceFolder_Context *source_context, - gpointer closure); - -struct _EvolutionShellComponentDndSourceFolder { - BonoboObject object; - DndSourceFolderPrivate *priv; -}; - -struct _EvolutionShellComponentDndSourceFolderClass { - BonoboObjectClass parent_class; - - POA_GNOME_Evolution_ShellComponentDnd_SourceFolder__epv epv; -}; - -GtkType evolution_shell_component_dnd_source_folder_get_type (void); - -EvolutionShellComponentDndSourceFolder* -evolution_shell_component_dnd_source_folder_new (DndSourceFolderBeginDragFn begin_drag, - DndSourceFolderGetDataFn get_data, - DndSourceFolderDeleteDataFn delete_data, - DndSourceFolderEndDragFn end_drag, - gpointer user_data); - - - -/* Destination Folder stuff */ -#define EVOLUTION_SHELL_COMPONENT_DND_DESTINATION_FOLDER_TYPE (evolution_shell_component_dnd_destination_folder_get_type ()) -#define EVOLUTION_SHELL_COMPONENT_DND_DESTINATION_FOLDER(obj) (GTK_CHECK_CAST ((obj), EVOLUTION_SHELL_COMPONENT_DND_DESTINATION_FOLDER_TYPE, EvolutionShellComponentDndDestinationFolder)) -#define EVOLUTION_SHELL_COMPONENT_DND_DESTINATION_FOLDER_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), EVOLUTION_SHELL_COMPONENT_DND_DESTINATION_FOLDER_TYPE, EvolutionShellComponentDndDestinationFolderClass)) -#define IS_EVOLUTION_SHELL_COMPONENT_DND_DESTINATION_FOLDER(obj) (GTK_CHECK_TYPE ((obj), EVOLUTION_SHELL_COMPONENT_DND_DESTINATION_FOLDER_TYPE)) -#define IS_EVOLUTION_SHELL_COMPONENT_DND_DESTINATION_FOLDER_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), EVOLUTION_SHELL_COMPONENT_DND_DESTINATION_FOLDER_TYPE)) - -typedef struct _DndDestinationFolderPrivate DndDestinationFolderPrivate; -typedef struct _EvolutionShellComponentDndDestinationFolder EvolutionShellComponentDndDestinationFolder; -typedef struct _EvolutionShellComponentDndDestinationFolderClass EvolutionShellComponentDndDestinationFolderClass; - -typedef CORBA_boolean (*DndDestinationFolderHandleMotionFn)(EvolutionShellComponentDndDestinationFolder *folder, - const char *physical_uri, - const char *folder_type, - const GNOME_Evolution_ShellComponentDnd_DestinationFolder_Context * destination_context, - GNOME_Evolution_ShellComponentDnd_Action * suggested_action_return, - gpointer closure); -typedef CORBA_boolean (*DndDestinationFolderHandleDropFn)(EvolutionShellComponentDndDestinationFolder *folder, - const char *physical_uri, - const char *folder_type, - const GNOME_Evolution_ShellComponentDnd_DestinationFolder_Context * destination_context, - const GNOME_Evolution_ShellComponentDnd_Action action, - const GNOME_Evolution_ShellComponentDnd_Data * data, - gpointer closure); - -struct _EvolutionShellComponentDndDestinationFolder { - BonoboObject object; - DndDestinationFolderPrivate *priv; -}; - -struct _EvolutionShellComponentDndDestinationFolderClass { - BonoboObjectClass parent_class; - - POA_GNOME_Evolution_ShellComponentDnd_DestinationFolder__epv epv; -}; - -GtkType evolution_shell_component_dnd_destination_folder_get_type (void); - -EvolutionShellComponentDndDestinationFolder* -evolution_shell_component_dnd_destination_folder_new (DndDestinationFolderHandleMotionFn handle_motion, - DndDestinationFolderHandleDropFn handle_drop, - gpointer user_data); - -#ifdef cplusplus -} -#endif /* cplusplus */ - -#endif /* EVOLUTION_SHELL_COMPONENT_DND_H */ diff --git a/shell/evolution-storage-listener.c b/shell/evolution-storage-listener.c deleted file mode 100644 index 3961014846..0000000000 --- a/shell/evolution-storage-listener.c +++ /dev/null @@ -1,386 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* evolution-storage-listener.c - * - * Copyright (C) 2000 Ximian, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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 <gtk/gtksignal.h> -#include <bonobo/bonobo-main.h> -#include <gal/util/e-util.h> - -#include "evolution-storage-listener.h" - -#include "e-shell-marshal.h" - - -#define PARENT_TYPE gtk_object_get_type () -static GtkObjectClass *parent_class = NULL; - -struct _EvolutionStorageListenerPrivate { - GNOME_Evolution_StorageListener corba_objref; - EvolutionStorageListenerServant *servant; -}; - - -enum { - DESTROYED, - NEW_FOLDER, - UPDATE_FOLDER, - REMOVED_FOLDER, - HAS_SUBFOLDERS, - LAST_SIGNAL -}; -static guint signals[LAST_SIGNAL] = { 0 }; - - -/* Evolution::StorageListener implementation. */ - -static POA_GNOME_Evolution_StorageListener__vepv my_GNOME_Evolution_StorageListener_vepv; - -static EvolutionStorageListener * -gtk_object_from_servant (PortableServer_Servant servant) -{ - EvolutionStorageListenerServant *my_servant; - - my_servant = (EvolutionStorageListenerServant *) servant; - return my_servant->gtk_object; -} - -static void -impl_GNOME_Evolution_StorageListener_notifyDestroyed (PortableServer_Servant servant, - CORBA_Environment *ev) -{ - EvolutionStorageListener *listener; - EvolutionStorageListenerPrivate *priv; - - listener = gtk_object_from_servant (servant); - priv = listener->priv; - - g_signal_emit (listener, signals[DESTROYED], 0); -} - -static void -impl_GNOME_Evolution_StorageListener_notifyFolderCreated (PortableServer_Servant servant, - const CORBA_char *path, - const GNOME_Evolution_Folder *folder, - CORBA_Environment *ev) -{ - EvolutionStorageListener *listener; - EvolutionStorageListenerPrivate *priv; - - listener = gtk_object_from_servant (servant); - priv = listener->priv; - - g_signal_emit (listener, signals[NEW_FOLDER], 0, path, folder); -} - -static void -impl_GNOME_Evolution_StorageListener_notifyFolderUpdated (PortableServer_Servant servant, - const CORBA_char *path, - CORBA_long unread_count, - CORBA_Environment *ev) -{ - EvolutionStorageListener *listener; - EvolutionStorageListenerPrivate *priv; - - listener = gtk_object_from_servant (servant); - priv = listener->priv; - - g_signal_emit (listener, signals[UPDATE_FOLDER], 0, path, unread_count); -} - -static void -impl_GNOME_Evolution_StorageListener_notifyFolderRemoved (PortableServer_Servant servant, - const CORBA_char *path, - CORBA_Environment *ev) -{ - EvolutionStorageListener *listener; - EvolutionStorageListenerPrivate *priv; - - listener = gtk_object_from_servant (servant); - priv = listener->priv; - - g_signal_emit (listener, signals[REMOVED_FOLDER], 0, path); -} - -static void -impl_GNOME_Evolution_StorageListener_notifyHasSubfolders (PortableServer_Servant servant, - const CORBA_char *path, - const CORBA_char *message, - CORBA_Environment *ev) -{ - EvolutionStorageListener *listener; - EvolutionStorageListenerPrivate *priv; - - listener = gtk_object_from_servant (servant); - priv = listener->priv; - - g_signal_emit (listener, signals[HAS_SUBFOLDERS], 0, path, message); -} - -static EvolutionStorageListenerServant * -create_servant (EvolutionStorageListener *listener) -{ - EvolutionStorageListenerServant *servant; - POA_GNOME_Evolution_StorageListener *corba_servant; - CORBA_Environment ev; - - CORBA_exception_init (&ev); - - servant = g_new0 (EvolutionStorageListenerServant, 1); - corba_servant = (POA_GNOME_Evolution_StorageListener *) servant; - - corba_servant->vepv = &my_GNOME_Evolution_StorageListener_vepv; - POA_GNOME_Evolution_StorageListener__init ((PortableServer_Servant) corba_servant, &ev); - if (ev._major != CORBA_NO_EXCEPTION) { - g_free (servant); - CORBA_exception_free (&ev); - return NULL; - } - - servant->gtk_object = listener; - - CORBA_exception_free (&ev); - - return servant; -} - -static GNOME_Evolution_StorageListener -activate_servant (EvolutionStorageListener *listener, - POA_GNOME_Evolution_StorageListener *servant) -{ - GNOME_Evolution_StorageListener corba_object; - CORBA_Environment ev; - - CORBA_exception_init (&ev); - - CORBA_free (PortableServer_POA_activate_object (bonobo_poa (), servant, &ev)); - - corba_object = PortableServer_POA_servant_to_reference (bonobo_poa(), servant, &ev); - - if (ev._major == CORBA_NO_EXCEPTION && ! CORBA_Object_is_nil (corba_object, &ev)) { - CORBA_exception_free (&ev); - return corba_object; - } - - CORBA_exception_free (&ev); - - return CORBA_OBJECT_NIL; -} - - -/* GObject methods. */ - -static void -impl_finalize (GObject *object) -{ - EvolutionStorageListener *storage_listener; - EvolutionStorageListenerPrivate *priv; - CORBA_Environment ev; - - storage_listener = EVOLUTION_STORAGE_LISTENER (object); - priv = storage_listener->priv; - - CORBA_exception_init (&ev); - - if (priv->corba_objref != CORBA_OBJECT_NIL) - CORBA_Object_release (priv->corba_objref, &ev); - - if (priv->servant != NULL) { - PortableServer_ObjectId *object_id; - - object_id = PortableServer_POA_servant_to_id (bonobo_poa(), priv->servant, &ev); - PortableServer_POA_deactivate_object (bonobo_poa (), object_id, &ev); - CORBA_free (object_id); - } - - CORBA_exception_free (&ev); - - g_free (priv); - - (* G_OBJECT_CLASS (parent_class)->finalize) (object); -} - - -static void -corba_class_init (void) -{ - POA_GNOME_Evolution_StorageListener__vepv *vepv; - POA_GNOME_Evolution_StorageListener__epv *epv; - 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; - - epv = g_new0 (POA_GNOME_Evolution_StorageListener__epv, 1); - epv->notifyDestroyed = impl_GNOME_Evolution_StorageListener_notifyDestroyed; - epv->notifyFolderCreated = impl_GNOME_Evolution_StorageListener_notifyFolderCreated; - epv->notifyFolderUpdated = impl_GNOME_Evolution_StorageListener_notifyFolderUpdated; - epv->notifyFolderRemoved = impl_GNOME_Evolution_StorageListener_notifyFolderRemoved; - epv->notifyHasSubfolders = impl_GNOME_Evolution_StorageListener_notifyHasSubfolders; - - vepv = & my_GNOME_Evolution_StorageListener_vepv; - vepv->_base_epv = base_epv; - vepv->GNOME_Evolution_StorageListener_epv = epv; -} - -static void -class_init (EvolutionStorageListenerClass *klass) -{ - GObjectClass *object_class; - - parent_class = g_type_class_ref(PARENT_TYPE); - - object_class = G_OBJECT_CLASS (klass); - object_class->finalize = impl_finalize; - - signals[DESTROYED] - = g_signal_new ("destroyed", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (EvolutionStorageListenerClass, destroyed), - NULL, NULL, - e_shell_marshal_NONE__NONE, - G_TYPE_NONE, 0); - - signals[NEW_FOLDER] - = g_signal_new ("new_folder", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (EvolutionStorageListenerClass, new_folder), - NULL, NULL, - e_shell_marshal_NONE__STRING_POINTER, - G_TYPE_NONE, 2, - G_TYPE_STRING, - G_TYPE_POINTER); - - signals[UPDATE_FOLDER] - = g_signal_new ("update_folder", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (EvolutionStorageListenerClass, update_folder), - NULL, NULL, - e_shell_marshal_NONE__STRING_INT, - G_TYPE_NONE, 2, - G_TYPE_STRING, - G_TYPE_INT); - - signals[REMOVED_FOLDER] - = g_signal_new ("removed_folder", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (EvolutionStorageListenerClass, removed_folder), - NULL, NULL, - e_shell_marshal_NONE__STRING, - G_TYPE_NONE, 1, - G_TYPE_STRING); - - signals[HAS_SUBFOLDERS] - = g_signal_new ("has_subfolders", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (EvolutionStorageListenerClass, has_subfolders), - NULL, NULL, - e_shell_marshal_NONE__STRING_STRING, - G_TYPE_NONE, 2, - G_TYPE_STRING, - G_TYPE_STRING); - - corba_class_init (); -} - -static void -init (EvolutionStorageListener *storage_listener) -{ - EvolutionStorageListenerPrivate *priv; - - priv = g_new (EvolutionStorageListenerPrivate, 1); - priv->corba_objref = CORBA_OBJECT_NIL; - - storage_listener->priv = priv; -} - - -void -evolution_storage_listener_construct (EvolutionStorageListener *listener, - GNOME_Evolution_StorageListener corba_objref) -{ - EvolutionStorageListenerPrivate *priv; - - g_return_if_fail (listener != NULL); - g_return_if_fail (corba_objref != CORBA_OBJECT_NIL); - - priv = listener->priv; - - g_return_if_fail (priv->corba_objref == CORBA_OBJECT_NIL); - - priv->corba_objref = corba_objref; - - GTK_OBJECT_UNSET_FLAGS (GTK_OBJECT (listener), GTK_FLOATING); -} - -EvolutionStorageListener * -evolution_storage_listener_new (void) -{ - EvolutionStorageListener *new; - EvolutionStorageListenerPrivate *priv; - GNOME_Evolution_StorageListener corba_objref; - - new = g_object_new (evolution_storage_listener_get_type (), NULL); - priv = new->priv; - - priv->servant = create_servant (new); - corba_objref = activate_servant (new, (POA_GNOME_Evolution_StorageListener *) priv->servant); - - evolution_storage_listener_construct (new, corba_objref); - - return new; -} - - -/** - * evolution_storage_listener_corba_objref: - * @listener: A pointer to an EvolutionStorageListener - * - * Get the CORBA object reference for the interface embedded in this GTK+ - * object wrapper. - * - * Return value: A pointer to the CORBA object reference. - **/ -GNOME_Evolution_StorageListener -evolution_storage_listener_corba_objref (EvolutionStorageListener *listener) -{ - EvolutionStorageListenerPrivate *priv; - - g_return_val_if_fail (listener != NULL, CORBA_OBJECT_NIL); - g_return_val_if_fail (EVOLUTION_IS_STORAGE_LISTENER (listener), CORBA_OBJECT_NIL); - - priv = listener->priv; - return priv->corba_objref; -} - - -E_MAKE_TYPE (evolution_storage_listener, "EvolutionStorageListener", EvolutionStorageListener, - class_init, init, PARENT_TYPE) diff --git a/shell/evolution-storage-listener.h b/shell/evolution-storage-listener.h deleted file mode 100644 index e48a3243f8..0000000000 --- a/shell/evolution-storage-listener.h +++ /dev/null @@ -1,94 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* evolution-storage-listener.h - * - * Copyright (C) 2000 Ximian, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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_STORAGE_LISTENER_H__ -#define __EVOLUTION_STORAGE_LISTENER_H__ - -#include <gtk/gtkobject.h> -#include "Evolution.h" - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - -#define EVOLUTION_TYPE_STORAGE_LISTENER (evolution_storage_listener_get_type ()) -#define EVOLUTION_STORAGE_LISTENER(obj) (GTK_CHECK_CAST ((obj), EVOLUTION_TYPE_STORAGE_LISTENER, EvolutionStorageListener)) -#define EVOLUTION_STORAGE_LISTENER_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), EVOLUTION_TYPE_STORAGE_LISTENER, EvolutionStorageListenerClass)) -#define EVOLUTION_IS_STORAGE_LISTENER(obj) (GTK_CHECK_TYPE ((obj), EVOLUTION_TYPE_STORAGE_LISTENER)) -#define EVOLUTION_IS_STORAGE_LISTENER_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), EVOLUTION_TYPE_STORAGE_LISTENER)) - - -typedef struct _EvolutionStorageListener EvolutionStorageListener; -typedef struct _EvolutionStorageListenerPrivate EvolutionStorageListenerPrivate; -typedef struct _EvolutionStorageListenerClass EvolutionStorageListenerClass; - -struct _EvolutionStorageListener { - GtkObject parent; - - EvolutionStorageListenerPrivate *priv; -}; - -struct _EvolutionStorageListenerClass { - GtkObjectClass parent_class; - - /* Signals. */ - void (* destroyed) (EvolutionStorageListener *storage_listener); - void (* new_folder) (EvolutionStorageListener *storage_listener, - const char *path, - const GNOME_Evolution_Folder *folder); - void (* update_folder) (EvolutionStorageListener *storage_listener, - const char *path, - int unread_count); - void (* removed_folder) (EvolutionStorageListener *storage_listener, - const char *path); - void (* has_subfolders) (EvolutionStorageListener *storage_listener, - const char *path, - const char *message); - - void (* shared_folder_discovery_result) (EvolutionStorageListener *storage_listener, - const char *user, - const char *folder_name, - const char *storage_path, - const char *physical_uri); -}; - - -struct _EvolutionStorageListenerServant { - POA_GNOME_Evolution_StorageListener servant_placeholder; - EvolutionStorageListener *gtk_object; -}; -typedef struct _EvolutionStorageListenerServant EvolutionStorageListenerServant; - - -GtkType evolution_storage_listener_get_type (void); -void evolution_storage_listener_construct (EvolutionStorageListener *listener, - GNOME_Evolution_StorageListener corba_objref); -EvolutionStorageListener *evolution_storage_listener_new (void); - -GNOME_Evolution_StorageListener evolution_storage_listener_corba_objref (EvolutionStorageListener *listener); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* __EVOLUTION_STORAGE_LISTENER_H__ */ diff --git a/shell/evolution-storage-set-view-listener.c b/shell/evolution-storage-set-view-listener.c deleted file mode 100644 index 3e78b97caa..0000000000 --- a/shell/evolution-storage-set-view-listener.c +++ /dev/null @@ -1,287 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* evolution-storage-set-view-listener.c - * - * Copyright (C) 2000 Ximian, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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 <gtk/gtksignal.h> -#include <bonobo/bonobo-main.h> -#include <gal/util/e-util.h> - -#include "evolution-storage-set-view-listener.h" - -#include "e-shell-marshal.h" - - -#define PARENT_TYPE gtk_object_get_type () -static GtkObjectClass *parent_class = NULL; - -struct _EvolutionStorageSetViewListenerPrivate { - GNOME_Evolution_StorageSetViewListener corba_listener; - EvolutionStorageSetViewListenerServant *servant; -}; - -enum { - FOLDER_SELECTED, - FOLDER_TOGGLED, - LAST_SIGNAL -}; -static guint signals[LAST_SIGNAL] = { 0 }; - - -/* Evolution::StorageSetViewListener implementation. */ - -static POA_GNOME_Evolution_StorageSetViewListener__vepv my_GNOME_Evolution_StorageSetViewListener_vepv; - -static EvolutionStorageSetViewListener * -gtk_object_from_servant (PortableServer_Servant servant) -{ - EvolutionStorageSetViewListenerServant *my_servant; - - my_servant = (EvolutionStorageSetViewListenerServant *) servant; - return my_servant->gtk_object; -} - -static void -impl_GNOME_Evolution_StorageSetViewListener_notifyFolderSelected (PortableServer_Servant servant, - const CORBA_char *uri, - CORBA_Environment *ev) -{ - EvolutionStorageSetViewListener *listener; - - listener = gtk_object_from_servant (servant); - - g_signal_emit (listener, signals[FOLDER_SELECTED], 0, uri); -} - -static void -impl_GNOME_Evolution_StorageSetViewListener_notifyFolderToggled (PortableServer_Servant servant, - CORBA_Environment *ev) -{ - EvolutionStorageSetViewListener *listener; - - listener = gtk_object_from_servant (servant); - - g_signal_emit (listener, signals[FOLDER_TOGGLED], 0); -} - -static EvolutionStorageSetViewListenerServant * -create_servant (EvolutionStorageSetViewListener *listener) -{ - EvolutionStorageSetViewListenerServant *servant; - POA_GNOME_Evolution_StorageSetViewListener *corba_servant; - CORBA_Environment ev; - - CORBA_exception_init (&ev); - - servant = g_new0 (EvolutionStorageSetViewListenerServant, 1); - corba_servant = (POA_GNOME_Evolution_StorageSetViewListener *) servant; - - corba_servant->vepv = &my_GNOME_Evolution_StorageSetViewListener_vepv; - POA_GNOME_Evolution_StorageSetViewListener__init ((PortableServer_Servant) corba_servant, &ev); - if (ev._major != CORBA_NO_EXCEPTION) { - g_free (servant); - CORBA_exception_free (&ev); - return NULL; - } - - servant->gtk_object = listener; - - CORBA_exception_free (&ev); - - return servant; -} - -static GNOME_Evolution_StorageSetViewListener -activate_servant (EvolutionStorageSetViewListener *listener, - POA_GNOME_Evolution_StorageSetViewListener *servant) -{ - GNOME_Evolution_StorageSetViewListener corba_object; - CORBA_Environment ev; - - CORBA_exception_init (&ev); - - CORBA_free (PortableServer_POA_activate_object (bonobo_poa (), servant, &ev)); - - corba_object = PortableServer_POA_servant_to_reference (bonobo_poa(), servant, &ev); - - if (ev._major == CORBA_NO_EXCEPTION && ! CORBA_Object_is_nil (corba_object, &ev)) { - CORBA_exception_free (&ev); - return corba_object; - } - - CORBA_exception_free (&ev); - - return CORBA_OBJECT_NIL; -} - - -/* GObject methods. */ - -static void -impl_finalize (GObject *object) -{ - EvolutionStorageSetViewListener *listener; - EvolutionStorageSetViewListenerPrivate *priv; - CORBA_Environment ev; - - listener = EVOLUTION_STORAGE_SET_VIEW_LISTENER (object); - priv = listener->priv; - - CORBA_exception_init (&ev); - - if (priv->corba_listener != CORBA_OBJECT_NIL) - CORBA_Object_release (priv->corba_listener, &ev); - - if (priv->servant != NULL) { - PortableServer_ObjectId *object_id; - - object_id = PortableServer_POA_servant_to_id (bonobo_poa(), priv->servant, &ev); - PortableServer_POA_deactivate_object (bonobo_poa (), object_id, &ev); - CORBA_free (object_id); - } - - CORBA_exception_free (&ev); - - g_free (priv); - - (* G_OBJECT_CLASS (parent_class)->finalize) (object); -} - - -static void -corba_class_init (void) -{ - POA_GNOME_Evolution_StorageSetViewListener__vepv *vepv; - POA_GNOME_Evolution_StorageSetViewListener__epv *epv; - 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; - - epv = g_new0 (POA_GNOME_Evolution_StorageSetViewListener__epv, 1); - epv->notifyFolderSelected = impl_GNOME_Evolution_StorageSetViewListener_notifyFolderSelected; - epv->notifyFolderToggled = impl_GNOME_Evolution_StorageSetViewListener_notifyFolderToggled; - - vepv = & my_GNOME_Evolution_StorageSetViewListener_vepv; - vepv->_base_epv = base_epv; - vepv->GNOME_Evolution_StorageSetViewListener_epv = epv; -} - -static void -class_init (EvolutionStorageSetViewListenerClass *klass) -{ - GObjectClass *object_class; - - object_class = G_OBJECT_CLASS (klass); - object_class->finalize = impl_finalize; - - parent_class = g_type_class_ref(gtk_object_get_type ()); - - signals[FOLDER_SELECTED] - = g_signal_new ("folder_selected", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (EvolutionStorageSetViewListenerClass, folder_selected), - NULL, NULL, - e_shell_marshal_NONE__STRING, - G_TYPE_NONE, 1, - G_TYPE_STRING); - signals[FOLDER_TOGGLED] - = g_signal_new ("folder_toggled", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (EvolutionStorageSetViewListenerClass, folder_toggled), - NULL, NULL, - e_shell_marshal_NONE__NONE, - G_TYPE_NONE, 0); - - corba_class_init (); -} - -static void -init (EvolutionStorageSetViewListener *storage_set_view_listener) -{ - EvolutionStorageSetViewListenerPrivate *priv; - - priv = g_new (EvolutionStorageSetViewListenerPrivate, 1); - priv->corba_listener = CORBA_OBJECT_NIL; - - storage_set_view_listener->priv = priv; -} - - -void -evolution_storage_set_view_listener_construct (EvolutionStorageSetViewListener *listener, - GNOME_Evolution_StorageSetViewListener corba_listener) -{ - EvolutionStorageSetViewListenerPrivate *priv; - - g_return_if_fail (listener != NULL); - g_return_if_fail (EVOLUTION_IS_STORAGE_SET_VIEW_LISTENER (listener)); - g_return_if_fail (corba_listener != CORBA_OBJECT_NIL); - - priv = listener->priv; - - g_return_if_fail (priv->corba_listener == CORBA_OBJECT_NIL); - - priv->corba_listener = corba_listener; - - GTK_OBJECT_UNSET_FLAGS (GTK_OBJECT (listener), GTK_FLOATING); -} - -EvolutionStorageSetViewListener * -evolution_storage_set_view_listener_new (void) -{ - EvolutionStorageSetViewListener *new; - EvolutionStorageSetViewListenerPrivate *priv; - GNOME_Evolution_StorageSetViewListener corba_listener; - - new = g_object_new (evolution_storage_set_view_listener_get_type (), NULL); - priv = new->priv; - - priv->servant = create_servant (new); - corba_listener = activate_servant (new, (POA_GNOME_Evolution_StorageSetViewListener *) priv->servant); - - evolution_storage_set_view_listener_construct (new, corba_listener); - - return new; -} - -GNOME_Evolution_StorageSetViewListener -evolution_storage_set_view_listener_corba_objref (EvolutionStorageSetViewListener *listener) -{ - EvolutionStorageSetViewListenerPrivate *priv; - - g_return_val_if_fail (listener != NULL, CORBA_OBJECT_NIL); - g_return_val_if_fail (EVOLUTION_IS_STORAGE_SET_VIEW_LISTENER (listener), CORBA_OBJECT_NIL); - - priv = listener->priv; - return priv->corba_listener; -} - - -E_MAKE_TYPE (evolution_storage_set_view_listener, "EvolutionStorageSetViewListener", EvolutionStorageSetViewListener, - class_init, init, PARENT_TYPE) diff --git a/shell/evolution-storage-set-view-listener.h b/shell/evolution-storage-set-view-listener.h deleted file mode 100644 index b81ab1ed30..0000000000 --- a/shell/evolution-storage-set-view-listener.h +++ /dev/null @@ -1,81 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* evolution-storage-set-view-listener.h - * - * Copyright (C) 2000 Ximian, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * 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_STORAGE_SET_VIEW_LISTENER_H_ -#define _EVOLUTION_STORAGE_SET_VIEW_LISTENER_H_ - -#include <gtk/gtkobject.h> - -#include "Evolution.h" - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - -#define EVOLUTION_TYPE_STORAGE_SET_VIEW_LISTENER (evolution_storage_set_view_listener_get_type ()) -#define EVOLUTION_STORAGE_SET_VIEW_LISTENER(obj) (GTK_CHECK_CAST ((obj), EVOLUTION_TYPE_STORAGE_SET_VIEW_LISTENER, EvolutionStorageSetViewListener)) -#define EVOLUTION_STORAGE_SET_VIEW_LISTENER_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), EVOLUTION_TYPE_STORAGE_SET_VIEW_LISTENER, EvolutionStorageSetViewListenerClass)) -#define EVOLUTION_IS_STORAGE_SET_VIEW_LISTENER(obj) (GTK_CHECK_TYPE ((obj), EVOLUTION_TYPE_STORAGE_SET_VIEW_LISTENER)) -#define EVOLUTION_IS_STORAGE_SET_VIEW_LISTENER_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), EVOLUTION_TYPE_STORAGE_SET_VIEW_LISTENER)) - - -typedef struct _EvolutionStorageSetViewListener EvolutionStorageSetViewListener; -typedef struct _EvolutionStorageSetViewListenerPrivate EvolutionStorageSetViewListenerPrivate; -typedef struct _EvolutionStorageSetViewListenerClass EvolutionStorageSetViewListenerClass; - -struct _EvolutionStorageSetViewListener { - GtkObject parent; - - EvolutionStorageSetViewListenerPrivate *priv; -}; - -struct _EvolutionStorageSetViewListenerClass { - GtkObjectClass parent_class; - - void (* folder_selected) (EvolutionStorageSetViewListener *listener, - const char *uri); - void (* folder_toggled) (EvolutionStorageSetViewListener *listener, - const char *uri, - gboolean active); -}; - - -struct _EvolutionStorageSetViewListenerServant { - POA_GNOME_Evolution_StorageSetViewListener servant_placeholder; - EvolutionStorageSetViewListener *gtk_object; -}; -typedef struct _EvolutionStorageSetViewListenerServant EvolutionStorageSetViewListenerServant; - - -GtkType evolution_storage_set_view_listener_get_type (void); -void evolution_storage_set_view_listener_construct (EvolutionStorageSetViewListener *listener, - GNOME_Evolution_StorageSetViewListener corba_objref); -EvolutionStorageSetViewListener *evolution_storage_set_view_listener_new (void); - -GNOME_Evolution_StorageSetViewListener evolution_storage_set_view_listener_corba_objref (EvolutionStorageSetViewListener *listener); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* _EVOLUTION_STORAGE_SET_VIEW_LISTENER_H_ */ diff --git a/shell/main.c b/shell/main.c index bdc6e21a86..6285e55560 100644 --- a/shell/main.c +++ b/shell/main.c @@ -91,7 +91,7 @@ static gboolean setup_only = FALSE; static gboolean killev = FALSE; static char *default_component_id = NULL; -extern char *evolution_debug_log; +static char *evolution_debug_log = NULL; static GtkWidget * |