/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ /* evolution-storage-set-view.c * * Copyright (C) 2000 Helix Code, Inc. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. * * Author: Ettore Perazzoli */ #ifdef HAVE_CONFIG_H #include #endif #include "evolution-storage-set-view.h" #include #define PARENT_TYPE bonobo_object_get_type () static BonoboObjectClass *parent_class = NULL; struct _EvolutionStorageSetViewPrivate { GtkWidget *storage_set_view_widget; GList *listeners; }; /* EStorageSet widget callbacks. */ static void storage_set_view_widget_folder_selected_cb (EStorageSetView *storage_set_view_widget, const char *uri, void *data) { EvolutionStorageSetView *storage_set_view; EvolutionStorageSetViewPrivate *priv; GList *p; storage_set_view = EVOLUTION_STORAGE_SET_VIEW (data); priv = storage_set_view->priv; for (p = priv->listeners; p != NULL; p = p->next) { CORBA_Environment ev; GNOME_Evolution_StorageSetViewListener listener; CORBA_exception_init (&ev); listener = (GNOME_Evolution_StorageSetViewListener) p->data; GNOME_Evolution_StorageSetViewListener_notifyFolderSelected (listener, uri, &ev); /* FIXME: What if we fail? */ CORBA_exception_free (&ev); } } static void storage_set_view_widget_storage_selected_cb (EStorageSetView *storage_set_view_widget, const char *name, void *data) { EvolutionStorageSetView *storage_set_view; EvolutionStorageSetViewPrivate *priv; GList *p; storage_set_view = EVOLUTION_STORAGE_SET_VIEW (data); priv = storage_set_view->priv; for (p = priv->listeners; p != NULL; p = p->next) { CORBA_Environment ev; GNOME_Evolution_StorageSetViewListener listener; CORBA_exception_init (&ev); listener = (GNOME_Evolution_StorageSetViewListener) p->data; GNOME_Evolution_StorageSetViewListener_notifyStorageSelected (listener, name, &ev); /* FIXME: What if we fail? */ CORBA_exception_free (&ev); } } /* Listener handling. */ static GList * find_listener_in_list (GNOME_Evolution_StorageSetViewListener listener, GList *list) { CORBA_Environment ev; GList *p; CORBA_exception_init (&ev); for (p = list; p != NULL; p = p->next) { GNOME_Evolution_StorageSetViewListener listener_item; listener_item = (GNOME_Evolution_StorageSetViewListener) p->data; if (CORBA_Object_is_equivalent (listener, listener_item, &ev)) break; } CORBA_exception_free (&ev); return p; } static gboolean add_listener (EvolutionStorageSetView *storage_set_view, GNOME_Evolution_StorageSetViewListener listener) { EvolutionStorageSetViewPrivate *priv; CORBA_Environment ev; const char *current_uri; GNOME_Evolution_StorageSetViewListener copy_of_listener; priv = storage_set_view->priv; if (find_listener_in_list (listener, priv->listeners) != NULL) return FALSE; CORBA_exception_init (&ev); copy_of_listener = CORBA_Object_duplicate (listener, &ev); if (ev._major != CORBA_NO_EXCEPTION) { CORBA_exception_free (&ev); return FALSE; } priv->listeners = g_list_prepend (priv->listeners, copy_of_listener); current_uri = e_storage_set_view_get_current_folder (E_STORAGE_SET_VIEW (priv->storage_set_view_widget)); if (current_uri != NULL) GNOME_Evolution_StorageSetViewListener_notifyFolderSelected (listener, current_uri, &ev); CORBA_exception_free (&ev); return TRUE; } static gboolean remove_listener (EvolutionStorageSetView *storage_set_view, GNOME_Evolution_StorageSetViewListener listener) { EvolutionStorageSetViewPrivate *priv; GList *listener_node; CORBA_Environment ev; priv = storage_set_view->priv; listener_node = find_listener_in_list (listener, priv->listeners); if (listener_node == NULL) return FALSE; CORBA_exception_init (&ev); CORBA_Object_release ((CORBA_Object) listener_node->data, &ev); CORBA_exception_free (&ev); priv->listeners = g_list_remove_link (priv->listeners, listener_node); return TRUE; } /* CORBA interface implementation. */ static POA_GNOME_Evolution_StorageSetView__vepv StorageSetView_vepv; static POA_GNOME_Evolution_StorageSetView * create_servant (void) { POA_GNOME_Evolution_StorageSetView *servant; CORBA_Environment ev; CORBA_exception_init (&ev); servant = (POA_GNOME_Evolution_StorageSetView *) g_new0 (BonoboObjectServant, 1); servant->vepv = &StorageSetView_vepv; POA_GNOME_Evolution_StorageSetView__init ((PortableServer_Servant) servant, &ev); if (ev._major != CORBA_NO_EXCEPTION) { g_free (servant); servant = NULL; } CORBA_exception_free (&ev); return servant; } static void impl_StorageSetView_add_listener (PortableServer_Servant servant, const GNOME_Evolution_StorageSetViewListener listener, CORBA_Environment *ev) { BonoboObject *bonobo_object; EvolutionStorageSetView *storage_set_view; bonobo_object = bonobo_object_from_servant (servant); storage_set_view = EVOLUTION_STORAGE_SET_VIEW (bonobo_object); if (! add_listener (storage_set_view, listener)) CORBA_exception_set (ev, CORBA_USER_EXCEPTION, ex_GNOME_Evolution_StorageSetView_AlreadyListening, NULL); } static void impl_StorageSetView_remove_listener (PortableServer_Servant servant, const GNOME_Evolution_StorageSetViewListener listener, CORBA_Environment *ev) { BonoboObject *bonobo_object; EvolutionStorageSetView *storage_set_view; bonobo_object = bonobo_object_from_servant (servant); storage_set_view = EVOLUTION_STORAGE_SET_VIEW (bonobo_object); if (! remove_listener (storage_set_view, listener)) CORBA_exception_set (ev, CORBA_USER_EXCEPTION, ex_GNOME_Evolution_StorageSetView_NotFound, NULL); } static CORBA_boolean impl_StorageSetView__get_show_folders (PortableServer_Servant servant, CORBA_Environment * ev) { BonoboObject *bonobo_object; EvolutionStorageSetView *storage_set_view; EvolutionStorageSetViewPrivate *priv; bonobo_object = bonobo_object_from_servant (servant); storage_set_view = EVOLUTION_STORAGE_SET_VIEW (bonobo_object); priv = storage_set_view->priv; return (CORBA_boolean)e_storage_set_view_get_show_folders ( E_STORAGE_SET_VIEW(priv->storage_set_view_widget)); } static void impl_StorageSetView__set_show_folders (PortableServer_Servant servant, const CORBA_boolean value, CORBA_Environment * ev) { BonoboObject *bonobo_object; EvolutionStorageSetView *storage_set_view; EvolutionStorageSetViewPrivate *priv; bonobo_object = bonobo_object_from_servant (servant); storage_set_view = EVOLUTION_STORAGE_SET_VIEW (bonobo_object); priv = storage_set_view->priv; e_storage_set_view_set_show_folders ( E_STORAGE_SET_VIEW(priv->storage_set_view_widget), (gboolean)value); } /* GtkObject methods. */ static void impl_destroy (GtkObject *object) { EvolutionStorageSetView *storage_set_view; EvolutionStorageSetViewPrivate *priv; CORBA_Environment ev; GList *p; storage_set_view = EVOLUTION_STORAGE_SET_VIEW (object); priv = storage_set_view->priv; CORBA_exception_init (&ev); for (p = priv->listeners; p != NULL; p = p->next) { GNOME_Evolution_StorageSetViewListener listener; listener = (GNOME_Evolution_StorageSetViewListener) p->data; CORBA_Object_release (listener, &ev); } CORBA_exception_free (&ev); g_free (priv); if (GTK_OBJECT_CLASS (parent_class)->destroy != NULL) (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); } static void corba_class_init (void) { POA_GNOME_Evolution_StorageSetView__vepv *vepv; POA_GNOME_Evolution_StorageSetView__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_StorageSetView__epv, 1); epv->addListener = impl_StorageSetView_add_listener; epv->removeListener = impl_StorageSetView_remove_listener; epv->_set_showFolders = impl_StorageSetView__set_show_folders; epv->_get_showFolders = impl_StorageSetView__get_show_folders; vepv = &StorageSetView_vepv; vepv->_base_epv = base_epv; vepv->Bonobo_Unknown_epv = bonobo_object_get_epv (); vepv->GNOME_Evolution_StorageSetView_epv = epv; } static void class_init (EvolutionStorageSetViewClass *klass) { GtkObjectClass *object_class; object_class = GTK_OBJECT_CLASS (klass); object_class->destroy = impl_destroy; parent_class = gtk_type_class (bonobo_object_get_type ()); corba_class_init (); } static void init (EvolutionStorageSetView *storage_set_view) { EvolutionStorageSetViewPrivate *priv; priv = g_new (EvolutionStorageSetViewPrivate, 1); priv->storage_set_view_widget = NULL; priv->listeners = NULL; storage_set_view->priv = priv; } void evolution_storage_set_view_construct (EvolutionStorageSetView *storage_set_view, GNOME_Evolution_StorageSetView corba_object, EStorageSetView *storage_set_view_widget) { EvolutionStorageSetViewPrivate *priv; g_return_if_fail (storage_set_view != NULL); g_return_if_fail (EVOLUTION_IS_STORAGE_SET_VIEW (storage_set_view)); g_return_if_fail (corba_object != CORBA_OBJECT_NIL); g_return_if_fail (storage_set_view_widget != NULL); g_return_if_fail (E_IS_STORAGE_SET_VIEW (storage_set_view_widget)); priv = storage_set_view->priv; bonobo_object_construct (BONOBO_OBJECT (storage_set_view), corba_object); g_assert (priv->storage_set_view_widget == NULL); priv->storage_set_view_widget = GTK_WIDGET (storage_set_view_widget); gtk_signal_connect (GTK_OBJECT (priv->storage_set_view_widget), "folder_selected", GTK_SIGNAL_FUNC (storage_set_view_widget_folder_selected_cb), storage_set_view); gtk_signal_connect (GTK_OBJECT (priv->storage_set_view_widget), "storage_selected", GTK_SIGNAL_FUNC (storage_set_view_widget_storage_selected_cb), storage_set_view); } EvolutionStorageSetView * evolution_storage_set_view_new (EStorageSetView *storage_set_view_widget) { POA_GNOME_Evolution_StorageSetView *servant; GNOME_Evolution_StorageSetView corba_object; EvolutionStorageSetView *new; g_return_val_if_fail (storage_set_view_widget != NULL, NULL); g_return_val_if_fail (E_IS_STORAGE_SET_VIEW (storage_set_view_widget), NULL); servant = create_servant (); if (servant == NULL) return NULL; new = gtk_type_new (evolution_storage_set_view_get_type ()); corba_object = bonobo_object_activate_servant (BONOBO_OBJECT (new), servant); evolution_storage_set_view_construct (new, corba_object, storage_set_view_widget); return new; } E_MAKE_TYPE (evolution_storage_set_view, "EvolutionStorageSetView", EvolutionStorageSetView, class_init, init, PARENT_TYPE) 31724a07b10f8aae4f4393f97b8e1f01ca'>Upgrade to 0.99g3ache2006-05-272-4/+4 * remove USE_REINPLACE from russian categoryedwin2006-05-132-2/+0 * remove USE_REINPLACE for all categories starting with Iedwin2006-05-082-2/+0 * Update to KOffice 1.5.0lofi2006-04-299-15/+30 * Update to KDE 3.5.2lofi2006-03-314-126/+26 * Bump PORTREVISION on glib12/gtk12 consumer ports to ease the upgrade path.ade2006-03-071-1/+1 * Conversion to a single libtool environment.ade2006-02-232-1/+34 * - Remove deprecated USE_REINPLACEaz2006-02-221-2/+2 * Remove myself from maintainerache2006-02-031-1/+1 * - Update to 0.76barner2006-02-022-4/+4 * Update to KDE 3.5.1.lofi2006-02-014-6/+14 * Update to 0.5anray2006-02-013-21/+20 * SHA256ifyedwin2006-01-302-2/+4 * - Use MASTER_SITE_SOURCEFORGE, project is hosted theregarga2006-01-272-5/+6 * BROKEN when WITHOUT_NLS: Incorrect pkg-plistkris2006-01-262-0/+8 * Update to 0.74anray2006-01-254-67/+5 * SHA256ifyedwin2006-01-241-1/+2 * SHA256ifyedwin2006-01-2418-0/+27 * Replace ugly "@unexec rmdir %D... 2>/dev/null || true" with @dirrmtryedwin2006-01-227-27/+27 * Replace ugly "@unexec rmdir %D... 2>/dev/null || true" with @dirrmtryedwin2006-01-222-4/+4 * Update to KDE 3.5.0lofi2006-01-094-114/+244 * Chase libversion bumb to libMagick.so.9edwin2006-01-051-0/+1 * - Fix build on FreeBSD 4.11anray2006-01-042-0/+62 * Fix CAN-2005-3352 (http://www.FreeBSD.org/ports/portaudit/9fff8dc8-7aa7-11d...lev2006-01-042-0/+36 * Fix CAN-2005-3352 (http://www.FreeBSD.org/ports/portaudit/9fff8dc8-7aa7-11d...lev2006-01-042-0/+36 * Added rux, the best cyrillic text viewer and code page converter.anray2005-12-264-0/+46 * Update to latest 1.3.34+30.22+2.8.25.lev2005-12-213-9/+10 * Update to latest 1.3.34+30.22.lev2005-12-213-6/+7 * Remove expired ports.lawrance2005-12-155-61/+0 * Bump PORTREVISION to force a regeneration of the .dat fileehaupt2005-12-051-0/+1 * - Add SHA256pav2005-11-269-0/+11 * big whitespace cleanup (see ports/65409)edwin2005-11-252-5/+5 * Fix fetch.novel2005-11-131-1/+3 * Update to KDE 3.4.3 / KOffice 1.4.2lofi2005-11-0511-16/+13 * Remove expired portskris2005-11-0512-591/+0 * Bump PORTREVISION to chase the glib20 shared library update.marcus2005-11-051-1/+1 * Unbreak port by using pkg-install and pkg-deinstall scripts.edwin2005-11-043-8/+39 * Unbreak port by fixing pkg-plist and adding pkg-install andedwin2005-11-044-13/+52 * Remove all the secondary port of editors/ooodict-allmaho2005-11-012-23/+0 * BROKEN: Incorrect pkg-plistkris2005-10-291-0/+2 * Make it respect X11BASE.novel2005-10-221-1/+1 * Upgrade to 1.15.4ache2005-10-223-16/+16 * Upgrade to 1.5.1ache2005-10-172-3/+5 * Reset bouncing maintainer address, mark as BROKEN since it no longer fetches.linimon2005-10-101-4/+5 * Remove unnecessary setting of DISTNAME.fenner2005-10-071-2/+1 * This port has been deprecated for 3 months.yar2005-10-052-27/+0 * - Change my e-mailaz2005-10-031-1/+1 * - Fix fetching problem [1]novel2005-09-261-3/+1 * unbreak OSSP mm based ports after library version bumprse2005-09-091-1/+1 * - RIP russian version of nagios. It's too old. No new one available.sem2005-08-3020-827/+0 * Fix index build by moving openoffice.org-1.1 ports.maho2005-08-291-1/+1 * Update to KDE 3.4.2 / KOffice 1.4.1lofi2005-08-018-13/+13 * This port is scheduled for deletion on 2005-09-22 if it is still brokenkris2005-07-234-0/+8 * Update to KOffice 1.4.0a.lofi2005-07-069-87/+126 * Remove openoffice.org localized ports as I announced:maho2005-06-293-44/+0 * Update to KDE 3.4.1lofi2005-06-268-48/+60 * Upgrade to 0.99f9ache2005-06-062-3/+3 * - Follow the new teTeX structuresem2005-06-065-51/+54 * - Unbreak and general updatepav2005-06-061-2/+3 * Disable building packages from this portyar2005-05-301-0/+2 * - Match the reality of bogofilter 0.94.13.yar2005-05-301-2/+6 * - Remove linux-mozillafirebird and it's language spinoffs. This port ispav2005-05-284-40/+0 * - Update CONFLICTSpav2005-05-261-1/+1 * Mark ru-bogofilter port as broken to prevent people from upgradingyar2005-05-231-0/+2 * Added slave port of lang/php_doc for the Russian languageedwin2005-05-232-0/+14 * Fix CONFLICTS (again - don't blame me!):skv2005-05-131-1/+1 * Fix CONFLICTS:skv2005-05-131-1/+1 * Add unzip , unzip with CP866 and KOI8-R support.skv2005-05-133-0/+98 * - update to 3.2.1novel2005-04-202-5/+5 * At Kris's request, back out the MACHINE_ARCH spelling correction untilobrien2005-04-122-2/+2 * Assist getting more ports working on AMD64 by obeying theobrien2005-04-112-2/+2 * Remove myself from maintainerache2005-04-081-1/+1 * Fix a typo in the kio translation, which causes all Open File / Save Filelofi2005-03-284-0/+24 * Update to KDE 3.4lofi2005-03-21