From ded7e245d8be7a676747e0881deed6113df88eba Mon Sep 17 00:00:00 2001 From: Christopher James Lahey Date: Fri, 10 May 2002 20:04:06 +0000 Subject: Added SimpleCard interface. 2002-05-10 Christopher James Lahey * gui/component/select-names/Evolution-Addressbook-SelectNames.idl: Added SimpleCard interface. * gui/component/select-names/Makefile.am: Added e-simple-card-bonobo.c and e-simple-card-bonobo.h. * gui/component/select-names/e-select-names-bonobo.c (entry_get_property_fn): Added SIMPLE_CARD_LIST arg. * gui/component/select-names/e-simple-card-bonobo.c, gui/component/select-names/e-simple-card-bonobo.h: New class to represent an ECardSimple across Bonobo. svn path=/trunk/; revision=16757 --- .../Evolution-Addressbook-SelectNames.idl | 73 +++++- addressbook/gui/component/select-names/Makefile.am | 4 +- .../component/select-names/e-select-names-bonobo.c | 36 ++- .../component/select-names/e-simple-card-bonobo.c | 269 +++++++++++++++++++++ .../component/select-names/e-simple-card-bonobo.h | 70 ++++++ 5 files changed, 440 insertions(+), 12 deletions(-) create mode 100644 addressbook/gui/component/select-names/e-simple-card-bonobo.c create mode 100644 addressbook/gui/component/select-names/e-simple-card-bonobo.h (limited to 'addressbook/gui') diff --git a/addressbook/gui/component/select-names/Evolution-Addressbook-SelectNames.idl b/addressbook/gui/component/select-names/Evolution-Addressbook-SelectNames.idl index 244799deb2..f25279bb38 100644 --- a/addressbook/gui/component/select-names/Evolution-Addressbook-SelectNames.idl +++ b/addressbook/gui/component/select-names/Evolution-Addressbook-SelectNames.idl @@ -1,4 +1,4 @@ -/* -*- Mode: IDL; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ /* * CORBA interface for the SelectNames dialog. * @@ -14,6 +14,77 @@ module GNOME { module Evolution { module Addressbook { + interface SimpleCard : Bonobo::Unknown { + struct Arbitrary { + string key; + string type; + string value; + }; + + enum Field { + FileAs, + FullName, + Email, + PhonePrimary, + PhoneAssistant, + PhoneBusiness, + PhoneCallback, + PhoneCompany, + PhoneHome, + Org, + AddressBusiness, + AddressHome, + PhoneMobile, + PhoneCar, + PhoneBusinessFax, + PhoneHomeFax, + PhoneBusiness2, + PhoneHome2, + PhoneIsdn, + PhoneOther, + PhoneOtherFax, + PhonePager, + PhoneRadio, + PhoneTelex, + PhoneTtytdd, + AddressOther, + Email2, + Email3, + Url, + OrgUnit, + Office, + Title, + Role, + Manager, + Assistant, + Nickname, + Spouse, + Note, + Caluri, + Fburl, + Anniversary, + BirthDate, + Mailer, + NameOrOrg, + Categories, + FamilyName, + GivenName, + AdditionalName, + NameSuffix, + WantsHtml, + IsList, + Last + }; + + Arbitrary getArbitrary (in string key); + void setArbitrary (in string key, in string type, in string value); + + string get (in Field field); + void set (in Field field, in string value); + }; + + typedef sequence SimpleCardList; + interface SelectNames : Bonobo::Unknown { struct Section { string id; diff --git a/addressbook/gui/component/select-names/Makefile.am b/addressbook/gui/component/select-names/Makefile.am index 0f6789dd11..347af45f74 100644 --- a/addressbook/gui/component/select-names/Makefile.am +++ b/addressbook/gui/component/select-names/Makefile.am @@ -63,7 +63,9 @@ libeselectnames_la_SOURCES = \ e-select-names-text-model.c \ e-select-names-text-model.h \ e-select-names.c \ - e-select-names.h + e-select-names.h \ + e-simple-card-bonobo.c \ + e-simple-card-bonobo.h gladedir = $(datadir)/evolution/glade glade_DATA = select-names.glade diff --git a/addressbook/gui/component/select-names/e-select-names-bonobo.c b/addressbook/gui/component/select-names/e-select-names-bonobo.c index 0a763899c6..a8d0975771 100644 --- a/addressbook/gui/component/select-names/e-select-names-bonobo.c +++ b/addressbook/gui/component/select-names/e-select-names-bonobo.c @@ -25,6 +25,7 @@ #endif #include "e-select-names-bonobo.h" +#include "e-simple-card-bonobo.h" #include #include @@ -53,7 +54,7 @@ struct _ESelectNamesBonoboPrivate { enum _EntryPropertyID { ENTRY_PROPERTY_ID_TEXT, ENTRY_PROPERTY_ID_DESTINATIONS, - ENTRY_PROPERTY_ID_FIRST_EMAIL, + ENTRY_PROPERTY_ID_SIMPLE_CARD_LIST, ENTRY_PROPERTY_ID_ALLOW_CONTACT_LISTS, ENTRY_PROPERTY_ID_ENTRY_CHANGED }; @@ -98,20 +99,35 @@ entry_get_property_fn (BonoboPropertyBag *bag, } break; - case ENTRY_PROPERTY_ID_FIRST_EMAIL: + case ENTRY_PROPERTY_ID_SIMPLE_CARD_LIST: { ESelectNamesModel *model; + int count; + int i; + GNOME_Evolution_Addressbook_SimpleCardList *card_list; model = E_SELECT_NAMES_MODEL (gtk_object_get_data (GTK_OBJECT (w), "select_names_model")); g_assert (model != NULL); - if (e_select_names_model_count (model) > 0) { - const EDestination *destination = e_select_names_model_get_destination (model, 0); - const char *text = e_destination_get_email (destination); - BONOBO_ARG_SET_STRING (arg, text); - } else { - BONOBO_ARG_SET_STRING (arg, ""); + count = e_select_names_model_count (model); + + card_list = GNOME_Evolution_Addressbook_SimpleCardList__alloc (); + card_list->_buffer = CORBA_sequence_GNOME_Evolution_Addressbook_SimpleCard_allocbuf (count); + card_list->_maximum = count; + card_list->_length = count; + + for (i = 0; i < count; i++) { + const EDestination *destination = e_select_names_model_get_destination (model, i); + const ECard *card = e_destination_get_card (destination); + ECardSimple *simple = e_card_simple_new ((ECard *) card); + ESimpleCardBonobo *simple_card = e_simple_card_bonobo_new (simple); + gtk_object_unref (GTK_OBJECT (simple)); + + card_list->_buffer[i] = bonobo_object_corba_objref (BONOBO_OBJECT (simple_card)); } + + CORBA_free (arg->_value); + BONOBO_ARG_SET_GENERAL (arg, card_list, TC_GNOME_Evolution_Addressbook_SimpleCardList, GNOME_Evolution_Addressbook_SimpleCardList *, NULL); } break; @@ -333,8 +349,8 @@ impl_SelectNames_get_entry_for_section (PortableServer_Servant servant, bonobo_property_bag_add (property_bag, "destinations", ENTRY_PROPERTY_ID_DESTINATIONS, BONOBO_ARG_STRING, NULL, NULL, BONOBO_PROPERTY_READABLE | BONOBO_PROPERTY_WRITEABLE); - bonobo_property_bag_add (property_bag, "first_email", ENTRY_PROPERTY_ID_FIRST_EMAIL, - BONOBO_ARG_STRING, NULL, NULL, + bonobo_property_bag_add (property_bag, "simple_card_list", ENTRY_PROPERTY_ID_SIMPLE_CARD_LIST, + TC_GNOME_Evolution_Addressbook_SimpleCardList, NULL, NULL, BONOBO_PROPERTY_READABLE); bonobo_property_bag_add (property_bag, "allow_contact_lists", ENTRY_PROPERTY_ID_ALLOW_CONTACT_LISTS, BONOBO_ARG_BOOLEAN, NULL, NULL, diff --git a/addressbook/gui/component/select-names/e-simple-card-bonobo.c b/addressbook/gui/component/select-names/e-simple-card-bonobo.c new file mode 100644 index 0000000000..9834eddd83 --- /dev/null +++ b/addressbook/gui/component/select-names/e-simple-card-bonobo.c @@ -0,0 +1,269 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* e-simple-card-bonobo.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. + * + * Authors: + * Ettore Perazzoli + * Chris Lahey + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include "e-simple-card-bonobo.h" + +#include + +#include "Evolution-Addressbook-SelectNames.h" + + +#define PARENT_TYPE bonobo_object_get_type () +static BonoboObjectClass *parent_class = NULL; + +struct _ESimpleCardBonoboPrivate { + ECardSimple *card_simple; +}; + + +/* CORBA interface implementation. */ + +static POA_GNOME_Evolution_Addressbook_SimpleCard__vepv SimpleCard_vepv; + +static POA_GNOME_Evolution_Addressbook_SimpleCard * +create_servant (void) +{ + POA_GNOME_Evolution_Addressbook_SimpleCard *servant; + CORBA_Environment ev; + + servant = (POA_GNOME_Evolution_Addressbook_SimpleCard *) g_new0 (BonoboObjectServant, 1); + servant->vepv = &SimpleCard_vepv; + + CORBA_exception_init (&ev); + + POA_GNOME_Evolution_Addressbook_SimpleCard__init ((PortableServer_Servant) servant, &ev); + if (ev._major != CORBA_NO_EXCEPTION) { + g_free (servant); + CORBA_exception_free (&ev); + return NULL; + } + + CORBA_exception_free (&ev); + + return servant; +} + +static GNOME_Evolution_Addressbook_SimpleCard_Arbitrary * +impl_SimpleCard_get_arbitrary (PortableServer_Servant servant, + const CORBA_char *key, + CORBA_Environment *ev) +{ + BonoboObject *bonobo_object; + ESimpleCardBonobo *simple_card; + ESimpleCardBonoboPrivate *priv; + GNOME_Evolution_Addressbook_SimpleCard_Arbitrary *ret_val = GNOME_Evolution_Addressbook_SimpleCard_Arbitrary__alloc (); + + bonobo_object = bonobo_object_from_servant (servant); + simple_card = E_SIMPLE_CARD_BONOBO (bonobo_object); + priv = simple_card->priv; + + if (priv->card_simple) { + const ECardArbitrary *arbitrary = e_card_simple_get_arbitrary (priv->card_simple, key); + ret_val->key = CORBA_string_dup (arbitrary->key); + ret_val->value = CORBA_string_dup (arbitrary->value); + ret_val->type = CORBA_string_dup (arbitrary->type); + } else { + ret_val->key = CORBA_string_dup (""); + ret_val->value = CORBA_string_dup (""); + ret_val->type = CORBA_string_dup (""); + } + + return ret_val; +} + +static void +impl_SimpleCard_set_arbitrary (PortableServer_Servant servant, + const CORBA_char *key, + const CORBA_char *type, + const CORBA_char *value, + CORBA_Environment *ev) +{ + BonoboObject *bonobo_object; + ESimpleCardBonobo *simple_card; + ESimpleCardBonoboPrivate *priv; + + bonobo_object = bonobo_object_from_servant (servant); + simple_card = E_SIMPLE_CARD_BONOBO (bonobo_object); + priv = simple_card->priv; + + if (priv->card_simple) { + e_card_simple_set_arbitrary (priv->card_simple, key, type, value); + } +} + +static CORBA_char * +impl_SimpleCard_get (PortableServer_Servant servant, + GNOME_Evolution_Addressbook_SimpleCard_Field field, + CORBA_Environment *ev) +{ + BonoboObject *bonobo_object; + ESimpleCardBonobo *simple_card; + ESimpleCardBonoboPrivate *priv; + + bonobo_object = bonobo_object_from_servant (servant); + simple_card = E_SIMPLE_CARD_BONOBO (bonobo_object); + priv = simple_card->priv; + + if (priv->card_simple) { + char *value = e_card_simple_get (priv->card_simple, + field); + char *ret_val = CORBA_string_dup (value); + g_free (value); + return ret_val; + } else { + return CORBA_string_dup (""); + } +} + +static void +impl_SimpleCard_set (PortableServer_Servant servant, + GNOME_Evolution_Addressbook_SimpleCard_Field field, + const CORBA_char *value, + CORBA_Environment *ev) +{ + BonoboObject *bonobo_object; + ESimpleCardBonobo *simple_card; + ESimpleCardBonoboPrivate *priv; + + bonobo_object = bonobo_object_from_servant (servant); + simple_card = E_SIMPLE_CARD_BONOBO (bonobo_object); + priv = simple_card->priv; + + if (priv->card_simple) { + e_card_simple_set (priv->card_simple, + field, + value); + } +} + + +/* GtkObject methods. */ + +static void +impl_destroy (GtkObject *object) +{ + ESimpleCardBonobo *simple_card; + ESimpleCardBonoboPrivate *priv; + + simple_card = E_SIMPLE_CARD_BONOBO (object); + priv = simple_card->priv; + + if (priv->card_simple) { + gtk_object_unref (GTK_OBJECT (priv->card_simple)); + } + + g_free (priv); + + simple_card->priv = NULL; +} + + +static void +corba_class_init () +{ + POA_GNOME_Evolution_Addressbook_SimpleCard__vepv *vepv; + POA_GNOME_Evolution_Addressbook_SimpleCard__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_Addressbook_SimpleCard__epv, 1); + epv->getArbitrary = impl_SimpleCard_get_arbitrary; + epv->setArbitrary = impl_SimpleCard_set_arbitrary; + epv->get = impl_SimpleCard_get; + epv->set = impl_SimpleCard_set; + + vepv = &SimpleCard_vepv; + vepv->Bonobo_Unknown_epv = bonobo_object_get_epv (); + vepv->GNOME_Evolution_Addressbook_SimpleCard_epv = epv; +} + +static void +class_init (ESimpleCardBonoboClass *klass) +{ + GtkObjectClass *object_class; + + object_class = GTK_OBJECT_CLASS (klass); + parent_class = gtk_type_class (bonobo_object_get_type ()); + + object_class->destroy = impl_destroy; + + corba_class_init (); +} + +static void +init (ESimpleCardBonobo *simple_card) +{ + ESimpleCardBonoboPrivate *priv; + + priv = g_new (ESimpleCardBonoboPrivate, 1); + + priv->card_simple = NULL; + + simple_card->priv = priv; +} + + +void +e_simple_card_bonobo_construct (ESimpleCardBonobo *simple_card, + GNOME_Evolution_Addressbook_SimpleCard corba_object, + ECardSimple *card_simple) +{ + g_return_if_fail (simple_card != NULL); + g_return_if_fail (E_IS_SIMPLE_CARD_BONOBO (simple_card)); + + bonobo_object_construct (BONOBO_OBJECT (simple_card), corba_object); + + simple_card->priv->card_simple = card_simple; + gtk_object_ref (GTK_OBJECT (card_simple)); +} + +ESimpleCardBonobo * +e_simple_card_bonobo_new (ECardSimple *card_simple) +{ + POA_GNOME_Evolution_Addressbook_SimpleCard *servant; + GNOME_Evolution_Addressbook_SimpleCard corba_object; + ESimpleCardBonobo *simple_card; + + servant = create_servant (); + if (servant == NULL) + return NULL; + + simple_card = gtk_type_new (e_simple_card_bonobo_get_type ()); + + corba_object = bonobo_object_activate_servant (BONOBO_OBJECT (simple_card), servant); + e_simple_card_bonobo_construct (simple_card, corba_object, card_simple); + + return simple_card; +} + + +E_MAKE_TYPE (e_simple_card_bonobo, "ESimpleCardBonobo", ESimpleCardBonobo, class_init, init, PARENT_TYPE) diff --git a/addressbook/gui/component/select-names/e-simple-card-bonobo.h b/addressbook/gui/component/select-names/e-simple-card-bonobo.h new file mode 100644 index 0000000000..763c54085b --- /dev/null +++ b/addressbook/gui/component/select-names/e-simple-card-bonobo.h @@ -0,0 +1,70 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* e-simple-card-bonobo.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. + * + * Authors: + * Ettore Perazzoli + * Chris Lahey + */ + +#ifndef __E_SIMPLE_CARD_BONOBO_H__ +#define __E_SIMPLE_CARD_BONOBO_H__ + +#include + +#include "Evolution-Addressbook-SelectNames.h" +#include + +#ifdef __cplusplus +extern "C" { +#pragma } +#endif /* __cplusplus */ + +#define E_TYPE_SIMPLE_CARD_BONOBO (e_simple_card_bonobo_get_type ()) +#define E_SIMPLE_CARD_BONOBO(obj) (GTK_CHECK_CAST ((obj), E_TYPE_SIMPLE_CARD_BONOBO, ESimpleCardBonobo)) +#define E_SIMPLE_CARD_BONOBO_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_TYPE_SIMPLE_CARD_BONOBO, ESimpleCardBonoboClass)) +#define E_IS_SIMPLE_CARD_BONOBO(obj) (GTK_CHECK_TYPE ((obj), E_TYPE_SIMPLE_CARD_BONOBO)) +#define E_IS_SIMPLE_CARD_BONOBO_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), E_TYPE_SIMPLE_CARD_BONOBO)) + + +typedef struct _ESimpleCardBonobo ESimpleCardBonobo; +typedef struct _ESimpleCardBonoboPrivate ESimpleCardBonoboPrivate; +typedef struct _ESimpleCardBonoboClass ESimpleCardBonoboClass; + +struct _ESimpleCardBonobo { + BonoboObject parent; + + ESimpleCardBonoboPrivate *priv; +}; + +struct _ESimpleCardBonoboClass { + BonoboObjectClass parent_class; +}; + + +GtkType e_simple_card_bonobo_get_type (void); +void e_simple_card_bonobo_construct (ESimpleCardBonobo *simple_card, + GNOME_Evolution_Addressbook_SimpleCard corba_object, + ECardSimple *card_simple); +ESimpleCardBonobo *e_simple_card_bonobo_new (ECardSimple *card_simple); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* __E_SIMPLE_CARD_BONOBO_H__ */ -- cgit v1.2.3