diff options
Diffstat (limited to 'addressbook/gui')
137 files changed, 0 insertions, 43928 deletions
diff --git a/addressbook/gui/.cvsignore b/addressbook/gui/.cvsignore deleted file mode 100644 index 09980ae6ba..0000000000 --- a/addressbook/gui/.cvsignore +++ /dev/null @@ -1,6 +0,0 @@ -.deps -.libs -Makefile -Makefile.in -*.lo -*.la diff --git a/addressbook/gui/Makefile.am b/addressbook/gui/Makefile.am deleted file mode 100644 index 4e049a7116..0000000000 --- a/addressbook/gui/Makefile.am +++ /dev/null @@ -1 +0,0 @@ -SUBDIRS = merging contact-editor contact-list-editor widgets search component diff --git a/addressbook/gui/component/.cvsignore b/addressbook/gui/component/.cvsignore deleted file mode 100644 index 847efaf29c..0000000000 --- a/addressbook/gui/component/.cvsignore +++ /dev/null @@ -1,15 +0,0 @@ -.deps -.libs -.pure -Makefile -Makefile.in -*.lo -*.la -evolution-addressbook -evolution-addressbook.pure -test-addressbook -GNOME_Evolution_Addressbook*.server -GNOME_Evolution_Addressbook*.server.in -addressbook-marshal.c -addressbook-marshal.h -*.schemas
\ No newline at end of file diff --git a/addressbook/gui/component/GNOME_Evolution_Addressbook.server.in.in b/addressbook/gui/component/GNOME_Evolution_Addressbook.server.in.in deleted file mode 100644 index f57fcb7f09..0000000000 --- a/addressbook/gui/component/GNOME_Evolution_Addressbook.server.in.in +++ /dev/null @@ -1,135 +0,0 @@ -<oaf_info> - -<oaf_server iid="OAFIID:GNOME_Evolution_Addressbook_Factory:@VERSION@" - type="shlib" - location="@COMPONENTDIR@/libevolution-addressbook.so"> - - <oaf_attribute name="repo_ids" type="stringv"> - <item value="IDL:GNOME/ObjectFactory:1.0"/> - </oaf_attribute> - - <oaf_attribute name="name" type="string" - _value="Evolution Addressbook"/> - -</oaf_server> - -<oaf_server iid="OAFIID:GNOME_Evolution_Addressbook_VCard_Control:@VERSION@" - type="factory" - location="OAFIID:GNOME_Evolution_Addressbook_Factory:@VERSION@"> - - <oaf_attribute name="repo_ids" type="stringv"> - <item value="IDL:Bonobo/Control:1.0"/> - <item value="IDL:Bonobo/PersistStream:1.0"/> - </oaf_attribute> - - <oaf_attribute name="bonobo:supported_mime_types" type="stringv"> - <item value="text/vcard"/> - <item value="text/x-vcard"/> - </oaf_attribute> - - <oaf_attribute name="name" type="string" - _value="Evolution Addressbook card viewer"/> - -</oaf_server> - -<oaf_server iid="OAFIID:GNOME_Evolution_Addressbook_Component:@VERSION@" - type="factory" - location="OAFIID:GNOME_Evolution_Addressbook_Factory:@VERSION@"> - - <oaf_attribute name="repo_ids" type="stringv"> - <item value="IDL:GNOME/Evolution/Component:@VERSION@"/> - </oaf_attribute> - - <oaf_attribute name="name" type="string" - _value="Evolution Addressbook component"/> - - <oaf_attribute name="evolution:component_alias" type="string" value="contacts"/> - - <oaf_attribute name="evolution:menu_label" type="string" _value="C_ontacts"/> - <oaf_attribute name="evolution:menu_accelerator" type="string" value="*Control*F2"/> - <oaf_attribute name="evolution:button_label" type="string" _value="Contacts"/> - <oaf_attribute name="evolution:button_sort_order" type="string" value="-9"/> - <oaf_attribute name="evolution:button_icon" type="string" value="stock_addressbook"/> - -</oaf_server> - -<oaf_server iid="OAFIID:GNOME_Evolution_Addressbook_AddressWidget:@VERSION@" - type="factory" - location="OAFIID:GNOME_Evolution_Addressbook_Factory:@VERSION@"> - - <oaf_attribute name="repo_ids" type="stringv"> - <item value="IDL:BonoboControl/address-widget:@VERSION@"/> - <item value="IDL:GNOME/Control:1.0"/> - </oaf_attribute> - - <oaf_attribute name="name" type="string" - _value="Evolution Addressbook address viewer"/> - -</oaf_server> - -<oaf_server iid="OAFIID:GNOME_Evolution_Addressbook_AddressPopup:@VERSION@" - type="factory" - location="OAFIID:GNOME_Evolution_Addressbook_Factory:@VERSION@"> - - <oaf_attribute name="repo_ids" type="stringv"> - <item value="IDL:BonoboControl/address-widget:@VERSION@"/> - <item value="IDL:GNOME/Control:1.0"/> - </oaf_attribute> - - <oaf_attribute name="name" type="string" - _value="Evolution Addressbook address pop-up"/> - -</oaf_server> - -<oaf_server iid="OAFIID:GNOME_Evolution_SMime_CertificateManager_ConfigControl:@VERSION@" - type="factory" - location="OAFIID:GNOME_Evolution_Addressbook_Factory:@VERSION@"> - - <oaf_attribute name="repo_ids" type="stringv"> - <item value="IDL:GNOME/Evolution/ConfigControl:@VERSION@"/> - </oaf_attribute> - - <oaf_attribute name="evolution2:config_item:title" type="string" - _value="Certificates"/> - - <oaf_attribute name="evolution2:config_item:description" type="string" - _value="Manage your S/MIME certificates here"/> - - <oaf_attribute name="evolution2:config_item:icon_name" type="string" - value="stock_lock-ok"/> - - <oaf_attribute name="evolution2:config_item:priority" type="string" value="-6"/> - - <oaf_attribute name="name" type="string" - _value="Evolution S/Mime Certificate Management Control"/> - -</oaf_server> - -<oaf_server iid="OAFIID:GNOME_Evolution_Addressbook_Autocompletion_ConfigControl:@VERSION@" - type="factory" - location="OAFIID:GNOME_Evolution_Addressbook_Factory:@VERSION@"> - - <oaf_attribute name="repo_ids" type="stringv"> - <item value="IDL:GNOME/Evolution/ConfigControl:@VERSION@"/> - </oaf_attribute> - - <oaf_attribute name="evolution2:config_item:title" type="string" - _value="Autocompletion"/> - - <oaf_attribute name="evolution2:config_item:description" type="string" - _value="Configure autocomplete here"/> - - <oaf_attribute name="evolution2:config_item:icon_name" type="string" - value="stock_contact"/> - - <oaf_attribute name="evolution2:config_item:type" type="stringv"> - <item value="contacts"/> - </oaf_attribute> - - <oaf_attribute name="evolution2:config_item:priority" type="string" value="-9"/> - - <oaf_attribute name="name" type="string" - _value="Evolution folder settings configuration control"/> -</oaf_server> - -</oaf_info> diff --git a/addressbook/gui/component/Makefile.am b/addressbook/gui/component/Makefile.am deleted file mode 100644 index adf772206c..0000000000 --- a/addressbook/gui/component/Makefile.am +++ /dev/null @@ -1,115 +0,0 @@ -SUBDIRS = select-names - -INCLUDES = \ - -DG_LOG_DOMAIN=\"evolution-addressbook\" \ - -I$(top_srcdir) \ - -I$(top_builddir) \ - -I$(top_srcdir)/shell \ - -I$(top_builddir)/shell \ - -I$(top_srcdir)/widgets/misc \ - -I$(top_srcdir)/addressbook/util \ - -I$(top_srcdir)/addressbook/gui/contact-editor \ - -I$(top_srcdir)/addressbook/gui/contact-list-editor \ - -I$(top_srcdir)/addressbook/gui/widgets \ - -I$(top_builddir)/a11y/addressbook \ - -DEVOLUTION_DATADIR=\""$(datadir)"\" \ - -DEVOLUTION_GLADEDIR=\""$(gladedir)"\" \ - -DEVOLUTION_ETSPECDIR=\""$(etspecdir)"\" \ - -DEVOLUTION_IMAGESDIR=\""$(imagesdir)"\" \ - -DEVOLUTION_LOCALEDIR=\""$(localedir)"\" \ - -DEVOLUTION_UIDIR=\""$(evolutionuidir)"\" \ - -DPREFIX=\""$(prefix)"\" \ - $(LDAP_CFLAGS) \ - $(EVOLUTION_ADDRESSBOOK_CFLAGS) - -component_LTLIBRARIES = libevolution-addressbook.la - -libevolution_addressbook_la_SOURCES = \ - addressbook-component.c \ - addressbook-component.h \ - addressbook-config.c \ - addressbook-config.h \ - addressbook-migrate.c \ - addressbook-migrate.h \ - autocompletion-config.c \ - autocompletion-config.h \ - addressbook.c \ - addressbook.h \ - addressbook-view.c \ - addressbook-view.h \ - component-factory.c - -# $(top_builddir)/addressbook/printing/libecontactprint.la - -if ENABLE_SMIME -SMIME_LIB=$(top_builddir)/smime/gui/libevolution-smime.la -endif - -libevolution_addressbook_la_LIBADD = \ - $(SMIME_LIB) \ - $(top_builddir)/addressbook/printing/libecontactprint.la \ - $(top_builddir)/addressbook/gui/component/select-names/libeselectnames.la \ - $(top_builddir)/shell/libeshell.la \ - $(top_builddir)/addressbook/gui/merging/libeabbookmerging.la \ - $(top_builddir)/addressbook/gui/widgets/libeabwidgets.la \ - $(top_builddir)/addressbook/gui/search/libeaddressbooksearch.la \ - $(top_builddir)/filter/libfilter.la \ - $(top_builddir)/addressbook/util/libeabutil.la \ - $(top_builddir)/addressbook/gui/contact-editor/libecontacteditor.la \ - $(top_builddir)/addressbook/gui/contact-list-editor/libecontactlisteditor.la \ - $(top_builddir)/widgets/misc/libemiscwidgets.la \ - $(top_builddir)/widgets/menus/libmenus.la \ - $(top_builddir)/a11y/addressbook/libevolution-addressbook-a11y.la \ - $(top_builddir)/camel/libcamel.la \ - $(EVOLUTION_ADDRESSBOOK_LIBS) $(LDAP_LIBS) - - - -libevolution_addressbook_la_LDFLAGS = -module -avoid-version - -# GConf schemas - -schemadir = $(GCONF_SCHEMA_FILE_DIR) -schema_in_files = apps_evolution_addressbook.schemas.in.in -schema_DATA = $(schema_in_files:.schemas.in.in=-$(BASE_VERSION).schemas) -%-$(BASE_VERSION).schemas.in: %.schemas.in.in - cp $< $@ - -@INTLTOOL_SCHEMAS_RULE@ - -install-data-local: - if test -z "$(DESTDIR)" ; then \ - for p in $(schema_DATA) ; do \ - GCONF_CONFIG_SOURCE=$(GCONF_SCHEMA_CONFIG_SOURCE) $(GCONFTOOL) --makefile-install-rule $(srcdir)/$$p; \ - done \ - fi - -server_in_files = GNOME_Evolution_Addressbook.server.in.in -server_DATA = $(server_in_files:.server.in.in=_$(BASE_VERSION).server) -@EVO_SERVER_RULE@ -@INTLTOOL_SERVER_RULE@ - -glade_DATA = \ - ldap-config.glade - -BUILT_SOURCES = $(server_DATA) -CLEANFILES = $(BUILT_SOURCES) - -EXTRA_DIST = \ - $(glade_DATA) \ - $(schema_in_files) \ - $(server_in_files) - -dist-hook: - cd $(distdir); rm -f $(BUILT_SOURCES) - -if ENABLE_PURIFY -PLINK = $(LIBTOOL) --mode=link $(PURIFY) $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ - -all-local: evolution-addressbook.pure - -evolution-addressbook.pure: evolution-addressbook - @rm -f evolution-addressbook.pure - $(PLINK) $(evolution_addressbook_LDFLAGS) $(evolution_addressbook_OBJECTS) $(evolution_addressbook_LDADD) $(LIBS) - -endif diff --git a/addressbook/gui/component/addressbook-component.c b/addressbook/gui/component/addressbook-component.c deleted file mode 100644 index 3e1bba599a..0000000000 --- a/addressbook/gui/component/addressbook-component.c +++ /dev/null @@ -1,306 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* addressbook-component.c - * - * Copyright (C) 2003 Ettore Perazzoli - * - * 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> - */ - -/* EPFIXME: Add autocompletion setting. */ - - -#include <config.h> - -#include "addressbook-component.h" -#include "addressbook-config.h" -#include "addressbook-migrate.h" -#include "addressbook-view.h" -#include "addressbook/gui/contact-editor/eab-editor.h" -#include "addressbook/gui/widgets/eab-gui-util.h" -#include "e-util/e-plugin.h" -#include "addressbook/gui/widgets/eab-popup.h" -#include "addressbook/gui/widgets/eab-menu.h" -#include "addressbook/gui/widgets/eab-config.h" - -#include "widgets/misc/e-task-bar.h" -#include "widgets/misc/e-info-label.h" - -#include <string.h> -#include <bonobo/bonobo-i18n.h> -#include <gtk/gtkimage.h> -#include <gconf/gconf-client.h> -#include <gal/util/e-util.h> - -#ifdef ENABLE_SMIME -#include "smime/gui/component.h" -#endif - - -#define PARENT_TYPE bonobo_object_get_type () -static BonoboObjectClass *parent_class = NULL; - -struct _AddressbookComponentPrivate { - GConfClient *gconf_client; - char *base_directory; -}; - -/* Evolution::Component CORBA methods. */ - -static void -impl_createControls (PortableServer_Servant servant, - Bonobo_Control *corba_sidebar_control, - Bonobo_Control *corba_view_control, - Bonobo_Control *corba_statusbar_control, - CORBA_Environment *ev) -{ - AddressbookView *view = addressbook_view_new (); - BonoboControl *sidebar_control; - BonoboControl *view_control; - BonoboControl *statusbar_control; - - sidebar_control = bonobo_control_new (addressbook_view_peek_sidebar (view)); - view_control = addressbook_view_peek_folder_view (view); - statusbar_control = bonobo_control_new (addressbook_view_peek_statusbar (view)); - - *corba_sidebar_control = CORBA_Object_duplicate (BONOBO_OBJREF (sidebar_control), ev); - *corba_view_control = CORBA_Object_duplicate (BONOBO_OBJREF (view_control), ev); - *corba_statusbar_control = CORBA_Object_duplicate (BONOBO_OBJREF (statusbar_control), ev); -} - -static GNOME_Evolution_CreatableItemTypeList * -impl__get_userCreatableItems (PortableServer_Servant servant, - CORBA_Environment *ev) -{ - GNOME_Evolution_CreatableItemTypeList *list = GNOME_Evolution_CreatableItemTypeList__alloc (); - - list->_length = 3; - list->_maximum = list->_length; - list->_buffer = GNOME_Evolution_CreatableItemTypeList_allocbuf (list->_length); - - CORBA_sequence_set_release (list, FALSE); - - list->_buffer[0].id = "contact"; - list->_buffer[0].description = _("New Contact"); - list->_buffer[0].menuDescription = _("_Contact"); - list->_buffer[0].tooltip = _("Create a new contact"); - list->_buffer[0].menuShortcut = 'c'; - list->_buffer[0].iconName = "stock_contact"; - list->_buffer[0].type = GNOME_Evolution_CREATABLE_OBJECT; - - list->_buffer[1].id = "contact_list"; - list->_buffer[1].description = _("New Contact List"); - list->_buffer[1].menuDescription = _("Contact _List"); - list->_buffer[1].tooltip = _("Create a new contact list"); - list->_buffer[1].menuShortcut = 'l'; - list->_buffer[1].iconName = "stock_contact-list"; - list->_buffer[1].type = GNOME_Evolution_CREATABLE_OBJECT; - - list->_buffer[2].id = "address_book"; - list->_buffer[2].description = _("New Address Book"); - list->_buffer[2].menuDescription = _("Address _Book"); - list->_buffer[2].tooltip = _("Create a new address book"); - list->_buffer[2].menuShortcut = 'b'; - list->_buffer[2].iconName = "stock_addressbook"; - list->_buffer[2].type = GNOME_Evolution_CREATABLE_FOLDER; - - return list; -} - -static void -book_loaded_cb (EBook *book, EBookStatus status, gpointer data) -{ - EContact *contact; - char *item_type_name = data; - - if (status != E_BOOK_ERROR_OK) { - /* XXX we really need a dialog here, but we don't have - access to the ESource so we can't use - eab_load_error_dialog. fun! */ - return; - } - - contact = e_contact_new (); - - if (!strcmp (item_type_name, "contact")) { - eab_show_contact_editor (book, contact, TRUE, TRUE); - } - else if (!strcmp (item_type_name, "contact_list")) { - eab_show_contact_list_editor (book, contact, TRUE, TRUE); - } - - g_object_unref (book); - g_object_unref (contact); - - g_free (item_type_name); -} - -static void -impl_requestCreateItem (PortableServer_Servant servant, - const CORBA_char *item_type_name, - CORBA_Environment *ev) -{ - AddressbookComponent *addressbook_component = ADDRESSBOOK_COMPONENT (bonobo_object_from_servant (servant)); - AddressbookComponentPrivate *priv; - EBook *book; - - priv = addressbook_component->priv; - - if (!item_type_name || - (strcmp (item_type_name, "address_book") && - strcmp (item_type_name, "contact") && - strcmp (item_type_name, "contact_list"))) { - CORBA_exception_set (ev, CORBA_USER_EXCEPTION, ex_GNOME_Evolution_Component_UnknownType, NULL); - return; - } - - if (!strcmp (item_type_name, "address_book")) { - addressbook_config_create_new_source (NULL); - return; - } - - book = e_book_new_default_addressbook (NULL); - e_book_async_open (book, FALSE, book_loaded_cb, g_strdup (item_type_name)); -} - -static void -impl_upgradeFromVersion (PortableServer_Servant servant, short major, short minor, short revision, CORBA_Environment *ev) -{ - GError *err = NULL; - - if (!addressbook_migrate (addressbook_component_peek (), major, minor, revision, &err)) { - GNOME_Evolution_Component_UpgradeFailed *failedex; - - failedex = GNOME_Evolution_Component_UpgradeFailed__alloc(); - failedex->what = CORBA_string_dup(_("Failed upgrading Addressbook settings or folders.")); - failedex->why = CORBA_string_dup(err->message); - CORBA_exception_set(ev, CORBA_USER_EXCEPTION, ex_GNOME_Evolution_Component_UpgradeFailed, failedex); - } - - if (err) - g_error_free(err); -} - -static CORBA_boolean -impl_requestQuit (PortableServer_Servant servant, CORBA_Environment *ev) -{ - return eab_editor_request_close_all (); -} - -/* GObject methods. */ - -static void -impl_dispose (GObject *object) -{ - AddressbookComponentPrivate *priv = ADDRESSBOOK_COMPONENT (object)->priv; - - if (priv->gconf_client != NULL) { - g_object_unref (priv->gconf_client); - priv->gconf_client = NULL; - } - - (* G_OBJECT_CLASS (parent_class)->dispose) (object); -} - -static void -impl_finalize (GObject *object) -{ - AddressbookComponentPrivate *priv = ADDRESSBOOK_COMPONENT (object)->priv; - - g_free (priv); - - (* G_OBJECT_CLASS (parent_class)->finalize) (object); -} - - -/* Initialization. */ - -static void -addressbook_component_class_init (AddressbookComponentClass *class) -{ - POA_GNOME_Evolution_Component__epv *epv = &class->epv; - GObjectClass *object_class = G_OBJECT_CLASS (class); - - epv->createControls = impl_createControls; - epv->_get_userCreatableItems = impl__get_userCreatableItems; - epv->requestCreateItem = impl_requestCreateItem; - epv->upgradeFromVersion = impl_upgradeFromVersion; - epv->requestQuit = impl_requestQuit; - - object_class->dispose = impl_dispose; - object_class->finalize = impl_finalize; - - parent_class = g_type_class_peek_parent (class); -} - -static void -addressbook_component_init (AddressbookComponent *component) -{ - AddressbookComponentPrivate *priv; - static int first = TRUE; - - priv = g_new0 (AddressbookComponentPrivate, 1); - - /* EPFIXME: Should use a custom one instead? */ - priv->gconf_client = gconf_client_get_default (); - - priv->base_directory = g_build_filename (g_get_home_dir (), ".evolution", NULL); - - component->priv = priv; - -#ifdef ENABLE_SMIME - smime_component_init (); -#endif - - if (first) { - first = FALSE; - e_plugin_hook_register_type(eab_popup_hook_get_type()); - e_plugin_hook_register_type(eab_menu_hook_get_type()); - e_plugin_hook_register_type(eab_config_hook_get_type()); - } -} - - -/* Public API. */ - -AddressbookComponent * -addressbook_component_peek (void) -{ - static AddressbookComponent *component = NULL; - - if (component == NULL) - component = g_object_new (addressbook_component_get_type (), NULL); - - return component; -} - -GConfClient* -addressbook_component_peek_gconf_client (AddressbookComponent *component) -{ - g_return_val_if_fail (ADDRESSBOOK_IS_COMPONENT (component), NULL); - - return component->priv->gconf_client; -} - -const char * -addressbook_component_peek_base_directory (AddressbookComponent *component) -{ - g_return_val_if_fail (ADDRESSBOOK_IS_COMPONENT (component), NULL); - - return component->priv->base_directory; -} - -BONOBO_TYPE_FUNC_FULL (AddressbookComponent, GNOME_Evolution_Component, PARENT_TYPE, addressbook_component) diff --git a/addressbook/gui/component/addressbook-component.h b/addressbook/gui/component/addressbook-component.h deleted file mode 100644 index de92637a59..0000000000 --- a/addressbook/gui/component/addressbook-component.h +++ /dev/null @@ -1,63 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* addressbook-component.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 _ADDRESSBOOK_COMPONENT_H_ -#define _ADDRESSBOOK_COMPONENT_H_ - -#include <bonobo/bonobo-object.h> - -#include "Evolution.h" -#include "e-activity-handler.h" -#include <libedataserver/e-source-list.h> - -#define ADDRESSBOOK_TYPE_COMPONENT (addressbook_component_get_type ()) -#define ADDRESSBOOK_COMPONENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ADDRESSBOOK_TYPE_COMPONENT, AddressbookComponent)) -#define ADDRESSBOOK_COMPONENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ADDRESSBOOK_TYPE_COMPONENT, AddressbookComponentClass)) -#define ADDRESSBOOK_IS_COMPONENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ADDRESSBOOK_TYPE_COMPONENT)) -#define ADDRESSBOOK_IS_COMPONENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), ADDRESSBOOK_TYPE_COMPONENT)) - - -typedef struct _AddressbookComponent AddressbookComponent; -typedef struct _AddressbookComponentPrivate AddressbookComponentPrivate; -typedef struct _AddressbookComponentClass AddressbookComponentClass; - -struct _AddressbookComponent { - BonoboObject parent; - - AddressbookComponentPrivate *priv; -}; - -struct _AddressbookComponentClass { - BonoboObjectClass parent_class; - - POA_GNOME_Evolution_Component__epv epv; -}; - - -GType addressbook_component_get_type (void); - -AddressbookComponent *addressbook_component_peek (void); - -GConfClient *addressbook_component_peek_gconf_client (AddressbookComponent *component); -const char *addressbook_component_peek_base_directory (AddressbookComponent *component); - -#endif /* _ADDRESSBOOK_COMPONENT_H_ */ diff --git a/addressbook/gui/component/addressbook-config.c b/addressbook/gui/component/addressbook-config.c deleted file mode 100644 index ddf44281fb..0000000000 --- a/addressbook/gui/component/addressbook-config.c +++ /dev/null @@ -1,1072 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Authors: - * Chris Toshok <toshok@ximian.com> - * Chris Lahey <clahey@ximian.com> - * Michael Zucchi <notzed@ximian.com> - * And no doubt others ... - **/ - -/*#define STANDALONE*/ - -#include <config.h> - -#include <string.h> -#include <stdlib.h> -#include <sys/time.h> - -#include <gtk/gtkcombo.h> -#include <gtk/gtkdialog.h> -#include <gtk/gtkentry.h> -#include <gtk/gtkrange.h> -#include <gtk/gtktreeview.h> -#include <gtk/gtkliststore.h> -#include <gtk/gtkscrolledwindow.h> -#include <gtk/gtktreeselection.h> -#include <gtk/gtkcellrenderertext.h> -#include <gtk/gtkcombobox.h> -#include <gtk/gtkoptionmenu.h> -#include <gtk/gtkspinbutton.h> -#include <gtk/gtkcelllayout.h> -#include <gtk/gtklabel.h> -#include <libgnome/gnome-i18n.h> - -#include <bonobo/bonobo-generic-factory.h> - -#include <glade/glade.h> - -#include "addressbook.h" -#include "addressbook-component.h" -#include "addressbook-config.h" - -#include "widgets/misc/e-error.h" - -#include "evolution-config-control.h" - -#include "addressbook/gui/widgets/eab-config.h" - -#define d(x) - -#ifdef HAVE_LDAP -#include "ldap.h" -#include "ldap_schema.h" -#endif - -#define LDAP_PORT_STRING "389" -#define LDAPS_PORT_STRING "636" - -#define GLADE_FILE_NAME "ldap-config.glade" -#define CONFIG_CONTROL_FACTORY_ID "OAFIID:GNOME_Evolution_Addressbook_ConfigControlFactory:" BASE_VERSION -#define LDAP_CONFIG_CONTROL_ID "OAFIID:GNOME_Evolution_LDAPStorage_ConfigControl:" BASE_VERSION - -GtkWidget* supported_bases_create_table (char *name, char *string1, char *string2, - int num1, int num2); - -/* default objectclasses */ -#define TOP "top" -#define PERSON "person" -#define ORGANIZATIONALPERSON "organizationalPerson" -#define INETORGPERSON "inetOrgPerson" -#define EVOLUTIONPERSON "evolutionPerson" -#define CALENTRY "calEntry" - - -typedef struct _AddressbookSourceDialog AddressbookSourceDialog; - -struct _AddressbookSourceDialog { - GladeXML *gui; - - EABConfig *config; /* the config manager */ - - GtkWidget *window; - - /* Source selection (druid only) */ - ESourceList *source_list; - GSList *menu_source_groups; - GtkWidget *group_optionmenu; - - /* ESource we're currently editing */ - ESource *source; - /* The original source in edit mode. Also used to flag when we are in edit mode. */ - ESource *original_source; - - /* Source group we're creating/editing a source in */ - ESourceGroup *source_group; - - /* info page fields */ - GtkWidget *host; - GtkWidget *auth_optionmenu; - AddressbookLDAPAuthType auth; - GtkWidget *auth_principal; - - /* connecting page fields */ - GtkWidget *port_combo; - GtkWidget *ssl_optionmenu; - AddressbookLDAPSSLType ssl; - - /* searching page fields */ - GtkWidget *rootdn; - AddressbookLDAPScopeType scope; - GtkWidget *scope_optionmenu; - GtkWidget *timeout_scale; - GtkWidget *limit_spinbutton; - - /* display name page fields */ - GtkWidget *display_name; -}; - - - -#ifdef HAVE_LDAP - -static char * -ldap_unparse_auth (AddressbookLDAPAuthType auth_type) -{ - switch (auth_type) { - case ADDRESSBOOK_LDAP_AUTH_NONE: - return "none"; - case ADDRESSBOOK_LDAP_AUTH_SIMPLE_EMAIL: - return "ldap/simple-email"; - case ADDRESSBOOK_LDAP_AUTH_SIMPLE_BINDDN: - return "ldap/simple-binddn"; - default: - g_assert(0); - return "none"; - } -} - -static AddressbookLDAPAuthType -ldap_parse_auth (const char *auth) -{ - if (!auth) - return ADDRESSBOOK_LDAP_AUTH_NONE; - - if (!strcmp (auth, "ldap/simple-email") || !strcmp (auth, "simple")) - return ADDRESSBOOK_LDAP_AUTH_SIMPLE_EMAIL; - else if (!strcmp (auth, "ldap/simple-binddn")) - return ADDRESSBOOK_LDAP_AUTH_SIMPLE_BINDDN; - else - return ADDRESSBOOK_LDAP_AUTH_NONE; -} - -static char * -ldap_unparse_scope (AddressbookLDAPScopeType scope_type) -{ - switch (scope_type) { - case ADDRESSBOOK_LDAP_SCOPE_BASE: - return "base"; - case ADDRESSBOOK_LDAP_SCOPE_ONELEVEL: - return "one"; - case ADDRESSBOOK_LDAP_SCOPE_SUBTREE: - return "sub"; - default: - g_assert(0); - return ""; - } -} - -static char * -ldap_unparse_ssl (AddressbookLDAPSSLType ssl_type) -{ - switch (ssl_type) { - case ADDRESSBOOK_LDAP_SSL_NEVER: - return "never"; - case ADDRESSBOOK_LDAP_SSL_WHENEVER_POSSIBLE: - return "whenever_possible"; - case ADDRESSBOOK_LDAP_SSL_ALWAYS: - return "always"; - default: - g_assert(0); - return ""; - } -} - -static AddressbookLDAPSSLType -ldap_parse_ssl (const char *ssl) -{ - if (!ssl) - return ADDRESSBOOK_LDAP_SSL_WHENEVER_POSSIBLE; /* XXX good default? */ - - if (!strcmp (ssl, "always")) - return ADDRESSBOOK_LDAP_SSL_ALWAYS; - else if (!strcmp (ssl, "never")) - return ADDRESSBOOK_LDAP_SSL_NEVER; - else - return ADDRESSBOOK_LDAP_SSL_WHENEVER_POSSIBLE; -} - -static gboolean -source_to_uri_parts (ESource *source, gchar **host, gchar **rootdn, AddressbookLDAPScopeType *scope, gint *port) -{ - gchar *uri; - LDAPURLDesc *lud; - gint ldap_error; - - g_assert (source); - - uri = e_source_get_uri (source); - ldap_error = ldap_url_parse ((gchar *) uri, &lud); - g_free (uri); - - if (ldap_error != LDAP_SUCCESS) - return FALSE; - - if (host) - *host = g_strdup (lud->lud_host ? lud->lud_host : ""); - if (rootdn) - *rootdn = g_strdup (lud->lud_dn ? lud->lud_dn : ""); - if (port) - *port = lud->lud_port ? lud->lud_port : LDAP_PORT; - if (scope) - *scope = lud->lud_scope == LDAP_SCOPE_BASE ? ADDRESSBOOK_LDAP_SCOPE_BASE : - lud->lud_scope == LDAP_SCOPE_ONELEVEL ? ADDRESSBOOK_LDAP_SCOPE_ONELEVEL : - lud->lud_scope == LDAP_SCOPE_SUBTREE ? ADDRESSBOOK_LDAP_SCOPE_SUBTREE : - ADDRESSBOOK_LDAP_SCOPE_ONELEVEL; - - ldap_free_urldesc (lud); - return TRUE; -} - -static gboolean -source_group_is_remote (ESourceGroup *group) -{ - return strncmp ("ldap:", e_source_group_peek_base_uri (group), 5) == 0; -} - -/* ldap api foo */ -static LDAP * -addressbook_ldap_init (GtkWidget *window, ESource *source) -{ - LDAP *ldap; - gchar *host; - gint port; - int ldap_error; - int protocol_version = LDAP_VERSION3; - - if (!source_to_uri_parts (source, &host, NULL, NULL, &port)) - return NULL; - - if (!(ldap = ldap_init (host, port))) { - e_error_run ((GtkWindow *) window, "addressbook:ldap-init", NULL); - goto done; - } - - ldap_error = ldap_set_option (ldap, LDAP_OPT_PROTOCOL_VERSION, &protocol_version); - if (LDAP_OPT_SUCCESS != ldap_error) - g_warning ("failed to set protocol version to LDAPv3"); - - /* XXX do TLS if it's configured in */ - - done: - g_free (host); - return ldap; -} - -static gint -addressbook_ldap_auth (GtkWidget *window, LDAP *ldap) -{ - gint ldap_error; - - /* XXX use auth info from source */ - ldap_error = ldap_simple_bind_s (ldap, NULL, NULL); - if (LDAP_SUCCESS != ldap_error) - e_error_run ((GtkWindow *) window, "addressbook:ldap-auth", NULL); - - return ldap_error; -} - -static int -addressbook_root_dse_query (AddressbookSourceDialog *dialog, LDAP *ldap, - char **attrs, LDAPMessage **resp) -{ - int ldap_error; - struct timeval timeout; - - timeout.tv_sec = (gint) gtk_adjustment_get_value (GTK_RANGE(dialog->timeout_scale)->adjustment); - timeout.tv_usec = 0; - - ldap_error = ldap_search_ext_s (ldap, - LDAP_ROOT_DSE, LDAP_SCOPE_BASE, - "(objectclass=*)", - attrs, 0, NULL, NULL, &timeout, LDAP_NO_LIMIT, resp); - if (LDAP_SUCCESS != ldap_error) - e_error_run (GTK_WINDOW (dialog->window), "addressbook:ldap-search-base", NULL); - - return ldap_error; -} - -/* searching page */ -GtkWidget* -supported_bases_create_table (char *name, char *string1, char *string2, int num1, int num2) -{ - GtkWidget *table, *scrolled; - GtkTreeSelection *selection; - GtkCellRenderer *renderer; - GtkListStore *model; - - scrolled = gtk_scrolled_window_new (NULL, NULL); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled), GTK_SHADOW_IN); - - model = gtk_list_store_new (1, G_TYPE_STRING); - table = gtk_tree_view_new_with_model ((GtkTreeModel *) model); - renderer = gtk_cell_renderer_text_new (); - gtk_tree_view_insert_column_with_attributes ((GtkTreeView *) table, -1, _("Base"), renderer, "text", 0, NULL); - gtk_tree_view_set_headers_visible ((GtkTreeView *) table, FALSE); - selection = gtk_tree_view_get_selection ((GtkTreeView *) table); - gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE); - - gtk_container_add (GTK_CONTAINER (scrolled), table); - g_object_set_data((GObject *)scrolled, "table", table); - - return scrolled; -} - -static gboolean -do_ldap_root_dse_query (AddressbookSourceDialog *sdialog, GtkListStore *model, ESource *source) -{ - LDAP *ldap; - char *attrs[2]; - int ldap_error; - char **values; - LDAPMessage *resp; - int i; - - ldap = addressbook_ldap_init (sdialog->window, source); - if (!ldap) - return FALSE; - - if (LDAP_SUCCESS != addressbook_ldap_auth (sdialog->window, ldap)) - goto fail; - - attrs[0] = "namingContexts"; - attrs[1] = NULL; - - ldap_error = addressbook_root_dse_query (sdialog, ldap, attrs, &resp); - - if (ldap_error != LDAP_SUCCESS) - goto fail; - - values = ldap_get_values (ldap, resp, "namingContexts"); - if (!values || values[0] == NULL) { - e_error_run (GTK_WINDOW (sdialog->window), "addressbook:ldap-search-base", NULL); - goto fail; - } - - for (i = 0; values[i]; i++) { - GtkTreeIter iter; - - gtk_list_store_append (model, &iter); - gtk_list_store_set (model, &iter, 0, values[i], -1); - } - - ldap_value_free (values); - ldap_unbind_s (ldap); - return TRUE; - - fail: - ldap_unbind_s (ldap); - return FALSE; -} - -static void -search_base_selection_model_changed (GtkTreeSelection *selection, GtkWidget *dialog) -{ - gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog), - GTK_RESPONSE_OK, - gtk_tree_selection_get_selected(selection, NULL, NULL)); -} - -static void -query_for_supported_bases (GtkWidget *button, AddressbookSourceDialog *sdialog) -{ - GtkTreeSelection *selection; - GtkListStore *model; - GtkTreeView *table; - GtkWidget *dialog; - GtkWidget *supported_bases_table; - GladeXML *gui; - GtkTreeIter iter; - - gui = glade_xml_new (EVOLUTION_GLADEDIR "/" GLADE_FILE_NAME, "supported-bases-dialog", NULL); - dialog = glade_xml_get_widget (gui, "supported-bases-dialog"); - - gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (sdialog->window)); - gtk_window_set_modal (GTK_WINDOW (dialog), TRUE); - - gtk_widget_ensure_style (dialog); - gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), 0); - gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (dialog)->action_area), 12); - - supported_bases_table = glade_xml_get_widget (gui, "supported-bases-table"); - gtk_widget_show_all (supported_bases_table); - - table = g_object_get_data((GObject *)supported_bases_table, "table"); - model = (GtkListStore *)gtk_tree_view_get_model(table); - selection = gtk_tree_view_get_selection (table); - g_signal_connect (selection, "changed", G_CALLBACK (search_base_selection_model_changed), dialog); - search_base_selection_model_changed (selection, dialog); - - if (do_ldap_root_dse_query (sdialog, model, sdialog->source)) { - gtk_widget_show (dialog); - - if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_OK - && gtk_tree_selection_get_selected(selection, (GtkTreeModel **)&model, &iter)) { - char *dn; - - gtk_tree_model_get ((GtkTreeModel *)model, &iter, 0, &dn, -1); - gtk_entry_set_text((GtkEntry *)sdialog->rootdn, dn); - g_free(dn); - } - } - - gtk_widget_destroy (dialog); -} - -#endif /* HAVE_LDAP */ - -GtkWidget* -addressbook_config_create_new_source (GtkWidget *parent) -{ - return addressbook_config_edit_source(parent, NULL); -} - -/* ********************************************************************** */ - -static void -eabc_type_changed(GtkComboBox *dropdown, AddressbookSourceDialog *sdialog) -{ - int id = gtk_combo_box_get_active(dropdown); - GtkTreeModel *model; - GtkTreeIter iter; - - model = gtk_combo_box_get_model(dropdown); - if (id == -1 || !gtk_tree_model_iter_nth_child(model, &iter, NULL, id)) - return; - - /* TODO: when we change the group type, we lose all of the pre-filled dialog info */ - - gtk_tree_model_get(model, &iter, 1, &sdialog->source_group, -1); - /* HACK: doesn't work if you don't do this */ - e_source_set_absolute_uri(sdialog->source, NULL); - e_source_set_group(sdialog->source, sdialog->source_group); - - /* BIG HACK: We load the defaults for each type here. - I guess plugins will have to use the do it in their factory callbacks */ - if (!strncmp(e_source_group_peek_base_uri(sdialog->source_group), "groupwise:", 10)) { - GSList *l; - ESource *source; - char *tmp; - - l = e_source_group_peek_sources(sdialog->source_group); - if (l && l->data ) { - source = l->data; - e_source_set_property(sdialog->source, "auth", e_source_get_property(source, "auth")); - e_source_set_property(sdialog->source, "user", e_source_get_property(source, "user")); - e_source_set_property(sdialog->source, "user_ssl", e_source_get_property(source, "use_ssl")); - } - - e_source_set_property(sdialog->source, "auth-domain", "Groupwise"); - tmp = g_strconcat (";", e_source_peek_name(sdialog->source), NULL); - e_source_set_relative_uri (sdialog->source, tmp); - g_free (tmp); -#ifdef HAVE_LDAP - } else if (!strncmp(e_source_group_peek_base_uri(sdialog->source_group), "ldap:", 5)) { - char *tmp; - - tmp = g_strdup_printf ("%s:%s/%s?" /* trigraph prevention */ "?%s", - "", LDAP_PORT_STRING, - "", - "one"); - e_source_set_relative_uri (sdialog->source, tmp); - g_free (tmp); - e_source_set_property(sdialog->source, "timeout", "3"); - e_source_set_property(sdialog->source, "limit", "100"); -#endif - } else { - e_source_set_relative_uri (sdialog->source, e_source_peek_uid (sdialog->source)); - } - - e_config_target_changed((EConfig *)sdialog->config, E_CONFIG_TARGET_CHANGED_REBUILD); -} - -static GtkWidget * -eabc_general_type(EConfig *ec, EConfigItem *item, struct _GtkWidget *parent, struct _GtkWidget *old, void *data) -{ - AddressbookSourceDialog *sdialog = data; - GtkComboBox *dropdown; - GtkCellRenderer *cell; - GtkListStore *store; - GtkTreeIter iter; - GSList *l; - GtkWidget *w, *label; - - if (old) - return old; - - w = gtk_hbox_new(FALSE, 6); - label = gtk_label_new_with_mnemonic(_("_Type:")); - gtk_box_pack_start((GtkBox *)w, label, FALSE, FALSE, 0); - - dropdown = (GtkComboBox *)gtk_combo_box_new(); - cell = gtk_cell_renderer_text_new(); - store = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_POINTER); - for (l=sdialog->menu_source_groups;l;l=g_slist_next(l)) { - ESourceGroup *group = l->data; - - gtk_list_store_append(store, &iter); - gtk_list_store_set(store, &iter, 0, e_source_group_peek_name(group), 1, group, -1); - } - - gtk_cell_layout_pack_start((GtkCellLayout *)dropdown, cell, TRUE); - gtk_cell_layout_set_attributes((GtkCellLayout *)dropdown, cell, "text", 0, NULL); - gtk_combo_box_set_model(dropdown, (GtkTreeModel *)store); - gtk_combo_box_set_active(dropdown, -1); - gtk_combo_box_set_active(dropdown, 0); - g_signal_connect(dropdown, "changed", G_CALLBACK(eabc_type_changed), sdialog); - gtk_widget_show((GtkWidget *)dropdown); - gtk_box_pack_start((GtkBox *)w, (GtkWidget *)dropdown, TRUE, TRUE, 0); - gtk_label_set_mnemonic_widget((GtkLabel *)label, (GtkWidget *)dropdown); - - gtk_box_pack_start((GtkBox *)parent, (GtkWidget *)w, FALSE, FALSE, 0); - - gtk_widget_show_all(w); - - return (GtkWidget *)w; -} - -static void -name_changed_cb(GtkWidget *w, AddressbookSourceDialog *sdialog) -{ - e_source_set_name (sdialog->source, gtk_entry_get_text (GTK_ENTRY (sdialog->display_name))); -} - -static GtkWidget * -eabc_general_name(EConfig *ec, EConfigItem *item, struct _GtkWidget *parent, struct _GtkWidget *old, void *data) -{ - AddressbookSourceDialog *sdialog = data; - const char *uri; - GtkWidget *w; - GladeXML *gui; - - if (old) - return old; - - gui = glade_xml_new (EVOLUTION_GLADEDIR "/" GLADE_FILE_NAME, item->label, NULL); - w = glade_xml_get_widget(gui, item->label); - gtk_box_pack_start((GtkBox *)parent, w, FALSE, FALSE, 0); - - sdialog->display_name = glade_xml_get_widget (gui, "account-editor-display-name-entry"); - g_signal_connect(sdialog->display_name, "changed", G_CALLBACK(name_changed_cb), sdialog); - gtk_entry_set_text((GtkEntry *)sdialog->display_name, e_source_peek_name(sdialog->source)); - - /* Hardcoded: groupwise can't edit the name (or anything else) */ - if (sdialog->original_source) { - uri = e_source_group_peek_base_uri (sdialog->source_group); - if (uri && strncmp(uri, "groupwise:", 10) == 0) { - gtk_widget_set_sensitive (GTK_WIDGET(sdialog->display_name), FALSE); - } - } - - g_object_unref(gui); - - return w; -} - -#ifdef HAVE_LDAP -static void -url_changed(AddressbookSourceDialog *sdialog) -{ - char *str; - - str = g_strdup_printf ("%s:%s/%s?" /* trigraph prevention */ "?%s", - gtk_entry_get_text (GTK_ENTRY (sdialog->host)), - gtk_entry_get_text (GTK_ENTRY (GTK_COMBO (sdialog->port_combo)->entry)), - gtk_entry_get_text (GTK_ENTRY (sdialog->rootdn)), - ldap_unparse_scope (sdialog->scope)); - e_source_set_relative_uri (sdialog->source, str); - g_free (str); -} - -static void -host_changed_cb(GtkWidget *w, AddressbookSourceDialog *sdialog) -{ - url_changed(sdialog); -} - -static void -port_entry_changed_cb(GtkWidget *w, AddressbookSourceDialog *sdialog) -{ - const char *port = gtk_entry_get_text((GtkEntry *)w); - - if (!strcmp (port, LDAPS_PORT_STRING)) { - sdialog->ssl = ADDRESSBOOK_LDAP_SSL_ALWAYS; - gtk_option_menu_set_history (GTK_OPTION_MENU(sdialog->ssl_optionmenu), sdialog->ssl); - gtk_widget_set_sensitive (sdialog->ssl_optionmenu, FALSE); - } else { - gtk_widget_set_sensitive (sdialog->ssl_optionmenu, TRUE); - } - - url_changed(sdialog); -} - -static void -ssl_optionmenu_changed_cb(GtkWidget *w, AddressbookSourceDialog *sdialog) -{ - sdialog->ssl = gtk_option_menu_get_history((GtkOptionMenu *)w); - e_source_set_property (sdialog->source, "ssl", ldap_unparse_ssl (sdialog->ssl)); -} - -static GtkWidget * -eabc_general_host(EConfig *ec, EConfigItem *item, struct _GtkWidget *parent, struct _GtkWidget *old, void *data) -{ - AddressbookSourceDialog *sdialog = data; - const char *tmp; - GtkWidget *w; - char *uri, port[16]; - LDAPURLDesc *lud; - GladeXML *gui; - - if (!source_group_is_remote(sdialog->source_group)) - return NULL; - - gui = glade_xml_new (EVOLUTION_GLADEDIR "/" GLADE_FILE_NAME, item->label, NULL); - w = glade_xml_get_widget(gui, item->label); - gtk_box_pack_start((GtkBox *)parent, w, FALSE, FALSE, 0); - - uri = e_source_get_uri(sdialog->source); - if (ldap_url_parse(uri, &lud) != LDAP_SUCCESS) - lud = NULL; - g_free(uri); - - sdialog->host = glade_xml_get_widget (gui, "server-name-entry"); - gtk_entry_set_text((GtkEntry *)sdialog->host, lud && lud->lud_host ? lud->lud_host : ""); - g_signal_connect (sdialog->host, "changed", G_CALLBACK (host_changed_cb), sdialog); - - sdialog->port_combo = glade_xml_get_widget (gui, "port-combo"); - sprintf(port, "%u", lud && lud->lud_port? lud->lud_port : LDAP_PORT); - gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (sdialog->port_combo)->entry), port); - g_signal_connect (GTK_COMBO(sdialog->port_combo)->entry, "changed", G_CALLBACK (port_entry_changed_cb), sdialog); - - if (lud) - ldap_free_urldesc (lud); - - sdialog->ssl_optionmenu = glade_xml_get_widget (gui, "ssl-optionmenu"); - tmp = e_source_get_property (sdialog->source, "ssl"); - sdialog->ssl = tmp ? ldap_parse_ssl (tmp) : ADDRESSBOOK_LDAP_SSL_WHENEVER_POSSIBLE; - gtk_option_menu_set_history (GTK_OPTION_MENU(sdialog->ssl_optionmenu), sdialog->ssl); - g_signal_connect(sdialog->ssl_optionmenu, "changed", G_CALLBACK(ssl_optionmenu_changed_cb), sdialog); - - g_object_unref(gui); - - return w; -} - -static void -auth_entry_changed_cb(GtkWidget *w, AddressbookSourceDialog *sdialog) -{ - const char *principal = gtk_entry_get_text((GtkEntry *)w); - - /* seems messy ... but the api is */ - switch (sdialog->auth) { - case ADDRESSBOOK_LDAP_AUTH_SIMPLE_BINDDN: - e_source_set_property(sdialog->source, "email_addr", NULL); - e_source_set_property(sdialog->source, "binddn", principal); - break; - case ADDRESSBOOK_LDAP_AUTH_SIMPLE_EMAIL: - e_source_set_property(sdialog->source, "binddn", NULL); - e_source_set_property(sdialog->source, "email_addr", principal); - break; - case ADDRESSBOOK_LDAP_AUTH_NONE: - default: - e_source_set_property(sdialog->source, "email_addr", NULL); - e_source_set_property(sdialog->source, "binddn", NULL); - break; - } -} - -static void -auth_optionmenu_changed_cb(GtkWidget *w, AddressbookSourceDialog *sdialog) -{ - sdialog->auth = gtk_option_menu_get_history((GtkOptionMenu *)w); - e_source_set_property (sdialog->source, "auth", ldap_unparse_auth (sdialog->auth)); - - /* make sure the right property is set for the auth - ugh, funny api */ - auth_entry_changed_cb(sdialog->auth_principal, sdialog); -} - -static GtkWidget * -eabc_general_auth(EConfig *ec, EConfigItem *item, struct _GtkWidget *parent, struct _GtkWidget *old, void *data) -{ - AddressbookSourceDialog *sdialog = data; - GtkWidget *w; - const char *tmp; - GladeXML *gui; - - if (!source_group_is_remote(sdialog->source_group)) - return NULL; - - gui = glade_xml_new (EVOLUTION_GLADEDIR "/" GLADE_FILE_NAME, item->label, NULL); - w = glade_xml_get_widget(gui, item->label); - gtk_box_pack_start((GtkBox *)parent, w, FALSE, FALSE, 0); - - sdialog->auth_optionmenu = glade_xml_get_widget (gui, "auth-optionmenu"); - tmp = e_source_get_property(sdialog->source, "auth"); - sdialog->auth = tmp ? ldap_parse_auth(tmp) : ADDRESSBOOK_LDAP_AUTH_NONE; - gtk_option_menu_set_history (GTK_OPTION_MENU(sdialog->auth_optionmenu), sdialog->auth); - g_signal_connect(sdialog->auth_optionmenu, "changed", G_CALLBACK(auth_optionmenu_changed_cb), sdialog); - - sdialog->auth_principal = glade_xml_get_widget (gui, "auth-entry"); - switch (sdialog->auth) { - case ADDRESSBOOK_LDAP_AUTH_SIMPLE_EMAIL: - tmp = e_source_get_property(sdialog->source, "email_addr"); - break; - case ADDRESSBOOK_LDAP_AUTH_SIMPLE_BINDDN: - tmp = e_source_get_property(sdialog->source, "binddn"); - break; - case ADDRESSBOOK_LDAP_AUTH_NONE: - default: - tmp = ""; - break; - } - gtk_entry_set_text((GtkEntry *)sdialog->auth_principal, tmp?tmp:""); - g_signal_connect (sdialog->auth_principal, "changed", G_CALLBACK (auth_entry_changed_cb), sdialog); - - g_object_unref(gui); - - return w; -} - -static void -rootdn_changed_cb(GtkWidget *w, AddressbookSourceDialog *sdialog) -{ - url_changed(sdialog); -} - -static void -scope_optionmenu_changed_cb(GtkWidget *w, AddressbookSourceDialog *sdialog) -{ - sdialog->scope = gtk_option_menu_get_history((GtkOptionMenu *)w); - url_changed(sdialog); -} - -static GtkWidget * -eabc_details_search(EConfig *ec, EConfigItem *item, struct _GtkWidget *parent, struct _GtkWidget *old, void *data) -{ - AddressbookSourceDialog *sdialog = data; - GtkWidget *w; - LDAPURLDesc *lud; - char *uri; - GladeXML *gui; - - if (!source_group_is_remote(sdialog->source_group)) - return NULL; - - gui = glade_xml_new (EVOLUTION_GLADEDIR "/" GLADE_FILE_NAME, item->label, NULL); - w = glade_xml_get_widget(gui, item->label); - gtk_box_pack_start((GtkBox *)parent, w, FALSE, FALSE, 0); - - uri = e_source_get_uri(sdialog->source); - if (ldap_url_parse(uri, &lud) != LDAP_SUCCESS) - lud = NULL; - g_free(uri); - - sdialog->rootdn = glade_xml_get_widget (gui, "rootdn-entry"); - gtk_entry_set_text((GtkEntry *)sdialog->rootdn, lud && lud->lud_dn ? lud->lud_dn : ""); - g_signal_connect (sdialog->rootdn, "changed", G_CALLBACK (rootdn_changed_cb), sdialog); - - sdialog->scope_optionmenu = glade_xml_get_widget (gui, "scope-optionmenu"); - switch (lud->lud_scope) { - case LDAP_SCOPE_BASE: - sdialog->scope = ADDRESSBOOK_LDAP_SCOPE_BASE; - break; - default: - case LDAP_SCOPE_ONELEVEL: - sdialog->scope = ADDRESSBOOK_LDAP_SCOPE_ONELEVEL; - break; - case LDAP_SCOPE_SUBTREE: - sdialog->scope = ADDRESSBOOK_LDAP_SCOPE_SUBTREE; - break; - } - gtk_option_menu_set_history (GTK_OPTION_MENU(sdialog->scope_optionmenu), sdialog->scope); - g_signal_connect(sdialog->scope_optionmenu, "changed", G_CALLBACK(scope_optionmenu_changed_cb), sdialog); - - g_signal_connect (glade_xml_get_widget(gui, "rootdn-button"), "clicked", - G_CALLBACK(query_for_supported_bases), sdialog); - - if (lud) - ldap_free_urldesc (lud); - - g_object_unref(gui); - - return w; -} - -static void -timeout_changed_cb(GtkWidget *w, AddressbookSourceDialog *sdialog) -{ - char *timeout; - - timeout = g_strdup_printf("%f", gtk_adjustment_get_value(((GtkRange *)sdialog->timeout_scale)->adjustment)); - e_source_set_property(sdialog->source, "timeout", timeout); - g_free(timeout); -} - -static void -limit_changed_cb(GtkWidget *w, AddressbookSourceDialog *sdialog) -{ - char limit[16]; - - sprintf(limit, "%d", gtk_spin_button_get_value_as_int((GtkSpinButton *)sdialog->limit_spinbutton)); - e_source_set_property(sdialog->source, "limit", limit); -} - -static GtkWidget * -eabc_details_limit(EConfig *ec, EConfigItem *item, struct _GtkWidget *parent, struct _GtkWidget *old, void *data) -{ - AddressbookSourceDialog *sdialog = data; - GtkWidget *w; - const char *tmp; - GladeXML *gui; - - if (!source_group_is_remote(sdialog->source_group)) - return NULL; - - gui = glade_xml_new (EVOLUTION_GLADEDIR "/" GLADE_FILE_NAME, item->label, NULL); - w = glade_xml_get_widget(gui, item->label); - gtk_box_pack_start((GtkBox *)parent, w, FALSE, FALSE, 0); - - sdialog->timeout_scale = glade_xml_get_widget (gui, "timeout-scale"); - tmp = e_source_get_property(sdialog->source, "timeout"); - gtk_adjustment_set_value(((GtkRange *)sdialog->timeout_scale)->adjustment, tmp?g_strtod(tmp, NULL):3.0); - g_signal_connect (GTK_RANGE(sdialog->timeout_scale)->adjustment, "value_changed", G_CALLBACK (timeout_changed_cb), sdialog); - - sdialog->limit_spinbutton = glade_xml_get_widget (gui, "download-limit-spinbutton"); - tmp = e_source_get_property(sdialog->source, "limit"); - gtk_spin_button_set_value((GtkSpinButton *)sdialog->limit_spinbutton, tmp?g_strtod(tmp, NULL):100.0); - g_signal_connect (sdialog->limit_spinbutton, "changed", G_CALLBACK (limit_changed_cb), sdialog); - - g_object_unref(gui); - - return w; -} -#endif - -static EConfigItem eabc_items[] = { - { E_CONFIG_BOOK, "", }, - { E_CONFIG_PAGE, "00.general", N_("General") }, - { E_CONFIG_SECTION, "00.general/10.display", N_("Addressbook") }, - { E_CONFIG_ITEM, "00.general/10.display/10.name", "hbox122", eabc_general_name }, -#ifdef HAVE_LDAP - { E_CONFIG_SECTION, "00.general/20.server", N_("Server Information") }, - { E_CONFIG_ITEM, "00.general/20.server/00.host", "table31", eabc_general_host }, - { E_CONFIG_SECTION, "00.general/30.auth", N_("Authentication") }, - { E_CONFIG_ITEM, "00.general/30.auth/00.auth", "table32", eabc_general_auth }, - - { E_CONFIG_PAGE, "10.details", N_("Details") }, - { E_CONFIG_SECTION, "10.details/00.search", N_("Searching") }, - { E_CONFIG_ITEM, "10.details/00.search/00.search", "table33", eabc_details_search }, - { E_CONFIG_SECTION, "10.details/10.limit", N_("Downloading") }, - { E_CONFIG_ITEM, "10.details/10.limit/00.limit", "table34", eabc_details_limit }, -#endif - { 0 }, -}; - -/* items needed for the 'new addressbook' window */ -static EConfigItem eabc_new_items[] = { - { E_CONFIG_ITEM, "00.general/10.display/00.type", NULL, eabc_general_type }, - { 0 }, -}; - -static void -eabc_commit(EConfig *ec, GSList *items, void *data) -{ - AddressbookSourceDialog *sdialog = data; - xmlNodePtr xml; -#if d(!)0 - char *txt; -#endif - if (sdialog->original_source) { - d(printf("committing addressbook changes\n")); - - /* these api's kinda suck */ - xml = xmlNewNode(NULL, "dummy"); - e_source_dump_to_xml_node(sdialog->source, xml); - e_source_update_from_xml_node(sdialog->original_source, xml->children, NULL); - xmlFreeNode(xml); -#if d(!)0 - txt = e_source_to_standalone_xml(sdialog->original_source); - printf("source is now:\n%s\n", txt); - g_free(txt); -#endif - } else { - d(printf("committing new source\n")); - - e_source_group_add_source(sdialog->source_group, sdialog->source, -1); - e_source_list_sync(sdialog->source_list, NULL); - } - -#if d(!)0 - txt = e_source_to_standalone_xml(sdialog->source); - printf("running source is now:\n%s\n", txt); - g_free(txt); -#endif -} - -static void -eabc_free(EConfig *ec, GSList *items, void *data) -{ - AddressbookSourceDialog *sdialog = data; - - g_slist_free(items); - - g_object_unref(sdialog->source); - if (sdialog->original_source) - g_object_unref(sdialog->original_source); - if (sdialog->source_list) - g_object_unref(sdialog->source_list); - g_slist_free(sdialog->menu_source_groups); - - g_object_unref(sdialog->gui); - - g_free(sdialog); -} - -static gboolean -eabc_check_complete(EConfig *ec, const char *pageid, void *data) -{ - AddressbookSourceDialog *sdialog = data; - int valid = TRUE; - const char *tmp; - ESource *source; - - d(printf("check complete, pageid = '%s'\n", pageid?pageid:"<all>")); - /* have name, and unique */ - tmp = e_source_peek_name(sdialog->source); - valid = tmp && tmp[0] != 0 - && ((source = e_source_group_peek_source_by_name(sdialog->source_group, tmp)) == NULL - || source == sdialog->original_source); - -#ifdef HAVE_LDAP - if (valid && source_group_is_remote(sdialog->source_group)) { - char *uri = e_source_get_uri(sdialog->source); - LDAPURLDesc *lud; - - /* check host and port set */ - if (ldap_url_parse(uri, &lud) == LDAP_SUCCESS) { - valid = lud->lud_host != NULL - && lud->lud_host[0] != 0 - && lud->lud_port != 0; - ldap_free_urldesc (lud); - } else - valid = FALSE; - g_free(uri); - - /* check auth name provided if auth set */ - if (valid && (tmp = e_source_get_property(sdialog->source, "auth"))) { - switch (ldap_parse_auth(tmp)) { - case ADDRESSBOOK_LDAP_AUTH_SIMPLE_EMAIL: - tmp = e_source_get_property(sdialog->source, "email_addr"); - break; - case ADDRESSBOOK_LDAP_AUTH_SIMPLE_BINDDN: - tmp = e_source_get_property(sdialog->source, "binddn"); - break; - default: - tmp = "dummy"; - break; - } - valid = tmp && tmp[0]; - } - - /* check timeout isn't too short (why don't we just force it?) */ - if (valid) { - tmp = e_source_get_property(sdialog->source, "timeout"); - valid = tmp && g_strtod(tmp, NULL) > 0.0; - } - } -#endif - return valid; -} - -/* debug only: */ -#if d(!)0 -static void -source_changed(ESource *source, AddressbookSourceDialog *sdialog) -{ - char *xml; - - xml = e_source_to_standalone_xml(source); - printf("source changed:\n%s\n", xml); - g_free(xml); -} -#endif - -GtkWidget* -addressbook_config_edit_source (GtkWidget *parent, ESource *source) -{ - AddressbookSourceDialog *sdialog = g_new0 (AddressbookSourceDialog, 1); - EABConfig *ec; - int i; - GSList *items = NULL; - EABConfigTargetSource *target; - char *xml; - - sdialog->gui = glade_xml_new (EVOLUTION_GLADEDIR "/" GLADE_FILE_NAME, "account-editor-notebook", NULL); - - if (source) { - sdialog->original_source = source; - g_object_ref(source); - sdialog->source_group = e_source_peek_group (source); - xml = e_source_to_standalone_xml(source); - sdialog->source = e_source_new_from_standalone_xml(xml); - g_free(xml); - } else { - GConfClient *gconf; - GSList *l; - - sdialog->source = e_source_new("", ""); - gconf = gconf_client_get_default(); - sdialog->source_list = e_source_list_new_for_gconf(gconf, "/apps/evolution/addressbook/sources"); - l = e_source_list_peek_groups(sdialog->source_list); - sdialog->menu_source_groups = g_slist_copy(l); -#ifndef HAVE_LDAP - for (;l;l = g_slist_next(l)) - if (!strncmp("ldap:", e_source_group_peek_base_uri(l->data), 5)) - sdialog->menu_source_groups = g_slist_remove (sdialog->menu_source_groups, l->data); -#endif - sdialog->source_group = (ESourceGroup *)sdialog->menu_source_groups->data; - for (i=0;eabc_new_items[i].path;i++) - items = g_slist_prepend(items, &eabc_new_items[i]); - g_object_unref(gconf); - } - - /* HACK: doesn't work if you don't do this */ - e_source_set_absolute_uri(sdialog->source, NULL); - e_source_set_group(sdialog->source, sdialog->source_group); - -#if d(!)0 - xml = e_source_to_standalone_xml(sdialog->source); - printf("but working standalone xml: %s\n", xml); - g_free(xml); - g_signal_connect(sdialog->source, "changed", source_changed, sdialog); -#endif - - sdialog->config = ec = eab_config_new(E_CONFIG_BOOK, "com.novell.evolution.addressbook.config.accountEditor"); - - for (i=0;eabc_items[i].path;i++) - items = g_slist_prepend(items, &eabc_items[i]); - - e_config_add_items((EConfig *)ec, items, eabc_commit, NULL, eabc_free, sdialog); - e_config_add_page_check((EConfig *)ec, NULL, eabc_check_complete, sdialog); - - target = eab_config_target_new_source(ec, sdialog->source); - e_config_set_target((EConfig *)ec, (EConfigTarget *)target); - - sdialog->window = e_config_create_window((EConfig *)ec, NULL, _("Address Book Properties")); - - /* forces initial validation */ - if (!sdialog->original_source) - e_config_target_changed((EConfig *)ec, E_CONFIG_TARGET_CHANGED_STATE); - - return sdialog->window; -} diff --git a/addressbook/gui/component/addressbook-config.h b/addressbook/gui/component/addressbook-config.h deleted file mode 100644 index 8818fd08d7..0000000000 --- a/addressbook/gui/component/addressbook-config.h +++ /dev/null @@ -1,52 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* addressbook-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. - * - * Authors: - * Chris Toshok <toshok@ximian.com> - * Chris Lahey <clahey@ximian.com> - **/ - -#ifndef __ADDRESSBOOK_CONFIG_H__ -#define __ADDRESSBOOK_CONFIG_H__ - -#include "evolution-config-control.h" - -typedef enum { - ADDRESSBOOK_LDAP_AUTH_NONE, - ADDRESSBOOK_LDAP_AUTH_SIMPLE_EMAIL, - ADDRESSBOOK_LDAP_AUTH_SIMPLE_BINDDN, -} AddressbookLDAPAuthType; - -typedef enum { - ADDRESSBOOK_LDAP_SCOPE_ONELEVEL, - ADDRESSBOOK_LDAP_SCOPE_SUBTREE, - ADDRESSBOOK_LDAP_SCOPE_BASE, - ADDRESSBOOK_LDAP_SCOPE_LAST -} AddressbookLDAPScopeType; - -typedef enum { - ADDRESSBOOK_LDAP_SSL_ALWAYS, - ADDRESSBOOK_LDAP_SSL_WHENEVER_POSSIBLE, - ADDRESSBOOK_LDAP_SSL_NEVER -} AddressbookLDAPSSLType; - -GtkWidget* addressbook_config_edit_source (GtkWidget *parent, ESource *source); -GtkWidget* addressbook_config_create_new_source (GtkWidget *parent); - -#endif /* __ADDRESSBOOK_CONFIG_H__ */ diff --git a/addressbook/gui/component/addressbook-migrate.c b/addressbook/gui/component/addressbook-migrate.c deleted file mode 100644 index 087a867dbb..0000000000 --- a/addressbook/gui/component/addressbook-migrate.c +++ /dev/null @@ -1,1201 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2004, Novell, 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 (toshok@ximian.com) - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <glib.h> -#include <string.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <unistd.h> -#include <dirent.h> -#include <fcntl.h> -#include <errno.h> - -#include "addressbook-migrate.h" -#include "e-destination.h" -#include <libebook/e-book.h> -#include <libgnome/gnome-i18n.h> -#include <gal/util/e-util.h> -#include <gal/util/e-xml-utils.h> -#include <gtk/gtkwidget.h> -#include <gtk/gtkvbox.h> -#include <gtk/gtkmain.h> -#include <gtk/gtklabel.h> -#include <gtk/gtkprogressbar.h> -#include <e-util/e-folder-map.h> - -/*#define SLOW_MIGRATION*/ - -typedef struct { - /* this hash table maps old folder uris to new uids. It's - build in migrate_contact_folder and it's used in - migrate_completion_folders. */ - GHashTable *folder_uid_map; - - ESourceList *source_list; - - AddressbookComponent *component; - - GtkWidget *window; - GtkWidget *label; - GtkWidget *folder_label; - GtkWidget *progress; -} MigrationContext; - -static void -setup_progress_dialog (MigrationContext *context) -{ - GtkWidget *vbox, *hbox; - - context->window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - gtk_window_set_title (GTK_WINDOW (context->window), _("Migrating...")); - gtk_window_set_modal (GTK_WINDOW (context->window), TRUE); - gtk_container_set_border_width (GTK_CONTAINER (context->window), 6); - - vbox = gtk_vbox_new (FALSE, 6); - gtk_widget_show (vbox); - gtk_container_add (GTK_CONTAINER (context->window), vbox); - - context->label = gtk_label_new (""); - gtk_label_set_line_wrap (GTK_LABEL (context->label), TRUE); - gtk_widget_show (context->label); - gtk_box_pack_start_defaults (GTK_BOX (vbox), context->label); - - hbox = gtk_hbox_new (FALSE, 6); - gtk_widget_show (hbox); - gtk_box_pack_start_defaults (GTK_BOX (vbox), hbox); - - context->folder_label = gtk_label_new (""); - gtk_widget_show (context->folder_label); - gtk_box_pack_start_defaults (GTK_BOX (hbox), context->folder_label); - - context->progress = gtk_progress_bar_new (); - gtk_widget_show (context->progress); - gtk_box_pack_start_defaults (GTK_BOX (hbox), context->progress); - - gtk_widget_show (context->window); -} - -static void -dialog_close (MigrationContext *context) -{ - gtk_widget_destroy (context->window); -} - -static void -dialog_set_label (MigrationContext *context, const char *str) -{ - gtk_label_set_text (GTK_LABEL (context->label), str); - - while (gtk_events_pending ()) - gtk_main_iteration (); - -#ifdef SLOW_MIGRATION - sleep (1); -#endif -} - -static void -dialog_set_folder_name (MigrationContext *context, const char *folder_name) -{ - char *text; - - text = g_strdup_printf (_("Migrating `%s':"), folder_name); - gtk_label_set_text (GTK_LABEL (context->folder_label), text); - g_free (text); - - gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (context->progress), 0.0); - - while (gtk_events_pending ()) - gtk_main_iteration (); - -#ifdef SLOW_MIGRATION - sleep (1); -#endif -} - -static void -dialog_set_progress (MigrationContext *context, double percent) -{ - char text[5]; - - snprintf (text, sizeof (text), "%d%%", (int) (percent * 100.0f)); - - gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (context->progress), percent); - gtk_progress_bar_set_text (GTK_PROGRESS_BAR (context->progress), text); - - while (gtk_events_pending ()) - gtk_main_iteration (); - -#ifdef SLOW_MIGRATION - sleep (1); -#endif -} - -static gboolean -check_for_conflict (ESourceGroup *group, char *name) -{ - GSList *sources; - GSList *s; - - sources = e_source_group_peek_sources (group); - - for (s = sources; s; s = s->next) { - ESource *source = E_SOURCE (s->data); - - if (!strcmp (e_source_peek_name (source), name)) - return TRUE; - } - - return FALSE; -} - -static char * -get_source_name (ESourceGroup *group, const char *path) -{ - char **p = g_strsplit (path, "/", 0); - int i, j, starting_index; - int num_elements; - gboolean conflict; - GString *s = g_string_new (""); - - for (i = 0; p[i]; i ++) ; - - num_elements = i; - i--; - - /* p[i] is now the last path element */ - - /* check if it conflicts */ - starting_index = i; - do { - g_string_assign (s, ""); - for (j = starting_index; j < num_elements; j += 2) { - if (j != starting_index) - g_string_append_c (s, '_'); - g_string_append (s, p[j]); - } - - conflict = check_for_conflict (group, s->str); - - - /* if there was a conflict back up 2 levels (skipping the /subfolder/ element) */ - if (conflict) - starting_index -= 2; - - /* we always break out if we can't go any further, - regardless of whether or not we conflict. */ - if (starting_index < 0) - break; - - } while (conflict); - - return g_string_free (s, FALSE); -} - -static void -add_to_notes (EContact *contact, EContactField field) -{ - const gchar *old_text; - const gchar *field_text; - gchar *new_text; - - old_text = e_contact_get_const (contact, E_CONTACT_NOTE); - if (old_text && strstr (old_text, e_contact_pretty_name (field))) - return; - - field_text = e_contact_get_const (contact, field); - if (!field_text || !*field_text) - return; - - new_text = g_strdup_printf ("%s%s%s: %s", - old_text ? old_text : "", - old_text && *old_text && - *(old_text + strlen (old_text) - 1) != '\n' ? "\n" : "", - e_contact_pretty_name (field), field_text); - e_contact_set (contact, E_CONTACT_NOTE, new_text); - g_free (new_text); -} - -static void -migrate_contacts (MigrationContext *context, EBook *old_book, EBook *new_book) -{ - EBookQuery *query = e_book_query_any_field_contains (""); - GList *l, *contacts; - int num_added = 0; - int num_contacts; - - /* both books are loaded, start the actual migration */ - e_book_get_contacts (old_book, query, &contacts, NULL); - - num_contacts = g_list_length (contacts); - for (l = contacts; l; l = l->next) { - EContact *contact = l->data; - GError *e = NULL; - GList *attrs, *attr; - - /* do some last minute massaging of the contact's attributes */ - - attrs = e_vcard_get_attributes (E_VCARD (contact)); - for (attr = attrs; attr;) { - EVCardAttribute *a = attr->data; - - /* evo 1.4 used the non-standard X-EVOLUTION-OFFICE attribute, - evo 1.5 uses the third element in the ORG list attribute. */ - if (!strcmp ("X-EVOLUTION-OFFICE", e_vcard_attribute_get_name (a))) { - GList *v = e_vcard_attribute_get_values (a); - GList *next_attr; - - if (v && v->data) - e_contact_set (contact, E_CONTACT_OFFICE, v->data); - - next_attr = attr->next; - e_vcard_remove_attribute (E_VCARD (contact), a); - attr = next_attr; - } - /* evo 1.4 didn't put TYPE=VOICE in for phone numbers. - evo 1.5 does. - - so we search through the attribute params for - either TYPE=VOICE or TYPE=FAX. If we find - either we do nothing. If we find neither, we - add TYPE=VOICE. - */ - else if (!strcmp ("TEL", e_vcard_attribute_get_name (a))) { - GList *params, *param; - gboolean found = FALSE; - - params = e_vcard_attribute_get_params (a); - for (param = params; param; param = param->next) { - EVCardAttributeParam *p = param->data; - if (!strcmp (EVC_TYPE, e_vcard_attribute_param_get_name (p))) { - GList *v = e_vcard_attribute_param_get_values (p); - if (v && v->data) - if (!strcmp ("VOICE", v->data) - || !strcmp ("FAX", v->data)) - found = TRUE; - } - } - - if (!found) - e_vcard_attribute_add_param_with_value (a, - e_vcard_attribute_param_new (EVC_TYPE), - "VOICE"); - attr = attr->next; - } - /* Replace "POSTAL" (1.4) addresses with "OTHER" (1.5) */ - else if (!strcmp ("ADR", e_vcard_attribute_get_name (a))) { - GList *params, *param; - gboolean found = FALSE; - EVCardAttributeParam *p; - - params = e_vcard_attribute_get_params (a); - for (param = params; param; param = param->next) { - p = param->data; - if (!strcmp (EVC_TYPE, e_vcard_attribute_param_get_name (p))) { - GList *v = e_vcard_attribute_param_get_values (p); - if (v && v->data && !strcmp ("POSTAL", v->data)) { - found = TRUE; - break; - } - } - } - - if (found) { - e_vcard_attribute_param_remove_values (p); - e_vcard_attribute_param_add_value (p, "OTHER"); - } - - attr = attr->next; - } - /* this is kinda gross. The new vcard parser - needs ';'s to be escaped by \'s. but the - 1.4 vcard generator would put unescaped xml - (including entities like >) in the value - of attributes, so we need to go through and - escape those ';'s. */ - else if (!strcmp ("EMAIL", e_vcard_attribute_get_name (a))) { - GList *v = e_vcard_attribute_get_values (a); - - if (v && v->data) { - if (!strncmp ((char*)v->data, "<?xml", 5)) { - /* k, this is the nasty part. we glomb all the - value strings back together again (if there is - more than one), then work our magic */ - GString *str = g_string_new (""); - while (v) { - g_string_append (str, v->data); - if (v->next) - g_string_append_c (str, ';'); - v = v->next; - } - - e_vcard_attribute_remove_values (a); - e_vcard_attribute_add_value (a, str->str); - g_string_free (str, TRUE); - } - } - - attr = attr->next; - } - else { - attr = attr->next; - } - } - - if (!e_book_add_contact (new_book, - contact, - &e)) - g_warning ("contact add failed: `%s'", e->message); - - num_added ++; - - dialog_set_progress (context, (double)num_added / num_contacts); - } - - g_list_foreach (contacts, (GFunc)g_object_unref, NULL); - g_list_free (contacts); -} - -static void -migrate_contact_folder_to_source (MigrationContext *context, char *old_path, ESource *new_source) -{ - char *old_uri = g_strdup_printf ("file://%s", old_path); - GError *e = NULL; - - EBook *old_book = NULL, *new_book = NULL; - ESource *old_source; - ESourceGroup *group; - - group = e_source_group_new ("", old_uri); - old_source = e_source_new ("", ""); - e_source_group_add_source (group, old_source, -1); - - dialog_set_folder_name (context, e_source_peek_name (new_source)); - - old_book = e_book_new (old_source, &e); - if (!old_book - || !e_book_open (old_book, TRUE, &e)) { - g_warning ("failed to load source book for migration: `%s'", e->message); - goto finish; - } - - new_book = e_book_new (new_source, &e); - if (!new_book - || !e_book_open (new_book, FALSE, &e)) { - g_warning ("failed to load destination book for migration: `%s'", e->message); - goto finish; - } - - migrate_contacts (context, old_book, new_book); - - finish: - g_object_unref (old_source); - g_object_unref (group); - if (old_book) - g_object_unref (old_book); - if (new_book) - g_object_unref (new_book); - g_free (old_uri); -} - -static void -migrate_contact_folder (MigrationContext *context, char *old_path, ESourceGroup *dest_group, char *source_name) -{ - ESource *new_source; - - new_source = e_source_new (source_name, source_name); - e_source_set_relative_uri (new_source, e_source_peek_uid (new_source)); - e_source_group_add_source (dest_group, new_source, -1); - - g_hash_table_insert (context->folder_uid_map, g_strdup (old_path), g_strdup (e_source_peek_uid (new_source))); - - migrate_contact_folder_to_source (context, old_path, new_source); - - g_object_unref (new_source); -} - -#define LDAP_BASE_URI "ldap://" -#define PERSONAL_RELATIVE_URI "system" - -static void -create_groups (MigrationContext *context, - ESourceGroup **on_this_computer, - ESourceGroup **on_ldap_servers, - ESource **personal_source) -{ - GSList *groups; - ESourceGroup *group; - char *base_uri, *base_uri_proto; - - *on_this_computer = NULL; - *on_ldap_servers = NULL; - *personal_source = NULL; - - base_uri = g_build_filename (addressbook_component_peek_base_directory (context->component), - "addressbook", "local", - NULL); - - base_uri_proto = g_strconcat ("file://", base_uri, NULL); - - groups = e_source_list_peek_groups (context->source_list); - if (groups) { - /* groups are already there, we need to search for things... */ - GSList *g; - - for (g = groups; g; g = g->next) { - - group = E_SOURCE_GROUP (g->data); - - if (!*on_this_computer && !strcmp (base_uri_proto, e_source_group_peek_base_uri (group))) - *on_this_computer = g_object_ref (group); - else if (!*on_ldap_servers && !strcmp (LDAP_BASE_URI, e_source_group_peek_base_uri (group))) - *on_ldap_servers = g_object_ref (group); - } - } - - if (*on_this_computer) { - /* make sure "Personal" shows up as a source under - this group */ - GSList *sources = e_source_group_peek_sources (*on_this_computer); - GSList *s; - for (s = sources; s; s = s->next) { - ESource *source = E_SOURCE (s->data); - if (!strcmp (PERSONAL_RELATIVE_URI, e_source_peek_relative_uri (source))) { - *personal_source = g_object_ref (source); - break; - } - } - } - else { - /* create the local source group */ - group = e_source_group_new (_("On This Computer"), base_uri_proto); - e_source_list_add_group (context->source_list, group, -1); - - *on_this_computer = group; - } - - if (!*personal_source) { - /* Create the default Person addressbook */ - ESource *source = e_source_new (_("Personal"), PERSONAL_RELATIVE_URI); - e_source_group_add_source (*on_this_computer, source, -1); - - *personal_source = source; - } - - if (!*on_ldap_servers) { - /* Create the LDAP source group */ - group = e_source_group_new (_("On LDAP Servers"), LDAP_BASE_URI); - e_source_list_add_group (context->source_list, group, -1); - - *on_ldap_servers = group; - } - - g_free (base_uri_proto); - g_free (base_uri); -} - -static gboolean -migrate_local_folders (MigrationContext *context, ESourceGroup *on_this_computer, ESource *personal_source) -{ - char *old_path = NULL; - GSList *dirs, *l; - char *local_contact_folder = NULL; - - old_path = g_strdup_printf ("%s/evolution/local", g_get_home_dir ()); - - dirs = e_folder_map_local_folders (old_path, "contacts"); - - /* migrate the local addressbook first, to local/system */ - local_contact_folder = g_build_filename (g_get_home_dir (), - "evolution", "local", "Contacts", - NULL); - - for (l = dirs; l; l = l->next) { - char *source_name; - /* we handle the system folder differently */ - if (personal_source && !strcmp ((char*)l->data, local_contact_folder)) { - g_hash_table_insert (context->folder_uid_map, g_strdup (l->data), g_strdup (e_source_peek_uid (personal_source))); - migrate_contact_folder_to_source (context, local_contact_folder, personal_source); - continue; - } - - source_name = get_source_name (on_this_computer, (char*)l->data); - migrate_contact_folder (context, l->data, on_this_computer, source_name); - g_free (source_name); - } - - g_slist_foreach (dirs, (GFunc)g_free, NULL); - g_slist_free (dirs); - g_free (local_contact_folder); - g_free (old_path); - - return TRUE; -} - -static char * -get_string_child (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) /* there's no text between the tags, return the empty string */ - return g_strdup(""); - - xml_string = xmlNodeListGetString (node->doc, p, 1); - retval = g_strdup ((char *) xml_string); - xmlFree (xml_string); - - return retval; -} - -static int -get_integer_child (xmlNode *node, - const char *name, - int defval) -{ - xmlNode *p; - xmlChar *xml_string; - int retval; - - p = e_xml_get_child_by_name (node, (xmlChar *) name); - if (p == NULL) - return defval; - - p = e_xml_get_child_by_name (p, (xmlChar *) "text"); - if (p == NULL) /* there's no text between the tags, return the default */ - return defval; - - xml_string = xmlNodeListGetString (node->doc, p, 1); - retval = atoi (xml_string); - xmlFree (xml_string); - - return retval; -} - -static gboolean -migrate_ldap_servers (MigrationContext *context, ESourceGroup *on_ldap_servers) -{ - char *sources_xml = g_strdup_printf ("%s/evolution/addressbook-sources.xml", - g_get_home_dir ()); - - printf ("trying to migrate from %s\n", sources_xml); - - if (g_file_test (sources_xml, G_FILE_TEST_EXISTS)) { - xmlDoc *doc = xmlParseFile (sources_xml); - xmlNode *root; - xmlNode *child; - int num_contactservers; - int servernum; - - if (!doc) - return FALSE; - - root = xmlDocGetRootElement (doc); - if (root == NULL || strcmp (root->name, "addressbooks") != 0) { - xmlFreeDoc (doc); - return FALSE; - } - - /* count the number of servers, so we can give progress */ - num_contactservers = 0; - for (child = root->children; child; child = child->next) { - if (!strcmp (child->name, "contactserver")) { - num_contactservers++; - } - } - printf ("found %d contact servers to migrate\n", num_contactservers); - - dialog_set_folder_name (context, _("LDAP Servers")); - - servernum = 0; - for (child = root->children; child; child = child->next) { - if (!strcmp (child->name, "contactserver")) { - char *port, *host, *rootdn, *scope, *authmethod, *ssl; - char *emailaddr, *binddn, *limitstr; - int limit; - char *name, *description; - GString *uri = g_string_new (""); - ESource *source; - - name = get_string_child (child, "name"); - description = get_string_child (child, "description"); - port = get_string_child (child, "port"); - host = get_string_child (child, "host"); - rootdn = get_string_child (child, "rootdn"); - scope = get_string_child (child, "scope"); - authmethod = get_string_child (child, "authmethod"); - ssl = get_string_child (child, "ssl"); - emailaddr = get_string_child (child, "emailaddr"); - binddn = get_string_child (child, "binddn"); - limit = get_integer_child (child, "limit", 100); - limitstr = g_strdup_printf ("%d", limit); - - g_string_append_printf (uri, - "%s:%s/%s?"/*trigraph prevention*/"?%s", - host, port, rootdn, scope); - - source = e_source_new (name, uri->str); - e_source_set_property (source, "description", description); - e_source_set_property (source, "limit", limitstr); - e_source_set_property (source, "ssl", ssl); - e_source_set_property (source, "auth", authmethod); - if (emailaddr) - e_source_set_property (source, "email_addr", emailaddr); - if (binddn) - e_source_set_property (source, "binddn", binddn); - - e_source_group_add_source (on_ldap_servers, source, -1); - - g_string_free (uri, TRUE); - g_free (port); - g_free (host); - g_free (rootdn); - g_free (scope); - g_free (authmethod); - g_free (ssl); - g_free (emailaddr); - g_free (binddn); - g_free (limitstr); - g_free (name); - g_free (description); - - servernum++; - dialog_set_progress (context, (double)servernum/num_contactservers); - } - } - - xmlFreeDoc (doc); - } - - g_free (sources_xml); - - return TRUE; -} - -static ESource* -get_source_by_name (ESourceList *source_list, const char *name) -{ - GSList *groups; - GSList *g; - - groups = e_source_list_peek_groups (source_list); - if (!groups) - return NULL; - - for (g = groups; g; g = g->next) { - GSList *sources; - GSList *s; - ESourceGroup *group = E_SOURCE_GROUP (g->data); - - sources = e_source_group_peek_sources (group); - if (!sources) - continue; - - for (s = sources; s; s = s->next) { - ESource *source = E_SOURCE (s->data); - const char *source_name = e_source_peek_name (source); - - if (!strcmp (name, source_name)) - return source; - } - } - - return NULL; -} - -static gboolean -migrate_completion_folders (MigrationContext *context) -{ - char *uris_xml = gconf_client_get_string (addressbook_component_peek_gconf_client (context->component), - "/apps/evolution/addressbook/completion/uris", - NULL); - - printf ("trying to migrate completion folders\n"); - - if (uris_xml) { - xmlDoc *doc = xmlParseMemory (uris_xml, strlen (uris_xml)); - xmlNode *root; - xmlNode *child; - - if (!doc) - return FALSE; - - dialog_set_folder_name (context, _("Autocompletion Settings")); - - root = xmlDocGetRootElement (doc); - if (root == NULL || strcmp (root->name, "EvolutionFolderList") != 0) { - xmlFreeDoc (doc); - return FALSE; - } - - for (child = root->children; child; child = child->next) { - if (!strcmp (child->name, "folder")) { - char *physical_uri = e_xml_get_string_prop_by_name (child, "physical-uri"); - ESource *source = NULL; - - /* if the physical uri is file://... - we look it up in our folder_uid_map - hashtable. If it's a folder we - converted over, we should get back - a uid we can search for. - - if the physical_uri is anything - else, we strip off the args - (anything after ;) before searching - for the uri. */ - - if (!strncmp (physical_uri, "file://", 7)) { - char *uid = g_hash_table_lookup (context->folder_uid_map, - physical_uri + 7); - - if (uid) - source = e_source_list_peek_source_by_uid (context->source_list, uid); - } - else { - char *name = e_xml_get_string_prop_by_name (child, "display-name"); - - source = get_source_by_name (context->source_list, name); - - g_free (name); - } - - if (source) { - e_source_set_property (source, "completion", "true"); - } - else { - g_warning ("found completion folder with uri `%s' that " - "doesn't correspond to anything we migrated.", physical_uri); - } - - g_free (physical_uri); - } - } - - g_free (uris_xml); - } - else { - g_message ("no completion folder settings to migrate"); - } - - return TRUE; -} - -static void -migrate_contact_lists_for_local_folders (MigrationContext *context, ESourceGroup *on_this_computer) -{ - GSList *sources, *s; - - sources = e_source_group_peek_sources (on_this_computer); - for (s = sources; s; s = s->next) { - ESource *source = s->data; - EBook *book; - EBookQuery *query; - GList *l, *contacts; - int num_contacts, num_converted; - - dialog_set_folder_name (context, e_source_peek_name (source)); - - book = e_book_new (source, NULL); - if (!book - || !e_book_open (book, TRUE, NULL)) { - char *uri = e_source_get_uri (source); - g_warning ("failed to migrate contact lists for source %s", uri); - g_free (uri); - continue; - } - - query = e_book_query_any_field_contains (""); - - e_book_get_contacts (book, query, &contacts, NULL); - - num_converted = 0; - num_contacts = g_list_length (contacts); - for (l = contacts; l; l = l->next) { - EContact *contact = l->data; - GError *e = NULL; - GList *attrs, *attr; - gboolean converted = FALSE; - - attrs = e_contact_get_attributes (contact, E_CONTACT_EMAIL); - for (attr = attrs; attr; attr = attr->next) { - EVCardAttribute *a = attr->data; - GList *v = e_vcard_attribute_get_values (a); - - if (v && v->data) { - if (!strncmp ((char*)v->data, "<?xml", 5)) { - EDestination *dest = e_destination_import ((char*)v->data); - - e_destination_export_to_vcard_attribute (dest, a); - - g_object_unref (dest); - - converted = TRUE; - } - } - } - - if (converted) { - e_contact_set_attributes (contact, E_CONTACT_EMAIL, attrs); - - if (!e_book_commit_contact (book, - contact, - &e)) - g_warning ("contact commit failed: `%s'", e->message); - } - - num_converted ++; - - dialog_set_progress (context, (double)num_converted / num_contacts); - } - - g_list_foreach (contacts, (GFunc)g_object_unref, NULL); - g_list_free (contacts); - - g_object_unref (book); - } -} - -static void -migrate_company_phone_for_local_folders (MigrationContext *context, ESourceGroup *on_this_computer) -{ - GSList *sources, *s; - - sources = e_source_group_peek_sources (on_this_computer); - for (s = sources; s; s = s->next) { - ESource *source = s->data; - EBook *book; - EBookQuery *query; - GList *l, *contacts; - int num_contacts, num_converted; - - dialog_set_folder_name (context, e_source_peek_name (source)); - - book = e_book_new (source, NULL); - if (!book - || !e_book_open (book, TRUE, NULL)) { - char *uri = e_source_get_uri (source); - g_warning ("failed to migrate company phone numbers for source %s", uri); - g_free (uri); - continue; - } - - query = e_book_query_any_field_contains (""); - - e_book_get_contacts (book, query, &contacts, NULL); - - num_converted = 0; - num_contacts = g_list_length (contacts); - for (l = contacts; l; l = l->next) { - EContact *contact = l->data; - GError *e = NULL; - GList *attrs, *attr; - gboolean converted = FALSE; - int num_work_voice = 0; - - attrs = e_vcard_get_attributes (E_VCARD (contact)); - for (attr = attrs; attr;) { - EVCardAttribute *a = attr->data; - GList *next_attr = attr->next; - - if (!strcmp ("TEL", e_vcard_attribute_get_name (a))) { - GList *params, *param; - gboolean found_voice = FALSE; - gboolean found_work = FALSE; - - params = e_vcard_attribute_get_params (a); - for (param = params; param; param = param->next) { - EVCardAttributeParam *p = param->data; - if (!strcmp (EVC_TYPE, e_vcard_attribute_param_get_name (p))) { - GList *v = e_vcard_attribute_param_get_values (p); - if (v && v->data) { - if (!strcmp ("VOICE", v->data)) - found_voice = TRUE; - else if (!strcmp ("WORK", v->data)) - found_work = TRUE; - } - } - - if (found_work && found_voice) - num_work_voice++; - - if (num_work_voice == 3) { - GList *v = e_vcard_attribute_get_values (a); - - if (v && v->data) - e_contact_set (contact, E_CONTACT_PHONE_COMPANY, v->data); - - e_vcard_remove_attribute (E_VCARD (contact), a); - - converted = TRUE; - break; - } - } - } - - attr = next_attr; - - if (converted) - break; - } - - if (converted) { - if (!e_book_commit_contact (book, - contact, - &e)) - g_warning ("contact commit failed: `%s'", e->message); - } - - num_converted ++; - - dialog_set_progress (context, (double)num_converted / num_contacts); - } - - g_list_foreach (contacts, (GFunc)g_object_unref, NULL); - g_list_free (contacts); - - g_object_unref (book); - } -} - -static void -migrate_pilot_data (const char *old_path, const char *new_path) -{ - struct dirent *dent; - const char *ext; - char *filename; - DIR *dir; - - if (!(dir = opendir (old_path))) - return; - - while ((dent = readdir (dir))) { - if ((!strncmp (dent->d_name, "pilot-map-", 10) && - ((ext = strrchr (dent->d_name, '.')) && !strcmp (ext, ".xml"))) || - (!strncmp (dent->d_name, "pilot-sync-evolution-addressbook-", 33) && - ((ext = strrchr (dent->d_name, '.')) && !strcmp (ext, ".db")))) { - /* src and dest file formats are identical for both map and changelog files */ - unsigned char inbuf[4096]; - size_t nread, nwritten; - int fd0, fd1; - ssize_t n; - - filename = g_build_filename (old_path, dent->d_name, NULL); - if ((fd0 = open (filename, O_RDONLY)) == -1) { - g_free (filename); - continue; - } - - g_free (filename); - filename = g_build_filename (new_path, dent->d_name, NULL); - if ((fd1 = open (filename, O_WRONLY | O_CREAT | O_TRUNC, 0666)) == -1) { - g_free (filename); - close (fd0); - continue; - } - - do { - do { - n = read (fd0, inbuf, sizeof (inbuf)); - } while (n == -1 && errno == EINTR); - - if (n < 1) - break; - - nread = n; - nwritten = 0; - do { - do { - n = write (fd1, inbuf + nwritten, nread - nwritten); - } while (n == -1 && errno == EINTR); - - if (n > 0) - nwritten += n; - } while (nwritten < nread && n != -1); - - if (n == -1) - break; - } while (1); - - if (n != -1) - n = fsync (fd1); - - if (n == -1) { - g_warning ("Failed to migrate %s: %s", dent->d_name, strerror (errno)); - unlink (filename); - } - - close (fd0); - close (fd1); - g_free (filename); - } - } - - closedir (dir); -} - -static MigrationContext* -migration_context_new (AddressbookComponent *component) -{ - MigrationContext *context = g_new (MigrationContext, 1); - - /* set up the mapping from old uris to new uids */ - context->folder_uid_map = g_hash_table_new_full (g_str_hash, g_str_equal, (GDestroyNotify)g_free, (GDestroyNotify)g_free); - - e_book_get_addressbooks (&context->source_list, NULL); - - context->component = component; - - return context; -} - -static void -migration_context_free (MigrationContext *context) -{ - e_source_list_sync (context->source_list, NULL); - - g_hash_table_destroy (context->folder_uid_map); - - g_object_unref (context->source_list); - - g_free (context); -} - -int -addressbook_migrate (AddressbookComponent *component, int major, int minor, int revision, GError **err) -{ - ESourceGroup *on_this_computer; - ESourceGroup *on_ldap_servers; - ESource *personal_source; - MigrationContext *context = migration_context_new (component); - gboolean need_dialog = FALSE; - - printf ("addressbook_migrate (%d.%d.%d)\n", major, minor, revision); - - /* we call this unconditionally now - create_groups either - creates the groups/sources or it finds the necessary - groups/sources. */ - create_groups (context, &on_this_computer, &on_ldap_servers, &personal_source); - - /* figure out if we need the dialog displayed */ - if (major == 1 - /* we only need the most recent upgrade point here. - further decomposition will happen below. */ - && (minor < 5 || (minor == 5 && revision <= 10))) - need_dialog = TRUE; - - if (need_dialog) - setup_progress_dialog (context); - - if (major == 1) { - - if (minor < 5 || (minor == 5 && revision <= 2)) { - /* initialize our dialog */ - dialog_set_label (context, - _("The location and hierarchy of the Evolution contact " - "folders has changed since Evolution 1.x.\n\nPlease be " - "patient while Evolution migrates your folders...")); - - if (on_this_computer) - migrate_local_folders (context, on_this_computer, personal_source); - if (on_ldap_servers) - migrate_ldap_servers (context, on_ldap_servers); - - migrate_completion_folders (context); - } - - if (minor < 5 || (minor == 5 && revision <= 7)) { - dialog_set_label (context, - _("The format of mailing list contacts has changed.\n\n" - "Please be patient while Evolution migrates your " - "folders...")); - - migrate_contact_lists_for_local_folders (context, on_this_computer); - } - - if (minor < 5 || (minor == 5 && revision <= 8)) { - dialog_set_label (context, - _("The way Evolution stores some phone numbers has changed.\n\n" - "Please be patient while Evolution migrates your " - "folders...")); - - migrate_company_phone_for_local_folders (context, on_this_computer); - } - - if (minor < 5 || (minor == 5 && revision <= 10)) { - char *old_path, *new_path; - - dialog_set_label (context, _("Evolution's Palm Sync changelog and map files have changed.\n\n" - "Please be patient while Evolution migrates your Pilot Sync data...")); - - old_path = g_build_filename (g_get_home_dir (), "evolution", "local", "Contacts", NULL); - new_path = g_build_filename (addressbook_component_peek_base_directory (component), - "addressbook", "local", "system", NULL); - migrate_pilot_data (old_path, new_path); - g_free (new_path); - g_free (old_path); - } - - /* we only need to do this next step if people ran - older versions of 1.5. We need to clear out the - absolute URI's that were assigned to ESources - during one phase of development, as they take - precedent over relative uris (but aren't updated - when editing an ESource). */ - if (minor == 5 && revision <= 11) { - GSList *g; - for (g = e_source_list_peek_groups (context->source_list); g; g = g->next) { - ESourceGroup *group = g->data; - GSList *s; - - for (s = e_source_group_peek_sources (group); s; s = s->next) { - ESource *source = s->data; - e_source_set_absolute_uri (source, NULL); - } - } - } - } - - if (need_dialog) - dialog_close (context); - - if (on_this_computer) - g_object_unref (on_this_computer); - if (on_ldap_servers) - g_object_unref (on_ldap_servers); - if (personal_source) - g_object_unref (personal_source); - - - migration_context_free (context); - - return TRUE; -} diff --git a/addressbook/gui/component/addressbook-migrate.h b/addressbook/gui/component/addressbook-migrate.h deleted file mode 100644 index dc7c473e12..0000000000 --- a/addressbook/gui/component/addressbook-migrate.h +++ /dev/null @@ -1,31 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Copyright (C) 2004, Novell, 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 (toshok@ximian.com) - */ - -#ifndef _ADDRESSBOOK_MIGRATE_H_ -#define _ADDRESSBOOK_MIGRATE_H_ - -#include "addressbook-component.h" - -struct _GError; - -int addressbook_migrate (AddressbookComponent *component, int major, int minor, int revision, struct _GError **err); - -#endif /* _ADDRESSBOOK_MIGRATE_H_ */ diff --git a/addressbook/gui/component/addressbook-view.c b/addressbook/gui/component/addressbook-view.c deleted file mode 100644 index 48a912c062..0000000000 --- a/addressbook/gui/component/addressbook-view.c +++ /dev/null @@ -1,1396 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* addressbook-view.c - * - * Copyright (C) 2000, 2001, 2002, 2003 Ximian, Inc. - * Copyright (C) 2004 Novell, 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 (toshok@ximian.com) - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <string.h> -#include <glib.h> -#include <gtk/gtkvbox.h> -#include <gtk/gtknotebook.h> -#include <gtk/gtkwidget.h> -#include <gtk/gtkmessagedialog.h> -#include <libgnome/gnome-i18n.h> -#include <libgnomeui/gnome-app.h> -#include <libgnomeui/gnome-href.h> -#include <libgnomeui/gnome-uidefs.h> -#include <bonobo/bonobo-generic-factory.h> -#include <bonobo/bonobo-ui-util.h> -#include <bonobo/bonobo-exception.h> -#include <gal/util/e-util.h> -#include <libedataserverui/e-source-selector.h> - -#include "widgets/misc/e-error.h" -#include "widgets/misc/e-task-bar.h" -#include "widgets/misc/e-info-label.h" - - -#include "e-util/e-passwords.h" -#include "e-util/e-icon-factory.h" -#include "shell/e-user-creatable-items-handler.h" - -#include "evolution-shell-component-utils.h" -#include "e-activity-handler.h" -#include "e-contact-editor.h" -#include "addressbook-config.h" -#include "addressbook.h" -#include "addressbook-view.h" -#include "addressbook-component.h" -#include "addressbook/gui/search/e-addressbook-search-dialog.h" -#include "addressbook/gui/widgets/e-addressbook-view.h" -#include "addressbook/gui/widgets/eab-gui-util.h" -#include "addressbook/gui/merging/eab-contact-merging.h" -#include "addressbook/printing/e-contact-print.h" -#include "addressbook/util/eab-book-util.h" -#include "addressbook/gui/widgets/eab-popup.h" -#include "addressbook/gui/widgets/eab-menu.h" - -#define PARENT_TYPE G_TYPE_OBJECT -static GObjectClass *parent_class = NULL; - -/* This is used for the addressbook status bar */ -#define EVOLUTION_CONTACTS_PROGRESS_IMAGE "stock_contact" -static GdkPixbuf *progress_icon = NULL; - -#define d(x) - -struct _AddressbookViewPrivate { - GtkWidget *notebook; - BonoboControl *folder_view_control; - - GtkWidget *statusbar_widget; - EActivityHandler *activity_handler; - - GtkWidget *info_widget; - GtkWidget *sidebar_widget; - GtkWidget *selector; - - GConfClient *gconf_client; - - GHashTable *uid_to_view; - GHashTable *uid_to_editor; - - EBook *book; - guint activity_id; - ESourceList *source_list; - char *passwd; - EUserCreatableItemsHandler *creatable_items_handler; - - EABMenu *menu; -}; - -enum DndTargetType { - DND_TARGET_TYPE_VCARD_LIST, - DND_TARGET_TYPE_SOURCE_VCARD_LIST -}; -#define VCARD_TYPE "text/x-vcard" -#define SOURCE_VCARD_TYPE "text/x-source-vcard" -static GtkTargetEntry drag_types[] = { - { SOURCE_VCARD_TYPE, 0, DND_TARGET_TYPE_SOURCE_VCARD_LIST }, - { VCARD_TYPE, 0, DND_TARGET_TYPE_VCARD_LIST } -}; -static gint num_drag_types = sizeof(drag_types) / sizeof(drag_types[0]); - -static void set_status_message (EABView *eav, const char *message, AddressbookView *view); -static void search_result (EABView *eav, EBookViewStatus status, AddressbookView *view); - -static void activate_source (AddressbookView *view, ESource *source); - -static void addressbook_view_init (AddressbookView *view); -static void addressbook_view_class_init (AddressbookViewClass *klass); -static void addressbook_view_dispose (GObject *object); - -typedef struct { - GtkWidget *editor; - char *uid; - AddressbookView *view; -} EditorUidClosure; - -static void -editor_weak_notify (gpointer data, GObject *o) -{ - EditorUidClosure *closure = data; - AddressbookViewPrivate *priv = closure->view->priv; - - g_hash_table_remove (priv->uid_to_editor, - closure->uid); -} - -static EABView * -get_current_view (AddressbookView *view) -{ - AddressbookViewPrivate *priv = view->priv; - - return EAB_VIEW (gtk_notebook_get_nth_page (GTK_NOTEBOOK (priv->notebook), - gtk_notebook_get_current_page (GTK_NOTEBOOK (priv->notebook)))); -} - -static void -save_contact_cb (BonoboUIComponent *uih, void *user_data, const char *path) -{ - AddressbookView *view = (AddressbookView *) user_data; - EABView *v = get_current_view (view); - if (v) - eab_view_save_as(v); -} - -static void -view_contact_cb (BonoboUIComponent *uih, void *user_data, const char *path) -{ - AddressbookView *view = (AddressbookView *) user_data; - EABView *v = get_current_view (view); - if (v) - eab_view_view(v); -} - -static void -search_cb (BonoboUIComponent *uih, void *user_data, const char *path) -{ - AddressbookView *view = (AddressbookView *) user_data; - EABView *v = get_current_view (view); - if (v) - gtk_widget_show(eab_search_dialog_new(v)); -} - -static void -delete_contact_cb (BonoboUIComponent *uih, void *user_data, const char *path) -{ - AddressbookView *view = (AddressbookView *) user_data; - EABView *v = get_current_view (view); - if (v) - eab_view_delete_selection(v); -} - -static void -print_cb (BonoboUIComponent *uih, void *user_data, const char *path) -{ - AddressbookView *view = (AddressbookView *) user_data; - EABView *v = get_current_view (view); - if (v) - eab_view_print(v); -} - -static void -print_preview_cb (BonoboUIComponent *uih, void *user_data, const char *path) -{ - AddressbookView *view = (AddressbookView *) user_data; - EABView *v = get_current_view (view); - if (v) - eab_view_print_preview(v); -} - -static void -stop_loading_cb (BonoboUIComponent *uih, void *user_data, const char *path) -{ - AddressbookView *view = (AddressbookView *) user_data; - EABView *v = get_current_view (view); - if (v) - eab_view_stop(v); -} - -static void -cut_contacts_cb (BonoboUIComponent *uih, void *user_data, const char *path) -{ - AddressbookView *view = (AddressbookView *) user_data; - EABView *v = get_current_view (view); - if (v) - eab_view_cut(v); -} - -static void -copy_contacts_cb (BonoboUIComponent *uih, void *user_data, const char *path) -{ - AddressbookView *view = (AddressbookView *) user_data; - EABView *v = get_current_view (view); - if (v) - eab_view_copy(v); -} - -static void -paste_contacts_cb (BonoboUIComponent *uih, void *user_data, const char *path) -{ - AddressbookView *view = (AddressbookView *) user_data; - EABView *v = get_current_view (view); - if (v) - eab_view_paste(v); -} - -static void -select_all_contacts_cb (BonoboUIComponent *uih, void *user_data, const char *path) -{ - AddressbookView *view = (AddressbookView *) user_data; - EABView *v = get_current_view (view); - if (v) - eab_view_select_all (v); -} - -static void -send_contact_cb (BonoboUIComponent *uih, void *user_data, const char *path) -{ - AddressbookView *view = (AddressbookView *) user_data; - EABView *v = get_current_view (view); - if (v) - eab_view_send (v); -} - -static void -send_contact_to_cb (BonoboUIComponent *uih, void *user_data, const char *path) -{ - AddressbookView *view = (AddressbookView *) user_data; - EABView *v = get_current_view (view); - if (v) - eab_view_send_to (v); -} - -static void -copy_contact_to_cb (BonoboUIComponent *uih, void *user_data, const char *path) -{ - AddressbookView *view = (AddressbookView *) user_data; - EABView *v = get_current_view (view); - if (v) - eab_view_copy_to_folder (v); -} - -static void -move_contact_to_cb (BonoboUIComponent *uih, void *user_data, const char *path) -{ - AddressbookView *view = (AddressbookView *) user_data; - EABView *v = get_current_view (view); - if (v) - eab_view_move_to_folder (v); -} - -static void -forget_passwords_cb (BonoboUIComponent *uih, void *user_data, const char *path) -{ - e_passwords_forget_passwords(); -} - -static void -set_status_message (EABView *eav, const char *message, AddressbookView *view) -{ - AddressbookViewPrivate *priv = view->priv; - EActivityHandler *activity_handler = priv->activity_handler; - - if (!message || !*message) { - if (priv->activity_id != 0) { - e_activity_handler_operation_finished (activity_handler, priv->activity_id); - priv->activity_id = 0; - } - } else if (priv->activity_id == 0) { - char *clientid = g_strdup_printf ("%p", view); - - if (progress_icon == NULL) - progress_icon = e_icon_factory_get_icon (EVOLUTION_CONTACTS_PROGRESS_IMAGE, E_ICON_SIZE_STATUS); - - priv->activity_id = e_activity_handler_operation_started (activity_handler, clientid, - progress_icon, message, TRUE); - - g_free (clientid); - } else { - e_activity_handler_operation_progressing (activity_handler, priv->activity_id, message, -1.0); - } - -} - -static void -set_folder_bar_message (EABView *eav, const char *message, AddressbookView *view) -{ - AddressbookViewPrivate *priv = view->priv; - EABView *current_view = get_current_view (view); - - if (eav == current_view) { - ESource *source = eav->source; - - if (source) { - const char *name = e_source_peek_name (source); - - e_info_label_set_info((EInfoLabel*)priv->info_widget, name, message); - } - } -} - -static void -search_result (EABView *eav, EBookViewStatus status, AddressbookView *view) -{ - eab_search_result_dialog (NULL /* XXX */, status); -} - -static void -update_command_state (EABView *eav, AddressbookView *view) -{ - AddressbookViewPrivate *priv = view->priv; - BonoboUIComponent *uic; - EABMenuTargetSelect *target; - - if (eav != get_current_view (view)) - return; - - g_object_ref (view); - - target = eab_view_get_menu_target(eav, priv->menu); - e_menu_update_target((EMenu *)priv->menu, target); - - uic = bonobo_control_get_ui_component (priv->folder_view_control); - - /* TODO: this stuff can mostly be made to use the target bits instead */ - - if (bonobo_ui_component_get_container (uic) != CORBA_OBJECT_NIL) { -#define SET_SENSITIVE(verb,f) \ - bonobo_ui_component_set_prop (uic, (verb), "sensitive", (f)(eav) ? "1" : "0", NULL) - - SET_SENSITIVE ("/commands/ContactsSaveAsVCard", eab_view_can_save_as); - SET_SENSITIVE ("/commands/ContactsView", eab_view_can_view); - - /* Print Contact */ - SET_SENSITIVE ("/commands/ContactsPrint", eab_view_can_print); - SET_SENSITIVE ("/commands/ContactsPrintPreview", eab_view_can_print); - - /* Delete Contact */ - SET_SENSITIVE ("/commands/ContactDelete", eab_view_can_delete); - SET_SENSITIVE ("/commands/ContactsCut", eab_view_can_cut); - - SET_SENSITIVE ("/commands/ContactsCopy", eab_view_can_copy); - SET_SENSITIVE ("/commands/ContactsPaste", eab_view_can_paste); - SET_SENSITIVE ("/commands/ContactsSelectAll", eab_view_can_select_all); - SET_SENSITIVE ("/commands/ContactsSendContactToOther", eab_view_can_send); - SET_SENSITIVE ("/commands/ContactsSendMessageToContact", eab_view_can_send_to); - SET_SENSITIVE ("/commands/ContactsMoveToFolder", eab_view_can_move_to_folder); - SET_SENSITIVE ("/commands/ContactsCopyToFolder", eab_view_can_copy_to_folder); - - /* Stop */ - SET_SENSITIVE ("/commands/ContactStop", eab_view_can_stop); -#undef SET_SENSITIVE - } - - g_object_unref (view); -} - -static BonoboUIVerb verbs [] = { - BONOBO_UI_UNSAFE_VERB ("ContactsPrint", print_cb), - BONOBO_UI_UNSAFE_VERB ("ContactsPrintPreview", print_preview_cb), - BONOBO_UI_UNSAFE_VERB ("ContactsSaveAsVCard", save_contact_cb), - BONOBO_UI_UNSAFE_VERB ("ContactsView", view_contact_cb), - - BONOBO_UI_UNSAFE_VERB ("ContactDelete", delete_contact_cb), - BONOBO_UI_UNSAFE_VERB ("ContactStop", stop_loading_cb), - - BONOBO_UI_UNSAFE_VERB ("ContactsCut", cut_contacts_cb), - BONOBO_UI_UNSAFE_VERB ("ContactsCopy", copy_contacts_cb), - BONOBO_UI_UNSAFE_VERB ("ContactsPaste", paste_contacts_cb), - BONOBO_UI_UNSAFE_VERB ("ContactsSelectAll", select_all_contacts_cb), - - BONOBO_UI_UNSAFE_VERB ("ContactsSendContactToOther", send_contact_cb), - BONOBO_UI_UNSAFE_VERB ("ContactsSendMessageToContact", send_contact_to_cb), - BONOBO_UI_UNSAFE_VERB ("ContactsMoveToFolder", move_contact_to_cb), - BONOBO_UI_UNSAFE_VERB ("ContactsCopyToFolder", copy_contact_to_cb), - BONOBO_UI_UNSAFE_VERB ("ContactsForgetPasswords", forget_passwords_cb), - /* ContactsViewPreview is a toggle */ - - BONOBO_UI_VERB_END -}; - -static EPixmap pixmaps [] = { - E_PIXMAP ("/menu/File/FileOps/ContactsSaveAsVCard", "stock_save-as", E_ICON_SIZE_MENU), - E_PIXMAP ("/menu/File/Print/ContactsPrint", "stock_print", E_ICON_SIZE_MENU), - E_PIXMAP ("/menu/File/Print/ContactsPrintPreview", "stock_print-preview", E_ICON_SIZE_MENU), - - E_PIXMAP ("/menu/EditPlaceholder/Edit/ContactsCut", "stock_cut", E_ICON_SIZE_MENU), - E_PIXMAP ("/menu/EditPlaceholder/Edit/ContactsCopy", "stock_copy", E_ICON_SIZE_MENU), - E_PIXMAP ("/menu/EditPlaceholder/Edit/ContactsPaste", "stock_paste", E_ICON_SIZE_MENU), - E_PIXMAP ("/menu/EditPlaceholder/Edit/ContactDelete", "stock_delete", E_ICON_SIZE_MENU), - - E_PIXMAP ("/Toolbar/ContactsPrint", "stock_print", E_ICON_SIZE_LARGE_TOOLBAR), - E_PIXMAP ("/Toolbar/ContactDelete", "stock_delete", E_ICON_SIZE_LARGE_TOOLBAR), - - E_PIXMAP_END -}; - -static void -control_activate (BonoboControl *control, - BonoboUIComponent *uic, - AddressbookView *view) -{ - AddressbookViewPrivate *priv = view->priv; - Bonobo_UIContainer remote_ui_container; - EABView *v = get_current_view (view); - - remote_ui_container = bonobo_control_get_remote_ui_container (control, NULL); - bonobo_ui_component_set_container (uic, remote_ui_container, NULL); - bonobo_object_release_unref (remote_ui_container, NULL); - - bonobo_ui_component_add_verb_list_with_data ( - uic, verbs, view); - - bonobo_ui_component_freeze (uic, NULL); - - bonobo_ui_util_set_ui (uic, PREFIX, - EVOLUTION_UIDIR "/evolution-addressbook.xml", - "evolution-addressbook", NULL); - - if (v) - eab_view_setup_menus (v, uic); - - e_pixmaps_update (uic, pixmaps); - - e_user_creatable_items_handler_activate (priv->creatable_items_handler, uic); - - bonobo_ui_component_thaw (uic, NULL); - - if (v) - update_command_state (v, view); -} - -static void -control_activate_cb (BonoboControl *control, - gboolean activate, - AddressbookView *view) -{ - BonoboUIComponent *uic; - EABView *v = get_current_view (view); - - uic = bonobo_control_get_ui_component (control); - g_assert (uic != NULL); - - if (activate) { - control_activate (control, uic, view); - e_menu_activate((EMenu *)view->priv->menu, uic, activate); - if (activate && v && v->model) - eab_model_force_folder_bar_message (v->model); - } else { - e_menu_activate((EMenu *)view->priv->menu, uic, activate); - bonobo_ui_component_unset_container (uic, NULL); - eab_view_discard_menus (v); - } -} - -static void -gather_uids_foreach (char *key, - gpointer value, - GList **list) -{ - (*list) = g_list_prepend (*list, key); -} - -static void -source_list_changed_cb (ESourceList *source_list, AddressbookView *view) -{ - AddressbookViewPrivate *priv = view->priv; - GList *uids, *l; - EABView *v; - - uids = NULL; - g_hash_table_foreach (priv->uid_to_view, (GHFunc)gather_uids_foreach, &uids); - for (l = uids; l; l = l->next) { - char *uid = l->data; - if (e_source_list_peek_source_by_uid (source_list, uid)) { - /* the source still exists, do nothing */ - } - else { - /* the source no longer exists, remove its - view remove it from our hash table. */ - v = g_hash_table_lookup (priv->uid_to_view, - uid); - gtk_notebook_remove_page (GTK_NOTEBOOK (priv->notebook), - gtk_notebook_page_num (GTK_NOTEBOOK (priv->notebook), - GTK_WIDGET (v))); - g_hash_table_remove (priv->uid_to_view, uid); - } - } - g_list_free (uids); - - uids = NULL; - g_hash_table_foreach (priv->uid_to_editor, (GHFunc)gather_uids_foreach, &uids); - for (l = uids; l; l = l->next) { - char *uid = l->data; - if (e_source_list_peek_source_by_uid (source_list, uid)) { - /* the source still exists, do nothing */ - } - else { - /* the source no longer exists, remove its - editor remove it from our hash table. */ - EditorUidClosure *closure = g_hash_table_lookup (priv->uid_to_editor, - uid); - g_object_weak_unref (G_OBJECT (closure->editor), - editor_weak_notify, closure); - gtk_widget_destroy (closure->editor); - g_hash_table_remove (priv->uid_to_editor, uid); - } - } - g_list_free (uids); - - /* make sure we've got the current view selected and updated - properly */ - v = get_current_view (view); - if (v) { - eab_view_setup_menus (v, bonobo_control_get_ui_component (priv->folder_view_control)); - update_command_state (v, view); - } -} - -static void -load_uri_for_selection (ESourceSelector *selector, - AddressbookView *view) -{ - ESource *selected_source = e_source_selector_peek_primary_selection (E_SOURCE_SELECTOR (selector)); - - if (selected_source != NULL) - activate_source (view, selected_source); -} - -static ESource * -find_first_source (ESourceList *source_list) -{ - GSList *groups, *sources, *l, *m; - - groups = e_source_list_peek_groups (source_list); - for (l = groups; l; l = l->next) { - ESourceGroup *group = l->data; - - sources = e_source_group_peek_sources (group); - for (m = sources; m; m = m->next) { - ESource *source = m->data; - - return source; - } - } - - return NULL; -} - -static void -save_primary_selection (AddressbookView *view) -{ - AddressbookViewPrivate *priv = view->priv; - ESource *source; - - source = e_source_selector_peek_primary_selection (E_SOURCE_SELECTOR (priv->selector)); - if (!source) - return; - - /* Save the selection for next time we start up */ - gconf_client_set_string (priv->gconf_client, - "/apps/evolution/addressbook/display/primary_addressbook", - e_source_peek_uid (source), NULL); -} - -static ESource * -get_primary_source (AddressbookView *view) -{ - AddressbookViewPrivate *priv = view->priv; - ESource *source; - char *uid; - - uid = gconf_client_get_string (priv->gconf_client, - "/apps/evolution/addressbook/display/primary_addressbook", - NULL); - if (uid) { - source = e_source_list_peek_source_by_uid (priv->source_list, uid); - g_free (uid); - } else { - /* Try to create a default if there isn't one */ - source = find_first_source (priv->source_list); - } - - return source; -} - -static void -load_primary_selection (AddressbookView *view) -{ - AddressbookViewPrivate *priv = view->priv; - ESource *source; - - source = get_primary_source (view); - if (source) - e_source_selector_set_primary_selection (E_SOURCE_SELECTOR (priv->selector), source); -} - -/* Folder popup menu callbacks */ -typedef struct { - AddressbookView *view; - ESource *selected_source; - GtkWidget *toplevel; -} BookRemovedClosure; - -static void -book_removed (EBook *book, EBookStatus status, gpointer data) -{ - BookRemovedClosure *closure = data; - AddressbookView *view = closure->view; - AddressbookViewPrivate *priv = view->priv; - ESource *source = closure->selected_source; - GtkWidget *toplevel = closure->toplevel; - - g_free (closure); - - g_object_unref (book); - - if (E_BOOK_ERROR_OK == status) { - /* Remove source */ - if (e_source_selector_source_is_selected (E_SOURCE_SELECTOR (priv->selector), - source)) - e_source_selector_unselect_source (E_SOURCE_SELECTOR (priv->selector), - source); - - e_source_group_remove_source (e_source_peek_group (source), source); - - e_source_list_sync (priv->source_list, NULL); - } - else { - e_error_run (GTK_WINDOW (toplevel), - "addressbook:remove-addressbook", - NULL); - } -} - -static void -delete_addressbook_cb(EPopup *ep, EPopupItem *pitem, void *data) -{ - AddressbookView *view = data; - AddressbookViewPrivate *priv = view->priv; - ESource *selected_source; - EBook *book; - GError *error = NULL; - GtkWindow *toplevel; - - selected_source = e_source_selector_peek_primary_selection (E_SOURCE_SELECTOR (priv->selector)); - if (!selected_source) - return; - - toplevel = (GtkWindow *)gtk_widget_get_toplevel(ep->target->widget); - - if (e_error_run(toplevel, "addressbook:ask-delete-addressbook", e_source_peek_name(selected_source)) != GTK_RESPONSE_YES) - return; - - /* Remove local data */ - book = e_book_new (selected_source, &error); - if (book) { - BookRemovedClosure *closure = g_new (BookRemovedClosure, 1); - - closure->toplevel = (GtkWidget *)toplevel; - closure->view = view; - closure->selected_source = selected_source; - - if (e_book_async_remove (book, book_removed, closure)) { - e_error_run (toplevel, "addressbook:remove-addressbook", NULL); - g_free (closure); - g_object_unref (book); - } - } -} - -static void -new_addressbook_cb(EPopup *ep, EPopupItem *pitem, void *data) -{ - addressbook_config_create_new_source (gtk_widget_get_toplevel(ep->target->widget)); -} - -static void -edit_addressbook_cb(EPopup *ep, EPopupItem *pitem, void *data) -{ - AddressbookView *view = data; - AddressbookViewPrivate *priv = view->priv; - ESource *selected_source; - const char *uid; - EditorUidClosure *closure; - - selected_source = - e_source_selector_peek_primary_selection (E_SOURCE_SELECTOR (priv->selector)); - if (!selected_source) - return; - - uid = e_source_peek_uid (selected_source); - - closure = g_hash_table_lookup (priv->uid_to_editor, uid); - if (!closure) { - char *uid_copy = g_strdup (uid); - - closure = g_new (EditorUidClosure, 1); - closure->editor = addressbook_config_edit_source (gtk_widget_get_toplevel(ep->target->widget), selected_source); - closure->uid = uid_copy; - closure->view = view; - - g_hash_table_insert (priv->uid_to_editor, - uid_copy, - closure); - - g_object_weak_ref (G_OBJECT (closure->editor), - editor_weak_notify, closure); - } - - gtk_window_present (GTK_WINDOW (closure->editor)); -} - -/* Callbacks. */ - -static void -primary_source_selection_changed_callback (ESourceSelector *selector, - AddressbookView *view) -{ - load_uri_for_selection (selector, view); - save_primary_selection (view); -} - -static EPopupItem abv_source_popups[] = { - { E_POPUP_ITEM, "10.new", N_("New Address Book"), new_addressbook_cb, NULL, "stock_contact", 0, 0 }, - { E_POPUP_ITEM, "20.delete", N_("Delete"), delete_addressbook_cb, NULL, "stock_delete", 0, EAB_POPUP_SOURCE_USER|EAB_POPUP_SOURCE_PRIMARY }, - { E_POPUP_BAR, "30.bar"}, - { E_POPUP_ITEM, "30.properties", N_("Properties..."), edit_addressbook_cb, NULL,"stock_folder-properties", 0, EAB_POPUP_SOURCE_PRIMARY }, -}; - -static void -abv_source_popup_free(EPopup *ep, GSList *list, void *data) -{ - g_slist_free(list); -} - -static gboolean -popup_event_callback(ESourceSelector *selector, ESource *source, GdkEventButton *event, AddressbookView *view) -{ - EABPopup *ep; - EABPopupTargetSource *t; - GSList *menus = NULL; - int i; - GtkMenu *menu; - - ep = eab_popup_new("org.gnome.evolution.addressbook.source.popup"); - t = eab_popup_target_new_source(ep, selector); - t->target.widget = (GtkWidget *)view->priv->notebook; - - for (i=0;i<sizeof(abv_source_popups)/sizeof(abv_source_popups[0]);i++) - menus = g_slist_prepend(menus, &abv_source_popups[i]); - - e_popup_add_items((EPopup *)ep, menus, abv_source_popup_free, view); - - menu = e_popup_create_menu_once((EPopup *)ep, (EPopupTarget *)t, 0); - gtk_menu_popup(menu, NULL, NULL, NULL, NULL, event?event->button:0, event?event->time:gtk_get_current_event_time()); - - return TRUE; -} - -static gboolean -selector_tree_drag_drop (GtkWidget *widget, - GdkDragContext *context, - int x, - int y, - guint time, - AddressbookView *view) -{ - GtkTreeViewColumn *column; - int cell_x; - int cell_y; - GtkTreePath *path; - GtkTreeModel *model; - GtkTreeIter iter; - gpointer data; - - if (!gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (widget), x, y, &path, &column, &cell_x, &cell_y)) - return FALSE; - - model = gtk_tree_view_get_model (GTK_TREE_VIEW (widget)); - - if (!gtk_tree_model_get_iter (model, &iter, path)) { - gtk_tree_path_free (path); - return FALSE; - } - - gtk_tree_model_get (model, &iter, 0, &data, -1); - - if (E_IS_SOURCE_GROUP (data)) { - g_object_unref (data); - gtk_tree_path_free (path); - return FALSE; - } - - gtk_tree_path_free (path); - return TRUE; -} - -static gboolean -selector_tree_drag_motion (GtkWidget *widget, - GdkDragContext *context, - int x, - int y) -{ - GtkTreePath *path = NULL; - gpointer data = NULL; - GtkTreeViewDropPosition pos; - GtkTreeModel *model; - GtkTreeIter iter; - GdkDragAction action; - - if (!gtk_tree_view_get_dest_row_at_pos (GTK_TREE_VIEW (widget), - x, y, &path, &pos)) - goto finish; - - model = gtk_tree_view_get_model (GTK_TREE_VIEW (widget)); - - if (!gtk_tree_model_get_iter (model, &iter, path)) - goto finish; - - gtk_tree_model_get (model, &iter, 0, &data, -1); - - if (E_IS_SOURCE_GROUP (data) || e_source_get_readonly (data)) - goto finish; - - gtk_tree_view_set_drag_dest_row(GTK_TREE_VIEW (widget), path, GTK_TREE_VIEW_DROP_INTO_OR_BEFORE); - action = context->suggested_action; - - finish: - if (path) - gtk_tree_path_free (path); - if (data) - g_object_unref (data); - - gdk_drag_status (context, action, GDK_CURRENT_TIME); - return TRUE; -} - -typedef struct -{ - guint remove_from_source : 1; - guint copy_done : 1; - gint pending_removals; - - EContact *current_contact; - GList *remaining_contacts; - - EBook *source_book; - EBook *target_book; -} -MergeContext; - -static void -destroy_merge_context (MergeContext *merge_context) -{ - if (merge_context->source_book) - g_object_unref (merge_context->source_book); - if (merge_context->target_book) - g_object_unref (merge_context->target_book); - - g_free (merge_context); -} - -static void -removed_contact_cb (EBook *book, EBookStatus status, gpointer closure) -{ - MergeContext *merge_context = closure; - - merge_context->pending_removals--; - - if (merge_context->copy_done && merge_context->pending_removals == 0) { - /* Finished */ - - destroy_merge_context (merge_context); - } -} - -static void -merged_contact_cb (EBook *book, EBookStatus status, const char *id, gpointer closure) -{ - MergeContext *merge_context = closure; - - if (merge_context->remove_from_source && status == E_BOOK_ERROR_OK) { - /* Remove previous contact from source */ - - e_book_async_remove_contact (merge_context->source_book, merge_context->current_contact, - removed_contact_cb, merge_context); - merge_context->pending_removals++; - } - - g_object_unref (merge_context->current_contact); - - if (merge_context->remaining_contacts) { - /* Copy next contact */ - - merge_context->current_contact = merge_context->remaining_contacts->data; - merge_context->remaining_contacts = g_list_delete_link (merge_context->remaining_contacts, - merge_context->remaining_contacts); - eab_merging_book_add_contact (merge_context->target_book, merge_context->current_contact, - merged_contact_cb, merge_context); - } else if (merge_context->pending_removals == 0) { - /* Finished */ - - destroy_merge_context (merge_context); - } else { - /* Finished, but have pending removals */ - - merge_context->copy_done = TRUE; - } -} - -static gboolean -selector_tree_drag_data_received (GtkWidget *widget, - GdkDragContext *context, - gint x, - gint y, - GtkSelectionData *data, - guint info, - guint time, - gpointer user_data) -{ - GtkTreePath *path = NULL; - GtkTreeViewDropPosition pos; - gpointer target = NULL; - GtkTreeModel *model; - GtkTreeIter iter; - gboolean success = FALSE; - EBook *source_book, *target_book; - MergeContext *merge_context; - GList *contactlist; - - if (!gtk_tree_view_get_dest_row_at_pos (GTK_TREE_VIEW (widget), - x, y, &path, &pos)) - goto finish; - - model = gtk_tree_view_get_model (GTK_TREE_VIEW (widget)); - - if (!gtk_tree_model_get_iter (model, &iter, path)) - goto finish; - - gtk_tree_model_get (model, &iter, 0, &target, -1); - - if (E_IS_SOURCE_GROUP (target) || e_source_get_readonly (target)) - goto finish; - - target_book = e_book_new (target, NULL); - if (!target_book) { - g_message (G_STRLOC ":Couldn't create EBook."); - return FALSE; - } - e_book_open (target_book, TRUE, NULL); - - eab_book_and_contact_list_from_string (data->data, &source_book, &contactlist); - - if (source_book) { - if (!e_book_open (source_book, FALSE, NULL)) { - g_warning (G_STRLOC ": Couldn't open source EBook."); - g_object_unref (source_book); - source_book = NULL; - } - } else { - g_warning (G_STRLOC ": No source EBook provided."); - } - - /* Set up merge context */ - - merge_context = g_new0 (MergeContext, 1); - - merge_context->source_book = source_book; - merge_context->target_book = target_book; - - merge_context->current_contact = contactlist->data; - merge_context->remaining_contacts = g_list_delete_link (contactlist, contactlist); - - merge_context->remove_from_source = context->suggested_action == GDK_ACTION_MOVE ? TRUE : FALSE; - - /* Start merge */ - - eab_merging_book_add_contact (target_book, merge_context->current_contact, - merged_contact_cb, merge_context); - - finish: - if (path) - gtk_tree_path_free (path); - if (target) - g_object_unref (target); - - gtk_drag_finish (context, success, context->action == GDK_ACTION_MOVE, time); - - return TRUE; -} - -static void -selector_tree_drag_leave (GtkWidget *widget, GdkDragContext *context, guint time, gpointer data) -{ - gtk_tree_view_set_drag_dest_row(GTK_TREE_VIEW (widget), NULL, GTK_TREE_VIEW_DROP_BEFORE); -} - - -static void -destroy_callback(gpointer data, GObject *where_object_was) -{ - AddressbookView *view = data; - g_object_unref (view); -} - -GType -addressbook_view_get_type (void) -{ - static GType type = 0; - - if (!type) { - static const GTypeInfo info = { - sizeof (AddressbookViewClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) addressbook_view_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (EABView), - 0, /* n_preallocs */ - (GInstanceInitFunc) addressbook_view_init, - }; - - type = g_type_register_static (PARENT_TYPE, "AddressbookView", &info, 0); - } - - return type; -} - -static void -addressbook_view_class_init (AddressbookViewClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - object_class->dispose = addressbook_view_dispose; - - parent_class = g_type_class_peek_parent (klass); -} - -static void -addressbook_view_init (AddressbookView *view) -{ - AddressbookViewPrivate *priv; - GtkWidget *selector_scrolled_window; - - view->priv = - priv = g_new0 (AddressbookViewPrivate, 1); - - priv->gconf_client = addressbook_component_peek_gconf_client (addressbook_component_peek ()); - - priv->uid_to_view = g_hash_table_new_full (g_str_hash, g_str_equal, (GDestroyNotify)g_free, (GDestroyNotify)g_object_unref); - priv->uid_to_editor = g_hash_table_new_full (g_str_hash, g_str_equal, (GDestroyNotify)g_free, (GDestroyNotify)g_free); - - priv->notebook = gtk_notebook_new (); - gtk_notebook_set_show_tabs (GTK_NOTEBOOK (priv->notebook), FALSE); - gtk_notebook_set_show_border (GTK_NOTEBOOK (priv->notebook), FALSE); - - g_object_weak_ref (G_OBJECT (priv->notebook), destroy_callback, view); - - /* Create the control. */ - priv->folder_view_control = bonobo_control_new (priv->notebook); - - gtk_widget_show (priv->notebook); - - e_book_get_addressbooks (&priv->source_list, NULL); - g_signal_connect (priv->source_list, - "changed", - G_CALLBACK (source_list_changed_cb), view); - - priv->creatable_items_handler = e_user_creatable_items_handler_new ("contacts", NULL, NULL); - priv->menu = eab_menu_new("org.gnome.evolution.addressbook.view"); - - g_signal_connect (priv->folder_view_control, "activate", - G_CALLBACK (control_activate_cb), view); - - priv->activity_handler = e_activity_handler_new (); - - priv->statusbar_widget = e_task_bar_new (); - gtk_widget_show (priv->statusbar_widget); - - e_activity_handler_attach_task_bar (priv->activity_handler, - E_TASK_BAR (priv->statusbar_widget)); - - priv->info_widget = e_info_label_new("stock_contact"); - e_info_label_set_info((EInfoLabel*)priv->info_widget, _("Contacts"), ""); - gtk_widget_show (priv->info_widget); - - priv->selector = e_source_selector_new (priv->source_list); - - g_signal_connect (priv->selector, "drag-motion", G_CALLBACK (selector_tree_drag_motion), view); - g_signal_connect (priv->selector, "drag-leave", G_CALLBACK (selector_tree_drag_leave), view); - g_signal_connect (priv->selector, "drag-drop", G_CALLBACK (selector_tree_drag_drop), view); - g_signal_connect (priv->selector, "drag-data-received", G_CALLBACK (selector_tree_drag_data_received), view); - gtk_drag_dest_set (priv->selector, GTK_DEST_DEFAULT_ALL, drag_types, num_drag_types, GDK_ACTION_COPY | GDK_ACTION_MOVE); - - e_source_selector_show_selection (E_SOURCE_SELECTOR (priv->selector), FALSE); - gtk_widget_show (priv->selector); - - selector_scrolled_window = gtk_scrolled_window_new (NULL, NULL); - gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (selector_scrolled_window), GTK_SHADOW_IN); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (selector_scrolled_window), - GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - gtk_container_add (GTK_CONTAINER (selector_scrolled_window), priv->selector); - gtk_widget_show (selector_scrolled_window); - - priv->sidebar_widget = gtk_vbox_new(FALSE, 0); - gtk_box_pack_start(GTK_BOX (priv->sidebar_widget), priv->info_widget, FALSE, TRUE, 0); - gtk_box_pack_start(GTK_BOX (priv->sidebar_widget), selector_scrolled_window, TRUE, TRUE, 0); - gtk_widget_show (priv->sidebar_widget); - - g_signal_connect_object (priv->selector, "primary_selection_changed", - G_CALLBACK (primary_source_selection_changed_callback), - G_OBJECT (view), 0); - g_signal_connect_object (priv->selector, "popup_event", - G_CALLBACK (popup_event_callback), - G_OBJECT (view), 0); - - load_primary_selection (view); - load_uri_for_selection (E_SOURCE_SELECTOR (priv->selector), view); -} - -static void -destroy_editor (char *key, - gpointer value, - gpointer nada) -{ - EditorUidClosure *closure = value; - - g_object_weak_unref (G_OBJECT (closure->editor), - editor_weak_notify, closure); - - gtk_widget_destroy (GTK_WIDGET (closure->editor)); -} - -static void -addressbook_view_dispose (GObject *object) -{ - AddressbookView *view = ADDRESSBOOK_VIEW (object); - AddressbookViewPrivate *priv = view->priv; - - if (view->priv) { - if (priv->book) - g_object_unref (priv->book); - - g_free(priv->passwd); - - if (priv->source_list) - g_object_unref (priv->source_list); - - if (priv->uid_to_view) - g_hash_table_destroy (priv->uid_to_view); - - if (priv->uid_to_editor) { - g_hash_table_foreach (priv->uid_to_editor, (GHFunc)destroy_editor, NULL); - g_hash_table_destroy (priv->uid_to_editor); - } - - if (priv->creatable_items_handler) - g_object_unref (priv->creatable_items_handler); - - if (priv->menu) - g_object_unref (priv->menu); - - g_free (view->priv); - view->priv = NULL; - } - - if (G_OBJECT_CLASS (parent_class)->dispose) - (* G_OBJECT_CLASS (parent_class)->dispose) (object); -} - -typedef struct { - EABView *view; - ESource *source; -} BookOpenData; - -static void -book_open_cb (EBook *book, EBookStatus status, gpointer closure) -{ - BookOpenData *data = closure; - EABView *view = data->view; - ESource *source = data->source; - - g_free (data); - - /* we always set the "source" property on the EABView, since - we use it to reload a previously failed book. */ - g_object_set(view, - "source", source, - NULL); - - if (status == E_BOOK_ERROR_OK) { - g_object_set(view, - "book", book, - NULL); - - if (view->model) - eab_model_force_folder_bar_message (view->model); - } - else if (status != E_BOOK_ERROR_CANCELLED) { - eab_load_error_dialog (NULL /* XXX */, source, status); - } - - - g_object_unref (source); -} - -static void -activate_source (AddressbookView *view, - ESource *source) -{ - AddressbookViewPrivate *priv = view->priv; - const char *uid; - GtkWidget *uid_view; - EBook *book; - BookOpenData *data; - - uid = e_source_peek_uid (source); - uid_view = g_hash_table_lookup (priv->uid_to_view, uid); - - if (uid_view) { - /* there is a view for this uid. make - sure that the view actually - contains an EBook (if it doesn't - contain an EBook a previous load - failed. try to load it again */ - g_object_get (uid_view, - "book", &book, - NULL); - - if (book) { - g_object_unref (book); - } - else { - g_object_get (uid_view, - "source", &source, - NULL); - - /* source can be NULL here, if - a previous load hasn't - actually made it to - book_open_cb yet. */ - if (source) { - book = e_book_new (source, NULL); - - if (!book) { - g_object_unref (source); - } - else { - data = g_new (BookOpenData, 1); - data->view = g_object_ref (uid_view); - data->source = source; /* transfer the ref we get back from g_object_get */ - - addressbook_load (book, book_open_cb, data); - } - } - } - } - else { - /* we don't have a view for this uid already - set up. */ - GtkWidget *label = gtk_label_new (uid); - GError *error = NULL; - - uid_view = eab_view_new (); - - gtk_widget_show (uid_view); - gtk_widget_show (label); - - g_object_set (uid_view, "type", EAB_VIEW_TABLE, NULL); - - gtk_notebook_append_page (GTK_NOTEBOOK (priv->notebook), - uid_view, - label); - - g_hash_table_insert (priv->uid_to_view, g_strdup (uid), uid_view); - - g_signal_connect (uid_view, "status_message", - G_CALLBACK(set_status_message), view); - - g_signal_connect (uid_view, "search_result", - G_CALLBACK(search_result), view); - - g_signal_connect (uid_view, "folder_bar_message", - G_CALLBACK(set_folder_bar_message), view); - - g_signal_connect (uid_view, "command_state_change", - G_CALLBACK(update_command_state), view); - - book = e_book_new (source, &error); - - if (book) { - data = g_new (BookOpenData, 1); - data->view = g_object_ref (uid_view); - data->source = g_object_ref (source); - - addressbook_load (book, book_open_cb, data); - } - else { - g_warning ("error loading addressbook : %s", error->message); - g_error_free (error); - } - } - - gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->notebook), - gtk_notebook_page_num (GTK_NOTEBOOK (priv->notebook), - uid_view)); - - if (EAB_VIEW (uid_view)->model) - eab_model_force_folder_bar_message (EAB_VIEW (uid_view)->model); - - /* change menus/toolbars to reflect the new view, assuming we are already displayed */ - if (bonobo_ui_component_get_container (bonobo_control_get_ui_component (priv->folder_view_control)) != CORBA_OBJECT_NIL) { - eab_view_setup_menus (EAB_VIEW (uid_view), bonobo_control_get_ui_component (priv->folder_view_control)); - update_command_state (EAB_VIEW (uid_view), view); - } -} - -AddressbookView * -addressbook_view_new (void) -{ - return g_object_new (ADDRESSBOOK_TYPE_VIEW, NULL); -} - -EActivityHandler* -addressbook_view_peek_activity_handler (AddressbookView *view) -{ - g_return_val_if_fail (ADDRESSBOOK_IS_VIEW (view), NULL); - - return view->priv->activity_handler; -} - -GtkWidget* -addressbook_view_peek_info_label (AddressbookView *view) -{ - g_return_val_if_fail (ADDRESSBOOK_IS_VIEW (view), NULL); - - return view->priv->info_widget; -} - -GtkWidget* -addressbook_view_peek_sidebar (AddressbookView *view) -{ - g_return_val_if_fail (ADDRESSBOOK_IS_VIEW (view), NULL); - - return view->priv->sidebar_widget; -} - -GtkWidget* -addressbook_view_peek_statusbar (AddressbookView *view) -{ - g_return_val_if_fail (ADDRESSBOOK_IS_VIEW (view), NULL); - - return view->priv->statusbar_widget; -} - -BonoboControl* -addressbook_view_peek_folder_view (AddressbookView *view) -{ - g_return_val_if_fail (ADDRESSBOOK_IS_VIEW (view), NULL); - - return view->priv->folder_view_control; -} diff --git a/addressbook/gui/component/addressbook-view.h b/addressbook/gui/component/addressbook-view.h deleted file mode 100644 index e2292c4527..0000000000 --- a/addressbook/gui/component/addressbook-view.h +++ /dev/null @@ -1,60 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* addressbook-view.h - * - * Copyright (C) 2004 Novell, 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 <toshok@ximian.com> - */ - -#ifndef _ADDRESSBOOK_VIEW_H_ -#define _ADDRESSBOOK_VIEW_H_ - -#include <bonobo/bonobo-control.h> - -#define ADDRESSBOOK_TYPE_VIEW (addressbook_view_get_type ()) -#define ADDRESSBOOK_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ADDRESSBOOK_TYPE_VIEW, AddressbookView)) -#define ADDRESSBOOK_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), ADDRESSBOOK_TYPE_VIEW, AddressbookViewClass)) -#define ADDRESSBOOK_IS_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ADDRESSBOOK_TYPE_VIEW)) -#define ADDRESSBOOK_IS_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), ADDRESSBOOK_TYPE_VIEW)) - - -typedef struct _AddressbookView AddressbookView; -typedef struct _AddressbookViewPrivate AddressbookViewPrivate; -typedef struct _AddressbookViewClass AddressbookViewClass; - -struct _AddressbookView { - GObject parent; - - AddressbookViewPrivate *priv; -}; - -struct _AddressbookViewClass { - GObjectClass parent_class; -}; - - -GType addressbook_view_get_type (void); - -AddressbookView *addressbook_view_new (void); - -EActivityHandler *addressbook_view_peek_activity_handler (AddressbookView *view); -GtkWidget *addressbook_view_peek_info_label (AddressbookView *view); -GtkWidget *addressbook_view_peek_sidebar (AddressbookView *view); -GtkWidget *addressbook_view_peek_statusbar (AddressbookView *view); -BonoboControl *addressbook_view_peek_folder_view (AddressbookView *view); - -#endif /* _ADDRESSBOOK_VIEW_H_ */ diff --git a/addressbook/gui/component/addressbook.c b/addressbook/gui/component/addressbook.c deleted file mode 100644 index cbf908c17f..0000000000 --- a/addressbook/gui/component/addressbook.c +++ /dev/null @@ -1,298 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* addressbook.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: Chris Lahey (clahey@ximian.com) - */ - -#include <config.h> - -#include <string.h> - -#include <gtk/gtkmessagedialog.h> -#include <libgnome/gnome-i18n.h> -#include <libebook/e-book.h> - -#include "e-util/e-passwords.h" - -#include "addressbook.h" - -#define d(x) - -static void addressbook_authenticate (EBook *book, gboolean previous_failure, - ESource *source, EBookCallback cb, gpointer closure); - -typedef struct { - EBookCallback cb; - ESource *source; - gpointer closure; - guint cancelled : 1; -} LoadSourceData; - -static void -free_load_source_data (LoadSourceData *data) -{ - if (data->source) - g_object_unref (data->source); - g_free (data); -} - -/*this function removes of anything present after semicolon -in uri*/ - -static gchar* -remove_parameters_from_uri (gchar *uri) -{ - gchar **components; - gchar *new_uri = NULL; - - components = g_strsplit (uri, ";", 2); - if (components[0]) - new_uri = g_strdup (components[0]); - g_strfreev (components); - return new_uri; -} - -static void -load_source_auth_cb (EBook *book, EBookStatus status, gpointer closure) -{ - LoadSourceData *data = closure; - - if (data->cancelled) { - free_load_source_data (data); - return; - } - - if (status != E_BOOK_ERROR_OK) { - - /* the user clicked cancel in the password dialog */ - if (status == E_BOOK_ERROR_CANCELLED) { - - if (e_book_check_static_capability (book, "anon-access")) { - - GtkWidget *dialog; - - /* XXX "LDAP" has to be removed from the folowing message - so that it wil valid for other servers which provide - anonymous access*/ - - dialog = gtk_message_dialog_new (NULL, - 0, - GTK_MESSAGE_WARNING, - GTK_BUTTONS_OK, - _("Accessing LDAP Server anonymously")); - g_signal_connect (dialog, "response", G_CALLBACK(gtk_widget_destroy), NULL); - gtk_widget_show (dialog); - data->cb (book, E_BOOK_ERROR_OK, data->closure); - free_load_source_data (data); - return; - } - } - else { - gchar *uri = e_source_get_uri (data->source); - gchar *stripped_uri = remove_parameters_from_uri (uri); - const gchar *auth_domain = e_source_get_property (data->source, "auth-domain"); - const gchar *component_name; - - component_name = auth_domain ? auth_domain : "Addressbook"; - - e_passwords_forget_password (component_name, stripped_uri); - addressbook_authenticate (book, TRUE, data->source, load_source_auth_cb, closure); - - g_free (stripped_uri); - g_free (uri); - return; - } - } - - data->cb (book, status, data->closure); - - free_load_source_data (data); -} - -static gboolean -get_remember_password (ESource *source) -{ - const gchar *value; - - value = e_source_get_property (source, "remember_password"); - if (value && !strcasecmp (value, "true")) - return TRUE; - - return FALSE; -} - -static void -set_remember_password (ESource *source, gboolean value) -{ - e_source_set_property (source, "remember_password", - value ? "true" : "false"); -} - -static void -addressbook_authenticate (EBook *book, gboolean previous_failure, ESource *source, - EBookCallback cb, gpointer closure) -{ - const char *password = NULL; - char *pass_dup = NULL; - const gchar *auth; - const gchar *user; - gchar *uri = e_source_get_uri (source); - gchar *stripped_uri = remove_parameters_from_uri (uri); - const gchar *auth_domain = e_source_get_property (source, "auth-domain"); - const gchar *component_name; - - component_name = auth_domain ? auth_domain : "Addressbook"; - g_free (uri); - uri = stripped_uri; - - password = e_passwords_get_password (component_name, uri); - - auth = e_source_get_property (source, "auth"); - - if (auth && !strcmp ("ldap/simple-binddn", auth)) - user = e_source_get_property (source, "binddn"); - else if (auth && !strcmp ("plain/password", auth)) - user = e_source_get_property (source, "user"); - else - user = e_source_get_property (source, "email_addr"); - if (!user) - user = ""; - - if (!password) { - char *prompt; - gboolean remember; - char *failed_auth; - guint32 flags = E_PASSWORDS_REMEMBER_FOREVER|E_PASSWORDS_SECRET|E_PASSWORDS_ONLINE; - - if (previous_failure) { - failed_auth = _("Failed to authenticate.\n"); - flags |= E_PASSWORDS_REPROMPT; - } - else { - failed_auth = ""; - } - - prompt = g_strdup_printf (_("%sEnter password for %s (user %s)"), - failed_auth, e_source_peek_name (source), user); - - remember = get_remember_password (source); - pass_dup = e_passwords_ask_password (prompt, component_name, uri, prompt, - flags, &remember, - NULL); - if (remember != get_remember_password (source)) - set_remember_password (source, remember); - - g_free (prompt); - } - - if (password || pass_dup) { - e_book_async_authenticate_user (book, user, password ? password : pass_dup, - e_source_get_property (source, "auth"), - cb, closure); - g_free (pass_dup); - } - else { - /* they hit cancel */ - cb (book, E_BOOK_ERROR_CANCELLED, closure); - } - - g_free (uri); -} - -static void -load_source_cb (EBook *book, EBookStatus status, gpointer closure) -{ - LoadSourceData *load_source_data = closure; - - if (load_source_data->cancelled) { - free_load_source_data (load_source_data); - return; - } - - if (status == E_BOOK_ERROR_OK && book != NULL) { - const gchar *auth; - - auth = e_source_get_property (load_source_data->source, "auth"); - - /* check if the addressbook needs authentication */ - - if (auth && strcmp (auth, "none")) { - addressbook_authenticate (book, FALSE, load_source_data->source, - load_source_auth_cb, closure); - - return; - } - } - - load_source_data->cb (book, status, load_source_data->closure); - free_load_source_data (load_source_data); -} - -guint -addressbook_load (EBook *book, - EBookCallback cb, gpointer closure) -{ - LoadSourceData *load_source_data = g_new0 (LoadSourceData, 1); - - load_source_data->cb = cb; - load_source_data->closure = closure; - load_source_data->source = g_object_ref (g_object_ref (e_book_get_source (book))); - load_source_data->cancelled = FALSE; - - e_book_async_open (book, FALSE, load_source_cb, load_source_data); - - return GPOINTER_TO_UINT (load_source_data); -} - -void -addressbook_load_cancel (guint id) -{ - LoadSourceData *load_source_data = GUINT_TO_POINTER (id); - - load_source_data->cancelled = TRUE; -} - -static void -default_book_cb (EBook *book, EBookStatus status, gpointer closure) -{ - LoadSourceData *load_source_data = closure; - - if (status == E_BOOK_ERROR_OK) - load_source_data->source = g_object_ref (e_book_get_source (book)); - - load_source_cb (book, status, closure); -} - -void -addressbook_load_default_book (EBookCallback cb, gpointer closure) -{ - LoadSourceData *load_source_data = g_new (LoadSourceData, 1); - EBook *book; - - load_source_data->cb = cb; - load_source_data->source = NULL; - load_source_data->closure = closure; - load_source_data->cancelled = FALSE; - - book = e_book_new_default_addressbook (NULL); - if (!book) - load_source_cb (NULL, E_BOOK_ERROR_OTHER_ERROR, load_source_data); /* XXX we should just use a GError and it's error code here */ - else - e_book_async_open (book, FALSE, default_book_cb, load_source_data); -} diff --git a/addressbook/gui/component/addressbook.h b/addressbook/gui/component/addressbook.h deleted file mode 100644 index a2a475951a..0000000000 --- a/addressbook/gui/component/addressbook.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef __ADDRESSBOOK_H__ -#define __ADDRESSBOOK_H__ - -#include <bonobo/bonobo-control.h> -#include <e-util/e-config-listener.h> -#include <bonobo/bonobo-object.h> -#include <bonobo/bonobo-moniker-util.h> -#include <libebook/e-book.h> - -guint addressbook_load (EBook *book, EBookCallback cb, gpointer closure); -void addressbook_load_cancel (guint id); -void addressbook_load_default_book (EBookCallback open_response, gpointer closure); - -#endif /* __ADDRESSBOOK_H__ */ diff --git a/addressbook/gui/component/apps_evolution_addressbook.schemas.in.in b/addressbook/gui/component/apps_evolution_addressbook.schemas.in.in deleted file mode 100644 index 1f835d9414..0000000000 --- a/addressbook/gui/component/apps_evolution_addressbook.schemas.in.in +++ /dev/null @@ -1,70 +0,0 @@ -<gconfschemafile> - <schemalist> - - <!-- Completion uris --> - - <schema> - <key>/schemas/apps/evolution/addressbook/completion/uris</key> - <applyto>/apps/evolution/addressbook/completion/uris</applyto> - <owner>evolution-addressbook</owner> - <type>string</type> - <default></default> - <locale name="C"> - <short>EFolderList XML for the list of completion URIs</short> - <long>EFolderList XML for the list of completion URIs.</long> - </locale> - </schema> - - <schema> - <key>/schemas/apps/evolution/addressbook/completion/minimum_query_length</key> - <applyto>/apps/evolution/addressbook/completion/minimum_query_length</applyto> - <owner>evolution-addressbook</owner> - <type>int</type> - <default>3</default> - <locale name="C"> - <short>The number of characters that must be typed before evolution will attempt to autocomplete</short> - <long>The number of characters that must be typed before evolution will attempt to autocomplete.</long> - </locale> - </schema> - - <!-- Select names last used uri --> - - <schema> - <key>/schemas/apps/evolution/addressbook/select_names/last_used_uri</key> - <applyto>/apps/evolution/addressbook/select_names/last_used_uri</applyto> - <owner>evolution-addressbook</owner> - <type>string</type> - <default></default> - <locale name="C"> - <short>URI for the folder last used in the select names dialog</short> - <long>URI for the folder last used in the select names dialog.</long> - </locale> - </schema> - - <!-- View state --> - - <schema> - <key>/schemas/apps/evolution/addressbook/display/vpane_position</key> - <applyto>/apps/evolution/addressbook/display/vpane_position</applyto> - <owner>evolution-addressbook</owner> - <type>int</type> - <locale name="C"> - <short>Position of the vertical pane in main view</short> - <long>Position of the vertical pane in main view.</long> - </locale> - </schema> - - <schema> - <key>/schemas/apps/evolution/addressbook/display/show_preview</key> - <applyto>/apps/evolution/addressbook/display/show_preview</applyto> - <owner>evolution-addressbook</owner> - <type>bool</type> - <default>true</default> - <locale name="C"> - <short>Show the "Preview" pane</short> - <long>Show the "Preview" pane.</long> - </locale> - </schema> - - </schemalist> -</gconfschemafile> diff --git a/addressbook/gui/component/autocompletion-config.c b/addressbook/gui/component/autocompletion-config.c deleted file mode 100644 index 0324ad838e..0000000000 --- a/addressbook/gui/component/autocompletion-config.c +++ /dev/null @@ -1,154 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-shell-config-autocompletion.h - Configuration page for addressbook autocompletion. - * - * Copyright (C) 2003 Novell, 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: Chris Toshok <toshok@ximian.com> - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - - -#include "autocompletion-config.h" - -#include "Evolution.h" - -#include <bonobo/bonobo-exception.h> - -#include <libedataserver/e-source-list.h> -#include <libedataserverui/e-source-selector.h> -#include <libgnome/gnome-i18n.h> -#include <gtk/gtkscrolledwindow.h> -#include <gtk/gtktreeselection.h> -#include <gtk/gtkwidget.h> -#include <gtk/gtksignal.h> - - -typedef struct { - EvolutionConfigControl *config_control; - - GtkWidget *control_widget; - - ESourceList *source_list; -} AutocompletionConfig; - -static void -source_selection_changed (ESourceSelector *selector, - AutocompletionConfig *ac) -{ - GSList *selection; - GSList *l; - GSList *groups; - - /* first we clear all the completion flags from all sources */ - for (groups = e_source_list_peek_groups (ac->source_list); groups; groups = groups->next) { - ESourceGroup *group = E_SOURCE_GROUP (groups->data); - GSList *sources; - for (sources = e_source_group_peek_sources (group); sources; sources = sources->next) { - ESource *source = E_SOURCE (sources->data); - - e_source_set_property (source, "completion", NULL); - } - } - - /* then we loop over the selector's selection, setting the - property on those sources */ - selection = e_source_selector_get_selection (selector); - for (l = selection; l; l = l->next) { - e_source_set_property (E_SOURCE (l->data), "completion", "true"); - } - e_source_selector_free_selection (selection); - - e_source_list_sync (ac->source_list, NULL); /* XXX we should pop up a dialog if this fails */ -} - -static void -config_control_destroy_notify (void *data, - GObject *where_the_config_control_was) -{ - AutocompletionConfig *ac = (AutocompletionConfig *) data; - - g_object_unref (ac->source_list); - - g_free (ac); -} - -static void -initialize_selection (AutocompletionConfig *ac) -{ - GSList *groups; - - for (groups = e_source_list_peek_groups (ac->source_list); groups; groups = groups->next) { - ESourceGroup *group = E_SOURCE_GROUP (groups->data); - GSList *sources; - for (sources = e_source_group_peek_sources (group); sources; sources = sources->next) { - ESource *source = E_SOURCE (sources->data); - const char *completion = e_source_get_property (source, "completion"); - if (completion && !g_ascii_strcasecmp (completion, "true")) - e_source_selector_select_source (E_SOURCE_SELECTOR (ac->control_widget), - source); - } - } -} - -EvolutionConfigControl* -autocompletion_config_control_new (void) -{ - AutocompletionConfig *ac; - CORBA_Environment ev; - GtkWidget *scrolledwin; - - ac = g_new0 (AutocompletionConfig, 1); - - CORBA_exception_init (&ev); - - ac->source_list = e_source_list_new_for_gconf_default ("/apps/evolution/addressbook/sources"); - /* XXX should we watch for the source list to change and - update it in the control? what about our local changes? */ - /* g_signal_connect (ac->source_list, "changed", G_CALLBACK (source_list_changed), ac); */ - - scrolledwin = gtk_scrolled_window_new (NULL, NULL); - - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwin), - GTK_POLICY_AUTOMATIC, - GTK_POLICY_AUTOMATIC); - gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolledwin), - GTK_SHADOW_IN); - - ac->control_widget = e_source_selector_new (ac->source_list); - - gtk_container_add (GTK_CONTAINER (scrolledwin), ac->control_widget); - - initialize_selection (ac); - - gtk_widget_show (ac->control_widget); - gtk_widget_show (scrolledwin); - - ac->config_control = evolution_config_control_new (scrolledwin); - - g_signal_connect (ac->control_widget, "selection_changed", - G_CALLBACK (source_selection_changed), ac); - - g_object_weak_ref (G_OBJECT (ac->config_control), config_control_destroy_notify, ac); - - CORBA_exception_free (&ev); - - return ac->config_control; -} - diff --git a/addressbook/gui/component/autocompletion-config.h b/addressbook/gui/component/autocompletion-config.h deleted file mode 100644 index 86f056477e..0000000000 --- a/addressbook/gui/component/autocompletion-config.h +++ /dev/null @@ -1,30 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-shell-config-autocompletion.h - Configuration page for addressbook autocompletion. - * - * Copyright (C) 2003 Novell, 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: Chris Toshok <toshok@ximian.com> - */ - -#ifndef _AUTOCOMPLETION_CONFIG_H -#define _AUTOCOMPLETION_CONFIG_H - -#include "evolution-config-control.h" - -EvolutionConfigControl* autocompletion_config_control_new (void); - -#endif /* _AUTOCOMPLETION_CONFIG_H */ diff --git a/addressbook/gui/component/component-factory.c b/addressbook/gui/component/component-factory.c deleted file mode 100644 index 382722785e..0000000000 --- a/addressbook/gui/component/component-factory.c +++ /dev/null @@ -1,81 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* component-factory.c - Factory for Evolution's Addressbook component. - * - * 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> - */ - -#include <config.h> - -#include <string.h> -#include "addressbook.h" -#include "addressbook-component.h" -#include "addressbook-config.h" -#include "addressbook-view.h" -#include "autocompletion-config.h" -#include "eab-popup-control.h" -#include "eab-vcard-control.h" -#include "select-names/e-select-names-bonobo.h" -#ifdef ENABLE_SMIME -#include "smime/gui/certificate-manager.h" -#endif -#include <bonobo/bonobo-shlib-factory.h> - - -#define FACTORY_ID "OAFIID:GNOME_Evolution_Addressbook_Factory:" BASE_VERSION - -#define VCARD_CONTROL_ID "OAFIID:GNOME_Evolution_Addressbook_VCard_Control:" BASE_VERSION -#define COMPONENT_ID "OAFIID:GNOME_Evolution_Addressbook_Component:" BASE_VERSION -#define ADDRESS_POPUP_ID "OAFIID:GNOME_Evolution_Addressbook_AddressPopup:" BASE_VERSION -#define SELECT_NAMES_ID "OAFIID:GNOME_Evolution_Addressbook_SelectNames:" BASE_VERSION -#define COMPLETION_CONFIG_CONTROL_ID "OAFIID:GNOME_Evolution_Addressbook_Autocompletion_ConfigControl:" BASE_VERSION -#define CERTIFICATE_MANAGER_CONFIG_CONTROL_ID "OAFIID:GNOME_Evolution_SMime_CertificateManager_ConfigControl:" BASE_VERSION - -#define d(x) - - -static BonoboObject * -factory (BonoboGenericFactory *factory, - const char *component_id, - void *closure) -{ - d(printf ("asked to activate component_id `%s'\n", component_id)); - - if (strcmp (component_id, VCARD_CONTROL_ID) == 0) - return BONOBO_OBJECT (eab_vcard_control_new ()); - if (strcmp (component_id, COMPONENT_ID) == 0) { - BonoboObject *object = BONOBO_OBJECT (addressbook_component_peek ()); - bonobo_object_ref (object); - return object; - } - if (strcmp (component_id, ADDRESS_POPUP_ID) == 0) - return BONOBO_OBJECT (eab_popup_control_new ()); - if (strcmp (component_id, COMPLETION_CONFIG_CONTROL_ID) == 0) - return BONOBO_OBJECT (autocompletion_config_control_new ()); - if (strcmp (component_id, SELECT_NAMES_ID) == 0) - return BONOBO_OBJECT (e_select_names_bonobo_new ()); -#ifdef ENABLE_SMIME - if (strcmp (component_id, CERTIFICATE_MANAGER_CONFIG_CONTROL_ID) == 0) - return BONOBO_OBJECT (certificate_manager_config_control_new ()); -#endif - - g_warning (FACTORY_ID ": Don't know what to do with %s", component_id); - return NULL; -} - -BONOBO_ACTIVATION_SHLIB_FACTORY (FACTORY_ID, "Evolution Addressbook component factory", factory, NULL) diff --git a/addressbook/gui/component/ldap-config.glade b/addressbook/gui/component/ldap-config.glade deleted file mode 100644 index 8c6bfa1c84..0000000000 --- a/addressbook/gui/component/ldap-config.glade +++ /dev/null @@ -1,2676 +0,0 @@ -<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*--> -<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd"> - -<glade-interface> - -<widget class="GtkDialog" id="account-editor-window"> - <property name="visible">True</property> - <property name="title" translatable="yes">Address Book Properties</property> - <property name="type">GTK_WINDOW_TOPLEVEL</property> - <property name="window_position">GTK_WIN_POS_NONE</property> - <property name="modal">False</property> - <property name="resizable">True</property> - <property name="destroy_with_parent">False</property> - <property name="decorated">True</property> - <property name="skip_taskbar_hint">False</property> - <property name="skip_pager_hint">False</property> - <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property> - <property name="gravity">GDK_GRAVITY_NORTH_WEST</property> - <property name="has_separator">False</property> - - <child internal-child="vbox"> - <widget class="GtkVBox" id="dialog-vbox7"> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">0</property> - - <child internal-child="action_area"> - <widget class="GtkHButtonBox" id="dialog-action_area7"> - <property name="visible">True</property> - <property name="layout_style">GTK_BUTTONBOX_END</property> - - <child> - <widget class="GtkButton" id="account-editor-cancel-button"> - <property name="visible">True</property> - <property name="can_default">True</property> - <property name="can_focus">True</property> - <property name="label">gtk-cancel</property> - <property name="use_stock">True</property> - <property name="relief">GTK_RELIEF_NORMAL</property> - <property name="focus_on_click">True</property> - <property name="response_id">-6</property> - </widget> - </child> - - <child> - <widget class="GtkButton" id="account-editor-ok-button"> - <property name="visible">True</property> - <property name="can_default">True</property> - <property name="can_focus">True</property> - <property name="label">gtk-ok</property> - <property name="use_stock">True</property> - <property name="relief">GTK_RELIEF_NORMAL</property> - <property name="focus_on_click">True</property> - <property name="response_id">-5</property> - </widget> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="pack_type">GTK_PACK_END</property> - </packing> - </child> - - <child> - <widget class="GtkNotebook" id="account-editor-notebook"> - <property name="border_width">12</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="show_tabs">True</property> - <property name="show_border">True</property> - <property name="tab_pos">GTK_POS_TOP</property> - <property name="scrollable">False</property> - <property name="enable_popup">False</property> - - <child> - <widget class="GtkVBox" id="account-editor-general-vbox"> - <property name="border_width">12</property> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">12</property> - - <child> - <widget class="GtkLabel" id="label564"> - <property name="visible">True</property> - <property name="label" translatable="yes"><b>Display</b></property> - <property name="use_underline">False</property> - <property name="use_markup">True</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - - <child> - <widget class="GtkHBox" id="hbox122"> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">0</property> - - <child> - <widget class="GtkLabel" id="label563"> - <property name="visible">True</property> - <property name="label" translatable="yes"></property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label431"> - <property name="visible">True</property> - <property name="label" translatable="yes">_Name:</property> - <property name="use_underline">True</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_CENTER</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="mnemonic_widget">account-editor-display-name-entry</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - - <child> - <widget class="GtkEntry" id="account-editor-display-name-entry"> - <property name="visible">True</property> - <property name="tooltip" translatable="yes">This is the name for this server that will appear in your Evolution folder list. It is for display purposes only. </property> - <property name="can_focus">True</property> - <property name="editable">True</property> - <property name="visibility">True</property> - <property name="max_length">0</property> - <property name="text" translatable="yes"></property> - <property name="has_frame">True</property> - <property name="invisible_char" translatable="yes">*</property> - <property name="activates_default">False</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">True</property> - <property name="fill">True</property> - </packing> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - - <child> - <widget class="GtkVBox" id="account-editor-connecting-vbox"> - <property name="homogeneous">False</property> - <property name="spacing">12</property> - - <child> - <widget class="GtkLabel" id="label557"> - <property name="visible">True</property> - <property name="label" translatable="yes"><b>Server Information</b></property> - <property name="use_underline">False</property> - <property name="use_markup">True</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - - <child> - <widget class="GtkHBox" id="hbox123"> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">12</property> - - <child> - <widget class="GtkLabel" id="label558"> - <property name="visible">True</property> - <property name="label" translatable="yes"></property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - - <child> - <widget class="GtkTable" id="table31"> - <property name="visible">True</property> - <property name="n_rows">3</property> - <property name="n_columns">2</property> - <property name="homogeneous">False</property> - <property name="row_spacing">6</property> - <property name="column_spacing">6</property> - - <child> - <widget class="GtkLabel" id="label554"> - <property name="visible">True</property> - <property name="label" translatable="yes">_Port:</property> - <property name="use_underline">True</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="mnemonic_widget">entry27</property> - </widget> - <packing> - <property name="left_attach">0</property> - <property name="right_attach">1</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label556"> - <property name="visible">True</property> - <property name="label" translatable="yes">_Server:</property> - <property name="use_underline">True</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="mnemonic_widget">server-name-entry</property> - </widget> - <packing> - <property name="left_attach">0</property> - <property name="right_attach">1</property> - <property name="top_attach">0</property> - <property name="bottom_attach">1</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkHBox" id="hbox123"> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">6</property> - - <child> - <widget class="GtkLabel" id="label555"> - <property name="visible">True</property> - <property name="label" translatable="yes">_Use secure connection:</property> - <property name="use_underline">True</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="mnemonic_widget">ssl-optionmenu</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - - <child> - <widget class="GtkOptionMenu" id="ssl-optionmenu"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="history">0</property> - - <child internal-child="menu"> - <widget class="GtkMenu" id="convertwidget41"> - <property name="visible">True</property> - - <child> - <widget class="GtkMenuItem" id="convertwidget42"> - <property name="visible">True</property> - <property name="tooltip" translatable="yes">Selecting this option means that Evolution will only connect to your LDAP server if your LDAP server supports SSL or TLS.</property> - <property name="label" translatable="yes">Always</property> - <property name="use_underline">True</property> - </widget> - </child> - - <child> - <widget class="GtkMenuItem" id="convertwidget43"> - <property name="visible">True</property> - <property name="tooltip" translatable="yes">Selecting this option means that Evolution will only try to use SSL/TLS if you are in a insecure environment. For example, if you and your LDAP server are behind a firewall at work, then Evolution doesn't need to use SSL/TLS because your connection is already secure.</property> - <property name="label" translatable="yes">Whenever Possible</property> - <property name="use_underline">True</property> - </widget> - </child> - - <child> - <widget class="GtkMenuItem" id="convertwidget44"> - <property name="visible">True</property> - <property name="tooltip" translatable="yes">Selecting this option means that your server does not support either SSL or TLS. This means that your connection will be insecure, and that you will be vulnerable to security exploits. </property> - <property name="label" translatable="yes">Never</property> - <property name="use_underline">True</property> - </widget> - </child> - </widget> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">True</property> - <property name="fill">True</property> - </packing> - </child> - </widget> - <packing> - <property name="left_attach">0</property> - <property name="right_attach">2</property> - <property name="top_attach">2</property> - <property name="bottom_attach">3</property> - <property name="x_options">expand|shrink|fill</property> - <property name="y_options">shrink|fill</property> - </packing> - </child> - - <child> - <widget class="GtkCombo" id="port-combo"> - <property name="visible">True</property> - <property name="value_in_list">False</property> - <property name="allow_empty">True</property> - <property name="case_sensitive">False</property> - <property name="enable_arrow_keys">True</property> - <property name="enable_arrows_always">False</property> - - <child internal-child="entry"> - <widget class="GtkEntry" id="entry27"> - <property name="visible">True</property> - <property name="tooltip" translatable="yes">This is the port on the LDAP server that Evolution will try to connect to. A list of standard ports has been provided. Ask your system administrator what port you should specify.</property> - <property name="can_focus">True</property> - <property name="has_focus">True</property> - <property name="editable">True</property> - <property name="visibility">True</property> - <property name="max_length">0</property> - <property name="text" translatable="yes"></property> - <property name="has_frame">True</property> - <property name="invisible_char" translatable="yes">*</property> - <property name="activates_default">False</property> - </widget> - </child> - - <child internal-child="list"> - <widget class="GtkList" id="convertwidget32"> - <property name="visible">True</property> - <property name="selection_mode">GTK_SELECTION_BROWSE</property> - - <child> - <widget class="GtkListItem" id="listitem16"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="label" translatable="yes">389</property> - </widget> - </child> - - <child> - <widget class="GtkListItem" id="listitem17"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="label" translatable="yes">636</property> - </widget> - </child> - - <child> - <widget class="GtkListItem" id="listitem18"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="label" translatable="yes">3268</property> - </widget> - </child> - </widget> - </child> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkEntry" id="server-name-entry"> - <property name="visible">True</property> - <property name="tooltip" translatable="yes">This is the full name of your ldap server. For example, "ldap.mycompany.com".</property> - <property name="can_focus">True</property> - <property name="has_focus">True</property> - <property name="editable">True</property> - <property name="visibility">True</property> - <property name="max_length">0</property> - <property name="text" translatable="yes"></property> - <property name="has_frame">True</property> - <property name="invisible_char" translatable="yes">*</property> - <property name="activates_default">False</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">0</property> - <property name="bottom_attach">1</property> - <property name="y_options"></property> - </packing> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">True</property> - <property name="fill">True</property> - </packing> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">True</property> - <property name="fill">True</property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label559"> - <property name="visible">True</property> - <property name="label" translatable="yes"><b>Authentication</b></property> - <property name="use_underline">False</property> - <property name="use_markup">True</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - - <child> - <widget class="GtkHBox" id="hbox124"> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">12</property> - - <child> - <widget class="GtkLabel" id="label562"> - <property name="visible">True</property> - <property name="label" translatable="yes"></property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - - <child> - <widget class="GtkTable" id="table32"> - <property name="visible">True</property> - <property name="n_rows">2</property> - <property name="n_columns">2</property> - <property name="homogeneous">False</property> - <property name="row_spacing">6</property> - <property name="column_spacing">6</property> - - <child> - <widget class="GtkLabel" id="label560"> - <property name="visible">True</property> - <property name="label" translatable="yes">_Log in method:</property> - <property name="use_underline">True</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="mnemonic_widget">auth-optionmenu</property> - </widget> - <packing> - <property name="left_attach">0</property> - <property name="right_attach">1</property> - <property name="top_attach">0</property> - <property name="bottom_attach">1</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label561"> - <property name="visible">True</property> - <property name="label" translatable="yes">Lo_gin:</property> - <property name="use_underline">True</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="mnemonic_widget">auth-entry</property> - </widget> - <packing> - <property name="left_attach">0</property> - <property name="right_attach">1</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkOptionMenu" id="auth-optionmenu"> - <property name="visible">True</property> - <property name="tooltip" translatable="yes">This is the method evolution will use to authenticate you. Note that setting this to "Email Address" requires anonymous access to your ldap server.</property> - <property name="can_focus">True</property> - <property name="history">0</property> - - <child internal-child="menu"> - <widget class="GtkMenu" id="convertwidget28"> - <property name="visible">True</property> - - <child> - <widget class="GtkMenuItem" id="convertwidget29"> - <property name="visible">True</property> - <property name="label" translatable="yes">Anonymously</property> - <property name="use_underline">True</property> - </widget> - </child> - - <child> - <widget class="GtkMenuItem" id="convertwidget30"> - <property name="visible">True</property> - <property name="label" translatable="yes">Using email address</property> - <property name="use_underline">True</property> - </widget> - </child> - - <child> - <widget class="GtkMenuItem" id="convertwidget31"> - <property name="visible">True</property> - <property name="label" translatable="yes">Using distinguished name (DN)</property> - <property name="use_underline">True</property> - </widget> - </child> - </widget> - </child> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">0</property> - <property name="bottom_attach">1</property> - <property name="x_options">expand|shrink|fill</property> - <property name="y_options">shrink</property> - </packing> - </child> - - <child> - <widget class="GtkEntry" id="auth-entry"> - <property name="visible">True</property> - <property name="tooltip" translatable="yes">Evolution will use this email address to authenticate you with the server.</property> - <property name="can_focus">True</property> - <property name="editable">True</property> - <property name="visibility">True</property> - <property name="max_length">0</property> - <property name="text" translatable="yes"></property> - <property name="has_frame">True</property> - <property name="invisible_char" translatable="yes">*</property> - <property name="activates_default">False</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="y_options"></property> - </packing> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">True</property> - <property name="fill">True</property> - </packing> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">True</property> - <property name="fill">True</property> - </packing> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - </widget> - <packing> - <property name="tab_expand">False</property> - <property name="tab_fill">False</property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label334"> - <property name="visible">True</property> - <property name="label" translatable="yes">General</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_CENTER</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="type">tab</property> - </packing> - </child> - - <child> - <widget class="GtkVBox" id="account-editor-searching-vbox"> - <property name="border_width">12</property> - <property name="homogeneous">False</property> - <property name="spacing">12</property> - - <child> - <widget class="GtkLabel" id="label565"> - <property name="visible">True</property> - <property name="label" translatable="yes"><b>Searching</b></property> - <property name="use_underline">False</property> - <property name="use_markup">True</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - - <child> - <widget class="GtkHBox" id="hbox125"> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">12</property> - - <child> - <widget class="GtkLabel" id="label571"> - <property name="visible">True</property> - <property name="label" translatable="yes"></property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - - <child> - <widget class="GtkTable" id="table33"> - <property name="visible">True</property> - <property name="n_rows">3</property> - <property name="n_columns">3</property> - <property name="homogeneous">False</property> - <property name="row_spacing">6</property> - <property name="column_spacing">6</property> - - <child> - <widget class="GtkLabel" id="label569"> - <property name="visible">True</property> - <property name="label" translatable="yes"></property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="left_attach">0</property> - <property name="right_attach">1</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label566"> - <property name="visible">True</property> - <property name="label" translatable="yes">Search _base:</property> - <property name="use_underline">True</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="mnemonic_widget">rootdn-entry</property> - </widget> - <packing> - <property name="left_attach">0</property> - <property name="right_attach">1</property> - <property name="top_attach">0</property> - <property name="bottom_attach">1</property> - <property name="x_options">expand|shrink|fill</property> - <property name="y_options">shrink|fill</property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label567"> - <property name="visible">True</property> - <property name="label" translatable="yes">_Search scope:</property> - <property name="use_underline">True</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="mnemonic_widget">scope-optionmenu</property> - </widget> - <packing> - <property name="left_attach">0</property> - <property name="right_attach">1</property> - <property name="top_attach">2</property> - <property name="bottom_attach">3</property> - <property name="x_options">expand|shrink|fill</property> - <property name="y_options">shrink|fill</property> - </packing> - </child> - - <child> - <widget class="GtkOptionMenu" id="scope-optionmenu"> - <property name="visible">True</property> - <property name="tooltip" translatable="yes">The search scope defines how deep you would like the search to extend down the directory tree. A search scope of "sub" will include all entries below your search base. A search scope of "one" will only include the entries one level beneath your base.</property> - <property name="can_focus">True</property> - <property name="history">0</property> - - <child> - <widget class="GtkMenu" id="menu12"> - - <child> - <widget class="GtkMenuItem" id="menuitem7"> - <property name="visible">True</property> - <property name="label" translatable="yes">One</property> - <property name="use_underline">True</property> - </widget> - </child> - - <child> - <widget class="GtkMenuItem" id="menuitem8"> - <property name="visible">True</property> - <property name="label" translatable="yes">Sub</property> - <property name="use_underline">True</property> - </widget> - </child> - </widget> - </child> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">3</property> - <property name="top_attach">2</property> - <property name="bottom_attach">3</property> - <property name="x_options">expand|shrink|fill</property> - <property name="y_options">shrink|fill</property> - </packing> - </child> - - <child> - <widget class="GtkEntry" id="rootdn-entry"> - <property name="visible">True</property> - <property name="tooltip" translatable="yes">The search base is the distinguished name (DN) of the entry where your searches will begin. If you leave this blank, the search will begin at the root of the directory tree.</property> - <property name="can_focus">True</property> - <property name="has_focus">True</property> - <property name="editable">True</property> - <property name="visibility">True</property> - <property name="max_length">0</property> - <property name="text" translatable="yes"></property> - <property name="has_frame">True</property> - <property name="invisible_char" translatable="yes">*</property> - <property name="activates_default">False</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">3</property> - <property name="top_attach">0</property> - <property name="bottom_attach">1</property> - <property name="x_options">expand|shrink|fill</property> - <property name="y_options">shrink|fill</property> - </packing> - </child> - - <child> - <widget class="GtkButton" id="rootdn-button"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="relief">GTK_RELIEF_NORMAL</property> - <property name="focus_on_click">True</property> - - <child> - <widget class="GtkAlignment" id="alignment61"> - <property name="visible">True</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xscale">0</property> - <property name="yscale">0</property> - <property name="top_padding">0</property> - <property name="bottom_padding">0</property> - <property name="left_padding">0</property> - <property name="right_padding">0</property> - - <child> - <widget class="GtkHBox" id="hbox126"> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">2</property> - - <child> - <widget class="GtkImage" id="image10"> - <property name="visible">True</property> - <property name="stock">gtk-find</property> - <property name="icon_size">4</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label568"> - <property name="visible">True</property> - <property name="label" translatable="yes">_Find Possible Search Bases</property> - <property name="use_underline">True</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - </widget> - </child> - </widget> - </child> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="x_options">expand|shrink|fill</property> - <property name="y_options">shrink|fill</property> - </packing> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">True</property> - <property name="fill">True</property> - </packing> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label572"> - <property name="visible">True</property> - <property name="label" translatable="yes"><b>Downloading</b></property> - <property name="use_underline">False</property> - <property name="use_markup">True</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - - <child> - <widget class="GtkHBox" id="hbox127"> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">12</property> - - <child> - <widget class="GtkLabel" id="label579"> - <property name="visible">True</property> - <property name="label" translatable="yes"></property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - - <child> - <widget class="GtkTable" id="table34"> - <property name="visible">True</property> - <property name="n_rows">2</property> - <property name="n_columns">3</property> - <property name="homogeneous">False</property> - <property name="row_spacing">6</property> - <property name="column_spacing">6</property> - - <child> - <widget class="GtkHBox" id="hbox128"> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">6</property> - - <child> - <widget class="GtkLabel" id="label575"> - <property name="visible">True</property> - <property name="label" translatable="yes">1</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - - <child> - <widget class="GtkHScale" id="timeout-scale"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="draw_value">False</property> - <property name="value_pos">GTK_POS_TOP</property> - <property name="digits">1</property> - <property name="update_policy">GTK_UPDATE_CONTINUOUS</property> - <property name="inverted">False</property> - <property name="adjustment">3 1 5 0.5 1 0</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">True</property> - <property name="fill">True</property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label576"> - <property name="visible">True</property> - <property name="label" translatable="yes">5</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">0</property> - <property name="bottom_attach">1</property> - <property name="x_options">expand|shrink|fill</property> - <property name="y_options">shrink|fill</property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label574"> - <property name="visible">True</property> - <property name="label" translatable="yes">minutes</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="left_attach">2</property> - <property name="right_attach">3</property> - <property name="top_attach">0</property> - <property name="bottom_attach">1</property> - <property name="x_options">shrink|fill</property> - <property name="y_options">shrink|fill</property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label578"> - <property name="visible">True</property> - <property name="label" translatable="yes">cards</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="left_attach">2</property> - <property name="right_attach">3</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="x_options">shrink|fill</property> - <property name="y_options">shrink|fill</property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label573"> - <property name="visible">True</property> - <property name="label" translatable="yes">_Timeout:</property> - <property name="use_underline">True</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="mnemonic_widget">timeout-scale</property> - </widget> - <packing> - <property name="left_attach">0</property> - <property name="right_attach">1</property> - <property name="top_attach">0</property> - <property name="bottom_attach">1</property> - <property name="x_options">shrink|fill</property> - <property name="y_options">shrink|fill</property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label577"> - <property name="visible">True</property> - <property name="label" translatable="yes">_Download limit:</property> - <property name="use_underline">True</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="mnemonic_widget">download-limit-spinbutton</property> - </widget> - <packing> - <property name="left_attach">0</property> - <property name="right_attach">1</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="x_options">shrink|fill</property> - <property name="y_options">shrink|fill</property> - </packing> - </child> - - <child> - <widget class="GtkSpinButton" id="download-limit-spinbutton"> - <property name="visible">True</property> - <property name="tooltip" translatable="yes">This is the maximum number of entries to download. Setting this number to be too large will slow down your address book.</property> - <property name="can_focus">True</property> - <property name="climb_rate">1</property> - <property name="digits">0</property> - <property name="numeric">False</property> - <property name="update_policy">GTK_UPDATE_ALWAYS</property> - <property name="snap_to_ticks">False</property> - <property name="wrap">False</property> - <property name="adjustment">0 0 1000 1 10 10</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="x_options">expand|shrink|fill</property> - <property name="y_options">shrink|fill</property> - </packing> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">True</property> - <property name="fill">True</property> - </packing> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - </widget> - <packing> - <property name="tab_expand">False</property> - <property name="tab_fill">False</property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label344"> - <property name="visible">True</property> - <property name="label" translatable="yes">Details</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_CENTER</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="type">tab</property> - </packing> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">True</property> - <property name="fill">True</property> - </packing> - </child> - </widget> - </child> -</widget> - -<widget class="GtkDialog" id="supported-bases-dialog"> - <property name="title" translatable="yes">Supported Search Bases</property> - <property name="type">GTK_WINDOW_TOPLEVEL</property> - <property name="window_position">GTK_WIN_POS_CENTER</property> - <property name="modal">False</property> - <property name="default_width">320</property> - <property name="default_height">200</property> - <property name="resizable">True</property> - <property name="destroy_with_parent">False</property> - <property name="decorated">True</property> - <property name="skip_taskbar_hint">False</property> - <property name="skip_pager_hint">False</property> - <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property> - <property name="gravity">GDK_GRAVITY_NORTH_WEST</property> - <property name="has_separator">False</property> - - <child internal-child="vbox"> - <widget class="GtkVBox" id="dialog-vbox8"> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">0</property> - - <child internal-child="action_area"> - <widget class="GtkHButtonBox" id="dialog-action_area8"> - <property name="visible">True</property> - <property name="layout_style">GTK_BUTTONBOX_END</property> - - <child> - <widget class="GtkButton" id="cancelbutton1"> - <property name="visible">True</property> - <property name="can_default">True</property> - <property name="can_focus">True</property> - <property name="label">gtk-cancel</property> - <property name="use_stock">True</property> - <property name="relief">GTK_RELIEF_NORMAL</property> - <property name="focus_on_click">True</property> - <property name="response_id">-6</property> - </widget> - </child> - - <child> - <widget class="GtkButton" id="okbutton1"> - <property name="visible">True</property> - <property name="can_default">True</property> - <property name="can_focus">True</property> - <property name="label">gtk-ok</property> - <property name="use_stock">True</property> - <property name="relief">GTK_RELIEF_NORMAL</property> - <property name="focus_on_click">True</property> - <property name="response_id">-5</property> - </widget> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="pack_type">GTK_PACK_END</property> - </packing> - </child> - - <child> - <widget class="GtkVBox" id="vbox40"> - <property name="border_width">12</property> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">0</property> - - <child> - <widget class="Custom" id="supported-bases-table"> - <property name="visible">True</property> - <property name="creation_function">supported_bases_create_table</property> - <property name="int1">0</property> - <property name="int2">0</property> - <property name="last_modification_time">Fri, 12 Apr 2002 20:06:45 GMT</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">True</property> - <property name="fill">True</property> - </packing> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">True</property> - <property name="fill">True</property> - </packing> - </child> - </widget> - </child> -</widget> - -<widget class="GtkDialog" id="account-add-window"> - <property name="visible">True</property> - <property name="title" translatable="yes">Add Address Book</property> - <property name="type">GTK_WINDOW_TOPLEVEL</property> - <property name="window_position">GTK_WIN_POS_NONE</property> - <property name="modal">False</property> - <property name="resizable">True</property> - <property name="destroy_with_parent">False</property> - <property name="decorated">True</property> - <property name="skip_taskbar_hint">False</property> - <property name="skip_pager_hint">False</property> - <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property> - <property name="gravity">GDK_GRAVITY_NORTH_WEST</property> - <property name="has_separator">False</property> - - <child internal-child="vbox"> - <widget class="GtkVBox" id="dialog-vbox10"> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">0</property> - - <child internal-child="action_area"> - <widget class="GtkHButtonBox" id="dialog-action_area10"> - <property name="visible">True</property> - <property name="layout_style">GTK_BUTTONBOX_END</property> - - <child> - <widget class="GtkButton" id="cancel-button"> - <property name="visible">True</property> - <property name="can_default">True</property> - <property name="can_focus">True</property> - <property name="label">gtk-cancel</property> - <property name="use_stock">True</property> - <property name="relief">GTK_RELIEF_NORMAL</property> - <property name="focus_on_click">True</property> - <property name="response_id">-6</property> - </widget> - </child> - - <child> - <widget class="GtkButton" id="ok-button"> - <property name="visible">True</property> - <property name="can_default">True</property> - <property name="can_focus">True</property> - <property name="relief">GTK_RELIEF_NORMAL</property> - <property name="focus_on_click">True</property> - <property name="response_id">0</property> - - <child> - <widget class="GtkAlignment" id="alignment62"> - <property name="visible">True</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xscale">0</property> - <property name="yscale">0</property> - <property name="top_padding">0</property> - <property name="bottom_padding">0</property> - <property name="left_padding">0</property> - <property name="right_padding">0</property> - - <child> - <widget class="GtkHBox" id="hbox129"> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">2</property> - - <child> - <widget class="GtkImage" id="image11"> - <property name="visible">True</property> - <property name="stock">gtk-add</property> - <property name="icon_size">4</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label580"> - <property name="visible">True</property> - <property name="label" translatable="yes">_Add Address Book</property> - <property name="use_underline">True</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - </widget> - </child> - </widget> - </child> - </widget> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="pack_type">GTK_PACK_END</property> - </packing> - </child> - - <child> - <widget class="GtkNotebook" id="notebook1"> - <property name="border_width">12</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="show_tabs">True</property> - <property name="show_border">True</property> - <property name="tab_pos">GTK_POS_TOP</property> - <property name="scrollable">False</property> - <property name="enable_popup">False</property> - - <child> - <widget class="GtkVBox" id="vbox5"> - <property name="border_width">12</property> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">12</property> - - <child> - <widget class="GtkHBox" id="hbox19"> - <property name="border_width">6</property> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">6</property> - - <child> - <widget class="GtkLabel" id="label64"> - <property name="visible">True</property> - <property name="label" translatable="yes"><b>Type:</b></property> - <property name="use_underline">False</property> - <property name="use_markup">True</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - - <child> - <widget class="GtkOptionMenu" id="group-optionmenu"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="history">-1</property> - - <child> - <widget class="GtkMenu" id="menu11"> - </widget> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">True</property> - <property name="fill">True</property> - </packing> - </child> - - <child> - <widget class="GtkFrame" id="frame1"> - <property name="visible">True</property> - <property name="label_xalign">0</property> - <property name="label_yalign">0.5</property> - <property name="shadow_type">GTK_SHADOW_NONE</property> - - <child> - <widget class="GtkTable" id="table7"> - <property name="border_width">12</property> - <property name="visible">True</property> - <property name="n_rows">1</property> - <property name="n_columns">2</property> - <property name="homogeneous">False</property> - <property name="row_spacing">6</property> - <property name="column_spacing">6</property> - - <child> - <widget class="GtkEntry" id="display-name-entry"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="editable">True</property> - <property name="visibility">True</property> - <property name="max_length">0</property> - <property name="text" translatable="yes"></property> - <property name="has_frame">True</property> - <property name="invisible_char" translatable="yes">*</property> - <property name="activates_default">False</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">0</property> - <property name="bottom_attach">1</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label41"> - <property name="visible">True</property> - <property name="label" translatable="yes">_Name:</property> - <property name="use_underline">True</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="mnemonic_widget">display-name-entry</property> - </widget> - <packing> - <property name="left_attach">0</property> - <property name="right_attach">1</property> - <property name="top_attach">0</property> - <property name="bottom_attach">1</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> - </child> - </widget> - </child> - - <child> - <widget class="GtkLabel" id="label38"> - <property name="visible">True</property> - <property name="label" translatable="yes"><b>Display</b></property> - <property name="use_underline">False</property> - <property name="use_markup">True</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="type">label_item</property> - </packing> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">True</property> - </packing> - </child> - - <child> - <widget class="GtkFrame" id="server-frame"> - <property name="visible">True</property> - <property name="label_xalign">0</property> - <property name="label_yalign">0.5</property> - <property name="shadow_type">GTK_SHADOW_NONE</property> - - <child> - <widget class="GtkTable" id="table8"> - <property name="border_width">12</property> - <property name="visible">True</property> - <property name="n_rows">3</property> - <property name="n_columns">2</property> - <property name="homogeneous">False</property> - <property name="row_spacing">6</property> - <property name="column_spacing">6</property> - - <child> - <widget class="GtkEntry" id="server-name-entry"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="editable">True</property> - <property name="visibility">True</property> - <property name="max_length">0</property> - <property name="text" translatable="yes"></property> - <property name="has_frame">True</property> - <property name="invisible_char" translatable="yes">*</property> - <property name="activates_default">False</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">0</property> - <property name="bottom_attach">1</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label44"> - <property name="visible">True</property> - <property name="label" translatable="yes">_Port:</property> - <property name="use_underline">True</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="mnemonic_widget">port-entry</property> - </widget> - <packing> - <property name="left_attach">0</property> - <property name="right_attach">1</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkCombo" id="port-combo"> - <property name="visible">True</property> - <property name="value_in_list">False</property> - <property name="allow_empty">True</property> - <property name="case_sensitive">False</property> - <property name="enable_arrow_keys">True</property> - <property name="enable_arrows_always">False</property> - - <child internal-child="entry"> - <widget class="GtkEntry" id="port-entry"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="editable">True</property> - <property name="visibility">True</property> - <property name="max_length">0</property> - <property name="text" translatable="yes"></property> - <property name="has_frame">True</property> - <property name="invisible_char" translatable="yes">*</property> - <property name="activates_default">False</property> - </widget> - </child> - - <child internal-child="list"> - <widget class="GtkList" id="combo-list1"> - <property name="visible">True</property> - <property name="selection_mode">GTK_SELECTION_BROWSE</property> - - <child> - <widget class="GtkListItem" id="listitem11"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="label" translatable="yes">389</property> - </widget> - </child> - - <child> - <widget class="GtkListItem" id="listitem12"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="label" translatable="yes">636</property> - </widget> - </child> - - <child> - <widget class="GtkListItem" id="listitem13"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="label" translatable="yes">3268</property> - </widget> - </child> - </widget> - </child> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkHBox" id="hbox15"> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">6</property> - - <child> - <widget class="GtkLabel" id="label50"> - <property name="visible">True</property> - <property name="label" translatable="yes">_Use secure connection:</property> - <property name="use_underline">True</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="mnemonic_widget">ssl-optionmenu</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - - <child> - <widget class="GtkOptionMenu" id="ssl-optionmenu"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="history">0</property> - - <child> - <widget class="GtkMenu" id="menu9"> - - <child> - <widget class="GtkMenuItem" id="always1"> - <property name="visible">True</property> - <property name="label" translatable="yes">Always</property> - <property name="use_underline">True</property> - <signal name="activate" handler="on_always1_activate" last_modification_time="Mon, 29 Mar 2004 21:37:12 GMT"/> - </widget> - </child> - - <child> - <widget class="GtkMenuItem" id=""> - <property name="visible">True</property> - <property name="label" translatable="yes">Whenever Possible</property> - <property name="use_underline">True</property> - <signal name="activate" handler="on_whenever_possible1_activate" last_modification_time="Mon, 29 Mar 2004 21:37:12 GMT"/> - </widget> - </child> - - <child> - <widget class="GtkMenuItem" id="never1"> - <property name="visible">True</property> - <property name="label" translatable="yes">Never</property> - <property name="use_underline">True</property> - <signal name="activate" handler="on_never1_activate" last_modification_time="Mon, 29 Mar 2004 21:37:12 GMT"/> - </widget> - </child> - </widget> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - </widget> - <packing> - <property name="left_attach">0</property> - <property name="right_attach">2</property> - <property name="top_attach">2</property> - <property name="bottom_attach">3</property> - <property name="x_options">fill</property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="server-name-label"> - <property name="visible">True</property> - <property name="label" translatable="yes">_Server:</property> - <property name="use_underline">True</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="mnemonic_widget">server-name-entry</property> - </widget> - <packing> - <property name="left_attach">0</property> - <property name="right_attach">1</property> - <property name="top_attach">0</property> - <property name="bottom_attach">1</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> - </child> - </widget> - </child> - - <child> - <widget class="GtkLabel" id="label39"> - <property name="visible">True</property> - <property name="label" translatable="yes"><b>Server Information</b></property> - <property name="use_underline">False</property> - <property name="use_markup">True</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="type">label_item</property> - </packing> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">True</property> - </packing> - </child> - - <child> - <widget class="GtkFrame" id="authentication-frame"> - <property name="visible">True</property> - <property name="label_xalign">0</property> - <property name="label_yalign">0.5</property> - <property name="shadow_type">GTK_SHADOW_NONE</property> - - <child> - <widget class="GtkTable" id="table9"> - <property name="border_width">12</property> - <property name="visible">True</property> - <property name="n_rows">2</property> - <property name="n_columns">2</property> - <property name="homogeneous">False</property> - <property name="row_spacing">6</property> - <property name="column_spacing">6</property> - - <child> - <widget class="GtkLabel" id="label46"> - <property name="visible">True</property> - <property name="label" translatable="yes">_Log in method:</property> - <property name="use_underline">True</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="mnemonic_widget">auth-optionmenu</property> - </widget> - <packing> - <property name="left_attach">0</property> - <property name="right_attach">1</property> - <property name="top_attach">0</property> - <property name="bottom_attach">1</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label47"> - <property name="visible">True</property> - <property name="label" translatable="yes">Lo_gin:</property> - <property name="use_underline">True</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="mnemonic_widget">auth-entry</property> - </widget> - <packing> - <property name="left_attach">0</property> - <property name="right_attach">1</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkEntry" id="auth-entry"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="editable">True</property> - <property name="visibility">True</property> - <property name="max_length">0</property> - <property name="text" translatable="yes"></property> - <property name="has_frame">True</property> - <property name="invisible_char" translatable="yes">*</property> - <property name="activates_default">False</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkOptionMenu" id="auth-optionmenu"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="history">0</property> - - <child> - <widget class="GtkMenu" id="menu8"> - - <child> - <widget class="GtkMenuItem" id="anonymously1"> - <property name="visible">True</property> - <property name="label" translatable="yes">Anonymously</property> - <property name="use_underline">True</property> - <signal name="activate" handler="on_anonymously1_activate" last_modification_time="Mon, 29 Mar 2004 21:27:10 GMT"/> - </widget> - </child> - - <child> - <widget class="GtkMenuItem" id="email_address2"> - <property name="visible">True</property> - <property name="label" translatable="yes">Email address</property> - <property name="use_underline">True</property> - <signal name="activate" handler="on_email_address2_activate" last_modification_time="Mon, 29 Mar 2004 21:27:10 GMT"/> - </widget> - </child> - - <child> - <widget class="GtkMenuItem" id="distinguished_name2"> - <property name="visible">True</property> - <property name="label" translatable="yes">Distinguished name</property> - <property name="use_underline">True</property> - <signal name="activate" handler="on_distinguished_name2_activate" last_modification_time="Mon, 29 Mar 2004 21:27:10 GMT"/> - </widget> - </child> - </widget> - </child> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">0</property> - <property name="bottom_attach">1</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> - </child> - </widget> - </child> - - <child> - <widget class="GtkLabel" id="label49"> - <property name="visible">True</property> - <property name="label" translatable="yes"><b>Authentication</b></property> - <property name="use_underline">False</property> - <property name="use_markup">True</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="type">label_item</property> - </packing> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">True</property> - <property name="fill">True</property> - </packing> - </child> - </widget> - <packing> - <property name="tab_expand">False</property> - <property name="tab_fill">True</property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="basic-label"> - <property name="visible">True</property> - <property name="label" translatable="yes">Basic</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="type">tab</property> - </packing> - </child> - - <child> - <widget class="GtkVBox" id="details-vbox"> - <property name="border_width">12</property> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">12</property> - - <child> - <widget class="GtkFrame" id="searching-frame"> - <property name="visible">True</property> - <property name="label_xalign">0</property> - <property name="label_yalign">0.5</property> - <property name="shadow_type">GTK_SHADOW_NONE</property> - - <child> - <widget class="GtkTable" id="table10"> - <property name="border_width">12</property> - <property name="visible">True</property> - <property name="n_rows">3</property> - <property name="n_columns">3</property> - <property name="homogeneous">False</property> - <property name="row_spacing">6</property> - <property name="column_spacing">6</property> - - <child> - <widget class="GtkLabel" id="label53"> - <property name="visible">True</property> - <property name="label" translatable="yes">Search _base:</property> - <property name="use_underline">True</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="mnemonic_widget">rootdn-entry</property> - </widget> - <packing> - <property name="left_attach">0</property> - <property name="right_attach">1</property> - <property name="top_attach">0</property> - <property name="bottom_attach">1</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label54"> - <property name="visible">True</property> - <property name="label" translatable="yes">_Search scope:</property> - <property name="use_underline">True</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="mnemonic_widget">scope-optionmenu</property> - </widget> - <packing> - <property name="left_attach">0</property> - <property name="right_attach">1</property> - <property name="top_attach">2</property> - <property name="bottom_attach">3</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkEntry" id="rootdn-entry"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="editable">True</property> - <property name="visibility">True</property> - <property name="max_length">0</property> - <property name="text" translatable="yes"></property> - <property name="has_frame">True</property> - <property name="invisible_char" translatable="yes">*</property> - <property name="activates_default">False</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">3</property> - <property name="top_attach">0</property> - <property name="bottom_attach">1</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkButton" id="rootdn-button"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="relief">GTK_RELIEF_NORMAL</property> - <property name="focus_on_click">True</property> - - <child> - <widget class="GtkAlignment" id="alignment13"> - <property name="visible">True</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xscale">0</property> - <property name="yscale">0</property> - <property name="top_padding">0</property> - <property name="bottom_padding">0</property> - <property name="left_padding">0</property> - <property name="right_padding">0</property> - - <child> - <widget class="GtkHBox" id="hbox16"> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">2</property> - - <child> - <widget class="GtkImage" id="image9"> - <property name="visible">True</property> - <property name="stock">gtk-find</property> - <property name="icon_size">4</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label57"> - <property name="visible">True</property> - <property name="label" translatable="yes">Find Possible Search Bases</property> - <property name="use_underline">True</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - </widget> - </child> - </widget> - </child> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkOptionMenu" id="scope-optionmenu"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="history">0</property> - - <child> - <widget class="GtkMenu" id="menu10"> - - <child> - <widget class="GtkMenuItem" id="one"> - <property name="visible">True</property> - <property name="label" translatable="yes">One</property> - <property name="use_underline">True</property> - </widget> - </child> - - <child> - <widget class="GtkMenuItem" id="sub"> - <property name="visible">True</property> - <property name="label" translatable="yes">Sub</property> - <property name="use_underline">True</property> - </widget> - </child> - </widget> - </child> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">3</property> - <property name="top_attach">2</property> - <property name="bottom_attach">3</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label55"> - <property name="visible">True</property> - <property name="label" translatable="yes"></property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="left_attach">0</property> - <property name="right_attach">1</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label56"> - <property name="visible">True</property> - <property name="label" translatable="yes"></property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="left_attach">2</property> - <property name="right_attach">3</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> - </child> - </widget> - </child> - - <child> - <widget class="GtkLabel" id="label51"> - <property name="visible">True</property> - <property name="label" translatable="yes"><b>Searching</b></property> - <property name="use_underline">False</property> - <property name="use_markup">True</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="type">label_item</property> - </packing> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - - <child> - <widget class="GtkFrame" id="downloading-frame"> - <property name="visible">True</property> - <property name="label_xalign">0</property> - <property name="label_yalign">0.5</property> - <property name="shadow_type">GTK_SHADOW_NONE</property> - - <child> - <widget class="GtkTable" id="table11"> - <property name="border_width">12</property> - <property name="visible">True</property> - <property name="n_rows">2</property> - <property name="n_columns">3</property> - <property name="homogeneous">False</property> - <property name="row_spacing">6</property> - <property name="column_spacing">6</property> - - <child> - <widget class="GtkLabel" id="label58"> - <property name="visible">True</property> - <property name="label" translatable="yes">_Timeout:</property> - <property name="use_underline">True</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="mnemonic_widget">timeout-scale</property> - </widget> - <packing> - <property name="left_attach">0</property> - <property name="right_attach">1</property> - <property name="top_attach">0</property> - <property name="bottom_attach">1</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label59"> - <property name="visible">True</property> - <property name="label" translatable="yes">minutes</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="left_attach">2</property> - <property name="right_attach">3</property> - <property name="top_attach">0</property> - <property name="bottom_attach">1</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkHBox" id="hbox17"> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">6</property> - - <child> - <widget class="GtkLabel" id="label60"> - <property name="visible">True</property> - <property name="label" translatable="yes">1</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - - <child> - <widget class="GtkHScale" id="timeout-scale"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="draw_value">False</property> - <property name="value_pos">GTK_POS_TOP</property> - <property name="digits">1</property> - <property name="update_policy">GTK_UPDATE_CONTINUOUS</property> - <property name="inverted">False</property> - <property name="adjustment">3 1 5 0.5 1 0</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">True</property> - <property name="fill">True</property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label61"> - <property name="visible">True</property> - <property name="label" translatable="yes">5</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">0</property> - <property name="bottom_attach">1</property> - <property name="y_options">fill</property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label62"> - <property name="visible">True</property> - <property name="label" translatable="yes">_Download limit:</property> - <property name="use_underline">True</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="mnemonic_widget">download-limit-spinbutton</property> - </widget> - <packing> - <property name="left_attach">0</property> - <property name="right_attach">1</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label63"> - <property name="visible">True</property> - <property name="label" translatable="yes">cards</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="left_attach">2</property> - <property name="right_attach">3</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkSpinButton" id="download-limit-spinbutton"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="climb_rate">1</property> - <property name="digits">0</property> - <property name="numeric">False</property> - <property name="update_policy">GTK_UPDATE_ALWAYS</property> - <property name="snap_to_ticks">False</property> - <property name="wrap">False</property> - <property name="adjustment">0 0 1000 1 10 10</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="y_options"></property> - </packing> - </child> - </widget> - </child> - - <child> - <widget class="GtkLabel" id="label52"> - <property name="visible">True</property> - <property name="label" translatable="yes"><b>Downloading</b></property> - <property name="use_underline">False</property> - <property name="use_markup">True</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="type">label_item</property> - </packing> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">True</property> - <property name="fill">True</property> - </packing> - </child> - </widget> - <packing> - <property name="tab_expand">False</property> - <property name="tab_fill">True</property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="details-label"> - <property name="visible">True</property> - <property name="label" translatable="yes">Details</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="type">tab</property> - </packing> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">True</property> - <property name="fill">True</property> - </packing> - </child> - </widget> - </child> -</widget> - -</glade-interface> diff --git a/addressbook/gui/component/select-names/.cvsignore b/addressbook/gui/component/select-names/.cvsignore deleted file mode 100644 index 1520453f86..0000000000 --- a/addressbook/gui/component/select-names/.cvsignore +++ /dev/null @@ -1,15 +0,0 @@ -.deps -.libs -.pure -Makefile -Makefile.in -*.lo -*.la -Evolution-Addressbook-SelectNames-stubs.c -Evolution-Addressbook-SelectNames-skels.c -Evolution-Addressbook-SelectNames-common.c -Evolution-Addressbook-SelectNames.h -GNOME_Evolution_Addressbook_SelectNames*.server -GNOME_Evolution_Addressbook_SelectNames*.server.in -e-select-names-marshal.c -e-select-names-marshal.h diff --git a/addressbook/gui/component/select-names/Evolution-Addressbook-SelectNames.idl b/addressbook/gui/component/select-names/Evolution-Addressbook-SelectNames.idl deleted file mode 100644 index 6feb6b54bb..0000000000 --- a/addressbook/gui/component/select-names/Evolution-Addressbook-SelectNames.idl +++ /dev/null @@ -1,42 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * CORBA interface for the SelectNames dialog. - * - * Authors: - * Ettore Perazzoli <ettore@ximian.com> - * - * Copyright (C) 2000 Ximian, Inc. - */ - -#include <Bonobo.idl> - -module GNOME { -module Evolution { -module Addressbook { - - interface SelectNames : Bonobo::Unknown { - struct Section { - string id; - string title; - }; - - typedef sequence<Section> SectionList; - - exception DuplicateID {}; - exception SectionNotFound {}; - - void addSection (in string id, in string title) - raises (DuplicateID); - void addSectionWithLimit (in string id, in string title, in short limit) - raises (DuplicateID); - - Bonobo::Control getEntryBySection (in string section_id) - raises (SectionNotFound); - - void activateDialog (in string section_id); - }; - - -}; -}; -}; diff --git a/addressbook/gui/component/select-names/GNOME_Evolution_Addressbook_SelectNames.server.in.in b/addressbook/gui/component/select-names/GNOME_Evolution_Addressbook_SelectNames.server.in.in deleted file mode 100644 index 0a9f975463..0000000000 --- a/addressbook/gui/component/select-names/GNOME_Evolution_Addressbook_SelectNames.server.in.in +++ /dev/null @@ -1,31 +0,0 @@ -<oaf_info> - -<!-- -<oaf_server iid="OAFIID:GNOME_Evolution_Addressbook_SelectNamesFactory:@VERSION@" - type="shlib" - location="@COMPONENTDIR@/libevolution-addressbook.so"> - - <oaf_attribute name="repo_ids" type="stringv"> - <item value="IDL:GNOME/ObjectFactory:1.0"/> - </oaf_attribute> - - <oaf_attribute name="name" type="string" - _value="Evolution Addressbook name selection interface"/> - -</oaf_server> ---> - -<oaf_server iid="OAFIID:GNOME_Evolution_Addressbook_SelectNames:@VERSION@" - type="factory" - location="OAFIID:GNOME_Evolution_Addressbook_Factory:@VERSION@"> - - <oaf_attribute name="repo_ids" type="stringv"> - <item value="IDL:GNOME/Evolution/Addressbook/SelectNames:@VERSION@"/> - </oaf_attribute> - - <oaf_attribute name="name" type="string" - _value="Evolution Addressbook name selection interface"/> - -</oaf_server> - -</oaf_info> diff --git a/addressbook/gui/component/select-names/Makefile.am b/addressbook/gui/component/select-names/Makefile.am deleted file mode 100644 index c8d0b83052..0000000000 --- a/addressbook/gui/component/select-names/Makefile.am +++ /dev/null @@ -1,96 +0,0 @@ -# CORBA stuff - -idl_DATA = \ - Evolution-Addressbook-SelectNames.idl - -IDL_GENERATED_H = \ - Evolution-Addressbook-SelectNames.h -IDL_GENERATED_C = \ - Evolution-Addressbook-SelectNames-common.c \ - Evolution-Addressbook-SelectNames-skels.c \ - Evolution-Addressbook-SelectNames-stubs.c -IDL_GENERATED = $(IDL_GENERATED_C) $(IDL_GENERATED_H) - -$(IDL_GENERATED_H): $(idl_DATA) - $(ORBIT_IDL) -I $(srcdir) $(IDL_INCLUDES) \ - $(srcdir)/Evolution-Addressbook-SelectNames.idl -$(IDL_GENERATED_C): $(IDL_GENERATED_H) - -server_in_files = GNOME_Evolution_Addressbook_SelectNames.server.in.in -server_DATA = $(server_in_files:.server.in.in=_$(BASE_VERSION).server) -@EVO_SERVER_RULE@ -@INTLTOOL_SERVER_RULE@ - -INCLUDES = \ - -DG_LOG_DOMAIN=\"evolution-addressbook\" \ - -I$(top_srcdir) \ - -I$(top_builddir) \ - -I$(top_srcdir)/shell \ - -I$(top_builddir)/shell \ - -I$(top_srcdir)/widgets/misc \ - -I$(top_srcdir)/addressbook/gui/minicard \ - -I$(top_srcdir)/addressbook/gui/widgets \ - -I$(top_srcdir)/addressbook/contact-editor \ - -I$(top_srcdir)/addressbook/backend \ - -I$(top_builddir)/addressbook/backend \ - -I$(top_srcdir)/addressbook/util \ - -DEVOLUTION_IMAGESDIR=\""$(imagesdir)"\" \ - -DEVOLUTION_DATADIR=\""$(datadir)"\" \ - -DEVOLUTION_GLADEDIR=\""$(gladedir)"\" \ - -DEVOLUTION_ETSPECDIR=\""$(etspecdir)"\" \ - -DEVOLUTION_UIDIR=\""$(evolutionuidir)"\" \ - -DPREFIX=\""$(prefix)"\" \ - $(EVOLUTION_ADDRESSBOOK_CFLAGS) - -privlib_LTLIBRARIES = libeselectnames.la - -libeselectnames_la_SOURCES = \ - $(IDL_GENERATED) \ - $(MARSHAL_GENERATED) \ - e-select-names-bonobo.c \ - e-select-names-bonobo.h \ - e-select-names-completion.c \ - e-select-names-completion.h \ - e-select-names-config.c \ - e-select-names-config.h \ - e-select-names-config-keys.h \ - e-select-names-manager.c \ - e-select-names-manager.h \ - e-select-names-model.c \ - e-select-names-model.h \ - e-select-names-popup.c \ - e-select-names-popup.h \ - e-select-names-table-model.c \ - e-select-names-table-model.h \ - e-select-names-text-model.c \ - e-select-names-text-model.h \ - e-select-names.c \ - e-select-names.h - -libeselectnames_la_LIBADD = \ - $(EVOLUTION_ADDRESSBOOK_LIBS) - -# We'll need these again when we split out the select names control -# into its own shlib factory, but for now they're redundant. -# -# e-select-names-factory.c -# e-select-names-factory.h - -MARSHAL_GENERATED = e-select-names-marshal.c e-select-names-marshal.h -@EVO_MARSHAL_RULE@ - -glade_DATA = select-names.glade -etspec_DATA = e-select-names.etspec e-select-names-section.etspec - -EXTRA_DIST = \ - $(glade_DATA) \ - $(server_in_files) \ - $(idl_DATA) \ - $(etspec_DATA) \ - e-select-names-marshal.list - -BUILT_SOURCES = $(IDL_GENERATED) $(MARSHAL_GENERATED) $(server_DATA) -CLEANFILES = $(BUILT_SOURCES) - -dist-hook: - cd $(distdir); rm -f $(BUILT_SOURCES) diff --git a/addressbook/gui/component/select-names/e-select-names-bonobo.c b/addressbook/gui/component/select-names/e-select-names-bonobo.c deleted file mode 100644 index 9c0245ff46..0000000000 --- a/addressbook/gui/component/select-names/e-select-names-bonobo.c +++ /dev/null @@ -1,600 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-select-names-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. - * - * Author: Ettore Perazzoli - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include "e-select-names-bonobo.h" - -#include <bonobo-activation/bonobo-activation-activate.h> - -#include <bonobo/bonobo-property-bag.h> -#include <bonobo/bonobo-control.h> -#include <bonobo/bonobo-exception.h> -#include <bonobo/bonobo-event-source.h> -#include <bonobo/bonobo-ui-util.h> - -#include <gal/util/e-util.h> -#include <gal/e-text/e-entry.h> -#include <gal/util/e-text-event-processor.h> - -#include "Evolution-Addressbook-SelectNames.h" - -#include "e-select-names-manager.h" -#include "e-select-names-model.h" -#include "e-select-names-text-model.h" -#include "e-select-names-completion.h" - -#include <string.h> - - -#define PARENT_TYPE BONOBO_TYPE_OBJECT -static BonoboObjectClass *parent_class = NULL; - -struct _ESelectNamesBonoboPrivate { - ESelectNamesManager *manager; - BonoboEventSource *event_source; -}; - -enum _EntryPropertyID { - ENTRY_PROPERTY_ID_TEXT, - ENTRY_PROPERTY_ID_ADDRESSES, - ENTRY_PROPERTY_ID_DESTINATIONS, - ENTRY_PROPERTY_ID_ALLOW_CONTACT_LISTS, - ENTRY_PROPERTY_ID_ENTRY_CHANGED -}; -typedef enum _EntryPropertyID EntryPropertyID; - - -/* PropertyBag implementation for the entry widgets. */ - -static void -entry_get_property_fn (BonoboPropertyBag *bag, - BonoboArg *arg, - unsigned int arg_id, - CORBA_Environment *ev, - void *user_data) -{ - GtkWidget *w; - - w = GTK_WIDGET (user_data); - - switch (arg_id) { - case ENTRY_PROPERTY_ID_TEXT: - { - ETextModel *text_model; - text_model = E_TEXT_MODEL (g_object_get_data (G_OBJECT (w), "select_names_text_model")); - g_assert (text_model != NULL); - - BONOBO_ARG_SET_STRING (arg, e_text_model_get_text (text_model)); - break; - } - - case ENTRY_PROPERTY_ID_ADDRESSES: - { - ESelectNamesModel *model; - char *text; - - model = E_SELECT_NAMES_MODEL (g_object_get_data (G_OBJECT (w), "select_names_model")); - g_assert (model != NULL); - - text = e_select_names_model_get_address_text (model, ", "); - BONOBO_ARG_SET_STRING (arg, text); - g_free (text); - } - break; - - case ENTRY_PROPERTY_ID_DESTINATIONS: - { - ESelectNamesModel *model; - char *text; - - model = E_SELECT_NAMES_MODEL (g_object_get_data (G_OBJECT (w), "select_names_model")); - g_assert (model != NULL); - - text = e_select_names_model_export_destinationv (model); - BONOBO_ARG_SET_STRING (arg, text); - g_free (text); - } - break; - - case ENTRY_PROPERTY_ID_ALLOW_CONTACT_LISTS: - { - ESelectNamesCompletion *comp; - comp = E_SELECT_NAMES_COMPLETION (g_object_get_data (G_OBJECT (w), "completion_handler")); - g_assert (comp != NULL); - - BONOBO_ARG_SET_BOOLEAN (arg, e_select_names_completion_get_match_contact_lists (comp)); - break; - } - - case ENTRY_PROPERTY_ID_ENTRY_CHANGED: - /* This is a read-only property. */ - g_assert_not_reached (); - break; - - default: - break; - } -} - -static void -entry_set_property_fn (BonoboPropertyBag *bag, - const BonoboArg *arg, - guint arg_id, - CORBA_Environment *ev, - gpointer user_data) -{ - GtkWidget *w; - - w = GTK_WIDGET (user_data); - - switch (arg_id) { - - case ENTRY_PROPERTY_ID_TEXT: - case ENTRY_PROPERTY_ID_ADDRESSES: - { - ESelectNamesModel *model; - model = E_SELECT_NAMES_MODEL (g_object_get_data (G_OBJECT (w), "select_names_model")); - g_assert (model != NULL); - - e_entry_set_text (E_ENTRY (w), BONOBO_ARG_GET_STRING (arg)); - e_select_names_model_load_contacts (model); - break; - } - - case ENTRY_PROPERTY_ID_DESTINATIONS: - { - ESelectNamesModel *model; - model = E_SELECT_NAMES_MODEL (g_object_get_data (G_OBJECT (w), "select_names_model")); - g_assert (model != NULL); - - e_select_names_model_import_destinationv (model, BONOBO_ARG_GET_STRING (arg)); - e_select_names_model_load_contacts (model); - break; - } - - case ENTRY_PROPERTY_ID_ALLOW_CONTACT_LISTS: - { - ESelectNamesCompletion *comp; - comp = E_SELECT_NAMES_COMPLETION (g_object_get_data (G_OBJECT (w), "completion_handler")); - g_assert (comp != NULL); - - e_select_names_completion_set_match_contact_lists (comp, BONOBO_ARG_GET_BOOLEAN (arg)); - break; - } - - case ENTRY_PROPERTY_ID_ENTRY_CHANGED: - g_object_set_data (G_OBJECT (w), "entry_property_id_changed", GUINT_TO_POINTER (1)); - break; - - default: - break; - } -} - -static void -impl_SelectNames_add_section (PortableServer_Servant servant, - const CORBA_char *id, - const CORBA_char *title, - CORBA_Environment *ev) -{ - ESelectNamesBonobo *select_names; - ESelectNamesBonoboPrivate *priv; - - select_names = E_SELECT_NAMES_BONOBO (bonobo_object (servant)); - priv = select_names->priv; - - e_select_names_manager_add_section (priv->manager, id, title); -} - -static void -impl_SelectNames_add_section_with_limit (PortableServer_Servant servant, - const CORBA_char *id, - const CORBA_char *title, - CORBA_short limit, - CORBA_Environment *ev) -{ - ESelectNamesBonobo *select_names; - ESelectNamesBonoboPrivate *priv; - - select_names = E_SELECT_NAMES_BONOBO (bonobo_object (servant)); - priv = select_names->priv; - - e_select_names_manager_add_section_with_limit (priv->manager, id, title, limit); -} - -static void -entry_changed (GtkWidget *widget, BonoboControl *control) -{ - gboolean changed = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (widget), "entry_property_id_changed")); - - if (!changed) - bonobo_control_set_property (control, NULL, "entry_changed", TC_CORBA_boolean, TRUE, NULL); -} - -static void -manager_changed_cb (ESelectNamesManager *manager, const gchar *section_id, gint changed_working_copy, gpointer closure) -{ - ESelectNamesBonobo *select_names = E_SELECT_NAMES_BONOBO (closure); - BonoboArg *arg; - - arg = bonobo_arg_new (BONOBO_ARG_STRING); - BONOBO_ARG_SET_STRING (arg, section_id); - - bonobo_event_source_notify_listeners_full (select_names->priv->event_source, - "GNOME/Evolution", - "changed", - changed_working_copy ? "working_copy" : "model", - arg, NULL); - - bonobo_arg_release (arg); -} - -static void -manager_ok_cb (ESelectNamesManager *manager, gpointer closure) -{ - ESelectNamesBonobo *select_names = E_SELECT_NAMES_BONOBO (closure); - BonoboArg *arg; - - arg = bonobo_arg_new (BONOBO_ARG_NULL); - - bonobo_event_source_notify_listeners_full (select_names->priv->event_source, - "GNOME/Evolution", - "ok", - "dialog", - arg, - NULL); - - bonobo_arg_release (arg); -} - -static void -copy_cb (BonoboUIComponent *ui, gpointer user_data, const char *command) -{ - EEntry *entry = E_ENTRY (user_data); - - e_text_copy_clipboard (entry->item); -} - -static void -cut_cb (BonoboUIComponent *ui, gpointer user_data, const char *command) -{ - EEntry *entry = E_ENTRY (user_data); - - e_text_cut_clipboard (entry->item); -} - -static void -paste_cb (BonoboUIComponent *ui, gpointer user_data, const char *command) -{ - EEntry *entry = E_ENTRY (user_data); - - e_text_paste_clipboard (entry->item); -} - -static void -select_all_cb (BonoboUIComponent *ui, gpointer user_data, const char *command) -{ - EEntry *entry = E_ENTRY (user_data); - - e_text_select_all (entry->item); -} - -static BonoboUIVerb verbs [] = { - BONOBO_UI_VERB ("EditCut", cut_cb), - BONOBO_UI_VERB ("EditCopy", copy_cb), - BONOBO_UI_VERB ("EditPaste", paste_cb), - BONOBO_UI_VERB ("EditSelectAll", select_all_cb), - BONOBO_UI_VERB_END -}; - -typedef struct { - GtkWidget *widget; - BonoboControl *control; - Bonobo_UIContainer remote_ui_container; - char *ui_xml_path; - char *app_name; - BonoboUIVerb *verbs; - gpointer user_data; -} ControlUIClosure; - -static void -free_closure (ControlUIClosure *closure, - GtkObject *where_object_was) -{ - bonobo_object_release_unref (closure->remote_ui_container, NULL); - g_free (closure->ui_xml_path); - g_free (closure->app_name); - g_free (closure); -} - -static void -merge_menu_items (BonoboControl *control, BonoboUIComponent *uic, ControlUIClosure *closure) -{ - if (closure->remote_ui_container) { - bonobo_ui_component_set_container (uic, closure->remote_ui_container, NULL); - - bonobo_ui_component_add_verb_list_with_data (uic, closure->verbs, closure->user_data); - - bonobo_ui_component_freeze (uic, NULL); - - bonobo_ui_util_set_ui (uic, PREFIX, - closure->ui_xml_path, - closure->app_name, NULL); - - bonobo_ui_component_thaw (uic, NULL); - } -} - -static void -unmerge_menu_items (BonoboControl *control, BonoboUIComponent *uic, ControlUIClosure *closure) -{ - bonobo_ui_component_unset_container (uic, NULL); -} - -static void -control_set_frame_cb (BonoboControl *control, - ControlUIClosure *closure) -{ - Bonobo_ControlFrame frame = bonobo_control_get_control_frame (control, - NULL); - if (!frame) - return; - closure->remote_ui_container = bonobo_control_get_remote_ui_container (control, NULL); -} - -static void -control_activate_cb (BonoboControl *control, - gboolean activate, - ControlUIClosure *closure) -{ - if (activate) - gtk_widget_grab_focus (closure->widget); /* the ECanvas */ -} - -static gboolean -widget_focus_cb (GtkWidget *w, GdkEventFocus *focus, ControlUIClosure *closure) -{ - BonoboUIComponent *uic; - - uic = bonobo_control_get_ui_component (closure->control); - - if (GTK_WIDGET_HAS_FOCUS (w)) { - merge_menu_items (closure->control, uic, closure); - } else { - unmerge_menu_items (closure->control, uic, closure); - } - - return FALSE; -} - -static void -e_bonobo_control_automerge_ui (GtkWidget *w, - BonoboControl *control, - const char *ui_xml_path, - const char *app_name, - BonoboUIVerb *verbs, - gpointer data) -{ - ControlUIClosure *closure; - - g_return_if_fail (GTK_IS_WIDGET (w)); - g_return_if_fail (BONOBO_IS_CONTROL (control)); - g_return_if_fail (ui_xml_path != NULL); - g_return_if_fail (app_name != NULL); - g_return_if_fail (verbs != NULL); - - closure = g_new (ControlUIClosure, 1); - - closure->widget = w; - closure->control = control; - closure->ui_xml_path = g_strdup (ui_xml_path); - closure->app_name = g_strdup (app_name); - closure->verbs = verbs; - closure->user_data = data; - - g_signal_connect (w, "focus_in_event", - G_CALLBACK (widget_focus_cb), closure); - g_signal_connect (w, "focus_out_event", - G_CALLBACK (widget_focus_cb), closure); - g_signal_connect (control, "activate", - G_CALLBACK (control_activate_cb), closure); - g_signal_connect (control, "set_frame", - G_CALLBACK (control_set_frame_cb), closure); - - g_object_weak_ref (G_OBJECT (control), (GWeakNotify)free_closure, closure); -} - -static Bonobo_Control -impl_SelectNames_get_entry_for_section (PortableServer_Servant servant, - const CORBA_char *section_id, - CORBA_Environment *ev) -{ - ESelectNamesBonobo *select_names; - ESelectNamesBonoboPrivate *priv; - GtkWidget *entry_widget; - BonoboControl *control; - BonoboPropertyBag *property_bag; - - select_names = E_SELECT_NAMES_BONOBO (bonobo_object (servant)); - priv = select_names->priv; - - entry_widget = e_select_names_manager_create_entry (priv->manager, section_id); - gtk_widget_show (entry_widget); - - if (entry_widget == NULL) { - CORBA_exception_set (ev, - CORBA_USER_EXCEPTION, - ex_GNOME_Evolution_Addressbook_SelectNames_SectionNotFound, - NULL); - return CORBA_OBJECT_NIL; - } - - control = bonobo_control_new (entry_widget); - - property_bag = bonobo_property_bag_new (entry_get_property_fn, entry_set_property_fn, entry_widget); - bonobo_property_bag_add (property_bag, "text", ENTRY_PROPERTY_ID_TEXT, - BONOBO_ARG_STRING, NULL, NULL, - BONOBO_PROPERTY_READABLE | BONOBO_PROPERTY_WRITEABLE); - bonobo_property_bag_add (property_bag, "addresses", ENTRY_PROPERTY_ID_ADDRESSES, - BONOBO_ARG_STRING, NULL, NULL, - BONOBO_PROPERTY_READABLE | BONOBO_PROPERTY_WRITEABLE); - 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, "allow_contact_lists", ENTRY_PROPERTY_ID_ALLOW_CONTACT_LISTS, - BONOBO_ARG_BOOLEAN, NULL, NULL, - BONOBO_PROPERTY_READABLE | BONOBO_PROPERTY_WRITEABLE); - bonobo_property_bag_add (property_bag, "entry_changed", ENTRY_PROPERTY_ID_ENTRY_CHANGED, - BONOBO_ARG_BOOLEAN, NULL, NULL, - BONOBO_PROPERTY_WRITEABLE); - - bonobo_control_set_properties (control, bonobo_object_corba_objref (BONOBO_OBJECT (property_bag)), NULL); - bonobo_object_unref (BONOBO_OBJECT (property_bag)); - - g_signal_connect (entry_widget, "changed", G_CALLBACK (entry_changed), control); - - e_bonobo_control_automerge_ui (GTK_WIDGET (E_ENTRY (entry_widget)->canvas), - control, - EVOLUTION_UIDIR "/evolution-composer-entries.xml", - "evolution-addressbook", - verbs, entry_widget); - - return CORBA_Object_duplicate (bonobo_object_corba_objref (BONOBO_OBJECT (control)), ev); -} - -static void -impl_SelectNames_activate_dialog (PortableServer_Servant servant, - const CORBA_char *section_id, - CORBA_Environment *ev) -{ - ESelectNamesBonobo *select_names; - ESelectNamesBonoboPrivate *priv; - - select_names = E_SELECT_NAMES_BONOBO (bonobo_object (servant)); - priv = select_names->priv; - - e_select_names_manager_activate_dialog (priv->manager, section_id); -} - - -/* GtkObject methods. */ - -static void -impl_dispose (GObject *object) -{ - ESelectNamesBonobo *select_names; - ESelectNamesBonoboPrivate *priv; - - select_names = E_SELECT_NAMES_BONOBO (object); - priv = select_names->priv; - - if (priv) { - if (priv->manager->names) { - gtk_widget_destroy (GTK_WIDGET (priv->manager->names)); - priv->manager->names = NULL; - } - - g_object_unref (priv->manager); - - g_free (priv); - select_names->priv = NULL; - } - - if (G_OBJECT_CLASS (parent_class)->dispose) - G_OBJECT_CLASS (parent_class)->dispose (object); -} - - -static void -e_select_names_bonobo_class_init (ESelectNamesBonoboClass *klass) -{ - GObjectClass *object_class; - POA_GNOME_Evolution_Addressbook_SelectNames__epv *epv; - - object_class = G_OBJECT_CLASS (klass); - parent_class = g_type_class_peek_parent (klass); - - object_class->dispose = impl_dispose; - - epv = &klass->epv; - epv->addSection = impl_SelectNames_add_section; - epv->addSectionWithLimit = impl_SelectNames_add_section_with_limit; - epv->getEntryBySection = impl_SelectNames_get_entry_for_section; - epv->activateDialog = impl_SelectNames_activate_dialog; -} - -static void -e_select_names_bonobo_init (ESelectNamesBonobo *select_names) -{ - ESelectNamesBonoboPrivate *priv; - - priv = g_new (ESelectNamesBonoboPrivate, 1); - - priv->manager = e_select_names_manager_new (); - priv->event_source = NULL; - - g_signal_connect (priv->manager, - "changed", - G_CALLBACK (manager_changed_cb), - select_names); - - g_signal_connect (priv->manager, - "ok", - G_CALLBACK (manager_ok_cb), - select_names); - - select_names->priv = priv; -} - - -static void -e_select_names_bonobo_construct (ESelectNamesBonobo *select_names) -{ - g_return_if_fail (select_names != NULL); - g_return_if_fail (E_IS_SELECT_NAMES_BONOBO (select_names)); - - g_assert (select_names->priv->event_source == NULL); - select_names->priv->event_source = bonobo_event_source_new (); - bonobo_object_add_interface (BONOBO_OBJECT (select_names), BONOBO_OBJECT (select_names->priv->event_source)); -} - -ESelectNamesBonobo * -e_select_names_bonobo_new (void) -{ - ESelectNamesBonobo *select_names; - - select_names = g_object_new (E_TYPE_SELECT_NAMES_BONOBO, NULL); - - e_select_names_bonobo_construct (select_names); - - return select_names; -} - - -BONOBO_TYPE_FUNC_FULL ( - ESelectNamesBonobo, - GNOME_Evolution_Addressbook_SelectNames, - PARENT_TYPE, - e_select_names_bonobo); diff --git a/addressbook/gui/component/select-names/e-select-names-bonobo.h b/addressbook/gui/component/select-names/e-select-names-bonobo.h deleted file mode 100644 index 5b04ed5b2e..0000000000 --- a/addressbook/gui/component/select-names/e-select-names-bonobo.h +++ /dev/null @@ -1,66 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-select-names-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. - * - * Author: Ettore Perazzoli - */ - -#ifndef __E_SELECT_NAMES_BONOBO_H__ -#define __E_SELECT_NAMES_BONOBO_H__ - -#include <bonobo/bonobo-object.h> - -#include "Evolution-Addressbook-SelectNames.h" - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - -#define E_TYPE_SELECT_NAMES_BONOBO (e_select_names_bonobo_get_type ()) -#define E_SELECT_NAMES_BONOBO(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_SELECT_NAMES_BONOBO, ESelectNamesBonobo)) -#define E_SELECT_NAMES_BONOBO_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_SELECT_NAMES_BONOBO, ESelectNamesBonoboClass)) -#define E_IS_SELECT_NAMES_BONOBO(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_SELECT_NAMES_BONOBO)) -#define E_IS_SELECT_NAMES_BONOBO_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), E_TYPE_SELECT_NAMES_BONOBO)) - - -typedef struct _ESelectNamesBonobo ESelectNamesBonobo; -typedef struct _ESelectNamesBonoboPrivate ESelectNamesBonoboPrivate; -typedef struct _ESelectNamesBonoboClass ESelectNamesBonoboClass; - -struct _ESelectNamesBonobo { - BonoboObject parent; - - ESelectNamesBonoboPrivate *priv; -}; - -struct _ESelectNamesBonoboClass { - BonoboObjectClass parent_class; - - POA_GNOME_Evolution_Addressbook_SelectNames__epv epv; -}; - - -GType e_select_names_bonobo_get_type (void); -ESelectNamesBonobo *e_select_names_bonobo_new (void); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* __E_SELECT_NAMES_BONOBO_H__ */ diff --git a/addressbook/gui/component/select-names/e-select-names-completion.c b/addressbook/gui/component/select-names/e-select-names-completion.c deleted file mode 100644 index 2bf0341e40..0000000000 --- a/addressbook/gui/component/select-names/e-select-names-completion.c +++ /dev/null @@ -1,1236 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * e-select-names-completion.c - * - * Copyright (C) 2001 Ximian, Inc. - * - * Developed by Jon Trowbridge <trow@ximian.com> - */ - -/* - * 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. - */ - -#include <config.h> -#include "e-select-names-completion.h" - -#include <ctype.h> -#include <stdio.h> -#include <string.h> -#include <math.h> - -#include <gtk/gtksignal.h> - -#include <libebook/e-contact.h> -#include <addressbook/util/eab-book-util.h> -#include <addressbook/util/e-destination.h> -#include <addressbook/gui/merging/eab-contact-compare.h> - -#include <e-util/e-sexp.h> - -typedef struct { - EBook *book; - guint book_view_tag; - EBookView *book_view; - ESelectNamesCompletion *comp; - guint contacts_added_tag; - guint seq_complete_tag; - gboolean sequence_complete_received; - - gchar *cached_query_text; - GList *cached_cards; - gboolean cache_complete; - -} ESelectNamesCompletionBookData; - -struct _ESelectNamesCompletionPrivate { - - ESelectNamesTextModel *text_model; - - GList *book_data; - gint books_not_ready; - gint pending_completion_seq; - - gchar *waiting_query; - gint waiting_pos, waiting_limit; - gchar *query_text; - - gboolean match_contact_lists; - - gint minimum_query_length; -}; - -static void e_select_names_completion_class_init (ESelectNamesCompletionClass *); -static void e_select_names_completion_init (ESelectNamesCompletion *); -static void e_select_names_completion_dispose (GObject *object); - -static void e_select_names_completion_got_book_view_cb (EBook *book, EBookStatus status, EBookView *view, gpointer user_data); -static void e_select_names_completion_contacts_added_cb (EBookView *, const GList *cards, gpointer user_data); -static void e_select_names_completion_seq_complete_cb (EBookView *, EBookViewStatus status, gpointer user_data); - -static void e_select_names_completion_do_query (ESelectNamesCompletion *, const gchar *query_text, gint pos, gint limit); - -static void e_select_names_completion_handle_request (ECompletion *, const gchar *txt, gint pos, gint limit); -static void e_select_names_completion_end (ECompletion *); - -static GObjectClass *parent_class; - -static FILE *out; - -/* - * - * Query builders - * - */ - -typedef gchar *(*BookQuerySExp) (ESelectNamesCompletion *); -typedef ECompletionMatch *(*BookQueryMatchTester) (ESelectNamesCompletion *, EDestination *); - -static int -utf8_casefold_collate_len (const gchar *str1, const gchar *str2, int len) -{ - gchar *s1 = g_utf8_casefold(str1, len); - gchar *s2 = g_utf8_casefold(str2, len); - int rv; - - rv = g_utf8_collate (s1, s2); - - g_free (s1); - g_free (s2); - - return rv; -} - -static int -utf8_casefold_collate (const gchar *str1, const gchar *str2) -{ - return utf8_casefold_collate_len (str1, str2, -1); -} - -static void -our_match_destroy (ECompletionMatch *match) -{ - g_object_unref (match->user_data); -} - -static ECompletionMatch * -make_match (EDestination *dest, const gchar *menu_form, double score) -{ - ECompletionMatch *match; -#if notyet - EContact *contact = e_destination_get_contact (dest); -#endif - - match = e_completion_match_new (e_destination_get_name (dest), menu_form, score); - - e_completion_match_set_text (match, e_destination_get_name (dest), menu_form); - - /* Reject any match that has null text fields. */ - if (! (e_completion_match_get_match_text (match) && e_completion_match_get_menu_text (match))) { - g_object_unref (match); - return NULL; - } - -#if notyet - /* XXX toshok - EContact doesn't have the use_score stuff */ - /* Since we sort low to high, we negate so that larger use scores will come first */ - match->sort_major = contact ? -floor (e_contact_get_use_score (contact)) : 0; -#else - match->sort_major = 0; -#endif - - match->sort_minor = e_destination_get_email_num (dest); - - match->user_data = g_object_ref (dest); - - match->destroy = our_match_destroy; - - return match; -} - -/* - * Nickname query - */ - -static gchar * -sexp_nickname (ESelectNamesCompletion *comp) -{ - gchar *query = g_strdup_printf ("(beginswith \"nickname\" \"%s\")", comp->priv->query_text); - - return query; -} - -static ECompletionMatch * -match_nickname (ESelectNamesCompletion *comp, EDestination *dest) -{ - ECompletionMatch *match = NULL; - gint len; - EContact *contact = e_destination_get_contact (dest); - double score; - const char *nickname; - - nickname = e_contact_get_const (contact, E_CONTACT_NICKNAME); - if (nickname == NULL) - return NULL; - - len = g_utf8_strlen (comp->priv->query_text, -1); - if (nickname && !utf8_casefold_collate_len (comp->priv->query_text, nickname, len)) { - const gchar *name; - gchar *str; - - score = len * 2; /* nickname gives 2 points per matching character */ - - if (len == g_utf8_strlen (nickname, -1)) /* boost score on an exact match */ - score *= 10; - - name = e_destination_get_name (dest); - if (name && *name) - str = g_strdup_printf ("'%s' %s <%s>", nickname, name, e_destination_get_email (dest)); - else - str = g_strdup_printf ("'%s' <%s>", nickname, e_destination_get_email (dest)); - - match = make_match (dest, str, score); - g_free (str); - } - - return match; -} - -/* - * E-Mail Query - */ - -static gchar * -sexp_email (ESelectNamesCompletion *comp) -{ - return g_strdup_printf ("(beginswith \"email\" \"%s\")", comp->priv->query_text); -} - -static ECompletionMatch * -match_email (ESelectNamesCompletion *comp, EDestination *dest) -{ - ECompletionMatch *match; - gint len = strlen (comp->priv->query_text); - const gchar *name = e_destination_get_name (dest); - const gchar *email = e_destination_get_email (dest); - double score; - - if (email - && !utf8_casefold_collate_len (comp->priv->query_text, email, len) - && !e_destination_is_evolution_list (dest)) { - - gchar *str; - - score = len * 2; /* 2 points for each matching character */ - - if (name && *name) - str = g_strdup_printf ("<%s> %s", email, name); - else - str = g_strdup (email); - - match = make_match (dest, str, score); - - g_free (str); - - return match; - } - - return NULL; -} - -/* - * Name Query - */ - -static gchar * -name_style_query (ESelectNamesCompletion *comp, const gchar *field) -{ - if (comp && comp->priv->query_text && *comp->priv->query_text) { - gchar *cpy = g_strdup (comp->priv->query_text), *c; - gchar **strv; - gchar *query; - gint i; - GString *out = g_string_new(""); - - for (c = cpy; *c; ++c) { - if (*c == ',') - *c = ' '; - } - - strv = g_strsplit (cpy, " ", 0); - if (strv[0] && strv[1]) - g_string_append(out, "(and "); - for (i=0; strv[i]; ++i) { - if (i==0) - g_string_append(out, "(beginswith "); - else - g_string_append(out, " (beginswith "); - e_sexp_encode_string(out, field); - g_strstrip(strv[i]); - e_sexp_encode_string(out, strv[i]); - g_string_append(out, ")"); - } - if (strv[0] && strv[1]) - g_string_append(out, ")"); - - query = out->str; - g_string_free(out, FALSE); - - g_free (cpy); - g_strfreev (strv); - - return query; - } - - return NULL; -} - -static gchar * -sexp_name (ESelectNamesCompletion *comp) -{ - return name_style_query (comp, "full_name"); -} - -static ECompletionMatch * -match_name (ESelectNamesCompletion *comp, EDestination *dest) -{ - ECompletionMatch *final_match = NULL; - gchar *menu_text = NULL; - EContact *contact; - const gchar *email; - gint match_len = 0; - EABContactMatchType match; - EABContactMatchPart first_match; - double score = 0; - gboolean have_given, have_additional, have_family; - EContactName *contact_name; - - contact = e_destination_get_contact (dest); - - contact_name = e_contact_get (contact, E_CONTACT_NAME); - if (!contact_name) - return NULL; - - email = e_destination_get_email (dest); - - match = eab_contact_compare_name_to_string_full (contact, comp->priv->query_text, TRUE /* yes, allow partial matches */, - NULL, &first_match, &match_len); - - if (match <= EAB_CONTACT_MATCH_NONE) { - e_contact_name_free (contact_name); - return NULL; - } - - score = match_len * 3; /* three points per match character */ - - have_given = contact_name->given && *contact_name->given; - have_additional = contact_name->additional && *contact_name->additional; - have_family = contact_name->family && *contact_name->family; - - if (e_contact_get (contact, E_CONTACT_IS_LIST)) { - - menu_text = e_contact_name_to_string (contact_name); - - } else if (first_match == EAB_CONTACT_MATCH_PART_GIVEN_NAME) { - - if (have_family) - menu_text = g_strdup_printf ("%s %s <%s>", contact_name->given, contact_name->family, email); - else - menu_text = g_strdup_printf ("%s <%s>", contact_name->given, email); - - } else if (first_match == EAB_CONTACT_MATCH_PART_ADDITIONAL_NAME) { - - if (have_given) { - - menu_text = g_strdup_printf ("%s%s%s, %s <%s>", - contact_name->additional, - have_family ? " " : "", - have_family ? contact_name->family : "", - contact_name->given, - email); - } else { - - menu_text = g_strdup_printf ("%s%s%s <%s>", - contact_name->additional, - have_family ? " " : "", - have_family ? contact_name->family : "", - email); - } - - } else if (first_match == EAB_CONTACT_MATCH_PART_FAMILY_NAME) { - - if (have_given) - menu_text = g_strdup_printf ("%s, %s%s%s <%s>", - contact_name->family, - contact_name->given, - have_additional ? " " : "", - have_additional ? contact_name->additional : "", - email); - else - menu_text = g_strdup_printf ("%s <%s>", contact_name->family, email); - - } else { /* something funny happened */ - - menu_text = g_strdup_printf ("<%s> ???", email); - - } - - if (menu_text) { - g_strstrip (menu_text); - final_match = make_match (dest, menu_text, score); - g_free (menu_text); - } - - e_contact_name_free (contact_name); - - return final_match; -} - -/* - * File As Query - */ - -static gchar * -sexp_file_as (ESelectNamesCompletion *comp) -{ - return name_style_query (comp, "file_as"); -} - -static ECompletionMatch * -match_file_as (ESelectNamesCompletion *comp, EDestination *dest) -{ - const gchar *name; - const gchar *email; - gchar *cpy, **strv, *menu_text; - gint i, len; - double score = 0.00001; - ECompletionMatch *match; - - name = e_destination_get_name (dest); - email = e_destination_get_email (dest); - - if (!(name && *name)) - return NULL; - - cpy = g_strdup (comp->priv->query_text); - strv = g_strsplit (cpy, " ", 0); - - for (i=0; strv[i] && score > 0; ++i) { - len = g_utf8_strlen (strv[i], -1); - if (!utf8_casefold_collate_len (name, strv[i], len)) - score += len; /* one point per character of the match */ - else - score = 0; - } - - g_free (cpy); - g_strfreev (strv); - - if (score <= 0) - return NULL; - - menu_text = g_strdup_printf ("%s <%s>", name, email); - g_strstrip (menu_text); - match = make_match (dest, menu_text, score); - g_free (menu_text); - - return match; -} - -typedef struct _BookQuery BookQuery; -struct _BookQuery { - BookQuerySExp builder; - BookQueryMatchTester tester; -}; - -static BookQuery book_queries[] = { - { sexp_nickname, match_nickname}, - { sexp_email, match_email }, - { sexp_name, match_name }, - { sexp_file_as, match_file_as }, -}; -static gint book_query_count = sizeof (book_queries) / sizeof (BookQuery); - -/* - * Build up a big compound sexp corresponding to all of our queries. - */ -static EBookQuery* -book_query_sexp (ESelectNamesCompletion *comp) -{ - gint i, j; - gchar **queryv; - EBookQuery *query; - - g_return_val_if_fail (comp && E_IS_SELECT_NAMES_COMPLETION (comp), NULL); - - if (! (comp->priv->query_text && *comp->priv->query_text)) - return NULL; - - queryv = g_new0 (gchar *, book_query_count+1); - for (i=0, j=0; i<book_query_count; ++i) { - queryv[j] = book_queries[i].builder (comp); - if (queryv[j]) - ++j; - } - - if (j == 0) { - query = NULL; - } else if (j == 1) { - query = e_book_query_from_string (queryv[0]); - queryv[0] = NULL; - } else { - gchar *tmp, *tmp2; - tmp = g_strjoinv (" ", queryv); - tmp2 = g_strdup_printf ("(or %s)", tmp); - query = e_book_query_from_string (tmp2); - g_free (tmp); - g_free (tmp2); - } - - for (i=0; i<book_query_count; ++i) - g_free (queryv[i]); - g_free (queryv); - - return query; -} - -/* - * Sweep across all of our query rules and find the best score/match - * string that applies to a given destination. - */ -static ECompletionMatch * -book_query_score (ESelectNamesCompletion *comp, EDestination *dest) -{ - ECompletionMatch *best_match = NULL; - gint i; - - g_return_val_if_fail (E_IS_SELECT_NAMES_COMPLETION (comp), NULL); - g_return_val_if_fail (E_IS_DESTINATION (dest), NULL); - - if (! (comp->priv->query_text && *comp->priv->query_text)) - return NULL; - - for (i=0; i<book_query_count; ++i) { - - ECompletionMatch *this_match = NULL; - - if (book_queries[i].tester && e_destination_get_contact (dest)) { - this_match = book_queries[i].tester (comp, dest); - } - - if (this_match) { - if (best_match == NULL || this_match->score > best_match->score) { - e_completion_match_unref (best_match); - best_match = this_match; - } else { - e_completion_match_unref (this_match); - } - } - } - - return best_match; -} - -static void -book_query_process_card_list (ESelectNamesCompletion *comp, const GList *contacts) -{ - while (contacts) { - EContact *contact = E_CONTACT (contacts->data); - - if (e_contact_get (contact, E_CONTACT_IS_LIST)) { - - if (comp->priv->match_contact_lists) { - - EDestination *dest = e_destination_new (); - ECompletionMatch *match; - e_destination_set_contact (dest, contact, 0); - match = book_query_score (comp, dest); - if (match && match->score > 0) { - e_completion_found_match (E_COMPLETION (comp), match); - } else { - e_completion_match_unref (match); - } - g_object_unref (dest); - - } - - } - else { - GList *email = e_contact_get (contact, E_CONTACT_EMAIL); - if (email) { - GList *iter; - gint i; - for (i=0, iter = email; iter; ++i, iter = iter->next) { - EDestination *dest = e_destination_new (); - gchar *e; - ECompletionMatch *match; - - e_destination_set_contact (dest, contact, i); - e = iter->data; - - if (e && *e) { - - match = book_query_score (comp, dest); - if (match && match->score > 0) { - e_completion_found_match (E_COMPLETION (comp), match); - } else { - e_completion_match_unref (match); - } - } - - g_object_unref (dest); - } - } - g_list_foreach (email, (GFunc)g_free, NULL); - g_list_free (email); - } - - contacts = contacts->next; - } -} - -/* - * - * ESelectNamesCompletion code - * - */ - - -GType -e_select_names_completion_get_type (void) -{ - static GType type = 0; - - if (!type) { - static const GTypeInfo info = { - sizeof (ESelectNamesCompletionClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) e_select_names_completion_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (ESelectNamesCompletion), - 0, /* n_preallocs */ - (GInstanceInitFunc) e_select_names_completion_init, - }; - - type = g_type_register_static (e_completion_get_type (), "ESelectNamesCompletion", &info, 0); - } - - return type; -} - -static void -e_select_names_completion_class_init (ESelectNamesCompletionClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - ECompletionClass *completion_class = E_COMPLETION_CLASS (klass); - - parent_class = g_type_class_peek_parent (klass); - - object_class->dispose = e_select_names_completion_dispose; - - completion_class->request_completion = e_select_names_completion_handle_request; - completion_class->end_completion = e_select_names_completion_end; - - if (getenv ("EVO_DEBUG_SELECT_NAMES_COMPLETION")) { - out = fopen ("/tmp/evo-debug-select-names-completion", "w"); - if (out) - setvbuf (out, NULL, _IONBF, 0); - } -} - -static void -e_select_names_completion_init (ESelectNamesCompletion *comp) -{ - comp->priv = g_new0 (struct _ESelectNamesCompletionPrivate, 1); - comp->priv->match_contact_lists = TRUE; -} - -static void -e_select_names_completion_clear_book_data (ESelectNamesCompletion *comp) -{ - GList *l; - - for (l = comp->priv->book_data; l; l = l->next) { - ESelectNamesCompletionBookData *book_data = l->data; - - if (book_data->contacts_added_tag) { - g_signal_handler_disconnect (book_data->book_view, book_data->contacts_added_tag); - book_data->contacts_added_tag = 0; - } - - if (book_data->seq_complete_tag) { - g_signal_handler_disconnect (book_data->book_view, book_data->seq_complete_tag); - book_data->seq_complete_tag = 0; - } - - g_object_unref (book_data->book); - - if (book_data->book_view) { - e_book_view_stop (book_data->book_view); - g_object_unref (book_data->book_view); - } - - g_free (book_data->cached_query_text); - g_list_foreach (book_data->cached_cards, (GFunc)g_object_unref, NULL); - g_list_free (book_data->cached_cards); - - g_free (book_data); - } - g_list_free (comp->priv->book_data); - comp->priv->book_data = NULL; -} - -static void -e_select_names_completion_dispose (GObject *object) -{ - ESelectNamesCompletion *comp = E_SELECT_NAMES_COMPLETION (object); - - if (comp->priv) { - if (comp->priv->text_model) - g_object_unref (comp->priv->text_model); - - e_select_names_completion_clear_book_data (comp); - - g_free (comp->priv->waiting_query); - g_free (comp->priv->query_text); - - g_free (comp->priv); - comp->priv = NULL; - } - - if (parent_class->dispose) - parent_class->dispose (object); -} - - -/* - * - * EBook/EBookView Callbacks & Query Stuff - * - */ - -static gchar * -clean_query_text (const gchar *s) -{ - gchar *q = g_new (gchar, strlen(s)+1), *t; - - t = q; - while (*s) { - if (*s != ',' && *s != '"') { - *t = *s; - ++t; - } - ++s; - } - *t = '\0'; - - g_strstrip (q); - - return q; -} - -static void -e_select_names_completion_clear_cache (ESelectNamesCompletionBookData *book_data) -{ - if (out) - fprintf (out, "** clearing cache on book %s\n", e_book_get_uri (book_data->book)); - - g_free (book_data->cached_query_text); - g_list_foreach (book_data->cached_cards, (GFunc)g_object_unref, NULL); - g_list_free (book_data->cached_cards); - - book_data->cached_query_text = NULL; - book_data->cached_cards = NULL; -} - -static void -e_select_names_completion_done (ESelectNamesCompletion *comp) -{ - g_free (comp->priv->query_text); - comp->priv->query_text = NULL; - - e_completion_end_search (E_COMPLETION (comp)); /* That's all folks! */ - - /* Need to launch a new completion if another one is pending. */ - if (comp->priv->waiting_query) { - gchar *s = comp->priv->waiting_query; - comp->priv->waiting_query = NULL; - e_completion_begin_search (E_COMPLETION (comp), s, comp->priv->waiting_pos, comp->priv->waiting_limit); - g_free (s); - } -} - -static void -e_select_names_completion_got_book_view_cb (EBook *book, EBookStatus status, EBookView *view, gpointer user_data) -{ - ESelectNamesCompletion *comp; - ESelectNamesCompletionBookData *book_data; - - book_data = (ESelectNamesCompletionBookData*)user_data; - comp = book_data->comp; - - if (status != E_BOOK_ERROR_OK) { - comp->priv->pending_completion_seq--; - if (!comp->priv->pending_completion_seq) - e_select_names_completion_done (comp); - return; - } - - book_data->book_view_tag = 0; - - if (book_data->contacts_added_tag) { - g_signal_handler_disconnect (book_data->book_view, book_data->contacts_added_tag); - book_data->contacts_added_tag = 0; - } - if (book_data->seq_complete_tag) { - g_signal_handler_disconnect (book_data->book_view, book_data->seq_complete_tag); - book_data->seq_complete_tag = 0; - } - - g_object_ref (view); - if (book_data->book_view) { - e_book_view_stop (book_data->book_view); - g_object_unref (book_data->book_view); - } - book_data->book_view = view; - - book_data->contacts_added_tag = - g_signal_connect (view, - "contacts_added", - G_CALLBACK (e_select_names_completion_contacts_added_cb), - book_data); - - book_data->seq_complete_tag = - g_signal_connect (view, - "sequence_complete", - G_CALLBACK (e_select_names_completion_seq_complete_cb), - book_data); - - book_data->sequence_complete_received = FALSE; - - e_book_view_start (view); -} - -static void -e_select_names_completion_contacts_added_cb (EBookView *book_view, const GList *cards, gpointer user_data) -{ - ESelectNamesCompletionBookData *book_data = user_data; - ESelectNamesCompletion *comp = book_data->comp; - - if (e_completion_searching (E_COMPLETION (comp))) { - book_query_process_card_list (comp, cards); - - /* Save the list of matching cards. */ - while (cards) { - book_data->cached_cards = g_list_prepend (book_data->cached_cards, g_object_ref (cards->data)); - cards = g_list_next (cards); - } - } -} - -static void -e_select_names_completion_seq_complete_cb (EBookView *book_view, EBookViewStatus status, gpointer user_data) -{ - ESelectNamesCompletionBookData *book_data = user_data; - ESelectNamesCompletion *comp = book_data->comp; - - if (out) - fprintf (out, "** got sequence_complete (status = %d) on book %s\n", status, e_book_get_uri (book_data->book)); - - /* - * We aren't searching, but the addressbook has changed -- clear our card cache so that - * future completion requests will take the changes into account. - */ - if (! e_completion_searching (E_COMPLETION (comp))) { - if (out) - fprintf (out, "\t we weren't searching, clearing the cache\n"); - e_select_names_completion_clear_cache (book_data); - return; - } - - if (book_data->cached_query_text - && status == E_BOOK_ERROR_OK - && !book_data->cache_complete - && !strcmp (book_data->cached_query_text, comp->priv->query_text)) - book_data->cache_complete = TRUE; - - if (out) - fprintf (out, "\tending search, book_data->cache_complete == %d, cached_cards = %p\n", - book_data->cache_complete, - book_data->cached_cards); - - if (!book_data->sequence_complete_received) { - book_data->sequence_complete_received = TRUE; - - if (book_data->contacts_added_tag) { - g_signal_handler_disconnect (book_data->book_view, book_data->contacts_added_tag); - book_data->contacts_added_tag = 0; - } - if (book_data->seq_complete_tag) { - g_signal_handler_disconnect (book_data->book_view, book_data->seq_complete_tag); - book_data->seq_complete_tag = 0; - } - - if (out) - fprintf (out, "\t %d remaining book view's\n", comp->priv->pending_completion_seq - 1); - - comp->priv->pending_completion_seq --; - if (comp->priv->pending_completion_seq > 0) - return; - } - - e_select_names_completion_done (comp); -} - -static void -e_select_names_completion_stop_query (ESelectNamesCompletion *comp) -{ - GList *l; - - g_return_if_fail (comp && E_IS_SELECT_NAMES_COMPLETION (comp)); - - if (out) - fprintf (out, "stopping query\n"); - - if (comp->priv->waiting_query) { - if (out) - fprintf (out, "stopped waiting query\n"); - g_free (comp->priv->waiting_query); - comp->priv->waiting_query = NULL; - } - - g_free (comp->priv->query_text); - comp->priv->query_text = NULL; - - for (l = comp->priv->book_data; l; l = l->next) { - ESelectNamesCompletionBookData *book_data = l->data; - if (book_data->book_view_tag) { - e_book_cancel (book_data->book, NULL); - book_data->book_view_tag = 0; - } - if (book_data->book_view) { - if (book_data->contacts_added_tag) { - g_signal_handler_disconnect (book_data->book_view, book_data->contacts_added_tag); - book_data->contacts_added_tag = 0; - } - if (book_data->seq_complete_tag) { - g_signal_handler_disconnect (book_data->book_view, book_data->seq_complete_tag); - book_data->seq_complete_tag = 0; - } - - e_book_view_stop (book_data->book_view); - g_object_unref (book_data->book_view); - book_data->book_view = NULL; - } - } - - comp->priv->pending_completion_seq = 0; -} - -static void -e_select_names_completion_start_query (ESelectNamesCompletion *comp, const gchar *query_text) -{ - g_return_if_fail (comp && E_IS_SELECT_NAMES_COMPLETION (comp)); - g_return_if_fail (query_text); - - e_select_names_completion_stop_query (comp); /* Stop any prior queries. */ - - if (comp->priv->books_not_ready == 0) { - EBookQuery *query; - - if (strlen (query_text) < comp->priv->minimum_query_length) { - e_completion_end_search (E_COMPLETION (comp)); - return; - } - - g_free (comp->priv->query_text); - comp->priv->query_text = g_strdup (query_text); - - query = book_query_sexp (comp); - if (query) { - GList *l; - - if (out) - fprintf (out, "\n\n**** starting query: \"%s\"\n", comp->priv->query_text); - - for (l = comp->priv->book_data; l; l = l->next) { - ESelectNamesCompletionBookData *book_data = l->data; - gboolean can_reuse_cached_cards; - - if (out) { - fprintf (out, - "book == %s[\n" - "\tbook_data->cached_query_text == `%s'\n" - "\tbook_data->cache_complete == %d\n" - "\tbook_data->cached_cards == %p\n", - e_book_get_uri (book_data->book), - book_data->cached_query_text, - book_data->cache_complete, - book_data->cached_cards); - } - - /* for lack of a better place, we invalidate the cache here if we - notice that the text is different. */ - if (book_data->cached_query_text - && (strlen (book_data->cached_query_text) > strlen (query_text) - || utf8_casefold_collate_len (book_data->cached_query_text, query_text, - strlen (book_data->cached_query_text)))) - book_data->cache_complete = FALSE; - - can_reuse_cached_cards = (book_data->cached_query_text - && book_data->cache_complete - && book_data->cached_cards != NULL); - - if (can_reuse_cached_cards) { - - if (out) - fprintf (out, "\t*** can reuse cached cards (%d cards cached)!\n", g_list_length (book_data->cached_cards)); - - if (out) - fprintf (out, "\tusing existing query info: %s (vs %s)\n", query_text, book_data->cached_query_text); - book_query_process_card_list (comp, book_data->cached_cards); - } - else { - e_select_names_completion_clear_cache (book_data); - book_data->cached_query_text = g_strdup (query_text); - - book_data->book_view_tag = e_book_async_get_book_view (book_data->book, - query, - NULL, -1, - e_select_names_completion_got_book_view_cb, book_data); - comp->priv->pending_completion_seq++; - } - - if (out) - fprintf (out, "]\n"); - } - - /* if we looped through all the books - and were able to complete based - solely on our cached cards, signal - that the search is over. */ - if (!comp->priv->pending_completion_seq) - e_select_names_completion_done (E_SELECT_NAMES_COMPLETION (comp)); - - e_book_query_unref (query); - } else { - g_free (comp->priv->query_text); - comp->priv->query_text = NULL; - } - } else { - g_free (comp->priv->waiting_query); - comp->priv->waiting_query = g_strdup (query_text); - } -} - -static void -e_select_names_completion_do_query (ESelectNamesCompletion *comp, const gchar *query_text, gint pos, gint limit) -{ - gchar *clean; - - g_return_if_fail (comp != NULL); - g_return_if_fail (E_IS_SELECT_NAMES_COMPLETION (comp)); - - clean = clean_query_text (query_text); - if (! (clean && *clean)) { - g_free (clean); - e_completion_end_search (E_COMPLETION (comp)); - return; - } - - if (out) - fprintf (out, "do_query: %s => %s\n", query_text, clean); - - e_select_names_completion_start_query (comp, clean); - g_free (clean); -} - - -/* - * - * Completion Search Override - a Framework for Christian-Resurrection-Holiday Edible-Chicken-Ova - * - */ - -typedef struct _SearchOverride SearchOverride; -struct _SearchOverride { - const gchar *trigger; - const gchar *text[4]; -}; -static SearchOverride override[] = { - { "why?", { "\"I must create a system, or be enslaved by another man's.\"", - " -- Wiliam Blake, \"Jerusalem\"", - NULL } }, - { "easter-egg?", { "What were you expecting, a flight simulator?", NULL } }, - { NULL, { NULL } } }; - -static gboolean -search_override_check (SearchOverride *over, const gchar *text) -{ - /* The g_utf8_validate is needed because as of 2001-06-11, - * EText doesn't translate from locale->UTF8 when you paste - * into it. - */ - if (over == NULL || text == NULL || !g_utf8_validate (text, -1, NULL)) - return FALSE; - - return !utf8_casefold_collate (over->trigger, text); -} - - -/* - * - * Completion Callbacks - * - */ - -static void -e_select_names_completion_handle_request (ECompletion *comp, const gchar *text, gint pos, gint limit) -{ - ESelectNamesCompletion *selcomp = E_SELECT_NAMES_COMPLETION (comp); - const gchar *str; - gint index, j; - - g_return_if_fail (comp != NULL); - g_return_if_fail (E_IS_SELECT_NAMES_COMPLETION (comp)); - g_return_if_fail (text != NULL); - - if (out) { - fprintf (out, "\n\n**** requesting completion\n"); - fprintf (out, "text=\"%s\" pos=%d limit=%d\n", text, pos, limit); - } - - e_select_names_model_text_pos (selcomp->priv->text_model->source, - selcomp->priv->text_model->seplen, - pos, &index, NULL, NULL); - str = index >= 0 ? e_select_names_model_get_string (selcomp->priv->text_model->source, index) : NULL; - - if (out) - fprintf (out, "index=%d str=\"%s\"\n", index, str); - - if (str == NULL || *str == '\0') { - if (out) - fprintf (out, "aborting empty query\n"); - e_completion_end_search (comp); - return; - } - - for (j=0; override[j].trigger; ++j) { - if (search_override_check (&(override[j]), str)) { - gint k; - - for (k=0; override[j].text[k]; ++k) { - ECompletionMatch *match = g_new (ECompletionMatch, 1); - e_completion_match_construct (match); - e_completion_match_set_text (match, text, override[j].text[k]); - match->score = 1 / (double) (k + 1); - e_completion_found_match (comp, match); - } - - e_completion_end_search (comp); - return; - } - } - - e_select_names_completion_do_query (selcomp, str, pos, limit); -} - -static void -e_select_names_completion_end (ECompletion *comp) -{ - g_return_if_fail (comp != NULL); - g_return_if_fail (E_IS_COMPLETION (comp)); - - if (out) - fprintf (out, "completion ended\n"); -} - -/* - * - * Our Pseudo-Constructor - * - */ - -ECompletion * -e_select_names_completion_new (ESelectNamesTextModel *text_model) -{ - ESelectNamesCompletion *comp; - - g_return_val_if_fail (E_IS_SELECT_NAMES_TEXT_MODEL (text_model), NULL); - - comp = g_object_new (E_TYPE_SELECT_NAMES_COMPLETION, NULL); - - comp->priv->text_model = text_model; - g_object_ref (text_model); - - return E_COMPLETION (comp); -} - -void -e_select_names_completion_add_book (ESelectNamesCompletion *comp, EBook *book) -{ - ESelectNamesCompletionBookData *book_data; - - g_return_if_fail (book != NULL); - - book_data = g_new0 (ESelectNamesCompletionBookData, 1); - book_data->book = book; - book_data->comp = comp; - g_object_ref (book_data->book); - comp->priv->book_data = g_list_append (comp->priv->book_data, book_data); - - /* XXX toshok - this doesn't work properly. need to rethink this next bit. */ - /* if the user is typing as we're adding books, restart the - query after the new book has been added */ - if (comp->priv->query_text && *comp->priv->query_text) { - char *query_text = g_strdup (comp->priv->query_text); - e_select_names_completion_stop_query (comp); - e_select_names_completion_start_query (comp, query_text); - g_free (query_text); - } -} - -void -e_select_names_completion_clear_books (ESelectNamesCompletion *comp) -{ - e_select_names_completion_stop_query (comp); - e_select_names_completion_clear_book_data (comp); -} - -void -e_select_names_completion_set_minimum_query_length (ESelectNamesCompletion *comp, int query_length) -{ - g_return_if_fail (E_IS_SELECT_NAMES_COMPLETION (comp)); - comp->priv->minimum_query_length = query_length; -} - -gboolean -e_select_names_completion_get_match_contact_lists (ESelectNamesCompletion *comp) -{ - g_return_val_if_fail (E_IS_SELECT_NAMES_COMPLETION (comp), FALSE); - return comp->priv->match_contact_lists; -} - - -void -e_select_names_completion_set_match_contact_lists (ESelectNamesCompletion *comp, gboolean x) -{ - g_return_if_fail (E_IS_SELECT_NAMES_COMPLETION (comp)); - comp->priv->match_contact_lists = x; -} - diff --git a/addressbook/gui/component/select-names/e-select-names-completion.h b/addressbook/gui/component/select-names/e-select-names-completion.h deleted file mode 100644 index 97a3f3f5ca..0000000000 --- a/addressbook/gui/component/select-names/e-select-names-completion.h +++ /dev/null @@ -1,68 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * e-select-names-completion.h - * - * Copyright (C) 2001 Ximian, Inc. - * - * Developed by Jon Trowbridge <trow@ximian.com> - */ - -/* - * 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. - */ - -#ifndef E_SELECT_NAMES_COMPLETION_H -#define E_SELECT_NAMES_COMPLETION_H - -#include <gal/e-text/e-completion.h> -#include <libebook/e-book.h> -#include "e-select-names-text-model.h" - -G_BEGIN_DECLS - -#define E_TYPE_SELECT_NAMES_COMPLETION (e_select_names_completion_get_type ()) -#define E_SELECT_NAMES_COMPLETION(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), E_TYPE_SELECT_NAMES_COMPLETION, ESelectNamesCompletion)) -#define E_SELECT_NAMES_COMPLETION_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), E_TYPE_SELECT_NAMES_COMPLETION, ESelectNamesCompletionClass)) -#define E_IS_SELECT_NAMES_COMPLETION(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), E_TYPE_SELECT_NAMES_COMPLETION)) -#define E_IS_SELECT_NAMES_COMPLETION_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), E_TYPE_SELECT_NAMES_COMPLETION)) - -typedef struct _ESelectNamesCompletion ESelectNamesCompletion; -typedef struct _ESelectNamesCompletionClass ESelectNamesCompletionClass; -struct _ESelectNamesCompletionPrivate; - -struct _ESelectNamesCompletion { - ECompletion parent; - - struct _ESelectNamesCompletionPrivate *priv; -}; - -struct _ESelectNamesCompletionClass { - ECompletionClass parent_class; - -}; - -GType e_select_names_completion_get_type (void); - -ECompletion *e_select_names_completion_new (ESelectNamesTextModel *); -void e_select_names_completion_add_book (ESelectNamesCompletion *, EBook *); -void e_select_names_completion_clear_books (ESelectNamesCompletion *); -void e_select_names_completion_set_minimum_query_length (ESelectNamesCompletion *, int); -gboolean e_select_names_completion_get_match_contact_lists (ESelectNamesCompletion *); -void e_select_names_completion_set_match_contact_lists (ESelectNamesCompletion *, gboolean); - -G_END_DECLS - -#endif /* E_SELECT_NAMES_COMPLETION_H */ diff --git a/addressbook/gui/component/select-names/e-select-names-config-keys.h b/addressbook/gui/component/select-names/e-select-names-config-keys.h deleted file mode 100644 index e0f08c3019..0000000000 --- a/addressbook/gui/component/select-names/e-select-names-config-keys.h +++ /dev/null @@ -1,39 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Authors : - * JP Rosevear <jpr@ximian.com> - * - * Copyright 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 - */ - -#ifndef _E_SELECT_NAMES_CONFIG_KEYS_H_ -#define _E_SELECT_NAMES_CONFIG_KEYS_H_ - -#include <glib.h> - -G_BEGIN_DECLS - -#define SELECT_NAMES_CONFIG_PREFIX "/apps/evolution/addressbook/completion" - -/* Display settings */ -#define SELECT_NAMES_CONFIG_COMPLETION_BOOKS SELECT_NAMES_CONFIG_PREFIX "/books" -#define SELECT_NAMES_CONFIG_LAST_COMPLETION_BOOK SELECT_NAMES_CONFIG_PREFIX "/last_book" -#define SELECT_NAMES_CONFIG_MIN_QUERY_LENGTH SELECT_NAMES_CONFIG_PREFIX "/minimum_query_length" - -G_END_DECLS - -#endif diff --git a/addressbook/gui/component/select-names/e-select-names-config.c b/addressbook/gui/component/select-names/e-select-names-config.c deleted file mode 100644 index 8335ed7c3b..0000000000 --- a/addressbook/gui/component/select-names/e-select-names-config.c +++ /dev/null @@ -1,117 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * Authors : - * Damon Chaplin <damon@ximian.com> - * Rodrigo Moya <rodrigo@ximian.com> - * - * Copyright 2000, Ximian, Inc. - * Copyright 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 - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <string.h> - -#include "e-select-names-config-keys.h" -#include "e-select-names-config.h" - -static GConfClient *config = NULL; - -static void -do_cleanup (void) -{ - g_object_unref (config); - config = NULL; -} - -static void -e_select_names_config_init (void) -{ - if (config) - return; - - config = gconf_client_get_default (); - g_atexit ((GVoidFunc) do_cleanup); - - gconf_client_add_dir (config, SELECT_NAMES_CONFIG_PREFIX, GCONF_CLIENT_PRELOAD_RECURSIVE, NULL); -} - -void -e_select_names_config_remove_notification (guint id) -{ - gconf_client_notify_remove (config, id); -} - -char * -e_select_names_config_get_last_completion_book (void) -{ - e_select_names_config_init (); - - return gconf_client_get_string (config, SELECT_NAMES_CONFIG_LAST_COMPLETION_BOOK, NULL); -} - -void -e_select_names_config_set_last_completion_book (const char *last_completion_book) -{ - e_select_names_config_init (); - - gconf_client_set_string (config, SELECT_NAMES_CONFIG_LAST_COMPLETION_BOOK, last_completion_book, NULL); -} - -guint -e_select_names_config_add_notification_last_completion_book (GConfClientNotifyFunc func, gpointer data) -{ - guint id; - - e_select_names_config_init (); - - id = gconf_client_notify_add (config, SELECT_NAMES_CONFIG_LAST_COMPLETION_BOOK, func, data, NULL, NULL); - - return id; -} - -gint -e_select_names_config_get_min_query_length (void) -{ - e_select_names_config_init (); - - return gconf_client_get_int (config, SELECT_NAMES_CONFIG_MIN_QUERY_LENGTH, NULL); -} - - -void -e_select_names_config_set_min_query_length (gint day_end_hour) -{ - e_select_names_config_init (); - - gconf_client_set_int (config, SELECT_NAMES_CONFIG_MIN_QUERY_LENGTH, day_end_hour, NULL); -} - -guint -e_select_names_config_add_notification_min_query_length (GConfClientNotifyFunc func, gpointer data) -{ - guint id; - - e_select_names_config_init (); - - id = gconf_client_notify_add (config, SELECT_NAMES_CONFIG_MIN_QUERY_LENGTH, func, data, NULL, NULL); - - return id; -} diff --git a/addressbook/gui/component/select-names/e-select-names-config.h b/addressbook/gui/component/select-names/e-select-names-config.h deleted file mode 100644 index 12d2c1314d..0000000000 --- a/addressbook/gui/component/select-names/e-select-names-config.h +++ /dev/null @@ -1,43 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Authors : - * Damon Chaplin <damon@ximian.com> - * Rodrigo Moya <rodrigo@ximian.com> - * - * Copyright 2000, Ximian, Inc. - * Copyright 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 - */ - -#ifndef _E_SELECT_NAMES_CONFIG_H_ -#define _E_SELECT_NAMES_CONFIG_H_ - -#include <gconf/gconf-client.h> - -void e_select_names_config_remove_notification (guint id); - -/* The last completion book */ -char *e_select_names_config_get_last_completion_book (void); -void e_select_names_config_set_last_completion_book (const char *last_completion_book); -guint e_select_names_config_add_notification_last_completion_book (GConfClientNotifyFunc func, gpointer data); - - -/* The minimum query length */ -gint e_select_names_config_get_min_query_length (void); -void e_select_names_config_set_min_query_length (gint day_end_hour); -guint e_select_names_config_add_notification_min_query_length (GConfClientNotifyFunc func, gpointer data); - -#endif /* _E_SELECT_NAMES_CONFIG_H_ */ diff --git a/addressbook/gui/component/select-names/e-select-names-factory.c b/addressbook/gui/component/select-names/e-select-names-factory.c deleted file mode 100644 index 9e427513e0..0000000000 --- a/addressbook/gui/component/select-names/e-select-names-factory.c +++ /dev/null @@ -1,59 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-select-names-factory.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 <bonobo/bonobo-generic-factory.h> - -#include "e-select-names-bonobo.h" -#include "e-select-names-factory.h" - - -#define COMPONENT_FACTORY_ID "OAFIID:GNOME_Evolution_Addressbook_SelectNamesFactory:" BASE_VERSION - -static BonoboGenericFactory *factory = NULL; - - -static BonoboObject * -factory_fn (BonoboGenericFactory *factory, - const char *component_id, - void *closure) -{ - return BONOBO_OBJECT (e_select_names_bonobo_new ()); -} - - -gboolean -e_select_names_factory_init (void) -{ - if (factory != NULL) - return TRUE; - - factory = bonobo_generic_factory_new (COMPONENT_FACTORY_ID, factory_fn, NULL); - - if (factory == NULL) - return FALSE; - - return TRUE; -} diff --git a/addressbook/gui/component/select-names/e-select-names-factory.h b/addressbook/gui/component/select-names/e-select-names-factory.h deleted file mode 100644 index 0fe85c8361..0000000000 --- a/addressbook/gui/component/select-names/e-select-names-factory.h +++ /dev/null @@ -1,30 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-select-names-factory.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_SECELT_NAMES_FACTORY_H -#define _E_SECELT_NAMES_FACTORY_H - -#include <glib.h> - -gboolean e_select_names_factory_init (void); - -#endif diff --git a/addressbook/gui/component/select-names/e-select-names-manager.c b/addressbook/gui/component/select-names/e-select-names-manager.c deleted file mode 100644 index 43b69d9149..0000000000 --- a/addressbook/gui/component/select-names/e-select-names-manager.c +++ /dev/null @@ -1,684 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Authors: - * Chris Lahey <clahey@ximian.com> - * Jon Trowbridge <trow@ximian.com. - * - * Copyright (C) 2000, 2001 Ximian, Inc. - */ - -#include <config.h> - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#include <gal/e-text/e-entry.h> - -#include <libgnome/gnome-i18n.h> -#include "e-select-names-config.h" -#include "e-select-names-manager.h" -#include "e-select-names-marshal.h" -#include "e-select-names-model.h" -#include "e-select-names-text-model.h" -#include "e-select-names.h" -#include "e-select-names-completion.h" -#include "e-select-names-popup.h" -#include <addressbook/util/eab-book-util.h> -#include <addressbook/util/e-destination.h> -#include "addressbook/gui/component/addressbook.h" -#include <bonobo/bonobo-object.h> - -#define DEFAULT_MINIMUM_QUERY_LENGTH 3 - -enum { - CHANGED, - OK, - CANCEL, - LAST_SIGNAL -}; - -static guint e_select_names_manager_signals[LAST_SIGNAL] = { 0 }; - -static GObjectClass *parent_class = NULL; - -typedef struct { - char *id; - char *title; - ESelectNamesModel *model; - ESelectNamesModel *original_model; - ESelectNamesManager *manager; - guint changed_tag; -} ESelectNamesManagerSection; - -typedef struct { - char *id; - EEntry *entry; - ESelectNamesManager *manager; - ESelectNamesModel *model; - ECompletion *comp; - guint cleaning_tag; -} ESelectNamesManagerEntry; - -static void e_select_names_manager_init (ESelectNamesManager *manager); -static void e_select_names_manager_class_init (ESelectNamesManagerClass *klass); - -static void e_select_names_manager_dispose (GObject *object); - -/* ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** */ - -/* ESelectNamesManagerSection routines */ - -static void -section_model_changed_cb (ESelectNamesModel *model, gpointer closure) -{ - ESelectNamesManagerSection *section = closure; - g_signal_emit (section->manager, - e_select_names_manager_signals[CHANGED], 0, - section->id, - FALSE); -} - -static ESelectNamesManagerSection * -e_select_names_manager_section_new (ESelectNamesManager *manager, - const gchar *id, - const gchar *title, - ESelectNamesModel *model) -{ - ESelectNamesManagerSection *section; - - g_return_val_if_fail (E_IS_SELECT_NAMES_MANAGER (manager), NULL); - g_return_val_if_fail (E_IS_SELECT_NAMES_MODEL (model), NULL); - - section = g_new0 (ESelectNamesManagerSection, 1); - - section->id = g_strdup (id); - section->title = g_strdup (title); - - section->manager = manager; - - section->model = model; - g_object_ref (section->model); - section->changed_tag = - g_signal_connect (section->model, - "changed", - G_CALLBACK (section_model_changed_cb), - section); - - return section; -} - -static void -e_select_names_manager_section_free (ESelectNamesManagerSection *section) -{ - if (section == NULL) - return; - - g_free (section->id); - g_free (section->title); - - if (section->model) { - g_signal_handler_disconnect (section->model, section->changed_tag); - g_object_unref (section->model); - } - - if (section->original_model) { - g_object_unref (section->original_model); - } - - g_free (section); -} - -/* ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** */ - -/* ESelectNamesManagerEntry routines */ - -static ESelectNamesManagerEntry * -get_entry_info (EEntry *entry) -{ - g_return_val_if_fail (E_IS_ENTRY (entry), NULL); - return (ESelectNamesManagerEntry *) g_object_get_data (G_OBJECT (entry), "entry_info"); -} - -static void -populate_popup_cb (EEntry *eentry, GdkEventButton *ev, gint pos, GtkWidget *menu, gpointer user_data) -{ - ESelectNamesTextModel *text_model; - - g_object_get (eentry, - "model", &text_model, - NULL); - g_assert (E_IS_SELECT_NAMES_TEXT_MODEL (text_model)); - - e_select_names_populate_popup (menu, text_model, ev, pos, GTK_WIDGET (eentry)); -} - -static void -completion_handler (EEntry *entry, ECompletionMatch *match) -{ - ESelectNamesManagerEntry *mgr_entry; - ESelectNamesTextModel *text_model; - EDestination *dest; - gint i, pos, start_pos, len; - - if (match == NULL || match->user_data == NULL) - return; - - mgr_entry = get_entry_info (entry); - dest = E_DESTINATION (match->user_data); - - /* Sometimes I really long for garbage collection. Reference - counting makes you feel 31337, but sometimes it is just a - bitch. */ - g_object_ref (dest); - - g_object_get (entry, - "model", &text_model, - NULL); - g_assert (E_IS_SELECT_NAMES_TEXT_MODEL (text_model)); - - pos = e_entry_get_position (entry); - e_select_names_model_text_pos (mgr_entry->model, text_model->seplen, pos, &i, NULL, NULL); - e_select_names_model_replace (mgr_entry->model, i, dest); - e_select_names_model_name_pos (mgr_entry->model, text_model->seplen, i, &start_pos, &len); - e_entry_set_position (entry, start_pos+len); -} - -static ESelectNamesManagerEntry * -e_select_names_manager_entry_new (ESelectNamesManager *manager, ESelectNamesModel *model, const gchar *id) -{ - ESelectNamesManagerEntry *entry; - ETextModel *text_model; - GList *l; - - g_return_val_if_fail (E_IS_SELECT_NAMES_MANAGER (manager), NULL); - g_return_val_if_fail (E_IS_SELECT_NAMES_MODEL (model), NULL); - - entry = g_new0 (ESelectNamesManagerEntry, 1); - - entry->id = g_strdup (id); - - entry->entry = E_ENTRY (e_entry_new ()); - text_model = e_select_names_text_model_new (model); - g_object_set(entry->entry, - "model", text_model, /* The entry takes ownership of the text model */ - "editable", TRUE, - "use_ellipsis", TRUE, - "allow_newlines", FALSE, - NULL); - - g_object_ref (entry->entry); - - entry->comp = e_select_names_completion_new (E_SELECT_NAMES_TEXT_MODEL (text_model)); - - for (l = manager->completion_books; l; l = l->next) { - EBook *book = l->data; - e_select_names_completion_add_book (E_SELECT_NAMES_COMPLETION(entry->comp), book); - } - - e_select_names_completion_set_minimum_query_length (E_SELECT_NAMES_COMPLETION(entry->comp), - manager->minimum_query_length); - - e_entry_enable_completion_full (entry->entry, entry->comp, 100, completion_handler); - - entry->manager = manager; - - entry->model = model; - g_object_ref (model); - - g_signal_connect (entry->entry, - "populate_popup", - G_CALLBACK (populate_popup_cb), - entry); - - g_object_set_data (G_OBJECT (entry->entry), "entry_info", entry); - g_object_set_data (G_OBJECT (entry->entry), "select_names_model", model); - g_object_set_data (G_OBJECT (entry->entry), "select_names_text_model", text_model); - g_object_set_data (G_OBJECT (entry->entry), "completion_handler", entry->comp); - - return entry; -} - -static void -e_select_names_manager_entry_free (ESelectNamesManagerEntry *entry) -{ - if (entry == NULL) - return; - - g_free (entry->id); - g_object_unref (entry->model); - g_object_unref (entry->entry); - - if (entry->cleaning_tag) - g_source_remove (entry->cleaning_tag); - - g_free (entry); -} - -/* ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** */ - -static void -e_select_names_manager_save_models (ESelectNamesManager *manager) -{ - GList *iter; - - for (iter = manager->sections; iter != NULL; iter = g_list_next (iter)) { - ESelectNamesManagerSection *section = iter->data; - - if (section->original_model == NULL && section->model != NULL) - section->original_model = e_select_names_model_duplicate (section->model); - - } -} - -static void -e_select_names_manager_revert_to_saved_models (ESelectNamesManager *manager) -{ - GList *iter; - - for (iter = manager->sections; iter != NULL; iter = g_list_next (iter)) { - ESelectNamesManagerSection *section = iter->data; - if (section->model && section->original_model) { - e_select_names_model_overwrite_copy (section->model, section->original_model); - g_object_unref (section->original_model); - section->original_model = NULL; - } - } -} - -static void -e_select_names_manager_discard_saved_models (ESelectNamesManager *manager) -{ - GList *iter; - - for (iter = manager->sections; iter != NULL; iter = g_list_next (iter)) { - ESelectNamesManagerSection *section = iter->data; - if (section->original_model) { - g_object_unref (section->original_model); - section->original_model = NULL; - } - } -} - -/* ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** */ - -static void -open_book_cb (EBook *book, EBookStatus status, gpointer user_data) -{ - ESelectNamesManager *manager = E_SELECT_NAMES_MANAGER (user_data); - - if (status == E_BOOK_ERROR_OK) { - GList *l; - for (l = manager->entries; l; l = l->next) { - ESelectNamesManagerEntry *entry = l->data; - e_select_names_completion_add_book (E_SELECT_NAMES_COMPLETION(entry->comp), book); - } - - manager->completion_books = g_list_append (manager->completion_books, book); - g_object_ref (book); - } - - g_object_unref (manager); /* unref ourself (matches ref before the load_source call below) */ -} - -static void -update_completion_books (ESelectNamesManager *manager) -{ - GSList *groups; - - /* Add all the completion books */ - for (groups = e_source_list_peek_groups (manager->source_list); groups; groups = groups->next) { - ESourceGroup *group = E_SOURCE_GROUP (groups->data); - GSList *sources; - - for (sources = e_source_group_peek_sources (group); sources; sources = sources->next) { - ESource *source = E_SOURCE (sources->data); - const char *completion = e_source_get_property (source, "completion"); - if (completion && !g_ascii_strcasecmp (completion, "true")) { - EBook *book = e_book_new (source, NULL); - g_object_ref (manager); - addressbook_load (book, open_book_cb, manager); - } - } - } -} - -static void -source_list_changed (ESourceList *source_list, ESelectNamesManager *manager) -{ - GList *l; - - for (l = manager->entries; l; l = l->next) { - ESelectNamesManagerEntry *entry = l->data; - e_select_names_completion_clear_books (E_SELECT_NAMES_COMPLETION (entry->comp)); - } - - g_list_foreach (manager->completion_books, (GFunc)g_object_unref, NULL); - g_list_free (manager->completion_books); - manager->completion_books = NULL; - - update_completion_books (manager); -} - -static void -config_min_query_length_changed_cb (GConfClient *client, guint id, GConfEntry *entry, gpointer data) -{ - ESelectNamesManager *manager = data; - GList *l; - - manager->minimum_query_length = e_select_names_config_get_min_query_length (); - if (manager->minimum_query_length <= 0) - manager->minimum_query_length = DEFAULT_MINIMUM_QUERY_LENGTH; - - for (l = manager->entries; l; l = l->next) { - ESelectNamesManagerEntry *entry = l->data; - e_select_names_completion_set_minimum_query_length (E_SELECT_NAMES_COMPLETION(entry->comp), - manager->minimum_query_length); - } -} - -/** - * e_select_names_manager_new: - * - * Returns: a new #ESelectNamesManager - */ -ESelectNamesManager * -e_select_names_manager_new (void) -{ - ESelectNamesManager *manager = g_object_new (E_TYPE_SELECT_NAMES_MANAGER, NULL); - - return manager; -} - - -/* - * ESelectNamesManager lifecycle management and vcard loading/saving. - */ - - -void -e_select_names_manager_add_section (ESelectNamesManager *manager, - const char *id, - const char *title) -{ - g_return_if_fail (E_IS_SELECT_NAMES_MANAGER (manager)); - g_return_if_fail (id != NULL); - g_return_if_fail (title != NULL); - - e_select_names_manager_add_section_with_limit (manager, id, title, -1); -} - -void -e_select_names_manager_add_section_with_limit (ESelectNamesManager *manager, - const char *id, - const char *title, - gint limit) -{ - ESelectNamesManagerSection *section; - ESelectNamesModel *model; - - g_return_if_fail (E_IS_SELECT_NAMES_MANAGER (manager)); - g_return_if_fail (id != NULL); - g_return_if_fail (title != NULL); - - model = e_select_names_model_new (); - e_select_names_model_set_limit (model, limit); - - section = e_select_names_manager_section_new (manager, id, title, model); - - manager->sections = g_list_append (manager->sections, section); - - g_object_unref (model); -} - -ESelectNamesModel * -e_select_names_manager_get_source (ESelectNamesManager *manager, - const char *id) -{ - GList *iter; - - g_return_val_if_fail (E_IS_SELECT_NAMES_MANAGER (manager), NULL); - g_return_val_if_fail (id != NULL, NULL); - - for (iter = manager->sections; iter != NULL; iter = g_list_next (iter)) { - ESelectNamesManagerSection *section = iter->data; - if (!strcmp (section->id, id)) - return section->model; - } - return NULL; -} - -GtkWidget * -e_select_names_manager_create_entry (ESelectNamesManager *manager, const char *id) -{ - GList *iter; - - g_return_val_if_fail (E_IS_SELECT_NAMES_MANAGER (manager), NULL); - g_return_val_if_fail (id != NULL, NULL); - - for (iter = manager->sections; iter != NULL; iter = g_list_next (iter)) { - ESelectNamesManagerSection *section = iter->data; - if (!strcmp(section->id, id)) { - ESelectNamesManagerEntry *entry; - - entry = e_select_names_manager_entry_new (manager, section->model, section->id); - manager->entries = g_list_append (manager->entries, entry); - - return GTK_WIDGET(entry->entry); - } - } - - return NULL; -} - -static void -e_select_names_response(ESelectNames *dialog, gint response_id, ESelectNamesManager *manager) -{ - gtk_widget_destroy (GTK_WIDGET (dialog)); - - switch(response_id) { - case GTK_RESPONSE_OK: - e_select_names_manager_discard_saved_models (manager); - g_signal_emit (manager, e_select_names_manager_signals[OK], 0); - break; - - case GTK_RESPONSE_CANCEL: - e_select_names_manager_revert_to_saved_models (manager); - g_signal_emit (manager, e_select_names_manager_signals[CANCEL], 0); - break; - } -} - -static void -clear_widget (gpointer data, GObject *where_object_was) -{ - GtkWidget **widget_ref = data; - *widget_ref = NULL; -} - -void -e_select_names_manager_activate_dialog (ESelectNamesManager *manager, - const char *id) -{ - g_return_if_fail (E_IS_SELECT_NAMES_MANAGER (manager)); - g_return_if_fail (id != NULL); - - if (manager->names) { - - g_assert (GTK_WIDGET_REALIZED (GTK_WIDGET (manager->names))); - e_select_names_set_default (manager->names, id); - gdk_window_show (GTK_WIDGET (manager->names)->window); - gdk_window_raise (GTK_WIDGET (manager->names)->window); - - } else { - - GList *iter; - - manager->names = E_SELECT_NAMES (e_select_names_new ()); - - for (iter = manager->sections; iter != NULL; iter = g_list_next (iter)) { - ESelectNamesManagerSection *section = iter->data; - e_select_names_add_section (manager->names, section->id, section->title, section->model); - } - - e_select_names_set_default (manager->names, id); - - g_signal_connect(manager->names, - "response", - G_CALLBACK(e_select_names_response), - manager); - - g_object_weak_ref (G_OBJECT (manager->names), clear_widget, &manager->names); - - gtk_widget_show(GTK_WIDGET(manager->names)); - } - - e_select_names_manager_save_models (manager); -} - -/* ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** */ - -static void -e_select_names_manager_init (ESelectNamesManager *manager) -{ - guint not; - - manager->sections = NULL; - manager->entries = NULL; - - manager->source_list = e_source_list_new_for_gconf_default ("/apps/evolution/addressbook/sources"); - g_signal_connect (manager->source_list, "changed", G_CALLBACK (source_list_changed), manager); - - manager->completion_books = NULL; - - manager->minimum_query_length = e_select_names_config_get_min_query_length (); - - update_completion_books (manager); - - not = e_select_names_config_add_notification_min_query_length (config_min_query_length_changed_cb, manager); - manager->notifications = g_list_append (manager->notifications, GUINT_TO_POINTER (not)); -} - -static void -e_select_names_manager_dispose (GObject *object) -{ - ESelectNamesManager *manager; - - manager = E_SELECT_NAMES_MANAGER (object); - - if (manager->names) { - gtk_widget_destroy (GTK_WIDGET (manager->names)); - manager->names = NULL; - } - - if (manager->sections) { - g_list_foreach (manager->sections, (GFunc) e_select_names_manager_section_free, NULL); - g_list_free (manager->sections); - manager->sections = NULL; - } - - if (manager->entries) { - g_list_foreach (manager->entries, (GFunc) e_select_names_manager_entry_free, NULL); - g_list_free (manager->entries); - manager->entries = NULL; - } - - if (manager->source_list) { - g_object_unref (manager->source_list); - manager->source_list = NULL; - } - - if (manager->completion_books) { - g_list_foreach (manager->completion_books, (GFunc) g_object_unref, NULL); - g_list_free (manager->completion_books); - manager->completion_books = NULL; - } - - if (manager->notifications) { - GList *l; - - for (l = manager->notifications; l; l = l->next) - e_select_names_config_remove_notification (GPOINTER_TO_UINT (l->data)); - g_list_free (manager->notifications); - manager->notifications = NULL; - } - - if (G_OBJECT_CLASS (parent_class)->dispose) - G_OBJECT_CLASS (parent_class)->dispose (object); -} - -static void -e_select_names_manager_class_init (ESelectNamesManagerClass *klass) -{ - GObjectClass *object_class; - - object_class = G_OBJECT_CLASS(klass); - parent_class = g_type_class_peek_parent (klass); - - object_class->dispose = e_select_names_manager_dispose; - - e_select_names_manager_signals[CHANGED] = - g_signal_new ("changed", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (ESelectNamesManagerClass, changed), - NULL, NULL, - e_select_names_marshal_NONE__POINTER_INT, - G_TYPE_NONE, 2, - G_TYPE_POINTER, - G_TYPE_INT); - - e_select_names_manager_signals[OK] = - g_signal_new ("ok", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (ESelectNamesManagerClass, ok), - NULL, NULL, - e_select_names_marshal_NONE__NONE, - G_TYPE_NONE, 0); - - e_select_names_manager_signals[CANCEL] = - g_signal_new ("cancel", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (ESelectNamesManagerClass, cancel), - NULL, NULL, - e_select_names_marshal_NONE__NONE, - G_TYPE_NONE, 0); -} - -/** - * e_select_names_manager_get_type: - * @void: - * - * Registers the &ESelectNamesManager class if necessary, and returns the type ID - * associated to it. - * - * Return value: The type ID of the &ESelectNamesManager class. - **/ -GType -e_select_names_manager_get_type (void) -{ - static GType manager_type = 0; - - if (!manager_type) { - static const GTypeInfo manager_info = { - sizeof (ESelectNamesManagerClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) e_select_names_manager_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (ESelectNamesManager), - 0, /* n_preallocs */ - (GInstanceInitFunc) e_select_names_manager_init, - }; - - manager_type = g_type_register_static (G_TYPE_OBJECT, "ESelectNamesManager", &manager_info, 0); - } - - return manager_type; -} - - - diff --git a/addressbook/gui/component/select-names/e-select-names-manager.h b/addressbook/gui/component/select-names/e-select-names-manager.h deleted file mode 100644 index 0830d299d5..0000000000 --- a/addressbook/gui/component/select-names/e-select-names-manager.h +++ /dev/null @@ -1,68 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Authors: - * Chris Lahey <clahey@ximian.com> - * - * Copyright (C) 2000 Ximian, Inc. - */ - -#ifndef __E_SELECT_NAMES_MANAGER_H__ -#define __E_SELECT_NAMES_MANAGER_H__ - -#include <stdio.h> -#include <time.h> -#include <gtk/gtkobject.h> -#include <e-util/e-list.h> -#include "e-select-names.h" - -#define E_TYPE_SELECT_NAMES_MANAGER (e_select_names_manager_get_type ()) -#define E_SELECT_NAMES_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_SELECT_NAMES_MANAGER, ESelectNamesManager)) -#define E_SELECT_NAMES_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_SELECT_NAMES_MANAGER, ESelectNamesManagerClass)) -#define E_IS_SELECT_NAMES_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_SELECT_NAMES_MANAGER)) -#define E_IS_SELECT_NAMES_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), E_TYPE_SELECT_NAMES_MANAGER)) - -typedef struct _ESelectNamesManager ESelectNamesManager; -typedef struct _ESelectNamesManagerClass ESelectNamesManagerClass; - -struct _ESelectNamesManager { - GObject object; - - GList *sections; - GList *entries; - - ESelectNames *names; - - ESourceList *source_list; - GList *completion_books; - - int minimum_query_length; - - GList *notifications; -}; - -struct _ESelectNamesManagerClass { - GObjectClass parent_class; - - void (*changed) (ESelectNamesManager *, const gchar *section_id, gint changed_working_copy); - void (*ok) (ESelectNamesManager *); - void (*cancel) (ESelectNamesManager *); -}; - -ESelectNamesManager *e_select_names_manager_new (void); -void e_select_names_manager_add_section (ESelectNamesManager *manager, - const char *id, - const char *title); -void e_select_names_manager_add_section_with_limit (ESelectNamesManager *manager, - const char *id, - const char *title, - gint limit); -ESelectNamesModel *e_select_names_manager_get_source (ESelectNamesManager *manager, - const char *id); -GtkWidget *e_select_names_manager_create_entry (ESelectNamesManager *manager, - const char *id); -void e_select_names_manager_activate_dialog (ESelectNamesManager *manager, - const char *id); -/* Standard Gtk function */ -GType e_select_names_manager_get_type (void); - -#endif /* ! __E_SELECT_NAMES_MANAGER_H__ */ diff --git a/addressbook/gui/component/select-names/e-select-names-marshal.list b/addressbook/gui/component/select-names/e-select-names-marshal.list deleted file mode 100644 index 8e751dc27d..0000000000 --- a/addressbook/gui/component/select-names/e-select-names-marshal.list +++ /dev/null @@ -1,3 +0,0 @@ -NONE:POINTER,INT -NONE:NONE -NONE:INT,INT,INT diff --git a/addressbook/gui/component/select-names/e-select-names-model.c b/addressbook/gui/component/select-names/e-select-names-model.c deleted file mode 100644 index 49b9e5039d..0000000000 --- a/addressbook/gui/component/select-names/e-select-names-model.c +++ /dev/null @@ -1,792 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Authors: - * Chris Lahey <clahey@ximian.com> - * Jon Trowbidge <trow@ximian.com> - * - * Copyright (C) 2000, 2001 Ximian, Inc. - */ - -#include <config.h> - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <gtk/gtkmarshal.h> -#include <gtk/gtksignal.h> - -#include <gal/util/e-util.h> -#include <libebook/e-book.h> -#include <libebook/e-contact.h> -#include "e-select-names-model.h" -#include "e-select-names-marshal.h" -#include "eab-book-util.h" - -enum { - E_SELECT_NAMES_MODEL_CHANGED, - E_SELECT_NAMES_MODEL_RESIZED, - E_SELECT_NAMES_MODEL_LAST_SIGNAL -}; - -static guint e_select_names_model_signals[E_SELECT_NAMES_MODEL_LAST_SIGNAL] = { 0 }; - -/* Object argument IDs */ -enum { - ARG_0, - ARG_CONTACT, -}; - -struct _ESelectNamesModelPrivate { - gchar *id; - gchar *title; - - GList *data; /* of EDestination */ - - gint limit; - - gint freeze_count; - gboolean pending_changed; -}; - -static GObjectClass *parent_class = NULL; - -static void e_select_names_model_init (ESelectNamesModel *model); -static void e_select_names_model_class_init (ESelectNamesModelClass *klass); - -static void e_select_names_model_dispose (GObject *object); - -GType -e_select_names_model_get_type (void) -{ - static GType type = 0; - - if (!type) { - static const GTypeInfo info = { - sizeof (ESelectNamesModelClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) e_select_names_model_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (ESelectNamesModel), - 0, /* n_preallocs */ - (GInstanceInitFunc) e_select_names_model_init, - }; - - type = g_type_register_static (G_TYPE_OBJECT, "ESelectNamesModel", &info, 0); - } - - return type; -} - -static void -e_select_names_model_class_init (ESelectNamesModelClass *klass) -{ - GObjectClass *object_class; - - object_class = G_OBJECT_CLASS(klass); - parent_class = g_type_class_peek_parent (klass); - - e_select_names_model_signals[E_SELECT_NAMES_MODEL_CHANGED] = - g_signal_new ("changed", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (ESelectNamesModelClass, changed), - NULL, NULL, - e_select_names_marshal_NONE__NONE, - G_TYPE_NONE, 0); - - e_select_names_model_signals[E_SELECT_NAMES_MODEL_RESIZED] = - g_signal_new ("resized", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (ESelectNamesModelClass, resized), - NULL, NULL, - e_select_names_marshal_NONE__INT_INT_INT, - G_TYPE_NONE, 3, - G_TYPE_INT, - G_TYPE_INT, - G_TYPE_INT); - - klass->changed = NULL; - - object_class->dispose = e_select_names_model_dispose; -} - -/** - * e_select_names_model_init: - */ -static void -e_select_names_model_init (ESelectNamesModel *model) -{ - model->priv = g_new0 (struct _ESelectNamesModelPrivate, 1); - - model->priv->limit = -1; -} - -static void -e_select_names_model_dispose (GObject *object) -{ - ESelectNamesModel *model = E_SELECT_NAMES_MODEL (object); - - if (model->priv) { - g_free (model->priv->title); - g_free (model->priv->id); - - g_list_foreach (model->priv->data, (GFunc) g_object_unref, NULL); - g_list_free (model->priv->data); - - g_free (model->priv); - model->priv = NULL; - } - - if (G_OBJECT_CLASS (parent_class)->dispose) - G_OBJECT_CLASS (parent_class)->dispose (object); -} - - -static void -e_select_names_model_changed (ESelectNamesModel *model) -{ - if (model->priv->freeze_count > 0) { - model->priv->pending_changed = TRUE; - } else { - g_signal_emit (model, e_select_names_model_signals[E_SELECT_NAMES_MODEL_CHANGED], 0); - model->priv->pending_changed = FALSE; - } -} - -/** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **/ - -ESelectNamesModel * -e_select_names_model_new (void) -{ - ESelectNamesModel *model; - model = g_object_new (E_TYPE_SELECT_NAMES_MODEL, NULL); - return model; -} - -ESelectNamesModel * -e_select_names_model_duplicate (ESelectNamesModel *old) -{ - ESelectNamesModel *model = e_select_names_model_new (); - GList *iter; - - model->priv->id = g_strdup (old->priv->id); - model->priv->title = g_strdup (old->priv->title); - - for (iter = old->priv->data; iter != NULL; iter = g_list_next (iter)) { - EDestination *dup = e_destination_copy (E_DESTINATION (iter->data)); - e_select_names_model_append (model, dup); - } - - model->priv->limit = old->priv->limit; - - return model; -} - -gchar * -e_select_names_model_get_textification (ESelectNamesModel *model, const char *separator) -{ - gchar *text; - - g_return_val_if_fail (model != NULL, NULL); - g_return_val_if_fail (E_IS_SELECT_NAMES_MODEL (model), NULL); - g_return_val_if_fail (separator && *separator, NULL); - - if (model->priv->data == NULL) { - - text = g_strdup (""); - - } else { - gchar **strv = g_new0 (gchar *, g_list_length (model->priv->data)+1); - gint i = 0; - GList *iter = model->priv->data; - - while (iter) { - EDestination *dest = E_DESTINATION (iter->data); - strv[i] = (gchar *) e_destination_get_textrep (dest, FALSE); - ++i; - iter = g_list_next (iter); - } - - text = g_strjoinv (separator, strv); - - g_free (strv); - - } - - return text; -} - -gchar * -e_select_names_model_get_address_text (ESelectNamesModel *model, const char *separator) -{ - gchar *addr_text; - - g_return_val_if_fail (model != NULL, NULL); - g_return_val_if_fail (E_IS_SELECT_NAMES_MODEL (model), NULL); - g_return_val_if_fail (separator && *separator, NULL); - - if (model->priv->data == NULL) { - - addr_text = g_strdup (""); - - } else { - gchar **strv = g_new0 (gchar *, g_list_length (model->priv->data)+1); - gint i = 0; - GList *iter = model->priv->data; - - while (iter) { - EDestination *dest = E_DESTINATION (iter->data); - strv[i] = (gchar *) e_destination_get_address (dest); - if (strv[i]) - ++i; - iter = g_list_next (iter); - } - - addr_text = g_strjoinv (separator, strv); - - g_free (strv); - - } - - return addr_text; -} - -gint -e_select_names_model_count (ESelectNamesModel *model) -{ - g_return_val_if_fail (model != NULL, 0); - g_return_val_if_fail (E_IS_SELECT_NAMES_MODEL (model), 0); - - return g_list_length (model->priv->data); -} - -gint -e_select_names_model_get_limit (ESelectNamesModel *model) -{ - g_return_val_if_fail (model != NULL, 0); - g_return_val_if_fail (E_IS_SELECT_NAMES_MODEL (model), 0); - - return model->priv->limit; -} - -void -e_select_names_model_set_limit (ESelectNamesModel *model, gint limit) -{ - g_return_if_fail (model != NULL); - g_return_if_fail (E_IS_SELECT_NAMES_MODEL (model)); - - model->priv->limit = MAX (limit, -1); -} - -gboolean -e_select_names_model_at_limit (ESelectNamesModel *model) -{ - g_return_val_if_fail (model != NULL, TRUE); - g_return_val_if_fail (E_IS_SELECT_NAMES_MODEL (model), TRUE); - - return model->priv->limit >= 0 && g_list_length (model->priv->data) >= model->priv->limit; -} - -const EDestination * -e_select_names_model_get_destination (ESelectNamesModel *model, gint index) -{ - g_return_val_if_fail (model && E_IS_SELECT_NAMES_MODEL (model), NULL); - g_return_val_if_fail (0 <= index, NULL); - g_return_val_if_fail (index < g_list_length (model->priv->data), NULL); - - return E_DESTINATION (g_list_nth_data (model->priv->data, index)); -} - -gchar * -e_select_names_model_export_destinationv (ESelectNamesModel *model) -{ - EDestination **destv; - gchar *str; - gint i, len = 0; - GList *j; - g_return_val_if_fail (model && E_IS_SELECT_NAMES_MODEL (model), NULL); - - len = g_list_length (model->priv->data); - destv = g_new0 (EDestination *, len+1); - - for (i=0, j = model->priv->data; j != NULL; j = g_list_next (j)) { - EDestination *dest = E_DESTINATION (j->data); - - if (dest) - destv[i++] = dest; - } - - str = e_destination_exportv (destv); - g_free (destv); - - return str; -} - -void -e_select_names_model_import_destinationv (ESelectNamesModel *model, - gchar *destinationv) -{ - EDestination **destv; - gint i; - - g_return_if_fail (model && E_IS_SELECT_NAMES_MODEL (model)); - - destv = e_destination_importv (destinationv); - - e_select_names_model_delete_all (model); - - if (destv == NULL) - return; - - for (i = 0; destv[i]; i++) { - e_select_names_model_append (model, destv[i]); - } - g_free (destv); -} - -EContact * -e_select_names_model_get_contact (ESelectNamesModel *model, gint index) -{ - const EDestination *dest; - - g_return_val_if_fail (model && E_IS_SELECT_NAMES_MODEL (model), NULL); - g_return_val_if_fail (0 <= index, NULL); - g_return_val_if_fail (index < g_list_length (model->priv->data), NULL); - - dest = e_select_names_model_get_destination (model, index); - return dest ? e_destination_get_contact (dest) : NULL; - -} - -const gchar * -e_select_names_model_get_string (ESelectNamesModel *model, gint index) -{ - const EDestination *dest; - - g_return_val_if_fail (model && E_IS_SELECT_NAMES_MODEL (model), NULL); - g_return_val_if_fail (0 <= index, NULL); - g_return_val_if_fail (index < g_list_length (model->priv->data), NULL); - - dest = e_select_names_model_get_destination (model, index); - - return dest ? e_destination_get_textrep (dest, FALSE) : ""; -} - -gboolean -e_select_names_model_contains (ESelectNamesModel *model, const EDestination *dest) -{ - GList *iter; - - g_return_val_if_fail (E_IS_SELECT_NAMES_MODEL (model), FALSE); - g_return_val_if_fail (E_IS_DESTINATION (dest), FALSE); - - for (iter = model->priv->data; iter != NULL; iter = g_list_next (iter)) { - if (iter->data != NULL && e_destination_equal (dest, E_DESTINATION (iter->data))) - return TRUE; - } - - return FALSE; -} - -void -e_select_names_model_insert (ESelectNamesModel *model, gint index, EDestination *dest) -{ - g_return_if_fail (model != NULL); - g_return_if_fail (E_IS_SELECT_NAMES_MODEL (model)); - g_return_if_fail (0 <= index && index <= g_list_length (model->priv->data)); - g_return_if_fail (dest && E_IS_DESTINATION (dest)); - - if (e_select_names_model_at_limit (model)) { - /* FIXME: This is bad. */ - g_object_unref (dest); - return; - } - - model->priv->data = g_list_insert (model->priv->data, dest, index); - - g_object_ref (dest); - - e_select_names_model_changed (model); -} - -void -e_select_names_model_append (ESelectNamesModel *model, EDestination *dest) -{ - g_return_if_fail (model && E_IS_SELECT_NAMES_MODEL (model)); - g_return_if_fail (dest && E_IS_DESTINATION (dest)); - - if (e_select_names_model_at_limit (model)) { - /* FIXME: This is bad. */ - g_object_unref (dest); - return; - } - - model->priv->data = g_list_append (model->priv->data, dest); - - g_object_ref (dest); - - e_select_names_model_changed (model); -} - -void -e_select_names_model_replace (ESelectNamesModel *model, gint index, EDestination *dest) -{ - GList *node; - const gchar *new_str, *old_str; - gint old_strlen=0, new_strlen=0; - - g_return_if_fail (model != NULL); - g_return_if_fail (E_IS_SELECT_NAMES_MODEL (model)); - g_return_if_fail (model->priv->data == NULL || (0 <= index && index < g_list_length (model->priv->data))); - g_return_if_fail (dest && E_IS_DESTINATION (dest)); - - new_str = e_destination_get_textrep (dest, FALSE); - new_strlen = new_str ? strlen (new_str) : 0; - - if (model->priv->data == NULL) { - - model->priv->data = g_list_append (model->priv->data, dest); - g_object_ref (dest); - - } else { - - node = g_list_nth (model->priv->data, index); - - if (node->data != dest) { - - old_str = e_destination_get_textrep (E_DESTINATION (node->data), FALSE); - old_strlen = old_str ? strlen (old_str) : 0; - - g_object_unref (node->data); - - node->data = dest; - g_object_ref (dest); - } - } - - e_select_names_model_changed (model); - - g_signal_emit (model, e_select_names_model_signals[E_SELECT_NAMES_MODEL_RESIZED], 0, - index, old_strlen, new_strlen); -} - -void -e_select_names_model_delete (ESelectNamesModel *model, gint index) -{ - GList *node; - EDestination *dest; - - g_return_if_fail (model != NULL); - g_return_if_fail (E_IS_SELECT_NAMES_MODEL (model)); - g_return_if_fail (0 <= index && index < g_list_length (model->priv->data)); - - node = g_list_nth (model->priv->data, index); - dest = E_DESTINATION (node->data); - - g_object_unref (dest); - - model->priv->data = g_list_remove_link (model->priv->data, node); - g_list_free_1 (node); - - e_select_names_model_changed (model); -} - -void -e_select_names_model_clean (ESelectNamesModel *model, gboolean clean_last_entry) -{ - GList *iter, *next; - gboolean changed = FALSE; - - g_return_if_fail (model != NULL && E_IS_SELECT_NAMES_MODEL (model)); - - iter = model->priv->data; - - while (iter) { - EDestination *dest; - - next = g_list_next (iter); - - if (next == NULL && !clean_last_entry) - break; - - dest = iter->data ? E_DESTINATION (iter->data) : NULL; - - if (dest == NULL || e_destination_empty (dest)) { - if (dest) - g_object_unref (dest); - model->priv->data = g_list_remove_link (model->priv->data, iter); - g_list_free_1 (iter); - changed = TRUE; - } - - iter = next; - } - - if (changed) - e_select_names_model_changed (model); -} - -void -e_select_names_model_delete_all (ESelectNamesModel *model) -{ - g_return_if_fail (model != NULL && E_IS_SELECT_NAMES_MODEL (model)); - - g_list_foreach (model->priv->data, (GFunc)g_object_unref, model); - g_list_free (model->priv->data); - model->priv->data = NULL; - - e_select_names_model_changed (model); -} - -void -e_select_names_model_overwrite_copy (ESelectNamesModel *dest, ESelectNamesModel *src) -{ - gint i, len; - - g_return_if_fail (dest && E_IS_SELECT_NAMES_MODEL (dest)); - g_return_if_fail (src && E_IS_SELECT_NAMES_MODEL (src)); - - if (src == dest) - return; - - e_select_names_model_delete_all (dest); - len = e_select_names_model_count (src); - for (i = 0; i < len; ++i) { - const EDestination *d = e_select_names_model_get_destination (src, i); - if (d) - e_select_names_model_append (dest, e_destination_copy (d)); - } -} - -void -e_select_names_model_merge (ESelectNamesModel *dest, ESelectNamesModel *src) -{ - gint i, len; - - g_return_if_fail (E_IS_SELECT_NAMES_MODEL (dest)); - g_return_if_fail (E_IS_SELECT_NAMES_MODEL (src)); - - if (src == dest) - return; - - len = e_select_names_model_count (src); - for (i = 0; i < len; ++i) { - const EDestination *d = e_select_names_model_get_destination (src, i); - if (d && !e_select_names_model_contains (dest, d)) - e_select_names_model_append (dest, e_destination_copy (d)); - } -} - -typedef struct { - EDestination *dest; - ESelectNamesModel *model; -} ModelDestClosure; - -static void -name_and_email_simple_query_cb (EBook *book, EBookStatus status, GList *contacts, gpointer closure) -{ - ModelDestClosure *c = closure; - EDestination *dest = c->dest; - ESelectNamesModel *model = c->model; - EContact *contact; - int num_non_list_contacts = 0; - GList *l; - - g_free (c); - - if (status == E_BOOK_ERROR_OK) { - for (l = contacts; l; l = l->next) { - EContact *c = E_CONTACT (l->data); - if (!e_contact_get (c, E_CONTACT_IS_LIST)) { - num_non_list_contacts++; - contact = c; - } - } - - if (num_non_list_contacts == 1) { - const char *email = e_destination_get_email (dest); - int email_num = 0; - - if (email && *email) { - GList *email_list = e_contact_get (contact, E_CONTACT_EMAIL); - GList *l; - - for (l = email_list; l; l = l->next) { - if (!g_ascii_strcasecmp (email, l->data)) - break; - email_num++; - } - if (l == NULL) - email_num = -1; - } - - if (email_num >= 0) { - e_destination_set_contact (dest, contact, email_num); - e_select_names_model_changed (model); - } - } - } - - - g_object_unref (dest); - g_object_unref (model); - g_object_unref (book); -} - -static void -book_opened (EBook *book, EBookStatus status, gpointer closure) -{ - ESelectNamesModel *model = closure; - GList *iter; - - for (iter = model->priv->data; iter != NULL; iter = g_list_next (iter)) { - ModelDestClosure *c = g_new (ModelDestClosure, 1); - - c->dest = g_object_ref (E_DESTINATION (iter->data)); - c->model = g_object_ref (model); - - if (e_destination_is_evolution_list (c->dest)) - continue; - - if (e_destination_get_contact (c->dest)) - continue; - - g_object_ref (book); - - eab_name_and_email_query (book, - e_destination_get_name (c->dest), - e_destination_get_email (c->dest), - name_and_email_simple_query_cb, - c); - } - - - g_object_unref (model); - g_object_unref (book); -} - -void -e_select_names_model_load_contacts (ESelectNamesModel *model) -{ - EBook *book; - - g_return_if_fail (E_IS_SELECT_NAMES_MODEL (model)); - - if (model->priv->data) { - g_object_ref (model); - - book = e_book_new_default_addressbook (NULL); - - e_book_async_open (book, TRUE, book_opened, model); - } -} - -void -e_select_names_cancel_contacts_load (ESelectNamesModel *model) -{ -} - - -void -e_select_names_model_name_pos (ESelectNamesModel *model, gint seplen, gint index, gint *pos, gint *length) -{ - gint rp = 0, i, len = 0; - GList *iter; - const gchar *str; - - g_return_if_fail (E_IS_SELECT_NAMES_MODEL (model)); - g_return_if_fail (seplen > 0); - - i = 0; - iter = model->priv->data; - while (iter && i <= index) { - rp += len + (i > 0 ? seplen : 0); - str = e_destination_get_textrep (E_DESTINATION (iter->data), FALSE); - len = str ? g_utf8_strlen (str, -1) : 0; - ++i; - iter = g_list_next (iter); - } - - if (i <= index) { - rp = -1; - len = 0; - } - - if (pos) - *pos = rp; - if (length) - *length = len; -} - -void -e_select_names_model_text_pos (ESelectNamesModel *model, gint seplen, gint pos, gint *index, gint *start_pos, gint *length) -{ - GList *iter; - const gchar *str; - gint len = 0, i = 0, sp = 0, adj = 0; - - g_return_if_fail (E_IS_SELECT_NAMES_MODEL (model)); - g_return_if_fail (seplen > 0); - - iter = model->priv->data; - - while (iter != NULL) { - str = e_destination_get_textrep (E_DESTINATION (iter->data), FALSE); - len = str ? g_utf8_strlen (str, -1) : 0; - - if (sp <= pos && pos <= sp + len + adj) { - break; - } - - sp += len + adj + 1; - adj = seplen-1; - ++i; - - iter = g_list_next (iter); - } - - if (i != 0) - sp += seplen-1; /* skip past "magic space" */ - - if (iter == NULL) { -#if 0 - g_print ("text_pos ended NULL\n"); -#endif - i = -1; - sp = -1; - len = 0; - } else { -#if 0 - g_print ("text_pos got index %d\n", i); -#endif - } - - if (index) - *index = i; - if (start_pos) - *start_pos = sp; - if (length) - *length = len; -} - -void -e_select_names_model_freeze (ESelectNamesModel *model) -{ - g_return_if_fail (E_IS_SELECT_NAMES_MODEL (model)); - - ++model->priv->freeze_count; -} - -void -e_select_names_model_thaw (ESelectNamesModel *model) -{ - g_return_if_fail (E_IS_SELECT_NAMES_MODEL (model)); - g_return_if_fail (model->priv->freeze_count > 0); - - --model->priv->freeze_count; - if (model->priv->pending_changed) - e_select_names_model_changed (model); -} diff --git a/addressbook/gui/component/select-names/e-select-names-model.h b/addressbook/gui/component/select-names/e-select-names-model.h deleted file mode 100644 index 10bede3f85..0000000000 --- a/addressbook/gui/component/select-names/e-select-names-model.h +++ /dev/null @@ -1,88 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * Authors: - * Chris Lahey <clahey@ximian.com> - * Jon Trowbridge <trow@ximian.com> - * - * Copyright (C) 2000, 2001 Ximian, Inc. - */ - -#ifndef __E_SELECT_NAMES_MODEL_H__ -#define __E_SELECT_NAMES_MODEL_H__ - -#include <time.h> -#include <gtk/gtkobject.h> -#include <stdio.h> -#include <e-util/e-list.h> -#include <libebook/e-contact.h> -#include <addressbook/util/e-destination.h> - -#define E_TYPE_SELECT_NAMES_MODEL (e_select_names_model_get_type ()) -#define E_SELECT_NAMES_MODEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_SELECT_NAMES_MODEL, ESelectNamesModel)) -#define E_SELECT_NAMES_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_SELECT_NAMES_MODEL, ESelectNamesModelClass)) -#define E_IS_SELECT_NAMES_MODEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_SELECT_NAMES_MODEL)) -#define E_IS_SELECT_NAMES_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), E_TYPE_SELECT_NAMES_MODEL)) - -typedef struct _ESelectNamesModel ESelectNamesModel; -typedef struct _ESelectNamesModelClass ESelectNamesModelClass; -struct _ESelectNamesModelPrivate; - -struct _ESelectNamesModel { - GObject object; - - struct _ESelectNamesModelPrivate *priv; -}; - -struct _ESelectNamesModelClass { - GObjectClass parent_class; - - void (*changed) (ESelectNamesModel *model); - void (*resized) (ESelectNamesModel *model, gint index, gint old_len, gint new_len); -}; - -GType e_select_names_model_get_type (void); - -ESelectNamesModel *e_select_names_model_new (void); -ESelectNamesModel *e_select_names_model_duplicate (ESelectNamesModel *old); - -gchar *e_select_names_model_get_textification (ESelectNamesModel *model, const char *separator); -gchar *e_select_names_model_get_address_text (ESelectNamesModel *model, const char *separator); - -gint e_select_names_model_count (ESelectNamesModel *model); -gint e_select_names_model_get_limit (ESelectNamesModel *model); -void e_select_names_model_set_limit (ESelectNamesModel *model, gint limit); -gboolean e_select_names_model_at_limit (ESelectNamesModel *model); - -const EDestination *e_select_names_model_get_destination (ESelectNamesModel *model, gint index); -gchar *e_select_names_model_export_destinationv (ESelectNamesModel *model); -void e_select_names_model_import_destinationv (ESelectNamesModel *model, - gchar *destinationv); -EContact *e_select_names_model_get_contact (ESelectNamesModel *model, gint index); -const gchar *e_select_names_model_get_string (ESelectNamesModel *model, gint index); - -gboolean e_select_names_model_contains (ESelectNamesModel *model, const EDestination *dest); - -void e_select_names_model_insert (ESelectNamesModel *model, gint index, EDestination *dest); -void e_select_names_model_append (ESelectNamesModel *model, EDestination *dest); -void e_select_names_model_replace (ESelectNamesModel *model, gint index, EDestination *dest); -void e_select_names_model_delete (ESelectNamesModel *model, gint index); -void e_select_names_model_delete_all (ESelectNamesModel *model); -void e_select_names_model_overwrite_copy (ESelectNamesModel *dest, ESelectNamesModel *src); -void e_select_names_model_merge (ESelectNamesModel *dest, ESelectNamesModel *src); - -void e_select_names_model_clean (ESelectNamesModel *model, gboolean clean_last_entry); - -void e_select_names_model_name_pos (ESelectNamesModel *model, gint seplen, gint index, gint *pos, gint *length); -void e_select_names_model_text_pos (ESelectNamesModel *model, gint seplen, gint pos, gint *index, gint *start_pos, gint *length); - -void e_select_names_model_load_contacts (ESelectNamesModel *model); -void e_select_names_cancel_contacts_load (ESelectNamesModel *model); - -/* This is a mildly annoying freeze/thaw pair, in that it only applies to the 'changed' - signal and not to 'resized'. This could cause unexpected results in some cases. */ -void e_select_names_model_freeze (ESelectNamesModel *model); -void e_select_names_model_thaw (ESelectNamesModel *model); - - -#endif /* ! __E_SELECT_NAMES_MODEL_H__ */ diff --git a/addressbook/gui/component/select-names/e-select-names-popup.c b/addressbook/gui/component/select-names/e-select-names-popup.c deleted file mode 100644 index 8251ed4ea1..0000000000 --- a/addressbook/gui/component/select-names/e-select-names-popup.c +++ /dev/null @@ -1,393 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * e-select-names-popup.c - * - * Copyright (C) 2001 Ximian, Inc. - * - * Developed by Jon Trowbridge <trow@ximian.com> - */ - -/* - * 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. - */ - -#include <config.h> - -#include <stdio.h> -#include <string.h> - -#include <glib.h> -#include <gtk/gtkimage.h> -#include <gtk/gtkmenuitem.h> -#include <gtk/gtkimagemenuitem.h> -#include <gtk/gtkcheckmenuitem.h> -#include <gtk/gtkradiomenuitem.h> -#include <gtk/gtkseparatormenuitem.h> -#include <libgnome/gnome-i18n.h> - -#include <addressbook/util/eab-book-util.h> -#include <addressbook/gui/contact-editor/e-contact-editor.h> -#include <addressbook/gui/contact-list-editor/e-contact-list-editor.h> -#include <addressbook/gui/contact-editor/e-contact-quick-add.h> -#include "eab-gui-util.h" -#include "e-select-names-popup.h" -#include <e-util/e-icon-factory.h> - -#define LIST_ICON_NAME "stock_contact-list" -#define CONTACT_ICON_NAME "stock_contact" - -typedef struct _PopupInfo PopupInfo; -struct _PopupInfo { - ESelectNamesTextModel *text_model; - EDestination *dest; - gint pos; - gint index; -}; - -static PopupInfo * -popup_info_new (ESelectNamesTextModel *text_model, EDestination *dest, gint pos, gint index) -{ - PopupInfo *info = g_new0 (PopupInfo, 1); - info->text_model = text_model; - info->dest = dest; - info->pos = pos; - info->index = index; - - if (text_model) - g_object_ref (text_model); - - if (dest) - g_object_ref (dest); - - return info; -} - -static void -popup_info_free (PopupInfo *info) -{ - if (info) { - - if (info->text_model) - g_object_unref (info->text_model); - - if (info->dest) - g_object_unref (info->dest); - - g_free (info); - } -} - -static void -popup_info_cleanup (GtkWidget *w, gpointer info) -{ - g_signal_handlers_disconnect_matched (G_OBJECT (w), G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, info); - - popup_info_free ((PopupInfo *) info); -} - -/* You are in a maze of twisty little callbacks, all alike... */ - -#if TOO_MANY_MENU_ITEMS -static void -make_contact_editor_cb (EBook *book, gpointer user_data) -{ - if (book) { - EDestination *dest = E_DESTINATION (user_data); - EContact *contact; - - contact = (EContact *) e_destination_get_contact (dest); - if (e_contact_get (contact, E_CONTACT_IS_LIST)) { - EContactListEditor *ce; - ce = e_addressbook_show_contact_list_editor (book, contact, FALSE, TRUE); - e_contact_list_editor_raise (ce); - } - else { - EContactEditor *ce; - ce = e_addressbook_show_contact_editor (book, contact, FALSE, TRUE); - e_contact_editor_raise (ce); - } - g_object_unref (dest); - } -} - -static void -edit_contact_info_cb (GtkWidget *w, gpointer user_data) -{ - PopupInfo *info = (PopupInfo *) user_data; - if (info == NULL) - return; - - g_object_ref (info->dest); - e_book_use_default_book (make_contact_editor_cb, (gpointer) info->dest); -} -#endif - -static void -change_email_num_cb (GtkWidget *w, gpointer user_data) -{ - PopupInfo *info = (PopupInfo *) user_data; - gint n; - EDestination *dest; - - if (info == NULL) - return; - - if (! GTK_CHECK_MENU_ITEM (w)->active) - return; - - n = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (w), "number")); - - if (n != e_destination_get_email_num (info->dest)) { - dest = e_destination_new (); - e_destination_set_contact (dest, e_destination_get_contact (info->dest), n); - e_select_names_model_replace (info->text_model->source, info->index, dest); - } -} - -#if TOO_MANY_MENU_ITEMS -static void -remove_recipient_cb (GtkWidget *w, gpointer user_data) -{ - PopupInfo *info = (PopupInfo *) user_data; - e_select_names_model_delete (info->text_model->source, info->index); -} - -static void -remove_all_recipients_cb (GtkWidget *w, gpointer user_data) -{ - PopupInfo *info = (PopupInfo *) user_data; - e_select_names_model_delete_all (info->text_model->source); -} - -static void -toggle_html_mail_cb (GtkWidget *w, gpointer user_data) -{ - PopupInfo *info = (PopupInfo *) user_data; - GtkCheckMenuItem *item = GTK_CHECK_MENU_ITEM (w); - const EDestination *dest; - - if (info == NULL) - return; - - dest = info->dest; - - item = GTK_CHECK_MENU_ITEM (item); - e_destination_set_html_mail_pref ((EDestination *) dest, item->active); -} -#endif - -static void -populate_popup_contact (GtkWidget *pop, gboolean list, PopupInfo *info) -{ - GdkPixbuf *pixbuf; - GtkWidget *image; - EContact *contact; - GtkWidget *menuitem; - GList *email_list; - - contact = e_destination_get_contact (info->dest); - -#if TOO_MANY_MENU_ITEMS - menuitem = gtk_separator_menu_item_new(); - gtk_widget_show (menuitem); - gtk_menu_shell_prepend (GTK_MENU_SHELL (pop), menuitem); - - menuitem = gtk_menu_item_new_with_label (_("Remove All")); - g_signal_connect (menuitem, "activate", - G_CALLBACK (remove_all_recipients_cb), - info); - gtk_widget_show (menuitem); - gtk_menu_shell_prepend (GTK_MENU_SHELL (pop), menuitem); - - menuitem = gtk_menu_item_new_with_label (_("Remove")); - g_signal_connect (menuitem, "activate", - G_CALLBACK (remove_recipient_cb), - info); - gtk_widget_show (menuitem); - gtk_menu_shell_prepend (GTK_MENU_SHELL (pop), menuitem); - - menuitem = gtk_menu_item_new_with_label (list ? _("View Contact List") : _("View Contact Info")); - g_signal_connect (menuitem, "activate", - G_CALLBACK (edit_contact_info_cb), - info); - gtk_widget_show (menuitem); - gtk_menu_shell_prepend (GTK_MENU_SHELL (pop), menuitem); - - menuitem = gtk_check_menu_item_new_with_label (_("Send HTML Mail?")); - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menuitem), - e_destination_get_html_mail_pref (info->dest)); - g_signal_connect (menuitem, "toggled", - G_CALLBACK (toggle_html_mail_cb), - info); - gtk_widget_show (menuitem); - gtk_menu_shell_prepend (GTK_MENU_SHELL (pop), menuitem); -#endif - - email_list = e_contact_get (contact, E_CONTACT_EMAIL); - - if (email_list) { - menuitem = gtk_separator_menu_item_new(); - gtk_widget_show (menuitem); - gtk_menu_shell_prepend (GTK_MENU_SHELL (pop), menuitem); - - if (g_list_length (email_list) > 1) { - GList *l; - GSList *radiogroup = NULL; - gint n = e_destination_get_email_num (info->dest); - gint j = g_list_length (email_list) - 1; - - for (l = g_list_last (email_list); l; l = l->prev) { - char *email = l->data; - char *label = NULL; - - label = g_strdup (email); - - if (list) { - menuitem = gtk_menu_item_new_with_label (label); - } - else { - menuitem = gtk_radio_menu_item_new_with_label (radiogroup, label); - g_signal_connect (menuitem, "toggled", - G_CALLBACK (change_email_num_cb), - info); - if (j == n) - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menuitem), TRUE); - - g_object_set_data (G_OBJECT (menuitem), "number", GINT_TO_POINTER (j)); - radiogroup = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (menuitem)); - } - - gtk_widget_show (menuitem); - gtk_menu_shell_prepend (GTK_MENU_SHELL (pop), menuitem); - - j--; - - g_free (label); - } - } else { - menuitem = gtk_menu_item_new_with_label (e_destination_get_email (info->dest)); - gtk_widget_show (menuitem); - gtk_menu_shell_prepend (GTK_MENU_SHELL (pop), menuitem); - } - - g_list_foreach (email_list, (GFunc)g_free, NULL); - g_list_free (email_list); - } - - menuitem = gtk_separator_menu_item_new (); - gtk_widget_show (menuitem); - gtk_menu_shell_prepend (GTK_MENU_SHELL (pop), menuitem); - - pixbuf = e_icon_factory_get_icon (list ? LIST_ICON_NAME : CONTACT_ICON_NAME, E_ICON_SIZE_MENU); - image = gtk_image_new_from_pixbuf (pixbuf); - g_object_unref (pixbuf); - gtk_widget_show (image); - menuitem = gtk_image_menu_item_new_with_label (e_destination_get_name (info->dest)); - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem), - image); - gtk_widget_show (menuitem); - gtk_menu_shell_prepend (GTK_MENU_SHELL (pop), menuitem); -} - -static void -quick_add_cb (GtkWidget *w, gpointer user_data) -{ - PopupInfo *info = (PopupInfo *) user_data; - e_contact_quick_add_free_form (e_destination_get_address (info->dest), NULL, NULL); -} - -static void -populate_popup_nocontact (GtkWidget *pop, PopupInfo *info) -{ - const gchar *str; - GtkWidget *menuitem; - - menuitem = gtk_separator_menu_item_new (); - gtk_widget_show (menuitem); - gtk_menu_shell_prepend (GTK_MENU_SHELL (pop), menuitem); - - menuitem = gtk_menu_item_new_with_label (_("Add to Contacts")); - gtk_widget_show (menuitem); - gtk_menu_shell_prepend (GTK_MENU_SHELL (pop), menuitem); - g_signal_connect (menuitem, "activate", - G_CALLBACK (quick_add_cb), - info); - -#if TOO_MANY_MENU_ITEMS - menuitem = gtk_check_menu_item_new_with_label (_("Send HTML Mail?")); - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menuitem), - e_destination_get_html_mail_pref (info->dest)); - g_signal_connect (menuitem, "toggled", - G_CALLBACK (toggle_html_mail_cb), - info); - gtk_widget_show (menuitem); - gtk_menu_shell_prepend (GTK_MENU_SHELL (pop), menuitem); -#endif - - menuitem = gtk_separator_menu_item_new (); - gtk_widget_show (menuitem); - gtk_menu_shell_prepend (GTK_MENU_SHELL (pop), menuitem); - - str = e_destination_get_name (info->dest); - if (! (str && *str)) - str = e_destination_get_email (info->dest); - if (! (str && *str)) - str = _("Unnamed Contact"); - - menuitem = gtk_menu_item_new_with_label (str); - gtk_widget_show (menuitem); - gtk_menu_shell_prepend (GTK_MENU_SHELL (pop), menuitem); -} - -void -e_select_names_populate_popup (GtkWidget *menu, ESelectNamesTextModel *text_model, - GdkEventButton *ev, gint pos, GtkWidget *for_widget) -{ - ESelectNamesModel *model; - PopupInfo *info; - EDestination *dest; - gint index; - - g_return_if_fail (GTK_IS_MENU_SHELL (menu)); - g_return_if_fail (E_IS_SELECT_NAMES_TEXT_MODEL (text_model)); - g_return_if_fail (ev); - g_return_if_fail (0 <= pos); - - model = text_model->source; - - e_select_names_model_text_pos (model, text_model->seplen, pos, &index, NULL, NULL); - if (index < 0 || index >= e_select_names_model_count (model)) - return; - - /* XXX yuck, why does this return a const? */ - dest = (EDestination *)e_select_names_model_get_destination (model, index); - if (e_destination_empty (dest)) - return; - - info = popup_info_new (text_model, dest, pos, index); - - if (e_destination_get_contact (dest)) { - populate_popup_contact (menu, e_destination_is_evolution_list (dest), info); - } else { - populate_popup_nocontact (menu, info); - } - - /* Clean up our info item after we've made our selection. */ - g_signal_connect (menu, - "selection-done", - G_CALLBACK (popup_info_cleanup), - info); -} diff --git a/addressbook/gui/component/select-names/e-select-names-popup.h b/addressbook/gui/component/select-names/e-select-names-popup.h deleted file mode 100644 index 531275190b..0000000000 --- a/addressbook/gui/component/select-names/e-select-names-popup.h +++ /dev/null @@ -1,36 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * e-select-names-popup.h - * - * Copyright (C) 2001 Ximian, Inc. - * - * Developed by Jon Trowbridge <trow@ximian.com> - */ - -/* - * 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. - */ - -#ifndef __E_SELECT_NAMES_POPUP_H__ -#define __E_SELECT_NAMES_POPUP_H__ - -#include "e-select-names-text-model.h" - -void e_select_names_populate_popup (GtkWidget *menu, ESelectNamesTextModel *text_model, - GdkEventButton *ev, gint pos, GtkWidget *for_widget); - -#endif /* __E_SELECT_NAMES_POPUP_H__ */ - diff --git a/addressbook/gui/component/select-names/e-select-names-section.etspec b/addressbook/gui/component/select-names/e-select-names-section.etspec deleted file mode 100644 index 9d7b038892..0000000000 --- a/addressbook/gui/component/select-names/e-select-names-section.etspec +++ /dev/null @@ -1,7 +0,0 @@ -<ETableSpecification no-headers="true" cursor-mode="line" alternating-row-colors="false"> - <ETableColumn model_col= "0" _title="Name" expansion="1.0" minimum_width="20" resizable="true" cell="string" compare="collate" search="string"/> - <ETableState> - <column source="0"/> - <grouping> <leaf column="0" ascending="true"/> </grouping> - </ETableState> -</ETableSpecification> diff --git a/addressbook/gui/component/select-names/e-select-names-table-model.c b/addressbook/gui/component/select-names/e-select-names-table-model.c deleted file mode 100644 index dd824a6322..0000000000 --- a/addressbook/gui/component/select-names/e-select-names-table-model.c +++ /dev/null @@ -1,366 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Authors: - * Chris Lahey <clahey@ximian.com> - * - * Copyright (C) 2000 Ximian, Inc. - */ - -#include <config.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#include <gtk/gtksignal.h> -#include <gal/util/e-util.h> -#include <libgnome/gnome-i18n.h> -#include <libebook/e-contact.h> -#include "e-select-names-table-model.h" - -/* Object argument IDs */ -enum { - PROP_0, - PROP_SOURCE, -}; - -static void e_select_names_table_model_init (ESelectNamesTableModel *model); -static void e_select_names_table_model_class_init (ESelectNamesTableModelClass *klass); - -static void e_select_names_table_model_dispose (GObject *object); -static void e_select_names_table_model_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec); -static void e_select_names_table_model_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); -static void e_select_names_table_model_model_changed (ESelectNamesModel *source, - ESelectNamesTableModel *model); - -static ETableModelClass *parent_class = NULL; - -static void -e_select_names_table_model_add_source (ESelectNamesTableModel *model, - ESelectNamesModel *source) -{ - model->source = source; - if (model->source) - g_object_ref(model->source); - model->source_changed_id = g_signal_connect(model->source, "changed", - G_CALLBACK(e_select_names_table_model_model_changed), - model); -} - -static void -e_select_names_table_model_drop_source (ESelectNamesTableModel *model) -{ - if (model->source_changed_id) - g_signal_handler_disconnect(model->source, model->source_changed_id); - if (model->source) - g_object_unref(model->source); - model->source = NULL; - model->source_changed_id = 0; -} - -/** - * e_select_names_table_model_get_type: - * @void: - * - * Registers the &ESelectNamesTableModel class if necessary, and returns the type ID - * associated to it. - * - * Return value: The type ID of the &ESelectNamesTableModel class. - **/ -GType -e_select_names_table_model_get_type (void) -{ - static GType type = 0; - - if (!type) { - static const GTypeInfo info = { - sizeof (ESelectNamesTableModelClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) e_select_names_table_model_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (ESelectNamesTableModel), - 0, /* n_preallocs */ - (GInstanceInitFunc) e_select_names_table_model_init, - }; - - type = g_type_register_static (e_table_model_get_type (), "ESelectNamesTableModel", &info, 0); - } - - return type; -} - -/** - * e_select_names_table_model_new: - * @VCard: a string in vCard format - * - * Returns: a new #ESelectNamesTableModel that wraps the @VCard. - */ -ETableModel * -e_select_names_table_model_new (ESelectNamesModel *source) -{ - ETableModel *model = g_object_new (E_TYPE_SELECT_NAMES_TABLE_MODEL, NULL); - g_object_set(model, - "source", source, - NULL); - return model; -} - -static void -fill_in_info (ESelectNamesTableModel *model) -{ - if (model->source) { - int count = e_select_names_model_count (model->source); - gint i; - - model->count = count; - model->data = g_new(ESelectNamesTableModelData, count); - - for (i = 0; i < count; ++i) { - const EDestination *dest = e_select_names_model_get_destination (model->source, i); - EContact *contact = dest ? e_destination_get_contact (dest) : NULL; - - if (contact) { - model->data[i].name = e_contact_get(contact, E_CONTACT_NAME_OR_ORG); - if (model->data[i].name == 0) - model->data[i].name = g_strdup(""); - model->data[i].email = e_contact_get(contact, E_CONTACT_EMAIL_1); - if (model->data[i].email == 0) - model->data[i].email = g_strdup(""); - } else { - const gchar *name = e_destination_get_name (dest); - const gchar *email = e_destination_get_email (dest); - - model->data[i].name = g_strdup (name && *name ? name : email); - model->data[i].email = g_strdup (email); - } - } - } else { - model->count = 0; - } -} - -static void -clear_info (ESelectNamesTableModel *model) -{ - if (model->data) { - int i; - for (i = 0; i < model->count; i++) { - g_free(model->data[i].name); - g_free(model->data[i].email); - } - g_free(model->data); - model->data = NULL; - } - - model->count = -1; -} - -/* - * ESelectNamesTableModel lifecycle management and vcard loading/saving. - */ - -static void -e_select_names_table_model_dispose (GObject *object) -{ - ESelectNamesTableModel *model; - - model = E_SELECT_NAMES_TABLE_MODEL (object); - - e_select_names_table_model_drop_source (model); - clear_info(model); - - if (G_OBJECT_CLASS (parent_class)->dispose) - G_OBJECT_CLASS (parent_class)->dispose (object); -} - -/* This function returns the number of columns in our ETableModel. */ -static int -e_select_names_table_model_col_count (ETableModel *etc) -{ - return 3; -} - -/* This function returns the number of rows in our ETableModel. */ -static int -e_select_names_table_model_row_count (ETableModel *etc) -{ - ESelectNamesTableModel *e_select_names_table_model = E_SELECT_NAMES_TABLE_MODEL(etc); - if (e_select_names_table_model->count == -1) { - if (e_select_names_table_model->source) { - fill_in_info(e_select_names_table_model); - } else { - return 0; - } - } - return e_select_names_table_model->count; -} - -/* This function returns the value at a particular point in our ETableModel. */ -static void * -e_select_names_table_model_value_at (ETableModel *etc, int col, int row) -{ - ESelectNamesTableModel *e_select_names_table_model = E_SELECT_NAMES_TABLE_MODEL(etc); - if (e_select_names_table_model->data == NULL) { - fill_in_info(e_select_names_table_model); - } - switch (col) { - case 0: - if (e_select_names_table_model->data[row].name == NULL) { - fill_in_info(e_select_names_table_model); - } - return e_select_names_table_model->data[row].name; - break; - case 1: - if (e_select_names_table_model->data[row].email == NULL) { - fill_in_info(e_select_names_table_model); - } - return e_select_names_table_model->data[row].email; - break; - case 2: - /* underline column*/ - return (void*)TRUE; - break; - } - return ""; -} - -/* This function sets the value at a particular point in our ETableModel. */ -static void -e_select_names_table_model_set_value_at (ETableModel *etc, int col, int row, const void *val) -{ -} - -/* This function returns whether a particular cell is editable. */ -static gboolean -e_select_names_table_model_is_cell_editable (ETableModel *etc, int col, int row) -{ - return FALSE; -} - -/* This function duplicates the value passed to it. */ -static void * -e_select_names_table_model_duplicate_value (ETableModel *etc, int col, const void *value) -{ - return g_strdup(value); -} - -/* This function frees the value passed to it. */ -static void -e_select_names_table_model_free_value (ETableModel *etc, int col, void *value) -{ - g_free(value); -} - -static void * -e_select_names_table_model_initialize_value (ETableModel *etc, int col) -{ - return g_strdup(""); -} - -static gboolean -e_select_names_table_model_value_is_empty (ETableModel *etc, int col, const void *value) -{ - return !(value && *(char *)value); -} - -static char * -e_select_names_table_model_value_to_string (ETableModel *etc, int col, const void *value) -{ - return g_strdup(value); -} - -static void -e_select_names_table_model_model_changed (ESelectNamesModel *source, - ESelectNamesTableModel *model) -{ - e_table_model_pre_change(E_TABLE_MODEL(model)); - clear_info(model); - e_table_model_changed(E_TABLE_MODEL(model)); -} - -/* Set_arg handler for the model */ -static void -e_select_names_table_model_set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec) -{ - ESelectNamesTableModel *model; - - model = E_SELECT_NAMES_TABLE_MODEL (object); - - switch (prop_id) { - case PROP_SOURCE: - e_select_names_table_model_drop_source (model); - e_select_names_table_model_add_source (model, E_SELECT_NAMES_MODEL(g_value_get_object (value))); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -/* Get_arg handler for the model */ -static void -e_select_names_table_model_get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec) -{ - ESelectNamesTableModel *model; - - model = E_SELECT_NAMES_TABLE_MODEL (object); - - switch (prop_id) { - case PROP_SOURCE: - g_value_set_object (value, model->source); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -/** - * e_select_names_table_model_init: - */ -static void -e_select_names_table_model_init (ESelectNamesTableModel *model) -{ - model->source = NULL; - model->source_changed_id = 0; - - model->count = -1; - model->data = NULL; -} - -static void -e_select_names_table_model_class_init (ESelectNamesTableModelClass *klass) -{ - GObjectClass *object_class; - ETableModelClass *table_model_class; - - object_class = G_OBJECT_CLASS(klass); - table_model_class = E_TABLE_MODEL_CLASS(klass); - - parent_class = g_type_class_peek_parent (klass); - - object_class->dispose = e_select_names_table_model_dispose; - object_class->get_property = e_select_names_table_model_get_property; - object_class->set_property = e_select_names_table_model_set_property; - - g_object_class_install_property (object_class, PROP_SOURCE, - g_param_spec_object ("source", - _("Source"), - /*_( */"XXX blurb" /*)*/, - E_TYPE_SELECT_NAMES_MODEL, - G_PARAM_READWRITE)); - - table_model_class->column_count = e_select_names_table_model_col_count; - table_model_class->row_count = e_select_names_table_model_row_count; - table_model_class->value_at = e_select_names_table_model_value_at; - table_model_class->set_value_at = e_select_names_table_model_set_value_at; - table_model_class->is_cell_editable = e_select_names_table_model_is_cell_editable; - table_model_class->duplicate_value = e_select_names_table_model_duplicate_value; - table_model_class->free_value = e_select_names_table_model_free_value; - table_model_class->initialize_value = e_select_names_table_model_initialize_value; - table_model_class->value_is_empty = e_select_names_table_model_value_is_empty; - table_model_class->value_to_string = e_select_names_table_model_value_to_string; -} diff --git a/addressbook/gui/component/select-names/e-select-names-table-model.h b/addressbook/gui/component/select-names/e-select-names-table-model.h deleted file mode 100644 index 1fd1026f19..0000000000 --- a/addressbook/gui/component/select-names/e-select-names-table-model.h +++ /dev/null @@ -1,51 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Authors: - * Chris Lahey <clahey@ximian.com> - * - * Copyright (C) 2000 Ximian, Inc. - */ - -#ifndef __E_SELECT_NAMES_TABLE_MODEL_H__ -#define __E_SELECT_NAMES_TABLE_MODEL_H__ - -#include <time.h> -#include <stdio.h> -#include <gtk/gtkobject.h> -#include <gal/e-table/e-table-model.h> -#include "e-select-names-model.h" - -#define E_TYPE_SELECT_NAMES_TABLE_MODEL (e_select_names_table_model_get_type ()) -#define E_SELECT_NAMES_TABLE_MODEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_SELECT_NAMES_TABLE_MODEL, ESelectNamesTableModel)) -#define E_SELECT_NAMES_TABLE_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_SELECT_NAMES_TABLE_MODEL, ESelectNamesTableModelClass)) -#define E_IS_SELECT_NAMES_TABLE_MODEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_SELECT_NAMES_TABLE_MODEL)) -#define E_IS_SELECT_NAMES_TABLE_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), E_TYPE_SELECT_NAMES_TABLE_MODEL)) - -typedef struct { - char *name; - char *email; -} ESelectNamesTableModelData; - -typedef struct _ESelectNamesTableModel ESelectNamesTableModel; -typedef struct _ESelectNamesTableModelClass ESelectNamesTableModelClass; - -struct _ESelectNamesTableModel { - ETableModel parent; - - ESelectNamesModel *source; - int source_changed_id; - - int count; - ESelectNamesTableModelData *data; /* This is used as an array. */ -}; - -struct _ESelectNamesTableModelClass { - ETableModelClass parent_class; -}; - -ETableModel *e_select_names_table_model_new (ESelectNamesModel *source); - -/* Standard Gtk function */ -GType e_select_names_table_model_get_type (void); - -#endif /* ! __E_SELECT_NAMES_TABLE_MODEL_H__ */ diff --git a/addressbook/gui/component/select-names/e-select-names-text-model.c b/addressbook/gui/component/select-names/e-select-names-text-model.c deleted file mode 100644 index 5d0a1edf36..0000000000 --- a/addressbook/gui/component/select-names/e-select-names-text-model.c +++ /dev/null @@ -1,856 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Authors: - * Chris Lahey <clahey@ximian.com> - * Jon Trowbridge <trow@ximian.com> - * - * Copyright (C) 2000, 2001 Ximian, Inc. - */ - -#include <config.h> - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <ctype.h> - -#include <gal/e-text/e-text-model-repos.h> -#include <libgnome/gnome-i18n.h> - -#include <addressbook/gui/contact-editor/e-contact-editor.h> -#include "e-select-names-text-model.h" -#include "eab-gui-util.h" - -static FILE *out = NULL; /* stream for debugging spew */ - -/* Object argument IDs */ -enum { - PROP_0, - PROP_SOURCE, -}; - -static void e_select_names_text_model_class_init (ESelectNamesTextModelClass *klass); -static void e_select_names_text_model_init (ESelectNamesTextModel *model); -static void e_select_names_text_model_dispose (GObject *object); -static void e_select_names_text_model_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec); -static void e_select_names_text_model_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); - -static void e_select_names_text_model_set_source (ESelectNamesTextModel *model, ESelectNamesModel *source); - -static const gchar *e_select_names_text_model_get_text (ETextModel *model); -static void e_select_names_text_model_set_text (ETextModel *model, const gchar *text); -static void e_select_names_text_model_insert (ETextModel *model, gint position, const gchar *text); -static void e_select_names_text_model_insert_length (ETextModel *model, gint position, const gchar *text, gint length); -static void e_select_names_text_model_delete (ETextModel *model, gint position, gint length); - -static gint e_select_names_text_model_obj_count (ETextModel *model); -static const gchar *e_select_names_text_model_get_nth_obj (ETextModel *model, gint n, gint *len); -static void e_select_names_text_model_activate_obj (ETextModel *model, gint n); - - -static ETextModelClass *parent_class; -#define PARENT_TYPE e_text_model_get_type() - -/** - * e_select_names_text_model_get_type: - * @void: - * - * Registers the &ESelectNamesTextModel class if necessary, and returns the type ID - * associated to it. - * - * Return value: The type ID of the &ESelectNamesTextModel class. - **/ -GtkType -e_select_names_text_model_get_type (void) -{ - static GType type = 0; - - if (!type) { - static const GTypeInfo info = { - sizeof (ESelectNamesTextModelClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) e_select_names_text_model_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (ESelectNamesTextModel), - 0, /* n_preallocs */ - (GInstanceInitFunc) e_select_names_text_model_init, - }; - - type = g_type_register_static (PARENT_TYPE, "ESelectNamesTextModel", &info, 0); - } - - return type; -} - -static void -e_select_names_text_model_class_init (ESelectNamesTextModelClass *klass) -{ - GObjectClass *object_class; - ETextModelClass *text_model_class; - - object_class = G_OBJECT_CLASS(klass); - text_model_class = E_TEXT_MODEL_CLASS(klass); - - parent_class = g_type_class_peek_parent (klass); - - object_class->dispose = e_select_names_text_model_dispose; - object_class->get_property = e_select_names_text_model_get_property; - object_class->set_property = e_select_names_text_model_set_property; - - g_object_class_install_property (object_class, PROP_SOURCE, - g_param_spec_object ("source", - _("Source"), - /*_( */"XXX blurb" /*)*/, - E_TYPE_SELECT_NAMES_MODEL, - G_PARAM_READWRITE)); - - text_model_class->get_text = e_select_names_text_model_get_text; - text_model_class->set_text = e_select_names_text_model_set_text; - text_model_class->insert = e_select_names_text_model_insert; - text_model_class->insert_length = e_select_names_text_model_insert_length; - text_model_class->delete = e_select_names_text_model_delete; - - text_model_class->obj_count = e_select_names_text_model_obj_count; - text_model_class->get_nth_obj = e_select_names_text_model_get_nth_obj; - text_model_class->object_activated = e_select_names_text_model_activate_obj; - - if (getenv ("EVO_DEBUG_SELECT_NAMES_TEXT_MODEL")) { - out = fopen ("/tmp/evo-debug-select-names-text-model", "w"); - if (out) - setvbuf (out, NULL, _IONBF, 0); - } -} - -static void -dump_model (ESelectNamesTextModel *text_model) -{ - ESelectNamesModel *model = text_model->source; - gint i; - - if (out == NULL) - return; - - fprintf (out, "\n*** Model State: count=%d\n", e_select_names_model_count (model)); - - for (i=0; i<e_select_names_model_count (model); ++i) - fprintf (out, "[%d] \"%s\" %s\n", i, - e_select_names_model_get_string (model, i), - e_select_names_model_get_contact (model, i) ? "<contact>" : ""); - fprintf (out, "\n"); -} - -static void -e_select_names_text_model_init (ESelectNamesTextModel *model) -{ - const gchar *default_sep; - - model->last_magic_comma_pos = -1; - - if (getenv ("EVOLUTION_DISABLE_MAGIC_COMMA")) - default_sep = ","; - else - default_sep = ", "; - - e_select_names_text_model_set_separator (model, default_sep); -} - -static void -e_select_names_text_model_dispose (GObject *object) -{ - ESelectNamesTextModel *model; - - model = E_SELECT_NAMES_TEXT_MODEL (object); - - if (model->text) { - g_free (model->text); - model->text = NULL; - } - if (model->sep) { - g_free (model->sep); - model->sep = NULL; - } - - e_select_names_text_model_set_source (model, NULL); - - if (G_OBJECT_CLASS(parent_class)->dispose) - G_OBJECT_CLASS(parent_class)->dispose(object); -} - -static void -e_select_names_text_model_set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec) -{ - ESelectNamesTextModel *model; - - model = E_SELECT_NAMES_TEXT_MODEL (object); - - switch (prop_id) { - case PROP_SOURCE: - e_select_names_text_model_set_source(model, E_SELECT_NAMES_MODEL (g_value_get_object(value))); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -e_select_names_text_model_get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec) -{ - ESelectNamesTextModel *model; - - model = E_SELECT_NAMES_TEXT_MODEL (object); - - switch (prop_id) { - case PROP_SOURCE: - g_value_set_object (value, model->source); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -resize_cb (ESelectNamesModel *source, gint index, gint old_len, gint new_len, ETextModel *model) -{ - EReposDeleteShift repos_del; - EReposInsertShift repos_ins; - gint pos; - gint seplen = E_SELECT_NAMES_TEXT_MODEL (model)->seplen; - - e_select_names_model_name_pos (source, seplen, index, &pos, NULL); - - if (new_len < old_len) { - - repos_del.model = model; - repos_del.pos = pos; - repos_del.len = old_len - new_len; - e_text_model_reposition (model, e_repos_delete_shift, &repos_del); - - } else if (old_len < new_len) { - - repos_ins.model = model; - repos_ins.pos = pos; - repos_ins.len = new_len - old_len; - e_text_model_reposition (model, e_repos_insert_shift, &repos_ins); - - } -} - -static void -changed_cb (ESelectNamesModel *source, ETextModel *model) -{ - ESelectNamesTextModel *text_model = E_SELECT_NAMES_TEXT_MODEL (model); - - g_free (text_model->text); - text_model->text = NULL; - - e_text_model_changed (model); -} - - -static void -e_select_names_text_model_set_source (ESelectNamesTextModel *model, - ESelectNamesModel *source) -{ - if (source == model->source) - return; - - if (model->source) { - g_signal_handler_disconnect (model->source, model->source_changed_id); - g_signal_handler_disconnect (model->source, model->source_resize_id); - g_object_unref (model->source); - } - - model->source = source; - - if (model->source) { - g_object_ref (model->source); - model->source_changed_id = g_signal_connect (model->source, - "changed", - G_CALLBACK (changed_cb), - model); - model->source_resize_id = g_signal_connect (model->source, - "resized", - G_CALLBACK (resize_cb), - model); - } -} - -ETextModel * -e_select_names_text_model_new (ESelectNamesModel *source) -{ - ETextModel *model = g_object_new (E_TYPE_SELECT_NAMES_TEXT_MODEL, NULL); - e_select_names_text_model_set_source (E_SELECT_NAMES_TEXT_MODEL (model), source); - return model; -} - -void -e_select_names_text_model_set_separator (ESelectNamesTextModel *model, const char *sep) -{ - g_return_if_fail (E_IS_SELECT_NAMES_TEXT_MODEL (model)); - g_return_if_fail (sep && *sep); - - g_free (model->sep); - model->sep = g_strdup (sep); - model->seplen = g_utf8_strlen (sep, -1); -} - -static const gchar * -e_select_names_text_model_get_text (ETextModel *model) -{ - ESelectNamesTextModel *snm = E_SELECT_NAMES_TEXT_MODEL(model); - - if (snm == NULL) - return ""; - else if (snm->text == NULL) - snm->text = e_select_names_model_get_textification (snm->source, snm->sep); - - return snm->text; -} - -static void -e_select_names_text_model_set_text (ETextModel *model, const gchar *text) -{ - ESelectNamesTextModel *snm = E_SELECT_NAMES_TEXT_MODEL(model); - - e_select_names_model_delete_all (snm->source); - e_select_names_text_model_insert (model, 0, text); -} - -static void -e_select_names_text_model_insert (ETextModel *model, gint position, const gchar *text) -{ - e_select_names_text_model_insert_length (model, position, text, g_utf8_strlen (text, -1)); -} - -static void -e_select_names_text_model_insert_length (ETextModel *model, gint pos, const gchar *text, gint length) -{ - ESelectNamesTextModel *text_model = E_SELECT_NAMES_TEXT_MODEL (model); - ESelectNamesModel *source = text_model->source; - const char *t; - gchar *tmp; - - if (out) { - tmp = g_strndup (text, length); - fprintf (out, ">> insert \"%s\" (len=%d) at %d\n", tmp, length, pos); - g_free (tmp); - } - - tmp = e_select_names_model_get_textification (source, text_model->sep); - pos = CLAMP (pos, 0, g_utf8_strlen (tmp, -1)); - g_free (tmp); - - /* We want to control all cursor motions ourselves, rather than taking hints - from the ESelectNamesModel. */ - g_signal_handler_block (source, text_model->source_resize_id); - - /* We handle this one character at a time. */ - - for (t = text; length >= 0; t = g_utf8_next_char (t), length--) { - gint index, start_pos, text_len; - gboolean inside_quote = FALSE; - gunichar ut = g_utf8_get_char (t); - - if (ut == 0) - break; - - text_model->last_magic_comma_pos = -1; - - if (out) - fprintf (out, "processing [%d]\n", ut); - - e_select_names_model_text_pos (source, text_model->seplen, pos, &index, &start_pos, &text_len); - - if (out) - fprintf (out, "index=%d start_pos=%d text_len=%d\n", index, start_pos, text_len); - - /* Is this a quoted or an unquoted separator we are dealing with? */ - if (ut == g_utf8_get_char(text_model->sep) && index >= 0) { - const EDestination *dest = e_select_names_model_get_destination (source, index); - if (dest) { - const gchar *str = e_destination_get_textrep (dest, FALSE); - int j; - const char *jp; - - if (out) - fprintf (out, "str=%s pos=%d\n", str, pos); - - for (jp = str, j = 0; j<pos-start_pos && *jp; jp = g_utf8_next_char (jp), ++j) { - if (*jp == '"') { - inside_quote = !inside_quote; - if (out) - fprintf (out, "flip to %d at %d\n", start_pos+j, inside_quote); - } - } - } - if (out) - fprintf (out, inside_quote ? "inside quote\n" : "not inside quote\n"); - } - - - if (ut == g_utf8_get_char (text_model->sep) && !inside_quote) { - - /* This is the case of hitting , first thing in an empty entry */ - if (index == -1) { - EReposAbsolute repos; - - e_select_names_model_insert (source, 0, e_destination_new ()); - e_select_names_model_insert (source, 0, e_destination_new ()); - - repos.model = model; - repos.pos = -1; /* At end */ - e_text_model_reposition (model, e_repos_absolute, &repos); - - - } else if (pos <= start_pos || pos == start_pos + text_len) { - EReposInsertShift repos; - gint ins_point = index; - - if (text_len != 0 && pos == start_pos + text_len) - ++ins_point; - - /* Block adjacent blank cards. */ - if (! ((ins_point < e_select_names_model_count (source) && - (e_select_names_model_get_string (source, ins_point) == NULL)) - || (ins_point > 0 && (e_select_names_model_get_string (source, ins_point-1) == NULL)))) { - - e_select_names_model_insert (source, ins_point, e_destination_new ()); - - repos.model = model; - repos.pos = pos; - repos.len = text_model->seplen; - e_text_model_reposition (model, e_repos_insert_shift, &repos); - pos += text_model->seplen; - } - - } else { - EReposInsertShift repos; - gint offset = MAX (pos - start_pos, 0); - const gchar *str = e_select_names_model_get_string (source, index); - gchar *str1 = g_strndup (str, offset); - gchar *str2 = g_strdup (str+offset); - EDestination *d1 = e_destination_new (), *d2 = e_destination_new (); - - e_destination_set_raw (d1, str1); - e_destination_set_raw (d2, str2); - - e_select_names_model_replace (source, index, d1); - e_select_names_model_insert (source, index+1, d2); - - g_free (str1); - g_free (str2); - - repos.model = model; - repos.pos = pos; - repos.len = text_model->seplen; - e_text_model_reposition (model, e_repos_insert_shift, &repos); - pos += text_model->seplen; - } - - if (text_model->seplen > 1) - text_model->last_magic_comma_pos = pos; - - } else { - EReposInsertShift repos; - gint offset = MAX (pos - start_pos, 0); - const gchar *str; - GString *new_str = g_string_new (NULL); - gint this_length = 1; - gboolean whitespace = g_unichar_isspace (ut); - - str = index >= 0 ? e_select_names_model_get_string (source, index) : NULL; - if (str && *str) { - if (pos <= start_pos) { - if (whitespace) { - /* swallow leading whitespace */ - this_length = 0; - } else { - /* Adjust for our "magic white space" */ - /* FIXME: This code does the wrong thing if seplen > 2 */ - g_string_append_unichar (new_str, ut); - g_string_append (new_str, pos < start_pos ? " " : ""); - g_string_append (new_str, str); - if (pos < start_pos) - ++this_length; - } - } else { - const char *u; - int n; - for (u = str, n = 0; n < offset; u = g_utf8_next_char (u), n++) - g_string_append_unichar (new_str, g_utf8_get_char (u)); - g_string_append_unichar (new_str, ut); - g_string_append (new_str, u); - } - } else { - if (whitespace) { - /* swallow leading whitespace */ - this_length = 0; - } else { - g_string_append_unichar (new_str, ut); - } - } - - if (new_str->len) { - - EDestination *dest; - dest = e_destination_new (); - e_destination_set_raw (dest, new_str->str); - e_select_names_model_replace (source, index, dest); - - if (this_length > 0) { - repos.model = model; - repos.pos = pos; - repos.len = this_length; - e_text_model_reposition (model, e_repos_insert_shift, &repos); - - pos += this_length; - } - } - g_string_free (new_str, TRUE); - } - } - - dump_model (text_model); - - g_signal_handler_unblock (source, text_model->source_resize_id); -} - - -static void -e_select_names_text_model_delete (ETextModel *model, gint pos, gint length) -{ - ESelectNamesTextModel *text_model = E_SELECT_NAMES_TEXT_MODEL (model); - ESelectNamesModel *source = text_model->source; - gint index, start_pos, text_len, offset; - - if (out) { - const gchar *str = e_select_names_model_get_textification (source, text_model->sep); - gint i, len; - - fprintf (out, ">> delete %d at pos %d\n", length, pos); - - len = strlen (str); - for (i=0; i<pos && i<len; ++i) - fprintf (out, "%c", str[i]); - fprintf (out, "["); - for (i=pos; i<pos+length && i<len; ++i) - fprintf (out, "%c", str[i]); - fprintf (out, "]"); - for (i=pos+length; i<len; ++i) - fprintf (out, "%c", str[i]); - fprintf (out, "\n"); - } - - if (length < 0) - return; - - if (text_model->last_magic_comma_pos == pos+1 && length == 1) { - pos -= text_model->seplen-1; - if (pos >= 0) - length = text_model->seplen; - text_model->last_magic_comma_pos = -1; - } - - e_select_names_model_text_pos (source, text_model->seplen, pos, &index, &start_pos, &text_len); - - if (out) - fprintf (out, "index=%d, start_pos=%d, text_len=%d\n", index, start_pos, text_len); - - /* We want to control all cursor motions ourselves, rather than taking hints - from the ESelectNamesModel. */ - g_signal_handler_block (source, E_SELECT_NAMES_TEXT_MODEL (model)->source_resize_id); - - /* First, we handle a few tricky cases. */ - - if (pos < start_pos) { - EReposAbsolute repos; - - repos.model = model; - repos.pos = pos; - e_text_model_reposition (model, e_repos_absolute, &repos); - - length -= start_pos - pos; - - if (length > 0) - e_select_names_text_model_delete (model, start_pos, length); - goto finished; - } - - if (pos == start_pos + text_len) { - /* We are positioned right at the end of an entry, possibly right in front of a comma. */ - - if (index+1 < e_select_names_model_count (source)) { - EReposDeleteShift repos; - EDestination *new_dest; - const gchar *str1 = e_select_names_model_get_string (source, index); - const gchar *str2 = e_select_names_model_get_string (source, index+1); - gchar *new_str; - - while (str1 && *str1 && isspace ((gint) *str1)) - ++str1; - while (str2 && *str2 && isspace ((gint) *str2)) - ++str2; - - if (str1 && str2) - new_str = g_strdup_printf ("%s%s%s", str1, text_model->sep+1, str2); - else if (str1) - new_str = g_strdup (str1); - else if (str2) - new_str = g_strdup (str2); - else - new_str = g_strdup (""); - - if (out) - fprintf (out, "joining \"%s\" and \"%s\" to \"%s\"\n", str1, str2, new_str); - - e_select_names_model_delete (source, index+1); - - new_dest = e_destination_new (); - e_destination_set_raw (new_dest, new_str); - e_select_names_model_replace (source, index, new_dest); - g_free (new_str); - - repos.model = model; - repos.pos = pos; - repos.len = text_model->seplen; - - e_text_model_reposition (model, e_repos_delete_shift, &repos); - - if (length > 1) - e_select_names_text_model_delete (model, pos, length-1); - } else { - /* If we are at the end of the last entry (which we must be if we end up in this block), - we can just do nothing. So this else-block is here just to give us a place to - put this comment. */ - } - - goto finished; - } - - if (pos + length > start_pos + text_len) { - /* Uh oh... our changes straddle two objects. */ - - if (pos == start_pos) { /* Delete the whole thing */ - EReposDeleteShift repos; - - e_select_names_model_delete (source, index); - - if (out) - fprintf (out, "deleted all of %d\n", index); - - repos.model = model; - repos.pos = pos; - repos.len = text_len + text_model->seplen; - - e_text_model_reposition (model, e_repos_delete_shift, &repos); - - length -= text_len + text_model->seplen; - if (length > 0) - e_select_names_text_model_delete (model, pos, length); - - } else { - /* Delete right up to the end, and then call e_select_names_text_model_delete again - to finish the job. */ - gint len1, len2; - - len1 = text_len - (pos - start_pos); - len2 = length - len1; - - if (out) - fprintf (out, "two-stage delete: %d, %d\n", len1, len2); - - - e_select_names_text_model_delete (model, pos, len1); - e_select_names_text_model_delete (model, pos, len2); - } - - goto finished; - } - - /* Our changes are confined to just one entry. */ - if (length > 0) { - const gchar *str; - gchar *new_str; - - offset = pos - start_pos; - - str = e_select_names_model_get_string (source, index); - - if (str) { - const char *p; - char *np; - int i; - EReposDeleteShift repos; - EDestination *dest; - - new_str = g_new0 (char, strlen (str) * 6 + 1); /* worse case it can't be any longer than this */ - - /* copy the region before the deletion */ - for (p = str, i = 0, np = new_str; i < offset; i++) { - gunichar ch; - - ch = g_utf8_get_char (p); - g_unichar_to_utf8 (ch, np); - - np = g_utf8_next_char (np); - p = g_utf8_next_char (p); - } - - /* skip the deleted segment */ - for (i = 0; i < length; i++) - p = g_utf8_next_char (p); - - /* copy the region after the deletion */ - for (; *p; p = g_utf8_next_char (p)) { - gunichar ch; - - ch = g_utf8_get_char (p); - g_unichar_to_utf8 (ch, np); - - np = g_utf8_next_char (np); - } - - dest = e_destination_new (); - e_destination_set_raw (dest, new_str); - e_select_names_model_replace (source, index, dest); - - if (out) - fprintf (out, "new_str: \"%s\"\n", new_str); - - g_free (new_str); - - repos.model = model; - repos.pos = pos; - repos.len = length; - - e_text_model_reposition (model, e_repos_delete_shift, &repos); - - } else { - EReposDeleteShift repos; - - e_select_names_model_delete (source, index); - - if (out) - fprintf (out, "deleted %d\n", index); - - - repos.model = model; - repos.pos = pos; - repos.len = text_model->seplen; - - e_text_model_reposition (model, e_repos_delete_shift, &repos); - } - } - - finished: - E_SELECT_NAMES_TEXT_MODEL (model)->last_magic_comma_pos = -1; - g_signal_handler_unblock (source, E_SELECT_NAMES_TEXT_MODEL (model)->source_resize_id); - dump_model (E_SELECT_NAMES_TEXT_MODEL (model)); -} - -static gint -e_select_names_text_model_obj_count (ETextModel *model) -{ - ESelectNamesModel *source = E_SELECT_NAMES_TEXT_MODEL (model)->source; - gint i, count; - - count = i = e_select_names_model_count (source); - while (i > 0) { - const EDestination *dest; - --i; - dest = e_select_names_model_get_destination (source, i); - if (e_destination_get_contact (dest) == NULL) - --count; - } - - return count; -} - -static gint -nth_obj_index (ESelectNamesModel *source, gint n) -{ - gint i, N; - - i = 0; - N = e_select_names_model_count (source); - - do { - const EDestination *dest = e_select_names_model_get_destination (source, i); - if (e_destination_get_contact (dest)) - --n; - ++i; - } while (n >= 0 && i < N); - - if (i <= N) - --i; - else - i = -1; - - return i; -} - -static const gchar * -e_select_names_text_model_get_nth_obj (ETextModel *model, gint n, gint *len) -{ - ESelectNamesTextModel *text_model = E_SELECT_NAMES_TEXT_MODEL (model); - ESelectNamesModel *source = text_model->source; - gint i, pos; - - i = nth_obj_index (source, n); - if (i < 0) - return NULL; - - e_select_names_model_name_pos (source, text_model->seplen, i, &pos, len); - if (pos < 0) - return NULL; - - if (text_model->text == NULL) - text_model->text = e_select_names_model_get_textification (source, text_model->sep); - return g_utf8_offset_to_pointer (text_model->text, pos); -} - -static void -e_select_names_text_model_activate_obj (ETextModel *model, gint n) -{ - ESelectNamesModel *source = E_SELECT_NAMES_TEXT_MODEL (model)->source; - EContact *contact; - EBook *book; - gint i; - - i = nth_obj_index (source, n); - g_return_if_fail (i >= 0); - - contact = e_select_names_model_get_contact (source, i); - g_return_if_fail (contact != NULL); - - /* XXX unfortunately we don't have an e_contact_get_book call - anymore, so we can't query for the addressbook that the - contact came from. however, since we're bringing up a - read-only contact editor, it really doesn't matter what we - show in the source option menu, does it? */ - book = e_book_new_system_addressbook (NULL); - g_return_if_fail (book != NULL); - - /* present read-only contact editor when someone double clicks from here */ - if (e_contact_get (contact, E_CONTACT_IS_LIST)) { - EContactListEditor *ce; - ce = eab_show_contact_list_editor (book, contact, FALSE, FALSE); - eab_editor_raise (EAB_EDITOR (ce)); - } - else { - EContactEditor *ce; - ce = eab_show_contact_editor (book, contact, FALSE, FALSE); - eab_editor_raise (EAB_EDITOR (ce)); - } - - g_object_unref (book); -} - - - diff --git a/addressbook/gui/component/select-names/e-select-names-text-model.h b/addressbook/gui/component/select-names/e-select-names-text-model.h deleted file mode 100644 index eec062aee6..0000000000 --- a/addressbook/gui/component/select-names/e-select-names-text-model.h +++ /dev/null @@ -1,53 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Authors: - * Chris Lahey <clahey@ximian.com> - * Jon Trowbridge <trow@ximian.com> - * - * Copyright (C) 2000, 2001 Ximian, Inc. - */ - -#ifndef __E_SELECT_NAMES_TEXT_MODEL_H__ -#define __E_SELECT_NAMES_TEXT_MODEL_H__ - -#include <time.h> -#include <stdio.h> -#include <gtk/gtkobject.h> -#include <gal/e-text/e-text-model.h> -#include "e-select-names-model.h" - -#define E_TYPE_SELECT_NAMES_TEXT_MODEL (e_select_names_text_model_get_type ()) -#define E_SELECT_NAMES_TEXT_MODEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_SELECT_NAMES_TEXT_MODEL, ESelectNamesTextModel)) -#define E_SELECT_NAMES_TEXT_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_SELECT_NAMES_TEXT_MODEL, ESelectNamesTextModelClass)) -#define E_IS_SELECT_NAMES_TEXT_MODEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_SELECT_NAMES_TEXT_MODEL)) -#define E_IS_SELECT_NAMES_TEXT_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), E_TYPE_SELECT_NAMES_TEXT_MODEL)) - -typedef struct _ESelectNamesTextModel ESelectNamesTextModel; -typedef struct _ESelectNamesTextModelClass ESelectNamesTextModelClass; - -struct _ESelectNamesTextModel { - ETextModel parent; - - ESelectNamesModel *source; - gint source_changed_id; - gint source_resize_id; - - gchar *text; - - gchar *sep; - gint seplen; - - gint last_magic_comma_pos; -}; - -struct _ESelectNamesTextModelClass { - ETextModelClass parent_class; -}; - -ETextModel *e_select_names_text_model_new (ESelectNamesModel *source); -void e_select_names_text_model_set_separator (ESelectNamesTextModel *model, const char *sep); - -/* Standard Gtk function */ -GType e_select_names_text_model_get_type (void); - -#endif /* ! __E_SELECT_NAMES_TEXT_MODEL_H__ */ diff --git a/addressbook/gui/component/select-names/e-select-names.c b/addressbook/gui/component/select-names/e-select-names.c deleted file mode 100644 index cfa8a021e2..0000000000 --- a/addressbook/gui/component/select-names/e-select-names.c +++ /dev/null @@ -1,861 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* e-select-names.c - * Copyright (C) 2000 Ximian, Inc. - * Author: Chris Lahey <clahey@ximian.com> - * - * This library 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 library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include <config.h> -#include <string.h> -#include <glib.h> -#include <gtk/gtkalignment.h> -#include <gtk/gtkentry.h> -#include <gtk/gtklabel.h> -#include <gtk/gtkstock.h> -#include <libgnome/gnome-i18n.h> - -#include <gal/e-table/e-table-simple.h> -#include <gal/e-table/e-table-without.h> - -#include <libebook/e-book.h> -#include <libebook/e-contact.h> -#include <addressbook/gui/widgets/e-addressbook-model.h> -#include <addressbook/gui/widgets/e-addressbook-table-adapter.h> -#include <addressbook/util/eab-book-util.h> -#include <addressbook/gui/component/addressbook-component.h> -#include <addressbook/gui/component/addressbook.h> -#include <addressbook/gui/widgets/eab-popup.h> - -#include "e-select-names-config.h" -#include "e-select-names.h" -#include "e-select-names-table-model.h" -#include <gal/widgets/e-categories-master-list-option-menu.h> -#include <gal/e-text/e-entry.h> -#include <e-util/e-categories-master-list-wombat.h> -#include "e-util/e-sexp.h" - -static void e_select_names_init (ESelectNames *names); -static void e_select_names_class_init (ESelectNamesClass *klass); -static void e_select_names_dispose (GObject *object); -static void update_query (GtkWidget *widget, ESelectNames *e_select_names); -static char *get_query_string (ESelectNames *e_select_names); - -static void sync_table_and_models (ESelectNamesModel *triggering_model, ESelectNames *esl); - -static GtkDialogClass *parent_class = NULL; -#define PARENT_TYPE gtk_dialog_get_type() - -/* The arguments we take */ -enum { - ARG_0, -}; - -typedef struct { - char *title; - ESelectNamesModel *source; - ESelectNamesTableModel *table_model; - ESelectNames *names; - GtkWidget *label; - GtkWidget *button; - GtkWidget *recipient_table; - gulong changed_id; -} ESelectNamesChild; - -GType -e_select_names_get_type (void) -{ - static GType type = 0; - - if (!type) { - static const GTypeInfo info = { - sizeof (ESelectNamesClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) e_select_names_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (ESelectNames), - 0, /* n_preallocs */ - (GInstanceInitFunc) e_select_names_init, - }; - - type = g_type_register_static (PARENT_TYPE, "ESelectNames", &info, 0); - } - - return type; -} - -static void -e_select_names_class_init (ESelectNamesClass *klass) -{ - GObjectClass *object_class; - - object_class = G_OBJECT_CLASS (klass); - - parent_class = g_type_class_peek_parent (klass); - - object_class->dispose = e_select_names_dispose; -} - -GtkWidget *e_addressbook_create_ebook_table(char *name, char *string1, char *string2, int num1, int num2); - -static void -search_result (EABModel *model, EBookViewStatus status, ESelectNames *esn) -{ - sync_table_and_models (NULL, esn); -} - -static void -set_book(EBook *book, EBookStatus status, ESelectNames *esn) -{ - char *query_str = get_query_string (esn); - g_object_set(esn->model, - "book", book, - "query", query_str, - NULL); - g_free (query_str); - g_object_unref(book); - g_object_unref(esn->model); - g_object_unref(esn); -} - -static ESource * -find_first_source (ESourceList *source_list) -{ - GSList *groups, *sources, *l, *m; - - groups = e_source_list_peek_groups (source_list); - for (l = groups; l; l = l->next) { - ESourceGroup *group = l->data; - - sources = e_source_group_peek_sources (group); - for (m = sources; m; m = m->next) { - ESource *source = m->data; - - return source; - } - } - - return NULL; -} - -static void -addressbook_model_set_source (ESelectNames *e_select_names, EABModel *model, ESource *source) -{ - EBook *book; - - book = e_book_new(source, NULL); - - g_object_ref(e_select_names); - g_object_ref(model); - - addressbook_load (book, (EBookCallback) set_book, e_select_names); -} - -static void * -contact_key (const EContact *contact) -{ - EBook *book = NULL; - const gchar *book_uri; - - if (contact == NULL) - return NULL; - - g_assert (E_IS_CONTACT (contact)); - -#if notyet - /* XXX we need a way to reproduce this here somehow.. or at - least make sure we never collide between two contacts in - different books. */ - book = e_contact_get_book (contact); -#endif - book_uri = book ? e_book_get_uri (book) : "NoBook"; - return g_strdup_printf ("%s|%s", book_uri ? book_uri : "NoURI", (char*)e_contact_get_const ((EContact*)contact, E_CONTACT_UID)); -} - -static void -sync_one_model (gpointer k, gpointer val, gpointer closure) -{ - ETableWithout *etw = E_TABLE_WITHOUT (closure); - ESelectNamesChild *child = val; - ESelectNamesModel *model = child->source; - gint i, count; - EContact *contact; - void *key; - - count = e_select_names_model_count (model); - for (i = 0; i < count; ++i) { - contact = e_select_names_model_get_contact (model, i); - if (contact) { - key = contact_key (contact); - e_table_without_hide (etw, key); - g_free (key); - } - } -} - -static void -sync_table_and_models (ESelectNamesModel *triggering_model, ESelectNames *esl) -{ - e_table_without_show_all (E_TABLE_WITHOUT (esl->without)); - g_hash_table_foreach (esl->children, sync_one_model, esl->without); -} - -static void -real_add_address_cb (int model_row, gpointer closure) -{ - ESelectNamesChild *child = closure; - ESelectNames *names = child->names; - const EContact *contact; - EDestination *dest = e_destination_new (); - gint mapped_row; - - mapped_row = e_table_subset_view_to_model_row (E_TABLE_SUBSET (names->without), model_row); - - contact = eab_model_contact_at (EAB_MODEL(names->model), mapped_row); - - if (contact != NULL) { - e_destination_set_contact (dest, (EContact*)contact, 0); - - e_select_names_model_append (child->source, dest); - e_select_names_model_clean (child->source, FALSE); - } -} - -static void -real_add_address(ESelectNames *names, ESelectNamesChild *child) -{ - e_select_names_model_freeze (child->source); - e_table_selected_row_foreach(e_table_scrolled_get_table(names->table), - real_add_address_cb, child); - e_select_names_model_thaw (child->source); -} - -static void -add_address(ETable *table, int row, int col, GdkEvent *event, ESelectNames *names) -{ - ESelectNamesChild *child; - - child = g_hash_table_lookup(names->children, names->def); - if (child) { - real_add_address(names, child); - } -} - -static void -sensitize_button (gpointer key, gpointer data, gpointer user_data) -{ - gboolean *sensitive = user_data; - ESelectNamesChild *child = data; - - gtk_widget_set_sensitive (child->button, *sensitive); -} - -static void -selection_change (ETable *table, ESelectNames *names) -{ - gboolean sensitive; - - sensitive = e_table_selected_count (table) > 0; - - g_hash_table_foreach (names->children, sensitize_button, &sensitive); -} - -static void * -esn_get_key_fn (ETableModel *source, int row, void *closure) -{ - EABModel *model = EAB_MODEL (closure); - const EContact *contact = eab_model_contact_at (model, row); - void *key = contact_key (contact); - return key; -} - -static void * -esn_dup_key_fn (const void *key, void *closure) -{ - void *dup = (void *) g_strdup ((const gchar *) key); - return dup; -} - -static void -esn_free_gotten_key_fn (void *key, void *closure) -{ - g_free (key); -} - -static void -esn_free_duped_key_fn (void *key, void *closure) -{ - g_free (key); -} - -GtkWidget * -e_addressbook_create_ebook_table(char *name, char *string1, char *string2, int num1, int num2) -{ - ETableModel *adapter; - ETableModel *without; - EABModel *model; - GtkWidget *table; - - model = eab_model_new (); - adapter = E_TABLE_MODEL (eab_table_adapter_new (model)); - - g_object_set(model, - "editable", FALSE, - NULL); - - without = e_table_without_new (adapter, - g_str_hash, - g_str_equal, - esn_get_key_fn, - esn_dup_key_fn, - esn_free_gotten_key_fn, - esn_free_duped_key_fn, - model); - - table = e_table_scrolled_new_from_spec_file (without, - NULL, - EVOLUTION_ETSPECDIR "/e-select-names.etspec", - NULL); - - g_object_set_data(G_OBJECT(table), "adapter", adapter); - g_object_set_data(G_OBJECT(table), "without", without); - g_object_set_data(G_OBJECT(table), "model", model); - - return table; -} - -static void -source_selected (ESourceOptionMenu *menu, ESource *source, ESelectNames *e_select_names) -{ - addressbook_model_set_source (e_select_names, e_select_names->model, source); - e_select_names_config_set_last_completion_book (e_source_peek_uid (source)); -} - -static char * -get_query_string (ESelectNames *e_select_names) -{ - char *category = ""; - const char *search = ""; - EBookQuery *query; - EBookQuery *q_array[4]; - char *query_str; - int i; - - if (e_select_names->categories) { - category = e_categories_master_list_option_menu_get_category (E_CATEGORIES_MASTER_LIST_OPTION_MENU (e_select_names->categories)); - } - if (e_select_names->select_entry) { - search = gtk_entry_get_text (GTK_ENTRY (e_select_names->select_entry)); - } - - i = 0; - q_array[i++] = e_book_query_field_test (E_CONTACT_EMAIL, E_BOOK_QUERY_CONTAINS, ""); - if (category && *category) - q_array[i++] = e_book_query_field_test (E_CONTACT_CATEGORY_LIST, E_BOOK_QUERY_IS, category); - if (search && *search) - q_array[i++] = e_book_query_orv (e_book_query_field_test (E_CONTACT_EMAIL, E_BOOK_QUERY_BEGINS_WITH, search), - e_book_query_field_test (E_CONTACT_FULL_NAME, E_BOOK_QUERY_BEGINS_WITH, search), - e_book_query_field_test (E_CONTACT_NICKNAME, E_BOOK_QUERY_BEGINS_WITH, search), - e_book_query_field_test (E_CONTACT_FILE_AS, E_BOOK_QUERY_BEGINS_WITH, search), - NULL); - if (i > 1) { - query = e_book_query_and (i, q_array, TRUE); - } - else { - query = q_array[0]; - } - query_str = e_book_query_to_string (query); - e_book_query_unref (query); - return query_str; -} - - -static void -update_query (GtkWidget *widget, ESelectNames *e_select_names) -{ - char *query_str = get_query_string (e_select_names); - printf ("query_str = %s\n", query_str); - g_object_set (e_select_names->model, - "query", query_str, - NULL); - g_free (query_str); -} - -static void -status_message (EABModel *model, const gchar *message, ESelectNames *e_select_names) -{ - if (message == NULL) - gtk_label_set_text (GTK_LABEL (e_select_names->status_message), ""); - else - gtk_label_set_text (GTK_LABEL (e_select_names->status_message), message); -} - -static void -categories_changed (GtkWidget *widget, ESelectNames *e_select_names) -{ - update_query (widget, e_select_names); -} - -static void -select_entry_changed (GtkWidget *widget, ESelectNames *e_select_names) -{ - if (e_select_names->select_entry) { - const char *select_string = gtk_entry_get_text (GTK_ENTRY (e_select_names->select_entry)); - char *select_strcoll_string = g_utf8_collate_key (select_string, -1); - int count; - ETable *table; - int i; - - table = e_table_scrolled_get_table (e_select_names->table); - - count = e_table_model_row_count (e_select_names->without); - - for (i = 0; i < count; i++) { - int model_row = e_table_view_to_model_row (table, i); - char *row_strcoll_string = - g_utf8_collate_key (e_table_model_value_at (e_select_names->without, - E_CONTACT_FULL_NAME, - model_row), - -1); - if (strcmp (select_strcoll_string, row_strcoll_string) <= 0) { - g_free (row_strcoll_string); - break; - } - g_free (row_strcoll_string); - } - g_free (select_strcoll_string); - if (i == count) - i --; - - if (count > 0) { - i = e_table_view_to_model_row (table, i); - e_table_set_cursor_row (table, i); - } - } -} - -GtkWidget *e_select_names_create_categories (gchar *name, - gchar *string1, gchar *string2, - gint int1, gint int2); - -GtkWidget * -e_select_names_create_categories (gchar *name, - gchar *string1, gchar *string2, - gint int1, gint int2) -{ - ECategoriesMasterList *ecml; - GtkWidget *option_menu; - - ecml = e_categories_master_list_wombat_new (); - option_menu = e_categories_master_list_option_menu_new (ecml); - g_object_unref (ecml); - - return option_menu; -} - -static void -clear_widget (gpointer data, GObject *where_object_was) -{ - GtkWidget **widget_ref = data; - *widget_ref = NULL; -} - -static void -e_select_names_init (ESelectNames *e_select_names) -{ - GladeXML *gui; - GtkWidget *widget, *button, *table, *esom; - ESource *source = NULL; - char *uid; - - gui = glade_xml_new (EVOLUTION_GLADEDIR "/select-names.glade", NULL, NULL); - widget = glade_xml_get_widget (gui, "select-names-box"); - if (!widget) { - g_object_unref (gui); - return; - } - gtk_widget_ref (widget); - gtk_container_remove (GTK_CONTAINER (widget->parent), widget); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (e_select_names)->vbox), widget, TRUE, TRUE, 0); - gtk_widget_unref (widget); - - gtk_dialog_add_buttons (GTK_DIALOG (e_select_names), - GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, - GTK_STOCK_OK, GTK_RESPONSE_OK, - NULL); - - gtk_window_set_modal (GTK_WINDOW (e_select_names), FALSE); - gtk_window_set_default_size (GTK_WINDOW (e_select_names), 472, 512); - gtk_window_set_title (GTK_WINDOW (e_select_names), _("Select Contacts from Address Book")); - gtk_window_set_resizable (GTK_WINDOW (e_select_names), TRUE); - gtk_dialog_set_has_separator (GTK_DIALOG (e_select_names), FALSE); - gtk_container_set_border_width (GTK_CONTAINER (e_select_names), 4); - - /* FIXME What to do on error/NULL ? */ - e_select_names->source_list = e_source_list_new_for_gconf_default ("/apps/evolution/addressbook/sources"); - - e_select_names->gui = gui; - - /* Add the source menu */ - esom = e_source_option_menu_new (e_select_names->source_list); - g_signal_connect (esom, "source_selected", G_CALLBACK (source_selected), e_select_names); - gtk_widget_show (esom); - - table = glade_xml_get_widget (gui, "show_contacts_table"); - gtk_table_attach (GTK_TABLE (table), esom, 1, 2, 0, 1, GTK_FILL, GTK_FILL, 0, 0); - - /* Set up the rest of the widgets */ - e_select_names->children = g_hash_table_new(g_str_hash, g_str_equal); - e_select_names->child_count = 0; - e_select_names->def = NULL; - - gtk_dialog_set_default_response (GTK_DIALOG (e_select_names), - GTK_RESPONSE_OK); - - e_select_names->table = E_TABLE_SCROLLED(glade_xml_get_widget(gui, "table-source")); - e_select_names->model = g_object_get_data(G_OBJECT(e_select_names->table), "model"); - e_select_names->adapter = g_object_get_data(G_OBJECT(e_select_names->table), "adapter"); - e_select_names->without = g_object_get_data(G_OBJECT(e_select_names->table), "without"); - gtk_widget_show (GTK_WIDGET (e_select_names->table)); - - e_select_names->status_message = glade_xml_get_widget (gui, "status-message"); - if (e_select_names->status_message && !GTK_IS_LABEL (e_select_names->status_message)) - e_select_names->status_message = NULL; - if (e_select_names->status_message) { - e_select_names->status_id = g_signal_connect (e_select_names->model, "status_message", - G_CALLBACK (status_message), e_select_names); - g_object_weak_ref (G_OBJECT (e_select_names->status_message), clear_widget, &e_select_names->status_message); - } - - e_select_names->search_id = g_signal_connect (e_select_names->model, - "search_result", G_CALLBACK (search_result), - e_select_names); - - e_select_names->categories = glade_xml_get_widget (gui, "custom-categories"); - if (e_select_names->categories && !E_IS_CATEGORIES_MASTER_LIST_OPTION_MENU (e_select_names->categories)) - e_select_names->categories = NULL; - if (e_select_names->categories) { - g_signal_connect(e_select_names->categories, "changed", - G_CALLBACK(categories_changed), e_select_names); - g_object_weak_ref (G_OBJECT (e_select_names->categories), clear_widget, &e_select_names->categories); - } - gtk_widget_show (e_select_names->categories); - - e_select_names->select_entry = glade_xml_get_widget (gui, "entry-select"); - if (e_select_names->select_entry && !GTK_IS_ENTRY (e_select_names->select_entry)) - e_select_names->select_entry = NULL; - if (e_select_names->select_entry) { - g_signal_connect(e_select_names->select_entry, "changed", - G_CALLBACK(select_entry_changed), e_select_names); - g_signal_connect(e_select_names->select_entry, "activate", - G_CALLBACK(update_query), e_select_names); - g_object_weak_ref (G_OBJECT (e_select_names->select_entry), clear_widget, &e_select_names->select_entry); - } - - button = glade_xml_get_widget (gui, "button-find"); - if (button && GTK_IS_BUTTON (button)) - g_signal_connect(button, "clicked", - G_CALLBACK(update_query), e_select_names); - - g_signal_connect (e_table_scrolled_get_table (e_select_names->table), "double_click", - G_CALLBACK (add_address), e_select_names); - g_signal_connect (e_table_scrolled_get_table (e_select_names->table), "selection_change", - G_CALLBACK (selection_change), e_select_names); - selection_change (e_table_scrolled_get_table (e_select_names->table), e_select_names); - - /* Select a source for to display initially */ - uid = e_select_names_config_get_last_completion_book (); - if (uid) { - source = e_source_list_peek_source_by_uid (e_select_names->source_list, uid); - g_free (uid); - } - - if (!source) - source = find_first_source (e_select_names->source_list); - - /* FIXME What if we still can't find a source? */ - e_source_option_menu_select (E_SOURCE_OPTION_MENU (esom), source); - -} - -static void e_select_names_child_free(char *key, ESelectNamesChild *child, ESelectNames *e_select_names) -{ - g_signal_handler_disconnect(child->source, child->changed_id); - - g_free(child->title); - g_object_unref(child->table_model); - g_object_unref(child->source); - g_free(key); - g_free(child); -} - -static void -e_select_names_dispose (GObject *object) -{ - ESelectNames *e_select_names = E_SELECT_NAMES(object); - - if (e_select_names->source_list) { - g_object_unref (e_select_names->source_list); - e_select_names->source_list = NULL; - } - - if (e_select_names->status_id) { - g_signal_handler_disconnect(e_select_names->model, e_select_names->status_id); - e_select_names->status_id = 0; - } - - if (e_select_names->search_id) { - g_signal_handler_disconnect(e_select_names->model, e_select_names->search_id); - e_select_names->search_id = 0; - } - - if (e_select_names->gui) { - g_object_unref(e_select_names->gui); - e_select_names->gui = NULL; - } - - if (e_select_names->children) { - g_hash_table_foreach(e_select_names->children, (GHFunc) e_select_names_child_free, e_select_names); - g_hash_table_destroy(e_select_names->children); - e_select_names->children = NULL; - } - - if (e_select_names->without) { - g_object_unref(e_select_names->without); - e_select_names->without = NULL; - } - if (e_select_names->adapter) { - g_object_unref(e_select_names->adapter); - e_select_names->adapter = NULL; - } - if (e_select_names->model) { - g_object_unref(e_select_names->model); - e_select_names->model = NULL; - } - - if (e_select_names->def) { - g_free(e_select_names->def); - e_select_names->def = NULL; - } - - if (G_OBJECT_CLASS(parent_class)->dispose) - G_OBJECT_CLASS(parent_class)->dispose(object); -} - -GtkWidget* -e_select_names_new (void) -{ - ESelectNames *e_select_names; - - e_select_names = g_object_new (E_TYPE_SELECT_NAMES, NULL); - - return GTK_WIDGET (e_select_names); -} - -static void -button_clicked(GtkWidget *button, ESelectNamesChild *child) -{ - real_add_address(child->names, child); -} - -static void -remove_address(ETable *table, int row, int col, GdkEvent *event, ESelectNamesChild *child) -{ - e_select_names_model_delete (child->source, row); -} - -static void -remove_cb (EPopup *ep, EPopupItem *pitem, void *data) -{ - EABPopupTargetSelectNames *t = (EABPopupTargetSelectNames *)ep->target; - - e_select_names_model_delete (t->model, t->row); -} - -static EPopupItem esn_select_popups[] = { - { E_POPUP_ITEM, "20.delete", N_("Remove"), remove_cb, NULL, NULL, 0, 0 }, -}; - -static void -esn_select_popup_free (EPopup *ep, GSList *list, void *data) -{ - g_slist_free (list); -} - -static void -section_right_click_cb (ETable *et, int row, int col, GdkEvent *ev, ESelectNamesChild *child) -{ - EABPopup *ep; - EABPopupTargetSelectNames *t; - GSList *menus = NULL; - int i; - GtkMenu *menu; - - ep = eab_popup_new("org.gnome.evolution.addressbook.selectNames.popup"); - t = eab_popup_target_new_select_names(ep, child->source, row); - t->target.widget = (GtkWidget *)et; - - for (i=0;i<sizeof(esn_select_popups)/sizeof(esn_select_popups[0]);i++) - menus = g_slist_prepend(menus, &esn_select_popups[i]); - - e_popup_add_items((EPopup *)ep, menus, esn_select_popup_free, NULL); - - menu = e_popup_create_menu_once((EPopup *)ep, (EPopupTarget *)t, 0); - gtk_menu_popup(menu, NULL, NULL, NULL, NULL, ev->button.button, ev->button.time); -} - -void -e_select_names_add_section (ESelectNames *e_select_names, - const char *name, const char *id, - ESelectNamesModel *source) -{ - ESelectNamesChild *child; - GtkWidget *button; - GtkWidget *label; - GtkWidget *alignment; - GtkTable *table; - char *label_text; - ETable *etable; - ETableExtras *extras; - ECell *string_cell; - - GtkWidget *sw; - - if (g_hash_table_lookup(e_select_names->children, id)) { - return; - } - - table = GTK_TABLE(glade_xml_get_widget (e_select_names->gui, "table-recipients")); - - child = g_new(ESelectNamesChild, 1); - - child->names = e_select_names; - child->title = g_strdup (_(name)); - - child->table_model = (ESelectNamesTableModel*)e_select_names_table_model_new (source); - - child->source = source; - g_object_ref(child->source); - - alignment = gtk_alignment_new(0, 0, 1, 0); - - label_text = g_strconcat (child->title, " ->", NULL); - - label = gtk_label_new (""); - - gtk_label_set_markup (GTK_LABEL(label), label_text); - - g_free (label_text); - - button = gtk_button_new (); - gtk_container_add (GTK_CONTAINER (button), label); - child->label = label; - child->button = button; - - gtk_container_add(GTK_CONTAINER(alignment), button); - gtk_widget_show_all(alignment); - g_signal_connect(button, "clicked", - G_CALLBACK(button_clicked), child); - gtk_table_attach(table, alignment, - 0, 1, - e_select_names->child_count, - e_select_names->child_count + 1, - GTK_FILL, GTK_FILL, - 0, 0); - - etable = e_table_scrolled_get_table (e_select_names->table); - gtk_widget_set_sensitive (button, e_table_selected_count (etable) > 0); - - extras = e_table_extras_new (); - string_cell = e_table_extras_get_cell (extras, "string"); - - g_object_set (string_cell, - "underline_column", 2, - NULL); - - sw = e_table_scrolled_new_from_spec_file (E_TABLE_MODEL (child->table_model), - extras, - EVOLUTION_ETSPECDIR "/e-select-names-section.etspec", - NULL); - g_object_unref (extras); - - child->recipient_table = GTK_WIDGET (e_table_scrolled_get_table (E_TABLE_SCROLLED (sw))); - - g_signal_connect (child->recipient_table, - "right_click", - G_CALLBACK (section_right_click_cb), - child); - - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), - GTK_POLICY_AUTOMATIC, - GTK_POLICY_AUTOMATIC); - - g_signal_connect(child->recipient_table, "double_click", - G_CALLBACK(remove_address), child); - - child->changed_id = g_signal_connect (child->source, - "changed", - G_CALLBACK (sync_table_and_models), - e_select_names); - - gtk_widget_show_all (sw); - - gtk_table_attach(table, sw, - 1, 2, - e_select_names->child_count, - e_select_names->child_count + 1, - GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_EXPAND, - 0, 0); - - g_hash_table_insert(e_select_names->children, g_strdup(id), child); - - sync_table_and_models (child->source, e_select_names); - - e_select_names->child_count++; -} - -void -e_select_names_set_default (ESelectNames *e_select_names, - const char *id) -{ - ESelectNamesChild *child; - - if (e_select_names->def) { - child = g_hash_table_lookup(e_select_names->children, e_select_names->def); - if (child) { - GtkWidget *label = child->label; - - /* set the previous default to non-bold */ - gtk_label_set_markup (GTK_LABEL (label), child->title); - } - } - - g_free(e_select_names->def); - e_select_names->def = g_strdup(id); - - if (e_select_names->def) { - child = g_hash_table_lookup(e_select_names->children, e_select_names->def); - if (child) { - GtkWidget *label = child->label; - char *markup = g_strconcat ("<b>", child->title, "</b>", NULL); - - /* set the new default to bold */ - gtk_label_set_markup (GTK_LABEL (label), markup); - g_free (markup); - } - } -} diff --git a/addressbook/gui/component/select-names/e-select-names.etspec b/addressbook/gui/component/select-names/e-select-names.etspec deleted file mode 100644 index 45899e1f23..0000000000 --- a/addressbook/gui/component/select-names/e-select-names.etspec +++ /dev/null @@ -1,7 +0,0 @@ -<ETableSpecification no-headers="true" cursor-mode="line"> - <ETableColumn model_col= "86" _title="Name" expansion="1.0" minimum_width="20" resizable="true" cell="string" compare="collate" search="string"/> - <ETableState> - <column source="0"/> - <grouping> <leaf column="0" ascending="true"/> </grouping> - </ETableState> -</ETableSpecification> diff --git a/addressbook/gui/component/select-names/e-select-names.h b/addressbook/gui/component/select-names/e-select-names.h deleted file mode 100644 index 664735f74a..0000000000 --- a/addressbook/gui/component/select-names/e-select-names.h +++ /dev/null @@ -1,101 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* e-select-names.h - * Copyright (C) 2000 Ximian, Inc. - * Author: Chris Lahey <clahey@ximian.com> - * - * This library 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 library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ -#ifndef __E_SELECT_NAMES_H__ -#define __E_SELECT_NAMES_H__ - -#include <glib.h> -#include <gtk/gtkwidget.h> -#include <gtk/gtkdialog.h> -#include <glade/glade.h> -#include <gal/e-table/e-table.h> -#include <gal/e-table/e-table-scrolled.h> -#include <libedataserver/e-source-list.h> -#include <libedataserverui/e-source-option-menu.h> - -#include "e-addressbook-model.h" - -#include "e-select-names-model.h" - -G_BEGIN_DECLS - -/* ESelectNames - A dialog displaying information about a contact. - * - * The following arguments are available: - * - * name type read/write description - * -------------------------------------------------------------------------------- - */ - -#define E_TYPE_SELECT_NAMES (e_select_names_get_type ()) -#define E_SELECT_NAMES(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_SELECT_NAMES, ESelectNames)) -#define E_SELECT_NAMES_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_SELECT_NAMES, ESelectNamesClass)) -#define E_IS_SELECT_NAMES(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_SELECT_NAMES)) -#define E_IS_SELECT_NAMES_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), E_TYPE_SELECT_NAMES)) - -typedef struct _ESelectNames ESelectNames; -typedef struct _ESelectNamesClass ESelectNamesClass; -typedef struct _ESelectNamesFolder ESelectNamesFolder; - -struct _ESelectNames -{ - GtkDialog parent; - - ESourceList *source_list; - - /* item specific fields */ - GladeXML *gui; - - GHashTable *children; /* Of type char * to ESelectNamesChild */ - int child_count; - ETableScrolled *table; - ETableModel *adapter; - ETableModel *without; - EABModel *model; - GtkWidget *categories; - GtkWidget *select_entry; - GtkWidget *status_message; - char *def; - ESelectNamesFolder *current_folder; - - /* signal handlers */ - gulong status_id; - gulong search_id; -}; - -struct _ESelectNamesClass -{ - GtkDialogClass parent_class; -}; - - -GType e_select_names_get_type (void); - -GtkWidget *e_select_names_new (void); - -void e_select_names_add_section (ESelectNames *e_select_names, - const char *name, - const char *id, - ESelectNamesModel *source); -void e_select_names_set_default (ESelectNames *e_select_names, - const char *id); - -G_END_DECLS - -#endif /* __E_SELECT_NAMES_H__ */ diff --git a/addressbook/gui/component/select-names/recipient.glade b/addressbook/gui/component/select-names/recipient.glade deleted file mode 100644 index edcf6bbab0..0000000000 --- a/addressbook/gui/component/select-names/recipient.glade +++ /dev/null @@ -1,45 +0,0 @@ -<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*--> -<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd" > - -<glade-interface> - <widget class="GtkWindow" id="window1"> - <property name="visible">no</property> - <property name="title" translatable="yes">window1</property> - <property name="type">GTK_WINDOW_TOPLEVEL</property> - <property name="modal">no</property> - <property name="allow_shrink">no</property> - <property name="allow_grow">yes</property> - <property name="window-position">GTK_WIN_POS_NONE</property> - - <child> - <widget class="GtkHBox" id="hbox-top"> - <property name="homogeneous">no</property> - <property name="spacing">4</property> - <property name="visible">yes</property> - - <child> - <widget class="GtkAlignment" id="alignment1"> - <property name="xalign">1.08033e-07</property> - <property name="yalign">0</property> - <property name="xscale">1</property> - <property name="yscale">0</property> - <property name="visible">yes</property> - - <child> - <widget class="GtkButton" id="text-button"> - <property name="can_focus">yes</property> - <property name="label" translatable="yes">-></property> - <property name="visible">yes</property> - </widget> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">no</property> - <property name="fill">yes</property> - </packing> - </child> - </widget> - </child> - </widget> -</glade-interface> diff --git a/addressbook/gui/component/select-names/select-names.glade b/addressbook/gui/component/select-names/select-names.glade deleted file mode 100644 index 205400de08..0000000000 --- a/addressbook/gui/component/select-names/select-names.glade +++ /dev/null @@ -1,443 +0,0 @@ -<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*--> -<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd"> - -<glade-interface> -<requires lib="gnome"/> - -<widget class="GtkDialog" id="dialog-top"> - <property name="border_width">3</property> - <property name="title" translatable="yes">Select Contacts from Address Book</property> - <property name="type">GTK_WINDOW_TOPLEVEL</property> - <property name="window_position">GTK_WIN_POS_NONE</property> - <property name="modal">True</property> - <property name="default_width">417</property> - <property name="default_height">332</property> - <property name="resizable">True</property> - <property name="destroy_with_parent">False</property> - <property name="decorated">True</property> - <property name="skip_taskbar_hint">False</property> - <property name="skip_pager_hint">False</property> - <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property> - <property name="gravity">GDK_GRAVITY_NORTH_WEST</property> - <property name="has_separator">False</property> - - <child internal-child="vbox"> - <widget class="GtkVBox" id="dialog-vbox1"> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">6</property> - - <child internal-child="action_area"> - <widget class="GtkHButtonBox" id="dialog-action_area1"> - <property name="visible">True</property> - <property name="layout_style">GTK_BUTTONBOX_END</property> - - <child> - <widget class="GtkButton" id="button4"> - <property name="visible">True</property> - <property name="can_default">True</property> - <property name="has_default">True</property> - <property name="can_focus">True</property> - <property name="label">gtk-cancel</property> - <property name="use_stock">True</property> - <property name="relief">GTK_RELIEF_NORMAL</property> - <property name="focus_on_click">True</property> - <property name="response_id">-6</property> - </widget> - </child> - - <child> - <widget class="GtkButton" id="button5"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="label">gtk-ok</property> - <property name="use_stock">True</property> - <property name="relief">GTK_RELIEF_NORMAL</property> - <property name="focus_on_click">True</property> - <property name="response_id">-5</property> - </widget> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="pack_type">GTK_PACK_END</property> - </packing> - </child> - - <child> - <widget class="GtkVBox" id="select-names-box"> - <property name="border_width">4</property> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">6</property> - - <child> - <widget class="GtkLabel" id="label33"> - <property name="visible">True</property> - <property name="label" translatable="yes"><b>Show Contacts</b></property> - <property name="use_underline">False</property> - <property name="use_markup">True</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - - <child> - <widget class="GtkHBox" id="hbox2"> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">12</property> - - <child> - <widget class="GtkLabel" id="label35"> - <property name="visible">True</property> - <property name="label" translatable="yes"></property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - - <child> - <widget class="GtkTable" id="show_contacts_table"> - <property name="visible">True</property> - <property name="n_rows">3</property> - <property name="n_columns">2</property> - <property name="homogeneous">False</property> - <property name="row_spacing">6</property> - <property name="column_spacing">12</property> - - <child> - <widget class="GtkLabel" id="label30"> - <property name="visible">True</property> - <property name="label" translatable="yes">Address _Book:</property> - <property name="use_underline">True</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_CENTER</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="left_attach">0</property> - <property name="right_attach">1</property> - <property name="top_attach">0</property> - <property name="bottom_attach">1</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label31"> - <property name="visible">True</property> - <property name="label" translatable="yes">C_ategory:</property> - <property name="use_underline">True</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_CENTER</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="left_attach">0</property> - <property name="right_attach">1</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="Custom" id="custom-categories"> - <property name="visible">True</property> - <property name="creation_function">e_select_names_create_categories</property> - <property name="int1">0</property> - <property name="int2">0</property> - <property name="last_modification_time">Tue, 19 Feb 2002 23:06:24 GMT</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="x_options">expand|shrink|fill</property> - <property name="y_options">shrink|fill</property> - </packing> - </child> - - <child> - <widget class="GtkHBox" id="hbox1"> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">12</property> - - <child> - <widget class="GtkEntry" id="entry-select"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="editable">True</property> - <property name="visibility">True</property> - <property name="max_length">0</property> - <property name="text" translatable="yes"></property> - <property name="has_frame">True</property> - <property name="invisible_char" translatable="yes">*</property> - <property name="activates_default">False</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">True</property> - <property name="fill">True</property> - </packing> - </child> - - <child> - <widget class="GtkButton" id="button-find"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="label" translatable="yes">_Find</property> - <property name="use_underline">True</property> - <property name="relief">GTK_RELIEF_NORMAL</property> - <property name="focus_on_click">True</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">2</property> - <property name="bottom_attach">3</property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label39"> - <property name="visible">True</property> - <property name="label" translatable="yes">_Search:</property> - <property name="use_underline">True</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="mnemonic_widget">entry-select</property> - </widget> - <packing> - <property name="left_attach">0</property> - <property name="right_attach">1</property> - <property name="top_attach">2</property> - <property name="bottom_attach">3</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">True</property> - <property name="fill">True</property> - </packing> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label37"> - <property name="visible">True</property> - <property name="label" translatable="yes"></property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label36"> - <property name="visible">True</property> - <property name="label" translatable="yes"><b>Contacts</b></property> - <property name="use_underline">False</property> - <property name="use_markup">True</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - - <child> - <widget class="GtkHBox" id="hbox3"> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">12</property> - - <child> - <widget class="GtkLabel" id="label38"> - <property name="visible">True</property> - <property name="label" translatable="yes"></property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - - <child> - <widget class="GtkVBox" id="vbox8"> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">6</property> - - <child> - <widget class="Custom" id="table-source"> - <property name="visible">True</property> - <property name="creation_function">e_addressbook_create_ebook_table</property> - <property name="int1">0</property> - <property name="int2">0</property> - <property name="last_modification_time">Sat, 10 Jun 2000 22:02:57 GMT</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">True</property> - <property name="fill">True</property> - </packing> - </child> - - <child> - <placeholder/> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">True</property> - <property name="fill">True</property> - </packing> - </child> - - <child> - <widget class="GtkTable" id="table-recipients"> - <property name="visible">True</property> - <property name="n_rows">3</property> - <property name="n_columns">2</property> - <property name="homogeneous">False</property> - <property name="row_spacing">18</property> - <property name="column_spacing">12</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">True</property> - <property name="fill">True</property> - </packing> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">True</property> - <property name="fill">True</property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="status-message"> - <property name="visible">True</property> - <property name="label" translatable="yes"></property> - <property name="use_underline">False</property> - <property name="use_markup">True</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">3</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="pack_type">GTK_PACK_END</property> - </packing> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">True</property> - <property name="fill">True</property> - </packing> - </child> - </widget> - </child> -</widget> - -</glade-interface> diff --git a/addressbook/gui/contact-editor/.cvsignore b/addressbook/gui/contact-editor/.cvsignore deleted file mode 100644 index ddbd38bb6e..0000000000 --- a/addressbook/gui/contact-editor/.cvsignore +++ /dev/null @@ -1,11 +0,0 @@ -.deps -.libs -.pure -Makefile -Makefile.in -*.lo -*.la -contact-editor-test -contact-editor.gladep -e-contact-editor-marshal.c -e-contact-editor-marshal.h diff --git a/addressbook/gui/contact-editor/Makefile.am b/addressbook/gui/contact-editor/Makefile.am deleted file mode 100644 index 376aa65205..0000000000 --- a/addressbook/gui/contact-editor/Makefile.am +++ /dev/null @@ -1,50 +0,0 @@ -INCLUDES = \ - -I$(top_srcdir) \ - -I$(top_srcdir)/addressbook/ \ - -I$(top_srcdir)/addressbook/backend \ - -I$(top_builddir)/addressbook/backend \ - -I$(top_srcdir)/addressbook/gui/merging \ - -I$(top_srcdir)/widgets/e-table \ - -I$(top_builddir)/shell \ - -I$(top_srcdir)/camel \ - -I$(top_builddir)/camel \ - -DEVOLUTION_GLADEDIR=\""$(gladedir)"\" \ - -DEVOLUTION_DATADIR=\""$(datadir)"\" \ - -DEVOLUTION_IMAGESDIR=\""$(imagesdir)"\" \ - -DEVOLUTION_UIDIR=\""$(evolutionuidir)\"" \ - -DPREFIX=\""$(prefix)"\" \ - -DG_LOG_DOMAIN=\"contact-editor\" \ - $(EVOLUTION_ADDRESSBOOK_CFLAGS) - -noinst_LTLIBRARIES = \ - libecontacteditor.la - -libecontacteditor_la_SOURCES = \ - $(MARSHAL_GENERATED) \ - eab-editor.c \ - eab-editor.h \ - e-contact-editor-im.c \ - e-contact-editor-im.h \ - e-contact-editor-address.c \ - e-contact-editor-address.h \ - e-contact-editor-fullname.c \ - e-contact-editor-fullname.h \ - e-contact-editor.c \ - e-contact-editor.h \ - e-contact-quick-add.c \ - e-contact-quick-add.h - -MARSHAL_GENERATED = e-contact-editor-marshal.c e-contact-editor-marshal.h -@EVO_MARSHAL_RULE@ - -glade_DATA = \ - im.glade \ - contact-editor.glade \ - fulladdr.glade \ - fullname.glade - -BUILT_SOURCES = $(MARSHAL_GENERATED) -CLEANFILES = $(BUILT_SOURCES) - -EXTRA_DIST= $(glade_DATA) \ - e-contact-editor-marshal.list diff --git a/addressbook/gui/contact-editor/contact-editor.glade b/addressbook/gui/contact-editor/contact-editor.glade deleted file mode 100644 index 2f1cd4e10f..0000000000 --- a/addressbook/gui/contact-editor/contact-editor.glade +++ /dev/null @@ -1,3563 +0,0 @@ -<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*--> -<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd"> - -<glade-interface> - -<widget class="GtkDialog" id="contact editor"> - <property name="title" translatable="yes">Contact Editor</property> - <property name="type">GTK_WINDOW_TOPLEVEL</property> - <property name="window_position">GTK_WIN_POS_NONE</property> - <property name="modal">False</property> - <property name="resizable">True</property> - <property name="destroy_with_parent">False</property> - <property name="has_separator">False</property> - - <child internal-child="vbox"> - <widget class="GtkVBox" id="dialog-vbox1"> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">0</property> - - <child internal-child="action_area"> - <widget class="GtkHButtonBox" id="dialog-action_area1"> - <property name="visible">True</property> - <property name="layout_style">GTK_BUTTONBOX_END</property> - - <child> - <widget class="GtkButton" id="button-help"> - <property name="visible">True</property> - <property name="can_default">True</property> - <property name="can_focus">True</property> - <property name="label">gtk-help</property> - <property name="use_stock">True</property> - <property name="relief">GTK_RELIEF_NORMAL</property> - <property name="response_id">-11</property> - </widget> - </child> - - <child> - <widget class="GtkButton" id="button-cancel"> - <property name="visible">True</property> - <property name="can_default">True</property> - <property name="can_focus">True</property> - <property name="label">gtk-cancel</property> - <property name="use_stock">True</property> - <property name="relief">GTK_RELIEF_NORMAL</property> - <property name="response_id">-6</property> - </widget> - </child> - - <child> - <widget class="GtkButton" id="button-ok"> - <property name="visible">True</property> - <property name="can_default">True</property> - <property name="has_default">True</property> - <property name="can_focus">True</property> - <property name="label">gtk-ok</property> - <property name="use_stock">True</property> - <property name="relief">GTK_RELIEF_NORMAL</property> - <property name="response_id">-5</property> - </widget> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="pack_type">GTK_PACK_END</property> - </packing> - </child> - - <child> - <widget class="GtkNotebook" id="notebook11"> - <property name="border_width">12</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="show_tabs">True</property> - <property name="show_border">True</property> - <property name="tab_pos">GTK_POS_TOP</property> - <property name="scrollable">False</property> - <property name="enable_popup">False</property> - - <child> - <widget class="GtkVBox" id="vbox33"> - <property name="border_width">12</property> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">1</property> - - <child> - <widget class="GtkHBox" id="hbox55"> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">6</property> - - <child> - <widget class="GtkButton" id="button-image"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="relief">GTK_RELIEF_NORMAL</property> - - <child> - <widget class="Custom" id="image-chooser"> - <property name="visible">True</property> - <property name="creation_function">eab_create_image_chooser_widget</property> - <property name="string1">stock_person</property> - <property name="int1">0</property> - <property name="int2">0</property> - <property name="last_modification_time">Tue, 13 Apr 2004 20:51:33 GMT</property> - </widget> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">True</property> - </packing> - </child> - - <child> - <widget class="GtkTable" id="table83"> - <property name="visible">True</property> - <property name="n_rows">3</property> - <property name="n_columns">4</property> - <property name="homogeneous">False</property> - <property name="row_spacing">6</property> - <property name="column_spacing">6</property> - - <child> - <widget class="GtkLabel" id="label-nickname"> - <property name="visible">True</property> - <property name="label" translatable="yes">Ni_ckname:</property> - <property name="use_underline">True</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">1</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="mnemonic_widget">entry-nickname</property> - </widget> - <packing> - <property name="left_attach">2</property> - <property name="right_attach">3</property> - <property name="top_attach">0</property> - <property name="bottom_attach">1</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkEntry" id="entry-fullname"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="editable">True</property> - <property name="visibility">True</property> - <property name="max_length">0</property> - <property name="text" translatable="yes"></property> - <property name="has_frame">True</property> - <property name="invisible_char" translatable="yes">*</property> - <property name="activates_default">False</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">0</property> - <property name="bottom_attach">1</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="accellabel-fileas"> - <property name="visible">True</property> - <property name="label" translatable="yes">_File under:</property> - <property name="use_underline">True</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">1</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="mnemonic_widget">entry-file-as</property> - </widget> - <packing> - <property name="left_attach">0</property> - <property name="right_attach">1</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="where-label"> - <property name="visible">True</property> - <property name="label" translatable="yes">_Where:</property> - <property name="use_underline">True</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">1</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="left_attach">2</property> - <property name="right_attach">3</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkButton" id="button-categories"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="label" translatable="yes">_Categories</property> - <property name="use_underline">True</property> - <property name="relief">GTK_RELIEF_NORMAL</property> - </widget> - <packing> - <property name="left_attach">0</property> - <property name="right_attach">1</property> - <property name="top_attach">2</property> - <property name="bottom_attach">3</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkEntry" id="entry-categories"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="editable">True</property> - <property name="visibility">True</property> - <property name="max_length">0</property> - <property name="text" translatable="yes"></property> - <property name="has_frame">True</property> - <property name="invisible_char" translatable="yes">*</property> - <property name="activates_default">False</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">4</property> - <property name="top_attach">2</property> - <property name="bottom_attach">3</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkEntry" id="entry-nickname"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="editable">True</property> - <property name="visibility">True</property> - <property name="max_length">0</property> - <property name="text" translatable="yes"></property> - <property name="has_frame">True</property> - <property name="invisible_char" translatable="yes">*</property> - <property name="activates_default">False</property> - </widget> - <packing> - <property name="left_attach">3</property> - <property name="right_attach">4</property> - <property name="top_attach">0</property> - <property name="bottom_attach">1</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkCombo" id="combo-file-as"> - <property name="visible">True</property> - <property name="value_in_list">False</property> - <property name="allow_empty">True</property> - <property name="case_sensitive">False</property> - <property name="enable_arrow_keys">True</property> - <property name="enable_arrows_always">False</property> - - <child internal-child="entry"> - <widget class="GtkEntry" id="entry-file-as"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="editable">True</property> - <property name="visibility">True</property> - <property name="max_length">0</property> - <property name="text" translatable="yes"></property> - <property name="has_frame">True</property> - <property name="invisible_char" translatable="yes">*</property> - <property name="activates_default">False</property> - </widget> - </child> - - <child internal-child="list"> - <widget class="GtkList" id="list14"> - <property name="visible">True</property> - <property name="selection_mode">GTK_SELECTION_BROWSE</property> - </widget> - </child> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="Custom" id="source-option-menu-source"> - <property name="visible">True</property> - <property name="creation_function">e_contact_editor_create_source_option_menu</property> - <property name="int1">0</property> - <property name="int2">0</property> - <property name="last_modification_time">Tue, 13 Apr 2004 20:47:50 GMT</property> - </widget> - <packing> - <property name="left_attach">3</property> - <property name="right_attach">4</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="x_options">fill</property> - <property name="y_options">fill</property> - </packing> - </child> - - <child> - <widget class="GtkButton" id="button-fullname"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="label" translatable="yes">Full _Name...</property> - <property name="use_underline">True</property> - <property name="relief">GTK_RELIEF_NORMAL</property> - </widget> - <packing> - <property name="left_attach">0</property> - <property name="right_attach">1</property> - <property name="top_attach">0</property> - <property name="bottom_attach">1</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">True</property> - <property name="fill">True</property> - </packing> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - - <child> - <widget class="GtkHSeparator" id="hseparator10"> - <property name="visible">True</property> - </widget> - <packing> - <property name="padding">6</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - - <child> - <widget class="GtkVBox" id="vbox34"> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">10</property> - - <child> - <widget class="GtkFrame" id="frame65"> - <property name="visible">True</property> - <property name="label_xalign">0</property> - <property name="label_yalign">0.5</property> - <property name="shadow_type">GTK_SHADOW_NONE</property> - - <child> - <widget class="GtkTable" id="table85"> - <property name="border_width">12</property> - <property name="visible">True</property> - <property name="n_rows">3</property> - <property name="n_columns">4</property> - <property name="homogeneous">False</property> - <property name="row_spacing">6</property> - <property name="column_spacing">6</property> - - <child> - <widget class="GtkOptionMenu" id="optionmenu-email-1"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="history">0</property> - - <child> - <widget class="GtkMenu" id="menu169"> - - <child> - <widget class="GtkMenuItem" id="menuitem380"> - <property name="visible">True</property> - <property name="label" translatable="yes">Work</property> - <property name="use_underline">True</property> - <signal name="activate" handler="on_work2_activate" last_modification_time="Fri, 12 Mar 2004 19:27:14 GMT"/> - </widget> - </child> - - <child> - <widget class="GtkMenuItem" id="menuitem381"> - <property name="visible">True</property> - <property name="label" translatable="yes">Personal</property> - <property name="use_underline">True</property> - <signal name="activate" handler="on_personal2_activate" last_modification_time="Fri, 12 Mar 2004 19:27:14 GMT"/> - </widget> - </child> - </widget> - </child> - </widget> - <packing> - <property name="left_attach">0</property> - <property name="right_attach">1</property> - <property name="top_attach">0</property> - <property name="bottom_attach">1</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkOptionMenu" id="optionmenu-email-2"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="history">0</property> - - <child> - <widget class="GtkMenu" id="menu170"> - - <child> - <widget class="GtkMenuItem" id="menuitem382"> - <property name="visible">True</property> - <property name="label" translatable="yes">Work</property> - <property name="use_underline">True</property> - <signal name="activate" handler="on_work2_activate" last_modification_time="Fri, 12 Mar 2004 19:27:14 GMT"/> - </widget> - </child> - - <child> - <widget class="GtkMenuItem" id="menuitem383"> - <property name="visible">True</property> - <property name="label" translatable="yes">Personal</property> - <property name="use_underline">True</property> - <signal name="activate" handler="on_personal2_activate" last_modification_time="Fri, 12 Mar 2004 19:27:14 GMT"/> - </widget> - </child> - </widget> - </child> - </widget> - <packing> - <property name="left_attach">0</property> - <property name="right_attach">1</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkEntry" id="entry-email-2"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="editable">True</property> - <property name="visibility">True</property> - <property name="max_length">0</property> - <property name="text" translatable="yes"></property> - <property name="has_frame">True</property> - <property name="invisible_char" translatable="yes">*</property> - <property name="activates_default">False</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkOptionMenu" id="optionmenu-email-3"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="history">0</property> - - <child> - <widget class="GtkMenu" id="menu171"> - - <child> - <widget class="GtkMenuItem" id="menuitem384"> - <property name="visible">True</property> - <property name="label" translatable="yes">Work</property> - <property name="use_underline">True</property> - <signal name="activate" handler="on_work2_activate" last_modification_time="Fri, 12 Mar 2004 19:27:14 GMT"/> - </widget> - </child> - - <child> - <widget class="GtkMenuItem" id="menuitem385"> - <property name="visible">True</property> - <property name="label" translatable="yes">Personal</property> - <property name="use_underline">True</property> - <signal name="activate" handler="on_personal2_activate" last_modification_time="Fri, 12 Mar 2004 19:27:14 GMT"/> - </widget> - </child> - </widget> - </child> - </widget> - <packing> - <property name="left_attach">2</property> - <property name="right_attach">3</property> - <property name="top_attach">0</property> - <property name="bottom_attach">1</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkOptionMenu" id="optionmenu-email-4"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="history">0</property> - - <child> - <widget class="GtkMenu" id="menu172"> - - <child> - <widget class="GtkMenuItem" id="menuitem386"> - <property name="visible">True</property> - <property name="label" translatable="yes">Work</property> - <property name="use_underline">True</property> - <signal name="activate" handler="on_work2_activate" last_modification_time="Fri, 12 Mar 2004 19:27:14 GMT"/> - </widget> - </child> - - <child> - <widget class="GtkMenuItem" id="menuitem387"> - <property name="visible">True</property> - <property name="label" translatable="yes">Personal</property> - <property name="use_underline">True</property> - <signal name="activate" handler="on_personal2_activate" last_modification_time="Fri, 12 Mar 2004 19:27:14 GMT"/> - </widget> - </child> - </widget> - </child> - </widget> - <packing> - <property name="left_attach">2</property> - <property name="right_attach">3</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkEntry" id="entry-email-1"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="editable">True</property> - <property name="visibility">True</property> - <property name="max_length">0</property> - <property name="text" translatable="yes"></property> - <property name="has_frame">True</property> - <property name="invisible_char" translatable="yes">*</property> - <property name="activates_default">False</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">0</property> - <property name="bottom_attach">1</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkEntry" id="entry-email-3"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="editable">True</property> - <property name="visibility">True</property> - <property name="max_length">0</property> - <property name="text" translatable="yes"></property> - <property name="has_frame">True</property> - <property name="invisible_char" translatable="yes">*</property> - <property name="activates_default">False</property> - </widget> - <packing> - <property name="left_attach">3</property> - <property name="right_attach">4</property> - <property name="top_attach">0</property> - <property name="bottom_attach">1</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkEntry" id="entry-email-4"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="editable">True</property> - <property name="visibility">True</property> - <property name="max_length">0</property> - <property name="text" translatable="yes"></property> - <property name="has_frame">True</property> - <property name="invisible_char" translatable="yes">*</property> - <property name="activates_default">False</property> - </widget> - <packing> - <property name="left_attach">3</property> - <property name="right_attach">4</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkCheckButton" id="checkbutton-htmlmail"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="label" translatable="yes">Wants to receive HTML mail</property> - <property name="use_underline">True</property> - <property name="relief">GTK_RELIEF_NORMAL</property> - <property name="active">False</property> - <property name="inconsistent">False</property> - <property name="draw_indicator">True</property> - </widget> - <packing> - <property name="left_attach">0</property> - <property name="right_attach">4</property> - <property name="top_attach">2</property> - <property name="bottom_attach">3</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> - </child> - </widget> - </child> - - <child> - <widget class="GtkLabel" id="label400"> - <property name="visible">True</property> - <property name="label" translatable="yes"><b>Email</b></property> - <property name="use_underline">False</property> - <property name="use_markup">True</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="type">label_item</property> - </packing> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - - <child> - <widget class="GtkVBox" id="vbox38"> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">0</property> - - <child> - <widget class="GtkFrame" id="frame64"> - <property name="visible">True</property> - <property name="label_xalign">0</property> - <property name="label_yalign">0.5</property> - <property name="shadow_type">GTK_SHADOW_NONE</property> - - <child> - <widget class="GtkVBox" id="vbox37"> - <property name="border_width">12</property> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">6</property> - - <child> - <widget class="GtkTable" id="table84"> - <property name="visible">True</property> - <property name="n_rows">2</property> - <property name="n_columns">4</property> - <property name="homogeneous">False</property> - <property name="row_spacing">6</property> - <property name="column_spacing">6</property> - - <child> - <widget class="GtkEntry" id="entry-phone-1"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="editable">True</property> - <property name="visibility">True</property> - <property name="max_length">0</property> - <property name="text" translatable="yes"></property> - <property name="has_frame">True</property> - <property name="invisible_char" translatable="yes">*</property> - <property name="activates_default">False</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">0</property> - <property name="bottom_attach">1</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkEntry" id="entry-phone-2"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="editable">True</property> - <property name="visibility">True</property> - <property name="max_length">0</property> - <property name="text" translatable="yes"></property> - <property name="has_frame">True</property> - <property name="invisible_char" translatable="yes">*</property> - <property name="activates_default">False</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkEntry" id="entry-phone-4"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="editable">True</property> - <property name="visibility">True</property> - <property name="max_length">0</property> - <property name="text" translatable="yes"></property> - <property name="has_frame">True</property> - <property name="invisible_char" translatable="yes">*</property> - <property name="activates_default">False</property> - </widget> - <packing> - <property name="left_attach">3</property> - <property name="right_attach">4</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkEntry" id="entry-phone-3"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="editable">True</property> - <property name="visibility">True</property> - <property name="max_length">0</property> - <property name="text" translatable="yes"></property> - <property name="has_frame">True</property> - <property name="invisible_char" translatable="yes">*</property> - <property name="activates_default">False</property> - </widget> - <packing> - <property name="left_attach">3</property> - <property name="right_attach">4</property> - <property name="top_attach">0</property> - <property name="bottom_attach">1</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkOptionMenu" id="optionmenu-phone-1"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="history">0</property> - - <child> - <widget class="GtkMenu" id="menu179"> - - <child> - <widget class="GtkMenuItem" id="menuitem412"> - <property name="visible">True</property> - <property name="label" translatable="yes">Work</property> - <property name="use_underline">True</property> - <signal name="activate" handler="on_work2_activate" last_modification_time="Fri, 12 Mar 2004 19:27:14 GMT"/> - </widget> - </child> - - <child> - <widget class="GtkMenuItem" id="menuitem413"> - <property name="visible">True</property> - <property name="label" translatable="yes">Personal</property> - <property name="use_underline">True</property> - <signal name="activate" handler="on_personal2_activate" last_modification_time="Fri, 12 Mar 2004 19:27:14 GMT"/> - </widget> - </child> - </widget> - </child> - </widget> - <packing> - <property name="left_attach">0</property> - <property name="right_attach">1</property> - <property name="top_attach">0</property> - <property name="bottom_attach">1</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkOptionMenu" id="optionmenu-phone-2"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="history">0</property> - - <child> - <widget class="GtkMenu" id="menu180"> - - <child> - <widget class="GtkMenuItem" id="menuitem414"> - <property name="visible">True</property> - <property name="label" translatable="yes">Work</property> - <property name="use_underline">True</property> - <signal name="activate" handler="on_work2_activate" last_modification_time="Fri, 12 Mar 2004 19:27:14 GMT"/> - </widget> - </child> - - <child> - <widget class="GtkMenuItem" id="menuitem415"> - <property name="visible">True</property> - <property name="label" translatable="yes">Personal</property> - <property name="use_underline">True</property> - <signal name="activate" handler="on_personal2_activate" last_modification_time="Fri, 12 Mar 2004 19:27:14 GMT"/> - </widget> - </child> - </widget> - </child> - </widget> - <packing> - <property name="left_attach">0</property> - <property name="right_attach">1</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkOptionMenu" id="optionmenu-phone-3"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="history">0</property> - - <child> - <widget class="GtkMenu" id="menu181"> - - <child> - <widget class="GtkMenuItem" id="menuitem416"> - <property name="visible">True</property> - <property name="label" translatable="yes">Work</property> - <property name="use_underline">True</property> - <signal name="activate" handler="on_work2_activate" last_modification_time="Fri, 12 Mar 2004 19:27:14 GMT"/> - </widget> - </child> - - <child> - <widget class="GtkMenuItem" id="menuitem417"> - <property name="visible">True</property> - <property name="label" translatable="yes">Personal</property> - <property name="use_underline">True</property> - <signal name="activate" handler="on_personal2_activate" last_modification_time="Fri, 12 Mar 2004 19:27:14 GMT"/> - </widget> - </child> - </widget> - </child> - </widget> - <packing> - <property name="left_attach">2</property> - <property name="right_attach">3</property> - <property name="top_attach">0</property> - <property name="bottom_attach">1</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkOptionMenu" id="optionmenu-phone-4"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="history">0</property> - - <child> - <widget class="GtkMenu" id="menu182"> - - <child> - <widget class="GtkMenuItem" id="menuitem418"> - <property name="visible">True</property> - <property name="label" translatable="yes">Work</property> - <property name="use_underline">True</property> - <signal name="activate" handler="on_work2_activate" last_modification_time="Fri, 12 Mar 2004 19:27:14 GMT"/> - </widget> - </child> - - <child> - <widget class="GtkMenuItem" id="menuitem419"> - <property name="visible">True</property> - <property name="label" translatable="yes">Personal</property> - <property name="use_underline">True</property> - <signal name="activate" handler="on_personal2_activate" last_modification_time="Fri, 12 Mar 2004 19:27:14 GMT"/> - </widget> - </child> - </widget> - </child> - </widget> - <packing> - <property name="left_attach">2</property> - <property name="right_attach">3</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">True</property> - </packing> - </child> - - <child> - <widget class="GtkTable" id="table-phone-extended"> - <property name="n_rows">2</property> - <property name="n_columns">4</property> - <property name="homogeneous">False</property> - <property name="row_spacing">6</property> - <property name="column_spacing">6</property> - - <child> - <widget class="GtkOptionMenu" id="optionmenu-phone-5"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="history">0</property> - - <child> - <widget class="GtkMenu" id="menu187"> - - <child> - <widget class="GtkMenuItem" id="menuitem430"> - <property name="visible">True</property> - <property name="label" translatable="yes">Work</property> - <property name="use_underline">True</property> - <signal name="activate" handler="on_work2_activate" last_modification_time="Fri, 12 Mar 2004 19:27:14 GMT"/> - </widget> - </child> - - <child> - <widget class="GtkMenuItem" id="menuitem431"> - <property name="visible">True</property> - <property name="label" translatable="yes">Personal</property> - <property name="use_underline">True</property> - <signal name="activate" handler="on_personal2_activate" last_modification_time="Fri, 12 Mar 2004 19:27:14 GMT"/> - </widget> - </child> - </widget> - </child> - </widget> - <packing> - <property name="left_attach">0</property> - <property name="right_attach">1</property> - <property name="top_attach">0</property> - <property name="bottom_attach">1</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkOptionMenu" id="optionmenu-phone-6"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="history">0</property> - - <child> - <widget class="GtkMenu" id="menu188"> - - <child> - <widget class="GtkMenuItem" id="menuitem432"> - <property name="visible">True</property> - <property name="label" translatable="yes">Work</property> - <property name="use_underline">True</property> - <signal name="activate" handler="on_work2_activate" last_modification_time="Fri, 12 Mar 2004 19:27:14 GMT"/> - </widget> - </child> - - <child> - <widget class="GtkMenuItem" id="menuitem433"> - <property name="visible">True</property> - <property name="label" translatable="yes">Personal</property> - <property name="use_underline">True</property> - <signal name="activate" handler="on_personal2_activate" last_modification_time="Fri, 12 Mar 2004 19:27:14 GMT"/> - </widget> - </child> - </widget> - </child> - </widget> - <packing> - <property name="left_attach">0</property> - <property name="right_attach">1</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkEntry" id="entry-phone-5"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="editable">True</property> - <property name="visibility">True</property> - <property name="max_length">0</property> - <property name="text" translatable="yes"></property> - <property name="has_frame">True</property> - <property name="invisible_char" translatable="yes">*</property> - <property name="activates_default">False</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">0</property> - <property name="bottom_attach">1</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkEntry" id="entry-phone-6"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="editable">True</property> - <property name="visibility">True</property> - <property name="max_length">0</property> - <property name="text" translatable="yes"></property> - <property name="has_frame">True</property> - <property name="invisible_char" translatable="yes">*</property> - <property name="activates_default">False</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkOptionMenu" id="optionmenu-phone-7"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="history">0</property> - - <child> - <widget class="GtkMenu" id="menu189"> - - <child> - <widget class="GtkMenuItem" id="menuitem434"> - <property name="visible">True</property> - <property name="label" translatable="yes">Work</property> - <property name="use_underline">True</property> - <signal name="activate" handler="on_work2_activate" last_modification_time="Fri, 12 Mar 2004 19:27:14 GMT"/> - </widget> - </child> - - <child> - <widget class="GtkMenuItem" id="menuitem435"> - <property name="visible">True</property> - <property name="label" translatable="yes">Personal</property> - <property name="use_underline">True</property> - <signal name="activate" handler="on_personal2_activate" last_modification_time="Fri, 12 Mar 2004 19:27:14 GMT"/> - </widget> - </child> - </widget> - </child> - </widget> - <packing> - <property name="left_attach">2</property> - <property name="right_attach">3</property> - <property name="top_attach">0</property> - <property name="bottom_attach">1</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkOptionMenu" id="optionmenu-phone-8"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="history">0</property> - - <child> - <widget class="GtkMenu" id="menu190"> - - <child> - <widget class="GtkMenuItem" id="menuitem436"> - <property name="visible">True</property> - <property name="label" translatable="yes">Work</property> - <property name="use_underline">True</property> - <signal name="activate" handler="on_work2_activate" last_modification_time="Fri, 12 Mar 2004 19:27:14 GMT"/> - </widget> - </child> - - <child> - <widget class="GtkMenuItem" id="menuitem437"> - <property name="visible">True</property> - <property name="label" translatable="yes">Personal</property> - <property name="use_underline">True</property> - <signal name="activate" handler="on_personal2_activate" last_modification_time="Fri, 12 Mar 2004 19:27:14 GMT"/> - </widget> - </child> - </widget> - </child> - </widget> - <packing> - <property name="left_attach">2</property> - <property name="right_attach">3</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkEntry" id="entry-phone-7"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="editable">True</property> - <property name="visibility">True</property> - <property name="max_length">0</property> - <property name="text" translatable="yes"></property> - <property name="has_frame">True</property> - <property name="invisible_char" translatable="yes">*</property> - <property name="activates_default">False</property> - </widget> - <packing> - <property name="left_attach">3</property> - <property name="right_attach">4</property> - <property name="top_attach">0</property> - <property name="bottom_attach">1</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkEntry" id="entry-phone-8"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="editable">True</property> - <property name="visibility">True</property> - <property name="max_length">0</property> - <property name="text" translatable="yes"></property> - <property name="has_frame">True</property> - <property name="invisible_char" translatable="yes">*</property> - <property name="activates_default">False</property> - </widget> - <packing> - <property name="left_attach">3</property> - <property name="right_attach">4</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="y_options"></property> - </packing> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">True</property> - </packing> - </child> - </widget> - </child> - - <child> - <widget class="GtkHBox" id="hbox56"> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">4</property> - - <child> - <widget class="GtkLabel" id="label399"> - <property name="visible">True</property> - <property name="label" translatable="yes"><b>Telephone</b></property> - <property name="use_underline">False</property> - <property name="use_markup">True</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - - <child> - <widget class="GtkButton" id="button-phone-expand"> - <property name="width_request">20</property> - <property name="height_request">20</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="relief">GTK_RELIEF_NONE</property> - - <child> - <widget class="GtkArrow" id="arrow-phone-expand"> - <property name="visible">True</property> - <property name="arrow_type">GTK_ARROW_RIGHT</property> - <property name="shadow_type">GTK_SHADOW_NONE</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">True</property> - <property name="fill">True</property> - </packing> - </child> - </widget> - <packing> - <property name="type">label_item</property> - </packing> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">True</property> - </packing> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">True</property> - </packing> - </child> - - <child> - <widget class="GtkFrame" id="frame66"> - <property name="visible">True</property> - <property name="label_xalign">0</property> - <property name="label_yalign">0.5</property> - <property name="shadow_type">GTK_SHADOW_NONE</property> - - <child> - <widget class="GtkTable" id="table86"> - <property name="border_width">12</property> - <property name="visible">True</property> - <property name="n_rows">2</property> - <property name="n_columns">4</property> - <property name="homogeneous">False</property> - <property name="row_spacing">6</property> - <property name="column_spacing">6</property> - - <child> - <widget class="GtkOptionMenu" id="optionmenu-im-service-1"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="history">0</property> - - <child> - <widget class="GtkMenu" id="menu173"> - - <child> - <widget class="GtkMenuItem" id="menuitem388"> - <property name="visible">True</property> - <property name="label" translatable="yes">AIM</property> - <property name="use_underline">True</property> - <signal name="activate" handler="on_aim1_activate" last_modification_time="Fri, 12 Mar 2004 18:38:59 GMT"/> - </widget> - </child> - - <child> - <widget class="GtkMenuItem" id="menuitem389"> - <property name="visible">True</property> - <property name="label" translatable="yes">Novell Groupwise</property> - <property name="use_underline">True</property> - <signal name="activate" handler="on_novell_groupwise1_activate" last_modification_time="Fri, 12 Mar 2004 18:38:59 GMT"/> - </widget> - </child> - - <child> - <widget class="GtkMenuItem" id="menuitem390"> - <property name="visible">True</property> - <property name="label" translatable="yes">MSN Messenger</property> - <property name="use_underline">True</property> - <signal name="activate" handler="on_msn_messenger1_activate" last_modification_time="Fri, 12 Mar 2004 18:38:59 GMT"/> - </widget> - </child> - </widget> - </child> - </widget> - <packing> - <property name="left_attach">0</property> - <property name="right_attach">1</property> - <property name="top_attach">0</property> - <property name="bottom_attach">1</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkEntry" id="entry-im-name-1"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="editable">True</property> - <property name="visibility">True</property> - <property name="max_length">0</property> - <property name="text" translatable="yes"></property> - <property name="has_frame">True</property> - <property name="invisible_char" translatable="yes">*</property> - <property name="activates_default">False</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">0</property> - <property name="bottom_attach">1</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkOptionMenu" id="optionmenu-im-service-2"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="history">0</property> - - <child> - <widget class="GtkMenu" id="menu174"> - - <child> - <widget class="GtkMenuItem" id="menuitem391"> - <property name="visible">True</property> - <property name="label" translatable="yes">AIM</property> - <property name="use_underline">True</property> - <signal name="activate" handler="on_aim1_activate" last_modification_time="Fri, 12 Mar 2004 18:38:59 GMT"/> - </widget> - </child> - - <child> - <widget class="GtkMenuItem" id="menuitem392"> - <property name="visible">True</property> - <property name="label" translatable="yes">Novell Groupwise</property> - <property name="use_underline">True</property> - <signal name="activate" handler="on_novell_groupwise1_activate" last_modification_time="Fri, 12 Mar 2004 18:38:59 GMT"/> - </widget> - </child> - - <child> - <widget class="GtkMenuItem" id="menuitem393"> - <property name="visible">True</property> - <property name="label" translatable="yes">MSN Messenger</property> - <property name="use_underline">True</property> - <signal name="activate" handler="on_msn_messenger1_activate" last_modification_time="Fri, 12 Mar 2004 18:38:59 GMT"/> - </widget> - </child> - </widget> - </child> - </widget> - <packing> - <property name="left_attach">0</property> - <property name="right_attach">1</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkEntry" id="entry-im-name-2"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="editable">True</property> - <property name="visibility">True</property> - <property name="max_length">0</property> - <property name="text" translatable="yes"></property> - <property name="has_frame">True</property> - <property name="invisible_char" translatable="yes">*</property> - <property name="activates_default">False</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkOptionMenu" id="optionmenu-im-service-3"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="history">0</property> - - <child> - <widget class="GtkMenu" id="menu175"> - - <child> - <widget class="GtkMenuItem" id="menuitem394"> - <property name="visible">True</property> - <property name="label" translatable="yes">AIM</property> - <property name="use_underline">True</property> - <signal name="activate" handler="on_aim1_activate" last_modification_time="Fri, 12 Mar 2004 18:38:59 GMT"/> - </widget> - </child> - - <child> - <widget class="GtkMenuItem" id="menuitem395"> - <property name="visible">True</property> - <property name="label" translatable="yes">Novell Groupwise</property> - <property name="use_underline">True</property> - <signal name="activate" handler="on_novell_groupwise1_activate" last_modification_time="Fri, 12 Mar 2004 18:38:59 GMT"/> - </widget> - </child> - - <child> - <widget class="GtkMenuItem" id="menuitem396"> - <property name="visible">True</property> - <property name="label" translatable="yes">MSN Messenger</property> - <property name="use_underline">True</property> - <signal name="activate" handler="on_msn_messenger1_activate" last_modification_time="Fri, 12 Mar 2004 18:38:59 GMT"/> - </widget> - </child> - </widget> - </child> - </widget> - <packing> - <property name="left_attach">2</property> - <property name="right_attach">3</property> - <property name="top_attach">0</property> - <property name="bottom_attach">1</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkEntry" id="entry-im-name-3"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="editable">True</property> - <property name="visibility">True</property> - <property name="max_length">0</property> - <property name="text" translatable="yes"></property> - <property name="has_frame">True</property> - <property name="invisible_char" translatable="yes">*</property> - <property name="activates_default">False</property> - </widget> - <packing> - <property name="left_attach">3</property> - <property name="right_attach">4</property> - <property name="top_attach">0</property> - <property name="bottom_attach">1</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkOptionMenu" id="optionmenu-im-service-4"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="history">0</property> - - <child> - <widget class="GtkMenu" id="menu183"> - - <child> - <widget class="GtkMenuItem" id="menuitem420"> - <property name="visible">True</property> - <property name="label" translatable="yes">AIM</property> - <property name="use_underline">True</property> - <signal name="activate" handler="on_aim1_activate" last_modification_time="Fri, 12 Mar 2004 18:38:59 GMT"/> - </widget> - </child> - - <child> - <widget class="GtkMenuItem" id="menuitem421"> - <property name="visible">True</property> - <property name="label" translatable="yes">Novell Groupwise</property> - <property name="use_underline">True</property> - <signal name="activate" handler="on_novell_groupwise1_activate" last_modification_time="Fri, 12 Mar 2004 18:38:59 GMT"/> - </widget> - </child> - - <child> - <widget class="GtkMenuItem" id="menuitem422"> - <property name="visible">True</property> - <property name="label" translatable="yes">MSN Messenger</property> - <property name="use_underline">True</property> - <signal name="activate" handler="on_msn_messenger1_activate" last_modification_time="Fri, 12 Mar 2004 18:38:59 GMT"/> - </widget> - </child> - </widget> - </child> - </widget> - <packing> - <property name="left_attach">2</property> - <property name="right_attach">3</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkEntry" id="entry-im-name-4"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="editable">True</property> - <property name="visibility">True</property> - <property name="max_length">0</property> - <property name="text" translatable="yes"></property> - <property name="has_frame">True</property> - <property name="invisible_char" translatable="yes">*</property> - <property name="activates_default">False</property> - </widget> - <packing> - <property name="left_attach">3</property> - <property name="right_attach">4</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="y_options"></property> - </packing> - </child> - </widget> - </child> - - <child> - <widget class="GtkLabel" id="label404"> - <property name="visible">True</property> - <property name="label" translatable="yes"><b>Instant Messaging</b></property> - <property name="use_underline">False</property> - <property name="use_markup">True</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="type">label_item</property> - </packing> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">True</property> - </packing> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">True</property> - <property name="fill">True</property> - </packing> - </child> - </widget> - <packing> - <property name="tab_expand">True</property> - <property name="tab_fill">True</property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label405"> - <property name="visible">True</property> - <property name="label" translatable="yes">Contact</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="type">tab</property> - </packing> - </child> - - <child> - <widget class="GtkVBox" id="vbox35"> - <property name="border_width">12</property> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">12</property> - - <child> - <widget class="GtkFrame" id="frame67"> - <property name="visible">True</property> - <property name="label_xalign">0</property> - <property name="label_yalign">0.5</property> - <property name="shadow_type">GTK_SHADOW_NONE</property> - - <child> - <widget class="GtkTable" id="table87"> - <property name="border_width">12</property> - <property name="visible">True</property> - <property name="n_rows">5</property> - <property name="n_columns">2</property> - <property name="homogeneous">False</property> - <property name="row_spacing">6</property> - <property name="column_spacing">6</property> - - <child> - <widget class="GtkLabel" id="accellabel-homepage"> - <property name="visible">True</property> - <property name="label" translatable="yes">Home Page:</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="left_attach">0</property> - <property name="right_attach">1</property> - <property name="top_attach">0</property> - <property name="bottom_attach">1</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label-caluri"> - <property name="visible">True</property> - <property name="label" translatable="yes">Calendar:</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="left_attach">0</property> - <property name="right_attach">1</property> - <property name="top_attach">2</property> - <property name="bottom_attach">3</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label-fburl"> - <property name="visible">True</property> - <property name="label" translatable="yes">Free/Busy:</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="left_attach">0</property> - <property name="right_attach">1</property> - <property name="top_attach">3</property> - <property name="bottom_attach">4</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label-videourl"> - <property name="visible">True</property> - <property name="label" translatable="yes">Video Chat:</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="left_attach">0</property> - <property name="right_attach">1</property> - <property name="top_attach">4</property> - <property name="bottom_attach">5</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="Custom" id="entry-homepage"> - <property name="visible">True</property> - <property name="creation_function">e_contact_editor_create_web</property> - <property name="int1">0</property> - <property name="int2">0</property> - <property name="last_modification_time">Tue, 13 Apr 2004 22:04:21 GMT</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">0</property> - <property name="bottom_attach">1</property> - <property name="y_options">fill</property> - </packing> - </child> - - <child> - <widget class="Custom" id="entry-caluri"> - <property name="visible">True</property> - <property name="creation_function">e_contact_editor_create_web</property> - <property name="int1">0</property> - <property name="int2">0</property> - <property name="last_modification_time">Tue, 13 Apr 2004 22:04:51 GMT</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">2</property> - <property name="bottom_attach">3</property> - <property name="y_options">fill</property> - </packing> - </child> - - <child> - <widget class="Custom" id="entry-fburl"> - <property name="visible">True</property> - <property name="creation_function">e_contact_editor_create_web</property> - <property name="int1">0</property> - <property name="int2">0</property> - <property name="last_modification_time">Tue, 13 Apr 2004 22:05:05 GMT</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">3</property> - <property name="bottom_attach">4</property> - <property name="y_options">fill</property> - </packing> - </child> - - <child> - <widget class="Custom" id="entry-videourl"> - <property name="visible">True</property> - <property name="creation_function">e_contact_editor_create_web</property> - <property name="int1">0</property> - <property name="int2">0</property> - <property name="last_modification_time">Tue, 13 Apr 2004 22:05:30 GMT</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">4</property> - <property name="bottom_attach">5</property> - <property name="y_options">fill</property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label-weblog"> - <property name="visible">True</property> - <property name="label" translatable="yes">Web Log:</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="left_attach">0</property> - <property name="right_attach">1</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="Custom" id="entry-weblog"> - <property name="visible">True</property> - <property name="creation_function">e_contact_editor_create_web</property> - <property name="int1">0</property> - <property name="int2">0</property> - <property name="last_modification_time">Tue, 13 Apr 2004 22:04:21 GMT</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="x_options">fill</property> - <property name="y_options">fill</property> - </packing> - </child> - </widget> - </child> - - <child> - <widget class="GtkLabel" id="label410"> - <property name="visible">True</property> - <property name="label" translatable="yes"><b>Web Addresses</b></property> - <property name="use_underline">False</property> - <property name="use_markup">True</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="type">label_item</property> - </packing> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">True</property> - </packing> - </child> - - <child> - <widget class="GtkFrame" id="frame68"> - <property name="visible">True</property> - <property name="label_xalign">0</property> - <property name="label_yalign">0.5</property> - <property name="shadow_type">GTK_SHADOW_NONE</property> - - <child> - <widget class="GtkTable" id="table88"> - <property name="border_width">12</property> - <property name="visible">True</property> - <property name="n_rows">3</property> - <property name="n_columns">4</property> - <property name="homogeneous">False</property> - <property name="row_spacing">6</property> - <property name="column_spacing">6</property> - - <child> - <widget class="GtkLabel" id="label-profession"> - <property name="visible">True</property> - <property name="label" translatable="yes">Profession:</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="left_attach">0</property> - <property name="right_attach">1</property> - <property name="top_attach">0</property> - <property name="bottom_attach">1</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkEntry" id="entry-profession"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="editable">True</property> - <property name="visibility">True</property> - <property name="max_length">0</property> - <property name="text" translatable="yes"></property> - <property name="has_frame">True</property> - <property name="invisible_char" translatable="yes">*</property> - <property name="activates_default">False</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">0</property> - <property name="bottom_attach">1</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label-jobtitle"> - <property name="visible">True</property> - <property name="label" translatable="yes">Title:</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="left_attach">2</property> - <property name="right_attach">3</property> - <property name="top_attach">0</property> - <property name="bottom_attach">1</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkEntry" id="entry-jobtitle"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="editable">True</property> - <property name="visibility">True</property> - <property name="max_length">0</property> - <property name="text" translatable="yes"></property> - <property name="has_frame">True</property> - <property name="invisible_char" translatable="yes">*</property> - <property name="activates_default">False</property> - </widget> - <packing> - <property name="left_attach">3</property> - <property name="right_attach">4</property> - <property name="top_attach">0</property> - <property name="bottom_attach">1</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label-company"> - <property name="visible">True</property> - <property name="label" translatable="yes">Company:</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="left_attach">0</property> - <property name="right_attach">1</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkEntry" id="entry-company"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="editable">True</property> - <property name="visibility">True</property> - <property name="max_length">0</property> - <property name="text" translatable="yes"></property> - <property name="has_frame">True</property> - <property name="invisible_char" translatable="yes">*</property> - <property name="activates_default">False</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label-department"> - <property name="visible">True</property> - <property name="label" translatable="yes">Department:</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="left_attach">2</property> - <property name="right_attach">3</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkEntry" id="entry-department"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="editable">True</property> - <property name="visibility">True</property> - <property name="max_length">0</property> - <property name="text" translatable="yes"></property> - <property name="has_frame">True</property> - <property name="invisible_char" translatable="yes">*</property> - <property name="activates_default">False</property> - </widget> - <packing> - <property name="left_attach">3</property> - <property name="right_attach">4</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label-manager"> - <property name="visible">True</property> - <property name="label" translatable="yes">Manager:</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="left_attach">0</property> - <property name="right_attach">1</property> - <property name="top_attach">2</property> - <property name="bottom_attach">3</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkEntry" id="entry-manager"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="editable">True</property> - <property name="visibility">True</property> - <property name="max_length">0</property> - <property name="text" translatable="yes"></property> - <property name="has_frame">True</property> - <property name="invisible_char" translatable="yes">*</property> - <property name="activates_default">False</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">2</property> - <property name="bottom_attach">3</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label-assistant"> - <property name="visible">True</property> - <property name="label" translatable="yes">Assistant:</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="left_attach">2</property> - <property name="right_attach">3</property> - <property name="top_attach">2</property> - <property name="bottom_attach">3</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkEntry" id="entry-assistant"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="editable">True</property> - <property name="visibility">True</property> - <property name="max_length">0</property> - <property name="text" translatable="yes"></property> - <property name="has_frame">True</property> - <property name="invisible_char" translatable="yes">*</property> - <property name="activates_default">False</property> - </widget> - <packing> - <property name="left_attach">3</property> - <property name="right_attach">4</property> - <property name="top_attach">2</property> - <property name="bottom_attach">3</property> - <property name="y_options"></property> - </packing> - </child> - </widget> - </child> - - <child> - <widget class="GtkLabel" id="label417"> - <property name="visible">True</property> - <property name="label" translatable="yes"><b>Job</b></property> - <property name="use_underline">False</property> - <property name="use_markup">True</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="type">label_item</property> - </packing> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">True</property> - </packing> - </child> - - <child> - <widget class="GtkFrame" id="frame69"> - <property name="visible">True</property> - <property name="label_xalign">0</property> - <property name="label_yalign">0.5</property> - <property name="shadow_type">GTK_SHADOW_NONE</property> - - <child> - <widget class="GtkTable" id="table89"> - <property name="border_width">12</property> - <property name="visible">True</property> - <property name="n_rows">3</property> - <property name="n_columns">4</property> - <property name="homogeneous">False</property> - <property name="row_spacing">6</property> - <property name="column_spacing">6</property> - - <child> - <widget class="GtkScrolledWindow" id="scrolledwindow41"> - <property name="height_request">38</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property> - <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property> - <property name="shadow_type">GTK_SHADOW_IN</property> - <property name="window_placement">GTK_CORNER_TOP_LEFT</property> - - <child> - <widget class="GtkTextView" id="text-comments"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="editable">True</property> - <property name="justification">GTK_JUSTIFY_LEFT</property> - <property name="wrap_mode">GTK_WRAP_NONE</property> - <property name="cursor_visible">True</property> - <property name="pixels_above_lines">0</property> - <property name="pixels_below_lines">0</property> - <property name="pixels_inside_wrap">0</property> - <property name="left_margin">0</property> - <property name="right_margin">0</property> - <property name="indent">0</property> - <property name="text" translatable="yes"></property> - </widget> - </child> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">4</property> - <property name="top_attach">2</property> - <property name="bottom_attach">3</property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label-comments"> - <property name="visible">True</property> - <property name="label" translatable="yes">Notes:</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="left_attach">0</property> - <property name="right_attach">1</property> - <property name="top_attach">2</property> - <property name="bottom_attach">3</property> - <property name="x_options">fill</property> - <property name="y_options">fill</property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label-office"> - <property name="visible">True</property> - <property name="label" translatable="yes">Office:</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="left_attach">0</property> - <property name="right_attach">1</property> - <property name="top_attach">0</property> - <property name="bottom_attach">1</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label-spouse"> - <property name="visible">True</property> - <property name="label" translatable="yes">Spouse:</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="left_attach">0</property> - <property name="right_attach">1</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkEntry" id="entry-office"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="editable">True</property> - <property name="visibility">True</property> - <property name="max_length">0</property> - <property name="text" translatable="yes"></property> - <property name="has_frame">True</property> - <property name="invisible_char" translatable="yes">*</property> - <property name="activates_default">False</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">0</property> - <property name="bottom_attach">1</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkEntry" id="entry-spouse"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="editable">True</property> - <property name="visibility">True</property> - <property name="max_length">0</property> - <property name="text" translatable="yes"></property> - <property name="has_frame">True</property> - <property name="invisible_char" translatable="yes">*</property> - <property name="activates_default">False</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label-birthday"> - <property name="visible">True</property> - <property name="label" translatable="yes">Birthday:</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="left_attach">2</property> - <property name="right_attach">3</property> - <property name="top_attach">0</property> - <property name="bottom_attach">1</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label-anniversary"> - <property name="visible">True</property> - <property name="label" translatable="yes">Anniversary:</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">1</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="left_attach">2</property> - <property name="right_attach">3</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="Custom" id="dateedit-anniversary"> - <property name="visible">True</property> - <property name="creation_function">e_contact_editor_create_date</property> - <property name="int1">0</property> - <property name="int2">0</property> - <property name="last_modification_time">Tue, 13 Apr 2004 23:56:03 GMT</property> - </widget> - <packing> - <property name="left_attach">3</property> - <property name="right_attach">4</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="x_options">fill</property> - <property name="y_options">fill</property> - </packing> - </child> - - <child> - <widget class="Custom" id="dateedit-birthday"> - <property name="visible">True</property> - <property name="creation_function">e_contact_editor_create_date</property> - <property name="int1">0</property> - <property name="int2">0</property> - <property name="last_modification_time">Tue, 13 Apr 2004 23:55:46 GMT</property> - </widget> - <packing> - <property name="left_attach">3</property> - <property name="right_attach">4</property> - <property name="top_attach">0</property> - <property name="bottom_attach">1</property> - <property name="x_options">fill</property> - <property name="y_options">fill</property> - </packing> - </child> - </widget> - </child> - - <child> - <widget class="GtkLabel" id="label421"> - <property name="visible">True</property> - <property name="label" translatable="yes"><b>Miscellaneous</b></property> - <property name="use_underline">False</property> - <property name="use_markup">True</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="type">label_item</property> - </packing> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">True</property> - <property name="fill">True</property> - </packing> - </child> - </widget> - <packing> - <property name="tab_expand">False</property> - <property name="tab_fill">True</property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label422"> - <property name="visible">True</property> - <property name="label" translatable="yes">Personal Information</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="type">tab</property> - </packing> - </child> - - <child> - <widget class="GtkVBox" id="vbox36"> - <property name="border_width">12</property> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">12</property> - - <child> - <widget class="GtkFrame" id="frame70"> - <property name="visible">True</property> - <property name="label_xalign">0</property> - <property name="label_yalign">0.5</property> - <property name="shadow_type">GTK_SHADOW_NONE</property> - - <child> - <widget class="GtkTable" id="table90"> - <property name="border_width">12</property> - <property name="visible">True</property> - <property name="n_rows">4</property> - <property name="n_columns">4</property> - <property name="homogeneous">False</property> - <property name="row_spacing">6</property> - <property name="column_spacing">6</property> - - <child> - <widget class="GtkLabel" id="label-home-city"> - <property name="visible">True</property> - <property name="label" translatable="yes">City:</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">1</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="left_attach">2</property> - <property name="right_attach">3</property> - <property name="top_attach">0</property> - <property name="bottom_attach">1</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkEntry" id="entry-home-city"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="editable">True</property> - <property name="visibility">True</property> - <property name="max_length">0</property> - <property name="text" translatable="yes"></property> - <property name="has_frame">True</property> - <property name="invisible_char" translatable="yes">*</property> - <property name="activates_default">False</property> - </widget> - <packing> - <property name="left_attach">3</property> - <property name="right_attach">4</property> - <property name="top_attach">0</property> - <property name="bottom_attach">1</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label-home-zip"> - <property name="visible">True</property> - <property name="label" translatable="yes">Zip/Postal Code:</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="left_attach">2</property> - <property name="right_attach">3</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkEntry" id="entry-home-zip"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="editable">True</property> - <property name="visibility">True</property> - <property name="max_length">0</property> - <property name="text" translatable="yes"></property> - <property name="has_frame">True</property> - <property name="invisible_char" translatable="yes">*</property> - <property name="activates_default">False</property> - </widget> - <packing> - <property name="left_attach">3</property> - <property name="right_attach">4</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label-home-state"> - <property name="visible">True</property> - <property name="label" translatable="yes">State/Province:</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">1</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="left_attach">2</property> - <property name="right_attach">3</property> - <property name="top_attach">2</property> - <property name="bottom_attach">3</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkEntry" id="entry-home-state"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="editable">True</property> - <property name="visibility">True</property> - <property name="max_length">0</property> - <property name="text" translatable="yes"></property> - <property name="has_frame">True</property> - <property name="invisible_char" translatable="yes">*</property> - <property name="activates_default">False</property> - </widget> - <packing> - <property name="left_attach">3</property> - <property name="right_attach">4</property> - <property name="top_attach">2</property> - <property name="bottom_attach">3</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label-home-country"> - <property name="visible">True</property> - <property name="label" translatable="yes">Country:</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">1</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="left_attach">2</property> - <property name="right_attach">3</property> - <property name="top_attach">3</property> - <property name="bottom_attach">4</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkEntry" id="entry-home-country"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="editable">True</property> - <property name="visibility">True</property> - <property name="max_length">0</property> - <property name="text" translatable="yes"></property> - <property name="has_frame">True</property> - <property name="invisible_char" translatable="yes">*</property> - <property name="activates_default">False</property> - </widget> - <packing> - <property name="left_attach">3</property> - <property name="right_attach">4</property> - <property name="top_attach">3</property> - <property name="bottom_attach">4</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label-home-address"> - <property name="visible">True</property> - <property name="label" translatable="yes">Address:</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">1</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="left_attach">0</property> - <property name="right_attach">1</property> - <property name="top_attach">0</property> - <property name="bottom_attach">1</property> - <property name="x_options">fill</property> - <property name="y_options">fill</property> - </packing> - </child> - - <child> - <widget class="GtkScrolledWindow" id="scrolledwindow42"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property> - <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property> - <property name="shadow_type">GTK_SHADOW_IN</property> - <property name="window_placement">GTK_CORNER_TOP_LEFT</property> - - <child> - <widget class="GtkTextView" id="textview-home-address"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="editable">True</property> - <property name="justification">GTK_JUSTIFY_LEFT</property> - <property name="wrap_mode">GTK_WRAP_NONE</property> - <property name="cursor_visible">True</property> - <property name="pixels_above_lines">0</property> - <property name="pixels_below_lines">0</property> - <property name="pixels_inside_wrap">0</property> - <property name="left_margin">0</property> - <property name="right_margin">0</property> - <property name="indent">0</property> - <property name="text" translatable="yes"></property> - </widget> - </child> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">0</property> - <property name="bottom_attach">3</property> - <property name="y_options">fill</property> - </packing> - </child> - - <child> - <widget class="GtkEntry" id="entry-home-pobox"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="editable">True</property> - <property name="visibility">True</property> - <property name="max_length">0</property> - <property name="text" translatable="yes"></property> - <property name="has_frame">True</property> - <property name="invisible_char" translatable="yes">*</property> - <property name="activates_default">False</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">3</property> - <property name="bottom_attach">4</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label-home-pobox"> - <property name="visible">True</property> - <property name="label" translatable="yes">PO Box:</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">1</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="left_attach">0</property> - <property name="right_attach">1</property> - <property name="top_attach">3</property> - <property name="bottom_attach">4</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> - </child> - </widget> - </child> - - <child> - <widget class="GtkLabel" id="label429"> - <property name="visible">True</property> - <property name="label" translatable="yes"><b>Home</b></property> - <property name="use_underline">False</property> - <property name="use_markup">True</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="type">label_item</property> - </packing> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">True</property> - </packing> - </child> - - <child> - <widget class="GtkFrame" id="frame71"> - <property name="visible">True</property> - <property name="label_xalign">0</property> - <property name="label_yalign">0.5</property> - <property name="shadow_type">GTK_SHADOW_NONE</property> - - <child> - <widget class="GtkTable" id="table91"> - <property name="border_width">12</property> - <property name="visible">True</property> - <property name="n_rows">4</property> - <property name="n_columns">4</property> - <property name="homogeneous">False</property> - <property name="row_spacing">6</property> - <property name="column_spacing">6</property> - - <child> - <widget class="GtkLabel" id="label-work-city"> - <property name="visible">True</property> - <property name="label" translatable="yes">City:</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">1</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="left_attach">2</property> - <property name="right_attach">3</property> - <property name="top_attach">0</property> - <property name="bottom_attach">1</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkEntry" id="entry-work-city"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="editable">True</property> - <property name="visibility">True</property> - <property name="max_length">0</property> - <property name="text" translatable="yes"></property> - <property name="has_frame">True</property> - <property name="invisible_char" translatable="yes">*</property> - <property name="activates_default">False</property> - </widget> - <packing> - <property name="left_attach">3</property> - <property name="right_attach">4</property> - <property name="top_attach">0</property> - <property name="bottom_attach">1</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label-work-state"> - <property name="visible">True</property> - <property name="label" translatable="yes">State/Province:</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">1</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="left_attach">2</property> - <property name="right_attach">3</property> - <property name="top_attach">2</property> - <property name="bottom_attach">3</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkEntry" id="entry-work-state"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="editable">True</property> - <property name="visibility">True</property> - <property name="max_length">0</property> - <property name="text" translatable="yes"></property> - <property name="has_frame">True</property> - <property name="invisible_char" translatable="yes">*</property> - <property name="activates_default">False</property> - </widget> - <packing> - <property name="left_attach">3</property> - <property name="right_attach">4</property> - <property name="top_attach">2</property> - <property name="bottom_attach">3</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label-work-zip"> - <property name="visible">True</property> - <property name="label" translatable="yes">Zip/Postal Code:</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="left_attach">2</property> - <property name="right_attach">3</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkEntry" id="entry-work-zip"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="editable">True</property> - <property name="visibility">True</property> - <property name="max_length">0</property> - <property name="text" translatable="yes"></property> - <property name="has_frame">True</property> - <property name="invisible_char" translatable="yes">*</property> - <property name="activates_default">False</property> - </widget> - <packing> - <property name="left_attach">3</property> - <property name="right_attach">4</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label-work-country"> - <property name="visible">True</property> - <property name="label" translatable="yes">Country:</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">1</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="left_attach">2</property> - <property name="right_attach">3</property> - <property name="top_attach">3</property> - <property name="bottom_attach">4</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkEntry" id="entry-work-country"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="editable">True</property> - <property name="visibility">True</property> - <property name="max_length">0</property> - <property name="text" translatable="yes"></property> - <property name="has_frame">True</property> - <property name="invisible_char" translatable="yes">*</property> - <property name="activates_default">False</property> - </widget> - <packing> - <property name="left_attach">3</property> - <property name="right_attach">4</property> - <property name="top_attach">3</property> - <property name="bottom_attach">4</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label-work-address"> - <property name="visible">True</property> - <property name="label" translatable="yes">Address:</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">1</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="left_attach">0</property> - <property name="right_attach">1</property> - <property name="top_attach">0</property> - <property name="bottom_attach">1</property> - <property name="x_options">fill</property> - <property name="y_options">fill</property> - </packing> - </child> - - <child> - <widget class="GtkScrolledWindow" id="scrolledwindow43"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property> - <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property> - <property name="shadow_type">GTK_SHADOW_IN</property> - <property name="window_placement">GTK_CORNER_TOP_LEFT</property> - - <child> - <widget class="GtkTextView" id="textview-work-address"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="editable">True</property> - <property name="justification">GTK_JUSTIFY_LEFT</property> - <property name="wrap_mode">GTK_WRAP_NONE</property> - <property name="cursor_visible">True</property> - <property name="pixels_above_lines">0</property> - <property name="pixels_below_lines">0</property> - <property name="pixels_inside_wrap">0</property> - <property name="left_margin">0</property> - <property name="right_margin">0</property> - <property name="indent">0</property> - <property name="text" translatable="yes"></property> - </widget> - </child> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">0</property> - <property name="bottom_attach">3</property> - <property name="y_options">fill</property> - </packing> - </child> - - <child> - <widget class="GtkEntry" id="entry-work-pobox"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="editable">True</property> - <property name="visibility">True</property> - <property name="max_length">0</property> - <property name="text" translatable="yes"></property> - <property name="has_frame">True</property> - <property name="invisible_char" translatable="yes">*</property> - <property name="activates_default">False</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">3</property> - <property name="bottom_attach">4</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label-work-pobox"> - <property name="visible">True</property> - <property name="label" translatable="yes">PO Box:</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">1</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="left_attach">0</property> - <property name="right_attach">1</property> - <property name="top_attach">3</property> - <property name="bottom_attach">4</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> - </child> - </widget> - </child> - - <child> - <widget class="GtkLabel" id="label436"> - <property name="visible">True</property> - <property name="label" translatable="yes"><b>Work</b></property> - <property name="use_underline">False</property> - <property name="use_markup">True</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="type">label_item</property> - </packing> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">True</property> - </packing> - </child> - - <child> - <widget class="GtkFrame" id="frame72"> - <property name="visible">True</property> - <property name="label_xalign">0</property> - <property name="label_yalign">0.5</property> - <property name="shadow_type">GTK_SHADOW_NONE</property> - - <child> - <widget class="GtkTable" id="table92"> - <property name="border_width">12</property> - <property name="visible">True</property> - <property name="n_rows">4</property> - <property name="n_columns">4</property> - <property name="homogeneous">False</property> - <property name="row_spacing">6</property> - <property name="column_spacing">6</property> - - <child> - <widget class="GtkLabel" id="label-other-city"> - <property name="visible">True</property> - <property name="label" translatable="yes">City:</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">1</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="left_attach">2</property> - <property name="right_attach">3</property> - <property name="top_attach">0</property> - <property name="bottom_attach">1</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkEntry" id="entry-other-city"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="editable">True</property> - <property name="visibility">True</property> - <property name="max_length">0</property> - <property name="text" translatable="yes"></property> - <property name="has_frame">True</property> - <property name="invisible_char" translatable="yes">*</property> - <property name="activates_default">False</property> - </widget> - <packing> - <property name="left_attach">3</property> - <property name="right_attach">4</property> - <property name="top_attach">0</property> - <property name="bottom_attach">1</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label-other-address"> - <property name="visible">True</property> - <property name="label" translatable="yes">Address:</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">1</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="left_attach">0</property> - <property name="right_attach">1</property> - <property name="top_attach">0</property> - <property name="bottom_attach">1</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkEntry" id="entry-other-state"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="editable">True</property> - <property name="visibility">True</property> - <property name="max_length">0</property> - <property name="text" translatable="yes"></property> - <property name="has_frame">True</property> - <property name="invisible_char" translatable="yes">*</property> - <property name="activates_default">False</property> - </widget> - <packing> - <property name="left_attach">3</property> - <property name="right_attach">4</property> - <property name="top_attach">2</property> - <property name="bottom_attach">3</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label-other-state"> - <property name="visible">True</property> - <property name="label" translatable="yes">State/Province:</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">1</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="left_attach">2</property> - <property name="right_attach">3</property> - <property name="top_attach">2</property> - <property name="bottom_attach">3</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label-other-zip"> - <property name="visible">True</property> - <property name="label" translatable="yes">Zip/Postal Code:</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="left_attach">2</property> - <property name="right_attach">3</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkEntry" id="entry-other-zip"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="editable">True</property> - <property name="visibility">True</property> - <property name="max_length">0</property> - <property name="text" translatable="yes"></property> - <property name="has_frame">True</property> - <property name="invisible_char" translatable="yes">*</property> - <property name="activates_default">False</property> - </widget> - <packing> - <property name="left_attach">3</property> - <property name="right_attach">4</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label-other-country"> - <property name="visible">True</property> - <property name="label" translatable="yes">Country:</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">1</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="left_attach">2</property> - <property name="right_attach">3</property> - <property name="top_attach">3</property> - <property name="bottom_attach">4</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkEntry" id="entry-other-country"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="editable">True</property> - <property name="visibility">True</property> - <property name="max_length">0</property> - <property name="text" translatable="yes"></property> - <property name="has_frame">True</property> - <property name="invisible_char" translatable="yes">*</property> - <property name="activates_default">False</property> - </widget> - <packing> - <property name="left_attach">3</property> - <property name="right_attach">4</property> - <property name="top_attach">3</property> - <property name="bottom_attach">4</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkScrolledWindow" id="scrolledwindow44"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property> - <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property> - <property name="shadow_type">GTK_SHADOW_IN</property> - <property name="window_placement">GTK_CORNER_TOP_LEFT</property> - - <child> - <widget class="GtkTextView" id="textview-other-address"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="editable">True</property> - <property name="justification">GTK_JUSTIFY_LEFT</property> - <property name="wrap_mode">GTK_WRAP_NONE</property> - <property name="cursor_visible">True</property> - <property name="pixels_above_lines">0</property> - <property name="pixels_below_lines">0</property> - <property name="pixels_inside_wrap">0</property> - <property name="left_margin">0</property> - <property name="right_margin">0</property> - <property name="indent">0</property> - <property name="text" translatable="yes"></property> - </widget> - </child> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">0</property> - <property name="bottom_attach">3</property> - <property name="y_options">fill</property> - </packing> - </child> - - <child> - <widget class="GtkEntry" id="entry-other-pobox"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="editable">True</property> - <property name="visibility">True</property> - <property name="max_length">0</property> - <property name="text" translatable="yes"></property> - <property name="has_frame">True</property> - <property name="invisible_char" translatable="yes">*</property> - <property name="activates_default">False</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">3</property> - <property name="bottom_attach">4</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label-other-pobox"> - <property name="visible">True</property> - <property name="label" translatable="yes">PO Box:</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">1</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="left_attach">0</property> - <property name="right_attach">1</property> - <property name="top_attach">3</property> - <property name="bottom_attach">4</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> - </child> - </widget> - </child> - - <child> - <widget class="GtkLabel" id="label444"> - <property name="visible">True</property> - <property name="label" translatable="yes"><b>Other</b></property> - <property name="use_underline">False</property> - <property name="use_markup">True</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="type">label_item</property> - </packing> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - </widget> - <packing> - <property name="tab_expand">False</property> - <property name="tab_fill">True</property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label437"> - <property name="visible">True</property> - <property name="label" translatable="yes">Mailing Address</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="type">tab</property> - </packing> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">True</property> - <property name="fill">True</property> - </packing> - </child> - </widget> - </child> -</widget> - -</glade-interface> diff --git a/addressbook/gui/contact-editor/e-contact-editor-address.c b/addressbook/gui/contact-editor/e-contact-editor-address.c deleted file mode 100644 index 1fc4994594..0000000000 --- a/addressbook/gui/contact-editor/e-contact-editor-address.c +++ /dev/null @@ -1,627 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * e-contact-editor-address.c - * Copyright (C) 2000 Ximian, Inc. - * Author: Chris Lahey <clahey@ximian.com> - * - * This library 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 library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include <config.h> - -#include <e-contact-editor-address.h> -#include <e-util/e-icon-factory.h> - -#include <glib.h> -#include <libgnome/gnome-i18n.h> -#include <libgnome/gnome-util.h> -#include <gal/widgets/e-gui-utils.h> -#include <gtk/gtkcombo.h> -#include <gtk/gtkentry.h> -#include <gtk/gtkstock.h> -#include <gtk/gtklabel.h> -#include <string.h> -#include <stdlib.h> -#include <locale.h> - -static void e_contact_editor_address_init (EContactEditorAddress *card); -static void e_contact_editor_address_class_init (EContactEditorAddressClass *klass); -static void e_contact_editor_address_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec); -static void e_contact_editor_address_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); -static void e_contact_editor_address_dispose (GObject *object); - -static void fill_in_info(EContactEditorAddress *editor); -static void extract_info(EContactEditorAddress *editor); - -static GtkDialogClass *parent_class = NULL; - -/* The arguments we take */ -enum { - PROP_0, - PROP_ADDRESS, - PROP_EDITABLE -}; - -GType -e_contact_editor_address_get_type (void) -{ - static GType contact_editor_address_type = 0; - - if (!contact_editor_address_type) { - static const GTypeInfo contact_editor_address_info = { - sizeof (EContactEditorAddressClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) e_contact_editor_address_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (EContactEditorAddress), - 0, /* n_preallocs */ - (GInstanceInitFunc) e_contact_editor_address_init, - }; - - contact_editor_address_type = g_type_register_static (GTK_TYPE_DIALOG, "EContactEditorAddress", &contact_editor_address_info, 0); - } - - return contact_editor_address_type; -} - -static void -e_contact_editor_address_class_init (EContactEditorAddressClass *klass) -{ - GObjectClass *object_class; - - object_class = G_OBJECT_CLASS (klass); - - parent_class = g_type_class_ref (GTK_TYPE_DIALOG); - - object_class->set_property = e_contact_editor_address_set_property; - object_class->get_property = e_contact_editor_address_get_property; - object_class->dispose = e_contact_editor_address_dispose; - - g_object_class_install_property (object_class, PROP_ADDRESS, - g_param_spec_boxed ("address", - _("Address"), - /*_( */"XXX blurb" /*)*/, - e_contact_address_get_type (), - G_PARAM_READWRITE)); - - g_object_class_install_property (object_class, PROP_EDITABLE, - g_param_spec_boolean ("editable", - _("Editable"), - /*_( */"XXX blurb" /*)*/, - FALSE, - G_PARAM_READWRITE)); -} - -static GList * -add_to_tab_order(GList *list, GladeXML *gui, char *name) -{ - GtkWidget *widget = glade_xml_get_widget(gui, name); - return g_list_prepend(list, widget); -} - -static void -setup_tab_order(GladeXML *gui) -{ - GtkWidget *container; - GList *list = NULL; - - container = glade_xml_get_widget(gui, "table-checkaddress"); - - if (container) { - list = add_to_tab_order(list, gui, "entry-city"); - list = add_to_tab_order(list, gui, "entry-region"); - list = add_to_tab_order(list, gui, "entry-code"); - list = add_to_tab_order(list, gui, "combo-country"); - list = g_list_reverse(list); - e_container_change_tab_order(GTK_CONTAINER(container), list); - g_list_free(list); - } -} - -static char * countries [] = { - N_("United States"), - N_("Afghanistan"), - N_("Albania"), - N_("Algeria"), - N_("American Samoa"), - N_("Andorra"), - N_("Angola"), - N_("Anguilla"), - N_("Antarctica"), - N_("Antigua And Barbuda"), - N_("Argentina"), - N_("Armenia"), - N_("Aruba"), - N_("Australia"), - N_("Austria"), - N_("Azerbaijan"), - N_("Bahamas"), - N_("Bahrain"), - N_("Bangladesh"), - N_("Barbados"), - N_("Belarus"), - N_("Belgium"), - N_("Belize"), - N_("Benin"), - N_("Bermuda"), - N_("Bhutan"), - N_("Bolivia"), - N_("Bosnia And Herzegowina"), - N_("Botswana"), - N_("Bouvet Island"), - N_("Brazil"), - N_("British Indian Ocean Territory"), - N_("Brunei Darussalam"), - N_("Bulgaria"), - N_("Burkina Faso"), - N_("Burundi"), - N_("Cambodia"), - N_("Cameroon"), - N_("Canada"), - N_("Cape Verde"), - N_("Cayman Islands"), - N_("Central African Republic"), - N_("Chad"), - N_("Chile"), - N_("China"), - N_("Christmas Island"), - N_("Cocos (Keeling) Islands"), - N_("Colombia"), - N_("Comoros"), - N_("Congo"), - N_("Congo, The Democratic Republic Of The"), - N_("Cook Islands"), - N_("Costa Rica"), - N_("Cote d'Ivoire"), - N_("Croatia"), - N_("Cuba"), - N_("Cyprus"), - N_("Czech Republic"), - N_("Denmark"), - N_("Djibouti"), - N_("Dominica"), - N_("Dominican Republic"), - N_("Ecuador"), - N_("Egypt"), - N_("El Salvador"), - N_("Equatorial Guinea"), - N_("Eritrea"), - N_("Estonia"), - N_("Ethiopia"), - N_("Falkland Islands"), - N_("Faroe Islands"), - N_("Fiji"), - N_("Finland"), - N_("France"), - N_("French Guiana"), - N_("French Polynesia"), - N_("French Southern Territories"), - N_("Gabon"), - N_("Gambia"), - N_("Georgia"), - N_("Germany"), - N_("Ghana"), - N_("Gibraltar"), - N_("Greece"), - N_("Greenland"), - N_("Grenada"), - N_("Guadeloupe"), - N_("Guam"), - N_("Guatemala"), - N_("Guernsey"), - N_("Guinea"), - N_("Guinea-bissau"), - N_("Guyana"), - N_("Haiti"), - N_("Heard And McDonald Islands"), - N_("Holy See"), - N_("Honduras"), - N_("Hong Kong"), - N_("Hungary"), - N_("Iceland"), - N_("India"), - N_("Indonesia"), - N_("Iran"), - N_("Iraq"), - N_("Ireland"), - N_("Isle of Man"), - N_("Israel"), - N_("Italy"), - N_("Jamaica"), - N_("Japan"), - N_("Jersey"), - N_("Jordan"), - N_("Kazakhstan"), - N_("Kenya"), - N_("Kiribati"), - N_("Korea, Democratic People's Republic Of"), - N_("Korea, Republic Of"), - N_("Kuwait"), - N_("Kyrgyzstan"), - N_("Laos"), - N_("Latvia"), - N_("Lebanon"), - N_("Lesotho"), - N_("Liberia"), - N_("Libya"), - N_("Liechtenstein"), - N_("Lithuania"), - N_("Luxembourg"), - N_("Macao"), - N_("Macedonia"), - N_("Madagascar"), - N_("Malawi"), - N_("Malaysia"), - N_("Maldives"), - N_("Mali"), - N_("Malta"), - N_("Marshall Islands"), - N_("Martinique"), - N_("Mauritania"), - N_("Mauritius"), - N_("Mayotte"), - N_("Mexico"), - N_("Micronesia"), - N_("Moldova, Republic Of"), - N_("Monaco"), - N_("Mongolia"), - N_("Montserrat"), - N_("Morocco"), - N_("Mozambique"), - N_("Myanmar"), - N_("Namibia"), - N_("Nauru"), - N_("Nepal"), - N_("Netherlands"), - N_("Netherlands Antilles"), - N_("New Caledonia"), - N_("New Zealand"), - N_("Nicaragua"), - N_("Niger"), - N_("Nigeria"), - N_("Niue"), - N_("Norfolk Island"), - N_("Northern Mariana Islands"), - N_("Norway"), - N_("Oman"), - N_("Pakistan"), - N_("Palau"), - N_("Palestinian Territory"), - N_("Panama"), - N_("Papua New Guinea"), - N_("Paraguay"), - N_("Peru"), - N_("Philippines"), - N_("Pitcairn"), - N_("Poland"), - N_("Portugal"), - N_("Puerto Rico"), - N_("Qatar"), - N_("Reunion"), - N_("Romania"), - N_("Russian Federation"), - N_("Rwanda"), - N_("Saint Kitts And Nevis"), - N_("Saint Lucia"), - N_("Saint Vincent And The Grenadines"), - N_("Samoa"), - N_("San Marino"), - N_("Sao Tome And Principe"), - N_("Saudi Arabia"), - N_("Senegal"), - N_("Serbia And Montenegro"), - N_("Seychelles"), - N_("Sierra Leone"), - N_("Singapore"), - N_("Slovakia"), - N_("Slovenia"), - N_("Solomon Islands"), - N_("Somalia"), - N_("South Africa"), - N_("South Georgia And The South Sandwich Islands"), - N_("Spain"), - N_("Sri Lanka"), - N_("St. Helena"), - N_("St. Pierre And Miquelon"), - N_("Sudan"), - N_("Suriname"), - N_("Svalbard And Jan Mayen Islands"), - N_("Swaziland"), - N_("Sweden"), - N_("Switzerland"), - N_("Syria"), - N_("Taiwan"), - N_("Tajikistan"), - N_("Tanzania, United Republic Of"), - N_("Thailand"), - N_("Timor-Leste"), - N_("Togo"), - N_("Tokelau"), - N_("Tonga"), - N_("Trinidad And Tobago"), - N_("Tunisia"), - N_("Turkey"), - N_("Turkmenistan"), - N_("Turks And Caicos Islands"), - N_("Tuvalu"), - N_("Uganda"), - N_("Ukraine"), - N_("United Arab Emirates"), - N_("United Kingdom"), - N_("United States Minor Outlying Islands"), - N_("Uruguay"), - N_("Uzbekistan"), - N_("Vanuatu"), - N_("Venezuela"), - N_("Viet Nam"), - N_("Virgin Islands, British"), - N_("Virgin Islands, U.S."), - N_("Wallis And Futuna Islands"), - N_("Western Sahara"), - N_("Yemen"), - N_("Zambia"), - N_("Zimbabwe"), - NULL -}; - -static int -compare_func (const void *voida, const void *voidb) -{ - char * const *stringa = voida, * const *stringb = voidb; - - return strcoll (*stringa, *stringb); -} - -static void -fill_in_countries (GladeXML *gui) -{ - GtkCombo *combo; - combo = (GtkCombo *) glade_xml_get_widget(gui, "combo-country"); - if (combo && GTK_IS_COMBO (combo)) { - static gboolean sorted = FALSE; - static GList *country_list; - if (!sorted) { - int i; - char *locale; - - for (i = 0; countries[i]; i++) { - countries[i] = _(countries[i]); - } - - locale = setlocale (LC_COLLATE, NULL); - qsort (countries + 1, i - 1, sizeof (countries[0]), compare_func); - country_list = NULL; - for (i = 0; countries[i]; i++) { - country_list = g_list_prepend (country_list, countries[i]); - } - country_list = g_list_reverse (country_list); - sorted = TRUE; - } - gtk_combo_set_popdown_strings (combo, country_list); - } -} - -static void -e_contact_editor_address_init (EContactEditorAddress *e_contact_editor_address) -{ - GladeXML *gui; - GtkWidget *widget; - GList *icon_list; - - gtk_dialog_add_buttons (GTK_DIALOG (e_contact_editor_address), - GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, - GTK_STOCK_OK, GTK_RESPONSE_OK, - NULL); - - gtk_window_set_resizable(GTK_WINDOW(e_contact_editor_address), TRUE); - - e_contact_editor_address->address = NULL; - - gui = glade_xml_new (EVOLUTION_GLADEDIR "/fulladdr.glade", NULL, NULL); - e_contact_editor_address->gui = gui; - - setup_tab_order (gui); - fill_in_countries (gui); - - widget = glade_xml_get_widget(gui, "dialog-checkaddress"); - gtk_window_set_title (GTK_WINDOW (e_contact_editor_address), - GTK_WINDOW (widget)->title); - - widget = glade_xml_get_widget(gui, "table-checkaddress"); - g_object_ref(widget); - gtk_container_remove(GTK_CONTAINER(widget->parent), widget); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (e_contact_editor_address)->vbox), widget, TRUE, TRUE, 0); - g_object_unref(widget); - - icon_list = e_icon_factory_get_icon_list ("stock_contact"); - if (icon_list) { - gtk_window_set_icon_list (GTK_WINDOW (e_contact_editor_address), icon_list); - g_list_foreach (icon_list, (GFunc) g_object_unref, NULL); - g_list_free (icon_list); - } -} - -void -e_contact_editor_address_dispose (GObject *object) -{ - EContactEditorAddress *e_contact_editor_address = E_CONTACT_EDITOR_ADDRESS(object); - - if (e_contact_editor_address->gui) { - g_object_unref(e_contact_editor_address->gui); - e_contact_editor_address->gui = NULL; - } - - if (e_contact_editor_address->address) { - e_contact_address_free (e_contact_editor_address->address); - e_contact_editor_address->address = NULL; - } - - if (G_OBJECT_CLASS (parent_class)->dispose) - (* G_OBJECT_CLASS (parent_class)->dispose) (object); -} - -GtkWidget* -e_contact_editor_address_new (const EContactAddress *address) -{ - GtkWidget *widget = g_object_new (E_TYPE_CONTACT_EDITOR_ADDRESS, NULL); - - g_object_set (widget, - "address", address, - NULL); - - return widget; -} - -static void -e_contact_editor_address_set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec) -{ - EContactEditorAddress *e_contact_editor_address; - - e_contact_editor_address = E_CONTACT_EDITOR_ADDRESS (object); - - switch (prop_id){ - case PROP_ADDRESS: - if (e_contact_editor_address->address) - g_boxed_free (e_contact_address_get_type (), e_contact_editor_address->address); - - e_contact_editor_address->address = g_value_dup_boxed (value); - fill_in_info (e_contact_editor_address); - break; - case PROP_EDITABLE: { - int i; - char *widget_names[] = { - "entry-street", - "entry-city", - "entry-ext", - "entry-po", - "entry-region", - "combo-country", - "entry-code", - "label-street", - "label-city", - "label-ext", - "label-po", - "label-region", - "label-country", - "label-code", - NULL - }; - e_contact_editor_address->editable = g_value_get_boolean (value) ? TRUE : FALSE; - for (i = 0; widget_names[i] != NULL; i ++) { - GtkWidget *w = glade_xml_get_widget(e_contact_editor_address->gui, widget_names[i]); - if (GTK_IS_ENTRY (w)) { - gtk_editable_set_editable (GTK_EDITABLE (w), - e_contact_editor_address->editable); - } - else if (GTK_IS_COMBO (w)) { - gtk_editable_set_editable (GTK_EDITABLE (GTK_COMBO (w)->entry), - e_contact_editor_address->editable); - gtk_widget_set_sensitive (GTK_COMBO (w)->button, e_contact_editor_address->editable); - } - else if (GTK_IS_LABEL (w)) { - gtk_widget_set_sensitive (w, e_contact_editor_address->editable); - } - } - break; - } - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -e_contact_editor_address_get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec) -{ - EContactEditorAddress *e_contact_editor_address; - - e_contact_editor_address = E_CONTACT_EDITOR_ADDRESS (object); - - switch (prop_id) { - case PROP_ADDRESS: - extract_info (e_contact_editor_address); - g_value_set_static_boxed (value, e_contact_editor_address->address); - break; - case PROP_EDITABLE: - g_value_set_boolean (value, e_contact_editor_address->editable ? TRUE : FALSE); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -fill_in_field(EContactEditorAddress *editor, char *field, char *string) -{ - GtkEntry *entry = GTK_ENTRY(glade_xml_get_widget(editor->gui, field)); - if (entry) { - if (string) - gtk_entry_set_text(entry, string); - else - gtk_entry_set_text(entry, ""); - } -} - -static void -fill_in_info(EContactEditorAddress *editor) -{ - EContactAddress *address = editor->address; - - if (address) { - fill_in_field (editor, "entry-street" , address->street ); - fill_in_field (editor, "entry-po" , address->po ); - fill_in_field (editor, "entry-ext" , address->ext ); - fill_in_field (editor, "entry-city" , address->locality); - fill_in_field (editor, "entry-region" , address->region ); - fill_in_field (editor, "entry-code" , address->code ); - fill_in_field (editor, "entry-country", address->country ); - } -} - -static char * -extract_field(EContactEditorAddress *editor, char *field) -{ - GtkEntry *entry = GTK_ENTRY(glade_xml_get_widget(editor->gui, field)); - if (entry) - return g_strdup (gtk_entry_get_text(entry)); - else - return NULL; -} - -static void -extract_info(EContactEditorAddress *editor) -{ - EContactAddress *address = editor->address; - - if (address) { - g_boxed_free (e_contact_address_get_type (), address); - } - - address = g_new0 (EContactAddress, 1); - editor->address = address; - - address->street = extract_field(editor, "entry-street" ); - address->po = extract_field(editor, "entry-po" ); - address->ext = extract_field(editor, "entry-ext" ); - address->locality = extract_field(editor, "entry-city" ); - address->region = extract_field(editor, "entry-region" ); - address->code = extract_field(editor, "entry-code" ); - address->country = extract_field(editor, "entry-country"); -} diff --git a/addressbook/gui/contact-editor/e-contact-editor-address.h b/addressbook/gui/contact-editor/e-contact-editor-address.h deleted file mode 100644 index 30fefa0e56..0000000000 --- a/addressbook/gui/contact-editor/e-contact-editor-address.h +++ /dev/null @@ -1,71 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* e-contact-editor-address.h - * Copyright (C) 2000 Ximian, Inc. - * Author: Chris Lahey <clahey@ximian.com> - * - * This library 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 library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ -#ifndef __E_CONTACT_EDITOR_ADDRESS_H__ -#define __E_CONTACT_EDITOR_ADDRESS_H__ - -#include <gtk/gtkdialog.h> -#include <glade/glade.h> -#include <libebook/e-contact.h> - -G_BEGIN_DECLS - -/* EContactEditorAddress - A dialog displaying information about a contact. - * - * The following arguments are available: - * - * name type read/write description - * -------------------------------------------------------------------------------- - * name ECardName * RW The card currently being edited. Returns a copy. - */ - -#define E_TYPE_CONTACT_EDITOR_ADDRESS (e_contact_editor_address_get_type ()) -#define E_CONTACT_EDITOR_ADDRESS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_CONTACT_EDITOR_ADDRESS, EContactEditorAddress)) -#define E_CONTACT_EDITOR_ADDRESS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_CONTACT_EDITOR_ADDRESS, EContactEditorAddressClass)) -#define E_IS_CONTACT_EDITOR_ADDRESS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_CONTACT_EDITOR_ADDRESS)) -#define E_IS_CONTACT_EDITOR_ADDRESS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), E_TYPE_CONTACT_EDITOR_ADDRESS)) - - -typedef struct _EContactEditorAddress EContactEditorAddress; -typedef struct _EContactEditorAddressClass EContactEditorAddressClass; - -struct _EContactEditorAddress -{ - GtkDialog parent; - - /* item specific fields */ - EContactAddress *address; - - guint editable : 1; - - GladeXML *gui; -}; - -struct _EContactEditorAddressClass -{ - GtkDialogClass parent_class; -}; - - -GtkWidget *e_contact_editor_address_new (const EContactAddress *address); -GType e_contact_editor_address_get_type (void); - -G_END_DECLS - -#endif /* __E_CONTACT_EDITOR_ADDRESS_H__ */ diff --git a/addressbook/gui/contact-editor/e-contact-editor-fullname.c b/addressbook/gui/contact-editor/e-contact-editor-fullname.c deleted file mode 100644 index 1847a463f1..0000000000 --- a/addressbook/gui/contact-editor/e-contact-editor-fullname.c +++ /dev/null @@ -1,303 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * eab-contact-editor-phones.c - * Copyright (C) 2003 Ximian, Inc. - * Author: Chris Toshok <toshok@ximian.com> - * - * This library 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 library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include <config.h> -#include "e-contact-editor-fullname.h" -#include <e-util/e-icon-factory.h> -#include <libgnome/gnome-util.h> -#include <libgnome/gnome-i18n.h> -#include <gtk/gtkcombo.h> -#include <gtk/gtkstock.h> -#include <gtk/gtkentry.h> -#include <gtk/gtklabel.h> - -static void e_contact_editor_fullname_init (EContactEditorFullname *card); -static void e_contact_editor_fullname_class_init (EContactEditorFullnameClass *klass); -static void e_contact_editor_fullname_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec); -static void e_contact_editor_fullname_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); -static void e_contact_editor_fullname_dispose (GObject *object); - -static void fill_in_info(EContactEditorFullname *editor); -static void extract_info(EContactEditorFullname *editor); - -static GtkDialogClass *parent_class = NULL; - -/* The arguments we take */ -enum { - PROP_0, - PROP_NAME, - PROP_EDITABLE -}; - -GType -e_contact_editor_fullname_get_type (void) -{ - static GType contact_editor_fullname_type = 0; - - if (!contact_editor_fullname_type) { - static const GTypeInfo contact_editor_fullname_info = { - sizeof (EContactEditorFullnameClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) e_contact_editor_fullname_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (EContactEditorFullname), - 0, /* n_preallocs */ - (GInstanceInitFunc) e_contact_editor_fullname_init, - }; - - contact_editor_fullname_type = g_type_register_static (GTK_TYPE_DIALOG, "EContactEditorFullname", &contact_editor_fullname_info, 0); - } - - return contact_editor_fullname_type; -} - -static void -e_contact_editor_fullname_class_init (EContactEditorFullnameClass *klass) -{ - GObjectClass *object_class; - - object_class = G_OBJECT_CLASS (klass); - - parent_class = g_type_class_ref (GTK_TYPE_DIALOG); - - object_class->set_property = e_contact_editor_fullname_set_property; - object_class->get_property = e_contact_editor_fullname_get_property; - object_class->dispose = e_contact_editor_fullname_dispose; - - g_object_class_install_property (object_class, PROP_NAME, - g_param_spec_pointer ("name", - _("Name"), - /*_( */"XXX blurb" /*)*/, - G_PARAM_READWRITE)); - - g_object_class_install_property (object_class, PROP_EDITABLE, - g_param_spec_boolean ("editable", - _("Editable"), - /*_( */"XXX blurb" /*)*/, - FALSE, - G_PARAM_READWRITE)); -} - -static void -e_contact_editor_fullname_init (EContactEditorFullname *e_contact_editor_fullname) -{ - GladeXML *gui; - GtkWidget *widget; - GList *icon_list; - - gtk_widget_realize (GTK_WIDGET (e_contact_editor_fullname)); - gtk_dialog_set_has_separator (GTK_DIALOG (e_contact_editor_fullname), - FALSE); - gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (e_contact_editor_fullname)->vbox), 0); - gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (e_contact_editor_fullname)->action_area), 12); - - gtk_dialog_add_buttons (GTK_DIALOG (e_contact_editor_fullname), - GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, - GTK_STOCK_OK, GTK_RESPONSE_OK, - NULL); - - gtk_window_set_resizable(GTK_WINDOW(e_contact_editor_fullname), TRUE); - - e_contact_editor_fullname->name = NULL; - gui = glade_xml_new (EVOLUTION_GLADEDIR "/fullname.glade", NULL, NULL); - e_contact_editor_fullname->gui = gui; - - widget = glade_xml_get_widget(gui, "dialog-checkfullname"); - gtk_window_set_title (GTK_WINDOW (e_contact_editor_fullname), - GTK_WINDOW (widget)->title); - - widget = glade_xml_get_widget(gui, "table-checkfullname"); - g_object_ref(widget); - gtk_container_remove(GTK_CONTAINER(widget->parent), widget); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (e_contact_editor_fullname)->vbox), widget, TRUE, TRUE, 0); - g_object_unref(widget); - - icon_list = e_icon_factory_get_icon_list ("stock_contact"); - if (icon_list) { - gtk_window_set_icon_list (GTK_WINDOW (e_contact_editor_fullname), icon_list); - g_list_foreach (icon_list, (GFunc) g_object_unref, NULL); - g_list_free (icon_list); - } -} - -void -e_contact_editor_fullname_dispose (GObject *object) -{ - EContactEditorFullname *e_contact_editor_fullname = E_CONTACT_EDITOR_FULLNAME(object); - - if (e_contact_editor_fullname->gui) { - g_object_unref(e_contact_editor_fullname->gui); - e_contact_editor_fullname->gui = NULL; - } - - if (e_contact_editor_fullname->name) { - e_contact_name_free(e_contact_editor_fullname->name); - e_contact_editor_fullname->name = NULL; - } - - if (G_OBJECT_CLASS (parent_class)->dispose) - (* G_OBJECT_CLASS (parent_class)->dispose) (object); -} - -GtkWidget* -e_contact_editor_fullname_new (const EContactName *name) -{ - GtkWidget *widget = g_object_new (E_TYPE_CONTACT_EDITOR_FULLNAME, NULL); - - g_object_set (widget, - "name", name, - NULL); - return widget; -} - -static void -e_contact_editor_fullname_set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec) -{ - EContactEditorFullname *e_contact_editor_fullname; - - e_contact_editor_fullname = E_CONTACT_EDITOR_FULLNAME (object); - - switch (prop_id){ - case PROP_NAME: - e_contact_name_free(e_contact_editor_fullname->name); - - if (g_value_get_pointer (value) != NULL) { - e_contact_editor_fullname->name = e_contact_name_copy(g_value_get_pointer (value)); - fill_in_info(e_contact_editor_fullname); - } - else { - e_contact_editor_fullname->name = NULL; - } - break; - case PROP_EDITABLE: { - int i; - char *widget_names[] = { - "combo-title", - "combo-suffix", - "entry-first", - "entry-middle", - "entry-last", - "label-title", - "label-suffix", - "label-first", - "label-middle", - "label-last", - NULL - }; - e_contact_editor_fullname->editable = g_value_get_boolean (value) ? TRUE : FALSE; - for (i = 0; widget_names[i] != NULL; i ++) { - GtkWidget *w = glade_xml_get_widget(e_contact_editor_fullname->gui, widget_names[i]); - if (GTK_IS_ENTRY (w)) { - gtk_editable_set_editable (GTK_EDITABLE (w), - e_contact_editor_fullname->editable); - } - else if (GTK_IS_COMBO (w)) { - gtk_editable_set_editable (GTK_EDITABLE (GTK_COMBO (w)->entry), - e_contact_editor_fullname->editable); - gtk_widget_set_sensitive (GTK_COMBO (w)->button, e_contact_editor_fullname->editable); - } - else if (GTK_IS_LABEL (w)) { - gtk_widget_set_sensitive (w, e_contact_editor_fullname->editable); - } - } - break; - } - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -e_contact_editor_fullname_get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec) -{ - EContactEditorFullname *e_contact_editor_fullname; - - e_contact_editor_fullname = E_CONTACT_EDITOR_FULLNAME (object); - - switch (prop_id) { - case PROP_NAME: - extract_info(e_contact_editor_fullname); - g_value_set_pointer (value, e_contact_name_copy(e_contact_editor_fullname->name)); - break; - case PROP_EDITABLE: - g_value_set_boolean (value, e_contact_editor_fullname->editable ? TRUE : FALSE); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -fill_in_field(EContactEditorFullname *editor, char *field, char *string) -{ - GtkEntry *entry = GTK_ENTRY(glade_xml_get_widget(editor->gui, field)); - if (entry) { - if (string) - gtk_entry_set_text(entry, string); - else - gtk_entry_set_text(entry, ""); - } -} - -static void -fill_in_info(EContactEditorFullname *editor) -{ - EContactName *name = editor->name; - if (name) { - fill_in_field(editor, "entry-title", name->prefixes); - fill_in_field(editor, "entry-first", name->given); - fill_in_field(editor, "entry-middle", name->additional); - fill_in_field(editor, "entry-last", name->family); - fill_in_field(editor, "entry-suffix", name->suffixes); - } -} - -static char * -extract_field(EContactEditorFullname *editor, char *field) -{ - GtkEntry *entry = GTK_ENTRY(glade_xml_get_widget(editor->gui, field)); - if (entry) - return g_strdup (gtk_entry_get_text(entry)); - else - return NULL; -} - -static void -extract_info(EContactEditorFullname *editor) -{ - EContactName *name = editor->name; - if (!name) { - name = e_contact_name_new(); - editor->name = name; - } - - name->prefixes = extract_field(editor, "entry-title" ); - name->given = extract_field(editor, "entry-first" ); - name->additional = extract_field(editor, "entry-middle"); - name->family = extract_field(editor, "entry-last" ); - name->suffixes = extract_field(editor, "entry-suffix"); -} diff --git a/addressbook/gui/contact-editor/e-contact-editor-fullname.h b/addressbook/gui/contact-editor/e-contact-editor-fullname.h deleted file mode 100644 index 0b254c789c..0000000000 --- a/addressbook/gui/contact-editor/e-contact-editor-fullname.h +++ /dev/null @@ -1,71 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* e-contact-editor-fullname.h - * Copyright (C) 2000 Ximian, Inc. - * Author: Chris Lahey <clahey@ximian.com> - * - * This library 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 library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ -#ifndef __E_CONTACT_EDITOR_FULLNAME_H__ -#define __E_CONTACT_EDITOR_FULLNAME_H__ - -#include <gtk/gtkdialog.h> -#include <glade/glade.h> -#include <libebook/e-contact.h> - -G_BEGIN_DECLS - -/* EContactEditorFullname - A dialog displaying information about a contact. - * - * The following arguments are available: - * - * name type read/write description - * -------------------------------------------------------------------------------- - * name ECardName * RW The card currently being edited. Returns a copy. - */ - -#define E_TYPE_CONTACT_EDITOR_FULLNAME (e_contact_editor_fullname_get_type ()) -#define E_CONTACT_EDITOR_FULLNAME(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_CONTACT_EDITOR_FULLNAME, EContactEditorFullname)) -#define E_CONTACT_EDITOR_FULLNAME_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_CONTACT_EDITOR_FULLNAME, EContactEditorFullnameClass)) -#define E_IS_CONTACT_EDITOR_FULLNAME(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_CONTACT_EDITOR_FULLNAME)) -#define E_IS_CONTACT_EDITOR_FULLNAME_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), E_TYPE_CONTACT_EDITOR_FULLNAME)) - - -typedef struct _EContactEditorFullname EContactEditorFullname; -typedef struct _EContactEditorFullnameClass EContactEditorFullnameClass; - -struct _EContactEditorFullname -{ - GtkDialog parent; - - /* item specific fields */ - EContactName *name; - GladeXML *gui; - - /* Whether the dialog will accept modifications */ - guint editable : 1; -}; - -struct _EContactEditorFullnameClass -{ - GtkDialogClass parent_class; -}; - - -GtkWidget *e_contact_editor_fullname_new(const EContactName *name); -GType e_contact_editor_fullname_get_type (void); - -G_END_DECLS - -#endif /* __E_CONTACT_EDITOR_FULLNAME_H__ */ diff --git a/addressbook/gui/contact-editor/e-contact-editor-im.c b/addressbook/gui/contact-editor/e-contact-editor-im.c deleted file mode 100644 index b77fefd88b..0000000000 --- a/addressbook/gui/contact-editor/e-contact-editor-im.c +++ /dev/null @@ -1,490 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * e-contact-editor-im.c - * Copyright (C) 2003 Ximian, Inc. - * Author: Christian Hammond <chipx86@gnupdate.org> - * - * This library 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 library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include <config.h> -#include "e-contact-editor-im.h" -#include <libgnome/gnome-util.h> -#include <libgnome/gnome-i18n.h> -#include <gtk/gtkbox.h> -#include <gtk/gtkentry.h> -#include <gtk/gtkhbox.h> -#include <gtk/gtkimage.h> -#include <gtk/gtklabel.h> -#include <gtk/gtkmenuitem.h> -#include <gtk/gtkoptionmenu.h> -#include <gtk/gtksizegroup.h> -#include <gtk/gtkstock.h> -#include <string.h> -#include <e-util/e-icon-factory.h> - -static void e_contact_editor_im_init (EContactEditorIm *card); -static void e_contact_editor_im_class_init (EContactEditorImClass *klass); -static void e_contact_editor_im_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec); -static void e_contact_editor_im_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); -static void e_contact_editor_im_dispose (GObject *object); - -static void fill_in_info(EContactEditorIm *editor); -static void extract_info(EContactEditorIm *editor); - -static GtkDialogClass *parent_class = NULL; - -/* The arguments we take */ -enum { - PROP_0, - PROP_SERVICE, - PROP_LOCATION, - PROP_USERNAME, - PROP_EDITABLE -}; - -#define FIRST_IM_TYPE E_CONTACT_IM_AIM -#define LAST_IM_TYPE E_CONTACT_IM_ICQ - -static const char *im_labels[] = { - N_("AOL Instant Messenger"), - N_("Novell Groupwise"), - N_("Jabber"), - N_("Yahoo Messenger"), - N_("MSN Messenger"), - N_("ICQ") -}; - -static const char *im_images[] = { - "im-aim", - "im-nov", - "im-jabber", - "im-yahoo", - "im-msn", - "im-icq" -}; - -GType -e_contact_editor_im_get_type (void) -{ - static GType contact_editor_im_type = 0; - - if (!contact_editor_im_type) { - static const GTypeInfo contact_editor_im_info = { - sizeof (EContactEditorImClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) e_contact_editor_im_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (EContactEditorIm), - 0, /* n_preallocs */ - (GInstanceInitFunc) e_contact_editor_im_init, - }; - - contact_editor_im_type = g_type_register_static (GTK_TYPE_DIALOG, "EContactEditorIm", &contact_editor_im_info, 0); - } - - return contact_editor_im_type; -} - -static void -e_contact_editor_im_class_init (EContactEditorImClass *klass) -{ - GObjectClass *object_class; - - object_class = G_OBJECT_CLASS (klass); - - parent_class = g_type_class_ref (GTK_TYPE_DIALOG); - - object_class->set_property = e_contact_editor_im_set_property; - object_class->get_property = e_contact_editor_im_get_property; - object_class->dispose = e_contact_editor_im_dispose; - - g_object_class_install_property (object_class, PROP_SERVICE, - g_param_spec_int ("service", - _("Service"), - /*_( */"XXX blurb" /*)*/, - FIRST_IM_TYPE, - LAST_IM_TYPE, - FIRST_IM_TYPE, - G_PARAM_READWRITE)); - - g_object_class_install_property (object_class, PROP_LOCATION, - g_param_spec_string ("location", - _("Location"), - /*_( */"XXX blurb" /*)*/, - "HOME", - G_PARAM_READWRITE)); - - g_object_class_install_property (object_class, PROP_USERNAME, - g_param_spec_string ("username", - _("Username"), - /*_( */"XXX blurb" /*)*/, - NULL, - G_PARAM_READWRITE)); - - g_object_class_install_property (object_class, PROP_EDITABLE, - g_param_spec_boolean ("editable", - _("Editable"), - /*_( */"XXX blurb" /*)*/, - FALSE, - G_PARAM_READWRITE)); -} - -static void -service_changed_cb(GtkWidget *optmenu, EContactEditorIm *editor) -{ - editor->service = gtk_option_menu_get_history(GTK_OPTION_MENU(optmenu)) + FIRST_IM_TYPE; -} - -static void -location_changed_cb(GtkWidget *optmenu, EContactEditorIm *editor) -{ - int i = gtk_option_menu_get_history(GTK_OPTION_MENU(optmenu)); - - if (editor->location != NULL) - g_free(editor->location); - - if (i == 0) - editor->location = g_strdup("HOME"); - else if (i == 1) - editor->location = g_strdup("WORK"); - else - editor->location = NULL; -} - -static void -setup_service_optmenu(EContactEditorIm *editor) -{ - GtkWidget *optmenu; - GtkWidget *menu; - GtkWidget *hbox; - GtkWidget *item; - GtkWidget *label; - GtkWidget *image; - GdkPixbuf *pixbuf; - GtkSizeGroup *sg; - int i; - - optmenu = glade_xml_get_widget(editor->gui, "optmenu-service"); - g_signal_connect(G_OBJECT(optmenu), "changed", - G_CALLBACK(service_changed_cb), editor); - - menu = gtk_menu_new(); - gtk_option_menu_set_menu(GTK_OPTION_MENU(optmenu), menu); - gtk_widget_show(menu); - - sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); - - for (i = 0; i < G_N_ELEMENTS(im_labels); i++) { - item = gtk_menu_item_new(); - - hbox = gtk_hbox_new(FALSE, 4); - gtk_container_add(GTK_CONTAINER(item), hbox); - gtk_widget_show(hbox); - - pixbuf = e_icon_factory_get_icon (im_images[i], E_ICON_SIZE_MENU); - - if (pixbuf != NULL) { - image = gtk_image_new_from_pixbuf(pixbuf); - - g_object_unref(G_OBJECT(pixbuf)); - } - else - image = gtk_image_new(); - - gtk_size_group_add_widget(sg, image); - - gtk_box_pack_start(GTK_BOX(hbox), image, FALSE, FALSE, 0); - gtk_widget_show(image); - - label = gtk_label_new(im_labels[i]); - gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); - gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, 0); - gtk_widget_show(label); - - gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); - gtk_widget_show(item); - } -} - -static void -setup_location_optmenu(EContactEditorIm *editor) -{ - GtkWidget *item; - GtkWidget *optmenu; - GtkWidget *menu; - - optmenu = glade_xml_get_widget(editor->gui, "optmenu-location"); - - g_signal_connect(G_OBJECT(optmenu), "changed", - G_CALLBACK(location_changed_cb), editor); - - menu = gtk_menu_new(); - gtk_option_menu_set_menu(GTK_OPTION_MENU(optmenu), menu); - gtk_widget_show(menu); - - item = gtk_menu_item_new_with_label(_("Home")); - gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); - gtk_widget_show(item); - - item = gtk_menu_item_new_with_label(_("Work")); - gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); - gtk_widget_show(item); - - item = gtk_menu_item_new_with_label(_("Other")); - gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); - gtk_widget_show(item); -} - -static void -e_contact_editor_im_init (EContactEditorIm *e_contact_editor_im) -{ - GladeXML *gui; - GtkWidget *widget; - GList *icon_list; - - gtk_dialog_add_buttons (GTK_DIALOG (e_contact_editor_im), - GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, - GTK_STOCK_OK, GTK_RESPONSE_OK, - NULL); - gtk_dialog_set_has_separator (GTK_DIALOG (e_contact_editor_im), FALSE); - - gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (e_contact_editor_im)->action_area), 12); - gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (e_contact_editor_im)->vbox), 0); - - gtk_window_set_resizable(GTK_WINDOW(e_contact_editor_im), TRUE); - - e_contact_editor_im->service = FIRST_IM_TYPE; - e_contact_editor_im->location = g_strdup("HOME"); - e_contact_editor_im->username = NULL; - gui = glade_xml_new (EVOLUTION_GLADEDIR "/im.glade", NULL, NULL); - e_contact_editor_im->gui = gui; - - widget = glade_xml_get_widget(gui, "dialog-im"); - gtk_window_set_title (GTK_WINDOW (e_contact_editor_im), - GTK_WINDOW (widget)->title); - - widget = glade_xml_get_widget(gui, "table-im"); - g_object_ref(widget); - gtk_container_remove(GTK_CONTAINER(widget->parent), widget); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (e_contact_editor_im)->vbox), widget, TRUE, TRUE, 0); - g_object_unref(widget); - - setup_service_optmenu(e_contact_editor_im); - setup_location_optmenu(e_contact_editor_im); - - gtk_widget_grab_focus(glade_xml_get_widget(gui, "entry-username")); - - /* set the icon */ - icon_list = e_icon_factory_get_icon_list ("stock_contact"); - if (icon_list) { - gtk_window_set_icon_list (GTK_WINDOW (e_contact_editor_im), icon_list); - g_list_foreach (icon_list, (GFunc) g_object_unref, NULL); - g_list_free (icon_list); - } -} - -void -e_contact_editor_im_dispose (GObject *object) -{ - EContactEditorIm *e_contact_editor_im = E_CONTACT_EDITOR_IM(object); - - if (e_contact_editor_im->gui) { - g_object_unref(e_contact_editor_im->gui); - e_contact_editor_im->gui = NULL; - } - - if (e_contact_editor_im->location) { - g_free(e_contact_editor_im->location); - e_contact_editor_im->location = NULL; - } - - if (e_contact_editor_im->username) { - g_free(e_contact_editor_im->username); - e_contact_editor_im->username = NULL; - } - - if (G_OBJECT_CLASS (parent_class)->dispose) - (* G_OBJECT_CLASS (parent_class)->dispose) (object); -} - -GtkWidget* -e_contact_editor_im_new (EContactField service, const char *location, const char *username) -{ - GtkWidget *widget = g_object_new (E_TYPE_CONTACT_EDITOR_IM, NULL); - g_object_set (widget, - "service", GINT_TO_POINTER(service), - "location", location, - "username", username, - NULL); - return widget; -} - -static void -e_contact_editor_im_set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec) -{ - EContactEditorIm *e_contact_editor_im; - const char *str; - - e_contact_editor_im = E_CONTACT_EDITOR_IM (object); - - switch (prop_id){ - case PROP_SERVICE: - e_contact_editor_im->service = g_value_get_int(value); - fill_in_info(e_contact_editor_im); - break; - - case PROP_LOCATION: - if (e_contact_editor_im->location != NULL) - g_free(e_contact_editor_im->location); - - str = g_value_get_string(value); - - if (str == NULL) - e_contact_editor_im->location = NULL; - else if (!g_ascii_strcasecmp(str, "HOME")) - e_contact_editor_im->location = g_strdup("HOME"); - else if (!g_ascii_strcasecmp(str, "WORK")) - e_contact_editor_im->location = g_strdup("WORK"); - else - e_contact_editor_im->location = NULL; - - fill_in_info(e_contact_editor_im); - break; - - case PROP_USERNAME: - if (e_contact_editor_im->username != NULL) - g_free(e_contact_editor_im->username); - - e_contact_editor_im->username = g_strdup(g_value_get_string(value)); - fill_in_info(e_contact_editor_im); - break; - - case PROP_EDITABLE: { - int i; - char *widget_names[] = { - "optmenu-service", - "optmenu-location", - "entry-username", - "label-service", - "label-location", - "label-username", - NULL - }; - e_contact_editor_im->editable = g_value_get_boolean (value) ? TRUE : FALSE; - for (i = 0; widget_names[i] != NULL; i ++) { - GtkWidget *w = glade_xml_get_widget(e_contact_editor_im->gui, widget_names[i]); - if (GTK_IS_ENTRY (w)) { - gtk_editable_set_editable (GTK_EDITABLE (w), - e_contact_editor_im->editable); - } - else { - gtk_widget_set_sensitive (w, e_contact_editor_im->editable); - } - } - break; - } - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -e_contact_editor_im_get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec) -{ - EContactEditorIm *e_contact_editor_im; - - e_contact_editor_im = E_CONTACT_EDITOR_IM (object); - - switch (prop_id) { - case PROP_SERVICE: - g_value_set_int (value, e_contact_editor_im->service); - break; - case PROP_LOCATION: - g_value_set_string (value, e_contact_editor_im->location); - break; - case PROP_USERNAME: - extract_info(e_contact_editor_im); - g_value_set_string (value, e_contact_editor_im->username); - break; - case PROP_EDITABLE: - g_value_set_boolean (value, e_contact_editor_im->editable ? TRUE : FALSE); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -fill_in_field(EContactEditorIm *editor, char *field, char *string) -{ - GtkEntry *entry = GTK_ENTRY(glade_xml_get_widget(editor->gui, field)); - if (entry) { - if (string) - gtk_entry_set_text(entry, string); - else - gtk_entry_set_text(entry, ""); - } -} - -static void -fill_in_info(EContactEditorIm *editor) -{ - GtkWidget *optmenu; - - fill_in_field(editor, "entry-username", editor->username); - - optmenu = glade_xml_get_widget(editor->gui, "optmenu-service"); - - if (optmenu != NULL) - gtk_option_menu_set_history(GTK_OPTION_MENU(optmenu), editor->service - FIRST_IM_TYPE); - - optmenu = glade_xml_get_widget(editor->gui, "optmenu-location"); - - if (optmenu != NULL) - gtk_option_menu_set_history(GTK_OPTION_MENU(optmenu), - (editor->location == NULL ? 2 : - !strcmp(editor->location, "WORK") ? 1 : 0)); -} - -static char * -extract_field(EContactEditorIm *editor, char *field) -{ - GtkEntry *entry = GTK_ENTRY(glade_xml_get_widget(editor->gui, field)); - if (entry) - return g_strdup (gtk_entry_get_text(entry)); - else - return NULL; -} - -static void -extract_info(EContactEditorIm *editor) -{ - if (editor->username != NULL) - g_free(editor->username); - - editor->username = extract_field(editor, "entry-username"); - - /* - * NOTE: We don't need to handle the option menus. - * These are set by the callbacks. - */ -} diff --git a/addressbook/gui/contact-editor/e-contact-editor-im.h b/addressbook/gui/contact-editor/e-contact-editor-im.h deleted file mode 100644 index da5bd652b2..0000000000 --- a/addressbook/gui/contact-editor/e-contact-editor-im.h +++ /dev/null @@ -1,76 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* e-contact-editor-add-im.h - * Copyright (C) 2003 Ximian, Inc. - * Author: Christian Hammond <chipx86@gnupdate.org> - * - * This library 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 library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ -#ifndef __E_CONTACT_EDITOR_IM_H__ -#define __E_CONTACT_EDITOR_IM_H__ - -#include <gtk/gtkdialog.h> -#include <glade/glade.h> -#include <libebook/e-contact.h> - -G_BEGIN_DECLS - -/* EContactEditorIm - A dialog allowing the user to add an IM account to a contact. - * - * The following arguments are available: - * - * name type read/write description - * -------------------------------------------------------------------------------- - * service EContactField RW The field of the IM service. - * location char * RW The location type. - * username char * RW The username of the account. - */ - -#define E_TYPE_CONTACT_EDITOR_IM (e_contact_editor_im_get_type ()) -#define E_CONTACT_EDITOR_IM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_CONTACT_EDITOR_IM, EContactEditorIm)) -#define E_CONTACT_EDITOR_IM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_CONTACT_EDITOR_IM, EContactEditorImClass)) -#define E_IS_CONTACT_EDITOR_IM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_CONTACT_EDITOR_IM)) -#define E_IS_CONTACT_EDITOR_IM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), E_TYPE_CONTACT_EDITOR_IM)) - - -typedef struct _EContactEditorIm EContactEditorIm; -typedef struct _EContactEditorImClass EContactEditorImClass; - -struct _EContactEditorIm -{ - GtkDialog parent; - - /* item specific fields */ - EContactField service; - char *location; - char *username; - GladeXML *gui; - - /* Whether the dialog will accept modifications */ - guint editable : 1; -}; - -struct _EContactEditorImClass -{ - GtkDialogClass parent_class; -}; - - -GtkWidget *e_contact_editor_im_new(EContactField service, const char *location, const char *username); -GType e_contact_editor_im_get_type (void); - -G_END_DECLS - -#endif /* __E_CONTACT_EDITOR_IM_H__ */ - diff --git a/addressbook/gui/contact-editor/e-contact-editor-marshal.list b/addressbook/gui/contact-editor/e-contact-editor-marshal.list deleted file mode 100644 index 58b2640de5..0000000000 --- a/addressbook/gui/contact-editor/e-contact-editor-marshal.list +++ /dev/null @@ -1,2 +0,0 @@ -NONE:INT,OBJECT -NONE:NONE diff --git a/addressbook/gui/contact-editor/e-contact-editor.c b/addressbook/gui/contact-editor/e-contact-editor.c deleted file mode 100644 index c21e78c6a2..0000000000 --- a/addressbook/gui/contact-editor/e-contact-editor.c +++ /dev/null @@ -1,3397 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * e-contact-editor.c - * Copyright (C) 2000 Ximian, Inc. - * Author: Chris Lahey <clahey@ximian.com> - * - * This library 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 library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include <config.h> - -#include "eab-editor.h" -#include "e-contact-editor.h" - -#include <string.h> -#include <time.h> -#include <gtk/gtkcheckbutton.h> -#include <gtk/gtkcheckmenuitem.h> -#include <gtk/gtkcombo.h> -#include <gtk/gtktextview.h> -#include <gtk/gtkmessagedialog.h> -#include <gtk/gtkstock.h> -#include <gtk/gtkentry.h> -#include <gtk/gtklabel.h> -#include <libgnomeui/gnome-window-icon.h> -#include <libgnome/gnome-util.h> -#include <libgnome/gnome-i18n.h> -#include <libgnome/gnome-help.h> - -#include <gdk-pixbuf/gdk-pixbuf.h> -#include <gal/widgets/e-categories.h> -#include <gal/widgets/e-gui-utils.h> -#include <gal/e-text/e-entry.h> - -#include <libebook/e-address-western.h> -#include <libedataserverui/e-source-option-menu.h> - -#include <e-util/e-categories-master-list-wombat.h> - -#include <camel/camel.h> - -#include "addressbook/gui/component/addressbook.h" -#include "addressbook/printing/e-contact-print.h" -#include "addressbook/printing/e-contact-print-envelope.h" -#include "addressbook/gui/widgets/eab-gui-util.h" -#include "e-util/e-gui-utils.h" -#include "widgets/misc/e-error.h" -#include "widgets/misc/e-dateedit.h" -#include "widgets/misc/e-image-chooser.h" -#include "widgets/misc/e-url-entry.h" -#include "shell/evolution-shell-component-utils.h" -#include "e-util/e-icon-factory.h" - -#include "eab-contact-merging.h" - -#include "e-contact-editor-address.h" -#include "e-contact-editor-im.h" -#include "e-contact-editor-fullname.h" -#include "e-contact-editor-marshal.h" - -#define EMAIL_SLOTS 4 -#define PHONE_SLOTS 8 -#define IM_SLOTS 4 -#define ADDRESS_SLOTS 3 - -#define EVOLUTION_UI_SLOT_PARAM "X-EVOLUTION-UI-SLOT" - -/* IM columns */ -enum { - COLUMN_IM_ICON, - COLUMN_IM_SERVICE, - COLUMN_IM_SCREENNAME, - COLUMN_IM_LOCATION, - COLUMN_IM_LOCATION_TYPE, - COLUMN_IM_SERVICE_FIELD, - NUM_IM_COLUMNS -}; - - -static void e_contact_editor_init (EContactEditor *editor); -static void e_contact_editor_class_init (EContactEditorClass *klass); -static void e_contact_editor_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec); -static void e_contact_editor_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); -static void e_contact_editor_dispose (GObject *object); - -static void e_contact_editor_raise (EABEditor *editor); -static void e_contact_editor_show (EABEditor *editor); -static void e_contact_editor_save_contact (EABEditor *editor, gboolean should_close); -static void e_contact_editor_close (EABEditor *editor); -static gboolean e_contact_editor_is_valid (EABEditor *editor); -static gboolean e_contact_editor_is_changed (EABEditor *editor); -static GtkWindow* e_contact_editor_get_window (EABEditor *editor); - -static void save_contact (EContactEditor *ce, gboolean should_close); -static void entry_activated (EContactEditor *editor); - -static void set_entry_text(EContactEditor *editor, GtkEntry *entry, const char *string); - -static EABEditorClass *parent_class = NULL; - -/* The arguments we take */ -enum { - PROP_0, - PROP_SOURCE_BOOK, - PROP_TARGET_BOOK, - PROP_CONTACT, - PROP_IS_NEW_CONTACT, - PROP_EDITABLE, - PROP_CHANGED, - PROP_WRITABLE_FIELDS -}; - -enum { - DYNAMIC_LIST_EMAIL, - DYNAMIC_LIST_PHONE, - DYNAMIC_LIST_ADDRESS -}; - -static struct { - EContactField field_id; - const gchar *type_1; - const gchar *type_2; -} -phones [] = { - { E_CONTACT_PHONE_ASSISTANT, EVC_X_ASSISTANT, NULL }, - { E_CONTACT_PHONE_BUSINESS, "WORK", "VOICE" }, - { E_CONTACT_PHONE_BUSINESS_FAX, "WORK", "FAX" }, - { E_CONTACT_PHONE_CALLBACK, EVC_X_CALLBACK, NULL }, - { E_CONTACT_PHONE_CAR, "CAR", NULL }, - { E_CONTACT_PHONE_COMPANY, "X-EVOLUTION-COMPANY", NULL }, - { E_CONTACT_PHONE_HOME, "HOME", "VOICE" }, - { E_CONTACT_PHONE_HOME_FAX, "HOME", "FAX" }, - { E_CONTACT_PHONE_ISDN, "ISDN", NULL }, - { E_CONTACT_PHONE_MOBILE, "CELL", NULL }, - { E_CONTACT_PHONE_OTHER, "VOICE", NULL }, - { E_CONTACT_PHONE_OTHER_FAX, "FAX", NULL }, - { E_CONTACT_PHONE_PAGER, "PAGER", NULL }, - { E_CONTACT_PHONE_PRIMARY, "PREF", NULL }, - { E_CONTACT_PHONE_RADIO, EVC_X_RADIO, NULL }, - { E_CONTACT_PHONE_TELEX, EVC_X_TELEX, NULL }, - { E_CONTACT_PHONE_TTYTDD, EVC_X_TTYTDD, NULL } -}; - -/* Defaults from the table above */ -gint phones_default [] = { 1, 6, 9, 2, 7, 12, 10, 10 }; - -static EContactField addresses [] = { - E_CONTACT_ADDRESS_WORK, - E_CONTACT_ADDRESS_HOME, - E_CONTACT_ADDRESS_OTHER -}; - -static EContactField address_labels [] = { - E_CONTACT_ADDRESS_LABEL_WORK, - E_CONTACT_ADDRESS_LABEL_HOME, - E_CONTACT_ADDRESS_LABEL_OTHER -}; - -static gchar *address_name [] = { - "work", - "home", - "other" -}; - -static struct { - EContactField field; - gchar *pretty_name; -} -im_service [] = -{ - { E_CONTACT_IM_AIM, N_ ("AIM") }, - { E_CONTACT_IM_JABBER, N_ ("Jabber") }, - { E_CONTACT_IM_YAHOO, N_ ("Yahoo") }, - { E_CONTACT_IM_MSN, N_ ("MSN") }, - { E_CONTACT_IM_ICQ, N_ ("ICQ") }, - { E_CONTACT_IM_GROUPWISE, N_ ("GroupWise") } -}; - -/* Defaults from the table above */ -gint im_service_default [] = { 0, 2, 4, 5 }; - -static struct { - gchar *name; - gchar *pretty_name; -} -common_location [] = -{ - { "WORK", N_ ("Work") }, - { "HOME", N_ ("Home") }, - { "OTHER", N_ ("Other") } -}; - -/* Default from the table above */ -gint email_default [] = { 0, 1, 2, 2 }; - -#define STRING_IS_EMPTY(x) (!(x) || !(*(x))) -#define STRING_MAKE_NON_NULL(x) ((x) ? (x) : "") - -GType -e_contact_editor_get_type (void) -{ - static GType contact_editor_type = 0; - - if (!contact_editor_type) { - static const GTypeInfo contact_editor_info = { - sizeof (EContactEditorClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) e_contact_editor_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (EContactEditor), - 0, /* n_preallocs */ - (GInstanceInitFunc) e_contact_editor_init, - }; - - contact_editor_type = g_type_register_static (EAB_TYPE_EDITOR, "EContactEditor", &contact_editor_info, 0); - } - - return contact_editor_type; -} - -static void -e_contact_editor_class_init (EContactEditorClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - EABEditorClass *editor_class = EAB_EDITOR_CLASS (klass); - - parent_class = g_type_class_ref (EAB_TYPE_EDITOR); - - object_class->set_property = e_contact_editor_set_property; - object_class->get_property = e_contact_editor_get_property; - object_class->dispose = e_contact_editor_dispose; - - editor_class->raise = e_contact_editor_raise; - editor_class->show = e_contact_editor_show; - editor_class->close = e_contact_editor_close; - editor_class->is_valid = e_contact_editor_is_valid; - editor_class->save_contact = e_contact_editor_save_contact; - editor_class->is_changed = e_contact_editor_is_changed; - editor_class->get_window = e_contact_editor_get_window; - - g_object_class_install_property (object_class, PROP_SOURCE_BOOK, - g_param_spec_object ("source_book", - _("Source Book"), - /*_( */"XXX blurb" /*)*/, - E_TYPE_BOOK, - G_PARAM_READWRITE)); - - g_object_class_install_property (object_class, PROP_TARGET_BOOK, - g_param_spec_object ("target_book", - _("Target Book"), - /*_( */"XXX blurb" /*)*/, - E_TYPE_BOOK, - G_PARAM_READWRITE)); - - g_object_class_install_property (object_class, PROP_CONTACT, - g_param_spec_object ("contact", - _("Contact"), - /*_( */"XXX blurb" /*)*/, - E_TYPE_CONTACT, - G_PARAM_READWRITE)); - - g_object_class_install_property (object_class, PROP_IS_NEW_CONTACT, - g_param_spec_boolean ("is_new_contact", - _("Is New Contact"), - /*_( */"XXX blurb" /*)*/, - FALSE, - G_PARAM_READWRITE)); - - g_object_class_install_property (object_class, PROP_WRITABLE_FIELDS, - g_param_spec_object ("writable_fields", - _("Writable Fields"), - /*_( */"XXX blurb" /*)*/, - E_TYPE_LIST, - G_PARAM_READWRITE)); - - g_object_class_install_property (object_class, PROP_EDITABLE, - g_param_spec_boolean ("editable", - _("Editable"), - /*_( */"XXX blurb" /*)*/, - FALSE, - G_PARAM_READWRITE)); - - g_object_class_install_property (object_class, PROP_CHANGED, - g_param_spec_boolean ("changed", - _("Changed"), - /*_( */"XXX blurb" /*)*/, - FALSE, - G_PARAM_READWRITE)); -} - -static void -entry_activated (EContactEditor *editor) -{ - save_contact (editor, TRUE); -} - -/* FIXME: Linear time... */ -static gboolean -is_field_supported (EContactEditor *editor, EContactField field_id) -{ - EList *fields; - const gchar *field; - EIterator *iter; - - fields = editor->writable_fields; - if (!fields) - return FALSE; - - field = e_contact_field_name (field_id); - if (!field) - return FALSE; - - for (iter = e_list_get_iterator (fields); - e_iterator_is_valid (iter); - e_iterator_next (iter)) { - const gchar *this_field = e_iterator_get (iter); - - if (!this_field) - continue; - - if (!strcmp (field, this_field)) - return TRUE; - } - - return FALSE; -} - -/* This function tells you whether name_to_style will make sense. */ -static gboolean -style_makes_sense (const EContactName *name, const gchar *company, int style) -{ - switch (style) { - case 0: /* Fall Through */ - case 1: - return TRUE; - case 2: - if (company && *company) - return TRUE; - else - return FALSE; - case 3: /* Fall Through */ - case 4: - if (company && *company && name && ((name->given && *name->given) || (name->family && *name->family))) - return TRUE; - else - return FALSE; - default: - return FALSE; - } -} - -static char * -name_to_style (const EContactName *name, const gchar *company, int style) -{ - char *string; - char *strings[4], **stringptr; - char *substring; - switch (style) { - case 0: - stringptr = strings; - if (name) { - if (name->family && *name->family) - *(stringptr++) = name->family; - if (name->given && *name->given) - *(stringptr++) = name->given; - } - *stringptr = NULL; - string = g_strjoinv(", ", strings); - break; - case 1: - stringptr = strings; - if (name) { - if (name->given && *name->given) - *(stringptr++) = name->given; - if (name->family && *name->family) - *(stringptr++) = name->family; - } - *stringptr = NULL; - string = g_strjoinv(" ", strings); - break; - case 2: - string = g_strdup(company); - break; - case 3: /* Fall Through */ - case 4: - stringptr = strings; - if (name) { - if (name->family && *name->family) - *(stringptr++) = name->family; - if (name->given && *name->given) - *(stringptr++) = name->given; - } - *stringptr = NULL; - substring = g_strjoinv(", ", strings); - if (!(company && *company)) - company = ""; - if (style == 3) - string = g_strdup_printf("%s (%s)", substring, company); - else - string = g_strdup_printf("%s (%s)", company, substring); - g_free(substring); - break; - default: - string = g_strdup(""); - } - return string; -} - -static int -file_as_get_style (EContactEditor *editor) -{ - GtkEntry *file_as = GTK_ENTRY(glade_xml_get_widget(editor->gui, "entry-file-as")); - GtkEntry *company_w = GTK_ENTRY (glade_xml_get_widget (editor->gui, "entry-company")); - char *filestring; - char *trystring; - EContactName *name = editor->name; - const gchar *company; - int i; - int style; - - if (!(file_as && GTK_IS_ENTRY(file_as))) - return -1; - - company = gtk_entry_get_text (GTK_ENTRY (company_w)); - filestring = g_strdup (gtk_entry_get_text (file_as)); - - style = -1; - for (i = 0; i < 5; i++) { - trystring = name_to_style (name, company, i); - if (!strcmp(trystring, filestring)) { - g_free(trystring); - g_free(filestring); - return i; - } - g_free(trystring); - } - g_free (filestring); - return -1; -} - -static void -file_as_set_style (EContactEditor *editor, int style) -{ - char *string; - int i; - GList *strings = NULL; - GtkEntry *file_as = GTK_ENTRY (glade_xml_get_widget (editor->gui, "entry-file-as")); - GtkEntry *company_w = GTK_ENTRY (glade_xml_get_widget (editor->gui, "entry-company")); - GtkWidget *widget; - const gchar *company; - - if (!(file_as && GTK_IS_ENTRY (file_as))) - return; - - company = gtk_entry_get_text (GTK_ENTRY (company_w)); - - if (style == -1) { - string = g_strdup (gtk_entry_get_text(file_as)); - strings = g_list_append (strings, string); - } - - widget = glade_xml_get_widget (editor->gui, "combo-file-as"); - - for (i = 0; i < 5; i++) { - if (style_makes_sense (editor->name, company, i)) { - char *u; - u = name_to_style (editor->name, company, i); - if (!STRING_IS_EMPTY (u)) - strings = g_list_append (strings, u); - else - g_free (u); - } - } - - if (widget && GTK_IS_COMBO (widget)) { - GtkCombo *combo = GTK_COMBO (widget); - gtk_combo_set_popdown_strings (combo, strings); - g_list_foreach (strings, (GFunc) g_free, NULL); - g_list_free (strings); - } - - if (style != -1) { - string = name_to_style (editor->name, company, style); - set_entry_text (editor, file_as, string); - g_free (string); - } -} - -static void -name_entry_changed (GtkWidget *widget, EContactEditor *editor) -{ - int style = 0; - const char *string; - - style = file_as_get_style (editor); - e_contact_name_free (editor->name); - string = gtk_entry_get_text (GTK_ENTRY (widget)); - editor->name = e_contact_name_from_string (string); - file_as_set_style (editor, style); -} - -static void -file_as_entry_changed (GtkWidget *widget, EContactEditor *editor) -{ - char *string = gtk_editable_get_chars (GTK_EDITABLE (widget), 0, -1); - char *title; - - if (string && *string) - title = string; - else - title = _("Contact Editor"); - - gtk_window_set_title (GTK_WINDOW (editor->app), title); - g_free (string); -} - -static void -company_entry_changed (GtkWidget *widget, EContactEditor *editor) -{ - int style = 0; - - style = file_as_get_style (editor); - file_as_set_style (editor, style); -} - -static void -update_file_as_combo (EContactEditor *editor) -{ - file_as_set_style (editor, file_as_get_style (editor)); -} - -static void -fill_in_source_field (EContactEditor *editor) -{ - GtkWidget *source_menu; - ESource *source; - - if (!editor->target_book) - return; - - source_menu = glade_xml_get_widget (editor->gui, "source-option-menu-source"); - source = e_book_get_source (editor->target_book); - - e_source_option_menu_select (E_SOURCE_OPTION_MENU (source_menu), source); -} - -static void -sensitize_ok (EContactEditor *ce) -{ - GtkWidget *widget; - gboolean allow_save; - - allow_save = ce->target_editable && ce->changed ? TRUE : FALSE; - - widget = glade_xml_get_widget (ce->gui, "button-ok"); - gtk_widget_set_sensitive (widget, allow_save); -} - -static void -object_changed (GObject *object, EContactEditor *editor) -{ - if (!editor->target_editable) { - g_warning ("non-editable contact editor has an editable field in it."); - return; - } - - if (!editor->changed) { - editor->changed = TRUE; - sensitize_ok (editor); - } -} - -static void -image_chooser_changed (GtkWidget *widget, EContactEditor *editor) -{ - editor->image_set = TRUE; -} - -static void -set_entry_text (EContactEditor *editor, GtkEntry *entry, const gchar *string) -{ - const char *oldstring = gtk_entry_get_text (entry); - - if (!string) - string = ""; - - if (strcmp (string, oldstring)) { - g_signal_handlers_block_matched (entry, G_SIGNAL_MATCH_DATA, - 0, 0, NULL, NULL, editor); - gtk_entry_set_text (entry, string); - g_signal_handlers_unblock_matched (entry, G_SIGNAL_MATCH_DATA, - 0, 0, NULL, NULL, editor); - } -} - -static void -set_option_menu_history (EContactEditor *editor, GtkOptionMenu *option_menu, gint history) -{ - g_signal_handlers_block_matched (option_menu, G_SIGNAL_MATCH_DATA, - 0, 0, NULL, NULL, editor); - gtk_option_menu_set_history (option_menu, history); - g_signal_handlers_unblock_matched (option_menu, G_SIGNAL_MATCH_DATA, - 0, 0, NULL, NULL, editor); -} - -static void -init_email_record_location (EContactEditor *editor, gint record) -{ - GtkWidget *location_option_menu; - GtkWidget *location_menu; - GtkWidget *email_entry; - gchar *widget_name; - gint i; - - widget_name = g_strdup_printf ("entry-email-%d", record); - email_entry = glade_xml_get_widget (editor->gui, widget_name); - g_free (widget_name); - - widget_name = g_strdup_printf ("optionmenu-email-%d", record); - location_option_menu = glade_xml_get_widget (editor->gui, widget_name); - g_free (widget_name); - - location_menu = gtk_menu_new (); - - for (i = 0; i < G_N_ELEMENTS (common_location); i++) { - GtkWidget *item; - - item = gtk_menu_item_new_with_label (common_location [i].pretty_name); - gtk_menu_shell_append (GTK_MENU_SHELL (location_menu), item); - } - - gtk_widget_show_all (location_menu); - gtk_option_menu_set_menu (GTK_OPTION_MENU (location_option_menu), location_menu); - - g_signal_connect (location_option_menu, "changed", G_CALLBACK (object_changed), editor); - g_signal_connect (email_entry, "changed", G_CALLBACK (object_changed), editor); - g_signal_connect_swapped (email_entry, "activate", G_CALLBACK (entry_activated), editor); -} - -static void -init_email (EContactEditor *editor) -{ - gint i; - - for (i = 1; i <= EMAIL_SLOTS; i++) - init_email_record_location (editor, i); -} - -static void -fill_in_email_record (EContactEditor *editor, gint record, const gchar *address, gint location) -{ - GtkWidget *location_option_menu; - GtkWidget *email_entry; - gchar *widget_name; - - widget_name = g_strdup_printf ("optionmenu-email-%d", record); - location_option_menu = glade_xml_get_widget (editor->gui, widget_name); - g_free (widget_name); - - widget_name = g_strdup_printf ("entry-email-%d", record); - email_entry = glade_xml_get_widget (editor->gui, widget_name); - g_free (widget_name); - - set_option_menu_history (editor, GTK_OPTION_MENU (location_option_menu), - location >= 0 ? location : email_default [record - 1]); - set_entry_text (editor, GTK_ENTRY (email_entry), address ? address : ""); -} - -static void -extract_email_record (EContactEditor *editor, gint record, gchar **address, gint *location) -{ - GtkWidget *location_option_menu; - GtkWidget *email_entry; - gchar *widget_name; - - widget_name = g_strdup_printf ("optionmenu-email-%d", record); - location_option_menu = glade_xml_get_widget (editor->gui, widget_name); - g_free (widget_name); - - widget_name = g_strdup_printf ("entry-email-%d", record); - email_entry = glade_xml_get_widget (editor->gui, widget_name); - g_free (widget_name); - - *address = g_strdup (gtk_entry_get_text (GTK_ENTRY (email_entry))); - *location = gtk_option_menu_get_history (GTK_OPTION_MENU (location_option_menu)); -} - -static const gchar * -email_index_to_location (gint index) -{ - return common_location [index].name; -} - -static const gchar * -im_index_to_location (gint index) -{ - return common_location [index].name; -} - -static void -phone_index_to_type (gint index, const gchar **type_1, const gchar **type_2) -{ - *type_1 = phones [index].type_1; - *type_2 = phones [index].type_2; -} - -static gint -get_email_location (EVCardAttribute *attr) -{ - gint i; - - for (i = 0; i < G_N_ELEMENTS (common_location); i++) { - if (e_vcard_attribute_has_type (attr, common_location [i].name)) - return i; - } - - return -1; -} - -static gint -get_im_location (EVCardAttribute *attr) -{ - gint i; - - for (i = 0; i < G_N_ELEMENTS (common_location); i++) { - if (e_vcard_attribute_has_type (attr, common_location [i].name)) - return i; - } - - return -1; -} - -static gint -get_phone_type (EVCardAttribute *attr) -{ - gint i; - - for (i = 0; i < G_N_ELEMENTS (phones); i++) { - if (e_vcard_attribute_has_type (attr, phones [i].type_1) && - (phones [i].type_2 == NULL || e_vcard_attribute_has_type (attr, phones [i].type_2))) - return i; - } - - return -1; -} - -static EVCardAttributeParam * -get_ui_slot_param (EVCardAttribute *attr) -{ - EVCardAttributeParam *param = NULL; - GList *param_list; - GList *l; - - param_list = e_vcard_attribute_get_params (attr); - - for (l = param_list; l; l = g_list_next (l)) { - const gchar *str; - - param = l->data; - - str = e_vcard_attribute_param_get_name (param); - if (!strcasecmp (str, EVOLUTION_UI_SLOT_PARAM)) - break; - - param = NULL; - } - - return param; -} - -static gint -get_ui_slot (EVCardAttribute *attr) -{ - EVCardAttributeParam *param; - gint slot = -1; - - param = get_ui_slot_param (attr); - - if (param) { - GList *value_list; - - value_list = e_vcard_attribute_param_get_values (param); - slot = atoi (value_list->data); - } - - return slot; -} - -static void -set_ui_slot (EVCardAttribute *attr, gint slot) -{ - EVCardAttributeParam *param; - gchar *slot_str; - - param = get_ui_slot_param (attr); - if (!param) { - param = e_vcard_attribute_param_new (EVOLUTION_UI_SLOT_PARAM); - e_vcard_attribute_add_param (attr, param); - } - - e_vcard_attribute_param_remove_values (param); - - slot_str = g_strdup_printf ("%d", slot); - e_vcard_attribute_param_add_value (param, slot_str); - g_free (slot_str); -} - -static gint -alloc_ui_slot (EContactEditor *editor, const gchar *widget_base, gint preferred_slot, gint num_slots) -{ - gchar *widget_name; - GtkWidget *widget; - const gchar *entry_contents; - gint i; - - /* See if we can get the preferred slot */ - - if (preferred_slot >= 1) { - widget_name = g_strdup_printf ("%s-%d", widget_base, preferred_slot); - widget = glade_xml_get_widget (editor->gui, widget_name); - entry_contents = gtk_entry_get_text (GTK_ENTRY (widget)); - g_free (widget_name); - - if (STRING_IS_EMPTY (entry_contents)) - return preferred_slot; - } - - /* Find first empty slot */ - - for (i = 1; i <= num_slots; i++) { - widget_name = g_strdup_printf ("%s-%d", widget_base, i); - widget = glade_xml_get_widget (editor->gui, widget_name); - entry_contents = gtk_entry_get_text (GTK_ENTRY (widget)); - g_free (widget_name); - - if (STRING_IS_EMPTY (entry_contents)) - return i; - } - - return -1; -} - -static void -free_attr_list (GList *attr_list) -{ - GList *l; - - for (l = attr_list; l; l = g_list_next (l)) { - EVCardAttribute *attr = l->data; - e_vcard_attribute_free (attr); - } - - g_list_free (attr_list); -} - -static void -fill_in_email (EContactEditor *editor) -{ - GList *email_attr_list; - GList *l; - gint record_n; - - /* Clear */ - - for (record_n = 1; record_n <= EMAIL_SLOTS; record_n++) { - fill_in_email_record (editor, record_n, NULL, -1); - } - - /* Fill in */ - - email_attr_list = e_contact_get_attributes (editor->contact, E_CONTACT_EMAIL); - - for (record_n = 1, l = email_attr_list; l && record_n <= EMAIL_SLOTS; l = g_list_next (l)) { - EVCardAttribute *attr = l->data; - gchar *email_address; - gint slot; - - email_address = e_vcard_attribute_get_value (attr); - slot = alloc_ui_slot (editor, "entry-email", get_ui_slot (attr), EMAIL_SLOTS); - if (slot < 1) - break; - - fill_in_email_record (editor, slot, email_address, - get_email_location (attr)); - - record_n++; - } -} - -static void -extract_email (EContactEditor *editor) -{ - GList *attr_list = NULL; - GList *old_attr_list; - GList *l, *l_next; - gint i; - - for (i = 1; i <= EMAIL_SLOTS; i++) { - gchar *address; - gint location; - - extract_email_record (editor, i, &address, &location); - - if (!STRING_IS_EMPTY (address)) { - EVCardAttribute *attr; - attr = e_vcard_attribute_new ("", e_contact_vcard_attribute (E_CONTACT_EMAIL)); - - if (location >= 0) - e_vcard_attribute_add_param_with_value (attr, - e_vcard_attribute_param_new (EVC_TYPE), - email_index_to_location (location)); - - e_vcard_attribute_add_value (attr, address); - set_ui_slot (attr, i); - - attr_list = g_list_append (attr_list, attr); - } - - g_free (address); - } - - /* Splice in the old attributes, minus the EMAIL_SLOTS first */ - - old_attr_list = e_contact_get_attributes (editor->contact, E_CONTACT_EMAIL); - for (l = old_attr_list, i = 1; l && i <= EMAIL_SLOTS; l = l_next, i++) { - l_next = g_list_next (l); - - e_vcard_attribute_free (l->data); - g_list_delete_link (l, l); - } - - old_attr_list = l; - attr_list = g_list_concat (attr_list, old_attr_list); - - e_contact_set_attributes (editor->contact, E_CONTACT_EMAIL, attr_list); - - free_attr_list (attr_list); -} - -static void -sensitize_email_record (EContactEditor *editor, gint record, gboolean enabled) -{ - GtkWidget *location_option_menu; - GtkWidget *email_entry; - gchar *widget_name; - - widget_name = g_strdup_printf ("optionmenu-email-%d", record); - location_option_menu = glade_xml_get_widget (editor->gui, widget_name); - g_free (widget_name); - - widget_name = g_strdup_printf ("entry-email-%d", record); - email_entry = glade_xml_get_widget (editor->gui, widget_name); - g_free (widget_name); - - gtk_widget_set_sensitive (location_option_menu, enabled); - gtk_editable_set_editable (GTK_EDITABLE (email_entry), enabled); -} - -static void -sensitize_email (EContactEditor *editor) -{ - gint i; - - for (i = 1; i <= EMAIL_SLOTS; i++) { - gboolean enabled = TRUE; - - if (!editor->target_editable) - enabled = FALSE; - - if (E_CONTACT_FIRST_EMAIL_ID + i - 1 <= E_CONTACT_LAST_EMAIL_ID && - !is_field_supported (editor, E_CONTACT_FIRST_EMAIL_ID + i - 1)) - enabled = FALSE; - - sensitize_email_record (editor, i, enabled); - } -} - -/* EContact can get attributes by field ID only, and there is none for TEL, so we need this */ -static GList * -get_attributes_named (EVCard *vcard, const gchar *attr_name) -{ - GList *attr_list_in; - GList *attr_list_out = NULL; - GList *l; - - attr_list_in = e_vcard_get_attributes (vcard); - - for (l = attr_list_in; l; l = g_list_next (l)) { - EVCardAttribute *attr = l->data; - const gchar *name; - - name = e_vcard_attribute_get_name (attr); - - if (!strcasecmp (attr_name, name)) { - attr_list_out = g_list_append (attr_list_out, e_vcard_attribute_copy (attr)); - } - } - - return attr_list_out; -} - -/* EContact can set attributes by field ID only, and there is none for TEL, so we need this */ -static void -set_attributes_named (EVCard *vcard, const gchar *attr_name, GList *attr_list) -{ - GList *l; - - e_vcard_remove_attributes (vcard, NULL, attr_name); - - for (l = attr_list; l; l = g_list_next (l)) { - EVCardAttribute *attr = l->data; - - e_vcard_add_attribute (vcard, e_vcard_attribute_copy (attr)); - } -} - -static void -expand_phone (EContactEditor *editor, gboolean expanded) -{ - GtkWidget *phone_ext_table; - GtkWidget *phone_ext_arrow; - - phone_ext_table = glade_xml_get_widget (editor->gui, "table-phone-extended"); - phone_ext_arrow = glade_xml_get_widget (editor->gui, "arrow-phone-expand"); - - if (expanded) { - gtk_arrow_set (GTK_ARROW (phone_ext_arrow), GTK_ARROW_DOWN, GTK_SHADOW_NONE); - gtk_widget_show (phone_ext_table); - } else { - gtk_arrow_set (GTK_ARROW (phone_ext_arrow), GTK_ARROW_RIGHT, GTK_SHADOW_NONE); - gtk_widget_hide (phone_ext_table); - } -} - -static void -fill_in_phone_record (EContactEditor *editor, gint record, const gchar *phone, gint phone_type) -{ - GtkWidget *phone_type_option_menu; - GtkWidget *phone_entry; - gchar *widget_name; - - widget_name = g_strdup_printf ("optionmenu-phone-%d", record); - phone_type_option_menu = glade_xml_get_widget (editor->gui, widget_name); - g_free (widget_name); - - widget_name = g_strdup_printf ("entry-phone-%d", record); - phone_entry = glade_xml_get_widget (editor->gui, widget_name); - g_free (widget_name); - - set_option_menu_history (editor, GTK_OPTION_MENU (phone_type_option_menu), - phone_type >= 0 ? phone_type : - phones_default [record - 1]); - set_entry_text (editor, GTK_ENTRY (phone_entry), phone ? phone : ""); - - if (phone && *phone && record >= 5) - expand_phone (editor, TRUE); -} - -static void -extract_phone_record (EContactEditor *editor, gint record, gchar **phone, gint *phone_type) -{ - GtkWidget *phone_type_option_menu; - GtkWidget *phone_entry; - gchar *widget_name; - - widget_name = g_strdup_printf ("optionmenu-phone-%d", record); - phone_type_option_menu = glade_xml_get_widget (editor->gui, widget_name); - g_free (widget_name); - - widget_name = g_strdup_printf ("entry-phone-%d", record); - phone_entry = glade_xml_get_widget (editor->gui, widget_name); - g_free (widget_name); - - *phone = g_strdup (gtk_entry_get_text (GTK_ENTRY (phone_entry))); - *phone_type = gtk_option_menu_get_history (GTK_OPTION_MENU (phone_type_option_menu)); -} - -static void -fill_in_phone (EContactEditor *editor) -{ - GList *phone_attr_list; - GList *l; - gint record_n; - - /* Clear */ - - for (record_n = 1; record_n <= PHONE_SLOTS; record_n++) { - fill_in_phone_record (editor, record_n, NULL, -1); - } - - /* Fill in */ - - phone_attr_list = get_attributes_named (E_VCARD (editor->contact), "TEL"); - - for (record_n = 1, l = phone_attr_list; l && record_n <= PHONE_SLOTS; l = g_list_next (l)) { - EVCardAttribute *attr = l->data; - gchar *phone; - gint slot; - - phone = e_vcard_attribute_get_value (attr); - slot = alloc_ui_slot (editor, "entry-phone", get_ui_slot (attr), PHONE_SLOTS); - if (slot < 1) - break; - - fill_in_phone_record (editor, slot, phone, - get_phone_type (attr)); - - record_n++; - } -} - -static void -extract_phone (EContactEditor *editor) -{ - GList *attr_list = NULL; - GList *old_attr_list; - GList *l, *l_next; - gint i; - - for (i = 1; i <= PHONE_SLOTS; i++) { - gchar *phone; - gint phone_type; - - extract_phone_record (editor, i, &phone, &phone_type); - - if (!STRING_IS_EMPTY (phone)) { - EVCardAttribute *attr; - - attr = e_vcard_attribute_new ("", "TEL"); - - if (phone_type >= 0) { - const gchar *type_1; - const gchar *type_2; - - phone_index_to_type (phone_type, &type_1, &type_2); - - e_vcard_attribute_add_param_with_value ( - attr, e_vcard_attribute_param_new (EVC_TYPE), type_1); - - if (type_2) - e_vcard_attribute_add_param_with_value ( - attr, e_vcard_attribute_param_new (EVC_TYPE), type_2); - - } - - e_vcard_attribute_add_value (attr, phone); - set_ui_slot (attr, i); - - attr_list = g_list_append (attr_list, attr); - } - - g_free (phone); - } - - /* Splice in the old attributes, minus the PHONE_SLOTS first */ - - old_attr_list = get_attributes_named (E_VCARD (editor->contact), "TEL"); - for (l = old_attr_list, i = 1; l && i <= PHONE_SLOTS; l = l_next, i++) { - l_next = g_list_next (l); - - e_vcard_attribute_free (l->data); - g_list_delete_link (l, l); - } - - old_attr_list = l; - attr_list = g_list_concat (attr_list, old_attr_list); - - set_attributes_named (E_VCARD (editor->contact), "TEL", attr_list); - - free_attr_list (attr_list); -} - -static void -init_phone_record_type (EContactEditor *editor, gint record) -{ - GtkWidget *phone_type_option_menu; - GtkWidget *phone_type_menu; - GtkWidget *phone_entry; - gchar *widget_name; - gint i; - - widget_name = g_strdup_printf ("entry-phone-%d", record); - phone_entry = glade_xml_get_widget (editor->gui, widget_name); - g_free (widget_name); - - widget_name = g_strdup_printf ("optionmenu-phone-%d", record); - phone_type_option_menu = glade_xml_get_widget (editor->gui, widget_name); - g_free (widget_name); - - phone_type_menu = gtk_menu_new (); - - for (i = 0; i < G_N_ELEMENTS (phones); i++) { - GtkWidget *item; - - item = gtk_menu_item_new_with_label (e_contact_pretty_name (phones [i].field_id)); - gtk_menu_shell_append (GTK_MENU_SHELL (phone_type_menu), item); - } - - gtk_widget_show_all (phone_type_menu); - gtk_option_menu_set_menu (GTK_OPTION_MENU (phone_type_option_menu), phone_type_menu); - - g_signal_connect (phone_type_option_menu, "changed", G_CALLBACK (object_changed), editor); - g_signal_connect (phone_entry, "changed", G_CALLBACK (object_changed), editor); - g_signal_connect_swapped (phone_entry, "activate", G_CALLBACK (entry_activated), editor); -} - -static void -init_phone (EContactEditor *editor) -{ - gint i; - - expand_phone (editor, FALSE); - - for (i = 1; i <= PHONE_SLOTS; i++) - init_phone_record_type (editor, i); -} - -static void -sensitize_phone_types (EContactEditor *editor, GtkWidget *option_menu) -{ - GtkWidget *menu; - GList *item_list, *l; - gint i; - - menu = gtk_option_menu_get_menu (GTK_OPTION_MENU (option_menu)); - l = item_list = gtk_container_get_children (GTK_CONTAINER (menu)); - - for (i = 0; i < G_N_ELEMENTS (phones); i++) { - GtkWidget *widget; - - if (!l) { - g_warning (G_STRLOC ": Unexpected end of phone items in option menu"); - return; - } - - widget = l->data; - gtk_widget_set_sensitive (widget, is_field_supported (editor, phones [i].field_id)); - - l = g_list_next (l); - } -} - -static void -sensitize_phone_record (EContactEditor *editor, gint record, gboolean enabled) -{ - GtkWidget *phone_type_option_menu; - GtkWidget *phone_entry; - gchar *widget_name; - - widget_name = g_strdup_printf ("optionmenu-phone-%d", record); - phone_type_option_menu = glade_xml_get_widget (editor->gui, widget_name); - g_free (widget_name); - - widget_name = g_strdup_printf ("entry-phone-%d", record); - phone_entry = glade_xml_get_widget (editor->gui, widget_name); - g_free (widget_name); - - gtk_widget_set_sensitive (phone_type_option_menu, enabled); - gtk_editable_set_editable (GTK_EDITABLE (phone_entry), enabled); - - sensitize_phone_types (editor, phone_type_option_menu); -} - -static void -sensitize_phone (EContactEditor *editor) -{ - gint i; - - for (i = 1; i <= PHONE_SLOTS; i++) { - gboolean enabled = TRUE; - - if (!editor->target_editable) - enabled = FALSE; - - sensitize_phone_record (editor, i, enabled); - } -} - -static void -init_im_record_location (EContactEditor *editor, gint record) -{ - GtkWidget *location_option_menu; - GtkWidget *location_menu; - GtkWidget *name_entry; - gchar *widget_name; - gint i; - - widget_name = g_strdup_printf ("entry-im-name-%d", record); - name_entry = glade_xml_get_widget (editor->gui, widget_name); - g_free (widget_name); - -#ifdef ENABLE_IM_LOCATION - widget_name = g_strdup_printf ("optionmenu-im-location-%d", record); - location_option_menu = glade_xml_get_widget (editor->gui, widget_name); - g_free (widget_name); - - location_menu = gtk_menu_new (); - - for (i = 0; i < G_N_ELEMENTS (common_location); i++) { - GtkWidget *item; - - item = gtk_menu_item_new_with_label (common_location [i].pretty_name); - gtk_menu_shell_append (GTK_MENU_SHELL (location_menu), item); - } - - gtk_widget_show_all (location_menu); - gtk_option_menu_set_menu (GTK_OPTION_MENU (location_option_menu), location_menu); - - g_signal_connect (location_option_menu, "changed", G_CALLBACK (object_changed), editor); -#endif - - g_signal_connect (name_entry, "changed", G_CALLBACK (object_changed), editor); - g_signal_connect_swapped (name_entry, "activate", G_CALLBACK (entry_activated), editor); -} - -static void -init_im_record_service (EContactEditor *editor, gint record) -{ - GtkWidget *service_option_menu; - GtkWidget *service_menu; - gchar *widget_name; - gint i; - - widget_name = g_strdup_printf ("optionmenu-im-service-%d", record); - service_option_menu = glade_xml_get_widget (editor->gui, widget_name); - g_free (widget_name); - - service_menu = gtk_menu_new (); - - for (i = 0; i < G_N_ELEMENTS (im_service); i++) { - GtkWidget *item; - - item = gtk_menu_item_new_with_label (im_service [i].pretty_name); - gtk_menu_shell_append (GTK_MENU_SHELL (service_menu), item); - } - - gtk_widget_show_all (service_menu); - gtk_option_menu_set_menu (GTK_OPTION_MENU (service_option_menu), service_menu); - - g_signal_connect (service_option_menu, "changed", G_CALLBACK (object_changed), editor); -} - -static void -init_im (EContactEditor *editor) -{ - gint i; - - for (i = 1; i <= IM_SLOTS; i++) { - init_im_record_service (editor, i); - init_im_record_location (editor, i); - } -} - -static void -fill_in_im_record (EContactEditor *editor, gint record, gint service, const gchar *name, gint location) -{ - GtkWidget *service_option_menu; -#ifdef ENABLE_IM_LOCATION - GtkWidget *location_option_menu; -#endif - GtkWidget *name_entry; - gchar *widget_name; - - widget_name = g_strdup_printf ("optionmenu-im-service-%d", record); - service_option_menu = glade_xml_get_widget (editor->gui, widget_name); - g_free (widget_name); - -#ifdef ENABLE_IM_LOCATION - widget_name = g_strdup_printf ("optionmenu-im-location-%d", record); - location_option_menu = glade_xml_get_widget (editor->gui, widget_name); - g_free (widget_name); -#endif - - widget_name = g_strdup_printf ("entry-im-name-%d", record); - name_entry = glade_xml_get_widget (editor->gui, widget_name); - g_free (widget_name); - -#ifdef ENABLE_IM_LOCATION - set_option_menu_history (editor, GTK_OPTION_MENU (location_option_menu), - location >= 0 ? location : 0); -#endif - set_option_menu_history (editor, GTK_OPTION_MENU (service_option_menu), - service >= 0 ? service : im_service_default [record - 1]); - set_entry_text (editor, GTK_ENTRY (name_entry), name ? name : ""); -} - -static void -fill_in_im (EContactEditor *editor) -{ - GList *im_attr_list; - GList *l; - gint record_n; - gint i; - - /* Clear */ - - for (record_n = 1 ; record_n <= IM_SLOTS; record_n++) { - fill_in_im_record (editor, record_n, -1, NULL, -1); - } - - /* Fill in */ - - for (record_n = 1, i = 0; i < G_N_ELEMENTS (im_service); i++) { - im_attr_list = e_contact_get_attributes (editor->contact, im_service [i].field); - - for (l = im_attr_list; l && record_n <= IM_SLOTS; l = g_list_next (l)) { - EVCardAttribute *attr = l->data; - gchar *im_name; - gint slot; - - im_name = e_vcard_attribute_get_value (attr); - slot = alloc_ui_slot (editor, "entry-im-name", get_ui_slot (attr), IM_SLOTS); - if (slot < 1) - break; - - fill_in_im_record (editor, slot, i, im_name, - get_im_location (attr)); - - record_n++; - } - } -} - -static void -extract_im_record (EContactEditor *editor, gint record, gint *service, gchar **name, gint *location) -{ - GtkWidget *service_option_menu; -#ifdef ENABLE_IM_LOCATION - GtkWidget *location_option_menu; -#endif - GtkWidget *name_entry; - gchar *widget_name; - - widget_name = g_strdup_printf ("optionmenu-im-service-%d", record); - service_option_menu = glade_xml_get_widget (editor->gui, widget_name); - g_free (widget_name); - -#ifdef ENABLE_IM_LOCATION - widget_name = g_strdup_printf ("optionmenu-im-location-%d", record); - location_option_menu = glade_xml_get_widget (editor->gui, widget_name); - g_free (widget_name); -#endif - - widget_name = g_strdup_printf ("entry-im-name-%d", record); - name_entry = glade_xml_get_widget (editor->gui, widget_name); - g_free (widget_name); - - *name = g_strdup (gtk_entry_get_text (GTK_ENTRY (name_entry))); - *service = gtk_option_menu_get_history (GTK_OPTION_MENU (service_option_menu)); -#ifdef ENABLE_IM_LOCATION - *location = gtk_option_menu_get_history (GTK_OPTION_MENU (location_option_menu)); -#else - *location = 1; /* set everything to HOME */ -#endif -} - -static void -extract_im (EContactEditor *editor) -{ - GList **service_attr_list; - gint remaining_slots = IM_SLOTS; - gint i; - - service_attr_list = g_new0 (GList *, G_N_ELEMENTS (im_service)); - - for (i = 1; i <= IM_SLOTS; i++) { - EVCardAttribute *attr; - gchar *name; - gint service; - gint location; - - extract_im_record (editor, i, &service, &name, &location); - - if (!STRING_IS_EMPTY (name)) { - attr = e_vcard_attribute_new ("", e_contact_vcard_attribute (im_service [service].field)); - - if (location >= 0) - e_vcard_attribute_add_param_with_value (attr, - e_vcard_attribute_param_new (EVC_TYPE), - im_index_to_location (location)); - - e_vcard_attribute_add_value (attr, name); - set_ui_slot (attr, i); - - service_attr_list [service] = g_list_append (service_attr_list [service], attr); - } - - g_free (name); - } - - for (i = 0; i < G_N_ELEMENTS (im_service); i++) { - GList *old_service_attr_list; - gint filled_in_slots; - GList *l, *l_next; - gint j; - - /* Splice in the old attributes, minus the filled_in_slots first */ - - old_service_attr_list = e_contact_get_attributes (editor->contact, im_service [i].field); - filled_in_slots = MIN (remaining_slots, g_list_length (old_service_attr_list)); - remaining_slots -= filled_in_slots; - - for (l = old_service_attr_list, j = 0; l && j < filled_in_slots; l = l_next, j++) { - l_next = g_list_next (l); - - e_vcard_attribute_free (l->data); - g_list_delete_link (l, l); - } - - old_service_attr_list = l; - service_attr_list [i] = g_list_concat (service_attr_list [i], old_service_attr_list); - - e_contact_set_attributes (editor->contact, im_service [i].field, - service_attr_list [i]); - - free_attr_list (service_attr_list [i]); - } - - g_free (service_attr_list); -} - -static void -sensitize_im_record (EContactEditor *editor, gint record, gboolean enabled) -{ - GtkWidget *service_option_menu; -#ifdef ENABLE_IM_LOCATION - GtkWidget *location_option_menu; -#endif - GtkWidget *name_entry; - gchar *widget_name; - - widget_name = g_strdup_printf ("optionmenu-im-service-%d", record); - service_option_menu = glade_xml_get_widget (editor->gui, widget_name); - g_free (widget_name); - -#ifdef ENABLE_IM_LOCATION - widget_name = g_strdup_printf ("optionmenu-im-location-%d", record); - location_option_menu = glade_xml_get_widget (editor->gui, widget_name); - g_free (widget_name); -#endif - - widget_name = g_strdup_printf ("entry-im-name-%d", record); - name_entry = glade_xml_get_widget (editor->gui, widget_name); - g_free (widget_name); - - gtk_widget_set_sensitive (service_option_menu, enabled); -#ifdef ENABLE_IM_LOCATION - gtk_widget_set_sensitive (location_option_menu, enabled); -#endif - gtk_editable_set_editable (GTK_EDITABLE (name_entry), enabled); -} - -static void -sensitize_im (EContactEditor *editor) -{ - gint i; - - for (i = 1; i <= IM_SLOTS; i++) { - gboolean enabled = TRUE; - - if (!editor->target_editable) - enabled = FALSE; - - sensitize_im_record (editor, i, enabled); - } -} - -static void -init_address_textview (EContactEditor *editor, gint record) -{ - gchar *textview_name; - GtkWidget *textview; - GtkTextBuffer *text_buffer; - - textview_name = g_strdup_printf ("textview-%s-address", address_name [record]); - textview = glade_xml_get_widget (editor->gui, textview_name); - g_free (textview_name); - - text_buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (textview)); - g_signal_connect (text_buffer, "changed", G_CALLBACK (object_changed), editor); -} - -static void -init_address_field (EContactEditor *editor, gint record, const gchar *widget_field_name) -{ - gchar *entry_name; - GtkWidget *entry; - - entry_name = g_strdup_printf ("entry-%s-%s", address_name [record], widget_field_name); - entry = glade_xml_get_widget (editor->gui, entry_name); - g_free (entry_name); - - g_signal_connect (entry, "changed", G_CALLBACK (object_changed), editor); - g_signal_connect_swapped (entry, "activate", G_CALLBACK (entry_activated), editor); -} - -static void -init_address_record (EContactEditor *editor, gint record) -{ - init_address_textview (editor, record); - init_address_field (editor, record, "city"); - init_address_field (editor, record, "state"); - init_address_field (editor, record, "zip"); - init_address_field (editor, record, "country"); - init_address_field (editor, record, "pobox"); -} - -static void -init_address (EContactEditor *editor) -{ - gint i; - - for (i = 0; i < ADDRESS_SLOTS; i++) - init_address_record (editor, i); -} - -static void -fill_in_address_textview (EContactEditor *editor, gint record, EContactAddress *address) -{ - gchar *textview_name; - GtkWidget *textview; - GtkTextBuffer *text_buffer; - GtkTextIter iter; - - textview_name = g_strdup_printf ("textview-%s-address", address_name [record]); - textview = glade_xml_get_widget (editor->gui, textview_name); - g_free (textview_name); - - text_buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (textview)); - gtk_text_buffer_set_text (text_buffer, address->street ? address->street : "", -1); - - gtk_text_buffer_get_end_iter (text_buffer, &iter); - gtk_text_buffer_insert (text_buffer, &iter, "\n", -1); - gtk_text_buffer_insert (text_buffer, &iter, address->ext ? address->ext : "", -1); -} - -static void -fill_in_address_label_textview (EContactEditor *editor, gint record, const gchar *label) -{ - gchar *textview_name; - GtkWidget *textview; - GtkTextBuffer *text_buffer; - - textview_name = g_strdup_printf ("textview-%s-address", address_name [record]); - textview = glade_xml_get_widget (editor->gui, textview_name); - g_free (textview_name); - - text_buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (textview)); - gtk_text_buffer_set_text (text_buffer, label ? label : "", -1); -} - -static void -fill_in_address_field (EContactEditor *editor, gint record, const gchar *widget_field_name, - const gchar *string) -{ - gchar *entry_name; - GtkWidget *entry; - - entry_name = g_strdup_printf ("entry-%s-%s", address_name [record], widget_field_name); - entry = glade_xml_get_widget (editor->gui, entry_name); - g_free (entry_name); - - set_entry_text (editor, GTK_ENTRY (entry), string); -} - -static void -fill_in_address_record (EContactEditor *editor, gint record) -{ - EContactAddress *address; - gchar *address_label; - - address = e_contact_get (editor->contact, addresses [record]); - address_label = e_contact_get (editor->contact, address_labels [record]); - - if (address && - (!STRING_IS_EMPTY (address->street) || - !STRING_IS_EMPTY (address->ext) || - !STRING_IS_EMPTY (address->locality) || - !STRING_IS_EMPTY (address->region) || - !STRING_IS_EMPTY (address->code) || - !STRING_IS_EMPTY (address->po) || - !STRING_IS_EMPTY (address->country))) { - fill_in_address_textview (editor, record, address); - fill_in_address_field (editor, record, "city", address->locality); - fill_in_address_field (editor, record, "state", address->region); - fill_in_address_field (editor, record, "zip", address->code); - fill_in_address_field (editor, record, "country", address->country); - fill_in_address_field (editor, record, "pobox", address->po); - } else if (!STRING_IS_EMPTY (address_label)) { - fill_in_address_label_textview (editor, record, address_label); - } - - g_free (address_label); - if (address) - g_boxed_free (e_contact_address_get_type (), address); -} - -static void -fill_in_address (EContactEditor *editor) -{ - gint i; - - for (i = 0; i < ADDRESS_SLOTS; i++) - fill_in_address_record (editor, i); -} - -static void -extract_address_textview (EContactEditor *editor, gint record, EContactAddress *address) -{ - gchar *textview_name; - GtkWidget *textview; - GtkTextBuffer *text_buffer; - GtkTextIter iter_1, iter_2; - - textview_name = g_strdup_printf ("textview-%s-address", address_name [record]); - textview = glade_xml_get_widget (editor->gui, textview_name); - g_free (textview_name); - - text_buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (textview)); - gtk_text_buffer_get_start_iter (text_buffer, &iter_1); - - /* Skip blank lines */ - while (gtk_text_iter_get_chars_in_line (&iter_1) < 1 && - !gtk_text_iter_is_end (&iter_1)) - gtk_text_iter_forward_line (&iter_1); - - if (gtk_text_iter_is_end (&iter_1)) - return; - - iter_2 = iter_1; - gtk_text_iter_forward_to_line_end (&iter_2); - - /* Extract street (first line of text) */ - address->street = gtk_text_iter_get_text (&iter_1, &iter_2); - - iter_1 = iter_2; - gtk_text_iter_forward_line (&iter_1); - - if (gtk_text_iter_is_end (&iter_1)) - return; - - gtk_text_iter_forward_to_end (&iter_2); - - /* Extract extended address (remaining lines of text) */ - address->ext = gtk_text_iter_get_text (&iter_1, &iter_2); -} - -static gchar * -extract_address_field (EContactEditor *editor, gint record, const gchar *widget_field_name) -{ - gchar *entry_name; - GtkWidget *entry; - - entry_name = g_strdup_printf ("entry-%s-%s", address_name [record], widget_field_name); - entry = glade_xml_get_widget (editor->gui, entry_name); - g_free (entry_name); - - return g_strdup (gtk_entry_get_text (GTK_ENTRY (entry))); -} - -static gchar * -append_to_address_label (gchar *address_label, const gchar *part, gboolean newline) -{ - gchar *new_address_label; - - if (STRING_IS_EMPTY (part)) - return address_label; - - if (address_label) - new_address_label = g_strjoin (newline ? "\n" : ", ", address_label, part, NULL); - else - new_address_label = g_strdup (part); - - g_free (address_label); - return new_address_label; -} - -static void -set_address_label (EContact *contact, EContactField field, EContactAddress *address) -{ - gchar *address_label = NULL; - - if (address) { - address_label = append_to_address_label (address_label, address->street, TRUE); - address_label = append_to_address_label (address_label, address->ext, TRUE); - address_label = append_to_address_label (address_label, address->locality, TRUE); - address_label = append_to_address_label (address_label, address->region, FALSE); - address_label = append_to_address_label (address_label, address->code, TRUE); - address_label = append_to_address_label (address_label, address->po, TRUE); - address_label = append_to_address_label (address_label, address->country, TRUE); - } - - e_contact_set (contact, field, address_label); - g_free (address_label); -} - -static void -extract_address_record (EContactEditor *editor, gint record) -{ - EContactAddress *address; - - address = g_new0 (EContactAddress, 1); - - extract_address_textview (editor, record, address); - address->locality = extract_address_field (editor, record, "city"); - address->region = extract_address_field (editor, record, "state"); - address->code = extract_address_field (editor, record, "zip"); - address->country = extract_address_field (editor, record, "country"); - address->po = extract_address_field (editor, record, "pobox"); - - if (!STRING_IS_EMPTY (address->street) || - !STRING_IS_EMPTY (address->ext) || - !STRING_IS_EMPTY (address->locality) || - !STRING_IS_EMPTY (address->region) || - !STRING_IS_EMPTY (address->code) || - !STRING_IS_EMPTY (address->po) || - !STRING_IS_EMPTY (address->country)) { - e_contact_set (editor->contact, addresses [record], address); - set_address_label (editor->contact, address_labels [record], address); - } - else { - e_contact_set (editor->contact, addresses [record], NULL); - set_address_label (editor->contact, address_labels [record], NULL); - } - - g_boxed_free (e_contact_address_get_type (), address); -} - -static void -extract_address (EContactEditor *editor) -{ - gint i; - - for (i = 0; i < ADDRESS_SLOTS; i++) - extract_address_record (editor, i); -} - -static void -sensitize_address_textview (EContactEditor *editor, gint record, gboolean enabled) -{ - gchar *widget_name; - GtkWidget *textview; - GtkWidget *label; - - widget_name = g_strdup_printf ("textview-%s-address", address_name [record]); - textview = glade_xml_get_widget (editor->gui, widget_name); - g_free (widget_name); - - widget_name = g_strdup_printf ("label-%s-address", address_name [record]); - label = glade_xml_get_widget (editor->gui, widget_name); - g_free (widget_name); - - gtk_text_view_set_editable (GTK_TEXT_VIEW (textview), enabled); - gtk_widget_set_sensitive (label, enabled); -} - -static void -sensitize_address_field (EContactEditor *editor, gint record, const gchar *widget_field_name, - gboolean enabled) -{ - gchar *widget_name; - GtkWidget *entry; - GtkWidget *label; - - widget_name = g_strdup_printf ("entry-%s-%s", address_name [record], widget_field_name); - entry = glade_xml_get_widget (editor->gui, widget_name); - g_free (widget_name); - - widget_name = g_strdup_printf ("label-%s-%s", address_name [record], widget_field_name); - label = glade_xml_get_widget (editor->gui, widget_name); - g_free (widget_name); - - gtk_editable_set_editable (GTK_EDITABLE (entry), enabled); - gtk_widget_set_sensitive (label, enabled); -} - -static void -sensitize_address_record (EContactEditor *editor, gint record, gboolean enabled) -{ - sensitize_address_textview (editor, record, enabled); - sensitize_address_field (editor, record, "city", enabled); - sensitize_address_field (editor, record, "state", enabled); - sensitize_address_field (editor, record, "zip", enabled); - sensitize_address_field (editor, record, "country", enabled); - sensitize_address_field (editor, record, "pobox", enabled); -} - -static void -sensitize_address (EContactEditor *editor) -{ - gint i; - - for (i = 0; i < ADDRESS_SLOTS; i++) { - gboolean enabled = TRUE; - - if (!editor->target_editable || - !(is_field_supported (editor, addresses [i]) || - is_field_supported (editor, address_labels[i]))) - enabled = FALSE; - - sensitize_address_record (editor, i, enabled); - } -} - -typedef struct { - char *widget_name; - gint field_id; /* EContactField or -1 */ - gboolean process_data; /* If we should extract/fill in contents */ - gboolean desensitize_for_read_only; -} -FieldMapping; - -/* Table of widgets that interact with simple fields. This table is used to: - * - * - Fill in data. - * - Extract data. - * - Set sensitivity based on backend capabilities. - * - Set sensitivity based on book writeability. */ - -static FieldMapping simple_field_map [] = { - { "entry-homepage", E_CONTACT_HOMEPAGE_URL, TRUE, TRUE }, - { "accellabel-homepage", E_CONTACT_HOMEPAGE_URL, FALSE, TRUE }, - - { "entry-jobtitle", E_CONTACT_TITLE, TRUE, TRUE }, - { "label-jobtitle", E_CONTACT_TITLE, FALSE, TRUE }, - - { "entry-company", E_CONTACT_ORG, TRUE, TRUE }, - { "label-company", E_CONTACT_ORG, FALSE, TRUE }, - - { "entry-department", E_CONTACT_ORG_UNIT, TRUE, TRUE }, - { "label-department", E_CONTACT_ORG_UNIT, FALSE, TRUE }, - - { "entry-profession", E_CONTACT_ROLE, TRUE, TRUE }, - { "label-profession", E_CONTACT_ROLE, FALSE, TRUE }, - - { "entry-manager", E_CONTACT_MANAGER, TRUE, TRUE }, - { "label-manager", E_CONTACT_MANAGER, FALSE, TRUE }, - - { "entry-assistant", E_CONTACT_ASSISTANT, TRUE, TRUE }, - { "label-assistant", E_CONTACT_ASSISTANT, FALSE, TRUE }, - - { "entry-nickname", E_CONTACT_NICKNAME, TRUE, TRUE }, - { "label-nickname", E_CONTACT_NICKNAME, FALSE, TRUE }, - - { "dateedit-birthday", E_CONTACT_BIRTH_DATE, TRUE, TRUE }, - { "label-birthday", E_CONTACT_BIRTH_DATE, FALSE, TRUE }, - - { "dateedit-anniversary", E_CONTACT_ANNIVERSARY, TRUE, TRUE }, - { "label-anniversary", E_CONTACT_ANNIVERSARY, FALSE, TRUE }, - - { "entry-spouse", E_CONTACT_SPOUSE, TRUE, TRUE }, - { "label-spouse", E_CONTACT_SPOUSE, FALSE, TRUE }, - - { "entry-office", E_CONTACT_OFFICE, TRUE, TRUE }, - { "label-office", E_CONTACT_OFFICE, FALSE, TRUE }, - - { "text-comments", E_CONTACT_NOTE, TRUE, TRUE }, - { "label-comments", E_CONTACT_NOTE, FALSE, TRUE }, - - { "entry-fullname", E_CONTACT_FULL_NAME, TRUE, TRUE }, - { "button-fullname", E_CONTACT_FULL_NAME, FALSE, TRUE }, - - { "entry-categories", E_CONTACT_CATEGORIES, TRUE, TRUE }, - { "button-categories", E_CONTACT_CATEGORIES, FALSE, TRUE }, - - { "entry-weblog", E_CONTACT_BLOG_URL, TRUE, TRUE }, - { "label-weblog", E_CONTACT_BLOG_URL, FALSE, TRUE }, - - { "entry-caluri", E_CONTACT_CALENDAR_URI, TRUE, TRUE }, - { "label-caluri", E_CONTACT_CALENDAR_URI, FALSE, TRUE }, - - { "entry-fburl", E_CONTACT_FREEBUSY_URL, TRUE, TRUE }, - { "label-fburl", E_CONTACT_FREEBUSY_URL, FALSE, TRUE }, - - { "entry-videourl", E_CONTACT_VIDEO_URL, TRUE, TRUE }, - { "label-videourl", E_CONTACT_VIDEO_URL, FALSE, TRUE }, - - { "checkbutton-htmlmail", E_CONTACT_WANTS_HTML, TRUE, TRUE }, - - { "image-chooser", E_CONTACT_PHOTO, TRUE, TRUE }, - { "button-image", E_CONTACT_PHOTO, FALSE, TRUE }, - - { "combo-file-as", E_CONTACT_FILE_AS, FALSE, TRUE }, - { "entry-file-as", E_CONTACT_FILE_AS, TRUE, TRUE }, - { "accellabel-fileas", E_CONTACT_FILE_AS, FALSE, TRUE }, -}; - -static void -init_simple_field (EContactEditor *editor, GtkWidget *widget) -{ - GObject *changed_object = NULL; - - if (GTK_IS_ENTRY (widget)) { - changed_object = G_OBJECT (widget); - g_signal_connect_swapped (widget, "activate", G_CALLBACK (entry_activated), editor); - } - else if (GTK_IS_TEXT_VIEW (widget)) { - changed_object = G_OBJECT (gtk_text_view_get_buffer (GTK_TEXT_VIEW (widget))); - } - else if (E_IS_URL_ENTRY (widget)) { - changed_object = G_OBJECT (e_url_entry_get_entry (E_URL_ENTRY (widget))); - g_signal_connect_swapped (GTK_WIDGET (changed_object), "activate", - G_CALLBACK (entry_activated), editor); - } - else if (E_IS_DATE_EDIT (widget)) { - changed_object = G_OBJECT (widget); - } - else if (E_IS_IMAGE_CHOOSER (widget)) { - changed_object = G_OBJECT (widget); - g_signal_connect (widget, "changed", G_CALLBACK (image_chooser_changed), editor); - } - else if (GTK_IS_TOGGLE_BUTTON (widget)) { - g_signal_connect (widget, "toggled", G_CALLBACK (object_changed), editor); - } - - if (changed_object) - g_signal_connect (changed_object, "changed", G_CALLBACK (object_changed), editor); -} - -static void -fill_in_simple_field (EContactEditor *editor, GtkWidget *widget, gint field_id) -{ - EContact *contact; - - contact = editor->contact; - - g_signal_handlers_block_matched (widget, G_SIGNAL_MATCH_DATA, - 0, 0, NULL, NULL, editor); - - if (GTK_IS_ENTRY (widget)) { - gchar *text = e_contact_get (contact, field_id); - gtk_entry_set_text (GTK_ENTRY (widget), STRING_MAKE_NON_NULL (text)); - g_free (text); - } - else if (GTK_IS_TEXT_VIEW (widget)) { - GtkTextBuffer *buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (widget)); - gchar *text = e_contact_get (contact, field_id); - gtk_text_buffer_set_text (buffer, STRING_MAKE_NON_NULL (text), -1); - g_free (text); - } - else if (E_IS_URL_ENTRY (widget)) { - GtkWidget *entry = e_url_entry_get_entry (E_URL_ENTRY (widget)); - gchar *text = e_contact_get (contact, field_id); - gtk_entry_set_text (GTK_ENTRY (entry), STRING_MAKE_NON_NULL (text)); - g_free (text); - } - else if (E_IS_DATE_EDIT (widget)) { - EContactDate *date = e_contact_get (contact, field_id); - if (date) - e_date_edit_set_date (E_DATE_EDIT (widget), - date->year, - date->month, - date->day); - else - e_date_edit_set_time (E_DATE_EDIT (widget), -1); - - e_contact_date_free (date); - } - else if (E_IS_IMAGE_CHOOSER (widget)) { - EContactPhoto *photo = e_contact_get (contact, field_id); - if (photo) { - e_image_chooser_set_image_data (E_IMAGE_CHOOSER (widget), - photo->data, - photo->length); - editor->image_set = TRUE; - } - else { - gchar *file_name = e_icon_factory_get_icon_filename ("stock_person", 48); - e_image_chooser_set_from_file (E_IMAGE_CHOOSER (widget), file_name); - editor->image_set = FALSE; - g_free (file_name); - } - - e_contact_photo_free (photo); - } - else if (GTK_IS_TOGGLE_BUTTON (widget)) { - gboolean val = (gboolean) e_contact_get (contact, field_id); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), val); - } - else { - g_warning (G_STRLOC ": Unhandled widget class in mappings!"); - } - - g_signal_handlers_unblock_matched (widget, G_SIGNAL_MATCH_DATA, - 0, 0, NULL, NULL, editor); -} - -static void -extract_simple_field (EContactEditor *editor, GtkWidget *widget, gint field_id) -{ - EContact *contact; - - contact = editor->contact; - - if (GTK_IS_ENTRY (widget)) { - const gchar *text = gtk_entry_get_text (GTK_ENTRY (widget)); - e_contact_set (contact, field_id, (gchar *) text); - } - else if (GTK_IS_TEXT_VIEW (widget)) { - GtkTextBuffer *buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (widget)); - GtkTextIter start, end; - gchar *text; - - gtk_text_buffer_get_start_iter (buffer, &start); - gtk_text_buffer_get_end_iter (buffer, &end); - text = gtk_text_buffer_get_text (buffer, &start, &end, FALSE); - - e_contact_set (contact, field_id, text); - g_free (text); - } - else if (E_IS_URL_ENTRY (widget)) { - GtkWidget *entry = e_url_entry_get_entry (E_URL_ENTRY (widget)); - const gchar *text = gtk_entry_get_text (GTK_ENTRY (entry)); - e_contact_set (contact, field_id, (gchar *) text); - } - else if (E_IS_DATE_EDIT (widget)) { - EContactDate date; - if (e_date_edit_get_date (E_DATE_EDIT (widget), - &date.year, - &date.month, - &date.day)) - e_contact_set (contact, field_id, &date); - else - e_contact_set (contact, field_id, NULL); - } - else if (E_IS_IMAGE_CHOOSER (widget)) { - EContactPhoto photo; - - if (editor->image_set && - e_image_chooser_get_image_data (E_IMAGE_CHOOSER (widget), - &photo.data, &photo.length)) { - e_contact_set (contact, field_id, &photo); - g_free (photo.data); - } - else { - e_contact_set (contact, E_CONTACT_PHOTO, NULL); - } - } - else if (GTK_IS_TOGGLE_BUTTON (widget)) { - gboolean val = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)); - e_contact_set (contact, field_id, (gpointer) val); - } - else { - g_warning (G_STRLOC ": Unhandled widget class in mappings!"); - } -} - -static void -sensitize_simple_field (GtkWidget *widget, gboolean enabled) -{ - if (GTK_IS_ENTRY (widget)) - gtk_editable_set_editable (GTK_EDITABLE (widget), enabled); - else if (GTK_IS_TEXT_VIEW (widget)) - gtk_text_view_set_editable (GTK_TEXT_VIEW (widget), enabled); - else if (E_IS_URL_ENTRY (widget)) { - GtkWidget *entry = e_url_entry_get_entry (E_URL_ENTRY (widget)); - gtk_editable_set_editable (GTK_EDITABLE (entry), enabled); - } - else if (E_IS_DATE_EDIT (widget)) - e_date_edit_set_editable (E_DATE_EDIT (widget), enabled); - else - gtk_widget_set_sensitive (widget, enabled); -} - -static void -init_simple (EContactEditor *editor) -{ - GtkWidget *widget; - gint i; - - for (i = 0; i < G_N_ELEMENTS (simple_field_map); i++) { - GtkWidget *widget; - - widget = glade_xml_get_widget (editor->gui, simple_field_map [i].widget_name); - if (!widget) - continue; - - init_simple_field (editor, widget); - } - - /* --- Special cases --- */ - - /* Update file_as */ - - widget = glade_xml_get_widget (editor->gui, "entry-fullname"); - g_signal_connect (widget, "changed", G_CALLBACK (name_entry_changed), editor); - widget = glade_xml_get_widget (editor->gui, "entry-file-as"); - g_signal_connect (widget, "changed", G_CALLBACK (file_as_entry_changed), editor); - widget = glade_xml_get_widget (editor->gui, "entry-company"); - g_signal_connect (widget, "changed", G_CALLBACK (company_entry_changed), editor); -} - -static void -fill_in_simple (EContactEditor *editor) -{ - EContactName *name; - gint i; - - for (i = 0; i < G_N_ELEMENTS (simple_field_map); i++) { - GtkWidget *widget; - - if (simple_field_map [i].field_id < 0 || - !simple_field_map [i].process_data) - continue; - - widget = glade_xml_get_widget (editor->gui, simple_field_map [i].widget_name); - if (!widget) - continue; - - fill_in_simple_field (editor, widget, simple_field_map [i].field_id); - } - - /* --- Special cases --- */ - - /* Update broken-up name */ - - g_object_get (editor->contact, - "name", &name, - NULL); - - if (editor->name) - e_contact_name_free (editor->name); - - editor->name = name; - - /* Update file_as combo options */ - - update_file_as_combo (editor); -} - -static void -extract_simple (EContactEditor *editor) -{ - gint i; - - for (i = 0; i < G_N_ELEMENTS (simple_field_map); i++) { - GtkWidget *widget; - - if (simple_field_map [i].field_id < 0 || - !simple_field_map [i].process_data) - continue; - - widget = glade_xml_get_widget (editor->gui, simple_field_map [i].widget_name); - if (!widget) - continue; - - extract_simple_field (editor, widget, simple_field_map [i].field_id); - } - - /* Special cases */ - - e_contact_set (editor->contact, E_CONTACT_NAME, editor->name); -} - -static void -sensitize_simple (EContactEditor *editor) -{ - gint i; - - for (i = 0; i < G_N_ELEMENTS (simple_field_map); i++) { - GtkWidget *widget; - gboolean enabled = TRUE; - - widget = glade_xml_get_widget (editor->gui, simple_field_map [i].widget_name); - if (!widget) - continue; - - if (simple_field_map [i].field_id >= 0 && - !is_field_supported (editor, simple_field_map [i].field_id)) - enabled = FALSE; - - if (simple_field_map [i].desensitize_for_read_only && - !editor->target_editable) - enabled = FALSE; - - sensitize_simple_field (widget, enabled); - } -} - -static void -fill_in_all (EContactEditor *editor) -{ - fill_in_source_field (editor); - fill_in_simple (editor); - fill_in_email (editor); - fill_in_phone (editor); - fill_in_im (editor); - fill_in_address (editor); -} - -static void -extract_all (EContactEditor *editor) -{ - extract_simple (editor); - extract_email (editor); - extract_phone (editor); - extract_im (editor); - extract_address (editor); -} - -static void -sensitize_all (EContactEditor *editor) -{ - sensitize_ok (editor); - sensitize_simple (editor); - sensitize_email (editor); - sensitize_phone (editor); - sensitize_im (editor); - sensitize_address (editor); -} - -static void -init_all (EContactEditor *editor) -{ - init_simple (editor); - init_email (editor); - init_phone (editor); - init_im (editor); - init_address (editor); -} - -static void -new_target_cb (EBook *new_book, EBookStatus status, EContactEditor *editor) -{ - editor->load_source_id = 0; - editor->load_book = NULL; - - if (status != E_BOOK_ERROR_OK || new_book == NULL) { - GtkWidget *source_option_menu; - - eab_load_error_dialog (NULL, e_book_get_source (new_book), status); - - source_option_menu = glade_xml_get_widget (editor->gui, "source-option-menu-source"); - e_source_option_menu_select (E_SOURCE_OPTION_MENU (source_option_menu), - e_book_get_source (editor->target_book)); - - if (new_book) - g_object_unref (new_book); - return; - } - - g_object_set (editor, "target_book", new_book, NULL); - g_object_unref (new_book); -} - -static void -cancel_load (EContactEditor *editor) -{ - if (editor->load_source_id) { - addressbook_load_cancel (editor->load_source_id); - editor->load_source_id = 0; - - g_object_unref (editor->load_book); - editor->load_book = NULL; - } -} - -static void -source_selected (GtkWidget *source_option_menu, ESource *source, EContactEditor *editor) -{ - cancel_load (editor); - - if (e_source_equal (e_book_get_source (editor->target_book), source)) - return; - - if (e_source_equal (e_book_get_source (editor->source_book), source)) { - g_object_set (editor, "target_book", editor->source_book, NULL); - return; - } - - editor->load_book = e_book_new (source, NULL); - editor->load_source_id = addressbook_load (editor->load_book, - (EBookCallback) new_target_cb, editor); -} - -static void -full_name_clicked (GtkWidget *button, EContactEditor *editor) -{ - GtkDialog *dialog = GTK_DIALOG (e_contact_editor_fullname_new (editor->name)); - gboolean fullname_supported; - int result; - - fullname_supported = is_field_supported (editor, E_CONTACT_FULL_NAME); - - g_object_set (dialog, - "editable", fullname_supported & editor->target_editable, - NULL); - gtk_widget_show (GTK_WIDGET(dialog)); - result = gtk_dialog_run (dialog); - gtk_widget_hide (GTK_WIDGET (dialog)); - - if (fullname_supported && editor->target_editable && result == GTK_RESPONSE_OK) { - EContactName *name; - GtkWidget *fname_widget; - int style = 0; - - g_object_get (dialog, - "name", &name, - NULL); - - style = file_as_get_style(editor); - - fname_widget = glade_xml_get_widget(editor->gui, "entry-fullname"); - if (fname_widget && GTK_IS_ENTRY (fname_widget)) { - char *full_name = e_contact_name_to_string(name); - const char *old_full_name = gtk_entry_get_text (GTK_ENTRY(fname_widget)); - - if (strcmp (full_name, old_full_name)) - gtk_entry_set_text (GTK_ENTRY (fname_widget), full_name); - g_free(full_name); - } - - e_contact_name_free(editor->name); - editor->name = name; - - file_as_set_style(editor, style); - } - gtk_widget_destroy (GTK_WIDGET (dialog)); -} - -static void -categories_clicked (GtkWidget *button, EContactEditor *editor) -{ - char *categories = NULL; - GtkDialog *dialog; - int result; - GtkWidget *entry = glade_xml_get_widget(editor->gui, "entry-categories"); - ECategoriesMasterList *ecml; - if (entry && GTK_IS_ENTRY(entry)) - categories = g_strdup (gtk_entry_get_text(GTK_ENTRY(entry))); - else if (editor->contact) - categories = e_contact_get (editor->contact, E_CONTACT_CATEGORIES); - - if (!(dialog = GTK_DIALOG (e_categories_new (categories)))) { - e_error_run (NULL, "addressbook:edit-categories", NULL); - g_free (categories); - return; - } - - ecml = e_categories_master_list_wombat_new (); - g_object_set (dialog, - "header", _("This contact belongs to these categories:"), - "ecml", ecml, - NULL); - g_object_unref (ecml); - gtk_widget_show(GTK_WIDGET(dialog)); - result = gtk_dialog_run (dialog); - g_free (categories); - if (result == GTK_RESPONSE_OK) { - g_object_get (dialog, - "categories", &categories, - NULL); - if (entry && GTK_IS_ENTRY(entry)) - gtk_entry_set_text (GTK_ENTRY (entry), categories); - else - e_contact_set (editor->contact, E_CONTACT_CATEGORIES, categories); - - g_free(categories); - } - gtk_widget_destroy(GTK_WIDGET(dialog)); -} - -static void -image_selected (EContactEditor *editor) -{ - gchar *file_name; - GtkWidget *image_chooser; - -#ifdef USE_GTKFILECHOOSER - file_name = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (editor->file_selector)); -#else - file_name = (gchar *) gtk_file_selection_get_filename (GTK_FILE_SELECTION (editor->file_selector)); -#endif - - if (!file_name) - return; - - image_chooser = glade_xml_get_widget (editor->gui, "image-chooser"); - - g_signal_handlers_block_by_func (image_chooser, image_chooser_changed, editor); - e_image_chooser_set_from_file (E_IMAGE_CHOOSER (image_chooser), file_name); - g_signal_handlers_unblock_by_func (image_chooser, image_chooser_changed, editor); - - editor->image_set = TRUE; - object_changed (G_OBJECT (image_chooser), editor); -} - -static void -image_cleared (EContactEditor *editor) -{ - GtkWidget *image_chooser; - gchar *file_name; - - image_chooser = glade_xml_get_widget (editor->gui, "image-chooser"); - - file_name = e_icon_factory_get_icon_filename ("stock_person", 48); - - g_signal_handlers_block_by_func (image_chooser, image_chooser_changed, editor); - e_image_chooser_set_from_file (E_IMAGE_CHOOSER (image_chooser), file_name); - g_signal_handlers_unblock_by_func (image_chooser, image_chooser_changed, editor); - - g_free (file_name); - - editor->image_set = FALSE; - object_changed (G_OBJECT (image_chooser), editor); -} - -#ifdef USE_GTKFILECHOOSER - -static void -file_chooser_response (GtkWidget *widget, gint response, EContactEditor *editor) -{ - if (response == GTK_RESPONSE_ACCEPT) - image_selected (editor); - else if (response == GTK_RESPONSE_NO) - image_cleared (editor); - - gtk_widget_hide (editor->file_selector); -} - -#endif - -static gboolean -file_selector_deleted (GtkWidget *widget) -{ - gtk_widget_hide (widget); - return TRUE; -} - -static void -image_clicked (GtkWidget *button, EContactEditor *editor) -{ - GtkWidget *clear_button; - GtkWidget *dialog; - const gchar *title = _("Please select an image for this contact"); - const gchar *no_image = _("No image"); - - if (!editor->file_selector) { -#ifdef USE_GTKFILECHOOSER - editor->file_selector = gtk_file_chooser_dialog_new (title, - GTK_WINDOW (editor->app), - GTK_FILE_CHOOSER_ACTION_OPEN, - GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, - GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, - no_image, GTK_RESPONSE_NO, - NULL); - gtk_dialog_set_default_response (GTK_DIALOG (editor->file_selector), GTK_RESPONSE_ACCEPT); - - gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (editor->file_selector), g_get_home_dir ()); - - g_signal_connect (editor->file_selector, "response", - G_CALLBACK (file_chooser_response), editor); -#else - /* Create the selector */ - - editor->file_selector = gtk_file_selection_new (title); - - dialog = GTK_FILE_SELECTION (editor->file_selector)->fileop_dialog; - - clear_button = gtk_dialog_add_button (GTK_DIALOG (editor->file_selector), no_image, 0); - - g_signal_connect_swapped (GTK_OBJECT (GTK_FILE_SELECTION (editor->file_selector)->ok_button), - "clicked", G_CALLBACK (image_selected), editor); - - g_signal_connect_swapped (clear_button, - "clicked", G_CALLBACK (image_cleared), editor); - - /* Ensure that the dialog box gets hidden when the user clicks a button */ - - g_signal_connect_swapped (GTK_OBJECT (GTK_FILE_SELECTION (editor->file_selector)->ok_button), - "clicked", G_CALLBACK (gtk_widget_hide), editor->file_selector); - - g_signal_connect_swapped (GTK_OBJECT (GTK_FILE_SELECTION (editor->file_selector)->cancel_button), - "clicked", G_CALLBACK (gtk_widget_hide), editor->file_selector); - - g_signal_connect_swapped (clear_button, - "clicked", G_CALLBACK (gtk_widget_hide), editor->file_selector); -#endif - - g_signal_connect_after (editor->file_selector, - "delete-event", G_CALLBACK (file_selector_deleted), - editor->file_selector); - } - - /* Display the dialog */ - - gtk_window_present (GTK_WINDOW (editor->file_selector)); -} - -typedef struct { - EContactEditor *ce; - gboolean should_close; - gchar *new_id; -} EditorCloseStruct; - -static void -contact_moved_cb (EBook *book, EBookStatus status, EditorCloseStruct *ecs) -{ - EContactEditor *ce = ecs->ce; - gboolean should_close = ecs->should_close; - - gtk_widget_set_sensitive (ce->app, TRUE); - ce->in_async_call = FALSE; - - e_contact_set (ce->contact, E_CONTACT_UID, ecs->new_id); - - eab_editor_contact_deleted (EAB_EDITOR (ce), status, ce->contact); - - ce->is_new_contact = FALSE; - - if (should_close) { - eab_editor_close (EAB_EDITOR (ce)); - } - else { - ce->changed = FALSE; - - g_object_ref (ce->target_book); - g_object_unref (ce->source_book); - ce->source_book = ce->target_book; - - sensitize_all (ce); - } - - g_object_unref (ce); - g_free (ecs->new_id); - g_free (ecs); -} - -static void -contact_added_cb (EBook *book, EBookStatus status, const char *id, EditorCloseStruct *ecs) -{ - EContactEditor *ce = ecs->ce; - gboolean should_close = ecs->should_close; - - if (ce->source_book != ce->target_book && e_book_is_writable (ce->source_book) && - status == E_BOOK_ERROR_OK && ce->is_new_contact == FALSE) { - ecs->new_id = g_strdup (id); - e_book_async_remove_contact (ce->source_book, ce->contact, - (EBookCallback) contact_moved_cb, ecs); - return; - } - - gtk_widget_set_sensitive (ce->app, TRUE); - ce->in_async_call = FALSE; - - e_contact_set (ce->contact, E_CONTACT_UID, (char *) id); - - eab_editor_contact_added (EAB_EDITOR (ce), status, ce->contact); - - if (status == E_BOOK_ERROR_OK) { - ce->is_new_contact = FALSE; - - if (should_close) { - eab_editor_close (EAB_EDITOR (ce)); - } - else { - ce->changed = FALSE; - sensitize_all (ce); - } - } - - g_object_unref (ce); - g_free (ecs); -} - -static void -contact_modified_cb (EBook *book, EBookStatus status, EditorCloseStruct *ecs) -{ - EContactEditor *ce = ecs->ce; - gboolean should_close = ecs->should_close; - - gtk_widget_set_sensitive (ce->app, TRUE); - ce->in_async_call = FALSE; - - eab_editor_contact_modified (EAB_EDITOR (ce), status, ce->contact); - - if (status == E_BOOK_ERROR_OK) { - if (should_close) { - eab_editor_close (EAB_EDITOR (ce)); - } - else { - ce->changed = FALSE; - sensitize_all (ce); - } - } - - g_object_unref (ce); - g_free (ecs); -} - -/* Emits the signal to request saving a contact */ -static void -real_save_contact (EContactEditor *ce, gboolean should_close) -{ - EditorCloseStruct *ecs; - - ecs = g_new0 (EditorCloseStruct, 1); - ecs->ce = ce; - g_object_ref (ecs->ce); - - ecs->should_close = should_close; - - gtk_widget_set_sensitive (ce->app, FALSE); - ce->in_async_call = TRUE; - - if (ce->source_book != ce->target_book) { - /* Two-step move; add to target, then remove from source */ - eab_merging_book_add_contact (ce->target_book, ce->contact, - (EBookIdCallback) contact_added_cb, ecs); - } else { - if (ce->is_new_contact) - eab_merging_book_add_contact (ce->target_book, ce->contact, - (EBookIdCallback) contact_added_cb, ecs); - else - eab_merging_book_commit_contact (ce->target_book, ce->contact, - (EBookCallback) contact_modified_cb, ecs); - } -} - -static void -save_contact (EContactEditor *ce, gboolean should_close) -{ - extract_all (ce); - if (!ce->target_book) - return; - - if (!e_contact_editor_is_valid (EAB_EDITOR (ce))) - return; - - if (ce->target_editable && !e_book_is_writable (ce->source_book)) { - if (e_error_run (GTK_WINDOW (ce->app), "addressbook:prompt-move", NULL) == GTK_RESPONSE_NO) - return; - } - - real_save_contact (ce, should_close); -} - -static void -e_contact_editor_save_contact (EABEditor *editor, gboolean should_close) -{ - save_contact (E_CONTACT_EDITOR (editor), should_close); -} - -/* Closes the dialog box and emits the appropriate signals */ -static void -e_contact_editor_close (EABEditor *editor) -{ - EContactEditor *ce = E_CONTACT_EDITOR (editor); - - if (ce->app != NULL) { - gtk_widget_destroy (ce->app); - ce->app = NULL; - eab_editor_closed (editor); - } -} - -/* insert checks here (date format, for instance, etc.) */ -static gboolean -e_contact_editor_is_valid (EABEditor *editor) -{ - EContactEditor *ce = E_CONTACT_EDITOR (editor); - GtkWidget *widget; - gboolean validation_error = FALSE; - GString *errmsg = g_string_new (_("The contact data is invalid:\n\n")); - - widget = glade_xml_get_widget (ce->gui, "dateedit-birthday"); - if (!(e_date_edit_date_is_valid (E_DATE_EDIT (widget)))) { - g_string_append_printf (errmsg, "'%s' has an invalid format", - e_contact_pretty_name (E_CONTACT_BIRTH_DATE)); - validation_error = TRUE; - } - - widget = glade_xml_get_widget (ce->gui, "dateedit-anniversary"); - if (!(e_date_edit_date_is_valid (E_DATE_EDIT (widget)))) { - g_string_append_printf (errmsg, "%s'%s' has an invalid format", - validation_error ? ",\n" : "", - e_contact_pretty_name (E_CONTACT_ANNIVERSARY)); - validation_error = TRUE; - } - - widget = glade_xml_get_widget (ce->gui, "entry-file-as"); - if (STRING_IS_EMPTY (gtk_entry_get_text (GTK_ENTRY (widget)))) { - g_string_append_printf (errmsg, "%s'%s' is empty", - validation_error ? ",\n" : "", - e_contact_pretty_name (E_CONTACT_FILE_AS)); - validation_error = TRUE; - } - - if (validation_error) { - g_string_append (errmsg, "."); - e_error_run (GTK_WINDOW (ce->app), "addressbook:generic-error", - _("Invalid contact."), errmsg->str, NULL); - g_string_free (errmsg, TRUE); - return FALSE; - } - else { - g_string_free (errmsg, TRUE); - return TRUE; - } -} - -static gboolean -e_contact_editor_is_changed (EABEditor *editor) -{ - return E_CONTACT_EDITOR (editor)->changed; -} - -static GtkWindow* -e_contact_editor_get_window (EABEditor *editor) -{ - return GTK_WINDOW (E_CONTACT_EDITOR (editor)->app); -} - -static void -file_save_and_close_cb (GtkWidget *widget, gpointer data) -{ - EContactEditor *ce; - - ce = E_CONTACT_EDITOR (data); - save_contact (ce, TRUE); -} - -static void -file_cancel_cb (GtkWidget *widget, gpointer data) -{ - EContactEditor *ce = E_CONTACT_EDITOR (data); - - eab_editor_close (EAB_EDITOR (ce)); -} - -/* Callback used when the dialog box is destroyed */ -static gint -app_delete_event_cb (GtkWidget *widget, GdkEvent *event, gpointer data) -{ - EContactEditor *ce; - - ce = E_CONTACT_EDITOR (data); - - /* if we're saving, don't allow the dialog to close */ - if (ce->in_async_call) - return TRUE; - - if (ce->changed) { - switch (eab_prompt_save_dialog (GTK_WINDOW (ce->app))) { - case GTK_RESPONSE_YES: - if (!eab_editor_is_valid (EAB_EDITOR (ce))) - return TRUE; - - eab_editor_save_contact (EAB_EDITOR (ce), TRUE); - return TRUE; - - case GTK_RESPONSE_NO: - break; - - case GTK_RESPONSE_CANCEL: - default: - return TRUE; - - } - } - - eab_editor_close (EAB_EDITOR (ce)); - return TRUE; -} - -static void -show_help_cb (GtkWidget *widget, gpointer data) -{ - GError *error = NULL; - - gnome_help_display_desktop (NULL, - "evolution-" BASE_VERSION, - "evolution-" BASE_VERSION ".xml", - "usage-contact-cards", - &error); - if (error != NULL) - g_warning ("%s", error->message); -} - -static GList * -add_to_tab_order(GList *list, GladeXML *gui, char *name) -{ - GtkWidget *widget = glade_xml_get_widget(gui, name); - return g_list_prepend(list, widget); -} - -static void -setup_tab_order(GladeXML *gui) -{ - GtkWidget *container; - GList *list = NULL; - - container = glade_xml_get_widget(gui, "table-contact-editor-general"); - - if (container) { - list = add_to_tab_order(list, gui, "entry-fullname"); - list = add_to_tab_order(list, gui, "entry-jobtitle"); - list = add_to_tab_order(list, gui, "entry-company"); - list = add_to_tab_order(list, gui, "combo-file-as"); - list = add_to_tab_order(list, gui, "entry-phone-1"); - list = add_to_tab_order(list, gui, "entry-phone-2"); - list = add_to_tab_order(list, gui, "entry-phone-3"); - list = add_to_tab_order(list, gui, "entry-phone-4"); - - list = add_to_tab_order(list, gui, "entry-email1"); - list = add_to_tab_order(list, gui, "alignment-htmlmail"); - list = add_to_tab_order(list, gui, "entry-web"); - list = add_to_tab_order(list, gui, "entry-homepage"); - list = add_to_tab_order(list, gui, "button-fulladdr"); - list = add_to_tab_order(list, gui, "text-address"); - list = g_list_reverse(list); - e_container_change_tab_order(GTK_CONTAINER(container), list); - g_list_free(list); - } -} - -static void -expand_phone_toggle (EContactEditor *ce) -{ - GtkWidget *phone_ext_table; - - phone_ext_table = glade_xml_get_widget (ce->gui, "table-phone-extended"); - expand_phone (ce, GTK_WIDGET_VISIBLE (phone_ext_table) ? FALSE : TRUE); -} - -static void -e_contact_editor_init (EContactEditor *e_contact_editor) -{ - GladeXML *gui; - GtkWidget *widget, *label; - char *icon_path; - - e_contact_editor->name = e_contact_name_new(); - - e_contact_editor->contact = NULL; - e_contact_editor->changed = FALSE; - e_contact_editor->image_set = FALSE; - e_contact_editor->in_async_call = FALSE; - e_contact_editor->target_editable = TRUE; - - e_contact_editor->load_source_id = 0; - e_contact_editor->load_book = NULL; - - gui = glade_xml_new (EVOLUTION_GLADEDIR "/contact-editor.glade", NULL, NULL); - e_contact_editor->gui = gui; - - setup_tab_order(gui); - - e_contact_editor->app = glade_xml_get_widget (gui, "contact editor"); - widget = e_contact_editor->app; - - gtk_window_set_type_hint (GTK_WINDOW (widget), GDK_WINDOW_TYPE_HINT_NORMAL); - gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (widget)->vbox), 0); - gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (widget)->action_area), 12); - - init_all (e_contact_editor); - - widget = glade_xml_get_widget (e_contact_editor->gui, "button-image"); - g_signal_connect (widget, "clicked", G_CALLBACK (image_clicked), e_contact_editor); - - widget = glade_xml_get_widget(e_contact_editor->gui, "button-fullname"); - g_signal_connect (widget, "clicked", G_CALLBACK (full_name_clicked), e_contact_editor); - widget = glade_xml_get_widget(e_contact_editor->gui, "button-categories"); - g_signal_connect (widget, "clicked", G_CALLBACK (categories_clicked), e_contact_editor); - widget = glade_xml_get_widget (e_contact_editor->gui, "source-option-menu-source"); - g_signal_connect (widget, "source_selected", G_CALLBACK (source_selected), e_contact_editor); - label = glade_xml_get_widget (e_contact_editor->gui, "where-label"); - gtk_label_set_mnemonic_widget (GTK_LABEL (label), widget); - widget = glade_xml_get_widget (e_contact_editor->gui, "button-ok"); - g_signal_connect (widget, "clicked", G_CALLBACK (file_save_and_close_cb), e_contact_editor); - widget = glade_xml_get_widget (e_contact_editor->gui, "button-cancel"); - g_signal_connect (widget, "clicked", G_CALLBACK (file_cancel_cb), e_contact_editor); - widget = glade_xml_get_widget (e_contact_editor->gui, "button-help"); - g_signal_connect (widget, "clicked", G_CALLBACK (show_help_cb), e_contact_editor); - widget = glade_xml_get_widget (e_contact_editor->gui, "button-phone-expand"); - g_signal_connect_swapped (widget, "clicked", G_CALLBACK (expand_phone_toggle), e_contact_editor); - - widget = glade_xml_get_widget (e_contact_editor->gui, "entry-fullname"); - if (widget) - gtk_widget_grab_focus (widget); - - /* Connect to the deletion of the dialog */ - - g_signal_connect (e_contact_editor->app, "delete_event", - GTK_SIGNAL_FUNC (app_delete_event_cb), e_contact_editor); - - /* set the icon */ - icon_path = g_build_filename (EVOLUTION_IMAGESDIR, "evolution-contacts-mini.png", NULL); - gnome_window_icon_set_from_file (GTK_WINDOW (e_contact_editor->app), icon_path); - g_free (icon_path); - - /* show window */ - gtk_widget_show (e_contact_editor->app); -} - -void -e_contact_editor_dispose (GObject *object) -{ - EContactEditor *e_contact_editor = E_CONTACT_EDITOR(object); - - if (e_contact_editor->file_selector != NULL) { - gtk_widget_destroy (e_contact_editor->file_selector); - e_contact_editor->file_selector = NULL; - } - - if (e_contact_editor->writable_fields) { - g_object_unref(e_contact_editor->writable_fields); - e_contact_editor->writable_fields = NULL; - } - - if (e_contact_editor->contact) { - g_object_unref(e_contact_editor->contact); - e_contact_editor->contact = NULL; - } - - if (e_contact_editor->source_book) { - g_object_unref(e_contact_editor->source_book); - e_contact_editor->source_book = NULL; - } - - if (e_contact_editor->target_book) { - g_signal_handler_disconnect (e_contact_editor->target_book, e_contact_editor->target_editable_id); - g_object_unref(e_contact_editor->target_book); - e_contact_editor->target_book = NULL; - } - - if (e_contact_editor->name) { - e_contact_name_free(e_contact_editor->name); - e_contact_editor->name = NULL; - } - - if (e_contact_editor->gui) { - g_object_unref(e_contact_editor->gui); - e_contact_editor->gui = NULL; - } - - cancel_load (e_contact_editor); - - if (G_OBJECT_CLASS (parent_class)->dispose) - (* G_OBJECT_CLASS (parent_class)->dispose) (object); -} - -static void -supported_fields_cb (EBook *book, EBookStatus status, - EList *fields, EContactEditor *ce) -{ - if (!g_slist_find ((GSList*)eab_editor_get_all_editors (), ce)) { - g_warning ("supported_fields_cb called for book that's still around, but contact editor that's been destroyed."); - return; - } - - g_object_set (ce, - "writable_fields", fields, - NULL); - - eab_editor_show (EAB_EDITOR (ce)); - - sensitize_all (ce); -} - -static void -contact_editor_destroy_notify (void *data, - GObject *where_the_object_was) -{ - eab_editor_remove (EAB_EDITOR (data)); -} - -EContactEditor * -e_contact_editor_new (EBook *book, - EContact *contact, - gboolean is_new_contact, - gboolean editable) -{ - EContactEditor *ce; - - g_return_val_if_fail (E_IS_BOOK (book), NULL); - g_return_val_if_fail (E_IS_CONTACT (contact), NULL); - - ce = g_object_new (E_TYPE_CONTACT_EDITOR, NULL); - - eab_editor_add (EAB_EDITOR (ce)); - g_object_weak_ref (G_OBJECT (ce), contact_editor_destroy_notify, ce); - - g_object_set (ce, - "source_book", book, - "contact", contact, - "is_new_contact", is_new_contact, - "editable", editable, - NULL); - - if (book) - e_book_async_get_supported_fields (book, (EBookEListCallback)supported_fields_cb, ce); - - return ce; -} - -static void -writable_changed (EBook *book, gboolean writable, EContactEditor *ce) -{ - int new_target_editable; - gboolean changed = FALSE; - - new_target_editable = e_book_is_writable (ce->target_book); - - if (ce->target_editable != new_target_editable) - changed = TRUE; - - ce->target_editable = new_target_editable; - - if (changed) - sensitize_all (ce); -} - -static void -e_contact_editor_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) -{ - EContactEditor *editor; - - editor = E_CONTACT_EDITOR (object); - - switch (prop_id){ - case PROP_SOURCE_BOOK: { - gboolean writable; - gboolean changed = FALSE; - EBook *source_book; - - source_book = E_BOOK (g_value_get_object (value)); - - if (source_book == editor->source_book) - break; - - if (editor->source_book) - g_object_unref(editor->source_book); - - editor->source_book = source_book; - g_object_ref (editor->source_book); - - if (!editor->target_book) { - editor->target_book = editor->source_book; - g_object_ref (editor->target_book); - - editor->target_editable_id = g_signal_connect (editor->target_book, "writable_status", - G_CALLBACK (writable_changed), editor); - - e_book_async_get_supported_fields (editor->target_book, - (EBookEListCallback) supported_fields_cb, editor); - } - - writable = e_book_is_writable (editor->target_book); - if (writable != editor->target_editable) { - editor->target_editable = writable; - changed = TRUE; - } - - if (changed) - sensitize_all (editor); - - break; - } - - case PROP_TARGET_BOOK: { - gboolean writable; - gboolean changed = FALSE; - EBook *target_book; - - target_book = E_BOOK (g_value_get_object (value)); - - if (target_book == editor->target_book) - break; - - if (editor->target_book) { - g_signal_handler_disconnect (editor->target_book, editor->target_editable_id); - g_object_unref(editor->target_book); - } - - editor->target_book = target_book; - g_object_ref (editor->target_book); - - editor->target_editable_id = g_signal_connect (editor->target_book, "writable_status", - G_CALLBACK (writable_changed), editor); - - e_book_async_get_supported_fields (editor->target_book, - (EBookEListCallback) supported_fields_cb, editor); - - if (!editor->is_new_contact) - editor->changed = TRUE; - - writable = e_book_is_writable (editor->target_book); - - if (writable != editor->target_editable) { - editor->target_editable = writable; - changed = TRUE; - } - - if (changed) - sensitize_all (editor); - - /* If we're trying to load a new target book, cancel that here. */ - cancel_load (editor); - break; - } - - case PROP_CONTACT: - if (editor->contact) - g_object_unref(editor->contact); - editor->contact = e_contact_duplicate(E_CONTACT(g_value_get_object (value))); - fill_in_all (editor); - editor->changed = FALSE; - break; - - case PROP_IS_NEW_CONTACT: - editor->is_new_contact = g_value_get_boolean (value) ? TRUE : FALSE; - break; - - case PROP_EDITABLE: { - gboolean new_value = g_value_get_boolean (value) ? TRUE : FALSE; - gboolean changed = (editor->target_editable != new_value); - - editor->target_editable = new_value; - - if (changed) - sensitize_all (editor); - break; - } - - case PROP_CHANGED: { - gboolean new_value = g_value_get_boolean (value) ? TRUE : FALSE; - gboolean changed = (editor->changed != new_value); - - editor->changed = new_value; - - if (changed) - sensitize_ok (editor); - break; - } - case PROP_WRITABLE_FIELDS: - if (editor->writable_fields) - g_object_unref(editor->writable_fields); - - editor->writable_fields = g_value_get_object (value); - if (editor->writable_fields) - g_object_ref (editor->writable_fields); - else - editor->writable_fields = e_list_new(NULL, NULL, NULL); - - sensitize_all (editor); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -e_contact_editor_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) -{ - EContactEditor *e_contact_editor; - - e_contact_editor = E_CONTACT_EDITOR (object); - - switch (prop_id) { - case PROP_SOURCE_BOOK: - g_value_set_object (value, e_contact_editor->source_book); - break; - - case PROP_TARGET_BOOK: - g_value_set_object (value, e_contact_editor->target_book); - break; - - case PROP_CONTACT: - extract_all (e_contact_editor); - g_value_set_object (value, e_contact_editor->contact); - break; - - case PROP_IS_NEW_CONTACT: - g_value_set_boolean (value, e_contact_editor->is_new_contact ? TRUE : FALSE); - break; - - case PROP_EDITABLE: - g_value_set_boolean (value, e_contact_editor->target_editable ? TRUE : FALSE); - break; - - case PROP_CHANGED: - g_value_set_boolean (value, e_contact_editor->changed ? TRUE : FALSE); - break; - - case PROP_WRITABLE_FIELDS: - if (e_contact_editor->writable_fields) - g_value_set_object (value, e_list_duplicate (e_contact_editor->writable_fields)); - else - g_value_set_object (value, NULL); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -/** - * e_contact_editor_raise: - * @config: The %EContactEditor object. - * - * Raises the dialog associated with this %EContactEditor object. - */ -static void -e_contact_editor_raise (EABEditor *editor) -{ - EContactEditor *ce = E_CONTACT_EDITOR (editor); - - if (GTK_WIDGET (ce->app)->window) - gdk_window_raise (GTK_WIDGET (ce->app)->window); -} - -/** - * e_contact_editor_show: - * @ce: The %EContactEditor object. - * - * Shows the dialog associated with this %EContactEditor object. - */ -static void -e_contact_editor_show (EABEditor *editor) -{ - EContactEditor *ce = E_CONTACT_EDITOR (editor); - gtk_widget_show (ce->app); -} - -GtkWidget * -e_contact_editor_create_date(gchar *name, - gchar *string1, gchar *string2, - gint int1, gint int2); - -GtkWidget * -e_contact_editor_create_date(gchar *name, - gchar *string1, gchar *string2, - gint int1, gint int2) -{ - GtkWidget *widget = e_date_edit_new (); - e_date_edit_set_allow_no_date_set (E_DATE_EDIT (widget), - TRUE); - e_date_edit_set_show_time (E_DATE_EDIT (widget), FALSE); - e_date_edit_set_time (E_DATE_EDIT (widget), -1); - gtk_widget_show (widget); - return widget; -} - -GtkWidget * -e_contact_editor_create_web(gchar *name, - gchar *string1, gchar *string2, - gint int1, gint int2); - -GtkWidget * -e_contact_editor_create_web(gchar *name, - gchar *string1, gchar *string2, - gint int1, gint int2) -{ - GtkWidget *widget = e_url_entry_new (); - gtk_widget_show (widget); - return widget; -} - -GtkWidget * -e_contact_editor_create_source_option_menu (gchar *name, - gchar *string1, gchar *string2, - gint int1, gint int2); - -GtkWidget * -e_contact_editor_create_source_option_menu (gchar *name, - gchar *string1, gchar *string2, - gint int1, gint int2) -{ - GtkWidget *menu; - GConfClient *gconf_client; - ESourceList *source_list; - - gconf_client = gconf_client_get_default (); - source_list = e_source_list_new_for_gconf (gconf_client, "/apps/evolution/addressbook/sources"); - - menu = e_source_option_menu_new (source_list); - g_object_unref (source_list); - - gtk_widget_show (menu); - return menu; -} diff --git a/addressbook/gui/contact-editor/e-contact-editor.h b/addressbook/gui/contact-editor/e-contact-editor.h deleted file mode 100644 index 6474e3c3a0..0000000000 --- a/addressbook/gui/contact-editor/e-contact-editor.h +++ /dev/null @@ -1,114 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* e-contact-editor.h - * Copyright (C) 2000 Ximian, Inc. - * Author: Chris Lahey <clahey@ximian.com> - * - * This library 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 library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ -#ifndef __E_CONTACT_EDITOR_H__ -#define __E_CONTACT_EDITOR_H__ - -#include <libgnomeui/gnome-app.h> -#include <libgnomeui/gnome-app-helper.h> -#include <bonobo/bonobo-ui-component.h> -#include <glade/glade.h> - -#include "addressbook/gui/contact-editor/eab-editor.h" - -#include <libebook/e-book.h> -#include <libebook/e-contact.h> - -#include <gtk/gtktreeview.h> -#include <gtk/gtkliststore.h> - -G_BEGIN_DECLS - -/* EContactEditor - A dialog displaying information about a contact. - * - * The following arguments are available: - * - * name type read/write description - * -------------------------------------------------------------------------------- - * card ECard * RW The card currently being edited - */ - -#define E_TYPE_CONTACT_EDITOR (e_contact_editor_get_type ()) -#define E_CONTACT_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_CONTACT_EDITOR, EContactEditor)) -#define E_CONTACT_EDITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_CONTACT_EDITOR, EContactEditorClass)) -#define E_IS_CONTACT_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_CONTACT_EDITOR)) -#define E_IS_CONTACT_EDITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), E_TYPE_CONTACT_EDITOR)) - - -typedef struct _EContactEditor EContactEditor; -typedef struct _EContactEditorClass EContactEditorClass; - -struct _EContactEditor -{ - EABEditor object; - - /* item specific fields */ - EBook *source_book; - EBook *target_book; - EContact *contact; - - /* UI handler */ - BonoboUIComponent *uic; - - GladeXML *gui; - GtkWidget *app; - - GtkWidget *file_selector; - - EContactName *name; - - /* Whether we are editing a new contact or an existing one */ - guint is_new_contact : 1; - - /* Whether the image chooser widget has been changed. */ - guint image_set : 1; - - /* Whether the contact has been changed since bringing up the contact editor */ - guint changed : 1; - - /* Whether the contact editor will accept modifications, save */ - guint target_editable : 1; - - /* Whether an async wombat call is in progress */ - guint in_async_call : 1; - - EList *writable_fields; - - /* ID for async load_source call */ - guint load_source_id; - EBook *load_book; - - /* signal ids for "writable_status" */ - int target_editable_id; -}; - -struct _EContactEditorClass -{ - EABEditorClass parent_class; -}; - -EContactEditor *e_contact_editor_new (EBook *book, - EContact *contact, - gboolean is_new_contact, - gboolean editable); -GType e_contact_editor_get_type (void); - -G_END_DECLS - -#endif /* __E_CONTACT_EDITOR_H__ */ diff --git a/addressbook/gui/contact-editor/e-contact-quick-add.c b/addressbook/gui/contact-editor/e-contact-quick-add.c deleted file mode 100644 index a317075450..0000000000 --- a/addressbook/gui/contact-editor/e-contact-quick-add.c +++ /dev/null @@ -1,447 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * e-contact-quick-add.c - * - * Copyright (C) 2001 Ximian, Inc. - * - * Developed by Jon Trowbridge <trow@ximian.com> - */ - -/* - * 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. - */ - -#include <config.h> -#include <ctype.h> -#include <string.h> -#include <glib.h> -#include <gtk/gtkentry.h> -#include <gtk/gtklabel.h> -#include <gtk/gtktable.h> -#include <gtk/gtkdialog.h> -#include <gtk/gtkstock.h> -#include <libgnome/gnome-i18n.h> -#include <libgnomeui/gnome-app.h> -#include <libebook/e-book.h> -#include <libebook/e-contact.h> -#include <addressbook/gui/component/addressbook.h> -#include <addressbook/util/eab-book-util.h> -#include "e-contact-editor.h" -#include "e-contact-quick-add.h" -#include "eab-contact-merging.h" - -typedef struct _QuickAdd QuickAdd; -struct _QuickAdd { - gchar *name; - gchar *email; - EContact *contact; - - EContactQuickAddCallback cb; - gpointer closure; - - GtkWidget *name_entry; - GtkWidget *email_entry; - - gint refs; - -}; - -static QuickAdd * -quick_add_new (void) -{ - QuickAdd *qa = g_new0 (QuickAdd, 1); - qa->contact = e_contact_new (); - qa->refs = 1; - return qa; -} - -static void -quick_add_ref (QuickAdd *qa) -{ - if (qa) { - ++qa->refs; - } -} - -static void -quick_add_unref (QuickAdd *qa) -{ - if (qa) { - --qa->refs; - if (qa->refs == 0) { - g_free (qa->name); - g_free (qa->email); - g_object_unref (qa->contact); - g_free (qa); - } - } -} - -static void -quick_add_set_name (QuickAdd *qa, const gchar *name) -{ - if (name == qa->name) - return; - - g_free (qa->name); - qa->name = g_strdup (name); - - e_contact_set (qa->contact, E_CONTACT_FULL_NAME, (char *) name); -} - -static void -quick_add_set_email (QuickAdd *qa, const gchar *email) -{ - if (email == qa->email) - return; - - g_free (qa->email); - qa->email = g_strdup (email); - - e_contact_set (qa->contact, E_CONTACT_EMAIL_1, (char*)email); -} - -static void -merge_cb (EBook *book, EBookStatus status, gpointer closure) -{ - QuickAdd *qa = (QuickAdd *) closure; - - if (status == E_BOOK_ERROR_OK) { - eab_merging_book_add_contact (book, qa->contact, NULL, NULL); - if (qa->cb) - qa->cb (qa->contact, qa->closure); - g_object_unref (book); - } else { - /* Something went wrong. */ - if (book) - g_object_unref (book); - if (qa->cb) - qa->cb (NULL, qa->closure); - } - - quick_add_unref (qa); -} - -static void -quick_add_merge_contact (QuickAdd *qa) -{ - quick_add_ref (qa); - - addressbook_load_default_book (merge_cb, qa); -} - - -/* - * Raise a contact editor with all fields editable, and hook up all signals accordingly. - */ - -static void -contact_added_cb (EContactEditor *ce, EBookStatus status, EContact *contact, gpointer closure) -{ - QuickAdd *qa = (QuickAdd *) g_object_get_data (G_OBJECT (ce), "quick_add"); - - if (qa) { - - if (qa->cb) - qa->cb (qa->contact, qa->closure); - - /* We don't need to unref qa because we set_data_full below */ - g_object_set_data (G_OBJECT (ce), "quick_add", NULL); - } -} - -static void -editor_closed_cb (GtkWidget *w, gpointer closure) -{ - QuickAdd *qa = (QuickAdd *) g_object_get_data (G_OBJECT (w), "quick_add"); - - if (qa) - /* We don't need to unref qa because we set_data_full below */ - g_object_set_data (G_OBJECT (w), "quick_add", NULL); - - g_object_unref (w); -} - -static void -ce_have_book (EBook *book, EBookStatus status, gpointer closure) -{ - QuickAdd *qa = (QuickAdd *) closure; - - if (status != E_BOOK_ERROR_OK) { - if (book) - g_object_unref (book); - g_warning ("Couldn't open local address book."); - quick_add_unref (qa); - } else { - EContactEditor *contact_editor = e_contact_editor_new (book, qa->contact, TRUE, TRUE /* XXX */); - - /* mark it as changed so the Save buttons are enabled when we bring up the dialog. */ - g_object_set (contact_editor, - "changed", TRUE, - NULL); - - /* We pass this via object data, so that we don't get a dangling pointer referenced if both - the "contact_added" and "editor_closed" get emitted. (Which, based on a backtrace in bugzilla, - I think can happen and cause a crash. */ - g_object_set_data_full (G_OBJECT (contact_editor), "quick_add", qa, - (GDestroyNotify) quick_add_unref); - - g_signal_connect (contact_editor, - "contact_added", - G_CALLBACK (contact_added_cb), - NULL); - g_signal_connect (contact_editor, - "editor_closed", - G_CALLBACK (editor_closed_cb), - NULL); - - g_object_unref (book); - } -} - -static void -edit_contact (QuickAdd *qa) -{ - addressbook_load_default_book (ce_have_book, qa); -} - -#define QUICK_ADD_RESPONSE_EDIT_FULL 2 - -static void -clicked_cb (GtkWidget *w, gint button, gpointer closure) -{ - QuickAdd *qa = (QuickAdd *) closure; - - /* Get data out of entries. */ - if (button == GTK_RESPONSE_OK || button == QUICK_ADD_RESPONSE_EDIT_FULL) { - gchar *name = NULL; - gchar *email = NULL; - - if (qa->name_entry) { - gchar *tmp; - tmp = gtk_editable_get_chars (GTK_EDITABLE (qa->name_entry), 0, -1); - name = tmp; - } - - if (qa->email_entry) { - gchar *tmp; - tmp = gtk_editable_get_chars (GTK_EDITABLE (qa->email_entry), 0, -1); - email = tmp; - } - - quick_add_set_name (qa, name); - quick_add_set_email (qa, email); - - g_free (name); - g_free (email); - } - - gtk_widget_destroy (w); - - if (button == GTK_RESPONSE_OK) { - - /* OK */ - quick_add_merge_contact (qa); - - } else if (button == QUICK_ADD_RESPONSE_EDIT_FULL) { - - /* EDIT FULL */ - edit_contact (qa); - - } else { - /* CANCEL */ - quick_add_unref (qa); - } - -} - -static GtkWidget * -build_quick_add_dialog (QuickAdd *qa) -{ - GtkWidget *dialog; - GtkTable *table; - const gint xpad=6, ypad=6; - - g_return_val_if_fail (qa != NULL, NULL); - - dialog = gtk_dialog_new_with_buttons (_("Contact Quick-Add"), - NULL, /* XXX */ - (GtkDialogFlags) 0, - _("_Edit Full"), QUICK_ADD_RESPONSE_EDIT_FULL, - GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, - GTK_STOCK_OK, GTK_RESPONSE_OK, - NULL); - - g_signal_connect (dialog, "response", G_CALLBACK (clicked_cb), qa); - - qa->name_entry = gtk_entry_new (); - if (qa->name) - gtk_entry_set_text (GTK_ENTRY (qa->name_entry), qa->name); - - - qa->email_entry = gtk_entry_new (); - if (qa->email) - gtk_entry_set_text (GTK_ENTRY (qa->email_entry), qa->email); - - table = GTK_TABLE (gtk_table_new (2, 2, FALSE)); - - gtk_table_attach (table, gtk_label_new_with_mnemonic (_("_Full Name:")), - 0, 1, 0, 1, - 0, 0, xpad, ypad); - gtk_table_attach (table, qa->name_entry, - 1, 2, 0, 1, - GTK_EXPAND | GTK_FILL, GTK_EXPAND, xpad, ypad); - gtk_table_attach (table, gtk_label_new_with_mnemonic (_("E-_mail:")), - 0, 1, 1, 2, - 0, 0, xpad, ypad); - gtk_table_attach (table, qa->email_entry, - 1, 2, 1, 2, - GTK_EXPAND | GTK_FILL, GTK_EXPAND, xpad, ypad); - gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), - 6); - - gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->vbox),6); - - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), - GTK_WIDGET (table), - TRUE, TRUE, 6); - gtk_widget_show_all (GTK_WIDGET (table)); - - - return dialog; -} - -void -e_contact_quick_add (const gchar *in_name, const gchar *email, - EContactQuickAddCallback cb, gpointer closure) -{ - QuickAdd *qa; - GtkWidget *dialog; - gchar *name = NULL; - gint len; - - /* We need to have *something* to work with. */ - if (in_name == NULL && email == NULL) { - if (cb) - cb (NULL, closure); - return; - } - - if (in_name) { - name = g_strdup (in_name); - - /* Remove extra whitespace and the quotes some mailers put around names. */ - g_strstrip (name); - len = strlen (name); - if ((name[0] == '\'' && name[len-1] == '\'') || (name[0] == '"' && name[len-1] == '"')) { - name[0] = ' '; - name[len-1] = ' '; - } - g_strstrip (name); - } - - qa = quick_add_new (); - qa->cb = cb; - qa->closure = closure; - if (name) - quick_add_set_name (qa, name); - if (email) - quick_add_set_email (qa, email); - - dialog = build_quick_add_dialog (qa); - gtk_widget_show_all (dialog); - - g_free (name); -} - -void -e_contact_quick_add_free_form (const gchar *text, EContactQuickAddCallback cb, gpointer closure) -{ - gchar *name=NULL, *email=NULL; - const gchar *last_at, *s; - gboolean in_quote; - - if (text == NULL) { - e_contact_quick_add (NULL, NULL, cb, closure); - return; - } - - /* Look for things that look like e-mail addresses embedded in text */ - in_quote = FALSE; - last_at = NULL; - for (s = text; *s; ++s) { - if (*s == '@' && !in_quote) - last_at = s; - else if (*s == '"') - in_quote = !in_quote; - } - - - if (last_at == NULL) { - /* No at sign, so we treat it all as the name */ - name = g_strdup (text); - } else { - gboolean bad_char = FALSE; - - /* walk backwards to whitespace or a < or a quote... */ - while (last_at >= text && !bad_char - && !(isspace ((gint) *last_at) || *last_at == '<' || *last_at == '"')) { - /* Check for some stuff that can't appear in a legal e-mail address. */ - if (*last_at == '[' - || *last_at == ']' - || *last_at == '(' - || *last_at == ')') - bad_char = TRUE; - --last_at; - } - if (last_at < text) - last_at = text; - - /* ...and then split the text there */ - if (!bad_char) { - if (text < last_at) - name = g_strndup (text, last_at-text); - email = g_strdup (last_at); - } - } - - /* If all else has failed, make it the name. */ - if (name == NULL && email == NULL) - name = g_strdup (text); - - - - /* Clean up email, remove bracketing <>s */ - if (email && *email) { - gboolean changed = FALSE; - g_strstrip (email); - if (*email == '<') { - *email = ' '; - changed = TRUE; - } - if (email[strlen (email)-1] == '>') { - email[strlen (email)-1] = ' '; - changed = TRUE; - } - if (changed) - g_strstrip (email); - } - - - e_contact_quick_add (name, email, cb, closure); - g_free (name); - g_free (email); -} diff --git a/addressbook/gui/contact-editor/e-contact-quick-add.h b/addressbook/gui/contact-editor/e-contact-quick-add.h deleted file mode 100644 index a969211915..0000000000 --- a/addressbook/gui/contact-editor/e-contact-quick-add.h +++ /dev/null @@ -1,40 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * e-contact-quick-add.h - * - * Copyright (C) 2001 Ximian, Inc. - * - * Developed by Jon Trowbridge <trow@ximian.com> - */ - -/* - * 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. - */ - -#ifndef __E_CONTACT_QUICK_ADD_H__ -#define __E_CONTACT_QUICK_ADD_H__ - -#include <libebook/e-contact.h> - -typedef void (*EContactQuickAddCallback) (EContact *new_contact, gpointer closure); - -void e_contact_quick_add (const gchar *name, const gchar *email, - EContactQuickAddCallback cb, gpointer closure); - -void e_contact_quick_add_free_form (const gchar *text, EContactQuickAddCallback cb, gpointer closure); - -#endif /* __E_CONTACT_QUICK_ADD_H__ */ - diff --git a/addressbook/gui/contact-editor/eab-editor.c b/addressbook/gui/contact-editor/eab-editor.c deleted file mode 100644 index 4f535e47c8..0000000000 --- a/addressbook/gui/contact-editor/eab-editor.c +++ /dev/null @@ -1,390 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* eab-editor.c - * Copyright (C) 2004 Novell, Inc. - * Author: Chris Toshok <toshok@ximian.com> - * - * This library 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 library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <gtk/gtkstock.h> -#include <gtk/gtkmessagedialog.h> -#include <libgnome/gnome-i18n.h> - -#include "eab-editor.h" -#include "addressbook/gui/widgets/eab-gui-util.h" -#include "e-contact-editor-marshal.h" - -static void eab_editor_default_show (EABEditor *editor); -static void eab_editor_default_raise (EABEditor *editor); -static void eab_editor_default_close (EABEditor *editor); -static void eab_editor_class_init (EABEditorClass *klass); -static void eab_editor_init (EABEditor *editor); - -/* Signal IDs */ -enum { - CONTACT_ADDED, - CONTACT_MODIFIED, - CONTACT_DELETED, - EDITOR_CLOSED, - LAST_SIGNAL -}; - -static GSList *all_editors = NULL; - -static GtkObjectClass *parent_class = NULL; - -static guint editor_signals[LAST_SIGNAL]; - -GType -eab_editor_get_type (void) -{ - static GType editor_type = 0; - - if (!editor_type) { - static const GTypeInfo editor_info = { - sizeof (EABEditorClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) eab_editor_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (EABEditor), - 0, /* n_preallocs */ - (GInstanceInitFunc) eab_editor_init, - }; - - editor_type = g_type_register_static (G_TYPE_OBJECT, "EABEditor", &editor_info, 0); - } - - return editor_type; -} - -static void -eab_editor_default_show (EABEditor *editor) -{ - g_warning ("abstract eab_editor_show called"); -} - -static void -eab_editor_default_close (EABEditor *editor) -{ - g_warning ("abstract eab_editor_close called"); -} - -static void -eab_editor_default_raise (EABEditor *editor) -{ - g_warning ("abstract eab_editor_raise called"); -} - -static void -eab_editor_default_save_contact (EABEditor *editor, gboolean should_close) -{ - g_warning ("abstract eab_editor_save_contact called"); -} - -static gboolean -eab_editor_default_is_valid (EABEditor *editor) -{ - g_warning ("abstract eab_editor_is_valid called"); - return FALSE; -} - -static gboolean -eab_editor_default_is_changed (EABEditor *editor) -{ - g_warning ("abstract eab_editor_is_changed called"); - return FALSE; -} - -static GtkWindow* -eab_editor_default_get_window (EABEditor *editor) -{ - g_warning ("abstract eab_editor_get_window called"); - return NULL; -} - -static void -eab_editor_class_init (EABEditorClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - parent_class = g_type_class_ref (G_TYPE_OBJECT); - - klass->show = eab_editor_default_show; - klass->close = eab_editor_default_close; - klass->raise = eab_editor_default_raise; - klass->save_contact = eab_editor_default_save_contact; - klass->is_valid = eab_editor_default_is_valid; - klass->is_changed = eab_editor_default_is_changed; - klass->get_window = eab_editor_default_get_window; - - editor_signals[CONTACT_ADDED] = - g_signal_new ("contact_added", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (EABEditorClass, contact_added), - NULL, NULL, - e_contact_editor_marshal_NONE__INT_OBJECT, - G_TYPE_NONE, 2, - G_TYPE_INT, G_TYPE_OBJECT); - - editor_signals[CONTACT_MODIFIED] = - g_signal_new ("contact_modified", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (EABEditorClass, contact_modified), - NULL, NULL, - e_contact_editor_marshal_NONE__INT_OBJECT, - G_TYPE_NONE, 2, - G_TYPE_INT, G_TYPE_OBJECT); - - editor_signals[CONTACT_DELETED] = - g_signal_new ("contact_deleted", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (EABEditorClass, contact_deleted), - NULL, NULL, - e_contact_editor_marshal_NONE__INT_OBJECT, - G_TYPE_NONE, 2, - G_TYPE_INT, G_TYPE_OBJECT); - - editor_signals[EDITOR_CLOSED] = - g_signal_new ("editor_closed", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (EABEditorClass, editor_closed), - NULL, NULL, - e_contact_editor_marshal_NONE__NONE, - G_TYPE_NONE, 0); -} - -static void -eab_editor_init (EABEditor *editor) -{ -} - - - -void -eab_editor_show (EABEditor *editor) -{ - g_return_if_fail (EAB_IS_EDITOR (editor)); - - if (EAB_EDITOR_GET_CLASS(editor)->show) - EAB_EDITOR_GET_CLASS(editor)->show (editor); -} - -void -eab_editor_close (EABEditor *editor) -{ - g_return_if_fail (EAB_IS_EDITOR (editor)); - - if (EAB_EDITOR_GET_CLASS(editor)->close) - EAB_EDITOR_GET_CLASS(editor)->close (editor); -} - -void -eab_editor_raise (EABEditor *editor) -{ - g_return_if_fail (EAB_IS_EDITOR (editor)); - - if (EAB_EDITOR_GET_CLASS(editor)->raise) - EAB_EDITOR_GET_CLASS(editor)->raise (editor); -} - -void -eab_editor_save_contact (EABEditor *editor, gboolean should_close) -{ - g_return_if_fail (EAB_IS_EDITOR (editor)); - - if (EAB_EDITOR_GET_CLASS(editor)->save_contact) - EAB_EDITOR_GET_CLASS(editor)->save_contact (editor, should_close); -} - -gboolean -eab_editor_is_changed (EABEditor *editor) -{ - g_return_val_if_fail (EAB_IS_EDITOR (editor), FALSE); - - if (EAB_EDITOR_GET_CLASS(editor)->is_changed) - return EAB_EDITOR_GET_CLASS(editor)->is_changed (editor); - else - return FALSE; -} - -gboolean -eab_editor_is_valid (EABEditor *editor) -{ - g_return_val_if_fail (EAB_IS_EDITOR (editor), FALSE); - - if (EAB_EDITOR_GET_CLASS(editor)->is_valid) - return EAB_EDITOR_GET_CLASS(editor)->is_valid (editor); - else - return FALSE; -} - -GtkWindow* -eab_editor_get_window (EABEditor *editor) -{ - g_return_val_if_fail (EAB_IS_EDITOR (editor), NULL); - - if (EAB_EDITOR_GET_CLASS(editor)->get_window) - return EAB_EDITOR_GET_CLASS(editor)->get_window (editor); - else - return NULL; -} - -gboolean -eab_editor_prompt_to_save_changes (EABEditor *editor, GtkWindow *window) -{ - if (!eab_editor_is_changed (editor)) - return TRUE; - - switch (eab_prompt_save_dialog (window)) { - case GTK_RESPONSE_YES: - if (!eab_editor_is_valid (editor)) { - return FALSE; - } - eab_editor_save_contact (editor, FALSE); - return TRUE; - case GTK_RESPONSE_NO: - return TRUE; - case GTK_RESPONSE_CANCEL: - default: - return FALSE; - } -} - -gboolean -eab_editor_request_close_all (void) -{ - GSList *p; - GSList *pnext; - gboolean retval; - - retval = TRUE; - for (p = all_editors; p != NULL; p = pnext) { - EABEditor *editor = EAB_EDITOR (p->data); - GtkWindow *window = eab_editor_get_window (editor); - - pnext = p->next; - - eab_editor_raise (editor); - if (! eab_editor_prompt_to_save_changes (editor, window)) { - retval = FALSE; - break; - } - eab_editor_close (editor); - } - - return retval; -} - -const GSList* -eab_editor_get_all_editors (void) -{ - return all_editors; -} - -gboolean -eab_editor_confirm_delete (GtkWindow *parent) -{ - GtkWidget *dialog; - gint result; - - dialog = gtk_message_dialog_new (parent, - 0, - GTK_MESSAGE_QUESTION, - GTK_BUTTONS_NONE, -#if notyet - /* XXX we really need to handle the plural case here.. */ - (plural - ? _("Are you sure you want\n" - "to delete these contacts?")) -#endif - _("Are you sure you want\n" - "to delete this contact?")); - - gtk_dialog_add_buttons (GTK_DIALOG (dialog), - GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, - GTK_STOCK_DELETE, GTK_RESPONSE_ACCEPT, - NULL); - - result = gtk_dialog_run(GTK_DIALOG (dialog)); - - gtk_widget_destroy (dialog); - - return (result == GTK_RESPONSE_ACCEPT); -} - - -void -eab_editor_contact_added (EABEditor *editor, EBookStatus status, EContact *contact) -{ - g_return_if_fail (EAB_IS_EDITOR (editor)); - g_return_if_fail (E_IS_CONTACT (contact)); - - g_signal_emit (editor, editor_signals[CONTACT_ADDED], 0, - status, contact); -} - -void -eab_editor_contact_modified (EABEditor *editor, EBookStatus status, EContact *contact) -{ - g_return_if_fail (EAB_IS_EDITOR (editor)); - g_return_if_fail (E_IS_CONTACT (contact)); - - g_signal_emit (editor, editor_signals[CONTACT_MODIFIED], 0, - status, contact); -} - -void -eab_editor_contact_deleted (EABEditor *editor, EBookStatus status, EContact *contact) -{ - g_return_if_fail (EAB_IS_EDITOR (editor)); - g_return_if_fail (E_IS_CONTACT (contact)); - - g_signal_emit (editor, editor_signals[CONTACT_DELETED], 0, - status, contact); -} - -void -eab_editor_closed (EABEditor *editor) -{ - g_return_if_fail (EAB_IS_EDITOR (editor)); - - g_signal_emit (editor, editor_signals[EDITOR_CLOSED], 0); -} - -void -eab_editor_add (EABEditor *editor) -{ - g_return_if_fail (EAB_IS_EDITOR (editor)); - - all_editors = g_slist_prepend (all_editors, editor); -} - -void -eab_editor_remove (EABEditor *editor) -{ - g_return_if_fail (EAB_IS_EDITOR (editor)); - - all_editors = g_slist_remove (all_editors, editor); -} diff --git a/addressbook/gui/contact-editor/eab-editor.h b/addressbook/gui/contact-editor/eab-editor.h deleted file mode 100644 index 6c1afccf21..0000000000 --- a/addressbook/gui/contact-editor/eab-editor.h +++ /dev/null @@ -1,110 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* eab-editor.h - * Copyright (C) 2004 Novell, Inc. - * Author: Chris Toshok <toshok@ximian.com> - * - * This library 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 library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ -#ifndef __EAB_EDITOR_H__ -#define __EAB_EDITOR_H__ - -#include <libgnomeui/gnome-app.h> -#include <libgnomeui/gnome-app-helper.h> -#include <bonobo/bonobo-ui-component.h> -#include <glade/glade.h> - -#include <libebook/e-book.h> -#include <libebook/e-contact.h> - -#include <gtk/gtktreeview.h> -#include <gtk/gtkliststore.h> - -G_BEGIN_DECLS - -/* EABEditor - A dialog displaying information about a contact. - * - * The following arguments are available: - * - * name type read/write description - * -------------------------------------------------------------------------------- - * card ECard * RW The card currently being edited - */ - -#define EAB_TYPE_EDITOR (eab_editor_get_type ()) -#define EAB_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EAB_TYPE_EDITOR, EABEditor)) -#define EAB_EDITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EAB_TYPE_EDITOR, EABEditorClass)) -#define EAB_IS_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EAB_TYPE_EDITOR)) -#define EAB_IS_EDITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), EAB_TYPE_EDITOR)) -#define EAB_EDITOR_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), EAB_EDITOR_TYPE, EABEditorClass)) - - -typedef struct _EABEditor EABEditor; -typedef struct _EABEditorClass EABEditorClass; - -struct _EABEditor -{ - GObject parent; -}; - -struct _EABEditorClass -{ - GObjectClass parent_class; - - /* virtual functions */ - void (* show) (EABEditor *editor); - void (* close) (EABEditor *editor); - void (* raise) (EABEditor *editor); - void (* save_contact) (EABEditor *editor, gboolean should_close); - gboolean (* is_valid) (EABEditor *editor); - gboolean (* is_changed) (EABEditor *editor); - GtkWindow* (* get_window) (EABEditor *editor); - - /* signals */ - void (* contact_added) (EABEditor *editor, EBookStatus status, EContact *contact); - void (* contact_modified) (EABEditor *editor, EBookStatus status, EContact *contact); - void (* contact_deleted) (EABEditor *editor, EBookStatus status, EContact *contact); - void (* editor_closed) (EABEditor *editor); -}; - -GType eab_editor_get_type (void); - -/* virtual functions */ -void eab_editor_show (EABEditor *editor); -void eab_editor_close (EABEditor *editor); -void eab_editor_raise (EABEditor *editor); -void eab_editor_save_contact (EABEditor *editor, gboolean should_close); -gboolean eab_editor_is_valid (EABEditor *editor); -gboolean eab_editor_is_changed (EABEditor *editor); -GtkWindow* eab_editor_get_window (EABEditor *editor); - -gboolean eab_editor_prompt_to_save_changes (EABEditor *editor, GtkWindow *window); -gboolean eab_editor_confirm_delete (GtkWindow *parent); - -/* these four generate EABEditor signals */ -void eab_editor_contact_added (EABEditor *editor, EBookStatus status, EContact *contact); -void eab_editor_contact_modified (EABEditor *editor, EBookStatus status, EContact *contact); -void eab_editor_contact_deleted (EABEditor *editor, EBookStatus status, EContact *contact); -void eab_editor_closed (EABEditor *editor); - -/* these maintain the global list of editors so we can prompt the user - if there are unsaved changes when they exit. */ -void eab_editor_add (EABEditor *editor); -void eab_editor_remove (EABEditor *editor); -gboolean eab_editor_request_close_all (void); -const GSList* eab_editor_get_all_editors (void); - -G_END_DECLS - -#endif /* __E_CONTACT_EDITOR_H__ */ diff --git a/addressbook/gui/contact-editor/fulladdr.glade b/addressbook/gui/contact-editor/fulladdr.glade deleted file mode 100644 index c7767b9751..0000000000 --- a/addressbook/gui/contact-editor/fulladdr.glade +++ /dev/null @@ -1,446 +0,0 @@ -<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*--> -<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd"> - -<glade-interface> - -<widget class="GtkDialog" id="dialog-checkaddress"> - <property name="title" translatable="yes">Full Address</property> - <property name="type">GTK_WINDOW_TOPLEVEL</property> - <property name="window_position">GTK_WIN_POS_NONE</property> - <property name="modal">True</property> - <property name="resizable">True</property> - <property name="destroy_with_parent">False</property> - <property name="has_separator">True</property> - - <child internal-child="vbox"> - <widget class="GtkVBox" id="vbox-container"> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">8</property> - - <child internal-child="action_area"> - <widget class="GtkHButtonBox" id="hbuttonbox1"> - <property name="visible">True</property> - <property name="layout_style">GTK_BUTTONBOX_END</property> - - <child> - <widget class="GtkButton" id="button1"> - <property name="visible">True</property> - <property name="can_default">True</property> - <property name="has_default">True</property> - <property name="can_focus">True</property> - <property name="label">gtk-ok</property> - <property name="use_stock">True</property> - <property name="relief">GTK_RELIEF_NORMAL</property> - <property name="response_id">0</property> - </widget> - </child> - - <child> - <widget class="GtkButton" id="button2"> - <property name="visible">True</property> - <property name="can_default">True</property> - <property name="can_focus">True</property> - <property name="label">gtk-cancel</property> - <property name="use_stock">True</property> - <property name="relief">GTK_RELIEF_NORMAL</property> - <property name="response_id">0</property> - </widget> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="pack_type">GTK_PACK_END</property> - </packing> - </child> - - <child> - <widget class="GtkTable" id="table-checkaddress"> - <property name="border_width">6</property> - <property name="visible">True</property> - <property name="n_rows">4</property> - <property name="n_columns">4</property> - <property name="homogeneous">False</property> - <property name="row_spacing">6</property> - <property name="column_spacing">6</property> - - <child> - <widget class="GtkLabel" id="label-street"> - <property name="visible">True</property> - <property name="label" translatable="yes">_Address:</property> - <property name="use_underline">True</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">1</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="mnemonic_widget">entry-street</property> - </widget> - <packing> - <property name="left_attach">0</property> - <property name="right_attach">1</property> - <property name="top_attach">0</property> - <property name="bottom_attach">1</property> - <property name="x_options">fill</property> - <property name="y_options">fill</property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label-city"> - <property name="visible">True</property> - <property name="label" translatable="yes">Ci_ty:</property> - <property name="use_underline">True</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_CENTER</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">1</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="mnemonic_widget">entry-city</property> - </widget> - <packing> - <property name="left_attach">0</property> - <property name="right_attach">1</property> - <property name="top_attach">2</property> - <property name="bottom_attach">3</property> - <property name="x_options">fill</property> - <property name="y_options">fill</property> - </packing> - </child> - - <child> - <widget class="GtkEntry" id="entry-city"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="editable">True</property> - <property name="visibility">True</property> - <property name="max_length">0</property> - <property name="text" translatable="yes"></property> - <property name="has_frame">True</property> - <property name="invisible_char" translatable="yes">*</property> - <property name="activates_default">False</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">2</property> - <property name="bottom_attach">3</property> - <property name="y_options">fill</property> - </packing> - </child> - - <child> - <widget class="GtkEntry" id="entry-ext"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="editable">True</property> - <property name="visibility">True</property> - <property name="max_length">0</property> - <property name="text" translatable="yes"></property> - <property name="has_frame">True</property> - <property name="invisible_char" translatable="yes">*</property> - <property name="activates_default">False</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="y_options">fill</property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label-po"> - <property name="visible">True</property> - <property name="label" translatable="yes">_PO Box:</property> - <property name="use_underline">True</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_CENTER</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">1</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="mnemonic_widget">entry-po</property> - </widget> - <packing> - <property name="left_attach">2</property> - <property name="right_attach">3</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="x_options">fill</property> - <property name="y_options">fill</property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label-ext"> - <property name="visible">True</property> - <property name="label" translatable="yes">Address _2:</property> - <property name="use_underline">True</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_CENTER</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">1</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="mnemonic_widget">entry-ext</property> - </widget> - <packing> - <property name="left_attach">0</property> - <property name="right_attach">1</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="x_options">fill</property> - <property name="y_options">fill</property> - </packing> - </child> - - <child> - <widget class="GtkEntry" id="entry-po"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="editable">True</property> - <property name="visibility">True</property> - <property name="max_length">0</property> - <property name="text" translatable="yes"></property> - <property name="has_frame">True</property> - <property name="invisible_char" translatable="yes">*</property> - <property name="activates_default">False</property> - </widget> - <packing> - <property name="left_attach">3</property> - <property name="right_attach">4</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="x_options">fill</property> - <property name="y_options">fill</property> - </packing> - </child> - - <child> - <widget class="GtkEntry" id="entry-street"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="has_focus">True</property> - <property name="editable">True</property> - <property name="visibility">True</property> - <property name="max_length">0</property> - <property name="text" translatable="yes"></property> - <property name="has_frame">True</property> - <property name="invisible_char" translatable="yes">*</property> - <property name="activates_default">False</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">4</property> - <property name="top_attach">0</property> - <property name="bottom_attach">1</property> - <property name="y_options">fill</property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label-region"> - <property name="visible">True</property> - <property name="label" translatable="yes">_State/Province:</property> - <property name="use_underline">True</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_CENTER</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">1</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="mnemonic_widget">entry-region</property> - </widget> - <packing> - <property name="left_attach">0</property> - <property name="right_attach">1</property> - <property name="top_attach">3</property> - <property name="bottom_attach">4</property> - <property name="x_options">fill</property> - <property name="y_options">fill</property> - </packing> - </child> - - <child> - <widget class="GtkEntry" id="entry-region"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="editable">True</property> - <property name="visibility">True</property> - <property name="max_length">0</property> - <property name="text" translatable="yes"></property> - <property name="has_frame">True</property> - <property name="invisible_char" translatable="yes">*</property> - <property name="activates_default">False</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">3</property> - <property name="bottom_attach">4</property> - <property name="y_options">fill</property> - </packing> - </child> - - <child> - <widget class="GtkCombo" id="combo-country"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="value_in_list">False</property> - <property name="allow_empty">True</property> - <property name="case_sensitive">False</property> - <property name="enable_arrow_keys">True</property> - <property name="enable_arrows_always">False</property> - - <child internal-child="entry"> - <widget class="GtkEntry" id="entry-country"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="editable">True</property> - <property name="visibility">True</property> - <property name="max_length">0</property> - <property name="text" translatable="yes"></property> - <property name="has_frame">True</property> - <property name="invisible_char" translatable="yes">*</property> - <property name="activates_default">False</property> - </widget> - </child> - - <child internal-child="list"> - <widget class="GtkList" id="convertwidget1"> - <property name="visible">True</property> - <property name="selection_mode">GTK_SELECTION_BROWSE</property> - - <child> - <widget class="GtkListItem" id="convertwidget2"> - <property name="visible">True</property> - - <child> - <widget class="GtkLabel" id="convertwidget3"> - <property name="visible">True</property> - <property name="label" translatable="yes"></property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - </child> - </widget> - </child> - </widget> - </child> - </widget> - <packing> - <property name="left_attach">3</property> - <property name="right_attach">4</property> - <property name="top_attach">3</property> - <property name="bottom_attach">4</property> - <property name="x_options">fill</property> - <property name="y_options">fill</property> - </packing> - </child> - - <child> - <widget class="GtkEntry" id="entry-code"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="editable">True</property> - <property name="visibility">True</property> - <property name="max_length">0</property> - <property name="text" translatable="yes"></property> - <property name="has_frame">True</property> - <property name="invisible_char" translatable="yes">*</property> - <property name="activates_default">False</property> - </widget> - <packing> - <property name="left_attach">3</property> - <property name="right_attach">4</property> - <property name="top_attach">2</property> - <property name="bottom_attach">3</property> - <property name="x_options">fill</property> - <property name="y_options">fill</property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label-code"> - <property name="visible">True</property> - <property name="label" translatable="yes">_ZIP Code:</property> - <property name="use_underline">True</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_CENTER</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">1</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="mnemonic_widget">entry-code</property> - </widget> - <packing> - <property name="left_attach">2</property> - <property name="right_attach">3</property> - <property name="top_attach">2</property> - <property name="bottom_attach">3</property> - <property name="x_options">fill</property> - <property name="y_options">fill</property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label-country"> - <property name="visible">True</property> - <property name="label" translatable="yes">Countr_y:</property> - <property name="use_underline">True</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_CENTER</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">1</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="mnemonic_widget">entry-country</property> - </widget> - <packing> - <property name="left_attach">2</property> - <property name="right_attach">3</property> - <property name="top_attach">3</property> - <property name="bottom_attach">4</property> - <property name="x_options">fill</property> - <property name="y_options">fill</property> - </packing> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">True</property> - <property name="fill">True</property> - </packing> - </child> - </widget> - </child> -</widget> - -</glade-interface> diff --git a/addressbook/gui/contact-editor/fullname.glade b/addressbook/gui/contact-editor/fullname.glade deleted file mode 100644 index f2ae7c92eb..0000000000 --- a/addressbook/gui/contact-editor/fullname.glade +++ /dev/null @@ -1,681 +0,0 @@ -<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*--> -<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd"> - -<glade-interface> - -<widget class="GtkDialog" id="dialog-checkfullname"> - <property name="title" translatable="yes">Full Name</property> - <property name="type">GTK_WINDOW_TOPLEVEL</property> - <property name="window_position">GTK_WIN_POS_NONE</property> - <property name="modal">True</property> - <property name="resizable">True</property> - <property name="destroy_with_parent">False</property> - <property name="decorated">True</property> - <property name="skip_taskbar_hint">False</property> - <property name="skip_pager_hint">False</property> - <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property> - <property name="gravity">GDK_GRAVITY_NORTH_WEST</property> - <property name="has_separator">False</property> - - <child internal-child="vbox"> - <widget class="GtkVBox" id="vbox-container"> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">8</property> - - <child internal-child="action_area"> - <widget class="GtkHButtonBox" id="hbuttonbox1"> - <property name="visible">True</property> - <property name="layout_style">GTK_BUTTONBOX_END</property> - - <child> - <widget class="GtkButton" id="button1"> - <property name="visible">True</property> - <property name="can_default">True</property> - <property name="can_focus">True</property> - <property name="label">gtk-ok</property> - <property name="use_stock">True</property> - <property name="relief">GTK_RELIEF_NORMAL</property> - <property name="focus_on_click">True</property> - <property name="response_id">0</property> - </widget> - </child> - - <child> - <widget class="GtkButton" id="button2"> - <property name="visible">True</property> - <property name="can_default">True</property> - <property name="can_focus">True</property> - <property name="label">gtk-cancel</property> - <property name="use_stock">True</property> - <property name="relief">GTK_RELIEF_NORMAL</property> - <property name="focus_on_click">True</property> - <property name="response_id">0</property> - </widget> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="pack_type">GTK_PACK_END</property> - </packing> - </child> - - <child> - <widget class="GtkTable" id="table-checkfullname"> - <property name="border_width">12</property> - <property name="visible">True</property> - <property name="n_rows">5</property> - <property name="n_columns">3</property> - <property name="homogeneous">False</property> - <property name="row_spacing">6</property> - <property name="column_spacing">6</property> - - <child> - <widget class="GtkCombo" id="combo-title"> - <property name="visible">True</property> - <property name="value_in_list">False</property> - <property name="allow_empty">True</property> - <property name="case_sensitive">False</property> - <property name="enable_arrow_keys">True</property> - <property name="enable_arrows_always">False</property> - - <child internal-child="entry"> - <widget class="GtkEntry" id="entry-title"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="editable">True</property> - <property name="visibility">True</property> - <property name="max_length">0</property> - <property name="text" translatable="yes"></property> - <property name="has_frame">True</property> - <property name="invisible_char" translatable="yes">*</property> - <property name="activates_default">False</property> - </widget> - </child> - - <child internal-child="list"> - <widget class="GtkList" id="convertwidget1"> - <property name="visible">True</property> - <property name="selection_mode">GTK_SELECTION_BROWSE</property> - - <child> - <widget class="GtkListItem" id="convertwidget2"> - <property name="visible">True</property> - - <child> - <widget class="GtkLabel" id="convertwidget3"> - <property name="visible">True</property> - <property name="label" translatable="yes"></property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - </child> - </widget> - </child> - - <child> - <widget class="GtkListItem" id="convertwidget4"> - <property name="visible">True</property> - - <child> - <widget class="GtkLabel" id="convertwidget5"> - <property name="visible">True</property> - <property name="label" translatable="yes">Mr.</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - </child> - </widget> - </child> - - <child> - <widget class="GtkListItem" id="convertwidget6"> - <property name="visible">True</property> - - <child> - <widget class="GtkLabel" id="convertwidget7"> - <property name="visible">True</property> - <property name="label" translatable="yes">Mrs.</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - </child> - </widget> - </child> - - <child> - <widget class="GtkListItem" id="convertwidget8"> - <property name="visible">True</property> - - <child> - <widget class="GtkLabel" id="convertwidget9"> - <property name="visible">True</property> - <property name="label" translatable="yes">Ms.</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - </child> - </widget> - </child> - - <child> - <widget class="GtkListItem" id="convertwidget10"> - <property name="visible">True</property> - - <child> - <widget class="GtkLabel" id="convertwidget11"> - <property name="visible">True</property> - <property name="label" translatable="yes">Miss</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - </child> - </widget> - </child> - - <child> - <widget class="GtkListItem" id="convertwidget12"> - <property name="visible">True</property> - - <child> - <widget class="GtkLabel" id="convertwidget13"> - <property name="visible">True</property> - <property name="label" translatable="yes">Dr.</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - </child> - </widget> - </child> - - <child> - <widget class="GtkListItem" id="convertwidget14"> - <property name="visible">True</property> - - <child> - <widget class="GtkLabel" id="convertwidget15"> - <property name="visible">True</property> - <property name="label" translatable="yes"></property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - </child> - </widget> - </child> - </widget> - </child> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">0</property> - <property name="bottom_attach">1</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkCombo" id="combo-suffix"> - <property name="visible">True</property> - <property name="value_in_list">False</property> - <property name="allow_empty">True</property> - <property name="case_sensitive">False</property> - <property name="enable_arrow_keys">True</property> - <property name="enable_arrows_always">False</property> - - <child internal-child="entry"> - <widget class="GtkEntry" id="entry-suffix"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="editable">True</property> - <property name="visibility">True</property> - <property name="max_length">0</property> - <property name="text" translatable="yes"></property> - <property name="has_frame">True</property> - <property name="invisible_char" translatable="yes">*</property> - <property name="activates_default">False</property> - </widget> - </child> - - <child internal-child="list"> - <widget class="GtkList" id="convertwidget16"> - <property name="visible">True</property> - <property name="selection_mode">GTK_SELECTION_BROWSE</property> - - <child> - <widget class="GtkListItem" id="convertwidget17"> - <property name="visible">True</property> - - <child> - <widget class="GtkLabel" id="convertwidget18"> - <property name="visible">True</property> - <property name="label" translatable="yes"></property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - </child> - </widget> - </child> - - <child> - <widget class="GtkListItem" id="convertwidget19"> - <property name="visible">True</property> - - <child> - <widget class="GtkLabel" id="convertwidget20"> - <property name="visible">True</property> - <property name="label" translatable="yes">Sr.</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - </child> - </widget> - </child> - - <child> - <widget class="GtkListItem" id="convertwidget21"> - <property name="visible">True</property> - - <child> - <widget class="GtkLabel" id="convertwidget22"> - <property name="visible">True</property> - <property name="label" translatable="yes">Jr.</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - </child> - </widget> - </child> - - <child> - <widget class="GtkListItem" id="convertwidget23"> - <property name="visible">True</property> - - <child> - <widget class="GtkLabel" id="convertwidget24"> - <property name="visible">True</property> - <property name="label" translatable="yes">I</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - </child> - </widget> - </child> - - <child> - <widget class="GtkListItem" id="convertwidget25"> - <property name="visible">True</property> - - <child> - <widget class="GtkLabel" id="convertwidget26"> - <property name="visible">True</property> - <property name="label" translatable="yes">II</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - </child> - </widget> - </child> - - <child> - <widget class="GtkListItem" id="convertwidget27"> - <property name="visible">True</property> - - <child> - <widget class="GtkLabel" id="convertwidget28"> - <property name="visible">True</property> - <property name="label" translatable="yes">III</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - </child> - </widget> - </child> - - <child> - <widget class="GtkListItem" id="convertwidget29"> - <property name="visible">True</property> - - <child> - <widget class="GtkLabel" id="convertwidget30"> - <property name="visible">True</property> - <property name="label" translatable="yes">Esq.</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - </child> - </widget> - </child> - - <child> - <widget class="GtkListItem" id="convertwidget31"> - <property name="visible">True</property> - - <child> - <widget class="GtkLabel" id="convertwidget32"> - <property name="visible">True</property> - <property name="label" translatable="yes"></property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - </child> - </widget> - </child> - </widget> - </child> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">4</property> - <property name="bottom_attach">5</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkEntry" id="entry-first"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="editable">True</property> - <property name="visibility">True</property> - <property name="max_length">0</property> - <property name="text" translatable="yes"></property> - <property name="has_frame">True</property> - <property name="invisible_char" translatable="yes">*</property> - <property name="activates_default">False</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">3</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkEntry" id="entry-middle"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="editable">True</property> - <property name="visibility">True</property> - <property name="max_length">0</property> - <property name="text" translatable="yes"></property> - <property name="has_frame">True</property> - <property name="invisible_char" translatable="yes">*</property> - <property name="activates_default">False</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">3</property> - <property name="top_attach">2</property> - <property name="bottom_attach">3</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkEntry" id="entry-last"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="editable">True</property> - <property name="visibility">True</property> - <property name="max_length">0</property> - <property name="text" translatable="yes"></property> - <property name="has_frame">True</property> - <property name="invisible_char" translatable="yes">*</property> - <property name="activates_default">False</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">3</property> - <property name="top_attach">3</property> - <property name="bottom_attach">4</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label-first"> - <property name="visible">True</property> - <property name="label" translatable="yes">_First:</property> - <property name="use_underline">True</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_CENTER</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">1</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="mnemonic_widget">entry-first</property> - </widget> - <packing> - <property name="left_attach">0</property> - <property name="right_attach">1</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="x_options">fill</property> - <property name="y_options">fill</property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label-title"> - <property name="visible">True</property> - <property name="label" translatable="yes">_Title:</property> - <property name="use_underline">True</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_CENTER</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">1</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="mnemonic_widget">entry-title</property> - </widget> - <packing> - <property name="left_attach">0</property> - <property name="right_attach">1</property> - <property name="top_attach">0</property> - <property name="bottom_attach">1</property> - <property name="x_options">fill</property> - <property name="y_options">fill</property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label-middle"> - <property name="visible">True</property> - <property name="label" translatable="yes">_Middle:</property> - <property name="use_underline">True</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_CENTER</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">1</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="mnemonic_widget">entry-middle</property> - </widget> - <packing> - <property name="left_attach">0</property> - <property name="right_attach">1</property> - <property name="top_attach">2</property> - <property name="bottom_attach">3</property> - <property name="x_options">fill</property> - <property name="y_options">fill</property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label-last"> - <property name="visible">True</property> - <property name="label" translatable="yes">_Last:</property> - <property name="use_underline">True</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_CENTER</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">1</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="mnemonic_widget">entry-last</property> - </widget> - <packing> - <property name="left_attach">0</property> - <property name="right_attach">1</property> - <property name="top_attach">3</property> - <property name="bottom_attach">4</property> - <property name="x_options">fill</property> - <property name="y_options">fill</property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label-suffix"> - <property name="visible">True</property> - <property name="label" translatable="yes">_Suffix:</property> - <property name="use_underline">True</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_CENTER</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">1</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="mnemonic_widget">entry-suffix</property> - </widget> - <packing> - <property name="left_attach">0</property> - <property name="right_attach">1</property> - <property name="top_attach">4</property> - <property name="bottom_attach">5</property> - <property name="x_options">fill</property> - <property name="y_options">fill</property> - </packing> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">True</property> - <property name="fill">True</property> - </packing> - </child> - </widget> - </child> -</widget> - -</glade-interface> diff --git a/addressbook/gui/contact-editor/im.glade b/addressbook/gui/contact-editor/im.glade deleted file mode 100644 index eb8832e8f1..0000000000 --- a/addressbook/gui/contact-editor/im.glade +++ /dev/null @@ -1,206 +0,0 @@ -<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*--> -<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd"> - -<glade-interface> - -<widget class="GtkDialog" id="dialog-im"> - <property name="title" translatable="yes">Add IM Account</property> - <property name="type">GTK_WINDOW_TOPLEVEL</property> - <property name="window_position">GTK_WIN_POS_NONE</property> - <property name="modal">True</property> - <property name="resizable">True</property> - <property name="destroy_with_parent">False</property> - <property name="has_separator">False</property> - - <child internal-child="vbox"> - <widget class="GtkVBox" id="dialog-vbox1"> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">2</property> - - <child internal-child="action_area"> - <widget class="GtkHButtonBox" id="dialog-action_area1"> - <property name="visible">True</property> - <property name="layout_style">GTK_BUTTONBOX_END</property> - - <child> - <widget class="GtkButton" id="cancelbutton1"> - <property name="visible">True</property> - <property name="can_default">True</property> - <property name="can_focus">True</property> - <property name="label">gtk-cancel</property> - <property name="use_stock">True</property> - <property name="relief">GTK_RELIEF_NORMAL</property> - <property name="response_id">-6</property> - </widget> - </child> - - <child> - <widget class="GtkButton" id="okbutton1"> - <property name="visible">True</property> - <property name="can_default">True</property> - <property name="can_focus">True</property> - <property name="label">gtk-ok</property> - <property name="use_stock">True</property> - <property name="relief">GTK_RELIEF_NORMAL</property> - <property name="response_id">-5</property> - </widget> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="pack_type">GTK_PACK_END</property> - </packing> - </child> - - <child> - <widget class="GtkTable" id="table-im"> - <property name="border_width">6</property> - <property name="visible">True</property> - <property name="n_rows">3</property> - <property name="n_columns">2</property> - <property name="homogeneous">False</property> - <property name="row_spacing">6</property> - <property name="column_spacing">12</property> - - <child> - <widget class="GtkLabel" id="label-service"> - <property name="visible">True</property> - <property name="label" translatable="yes">_IM Service:</property> - <property name="use_underline">True</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="mnemonic_widget">optmenu-service</property> - </widget> - <packing> - <property name="left_attach">0</property> - <property name="right_attach">1</property> - <property name="top_attach">0</property> - <property name="bottom_attach">1</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkOptionMenu" id="optmenu-service"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="history">-1</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">0</property> - <property name="bottom_attach">1</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label-username"> - <property name="visible">True</property> - <property name="label" translatable="yes">_Account name:</property> - <property name="use_underline">True</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="mnemonic_widget">entry-username</property> - </widget> - <packing> - <property name="left_attach">0</property> - <property name="right_attach">1</property> - <property name="top_attach">2</property> - <property name="bottom_attach">3</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkEntry" id="entry-username"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="editable">True</property> - <property name="visibility">True</property> - <property name="max_length">0</property> - <property name="text" translatable="yes"></property> - <property name="has_frame">True</property> - <property name="invisible_char" translatable="yes">*</property> - <property name="activates_default">False</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">2</property> - <property name="bottom_attach">3</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label-location"> - <property name="visible">True</property> - <property name="label" translatable="yes">_Location:</property> - <property name="use_underline">True</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="mnemonic_widget">optmenu-location</property> - </widget> - <packing> - <property name="left_attach">0</property> - <property name="right_attach">1</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkOptionMenu" id="optmenu-location"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="history">-1</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">True</property> - <property name="fill">True</property> - </packing> - </child> - </widget> - </child> -</widget> - -</glade-interface> diff --git a/addressbook/gui/contact-editor/test-editor.c b/addressbook/gui/contact-editor/test-editor.c deleted file mode 100644 index 4a8c111563..0000000000 --- a/addressbook/gui/contact-editor/test-editor.c +++ /dev/null @@ -1,142 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * test-editor.c - * Copyright (C) 2000 Ximian, Inc. - * Author: Chris Lahey <clahey@ximian.com> - * - * This library 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 library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include "config.h" - -#include <stdlib.h> -#include <gtk/gtkmain.h> -#include <libgnomeui/gnome-app.h> -#include <libgnomeui/gnome-ui-init.h> -#include <glade/glade.h> -#include "e-contact-editor.h" -#include "ebook/e-card.h" - -#define TEST_VCARD \ -"BEGIN:VCARD -" \ -"FN:Nat -" \ -"N:Friedman;Nat;D;Mr. -" \ -"BDAY:1977-08-06 -" \ -"TEL;WORK:617 679 1984 -" \ -"TEL;CELL:123 456 7890 -" \ -"EMAIL;INTERNET:nat@nat.org -" \ -"EMAIL;INTERNET:nat@ximian.com -" \ -"ADR;WORK;POSTAL:P.O. Box 101;;;Any Town;CA;91921-1234; -" \ -"ADR;HOME;POSTAL;INTL:P.O. Box 202;;;Any Town 2;MI;12344-4321;USA -" \ -"END:VCARD -" \ -" -" - -static char * -read_file (char *name) -{ - int len; - char buff[65536]; - char line[1024]; - FILE *f; - - f = fopen (name, "r"); - if (f == NULL) - g_error ("Unable to open %s!\n", name); - - len = 0; - while (fgets (line, sizeof (line), f) != NULL) { - strcpy (buff + len, line); - len += strlen (line); - } - - fclose (f); - - return g_strdup (buff); -} - -/* Callback used when a contact editor is closed */ -static void -editor_closed_cb (EContactEditor *ce, gpointer data) -{ - static int count = 2; - - count--; - g_object_unref (ce); - - if (count == 0) - exit (0); -} - -#if 0 -static void about_callback( GtkWidget *widget, gpointer data ) -{ - - const gchar *authors[] = - { - "Christopher James Lahey <clahey@umich.edu>", - NULL - }; - - GtkWidget *about = - gnome_about_new ( _( "Contact Editor Test" ), VERSION, - _( "Copyright (C) 2000, Ximian, Inc." ), - authors, - _( "This should test the contact editor canvas item" ), - NULL); - gtk_widget_show (about); -} -#endif - -int main( int argc, char *argv[] ) -{ - char *cardstr; - EContactEditor *ce; - - gnome_program_init("Contact Editor Test", VERSION, LIBGNOMEUI_MODULE, argc, argv, NULL); - - glade_init (); - - cardstr = NULL; - if (argc == 2) - cardstr = read_file (argv [1]); - - if (cardstr == NULL) - cardstr = TEST_VCARD; - - ce = e_contact_editor_new (NULL, e_card_new_with_default_charset (cardstr, "ISO-8859-1"), TRUE, FALSE); - g_signal_connect (ce, "editor_closed", - G_CALLBACK (editor_closed_cb), NULL); - - ce = e_contact_editor_new (NULL, e_card_new_with_default_charset (cardstr, "ISO-8859-1"), TRUE, FALSE); - g_signal_connect (ce, "editor_closed", - G_CALLBACK (editor_closed_cb), NULL); - - gtk_main(); - - /* Not reached. */ - return 0; -} diff --git a/addressbook/gui/contact-list-editor/.cvsignore b/addressbook/gui/contact-list-editor/.cvsignore deleted file mode 100644 index 1fe141cc30..0000000000 --- a/addressbook/gui/contact-list-editor/.cvsignore +++ /dev/null @@ -1,7 +0,0 @@ -Evolution-Addressbook-SelectNames.h -Makefile.in -Makefile -.deps -.pure -e-contact-list-editor-marshal.c -e-contact-list-editor-marshal.h diff --git a/addressbook/gui/contact-list-editor/Makefile.am b/addressbook/gui/contact-list-editor/Makefile.am deleted file mode 100644 index 5df78b3eac..0000000000 --- a/addressbook/gui/contact-list-editor/Makefile.am +++ /dev/null @@ -1,49 +0,0 @@ -IDL = Evolution-Addressbook-SelectNames.idl - -IDL_GENERATED_H = \ - Evolution-Addressbook-SelectNames.h - -selectnamesdir = $(top_srcdir)/addressbook/gui/component/select-names - -$(IDL_GENERATED_H): $(selectnamesdir)/$(IDL) - $(ORBIT_IDL) --nostubs --noskels --nocommon $(IDL_INCLUDES) $(selectnamesdir)/$(IDL) - -INCLUDES = \ - -I$(top_srcdir) \ - -I$(top_srcdir)/addressbook/ \ - -I$(top_srcdir)/addressbook/backend \ - -I$(top_builddir)/addressbook/backend \ - -I$(top_srcdir)/addressbook/gui/merging \ - -I$(top_srcdir)/addressbook/gui/contact-editor \ - -I$(top_builddir)/shell \ - -DEVOLUTION_GLADEDIR=\""$(gladedir)"\" \ - -DEVOLUTION_ETSPECDIR=\""$(etspecdir)"\" \ - -DEVOLUTION_DATADIR=\""$(datadir)"\" \ - -DEVOLUTION_IMAGESDIR=\""$(imagesdir)"\" \ - -DEVOLUTION_UIDIR=\""$(evolutionuidir)\"" \ - -DPREFIX=\""$(prefix)"\" \ - -DG_LOG_DOMAIN=\"contact-list-editor\" \ - $(EVOLUTION_ADDRESSBOOK_CFLAGS) - -noinst_LTLIBRARIES = \ - libecontactlisteditor.la - -libecontactlisteditor_la_SOURCES = \ - $(MARSHAL_GENERATED) \ - e-contact-list-editor.c \ - e-contact-list-editor.h \ - e-contact-list-model.c \ - e-contact-list-model.h - -MARSHAL_GENERATED = e-contact-list-editor-marshal.c e-contact-list-editor-marshal.h -@EVO_MARSHAL_RULE@ - -glade_DATA = contact-list-editor.glade -etspec_DATA = e-contact-list-editor.etspec - -BUILT_SOURCES = $(MARSHAL_GENERATED) $(IDL_GENERATED_H) -CLEANFILES = $(BUILT_SOURCES) - -EXTRA_DIST = $(glade_DATA) \ - $(etspec_DATA) \ - e-contact-list-editor-marshal.list diff --git a/addressbook/gui/contact-list-editor/contact-list-editor.glade b/addressbook/gui/contact-list-editor/contact-list-editor.glade deleted file mode 100644 index 30760f6108..0000000000 --- a/addressbook/gui/contact-list-editor/contact-list-editor.glade +++ /dev/null @@ -1,425 +0,0 @@ -<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*--> -<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd"> - -<glade-interface> - -<widget class="GtkDialog" id="contact list editor"> - <property name="visible">True</property> - <property name="title" translatable="yes">Contact List Editor</property> - <property name="type">GTK_WINDOW_TOPLEVEL</property> - <property name="window_position">GTK_WIN_POS_NONE</property> - <property name="modal">False</property> - <property name="resizable">True</property> - <property name="destroy_with_parent">False</property> - <property name="has_separator">True</property> - - <child internal-child="vbox"> - <widget class="GtkVBox" id="dialog-vbox1"> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">0</property> - - <child internal-child="action_area"> - <widget class="GtkHButtonBox" id="dialog-action_area1"> - <property name="visible">True</property> - <property name="layout_style">GTK_BUTTONBOX_END</property> - - <child> - <widget class="GtkButton" id="cancel-button"> - <property name="visible">True</property> - <property name="can_default">True</property> - <property name="can_focus">True</property> - <property name="label">gtk-cancel</property> - <property name="use_stock">True</property> - <property name="relief">GTK_RELIEF_NORMAL</property> - <property name="response_id">-6</property> - </widget> - </child> - - <child> - <widget class="GtkButton" id="ok-button"> - <property name="visible">True</property> - <property name="can_default">True</property> - <property name="can_focus">True</property> - <property name="label">gtk-ok</property> - <property name="use_stock">True</property> - <property name="relief">GTK_RELIEF_NORMAL</property> - <property name="response_id">-5</property> - </widget> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="pack_type">GTK_PACK_END</property> - </packing> - </child> - - <child> - <widget class="GtkVBox" id="vbox8"> - <property name="border_width">6</property> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">6</property> - - <child> - <widget class="GtkHBox" id="hbox6"> - <property name="border_width">6</property> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">6</property> - - <child> - <widget class="GtkTable" id="table1"> - <property name="visible">True</property> - <property name="n_rows">2</property> - <property name="n_columns">2</property> - <property name="homogeneous">False</property> - <property name="row_spacing">6</property> - <property name="column_spacing">6</property> - - <child> - <widget class="GtkLabel" id="label10"> - <property name="visible">True</property> - <property name="label" translatable="yes">_List name:</property> - <property name="use_underline">True</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - <property name="mnemonic_widget">list-name-entry</property> - </widget> - <packing> - <property name="left_attach">0</property> - <property name="right_attach">1</property> - <property name="top_attach">0</property> - <property name="bottom_attach">1</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkEntry" id="list-name-entry"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="has_focus">True</property> - <property name="editable">True</property> - <property name="visibility">True</property> - <property name="max_length">0</property> - <property name="text" translatable="yes"></property> - <property name="has_frame">True</property> - <property name="invisible_char" translatable="yes">*</property> - <property name="activates_default">False</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">0</property> - <property name="bottom_attach">1</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="source-label"> - <property name="visible">True</property> - <property name="label" translatable="yes">_Where:</property> - <property name="use_underline">True</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="left_attach">0</property> - <property name="right_attach">1</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="Custom" id="source-option-menu-source"> - <property name="visible">True</property> - <property name="creation_function">e_contact_list_editor_create_source_option_menu</property> - <property name="int1">0</property> - <property name="int2">0</property> - <property name="last_modification_time">Tue, 01 Jun 2004 18:22:38 GMT</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="x_options">fill</property> - <property name="y_options">fill</property> - </packing> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">True</property> - <property name="fill">True</property> - </packing> - </child> - - <child> - <widget class="Custom" id="list-image"> - <property name="visible">True</property> - <property name="creation_function">eab_create_image_chooser_widget</property> - <property name="string1">stock_addressbook</property> - <property name="int1">0</property> - <property name="int2">0</property> - <property name="last_modification_time">Sat, 23 Jun 2001 05:59:21 GMT</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - - <child> - <widget class="GtkFrame" id="frame3"> - <property name="border_width">3</property> - <property name="visible">True</property> - <property name="label_xalign">0</property> - <property name="label_yalign">0.5</property> - <property name="shadow_type">GTK_SHADOW_ETCHED_IN</property> - - <child> - <widget class="GtkHBox" id="hbox7"> - <property name="border_width">6</property> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">6</property> - - <child> - <widget class="GtkVBox" id="vbox9"> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">6</property> - - <child> - <widget class="GtkLabel" id="label11"> - <property name="visible">True</property> - <property name="label" translatable="yes">_Type an email address or drag a contact into the list below:</property> - <property name="use_underline">True</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_CENTER</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - - <child> - <widget class="GtkEntry" id="email-entry"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="editable">True</property> - <property name="visibility">True</property> - <property name="max_length">0</property> - <property name="text" translatable="yes"></property> - <property name="has_frame">True</property> - <property name="invisible_char" translatable="yes">*</property> - <property name="activates_default">False</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - - <child> - <widget class="Custom" id="contact-list-table"> - <property name="visible">True</property> - <property name="creation_function">e_contact_list_editor_create_table</property> - <property name="string1"></property> - <property name="int1">0</property> - <property name="int2">0</property> - <property name="last_modification_time">Sat, 23 Jun 2001 06:00:16 GMT</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">True</property> - <property name="fill">True</property> - </packing> - </child> - - <child> - <widget class="GtkCheckButton" id="visible-addrs-checkbutton"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="label" translatable="yes">_Hide addresses when sending mail to this list</property> - <property name="use_underline">True</property> - <property name="relief">GTK_RELIEF_NORMAL</property> - <property name="active">False</property> - <property name="inconsistent">False</property> - <property name="draw_indicator">True</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">True</property> - <property name="fill">True</property> - </packing> - </child> - - <child> - <widget class="GtkVBox" id="vbox10"> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">0</property> - - <child> - <widget class="GtkLabel" id="label12"> - <property name="visible">True</property> - <property name="label" translatable="yes"> -</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_CENTER</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - - <child> - <widget class="GtkVButtonBox" id="vbuttonbox4"> - <property name="visible">True</property> - <property name="layout_style">GTK_BUTTONBOX_START</property> - <property name="spacing">6</property> - - <child> - <widget class="GtkButton" id="add-email-button"> - <property name="visible">True</property> - <property name="tooltip" translatable="yes">Add an email to the List</property> - <property name="can_default">True</property> - <property name="can_focus">True</property> - <property name="label">gtk-add</property> - <property name="use_stock">True</property> - <property name="relief">GTK_RELIEF_NORMAL</property> - </widget> - </child> - - <child> - <widget class="GtkButton" id="remove-button"> - <property name="visible">True</property> - <property name="tooltip" translatable="yes">Remove an email address from the List</property> - <property name="can_default">True</property> - <property name="can_focus">True</property> - <property name="label">gtk-remove</property> - <property name="use_stock">True</property> - <property name="relief">GTK_RELIEF_NORMAL</property> - </widget> - </child> - - <child> - <widget class="GtkButton" id="select-button"> - <property name="visible">True</property> - <property name="tooltip" translatable="yes">Insert email adresses from Adress Book</property> - <property name="can_default">True</property> - <property name="can_focus">True</property> - <property name="label" translatable="yes">Select</property> - <property name="use_underline">True</property> - <property name="relief">GTK_RELIEF_NORMAL</property> - </widget> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">True</property> - <property name="fill">True</property> - </packing> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - </widget> - </child> - - <child> - <widget class="GtkLabel" id="label11"> - <property name="visible">True</property> - <property name="label" translatable="yes">Members</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="type">label_item</property> - </packing> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">True</property> - <property name="fill">True</property> - </packing> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">True</property> - <property name="fill">True</property> - </packing> - </child> - </widget> - </child> -</widget> - -</glade-interface> diff --git a/addressbook/gui/contact-list-editor/e-contact-list-editor-marshal.list b/addressbook/gui/contact-list-editor/e-contact-list-editor-marshal.list deleted file mode 100644 index 8d94a0bf3b..0000000000 --- a/addressbook/gui/contact-list-editor/e-contact-list-editor-marshal.list +++ /dev/null @@ -1,4 +0,0 @@ -INT:OBJECT -NONE:INT,OBJECT -NONE:INT,OBJECT -NONE:NONE diff --git a/addressbook/gui/contact-list-editor/e-contact-list-editor.c b/addressbook/gui/contact-list-editor/e-contact-list-editor.c deleted file mode 100644 index 07b6598b08..0000000000 --- a/addressbook/gui/contact-list-editor/e-contact-list-editor.c +++ /dev/null @@ -1,1127 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* e-contact-list-editor.c - * Copyright (C) 2001 Ximian, Inc. - * Author: Chris Toshok <toshok@ximian.com> - * - * This library 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 library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include <config.h> - -#include "e-contact-list-editor.h" -#include <e-util/e-icon-factory.h> - -#include <string.h> - -#include <libgnome/gnome-i18n.h> -#include <libgnomeui/gnome-window-icon.h> -#include <gtk/gtkentry.h> -#include <gtk/gtktogglebutton.h> -#include <gtk/gtkdialog.h> - -#include <libedataserverui/e-source-option-menu.h> - -#include <gal/e-table/e-table-scrolled.h> -#include <libgnomevfs/gnome-vfs-ops.h> - -#include <bonobo/bonobo-control.h> -#include <bonobo/bonobo-widget.h> -#include <bonobo/bonobo-exception.h> - -#include "shell/evolution-shell-component-utils.h" - -#include "widgets/misc/e-image-chooser.h" - -#include "addressbook/gui/component/addressbook.h" -#include "addressbook/gui/widgets/eab-gui-util.h" -#include "addressbook/util/eab-book-util.h" -#include "Evolution-Addressbook-SelectNames.h" - -#include "eab-editor.h" -#include "e-contact-editor.h" -#include "e-contact-list-model.h" -#include "e-contact-list-editor-marshal.h" - -static void e_contact_list_editor_init (EContactListEditor *editor); -static void e_contact_list_editor_class_init (EContactListEditorClass *klass); -static void e_contact_list_editor_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec); -static void e_contact_list_editor_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); -static void e_contact_list_editor_dispose (GObject *object); - -static void e_contact_list_editor_show (EABEditor *editor); -static void e_contact_list_editor_raise (EABEditor *editor); -static void e_contact_list_editor_close (EABEditor *editor); -static void e_contact_list_editor_save_contact (EABEditor *editor, gboolean should_close); -static gboolean e_contact_list_editor_is_valid (EABEditor *editor); -static gboolean e_contact_list_editor_is_changed (EABEditor *editor); -static GtkWindow* e_contact_list_editor_get_window (EABEditor *editor); - -static void set_editable (EContactListEditor *editor); -static void command_state_changed (EContactListEditor *editor); -static void extract_info(EContactListEditor *editor); -static void fill_in_info(EContactListEditor *editor); - -static void add_email_cb (GtkWidget *w, EContactListEditor *editor); -static void remove_entry_cb (GtkWidget *w, EContactListEditor *editor); -static void select_cb (GtkWidget *w, EContactListEditor *editor); -static void list_name_changed_cb (GtkWidget *w, EContactListEditor *editor); -static void list_image_changed_cb (GtkWidget *w, EContactListEditor *editor); -static void visible_addrs_toggled_cb (GtkWidget *w, EContactListEditor *editor); -static void source_selected (GtkWidget *source_option_menu, ESource *source, EContactListEditor *editor); - -static void close_cb (GtkWidget *widget, EContactListEditor *editor); -static void save_and_close_cb (GtkWidget *widget, EContactListEditor *editor); - -static gint app_delete_event_cb (GtkWidget *widget, GdkEvent *event, gpointer data); -static gboolean table_drag_drop_cb (ETable *table, int row, int col, GdkDragContext *context, - gint x, gint y, guint time, EContactListEditor *editor); -static gboolean table_drag_motion_cb (ETable *table, int row, int col, GdkDragContext *context, - gint x, gint y, guint time, EContactListEditor *editor); -static void table_drag_data_received_cb (ETable *table, int row, int col, - GdkDragContext *context, - gint x, gint y, - GtkSelectionData *selection_data, guint info, guint time, - EContactListEditor *editor); - -static EABEditorClass *parent_class = NULL; - -enum DndTargetType { - DND_TARGET_TYPE_VCARD, -}; -#define VCARD_TYPE "text/x-vcard" - -static GtkTargetEntry list_drag_types[] = { - { VCARD_TYPE, 0, DND_TARGET_TYPE_VCARD }, -}; -static const int num_list_drag_types = sizeof (list_drag_types) / sizeof (list_drag_types[0]); - -/* The arguments we take */ -enum { - PROP_0, - PROP_BOOK, - PROP_CONTACT, - PROP_IS_NEW_LIST, - PROP_EDITABLE -}; - -GType -e_contact_list_editor_get_type (void) -{ - static GType cle_type = 0; - - if (!cle_type) { - static const GTypeInfo cle_info = { - sizeof (EContactListEditorClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) e_contact_list_editor_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (EContactListEditor), - 0, /* n_preallocs */ - (GInstanceInitFunc) e_contact_list_editor_init, - }; - - cle_type = g_type_register_static (EAB_TYPE_EDITOR, "EContactListEditor", &cle_info, 0); - } - - return cle_type; -} - - -static void -e_contact_list_editor_class_init (EContactListEditorClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - EABEditorClass *editor_class = EAB_EDITOR_CLASS (klass); - - parent_class = g_type_class_ref (EAB_TYPE_EDITOR); - - editor_class->show = e_contact_list_editor_show; - editor_class->raise = e_contact_list_editor_raise; - editor_class->close = e_contact_list_editor_close; - editor_class->save_contact = e_contact_list_editor_save_contact; - editor_class->is_valid = e_contact_list_editor_is_valid; - editor_class->is_changed = e_contact_list_editor_is_changed; - editor_class->get_window = e_contact_list_editor_get_window; - - object_class->set_property = e_contact_list_editor_set_property; - object_class->get_property = e_contact_list_editor_get_property; - object_class->dispose = e_contact_list_editor_dispose; - - g_object_class_install_property (object_class, PROP_BOOK, - g_param_spec_object ("book", - _("Book"), - /*_( */"XXX blurb" /*)*/, - E_TYPE_BOOK, - G_PARAM_READWRITE)); - - g_object_class_install_property (object_class, PROP_CONTACT, - g_param_spec_object ("contact", - _("Contact"), - /*_( */"XXX blurb" /*)*/, - E_TYPE_CONTACT, - G_PARAM_READWRITE)); - - g_object_class_install_property (object_class, PROP_IS_NEW_LIST, - g_param_spec_boolean ("is_new_list", - _("Is New List"), - /*_( */"XXX blurb" /*)*/, - FALSE, - G_PARAM_READWRITE)); - - g_object_class_install_property (object_class, PROP_EDITABLE, - g_param_spec_boolean ("editable", - _("Editable"), - /*_( */"XXX blurb" /*)*/, - FALSE, - G_PARAM_READWRITE)); -} - -static void -e_contact_list_editor_init (EContactListEditor *editor) -{ - GladeXML *gui; - GList *icon_list; - - editor->contact = NULL; - editor->changed = FALSE; - editor->image_set = FALSE; - editor->editable = TRUE; - editor->allows_contact_lists = TRUE; - editor->in_async_call = FALSE; - editor->is_new_list = FALSE; - - editor->load_source_id = 0; - editor->load_book = NULL; - - gui = glade_xml_new (EVOLUTION_GLADEDIR "/contact-list-editor.glade", NULL, NULL); - editor->gui = gui; - - editor->app = glade_xml_get_widget (gui, "contact list editor"); - - editor->table = glade_xml_get_widget (gui, "contact-list-table"); - editor->model = g_object_get_data (G_OBJECT(editor->table), "model"); - - /* XXX need this for libglade-2 it seems */ - gtk_widget_show (editor->table); - - editor->add_button = glade_xml_get_widget (editor->gui, "add-email-button"); - editor->remove_button = glade_xml_get_widget (editor->gui, "remove-button"); - editor->select_button = glade_xml_get_widget (editor->gui, "select-button"); - - editor->email_entry = glade_xml_get_widget (gui, "email-entry"); - editor->list_name_entry = glade_xml_get_widget (gui, "list-name-entry"); - editor->list_image = glade_xml_get_widget (gui, "list-image"); - editor->visible_addrs_checkbutton = glade_xml_get_widget (gui, "visible-addrs-checkbutton"); - editor->source_menu = glade_xml_get_widget (gui, "source-option-menu-source"); - - editor->ok_button = glade_xml_get_widget (gui, "ok-button"); - editor->cancel_button = glade_xml_get_widget (gui, "cancel-button"); - - /* connect signals */ - g_signal_connect (editor->add_button, - "clicked", G_CALLBACK(add_email_cb), editor); - g_signal_connect (editor->email_entry, - "activate", G_CALLBACK(add_email_cb), editor); - g_signal_connect (editor->remove_button, - "clicked", G_CALLBACK(remove_entry_cb), editor); - g_signal_connect (editor->select_button, - "clicked", G_CALLBACK(select_cb), editor); - g_signal_connect (editor->list_name_entry, - "changed", G_CALLBACK(list_name_changed_cb), editor); - g_signal_connect (editor->visible_addrs_checkbutton, - "toggled", G_CALLBACK(visible_addrs_toggled_cb), editor); - - e_table_drag_dest_set (e_table_scrolled_get_table (E_TABLE_SCROLLED (editor->table)), - 0, list_drag_types, num_list_drag_types, GDK_ACTION_LINK); - - g_signal_connect (e_table_scrolled_get_table (E_TABLE_SCROLLED (editor->table)), - "table_drag_motion", G_CALLBACK(table_drag_motion_cb), editor); - g_signal_connect (e_table_scrolled_get_table (E_TABLE_SCROLLED (editor->table)), - "table_drag_drop", G_CALLBACK (table_drag_drop_cb), editor); - g_signal_connect (e_table_scrolled_get_table (E_TABLE_SCROLLED (editor->table)), - "table_drag_data_received", G_CALLBACK(table_drag_data_received_cb), editor); - - g_signal_connect (editor->ok_button, - "clicked", G_CALLBACK(save_and_close_cb), editor); - g_signal_connect (editor->cancel_button, - "clicked", G_CALLBACK(close_cb), editor); - - - g_signal_connect (editor->list_image, - "changed", G_CALLBACK(list_image_changed_cb), editor); - - g_signal_connect (editor->source_menu, - "source_selected", G_CALLBACK (source_selected), editor); - - command_state_changed (editor); - - /* Connect to the deletion of the dialog */ - g_signal_connect (editor->app, "delete_event", - G_CALLBACK (app_delete_event_cb), editor); - - gtk_dialog_set_has_separator (GTK_DIALOG (editor->app), FALSE); - - /* set the icon */ - icon_list = e_icon_factory_get_icon_list ("stock_contact-list"); - if (icon_list) { - gtk_window_set_icon_list (GTK_WINDOW (editor->app), icon_list); - g_list_foreach (icon_list, (GFunc) g_object_unref, NULL); - g_list_free (icon_list); - } - - gtk_widget_show_all (editor->app); -} - -static void -new_target_cb (EBook *new_book, EBookStatus status, EContactListEditor *editor) -{ - editor->load_source_id = 0; - editor->load_book = NULL; - - if (status != E_BOOK_ERROR_OK || new_book == NULL) { - eab_load_error_dialog (NULL, e_book_get_source (new_book), status); - - e_source_option_menu_select (E_SOURCE_OPTION_MENU (editor->source_menu), - e_book_get_source (editor->book)); - - if (new_book) - g_object_unref (new_book); - return; - } - - g_object_set (editor, "book", new_book, NULL); - g_object_unref (new_book); -} - -static void -cancel_load (EContactListEditor *editor) -{ - if (editor->load_source_id) { - addressbook_load_cancel (editor->load_source_id); - editor->load_source_id = 0; - - g_object_unref (editor->load_book); - editor->load_book = NULL; - } -} - -static void -source_selected (GtkWidget *source_option_menu, ESource *source, EContactListEditor *editor) -{ - cancel_load (editor); - - if (e_source_equal (e_book_get_source (editor->book), source)) - return; - - editor->load_book = e_book_new (source, NULL); - editor->load_source_id = addressbook_load (editor->load_book, - (EBookCallback) new_target_cb, editor); -} - -static void -e_contact_list_editor_dispose (GObject *object) -{ - cancel_load (E_CONTACT_LIST_EDITOR (object)); - - if (G_OBJECT_CLASS (parent_class)->dispose) - (* G_OBJECT_CLASS (parent_class)->dispose) (object); - -} - -typedef struct { - EContactListEditor *cle; - gboolean should_close; -} EditorCloseStruct; - -static void -list_added_cb (EBook *book, EBookStatus status, const char *id, EditorCloseStruct *ecs) -{ - EContactListEditor *cle = ecs->cle; - gboolean should_close = ecs->should_close; - - if (cle->app) - gtk_widget_set_sensitive (cle->app, TRUE); - cle->in_async_call = FALSE; - - e_contact_set (cle->contact, E_CONTACT_UID, (char*)id); - - eab_editor_contact_added (EAB_EDITOR (cle), status, cle->contact); - - if (status == E_BOOK_ERROR_OK) { - cle->is_new_list = FALSE; - - if (should_close) - eab_editor_close (EAB_EDITOR (cle)); - else - command_state_changed (cle); - } - - g_object_unref (cle); - g_free (ecs); -} - -static void -list_modified_cb (EBook *book, EBookStatus status, EditorCloseStruct *ecs) -{ - EContactListEditor *cle = ecs->cle; - gboolean should_close = ecs->should_close; - - if (cle->app) - gtk_widget_set_sensitive (cle->app, TRUE); - cle->in_async_call = FALSE; - - eab_editor_contact_modified (EAB_EDITOR (cle), status, cle->contact); - - if (status == E_BOOK_ERROR_OK) { - if (should_close) - eab_editor_close (EAB_EDITOR (cle)); - } - - g_object_unref (cle); /* release ref held for ebook callback */ - g_free (ecs); -} - -static void -save_contact (EContactListEditor *cle, gboolean should_close) -{ - extract_info (cle); - - if (cle->book) { - EditorCloseStruct *ecs = g_new(EditorCloseStruct, 1); - - ecs->cle = cle; - g_object_ref (cle); - ecs->should_close = should_close; - - if (cle->app) - gtk_widget_set_sensitive (cle->app, FALSE); - cle->in_async_call = TRUE; - - if (cle->is_new_list) - e_book_async_add_contact (cle->book, cle->contact, (EBookIdCallback)list_added_cb, ecs); - else - e_book_async_commit_contact (cle->book, cle->contact, (EBookCallback)list_modified_cb, ecs); - - cle->changed = FALSE; - } -} - -static gboolean -is_named (EContactListEditor *editor) -{ - char *string = gtk_editable_get_chars(GTK_EDITABLE (editor->list_name_entry), 0, -1); - gboolean named = FALSE; - - if (string && *string) { - named = TRUE; - } - - g_free (string); - - return named; -} - -static void -e_contact_list_editor_save_contact (EABEditor *editor, gboolean should_close) -{ - EContactListEditor *cle = E_CONTACT_LIST_EDITOR (editor); - - save_contact (editor, should_close); -} - -static gboolean -e_contact_list_editor_is_valid (EABEditor *editor) -{ - EContactListEditor *cle = E_CONTACT_LIST_EDITOR (editor); - - return is_named (cle); -} - -static gboolean -e_contact_list_editor_is_changed (EABEditor *editor) -{ - EContactListEditor *cle = E_CONTACT_LIST_EDITOR (editor); - - return cle->changed; -} - -static GtkWindow* -e_contact_list_editor_get_window (EABEditor *editor) -{ - return GTK_WINDOW (E_CONTACT_LIST_EDITOR (editor)->app); -} - -static void -close_cb (GtkWidget *widget, EContactListEditor *cle) -{ - if (!eab_editor_prompt_to_save_changes (EAB_EDITOR (cle), GTK_WINDOW (cle->app))) - return; - - eab_editor_close (EAB_EDITOR (cle)); -} - -static void -save_and_close_cb (GtkWidget *widget, EContactListEditor *cle) -{ - save_contact (cle, TRUE); -} - -static void -contact_list_editor_destroy_notify (gpointer data, - GObject *where_the_object_was) -{ - eab_editor_remove (EAB_EDITOR (data)); -} - -EContactListEditor * -e_contact_list_editor_new (EBook *book, - EContact *list_contact, - gboolean is_new_list, - gboolean editable) -{ - EContactListEditor *ce = g_object_new (E_TYPE_CONTACT_LIST_EDITOR, NULL); - - eab_editor_add (EAB_EDITOR (ce)); - g_object_weak_ref (G_OBJECT (ce), contact_list_editor_destroy_notify, ce); - - g_object_set (ce, - "book", book, - "contact", list_contact, - "is_new_list", is_new_list, - "editable", editable, - NULL); - - return ce; -} - -static void -e_contact_list_editor_set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec) -{ - EContactListEditor *editor; - - editor = E_CONTACT_LIST_EDITOR (object); - - switch (prop_id){ - case PROP_BOOK: { - gboolean changed; - - if (editor->book) - g_object_unref (editor->book); - editor->book = E_BOOK(g_value_get_object (value)); - g_object_ref (editor->book); - /* XXX more here about editable/etc. */ - - changed = (editor->allows_contact_lists != e_book_check_static_capability (editor->book, - "contact-lists")); - editor->allows_contact_lists = e_book_check_static_capability (editor->book, - "contact-lists"); - - if (changed) { - set_editable (editor); - command_state_changed (editor); - } - break; - } - case PROP_CONTACT: - if (editor->contact) - g_object_unref (editor->contact); - editor->contact = e_contact_duplicate(E_CONTACT(g_value_get_object (value))); - fill_in_info(editor); - editor->changed = FALSE; - command_state_changed (editor); - break; - case PROP_IS_NEW_LIST: { - gboolean new_value = g_value_get_boolean (value); - gboolean changed = (editor->is_new_list != new_value); - - editor->is_new_list = new_value; - - if (changed) - command_state_changed (editor); - break; - } - case PROP_EDITABLE: { - gboolean new_value = g_value_get_boolean (value); - gboolean changed = (editor->editable != new_value); - - editor->editable = new_value; - - if (changed) { - set_editable (editor); - command_state_changed (editor); - } - break; - } - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -e_contact_list_editor_get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec) -{ - EContactListEditor *editor; - - editor = E_CONTACT_LIST_EDITOR (object); - - switch (prop_id) { - case PROP_BOOK: - g_value_set_object (value, editor->book); - break; - - case PROP_CONTACT: - extract_info(editor); - g_value_set_object (value, editor->contact); - break; - - case PROP_IS_NEW_LIST: - g_value_set_boolean (value, editor->is_new_list); - break; - - case PROP_EDITABLE: - g_value_set_boolean (value, editor->editable); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -e_contact_list_editor_show (EABEditor *editor) -{ - EContactListEditor *cle = E_CONTACT_LIST_EDITOR (editor); - gtk_widget_show (cle->app); -} - -static void -e_contact_list_editor_raise (EABEditor *editor) -{ - EContactListEditor *cle = E_CONTACT_LIST_EDITOR (editor); - gdk_window_raise (GTK_WIDGET (cle->app)->window); -} - -static void -e_contact_list_editor_close (EABEditor *editor) -{ - EContactListEditor *cle = E_CONTACT_LIST_EDITOR (editor); - g_assert (cle->app != NULL); - - gtk_widget_destroy (cle->app); - cle->app = NULL; - - eab_editor_closed (EAB_EDITOR (cle)); -} - -GtkWidget * -e_contact_list_editor_create_table(gchar *name, - gchar *string1, gchar *string2, - gint int1, gint int2); - -GtkWidget * -e_contact_list_editor_create_table(gchar *name, - gchar *string1, gchar *string2, - gint int1, gint int2) -{ - - ETableModel *model; - GtkWidget *table; - - model = e_contact_list_model_new (); - - table = e_table_scrolled_new_from_spec_file (model, - NULL, - EVOLUTION_ETSPECDIR "/e-contact-list-editor.etspec", - NULL); - - g_object_set_data(G_OBJECT(table), "model", model); - - return table; -} - -static void -add_to_model (EContactListEditor *editor, EDestination **cards) -{ - int i; - - for (i = 0; cards[i] != NULL; i++) { - e_contact_list_model_add_destination (E_CONTACT_LIST_MODEL(editor->model), cards[i]); - } -} - -static void -select_names_ok_cb (BonoboListener *listener, const char *event_name, const CORBA_any *arg, - CORBA_Environment *ev, gpointer data) -{ - EContactListEditor *ce; - EDestination **destv; - Bonobo_Control corba_control; - GtkWidget *control_widget; - char *string = NULL; - - ce = E_CONTACT_LIST_EDITOR (data); - - corba_control = GNOME_Evolution_Addressbook_SelectNames_getEntryBySection (ce->corba_select_names, - "Members", ev); - control_widget = bonobo_widget_new_control_from_objref (corba_control, CORBA_OBJECT_NIL); - - bonobo_widget_get_property (BONOBO_WIDGET (control_widget), "destinations", - TC_CORBA_string, &string, NULL); - - destv = e_destination_importv (string); - if (destv) { - add_to_model (ce, destv); - g_free (destv); - } - - ce->changed = TRUE; - command_state_changed (ce); -} - -static gboolean -setup_corba (EContactListEditor *editor) -{ - CORBA_Environment ev; - - CORBA_exception_init (&ev); - - editor->corba_select_names = bonobo_activation_activate_from_id (SELECT_NAMES_OAFIID, 0, NULL, &ev); - - /* OAF seems to be broken -- it can return a CORBA_OBJECT_NIL without - raising an exception in `ev'. */ - if (ev._major != CORBA_NO_EXCEPTION || editor->corba_select_names == CORBA_OBJECT_NIL) { - CORBA_exception_free (&ev); - return FALSE; - } - - GNOME_Evolution_Addressbook_SelectNames_addSection ( - editor->corba_select_names, "Members", gettext ("Members"), &ev); - - bonobo_event_source_client_add_listener (editor->corba_select_names, - (BonoboListenerCallbackFn) select_names_ok_cb, - "GNOME/Evolution:ok:dialog", NULL, editor); - - CORBA_exception_free (&ev); - - return TRUE; -} - -static void -select_cb (GtkWidget *w, EContactListEditor *editor) -{ - CORBA_Environment ev; - - if(!setup_corba (editor)) - return; - - CORBA_exception_init (&ev); - - GNOME_Evolution_Addressbook_SelectNames_activateDialog ( - editor->corba_select_names, _("Required Participants"), &ev); - - CORBA_exception_free (&ev); -} - -GtkWidget * -e_contact_list_editor_create_source_option_menu (gchar *name, - gchar *string1, gchar *string2, - gint int1, gint int2); - -GtkWidget * -e_contact_list_editor_create_source_option_menu (gchar *name, - gchar *string1, gchar *string2, - gint int1, gint int2) -{ - - GtkWidget *menu; - GConfClient *gconf_client; - ESourceList *source_list; - - gconf_client = gconf_client_get_default (); - source_list = e_source_list_new_for_gconf (gconf_client, "/apps/evolution/addressbook/sources"); - - menu = e_source_option_menu_new (source_list); - g_object_unref (source_list); - - gtk_widget_show (menu); - return menu; -} - -static void -add_email_cb (GtkWidget *w, EContactListEditor *editor) -{ - GtkAdjustment *adj = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (editor->table)); - const char *text = gtk_entry_get_text (GTK_ENTRY(editor->email_entry)); - - if (text && *text) { - e_contact_list_model_add_email (E_CONTACT_LIST_MODEL(editor->model), text); - - /* Skip to the end of the list */ - if (adj->upper - adj->lower > adj->page_size) - gtk_adjustment_set_value (adj, adj->upper); - - editor->changed = TRUE; - - } - - gtk_entry_set_text (GTK_ENTRY(editor->email_entry), ""); - command_state_changed (editor); -} - -static void -remove_row (int model_row, EContactListEditor *editor) -{ - e_contact_list_model_remove_row (E_CONTACT_LIST_MODEL (editor->model), model_row); -} - -static void -remove_entry_cb (GtkWidget *w, EContactListEditor *editor) -{ - e_table_selected_row_foreach (e_table_scrolled_get_table(E_TABLE_SCROLLED(editor->table)), - (EForeachFunc)remove_row, editor); - editor->changed = TRUE; - command_state_changed (editor); -} - -static void -list_name_changed_cb (GtkWidget *w, EContactListEditor *editor) -{ - char *string = gtk_editable_get_chars(GTK_EDITABLE (w), 0, -1); - char *title; - - editor->changed = TRUE; - - if (string && *string) - title = string; - else - title = _("Contact List Editor"); - - gtk_window_set_title (GTK_WINDOW (editor->app), title); - - g_free (string); - - command_state_changed (editor); -} - -static void -list_image_changed_cb (GtkWidget *w, EContactListEditor *editor) -{ - editor->image_set = TRUE; - editor->changed = TRUE; - command_state_changed (editor); -} - -static void -visible_addrs_toggled_cb (GtkWidget *w, EContactListEditor *editor) -{ - editor->changed = TRUE; - command_state_changed (editor); -} - -static void -set_editable (EContactListEditor *editor) -{ - gtk_widget_set_sensitive (editor->email_entry, editor->editable && editor->allows_contact_lists); - gtk_widget_set_sensitive (editor->list_name_entry, editor->editable && editor->allows_contact_lists); - gtk_widget_set_sensitive (editor->add_button, editor->editable && editor->allows_contact_lists); - gtk_widget_set_sensitive (editor->remove_button, editor->editable && editor->allows_contact_lists); - gtk_widget_set_sensitive (editor->select_button, editor->editable && editor->allows_contact_lists); - gtk_widget_set_sensitive (editor->table, editor->editable && editor->allows_contact_lists); -} - -/* Callback used when the editor is destroyed */ -static gint -app_delete_event_cb (GtkWidget *widget, GdkEvent *event, gpointer data) -{ - EContactListEditor *ce; - - ce = E_CONTACT_LIST_EDITOR (data); - - /* if we're in an async call, don't allow the dialog to close */ - if (ce->in_async_call) - return TRUE; - - if (!eab_editor_prompt_to_save_changes (EAB_EDITOR (ce), GTK_WINDOW (ce->app))) - return TRUE; - - eab_editor_close (EAB_EDITOR (ce)); - return TRUE; -} - -static gboolean -table_drag_motion_cb (ETable *table, int row, int col, - GdkDragContext *context, - gint x, gint y, guint time, EContactListEditor *editor) -{ - GList *p; - - for (p = context->targets; p != NULL; p = p->next) { - char *possible_type; - - possible_type = gdk_atom_name (GDK_POINTER_TO_ATOM (p->data)); - if (!strcmp (possible_type, VCARD_TYPE)) { - g_free (possible_type); - gdk_drag_status (context, GDK_ACTION_LINK, time); - return TRUE; - } - - g_free (possible_type); - } - - return FALSE; -} - -static gboolean -table_drag_drop_cb (ETable *table, int row, int col, - GdkDragContext *context, - gint x, gint y, guint time, EContactListEditor *editor) -{ - GList *p; - - for (p = context->targets; p != NULL; p = p->next) { - char *possible_type; - - possible_type = gdk_atom_name (GDK_POINTER_TO_ATOM (p->data)); - if (!strcmp (possible_type, VCARD_TYPE)) { - g_free (possible_type); - break; - } - - g_free (possible_type); - } - - - if (p) { - gtk_drag_get_data (GTK_WIDGET (table), context, - GDK_POINTER_TO_ATOM (p->data), - time); - return TRUE; - } - - return FALSE; -} - -static void -table_drag_data_received_cb (ETable *table, int row, int col, - GdkDragContext *context, - gint x, gint y, - GtkSelectionData *selection_data, - guint info, guint time, EContactListEditor *editor) -{ - GtkAdjustment *adj = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (editor->table)); - char *target_type; - gboolean changed = FALSE; - gboolean handled = FALSE; - - target_type = gdk_atom_name (selection_data->target); - - if (!strcmp (target_type, VCARD_TYPE)) { - - GList *contact_list = eab_contact_list_from_string (selection_data->data); - GList *c; - - if (contact_list) - handled = TRUE; - - for (c = contact_list; c; c = c->next) { - EContact *contact = c->data; - - if (!e_contact_get (contact, E_CONTACT_IS_LIST)) { - e_contact_list_model_add_contact (E_CONTACT_LIST_MODEL (editor->model), - contact, - 0 /* Hard-wired for default e-mail */); - - changed = TRUE; - } - } - g_list_foreach (contact_list, (GFunc)g_object_unref, NULL); - g_list_free (contact_list); - - /* Skip to the end of the list */ - if (adj->upper - adj->lower > adj->page_size) - gtk_adjustment_set_value (adj, adj->upper); - - if (changed) { - editor->changed = TRUE; - command_state_changed (editor); - } - } - - gtk_drag_finish (context, handled, FALSE, time); -} - -static void -command_state_changed (EContactListEditor *editor) -{ - gboolean valid = eab_editor_is_valid (EAB_EDITOR (editor)); - - /* FIXME set the ok button to ok */ - gtk_widget_set_sensitive (editor->ok_button, valid && editor->allows_contact_lists); - gtk_widget_set_sensitive (editor->source_menu, editor->is_new_list); - gtk_widget_set_sensitive (glade_xml_get_widget (editor->gui, "source-label"), editor->is_new_list); -} - -static void -extract_info(EContactListEditor *editor) -{ - EContact *contact = editor->contact; - if (contact) { - int i; - char *image_data; - gsize image_data_len; - char *string = gtk_editable_get_chars(GTK_EDITABLE (editor->list_name_entry), 0, -1); - - if (string && *string) { - e_contact_set (contact, E_CONTACT_FILE_AS, string); - e_contact_set (contact, E_CONTACT_FULL_NAME, string); - } - - g_free (string); - - e_contact_set (contact, E_CONTACT_IS_LIST, GINT_TO_POINTER (TRUE)); - e_contact_set (contact, E_CONTACT_LIST_SHOW_ADDRESSES, - GINT_TO_POINTER (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(editor->visible_addrs_checkbutton)))); - - e_vcard_remove_attributes (E_VCARD (contact), "", EVC_EMAIL); - - /* then refill it from the contact list model */ - for (i = 0; i < e_table_model_row_count (editor->model); i ++) { - const EDestination *dest = e_contact_list_model_get_destination (E_CONTACT_LIST_MODEL (editor->model), i); - EVCardAttribute *attr; - - attr = e_vcard_attribute_new (NULL, EVC_EMAIL); - - e_vcard_add_attribute (E_VCARD (contact), attr); - - e_destination_export_to_vcard_attribute ((EDestination*)dest, attr); - } - - if (editor->image_set - && e_image_chooser_get_image_data (E_IMAGE_CHOOSER (editor->list_image), - &image_data, - &image_data_len)) { - EContactPhoto photo; - - photo.data = image_data; - photo.length = image_data_len; - - e_contact_set (contact, E_CONTACT_LOGO, &photo); - g_free (image_data); - } - else { - e_contact_set (contact, E_CONTACT_LOGO, NULL); - } - } -} - -static void -fill_in_info(EContactListEditor *editor) -{ - if (editor->contact) { - EContactPhoto *photo; - char *file_as; - gboolean show_addresses = FALSE; - gboolean is_evolution_list = FALSE; - GList *email_list; - GList *iter; - - file_as = e_contact_get_const (editor->contact, E_CONTACT_FILE_AS); - email_list = e_contact_get_attributes (editor->contact, E_CONTACT_EMAIL); - is_evolution_list = GPOINTER_TO_INT (e_contact_get (editor->contact, E_CONTACT_IS_LIST)); - show_addresses = GPOINTER_TO_INT (e_contact_get (editor->contact, E_CONTACT_LIST_SHOW_ADDRESSES)); - - gtk_editable_delete_text (GTK_EDITABLE (editor->list_name_entry), 0, -1); - if (file_as) { - int position = 0; - gtk_editable_insert_text (GTK_EDITABLE (editor->list_name_entry), file_as, strlen (file_as), &position); - g_free (file_as); - } - - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(editor->visible_addrs_checkbutton), !show_addresses); - - e_contact_list_model_remove_all (E_CONTACT_LIST_MODEL (editor->model)); - - for (iter = email_list; iter; iter = iter->next) { - EVCardAttribute *attr = iter->data; - GList *p; - EDestination *list_dest = e_destination_new (); - char *contact_uid = NULL; - char *email = NULL; - char *name = NULL; - int email_num = -1; - gboolean html_pref = FALSE; - - for (p = e_vcard_attribute_get_params (attr); p; p = p->next) { - EVCardAttributeParam *param = p->data; - const char *param_name = e_vcard_attribute_param_get_name (param); - if (!g_ascii_strcasecmp (param_name, - EVC_X_DEST_CONTACT_UID)) { - GList *v = e_vcard_attribute_param_get_values (param); - contact_uid = v ? v->data : NULL; - } - else if (!g_ascii_strcasecmp (param_name, - EVC_X_DEST_EMAIL_NUM)) { - GList *v = e_vcard_attribute_param_get_values (param); - email_num = v ? atoi (v->data) : -1; - } - else if (!g_ascii_strcasecmp (param_name, - EVC_X_DEST_NAME)) { - GList *v = e_vcard_attribute_param_get_values (param); - name = v ? v->data : NULL; - } - else if (!g_ascii_strcasecmp (param_name, - EVC_X_DEST_EMAIL)) { - GList *v = e_vcard_attribute_param_get_values (param); - email = v ? v->data : NULL; - } - else if (!g_ascii_strcasecmp (param_name, - EVC_X_DEST_HTML_MAIL)) { - GList *v = e_vcard_attribute_param_get_values (param); - html_pref = v ? !g_ascii_strcasecmp (v->data, "true") : FALSE; - } - } - - if (contact_uid) e_destination_set_contact_uid (list_dest, contact_uid, email_num); - if (name) e_destination_set_name (list_dest, name); - if (email) e_destination_set_email (list_dest, email); - e_destination_set_html_mail_pref (list_dest, html_pref); - - e_contact_list_model_add_destination (E_CONTACT_LIST_MODEL (editor->model), list_dest); - } - - g_list_foreach (email_list, (GFunc) e_vcard_attribute_free, NULL); - g_list_free (email_list); - - photo = e_contact_get (editor->contact, E_CONTACT_LOGO); - if (photo) { - e_image_chooser_set_image_data (E_IMAGE_CHOOSER (editor->list_image), photo->data, photo->length); - e_contact_photo_free (photo); - } - } - - if (editor->book) { - ESource *source; - - source = e_book_get_source (editor->book); - e_source_option_menu_select (E_SOURCE_OPTION_MENU (editor->source_menu), source); - gtk_widget_set_sensitive (editor->source_menu, editor->is_new_list); - gtk_widget_set_sensitive (glade_xml_get_widget (editor->gui, "source-label"), editor->is_new_list); - } -} diff --git a/addressbook/gui/contact-list-editor/e-contact-list-editor.etspec b/addressbook/gui/contact-list-editor/e-contact-list-editor.etspec deleted file mode 100644 index 6d5f4f2514..0000000000 --- a/addressbook/gui/contact-list-editor/e-contact-list-editor.etspec +++ /dev/null @@ -1,7 +0,0 @@ -<ETableSpecification no-headers="true" cursor-mode="line" selection-mode="single"> -<ETableColumn model_col= "0" _title="Contact" expansion="1.0" minimum_width="20" resizable="true" cell="string" compare="string" /> - <ETableState> - <column source="0"/> - <grouping> </grouping> - </ETableState> -</ETableSpecification> diff --git a/addressbook/gui/contact-list-editor/e-contact-list-editor.h b/addressbook/gui/contact-list-editor/e-contact-list-editor.h deleted file mode 100644 index ca6aef85bc..0000000000 --- a/addressbook/gui/contact-list-editor/e-contact-list-editor.h +++ /dev/null @@ -1,124 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* e-contact-list-editor.h - * Copyright (C) 2001 Ximian, Inc. - * Author: Chris Toshok <toshok@ximian.com> - * - * This library 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 library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ -#ifndef __E_CONTACT_LIST_EDITOR_H__ -#define __E_CONTACT_LIST_EDITOR_H__ - -#include <libgnomeui/gnome-app.h> -#include <libgnomeui/gnome-app-helper.h> -#include <bonobo/bonobo-ui-component.h> -#include <glade/glade.h> -#include <gal/e-table/e-table-model.h> - -#include "addressbook/gui/contact-editor/eab-editor.h" - -#include <libebook/e-book.h> -#include <libebook/e-contact.h> -#include "addressbook/util/e-destination.h" - -G_BEGIN_DECLS - -#define E_TYPE_CONTACT_LIST_EDITOR (e_contact_list_editor_get_type ()) -#define E_CONTACT_LIST_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_CONTACT_LIST_EDITOR, EContactListEditor)) -#define E_CONTACT_LIST_EDITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_CONTACT_LIST_EDITOR, EContactListEditorClass)) -#define E_IS_CONTACT_LIST_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_CONTACT_LIST_EDITOR)) -#define E_IS_CONTACT_LIST_EDITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), E_TYPE_CONTACT_LIST_EDITOR)) - -#define SELECT_NAMES_OAFIID "OAFIID:GNOME_Evolution_Addressbook_SelectNames:" BASE_VERSION - -typedef struct _EContactListEditor EContactListEditor; -typedef struct _EContactListEditorClass EContactListEditorClass; - -struct _EContactListEditor -{ - EABEditor parent; - - /* item specific fields */ - EBook *book; - - EContact *contact; - - /* UI handler */ - BonoboUIComponent *uic; - - GladeXML *gui; - GtkWidget *app; - - GtkWidget *table; - ETableModel *model; - GtkWidget *email_entry; - GtkWidget *list_name_entry; - GtkWidget *add_button; - GtkWidget *remove_button; - GtkWidget *select_button; - GtkWidget *list_image_button; - GtkWidget *visible_addrs_checkbutton; - GtkWidget *list_image; - GtkWidget *source_menu; - GtkWidget *ok_button; - GtkWidget *cancel_button; - - /* FIXME: Unfortunately, we can't use the proper name here, as it'd - * create a circular dependency. The long-term solution would be to - * move the select-names component out of the component/ dir so it can - * be built before sources using this. - * - * GNOME_Evolution_Addressbook_SelectNames corba_select_names; */ - gpointer corba_select_names; - - /* Whether we are editing a new contact or an existing one */ - guint is_new_list : 1; - - /* Whether the image chooser widget has been changed. */ - guint image_set : 1; - - /* Whether the contact has been changed since bringing up the contact editor */ - guint changed : 1; - - /* Whether the contact editor will accept modifications */ - guint editable : 1; - - /* Whether the target book accepts storing of contact lists */ - guint allows_contact_lists : 1; - - /* Whether an async wombat call is in progress */ - guint in_async_call : 1; - - /* ID for async load_source call */ - guint load_source_id; - EBook *load_book; -}; - -struct _EContactListEditorClass -{ - EABEditorClass parent_class; -}; - -EContactListEditor *e_contact_list_editor_new (EBook *book, - EContact *list_contact, - gboolean is_new_list, - gboolean editable); -GType e_contact_list_editor_get_type (void); - -gboolean e_contact_list_editor_request_close_all (void); - -G_END_DECLS - - -#endif /* __E_CONTACT_LIST_EDITOR_H__ */ diff --git a/addressbook/gui/contact-list-editor/e-contact-list-model.c b/addressbook/gui/contact-list-editor/e-contact-list-model.c deleted file mode 100644 index 4560413c19..0000000000 --- a/addressbook/gui/contact-list-editor/e-contact-list-model.c +++ /dev/null @@ -1,284 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -#include <config.h> -#include <string.h> -#include "e-contact-list-model.h" -#include "widgets/misc/e-error.h" - -#include <gtk/gtkmessagedialog.h> -#define PARENT_TYPE e_table_model_get_type() -static ETableModelClass *parent_class; - -#define COLS 1 - -/* This function returns the number of columns in our ETableModel. */ -static int -contact_list_col_count (ETableModel *etc) -{ - return COLS; -} - -/* This function returns the number of rows in our ETableModel. */ -static int -contact_list_row_count (ETableModel *etc) -{ - EContactListModel *model = E_CONTACT_LIST_MODEL (etc); - return model->data_count; -} - -/* This function returns the value at a particular point in our ETableModel. */ -static void * -contact_list_value_at (ETableModel *etc, int col, int row) -{ - EContactListModel *model = E_CONTACT_LIST_MODEL (etc); - - return (void *) e_destination_get_textrep (model->data[row], TRUE); -} - -/* This function sets the value at a particular point in our ETableModel. */ -static void -contact_list_set_value_at (ETableModel *etc, int col, int row, const void *val) -{ - /* nothing */ -} - -/* This function returns whether a particular cell is editable. */ -static gboolean -contact_list_is_cell_editable (ETableModel *etc, int col, int row) -{ - return FALSE; -} - -/* This function duplicates the value passed to it. */ -static void * -contact_list_duplicate_value (ETableModel *etc, int col, const void *value) -{ - return g_strdup(value); -} - -/* This function frees the value passed to it. */ -static void -contact_list_free_value (ETableModel *etc, int col, void *value) -{ - g_free(value); -} - -static void * -contact_list_initialize_value (ETableModel *etc, int col) -{ - return g_strdup(""); -} - -static gboolean -contact_list_value_is_empty (ETableModel *etc, int col, const void *value) -{ - return !(value && *(char *)value); -} - -static char * -contact_list_value_to_string (ETableModel *etc, int col, const void *value) -{ - return g_strdup(value); -} - -static void -contact_list_model_dispose (GObject *o) -{ - EContactListModel *model = E_CONTACT_LIST_MODEL (o); - int i; - - if (model->data != NULL) { - for (i = 0; i < model->data_count; i ++) { - g_object_unref (model->data[i]); - } - g_free (model->data); - model->data = NULL; - } - - model->data_count = 0; - model->data_alloc = 0; - - (* G_OBJECT_CLASS (parent_class)->dispose) (o); -} - -static void -e_contact_list_model_class_init (GObjectClass *object_class) -{ - ETableModelClass *model_class = (ETableModelClass *) object_class; - - parent_class = g_type_class_ref (PARENT_TYPE); - - object_class->dispose = contact_list_model_dispose; - - model_class->column_count = contact_list_col_count; - model_class->row_count = contact_list_row_count; - model_class->value_at = contact_list_value_at; - model_class->set_value_at = contact_list_set_value_at; - model_class->is_cell_editable = contact_list_is_cell_editable; - model_class->duplicate_value = contact_list_duplicate_value; - model_class->free_value = contact_list_free_value; - model_class->initialize_value = contact_list_initialize_value; - model_class->value_is_empty = contact_list_value_is_empty; - model_class->value_to_string = contact_list_value_to_string; -} - -static void -e_contact_list_model_init (GObject *object) -{ - EContactListModel *model = E_CONTACT_LIST_MODEL(object); - - model->data_alloc = 10; - model->data_count = 0; - model->data = g_new (EDestination*, model->data_alloc); -} - -GType -e_contact_list_model_get_type (void) -{ - static GType cle_type = 0; - - if (!cle_type) { - static const GTypeInfo cle_info = { - sizeof (EContactListModelClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) e_contact_list_model_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (EContactListModel), - 0, /* n_preallocs */ - (GInstanceInitFunc) e_contact_list_model_init, - }; - - cle_type = g_type_register_static (E_TABLE_MODEL_TYPE, "EContactListModel", &cle_info, 0); - } - - return cle_type; -} - -void -e_contact_list_model_construct (EContactListModel *model) -{ -} - -ETableModel * -e_contact_list_model_new () -{ - EContactListModel *model; - - model = g_object_new (E_TYPE_CONTACT_LIST_MODEL, NULL); - - e_contact_list_model_construct (model); - - return E_TABLE_MODEL(model); -} - -void -e_contact_list_model_add_destination (EContactListModel *model, EDestination *dest) -{ - g_return_if_fail (E_IS_CONTACT_LIST_MODEL (model)); - g_return_if_fail (E_IS_DESTINATION (dest)); - - e_table_model_pre_change (E_TABLE_MODEL (model)); - - if (model->data_count + 1 >= model->data_alloc) { - model->data_alloc *= 2; - model->data = g_renew (EDestination*, model->data, model->data_alloc); - } - - model->data[model->data_count ++] = dest; - g_object_ref (dest); - - e_table_model_row_inserted (E_TABLE_MODEL (model), model->data_count - 1); -} - -void -e_contact_list_model_add_email (EContactListModel *model, - const char *email) -{ - EDestination *new_dest; - char *list_email; - int row; - int row_count; - - g_return_if_fail (E_IS_CONTACT_LIST_MODEL (model)); - g_return_if_fail (email != NULL); - - row_count = e_table_model_row_count (E_TABLE_MODEL (model)); - - for (row = 0; row < row_count; row++) { - list_email = (char *) e_table_model_value_at (E_TABLE_MODEL (model), 1, row); - - if (strcmp (list_email, email) == 0) { - if (e_error_run (NULL, "addressbook:ask-list-add-exists", - email) != GTK_RESPONSE_YES) - return; - break; - } - } - - new_dest = e_destination_new (); - e_destination_set_email (new_dest, email); - - e_contact_list_model_add_destination (model, new_dest); -} - -void -e_contact_list_model_add_contact (EContactListModel *model, - EContact *contact, - int email_num) -{ - EDestination *new_dest; - - g_return_if_fail (E_IS_CONTACT_LIST_MODEL (model)); - g_return_if_fail (E_IS_CONTACT (contact)); - - new_dest = e_destination_new (); - e_destination_set_contact (new_dest, contact, email_num); - - e_contact_list_model_add_destination (model, new_dest); -} - -void -e_contact_list_model_remove_row (EContactListModel *model, int row) -{ - g_return_if_fail (E_IS_CONTACT_LIST_MODEL (model)); - g_return_if_fail (0 <= row && row < model->data_count); - - e_table_model_pre_change (E_TABLE_MODEL (model)); - - g_object_unref (model->data[row]); - memmove (model->data + row, model->data + row + 1, sizeof (EDestination*) * (model->data_count - row - 1)); - model->data_count --; - - e_table_model_row_deleted (E_TABLE_MODEL (model), row); -} - -void -e_contact_list_model_remove_all (EContactListModel *model) -{ - int i; - - g_return_if_fail (E_IS_CONTACT_LIST_MODEL (model)); - - e_table_model_pre_change (E_TABLE_MODEL (model)); - - for (i = 0; i < model->data_count; i ++) { - g_object_unref (model->data[i]); - model->data[i] = NULL; - } - - model->data_count = 0; - - e_table_model_changed (E_TABLE_MODEL (model)); -} - - -const EDestination * -e_contact_list_model_get_destination (EContactListModel *model, int row) -{ - g_return_val_if_fail (E_IS_CONTACT_LIST_MODEL (model), NULL); - g_return_val_if_fail (0 <= row && row < model->data_count, NULL); - - return model->data[row]; -} diff --git a/addressbook/gui/contact-list-editor/e-contact-list-model.h b/addressbook/gui/contact-list-editor/e-contact-list-model.h deleted file mode 100644 index 0c01dfa7ed..0000000000 --- a/addressbook/gui/contact-list-editor/e-contact-list-model.h +++ /dev/null @@ -1,49 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -#ifndef _E_CONTACT_LIST_MODEL_H_ -#define _E_CONTACT_LIST_MODEL_H_ - -#include <gal/e-table/e-table-model.h> -#include <libebook/e-contact.h> -#include "addressbook/util/e-destination.h" - -G_BEGIN_DECLS - -#define E_TYPE_CONTACT_LIST_MODEL (e_contact_list_model_get_type ()) -#define E_CONTACT_LIST_MODEL(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), E_TYPE_CONTACT_LIST_MODEL, EContactListModel)) -#define E_CONTACT_LIST_MODEL_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), E_TYPE_CONTACT_LIST_MODEL, EContactListModelClass)) -#define E_IS_CONTACT_LIST_MODEL(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), E_TYPE_CONTACT_LIST_MODEL)) -#define E_IS_CONTACT_LIST_MODEL_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), E_TYPE_CONTACT_LIST_MODEL)) - -typedef struct _EContactListModel EContactListModel; -typedef struct _EContactListModelClass EContactListModelClass; - -struct _EContactListModel { - ETableModel parent; - - EDestination **data; - int data_count; - int data_alloc; -}; - - -struct _EContactListModelClass { - ETableModelClass parent_class; -}; - - -GType e_contact_list_model_get_type (void); -void e_contact_list_model_construct (EContactListModel *model); -ETableModel *e_contact_list_model_new (void); - -void e_contact_list_model_add_destination (EContactListModel *model, EDestination *dest); -void e_contact_list_model_add_email (EContactListModel *model, const char *email); -void e_contact_list_model_add_contact (EContactListModel *model, EContact *contact, int email_num); - -void e_contact_list_model_remove_row (EContactListModel *model, int row); -void e_contact_list_model_remove_all (EContactListModel *model); - -const EDestination *e_contact_list_model_get_destination (EContactListModel *model, int row); - -G_END_DECLS - -#endif /* _E_CONTACT_LIST_MODEL_H_ */ diff --git a/addressbook/gui/merging/.cvsignore b/addressbook/gui/merging/.cvsignore deleted file mode 100644 index b6fa83ca4c..0000000000 --- a/addressbook/gui/merging/.cvsignore +++ /dev/null @@ -1,8 +0,0 @@ -.deps -.libs -.pure -Makefile -Makefile.in -*.lo -*.la -*.gladep diff --git a/addressbook/gui/merging/Makefile.am b/addressbook/gui/merging/Makefile.am deleted file mode 100644 index f1d589ad00..0000000000 --- a/addressbook/gui/merging/Makefile.am +++ /dev/null @@ -1,24 +0,0 @@ -INCLUDES = \ - -DG_LOG_DOMAIN=\"eab-contact-merging\" \ - -DEVOLUTION_GLADEDIR=\""$(gladedir)"\" \ - -I$(top_srcdir) \ - -I$(top_srcdir)/addressbook \ - -I$(top_srcdir)/addressbook/backend \ - -I$(top_builddir)/addressbook/backend \ - $(EVOLUTION_ADDRESSBOOK_CFLAGS) - -noinst_LTLIBRARIES = \ - libeabbookmerging.la - -libeabbookmerging_la_SOURCES = \ - eab-contact-compare.c \ - eab-contact-compare.h \ - eab-contact-merging.c \ - eab-contact-merging.h - - -glade_DATA = eab-contact-duplicate-detected.glade \ - eab-contact-commit-duplicate-detected.glade - -EXTRA_DIST = \ - $(glade_DATA) diff --git a/addressbook/gui/merging/eab-contact-commit-duplicate-detected.glade b/addressbook/gui/merging/eab-contact-commit-duplicate-detected.glade deleted file mode 100644 index 3ad86b40ba..0000000000 --- a/addressbook/gui/merging/eab-contact-commit-duplicate-detected.glade +++ /dev/null @@ -1,212 +0,0 @@ -<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*--> -<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd"> - -<glade-interface> - -<widget class="GtkDialog" id="dialog-duplicate-contact"> - <property name="border_width">6</property> - <property name="visible">True</property> - <property name="title" translatable="yes">Duplicate Contact Detected</property> - <property name="type">GTK_WINDOW_TOPLEVEL</property> - <property name="window_position">GTK_WIN_POS_NONE</property> - <property name="modal">False</property> - <property name="resizable">True</property> - <property name="destroy_with_parent">False</property> - <property name="has_separator">True</property> - - <child internal-child="vbox"> - <widget class="GtkVBox" id="dialog-vbox1"> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">6</property> - - <child internal-child="action_area"> - <widget class="GtkHButtonBox" id="dialog-action_area1"> - <property name="visible">True</property> - <property name="layout_style">GTK_BUTTONBOX_END</property> - - <child> - <widget class="GtkButton" id="button3"> - <property name="visible">True</property> - <property name="can_default">True</property> - <property name="can_focus">True</property> - <property name="label">gtk-cancel</property> - <property name="use_stock">True</property> - <property name="relief">GTK_RELIEF_NORMAL</property> - <property name="response_id">1</property> - </widget> - </child> - - <child> - <widget class="GtkButton" id="button4"> - <property name="visible">True</property> - <property name="can_default">True</property> - <property name="can_focus">True</property> - <property name="label">gtk-add</property> - <property name="use_stock">True</property> - <property name="relief">GTK_RELIEF_NORMAL</property> - <property name="response_id">0</property> - </widget> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="pack_type">GTK_PACK_END</property> - </packing> - </child> - - <child> - <widget class="GtkTable" id="table1"> - <property name="border_width">6</property> - <property name="visible">True</property> - <property name="n_rows">5</property> - <property name="n_columns">2</property> - <property name="homogeneous">False</property> - <property name="row_spacing">6</property> - <property name="column_spacing">6</property> - - <child> - <widget class="Custom" id="custom-old-contact"> - <property name="visible">True</property> - <property name="creation_function">_eab_contact_merging_create_contact_display</property> - <property name="int1">0</property> - <property name="int2">0</property> - <property name="last_modification_time">Sun, 05 Oct 2003 03:54:20 GMT</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">4</property> - <property name="bottom_attach">5</property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label1"> - <property name="visible">True</property> - <property name="label" translatable="yes">The changed email or name of this contact already -exists in this folder. Would you like to add it anyway?</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">0</property> - <property name="bottom_attach">1</property> - <property name="y_options">fill</property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label3"> - <property name="visible">True</property> - <property name="label" translatable="yes">Conflicting Contact:</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_CENTER</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">3</property> - <property name="bottom_attach">4</property> - <property name="y_options">fill</property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label4"> - <property name="visible">True</property> - <property name="label" translatable="yes">Changed Contact:</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_CENTER</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="Custom" id="custom-new-contact"> - <property name="visible">True</property> - <property name="creation_function">_eab_contact_merging_create_contact_display</property> - <property name="int1">0</property> - <property name="int2">0</property> - <property name="last_modification_time">Sun, 05 Oct 2003 03:53:42 GMT</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">2</property> - <property name="bottom_attach">3</property> - </packing> - </child> - - <child> - <widget class="GtkAlignment" id="alignment1"> - <property name="visible">True</property> - <property name="xalign">0.5</property> - <property name="yalign">0</property> - <property name="xscale">1</property> - <property name="yscale">0</property> - - <child> - <widget class="Custom" id="custom2"> - <property name="visible">True</property> - <property name="creation_function">e_create_image_widget</property> - <property name="string1">stock_person</property> - <property name="int1">0</property> - <property name="int2">0</property> - <property name="last_modification_time">Fri, 08 Jun 2001 00:18:39 GMT</property> - </widget> - </child> - </widget> - <packing> - <property name="left_attach">0</property> - <property name="right_attach">1</property> - <property name="top_attach">0</property> - <property name="bottom_attach">5</property> - <property name="x_options">fill</property> - <property name="y_options">fill</property> - </packing> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">True</property> - <property name="fill">True</property> - </packing> - </child> - </widget> - </child> -</widget> - -</glade-interface> diff --git a/addressbook/gui/merging/eab-contact-compare.c b/addressbook/gui/merging/eab-contact-compare.c deleted file mode 100644 index 4244f3fbff..0000000000 --- a/addressbook/gui/merging/eab-contact-compare.c +++ /dev/null @@ -1,798 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * eab-contact-compare.c - * - * Copyright (C) 2001, 2002, 2003 Ximian, Inc. - * - * Authors: Jon Trowbridge <trow@ximian.com> - * Chris Toshok <toshok@ximian.com> - */ - -/* - * 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. - */ - -#include <config.h> -#include <ctype.h> -#include <string.h> -#include "util/eab-book-util.h" -#include "../component/addressbook.h" -#include "eab-contact-compare.h" - -/* This is an "optimistic" combiner: the best of the two outcomes is - selected. */ -static EABContactMatchType -combine_comparisons (EABContactMatchType prev, - EABContactMatchType new_info) -{ - if (new_info == EAB_CONTACT_MATCH_NOT_APPLICABLE) - return prev; - return (EABContactMatchType) MAX ((gint) prev, (gint) new_info); -} - - -/*** Name comparisons ***/ - -/* This *so* doesn't belong here... at least not implemented in a - sucky way like this. But it can be fixed later. */ - -/* This is very Anglocentric. */ -static gchar *name_synonyms[][2] = { - { "jon", "john" }, /* Ah, the hacker's perogative */ - { "joseph", "joe" }, - { "robert", "bob" }, - { "gene", "jean" }, - { "jesse", "jessie" }, - { "ian", "iain" }, - { "richard", "dick" }, - { "william", "bill" }, - { "william", "will" }, - { "anthony", "tony" }, - { "michael", "mike" }, - { "eric", "erik" }, - { "elizabeth", "liz" }, - { "jeff", "geoff" }, - { "jeff", "geoffrey" }, - { "tom", "thomas" }, - { "dave", "david" }, - { "jim", "james" }, - { "abigal", "abby" }, - { "amanda", "amy" }, - { "amanda", "manda" }, - { "jennifer", "jenny" }, - { "christopher", "chris" }, - { "rebecca", "becca" }, - { "rebecca", "becky" }, - { "anderson", "andersen" }, - { "johnson", "johnsen" }, - /* We could go on and on... */ - /* We should add soundex here. */ - { NULL, NULL } -}; - -static gboolean -name_fragment_match (const gchar *a, const gchar *b, gboolean strict) -{ - gint len; - - if (!(a && b && *a && *b)) - return FALSE; - - /* If we are in 'strict' mode, b must match the beginning of a. - So "Robert", "Rob" would match, but "Robert", "Robbie" wouldn't. - - If strict is FALSE, it is sufficient for the strings to share - some leading characters. In this case, "Robert" and "Robbie" - would match, as would "Dave" and "Dan". */ - - if (strict) { - len = g_utf8_strlen (b, -1); - } else { - len = MIN (g_utf8_strlen (a, -1), g_utf8_strlen (b, -1)); - } - - return !e_utf8_casefold_collate_len (a, b, len); -} - -static gboolean -name_fragment_match_with_synonyms (const gchar *a, const gchar *b, gboolean strict) -{ - gint i; - - if (!(a && b && *a && *b)) - return FALSE; - - if (name_fragment_match (a, b, strict)) - return TRUE; - - /* Check for nicknames. Yes, the linear search blows. */ - for (i=0; name_synonyms[i][0]; ++i) { - - if (!e_utf8_casefold_collate (name_synonyms[i][0], a) - && !e_utf8_casefold_collate (name_synonyms[i][1], b)) - return TRUE; - - if (!e_utf8_casefold_collate (name_synonyms[i][0], b) - && !e_utf8_casefold_collate (name_synonyms[i][1], a)) - return TRUE; - } - - return FALSE; -} - -EABContactMatchType -eab_contact_compare_name_to_string (EContact *contact, const gchar *str) -{ - return eab_contact_compare_name_to_string_full (contact, str, FALSE, NULL, NULL, NULL); -} - -EABContactMatchType -eab_contact_compare_name_to_string_full (EContact *contact, const gchar *str, gboolean allow_partial_matches, - gint *matched_parts_out, EABContactMatchPart *first_matched_part_out, gint *matched_character_count_out) -{ - gchar **namev, **givenv = NULL, **addv = NULL, **familyv = NULL; - - gint matched_parts = EAB_CONTACT_MATCH_PART_NONE; - EABContactMatchPart first_matched_part = EAB_CONTACT_MATCH_PART_NONE; - EABContactMatchPart this_part_match = EAB_CONTACT_MATCH_PART_NOT_APPLICABLE; - EABContactMatchType match_type; - EContactName *contact_name; - - gint match_count = 0, matched_character_count = 0, fragment_count; - gint i, j; - gchar *str_cpy, *s; - - g_return_val_if_fail (E_IS_CONTACT (contact), EAB_CONTACT_MATCH_NOT_APPLICABLE); - - if (!e_contact_get_const (contact, E_CONTACT_FULL_NAME)) - return EAB_CONTACT_MATCH_NOT_APPLICABLE; - if (str == NULL) - return EAB_CONTACT_MATCH_NOT_APPLICABLE; - - str_cpy = s = g_strdup (str); - while (*s) { - if (*s == ',' || *s == '"') - *s = ' '; - ++s; - } - namev = g_strsplit (str_cpy, " ", 0); - g_free (str_cpy); - - contact_name = e_contact_get (contact, E_CONTACT_NAME); - - if (contact_name->given) - givenv = g_strsplit (contact_name->given, " ", 0); - if (contact_name->additional) - addv = g_strsplit (contact_name->additional, " ", 0); - if (contact_name->family) - familyv = g_strsplit (contact_name->family, " ", 0); - - e_contact_name_free (contact_name); - - fragment_count = 0; - for (i = 0; givenv && givenv[i]; ++i) - ++fragment_count; - for (i = 0; addv && addv[i]; ++i) - ++fragment_count; - for (i = 0; familyv && familyv[i]; ++i) - ++fragment_count; - - for (i = 0; namev[i] && this_part_match != EAB_CONTACT_MATCH_PART_NONE; ++i) { - - if (*namev[i]) { - - this_part_match = EAB_CONTACT_MATCH_PART_NONE; - - /* When we are allowing partials, we are strict about the matches we allow. - Does this make sense? Not really, but it does the right thing for the purposes - of completion. */ - - if (givenv && this_part_match == EAB_CONTACT_MATCH_PART_NONE) { - for (j = 0; givenv[j]; ++j) { - if (name_fragment_match_with_synonyms (givenv[j], namev[i], allow_partial_matches)) { - - this_part_match = EAB_CONTACT_MATCH_PART_GIVEN_NAME; - - /* We remove a piece of a name once it has been matched against, so - that "john john" won't match "john doe". */ - g_free (givenv[j]); - givenv[j] = g_strdup (""); - break; - } - } - } - - if (addv && this_part_match == EAB_CONTACT_MATCH_PART_NONE) { - for (j = 0; addv[j]; ++j) { - if (name_fragment_match_with_synonyms (addv[j], namev[i], allow_partial_matches)) { - - this_part_match = EAB_CONTACT_MATCH_PART_ADDITIONAL_NAME; - - g_free (addv[j]); - addv[j] = g_strdup (""); - break; - } - } - } - - if (familyv && this_part_match == EAB_CONTACT_MATCH_PART_NONE) { - for (j = 0; familyv[j]; ++j) { - if (allow_partial_matches ? name_fragment_match_with_synonyms (familyv[j], namev[i], allow_partial_matches) - : !e_utf8_casefold_collate (familyv[j], namev[i])) { - - this_part_match = EAB_CONTACT_MATCH_PART_FAMILY_NAME; - - g_free (familyv[j]); - familyv[j] = g_strdup (""); - break; - } - } - } - - if (this_part_match != EAB_CONTACT_MATCH_PART_NONE) { - ++match_count; - matched_character_count += g_utf8_strlen (namev[i], -1); - matched_parts |= this_part_match; - if (first_matched_part == EAB_CONTACT_MATCH_PART_NONE) - first_matched_part = this_part_match; - } - } - } - - match_type = EAB_CONTACT_MATCH_NONE; - - if (this_part_match != EAB_CONTACT_MATCH_PART_NONE) { - - if (match_count > 0) - match_type = EAB_CONTACT_MATCH_VAGUE; - - if (fragment_count == match_count) { - - match_type = EAB_CONTACT_MATCH_EXACT; - - } else if (fragment_count == match_count + 1) { - - match_type = EAB_CONTACT_MATCH_PARTIAL; - - } - } - - if (matched_parts_out) - *matched_parts_out = matched_parts; - if (first_matched_part_out) - *first_matched_part_out = first_matched_part; - if (matched_character_count_out) - *matched_character_count_out = matched_character_count; - - g_strfreev (namev); - g_strfreev (givenv); - g_strfreev (addv); - g_strfreev (familyv); - - return match_type; -} - -EABContactMatchType -eab_contact_compare_file_as (EContact *contact1, EContact *contact2) -{ - EABContactMatchType match_type; - gchar *a, *b; - - g_return_val_if_fail (E_IS_CONTACT (contact1), EAB_CONTACT_MATCH_NOT_APPLICABLE); - g_return_val_if_fail (E_IS_CONTACT (contact2), EAB_CONTACT_MATCH_NOT_APPLICABLE); - - a = e_contact_get (contact1, E_CONTACT_FILE_AS); - b = e_contact_get (contact2, E_CONTACT_FILE_AS); - - if (a == NULL || b == NULL) { - g_free (a); - g_free (b); - return EAB_CONTACT_MATCH_NOT_APPLICABLE; - } - - if (!strcmp (a, b)) - match_type = EAB_CONTACT_MATCH_EXACT; - else if (g_utf8_validate (a, -1, NULL) && g_utf8_validate (b, -1, NULL) && - !g_utf8_collate (a, b)) - match_type = EAB_CONTACT_MATCH_PARTIAL; - else - match_type = EAB_CONTACT_MATCH_NONE; - - g_free (a); - g_free (b); - return match_type; -} - -EABContactMatchType -eab_contact_compare_name (EContact *contact1, EContact *contact2) -{ - EContactName *a, *b; - gint matches=0, possible=0; - gboolean given_match = FALSE, additional_match = FALSE, family_match = FALSE; - - g_return_val_if_fail (E_IS_CONTACT (contact1), EAB_CONTACT_MATCH_NOT_APPLICABLE); - g_return_val_if_fail (E_IS_CONTACT (contact2), EAB_CONTACT_MATCH_NOT_APPLICABLE); - - a = e_contact_get (contact1, E_CONTACT_NAME); - b = e_contact_get (contact2, E_CONTACT_NAME); - - if (a == NULL || b == NULL) { - g_free (a); - g_free (b); - return EAB_CONTACT_MATCH_NOT_APPLICABLE; - } - - if (a->given && b->given && *a->given && *b->given) { - ++possible; - if (name_fragment_match_with_synonyms (a->given, b->given, FALSE /* both inputs are complete */)) { - ++matches; - given_match = TRUE; - } - } - - if (a->additional && b->additional && *a->additional && *b->additional) { - ++possible; - if (name_fragment_match_with_synonyms (a->additional, b->additional, FALSE /* both inputs are complete */)) { - ++matches; - additional_match = TRUE; - } - } - - if (a->family && b->family && *a->family && *b->family) { - ++possible; - /* We don't allow "loose matching" (i.e. John vs. Jon) on family names */ - if (! e_utf8_casefold_collate (a->family, b->family)) { - ++matches; - family_match = TRUE; - } - } - - e_contact_name_free (a); - e_contact_name_free (b); - - /* Now look at the # of matches and try to intelligently map - an EAB_CONTACT_MATCH_* type to it. Special consideration is given - to family-name matches. */ - - if (possible == 0) - return EAB_CONTACT_MATCH_NOT_APPLICABLE; - - if (possible == 1) - return family_match ? EAB_CONTACT_MATCH_VAGUE : EAB_CONTACT_MATCH_NONE; - - if (possible == matches) - return family_match ? EAB_CONTACT_MATCH_EXACT : EAB_CONTACT_MATCH_PARTIAL; - - if (possible == matches+1) - return family_match ? EAB_CONTACT_MATCH_VAGUE : EAB_CONTACT_MATCH_NONE; - - return EAB_CONTACT_MATCH_NONE; -} - - -/*** Nickname Comparisons ***/ - -EABContactMatchType -eab_contact_compare_nickname (EContact *contact1, EContact *contact2) -{ - g_return_val_if_fail (contact1 && E_IS_CONTACT (contact1), EAB_CONTACT_MATCH_NOT_APPLICABLE); - g_return_val_if_fail (contact2 && E_IS_CONTACT (contact2), EAB_CONTACT_MATCH_NOT_APPLICABLE); - - return EAB_CONTACT_MATCH_NOT_APPLICABLE; -} - - - -/*** E-mail Comparisons ***/ - -static gboolean -match_email_username (const gchar *addr1, const gchar *addr2) -{ - gint c1, c2; - if (addr1 == NULL || addr2 == NULL) - return FALSE; - - while (*addr1 && *addr2 && *addr1 != '@' && *addr2 != '@') { - c1 = isupper (*addr1) ? tolower (*addr1) : *addr1; - c2 = isupper (*addr2) ? tolower (*addr2) : *addr2; - if (c1 != c2) - return FALSE; - ++addr1; - ++addr2; - } - - return *addr1 == *addr2; -} - -static gboolean -match_email_hostname (const gchar *addr1, const gchar *addr2) -{ - gint c1, c2; - gboolean seen_at1, seen_at2; - if (addr1 == NULL || addr2 == NULL) - return FALSE; - - /* Walk to the end of each string. */ - seen_at1 = FALSE; - if (*addr1) { - while (*addr1) { - if (*addr1 == '@') - seen_at1 = TRUE; - ++addr1; - } - --addr1; - } - - seen_at2 = FALSE; - if (*addr2) { - while (*addr2) { - if (*addr2 == '@') - seen_at2 = TRUE; - ++addr2; - } - --addr2; - } - - if (!seen_at1 && !seen_at2) - return TRUE; - if (!seen_at1 || !seen_at2) - return FALSE; - - while (*addr1 != '@' && *addr2 != '@') { - c1 = isupper (*addr1) ? tolower (*addr1) : *addr1; - c2 = isupper (*addr2) ? tolower (*addr2) : *addr2; - if (c1 != c2) - return FALSE; - --addr1; - --addr2; - } - - /* This will match bob@foo.ximian.com and bob@ximian.com */ - return *addr1 == '.' || *addr2 == '.'; -} - -static EABContactMatchType -compare_email_addresses (const gchar *addr1, const gchar *addr2) -{ - if (addr1 == NULL || *addr1 == 0 || - addr2 == NULL || *addr2 == 0) - return EAB_CONTACT_MATCH_NOT_APPLICABLE; - - if (match_email_username (addr1, addr2)) - return match_email_hostname (addr1, addr2) ? EAB_CONTACT_MATCH_EXACT : EAB_CONTACT_MATCH_VAGUE; - - return EAB_CONTACT_MATCH_NONE; -} - -EABContactMatchType -eab_contact_compare_email (EContact *contact1, EContact *contact2) -{ - EABContactMatchType match = EAB_CONTACT_MATCH_NOT_APPLICABLE; - GList *contact1_email, *contact2_email; - GList *i1, *i2; - - g_return_val_if_fail (contact1 && E_IS_CONTACT (contact1), EAB_CONTACT_MATCH_NOT_APPLICABLE); - g_return_val_if_fail (contact2 && E_IS_CONTACT (contact2), EAB_CONTACT_MATCH_NOT_APPLICABLE); - - contact1_email = e_contact_get (contact1, E_CONTACT_EMAIL); - contact2_email = e_contact_get (contact2, E_CONTACT_EMAIL); - - if (contact1_email == NULL || contact2_email == NULL) { - g_list_foreach (contact1_email, (GFunc)g_free, NULL); - g_list_free (contact1_email); - - g_list_foreach (contact2_email, (GFunc)g_free, NULL); - g_list_free (contact2_email); - return EAB_CONTACT_MATCH_NOT_APPLICABLE; - } - - i1 = contact1_email; - - /* Do pairwise-comparisons on all of the e-mail addresses. If - we find an exact match, there is no reason to keep - checking. */ - while (i1 && match != EAB_CONTACT_MATCH_EXACT) { - char *addr1 = (char *) i1->data; - - i2 = contact2_email; - while (i2 && match != EAB_CONTACT_MATCH_EXACT) { - char *addr2 = (char *) i2->data; - - match = combine_comparisons (match, compare_email_addresses (addr1, addr2)); - - i2 = i2->next; - } - - i1 = i1->next; - } - - g_list_foreach (contact1_email, (GFunc)g_free, NULL); - g_list_free (contact1_email); - - g_list_foreach (contact2_email, (GFunc)g_free, NULL); - g_list_free (contact2_email); - - return match; -} - -EABContactMatchType -eab_contact_compare_address (EContact *contact1, EContact *contact2) -{ - g_return_val_if_fail (contact1 && E_IS_CONTACT (contact1), EAB_CONTACT_MATCH_NOT_APPLICABLE); - g_return_val_if_fail (contact2 && E_IS_CONTACT (contact2), EAB_CONTACT_MATCH_NOT_APPLICABLE); - - /* Unimplemented */ - - return EAB_CONTACT_MATCH_NOT_APPLICABLE; -} - -EABContactMatchType -eab_contact_compare_telephone (EContact *contact1, EContact *contact2) -{ - g_return_val_if_fail (contact1 && E_IS_CONTACT (contact1), EAB_CONTACT_MATCH_NOT_APPLICABLE); - g_return_val_if_fail (contact2 && E_IS_CONTACT (contact2), EAB_CONTACT_MATCH_NOT_APPLICABLE); - - /* Unimplemented */ - - return EAB_CONTACT_MATCH_NOT_APPLICABLE; -} - -EABContactMatchType -eab_contact_compare (EContact *contact1, EContact *contact2) -{ - EABContactMatchType result; - - g_return_val_if_fail (contact1 && E_IS_CONTACT (contact1), EAB_CONTACT_MATCH_NOT_APPLICABLE); - g_return_val_if_fail (contact2 && E_IS_CONTACT (contact2), EAB_CONTACT_MATCH_NOT_APPLICABLE); - - result = EAB_CONTACT_MATCH_NONE; - result = combine_comparisons (result, eab_contact_compare_name (contact1, contact2)); - result = combine_comparisons (result, eab_contact_compare_nickname (contact1, contact2)); - result = combine_comparisons (result, eab_contact_compare_email (contact1, contact2)); - result = combine_comparisons (result, eab_contact_compare_address (contact1, contact2)); - result = combine_comparisons (result, eab_contact_compare_telephone (contact1, contact2)); - result = combine_comparisons (result, eab_contact_compare_file_as (contact1, contact2)); - - return result; -} - -typedef struct _MatchSearchInfo MatchSearchInfo; -struct _MatchSearchInfo { - EContact *contact; - GList *avoid; - EABContactMatchQueryCallback cb; - gpointer closure; -}; - -static void -match_search_info_free (MatchSearchInfo *info) -{ - if (info) { - g_object_unref (info->contact); - - /* This should already have been deallocated, but just in case... */ - if (info->avoid) { - g_list_foreach (info->avoid, (GFunc) g_object_unref, NULL); - g_list_free (info->avoid); - info->avoid = NULL; - } - - g_free (info); - } -} - -static void -query_cb (EBook *book, EBookStatus status, GList *contacts, gpointer closure) -{ - /* XXX we need to free contacts */ - MatchSearchInfo *info = (MatchSearchInfo *) closure; - EABContactMatchType best_match = EAB_CONTACT_MATCH_NONE; - EContact *best_contact = NULL; - GList *remaining_contacts = NULL; - const GList *i; - - if (status != E_BOOK_ERROR_OK) { - info->cb (info->contact, NULL, EAB_CONTACT_MATCH_NONE, info->closure); - match_search_info_free (info); - return; - } - - /* remove the contacts we're to avoid from the list, if they're present */ - for (i = contacts; i != NULL; i = g_list_next (i)) { - EContact *this_contact = E_CONTACT (i->data); - const gchar *this_uid; - GList *iterator; - gboolean avoid = FALSE; - - this_uid = e_contact_get_const (this_contact, E_CONTACT_UID); - if (!this_uid) - continue; - - for (iterator = info->avoid; iterator; iterator = iterator->next) { - const gchar *avoid_uid; - - avoid_uid = e_contact_get_const (iterator->data, E_CONTACT_UID); - if (!avoid_uid) - continue; - - if (!strcmp (avoid_uid, this_uid)) { - avoid = TRUE; - break; - } - } - if (!avoid) - remaining_contacts = g_list_prepend (remaining_contacts, this_contact); - } - - remaining_contacts = g_list_reverse (remaining_contacts); - - for (i = remaining_contacts; i != NULL; i = g_list_next (i)) { - EContact *this_contact = E_CONTACT (i->data); - EABContactMatchType this_match = eab_contact_compare (info->contact, this_contact); - if ((gint)this_match > (gint)best_match) { - best_match = this_match; - best_contact = this_contact; - } - } - - g_list_free (remaining_contacts); - - info->cb (info->contact, best_contact, best_match, info->closure); - match_search_info_free (info); -} - -#define MAX_QUERY_PARTS 10 -static void -use_common_book_cb (EBook *book, gpointer closure) -{ - MatchSearchInfo *info = (MatchSearchInfo *) closure; - EContact *contact = info->contact; - EContactName *contact_name; - GList *contact_email; - gchar *query_parts[MAX_QUERY_PARTS]; - gint p=0; - gchar *contact_file_as, *qj; - EBookQuery *query = NULL; - int i; - - if (book == NULL) { - info->cb (info->contact, NULL, EAB_CONTACT_MATCH_NONE, info->closure); - match_search_info_free (info); - return; - } - - contact_file_as = e_contact_get (contact, E_CONTACT_FILE_AS); - if (contact_file_as) { - query_parts [p++] = g_strdup_printf ("(contains \"file_as\" \"%s\")", contact_file_as); - g_free (contact_file_as); - } - - contact_name = e_contact_get (contact, E_CONTACT_NAME); - if (contact_name) { - if (contact_name->given && *contact_name->given) - query_parts[p++] = g_strdup_printf ("(contains \"full_name\" \"%s\")", contact_name->given); - - if (contact_name->additional && *contact_name->additional) - query_parts[p++] = g_strdup_printf ("(contains \"full_name\" \"%s\")", contact_name->additional); - - if (contact_name->family && *contact_name->family) - query_parts[p++] = g_strdup_printf ("(contains \"full_name\" \"%s\")", contact_name->family); - - e_contact_name_free (contact_name); - } - - contact_email = e_contact_get (contact, E_CONTACT_EMAIL); - if (contact_email) { - GList *iter; - for (iter = contact_email; iter && p < MAX_QUERY_PARTS; iter = iter->next) { - gchar *addr = g_strdup (iter->data); - if (addr && *addr) { - gchar *s = addr; - while (*s) { - if (*s == '@') { - *s = '\0'; - break; - } - ++s; - } - query_parts[p++] = g_strdup_printf ("(beginswith \"email\" \"%s\")", addr); - g_free (addr); - } - } - } - g_list_foreach (contact_email, (GFunc)g_free, NULL); - g_list_free (contact_email); - - - /* Build up our full query from the parts. */ - query_parts[p] = NULL; - qj = g_strjoinv (" ", query_parts); - for(i = 0; query_parts[i] != NULL; i++) - g_free(query_parts[i]); - if (p > 1) { - char *s; - s = g_strdup_printf ("(or %s)", qj); - query = e_book_query_from_string (s); - g_free (s); - } - else if (p == 1) { - query = e_book_query_from_string (qj); - } - else { - query = NULL; - } - - if (query) - e_book_async_get_contacts (book, query, query_cb, info); - else - query_cb (book, E_BOOK_ERROR_OK, NULL, info); - - g_free (qj); - if (query) - e_book_query_unref (query); -} - -void -eab_contact_locate_match (EContact *contact, EABContactMatchQueryCallback cb, gpointer closure) -{ - MatchSearchInfo *info; - - g_return_if_fail (contact && E_IS_CONTACT (contact)); - g_return_if_fail (cb != NULL); - - info = g_new (MatchSearchInfo, 1); - info->contact = contact; - g_object_ref (contact); - info->cb = cb; - info->closure = closure; - info->avoid = NULL; - - addressbook_load_default_book ((EBookCallback) use_common_book_cb, info); -} - -/** - * e_contact_locate_match_full: - * @book: The book to look in. If this is NULL, use the default - * addressbook. - * @contact: The contact to compare to. - * @avoid: A list of contacts to not match. These will not show up in the search. - * @cb: The function to call. - * @closure: The closure to add to the call. - * - * Look for the best match and return it using the EABContactMatchQueryCallback. - **/ -void -eab_contact_locate_match_full (EBook *book, EContact *contact, GList *avoid, EABContactMatchQueryCallback cb, gpointer closure) -{ - MatchSearchInfo *info; - - g_return_if_fail (contact && E_IS_CONTACT (contact)); - g_return_if_fail (cb != NULL); - - info = g_new (MatchSearchInfo, 1); - info->contact = contact; - g_object_ref (contact); - info->cb = cb; - info->closure = closure; - info->avoid = g_list_copy (avoid); - g_list_foreach (info->avoid, (GFunc) g_object_ref, NULL); - - if (book) - use_common_book_cb (book, info); - else - addressbook_load_default_book ((EBookCallback) use_common_book_cb, info); -} - diff --git a/addressbook/gui/merging/eab-contact-compare.h b/addressbook/gui/merging/eab-contact-compare.h deleted file mode 100644 index 153e44aef1..0000000000 --- a/addressbook/gui/merging/eab-contact-compare.h +++ /dev/null @@ -1,74 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * eab-contact-compare.h - * - * Copyright (C) 2001,2002,2003 Ximian, Inc. - * - * Authors: Jon Trowbridge <trow@ximian.com> - * Chris Toshok <toshok@ximian.com> - */ - -/* - * 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. - */ - -#ifndef __EAB_CONTACT_COMPARE_H__ -#define __EAB_CONTACT_COMPARE_H__ - -#include <libebook/e-book.h> -#include <libebook/e-contact.h> - -typedef enum { - EAB_CONTACT_MATCH_NOT_APPLICABLE = 0, - EAB_CONTACT_MATCH_NONE = 1, - EAB_CONTACT_MATCH_VAGUE = 2, - EAB_CONTACT_MATCH_PARTIAL = 3, - EAB_CONTACT_MATCH_EXACT = 4 -} EABContactMatchType; - -typedef enum { - EAB_CONTACT_MATCH_PART_NOT_APPLICABLE = -1, - EAB_CONTACT_MATCH_PART_NONE = 0, - EAB_CONTACT_MATCH_PART_GIVEN_NAME = 1<<0, - EAB_CONTACT_MATCH_PART_ADDITIONAL_NAME = 1<<2, - EAB_CONTACT_MATCH_PART_FAMILY_NAME = 1<<3 -} EABContactMatchPart; - -typedef void (*EABContactMatchQueryCallback) (EContact *contact, EContact *match, EABContactMatchType type, gpointer closure); - -EABContactMatchType eab_contact_compare_name_to_string (EContact *contact, const gchar *str); - -EABContactMatchType eab_contact_compare_name_to_string_full (EContact *contact, const gchar *str, - gboolean allow_partial_matches, - gint *matched_parts, EABContactMatchPart *first_matched_part, - gint *matched_character_count); - -EABContactMatchType eab_contact_compare_file_as (EContact *contact1, EContact *contact2); -EABContactMatchType eab_contact_compare_name (EContact *contact1, EContact *contact2); -EABContactMatchType eab_contact_compare_nickname (EContact *contact1, EContact *contact2); -EABContactMatchType eab_contact_compare_email (EContact *contact1, EContact *contact2); -EABContactMatchType eab_contact_compare_address (EContact *contact1, EContact *contact2); -EABContactMatchType eab_contact_compare_telephone (EContact *contact1, EContact *contact2); - -EABContactMatchType eab_contact_compare (EContact *contact1, EContact *contact2); - -void eab_contact_locate_match (EContact *contact, EABContactMatchQueryCallback cb, gpointer closure); -void eab_contact_locate_match_full (EBook *book, EContact *contact, GList *avoid, EABContactMatchQueryCallback cb, gpointer closure); - - - -#endif /* __E_CONTACT_COMPARE_H__ */ - diff --git a/addressbook/gui/merging/eab-contact-duplicate-detected.glade b/addressbook/gui/merging/eab-contact-duplicate-detected.glade deleted file mode 100644 index f1095f9db0..0000000000 --- a/addressbook/gui/merging/eab-contact-duplicate-detected.glade +++ /dev/null @@ -1,212 +0,0 @@ -<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*--> -<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd"> - -<glade-interface> - -<widget class="GtkDialog" id="dialog-duplicate-contact"> - <property name="border_width">6</property> - <property name="visible">True</property> - <property name="title" translatable="yes">Duplicate Contact Detected</property> - <property name="type">GTK_WINDOW_TOPLEVEL</property> - <property name="window_position">GTK_WIN_POS_NONE</property> - <property name="modal">False</property> - <property name="resizable">True</property> - <property name="destroy_with_parent">False</property> - <property name="has_separator">True</property> - - <child internal-child="vbox"> - <widget class="GtkVBox" id="dialog-vbox1"> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">6</property> - - <child internal-child="action_area"> - <widget class="GtkHButtonBox" id="dialog-action_area1"> - <property name="visible">True</property> - <property name="layout_style">GTK_BUTTONBOX_END</property> - - <child> - <widget class="GtkButton" id="button4"> - <property name="visible">True</property> - <property name="can_default">True</property> - <property name="can_focus">True</property> - <property name="label">gtk-cancel</property> - <property name="use_stock">True</property> - <property name="relief">GTK_RELIEF_NORMAL</property> - <property name="response_id">1</property> - </widget> - </child> - - <child> - <widget class="GtkButton" id="button3"> - <property name="visible">True</property> - <property name="can_default">True</property> - <property name="can_focus">True</property> - <property name="label">gtk-add</property> - <property name="use_stock">True</property> - <property name="relief">GTK_RELIEF_NORMAL</property> - <property name="response_id">0</property> - </widget> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="pack_type">GTK_PACK_END</property> - </packing> - </child> - - <child> - <widget class="GtkTable" id="table1"> - <property name="border_width">6</property> - <property name="visible">True</property> - <property name="n_rows">5</property> - <property name="n_columns">2</property> - <property name="homogeneous">False</property> - <property name="row_spacing">6</property> - <property name="column_spacing">6</property> - - <child> - <widget class="Custom" id="custom-old-contact"> - <property name="visible">True</property> - <property name="creation_function">_eab_contact_merging_create_contact_display</property> - <property name="int1">0</property> - <property name="int2">0</property> - <property name="last_modification_time">Sun, 05 Oct 2003 03:55:10 GMT</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">4</property> - <property name="bottom_attach">5</property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label1"> - <property name="visible">True</property> - <property name="label" translatable="yes">The name or email address of this contact already exists -in this folder. Would you like to add it anyway?</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">0</property> - <property name="bottom_attach">1</property> - <property name="y_options">fill</property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label3"> - <property name="visible">True</property> - <property name="label" translatable="yes">Original Contact:</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_CENTER</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">3</property> - <property name="bottom_attach">4</property> - <property name="y_options">fill</property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label4"> - <property name="visible">True</property> - <property name="label" translatable="yes">New Contact:</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_CENTER</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="Custom" id="custom-new-contact"> - <property name="visible">True</property> - <property name="creation_function">_eab_contact_merging_create_contact_display</property> - <property name="int1">0</property> - <property name="int2">0</property> - <property name="last_modification_time">Sun, 05 Oct 2003 03:54:50 GMT</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">2</property> - <property name="bottom_attach">3</property> - </packing> - </child> - - <child> - <widget class="GtkAlignment" id="alignment1"> - <property name="visible">True</property> - <property name="xalign">0.5</property> - <property name="yalign">0</property> - <property name="xscale">1</property> - <property name="yscale">0</property> - - <child> - <widget class="Custom" id="custom2"> - <property name="visible">True</property> - <property name="creation_function">e_create_image_widget</property> - <property name="string1">stock_person</property> - <property name="int1">0</property> - <property name="int2">0</property> - <property name="last_modification_time">Fri, 08 Jun 2001 00:18:39 GMT</property> - </widget> - </child> - </widget> - <packing> - <property name="left_attach">0</property> - <property name="right_attach">1</property> - <property name="top_attach">0</property> - <property name="bottom_attach">5</property> - <property name="x_options">fill</property> - <property name="y_options">fill</property> - </packing> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">True</property> - <property name="fill">True</property> - </packing> - </child> - </widget> - </child> -</widget> - -</glade-interface> diff --git a/addressbook/gui/merging/eab-contact-merging.c b/addressbook/gui/merging/eab-contact-merging.c deleted file mode 100644 index 685739ed89..0000000000 --- a/addressbook/gui/merging/eab-contact-merging.c +++ /dev/null @@ -1,240 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Code for checking for duplicates when doing EContact work. - * - * Authors: - * Christopher James Lahey <clahey@ximian.com> - * Chris Toshok <toshok@ximian.com> - * - * Copyright (C) 2001, 2002, 2003, Ximian, Inc. - */ - -#include <config.h> - -#include "eab-contact-merging.h" -#include "eab-contact-compare.h" -#include <glade/glade.h> -#include <gtk/gtksignal.h> -#include "addressbook/gui/widgets/eab-contact-display.h" - -typedef enum { - E_CONTACT_MERGING_ADD, - E_CONTACT_MERGING_COMMIT -} EContactMergingOpType; - -typedef struct { - EContactMergingOpType op; - EBook *book; - EContact *contact; - GList *avoid; - EBookIdCallback id_cb; - EBookCallback cb; - gpointer closure; -} EContactMergingLookup; - -static void match_query_callback (EContact *contact, EContact *match, EABContactMatchType type, gpointer closure); - -#define SIMULTANEOUS_MERGING_REQUESTS 20 - -static GList *merging_queue = NULL; -static int running_merge_requests = 0; - - -static void -add_lookup (EContactMergingLookup *lookup) -{ - if (running_merge_requests < SIMULTANEOUS_MERGING_REQUESTS) { - running_merge_requests++; - eab_contact_locate_match_full (lookup->book, lookup->contact, lookup->avoid, match_query_callback, lookup); - } - else { - merging_queue = g_list_append (merging_queue, lookup); - } -} - -static void -finished_lookup (void) -{ - running_merge_requests--; - - while (running_merge_requests < SIMULTANEOUS_MERGING_REQUESTS) { - EContactMergingLookup *lookup; - - if (!merging_queue) - break; - - lookup = merging_queue->data; - - merging_queue = g_list_remove_link (merging_queue, merging_queue); - - running_merge_requests++; - eab_contact_locate_match_full (lookup->book, lookup->contact, lookup->avoid, match_query_callback, lookup); - } -} - -static void -free_lookup (EContactMergingLookup *lookup) -{ - g_object_unref (lookup->book); - g_object_unref (lookup->contact); - g_list_free (lookup->avoid); - - g_free (lookup); -} - -static void -final_id_cb (EBook *book, EBookStatus status, const char *id, gpointer closure) -{ - EContactMergingLookup *lookup = closure; - - if (lookup->id_cb) - lookup->id_cb (lookup->book, status, id, lookup->closure); - - free_lookup (lookup); - - finished_lookup (); -} - -static void -final_cb (EBook *book, EBookStatus status, gpointer closure) -{ - EContactMergingLookup *lookup = closure; - - if (lookup->cb) - lookup->cb (lookup->book, status, lookup->closure); - - free_lookup (lookup); - - finished_lookup (); -} - -static void -doit (EContactMergingLookup *lookup) -{ - if (lookup->op == E_CONTACT_MERGING_ADD) - e_book_async_add_contact (lookup->book, lookup->contact, final_id_cb, lookup); - else if (lookup->op == E_CONTACT_MERGING_COMMIT) - e_book_async_commit_contact (lookup->book, lookup->contact, final_cb, lookup); -} - -static void -cancelit (EContactMergingLookup *lookup) -{ - if (lookup->op == E_CONTACT_MERGING_ADD) { - if (lookup->id_cb) - final_id_cb (lookup->book, E_BOOK_ERROR_CANCELLED, NULL, lookup); - } else if (lookup->op == E_CONTACT_MERGING_COMMIT) { - if (lookup->cb) - final_cb (lookup->book, E_BOOK_ERROR_CANCELLED, lookup); - } -} - -static void -response (GtkWidget *dialog, int response, EContactMergingLookup *lookup) -{ - gtk_widget_destroy (dialog); - - switch (response) { - case 0: - doit (lookup); - break; - case 1: - cancelit (lookup); - break; - } -} - -static void -match_query_callback (EContact *contact, EContact *match, EABContactMatchType type, gpointer closure) -{ - EContactMergingLookup *lookup = closure; - - if ((gint) type <= (gint) EAB_CONTACT_MATCH_VAGUE) { - doit (lookup); - } else { - GladeXML *ui; - - GtkWidget *widget; - - if (lookup->op == E_CONTACT_MERGING_ADD) - ui = glade_xml_new (EVOLUTION_GLADEDIR "/eab-contact-duplicate-detected.glade", NULL, NULL); - else if (lookup->op == E_CONTACT_MERGING_COMMIT) - ui = glade_xml_new (EVOLUTION_GLADEDIR "/eab-contact-commit-duplicate-detected.glade", NULL, NULL); - else { - doit (lookup); - return; - } - - widget = glade_xml_get_widget (ui, "custom-old-contact"); - eab_contact_display_render (EAB_CONTACT_DISPLAY (widget), - match, EAB_CONTACT_DISPLAY_RENDER_COMPACT); - - widget = glade_xml_get_widget (ui, "custom-new-contact"); - eab_contact_display_render (EAB_CONTACT_DISPLAY (widget), - contact, EAB_CONTACT_DISPLAY_RENDER_COMPACT); - - widget = glade_xml_get_widget (ui, "dialog-duplicate-contact"); - - g_signal_connect (widget, "response", - G_CALLBACK (response), lookup); - - gtk_widget_show_all (widget); - } -} - -gboolean -eab_merging_book_add_contact (EBook *book, - EContact *contact, - EBookIdCallback cb, - gpointer closure) -{ - EContactMergingLookup *lookup; - - lookup = g_new (EContactMergingLookup, 1); - - lookup->op = E_CONTACT_MERGING_ADD; - lookup->book = g_object_ref (book); - lookup->contact = g_object_ref (contact); - lookup->id_cb = cb; - lookup->closure = closure; - lookup->avoid = NULL; - - add_lookup (lookup); - - return TRUE; -} - -gboolean -eab_merging_book_commit_contact (EBook *book, - EContact *contact, - EBookCallback cb, - gpointer closure) -{ - EContactMergingLookup *lookup; - - lookup = g_new (EContactMergingLookup, 1); - - lookup->op = E_CONTACT_MERGING_COMMIT; - lookup->book = g_object_ref (book); - lookup->contact = g_object_ref (contact); - lookup->cb = cb; - lookup->closure = closure; - lookup->avoid = g_list_append (NULL, contact); - - add_lookup (lookup); - - return TRUE; -} - -GtkWidget * -_eab_contact_merging_create_contact_display(gchar *name, - gchar *string1, gchar *string2, - gint int1, gint int2); - -GtkWidget * -_eab_contact_merging_create_contact_display(gchar *name, - gchar *string1, gchar *string2, - gint int1, gint int2) -{ - return eab_contact_display_new(); -} diff --git a/addressbook/gui/merging/eab-contact-merging.h b/addressbook/gui/merging/eab-contact-merging.h deleted file mode 100644 index 80a7717ce8..0000000000 --- a/addressbook/gui/merging/eab-contact-merging.h +++ /dev/null @@ -1,30 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * The Evolution addressbook client object. - * - * Authors: - * Christopher James Lahey <clahey@ximian.com> - * Chris Toshok <toshok@ximian.com> - * - * Copyright (C) 2001, 2002, 2003 Ximian, Inc. - */ - -#ifndef __E_CONTACT_MERGING_H__ -#define __E_CONTACT_MERGING_H__ - -#include <libebook/e-book.h> - -G_BEGIN_DECLS - -gboolean eab_merging_book_add_contact (EBook *book, - EContact *contact, - EBookIdCallback cb, - gpointer closure); -gboolean eab_merging_book_commit_contact (EBook *book, - EContact *contact, - EBookCallback cb, - gpointer closure); - -G_END_DECLS - -#endif /* ! __EAB_CONTACT_MERGING_H__ */ diff --git a/addressbook/gui/search/.cvsignore b/addressbook/gui/search/.cvsignore deleted file mode 100644 index d6c55c7345..0000000000 --- a/addressbook/gui/search/.cvsignore +++ /dev/null @@ -1,7 +0,0 @@ -.deps -.libs -.pure -Makefile -Makefile.in -*.lo -*.la diff --git a/addressbook/gui/search/Makefile.am b/addressbook/gui/search/Makefile.am deleted file mode 100644 index 391039d81f..0000000000 --- a/addressbook/gui/search/Makefile.am +++ /dev/null @@ -1,23 +0,0 @@ -ruledir = $(privdatadir) -rule_DATA = addresstypes.xml - -EXTRA_DIST = addresstypes.xml - -INCLUDES = \ - -DG_LOG_DOMAIN=\"e-addressbook-search\" \ - -I$(top_srcdir) \ - -I$(top_srcdir)/addressbook/backend \ - -I$(top_builddir)/addressbook/backend \ - -I$(top_srcdir)/addressbook/contact-editor \ - -I$(top_srcdir)/widgets/e-text \ - -I$(top_srcdir)/widgets/misc \ - -I$(top_builddir)/shell \ - -DSEARCH_RULE_DIR=\"$(ruledir)\" \ - $(EVOLUTION_ADDRESSBOOK_CFLAGS) - -noinst_LTLIBRARIES = \ - libeaddressbooksearch.la - -libeaddressbooksearch_la_SOURCES = \ - e-addressbook-search-dialog.c \ - e-addressbook-search-dialog.h diff --git a/addressbook/gui/search/addresstypes.xml b/addressbook/gui/search/addresstypes.xml deleted file mode 100644 index 4adbfd694b..0000000000 --- a/addressbook/gui/search/addresstypes.xml +++ /dev/null @@ -1,83 +0,0 @@ -<?xml version="1.0"?> -<filterdescription> -<partset> - <part name="name"> - <title>Name</title> - <input type="optionlist" name="name-type"> - <option value="contains"> - <title>contains</title> - <code>(contains "full_name" ${name})</code> - </option> - <option value="not contains"> - <title>does not contain</title> - <code>(not (contains "full_name" ${name}))</code> - </option> - <option value="is"> - <title>is</title> - <code>(is "full_name" ${name})))</code> - </option> - <option value="is not"> - <title>is not</title> - <code>(not (is "full_name" ${name}))</code> - </option> - <option value="begin"> - <title>begins with</title> - <code>(beginswith "full_name" ${name})</code> - </option> - <option value="end"> - <title>ends in</title> - <code>(endswith "full_name" ${name})</code> - </option> - </input> - <input type="string" name="name"/> - </part> - <part name="email"> - <title>Email</title> - <input type="optionlist" name="email-type"> - <option value="contains"> - <title>contains</title> - <code>(contains "email" ${email})</code> - </option> - <option value="not contains"> - <title>does not contain</title> - <code>(not (contains "email" ${email}))</code> - </option> - <option value="is"> - <title>is</title> - <code>(is "email" ${email})</code> - </option> - <option value="is not"> - <title>is not</title> - <code>(not (is "email" ${email}))</code> - </option> - </input> - <input type="address" name="email"/> - </part> - <part name="category"> - <title>Category</title> - <input type="optionlist" name="category-type"> - <option value="contains"> - <title>contains</title> - <code>(contains "category_list" ${category})</code> - </option> - <option value="not contains"> - <title>does not contain</title> - <code>(not (contains "category_list" ${category}))</code> - </option> - <option value="is"> - <title>is</title> - <code>(is "category_list" ${category})</code> - </option> - <option value="is not"> - <title>is not</title> - <code>(not (is "category_list" ${category}))</code> - </option> - </input> - <input type="string" name="category"/> - </part> - <part name="sexp"> - <title>Expression</title> - <input type="code" name="code"/> - </part> -</partset> -</filterdescription> diff --git a/addressbook/gui/search/e-addressbook-search-dialog.c b/addressbook/gui/search/e-addressbook-search-dialog.c deleted file mode 100644 index 857c7a666c..0000000000 --- a/addressbook/gui/search/e-addressbook-search-dialog.c +++ /dev/null @@ -1,200 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * e-addressbook-search-dialog.c - * Copyright (C) 2000 Ximian, Inc. - * Author: Chris Lahey <clahey@ximian.com> - * - * This library 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 library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include <config.h> - -#include <gtk/gtkbox.h> -#include <gtk/gtkentry.h> -#include <gtk/gtkstock.h> -#include <libgnome/gnome-i18n.h> -#include "gal/util/e-util.h" - -#include "e-addressbook-search-dialog.h" - - -static void eab_search_dialog_init (EABSearchDialog *widget); -static void eab_search_dialog_class_init (EABSearchDialogClass *klass); -static void eab_search_dialog_dispose (GObject *object); - -static GtkDialog *parent_class = NULL; - -#define PARENT_TYPE GTK_TYPE_DIALOG - -E_MAKE_TYPE (eab_search_dialog, - "EABSearchDialog", - EABSearchDialog, - eab_search_dialog_class_init, - eab_search_dialog_init, - PARENT_TYPE) - -enum -{ - PROP_VIEW = 1 -}; - -static GtkWidget * -get_widget (EABSearchDialog *view) -{ - RuleContext *context; - FilterRule *rule; - - context = eab_view_peek_search_context (view->view); - rule = eab_view_peek_search_rule (view->view); - - if (!context || !rule) { - g_warning ("Could not get search context."); - return gtk_entry_new (); - } - - return filter_rule_get_widget (rule, context); -} - -static void -eab_search_dialog_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) -{ - EABSearchDialog *search_dialog; - - search_dialog = EAB_SEARCH_DIALOG (object); - - switch (property_id) { - case PROP_VIEW: - search_dialog->view = g_value_get_object (value); - search_dialog->search = get_widget (search_dialog); - gtk_container_set_border_width (GTK_CONTAINER (search_dialog->search), 12); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (search_dialog)->vbox), - search_dialog->search, TRUE, TRUE, 0); - gtk_widget_show (search_dialog->search); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); - break; - } -} - -static void -eab_search_dialog_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec) -{ - EABSearchDialog *search_dialog; - - search_dialog = EAB_SEARCH_DIALOG (object); - - switch (property_id) { - case PROP_VIEW: - g_value_set_object (value, search_dialog->view); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); - break; - } -} - -static void -eab_search_dialog_class_init (EABSearchDialogClass *klass) -{ - GObjectClass *object_class; - - object_class = (GObjectClass*) klass; - - parent_class = g_type_class_ref (PARENT_TYPE); - - object_class->set_property = eab_search_dialog_set_property; - object_class->get_property = eab_search_dialog_get_property; - object_class->dispose = eab_search_dialog_dispose; - - g_object_class_install_property (object_class, PROP_VIEW, - g_param_spec_object ("view", NULL, NULL, E_TYPE_AB_VIEW, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); -} - -static char * -get_query (EABSearchDialog *view) -{ - FilterRule *rule; - GString *out = g_string_new(""); - char *ret; - - rule = eab_view_peek_search_rule (view->view); - - filter_rule_build_code(rule, out); - ret = out->str; - printf("Searching using %s\n", ret); - g_string_free(out, FALSE); - return ret; -} - -static void -dialog_response (GtkWidget *widget, int response_id, EABSearchDialog *dialog) -{ - char *query; - - if (response_id == GTK_RESPONSE_OK) { - query = get_query(dialog); - g_object_set(dialog->view, - "query", query, - NULL); - g_free(query); - } - - gtk_widget_destroy(GTK_WIDGET (dialog)); -} - -static void -eab_search_dialog_init (EABSearchDialog *view) -{ - GtkDialog *dialog = GTK_DIALOG (view); - - gtk_widget_realize (GTK_WIDGET (dialog)); - gtk_dialog_set_has_separator (dialog, FALSE); - gtk_container_set_border_width (GTK_CONTAINER (dialog->vbox), 0); - gtk_container_set_border_width (GTK_CONTAINER (dialog->action_area), 12); - - gtk_window_set_default_size (GTK_WINDOW (view), 550, 400); - gtk_window_set_title(GTK_WINDOW(view), _("Advanced Search")); - - gtk_dialog_add_buttons (dialog, - GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, - /*GTK_STOCK_SAVE, GTK_RESPONSE_APPLY,*/ - GTK_STOCK_OK, GTK_RESPONSE_OK, - NULL); - - gtk_dialog_set_default_response (dialog, GTK_RESPONSE_OK); - - g_signal_connect(dialog, "response", - G_CALLBACK(dialog_response), view); -} - -GtkWidget * -eab_search_dialog_new (EABView *addr_view) -{ - EABSearchDialog *view = g_object_new (EAB_SEARCH_DIALOG_TYPE, "view", addr_view, NULL); - - return GTK_WIDGET(view); -} - -static void -eab_search_dialog_dispose (GObject *object) -{ - EABSearchDialog *view; - - view = EAB_SEARCH_DIALOG (object); - - G_OBJECT_CLASS(parent_class)->dispose (object); -} diff --git a/addressbook/gui/search/e-addressbook-search-dialog.h b/addressbook/gui/search/e-addressbook-search-dialog.h deleted file mode 100644 index 1321409f94..0000000000 --- a/addressbook/gui/search/e-addressbook-search-dialog.h +++ /dev/null @@ -1,62 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* e-minicard-view-widget.h - * Copyright (C) 2000 Ximian, Inc. - * Author: Chris Lahey <clahey@ximian.com> - * - * This library 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 library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef __EAB_SEARCH_DIALOG_H__ -#define __EAB_SEARCH_DIALOG_H__ - -#include <libebook/e-book.h> - -#include "addressbook/gui/widgets/e-addressbook-view.h" -#include "filter/rule-context.h" -#include "filter/filter-rule.h" -#include <gtk/gtkdialog.h> - -G_BEGIN_DECLS - -#define EAB_SEARCH_DIALOG_TYPE (eab_search_dialog_get_type ()) -#define EAB_SEARCH_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EAB_SEARCH_DIALOG_TYPE, EABSearchDialog)) -#define EAB_SEARCH_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EAB_SEARCH_DIALOG_TYPE, EABSearchDialogClass)) -#define E_IS_ADDRESSBOOK_SEARCH_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EAB_SEARCH_DIALOG_TYPE)) -#define E_IS_ADDRESSBOOK_SEARCH_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), EAB_SEARCH_DIALOG_TYPE)) - - -typedef struct _EABSearchDialog EABSearchDialog; -typedef struct _EABSearchDialogClass EABSearchDialogClass; - -struct _EABSearchDialog -{ - GtkDialog parent; - - GtkWidget *search; - EABView *view; -}; - -struct _EABSearchDialogClass -{ - GtkDialogClass parent_class; -}; - -GType eab_search_dialog_get_type (void); - -GtkWidget *eab_search_dialog_new (EABView *view); - -G_END_DECLS - -#endif /* __EAB_SEARCH_DIALOG_H__ */ diff --git a/addressbook/gui/widgets/.cvsignore b/addressbook/gui/widgets/.cvsignore deleted file mode 100644 index b67f65e6c3..0000000000 --- a/addressbook/gui/widgets/.cvsignore +++ /dev/null @@ -1,19 +0,0 @@ -.deps -.libs -.pure -Makefile -Makefile.in -*.lo -*.la -minicard-label-test -minicard-test -minicard-view-test -minicard-widget-test -reflow-test -eab-marshal.c -eab-marshal.h -Evolution-Composer-stubs.c -Evolution-Composer-skels.c -Evolution-Composer-common.c -Evolution-Composer.h - diff --git a/addressbook/gui/widgets/Makefile.am b/addressbook/gui/widgets/Makefile.am deleted file mode 100644 index da204a4f06..0000000000 --- a/addressbook/gui/widgets/Makefile.am +++ /dev/null @@ -1,98 +0,0 @@ -ruledir = $(privdatadir) - -INCLUDES = \ - -DG_LOG_DOMAIN=\"eab-widgets\" \ - -DEVOLUTION_ETSPECDIR=\""$(etspecdir)"\" \ - -DEVOLUTION_IMAGESDIR=\""$(imagesdir)"\" \ - -DEVOLUTION_GALVIEWSDIR=\""$(viewsdir)"\" \ - -I$(top_srcdir) \ - -I$(top_srcdir)/addressbook \ - -I$(top_srcdir)/addressbook/backend \ - -I$(top_builddir)/addressbook/backend \ - -I$(top_srcdir)/addressbook/gui/contact-editor \ - -I$(top_srcdir)/addressbook/gui/merging \ - -I$(top_srcdir)/addressbook/gui/component \ - -I$(top_srcdir)/widgets/misc \ - -I$(top_builddir)/shell \ - -DSEARCH_RULE_DIR=\"$(ruledir)\" \ - $(EVOLUTION_ADDRESSBOOK_CFLAGS) - -CORBA_COMPOSER_SOURCE_H = \ - Evolution-Composer.h -CORBA_COMPOSER_SOURCE_C = \ - Evolution-Composer-common.c \ - Evolution-Composer-skels.c \ - Evolution-Composer-stubs.c -CORBA_COMPOSER_IDL = $(srcdir)/../../../composer/Evolution-Composer.idl - -$(CORBA_COMPOSER_SOURCE_H): $(CORBA_COMPOSER_IDL) - $(ORBIT_IDL) -I $(srcdir) $(IDL_INCLUDES) $(CORBA_COMPOSER_IDL) - -$(CORBA_COMPOSER_SOURCE_C): $(CORBA_COMPOSER_SOURCE_H) - -CORBA_SOURCE_H = $(CORBA_COMPOSER_SOURCE_H) -CORBA_SOURCE_C = $(CORBA_COMPOSER_SOURCE_C) -CORBA_SOURCE = $(CORBA_SOURCE_H) $(CORBA_SOURCE_C) - -noinst_LTLIBRARIES = \ - libeabwidgets.la - -libeabwidgets_la_SOURCES = \ - $(CORBA_SOURCE) \ - $(MARSHAL_GENERATED) \ - eab-config.c \ - eab-config.h \ - eab-contact-display.c \ - eab-contact-display.h \ - eab-gui-util.c \ - eab-gui-util.h \ - eab-menu.c \ - eab-menu.h \ - eab-popup.c \ - eab-popup.h \ - eab-popup-control.c \ - eab-popup-control.h \ - eab-vcard-control.c \ - eab-vcard-control.h \ - e-minicard.c \ - e-minicard.h \ - e-minicard-label.c \ - e-minicard-label.h \ - e-minicard-view.c \ - e-minicard-view.h \ - e-minicard-view-widget.c \ - e-minicard-view-widget.h \ - e-addressbook-reflow-adapter.c \ - e-addressbook-reflow-adapter.h \ - e-addressbook-table-adapter.c \ - e-addressbook-table-adapter.h \ - e-addressbook-model.c \ - e-addressbook-model.h \ - e-addressbook-view.c \ - e-addressbook-view.h \ - gal-view-minicard.c \ - gal-view-minicard.h \ - gal-view-factory-minicard.c \ - gal-view-factory-minicard.h - -#TREEVIEW_SOURCES= e-addressbook-treeview-adapter.c \ -# e-addressbook-treeview-adapter.h \ -# gal-view-factory-treeview.c \ -# gal-view-factory-treeview.h \ -# gal-view-treeview.c \ -# gal-view-treeview.h - -MARSHAL_GENERATED = eab-marshal.c eab-marshal.h -@EVO_MARSHAL_RULE@ - -BUILT_SOURCES = $(CORBA_SOURCE) $(MARSHAL_GENERATED) -CLEANFILES = $(BUILT_SOURCES) - -dist-hook: - cd $(distdir); rm -f $(BUILT_SOURCES) - -etspec_DATA= e-addressbook-view.etspec - -EXTRA_DIST = \ - $(etspec_DATA) \ - eab-marshal.list diff --git a/addressbook/gui/widgets/e-addressbook-model.c b/addressbook/gui/widgets/e-addressbook-model.c deleted file mode 100644 index e6f4ecb868..0000000000 --- a/addressbook/gui/widgets/e-addressbook-model.c +++ /dev/null @@ -1,720 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * - * Author: - * Christopher James Lahey <clahey@ximian.com> - * - * (C) 1999 Ximian, Inc. - */ - -#include <config.h> -#include "eab-marshal.h" -#include "e-addressbook-model.h" -#include <libxml/tree.h> -#include <libxml/parser.h> -#include <libxml/xmlmemory.h> -#include <gnome.h> -#include <gal/widgets/e-gui-utils.h> -#include "eab-gui-util.h" - -#define PARENT_TYPE G_TYPE_OBJECT -static GObjectClass *parent_class; - -/* - * EABModel callbacks - * These are the callbacks that define the behavior of our custom model. - */ -static void eab_model_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec); -static void eab_model_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); - - -enum { - PROP_0, - PROP_BOOK, - PROP_QUERY, - PROP_EDITABLE, -}; - -enum { - WRITABLE_STATUS, - STATUS_MESSAGE, - SEARCH_STARTED, - SEARCH_RESULT, - FOLDER_BAR_MESSAGE, - CONTACT_ADDED, - CONTACT_REMOVED, - CONTACT_CHANGED, - MODEL_CHANGED, - STOP_STATE_CHANGED, - BACKEND_DIED, - LAST_SIGNAL -}; - -static guint eab_model_signals [LAST_SIGNAL] = {0, }; - -static void -free_data (EABModel *model) -{ - if (model->data) { - int i; - - for ( i = 0; i < model->data_count; i++ ) { - g_object_unref (model->data[i]); - } - - g_free(model->data); - model->data = NULL; - model->data_count = 0; - model->allocated_count = 0; - } -} - -static void -remove_book_view(EABModel *model) -{ - if (model->book_view && model->create_contact_id) - g_signal_handler_disconnect (model->book_view, - model->create_contact_id); - if (model->book_view && model->remove_contact_id) - g_signal_handler_disconnect (model->book_view, - model->remove_contact_id); - if (model->book_view && model->modify_contact_id) - g_signal_handler_disconnect (model->book_view, - model->modify_contact_id); - if (model->book_view && model->status_message_id) - g_signal_handler_disconnect (model->book_view, - model->status_message_id); - if (model->book_view && model->sequence_complete_id) - g_signal_handler_disconnect (model->book_view, - model->sequence_complete_id); - - model->create_contact_id = 0; - model->remove_contact_id = 0; - model->modify_contact_id = 0; - model->status_message_id = 0; - model->sequence_complete_id = 0; - - model->search_in_progress = FALSE; - - if (model->book_view) { - e_book_view_stop (model->book_view); - g_object_unref (model->book_view); - model->book_view = NULL; - } -} - -static void -addressbook_dispose(GObject *object) -{ - EABModel *model = EAB_MODEL(object); - - remove_book_view(model); - free_data (model); - - if (model->book) { - if (model->writable_status_id) - g_signal_handler_disconnect (model->book, - model->writable_status_id); - model->writable_status_id = 0; - - if (model->backend_died_id) - g_signal_handler_disconnect (model->book, - model->backend_died_id); - model->backend_died_id = 0; - - g_object_unref (model->book); - model->book = NULL; - } - - if (model->query) { - e_book_query_unref (model->query); - model->query = NULL; - } - - if (G_OBJECT_CLASS(parent_class)->dispose) - G_OBJECT_CLASS(parent_class)->dispose(object); -} - -static void -update_folder_bar_message (EABModel *model) -{ - int count; - char *message; - - count = model->data_count; - - switch (count) { - case 0: - message = g_strdup (_("No contacts")); - break; - default: - message = g_strdup_printf (ngettext("%d contact", "%d contacts", count), count); - break; - } - - g_signal_emit (model, - eab_model_signals [FOLDER_BAR_MESSAGE], 0, - message); - - g_free (message); -} - -static void -create_contact(EBookView *book_view, - const GList *contacts, - EABModel *model) -{ - int old_count = model->data_count; - int length = g_list_length ((GList *)contacts); - - if (model->data_count + length > model->allocated_count) { - while (model->data_count + length > model->allocated_count) - model->allocated_count = model->allocated_count * 2 + 1; - model->data = g_renew(EContact *, model->data, model->allocated_count); - } - - for ( ; contacts; contacts = contacts->next) { - model->data[model->data_count++] = contacts->data; - g_object_ref (contacts->data); - } - - g_signal_emit (model, - eab_model_signals [CONTACT_ADDED], 0, - old_count, model->data_count - old_count); - - update_folder_bar_message (model); -} - -static void -remove_contact(EBookView *book_view, - GList *ids, - EABModel *model) -{ - /* XXX we should keep a hash around instead of this O(n*m) loop */ - int i = 0; - GList *l; - - for (l = ids; l; l = l->next) { - char *id = l->data; - for ( i = 0; i < model->data_count; i++) { - if ( !strcmp(e_contact_get_const (model->data[i], E_CONTACT_UID), id) ) { - g_object_unref (model->data[i]); - memmove(model->data + i, model->data + i + 1, (model->data_count - i - 1) * sizeof (EContact *)); - model->data_count--; - - g_signal_emit (model, - eab_model_signals [CONTACT_REMOVED], 0, - i); - - break; - } - } - } - - update_folder_bar_message (model); -} - -static void -modify_contact(EBookView *book_view, - const GList *contacts, - EABModel *model) -{ - for ( ; contacts; contacts = contacts->next) { - int i; - for ( i = 0; i < model->data_count; i++) { - if ( !strcmp(e_contact_get_const(model->data[i], E_CONTACT_UID), - e_contact_get_const(E_CONTACT(contacts->data), E_CONTACT_UID)) ) { - g_object_unref (model->data[i]); - model->data[i] = e_contact_duplicate(E_CONTACT(contacts->data)); - g_signal_emit (model, - eab_model_signals [CONTACT_CHANGED], 0, - i); - break; - } - } - } -} - -static void -status_message (EBookView *book_view, - char* status, - EABModel *model) -{ - g_signal_emit (model, - eab_model_signals [STATUS_MESSAGE], 0, - status); -} - -static void -sequence_complete (EBookView *book_view, - EBookViewStatus status, - EABModel *model) -{ - model->search_in_progress = FALSE; - status_message (book_view, NULL, model); - g_signal_emit (model, - eab_model_signals [SEARCH_RESULT], 0, - status); - g_signal_emit (model, - eab_model_signals [STOP_STATE_CHANGED], 0); -} - -static void -writable_status (EBook *book, - gboolean writable, - EABModel *model) -{ - if (!model->editable_set) { - model->editable = writable; - - g_signal_emit (model, - eab_model_signals [WRITABLE_STATUS], 0, - writable); - } -} - -static void -backend_died (EBook *book, - EABModel *model) -{ - g_signal_emit (model, - eab_model_signals [BACKEND_DIED], 0); -} - -static void -eab_model_class_init (GObjectClass *object_class) -{ - parent_class = g_type_class_ref (PARENT_TYPE); - - object_class->dispose = addressbook_dispose; - object_class->set_property = eab_model_set_property; - object_class->get_property = eab_model_get_property; - - g_object_class_install_property (object_class, PROP_BOOK, - g_param_spec_object ("book", - _("Book"), - /*_( */"XXX blurb" /*)*/, - E_TYPE_BOOK, - G_PARAM_READWRITE)); - - g_object_class_install_property (object_class, PROP_QUERY, - g_param_spec_string ("query", - _("Query"), - /*_( */"XXX blurb" /*)*/, - NULL, - G_PARAM_READWRITE)); - - g_object_class_install_property (object_class, PROP_EDITABLE, - g_param_spec_boolean ("editable", - _("Editable"), - /*_( */"XXX blurb" /*)*/, - FALSE, - G_PARAM_READWRITE)); - - eab_model_signals [WRITABLE_STATUS] = - g_signal_new ("writable_status", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (EABModelClass, writable_status), - NULL, NULL, - eab_marshal_NONE__BOOL, - G_TYPE_NONE, - 1, G_TYPE_BOOLEAN); - - eab_model_signals [STATUS_MESSAGE] = - g_signal_new ("status_message", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (EABModelClass, status_message), - NULL, NULL, - eab_marshal_NONE__POINTER, - G_TYPE_NONE, - 1, G_TYPE_POINTER); - - eab_model_signals [SEARCH_STARTED] = - g_signal_new ("search_started", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (EABModelClass, search_started), - NULL, NULL, - eab_marshal_NONE__NONE, - G_TYPE_NONE, 0); - - eab_model_signals [SEARCH_RESULT] = - g_signal_new ("search_result", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (EABModelClass, search_result), - NULL, NULL, - eab_marshal_NONE__INT, - G_TYPE_NONE, 1, G_TYPE_INT); - - eab_model_signals [FOLDER_BAR_MESSAGE] = - g_signal_new ("folder_bar_message", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (EABModelClass, folder_bar_message), - NULL, NULL, - eab_marshal_NONE__POINTER, - G_TYPE_NONE, 1, G_TYPE_POINTER); - - eab_model_signals [CONTACT_ADDED] = - g_signal_new ("contact_added", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (EABModelClass, contact_added), - NULL, NULL, - eab_marshal_NONE__INT_INT, - G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_INT); - - eab_model_signals [CONTACT_REMOVED] = - g_signal_new ("contact_removed", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (EABModelClass, contact_removed), - NULL, NULL, - eab_marshal_NONE__INT, - G_TYPE_NONE, 1, G_TYPE_INT); - - eab_model_signals [CONTACT_CHANGED] = - g_signal_new ("contact_changed", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (EABModelClass, contact_changed), - NULL, NULL, - eab_marshal_NONE__INT, - G_TYPE_NONE, 1, G_TYPE_INT); - - eab_model_signals [MODEL_CHANGED] = - g_signal_new ("model_changed", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (EABModelClass, model_changed), - NULL, NULL, - eab_marshal_NONE__NONE, - G_TYPE_NONE, 0); - - eab_model_signals [STOP_STATE_CHANGED] = - g_signal_new ("stop_state_changed", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (EABModelClass, stop_state_changed), - NULL, NULL, - eab_marshal_NONE__NONE, - G_TYPE_NONE, 0); - - eab_model_signals [BACKEND_DIED] = - g_signal_new ("backend_died", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (EABModelClass, backend_died), - NULL, NULL, - eab_marshal_NONE__NONE, - G_TYPE_NONE, 0); -} - -static void -eab_model_init (GObject *object) -{ - EABModel *model = EAB_MODEL(object); - model->book = NULL; - model->query = e_book_query_any_field_contains (""); - model->book_view = NULL; - model->create_contact_id = 0; - model->remove_contact_id = 0; - model->modify_contact_id = 0; - model->status_message_id = 0; - model->writable_status_id = 0; - model->backend_died_id = 0; - model->sequence_complete_id = 0; - model->data = NULL; - model->data_count = 0; - model->allocated_count = 0; - model->search_in_progress = FALSE; - model->editable = FALSE; - model->editable_set = FALSE; - model->first_get_view = TRUE; -} - -static void -book_view_loaded (EBook *book, EBookStatus status, EBookView *book_view, gpointer closure) -{ - EABModel *model = closure; - - if (status != E_BOOK_ERROR_OK) { - eab_error_dialog (_("Error getting book view"), status); - return; - } - - remove_book_view (model); - free_data (model); - - model->book_view = book_view; - if (model->book_view) - g_object_ref (model->book_view); - model->create_contact_id = g_signal_connect(model->book_view, - "contacts_added", - G_CALLBACK (create_contact), - model); - model->remove_contact_id = g_signal_connect(model->book_view, - "contacts_removed", - G_CALLBACK (remove_contact), - model); - model->modify_contact_id = g_signal_connect(model->book_view, - "contacts_changed", - G_CALLBACK(modify_contact), - model); - model->status_message_id = g_signal_connect(model->book_view, - "status_message", - G_CALLBACK(status_message), - model); - model->sequence_complete_id = g_signal_connect(model->book_view, - "sequence_complete", - G_CALLBACK(sequence_complete), - model); - - model->search_in_progress = TRUE; - g_signal_emit (model, - eab_model_signals [MODEL_CHANGED], 0); - g_signal_emit (model, - eab_model_signals [SEARCH_STARTED], 0); - g_signal_emit (model, - eab_model_signals [STOP_STATE_CHANGED], 0); - - e_book_view_start (model->book_view); -} - -static void -get_view (EABModel *model) -{ - gboolean success; - - if (model->book && model->query) { - ESource *source; - const char *limit_str; - int limit = -1; - - source = e_book_get_source (model->book); - - limit_str = e_source_get_property (source, "limit"); - if (limit_str && *limit_str) - limit = atoi (limit_str); - - remove_book_view(model); - - if (model->first_get_view) { - model->first_get_view = FALSE; - - if (e_book_check_static_capability (model->book, "do-initial-query")) { - success = e_book_async_get_book_view (model->book, model->query, NULL, limit, book_view_loaded, model); - } else { - free_data (model); - - g_signal_emit (model, - eab_model_signals [MODEL_CHANGED], 0); - g_signal_emit (model, - eab_model_signals [STOP_STATE_CHANGED], 0); - return; - } - } - else - success = e_book_async_get_book_view (model->book, model->query, NULL, limit, book_view_loaded, model); - - } -} - -static gboolean -get_view_idle (EABModel *model) -{ - model->book_view_idle_id = 0; - get_view (model); - g_object_unref (model); - return FALSE; -} - - -EContact * -eab_model_get_contact(EABModel *model, - int row) -{ - if (model->data && 0 <= row && row < model->data_count) { - return e_contact_duplicate (model->data[row]); - } - return NULL; -} - -static void -eab_model_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) -{ - EABModel *model; - gboolean need_get_book_view = FALSE; - - model = EAB_MODEL (object); - - switch (prop_id){ - case PROP_BOOK: - if (model->book) { - if (model->writable_status_id) - g_signal_handler_disconnect (model->book, - model->writable_status_id); - model->writable_status_id = 0; - - if (model->backend_died_id) - g_signal_handler_disconnect (model->book, - model->backend_died_id); - model->backend_died_id = 0; - - g_object_unref (model->book); - } - model->book = E_BOOK(g_value_get_object (value)); - if (model->book) { - model->writable_status_id = - g_signal_connect (model->book, - "writable_status", - G_CALLBACK (writable_status), model); - model->backend_died_id = - g_signal_connect (model->book, - "backend_died", - G_CALLBACK (backend_died), model); - - if (!model->editable_set) { - model->editable = e_book_is_writable (model->book); - - g_signal_emit (model, - eab_model_signals [WRITABLE_STATUS], 0, - model->editable); - } - - model->first_get_view = TRUE; - g_object_ref (model->book); - need_get_book_view = TRUE; - } - break; - case PROP_QUERY: - if (model->query) - e_book_query_unref (model->query); - model->query = e_book_query_from_string (g_value_get_string (value)); - need_get_book_view = TRUE; - break; - case PROP_EDITABLE: - model->editable = g_value_get_boolean (value); - model->editable_set = TRUE; - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } - - if (need_get_book_view) { - if (!model->book_view_idle_id) { - g_object_ref (model); - model->book_view_idle_id = g_idle_add ((GSourceFunc)get_view_idle, model); - } - } - -} - -static void -eab_model_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) -{ - EABModel *eab_model; - - eab_model = EAB_MODEL (object); - - switch (prop_id) { - case PROP_BOOK: - g_value_set_object (value, eab_model->book); - break; - case PROP_QUERY: { - char *query_string = e_book_query_to_string (eab_model->query); - g_value_set_string (value, query_string); - break; - } - case PROP_EDITABLE: - g_value_set_boolean (value, eab_model->editable); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -GType -eab_model_get_type (void) -{ - static GType type = 0; - - if (!type) { - static const GTypeInfo info = { - sizeof (EABModelClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) eab_model_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (EABModel), - 0, /* n_preallocs */ - (GInstanceInitFunc) eab_model_init, - }; - - type = g_type_register_static (PARENT_TYPE, "EABModel", &info, 0); - } - - return type; -} - -EABModel* -eab_model_new (void) -{ - EABModel *et; - - et = g_object_new (EAB_TYPE_MODEL, NULL); - - return et; -} - -void eab_model_stop (EABModel *model) -{ - remove_book_view(model); - g_signal_emit (model, - eab_model_signals [STOP_STATE_CHANGED], 0); - g_signal_emit (model, - eab_model_signals [STATUS_MESSAGE], 0, - "Search Interrupted."); -} - -gboolean -eab_model_can_stop (EABModel *model) -{ - return model->search_in_progress; -} - -void -eab_model_force_folder_bar_message (EABModel *model) -{ - update_folder_bar_message (model); -} - -int -eab_model_contact_count (EABModel *model) -{ - return model->data_count; -} - -const EContact * -eab_model_contact_at (EABModel *model, int index) -{ - return model->data[index]; -} - -gboolean -eab_model_editable (EABModel *model) -{ - return model->editable; -} - -EBook * -eab_model_get_ebook (EABModel *model) -{ - return model->book; -} diff --git a/addressbook/gui/widgets/e-addressbook-model.h b/addressbook/gui/widgets/e-addressbook-model.h deleted file mode 100644 index e5ebb83dab..0000000000 --- a/addressbook/gui/widgets/e-addressbook-model.h +++ /dev/null @@ -1,82 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -#ifndef _EAB_MODEL_H_ -#define _EAB_MODEL_H_ - -#include <glib.h> -#include <glib-object.h> -#include <libebook/e-book.h> -#include <libebook/e-book-view.h> - -#define EAB_TYPE_MODEL (eab_model_get_type ()) -#define EAB_MODEL(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EAB_TYPE_MODEL, EABModel)) -#define EAB_MODEL_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), EAB_TYPE_MODEL, EABModelClass)) -#define E_IS_ADDRESSBOOK_MODEL(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EAB_TYPE_MODEL)) -#define E_IS_ADDRESSBOOK_MODEL_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EAB_TYPE_MODEL)) - -typedef struct _EABModel EABModel; -typedef struct _EABModelClass EABModelClass; - -struct _EABModel { - GObject parent; - - /* item specific fields */ - EBook *book; - EBookQuery *query; - EBookView *book_view; - - int book_view_idle_id; - - EContact **data; - int data_count; - int allocated_count; - - int create_contact_id, remove_contact_id, modify_contact_id; - int status_message_id, writable_status_id, sequence_complete_id; - int backend_died_id; - - guint search_in_progress : 1; - guint editable : 1; - guint editable_set : 1; - guint first_get_view : 1; -}; - - -struct _EABModelClass { - GObjectClass parent_class; - - /* - * Signals - */ - void (*writable_status) (EABModel *model, gboolean writable); - void (*search_started) (EABModel *model); - void (*search_result) (EABModel *model, EBookViewStatus status); - void (*status_message) (EABModel *model, const gchar *message); - void (*folder_bar_message) (EABModel *model, const gchar *message); - void (*contact_added) (EABModel *model, gint index, gint count); - void (*contact_removed) (EABModel *model, gint index); - void (*contact_changed) (EABModel *model, gint index); - void (*model_changed) (EABModel *model); - void (*stop_state_changed) (EABModel *model); - void (*backend_died) (EABModel *model); -}; - - -GType eab_model_get_type (void); -EABModel *eab_model_new (void); - -/* Returns object with ref count of 1. */ -EContact *eab_model_get_contact (EABModel *model, - int row); -EBook *eab_model_get_ebook (EABModel *model); - -void eab_model_stop (EABModel *model); -gboolean eab_model_can_stop (EABModel *model); - -void eab_model_force_folder_bar_message (EABModel *model); - -int eab_model_contact_count (EABModel *model); -const EContact *eab_model_contact_at (EABModel *model, - int index); -gboolean eab_model_editable (EABModel *model); - -#endif /* _EAB_MODEL_H_ */ diff --git a/addressbook/gui/widgets/e-addressbook-reflow-adapter.c b/addressbook/gui/widgets/e-addressbook-reflow-adapter.c deleted file mode 100644 index 4d935198d1..0000000000 --- a/addressbook/gui/widgets/e-addressbook-reflow-adapter.c +++ /dev/null @@ -1,516 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - - -#include <config.h> -#include <string.h> - -#include <libgnome/gnome-i18n.h> -#include "eab-marshal.h" -#include "e-addressbook-reflow-adapter.h" -#include "e-addressbook-model.h" -#include "e-addressbook-view.h" -#include "eab-gui-util.h" - -#include "e-minicard.h" -#include <gal/widgets/e-gui-utils.h> -#include "addressbook/printing/e-contact-print.h" -#include "addressbook/printing/e-contact-print-envelope.h" - - -struct _EAddressbookReflowAdapterPrivate { - EABModel *model; - - gboolean loading; - - int create_contact_id, remove_contact_id, modify_contact_id, model_changed_id; - int search_started_id, search_result_id; -}; - -#define PARENT_TYPE e_reflow_model_get_type() -static EReflowModel *parent_class; - -#define d(x) - -enum { - PROP_0, - PROP_BOOK, - PROP_QUERY, - PROP_EDITABLE, - PROP_MODEL, -}; - -enum { - DRAG_BEGIN, - LAST_SIGNAL -}; - -static guint e_addressbook_reflow_adapter_signals [LAST_SIGNAL] = {0, }; - -static void -unlink_model(EAddressbookReflowAdapter *adapter) -{ - EAddressbookReflowAdapterPrivate *priv = adapter->priv; - - if (priv->model && priv->create_contact_id) - g_signal_handler_disconnect (priv->model, - priv->create_contact_id); - if (priv->model && priv->remove_contact_id) - g_signal_handler_disconnect (priv->model, - priv->remove_contact_id); - if (priv->model && priv->modify_contact_id) - g_signal_handler_disconnect (priv->model, - priv->modify_contact_id); - if (priv->model && priv->model_changed_id) - g_signal_handler_disconnect (priv->model, - priv->model_changed_id); - if (priv->model && priv->search_started_id) - g_signal_handler_disconnect (priv->model, - priv->search_started_id); - if (priv->model && priv->search_result_id) - g_signal_handler_disconnect (priv->model, - priv->search_result_id); - - priv->create_contact_id = 0; - priv->remove_contact_id = 0; - priv->modify_contact_id = 0; - priv->model_changed_id = 0; - priv->search_started_id = 0; - priv->search_result_id = 0; - - if (priv->model) - g_object_unref (priv->model); - - priv->model = NULL; -} - - -static int -text_height (PangoLayout *layout, const gchar *text) -{ - int height; - - pango_layout_set_text (layout, text, -1); - - pango_layout_get_pixel_size (layout, NULL, &height); - - return height; -} - -static void -addressbook_dispose(GObject *object) -{ - EAddressbookReflowAdapter *adapter = E_ADDRESSBOOK_REFLOW_ADAPTER(object); - - unlink_model (adapter); -} - -static void -addressbook_set_width (EReflowModel *erm, int width) -{ -} - -/* This function returns the number of items in our EReflowModel. */ -static int -addressbook_count (EReflowModel *erm) -{ - EAddressbookReflowAdapter *adapter = E_ADDRESSBOOK_REFLOW_ADAPTER(erm); - EAddressbookReflowAdapterPrivate *priv = adapter->priv; - - return eab_model_contact_count (priv->model); -} - -/* This function returns the height of the minicontact in question */ -static int -addressbook_height (EReflowModel *erm, int i, GnomeCanvasGroup *parent) -{ - EAddressbookReflowAdapter *adapter = E_ADDRESSBOOK_REFLOW_ADAPTER(erm); - EAddressbookReflowAdapterPrivate *priv = adapter->priv; - EContactField field; - int count = 0; - char *string; - EContact *contact = (EContact*)eab_model_contact_at (priv->model, i); - PangoLayout *layout = gtk_widget_create_pango_layout (GTK_WIDGET (GNOME_CANVAS_ITEM (parent)->canvas), ""); - int height; - - string = e_contact_get(contact, E_CONTACT_FILE_AS); - height = text_height (layout, string ? string : "") + 10.0; - g_free(string); - - for(field = E_CONTACT_FULL_NAME; field != E_CONTACT_LAST_SIMPLE_STRING && count < 5; field++) { - - if (field == E_CONTACT_FAMILY_NAME || field == E_CONTACT_GIVEN_NAME) - continue; - - string = e_contact_get(contact, field); - if (string && *string) { - int this_height; - int field_text_height; - - this_height = text_height (layout, e_contact_pretty_name(field)); - - field_text_height = text_height (layout, string); - if (this_height < field_text_height) - this_height = field_text_height; - - this_height += 3; - - height += this_height; - count ++; - } - g_free (string); - } - height += 2; - - g_object_unref (layout); - - return height; -} - -static int -addressbook_compare (EReflowModel *erm, int n1, int n2) -{ - EAddressbookReflowAdapter *adapter = E_ADDRESSBOOK_REFLOW_ADAPTER(erm); - EAddressbookReflowAdapterPrivate *priv = adapter->priv; - EContact *contact1, *contact2; - - if (priv->loading) { - return n1-n2; - } - else { - contact1 = (EContact*)eab_model_contact_at (priv->model, n1); - contact2 = (EContact*)eab_model_contact_at (priv->model, n2); - - if (contact1 && contact2) { - const char *file_as1, *file_as2; - file_as1 = e_contact_get_const (contact1, E_CONTACT_FILE_AS); - file_as2 = e_contact_get_const (contact2, E_CONTACT_FILE_AS); - if (file_as1 && file_as2) - return g_utf8_collate(file_as1, file_as2); - if (file_as1) - return -1; - if (file_as2) - return 1; - return strcmp(e_contact_get_const (contact1, E_CONTACT_UID), - e_contact_get_const (contact2, E_CONTACT_UID)); - } - if (contact1) - return -1; - if (contact2) - return 1; - return 0; - } -} - -static int -adapter_drag_begin (EMinicard *card, GdkEvent *event, EAddressbookReflowAdapter *adapter) -{ - gint ret_val = 0; - - g_signal_emit (adapter, - e_addressbook_reflow_adapter_signals[DRAG_BEGIN], 0, - event, &ret_val); - - return ret_val; -} - -static GnomeCanvasItem * -addressbook_incarnate (EReflowModel *erm, int i, GnomeCanvasGroup *parent) -{ - EAddressbookReflowAdapter *adapter = E_ADDRESSBOOK_REFLOW_ADAPTER(erm); - EAddressbookReflowAdapterPrivate *priv = adapter->priv; - GnomeCanvasItem *item; - - item = gnome_canvas_item_new(parent, - e_minicard_get_type(), - "contact", eab_model_contact_at (priv->model, i), - "editable", eab_model_editable (priv->model), - NULL); - -#if 0 - g_signal_connect (item, "selected", - G_CALLBACK(card_selected), 0, emvm); -#endif - - g_signal_connect (item, "drag_begin", - G_CALLBACK(adapter_drag_begin), adapter); - - return item; -} - -static void -addressbook_reincarnate (EReflowModel *erm, int i, GnomeCanvasItem *item) -{ - EAddressbookReflowAdapter *adapter = E_ADDRESSBOOK_REFLOW_ADAPTER(erm); - EAddressbookReflowAdapterPrivate *priv = adapter->priv; - - gnome_canvas_item_set(item, - "contact", eab_model_contact_at (priv->model, i), - NULL); -} - -static void -create_contact (EABModel *model, - gint index, gint count, - EAddressbookReflowAdapter *adapter) -{ - e_reflow_model_items_inserted (E_REFLOW_MODEL (adapter), - index, - count); -} - -static void -remove_contact (EABModel *model, - gint index, - EAddressbookReflowAdapter *adapter) -{ - e_reflow_model_item_removed (E_REFLOW_MODEL (adapter), index); -} - -static void -modify_contact (EABModel *model, - gint index, - EAddressbookReflowAdapter *adapter) -{ - e_reflow_model_item_changed (E_REFLOW_MODEL (adapter), index); -} - -static void -model_changed (EABModel *model, - EAddressbookReflowAdapter *adapter) -{ - e_reflow_model_changed (E_REFLOW_MODEL (adapter)); -} - -static void -search_started (EABModel *model, - EAddressbookReflowAdapter *adapter) -{ - EAddressbookReflowAdapterPrivate *priv = adapter->priv; - - priv->loading = TRUE; -} - -static void -search_result (EABModel *model, - EBookViewStatus status, - EAddressbookReflowAdapter *adapter) -{ - EAddressbookReflowAdapterPrivate *priv = adapter->priv; - - priv->loading = FALSE; - - e_reflow_model_comparison_changed (E_REFLOW_MODEL (adapter)); -} - -static void -addressbook_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) -{ - EAddressbookReflowAdapter *adapter = E_ADDRESSBOOK_REFLOW_ADAPTER(object); - EAddressbookReflowAdapterPrivate *priv = adapter->priv; - - switch (prop_id) { - case PROP_BOOK: - g_object_set (priv->model, - "book", g_value_get_object (value), - NULL); - break; - case PROP_QUERY: - g_object_set (priv->model, - "query", g_value_get_string (value), - NULL); - break; - case PROP_EDITABLE: - g_object_set (priv->model, - "editable", g_value_get_boolean (value), - NULL); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -addressbook_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) -{ - EAddressbookReflowAdapter *adapter = E_ADDRESSBOOK_REFLOW_ADAPTER(object); - EAddressbookReflowAdapterPrivate *priv = adapter->priv; - - switch (prop_id) { - case PROP_BOOK: { - g_object_get_property (G_OBJECT (priv->model), - "book", value); - break; - } - case PROP_QUERY: { - g_object_get_property (G_OBJECT (priv->model), - "query", value); - break; - } - case PROP_EDITABLE: { - g_object_get_property (G_OBJECT (priv->model), - "editable", value); - break; - } - case PROP_MODEL: - g_value_set_object (value, priv->model); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -e_addressbook_reflow_adapter_class_init (GObjectClass *object_class) -{ - EReflowModelClass *model_class = (EReflowModelClass *) object_class; - - parent_class = g_type_class_peek_parent (object_class); - - object_class->set_property = addressbook_set_property; - object_class->get_property = addressbook_get_property; - object_class->dispose = addressbook_dispose; - - g_object_class_install_property (object_class, PROP_BOOK, - g_param_spec_object ("book", - _("Book"), - /*_( */"XXX blurb" /*)*/, - E_TYPE_BOOK, - G_PARAM_READWRITE)); - - g_object_class_install_property (object_class, PROP_QUERY, - g_param_spec_string ("query", - _("Query"), - /*_( */"XXX blurb" /*)*/, - NULL, - G_PARAM_READWRITE)); - - g_object_class_install_property (object_class, PROP_EDITABLE, - g_param_spec_boolean ("editable", - _("Editable"), - /*_( */"XXX blurb" /*)*/, - FALSE, - G_PARAM_READWRITE)); - - g_object_class_install_property (object_class, PROP_MODEL, - g_param_spec_object ("model", - _("Model"), - /*_( */"XXX blurb" /*)*/, - EAB_TYPE_MODEL, - G_PARAM_READABLE)); - - e_addressbook_reflow_adapter_signals [DRAG_BEGIN] = - g_signal_new ("drag_begin", - G_OBJECT_CLASS_TYPE(object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (EAddressbookReflowAdapterClass, drag_begin), - NULL, NULL, - eab_marshal_INT__POINTER, - G_TYPE_INT, 1, G_TYPE_POINTER); - - model_class->set_width = addressbook_set_width; - model_class->count = addressbook_count; - model_class->height = addressbook_height; - model_class->compare = addressbook_compare; - model_class->incarnate = addressbook_incarnate; - model_class->reincarnate = addressbook_reincarnate; -} - -static void -e_addressbook_reflow_adapter_init (GtkObject *object) -{ - EAddressbookReflowAdapter *adapter = E_ADDRESSBOOK_REFLOW_ADAPTER(object); - EAddressbookReflowAdapterPrivate *priv; - - priv = adapter->priv = g_new0 (EAddressbookReflowAdapterPrivate, 1); - - priv->loading = FALSE; - priv->create_contact_id = 0; - priv->remove_contact_id = 0; - priv->modify_contact_id = 0; - priv->model_changed_id = 0; - priv->search_started_id = 0; - priv->search_result_id = 0; -} - -GType -e_addressbook_reflow_adapter_get_type (void) -{ - static GType type = 0; - - if (!type) { - static const GTypeInfo info = { - sizeof (EAddressbookReflowAdapterClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) e_addressbook_reflow_adapter_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (EAddressbookReflowAdapter), - 0, /* n_preallocs */ - (GInstanceInitFunc) e_addressbook_reflow_adapter_init, - }; - - type = g_type_register_static (PARENT_TYPE, "EAddressbookReflowAdapter", &info, 0); - } - - return type; -} - -void -e_addressbook_reflow_adapter_construct (EAddressbookReflowAdapter *adapter, - EABModel *model) -{ - EAddressbookReflowAdapterPrivate *priv = adapter->priv; - - priv->model = model; - g_object_ref (priv->model); - - priv->create_contact_id = g_signal_connect(priv->model, - "contact_added", - G_CALLBACK(create_contact), - adapter); - priv->remove_contact_id = g_signal_connect(priv->model, - "contact_removed", - G_CALLBACK(remove_contact), - adapter); - priv->modify_contact_id = g_signal_connect(priv->model, - "contact_changed", - G_CALLBACK(modify_contact), - adapter); - priv->model_changed_id = g_signal_connect(priv->model, - "model_changed", - G_CALLBACK(model_changed), - adapter); - priv->search_started_id = g_signal_connect(priv->model, - "search_started", - G_CALLBACK(search_started), - adapter); - priv->search_result_id = g_signal_connect(priv->model, - "search_result", - G_CALLBACK(search_result), - adapter); -} - -EReflowModel * -e_addressbook_reflow_adapter_new (EABModel *model) -{ - EAddressbookReflowAdapter *et; - - et = g_object_new (E_TYPE_ADDRESSBOOK_REFLOW_ADAPTER, NULL); - - e_addressbook_reflow_adapter_construct (et, model); - - return E_REFLOW_MODEL(et); -} - - -EContact * -e_addressbook_reflow_adapter_get_contact (EAddressbookReflowAdapter *adapter, - int index) -{ - EAddressbookReflowAdapterPrivate *priv = adapter->priv; - - return eab_model_get_contact (priv->model, index); -} diff --git a/addressbook/gui/widgets/e-addressbook-reflow-adapter.h b/addressbook/gui/widgets/e-addressbook-reflow-adapter.h deleted file mode 100644 index 1321b27bb4..0000000000 --- a/addressbook/gui/widgets/e-addressbook-reflow-adapter.h +++ /dev/null @@ -1,44 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -#ifndef _E_ADDRESSBOOK_REFLOW_ADAPTER_H_ -#define _E_ADDRESSBOOK_REFLOW_ADAPTER_H_ - -#include <gal/widgets/e-reflow-model.h> -#include <libebook/e-contact.h> -#include "e-addressbook-model.h" - -#define E_TYPE_ADDRESSBOOK_REFLOW_ADAPTER (e_addressbook_reflow_adapter_get_type ()) -#define E_ADDRESSBOOK_REFLOW_ADAPTER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), E_TYPE_ADDRESSBOOK_REFLOW_ADAPTER, EAddressbookReflowAdapter)) -#define E_ADDRESSBOOK_REFLOW_ADAPTER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), E_TYPE_ADDRESSBOOK_REFLOW_ADAPTER, EAddressbookReflowAdapterClass)) -#define E_IS_ADDRESSBOOK_REFLOW_ADAPTER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), E_TYPE_ADDRESSBOOK_REFLOW_ADAPTER)) -#define E_IS_ADDRESSBOOK_REFLOW_ADAPTER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), E_TYPE_ADDRESSBOOK_REFLOW_ADAPTER)) - -typedef struct _EAddressbookReflowAdapter EAddressbookReflowAdapter; -typedef struct _EAddressbookReflowAdapterPrivate EAddressbookReflowAdapterPrivate; -typedef struct _EAddressbookReflowAdapterClass EAddressbookReflowAdapterClass; - -struct _EAddressbookReflowAdapter { - EReflowModel parent; - - EAddressbookReflowAdapterPrivate *priv; -}; - - -struct _EAddressbookReflowAdapterClass { - EReflowModelClass parent_class; - - /* - * Signals - */ - gint (* drag_begin) (EAddressbookReflowAdapter *adapter, GdkEvent *event); -}; - - -GType e_addressbook_reflow_adapter_get_type (void); -void e_addressbook_reflow_adapter_construct (EAddressbookReflowAdapter *adapter, - EABModel *model); -EReflowModel *e_addressbook_reflow_adapter_new (EABModel *model); - -/* Returns object with ref count of 1. */ -EContact *e_addressbook_reflow_adapter_get_contact (EAddressbookReflowAdapter *adapter, - int index); -#endif /* _E_ADDRESSBOOK_REFLOW_ADAPTER_H_ */ diff --git a/addressbook/gui/widgets/e-addressbook-table-adapter.c b/addressbook/gui/widgets/e-addressbook-table-adapter.c deleted file mode 100644 index c3fadfdf23..0000000000 --- a/addressbook/gui/widgets/e-addressbook-table-adapter.c +++ /dev/null @@ -1,347 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -#include <config.h> -#include "e-addressbook-model.h" -#include "e-addressbook-table-adapter.h" -#include "eab-contact-merging.h" -#include "eab-gui-util.h" -#include <libxml/tree.h> -#include <libxml/parser.h> -#include <libxml/xmlmemory.h> -#include <gnome.h> - -struct _EAddressbookTableAdapterPrivate { - EABModel *model; - - int create_contact_id, remove_contact_id, modify_contact_id, model_changed_id; -}; - -#define PARENT_TYPE e_table_model_get_type() -static ETableModelClass *parent_class; - -#define COLS (E_CONTACT_FIELD_LAST) - -static void -unlink_model(EAddressbookTableAdapter *adapter) -{ - EAddressbookTableAdapterPrivate *priv = adapter->priv; - - g_signal_handler_disconnect (priv->model, - priv->create_contact_id); - g_signal_handler_disconnect (priv->model, - priv->remove_contact_id); - g_signal_handler_disconnect (priv->model, - priv->modify_contact_id); - g_signal_handler_disconnect (priv->model, - priv->model_changed_id); - - priv->create_contact_id = 0; - priv->remove_contact_id = 0; - priv->modify_contact_id = 0; - priv->model_changed_id = 0; - - g_object_unref (priv->model); - - priv->model = NULL; -} - -static void -addressbook_dispose(GObject *object) -{ - EAddressbookTableAdapter *adapter = EAB_TABLE_ADAPTER(object); - - if (adapter->priv) { - unlink_model(adapter); - - g_free (adapter->priv); - adapter->priv = NULL; - } - - if (G_OBJECT_CLASS (parent_class)->dispose) - (* G_OBJECT_CLASS (parent_class)->dispose) (object); -} - -/* This function returns the number of columns in our ETableModel. */ -static int -addressbook_col_count (ETableModel *etc) -{ - return COLS; -} - -/* This function returns the number of rows in our ETableModel. */ -static int -addressbook_row_count (ETableModel *etc) -{ - EAddressbookTableAdapter *adapter = EAB_TABLE_ADAPTER(etc); - EAddressbookTableAdapterPrivate *priv = adapter->priv; - - return eab_model_contact_count (priv->model); -} - -/* This function returns the value at a particular point in our ETableModel. */ -static void * -addressbook_value_at (ETableModel *etc, int col, int row) -{ - EAddressbookTableAdapter *adapter = EAB_TABLE_ADAPTER(etc); - EAddressbookTableAdapterPrivate *priv = adapter->priv; - const char *value; - - if ( col >= COLS || row >= eab_model_contact_count (priv->model) ) - return NULL; - - value = e_contact_get_const((EContact*)eab_model_contact_at (priv->model, row), col); - - return (void *)(value ? value : ""); -} - -/* This function sets the value at a particular point in our ETableModel. */ -static void -contact_modified_cb (EBook* book, EBookStatus status, - gpointer user_data) -{ - if (status != E_BOOK_ERROR_OK) - eab_error_dialog (_("Error modifying card"), status); -} - -static void -addressbook_set_value_at (ETableModel *etc, int col, int row, const void *val) -{ - EAddressbookTableAdapter *adapter = EAB_TABLE_ADAPTER(etc); - EAddressbookTableAdapterPrivate *priv = adapter->priv; - - if (eab_model_editable (priv->model)) { - EContact *contact; - - if (col >= COLS || row >= eab_model_contact_count (priv->model)) - return; - - contact = eab_model_get_contact (priv->model, row); - if (!contact) - return; - - e_table_model_pre_change(etc); - - e_contact_set(contact, col, (void *) val); - eab_merging_book_commit_contact (eab_model_get_ebook (priv->model), - contact, contact_modified_cb, NULL); - - g_object_unref (contact); - - /* XXX do we need this? shouldn't the commit_contact generate a changed signal? */ - e_table_model_cell_changed(etc, col, row); - } -} - -/* This function returns whether a particular cell is editable. */ -static gboolean -addressbook_is_cell_editable (ETableModel *etc, int col, int row) -{ -#if 0 - EAddressbookTableAdapter *adapter = EAB_TABLE_ADAPTER(etc); - EAddressbookTableAdapterPrivate *priv = adapter->priv; - const EContact *contact; - - if (row >= 0 && row < eab_model_contact_count (priv->model)) - contact = eab_model_contact_at (priv->model, row); - else - contact = NULL; - - if (!eab_model_editable(priv->model)) - return FALSE; - else if (contact && e_contact_get ((EContact *) contact, E_CONTACT_IS_LIST)) - /* we only allow editing of the name and file as for - lists */ - return col == E_CONTACT_FULL_NAME || col == E_CONTACT_FILE_AS; - else - return col < E_CONTACT_LAST_SIMPLE_STRING; -#endif - - return FALSE; -} - -static void -addressbook_append_row (ETableModel *etm, ETableModel *source, gint row) -{ - EAddressbookTableAdapter *adapter = EAB_TABLE_ADAPTER(etm); - EAddressbookTableAdapterPrivate *priv = adapter->priv; - EContact *contact; - int col; - - contact = e_contact_new (); - - for (col = 1; col < E_CONTACT_LAST_SIMPLE_STRING; col++) { - const void *val = e_table_model_value_at (source, col, row); - e_contact_set (contact, col, (void *) val); - } - - eab_merging_book_add_contact (eab_model_get_ebook (priv->model), contact, NULL, NULL); - - g_object_unref (contact); -} - -/* This function duplicates the value passed to it. */ -static void * -addressbook_duplicate_value (ETableModel *etc, int col, const void *value) -{ - return g_strdup(value); -} - -/* This function frees the value passed to it. */ -static void -addressbook_free_value (ETableModel *etc, int col, void *value) -{ - g_free(value); -} - -static void * -addressbook_initialize_value (ETableModel *etc, int col) -{ - return g_strdup(""); -} - -static gboolean -addressbook_value_is_empty (ETableModel *etc, int col, const void *value) -{ - return !(value && *(char *)value); -} - -static char * -addressbook_value_to_string (ETableModel *etc, int col, const void *value) -{ - return g_strdup(value); -} - -static void -eab_table_adapter_class_init (GObjectClass *object_class) -{ - ETableModelClass *model_class = (ETableModelClass *) object_class; - - parent_class = g_type_class_peek_parent (object_class); - - object_class->dispose = addressbook_dispose; - - model_class->column_count = addressbook_col_count; - model_class->row_count = addressbook_row_count; - model_class->value_at = addressbook_value_at; - model_class->set_value_at = addressbook_set_value_at; - model_class->is_cell_editable = addressbook_is_cell_editable; - model_class->append_row = addressbook_append_row; - model_class->duplicate_value = addressbook_duplicate_value; - model_class->free_value = addressbook_free_value; - model_class->initialize_value = addressbook_initialize_value; - model_class->value_is_empty = addressbook_value_is_empty; - model_class->value_to_string = addressbook_value_to_string; -} - -static void -eab_table_adapter_init (GObject *object) -{ - EAddressbookTableAdapter *adapter = EAB_TABLE_ADAPTER(object); - EAddressbookTableAdapterPrivate *priv; - - priv = adapter->priv = g_new0 (EAddressbookTableAdapterPrivate, 1); - - priv->create_contact_id = 0; - priv->remove_contact_id = 0; - priv->modify_contact_id = 0; - priv->model_changed_id = 0; -} - - -static void -create_contact (EABModel *model, - gint index, gint count, - EAddressbookTableAdapter *adapter) -{ - e_table_model_pre_change (E_TABLE_MODEL (adapter)); - e_table_model_rows_inserted (E_TABLE_MODEL (adapter), index, count); -} - -static void -remove_contact (EABModel *model, - gint index, - EAddressbookTableAdapter *adapter) -{ - e_table_model_pre_change (E_TABLE_MODEL (adapter)); - e_table_model_rows_deleted (E_TABLE_MODEL (adapter), index, 1); -} - -static void -modify_contact (EABModel *model, - gint index, - EAddressbookTableAdapter *adapter) -{ - e_table_model_pre_change (E_TABLE_MODEL (adapter)); - e_table_model_row_changed (E_TABLE_MODEL (adapter), index); -} - -static void -model_changed (EABModel *model, - EAddressbookTableAdapter *adapter) -{ - e_table_model_pre_change (E_TABLE_MODEL (adapter)); - e_table_model_changed (E_TABLE_MODEL (adapter)); -} - -GType -eab_table_adapter_get_type (void) -{ - static GType type = 0; - - if (!type) { - static const GTypeInfo info = { - sizeof (EAddressbookTableAdapterClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) eab_table_adapter_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (EAddressbookTableAdapter), - 0, /* n_preallocs */ - (GInstanceInitFunc) eab_table_adapter_init, - }; - - type = g_type_register_static (PARENT_TYPE, "EAddressbookTableAdapter", &info, 0); - } - - return type; -} - -void -eab_table_adapter_construct (EAddressbookTableAdapter *adapter, - EABModel *model) -{ - EAddressbookTableAdapterPrivate *priv = adapter->priv; - - priv->model = model; - g_object_ref (priv->model); - - priv->create_contact_id = g_signal_connect(priv->model, - "contact_added", - G_CALLBACK(create_contact), - adapter); - priv->remove_contact_id = g_signal_connect(priv->model, - "contact_removed", - G_CALLBACK(remove_contact), - adapter); - priv->modify_contact_id = g_signal_connect(priv->model, - "contact_changed", - G_CALLBACK(modify_contact), - adapter); - priv->model_changed_id = g_signal_connect(priv->model, - "model_changed", - G_CALLBACK(model_changed), - adapter); -} - -ETableModel * -eab_table_adapter_new (EABModel *model) -{ - EAddressbookTableAdapter *et; - - et = g_object_new(E_TYPE_AB_TABLE_ADAPTER, NULL); - - eab_table_adapter_construct (et, model); - - return E_TABLE_MODEL(et); -} diff --git a/addressbook/gui/widgets/e-addressbook-table-adapter.h b/addressbook/gui/widgets/e-addressbook-table-adapter.h deleted file mode 100644 index cf139e2bee..0000000000 --- a/addressbook/gui/widgets/e-addressbook-table-adapter.h +++ /dev/null @@ -1,36 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -#ifndef _EAB_TABLE_ADAPTER_H_ -#define _EAB_TABLE_ADAPTER_H_ - -#include <gal/e-table/e-table-model.h> -#include <libebook/e-book.h> -#include <libebook/e-book-view.h> - -#define E_TYPE_AB_TABLE_ADAPTER (eab_table_adapter_get_type ()) -#define EAB_TABLE_ADAPTER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), E_TYPE_AB_TABLE_ADAPTER, EAddressbookTableAdapter)) -#define EAB_TABLE_ADAPTER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), E_TYPE_AB_TABLE_ADAPTER, EAddressbookTableAdapterClass)) -#define E_IS_ADDRESSBOOK_TABLE_ADAPTER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), E_TYPE_AB_TABLE_ADAPTER)) -#define E_IS_ADDRESSBOOK_TABLE_ADAPTER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), E_TYPE_AB_TABLE_ADAPTER)) - -typedef struct _EAddressbookTableAdapter EAddressbookTableAdapter; -typedef struct _EAddressbookTableAdapterPrivate EAddressbookTableAdapterPrivate; -typedef struct _EAddressbookTableAdapterClass EAddressbookTableAdapterClass; - -struct _EAddressbookTableAdapter { - ETableModel parent; - - EAddressbookTableAdapterPrivate *priv; -}; - - -struct _EAddressbookTableAdapterClass { - ETableModelClass parent_class; -}; - - -GType eab_table_adapter_get_type (void); -void eab_table_adapter_construct (EAddressbookTableAdapter *adapter, - EABModel *model); -ETableModel *eab_table_adapter_new (EABModel *model); - -#endif /* _EAB_TABLE_ADAPTER_H_ */ diff --git a/addressbook/gui/widgets/e-addressbook-treeview-adapter.c b/addressbook/gui/widgets/e-addressbook-treeview-adapter.c deleted file mode 100644 index 2d0c4b8c93..0000000000 --- a/addressbook/gui/widgets/e-addressbook-treeview-adapter.c +++ /dev/null @@ -1,621 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -#include <config.h> -#include "e-addressbook-model.h" -#include "e-addressbook-treeview-adapter.h" -#include "e-card-merging.h" -#include "eab-gui-util.h" -#include <gtk/gtktreednd.h> -#include <libxml/tree.h> -#include <libxml/parser.h> -#include <libxml/xmlmemory.h> - -struct _EAddressbookTreeViewAdapterPrivate { - EAddressbookModel *model; - - gint stamp; - - ECardSimple **simples; - int count; - - int create_card_id, remove_card_id, modify_card_id, model_changed_id; -}; - -#define PARENT_TYPE G_TYPE_OBJECT -GObjectClass *parent_class; - -#define COLS (E_CARD_SIMPLE_FIELD_LAST) - -static void -unlink_model(EAddressbookTreeViewAdapter *adapter) -{ - EAddressbookTreeViewAdapterPrivate *priv = adapter->priv; - int i; - - g_signal_handler_disconnect (priv->model, - priv->create_card_id); - g_signal_handler_disconnect (priv->model, - priv->remove_card_id); - g_signal_handler_disconnect (priv->model, - priv->modify_card_id); - g_signal_handler_disconnect (priv->model, - priv->model_changed_id); - - priv->create_card_id = 0; - priv->remove_card_id = 0; - priv->modify_card_id = 0; - priv->model_changed_id = 0; - - /* free up the existing mapping if there is one */ - if (priv->simples) { - for (i = 0; i < priv->count; i ++) - g_object_unref (priv->simples[i]); - g_free (priv->simples); - priv->simples = NULL; - } - - g_object_unref (priv->model); - - priv->model = NULL; -} - -static void -build_simple_mapping(EAddressbookTreeViewAdapter *adapter) -{ - EAddressbookTreeViewAdapterPrivate *priv = adapter->priv; - int i; - - /* free up the existing mapping if there is one */ - if (priv->simples) { - for (i = 0; i < priv->count; i ++) - g_object_unref (priv->simples[i]); - g_free (priv->simples); - } - - /* build up our mapping to ECardSimple*'s */ - priv->count = e_addressbook_model_card_count (priv->model); - priv->simples = g_new (ECardSimple*, priv->count); - for (i = 0; i < priv->count; i ++) { - priv->simples[i] = e_card_simple_new (e_addressbook_model_card_at (priv->model, i)); - g_object_ref (priv->simples[i]); - } -} - -static void -addressbook_destroy(GtkObject *object) -{ - EAddressbookTreeViewAdapter *adapter = E_ADDRESSBOOK_TREEVIEW_ADAPTER(object); - - unlink_model(adapter); - - g_free (adapter->priv); - adapter->priv = NULL; - - (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); -} - -#if 0 -static void -addressbook_set_value_at (ETableModel *etc, int col, int row, const void *val) -{ - EAddressbookTreeViewAdapter *adapter = E_ADDRESSBOOK_TABLE_ADAPTER(etc); - EAddressbookTableAdapterPrivate *priv = adapter->priv; - if (e_addressbook_model_editable (priv->model)) { - ECard *card; - - if ( col >= COLS|| row >= e_addressbook_model_card_count (priv->model) ) - return; - - e_table_model_pre_change(etc); - - e_card_simple_set(priv->simples[row], - col, - val); - g_object_get(priv->simples[row], - "card", &card, - NULL); - - e_card_merging_book_commit_card(e_addressbook_model_get_ebook(priv->model), - card, card_modified_cb, NULL); - - /* XXX do we need this? shouldn't the commit_card generate a changed signal? */ - e_table_model_cell_changed(etc, col, row); - } -} - -/* This function returns whether a particular cell is editable. */ -static gboolean -addressbook_is_cell_editable (ETableModel *etc, int col, int row) -{ - EAddressbookTableAdapter *adapter = E_ADDRESSBOOK_TABLE_ADAPTER(etc); - EAddressbookTableAdapterPrivate *priv = adapter->priv; - ECard *card; - - if (row >= 0 && row < e_addressbook_model_card_count (priv->model)) - card = e_addressbook_model_card_at (priv->model, row); - else - card = NULL; - - if (!e_addressbook_model_editable(priv->model)) - return FALSE; - else if (card && e_card_evolution_list (card)) - /* we only allow editing of the name and file as for - lists */ - return col == E_CARD_SIMPLE_FIELD_FULL_NAME || col == E_CARD_SIMPLE_FIELD_FILE_AS; - else - return col < E_CARD_SIMPLE_FIELD_LAST_SIMPLE_STRING; -} - -static void -addressbook_append_row (ETableModel *etm, ETableModel *source, gint row) -{ - EAddressbookTableAdapter *adapter = E_ADDRESSBOOK_TABLE_ADAPTER(etm); - EAddressbookTableAdapterPrivate *priv = adapter->priv; - ECard *card; - ECardSimple *simple; - int col; - - card = e_card_new(""); - simple = e_card_simple_new(card); - - for (col = 0; col < E_CARD_SIMPLE_FIELD_LAST_SIMPLE_STRING; col++) { - const void *val = e_table_model_value_at(source, col, row); - e_card_simple_set(simple, col, val); - } - e_card_simple_sync_card(simple); - e_card_merging_book_add_card (e_addressbook_model_get_ebook (priv->model), card, NULL, NULL); - g_object_unref (simple); - g_object_unref (card); -} -#endif - -static void -e_addressbook_treeview_adapter_class_init (GtkObjectClass *object_class) -{ - parent_class = g_type_class_peek_parent (object_class); - - object_class->destroy = addressbook_destroy; -} - -static void -e_addressbook_treeview_adapter_init (GtkObject *object) -{ - EAddressbookTreeViewAdapter *adapter = E_ADDRESSBOOK_TREEVIEW_ADAPTER(object); - EAddressbookTreeViewAdapterPrivate *priv; - - priv = adapter->priv = g_new0 (EAddressbookTreeViewAdapterPrivate, 1); - - priv->create_card_id = 0; - priv->remove_card_id = 0; - priv->modify_card_id = 0; - priv->model_changed_id = 0; - priv->simples = NULL; - priv->count = 0; -} - -static void -get_iter (EAddressbookTreeViewAdapter *adapter, gint index, GtkTreeIter *iter) -{ - EAddressbookTreeViewAdapterPrivate *priv = adapter->priv; - - iter->stamp = priv->stamp; - iter->user_data = GINT_TO_POINTER (index); -} - -static void -create_card (EAddressbookModel *model, - gint index, gint count, - EAddressbookTreeViewAdapter *adapter) -{ - EAddressbookTreeViewAdapterPrivate *priv = adapter->priv; - int i; - - priv->count += count; - priv->simples = g_renew(ECardSimple *, priv->simples, priv->count); - memmove (priv->simples + index + count, priv->simples + index, (priv->count - index - count) * sizeof (ECardSimple *)); - - for (i = 0; i < count; i ++) { - GtkTreeIter iter; - GtkTreePath *path; - - priv->simples[index + i] = e_card_simple_new (e_addressbook_model_card_at (priv->model, index + i)); - - get_iter (adapter, index + i, &iter); - path = gtk_tree_model_get_path (GTK_TREE_MODEL (adapter), &iter); - - gtk_tree_model_row_inserted (GTK_TREE_MODEL (adapter), path, &iter); - gtk_tree_model_row_changed (GTK_TREE_MODEL (adapter), path, &iter); - - gtk_tree_path_free (path); - } -} - -static void -remove_card (EAddressbookModel *model, - gint index, - EAddressbookTreeViewAdapter *adapter) -{ - EAddressbookTreeViewAdapterPrivate *priv = adapter->priv; - GtkTreeIter iter; - GtkTreePath *path; - - g_object_unref (priv->simples[index]); - memmove (priv->simples + index, priv->simples + index + 1, (priv->count - index - 1) * sizeof (ECardSimple *)); - priv->count --; - get_iter (adapter, index, &iter); - path = gtk_tree_model_get_path (GTK_TREE_MODEL (adapter), &iter); - - gtk_tree_model_row_deleted (GTK_TREE_MODEL (adapter), path); - - gtk_tree_path_free (path); -} - -static void -modify_card (EAddressbookModel *model, - gint index, - EAddressbookTreeViewAdapter *adapter) -{ - EAddressbookTreeViewAdapterPrivate *priv = adapter->priv; - GtkTreeIter iter; - GtkTreePath *path; - - g_object_unref (priv->simples[index]); - priv->simples[index] = e_card_simple_new (e_addressbook_model_card_at (priv->model, index)); - - get_iter (adapter, index, &iter); - path = gtk_tree_model_get_path (GTK_TREE_MODEL (adapter), &iter); - - gtk_tree_model_row_changed (GTK_TREE_MODEL (adapter), path, &iter); - - gtk_tree_path_free (path); -} - -static void -model_changed (EAddressbookModel *model, - EAddressbookTreeViewAdapter *adapter) -{ - int i; - - /* there has *got* to be an easier/faster way to do this... */ - for (i = 0; i < adapter->priv->count; i++) { - remove_card (model, i, adapter); - } - - build_simple_mapping (adapter); - - if (adapter->priv->count) { - printf ("AIIEEEEEE\n"); - } - - /* XXX this isn't right either, we need to add the new cards */ -} - -static GtkTreeModelFlags -adapter_get_flags (GtkTreeModel *tree_model) -{ - g_return_val_if_fail (E_IS_ADDRESSBOOK_TREEVIEW_ADAPTER (tree_model), 0); - - return GTK_TREE_MODEL_LIST_ONLY; -} - -static gint -adapter_get_n_columns (GtkTreeModel *tree_model) -{ - g_return_val_if_fail (E_IS_ADDRESSBOOK_TREEVIEW_ADAPTER (tree_model), 0); - - return COLS; -} - -static GType -adapter_get_column_type (GtkTreeModel *tree_model, - gint index) -{ - g_return_val_if_fail (E_IS_ADDRESSBOOK_TREEVIEW_ADAPTER (tree_model), G_TYPE_INVALID); - g_return_val_if_fail (index < COLS && index >= 0, G_TYPE_INVALID); - - return G_TYPE_STRING; -} - -static gboolean -adapter_get_iter (GtkTreeModel *tree_model, - GtkTreeIter *iter, - GtkTreePath *path) -{ - EAddressbookTreeViewAdapter *adapter; - GSList *list; - gint i; - - g_return_val_if_fail (E_IS_ADDRESSBOOK_TREEVIEW_ADAPTER (tree_model), FALSE); - g_return_val_if_fail (gtk_tree_path_get_depth (path) > 0, FALSE); - - adapter = E_ADDRESSBOOK_TREEVIEW_ADAPTER (tree_model); - - i = gtk_tree_path_get_indices (path)[0]; - - if (i >= adapter->priv->count) - return FALSE; - - iter->stamp = adapter->priv->stamp; - iter->user_data = GINT_TO_POINTER (i); - - return TRUE; -} - -static GtkTreePath * -adapter_get_path (GtkTreeModel *tree_model, - GtkTreeIter *iter) -{ - EAddressbookTreeViewAdapter *adapter = E_ADDRESSBOOK_TREEVIEW_ADAPTER (tree_model); - GtkTreePath *retval; - - g_return_val_if_fail (E_IS_ADDRESSBOOK_TREEVIEW_ADAPTER (tree_model), NULL); - g_return_val_if_fail (iter->stamp == adapter->priv->stamp, NULL); - - - if (GPOINTER_TO_INT (iter->user_data) >= adapter->priv->count) - return NULL; - - retval = gtk_tree_path_new (); - gtk_tree_path_append_index (retval, GPOINTER_TO_INT (iter->user_data)); - return retval; -} - -static void -adapter_get_value (GtkTreeModel *tree_model, - GtkTreeIter *iter, - gint column, - GValue *value) -{ - EAddressbookTreeViewAdapter *adapter = E_ADDRESSBOOK_TREEVIEW_ADAPTER (tree_model); - ECardSimple *simple; - gint tmp_column = column; - const char *v; - - g_return_if_fail (E_IS_ADDRESSBOOK_TREEVIEW_ADAPTER (tree_model)); - g_return_if_fail (column < COLS); - g_return_if_fail (adapter->priv->stamp == iter->stamp); - - simple = adapter->priv->simples [ GPOINTER_TO_INT (iter->user_data) ]; - - v = e_card_simple_get_const(simple, column); - - g_value_init (value, G_TYPE_STRING); - g_value_set_string (value, (v ? v : "")); -} - -static gboolean -adapter_iter_next (GtkTreeModel *tree_model, - GtkTreeIter *iter) -{ - EAddressbookTreeViewAdapter *adapter; - - g_return_val_if_fail (E_IS_ADDRESSBOOK_TREEVIEW_ADAPTER (tree_model), FALSE); - g_return_val_if_fail (E_ADDRESSBOOK_TREEVIEW_ADAPTER (tree_model)->priv->stamp == iter->stamp, FALSE); - - adapter = E_ADDRESSBOOK_TREEVIEW_ADAPTER (tree_model); - - iter->user_data = GINT_TO_POINTER (GPOINTER_TO_INT (iter->user_data) + 1); - - return (GPOINTER_TO_INT (iter->user_data) < adapter->priv->count); -} - -static gboolean -adapter_iter_children (GtkTreeModel *tree_model, - GtkTreeIter *iter, - GtkTreeIter *parent) -{ - EAddressbookTreeViewAdapter *adapter = E_ADDRESSBOOK_TREEVIEW_ADAPTER (tree_model); - - /* this is a list, nodes have no children */ - if (parent) - return FALSE; - - /* but if parent == NULL we return the list itself as children of the - * "root" - */ - if (adapter->priv->count) { - iter->stamp = adapter->priv->stamp; - iter->user_data = GINT_TO_POINTER (0); - return TRUE; - } - else - return FALSE; -} - -static gboolean -adapter_iter_has_child (GtkTreeModel *tree_model, - GtkTreeIter *iter) -{ - return FALSE; -} - -static gint -adapter_iter_n_children (GtkTreeModel *tree_model, - GtkTreeIter *iter) -{ - EAddressbookTreeViewAdapter *adapter = E_ADDRESSBOOK_TREEVIEW_ADAPTER (tree_model); - - g_return_val_if_fail (E_IS_ADDRESSBOOK_TREEVIEW_ADAPTER (tree_model), -1); - if (iter == NULL) - return adapter->priv->count; - - g_return_val_if_fail (adapter->priv->stamp == iter->stamp, -1); - return 0; -} - -static gboolean -adapter_iter_nth_child (GtkTreeModel *tree_model, - GtkTreeIter *iter, - GtkTreeIter *parent, - gint n) -{ - EAddressbookTreeViewAdapter *adapter = E_ADDRESSBOOK_TREEVIEW_ADAPTER (tree_model); - - g_return_val_if_fail (E_IS_ADDRESSBOOK_TREEVIEW_ADAPTER (tree_model), FALSE); - - if (parent) - return FALSE; - - if (n < adapter->priv->count) { - iter->stamp = adapter->priv->stamp; - iter->user_data = GINT_TO_POINTER (n); - return TRUE; - } - else - return FALSE; -} - -static gboolean -adapter_iter_parent (GtkTreeModel *tree_model, - GtkTreeIter *iter, - GtkTreeIter *child) -{ - return FALSE; -} - -static void -adapter_tree_model_init (GtkTreeModelIface *iface) -{ - iface->get_flags = adapter_get_flags; - iface->get_n_columns = adapter_get_n_columns; - iface->get_column_type = adapter_get_column_type; - iface->get_iter = adapter_get_iter; - iface->get_path = adapter_get_path; - iface->get_value = adapter_get_value; - iface->iter_next = adapter_iter_next; - iface->iter_children = adapter_iter_children; - iface->iter_has_child = adapter_iter_has_child; - iface->iter_n_children = adapter_iter_n_children; - iface->iter_nth_child = adapter_iter_nth_child; - iface->iter_parent = adapter_iter_parent; -} - -static gboolean -adapter_drag_data_delete (GtkTreeDragSource *drag_source, - GtkTreePath *path) -{ - g_return_val_if_fail (E_IS_ADDRESSBOOK_TREEVIEW_ADAPTER (drag_source), FALSE); - - return FALSE; -} - -static gboolean -adapter_drag_data_get (GtkTreeDragSource *drag_source, - GtkTreePath *path, - GtkSelectionData *selection_data) -{ - g_return_val_if_fail (E_IS_ADDRESSBOOK_TREEVIEW_ADAPTER (drag_source), FALSE); - - /* Note that we don't need to handle the GTK_TREE_MODEL_ROW - * target, because the default handler does it for us, but - * we do anyway for the convenience of someone maybe overriding the - * default handler. - */ - - if (gtk_tree_set_row_drag_data (selection_data, - GTK_TREE_MODEL (drag_source), - path)) { - return TRUE; - } - else { - if (selection_data->target == gdk_atom_intern ("text/x-vcard", FALSE)) { - printf ("HI THERE\n"); - } - } - - return FALSE; -} - -static void -adapter_drag_source_init (GtkTreeDragSourceIface *iface) -{ - iface->drag_data_delete = adapter_drag_data_delete; - iface->drag_data_get = adapter_drag_data_get; -} - -GType -e_addressbook_treeview_adapter_get_type (void) -{ - static GType type = 0; - - if (!type) { - static const GTypeInfo adapter_info = { - sizeof (EAddressbookTreeViewAdapterClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) e_addressbook_treeview_adapter_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (EAddressbookTreeViewAdapter), - 0, /* n_preallocs */ - (GInstanceInitFunc) e_addressbook_treeview_adapter_init, - }; - - static const GInterfaceInfo tree_model_info = { - (GInterfaceInitFunc) adapter_tree_model_init, - NULL, - NULL - }; - - static const GInterfaceInfo drag_source_info = { - (GInterfaceInitFunc) adapter_drag_source_init, - NULL, - NULL - }; - - type = g_type_register_static (PARENT_TYPE, "EAddressbookTreeViewAdapter", &adapter_info, 0); - - g_type_add_interface_static (type, - GTK_TYPE_TREE_MODEL, - &tree_model_info); - - g_type_add_interface_static (type, - GTK_TYPE_TREE_DRAG_SOURCE, - &drag_source_info); - } - - return type; -} - -void -e_addressbook_treeview_adapter_construct (EAddressbookTreeViewAdapter *adapter, - EAddressbookModel *model) -{ - EAddressbookTreeViewAdapterPrivate *priv = adapter->priv; - - priv->model = model; - g_object_ref (priv->model); - - priv->stamp = g_random_int (); - - priv->create_card_id = g_signal_connect(priv->model, - "card_added", - G_CALLBACK(create_card), - adapter); - priv->remove_card_id = g_signal_connect(priv->model, - "card_removed", - G_CALLBACK(remove_card), - adapter); - priv->modify_card_id = g_signal_connect(priv->model, - "card_changed", - G_CALLBACK(modify_card), - adapter); - priv->model_changed_id = g_signal_connect(priv->model, - "model_changed", - G_CALLBACK(model_changed), - adapter); - - build_simple_mapping (adapter); -} - -GtkTreeModel * -e_addressbook_treeview_adapter_new (EAddressbookModel *model) -{ - EAddressbookTreeViewAdapter *et; - - et = g_object_new(E_TYPE_ADDRESSBOOK_TREEVIEW_ADAPTER, NULL); - - e_addressbook_treeview_adapter_construct (et, model); - - return (GtkTreeModel*)et; -} diff --git a/addressbook/gui/widgets/e-addressbook-treeview-adapter.h b/addressbook/gui/widgets/e-addressbook-treeview-adapter.h deleted file mode 100644 index 2c4370dee3..0000000000 --- a/addressbook/gui/widgets/e-addressbook-treeview-adapter.h +++ /dev/null @@ -1,44 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -#ifndef _E_ADDRESSBOOK_TREEVIEW_ADAPTER_H_ -#define _E_ADDRESSBOOK_TREEVIEW_ADAPTER_H_ - -#include <gtk/gtktreemodel.h> -#include "addressbook/backend/ebook/e-book.h" -#include "addressbook/backend/ebook/e-book-view.h" -#include "addressbook/backend/ebook/e-card-simple.h" - -#define E_TYPE_ADDRESSBOOK_TREEVIEW_ADAPTER (e_addressbook_treeview_adapter_get_type ()) -#define E_ADDRESSBOOK_TREEVIEW_ADAPTER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), E_TYPE_ADDRESSBOOK_TREEVIEW_ADAPTER, EAddressbookTreeViewAdapter)) -#define E_ADDRESSBOOK_TREEVIEW_ADAPTER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), E_TYPE_ADDRESSBOOK_TREEVIEW_ADAPTER, EAddressbookTreeViewAdapterClass)) -#define E_IS_ADDRESSBOOK_TREEVIEW_ADAPTER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), E_TYPE_ADDRESSBOOK_TREEVIEW_ADAPTER)) -#define E_IS_ADDRESSBOOK_TREEVIEW_ADAPTER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), E_TYPE_ADDRESSBOOK_TREEVIEW_ADAPTER)) - -/* Virtual Column list: - 0 Email - 1 Full Name - 2 Street - 3 Phone -*/ - -typedef struct _EAddressbookTreeViewAdapter EAddressbookTreeViewAdapter; -typedef struct _EAddressbookTreeViewAdapterPrivate EAddressbookTreeViewAdapterPrivate; -typedef struct _EAddressbookTreeViewAdapterClass EAddressbookTreeViewAdapterClass; - -struct _EAddressbookTreeViewAdapter { - GObject parent; - - EAddressbookTreeViewAdapterPrivate *priv; -}; - - -struct _EAddressbookTreeViewAdapterClass { - GObjectClass parent_class; -}; - - -GType e_addressbook_treeview_adapter_get_type (void); -void e_addressbook_treeview_adapter_construct (EAddressbookTreeViewAdapter *adapter, - EAddressbookModel *model); -GtkTreeModel *e_addressbook_treeview_adapter_new (EAddressbookModel *model); - -#endif /* _E_ADDRESSBOOK_TABLE_ADAPTER_H_ */ diff --git a/addressbook/gui/widgets/e-addressbook-view.c b/addressbook/gui/widgets/e-addressbook-view.c deleted file mode 100644 index 0d55297df1..0000000000 --- a/addressbook/gui/widgets/e-addressbook-view.c +++ /dev/null @@ -1,2196 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * e-addressbook-view.c - * Copyright (C) 2000 Ximian, Inc. - * Author: Chris Lahey <clahey@ximian.com> - * Chris Toshok <toshok@ximian.com> - * - * This library 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 library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include <config.h> - -#include <gtk/gtk.h> - -#include <libgnome/gnome-i18n.h> -#include <libgnome/gnome-util.h> -#include <gtk/gtkscrolledwindow.h> -#include <gal/e-table/e-table-scrolled.h> -#include <gal/e-table/e-table-model.h> -#include <gal/widgets/e-gui-utils.h> -#include <gal/menus/gal-view-factory-etable.h> -#include <gal/menus/gal-view-etable.h> -#include <gal/util/e-xml-utils.h> -#include <libgnomeui/gnome-dialog-util.h> - -#include <libgnomeprint/gnome-print.h> -#include <libgnomeprint/gnome-print-job.h> -#include <libgnomeprintui/gnome-print-dialog.h> -#include <libgnomeprintui/gnome-print-job-preview.h> - -#include "addressbook/printing/e-contact-print.h" -#include "addressbook/printing/e-contact-print-envelope.h" -#include "addressbook/gui/search/e-addressbook-search-dialog.h" -#include "addressbook/gui/widgets/eab-popup.h" -#include "addressbook/gui/widgets/eab-menu.h" - -#include "e-util/e-categories-master-list-wombat.h" -#include "e-util/e-sexp.h" - -#ifdef WITH_ADDRESSBOOK_VIEW_TREEVIEW -#include <gal/widgets/e-treeview-selection-model.h> -#include "gal-view-factory-treeview.h" -#include "gal-view-treeview.h" -#endif -#include "gal-view-minicard.h" -#include "gal-view-factory-minicard.h" - -#include "eab-marshal.h" -#include "e-addressbook-view.h" -#include "e-addressbook-model.h" -#include "eab-gui-util.h" -#include "util/eab-book-util.h" -#include "e-addressbook-table-adapter.h" -#ifdef WITH_ADDRESSBOOK_VIEW_TREEVIEW -#include "e-addressbook-treeview-adapter.h" -#endif -#include "eab-contact-merging.h" - -#include "widgets/misc/e-error.h" - -#include "e-contact-editor.h" -#include <gdk/gdkkeysyms.h> -#include <ctype.h> -#include <string.h> - -#include <libxml/tree.h> -#include <libxml/parser.h> - -#define SHOW_ALL_SEARCH "(contains \"x-evolution-any-field\" \"\")" - -#define d(x) - -static void eab_view_init (EABView *card); -static void eab_view_class_init (EABViewClass *klass); - -static void eab_view_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec); -static void eab_view_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); - -static void eab_view_dispose (GObject *object); -static void change_view_type (EABView *view, EABViewType view_type); - -static void status_message (GtkObject *object, const gchar *status, EABView *eav); -static void search_result (GtkObject *object, EBookViewStatus status, EABView *eav); -static void folder_bar_message (GtkObject *object, const gchar *status, EABView *eav); -static void stop_state_changed (GtkObject *object, EABView *eav); -static void writable_status (GtkObject *object, gboolean writable, EABView *eav); -static void backend_died (GtkObject *object, EABView *eav); -static void contact_changed (EABModel *model, gint index, EABView *eav); -static void contact_removed (EABModel *model, gint index, EABView *eav); -static GList *get_selected_contacts (EABView *view); - -static void command_state_change (EABView *eav); - -static void selection_clear_event (GtkWidget *invisible, GdkEventSelection *event, - EABView *view); -static void selection_received (GtkWidget *invisible, GtkSelectionData *selection_data, - guint time, EABView *view); -static void selection_get (GtkWidget *invisible, GtkSelectionData *selection_data, - guint info, guint time_stamp, EABView *view); -static void invisible_destroyed (gpointer data, GObject *where_object_was); - -static void make_suboptions (EABView *view); -static void query_changed (ESearchBar *esb, EABView *view); -static void search_activated (ESearchBar *esb, EABView *view); -static void search_menu_activated (ESearchBar *esb, int id, EABView *view); -static void connect_master_list_changed (EABView *view); -static ECategoriesMasterList *get_master_list (void); - -#define PARENT_TYPE GTK_TYPE_VBOX -static GtkVBoxClass *parent_class = NULL; - -/* The arguments we take */ -enum { - PROP_0, - PROP_BOOK, - PROP_SOURCE, - PROP_QUERY, - PROP_TYPE, -}; - -enum { - STATUS_MESSAGE, - SEARCH_RESULT, - FOLDER_BAR_MESSAGE, - COMMAND_STATE_CHANGE, - LAST_SIGNAL -}; - -enum DndTargetType { - DND_TARGET_TYPE_SOURCE_VCARD, - DND_TARGET_TYPE_VCARD -}; -#define VCARD_TYPE "text/x-vcard" -#define SOURCE_VCARD_TYPE "text/x-source-vcard" -static GtkTargetEntry drag_types[] = { - { SOURCE_VCARD_TYPE, 0, DND_TARGET_TYPE_SOURCE_VCARD }, - { VCARD_TYPE, 0, DND_TARGET_TYPE_VCARD } -}; -static const int num_drag_types = sizeof (drag_types) / sizeof (drag_types[0]); - -static guint eab_view_signals [LAST_SIGNAL] = {0, }; - -static GdkAtom clipboard_atom = GDK_NONE; - -static GalViewCollection *collection = NULL; - -enum { - ESB_FULL_NAME, - ESB_EMAIL, - ESB_CATEGORY, - ESB_ANY, - ESB_ADVANCED -}; - -static ESearchBarItem addressbook_search_option_items[] = { - { N_("Name begins with"), ESB_FULL_NAME, NULL }, - { N_("Email begins with"), ESB_EMAIL, NULL }, - { N_("Category is"), ESB_CATEGORY, NULL }, /* We attach subitems below */ - { N_("Any field contains"), ESB_ANY, NULL }, - { N_("Advanced..."), ESB_ADVANCED, NULL }, - { NULL, -1, NULL } -}; - -static ESearchBarItem addressbook_search_items[] = { - { N_("Advanced..."), ESB_ADVANCED, NULL }, - { NULL, -1, NULL }, -}; - -GType -eab_view_get_type (void) -{ - static GType type = 0; - - if (!type) { - static const GTypeInfo info = { - sizeof (EABViewClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) eab_view_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (EABView), - 0, /* n_preallocs */ - (GInstanceInitFunc) eab_view_init, - }; - - type = g_type_register_static (PARENT_TYPE, "EABView", &info, 0); - } - - return type; -} - -static void -eab_view_class_init (EABViewClass *klass) -{ - GObjectClass *object_class; - GtkWidgetClass *widget_class; - - object_class = G_OBJECT_CLASS(klass); - widget_class = GTK_WIDGET_CLASS(klass); - - parent_class = gtk_type_class (PARENT_TYPE); - - object_class->set_property = eab_view_set_property; - object_class->get_property = eab_view_get_property; - object_class->dispose = eab_view_dispose; - - g_object_class_install_property (object_class, PROP_BOOK, - g_param_spec_object ("book", - _("Book"), - /*_( */"XXX blurb" /*)*/, - E_TYPE_BOOK, - G_PARAM_READWRITE)); - - g_object_class_install_property (object_class, PROP_SOURCE, - g_param_spec_object ("source", - _("Source"), - /*_( */"XXX blurb" /*)*/, - E_TYPE_SOURCE, - G_PARAM_READWRITE)); - - g_object_class_install_property (object_class, PROP_QUERY, - g_param_spec_string ("query", - _("Query"), - /*_( */"XXX blurb" /*)*/, - NULL, - G_PARAM_READWRITE)); - - g_object_class_install_property (object_class, PROP_TYPE, - g_param_spec_int ("type", - _("Type"), - /*_( */"XXX blurb" /*)*/, - EAB_VIEW_NONE, - EAB_VIEW_TABLE, - EAB_VIEW_NONE, - G_PARAM_READWRITE)); - - eab_view_signals [STATUS_MESSAGE] = - g_signal_new ("status_message", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (EABViewClass, status_message), - NULL, NULL, - eab_marshal_NONE__POINTER, - G_TYPE_NONE, 1, G_TYPE_POINTER); - - eab_view_signals [SEARCH_RESULT] = - g_signal_new ("search_result", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (EABViewClass, search_result), - NULL, NULL, - eab_marshal_NONE__INT, - G_TYPE_NONE, 1, G_TYPE_INT); - - eab_view_signals [FOLDER_BAR_MESSAGE] = - g_signal_new ("folder_bar_message", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (EABViewClass, folder_bar_message), - NULL, NULL, - eab_marshal_NONE__POINTER, - G_TYPE_NONE, 1, G_TYPE_POINTER); - - eab_view_signals [COMMAND_STATE_CHANGE] = - g_signal_new ("command_state_change", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (EABViewClass, command_state_change), - NULL, NULL, - eab_marshal_NONE__NONE, - G_TYPE_NONE, 0); - - if (!clipboard_atom) - clipboard_atom = gdk_atom_intern ("CLIPBOARD", FALSE); - - /* init the accessibility support for e_addressbook_view */ - eab_view_a11y_init(); -} - -static void -eab_view_init (EABView *eav) -{ - eav->view_type = EAB_VIEW_NONE; - - eav->model = NULL; - eav->object = NULL; - eav->widget = NULL; - eav->contact_display_window = NULL; - eav->contact_display = NULL; - eav->displayed_contact = -1; - - eav->view_instance = NULL; - eav->view_menus = NULL; - eav->current_view = NULL; - eav->uic = NULL; - - eav->book = NULL; - eav->source = NULL; - eav->query = NULL; - - eav->invisible = NULL; - eav->clipboard_contacts = NULL; -} - -static void -eab_view_dispose (GObject *object) -{ - EABView *eav = EAB_VIEW(object); - - if (eav->model) { - g_signal_handlers_disconnect_matched (eav->model, - G_SIGNAL_MATCH_DATA, - 0, 0, NULL, NULL, - object); - g_object_unref (eav->model); - eav->model = NULL; - } - - if (eav->book) { - g_object_unref (eav->book); - eav->book = NULL; - } - - if (eav->source) { - g_object_unref (eav->source); - eav->source = NULL; - } - - if (eav->query) { - g_free(eav->query); - eav->query = NULL; - } - - eav->uic = NULL; - - if (eav->view_instance) { - g_object_unref (eav->view_instance); - eav->view_instance = NULL; - } - - if (eav->view_menus) { - g_object_unref (eav->view_menus); - eav->view_menus = NULL; - } - - if (eav->clipboard_contacts) { - g_list_foreach (eav->clipboard_contacts, (GFunc)g_object_unref, NULL); - g_list_free (eav->clipboard_contacts); - eav->clipboard_contacts = NULL; - } - - if (eav->invisible) { - gtk_widget_destroy (eav->invisible); - eav->invisible = NULL; - } - - if (eav->ecml_changed_id != 0) { - g_signal_handler_disconnect (get_master_list(), - eav->ecml_changed_id); - eav->ecml_changed_id = 0; - } - - if (G_OBJECT_CLASS(parent_class)->dispose) - G_OBJECT_CLASS(parent_class)->dispose(object); -} - -static void -set_paned_position (EABView *eav) -{ - GConfClient *gconf_client; - gint pos; - - /* XXX this should use the addressbook's global gconf client */ - gconf_client = gconf_client_get_default (); - pos = gconf_client_get_int (gconf_client, "/apps/evolution/addressbook/display/vpane_position", NULL); - if (pos < 1) - pos = 144; - - gtk_paned_set_position (GTK_PANED (eav->paned), pos); - - g_object_unref (gconf_client); -} - -static gboolean -get_paned_position (EABView *eav) -{ - GConfClient *gconf_client; - gint pos; - - /* XXX this should use the addressbook's global gconf client */ - gconf_client = gconf_client_get_default (); - - pos = gtk_paned_get_position (GTK_PANED (eav->paned)); - gconf_client_set_int (gconf_client, "/apps/evolution/addressbook/display/vpane_position", pos, NULL); - - g_object_unref (gconf_client); - - return FALSE; -} - -GtkWidget* -eab_view_new (void) -{ - GtkWidget *widget = GTK_WIDGET (g_object_new (E_TYPE_AB_VIEW, NULL)); - EABView *eav = EAB_VIEW (widget); - FilterPart *part; - - /* create our model */ - eav->model = eab_model_new (); - - g_signal_connect (eav->model, "status_message", - G_CALLBACK (status_message), eav); - g_signal_connect (eav->model, "search_result", - G_CALLBACK (search_result), eav); - g_signal_connect (eav->model, "folder_bar_message", - G_CALLBACK (folder_bar_message), eav); - g_signal_connect (eav->model, "stop_state_changed", - G_CALLBACK (stop_state_changed), eav); - g_signal_connect (eav->model, "writable_status", - G_CALLBACK (writable_status), eav); - g_signal_connect (eav->model, "backend_died", - G_CALLBACK (backend_died), eav); - g_signal_connect (eav->model, "contact_changed", - G_CALLBACK (contact_changed), eav); - g_signal_connect (eav->model, "contact_removed", - G_CALLBACK (contact_removed), eav); - - eav->editable = FALSE; - eav->query = g_strdup (SHOW_ALL_SEARCH); - - /* create our search bar */ - eav->search = E_SEARCH_BAR (e_search_bar_new (NULL, addressbook_search_option_items)); - e_search_bar_set_menu (eav->search, addressbook_search_items); - make_suboptions (eav); - connect_master_list_changed (eav); - g_signal_connect (eav->search, "query_changed", - G_CALLBACK (query_changed), eav); - g_signal_connect (eav->search, "search_activated", - G_CALLBACK (search_activated), eav); - g_signal_connect (eav->search, "menu_activated", - G_CALLBACK (search_menu_activated), eav); - gtk_box_pack_start (GTK_BOX (eav), GTK_WIDGET (eav->search), FALSE, FALSE, 0); - gtk_widget_show (GTK_WIDGET (eav->search)); - gtk_widget_set_sensitive (GTK_WIDGET (eav->search), FALSE); - - /* create the search context */ - eav->search_context = rule_context_new (); - rule_context_add_part_set (eav->search_context, "partset", filter_part_get_type (), - rule_context_add_part, rule_context_next_part); - rule_context_load (eav->search_context, SEARCH_RULE_DIR "/addresstypes.xml", ""); - - eav->search_rule = filter_rule_new (); - part = rule_context_next_part (eav->search_context, NULL); - - if (part == NULL) - g_warning ("Could not load addressbook search; no parts."); - else - filter_rule_add_part (eav->search_rule, filter_part_clone (part)); - - /* create the paned window and contact display */ - eav->paned = gtk_vpaned_new (); - gtk_box_pack_start (GTK_BOX (eav), eav->paned, TRUE, TRUE, 0); - g_signal_connect_swapped (eav->paned, "button_release_event", - G_CALLBACK (get_paned_position), eav); - - eav->contact_display = eab_contact_display_new (); - eav->contact_display_window = gtk_scrolled_window_new (NULL, NULL); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (eav->contact_display_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (eav->contact_display_window), GTK_SHADOW_IN); - gtk_container_add (GTK_CONTAINER (eav->contact_display_window), eav->contact_display); - gtk_paned_add2 (GTK_PANED (eav->paned), eav->contact_display_window); - gtk_widget_show (eav->contact_display); - gtk_widget_show (eav->contact_display_window); - gtk_widget_show (eav->paned); - - /* gtk selection crap */ - eav->invisible = gtk_invisible_new (); - - gtk_selection_add_target (eav->invisible, - clipboard_atom, - GDK_SELECTION_TYPE_STRING, - 0); - - g_signal_connect (eav->invisible, "selection_get", - G_CALLBACK (selection_get), - eav); - g_signal_connect (eav->invisible, "selection_clear_event", - G_CALLBACK (selection_clear_event), - eav); - g_signal_connect (eav->invisible, "selection_received", - G_CALLBACK (selection_received), - eav); - g_object_weak_ref (G_OBJECT (eav->invisible), invisible_destroyed, eav); - - return widget; -} - -RuleContext * -eab_view_peek_search_context (EABView *view) -{ - return view->search_context; -} - -FilterRule * -eab_view_peek_search_rule (EABView *view) -{ - return view->search_rule; -} - -static void -writable_status (GtkObject *object, gboolean writable, EABView *eav) -{ - eav->editable = writable; - command_state_change (eav); -} - -static void -init_collection (void) -{ - GalViewFactory *factory; - ETableSpecification *spec; - char *galview; - - if (collection == NULL) { - collection = gal_view_collection_new(); - - gal_view_collection_set_title (collection, _("Address Book")); - - galview = gnome_util_prepend_user_home("/.evolution/addressbook/views"); - gal_view_collection_set_storage_directories - (collection, - EVOLUTION_GALVIEWSDIR "/addressbook/", - galview); - g_free(galview); - - spec = e_table_specification_new(); - e_table_specification_load_from_file (spec, EVOLUTION_ETSPECDIR "/e-addressbook-view.etspec"); - - factory = gal_view_factory_etable_new (spec); - g_object_unref (spec); - gal_view_collection_add_factory (collection, factory); - g_object_unref (factory); - - factory = gal_view_factory_minicard_new(); - gal_view_collection_add_factory (collection, factory); - g_object_unref (factory); - -#ifdef WITH_ADDRESSBOOK_VIEW_TREEVIEW - factory = gal_view_factory_treeview_new (); - gal_view_collection_add_factory (collection, factory); - g_object_unref (factory); -#endif - - gal_view_collection_load(collection); - } -} - -static void -set_view_preview (EABView *view) -{ - /* XXX this should use the addressbook's global gconf client */ - GConfClient *gconf_client; - gboolean state; - - gconf_client = gconf_client_get_default(); - state = gconf_client_get_bool(gconf_client, "/apps/evolution/addressbook/display/show_preview", NULL); - bonobo_ui_component_set_prop (view->uic, - "/commands/ContactsViewPreview", - "state", - state ? "1" : "0", NULL); - - eab_view_show_contact_preview (view, state); - - g_object_unref (gconf_client); -} - -static void -display_view(GalViewInstance *instance, - GalView *view, - gpointer data) -{ - EABView *address_view = data; - if (GAL_IS_VIEW_ETABLE(view)) { - change_view_type (address_view, EAB_VIEW_TABLE); - gal_view_etable_attach_table (GAL_VIEW_ETABLE(view), e_table_scrolled_get_table(E_TABLE_SCROLLED(address_view->widget))); - } - else if (GAL_IS_VIEW_MINICARD(view)) { - change_view_type (address_view, EAB_VIEW_MINICARD); - gal_view_minicard_attach (GAL_VIEW_MINICARD (view), E_MINICARD_VIEW_WIDGET (address_view->object)); - } -#ifdef WITH_ADDRESSBOOK_VIEW_TREEVIEW - else if (GAL_IS_VIEW_TREEVIEW (view)) { - change_view_type (address_view, EAB_VIEW_TREEVIEW); - gal_view_treeview_attach (GAL_VIEW_TREEVIEW(view), GTK_TREE_VIEW (address_view->object)); - } -#endif - address_view->current_view = view; - - set_paned_position (address_view); - set_view_preview (address_view); -} - -static void -view_preview(BonoboUIComponent *uic, const char *path, Bonobo_UIComponent_EventType type, const char *state, void *data) -{ - /* XXX this should use the addressbook's global gconf client */ - GConfClient *gconf_client; - EABView *view = EAB_VIEW (data); - - if (type != Bonobo_UIComponent_STATE_CHANGED) - return; - - gconf_client = gconf_client_get_default(); - gconf_client_set_bool(gconf_client, "/apps/evolution/addressbook/display/show_preview", state[0] != '0', NULL); - - eab_view_show_contact_preview(view, state[0] != '0'); - - g_object_unref (gconf_client); -} - -static void -setup_menus (EABView *view) -{ - if (view->book && view->view_instance == NULL) { - init_collection (); - view->view_instance = gal_view_instance_new (collection, e_book_get_uri (view->book)); - } - - if (view->view_instance && view->uic) { - view->view_menus = gal_view_menus_new(view->view_instance); - gal_view_menus_apply(view->view_menus, view->uic, NULL); - - display_view (view->view_instance, gal_view_instance_get_current_view (view->view_instance), view); - - g_signal_connect(view->view_instance, "display_view", - G_CALLBACK (display_view), view); - } - - bonobo_ui_component_add_listener(view->uic, "ContactsViewPreview", view_preview, view); - - set_view_preview (view); -} - -static void -eab_view_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) -{ - EABView *eav = EAB_VIEW(object); - - switch (prop_id){ - case PROP_BOOK: - if (eav->book) { - g_object_unref (eav->book); - } - if (g_value_get_object (value)) { - eav->book = E_BOOK(g_value_get_object (value)); - g_object_ref (eav->book); - gtk_widget_set_sensitive (GTK_WIDGET (eav->search), TRUE); - } - else { - eav->book = NULL; - gtk_widget_set_sensitive (GTK_WIDGET (eav->search), FALSE); - } - - if (eav->view_instance) { - g_object_unref (eav->view_instance); - eav->view_instance = NULL; - } - - g_object_set(eav->model, - "book", eav->book, - NULL); - - setup_menus (eav); - - break; - case PROP_SOURCE: - if (eav->source) { - g_warning ("EABView at present does not support multiple writes on the \"source\" property."); - break; - } - else { - if (g_value_get_object (value)) { - eav->source = E_SOURCE(g_value_get_object (value)); - g_object_ref (eav->source); - } - else { - eav->source = NULL; - } - } - break; - case PROP_QUERY: -#if 0 /* This code will mess up ldap a bit. We need to think about the ramifications of this more. */ - if ((g_value_get_string (value) == NULL && !strcmp (eav->query, SHOW_ALL_SEARCH)) || - (g_value_get_string (value) != NULL && !strcmp (eav->query, g_value_get_string (value)))) - break; -#endif - g_free(eav->query); - eav->query = g_strdup(g_value_get_string (value)); - if (!eav->query) - eav->query = g_strdup (SHOW_ALL_SEARCH); - g_object_set(eav->model, - "query", eav->query, - NULL); - break; - case PROP_TYPE: - change_view_type(eav, g_value_get_int (value)); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -eab_view_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) -{ - EABView *eav = EAB_VIEW(object); - - switch (prop_id) { - case PROP_BOOK: - if (eav->book) - g_value_set_object (value, eav->book); - else - g_value_set_object (value, NULL); - break; - case PROP_SOURCE: - if (eav->source) - g_value_set_object (value, eav->source); - else - g_value_set_object (value, NULL); - break; - - case PROP_QUERY: - g_value_set_string (value, eav->query); - break; - case PROP_TYPE: - g_value_set_int (value, eav->view_type); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static ESelectionModel* -get_selection_model (EABView *view) -{ - if (view->view_type == EAB_VIEW_TABLE) - return e_table_get_selection_model (e_table_scrolled_get_table (E_TABLE_SCROLLED(view->widget))); - else if (view->view_type == EAB_VIEW_MINICARD) - return e_minicard_view_widget_get_selection_model (E_MINICARD_VIEW_WIDGET(view->object)); -#ifdef WITH_ADDRESSBOOK_VIEW_TREEVIEW - else if (view->view_type == EAB_VIEW_TREEVIEW) - return e_treeview_get_selection_model (GTK_TREE_VIEW (view->object)); -#endif - g_return_val_if_reached (NULL); -} - -/* Popup menu stuff */ -typedef struct { - EABView *view; - gpointer closure; -} ContactAndBook; - -static ESelectionModel* -contact_and_book_get_selection_model (ContactAndBook *contact_and_book) -{ - return get_selection_model (contact_and_book->view); -} - -static GList * -get_contact_list (EABPopupTargetSelect *t) -{ - GList *list = NULL; - int i; - - for (i=0;i<t->cards->len;i++) - list = g_list_prepend(list, t->cards->pdata[i]); - - return list; -} - -static void -save_as (EPopup *ep, EPopupItem *pitem, void *data) -{ - /*ContactAndBook *contact_and_book = data;*/ - GList *contacts = get_contact_list ((EABPopupTargetSelect *)ep->target); - - if (contacts) { - eab_contact_list_save(_("Save as VCard..."), contacts, NULL); - g_list_free(contacts); - } -} - -static void -send_as (EPopup *ep, EPopupItem *pitem, void *data) -{ - /*ContactAndBook *contact_and_book = data;*/ - GList *contacts = get_contact_list ((EABPopupTargetSelect *)ep->target); - - if (contacts) { - eab_send_contact_list(contacts, EAB_DISPOSITION_AS_ATTACHMENT); - g_list_free(contacts); - } -} - -static void -send_to (EPopup *ep, EPopupItem *pitem, void *data) -{ - /*ContactAndBook *contact_and_book = data;*/ - GList *contacts = get_contact_list ((EABPopupTargetSelect *)ep->target); - - if (contacts) { - eab_send_contact_list(contacts, EAB_DISPOSITION_AS_TO); - g_list_free(contacts); - } -} - -static void -print (EPopup *ep, EPopupItem *pitem, void *data) -{ - /*ContactAndBook *contact_and_book = data;*/ - EABPopupTargetSelect *t = (EABPopupTargetSelect *)ep->target; - - if (t->cards->len == 1) { - gtk_widget_show(e_contact_print_contact_dialog_new(t->cards->pdata[0])); - } else { - GList *contacts = get_contact_list(t); - - gtk_widget_show(e_contact_print_contact_list_dialog_new(contacts)); - g_list_free(contacts); - } -} - -static void -copy (EPopup *ep, EPopupItem *pitem, void *data) -{ - ContactAndBook *contact_and_book = data; - - eab_view_copy (contact_and_book->view); -} - -static void -paste (EPopup *ep, EPopupItem *pitem, void *data) -{ - ContactAndBook *contact_and_book = data; - - eab_view_paste (contact_and_book->view); -} - -static void -cut (EPopup *ep, EPopupItem *pitem, void *data) -{ - ContactAndBook *contact_and_book = data; - - eab_view_cut (contact_and_book->view); -} - -static void -delete (EPopup *ep, EPopupItem *pitem, void *data) -{ - ContactAndBook *contact_and_book = data; - - eab_view_delete_selection(contact_and_book->view); -} - -static void -copy_to_folder (EPopup *ep, EPopupItem *pitem, void *data) -{ - ContactAndBook *contact_and_book = data; - - eab_view_copy_to_folder (contact_and_book->view); -} - -static void -move_to_folder (EPopup *ep, EPopupItem *pitem, void *data) -{ - ContactAndBook *contact_and_book = data; - - eab_view_move_to_folder (contact_and_book->view); -} - -static void -new_card (EPopup *ep, EPopupItem *pitem, void *data) -{ - /*ContactAndBook *contact_and_book = data;*/ - EContact *contact = e_contact_new(); - - eab_show_contact_editor (((EABPopupTargetSelect *)ep->target)->book, contact, TRUE, TRUE); - g_object_unref (contact); -} - -static void -new_list (EPopup *ep, EPopupItem *pitem, void *data) -{ - /*ContactAndBook *contact_and_book = data;*/ - EContact *contact = e_contact_new (); - - eab_show_contact_list_editor (((EABPopupTargetSelect *)ep->target)->book, contact, TRUE, TRUE); - g_object_unref(contact); -} - -static EPopupItem eabv_popup_items[] = { - { E_POPUP_ITEM, "10.new", N_("New Contact..."), new_card, NULL, "stock_contact", 0, EAB_POPUP_SELECT_EDITABLE}, - { E_POPUP_ITEM, "15.newlist", N_("New Contact List..."), new_list, NULL, "stock_contact-list", 0, EAB_POPUP_SELECT_EDITABLE }, - - { E_POPUP_BAR, "20.bar" }, - { E_POPUP_ITEM, "30.saveas", N_("Save as VCard..."), save_as, NULL, "stock_save-as", 0, EAB_POPUP_SELECT_ANY }, - { E_POPUP_ITEM, "40.forward", N_("Forward Contact"), send_as, NULL, "stock_mail-forward", 0, EAB_POPUP_SELECT_ANY }, - { E_POPUP_ITEM, "50.mailto", N_("Send Message to Contact"), send_to, NULL, "stock_mail-send", 0, EAB_POPUP_SELECT_ANY|EAB_POPUP_SELECT_EMAIL }, - { E_POPUP_ITEM, "60.print", N_("Print"), print, NULL, "stock_print", 0, EAB_POPUP_SELECT_ANY }, - - { E_POPUP_BAR, "70.bar" }, - { E_POPUP_ITEM, "80.copyto", N_("Copy to Address Book..."), copy_to_folder, NULL, NULL, 0, EAB_POPUP_SELECT_ANY }, - { E_POPUP_ITEM, "90.moveto", N_("Move to Address Book..."), move_to_folder, NULL, NULL, 0, EAB_POPUP_SELECT_ANY|EAB_POPUP_SELECT_EDITABLE }, - - { E_POPUP_BAR, "a0.bar" }, - { E_POPUP_BAR, "b0.cut", N_("Cut"), cut, NULL, "stock_cut", 0, EAB_POPUP_SELECT_ANY|EAB_POPUP_SELECT_EDITABLE }, - { E_POPUP_ITEM, "c0.copy", N_("Copy"), copy, NULL, "stock_copy", 0, EAB_POPUP_SELECT_ANY }, - { E_POPUP_ITEM, "d0.paste", N_("Paste"), paste, NULL, "stock_paste", 0, EAB_POPUP_SELECT_EDITABLE }, - { E_POPUP_ITEM, "e0.delete", N_("Delete"), delete, NULL, "stock_delete", 0, EAB_POPUP_SELECT_EDITABLE|EAB_POPUP_SELECT_ANY }, -}; - -static void -get_card_1(gint model_row, void *data) -{ - ContactAndBook *contact_and_book = data; - EContact *contact; - - contact = eab_model_get_contact(contact_and_book->view->model, model_row); - if (contact) - g_ptr_array_add((GPtrArray *)contact_and_book->closure, contact); -} - -static void -eabv_popup_free(EPopup *ep, GSList *list, void *data) -{ - ContactAndBook *cab = data; - ESelectionModel *selection; - - /* NB: this looks strange to me */ - selection = contact_and_book_get_selection_model(cab); - if (selection) - e_selection_model_right_click_up(selection); - - g_slist_free(list); - g_object_unref(cab->view); - g_free(cab); -} - -static void -do_popup_menu(EABView *view, GdkEvent *event) -{ - EABPopup *ep; - EABPopupTargetSelect *t; - GSList *menus = NULL; - int i; - GtkMenu *menu; - GPtrArray *cards = g_ptr_array_new(); - ContactAndBook *contact_and_book; - ESelectionModel *selection_model; - - contact_and_book = g_new(ContactAndBook, 1); - contact_and_book->view = view; - g_object_ref(contact_and_book->view); - - selection_model = contact_and_book_get_selection_model(contact_and_book); - if (selection_model) { - contact_and_book->closure = cards; - e_selection_model_foreach(selection_model, get_card_1, contact_and_book); - } - - ep = eab_popup_new("org.gnome.evolution.addressbook.view.popup"); - t = eab_popup_target_new_select(ep, view->book, !eab_model_editable(view->model), cards); - t->target.widget = (GtkWidget *)view; - - for (i=0;i<sizeof(eabv_popup_items)/sizeof(eabv_popup_items[0]);i++) - menus = g_slist_prepend(menus, &eabv_popup_items[i]); - - e_popup_add_items((EPopup *)ep, menus, eabv_popup_free, contact_and_book); - - menu = e_popup_create_menu_once((EPopup *)ep, (EPopupTarget *)t, 0); - gtk_menu_popup(menu, NULL, NULL, NULL, NULL, event?event->button.button:0, event?event->button.time:gtk_get_current_event_time()); -} - -static void -render_contact (int row, EABView *view) -{ - EContact *contact = eab_model_get_contact (view->model, row); - - view->displayed_contact = row; - - eab_contact_display_render (EAB_CONTACT_DISPLAY (view->contact_display), contact, - EAB_CONTACT_DISPLAY_RENDER_NORMAL); -} - -static void -selection_changed (GObject *o, EABView *view) -{ - ESelectionModel *selection_model; - - command_state_change (view); - - selection_model = get_selection_model (view); - - if (e_selection_model_selected_count (selection_model) == 1) - e_selection_model_foreach (selection_model, - (EForeachFunc)render_contact, view); - else { - view->displayed_contact = -1; - eab_contact_display_render (EAB_CONTACT_DISPLAY (view->contact_display), NULL, - EAB_CONTACT_DISPLAY_RENDER_NORMAL); - } - -} - -static void -table_double_click(ETableScrolled *table, gint row, gint col, GdkEvent *event, EABView *view) -{ - if (E_IS_ADDRESSBOOK_TABLE_ADAPTER(view->object)) { - EABModel *model = view->model; - EContact *contact = eab_model_get_contact (model, row); - EBook *book; - - g_object_get(model, - "book", &book, - NULL); - - g_assert (E_IS_BOOK (book)); - - if (e_contact_get (contact, E_CONTACT_IS_LIST)) - eab_show_contact_list_editor (book, contact, FALSE, view->editable); - else - eab_show_contact_editor (book, contact, FALSE, view->editable); - - g_object_unref (book); - g_object_unref (contact); - } -} - -static gint -table_right_click(ETableScrolled *table, gint row, gint col, GdkEvent *event, EABView *view) -{ - do_popup_menu(view, event); - return TRUE; -} - -static gint -table_white_space_event(ETableScrolled *table, GdkEvent *event, EABView *view) -{ - if (event->type == GDK_BUTTON_PRESS && ((GdkEventButton *)event)->button == 3) { - do_popup_menu(view, event); - return TRUE; - } else { - return FALSE; - } -} - -static void -table_drag_data_get (ETable *table, - int row, - int col, - GdkDragContext *context, - GtkSelectionData *selection_data, - guint info, - guint time, - gpointer user_data) -{ - EABView *view = user_data; - GList *contact_list; - - if (!E_IS_ADDRESSBOOK_TABLE_ADAPTER(view->object)) - return; - - contact_list = get_selected_contacts (view); - - switch (info) { - case DND_TARGET_TYPE_VCARD: { - char *value; - - value = eab_contact_list_to_string (contact_list); - - gtk_selection_data_set (selection_data, - selection_data->target, - 8, - value, strlen (value)); - break; - } - case DND_TARGET_TYPE_SOURCE_VCARD: { - char *value; - - value = eab_book_and_contact_list_to_string (view->book, contact_list); - - gtk_selection_data_set (selection_data, - selection_data->target, - 8, - value, strlen (value)); - break; - } - } - - g_list_foreach (contact_list, (GFunc) g_object_unref, NULL); - g_list_free (contact_list); -} - -static void -emit_status_message (EABView *eav, const gchar *status) -{ - g_signal_emit (eav, - eab_view_signals [STATUS_MESSAGE], 0, - status); -} - -static void -emit_search_result (EABView *eav, EBookViewStatus status) -{ - g_signal_emit (eav, - eab_view_signals [SEARCH_RESULT], 0, - status); -} - -static void -emit_folder_bar_message (EABView *eav, const gchar *message) -{ - g_signal_emit (eav, - eab_view_signals [FOLDER_BAR_MESSAGE], 0, - message); -} - -static void -status_message (GtkObject *object, const gchar *status, EABView *eav) -{ - emit_status_message (eav, status); -} - -static void -search_result (GtkObject *object, EBookViewStatus status, EABView *eav) -{ - emit_search_result (eav, status); -} - -static void -folder_bar_message (GtkObject *object, const gchar *status, EABView *eav) -{ - emit_folder_bar_message (eav, status); -} - -static void -stop_state_changed (GtkObject *object, EABView *eav) -{ - command_state_change (eav); -} - -static void -command_state_change (EABView *eav) -{ - /* Reffing during emission is unnecessary. Gtk automatically refs during an emission. */ - g_signal_emit (eav, eab_view_signals [COMMAND_STATE_CHANGE], 0); -} - -static void -backend_died (GtkObject *object, EABView *eav) -{ - e_error_run (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (eav))), - "addressbook:backend-died", e_book_get_uri (eav->book), NULL); -} - -static void -contact_changed (EABModel *model, gint index, EABView *eav) -{ - if (eav->displayed_contact == index) { - /* if the contact that's presently displayed is changed, re-render it */ - render_contact (index, eav); - } -} - -static void -contact_removed (EABModel *model, gint index, EABView *eav) -{ - if (eav->displayed_contact == index) { - /* if the contact that's presently displayed is changed, clear the display */ - eab_contact_display_render (EAB_CONTACT_DISPLAY (eav->contact_display), NULL, - EAB_CONTACT_DISPLAY_RENDER_NORMAL); - eav->displayed_contact = -1; - } -} - -static void -minicard_right_click (EMinicardView *minicard_view_item, GdkEvent *event, EABView *view) -{ - do_popup_menu(view, event); -} - -static void -create_minicard_view (EABView *view) -{ - GtkWidget *scrolled_window; - GtkWidget *minicard_view; - EAddressbookReflowAdapter *adapter; - - adapter = E_ADDRESSBOOK_REFLOW_ADAPTER(e_addressbook_reflow_adapter_new (view->model)); - minicard_view = e_minicard_view_widget_new(adapter); - - g_signal_connect(minicard_view, "selection_change", - G_CALLBACK(selection_changed), view); - - g_signal_connect(minicard_view, "right_click", - G_CALLBACK(minicard_right_click), view); - - 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); - - view->object = G_OBJECT(minicard_view); - view->widget = scrolled_window; - - gtk_container_add (GTK_CONTAINER (scrolled_window), minicard_view); - gtk_widget_show (minicard_view); - - gtk_widget_show_all( GTK_WIDGET(scrolled_window) ); - - gtk_paned_add1 (GTK_PANED (view->paned), scrolled_window); - - e_reflow_model_changed (E_REFLOW_MODEL (adapter)); -} - -static void -create_table_view (EABView *view) -{ - ETableModel *adapter; - GtkWidget *table; - - adapter = eab_table_adapter_new(view->model); - - /* Here we create the table. We give it the three pieces of - the table we've created, the header, the model, and the - initial layout. It does the rest. */ - table = e_table_scrolled_new_from_spec_file (adapter, NULL, EVOLUTION_ETSPECDIR "/e-addressbook-view.etspec", NULL); - - view->object = G_OBJECT(adapter); - view->widget = table; - - g_signal_connect(e_table_scrolled_get_table(E_TABLE_SCROLLED(table)), "double_click", - G_CALLBACK(table_double_click), view); - g_signal_connect(e_table_scrolled_get_table(E_TABLE_SCROLLED(table)), "right_click", - G_CALLBACK(table_right_click), view); - g_signal_connect(e_table_scrolled_get_table(E_TABLE_SCROLLED(table)), "white_space_event", - G_CALLBACK(table_white_space_event), view); - g_signal_connect(e_table_scrolled_get_table(E_TABLE_SCROLLED(table)), "selection_change", - G_CALLBACK(selection_changed), view); - - /* drag & drop signals */ - e_table_drag_source_set (E_TABLE(E_TABLE_SCROLLED(table)->table), GDK_BUTTON1_MASK, - drag_types, num_drag_types, GDK_ACTION_MOVE | GDK_ACTION_COPY); - - g_signal_connect (E_TABLE_SCROLLED(table)->table, - "table_drag_data_get", - G_CALLBACK (table_drag_data_get), - view); - - gtk_paned_add1 (GTK_PANED (view->paned), table); - - gtk_widget_show( GTK_WIDGET(table) ); -} - -#ifdef WITH_ADDRESSBOOK_VIEW_TREEVIEW -static void -treeview_row_activated(GtkTreeView *treeview, - GtkTreePath *path, GtkTreeViewColumn *column, - EABView *view) -{ - EABModel *model = view->model; - int row = gtk_tree_path_get_indices (path)[0]; - ECard *card = eab_model_get_card(model, row); - EBook *book; - - g_object_get(model, - "book", &book, - NULL); - - g_assert (E_IS_BOOK (book)); - - if (e_card_evolution_list (card)) - eab_show_contact_list_editor (book, card, FALSE, view->editable); - else - eab_show_contact_editor (book, card, FALSE, view->editable); - - g_object_unref (book); - g_object_unref (card); -} - -static void -create_treeview_view (EABView *view) -{ - GtkTreeModel *adapter; - ECardSimple *simple; - GtkWidget *treeview; - GtkWidget *scrolled; - int i; - - simple = e_card_simple_new(NULL); - - adapter = eab_treeview_adapter_new(view->model); - - scrolled = gtk_scrolled_window_new (NULL, NULL); - gtk_scrolled_window_set_shadow (GTK_SCROLLED_WINDOW (scrolled), GTK_SHADOW_IN); - treeview = gtk_tree_view_new_with_model (adapter); - - gtk_widget_show (treeview); - - gtk_container_add (GTK_CONTAINER (scrolled), treeview); - - for (i = 0; i < 15; i ++) { - GtkTreeViewColumn *column = - gtk_tree_view_column_new_with_attributes (e_card_simple_get_name (simple, i), - gtk_cell_renderer_text_new (), - "text", i, - NULL); - - gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column); - } - - view->object = G_OBJECT(treeview); - view->widget = scrolled; - - gtk_tree_selection_set_mode (gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview)), GTK_SELECTION_MULTIPLE); - gtk_tree_view_enable_model_drag_source (GTK_TREE_VIEW (treeview), - GDK_BUTTON1_MASK, - drag_types, - num_drag_types, - GDK_ACTION_MOVE); - - g_signal_connect(treeview, "row_activated", - G_CALLBACK (treeview_row_activated), view); -#if 0 - g_signal_connect(e_table_scrolled_get_table(E_TABLE_SCROLLED(table)), "right_click", - G_CALLBACK(table_right_click), view); - - /* drag & drop signals */ - e_table_drag_source_set (E_TABLE(E_TABLE_SCROLLED(table)->table), GDK_BUTTON1_MASK, - drag_types, num_drag_types, GDK_ACTION_MOVE); - - g_signal_connect (E_TABLE_SCROLLED(table)->table, - "table_drag_data_get", - G_CALLBACK (table_drag_data_get), - view); -#endif - - - g_signal_connect(e_treeview_get_selection_model (GTK_TREE_VIEW (treeview)), "selection_changed", - G_CALLBACK(selection_changed), view); - - gtk_paned_add1 (GTK_PANED (view->paned), scrolled); - - gtk_widget_show( GTK_WIDGET(scrolled) ); - - g_object_unref (simple); -} -#endif - -static void -change_view_type (EABView *view, EABViewType view_type) -{ - if (view_type == view->view_type) - return; - - if (view->widget) { - gtk_container_remove (GTK_CONTAINER (view->paned), view->widget); - view->widget = NULL; - } - view->object = NULL; - - switch (view_type) { - case EAB_VIEW_TABLE: - create_table_view (view); - break; - case EAB_VIEW_MINICARD: - create_minicard_view (view); - break; -#ifdef WITH_ADDRESSBOOK_VIEW_TREEVIEW - case EAB_VIEW_TREEVIEW: - create_treeview_view (view); - break; -#endif - default: - g_warning ("view_type not recognized."); - return; - } - - view->view_type = view_type; - - command_state_change (view); -} - - - -static void -search_activated (ESearchBar *esb, EABView *v) -{ - ECategoriesMasterList *master_list; - char *search_word, *search_query; - const char *category_name; - int search_type, subid; - - g_message ("in search_activated"); - - g_object_get(esb, - "text", &search_word, - "item_id", &search_type, - NULL); - - if (search_type == ESB_ADVANCED) { - gtk_widget_show(eab_search_dialog_new(v)); - } - else { - if ((search_word && strlen (search_word)) || search_type == ESB_CATEGORY) { - GString *s = g_string_new (""); - e_sexp_encode_string (s, search_word); - switch (search_type) { - case ESB_ANY: - search_query = g_strdup_printf ("(contains \"x-evolution-any-field\" %s)", - s->str); - break; - case ESB_FULL_NAME: - search_query = g_strdup_printf ("(beginswith \"full_name\" %s)", - s->str); - break; - case ESB_EMAIL: - search_query = g_strdup_printf ("(beginswith \"email\" %s)", - s->str); - break; - case ESB_CATEGORY: - subid = e_search_bar_get_subitem_id (esb); - - if (subid < 0 || subid == G_MAXINT) { - /* match everything */ - search_query = g_strdup ("(contains \"x-evolution-any-field\" \"\")"); - } else { - master_list = get_master_list (); - category_name = e_categories_master_list_nth (master_list, subid); - search_query = g_strdup_printf ("(is \"category_list\" \"%s\")", category_name); - } - break; - default: - search_query = g_strdup ("(contains \"x-evolution-any-field\" \"\")"); - break; - } - g_string_free (s, TRUE); - } else - search_query = g_strdup ("(contains \"x-evolution-any-field\" \"\")"); - - if (search_query) - g_object_set (v, - "query", search_query, - NULL); - - g_free (search_query); - } - - g_free (search_word); -} - -static void -search_menu_activated (ESearchBar *esb, int id, EABView *view) -{ - if (id == ESB_ADVANCED) - gtk_widget_show(eab_search_dialog_new(view)); -} - -static void -query_changed (ESearchBar *esb, EABView *view) -{ - int search_type; - - search_type = e_search_bar_get_item_id(esb); - if (search_type == ESB_ADVANCED) - gtk_widget_show(eab_search_dialog_new(view)); -} - -static int -compare_subitems (const void *a, const void *b) -{ - const ESearchBarSubitem *subitem_a = a; - const ESearchBarSubitem *subitem_b = b; - char *collate_a, *collate_b; - int ret; - - collate_a = g_utf8_collate_key (subitem_a->text, -1); - collate_b = g_utf8_collate_key (subitem_b->text, -1); - - ret = strcmp (collate_a, collate_b); - - g_free (collate_a); - g_free (collate_b); - - return ret; -} - -static void -make_suboptions (EABView *view) -{ - ESearchBarSubitem *subitems, *s; - ECategoriesMasterList *master_list; - gint i, N; - - master_list = get_master_list (); - N = e_categories_master_list_count (master_list); - subitems = g_new (ESearchBarSubitem, N+2); - - subitems[0].id = G_MAXINT; - subitems[0].text = g_strdup (_("Any Category")); - subitems[0].translate = FALSE; - - for (i=0; i<N; ++i) { - const char *category = e_categories_master_list_nth (master_list, i); - - subitems[i+1].id = i; - subitems[i+1].text = g_strdup (category); - subitems[i+1].translate = FALSE; - } - subitems[N+1].id = -1; - subitems[N+1].text = NULL; - - qsort (subitems + 1, N, sizeof (subitems[0]), compare_subitems); - - e_search_bar_set_suboption (view->search, ESB_CATEGORY, subitems); - - for (s = subitems; s->id != -1; s++) { - if (s->text) - g_free (s->text); - } - g_free (subitems); -} - -static void -ecml_changed (ECategoriesMasterList *ecml, EABView *view) -{ - make_suboptions (view); -} - -static ECategoriesMasterList * -get_master_list (void) -{ - static ECategoriesMasterList *category_list = NULL; - - if (category_list == NULL) - category_list = e_categories_master_list_wombat_new (); - return category_list; -} - -static void -connect_master_list_changed (EABView *view) -{ - view->ecml_changed_id = - g_signal_connect (get_master_list(), "changed", - G_CALLBACK (ecml_changed), view); -} - - - -typedef struct { - GtkWidget *table; - GObject *printable; -} EContactPrintDialogWeakData; - -static void -e_contact_print_destroy(gpointer data, GObject *where_object_was) -{ - EContactPrintDialogWeakData *weak_data = data; - g_object_unref (weak_data->printable); - g_object_unref (weak_data->table); - g_free (weak_data); -} - -static void -e_contact_print_button(GtkDialog *dialog, gint response, gpointer data) -{ - GnomePrintJob *master; - GnomePrintContext *pc; - EPrintable *printable = g_object_get_data(G_OBJECT(dialog), "printable"); - GtkWidget *preview; - switch( response ) { - case GNOME_PRINT_DIALOG_RESPONSE_PRINT: - master = gnome_print_job_new(gnome_print_dialog_get_config ( GNOME_PRINT_DIALOG(dialog) )); - pc = gnome_print_job_get_context( master ); - e_printable_reset(printable); - while (e_printable_data_left(printable)) { - gnome_print_beginpage (pc, "Contacts"); - if (gnome_print_gsave(pc) == -1) - /* FIXME */; - if (gnome_print_translate(pc, 72, 72) == -1) - /* FIXME */; - e_printable_print_page(printable, - pc, - 6.5 * 72, - 5 * 72, - TRUE); - if (gnome_print_grestore(pc) == -1) - /* FIXME */; - if (gnome_print_showpage(pc) == -1) - /* FIXME */; - } - gnome_print_job_close(master); - gnome_print_job_print(master); - g_object_unref (master); - gtk_widget_destroy((GtkWidget *)dialog); - break; - case GNOME_PRINT_DIALOG_RESPONSE_PREVIEW: - master = gnome_print_job_new (gnome_print_dialog_get_config ( GNOME_PRINT_DIALOG(dialog) )); - pc = gnome_print_job_get_context( master ); - e_printable_reset(printable); - while (e_printable_data_left(printable)) { - gnome_print_beginpage (pc, "Contacts"); - if (gnome_print_gsave(pc) == -1) - /* FIXME */; - if (gnome_print_translate(pc, 72, 72) == -1) - /* FIXME */; - e_printable_print_page(printable, - pc, - 6.5 * 72, - 9 * 72, - TRUE); - if (gnome_print_grestore(pc) == -1) - /* FIXME */; - if (gnome_print_showpage(pc) == -1) - /* FIXME */; - } - gnome_print_job_close(master); - preview = GTK_WIDGET(gnome_print_job_preview_new(master, "Print Preview")); - gtk_widget_show_all(preview); - g_object_unref (master); - break; - case GNOME_PRINT_DIALOG_RESPONSE_CANCEL: - default: - gtk_widget_destroy((GtkWidget *)dialog); - break; - } -} - -void -eab_view_show_contact_preview (EABView *view, gboolean show) -{ - g_return_if_fail (view && E_IS_ADDRESSBOOK_VIEW (view)); - - if (show) - gtk_widget_show (view->contact_display_window); - else - gtk_widget_hide (view->contact_display_window); -} - -void -eab_view_setup_menus (EABView *view, - BonoboUIComponent *uic) -{ - - g_return_if_fail (view != NULL); - g_return_if_fail (E_IS_ADDRESSBOOK_VIEW (view)); - g_return_if_fail (uic != NULL); - g_return_if_fail (BONOBO_IS_UI_COMPONENT (uic)); - - init_collection (); - - view->uic = uic; - - setup_menus (view); - - /* XXX toshok - yeah this really doesn't belong here, but it - needs to happen at the same time and takes the uic */ - e_search_bar_set_ui_component (view->search, uic); -} - -/** - * eab_view_discard_menus: - * @view: An addressbook view. - * - * Makes an addressbook view discard its GAL view menus and its views instance - * objects. This should be called when the corresponding Bonobo component is - * deactivated. - **/ -void -eab_view_discard_menus (EABView *view) -{ - g_return_if_fail (view != NULL); - g_return_if_fail (E_IS_ADDRESSBOOK_VIEW (view)); - g_return_if_fail (view->view_instance); - - if (view->view_menus) { - gal_view_menus_unmerge (view->view_menus, NULL); - - g_object_unref (view->view_menus); - view->view_menus = NULL; - } - - if (view->view_instance) { - g_object_unref (view->view_instance); - view->view_instance = NULL; - } - - view->uic = NULL; -} - -void -eab_view_print(EABView *view) -{ - if (view->view_type == EAB_VIEW_MINICARD) { - char *query; - EBook *book; - GtkWidget *print; - - g_object_get (view->model, - "query", &query, - "book", &book, - NULL); - print = e_contact_print_dialog_new(book, query); - g_free(query); - gtk_widget_show_all(print); - } - else if (view->view_type == EAB_VIEW_TABLE) { - GtkWidget *dialog; - EPrintable *printable; - ETable *etable; - EContactPrintDialogWeakData *weak_data; - - dialog = gnome_print_dialog_new(NULL, "Print cards", GNOME_PRINT_DIALOG_RANGE | GNOME_PRINT_DIALOG_COPIES); - gnome_print_dialog_construct_range_any(GNOME_PRINT_DIALOG(dialog), GNOME_PRINT_RANGE_ALL | GNOME_PRINT_RANGE_SELECTION, - NULL, NULL, NULL); - - g_object_get(view->widget, "table", &etable, NULL); - printable = e_table_get_printable(etable); - g_object_ref (printable); - gtk_object_sink (GTK_OBJECT (printable)); - g_object_unref(etable); - g_object_ref (view->widget); - - g_object_set_data (G_OBJECT (dialog), "table", view->widget); - g_object_set_data (G_OBJECT (dialog), "printable", printable); - - g_signal_connect(dialog, - "response", G_CALLBACK(e_contact_print_button), NULL); - - weak_data = g_new (EContactPrintDialogWeakData, 1); - - weak_data->table = view->widget; - weak_data->printable = G_OBJECT (printable); - - g_object_weak_ref (G_OBJECT (dialog), e_contact_print_destroy, weak_data); - - gtk_widget_show(dialog); - } -#ifdef WITH_ADDRESSBOOK_VIEW_TREEVIEW - else if (view->view_type == EAB_VIEW_TREEVIEW) { - /* XXX */ - } -#endif -} - -void -eab_view_print_preview(EABView *view) -{ - if (view->view_type == EAB_VIEW_MINICARD) { - char *query; - EBook *book; - - g_object_get (view->model, - "query", &query, - "book", &book, - NULL); - e_contact_print_preview(book, query); - g_free(query); - } else if (view->view_type == EAB_VIEW_TABLE) { - EPrintable *printable; - ETable *etable; - GnomePrintJob *master; - GnomePrintContext *pc; - GnomePrintConfig *config; - GtkWidget *preview; - - g_object_get(view->widget, "table", &etable, NULL); - printable = e_table_get_printable(etable); - g_object_unref(etable); - g_object_ref (printable); - gtk_object_sink (GTK_OBJECT (printable)); - - master = gnome_print_job_new(NULL); - config = gnome_print_job_get_config (master); - gnome_print_config_set_int (config, GNOME_PRINT_KEY_NUM_COPIES, 1); - pc = gnome_print_job_get_context( master ); - e_printable_reset(printable); - while (e_printable_data_left(printable)) { - gnome_print_beginpage (pc, "Contacts"); - if (gnome_print_gsave(pc) == -1) - /* FIXME */; - if (gnome_print_translate(pc, 72, 72) == -1) - /* FIXME */; - e_printable_print_page(printable, - pc, - 6.5 * 72, - 9 * 72, - TRUE); - if (gnome_print_grestore(pc) == -1) - /* FIXME */; - if (gnome_print_showpage(pc) == -1) - /* FIXME */; - } - gnome_print_job_close(master); - preview = GTK_WIDGET(gnome_print_job_preview_new(master, "Print Preview")); - gtk_widget_show_all(preview); - g_object_unref (master); - g_object_unref (printable); - } -#ifdef WITH_ADDRESSBOOK_VIEW_TREEVIEW - else if (view->view_type == EAB_VIEW_TREEVIEW) { - /* XXX */ - } -#endif -} - -void -eab_view_delete_selection(EABView *view) -{ - GList *list, *l; - - if (!eab_editor_confirm_delete(GTK_WINDOW(gtk_widget_get_toplevel(view->widget)))) - return; - - list = get_selected_contacts(view); - if (e_book_check_static_capability (view->book, "bulk-remove")) { - GList *ids = NULL; - - for (l=list;l;l=g_list_next(l)) { - EContact *contact = l->data; - - ids = g_list_prepend (ids, (char*)e_contact_get_const (contact, E_CONTACT_UID)); - } - - /* Remove the cards all at once. */ - /* XXX no callback specified... ugh */ - e_book_async_remove_contacts (view->book, - ids, - NULL, - NULL); - - g_list_free (ids); - } - else { - for (l=list;l;l=g_list_next(l)) { - EContact *contact = l->data; - /* Remove the card. */ - /* XXX no callback specified... ugh */ - e_book_async_remove_contact (view->book, - contact, - NULL, - NULL); - } - } - - e_free_object_list(list); -} - -static void -invisible_destroyed (gpointer data, GObject *where_object_was) -{ - EABView *view = data; - view->invisible = NULL; -} - -static void -selection_get (GtkWidget *invisible, - GtkSelectionData *selection_data, - guint info, - guint time_stamp, - EABView *view) -{ - char *value; - - value = eab_contact_list_to_string (view->clipboard_contacts); - - gtk_selection_data_set (selection_data, GDK_SELECTION_TYPE_STRING, - 8, value, strlen (value)); - -} - -static void -selection_clear_event (GtkWidget *invisible, - GdkEventSelection *event, - EABView *view) -{ - if (view->clipboard_contacts) { - g_list_foreach (view->clipboard_contacts, (GFunc)g_object_unref, NULL); - g_list_free (view->clipboard_contacts); - view->clipboard_contacts = NULL; - } -} - -static void -selection_received (GtkWidget *invisible, - GtkSelectionData *selection_data, - guint time, - EABView *view) -{ - if (selection_data->length <= 0 || selection_data->type != GDK_SELECTION_TYPE_STRING) { - return; - } else { - GList *contact_list; - GList *l; - char *str = NULL; - - if (selection_data->data [selection_data->length - 1] != 0) { - str = g_malloc0 (selection_data->length + 1); - memcpy (str, selection_data->data, selection_data->length); - contact_list = eab_contact_list_from_string (str); - } else - contact_list = eab_contact_list_from_string (selection_data->data); - - for (l = contact_list; l; l = l->next) { - EContact *contact = l->data; - - /* XXX NULL for a callback /sigh */ - eab_merging_book_add_contact (view->book, contact, NULL /* XXX */, NULL); - } - - g_list_foreach (contact_list, (GFunc)g_object_unref, NULL); - g_list_free (contact_list); - g_free (str); - } -} - -static void -add_to_list (int model_row, gpointer closure) -{ - GList **list = closure; - *list = g_list_prepend (*list, GINT_TO_POINTER (model_row)); -} - -static GList * -get_selected_contacts (EABView *view) -{ - GList *list; - GList *iterator; - ESelectionModel *selection = get_selection_model (view); - - list = NULL; - e_selection_model_foreach (selection, add_to_list, &list); - - for (iterator = list; iterator; iterator = iterator->next) { - iterator->data = eab_model_get_contact (view->model, GPOINTER_TO_INT (iterator->data)); - } - list = g_list_reverse (list); - return list; -} - -void -eab_view_save_as (EABView *view) -{ - GList *list = get_selected_contacts (view); - if (list) - eab_contact_list_save (_("Save as VCard..."), list, NULL); - e_free_object_list(list); -} - -void -eab_view_view (EABView *view) -{ - GList *list = get_selected_contacts (view); - eab_show_multiple_contacts (view->book, list, view->editable); - e_free_object_list(list); -} - -void -eab_view_send (EABView *view) -{ - GList *list = get_selected_contacts (view); - if (list) - eab_send_contact_list (list, EAB_DISPOSITION_AS_ATTACHMENT); - e_free_object_list(list); -} - -void -eab_view_send_to (EABView *view) -{ - GList *list = get_selected_contacts (view); - if (list) - eab_send_contact_list (list, EAB_DISPOSITION_AS_TO); - e_free_object_list(list); -} - -void -eab_view_cut (EABView *view) -{ - eab_view_copy (view); - eab_view_delete_selection (view); -} - -void -eab_view_copy (EABView *view) -{ - view->clipboard_contacts = get_selected_contacts (view); - - gtk_selection_owner_set (view->invisible, clipboard_atom, GDK_CURRENT_TIME); -} - -void -eab_view_paste (EABView *view) -{ - gtk_selection_convert (view->invisible, clipboard_atom, - GDK_SELECTION_TYPE_STRING, - GDK_CURRENT_TIME); -} - -void -eab_view_select_all (EABView *view) -{ - ESelectionModel *model = get_selection_model (view); - - g_return_if_fail (model); - - e_selection_model_select_all (model); -} - -void -eab_view_show_all(EABView *view) -{ - g_object_set(view, - "query", NULL, - NULL); -} - -void -eab_view_stop(EABView *view) -{ - if (view) - eab_model_stop (view->model); -} - -static void -view_transfer_contacts (EABView *view, gboolean delete_from_source) -{ - EBook *book; - GList *contacts; - GtkWindow *parent_window; - - g_object_get(view->model, - "book", &book, - NULL); - contacts = get_selected_contacts (view); - parent_window = GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (view))); - - eab_transfer_contacts (book, contacts, delete_from_source, parent_window); - g_object_unref(book); -} - -void -eab_view_copy_to_folder (EABView *view) -{ - view_transfer_contacts (view, FALSE); -} - -void -eab_view_move_to_folder (EABView *view) -{ - view_transfer_contacts (view, TRUE); -} - - -static gboolean -eab_view_selection_nonempty (EABView *view) -{ - ESelectionModel *selection_model; - - selection_model = get_selection_model (view); - if (selection_model == NULL) - return FALSE; - - return e_selection_model_selected_count (selection_model) != 0; -} - -gboolean -eab_view_can_create (EABView *view) -{ - return view ? eab_model_editable (view->model) : FALSE; -} - -gboolean -eab_view_can_print (EABView *view) -{ - return view && view->model ? eab_model_contact_count (view->model) : FALSE; -} - -gboolean -eab_view_can_save_as (EABView *view) -{ - return view ? eab_view_selection_nonempty (view) : FALSE; -} - -gboolean -eab_view_can_view (EABView *view) -{ - return view ? eab_view_selection_nonempty (view) : FALSE; -} - -gboolean -eab_view_can_send (EABView *view) -{ - return view ? eab_view_selection_nonempty (view) : FALSE; -} - -gboolean -eab_view_can_send_to (EABView *view) -{ - return view ? eab_view_selection_nonempty (view) : FALSE; -} - -gboolean -eab_view_can_delete (EABView *view) -{ - return view ? eab_view_selection_nonempty (view) && eab_model_editable (view->model) : FALSE; -} - -gboolean -eab_view_can_cut (EABView *view) -{ - return view ? eab_view_selection_nonempty (view) && eab_model_editable (view->model) : FALSE; -} - -gboolean -eab_view_can_copy (EABView *view) -{ - return view ? eab_view_selection_nonempty (view) : FALSE; -} - -gboolean -eab_view_can_paste (EABView *view) -{ - return view ? eab_model_editable (view->model) : FALSE; -} - -gboolean -eab_view_can_select_all (EABView *view) -{ - return view ? eab_model_contact_count (view->model) != 0 : FALSE; -} - -gboolean -eab_view_can_stop (EABView *view) -{ - return view ? eab_model_can_stop (view->model) : FALSE; -} - -gboolean -eab_view_can_copy_to_folder (EABView *view) -{ - return view ? eab_view_selection_nonempty (view) : FALSE; -} - -gboolean -eab_view_can_move_to_folder (EABView *view) -{ - return view ? eab_view_selection_nonempty (view) && eab_model_editable (view->model) : FALSE; -} - -EABMenuTargetSelect * -eab_view_get_menu_target (EABView *view, EABMenu *menu) -{ - GPtrArray *cards = g_ptr_array_new(); - ESelectionModel *selection_model; - EABMenuTargetSelect *t; - - selection_model = get_selection_model (view); - if (selection_model) { - ContactAndBook cab; - - cab.view = view; - cab.closure = cards; - e_selection_model_foreach(selection_model, get_card_1, &cab); - } - - t = eab_menu_target_new_select(menu, view->book, !eab_model_editable(view->model), cards); - t->target.widget = (GtkWidget *)view; - - return t; -} diff --git a/addressbook/gui/widgets/e-addressbook-view.etspec b/addressbook/gui/widgets/e-addressbook-view.etspec deleted file mode 100644 index caddf081f8..0000000000 --- a/addressbook/gui/widgets/e-addressbook-view.etspec +++ /dev/null @@ -1,58 +0,0 @@ -<ETableSpecification draw-grid="true" cursor-mode="line"> - <ETableColumn model_col= "2" _title="File As" expansion="1.0" minimum_width="75" resizable="true" cell="string" compare="string"/> - <ETableColumn model_col= "3" _title="Full Name" expansion="1.0" minimum_width="75" resizable="true" cell="string" compare="string"/> - <ETableColumn model_col= "4" _title="Given Name" expansion="1.0" minimum_width="75" resizable="true" cell="string" compare="string"/> - <ETableColumn model_col= "5" _title="Family Name" expansion="1.0" minimum_width="75" resizable="true" cell="string" compare="string"/> - <ETableColumn model_col= "6" _title="Nickname" expansion="1.0" minimum_width="75" resizable="true" cell="string" compare="string"/> - - <ETableColumn model_col= "7" _title="Email" expansion="1.0" minimum_width="75" resizable="true" cell="string" compare="string"/> - <ETableColumn model_col= "8" _title="Email 2" expansion="1.0" minimum_width="75" resizable="true" cell="string" compare="string"/> - <ETableColumn model_col= "9" _title="Email 3" expansion="1.0" minimum_width="75" resizable="true" cell="string" compare="string"/> - - <ETableColumn model_col= "15" _title="Assistant Phone" expansion="1.0" minimum_width="75" resizable="true" cell="string" compare="string"/> - <ETableColumn model_col= "16" _title="Business Phone" expansion="1.0" minimum_width="75" resizable="true" cell="string" compare="string"/> - <ETableColumn model_col= "17" _title="Business Phone 2" expansion="1.0" minimum_width="75" resizable="true" cell="string" compare="string"/> - <ETableColumn model_col="18" _title="Business Fax" expansion="1.0" minimum_width="75" resizable="true" cell="string" compare="string"/> - <ETableColumn model_col="19" _title="Callback Phone" expansion="1.0" minimum_width="75" resizable="true" cell="string" compare="string"/> - <ETableColumn model_col="20" _title="Car Phone" expansion="1.0" minimum_width="75" resizable="true" cell="string" compare="string"/> - <ETableColumn model_col="21" _title="Company Phone" expansion="1.0" minimum_width="75" resizable="true" cell="string" compare="string"/> - <ETableColumn model_col="22" _title="Home Phone" expansion="1.0" minimum_width="75" resizable="true" cell="string" compare="string"/> - <ETableColumn model_col="23" _title="Home Phone 2" expansion="1.0" minimum_width="75" resizable="true" cell="string" compare="string"/> - <ETableColumn model_col="24" _title="Home Fax" expansion="1.0" minimum_width="75" resizable="true" cell="string" compare="string"/> - <ETableColumn model_col="25" _title="ISDN Phone" expansion="1.0" minimum_width="75" resizable="true" cell="string" compare="string"/> - <ETableColumn model_col="26" _title="Mobile Phone" expansion="1.0" minimum_width="75" resizable="true" cell="string" compare="string"/> - <ETableColumn model_col="27" _title="Other Phone" expansion="1.0" minimum_width="75" resizable="true" cell="string" compare="string"/> - <ETableColumn model_col="28" _title="Other Fax" expansion="1.0" minimum_width="75" resizable="true" cell="string" compare="string"/> - <ETableColumn model_col="29" _title="Pager" expansion="1.0" minimum_width="75" resizable="true" cell="string" compare="string"/> - <ETableColumn model_col="30" _title="Primary Phone" expansion="1.0" minimum_width="75" resizable="true" cell="string" compare="string"/> - <ETableColumn model_col="31" _title="Radio" expansion="1.0" minimum_width="75" resizable="true" cell="string" compare="string"/> - <ETableColumn model_col="32" _title="Telex" expansion="1.0" minimum_width="75" resizable="true" cell="string" compare="string"/> - <ETableColumn model_col="33" _title="TTYTDD" expansion="1.0" minimum_width="75" resizable="true" cell="string" compare="string"/> - - <ETableColumn model_col="34" _title="Organization" expansion="1.0" minimum_width="75" resizable="true" cell="string" compare="string"/> - <ETableColumn model_col="35" _title="Unit" expansion="1.0" minimum_width="75" resizable="true" cell="string" compare="string"/> - <ETableColumn model_col="36" _title="Office" expansion="1.0" minimum_width="75" resizable="true" cell="string" compare="string"/> - <ETableColumn model_col="37" _title="Title" expansion="1.0" minimum_width="75" resizable="true" cell="string" compare="string"/> - <ETableColumn model_col="38" _title="Role" expansion="1.0" minimum_width="75" resizable="true" cell="string" compare="string"/> - <ETableColumn model_col="39" _title="Manager" expansion="1.0" minimum_width="75" resizable="true" cell="string" compare="string"/> - <ETableColumn model_col="40" _title="Assistant" expansion="1.0" minimum_width="75" resizable="true" cell="string" compare="string"/> - - <ETableColumn model_col="41" _title="Web Site" expansion="1.0" minimum_width="75" resizable="true" cell="string" compare="string"/> - <ETableColumn model_col="42" _title="Journal" expansion="1.0" minimum_width="75" resizable="true" cell="string" compare="string"/> - - <ETableColumn model_col="43" _title="Categories" expansion="1.0" minimum_width="75" resizable="true" cell="string" compare="string"/> - - <ETableColumn model_col="48" _title="Spouse" expansion="1.0" minimum_width="75" resizable="true" cell="string" compare="string"/> - <ETableColumn model_col="49" _title="Note" expansion="1.0" minimum_width="75" resizable="true" cell="string" compare="string"/> - - <ETableState> - <column source="0"/> - <column source="1"/> - <column source="5"/> - <column source="23"/> - <column source="36"/> - <grouping> - <leaf column="0" ascending="true"/> - </grouping> - </ETableState> -</ETableSpecification> diff --git a/addressbook/gui/widgets/e-addressbook-view.h b/addressbook/gui/widgets/e-addressbook-view.h deleted file mode 100644 index a55406915e..0000000000 --- a/addressbook/gui/widgets/e-addressbook-view.h +++ /dev/null @@ -1,164 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* e-addressbook-view.h - * Copyright (C) 2000 Ximian, Inc. - * Author: Chris Lahey <clahey@ximian.com> - * - * This library 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 library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ -#ifndef __EAB_VIEW_H__ -#define __EAB_VIEW_H__ - -#include <gtk/gtkvbox.h> -#include <bonobo/bonobo-ui-component.h> -#include <gal/menus/gal-view-instance.h> -#include <libebook/e-book.h> -#include "e-addressbook-model.h" -#include "eab-contact-display.h" -#include "widgets/menus/gal-view-menus.h" -#include "widgets/misc/e-search-bar.h" -#include "widgets/misc/e-filter-bar.h" - -G_BEGIN_DECLS - -struct _EABMenu; -struct _EABMenuTargetSelect; - -/* EABView - A card displaying information about a contact. - * - * The following arguments are available: - * - * name type read/write description - * -------------------------------------------------------------------------------- - */ - -#define E_TYPE_AB_VIEW (eab_view_get_type ()) -#define EAB_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_AB_VIEW, EABView)) -#define EAB_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_AB_VIEW, EABViewClass)) -#define E_IS_ADDRESSBOOK_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_AB_VIEW)) -#define E_IS_ADDRESSBOOK_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), E_TYPE_AB_VIEW)) - -typedef enum { - EAB_VIEW_NONE, /* initialized to this */ - EAB_VIEW_MINICARD, - EAB_VIEW_TABLE, -#ifdef WITH_ADDRESSBOOK_VIEW_TREEVIEW - ,EAB_VIEW_TREEVIEW -#endif -} EABViewType; - - -typedef struct _EABView EABView; -typedef struct _EABViewClass EABViewClass; - -struct _EABView -{ - GtkVBox parent; - - /* item specific fields */ - EABViewType view_type; - - EABModel *model; - - GtkWidget *invisible; - GList *clipboard_contacts; - - EBook *book; - ESource *source; - char *query; - guint editable : 1; - - gint displayed_contact; - - GObject *object; - GtkWidget *widget; - - GtkWidget *contact_display_window; - GtkWidget *contact_display; - GtkWidget *paned; - - /* Menus handler and the view instance */ - GalViewInstance *view_instance; - GalViewMenus *view_menus; - GalView *current_view; - BonoboUIComponent *uic; - - /* the search bar and related machinery */ - ESearchBar *search; - gint ecml_changed_id; - RuleContext *search_context; - FilterRule *search_rule; -}; - -struct _EABViewClass -{ - GtkVBoxClass parent_class; - - /* - * Signals - */ - void (*status_message) (EABView *view, const gchar *message); - void (*search_result) (EABView *view, EBookViewStatus status); - void (*folder_bar_message) (EABView *view, const gchar *message); - void (*command_state_change) (EABView *view); -}; - -GtkWidget *eab_view_new (void); -GType eab_view_get_type (void); - -void eab_view_show_contact_preview (EABView *view, gboolean show); - -void eab_view_setup_menus (EABView *view, - BonoboUIComponent *uic); -void eab_view_discard_menus (EABView *view); - -RuleContext *eab_view_peek_search_context (EABView *view); -FilterRule *eab_view_peek_search_rule (EABView *view); - -void eab_view_save_as (EABView *view); -void eab_view_view (EABView *view); -void eab_view_send (EABView *view); -void eab_view_send_to (EABView *view); -void eab_view_print (EABView *view); -void eab_view_print_preview (EABView *view); -void eab_view_delete_selection (EABView *view); -void eab_view_cut (EABView *view); -void eab_view_copy (EABView *view); -void eab_view_paste (EABView *view); -void eab_view_select_all (EABView *view); -void eab_view_show_all (EABView *view); -void eab_view_stop (EABView *view); -void eab_view_copy_to_folder (EABView *view); -void eab_view_move_to_folder (EABView *view); - -gboolean eab_view_can_create (EABView *view); -gboolean eab_view_can_print (EABView *view); -gboolean eab_view_can_save_as (EABView *view); -gboolean eab_view_can_view (EABView *view); -gboolean eab_view_can_send (EABView *view); -gboolean eab_view_can_send_to (EABView *view); -gboolean eab_view_can_delete (EABView *view); -gboolean eab_view_can_cut (EABView *view); -gboolean eab_view_can_copy (EABView *view); -gboolean eab_view_can_paste (EABView *view); -gboolean eab_view_can_select_all (EABView *view); -gboolean eab_view_can_stop (EABView *view); -gboolean eab_view_can_copy_to_folder (EABView *view); -gboolean eab_view_can_move_to_folder (EABView *view); - -struct _EABMenuTargetSelect *eab_view_get_menu_target (EABView *view, struct _EABMenu *menu); - -G_END_DECLS; - -#endif /* __EAB_VIEW_H__ */ diff --git a/addressbook/gui/widgets/e-minicard-label.c b/addressbook/gui/widgets/e-minicard-label.c deleted file mode 100644 index df1465349e..0000000000 --- a/addressbook/gui/widgets/e-minicard-label.c +++ /dev/null @@ -1,508 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * e-minicard-label.c - * Copyright (C) 2000 Ximian, Inc. - * Author: Chris Lahey <clahey@ximian.com> - * - * This library 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 library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include <config.h> - -#include "e-minicard-label.h" -#include "eab-marshal.h" - -#include <gtk/gtksignal.h> -#include <libgnomecanvas/gnome-canvas-rect-ellipse.h> -#include <libgnome/gnome-i18n.h> -#include <gal/util/e-util.h> -#include <gal/e-text/e-text.h> -#include <gal/widgets/e-canvas.h> -#include <gal/widgets/e-canvas-utils.h> -#include <gdk/gdkkeysyms.h> - -static void e_minicard_label_init (EMinicardLabel *card); -static void e_minicard_label_class_init (EMinicardLabelClass *klass); -static void e_minicard_label_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec); -static void e_minicard_label_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); -static gboolean e_minicard_label_event (GnomeCanvasItem *item, GdkEvent *event); -static void e_minicard_label_realize (GnomeCanvasItem *item); -static void e_minicard_label_unrealize (GnomeCanvasItem *item); -static void e_minicard_label_reflow(GnomeCanvasItem *item, int flags); -static void e_minicard_label_style_set (EMinicardLabel *label, GtkStyle *previous_style); - -static void e_minicard_label_resize_children( EMinicardLabel *e_minicard_label ); - -static void set_colors (EMinicardLabel *label); - -static GnomeCanvasGroupClass *parent_class = NULL; - -/* The arguments we take */ -enum { - PROP_0, - PROP_WIDTH, - PROP_HEIGHT, - PROP_HAS_FOCUS, - PROP_FIELD, - PROP_FIELDNAME, - PROP_TEXT_MODEL, - PROP_MAX_FIELD_NAME_WIDTH, - PROP_EDITABLE -}; - -enum { - STYLE_SET, - LAST_SIGNAL -}; - -static guint e_minicard_label_signals [LAST_SIGNAL] = {0, }; - -GType -e_minicard_label_get_type (void) -{ - static GType type = 0; - - if (!type) { - static const GTypeInfo info = { - sizeof (EMinicardLabelClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) e_minicard_label_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (EMinicardLabel), - 0, /* n_preallocs */ - (GInstanceInitFunc) e_minicard_label_init, - }; - - type = g_type_register_static (gnome_canvas_group_get_type (), "EMinicardLabel", &info, 0); - } - - return type; -} - -static void -e_minicard_label_class_init (EMinicardLabelClass *klass) -{ - GObjectClass *object_class; - GnomeCanvasItemClass *item_class; - - object_class = G_OBJECT_CLASS (klass); - item_class = (GnomeCanvasItemClass *) klass; - - klass->style_set = e_minicard_label_style_set; - - parent_class = g_type_class_peek_parent (klass); - - object_class->set_property = e_minicard_label_set_property; - object_class->get_property = e_minicard_label_get_property; - /* object_class->destroy = e_minicard_label_destroy; */ - - g_object_class_install_property (object_class, PROP_WIDTH, - g_param_spec_double ("width", - _("Width"), - /*_( */"XXX blurb" /*)*/, - 0.0, G_MAXDOUBLE, 10.0, - G_PARAM_READWRITE)); - - g_object_class_install_property (object_class, PROP_HEIGHT, - g_param_spec_double ("height", - _("Height"), - /*_( */"XXX blurb" /*)*/, - 0.0, G_MAXDOUBLE, 10.0, - G_PARAM_READWRITE)); - - g_object_class_install_property (object_class, PROP_HAS_FOCUS, - g_param_spec_boolean ("has_focus", - _("Has Focus"), - /*_( */"XXX blurb" /*)*/, - FALSE, - G_PARAM_READWRITE)); - - g_object_class_install_property (object_class, PROP_FIELD, - g_param_spec_string ("field", - _("Field"), - /*_( */"XXX blurb" /*)*/, - NULL, - G_PARAM_READWRITE)); - - g_object_class_install_property (object_class, PROP_FIELDNAME, - g_param_spec_string ("fieldname", - _("Field Name"), - /*_( */"XXX blurb" /*)*/, - NULL, - G_PARAM_READWRITE)); - - g_object_class_install_property (object_class, PROP_TEXT_MODEL, - g_param_spec_object ("text_model", - _("Text Model"), - /*_( */"XXX blurb" /*)*/, - E_TYPE_TEXT_MODEL, - G_PARAM_READWRITE)); - - g_object_class_install_property (object_class, PROP_MAX_FIELD_NAME_WIDTH, - g_param_spec_double ("max_field_name_length", - _("Max field name length"), - /*_( */"XXX blurb" /*)*/, - -1.0, G_MAXDOUBLE, -1.0, - G_PARAM_READWRITE)); - - g_object_class_install_property (object_class, PROP_EDITABLE, - g_param_spec_boolean ("editable", - _("Editable"), - /*_( */"XXX blurb" /*)*/, - FALSE, - G_PARAM_READWRITE)); - - e_minicard_label_signals [STYLE_SET] = - g_signal_new ("style_set", - G_TYPE_FROM_CLASS (object_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (EMinicardLabelClass, style_set), - NULL, NULL, - eab_marshal_VOID__OBJECT, - G_TYPE_NONE, 1, - GTK_TYPE_STYLE); - - /* GnomeCanvasItem method overrides */ - item_class->realize = e_minicard_label_realize; - item_class->unrealize = e_minicard_label_unrealize; - item_class->event = e_minicard_label_event; -} - -static void -e_minicard_label_init (EMinicardLabel *minicard_label) -{ - minicard_label->width = 10; - minicard_label->height = 10; - minicard_label->rect = NULL; - minicard_label->fieldname = NULL; - minicard_label->field = NULL; - - minicard_label->max_field_name_length = -1; - - e_canvas_item_set_reflow_callback(GNOME_CANVAS_ITEM(minicard_label), e_minicard_label_reflow); -} - -static void -e_minicard_label_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) -{ - EMinicardLabel *e_minicard_label; - GnomeCanvasItem *item; - - e_minicard_label = E_MINICARD_LABEL (object); - item = GNOME_CANVAS_ITEM (object); - - switch (prop_id){ - case PROP_WIDTH: - e_minicard_label->width = g_value_get_double (value); - e_minicard_label_resize_children(e_minicard_label); - e_canvas_item_request_reflow (item); - break; - case PROP_HAS_FOCUS: - if (e_minicard_label->field && (g_value_get_boolean (value) != E_FOCUS_NONE)) - e_canvas_item_grab_focus(e_minicard_label->field, FALSE); - break; - case PROP_FIELD: - gnome_canvas_item_set( e_minicard_label->field, "text", g_value_get_string (value), NULL ); - break; - case PROP_FIELDNAME: - gnome_canvas_item_set( e_minicard_label->fieldname, "text", g_value_get_string (value), NULL ); - break; - case PROP_TEXT_MODEL: - gnome_canvas_item_set( e_minicard_label->field, "model", g_value_get_object (value), NULL); - break; - case PROP_MAX_FIELD_NAME_WIDTH: - e_minicard_label->max_field_name_length = g_value_get_double (value); - break; - case PROP_EDITABLE: - e_minicard_label->editable = g_value_get_boolean (value); - g_object_set (e_minicard_label->field, "editable", FALSE /* e_minicard_label->editable */, NULL); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -e_minicard_label_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) -{ - EMinicardLabel *e_minicard_label; - - e_minicard_label = E_MINICARD_LABEL (object); - - switch (prop_id) { - case PROP_WIDTH: - g_value_set_double (value, e_minicard_label->width); - break; - case PROP_HEIGHT: - g_value_set_double (value, e_minicard_label->height); - break; - case PROP_HAS_FOCUS: - g_value_set_boolean (value, e_minicard_label->has_focus ? E_FOCUS_CURRENT : E_FOCUS_NONE); - break; - case PROP_FIELD: - g_object_get_property (G_OBJECT (e_minicard_label->field), - "text", value); - break; - case PROP_FIELDNAME: - g_object_get_property (G_OBJECT (e_minicard_label->fieldname), - "text", value); - break; - case PROP_TEXT_MODEL: - g_object_get_property (G_OBJECT (e_minicard_label->field), - "model", value); - break; - case PROP_MAX_FIELD_NAME_WIDTH: - g_value_set_double (value, e_minicard_label->max_field_name_length); - break; - case PROP_EDITABLE: - g_value_set_boolean (value, e_minicard_label->editable); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -e_minicard_label_realize (GnomeCanvasItem *item) -{ - EMinicardLabel *e_minicard_label; - GnomeCanvasGroup *group; - - e_minicard_label = E_MINICARD_LABEL (item); - group = GNOME_CANVAS_GROUP( item ); - - if (GNOME_CANVAS_ITEM_CLASS( parent_class )->realize) - (* GNOME_CANVAS_ITEM_CLASS( parent_class )->realize) (item); - - e_canvas_item_request_reflow(item); - - e_minicard_label->rect = - gnome_canvas_item_new( group, - gnome_canvas_rect_get_type(), - "x1", (double) 0, - "y1", (double) 0, - "x2", (double) e_minicard_label->width - 1, - "y2", (double) e_minicard_label->height - 1, - "outline_color", NULL, - NULL ); - e_minicard_label->fieldname = - gnome_canvas_item_new( group, - e_text_get_type(), - "anchor", GTK_ANCHOR_NW, - "clip_width", (double) ( e_minicard_label->width / 2 - 4 ), - "clip", TRUE, - "use_ellipsis", TRUE, - "fill_color", "black", - "draw_background", FALSE, - "im_context", E_CANVAS (item->canvas)->im_context, - NULL ); - e_canvas_item_move_absolute(e_minicard_label->fieldname, 2, 1); - - e_minicard_label->field = - gnome_canvas_item_new( group, - e_text_get_type(), - "anchor", GTK_ANCHOR_NW, - "clip_width", (double) ( ( e_minicard_label->width + 1 ) / 2 - 4 ), - "clip", TRUE, - "use_ellipsis", TRUE, - "fill_color", "black", - "editable", FALSE, /* e_minicard_label->editable, */ - "draw_background", FALSE, - "im_context", E_CANVAS (item->canvas)->im_context, - NULL ); - e_canvas_item_move_absolute(e_minicard_label->field, ( e_minicard_label->width / 2 + 2), 1); - - set_colors (e_minicard_label); - - e_canvas_item_request_reflow(item); -} - -static void -e_minicard_label_unrealize (GnomeCanvasItem *item) -{ - EMinicardLabel *e_minicard_label; - - e_minicard_label = E_MINICARD_LABEL (item); - - if (GNOME_CANVAS_ITEM_CLASS( parent_class )->unrealize) - (* GNOME_CANVAS_ITEM_CLASS( parent_class )->unrealize) (item); -} - -static gboolean -e_minicard_label_event (GnomeCanvasItem *item, GdkEvent *event) -{ - EMinicardLabel *e_minicard_label; - - e_minicard_label = E_MINICARD_LABEL (item); - - switch( event->type ) { - case GDK_KEY_PRESS: - if (event->key.keyval == GDK_Escape) { - GnomeCanvasItem *parent; - - e_text_cancel_editing (E_TEXT (e_minicard_label->field)); - - parent = GNOME_CANVAS_ITEM (e_minicard_label)->parent; - if (parent) - e_canvas_item_grab_focus(parent, FALSE); - } - break; - case GDK_FOCUS_CHANGE: { - GdkEventFocus *focus_event = (GdkEventFocus *) event; - - e_minicard_label->has_focus = focus_event->in; - set_colors (e_minicard_label); - - g_object_set (e_minicard_label->field, - "handle_popup", e_minicard_label->has_focus, - NULL); - break; - } - case GDK_BUTTON_PRESS: - case GDK_BUTTON_RELEASE: - case GDK_MOTION_NOTIFY: - case GDK_ENTER_NOTIFY: - case GDK_LEAVE_NOTIFY: { - gboolean return_val; - g_signal_emit_by_name(e_minicard_label->field, "event", event, &return_val); - return return_val; - } - default: - break; - } - - if (GNOME_CANVAS_ITEM_CLASS( parent_class )->event) - return (* GNOME_CANVAS_ITEM_CLASS( parent_class )->event) (item, event); - else - return 0; -} - -static void -e_minicard_label_resize_children(EMinicardLabel *e_minicard_label) -{ - double left_width; - if (e_minicard_label->max_field_name_length != -1 && ((e_minicard_label->width / 2) - 4 > e_minicard_label->max_field_name_length)) - left_width = e_minicard_label->max_field_name_length; - else - left_width = e_minicard_label->width / 2 - 4; - - gnome_canvas_item_set( e_minicard_label->fieldname, - "clip_width", (double) MAX ( left_width, 0 ), - NULL ); - gnome_canvas_item_set( e_minicard_label->field, - "clip_width", (double) MAX ( e_minicard_label->width - 8 - left_width, 0 ), - NULL ); -} - -static void -set_colors (EMinicardLabel *label) -{ - if ( (GTK_OBJECT_FLAGS( label ) & GNOME_CANVAS_ITEM_REALIZED) ) { - GtkWidget *canvas = GTK_WIDGET (GNOME_CANVAS_ITEM (label)->canvas); - GtkStyle *style = gtk_widget_get_style (canvas); - if (label->has_focus) { - gnome_canvas_item_set (label->rect, - "outline_color_gdk", &style->mid[GTK_STATE_SELECTED], - "fill_color_gdk", &style->bg[GTK_STATE_NORMAL], - NULL); - - gnome_canvas_item_set (label->field, - "fill_color_gdk", &canvas->style->text[GTK_STATE_NORMAL], - NULL); - - gnome_canvas_item_set (label->fieldname, - "fill_color_gdk", &canvas->style->text[GTK_STATE_NORMAL], - NULL); - } - else { - gnome_canvas_item_set (label->rect, - "outline_color_gdk", NULL, - "fill_color_gdk", NULL, - NULL); - - gnome_canvas_item_set (label->field, - "fill_color_gdk", &canvas->style->text[GTK_STATE_NORMAL], - NULL); - - gnome_canvas_item_set (label->fieldname, - "fill_color_gdk", &canvas->style->text[GTK_STATE_NORMAL], - NULL); - } - } -} - -static void -e_minicard_label_style_set (EMinicardLabel *label, GtkStyle *previous_style) -{ - set_colors (label); -} - -static void -e_minicard_label_reflow(GnomeCanvasItem *item, int flags) -{ - EMinicardLabel *e_minicard_label = E_MINICARD_LABEL(item); - - gint old_height; - gdouble text_height; - gdouble left_width; - - old_height = e_minicard_label->height; - - g_object_get(e_minicard_label->fieldname, - "text_height", &text_height, - NULL); - - e_minicard_label->height = text_height; - - - g_object_get(e_minicard_label->field, - "text_height", &text_height, - NULL); - - if (e_minicard_label->height < text_height) - e_minicard_label->height = text_height; - e_minicard_label->height += 3; - - gnome_canvas_item_set( e_minicard_label->rect, - "x2", (double) e_minicard_label->width - 1, - "y2", (double) e_minicard_label->height - 1, - NULL ); - - gnome_canvas_item_set( e_minicard_label->fieldname, - "clip_height", (double) e_minicard_label->height - 3, - NULL ); - - if (e_minicard_label->max_field_name_length != -1 && ((e_minicard_label->width / 2) - 4 > e_minicard_label->max_field_name_length)) - left_width = e_minicard_label->max_field_name_length; - else - left_width = e_minicard_label->width / 2 - 4; - - e_canvas_item_move_absolute(e_minicard_label->field, left_width + 6, 1); - - if (old_height != e_minicard_label->height) - e_canvas_item_request_parent_reflow(item); -} - -GnomeCanvasItem * -e_minicard_label_new(GnomeCanvasGroup *parent) -{ - GnomeCanvasItem *item = gnome_canvas_item_new(parent, e_minicard_label_get_type(), NULL); - return item; -} - diff --git a/addressbook/gui/widgets/e-minicard-label.h b/addressbook/gui/widgets/e-minicard-label.h deleted file mode 100644 index d914cb30bb..0000000000 --- a/addressbook/gui/widgets/e-minicard-label.h +++ /dev/null @@ -1,86 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* e-minicard-label.h - * Copyright (C) 2000 Ximian, Inc. - * Author: Chris Lahey <clahey@ximian.com> - * - * This library 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 library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ -#ifndef __E_MINICARD_LABEL_H__ -#define __E_MINICARD_LABEL_H__ - -#include <glib.h> -#include <libgnomecanvas/gnome-canvas.h> - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - -/* EMinicardLabel - A label doing focus with non-marching ants. - * - * The following arguments are available: - * - * name type read/write description - * -------------------------------------------------------------------------------- - * width double RW width of the label - * height double R height of the label - * field string RW text in the field label - * fieldname string RW text in the fieldname label - */ - -#define E_TYPE_MINICARD_LABEL (e_minicard_label_get_type ()) -#define E_MINICARD_LABEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_MINICARD_LABEL, EMinicardLabel)) -#define E_MINICARD_LABEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_MINICARD_LABEL, EMiniCardLabelClass)) -#define E_IS_MINICARD_LABEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_MINICARD_LABEL)) -#define E_IS_MINICARD_LABEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), E_TYPE_MINICARD_LABEL)) - - -typedef struct _EMinicardLabel EMinicardLabel; -typedef struct _EMinicardLabelClass EMinicardLabelClass; - -struct _EMinicardLabel -{ - GnomeCanvasGroup parent; - - /* item specific fields */ - double width; - double height; - double max_field_name_length; - guint editable : 1; - GnomeCanvasItem *fieldname; - GnomeCanvasItem *field; - GnomeCanvasItem *rect; - - gboolean has_focus; -}; - -struct _EMinicardLabelClass -{ - GnomeCanvasGroupClass parent_class; - - void (* style_set) (EMinicardLabel *label, GtkStyle *previous_style); -}; - - -GType e_minicard_label_get_type (void); -GnomeCanvasItem *e_minicard_label_new(GnomeCanvasGroup *parent); -void e_minicard_label_construct (GnomeCanvasItem *item); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - - -#endif /* __E_MINICARD_LABEL_H__ */ diff --git a/addressbook/gui/widgets/e-minicard-view-widget.c b/addressbook/gui/widgets/e-minicard-view-widget.c deleted file mode 100644 index ff1bdc1f06..0000000000 --- a/addressbook/gui/widgets/e-minicard-view-widget.c +++ /dev/null @@ -1,440 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * e-minicard-view-widget.c - * Copyright (C) 2000 Ximian, Inc. - * Author: Chris Lahey <clahey@ximian.com> - * - * This library 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 library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include <config.h> - -#include <gtk/gtksignal.h> -#include <gal/widgets/e-canvas-background.h> -#include <gal/widgets/e-canvas.h> -#include <libgnome/gnome-i18n.h> - -#include "eab-marshal.h" -#include "e-minicard-view-widget.h" - -static void e_minicard_view_widget_init (EMinicardViewWidget *widget); -static void e_minicard_view_widget_class_init (EMinicardViewWidgetClass *klass); -static void e_minicard_view_widget_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec); -static void e_minicard_view_widget_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); -static void e_minicard_view_widget_dispose (GObject *object); -static void e_minicard_view_widget_reflow (ECanvas *canvas); -static void e_minicard_view_widget_size_allocate (GtkWidget *widget, GtkAllocation *allocation); -static void e_minicard_view_widget_style_set (GtkWidget *widget, GtkStyle *previous_style); -static void e_minicard_view_widget_realize (GtkWidget *widget); - -static ECanvasClass *parent_class = NULL; - -/* The arguments we take */ -enum { - PROP_0, - PROP_BOOK, - PROP_QUERY, - PROP_EDITABLE, - PROP_COLUMN_WIDTH -}; - -enum { - SELECTION_CHANGE, - COLUMN_WIDTH_CHANGED, - RIGHT_CLICK, - LAST_SIGNAL -}; - -static guint signals [LAST_SIGNAL] = {0, }; - -GType -e_minicard_view_widget_get_type (void) -{ - static GType type = 0; - - if (!type) { - static const GTypeInfo info = { - sizeof (EMinicardViewWidgetClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) e_minicard_view_widget_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (EMinicardViewWidget), - 0, /* n_preallocs */ - (GInstanceInitFunc) e_minicard_view_widget_init, - }; - - type = g_type_register_static (e_canvas_get_type (), "EMinicardViewWidget", &info, 0); - } - - return type; -} - -static void -e_minicard_view_widget_class_init (EMinicardViewWidgetClass *klass) -{ - GObjectClass *object_class; - GtkWidgetClass *widget_class; - ECanvasClass *canvas_class; - - object_class = (GObjectClass*) klass; - widget_class = GTK_WIDGET_CLASS (klass); - canvas_class = E_CANVAS_CLASS (klass); - - parent_class = gtk_type_class (e_canvas_get_type ()); - - object_class->set_property = e_minicard_view_widget_set_property; - object_class->get_property = e_minicard_view_widget_get_property; - object_class->dispose = e_minicard_view_widget_dispose; - - g_object_class_install_property (object_class, PROP_BOOK, - g_param_spec_object ("book", - _("Book"), - /*_( */"XXX blurb" /*)*/, - E_TYPE_BOOK, - G_PARAM_READWRITE)); - - g_object_class_install_property (object_class, PROP_QUERY, - g_param_spec_string ("query", - _("Query"), - /*_( */"XXX blurb" /*)*/, - NULL, - G_PARAM_READWRITE)); - - g_object_class_install_property (object_class, PROP_EDITABLE, - g_param_spec_boolean ("editable", - _("Editable"), - /*_( */"XXX blurb" /*)*/, - FALSE, - G_PARAM_READWRITE)); - - g_object_class_install_property (object_class, PROP_COLUMN_WIDTH, - g_param_spec_double ("column_width", - _("Column Width"), - /*_( */"XXX blurb" /*)*/, - 0.0, G_MAXDOUBLE, 150.0, - G_PARAM_READWRITE)); - - signals [SELECTION_CHANGE] = - g_signal_new ("selection_change", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (EMinicardViewWidgetClass, selection_change), - NULL, NULL, - eab_marshal_NONE__NONE, - G_TYPE_NONE, 0); - - signals [COLUMN_WIDTH_CHANGED] = - g_signal_new ("column_width_changed", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (EMinicardViewWidgetClass, column_width_changed), - NULL, NULL, - eab_marshal_NONE__DOUBLE, - G_TYPE_NONE, 1, G_TYPE_DOUBLE); - - signals [RIGHT_CLICK] = - g_signal_new ("right_click", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (EMinicardViewWidgetClass, right_click), - NULL, NULL, - eab_marshal_INT__POINTER, - G_TYPE_INT, 1, G_TYPE_POINTER); - - widget_class->style_set = e_minicard_view_widget_style_set; - widget_class->realize = e_minicard_view_widget_realize; - widget_class->size_allocate = e_minicard_view_widget_size_allocate; - - canvas_class->reflow = e_minicard_view_widget_reflow; - - klass->selection_change = NULL; - klass->column_width_changed = NULL; - klass->right_click = NULL; -} - -static void -e_minicard_view_widget_init (EMinicardViewWidget *view) -{ - view->emv = NULL; - - view->book = NULL; - view->query = NULL; - view->editable = FALSE; - view->column_width = 150; -} - -GtkWidget * -e_minicard_view_widget_new (EAddressbookReflowAdapter *adapter) -{ - EMinicardViewWidget *widget = E_MINICARD_VIEW_WIDGET (g_object_new (e_minicard_view_widget_get_type (), NULL)); - - widget->adapter = adapter; - g_object_ref (widget->adapter); - - return GTK_WIDGET (widget); -} - -static void -e_minicard_view_widget_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) -{ - EMinicardViewWidget *emvw; - - emvw = E_MINICARD_VIEW_WIDGET (object); - - switch (prop_id){ - case PROP_BOOK: - if (emvw->book) - g_object_unref (emvw->book); - if (g_value_get_object (value)) { - emvw->book = E_BOOK(g_value_get_object (value)); - if (emvw->book) - g_object_ref(emvw->book); - } else - emvw->book = NULL; - if (emvw->emv) - g_object_set(emvw->emv, - "book", emvw->book, - NULL); - break; - case PROP_QUERY: - emvw->query = g_strdup(g_value_get_string (value)); - if (emvw->emv) - g_object_set(emvw->emv, - "query", emvw->query, - NULL); - break; - case PROP_EDITABLE: - emvw->editable = g_value_get_boolean (value); - if (emvw->emv) - g_object_set (emvw->emv, - "editable", emvw->editable, - NULL); - break; - case PROP_COLUMN_WIDTH: - emvw->column_width = g_value_get_double (value); - if (emvw->emv) { - g_object_set (emvw->emv, - "column_width", emvw->column_width, - NULL); - } - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -e_minicard_view_widget_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) -{ - EMinicardViewWidget *emvw; - - emvw = E_MINICARD_VIEW_WIDGET (object); - - switch (prop_id) { - case PROP_BOOK: - g_value_set_object (value, emvw->book); - break; - case PROP_QUERY: - g_value_set_string (value, emvw->query); - break; - case PROP_EDITABLE: - g_value_set_boolean (value, emvw->editable); - break; - case PROP_COLUMN_WIDTH: - g_value_set_double (value, emvw->column_width); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -e_minicard_view_widget_dispose (GObject *object) -{ - EMinicardViewWidget *view = E_MINICARD_VIEW_WIDGET(object); - - if (view->book) { - g_object_unref (view->book); - view->book = NULL; - } - if (view->query) { - g_free(view->query); - view->query = NULL; - } - - if (view->adapter) { - g_object_unref (view->adapter); - view->adapter = NULL; - } - - if (G_OBJECT_CLASS(parent_class)->dispose) - G_OBJECT_CLASS(parent_class)->dispose (object); -} - -static void -selection_change (ESelectionModel *esm, EMinicardViewWidget *widget) -{ - g_signal_emit (widget, - signals [SELECTION_CHANGE], 0); -} - -static void -selection_row_change (ESelectionModel *esm, int row, EMinicardViewWidget *widget) -{ - gboolean selected = e_selection_model_is_row_selected (esm, row); - - /* we only handle the selected case here */ - if (!selected) - return; - - selection_change (esm, widget); -} - -static void -column_width_changed (ESelectionModel *esm, double width, EMinicardViewWidget *widget) -{ - g_signal_emit (widget, - signals [COLUMN_WIDTH_CHANGED], 0, width); -} - -static guint -right_click (EMinicardView *view, GdkEvent *event, EMinicardViewWidget *widget) -{ - guint ret_val; - g_signal_emit (widget, - signals [RIGHT_CLICK], 0, - event, &ret_val); - return ret_val; -} - -static void -e_minicard_view_widget_style_set (GtkWidget *widget, GtkStyle *previous_style) -{ - EMinicardViewWidget *view = E_MINICARD_VIEW_WIDGET(widget); - - if (view->background) - gnome_canvas_item_set (view->background, - "fill_color_gdk", &widget->style->base[GTK_STATE_NORMAL], - NULL ); - - if (GTK_WIDGET_CLASS(parent_class)->style_set) - GTK_WIDGET_CLASS(parent_class)->style_set (widget, previous_style); -} - - -static void -e_minicard_view_widget_realize (GtkWidget *widget) -{ - EMinicardViewWidget *view = E_MINICARD_VIEW_WIDGET(widget); - GtkStyle *style = gtk_widget_get_style (widget); - - view->background = gnome_canvas_item_new(gnome_canvas_root( GNOME_CANVAS(view) ), - e_canvas_background_get_type(), - "fill_color_gdk", &style->base[GTK_STATE_NORMAL], - NULL ); - - view->emv = gnome_canvas_item_new( - gnome_canvas_root( GNOME_CANVAS(view) ), - e_minicard_view_get_type(), - "height", (double) 100, - "minimum_width", (double) 100, - "adapter", view->adapter, - "column_width", view->column_width, - NULL ); - - g_signal_connect (E_REFLOW(view->emv)->selection, - "selection_changed", - G_CALLBACK (selection_change), view); - g_signal_connect (E_REFLOW(view->emv)->selection, - "selection_row_changed", - G_CALLBACK (selection_row_change), view); - g_signal_connect (view->emv, - "column_width_changed", - G_CALLBACK (column_width_changed), view); - g_signal_connect (view->emv, - "right_click", - G_CALLBACK (right_click), view); - - if (GTK_WIDGET_CLASS(parent_class)->realize) - GTK_WIDGET_CLASS(parent_class)->realize (widget); -} - -static void -e_minicard_view_widget_size_allocate(GtkWidget *widget, GtkAllocation *allocation) -{ - if (GTK_WIDGET_CLASS(parent_class)->size_allocate) - GTK_WIDGET_CLASS(parent_class)->size_allocate (widget, allocation); - - if (GTK_WIDGET_REALIZED(widget)) { - double width; - EMinicardViewWidget *view = E_MINICARD_VIEW_WIDGET(widget); - - gnome_canvas_item_set( view->emv, - "height", (double) allocation->height, - NULL ); - gnome_canvas_item_set( view->emv, - "minimum_width", (double) allocation->width, - NULL ); - g_object_get(view->emv, - "width", &width, - NULL); - width = MAX(width, allocation->width); - gnome_canvas_set_scroll_region (GNOME_CANVAS (view), 0, 0, width - 1, allocation->height - 1); - } -} - -static void -e_minicard_view_widget_reflow(ECanvas *canvas) -{ - double width; - EMinicardViewWidget *view = E_MINICARD_VIEW_WIDGET(canvas); - - if (E_CANVAS_CLASS(parent_class)->reflow) - E_CANVAS_CLASS(parent_class)->reflow (canvas); - - g_object_get(view->emv, - "width", &width, - NULL); - width = MAX(width, GTK_WIDGET(canvas)->allocation.width); - gnome_canvas_set_scroll_region(GNOME_CANVAS(canvas), 0, 0, width - 1, GTK_WIDGET(canvas)->allocation.height - 1); -} - -ESelectionModel * -e_minicard_view_widget_get_selection_model (EMinicardViewWidget *view) -{ - if (view->emv) - return E_SELECTION_MODEL (E_REFLOW (view->emv)->selection); - else - return NULL; -} - -EMinicardView * -e_minicard_view_widget_get_view (EMinicardViewWidget *view) -{ - if (view->emv) - return E_MINICARD_VIEW (view->emv); - else - return NULL; -} diff --git a/addressbook/gui/widgets/e-minicard-view-widget.h b/addressbook/gui/widgets/e-minicard-view-widget.h deleted file mode 100644 index ef8401b88c..0000000000 --- a/addressbook/gui/widgets/e-minicard-view-widget.h +++ /dev/null @@ -1,73 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* e-minicard-view-widget.h - * Copyright (C) 2000 Ximian, Inc. - * Author: Chris Lahey <clahey@ximian.com> - * - * This library 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 library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ -#ifndef __E_MINICARD_VIEW_WIDGET_H__ -#define __E_MINICARD_VIEW_WIDGET_H__ - -#include <gal/widgets/e-canvas.h> -#include <libebook/e-book.h> -#include "e-minicard-view.h" - -G_BEGIN_DECLS - -#define E_TYPE_MINICARD_VIEW_WIDGET (e_minicard_view_widget_get_type ()) -#define E_MINICARD_VIEW_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_MINICARD_VIEW_WIDGET, EMinicardViewWidget)) -#define E_MINICARD_VIEW_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_MINICARD_VIEW_WIDGET, EMinicardViewWidgetClass)) -#define E_IS_MINICARD_VIEW_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_MINICARD_VIEW_WIDGET)) -#define E_IS_MINICARD_VIEW_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), E_TYPE_MINICARD_VIEW_WIDGET)) - - -typedef struct _EMinicardViewWidget EMinicardViewWidget; -typedef struct _EMinicardViewWidgetClass EMinicardViewWidgetClass; - -struct _EMinicardViewWidget -{ - ECanvas parent; - - GnomeCanvasItem *background; - GnomeCanvasItem *emv; - - EAddressbookReflowAdapter *adapter; - - EBook *book; - char *query; - guint editable : 1; - - double column_width; -}; - -struct _EMinicardViewWidgetClass -{ - ECanvasClass parent_class; - void (*selection_change) (EMinicardViewWidget *emvw); - void (*column_width_changed) (EMinicardViewWidget *emvw, double width); - guint (*right_click) (EMinicardViewWidget *emvw); -}; - - -GType e_minicard_view_widget_get_type (void); -GtkWidget *e_minicard_view_widget_new (EAddressbookReflowAdapter *adapter); - -/* Get parts of the view widget. */ -ESelectionModel *e_minicard_view_widget_get_selection_model (EMinicardViewWidget *view); -EMinicardView *e_minicard_view_widget_get_view (EMinicardViewWidget *view); - -G_END_DECLS - -#endif /* __E_MINICARD_VIEW_WIDGET_H__ */ diff --git a/addressbook/gui/widgets/e-minicard-view.c b/addressbook/gui/widgets/e-minicard-view.c deleted file mode 100644 index b5803dc658..0000000000 --- a/addressbook/gui/widgets/e-minicard-view.c +++ /dev/null @@ -1,616 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * e-minicard-view.c - * Copyright (C) 2000 Ximian, Inc. - * Author: Chris Lahey <clahey@ximian.com> - * - * This library 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 library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include <config.h> - -#include "e-minicard-view.h" - -#include "eab-gui-util.h" -#include "eab-marshal.h" -#include "util/eab-book-util.h" - -#include <gtk/gtkselection.h> -#include <gtk/gtkdnd.h> -#include <gdk/gdkkeysyms.h> -#include <gal/widgets/e-canvas.h> -#include <libgnome/gnome-i18n.h> -#include <string.h> - -static void e_minicard_view_drag_data_get(GtkWidget *widget, - GdkDragContext *context, - GtkSelectionData *selection_data, - guint info, - guint time, - EMinicardView *view); - -static EReflowClass *parent_class = NULL; -#define PARENT_TYPE (E_REFLOW_TYPE) - -/* The arguments we take */ -enum { - PROP_0, - PROP_ADAPTER, - PROP_BOOK, - PROP_QUERY, - PROP_EDITABLE -}; - - -enum { - RIGHT_CLICK, - LAST_SIGNAL -}; - -static guint signals [LAST_SIGNAL] = {0, }; - -enum DndTargetType { - DND_TARGET_TYPE_VCARD_LIST, - DND_TARGET_TYPE_SOURCE_VCARD_LIST -}; -#define VCARD_LIST_TYPE "text/x-vcard" -#define SOURCE_VCARD_LIST_TYPE "text/x-source-vcard" -static GtkTargetEntry drag_types[] = { - { SOURCE_VCARD_LIST_TYPE, 0, DND_TARGET_TYPE_SOURCE_VCARD_LIST }, - { VCARD_LIST_TYPE, 0, DND_TARGET_TYPE_VCARD_LIST } -}; -static gint num_drag_types = sizeof(drag_types) / sizeof(drag_types[0]); - -static void -e_minicard_view_drag_data_get(GtkWidget *widget, - GdkDragContext *context, - GtkSelectionData *selection_data, - guint info, - guint time, - EMinicardView *view) -{ - if (!E_IS_MINICARD_VIEW(view)) - return; - - switch (info) { - case DND_TARGET_TYPE_VCARD_LIST: { - char *value; - - value = eab_contact_list_to_string (view->drag_list); - - gtk_selection_data_set (selection_data, - selection_data->target, - 8, - value, strlen (value)); - break; - } - case DND_TARGET_TYPE_SOURCE_VCARD_LIST: { - EBook *book; - char *value; - - g_object_get (view->adapter, "book", &book, NULL); - value = eab_book_and_contact_list_to_string (book, view->drag_list); - - gtk_selection_data_set (selection_data, - selection_data->target, - 8, - value, strlen (value)); - break; - } - } -} - -static void -clear_drag_data (EMinicardView *view) -{ - g_list_foreach (view->drag_list, (GFunc)g_object_unref, NULL); - g_list_free (view->drag_list); - view->drag_list = NULL; -} - -static int -e_minicard_view_drag_begin (EAddressbookReflowAdapter *adapter, GdkEvent *event, EMinicardView *view) -{ - GdkDragContext *context; - GtkTargetList *target_list; - GdkDragAction actions = GDK_ACTION_MOVE | GDK_ACTION_COPY; - - clear_drag_data (view); - - view->drag_list = e_minicard_view_get_card_list (view); - - g_print ("dragging %d card(s)\n", g_list_length (view->drag_list)); - - target_list = gtk_target_list_new (drag_types, num_drag_types); - - context = gtk_drag_begin (GTK_WIDGET (GNOME_CANVAS_ITEM (view)->canvas), - target_list, actions, 1/*XXX*/, event); - - if (!view->canvas_drag_data_get_id) - view->canvas_drag_data_get_id = g_signal_connect (GNOME_CANVAS_ITEM (view)->canvas, - "drag_data_get", - G_CALLBACK (e_minicard_view_drag_data_get), - view); - - gtk_drag_set_icon_default (context); - - return TRUE; -} - -static void -set_empty_message (EMinicardView *view) -{ - char *empty_message; - gboolean editable = FALSE; - - if (view->adapter) { - g_object_get (view->adapter, - "editable", &editable, - NULL); - } - - if (editable) - empty_message = _("\n\nThere are no items to show in this view.\n\n" - "Double-click here to create a new Contact."); - else - empty_message = _("\n\nThere are no items to show in this view."); - - g_object_set (view, - "empty_message", empty_message, - NULL); -} - -static void -writable_status_change (EABModel *model, gboolean writable, EMinicardView *view) -{ - set_empty_message (view); -} - -static void -adapter_changed (EMinicardView *view) -{ - set_empty_message (view); - - g_signal_connect (view->adapter, "drag_begin", - G_CALLBACK (e_minicard_view_drag_begin), view); -} - -static void -e_minicard_view_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) -{ - EMinicardView *view; - - view = E_MINICARD_VIEW (object); - - switch (prop_id){ - case PROP_ADAPTER: - if (view->adapter) { - if (view->writable_status_id) { - EABModel *model; - g_object_get (view->adapter, - "model", &model, - NULL); - if (model) { - g_signal_handler_disconnect (model, view->writable_status_id); - } - } - - g_object_unref (view->adapter); - } - view->writable_status_id = 0; - view->adapter = g_value_get_object (value); - g_object_ref (view->adapter); - adapter_changed (view); - g_object_set (view, - "model", view->adapter, - NULL); - if (view->adapter) { - EABModel *model; - g_object_get (view->adapter, - "model", &model, - NULL); - if (model) { - view->writable_status_id = - g_signal_connect (model, "writable_status", - G_CALLBACK (writable_status_change), view); - } - - } - break; - case PROP_BOOK: - g_object_set (view->adapter, - "book", g_value_get_object (value), - NULL); - set_empty_message (view); - break; - case PROP_QUERY: - g_object_set (view->adapter, - "query", g_value_get_string (value), - NULL); - break; - case PROP_EDITABLE: - g_object_set (view->adapter, - "editable", g_value_get_boolean (value), - NULL); - set_empty_message (view); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -e_minicard_view_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) -{ - EMinicardView *view; - - view = E_MINICARD_VIEW (object); - - switch (prop_id) { - case PROP_ADAPTER: - g_value_set_object (value, view->adapter); - break; - case PROP_BOOK: - g_object_get_property (G_OBJECT (view->adapter), - "book", value); - break; - case PROP_QUERY: - g_object_get_property (G_OBJECT (view->adapter), - "query", value); - break; - case PROP_EDITABLE: - g_object_get_property (G_OBJECT (view->adapter), - "editable", value); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -e_minicard_view_dispose (GObject *object) -{ - EMinicardView *view = E_MINICARD_VIEW(object); - - clear_drag_data (view); - - if (view->canvas_drag_data_get_id) { - g_signal_handler_disconnect (GNOME_CANVAS_ITEM (view)->canvas, - view->canvas_drag_data_get_id); - view->canvas_drag_data_get_id = 0; - } - - if (view->adapter) { - if (view->writable_status_id) { - EABModel *model; - g_object_get (view->adapter, - "model", &model, - NULL); - if (model) { - g_signal_handler_disconnect (model, view->writable_status_id); - } - } - - g_object_unref (view->adapter); - } - view->writable_status_id = 0; - view->adapter = NULL; - - if (G_OBJECT_CLASS(parent_class)->dispose) - G_OBJECT_CLASS(parent_class)->dispose (object); -} - -static guint -e_minicard_view_right_click (EMinicardView *view, GdkEvent *event) -{ - guint ret_val = 0; - g_signal_emit (view, signals[RIGHT_CLICK], 0, - event, &ret_val); - return ret_val; -} - -static gboolean -e_minicard_view_event (GnomeCanvasItem *item, GdkEvent *event) -{ - EMinicardView *view; - - view = E_MINICARD_VIEW (item); - - switch( event->type ) { - case GDK_2BUTTON_PRESS: - if (((GdkEventButton *)event)->button == 1) { - gboolean editable; - - g_object_get(view->adapter, "editable", &editable, NULL); - - if (editable) { - EBook *book; - g_object_get(view, "book", &book, NULL); - - if (book && E_IS_BOOK (book)) - eab_show_contact_editor (book, e_contact_new(), TRUE, editable); - } - return TRUE; - } - case GDK_BUTTON_PRESS: - if (event->button.button == 3) { - e_minicard_view_right_click (view, event); - } - break; - case GDK_KEY_PRESS: - if (event->key.keyval & GDK_SHIFT_MASK && - event->key.keyval == GDK_F10) { - e_minicard_view_right_click (view, event); - } - break; - default: - break; - } - - if (GNOME_CANVAS_ITEM_CLASS(parent_class)->event) - return GNOME_CANVAS_ITEM_CLASS(parent_class)->event(item, event); - else - return FALSE; -} - -static gint -e_minicard_view_selection_event (EReflow *reflow, GnomeCanvasItem *item, GdkEvent *event) -{ - EMinicardView *view; - int return_val = FALSE; - - view = E_MINICARD_VIEW (reflow); - if (parent_class->selection_event) { - return_val = parent_class->selection_event (reflow, item, event); - } - - switch (event->type) { - case GDK_FOCUS_CHANGE: - if (event->focus_change.in) { - int i; - for (i = 0; i < reflow->count; i++) { - if (reflow->items[i] == item) { - e_selection_model_maybe_do_something(reflow->selection, i, 0, 0); - break; - } - } - } - break; - case GDK_BUTTON_PRESS: - if (event->button.button == 3) { - return_val = e_minicard_view_right_click (view, event); - if (!return_val) - e_selection_model_right_click_up(reflow->selection); - } - break; - default: - break; - } - return return_val; -} - -typedef struct { - EMinicardView *view; - EBookCallback cb; - gpointer closure; -} ViewCbClosure; - -static void -do_remove (int i, gpointer user_data) -{ - EBook *book; - EContact *contact; - ViewCbClosure *viewcbclosure = user_data; - EMinicardView *view = viewcbclosure->view; - EBookCallback cb = viewcbclosure->cb; - gpointer closure = viewcbclosure->closure; - - g_object_get (view->adapter, - "book", &book, - NULL); - - contact = e_addressbook_reflow_adapter_get_contact (view->adapter, i); - - e_book_async_remove_contact(book, contact, cb, closure); - - g_object_unref (contact); -} - -#if 0 -static int -compare_to_utf_str (EMinicard *card, const char *utf_str) -{ - g_return_val_if_fail(card != NULL, 0); - g_return_val_if_fail(E_IS_MINICARD(card), 0); - - if (g_unichar_isdigit (g_utf8_get_char (utf_str))) { - return 1; - } - - if (card->card) { - char *file_as; - g_object_get(card->card, - "file_as", &file_as, - NULL); - if (file_as) - return g_utf8_strcasecmp (file_as, utf_str); - else - return 0; - } else { - return 0; - } -} -#endif - -static void -e_minicard_view_class_init (EMinicardViewClass *klass) -{ - GObjectClass *object_class; - GnomeCanvasItemClass *item_class; - EReflowClass *reflow_class; - - object_class = G_OBJECT_CLASS (klass); - item_class = (GnomeCanvasItemClass *) klass; - reflow_class = (EReflowClass *) klass; - - parent_class = g_type_class_peek_parent (klass); - - object_class->set_property = e_minicard_view_set_property; - object_class->get_property = e_minicard_view_get_property; - object_class->dispose = e_minicard_view_dispose; - - g_object_class_install_property (object_class, PROP_ADAPTER, - g_param_spec_object ("adapter", - _("Adapter"), - /*_( */"XXX blurb" /*)*/, - E_TYPE_ADDRESSBOOK_REFLOW_ADAPTER, - G_PARAM_READWRITE)); - - g_object_class_install_property (object_class, PROP_BOOK, - g_param_spec_object ("book", - _("Book"), - /*_( */"XXX blurb" /*)*/, - E_TYPE_BOOK, - G_PARAM_READWRITE)); - - g_object_class_install_property (object_class, PROP_QUERY, - g_param_spec_string ("query", - _("Query"), - /*_( */"XXX blurb" /*)*/, - NULL, - G_PARAM_READWRITE)); - - g_object_class_install_property (object_class, PROP_EDITABLE, - g_param_spec_boolean ("editable", - _("Editable"), - /*_( */"XXX blurb" /*)*/, - FALSE, - G_PARAM_READWRITE)); - - signals [RIGHT_CLICK] = - g_signal_new ("right_click", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (EMinicardViewClass, right_click), - NULL, NULL, - eab_marshal_INT__POINTER, - G_TYPE_INT, 1, G_TYPE_POINTER); - - item_class->event = e_minicard_view_event; - - reflow_class->selection_event = e_minicard_view_selection_event; - /* GnomeCanvasItem method overrides */ - - /* init the accessibility support for e_minicard_view */ - e_minicard_view_a11y_init(); -} - -static void -e_minicard_view_init (EMinicardView *view) -{ - view->drag_list = NULL; - view->adapter = NULL; - view->canvas_drag_data_get_id = 0; - view->writable_status_id = 0; - - set_empty_message (view); -} - -GType -e_minicard_view_get_type (void) -{ - static GType reflow_type = 0; - - if (!reflow_type) { - static const GTypeInfo reflow_info = { - sizeof (EMinicardViewClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) e_minicard_view_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (EMinicardView), - 0, /* n_preallocs */ - (GInstanceInitFunc) e_minicard_view_init, - }; - - reflow_type = g_type_register_static (PARENT_TYPE, "EMinicardView", &reflow_info, 0); - } - - return reflow_type; -} - -void -e_minicard_view_remove_selection(EMinicardView *view, - EBookCallback cb, - gpointer closure) -{ - ViewCbClosure viewcbclosure; - viewcbclosure.view = view; - viewcbclosure.cb = cb; - viewcbclosure.closure = closure; - - e_selection_model_foreach (E_REFLOW (view)->selection, - do_remove, - &viewcbclosure); -} - -void -e_minicard_view_jump_to_letter (EMinicardView *view, - gunichar letter) -{ -#if 0 - char uft_str[6 + 1]; - - utf_str [g_unichar_to_utf8 (letter, utf_str)] = '\0'; - e_reflow_sorted_jump (E_REFLOW_SORTED (view), - (GCompareFunc) compare_to_utf_str, - utf_str); -#endif -} - -typedef struct { - GList *list; - EAddressbookReflowAdapter *adapter; -} ModelAndList; - -static void -add_to_list (int index, gpointer closure) -{ - ModelAndList *mal = closure; - mal->list = g_list_prepend (mal->list, e_addressbook_reflow_adapter_get_contact (mal->adapter, index)); -} - -GList * -e_minicard_view_get_card_list (EMinicardView *view) -{ - ModelAndList mal; - - mal.adapter = view->adapter; - mal.list = NULL; - - e_selection_model_foreach (E_REFLOW (view)->selection, add_to_list, &mal); - - mal.list = g_list_reverse (mal.list); - return mal.list; -} diff --git a/addressbook/gui/widgets/e-minicard-view.h b/addressbook/gui/widgets/e-minicard-view.h deleted file mode 100644 index 50964568cf..0000000000 --- a/addressbook/gui/widgets/e-minicard-view.h +++ /dev/null @@ -1,93 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* e-minicard-view.h - * Copyright (C) 2000 Ximian, Inc. - * Author: Chris Lahey <clahey@ximian.com> - * - * This library 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 library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ -#ifndef __E_MINICARD_VIEW_H__ -#define __E_MINICARD_VIEW_H__ - -#include "e-minicard.h" - -#include <gal/widgets/e-reflow.h> -#include <gal/widgets/e-selection-model-simple.h> -#include <libebook/e-book.h> -#include "e-addressbook-reflow-adapter.h" - -G_BEGIN_DECLS - -/* EMinicardView - A canvas item container. - * - * The following arguments are available: - * - * name type read/write description - * -------------------------------------------------------------------------------- - * book EBook RW book to query - * query string RW query string - * - * From EReflowSorted: (you should really know what you're doing if you set these.) - * compare_func GCompareFunc RW compare function - * string_func EReflowStringFunc RW string function - * - * From EReflow: - * minimum_width double RW minimum width of the reflow. width >= minimum_width - * width double R width of the reflow - * height double RW height of the reflow - */ - -#define E_TYPE_MINICARD_VIEW (e_minicard_view_get_type ()) -#define E_MINICARD_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_MINICARD_VIEW, EMinicardView)) -#define E_MINICARD_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_MINICARD_VIEW, EMinicardViewClass)) -#define E_IS_MINICARD_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_MINICARD_VIEW)) -#define E_IS_MINICARD_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), E_TYPE_MINICARD_VIEW)) - - -typedef struct _EMinicardView EMinicardView; -typedef struct _EMinicardViewClass EMinicardViewClass; - -struct _EMinicardView -{ - EReflow parent; - - EAddressbookReflowAdapter *adapter; - - /* item specific fields */ - - GList *drag_list; - - guint canvas_drag_data_get_id; - guint writable_status_id; -}; - -struct _EMinicardViewClass -{ - EReflowClass parent_class; - - void (*right_click) (EMinicardView *view, GdkEvent *event); -}; - -GType e_minicard_view_get_type (void); -void e_minicard_view_remove_selection (EMinicardView *view, - EBookCallback cb, - gpointer closure); -void e_minicard_view_jump_to_letter (EMinicardView *view, - gunichar letter); -GList *e_minicard_view_get_card_list (EMinicardView *view); - - -G_END_DECLS - -#endif /* __E_MINICARD_VIEW_H__ */ diff --git a/addressbook/gui/widgets/e-minicard.c b/addressbook/gui/widgets/e-minicard.c deleted file mode 100644 index 30b0c17af5..0000000000 --- a/addressbook/gui/widgets/e-minicard.c +++ /dev/null @@ -1,1015 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * e-minicard.c - * Copyright (C) 2000 Ximian, Inc. - * Author: Chris Lahey <clahey@ximian.com> - * - * This library 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 library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include <config.h> -#include <string.h> -#include <glib.h> -#include <gtk/gtkdnd.h> -#include <gtk/gtkmain.h> -#include <gdk/gdkkeysyms.h> -#include <libgnome/gnome-i18n.h> -#include <libgnomecanvas/gnome-canvas-rect-ellipse.h> -#include <libgnomecanvas/gnome-canvas-pixbuf.h> -#include <gal/e-text/e-text.h> -#include <gal/util/e-util.h> -#include <gal/widgets/e-canvas-utils.h> -#include <gal/widgets/e-canvas.h> -#include <libebook/e-book.h> -#include "eab-marshal.h" -#include "eab-gui-util.h" -#include "e-minicard.h" -#include "e-minicard-label.h" -#include "e-minicard-view.h" -#include "e-contact-editor.h" -#include <e-util/e-icon-factory.h> -#include "util/e-destination.h" - -static void e_minicard_init (EMinicard *card); -static void e_minicard_class_init (EMinicardClass *klass); -static void e_minicard_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec); -static void e_minicard_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); -static void e_minicard_dispose (GObject *object); -static void e_minicard_finalize (GObject *object); -static gboolean e_minicard_event (GnomeCanvasItem *item, GdkEvent *event); -static void e_minicard_realize (GnomeCanvasItem *item); -static void e_minicard_unrealize (GnomeCanvasItem *item); -static void e_minicard_reflow ( GnomeCanvasItem *item, int flags ); -static void e_minicard_style_set (EMinicard *minicard, GtkStyle *previous_style); - -static void e_minicard_resize_children( EMinicard *e_minicard ); -static void remodel( EMinicard *e_minicard ); - -static gint e_minicard_drag_begin (EMinicard *minicard, GdkEvent *event); - -static GnomeCanvasGroupClass *parent_class = NULL; - -#define d(x) - -#define LIST_ICON_NAME "stock_contact-list" - -static void -e_minicard_field_destroy(EMinicardField *field) -{ - gtk_object_destroy(GTK_OBJECT(field->label)); - g_free(field); -} - -/* The arguments we take */ -enum { - PROP_0, - PROP_WIDTH, - PROP_HEIGHT, - PROP_HAS_FOCUS, - PROP_SELECTED, - PROP_HAS_CURSOR, - PROP_EDITABLE, - PROP_CONTACT -}; - -enum { - SELECTED, - DRAG_BEGIN, - STYLE_SET, - LAST_SIGNAL -}; - -static guint e_minicard_signals [LAST_SIGNAL] = {0, }; - -GType -e_minicard_get_type (void) -{ - static GType type = 0; - - if (!type) { - static const GTypeInfo info = { - sizeof (EMinicardClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) e_minicard_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (EMinicard), - 0, /* n_preallocs */ - (GInstanceInitFunc) e_minicard_init, - }; - - type = g_type_register_static (gnome_canvas_group_get_type (), "EMinicard", &info, 0); - } - - return type; -} - -static void -e_minicard_class_init (EMinicardClass *klass) -{ - GObjectClass *object_class = (GObjectClass*) klass; - GnomeCanvasItemClass *item_class = (GnomeCanvasItemClass *) klass; - - object_class->set_property = e_minicard_set_property; - object_class->get_property = e_minicard_get_property; - object_class->dispose = e_minicard_dispose; - object_class->finalize = e_minicard_finalize; - - klass->style_set = e_minicard_style_set; - - parent_class = gtk_type_class (gnome_canvas_group_get_type ()); - - g_object_class_install_property (object_class, PROP_WIDTH, - g_param_spec_double ("width", - _("Width"), - /*_( */"XXX blurb" /*)*/, - 0.0, G_MAXDOUBLE, 10.0, - G_PARAM_READWRITE)); - - g_object_class_install_property (object_class, PROP_HEIGHT, - g_param_spec_double ("height", - _("Height"), - /*_( */"XXX blurb" /*)*/, - 0.0, G_MAXDOUBLE, 10.0, - G_PARAM_READABLE)); - - g_object_class_install_property (object_class, PROP_HAS_FOCUS, - /* XXX should be _enum */ - g_param_spec_int ("has_focus", - _("Has Focus"), - /*_( */"XXX blurb" /*)*/, - E_MINICARD_FOCUS_TYPE_START, E_MINICARD_FOCUS_TYPE_END, - E_MINICARD_FOCUS_TYPE_START, - G_PARAM_READWRITE)); - - g_object_class_install_property (object_class, PROP_SELECTED, - g_param_spec_boolean ("selected", - _("Selected"), - /*_( */"XXX blurb" /*)*/, - FALSE, - G_PARAM_READWRITE)); - - g_object_class_install_property (object_class, PROP_HAS_CURSOR, - g_param_spec_boolean ("has_cursor", - _("Has Cursor"), - /*_( */"XXX blurb" /*)*/, - FALSE, - G_PARAM_READWRITE)); - - g_object_class_install_property (object_class, PROP_EDITABLE, - g_param_spec_boolean ("editable", - _("Editable"), - /*_( */"XXX blurb" /*)*/, - FALSE, - G_PARAM_READWRITE)); - - g_object_class_install_property (object_class, PROP_CONTACT, - g_param_spec_object ("contact", - _("Contact"), - /*_( */"XXX blurb" /*)*/, - E_TYPE_CONTACT, - G_PARAM_READWRITE)); - - e_minicard_signals [SELECTED] = - g_signal_new ("selected", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (EMinicardClass, selected), - NULL, NULL, - eab_marshal_INT__POINTER, - G_TYPE_INT, 1, G_TYPE_POINTER); - - e_minicard_signals [DRAG_BEGIN] = - g_signal_new ("drag_begin", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (EMinicardClass, drag_begin), - NULL, NULL, - eab_marshal_INT__POINTER, - G_TYPE_INT, 1, G_TYPE_POINTER); - - e_minicard_signals [STYLE_SET] = - g_signal_new ("style_set", - G_TYPE_FROM_CLASS (object_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (EMinicardClass, style_set), - NULL, NULL, - eab_marshal_VOID__OBJECT, - G_TYPE_NONE, 1, - GTK_TYPE_STYLE); - - /* GnomeCanvasItem method overrides */ - item_class->realize = e_minicard_realize; - item_class->unrealize = e_minicard_unrealize; - item_class->event = e_minicard_event; - - klass->selected = NULL; - - /* init the accessibility support for e_minicard */ - e_minicard_a11y_init(); -} - -static void -e_minicard_init (EMinicard *minicard) -{ - minicard->rect = NULL; - minicard->fields = NULL; - minicard->width = 10; - minicard->height = 10; - minicard->has_focus = FALSE; - minicard->selected = FALSE; - minicard->editable = FALSE; - minicard->has_cursor = FALSE; - - minicard->contact = NULL; - - minicard->list_icon_pixbuf = e_icon_factory_get_icon (LIST_ICON_NAME, E_ICON_SIZE_MENU); - minicard->list_icon_size = gdk_pixbuf_get_height (minicard->list_icon_pixbuf); - - minicard->editor = NULL; - - minicard->changed = FALSE; - - e_canvas_item_set_reflow_callback(GNOME_CANVAS_ITEM(minicard), e_minicard_reflow); -} - -static void -set_selected (EMinicard *minicard, gboolean selected) -{ - GtkWidget *canvas = GTK_WIDGET(GNOME_CANVAS_ITEM(minicard)->canvas); - if (selected) { - gnome_canvas_item_set (minicard->rect, - "outline_color_gdk", &canvas->style->bg[GTK_STATE_ACTIVE], - NULL); - gnome_canvas_item_set (minicard->header_rect, - "fill_color_gdk", &canvas->style->bg[GTK_STATE_SELECTED], - NULL); - gnome_canvas_item_set (minicard->header_text, - "fill_color_gdk", &canvas->style->text[GTK_STATE_SELECTED], - NULL); - } else { - gnome_canvas_item_set (minicard->rect, - "outline_color", NULL, - NULL); - gnome_canvas_item_set (minicard->header_rect, - "fill_color_gdk", &canvas->style->bg[GTK_STATE_NORMAL], - NULL); - gnome_canvas_item_set (minicard->header_text, - "fill_color_gdk", &canvas->style->text[GTK_STATE_NORMAL], - NULL); - } - minicard->selected = selected; -} - -static void -set_has_cursor (EMinicard *minicard, gboolean has_cursor) -{ - if (!minicard->has_focus && has_cursor) - e_canvas_item_grab_focus(GNOME_CANVAS_ITEM (minicard), FALSE); - minicard->has_cursor = has_cursor; -} - - -static void -e_minicard_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) -{ - GnomeCanvasItem *item; - EMinicard *e_minicard; - EContact *contact; - GList *l; - - item = GNOME_CANVAS_ITEM (object); - e_minicard = E_MINICARD (object); - - switch (prop_id){ - case PROP_WIDTH: - if (e_minicard->width != g_value_get_double (value)) { - e_minicard->width = g_value_get_double (value); - e_minicard_resize_children(e_minicard); - if ( GTK_OBJECT_FLAGS( e_minicard ) & GNOME_CANVAS_ITEM_REALIZED ) - e_canvas_item_request_reflow(item); - } - break; - case PROP_HAS_FOCUS: - if (e_minicard->fields) { - if ( g_value_get_int(value) == E_FOCUS_START || - g_value_get_int(value) == E_FOCUS_CURRENT) { - gnome_canvas_item_set(E_MINICARD_FIELD(e_minicard->fields->data)->label, - "has_focus", g_value_get_int (value), - NULL); - } else if ( g_value_get_int (value) == E_FOCUS_END ) { - gnome_canvas_item_set(E_MINICARD_FIELD(g_list_last(e_minicard->fields)->data)->label, - "has_focus", g_value_get_int (value), - NULL); - } - } - else { - if (!e_minicard->has_focus) - e_canvas_item_grab_focus(item, FALSE); - } - break; - case PROP_SELECTED: - if (e_minicard->selected != g_value_get_boolean (value)) - set_selected (e_minicard, g_value_get_boolean (value)); - break; - case PROP_EDITABLE: - e_minicard->editable = g_value_get_boolean (value); - for (l = e_minicard->fields; l; l = l->next) { - g_object_set (E_MINICARD_FIELD (l->data)->label, - "editable", FALSE /* e_minicard->editable */, - NULL); - } - break; - case PROP_HAS_CURSOR: - d(g_print("%s: PROP_HAS_CURSOR\n", G_GNUC_FUNCTION)); - if (e_minicard->has_cursor != g_value_get_boolean (value)) - set_has_cursor (e_minicard, g_value_get_boolean (value)); - break; - case PROP_CONTACT: - contact = E_CONTACT (g_value_get_object (value)); - if (contact) - g_object_ref (contact); - - if (e_minicard->contact) - g_object_unref (e_minicard->contact); - - e_minicard->contact = contact; - - remodel(e_minicard); - e_canvas_item_request_reflow(item); - e_minicard->changed = FALSE; - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -e_minicard_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) -{ - EMinicard *e_minicard; - - e_minicard = E_MINICARD (object); - - switch (prop_id) { - case PROP_WIDTH: - g_value_set_double (value, e_minicard->width); - break; - case PROP_HEIGHT: - g_value_set_double (value, e_minicard->height); - break; - case PROP_HAS_FOCUS: - g_value_set_int (value, e_minicard->has_focus ? E_FOCUS_CURRENT : E_FOCUS_NONE); - break; - case PROP_SELECTED: - g_value_set_boolean (value, e_minicard->selected); - break; - case PROP_HAS_CURSOR: - g_value_set_boolean (value, e_minicard->has_cursor); - break; - case PROP_EDITABLE: - g_value_set_boolean (value, e_minicard->editable); - break; - case PROP_CONTACT: - g_value_set_object (value, e_minicard->contact); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -e_minicard_dispose (GObject *object) -{ - EMinicard *e_minicard; - - g_return_if_fail (object != NULL); - g_return_if_fail (E_IS_MINICARD (object)); - - e_minicard = E_MINICARD (object); - - if (e_minicard->fields) { - g_list_foreach(e_minicard->fields, (GFunc) e_minicard_field_destroy, NULL); - g_list_free(e_minicard->fields); - e_minicard->fields = NULL; - } - - if (e_minicard->list_icon_pixbuf) { - gdk_pixbuf_unref (e_minicard->list_icon_pixbuf); - e_minicard->list_icon_pixbuf = NULL; - } - - if (G_OBJECT_CLASS (parent_class)->dispose) - (* G_OBJECT_CLASS (parent_class)->dispose) (object); -} - - - -static void -e_minicard_finalize (GObject *object) -{ - EMinicard *e_minicard; - - g_return_if_fail (object != NULL); - g_return_if_fail (E_IS_MINICARD (object)); - - e_minicard = E_MINICARD (object); - - if (e_minicard->contact) { - g_object_unref (e_minicard->contact); - e_minicard->contact = NULL; - } - - if (e_minicard->list_icon_pixbuf) { - g_object_unref (e_minicard->list_icon_pixbuf); - e_minicard->list_icon_pixbuf = NULL; - } - - if (G_OBJECT_CLASS (parent_class)->finalize) - (* G_OBJECT_CLASS (parent_class)->finalize) (object); -} - -static void -e_minicard_style_set (EMinicard *minicard, GtkStyle *previous_style) -{ - if ( (GTK_OBJECT_FLAGS( minicard ) & GNOME_CANVAS_ITEM_REALIZED) ) - set_selected (minicard, minicard->selected); -} - -static void -e_minicard_realize (GnomeCanvasItem *item) -{ - EMinicard *e_minicard; - GnomeCanvasGroup *group; - GtkWidget *canvas; - - e_minicard = E_MINICARD (item); - group = GNOME_CANVAS_GROUP( item ); - canvas = GTK_WIDGET (GNOME_CANVAS_ITEM (item)->canvas); - - if (GNOME_CANVAS_ITEM_CLASS(parent_class)->realize) - (* GNOME_CANVAS_ITEM_CLASS(parent_class)->realize) (item); - - e_minicard->rect = - gnome_canvas_item_new( group, - gnome_canvas_rect_get_type(), - "x1", (double) 0, - "y1", (double) 0, - "x2", (double) MAX (e_minicard->width - 1, 0), - "y2", (double) MAX (e_minicard->height - 1, 0), - "outline_color", NULL, - NULL ); - - e_minicard->header_rect = - gnome_canvas_item_new( group, - gnome_canvas_rect_get_type(), - "x1", (double) 2, - "y1", (double) 2, - "x2", (double) MAX (e_minicard->width - 3, 0), - "y2", (double) MAX (e_minicard->height - 3, 0), - "fill_color_gdk", &canvas->style->bg[GTK_STATE_NORMAL], - NULL ); - - e_minicard->header_text = - gnome_canvas_item_new( group, - e_text_get_type(), - "anchor", GTK_ANCHOR_NW, - "width", (double) MAX( e_minicard->width - 12, 0 ), - "clip", TRUE, - "use_ellipsis", TRUE, - "fill_color_gdk", &canvas->style->fg[GTK_STATE_NORMAL], - "text", "", - "draw_background", FALSE, - NULL ); - - e_canvas_item_move_absolute(e_minicard->header_text, 6, 6); - - e_minicard->list_icon = - gnome_canvas_item_new ( group, - gnome_canvas_pixbuf_get_type(), - "pixbuf", e_minicard->list_icon_pixbuf, - NULL); - - set_selected (e_minicard, e_minicard->selected); - - remodel(e_minicard); - e_canvas_item_request_reflow(item); -} - -static void -e_minicard_unrealize (GnomeCanvasItem *item) -{ - EMinicard *e_minicard; - - e_minicard = E_MINICARD (item); - - if (GNOME_CANVAS_ITEM_CLASS(parent_class)->unrealize) - (* GNOME_CANVAS_ITEM_CLASS(parent_class)->unrealize) (item); -} - -/* Callback used when the contact editor is closed */ -static void -editor_closed_cb (GtkObject *editor, gpointer data) -{ - EMinicard *minicard = data; - g_object_unref (editor); - minicard->editor = NULL; -} - -static gboolean -activiate_editor(GnomeCanvasItem *item) -{ - EMinicard *e_minicard; - e_minicard = E_MINICARD (item); - - if (e_minicard->editor) { - eab_editor_raise (e_minicard->editor); - } - else { - EBook *book = NULL; - if (E_IS_MINICARD_VIEW(item->parent)) { - g_object_get(item->parent, "book", &book, NULL); - } - - if (book != NULL) { - if (e_contact_get (e_minicard->contact, E_CONTACT_IS_LIST)) { - EContactListEditor *editor = eab_show_contact_list_editor (book, e_minicard->contact, - FALSE, e_minicard->editable); - e_minicard->editor = EAB_EDITOR (editor); - } - else { - EContactEditor *editor = eab_show_contact_editor (book, e_minicard->contact, - FALSE, e_minicard->editable); - e_minicard->editor = EAB_EDITOR (editor); - } - - g_object_ref (e_minicard->editor); - g_signal_connect (e_minicard->editor, "editor_closed", - G_CALLBACK (editor_closed_cb), e_minicard); - - g_object_unref (book); - } - } - - return TRUE; -} - -static gboolean -e_minicard_event (GnomeCanvasItem *item, GdkEvent *event) -{ - EMinicard *e_minicard; - GtkWidget *canvas; - - e_minicard = E_MINICARD (item); - canvas = GTK_WIDGET (GNOME_CANVAS_ITEM (item)->canvas); - - switch( event->type ) { - case GDK_FOCUS_CHANGE: - { - GdkEventFocus *focus_event = (GdkEventFocus *) event; - d(g_print("%s: GDK_FOCUS_CHANGE: %s\n", G_GNUC_FUNCTION, focus_event->in?"in":"out")); - if (focus_event->in) { - /* Chris: When EMinicard gets the cursor, if it doesn't have the focus, it should take it. */ - e_minicard->has_focus = TRUE; - if (!e_minicard->selected) { - e_minicard_selected(e_minicard, event); - } - } - else { - e_minicard->has_focus = FALSE; - } - } - break; - case GDK_BUTTON_PRESS: { - if (1 <= event->button.button && event->button.button <= 2) { - int ret_val = e_minicard_selected(e_minicard, event); - GdkEventMask mask = ((1 << (4 + event->button.button)) | - GDK_POINTER_MOTION_MASK | - GDK_BUTTON_PRESS_MASK | - GDK_BUTTON_RELEASE_MASK); - - e_canvas_item_grab_focus(item, TRUE); - - if (gnome_canvas_item_grab (GNOME_CANVAS_ITEM (e_minicard), - mask, NULL, event->button.time)) { - return FALSE; - } - gtk_grab_add (GTK_WIDGET (GNOME_CANVAS_ITEM (e_minicard)->canvas)); - e_minicard->button_x = event->button.x; - e_minicard->button_y = event->button.y; - e_minicard->drag_button = event->button.button; - e_minicard->drag_button_down = TRUE; - return ret_val; - } else if (event->button.button == 3) { - int ret_val = e_minicard_selected(e_minicard, event); - if (ret_val != 0) - return ret_val; - } - break; - } - case GDK_BUTTON_RELEASE: - e_minicard_selected(e_minicard, event); - if (e_minicard->drag_button == event->button.button) { - e_minicard->drag_button = 0; - e_minicard->drag_button_down = FALSE; - e_minicard->button_x = -1; - e_minicard->button_y = -1; - - if (GTK_WIDGET_HAS_GRAB (GNOME_CANVAS_ITEM (e_minicard)->canvas)) { - gtk_grab_remove (GTK_WIDGET (GNOME_CANVAS_ITEM (e_minicard)->canvas)); - gnome_canvas_item_ungrab (GNOME_CANVAS_ITEM (e_minicard), event->button.time); - } - } - break; - case GDK_MOTION_NOTIFY: - if (e_minicard->drag_button_down && event->motion.state & GDK_BUTTON1_MASK) { - if (MAX (abs (e_minicard->button_x - event->motion.x), - abs (e_minicard->button_y - event->motion.y)) > 3) { - gint ret_val; - - ret_val = e_minicard_drag_begin(e_minicard, event); - - e_minicard->drag_button_down = FALSE; - - return ret_val; - } - } - break; - case GDK_2BUTTON_PRESS: - if (event->button.button == 1 && E_IS_MINICARD_VIEW(item->parent)) { - return activiate_editor(item); - } - break; - case GDK_KEY_PRESS: - if (event->key.keyval == GDK_Tab || - event->key.keyval == GDK_KP_Tab || - event->key.keyval == GDK_ISO_Left_Tab) { - - EMinicardView *view = E_MINICARD_VIEW(item->parent); - EReflow *reflow = E_REFLOW(view); - - if (reflow == NULL) { - return FALSE; - } - - if (event->key.state & GDK_SHIFT_MASK) { - if (event->key.state & GDK_CONTROL_MASK) { - return FALSE; - } - else { - int row_count = e_selection_model_row_count(reflow->selection); - int model_index = e_selection_model_cursor_row (reflow->selection); - int view_index = e_sorter_model_to_sorted (reflow->selection->sorter, model_index); - - if (view_index == 0) - view_index = row_count-1; - else - view_index--; - - model_index = e_sorter_sorted_to_model (E_SORTER (reflow->sorter), view_index); - e_canvas_item_grab_focus(reflow->items[model_index], FALSE); - return TRUE; - } - } - else { - if (event->key.state & GDK_CONTROL_MASK) { - return FALSE; - } - else { - int row_count = e_selection_model_row_count(reflow->selection); - int model_index = e_selection_model_cursor_row (reflow->selection); - int view_index = e_sorter_model_to_sorted (reflow->selection->sorter, model_index); - - if (view_index == row_count-1) - view_index = 0; - else - view_index++; - - model_index = e_sorter_sorted_to_model (E_SORTER (reflow->sorter), view_index); - e_canvas_item_grab_focus(reflow->items[model_index], FALSE); - return TRUE; - } - } - } - else if (event->key.keyval == GDK_Return || - event->key.keyval == GDK_KP_Enter) { - return activiate_editor(item); - } - break; - default: - break; - } - - if (GNOME_CANVAS_ITEM_CLASS( parent_class )->event) - return (* GNOME_CANVAS_ITEM_CLASS( parent_class )->event) (item, event); - else - return 0; -} - -static void -e_minicard_resize_children( EMinicard *e_minicard ) -{ - GList *list; - gboolean is_list = GPOINTER_TO_INT (e_contact_get (e_minicard->contact, E_CONTACT_IS_LIST)); - - if (e_minicard->header_text) { - gnome_canvas_item_set( e_minicard->header_text, - "width", ((double) e_minicard->width - 12 - - (is_list ? e_minicard->list_icon_size : 0.0)), - NULL ); - } - if (e_minicard->list_icon) { - e_canvas_item_move_absolute(e_minicard->list_icon, - e_minicard->width - e_minicard->list_icon_size - 3, - 3); - } - for ( list = e_minicard->fields; list; list = g_list_next( list ) ) { - gnome_canvas_item_set( E_MINICARD_FIELD( list->data )->label, - "width", (double) e_minicard->width - 4.0, - NULL ); - } -} - -static void -add_field (EMinicard *e_minicard, EContactField field, gdouble left_width) -{ - GnomeCanvasItem *new_item; - GnomeCanvasGroup *group; - EMinicardField *minicard_field; - char *name; - char *string; - - group = GNOME_CANVAS_GROUP( e_minicard ); - - name = g_strdup_printf("%s:", e_contact_pretty_name (field)); - string = e_contact_get (e_minicard->contact, field); - - new_item = e_minicard_label_new(group); - gnome_canvas_item_set( new_item, - "width", e_minicard->width - 4.0, - "fieldname", name, - "field", string, - "max_field_name_length", left_width, - "editable", FALSE /* e_minicard->editable */, - NULL ); -#if notyet - g_object_set(E_MINICARD_LABEL(new_item)->field, - "allow_newlines", e_card_simple_get_allow_newlines (e_minicard->contact, field), - NULL); -#endif - g_object_set_data(G_OBJECT (E_MINICARD_LABEL(new_item)->field), - "EMinicard:field", - GINT_TO_POINTER(field)); - - minicard_field = g_new(EMinicardField, 1); - minicard_field->field = field; - minicard_field->label = new_item; - - e_minicard->fields = g_list_append( e_minicard->fields, minicard_field); - e_canvas_item_move_absolute(new_item, 2, e_minicard->height); - g_free(name); - g_free(string); -} - -static int -get_left_width(EMinicard *e_minicard) -{ - gchar *name; - EContactField field; - int width = -1; - PangoLayout *layout; - - layout = gtk_widget_create_pango_layout (GTK_WIDGET (GNOME_CANVAS_ITEM (e_minicard)->canvas), ""); - for(field = E_CONTACT_FULL_NAME; field != E_CONTACT_LAST_SIMPLE_STRING; field++) { - int this_width; - - if (field == E_CONTACT_FAMILY_NAME || field == E_CONTACT_GIVEN_NAME) - continue; - - name = g_strdup_printf("%s:", e_contact_pretty_name (field)); - pango_layout_set_text (layout, name, -1); - pango_layout_get_pixel_size (layout, &this_width, NULL); - if (width < this_width) - width = this_width; - g_free(name); - } - g_object_unref (layout); - return width; -} - -static void -remodel( EMinicard *e_minicard ) -{ - int count = 0; - if ( !(GTK_OBJECT_FLAGS( e_minicard ) & GNOME_CANVAS_ITEM_REALIZED) ) - return; - if (e_minicard->contact) { - EContactField field; - GList *list; - char *file_as; - int left_width = -1; - - if (e_minicard->header_text) { - file_as = e_contact_get (e_minicard->contact, E_CONTACT_FILE_AS); - gnome_canvas_item_set (e_minicard->header_text, - "text", file_as ? file_as : "", - NULL ); - g_free(file_as); - } - - if (e_minicard->contact && e_contact_get (e_minicard->contact, E_CONTACT_IS_LIST)) - gnome_canvas_item_show (e_minicard->list_icon); - else - gnome_canvas_item_hide (e_minicard->list_icon); - - list = e_minicard->fields; - e_minicard->fields = NULL; - - for(field = E_CONTACT_FULL_NAME; field != E_CONTACT_LAST_SIMPLE_STRING && count < 5; field++) { - EMinicardField *minicard_field = NULL; - - if (field == E_CONTACT_FAMILY_NAME || field == E_CONTACT_GIVEN_NAME) - continue; - - if (list) - minicard_field = list->data; - if (minicard_field && minicard_field->field == field) { - GList *this_list = list; - char *string; - - string = e_contact_get(e_minicard->contact, field); - if (string && *string) { - e_minicard->fields = g_list_append(e_minicard->fields, minicard_field); - g_object_set(minicard_field->label, - "field", string, - NULL); - count ++; - } else { - e_minicard_field_destroy(minicard_field); - } - list = g_list_remove_link(list, this_list); - g_list_free_1(this_list); - g_free(string); - } else { - char *string; - if (left_width == -1) { - left_width = get_left_width(e_minicard); - } - - string = e_contact_get(e_minicard->contact, field); - if (string && *string) { - add_field(e_minicard, field, left_width); - count++; - } - g_free(string); - } - } - - g_list_foreach(list, (GFunc) e_minicard_field_destroy, NULL); - g_list_free(list); - } -} - -static void -e_minicard_reflow( GnomeCanvasItem *item, int flags ) -{ - EMinicard *e_minicard = E_MINICARD(item); - if ( GTK_OBJECT_FLAGS( e_minicard ) & GNOME_CANVAS_ITEM_REALIZED ) { - GList *list; - gdouble text_height; - gint old_height; - - old_height = e_minicard->height; - - g_object_get( e_minicard->header_text, - "text_height", &text_height, - NULL ); - - e_minicard->height = text_height + 10.0; - - gnome_canvas_item_set( e_minicard->header_rect, - "y2", text_height + 9.0, - NULL ); - - for(list = e_minicard->fields; list; list = g_list_next(list)) { - EMinicardField *field = E_MINICARD_FIELD(list->data); - GnomeCanvasItem *item = field->label; - g_object_get (item, - "height", &text_height, - NULL); - e_canvas_item_move_absolute(item, 2, e_minicard->height); - e_minicard->height += text_height; - } - e_minicard->height += 2; - - gnome_canvas_item_set( e_minicard->rect, - "x2", (double) e_minicard->width - 1.0, - "y2", (double) e_minicard->height - 1.0, - NULL ); - gnome_canvas_item_set( e_minicard->header_rect, - "x2", (double) e_minicard->width - 3.0, - NULL ); - - if (old_height != e_minicard->height) - e_canvas_item_request_parent_reflow(item); - } -} - -const char * -e_minicard_get_card_id (EMinicard *minicard) -{ - g_return_val_if_fail(minicard != NULL, NULL); - g_return_val_if_fail(E_IS_MINICARD(minicard), NULL); - - if (minicard->contact) { - return e_contact_get_const (minicard->contact, E_CONTACT_UID); - } else { - return ""; - } -} - -int -e_minicard_compare (EMinicard *minicard1, EMinicard *minicard2) -{ - int cmp = 0; - - g_return_val_if_fail(minicard1 != NULL, 0); - g_return_val_if_fail(E_IS_MINICARD(minicard1), 0); - g_return_val_if_fail(minicard2 != NULL, 0); - g_return_val_if_fail(E_IS_MINICARD(minicard2), 0); - - if (minicard1->contact && minicard2->contact) { - char *file_as1, *file_as2; - g_object_get(minicard1->contact, - "file_as", &file_as1, - NULL); - g_object_get(minicard2->contact, - "file_as", &file_as2, - NULL); - - if (file_as1 && file_as2) - cmp = g_utf8_collate(file_as1, file_as2); - else if (file_as1) - cmp = -1; - else if (file_as2) - cmp = 1; - else - cmp = strcmp(e_minicard_get_card_id(minicard1), e_minicard_get_card_id(minicard2)); - - g_free (file_as1); - g_free (file_as2); - } - - return cmp; -} - -int -e_minicard_selected (EMinicard *minicard, GdkEvent *event) -{ - gint ret_val = 0; - GnomeCanvasItem *item = GNOME_CANVAS_ITEM (minicard); - if (item->parent) { - guint signal_id = g_signal_lookup ("selection_event", G_OBJECT_TYPE (item->parent)); - /* We should probably check the signature here, but I - * don't think it's worth the time required to code - * it. - */ - if (signal_id != 0) { - g_signal_emit(item->parent, - signal_id, 0, - item, event, &ret_val); - } - } - return ret_val; -} - -static gint -e_minicard_drag_begin (EMinicard *minicard, GdkEvent *event) -{ - gint ret_val = 0; - GnomeCanvasItem *parent; - g_signal_emit (minicard, - e_minicard_signals[DRAG_BEGIN], 0, - event, &ret_val); - - parent = GNOME_CANVAS_ITEM (minicard)->parent; - if (parent && E_IS_REFLOW (parent)) { - E_REFLOW (parent)->maybe_in_drag = FALSE; - } - return ret_val; -} diff --git a/addressbook/gui/widgets/e-minicard.h b/addressbook/gui/widgets/e-minicard.h deleted file mode 100644 index dd6ab33199..0000000000 --- a/addressbook/gui/widgets/e-minicard.h +++ /dev/null @@ -1,131 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* e-minicard.h - * Copyright (C) 2000 Ximian, Inc. - * Author: Chris Lahey <clahey@ximian.com> - * - * This library 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 library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ -#ifndef __E_MINICARD_H__ -#define __E_MINICARD_H__ - -#include <gdk-pixbuf/gdk-pixbuf.h> -#include "addressbook/gui/contact-editor/eab-editor.h" -#include <libgnomecanvas/gnome-canvas.h> -#include <libebook/e-contact.h> - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - -/* EMinicard - A small card displaying information about a contact. - * - * The following arguments are available: - * - * name type read/write description - * -------------------------------------------------------------------------------- - * width double RW width of the card - * height double R height of the card - * card ECard* RW Pointer to the ECard - */ - -#define E_TYPE_MINICARD (e_minicard_get_type ()) -#define E_MINICARD(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_MINICARD, EMinicard)) -#define E_MINICARD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_MINICARD, EMinicardClass)) -#define E_IS_MINICARD(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_MINICARD)) -#define E_IS_MINICARD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), E_TYPE_MINICARD)) - - -typedef struct _EMinicard EMinicard; -typedef struct _EMinicardClass EMinicardClass; -typedef enum _EMinicardFocusType EMinicardFocusType; - -enum _EMinicardFocusType { - E_MINICARD_FOCUS_TYPE_START, - E_MINICARD_FOCUS_TYPE_END -}; - -struct _EMinicard -{ - GnomeCanvasGroup parent; - - /* item specific fields */ - EContact *contact; - - GnomeCanvasItem *rect; - GnomeCanvasItem *header_rect; - GnomeCanvasItem *header_text; - GnomeCanvasItem *list_icon; - - GdkPixbuf *list_icon_pixbuf; - double list_icon_size; - - EABEditor *editor; - - GList *fields; /* Of type EMinicardField */ - guint needs_remodeling : 1; - - guint changed : 1; - - guint selected : 1; - guint has_cursor : 1; - - guint has_focus : 1; - - guint editable : 1; - - guint drag_button_down : 1; - gint drag_button; - - gint button_x; - gint button_y; - - double width; - double height; -}; - -struct _EMinicardClass -{ - GnomeCanvasGroupClass parent_class; - - gint (* selected) (EMinicard *minicard, GdkEvent *event); - gint (* drag_begin) (EMinicard *minicard, GdkEvent *event); - - void (* style_set) (EMinicard *minicard, GtkStyle *previous_style); -}; - -typedef struct _EMinicardField EMinicardField; - -struct _EMinicardField { - EContactField field; - GnomeCanvasItem *label; -}; - -#define E_MINICARD_FIELD(field) ((EMinicardField *)(field)) - -GType e_minicard_get_type (void); -const char *e_minicard_get_card_id (EMinicard *minicard); -int e_minicard_compare (EMinicard *minicard1, - EMinicard *minicard2); - -int e_minicard_selected (EMinicard *minicard, - GdkEvent *event); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - - -#endif /* __E_MINICARD_H__ */ diff --git a/addressbook/gui/widgets/eab-config.c b/addressbook/gui/widgets/eab-config.c deleted file mode 100644 index 18837289e0..0000000000 --- a/addressbook/gui/widgets/eab-config.c +++ /dev/null @@ -1,189 +0,0 @@ -/* - * Authors: David Trowbridge <trowbrds@cs.colorado.edu> - * - * Copyright (C) 2004 Novell, Inc (www.novell.com) - * - * 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. - * - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include "eab-config.h" - -static GObjectClass *ecp_parent_class; -static GObjectClass *ecph_parent_class; - -struct _EABConfigPrivate { - ulong source_changed_id; -}; - -#define _PRIVATE(o) (g_type_instance_get_private((GTypeInstance *)o, eab_config_get_type())) - -static void -ecp_init (GObject *o) -{ -} - -static void -ecp_target_free (EConfig *ec, EConfigTarget *t) -{ - struct _EABConfigPrivate *p = _PRIVATE(ec); - - if (ec->target == t) { - switch (t->type) { - case EAB_CONFIG_TARGET_SOURCE: { - EABConfigTargetSource *s = (EABConfigTargetSource *)t; - - if (p->source_changed_id) { - g_signal_handler_disconnect(s->source, p->source_changed_id); - p->source_changed_id = 0; - } - break; } - } - } - - switch (t->type) { - case EAB_CONFIG_TARGET_SOURCE: { - EABConfigTargetSource *s = (EABConfigTargetSource *)t; - - if (s->source) - g_object_unref (s->source); - break; } - } - - ((EConfigClass *) ecp_parent_class)->target_free (ec, t); -} - -static void -ecp_source_changed(struct _ESource *source, EConfig *ec) -{ - e_config_target_changed(ec, E_CONFIG_TARGET_CHANGED_STATE); -} - -static void -ecp_set_target (EConfig *ec, EConfigTarget *t) -{ - struct _EABConfigPrivate *p = _PRIVATE(ec); - - ((EConfigClass *)ecp_parent_class)->set_target(ec, t); - - if (t) { - switch (t->type) { - case EAB_CONFIG_TARGET_SOURCE: { - EABConfigTargetSource *s = (EABConfigTargetSource *)t; - - p->source_changed_id = g_signal_connect(s->source, "changed", G_CALLBACK(ecp_source_changed), ec); - break; } - } - } -} - -static void -ecp_class_init (GObjectClass *klass) -{ - ((EConfigClass *)klass)->set_target = ecp_set_target; - ((EConfigClass *)klass)->target_free = ecp_target_free; - - g_type_class_add_private(klass, sizeof(struct _EABConfigPrivate)); -} - -GType -eab_config_get_type (void) -{ - static GType type = 0; - - if (!type) { - static const GTypeInfo info = { - sizeof (EABConfigClass), - NULL, NULL, - (GClassInitFunc) ecp_class_init, - NULL, NULL, - sizeof (EABConfig), 0, - (GInstanceInitFunc) ecp_init - }; - - ecp_parent_class = g_type_class_ref (e_config_get_type ()); - type = g_type_register_static (e_config_get_type (), "EABConfig", &info, 0); - } - - return type; -} - -EABConfig * -eab_config_new (int type, const char *menuid) -{ - EABConfig *ecp = g_object_new (eab_config_get_type(), 0); - e_config_construct (&ecp->config, type, menuid); - return ecp; -} - -EABConfigTargetSource * -eab_config_target_new_source (EABConfig *ecp, struct _ESource *source) -{ - EABConfigTargetSource *t = e_config_target_new (&ecp->config, EAB_CONFIG_TARGET_SOURCE, sizeof (*t)); - - t->source = source; - g_object_ref (source); - - return t; -} - -static const EConfigHookTargetMask ecph_no_masks[] = { - { 0 } -}; - -static const EConfigHookTargetMap ecph_targets[] = { - { "source", EAB_CONFIG_TARGET_SOURCE, ecph_no_masks }, - { 0 }, -}; - -static void -ecph_class_init (EPluginHookClass *klass) -{ - int i; - - klass->id = "org.gnome.evolution.addressbook.config:1.0"; - - for (i = 0; ecph_targets[i].type; i++) { - e_config_hook_class_add_target_map ((EConfigHookClass *)klass, &ecph_targets[i]); - } - - ((EConfigHookClass *)klass)->config_class = g_type_class_ref (eab_config_get_type ()); -} - -GType -eab_config_hook_get_type (void) -{ - static GType type = 0; - - if (!type) { - static const GTypeInfo info = { - sizeof (EABConfigHookClass), - NULL, NULL, - (GClassInitFunc) ecph_class_init, - NULL, NULL, - sizeof (EABConfigHook), 0, - (GInstanceInitFunc) NULL - }; - - ecph_parent_class = g_type_class_ref (e_config_hook_get_type ()); - type = g_type_register_static (e_config_hook_get_type (), "EABConfigHook", &info, 0); - } - - return type; -} diff --git a/addressbook/gui/widgets/eab-config.h b/addressbook/gui/widgets/eab-config.h deleted file mode 100644 index 93d26abf1c..0000000000 --- a/addressbook/gui/widgets/eab-config.h +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Authors: David Trowbridge <trowbrds@cs.colorado.edu> - * - * Copyright (C) 2004 Novell, Inc (www.novell.com) - * - * 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. - * - */ - -#ifndef __EAB_CONFIG_H__ -#define __EAB_CONFIG_H__ - -#include <glib-object.h> - -#include "e-util/e-config.h" - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif - -typedef struct _EABConfig EABConfig; -typedef struct _EABConfigClass EABConfigClass; - -struct _EABConfig { - EConfig config; -}; - -struct _EABConfigClass { - EConfigClass config_class; -}; - -enum _eab_config_target_t { - EAB_CONFIG_TARGET_SOURCE, -}; - -typedef struct _EABConfigTargetSource EABConfigTargetSource; - -struct _EABConfigTargetSource { - EConfigTarget target; - - struct _ESource *source; -}; - -typedef struct _EConfigItem EABConfigItem; - -GType eab_config_get_type (void); -EABConfig *eab_config_new (int type, const char *menuid); - -EABConfigTargetSource *eab_config_target_new_source (EABConfig *ecp, struct _ESource *source); - -/* ********************************************************************** */ - -typedef struct _EABConfigHook EABConfigHook; -typedef struct _EABConfigHookClass EABConfigHookClass; - -struct _EABConfigHook { - EConfigHook hook; -}; - -struct _EABConfigHookClass { - EConfigHookClass hook_class; -}; - -GType eab_config_hook_get_type (void); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/addressbook/gui/widgets/eab-contact-display.c b/addressbook/gui/widgets/eab-contact-display.c deleted file mode 100644 index 9e7d66cf3e..0000000000 --- a/addressbook/gui/widgets/eab-contact-display.c +++ /dev/null @@ -1,692 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Authors: Chris Toshok <toshok@ximian.com> - * - * Copyright (C) 2003 Ximian, Inc. (www.ximian.com) - * - * 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 Street #330, Boston, MA 02111-1307, USA. - * - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include "eab-contact-display.h" - -#include "eab-gui-util.h" -#include "e-util/e-html-utils.h" -#include "e-util/e-icon-factory.h" - -#include <string.h> -#include <libgnome/gnome-i18n.h> -#include <libgnome/gnome-url.h> -#include <gtkhtml/gtkhtml.h> -#include <gtkhtml/gtkhtml-stream.h> - -#define HANDLE_MAILTO_INTERNALLY 1 - -#define PARENT_TYPE (GTK_TYPE_HTML) - -struct _EABContactDisplayPrivate { - EContact *contact; -}; - - -#define HTML_HEADER "<!doctype html public \"-//W3C//DTD HTML 4.0 TRANSITIONAL//EN\">\n<html>\n" \ - "<head>\n<meta name=\"generator\" content=\"Evolution Addressbook Component\">\n</head>\n" - -#define HEADER_COLOR "#7f7f7f" -#define IMAGE_COL_WIDTH "20" -#define CONTACT_LIST_ICON "stock_contact-list" -#define AIM_ICON "im-aim" -#define GROUPWISE_ICON "im-nov" -#define ICQ_ICON "im-icq" -#define JABBER_ICON "im-jabber" -#define MSN_ICON "im-msn" -#define YAHOO_ICON "im-yahoo" -#define VIDEOCONF_ICON "stock_video-conferencing" - -#define MAX_COMPACT_IMAGE_DIMENSION 48 - -static void -on_url_requested (GtkHTML *html, const char *url, GtkHTMLStream *handle, - EABContactDisplay *display) -{ - if (!strcmp (url, "internal-contact-photo:")) { - EContactPhoto *photo; - - photo = e_contact_get (display->priv->contact, E_CONTACT_PHOTO); - if (!photo) - photo = e_contact_get (display->priv->contact, E_CONTACT_LOGO); - - gtk_html_stream_write (handle, photo->data, photo->length); - - gtk_html_end (html, handle, GTK_HTML_STREAM_OK); - } - else if (!strncmp (url, "evo-icon:", strlen ("evo-icon:"))) { - gchar *data; - gsize data_length; - gchar *filename; - - filename = e_icon_factory_get_icon_filename (url + strlen ("evo-icon:"), E_ICON_SIZE_MENU); - if (g_file_get_contents (filename, &data, &data_length, NULL)) { - gtk_html_stream_write (handle, data, data_length); - g_free (data); - } - - gtk_html_stream_close (handle, GTK_HTML_STREAM_OK); - - g_free (filename); - } -} - -static void -on_link_clicked (GtkHTML *html, const char *url, EABContactDisplay *display) -{ - GError *err = NULL; - -#ifdef HANDLE_MAILTO_INTERNALLY - if (!strncmp (url, "internal-mailto:", strlen ("internal-mailto:"))) { - int mail_num = atoi (url + strlen ("internal-mailto:")); - - if (mail_num == -1) - return; - - eab_send_contact (display->priv->contact, mail_num, EAB_DISPOSITION_AS_TO); - - return; - } -#endif - - gnome_url_show (url, &err); - - if (err) { - g_warning ("gnome_url_show: %s", err->message); - g_error_free (err); - } -} - -#if 0 -static void -render_address (GtkHTMLStream *html_stream, EContact *contact, const char *html_label, EContactField adr_field, EContactField label_field) -{ - EContactAddress *adr; - const char *label; - - label = e_contact_get_const (contact, label_field); - if (label) { - char *html = e_text_to_html (label, E_TEXT_TO_HTML_CONVERT_NL); - - gtk_html_stream_printf (html_stream, "<tr><td valign=\"top\" width=\"" IMAGE_COL_WIDTH "\"></td><td valign=\"top\" width=\"100\"><font color=" HEADER_COLOR ">%s:</font><br><a href=\"http://www.mapquest.com/\">%s</a></td><td valign=\"top\">%s</td></tr>", html_label, _("(map)"), html); - - g_free (html); - return; - } - - adr = e_contact_get (contact, adr_field); - if (adr && - (adr->po || adr->ext || adr->street || adr->locality || adr->region || adr->code || adr->country)) { - - gtk_html_stream_printf (html_stream, "<tr><td valign=\"top\" width=\"" IMAGE_COL_WIDTH "\"></td><td valign=\"top\" width=\"100\"><font color=" HEADER_COLOR ">%s:</font><br><a href=\"http://www.mapquest.com/\">%s</a></td><td valign=\"top\">", html_label, _("map")); - - if (adr->po && *adr->po) gtk_html_stream_printf (html_stream, "%s<br>", adr->po); - if (adr->ext && *adr->ext) gtk_html_stream_printf (html_stream, "%s<br>", adr->ext); - if (adr->street && *adr->street) gtk_html_stream_printf (html_stream, "%s<br>", adr->street); - if (adr->locality && *adr->locality) gtk_html_stream_printf (html_stream, "%s<br>", adr->locality); - if (adr->region && *adr->region) gtk_html_stream_printf (html_stream, "%s<br>", adr->region); - if (adr->code && *adr->code) gtk_html_stream_printf (html_stream, "%s<br>", adr->code); - if (adr->country && *adr->country) gtk_html_stream_printf (html_stream, "%s<br>", adr->country); - - gtk_html_stream_printf (html_stream, "</td></tr>"); - } - if (adr) - e_contact_address_free (adr); -} -#endif - -static void -render_name_value (GtkHTMLStream *html_stream, const char *label, const char *str, const char *icon, unsigned int html_flags) -{ - char *value = e_text_to_html (str, html_flags); - - gtk_html_stream_printf (html_stream, "<tr><td valign=\"top\" width=\"" IMAGE_COL_WIDTH "\">"); - if (icon) - gtk_html_stream_printf (html_stream, "<img width=\"16\" height=\"16\" src=\"evo-icon:%s\">", icon); - gtk_html_stream_printf (html_stream, "</td><td valign=\"top\" width=\"100\" nowrap><font color=" HEADER_COLOR ">%s:</font></td> <td valign=\"top\">%s</td></tr>", label, value); - - g_free (value); -} - -static void -render_attribute (GtkHTMLStream *html_stream, EContact *contact, const char *html_label, EContactField field, const char *icon, unsigned int html_flags) -{ - const char *str; - - str = e_contact_get_const (contact, field); - - if (str && *str) { - render_name_value (html_stream, html_label, str, icon, html_flags); - } -} - -static void -accum_address (GString *gstr, EContact *contact, const char *html_label, EContactField adr_field, EContactField label_field) -{ - EContactAddress *adr; - const char *label; - - label = e_contact_get_const (contact, label_field); - if (label) { - char *html = e_text_to_html (label, E_TEXT_TO_HTML_CONVERT_NL); - -#if mapping_works - g_string_append_printf (gstr, "<tr><td valign=\"top\" width=\"" IMAGE_COL_WIDTH "\"></td><td valign=\"top\" width=\"100\"><font color=" HEADER_COLOR ">%s:</font><br><a href=\"http://www.mapquest.com/\">%s</a></td><td valign=\"top\">%s</td></tr>", html_label, _("(map)"), html); -#else - g_string_append_printf (gstr, "<tr><td valign=\"top\" width=\"" IMAGE_COL_WIDTH "\"></td><td valign=\"top\" width=\"100\"><font color=" HEADER_COLOR ">%s:</font></td><td valign=\"top\">%s</td></tr>", html_label, html); -#endif - - g_free (html); - return; - } - - adr = e_contact_get (contact, adr_field); - if (adr && - (adr->po || adr->ext || adr->street || adr->locality || adr->region || adr->code || adr->country)) { - - g_string_append_printf (gstr, "<tr><td valign=\"top\" width=\"" IMAGE_COL_WIDTH "\"></td><td valign=\"top\" width=\"100\"><font color=" HEADER_COLOR ">%s:</font><br><a href=\"http://www.mapquest.com/\">%s</a></td><td valign=\"top\">", html_label, _("map")); - - if (adr->po && *adr->po) g_string_append_printf (gstr, "%s<br>", adr->po); - if (adr->ext && *adr->ext) g_string_append_printf (gstr, "%s<br>", adr->ext); - if (adr->street && *adr->street) g_string_append_printf (gstr, "%s<br>", adr->street); - if (adr->locality && *adr->locality) g_string_append_printf (gstr, "%s<br>", adr->locality); - if (adr->region && *adr->region) g_string_append_printf (gstr, "%s<br>", adr->region); - if (adr->code && *adr->code) g_string_append_printf (gstr, "%s<br>", adr->code); - if (adr->country && *adr->country) g_string_append_printf (gstr, "%s<br>", adr->country); - - g_string_append_printf (gstr, "</td></tr>"); - } - if (adr) - e_contact_address_free (adr); -} - -static void -accum_name_value (GString *gstr, const char *label, const char *str, const char *icon, unsigned int html_flags) -{ - char *value = e_text_to_html (str, html_flags); - - g_string_append_printf (gstr, "<tr><td valign=\"top\" width=\"" IMAGE_COL_WIDTH "\">"); - if (icon) - g_string_append_printf (gstr, "<img width=\"16\" height=\"16\" src=\"evo-icon:%s\">", icon); - g_string_append_printf (gstr, "</td><td valign=\"top\" width=\"100\" nowrap><font color=" HEADER_COLOR ">%s:</font></td> <td valign=\"top\">%s</td></tr>", label, value); - - g_free (value); -} - - -static void -accum_attribute (GString *gstr, EContact *contact, const char *html_label, EContactField field, const char *icon, unsigned int html_flags) -{ - const char *str; - - str = e_contact_get_const (contact, field); - - if (str && *str) { - accum_name_value (gstr, html_label, str, icon, html_flags); - } -} - -static void -accum_multival_attribute (GString *gstr, EContact *contact, const char *html_label, EContactField field, const char *icon, unsigned int html_flags) -{ - GList *val_list, *l; - - val_list = e_contact_get (contact, field); - for (l = val_list; l; l = l->next) { - const char *str = (const char *) l->data; - accum_name_value (gstr, html_label, str, icon, html_flags); - } - g_list_foreach (val_list, (GFunc) g_free, NULL); - g_list_free (val_list); -} - -static void -render_contact_list (GtkHTMLStream *html_stream, EContact *contact) -{ - GList *email_list; - GList *l; - - gtk_html_stream_printf (html_stream, "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr>"); - gtk_html_stream_printf (html_stream, "<td valign=\"top\" width=\"" IMAGE_COL_WIDTH "\">"); - gtk_html_stream_printf (html_stream, "<img width=\"16\" height=\"16\" src=\"evo-icon:" CONTACT_LIST_ICON "\">"); - gtk_html_stream_printf (html_stream, "</td><td valign=\"top\" width=\"100\" nowrap><font color=" HEADER_COLOR ">%s:</font></td> <td valign=\"top\">", _("List Members")); - - email_list = e_contact_get (contact, E_CONTACT_EMAIL); - for (l = email_list; l; l = l->next) { - char *html = e_text_to_html (l->data, E_TEXT_TO_HTML_CONVERT_ADDRESSES); - gtk_html_stream_printf (html_stream, "%s<br>", html); - g_free (html); - } - gtk_html_stream_printf (html_stream, "</td></tr></table>"); -} - -static void -start_block (GtkHTMLStream *html_stream, const char *label) -{ - gtk_html_stream_printf (html_stream, "<tr><td height=\"20\" colspan=\"3\"><font color=" HEADER_COLOR "><b>%s</b></font></td></tr>", label); -} - -static void -end_block (GtkHTMLStream *html_stream) -{ - gtk_html_stream_printf (html_stream, "<tr><td height=\"20\"> </td></tr>"); -} - -static void -render_contact (GtkHTMLStream *html_stream, EContact *contact) -{ - GString *accum; - GList *email_list, *l; -#ifdef HANDLE_MAILTO_INTERNALLY - int email_num = 0; -#endif - char *nl; - - gtk_html_stream_printf (html_stream, "<table border=\"0\">"); - - accum = g_string_new (""); - nl = ""; - - start_block (html_stream, ""); - - email_list = e_contact_get (contact, E_CONTACT_EMAIL); - for (l = email_list; l; l = l->next) { -#ifdef HANDLE_MAILTO_INTERNALLY - char *html = e_text_to_html (l->data, 0); - g_string_append_printf (accum, "%s<a href=\"internal-mailto:%d\">%s</a>", nl, email_num, html); - email_num ++; - g_free (html); - nl = "<br>"; - -#else - g_string_append_printf (accum, "%s%s", nl, (char*)l->data); - nl = "\n"; -#endif - } - g_list_foreach (email_list, (GFunc)g_free, NULL); - g_list_free (email_list); - - if (accum->len) { - -#ifdef HANDLE_MAILTO_INTERNALLY - gtk_html_stream_printf (html_stream, "<tr><td valign=\"top\" width=\"" IMAGE_COL_WIDTH "\">"); - gtk_html_stream_printf (html_stream, - "</td><td valign=\"top\" width=\"100\" nowrap><font color=" HEADER_COLOR ">%s:</font></td> <td valign=\"top\">%s</td></tr>", - _("E-mail"), accum->str); -#else - render_name_value (html_stream, _("E-mail"), accum->str, NULL, - E_TEXT_TO_HTML_CONVERT_ADDRESSES | E_TEXT_TO_HTML_CONVERT_NL); -#endif - } - - g_string_assign (accum, ""); - - accum_multival_attribute (accum, contact, _("AIM"), E_CONTACT_IM_AIM, AIM_ICON, 0); - accum_multival_attribute (accum, contact, _("GroupWise"), E_CONTACT_IM_GROUPWISE, GROUPWISE_ICON, 0); - accum_multival_attribute (accum, contact, _("ICQ"), E_CONTACT_IM_ICQ, ICQ_ICON, 0); - accum_multival_attribute (accum, contact, _("Jabber"), E_CONTACT_IM_JABBER, JABBER_ICON, 0); - accum_multival_attribute (accum, contact, _("MSN"), E_CONTACT_IM_MSN, MSN_ICON, 0); - accum_multival_attribute (accum, contact, _("Yahoo"), E_CONTACT_IM_YAHOO, YAHOO_ICON, 0); - - if (accum->len > 0) - gtk_html_stream_printf (html_stream, accum->str); - - end_block (html_stream); - - g_string_assign (accum, ""); - - accum_attribute (accum, contact, _("Organization"), E_CONTACT_ORG, NULL, 0); - accum_attribute (accum, contact, _("Position"), E_CONTACT_TITLE, NULL, 0); - accum_attribute (accum, contact, _("Video Conferencing"), E_CONTACT_VIDEO_URL, VIDEOCONF_ICON, E_TEXT_TO_HTML_CONVERT_URLS); - accum_attribute (accum, contact, _("Phone"), E_CONTACT_PHONE_BUSINESS, NULL, 0); - accum_attribute (accum, contact, _("Fax"), E_CONTACT_PHONE_BUSINESS_FAX, NULL, 0); - accum_address (accum, contact, _("Address"), E_CONTACT_ADDRESS_WORK, E_CONTACT_ADDRESS_LABEL_WORK); - - if (accum->len > 0) { - start_block (html_stream, _("work")); - gtk_html_stream_printf (html_stream, accum->str); - end_block (html_stream); - } - - g_string_assign (accum, ""); - - accum_attribute (accum, contact, _("WWW"), E_CONTACT_HOMEPAGE_URL, NULL, E_TEXT_TO_HTML_CONVERT_URLS); - accum_attribute (accum, contact, _("Blog"), E_CONTACT_BLOG_URL, NULL, E_TEXT_TO_HTML_CONVERT_URLS); - - accum_attribute (accum, contact, _("Phone"), E_CONTACT_PHONE_HOME, NULL, 0); - accum_attribute (accum, contact, _("Mobile Phone"), E_CONTACT_PHONE_MOBILE, NULL, 0); - accum_address (accum, contact, _("Address"), E_CONTACT_ADDRESS_HOME, E_CONTACT_ADDRESS_LABEL_HOME); - - if (accum->len > 0) { - start_block (html_stream, _("personal")); - gtk_html_stream_printf (html_stream, accum->str); - end_block (html_stream); - } - - start_block (html_stream, ""); - - render_attribute (html_stream, contact, _("Note"), E_CONTACT_NOTE, NULL, - E_TEXT_TO_HTML_CONVERT_ADDRESSES | E_TEXT_TO_HTML_CONVERT_URLS | E_TEXT_TO_HTML_CONVERT_NL); - end_block (html_stream); - - gtk_html_stream_printf (html_stream, "</table>"); -} - -static void -eab_contact_display_render_normal (EABContactDisplay *display, EContact *contact) -{ - GtkHTMLStream *html_stream; - - if (display->priv->contact) - g_object_unref (display->priv->contact); - display->priv->contact = contact; - if (display->priv->contact) - g_object_ref (display->priv->contact); - - html_stream = gtk_html_begin (GTK_HTML (display)); - gtk_html_stream_write (html_stream, HTML_HEADER, sizeof (HTML_HEADER) - 1); - gtk_html_stream_write (html_stream, "<body>\n", 7); - - if (contact) { - char *str, *html; - EContactPhoto *photo; - - gtk_html_stream_printf (html_stream, "<table cellspacing=\"20\" border=\"0\"><td valign=\"top\">"); - photo = e_contact_get (contact, E_CONTACT_PHOTO); - if (!photo) - photo = e_contact_get (contact, E_CONTACT_LOGO); - if (photo) { - gtk_html_stream_printf (html_stream, "<img border=\"1\" src=\"internal-contact-photo:\">"); - e_contact_photo_free (photo); - } - - gtk_html_stream_printf (html_stream, "</td><td valign=\"top\">\n"); - - str = e_contact_get_const (contact, E_CONTACT_FILE_AS); - if (!str) - str = e_contact_get_const (contact, E_CONTACT_FULL_NAME); - - if (str) { - html = e_text_to_html (str, 0); - gtk_html_stream_printf (html_stream, "<h2>%s</h2>", html); - g_free (html); - } - - - if (e_contact_get (contact, E_CONTACT_IS_LIST)) - render_contact_list (html_stream, contact); - else - render_contact (html_stream, contact); - - gtk_html_stream_printf (html_stream, "</td></tr></table>\n"); - } - - gtk_html_stream_write (html_stream, "</body></html>\n", 15); - gtk_html_end (GTK_HTML (display), html_stream, GTK_HTML_STREAM_OK); -} - -static void -eab_contact_display_render_compact (EABContactDisplay *display, EContact *contact) -{ - GtkHTMLStream *html_stream; - - if (display->priv->contact) - g_object_unref (display->priv->contact); - display->priv->contact = contact; - if (display->priv->contact) - g_object_ref (display->priv->contact); - - html_stream = gtk_html_begin (GTK_HTML (display)); - gtk_html_stream_write (html_stream, HTML_HEADER, sizeof (HTML_HEADER) - 1); - gtk_html_stream_write (html_stream, "<body>\n", 7); - - if (contact) { - char *str, *html; - EContactPhoto *photo; - - gtk_html_stream_printf (html_stream, - "<table width=\"100%%\" cellpadding=1 cellspacing=0 bgcolor=\"#000000\">" - "<tr><td valign=\"top\">" - "<table width=\"100%%\" cellpadding=0 cellspacing=0 bgcolor=\"#eeeeee\">" - "<tr><td valign=\"top\">" - "<table>" - "<tr><td valign=\"top\">"); - - photo = e_contact_get (contact, E_CONTACT_PHOTO); - if (!photo) - photo = e_contact_get (contact, E_CONTACT_LOGO); - if (photo) { - int calced_width = MAX_COMPACT_IMAGE_DIMENSION, calced_height = MAX_COMPACT_IMAGE_DIMENSION; - GdkPixbufLoader *loader = gdk_pixbuf_loader_new (); - GdkPixbuf *pixbuf; - - /* figure out if we need to downscale the - image here. we don't scale the pixbuf - itself, just insert width/height tags in - the html */ - gdk_pixbuf_loader_write (loader, photo->data, photo->length, NULL); - pixbuf = gdk_pixbuf_loader_get_pixbuf (loader); - if (pixbuf) - gdk_pixbuf_ref (pixbuf); - gdk_pixbuf_loader_close (loader, NULL); - g_object_unref (loader); - if (pixbuf) { - int max_dimension; - - calced_width = gdk_pixbuf_get_width (pixbuf); - calced_height = gdk_pixbuf_get_height (pixbuf); - - max_dimension = calced_width; - if (max_dimension < calced_height) - max_dimension = calced_height; - - if (max_dimension > MAX_COMPACT_IMAGE_DIMENSION) { - calced_width *= ((float)MAX_COMPACT_IMAGE_DIMENSION / max_dimension); - calced_height *= ((float)MAX_COMPACT_IMAGE_DIMENSION / max_dimension); - } - } - - gdk_pixbuf_unref (pixbuf); - gtk_html_stream_printf (html_stream, "<img width=\"%d\" height=\"%d\" src=\"internal-contact-photo:\">", - calced_width, calced_height); - e_contact_photo_free (photo); - } - - gtk_html_stream_printf (html_stream, "</td><td valign=\"top\">\n"); - - str = e_contact_get_const (contact, E_CONTACT_FILE_AS); - if (str) { - html = e_text_to_html (str, 0); - gtk_html_stream_printf (html_stream, "<b>%s</b>", html); - g_free (html); - } - else { - str = e_contact_get_const (contact, E_CONTACT_FULL_NAME); - if (str) { - html = e_text_to_html (str, 0); - gtk_html_stream_printf (html_stream, "<b>%s</b>", html); - g_free (html); - } - } - - gtk_html_stream_write (html_stream, "<hr>", 4); - - if (e_contact_get (contact, E_CONTACT_IS_LIST)) { - GList *email_list; - GList *l; - - gtk_html_stream_printf (html_stream, "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr><td valign=\"top\">"); - gtk_html_stream_printf (html_stream, "<b>%s:</b> <td>", _("List Members")); - - email_list = e_contact_get (contact, E_CONTACT_EMAIL); - for (l = email_list; l; l = l->next) { - char *html = e_text_to_html (l->data, 0); - gtk_html_stream_printf (html_stream, "%s, ", html); - g_free (html); - } - gtk_html_stream_printf (html_stream, "</td></tr></table>"); - } - else { - gboolean comma = FALSE; - str = e_contact_get_const (contact, E_CONTACT_TITLE); - if (str) { - html = e_text_to_html (str, 0); - gtk_html_stream_printf (html_stream, "<b>%s:</b> %s<br>", _("Job Title"), str); - g_free (html); - } - - gtk_html_stream_printf (html_stream, "<b>%s:</b> ", _("Email")); - str = e_contact_get_const (contact, E_CONTACT_EMAIL_1); - if (str) { - html = e_text_to_html (str, 0); - gtk_html_stream_printf (html_stream, "%s", str); - g_free (html); - comma = TRUE; - } - str = e_contact_get_const (contact, E_CONTACT_EMAIL_2); - if (str) { - html = e_text_to_html (str, 0); - gtk_html_stream_printf (html_stream, "%s%s", comma ? ", " : "", str); - g_free (html); - comma = TRUE; - } - str = e_contact_get_const (contact, E_CONTACT_EMAIL_3); - if (str) { - html = e_text_to_html (str, 0); - gtk_html_stream_printf (html_stream, "%s%s", comma ? ", " : "", str); - g_free (html); - } - gtk_html_stream_write (html_stream, "<br>", 4); - - str = e_contact_get_const (contact, E_CONTACT_HOMEPAGE_URL); - if (str) { - html = e_text_to_html (str, E_TEXT_TO_HTML_CONVERT_URLS); - gtk_html_stream_printf (html_stream, "<b>%s:</b> %s<br>", - _("Home page"), html); - g_free (html); - } - - str = e_contact_get_const (contact, E_CONTACT_BLOG_URL); - if (str) { - html = e_text_to_html (str, E_TEXT_TO_HTML_CONVERT_URLS); - gtk_html_stream_printf (html_stream, "<b>%s:</b> %s<br>", - _("Blog"), html); - } - } - - gtk_html_stream_printf (html_stream, "</td></tr></table></td></tr></table></td></tr></table>\n"); - } - - gtk_html_stream_write (html_stream, "</body></html>\n", 15); - gtk_html_end (GTK_HTML (display), html_stream, GTK_HTML_STREAM_OK); -} - -void -eab_contact_display_render (EABContactDisplay *display, EContact *contact, - EABContactDisplayRenderMode mode) -{ - switch (mode) { - case EAB_CONTACT_DISPLAY_RENDER_NORMAL: - eab_contact_display_render_normal (display, contact); - break; - case EAB_CONTACT_DISPLAY_RENDER_COMPACT: - eab_contact_display_render_compact (display, contact); - break; - } -} - -GtkWidget* -eab_contact_display_new (void) -{ - EABContactDisplay *display; - - display = g_object_new (EAB_TYPE_CONTACT_DISPLAY, NULL); - - display->priv = g_new0 (EABContactDisplayPrivate, 1); - - gtk_html_set_default_content_type (GTK_HTML (display), "text/html; charset=utf-8"); - - gtk_html_set_editable (GTK_HTML (display), FALSE); - - g_signal_connect (display, "url_requested", - G_CALLBACK (on_url_requested), - display); - g_signal_connect (display, "link_clicked", - G_CALLBACK (on_link_clicked), - display); -#if 0 - g_signal_connect (display, "object_requested", - G_CALLBACK (on_object_requested), - mail_display); - g_signal_connect (display, "button_press_event", - G_CALLBACK (html_button_press_event), mail_display); - g_signal_connect (display, "motion_notify_event", - G_CALLBACK (html_motion_notify_event), mail_display); - g_signal_connect (display, "enter_notify_event", - G_CALLBACK (html_enter_notify_event), mail_display); - g_signal_connect (display, "iframe_created", - G_CALLBACK (html_iframe_created), mail_display); - g_signal_connect (display, "on_url", - G_CALLBACK (html_on_url), mail_display); -#endif - - return GTK_WIDGET (display); -} - - -static void -eab_contact_display_init (GObject *object) -{ -} - -static void -eab_contact_display_class_init (GtkObjectClass *object_class) -{ - /* object_class->destroy = mail_display_destroy;*/ -} - -GType -eab_contact_display_get_type (void) -{ - static GType type = 0; - - if (!type) { - static const GTypeInfo info = { - sizeof (EABContactDisplayClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) eab_contact_display_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (EABContactDisplay), - 0, /* n_preallocs */ - (GInstanceInitFunc) eab_contact_display_init, - }; - - type = g_type_register_static (PARENT_TYPE, "EABContactDisplay", &info, 0); - } - - return type; -} diff --git a/addressbook/gui/widgets/eab-contact-display.h b/addressbook/gui/widgets/eab-contact-display.h deleted file mode 100644 index 08c3936cad..0000000000 --- a/addressbook/gui/widgets/eab-contact-display.h +++ /dev/null @@ -1,60 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Authors: Chris Toshok <toshok@ximian.com> - * - * Copyright 2003 Ximian, Inc. (www.ximian.com) - * - * 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 Street #330, Boston, MA 02111-1307, USA. - * - */ - -#ifndef _EAB_CONTACT_DISPLAY_H_ -#define _EAB_CONTACT_DISPLAY_H_ - -#include <gtkhtml/gtkhtml.h> -#include <libebook/e-contact.h> - -#define EAB_TYPE_CONTACT_DISPLAY (eab_contact_display_get_type ()) -#define EAB_CONTACT_DISPLAY(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EAB_TYPE_CONTACT_DISPLAY, EABContactDisplay)) -#define EAB_CONTACT_DISPLAY_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), EAB_TYPE_CONTACT_DISPLAY, EABContactDisplayClass)) -#define IS_EAB_CONTACT_DISPLAY(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EAB_TYPE_CONTACT_DISPLAY)) -#define IS_EAB_CONTACT_DISPLAY_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EAB_TYPE_CONTACT_DISPLAY)) - -typedef struct _EABContactDisplay EABContactDisplay; -typedef struct _EABContactDisplayPrivate EABContactDisplayPrivate; -typedef struct _EABContactDisplayClass EABContactDisplayClass; - -typedef enum { - EAB_CONTACT_DISPLAY_RENDER_NORMAL, /* for use in the preview pane */ - EAB_CONTACT_DISPLAY_RENDER_COMPACT /* for use with embedded vcards (e.g, the EABVCardControl) */ -} EABContactDisplayRenderMode; - -struct _EABContactDisplay { - GtkHTML parent; - - EABContactDisplayPrivate *priv; -}; - -struct _EABContactDisplayClass { - GtkHTMLClass parent_class; -}; - -GtkType eab_contact_display_get_type (void); -GtkWidget * eab_contact_display_new (void); - -void eab_contact_display_render (EABContactDisplay *display, EContact *contact, - EABContactDisplayRenderMode render_mode); - -#endif /* _EAB_CONTACT_DISPLAY_H_ */ diff --git a/addressbook/gui/widgets/eab-gui-util.c b/addressbook/gui/widgets/eab-gui-util.c deleted file mode 100644 index a88bd4cf82..0000000000 --- a/addressbook/gui/widgets/eab-gui-util.c +++ /dev/null @@ -1,1090 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * e-table-field-chooser.c - * Copyright (C) 2001 Ximian, Inc. - * Author: Chris Toshok <toshok@ximian.com> - * - * This library 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 library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include <config.h> - -#include <unistd.h> -#include <fcntl.h> -#include <errno.h> -#include <string.h> - -#include <libedataserverui/e-source-selector.h> -#include <gal/util/e-util.h> -#include "eab-gui-util.h" -#include "util/eab-book-util.h" -#include "util/e-destination.h" -#include "widgets/misc/e-error.h" -#include "widgets/misc/e-image-chooser.h" -#include <e-util/e-icon-factory.h> - -#include <gnome.h> - -#include "addressbook/gui/contact-editor/eab-editor.h" -#include "addressbook/gui/contact-editor/e-contact-editor.h" -#include "addressbook/gui/contact-list-editor/e-contact-list-editor.h" -#include "addressbook/gui/component/addressbook-component.h" -#include "addressbook/gui/component/addressbook.h" - -/* the NULL's in this table correspond to the status codes - that should *never* be generated by a backend */ -static const char *status_to_string[] = { - /* E_BOOK_ERROR_OK */ N_("Success"), - /* E_BOOK_ERROR_INVALID_ARG */ NULL, - /* E_BOOK_ERROR_BUSY */ N_("Backend busy"), - /* E_BOOK_ERROR_REPOSITORY_OFFLINE */ N_("Repository offline"), - /* E_BOOK_ERROR_NO_SUCH_BOOK */ N_("Address Book does not exist"), - /* E_BOOK_ERROR_NO_SELF_CONTACT */ N_("No Self Contact defined"), - /* E_BOOK_ERROR_URI_NOT_LOADED */ NULL, - /* E_BOOK_ERROR_URI_ALREADY_LOADED */ NULL, - /* E_BOOK_ERROR_PERMISSION_DENIED */ N_("Permission denied"), - /* E_BOOK_ERROR_CONTACT_NOT_FOUND */ N_("Contact not found"), - /* E_BOOK_ERROR_CONTACT_ID_ALREADY_EXISTS */ N_("Contact ID already exists"), - /* E_BOOK_ERROR_PROTOCOL_NOT_SUPPORTED */ N_("Protocol not supported"), - /* E_BOOK_ERROR_CANCELLED */ N_("Cancelled"), - /* E_BOOK_ERROR_COULD_NOT_CANCEL */ N_("Could not cancel"), - /* E_BOOK_ERROR_AUTHENTICATION_FAILED */ N_("Authentication Failed"), - /* E_BOOK_ERROR_AUTHENTICATION_REQUIRED */ N_("Authentication Required"), - /* E_BOOK_ERROR_TLS_NOT_AVAILABLE */ N_("TLS not Available"), - /* E_BOOK_ERROR_CORBA_EXCEPTION */ NULL, - /* E_BOOK_ERROR_NO_SUCH_SOURCE */ N_("No such source"), - /* E_BOOK_ERROR_OTHER_ERROR */ N_("Other error") -}; - -void -eab_error_dialog (const char *msg, EBookStatus status) -{ - const char *status_str = status_to_string [status]; - - if (status_str) - e_error_run (NULL, "addressbook:generic-error", msg, status_str, NULL); -} - -void -eab_load_error_dialog (GtkWidget *parent, ESource *source, EBookStatus status) -{ - char *label_string, *uri; - - g_return_if_fail (source != NULL); - - uri = e_source_get_uri (source); - - if (!strncmp (uri, "file:", 5)) { - label_string = - _("We were unable to open this addressbook. Please check that the " - "path exists and that you have permission to access it."); - } - else if (!strncmp (uri, "ldap:", 5)) { - /* special case for ldap: contact folders so we can tell the user about openldap */ -#if HAVE_LDAP - label_string = - _("We were unable to open this addressbook. This either " - "means you have entered an incorrect URI, or the LDAP server " - "is unreachable."); -#else - label_string = - _("This version of Evolution does not have LDAP support " - "compiled in to it. If you want to use LDAP in Evolution, " - "you must install an LDAP-enabled Evolution package."); -#endif - } else { - /* other network folders */ - label_string = - _("We were unable to open this addressbook. This either " - "means you have entered an incorrect URI, or the server " - "is unreachable."); - } - - e_error_run ((GtkWindow *) parent, "addressbook:load-error", label_string, NULL); - - g_free (uri); -} - -void -eab_search_result_dialog (GtkWidget *parent, - EBookViewStatus status) -{ - char *str = NULL; - - switch (status) { - case E_BOOK_VIEW_STATUS_OK: - return; - case E_BOOK_VIEW_STATUS_SIZE_LIMIT_EXCEEDED: - str = _("More cards matched this query than either the server is \n" - "configured to return or Evolution is configured to display.\n" - "Please make your search more specific or raise the result limit in\n" - "the directory server preferences for this addressbook."); - break; - case E_BOOK_VIEW_STATUS_TIME_LIMIT_EXCEEDED: - str = _("The time to execute this query exceeded the server limit or the limit\n" - "you have configured for this addressbook. Please make your search\n" - "more specific or raise the time limit in the directory server\n" - "preferences for this addressbook."); - break; - case E_BOOK_VIEW_ERROR_INVALID_QUERY: - str = _("The backend for this addressbook was unable to parse this query."); - break; - case E_BOOK_VIEW_ERROR_QUERY_REFUSED: - str = _("The backend for this addressbook refused to perform this query."); - break; - case E_BOOK_VIEW_ERROR_OTHER_ERROR: - str = _("This query did not complete successfully."); - break; - default: - g_assert_not_reached (); - } - - e_error_run ((GtkWindow *) parent, "addressbook:search-error", str, NULL); -} - -gint -eab_prompt_save_dialog (GtkWindow *parent) -{ - return e_error_run (parent, "addressbook:prompt-save", NULL); -} - -static void -added_cb (EBook* book, EBookStatus status, EContact *contact, - gpointer data) -{ - gboolean is_list = GPOINTER_TO_INT (data); - - if (status != E_BOOK_ERROR_OK && status != E_BOOK_ERROR_CANCELLED) { - eab_error_dialog (is_list ? _("Error adding list") : _("Error adding contact"), status); - } -} - -static void -modified_cb (EBook* book, EBookStatus status, EContact *contact, - gpointer data) -{ - gboolean is_list = GPOINTER_TO_INT (data); - - if (status != E_BOOK_ERROR_OK && status != E_BOOK_ERROR_CANCELLED) { - eab_error_dialog (is_list ? _("Error modifying list") : _("Error modifying contact"), - status); - } -} - -static void -deleted_cb (EBook* book, EBookStatus status, EContact *contact, - gpointer data) -{ - gboolean is_list = GPOINTER_TO_INT (data); - - if (status != E_BOOK_ERROR_OK) { - eab_error_dialog (is_list ? _("Error removing list") : _("Error removing contact"), - status); - } -} - -static void -editor_closed_cb (GtkObject *editor, gpointer data) -{ - g_object_unref (editor); -} - -EContactEditor * -eab_show_contact_editor (EBook *book, EContact *contact, - gboolean is_new_contact, - gboolean editable) -{ - EContactEditor *ce; - - ce = e_contact_editor_new (book, contact, is_new_contact, editable); - - g_signal_connect (ce, "contact_added", - G_CALLBACK (added_cb), GINT_TO_POINTER (FALSE)); - g_signal_connect (ce, "contact_modified", - G_CALLBACK (modified_cb), GINT_TO_POINTER (FALSE)); - g_signal_connect (ce, "contact_deleted", - G_CALLBACK (deleted_cb), GINT_TO_POINTER (FALSE)); - g_signal_connect (ce, "editor_closed", - G_CALLBACK (editor_closed_cb), NULL); - - return ce; -} - -EContactListEditor * -eab_show_contact_list_editor (EBook *book, EContact *contact, - gboolean is_new_contact, - gboolean editable) -{ - EContactListEditor *ce; - - ce = e_contact_list_editor_new (book, contact, is_new_contact, editable); - - g_signal_connect (ce, "contact_added", - G_CALLBACK (added_cb), GINT_TO_POINTER (TRUE)); - g_signal_connect (ce, "contact_modified", - G_CALLBACK (modified_cb), GINT_TO_POINTER (TRUE)); - g_signal_connect (ce, "contact_deleted", - G_CALLBACK (deleted_cb), GINT_TO_POINTER (TRUE)); - g_signal_connect (ce, "editor_closed", - G_CALLBACK (editor_closed_cb), GINT_TO_POINTER (TRUE)); - - eab_editor_show (EAB_EDITOR (ce)); - - return ce; -} - -static void -view_contacts (EBook *book, GList *list, gboolean editable) -{ - for (; list; list = list->next) { - EContact *contact = list->data; - if (e_contact_get (contact, E_CONTACT_IS_LIST)) - eab_show_contact_list_editor (book, contact, FALSE, editable); - else - eab_show_contact_editor (book, contact, FALSE, editable); - } -} - -void -eab_show_multiple_contacts (EBook *book, - GList *list, - gboolean editable) -{ - if (list) { - int length = g_list_length (list); - if (length > 5) { - GtkWidget *dialog; - gint response; - - dialog = gtk_message_dialog_new (NULL, - 0, - GTK_MESSAGE_QUESTION, - GTK_BUTTONS_YES_NO, - ngettext("Opening %d contact will open %d new window as well.\n" - "Do you really want to display this contact?", - "Opening %d contacts will open %d new windows as well.\n" - "Do you really want to display all of these contacts?", - length), - length, - length); - - response = gtk_dialog_run (GTK_DIALOG (dialog)); - gtk_widget_destroy (dialog); - if (response == GTK_RESPONSE_YES) - view_contacts (book, list, editable); - } else { - view_contacts (book, list, editable); - } - } -} - - -static gint -file_exists(GtkWindow *window, const char *filename) -{ - GtkWidget *dialog; - gint response; - - dialog = gtk_message_dialog_new (window, - 0, - GTK_MESSAGE_QUESTION, - GTK_BUTTONS_NONE, - _("%s already exists\nDo you want to overwrite it?"), filename); - - gtk_dialog_add_buttons (GTK_DIALOG (dialog), - GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, - _("Overwrite"), GTK_RESPONSE_ACCEPT, - NULL); - - response = gtk_dialog_run (GTK_DIALOG (dialog)); - gtk_widget_destroy (dialog); - return response; -} - -typedef struct { - GtkWidget *filesel; - char *vcard; -} SaveAsInfo; - -static void -save_it(GtkWidget *widget, SaveAsInfo *info) -{ - const char *filename; - gint error = 0; - gint response = 0; - - -#ifdef USE_GTKFILECHOOSER - filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (info->filesel)); -#else - filename = gtk_file_selection_get_filename (GTK_FILE_SELECTION (info->filesel)); -#endif - - error = e_write_file (filename, info->vcard, O_WRONLY | O_CREAT | O_EXCL | O_TRUNC); - - if (error == EEXIST) { - response = file_exists(GTK_WINDOW (info->filesel), filename); - switch (response) { - case GTK_RESPONSE_ACCEPT : /* Overwrite */ - e_write_file(filename, info->vcard, O_WRONLY | O_CREAT | O_TRUNC); - break; - case GTK_RESPONSE_CANCEL : /* cancel */ - return; - } - } else if (error != 0) { - e_error_run (GTK_WINDOW (info->filesel), "addressbook:save-error", filename, g_strerror (errno)); - return; - } - - gtk_widget_destroy(GTK_WIDGET(info->filesel)); -} - -static void -close_it(GtkWidget *widget, SaveAsInfo *info) -{ - gtk_widget_destroy (GTK_WIDGET (info->filesel)); -} - -static void -destroy_it(void *data, GObject *where_the_object_was) -{ - SaveAsInfo *info = data; - g_free (info->vcard); - g_free (info); -} - -#ifdef USE_GTKFILECHOOSER -static void -filechooser_response (GtkWidget *widget, gint response_id, SaveAsInfo *info) -{ - if (response_id == GTK_RESPONSE_ACCEPT) - save_it (widget, info); - else - close_it (widget, info); -} -#endif - -static char * -make_safe_filename (char *name) -{ - char *safe; - - if (!name) { - /* This is a filename. Translators take note. */ - name = _("card.vcf"); - } - - if (!g_strrstr (name, ".vcf")) - safe = g_strdup_printf ("%s%s", name, ".vcf"); - else - safe = g_strdup (name); - - e_filename_make_safe (safe); - - return safe; -} - -static void -source_selection_changed_cb (GtkWidget *selector, GtkWidget *ok_button) -{ - gtk_widget_set_sensitive (ok_button, - e_source_selector_peek_primary_selection (E_SOURCE_SELECTOR (selector)) ? - TRUE : FALSE); -} - -ESource * -eab_select_source (const gchar *title, const gchar *message, const gchar *select_uid, GtkWindow *parent) -{ - ESource *source; - ESourceList *source_list; - GtkWidget *dialog; - GtkWidget *ok_button; - GtkWidget *cancel_button; - GtkWidget *label; - GtkWidget *selector; - GtkWidget *scrolled_window; - gint response; - - if (!e_book_get_addressbooks (&source_list, NULL)) - return NULL; - - dialog = gtk_dialog_new_with_buttons (title, parent, - GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, - NULL); - gtk_window_set_default_size (GTK_WINDOW (dialog), 200, 350); - - cancel_button = gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL); - ok_button = gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_OK, GTK_RESPONSE_ACCEPT); - gtk_widget_set_sensitive (ok_button, FALSE); - - label = gtk_label_new (message); - - selector = e_source_selector_new (source_list); - e_source_selector_show_selection (E_SOURCE_SELECTOR (selector), FALSE); - g_signal_connect (selector, "primary_selection_changed", - G_CALLBACK (source_selection_changed_cb), ok_button); - - if (select_uid) { - source = e_source_list_peek_source_by_uid (source_list, select_uid); - if (source) - e_source_selector_set_primary_selection (E_SOURCE_SELECTOR (selector), source); - } - - scrolled_window = gtk_scrolled_window_new (NULL, NULL); - gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_window), GTK_SHADOW_IN); - gtk_container_add (GTK_CONTAINER (scrolled_window), selector); - - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), label, FALSE, FALSE, 4); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), scrolled_window, TRUE, TRUE, 4); - - gtk_widget_show_all (dialog); - response = gtk_dialog_run (GTK_DIALOG (dialog)); - - if (response == GTK_RESPONSE_ACCEPT) - source = e_source_selector_peek_primary_selection (E_SOURCE_SELECTOR (selector)); - else - source = NULL; - - gtk_widget_destroy (dialog); - return source; -} - -void -eab_contact_save (char *title, EContact *contact, GtkWindow *parent_window) -{ - GtkWidget *filesel; - char *file, *full_filename; - char *name; - SaveAsInfo *info = g_new(SaveAsInfo, 1); - - name = e_contact_get (contact, E_CONTACT_FILE_AS); - file = make_safe_filename (name); - -#ifdef USE_GTKFILECHOOSER - filesel = gtk_file_chooser_dialog_new (title, - parent_window, - GTK_FILE_CHOOSER_ACTION_SAVE, - GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, - GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT, - NULL); - gtk_dialog_set_default_response (GTK_DIALOG (filesel), GTK_RESPONSE_ACCEPT); - - gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (filesel), g_get_home_dir ()); - gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (filesel), file); - - info->filesel = filesel; - info->vcard = e_vcard_to_string (E_VCARD (contact), EVC_FORMAT_VCARD_30); - - g_signal_connect (G_OBJECT (filesel), "response", - G_CALLBACK (filechooser_response), info); - g_object_weak_ref (G_OBJECT (filesel), destroy_it, info); -#else - filesel = gtk_file_selection_new (title); - - full_filename = g_strdup_printf ("%s/%s", g_get_home_dir (), file); - gtk_file_selection_set_filename (GTK_FILE_SELECTION (filesel), full_filename); - g_free (full_filename); - - info->filesel = filesel; - info->vcard = e_vcard_to_string (E_VCARD (contact), EVC_FORMAT_VCARD_30); - - g_signal_connect(G_OBJECT (GTK_FILE_SELECTION (filesel)->ok_button), "clicked", - G_CALLBACK (save_it), info); - g_signal_connect(G_OBJECT (GTK_FILE_SELECTION (filesel)->cancel_button), "clicked", - G_CALLBACK (close_it), info); - g_object_weak_ref (G_OBJECT (filesel), destroy_it, info); -#endif - - if (parent_window) { - gtk_window_set_transient_for (GTK_WINDOW (filesel), - parent_window); - gtk_window_set_modal (GTK_WINDOW (filesel), TRUE); - } - - gtk_widget_show(GTK_WIDGET(filesel)); - g_free (file); -} - -void -eab_contact_list_save (char *title, GList *list, GtkWindow *parent_window) -{ - GtkWidget *filesel; - SaveAsInfo *info = g_new(SaveAsInfo, 1); - char *file, *full_filename; - -#ifdef USE_GTKFILECHOOSER - filesel = gtk_file_chooser_dialog_new (title, - parent_window, - GTK_FILE_CHOOSER_ACTION_SAVE, - GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, - GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT, - NULL); - gtk_dialog_set_default_response (GTK_DIALOG (filesel), GTK_RESPONSE_ACCEPT); -#else - filesel = gtk_file_selection_new(title); -#endif - - /* This is a filename. Translators take note. */ - if (list && list->data && list->next == NULL) { - char *name; - name = e_contact_get (E_CONTACT (list->data), E_CONTACT_FILE_AS); - if (!name) - name = e_contact_get (E_CONTACT (list->data), E_CONTACT_FULL_NAME); - - file = make_safe_filename (name); - } else { - file = make_safe_filename (_("list")); - } - -#ifdef USE_GTKFILECHOOSER - gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (filesel), g_get_home_dir ()); - gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (filesel), file); -#else - full_filename = g_strdup_printf ("%s/%s", g_get_home_dir (), file); - gtk_file_selection_set_filename (GTK_FILE_SELECTION (filesel), full_filename); - g_free (full_filename); -#endif - - info->filesel = filesel; - info->vcard = eab_contact_list_to_string (list); - -#ifdef USE_GTKFILECHOOSER - g_signal_connect (G_OBJECT (filesel), "response", - G_CALLBACK (filechooser_response), info); - g_object_weak_ref (G_OBJECT (filesel), destroy_it, info); -#else - g_signal_connect(G_OBJECT (GTK_FILE_SELECTION (filesel)->ok_button), "clicked", - G_CALLBACK (save_it), info); - g_signal_connect(G_OBJECT (GTK_FILE_SELECTION (filesel)->cancel_button), "clicked", - G_CALLBACK (close_it), info); - g_object_weak_ref (G_OBJECT (filesel), destroy_it, info); -#endif - - if (parent_window) { - gtk_window_set_transient_for (GTK_WINDOW (filesel), - parent_window); - gtk_window_set_modal (GTK_WINDOW (filesel), TRUE); - } - - gtk_widget_show(GTK_WIDGET(filesel)); - g_free (file); -} - -typedef struct ContactCopyProcess_ ContactCopyProcess; - -typedef void (*ContactCopyDone) (ContactCopyProcess *process); - -struct ContactCopyProcess_ { - int count; - GList *contacts; - EBook *source; - EBook *destination; - ContactCopyDone done_cb; -}; - -static void -contact_deleted_cb (EBook* book, EBookStatus status, gpointer user_data) -{ - if (status != E_BOOK_ERROR_OK) { - eab_error_dialog (_("Error removing contact"), status); - } -} - -static void -do_delete (gpointer data, gpointer user_data) -{ - EBook *book = user_data; - EContact *contact = data; - - e_book_async_remove_contact(book, contact, contact_deleted_cb, NULL); -} - -static void -delete_contacts (ContactCopyProcess *process) -{ - g_list_foreach (process->contacts, - do_delete, - process->source); -} - -static void -process_unref (ContactCopyProcess *process) -{ - process->count --; - if (process->count == 0) { - if (process->done_cb) { - process->done_cb (process); - } - e_free_object_list(process->contacts); - g_object_unref (process->source); - g_object_unref (process->destination); - g_free (process); - } -} - -static void -contact_added_cb (EBook* book, EBookStatus status, const char *id, gpointer user_data) -{ - ContactCopyProcess *process = user_data; - - if (status != E_BOOK_ERROR_OK) { - eab_error_dialog (_("Error adding contact"), status); - } else { - process_unref (process); - } -} - -static void -do_copy (gpointer data, gpointer user_data) -{ - EBook *book; - EContact *contact; - ContactCopyProcess *process; - - process = user_data; - contact = data; - - book = process->destination; - - process->count ++; - e_book_async_add_contact(book, contact, contact_added_cb, process); -} - -static void -got_book_cb (EBook *book, EBookStatus status, gpointer closure) -{ - ContactCopyProcess *process; - process = closure; - if (status == E_BOOK_ERROR_OK) { - process->destination = book; - g_object_ref (book); - g_list_foreach (process->contacts, - do_copy, - process); - } - process_unref (process); -} - -void -eab_transfer_contacts (EBook *source, GList *contacts /* adopted */, gboolean delete_from_source, GtkWindow *parent_window) -{ - EBook *dest; - ESource *destination_source; - static char *last_uid = NULL; - ContactCopyProcess *process; - char *desc; - - if (contacts == NULL) - return; - - if (last_uid == NULL) - last_uid = g_strdup (""); - - if (contacts->next == NULL) { - if (delete_from_source) - desc = _("Move contact to"); - else - desc = _("Copy contact to"); - } else { - if (delete_from_source) - desc = _("Move contacts to"); - else - desc = _("Copy contacts to"); - } - - destination_source = eab_select_source (desc, _("Select target addressbook."), - last_uid, parent_window); - - if (!destination_source) - return; - - if (strcmp (last_uid, e_source_peek_uid (destination_source)) != 0) { - g_free (last_uid); - last_uid = g_strdup (e_source_peek_uid (destination_source)); - } - - process = g_new (ContactCopyProcess, 1); - process->count = 1; - process->source = source; - g_object_ref (source); - process->contacts = contacts; - process->destination = NULL; - - if (delete_from_source) - process->done_cb = delete_contacts; - else - process->done_cb = NULL; - - dest = e_book_new (destination_source, NULL); - addressbook_load (dest, got_book_cb, process); -} - -#include <Evolution-Composer.h> - -#define COMPOSER_OAFID "OAFIID:GNOME_Evolution_Mail_Composer:" BASE_VERSION - -typedef struct { - EContact *contact; - int email_num; /* if the contact is a person (not a list), the email address to use */ -} ContactAndEmailNum; - -static void -eab_send_to_contact_and_email_num_list (GList *c) -{ - GNOME_Evolution_Composer composer_server; - CORBA_Environment ev; - GNOME_Evolution_Composer_RecipientList *to_list, *cc_list, *bcc_list; - CORBA_char *subject; - int to_i, bcc_i; - GList *iter; - gint to_length = 0, bcc_length = 0; - - if (c == NULL) - return; - - CORBA_exception_init (&ev); - - composer_server = bonobo_activation_activate_from_id (COMPOSER_OAFID, 0, NULL, &ev); - - /* Figure out how many addresses of each kind we have. */ - for (iter = c; iter != NULL; iter = g_list_next (iter)) { - ContactAndEmailNum *ce = iter->data; - EContact *contact = ce->contact; - GList *emails = e_contact_get (contact, E_CONTACT_EMAIL); - if (e_contact_get (contact, E_CONTACT_IS_LIST)) { - gint len = g_list_length (emails); - if (e_contact_get (contact, E_CONTACT_LIST_SHOW_ADDRESSES)) - to_length += len; - else - bcc_length += len; - } else { - if (emails != NULL) - ++to_length; - } - g_list_foreach (emails, (GFunc)g_free, NULL); - g_list_free (emails); - } - - /* Now I have to make a CORBA sequences that represents a recipient list with - the right number of entries, for the contacts. */ - to_list = GNOME_Evolution_Composer_RecipientList__alloc (); - to_list->_maximum = to_length; - to_list->_length = to_length; - if (to_length > 0) { - to_list->_buffer = CORBA_sequence_GNOME_Evolution_Composer_Recipient_allocbuf (to_length); - } - - cc_list = GNOME_Evolution_Composer_RecipientList__alloc (); - cc_list->_maximum = cc_list->_length = 0; - - bcc_list = GNOME_Evolution_Composer_RecipientList__alloc (); - bcc_list->_maximum = bcc_length; - bcc_list->_length = bcc_length; - if (bcc_length > 0) { - bcc_list->_buffer = CORBA_sequence_GNOME_Evolution_Composer_Recipient_allocbuf (bcc_length); - } - - to_i = 0; - bcc_i = 0; - while (c != NULL) { - ContactAndEmailNum *ce = c->data; - EContact *contact = ce->contact; - int nth = ce->email_num; - char *name, *addr; - gboolean is_list, is_hidden; - GNOME_Evolution_Composer_Recipient *recipient; - GList *emails = e_contact_get (contact, E_CONTACT_EMAIL); - GList *iterator; - - if (emails != NULL) { - - is_list = (gboolean)e_contact_get (contact, E_CONTACT_IS_LIST); - is_hidden = is_list && !e_contact_get (contact, E_CONTACT_LIST_SHOW_ADDRESSES); - - if (is_list) { - for (iterator = emails; iterator; iterator = iterator->next) { - - if (is_hidden) { - recipient = &(bcc_list->_buffer[bcc_i]); - ++bcc_i; - } else { - recipient = &(to_list->_buffer[to_i]); - ++to_i; - } - - name = NULL; - addr = NULL; - if (iterator && iterator->data) { - /* XXX we should probably try to get the name from the attribute parameter here.. */ - addr = g_strdup ((char*)iterator->data); - } - - recipient->name = CORBA_string_dup (name ? name : ""); - recipient->address = CORBA_string_dup (addr ? addr : ""); - - g_free (name); - g_free (addr); - } - } - else { - EContactName *contact_name = e_contact_get (contact, E_CONTACT_NAME); - int length = g_list_length (emails); - - if (is_hidden) { - recipient = &(bcc_list->_buffer[bcc_i]); - ++bcc_i; - } else { - recipient = &(to_list->_buffer[to_i]); - ++to_i; - } - - if (nth >= length) - nth = 0; - - if (contact_name) { - name = e_contact_name_to_string (contact_name); - e_contact_name_free (contact_name); - } - else - name = NULL; - - addr = g_strdup (g_list_nth_data (emails, nth)); - - - recipient->name = CORBA_string_dup (name ? name : ""); - recipient->address = CORBA_string_dup (addr ? addr : ""); - - g_free (name); - g_free (addr); - } - - g_list_foreach (emails, (GFunc)g_free, NULL); - g_list_free (emails); - } - - c = c->next; - } - - subject = CORBA_string_dup (""); - - GNOME_Evolution_Composer_setHeaders (composer_server, "", to_list, cc_list, bcc_list, subject, &ev); - if (ev._major != CORBA_NO_EXCEPTION) { - g_printerr ("gui/e-meeting-edit.c: I couldn't set the composer headers via CORBA! Aagh.\n"); - CORBA_exception_free (&ev); - return; - } - - CORBA_free (to_list); - CORBA_free (cc_list); - CORBA_free (bcc_list); - CORBA_free (subject); - - GNOME_Evolution_Composer_show (composer_server, &ev); - - if (ev._major != CORBA_NO_EXCEPTION) { - g_printerr ("gui/e-meeting-edit.c: I couldn't show the composer via CORBA! Aagh.\n"); - CORBA_exception_free (&ev); - return; - } - - CORBA_exception_free (&ev); -} - -static void -eab_send_contact_list_as_attachment (GList *contacts) -{ - GNOME_Evolution_Composer composer_server; - CORBA_Environment ev; - CORBA_char *content_type, *filename, *description; - GNOME_Evolution_Composer_AttachmentData *attach_data; - CORBA_boolean show_inline; - char *tempstr; - GNOME_Evolution_Composer_RecipientList *to_list, *cc_list, *bcc_list; - CORBA_char *subject; - - if (contacts == NULL) - return; - - CORBA_exception_init (&ev); - - composer_server = bonobo_activation_activate_from_id (COMPOSER_OAFID, 0, NULL, &ev); - - - - content_type = CORBA_string_dup ("text/x-vcard"); - filename = CORBA_string_dup (""); - - if (contacts->next) { - description = CORBA_string_dup (_("Multiple VCards")); - } else { - char *file_as = e_contact_get (E_CONTACT (contacts->data), E_CONTACT_FILE_AS); - tempstr = g_strdup_printf (_("VCard for %s"), file_as); - description = CORBA_string_dup (tempstr); - g_free (tempstr); - g_free (file_as); - } - - show_inline = FALSE; - - tempstr = eab_contact_list_to_string (contacts); - attach_data = GNOME_Evolution_Composer_AttachmentData__alloc(); - attach_data->_maximum = attach_data->_length = strlen (tempstr); - attach_data->_buffer = CORBA_sequence_CORBA_char_allocbuf (attach_data->_length); - memcpy (attach_data->_buffer, tempstr, attach_data->_length); - g_free (tempstr); - - GNOME_Evolution_Composer_attachData (composer_server, - content_type, filename, description, - show_inline, attach_data, - &ev); - - if (ev._major != CORBA_NO_EXCEPTION) { - g_printerr ("gui/e-meeting-edit.c: I couldn't attach data to the composer via CORBA! Aagh.\n"); - CORBA_exception_free (&ev); - return; - } - - CORBA_free (content_type); - CORBA_free (filename); - CORBA_free (description); - CORBA_free (attach_data); - - to_list = GNOME_Evolution_Composer_RecipientList__alloc (); - to_list->_maximum = to_list->_length = 0; - - cc_list = GNOME_Evolution_Composer_RecipientList__alloc (); - cc_list->_maximum = cc_list->_length = 0; - - bcc_list = GNOME_Evolution_Composer_RecipientList__alloc (); - bcc_list->_maximum = bcc_list->_length = 0; - - if (!contacts || contacts->next) { - subject = CORBA_string_dup ("Contact information"); - } else { - EContact *contact = contacts->data; - const gchar *tempstr2; - - tempstr2 = e_contact_get_const (contact, E_CONTACT_FILE_AS); - if (!tempstr2 || !*tempstr2) - tempstr2 = e_contact_get_const (contact, E_CONTACT_FULL_NAME); - if (!tempstr2 || !*tempstr2) - tempstr2 = e_contact_get_const (contact, E_CONTACT_ORG); - if (!tempstr2 || !*tempstr2) - tempstr2 = e_contact_get_const (contact, E_CONTACT_EMAIL_1); - if (!tempstr2 || !*tempstr2) - tempstr2 = e_contact_get_const (contact, E_CONTACT_EMAIL_2); - if (!tempstr2 || !*tempstr2) - tempstr2 = e_contact_get_const (contact, E_CONTACT_EMAIL_3); - - if (!tempstr2 || !*tempstr2) - tempstr = g_strdup_printf ("Contact information"); - else - tempstr = g_strdup_printf ("Contact information for %s", tempstr2); - subject = CORBA_string_dup (tempstr); - g_free (tempstr); - } - - GNOME_Evolution_Composer_setHeaders (composer_server, "", to_list, cc_list, bcc_list, subject, &ev); - - CORBA_free (to_list); - CORBA_free (cc_list); - CORBA_free (bcc_list); - CORBA_free (subject); - - GNOME_Evolution_Composer_show (composer_server, &ev); - - if (ev._major != CORBA_NO_EXCEPTION) { - g_printerr ("gui/e-meeting-edit.c: I couldn't show the composer via CORBA! Aagh.\n"); - CORBA_exception_free (&ev); - return; - } - - CORBA_exception_free (&ev); -} - -void -eab_send_contact_list (GList *contacts, EABDisposition disposition) -{ - switch (disposition) { - case EAB_DISPOSITION_AS_TO: { - GList *list = NULL, *l; - - for (l = contacts; l; l = l->next) { - ContactAndEmailNum *ce = g_new (ContactAndEmailNum, 1); - ce->contact = l->data; - ce->email_num = 0; /* hardcode this */ - - list = g_list_append (list, ce); - } - - eab_send_to_contact_and_email_num_list (list); - - g_list_foreach (list, (GFunc)g_free, NULL); - g_list_free (list); - break; - } - case EAB_DISPOSITION_AS_ATTACHMENT: - eab_send_contact_list_as_attachment (contacts); - break; - } -} - -void -eab_send_contact (EContact *contact, int email_num, EABDisposition disposition) -{ - GList *list = NULL; - - switch (disposition) { - case EAB_DISPOSITION_AS_TO: { - ContactAndEmailNum ce; - - ce.contact = contact; - ce.email_num = email_num; - - list = g_list_prepend (NULL, &ce); - eab_send_to_contact_and_email_num_list (list); - break; - } - case EAB_DISPOSITION_AS_ATTACHMENT: { - list = g_list_prepend (NULL, contact); - eab_send_contact_list_as_attachment (list); - break; - } - } - - g_list_free (list); -} - -GtkWidget * -eab_create_image_chooser_widget(gchar *name, - gchar *string1, gchar *string2, - gint int1, gint int2) -{ - char *filename; - GtkWidget *w = NULL; - - w = e_image_chooser_new (); - gtk_widget_show_all (w); - - if (string1) { - filename = e_icon_factory_get_icon_filename (string1, E_ICON_SIZE_DIALOG); - - e_image_chooser_set_from_file (E_IMAGE_CHOOSER (w), filename); - - g_free (filename); - } - - return w; -} diff --git a/addressbook/gui/widgets/eab-gui-util.h b/addressbook/gui/widgets/eab-gui-util.h deleted file mode 100644 index 4a3dffba0b..0000000000 --- a/addressbook/gui/widgets/eab-gui-util.h +++ /dev/null @@ -1,82 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* eab-gui-util.h - * Copyright (C) 2001-2003 Ximian, Inc. - * Author: Chris Toshok <toshok@ximian.com> - * - * This library 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 library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ -#ifndef __E_ADDRESSBOOK_UTIL_H__ -#define __E_ADDRESSBOOK_UTIL_H__ - -#include <gtk/gtkwindow.h> -#include <libebook/e-book.h> -#include "addressbook/gui/contact-editor/e-contact-editor.h" -#include "addressbook/gui/contact-list-editor/e-contact-list-editor.h" - -G_BEGIN_DECLS - -void eab_error_dialog (const gchar *msg, - EBookStatus status); -void eab_load_error_dialog (GtkWidget *parent, - ESource *source, - EBookStatus status); -void eab_search_result_dialog (GtkWidget *parent, - EBookViewStatus status); -gint eab_prompt_save_dialog (GtkWindow *parent); - -EContactEditor *eab_show_contact_editor (EBook *book, - EContact *contact, - gboolean is_new_contact, - gboolean editable); -EContactListEditor *eab_show_contact_list_editor (EBook *book, - EContact *contact, - gboolean is_new_contact, - gboolean editable); -void eab_show_multiple_contacts (EBook *book, - GList *list, - gboolean editable); -void eab_transfer_contacts (EBook *source, - GList *contacts, /* adopted */ - gboolean delete_from_source, - GtkWindow *parent_window); - -void eab_contact_save (char *title, - EContact *contact, - GtkWindow *parent_window); - -void eab_contact_list_save (char *title, - GList *list, - GtkWindow *parent_window); - -typedef enum { - EAB_DISPOSITION_AS_ATTACHMENT, - EAB_DISPOSITION_AS_TO, -} EABDisposition; - -void eab_send_contact (EContact *contact, - int email_num, - EABDisposition disposition); -void eab_send_contact_list (GList *contacts, - EABDisposition disposition); - -GtkWidget *eab_create_image_chooser_widget (gchar *name, gchar *string1, gchar *string2, gint int1, gint int2); - - -ESource *eab_select_source (const gchar *title, const gchar *message, - const gchar *select_uid, GtkWindow *parent); - -G_END_DECLS - -#endif /* __E_ADDRESSBOOK_UTIL_H__ */ diff --git a/addressbook/gui/widgets/eab-marshal.list b/addressbook/gui/widgets/eab-marshal.list deleted file mode 100644 index 2b34707dbb..0000000000 --- a/addressbook/gui/widgets/eab-marshal.list +++ /dev/null @@ -1,11 +0,0 @@ -INT:POINTER -NONE:NONE -NONE:BOOL -NONE:POINTER -NONE:OBJECT -NONE:ENUM -NONE:INT,INT -NONE:INT -NONE:UINT -NONE:DOUBLE -INT:POINTER diff --git a/addressbook/gui/widgets/eab-menu.c b/addressbook/gui/widgets/eab-menu.c deleted file mode 100644 index fd6c94c81e..0000000000 --- a/addressbook/gui/widgets/eab-menu.c +++ /dev/null @@ -1,258 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Authors: Michael Zucchi <notzed@ximian.com> - * - * Copyright 2004 Ximian, Inc. (www.ximian.com) - * - * 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 Street #330, Boston, MA 02111-1307, USA. - * - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <string.h> -#include <stdlib.h> - -#include <glib.h> - -#include <libebook/e-contact.h> - -#include "eab-menu.h" - -static void eabm_standard_menu_factory(EMenu *emp, void *data); - -static GObjectClass *eabm_parent; - -static void -eabm_init(GObject *o) -{ - /*EABMenu *emp = (EABMenu *)o; */ -} - -static void -eabm_finalise(GObject *o) -{ - ((GObjectClass *)eabm_parent)->finalize(o); -} - -static void -eabm_target_free(EMenu *ep, EMenuTarget *t) -{ - switch (t->type) { - case EAB_MENU_TARGET_SELECT: { - EABMenuTargetSelect *s = (EABMenuTargetSelect *)t; - int i; - - for (i=0;i<s->cards->len;i++) - g_object_unref(s->cards->pdata[i]); - g_ptr_array_free(s->cards, TRUE); - if (s->book) - g_object_unref(s->book); - break; } - } - - ((EMenuClass *)eabm_parent)->target_free(ep, t); -} - -static void -eabm_class_init(GObjectClass *klass) -{ - klass->finalize = eabm_finalise; - ((EMenuClass *)klass)->target_free = eabm_target_free; - - e_menu_class_add_factory((EMenuClass *)klass, NULL, (EMenuFactoryFunc)eabm_standard_menu_factory, NULL); -} - -GType -eab_menu_get_type(void) -{ - static GType type = 0; - - if (type == 0) { - static const GTypeInfo info = { - sizeof(EABMenuClass), - NULL, NULL, - (GClassInitFunc)eabm_class_init, - NULL, NULL, - sizeof(EABMenu), 0, - (GInstanceInitFunc)eabm_init - }; - eabm_parent = g_type_class_ref(e_menu_get_type()); - type = g_type_register_static(e_menu_get_type(), "EABMenu", &info, 0); - } - - return type; -} - -EABMenu *eab_menu_new(const char *menuid) -{ - EABMenu *emp = g_object_new(eab_menu_get_type(), 0); - - e_menu_construct(&emp->menu, menuid); - - return emp; -} - -/** - * eab_menu_target_new_select - create a menu target of the current selection. - * @eabp: Address book menu. - * @book: Book the cards belong to. May be NULL in which case cards must be an empty GPtrArray. - * @readonly: Book is read-only mode. FIXME: Why can't we just get this off the book? - * @cards: Cards selected. This will be freed on completion and the array indices unreferenced. - * - * Create a new selection menu target. - * - * Return value: - **/ -EABMenuTargetSelect * -eab_menu_target_new_select(EABMenu *eabp, struct _EBook *book, int readonly, GPtrArray *cards) -{ - EABMenuTargetSelect *t = e_menu_target_new(&eabp->menu, EAB_MENU_TARGET_SELECT, sizeof(*t)); - guint32 mask = ~0; - int has_email = FALSE, i; - - /* FIXME: duplicated in eab-popup.c */ - - t->book = book; - if (book) - g_object_ref(book); - t->cards = cards; - - for (i=0;i<cards->len && !has_email;i++) { - EContact *contact = cards->pdata[i]; - GList *email; - - email = e_contact_get(E_CONTACT(contact), E_CONTACT_EMAIL); - if (email) { - has_email = TRUE; - - g_list_foreach(email, (GFunc)g_free, NULL); - g_list_free(email); - } - } - - if (has_email) - mask &= ~EAB_MENU_SELECT_EMAIL; - - if (!readonly) - mask &= ~EAB_MENU_SELECT_EDITABLE; - - if (cards->len == 1) - mask &= ~EAB_MENU_SELECT_ONE; - - if (cards->len > 1) - mask &= ~EAB_MENU_SELECT_MANY; - - if (cards->len >= 1) - mask &= ~EAB_MENU_SELECT_ANY; - - t->target.mask = mask; - - return t; -} - -static void -eabm_standard_menu_factory(EMenu *emp, void *data) -{ - /* noop */ -} - -/* ********************************************************************** */ - -/* menu plugin handler */ - -/* -<e-plugin - class="org.gnome.mail.plugin.popup:1.0" - id="org.gnome.mail.plugin.popup.item:1.0" - type="shlib" - location="/opt/gnome2/lib/camel/1.0/libcamelimap.so" - name="imap" - description="IMAP4 and IMAP4v1 mail store"> - <hook class="org.gnome.mail.popupMenu:1.0" - handler="HandlePopup"> - <menu id="any" target="select"> - <item - type="item|toggle|radio|image|submenu|bar" - active - path="foo/bar" - label="label" - icon="foo" - mask="select_one" - activate="eabm_view_emacs"/> - </menu> - </extension> - -*/ - -static void *eabmph_parent_class; -#define eabmph ((EABMenuHook *)eph) - -static const EMenuHookTargetMask eabmph_select_masks[] = { - { "one", EAB_MENU_SELECT_ONE }, - { "many", EAB_MENU_SELECT_MANY }, - { "any", EAB_MENU_SELECT_ANY }, - { "editable", EAB_MENU_SELECT_EDITABLE }, - { "email", EAB_MENU_SELECT_EMAIL }, - { 0 } -}; - -static const EMenuHookTargetMap eabmph_targets[] = { - { "select", EAB_MENU_TARGET_SELECT, eabmph_select_masks }, - { 0 } -}; - -static void -eabmph_finalise(GObject *o) -{ - /*EPluginHook *eph = (EPluginHook *)o;*/ - - ((GObjectClass *)eabmph_parent_class)->finalize(o); -} - -static void -eabmph_class_init(EPluginHookClass *klass) -{ - int i; - - ((GObjectClass *)klass)->finalize = eabmph_finalise; - ((EPluginHookClass *)klass)->id = "org.gnome.evolution.addressbook.bonobomenu:1.0"; - - for (i=0;eabmph_targets[i].type;i++) - e_menu_hook_class_add_target_map((EMenuHookClass *)klass, &eabmph_targets[i]); - - /* FIXME: leaks parent set class? */ - ((EMenuHookClass *)klass)->menu_class = g_type_class_ref(eab_menu_get_type()); -} - -GType -eab_menu_hook_get_type(void) -{ - static GType type = 0; - - if (!type) { - static const GTypeInfo info = { - sizeof(EABMenuHookClass), NULL, NULL, (GClassInitFunc) eabmph_class_init, NULL, NULL, - sizeof(EABMenuHook), 0, (GInstanceInitFunc) NULL, - }; - - eabmph_parent_class = g_type_class_ref(e_menu_hook_get_type()); - type = g_type_register_static(e_menu_hook_get_type(), "EABMenuHook", &info, 0); - } - - return type; -} diff --git a/addressbook/gui/widgets/eab-menu.h b/addressbook/gui/widgets/eab-menu.h deleted file mode 100644 index 0427d43fe1..0000000000 --- a/addressbook/gui/widgets/eab-menu.h +++ /dev/null @@ -1,109 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- - * - * Authors: Michel Zucchi <notzed@ximian.com> - * - * Copyright 2004 Novell Inc. (www.novell.com) - * - * 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 Street #330, Boston, MA 02111-1307, USA. - * - */ - -#ifndef __EAB_MENU_H__ -#define __EAB_MENU_H__ - -#include <glib-object.h> - -#include "e-util/e-menu.h" - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - -struct _EBook; - -typedef struct _EABMenu EABMenu; -typedef struct _EABMenuClass EABMenuClass; - -/* Current target description */ -enum _eab_menu_target_t { - EAB_MENU_TARGET_SELECT, -}; - -/** - * enum _eab_menu_target_select_t - EABMenuTargetSelect qualifiers. - * - * @EAB_MENU_SELECT_ONE: Only one item is selected. - * @EAB_MENU_SELECT_MANY: More than one item selected. - * @EAB_MENU_SELECT_ANY: One or more items selected. - * @EAB_MENU_SELECT_EDITABLE: Editable addressbook. - * @EAB_MENU_SELECT_EMAIL: Has an email address. - **/ -enum _eab_menu_target_select_t { - EAB_MENU_SELECT_ONE = 1<<0, - EAB_MENU_SELECT_MANY = 1<<1, - EAB_MENU_SELECT_ANY = 1<<2, - EAB_MENU_SELECT_EDITABLE = 1<<3, - EAB_MENU_SELECT_EMAIL = 1<<4, -}; - -typedef struct _EABMenuTargetSelect EABMenuTargetSelect; - -struct _EABMenuTargetSelect { - EMenuTarget target; - - struct _EBook *book; - GPtrArray *cards; -}; - -typedef struct _EMenuItem EABMenuItem; - -/* The object */ -struct _EABMenu { - EMenu menu; - - struct _EABMenuPrivate *priv; -}; - -struct _EABMenuClass { - EMenuClass menu_class; -}; - -GType eab_menu_get_type(void); - -EABMenu *eab_menu_new(const char *menuid); - -EABMenuTargetSelect *eab_menu_target_new_select(EABMenu *eabp, struct _EBook *book, int readonly, GPtrArray *cards); - -/* ********************************************************************** */ - -typedef struct _EABMenuHook EABMenuHook; -typedef struct _EABMenuHookClass EABMenuHookClass; - -struct _EABMenuHook { - EMenuHook hook; -}; - -struct _EABMenuHookClass { - EMenuHookClass hook_class; -}; - -GType eab_menu_hook_get_type(void); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* __EAB_MENU_H__ */ diff --git a/addressbook/gui/widgets/eab-popup-control.c b/addressbook/gui/widgets/eab-popup-control.c deleted file mode 100644 index 10ef769632..0000000000 --- a/addressbook/gui/widgets/eab-popup-control.c +++ /dev/null @@ -1,1211 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * eab-popup-control.c - * - * Copyright (C) 2001-2003, Ximian, Inc. - * - * Authors: Jon Trowbridge <trow@ximian.com> - * Chris Toshok <toshok@ximian.com> - */ - -/* - * 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. - */ - -/* - * This file is too big and this widget is too complicated. Forgive me. - */ - -#include <config.h> -#include <string.h> -#include "addressbook.h" -#include "eab-popup-control.h" -#include <gtk/gtkbutton.h> -#include <gtk/gtkcellrenderertext.h> -#include <gtk/gtkframe.h> -#include <gtk/gtkhbbox.h> -#include <gtk/gtkhseparator.h> -#include <gtk/gtklabel.h> -#include <gtk/gtkoptionmenu.h> -#include <gtk/gtkstock.h> -#include <gtk/gtktable.h> -#include <gtk/gtktreeselection.h> -#include <gtk/gtktreeview.h> -#include <gtk/gtkvbox.h> -#include <bonobo/bonobo-control.h> -#include <bonobo/bonobo-property-bag.h> -#include <bonobo/bonobo-generic-factory.h> -#include <addressbook/util/eab-book-util.h> -#include <addressbook/gui/contact-editor/e-contact-editor.h> -#include <addressbook/gui/contact-editor/e-contact-quick-add.h> -#include <addressbook/gui/widgets/eab-contact-display.h> -#include <addressbook/gui/widgets/eab-gui-util.h> -#include "e-util/e-gui-utils.h" - -static void eab_popup_control_set_name (EABPopupControl *pop, const gchar *name); -static void eab_popup_control_set_email (EABPopupControl *pop, const gchar *email); - -/* - * Some general scaffolding for our widgets. Think of this as a really, really - * lame implementation of a wizard (...which is still somewhat more general that - * we really need it to be). - */ - -typedef struct _MiniWizard MiniWizard; -struct _MiniWizard { - GtkWidget *body; - - GtkWidget *vbox; - GtkWidget *ok_button; - GtkWidget *cancel_button; - - void (*ok_cb) (MiniWizard *, gpointer); - void (*cleanup_cb) (gpointer); - gpointer closure; - - void (*destroy_cb) (MiniWizard *, gpointer); - gpointer destroy_closure; -}; - -static void -mini_wizard_container_add (MiniWizard *wiz, GtkWidget *w) -{ - GList *iter = gtk_container_get_children (GTK_CONTAINER (wiz->vbox)); - while (iter != NULL) { - GtkWidget *oldw = (GtkWidget *) iter->data; - iter = g_list_next (iter); - gtk_container_remove (GTK_CONTAINER (wiz->vbox), oldw); - } - gtk_container_add (GTK_CONTAINER (wiz->vbox), w); -} - -static void -mini_wizard_destroy (MiniWizard *wiz) -{ - if (wiz->cleanup_cb) - wiz->cleanup_cb (wiz->closure); - wiz->cleanup_cb = NULL; - - if (wiz->destroy_cb) - wiz->destroy_cb (wiz, wiz->destroy_closure); -} - -static void -mini_wizard_ok_cb (GtkWidget *b, gpointer closure) -{ - MiniWizard *wiz = (MiniWizard *) closure; - - gpointer old_closure = wiz->closure; - void (*old_cleanup) (gpointer) = wiz->cleanup_cb; - - wiz->cleanup_cb = NULL; - - if (wiz->ok_cb) - wiz->ok_cb (wiz, wiz->closure); - - if (old_cleanup) - old_cleanup (old_closure); - -} - -static void -mini_wizard_cancel_cb (GtkWidget *b, gpointer closure) -{ - mini_wizard_destroy ((MiniWizard *) closure); -} - -static void -mini_wizard_destroy_cb (gpointer closure, GObject *where_object_was) -{ - MiniWizard *wiz = (MiniWizard *) closure; - if (wiz->cleanup_cb) - wiz->cleanup_cb (wiz->closure); - g_free (wiz); -} - -static MiniWizard * -mini_wizard_new (void) -{ - MiniWizard *wiz = g_new (MiniWizard, 1); - GtkWidget *bbox; - - wiz->body = gtk_vbox_new (FALSE, 2); - wiz->vbox = gtk_vbox_new (FALSE, 2); - wiz->ok_button = gtk_button_new_from_stock (GTK_STOCK_OK); - wiz->cancel_button = gtk_button_new_from_stock (GTK_STOCK_CANCEL); - - wiz->ok_cb = NULL; - wiz->cleanup_cb = NULL; - wiz->closure = NULL; - - wiz->destroy_cb = NULL; - wiz->destroy_closure = NULL; - - bbox = gtk_hbutton_box_new (); - gtk_button_box_set_layout (GTK_BUTTON_BOX (bbox), - GTK_BUTTONBOX_END); - - gtk_box_pack_start (GTK_BOX (bbox), wiz->cancel_button, FALSE, TRUE, 0); - gtk_box_pack_start (GTK_BOX (bbox), wiz->ok_button, FALSE, TRUE, 0); - - gtk_box_set_spacing (GTK_BOX (bbox), - 10 /* ugh */); - - gtk_box_pack_start (GTK_BOX (wiz->body), wiz->vbox, TRUE, TRUE, 2); - gtk_box_pack_start (GTK_BOX (wiz->body), gtk_hseparator_new (), FALSE, TRUE, 2); - gtk_box_pack_start (GTK_BOX (wiz->body), bbox, FALSE, TRUE, 2); - - gtk_widget_show_all (wiz->body); - - g_signal_connect (wiz->ok_button, - "clicked", - G_CALLBACK (mini_wizard_ok_cb), - wiz); - g_signal_connect (wiz->cancel_button, - "clicked", - G_CALLBACK (mini_wizard_cancel_cb), - wiz); - - g_object_weak_ref (G_OBJECT (wiz->body), - mini_wizard_destroy_cb, - wiz); - - return wiz; - -} - - - -/* - * This is the code for the UI thingie that lets you manipulate the e-mail - * addresses (and *only* the e-mail addresses) associated with an existing - * contact. - */ - -#define EMPTY_ENTRY _("(none)") - -typedef struct _EMailMenu EMailMenu; -struct _EMailMenu { - GtkWidget *option_menu; - GList *options; - gchar *current_selection; -}; - -static void -email_menu_free (EMailMenu *menu) -{ - if (menu == NULL) - return; - - g_list_foreach (menu->options, (GFunc) g_free, NULL); - g_list_free (menu->options); - g_free (menu); -} - -static EMailMenu * -email_menu_new (void) -{ - EMailMenu *menu = g_new (EMailMenu, 1); - - menu->option_menu = gtk_option_menu_new (); - menu->options = NULL; - menu->current_selection = NULL; - - gtk_option_menu_set_menu (GTK_OPTION_MENU (menu->option_menu), gtk_menu_new ()); - - return menu; -} - -static void -menu_activate_cb (GtkWidget *w, gpointer closure) -{ - EMailMenu *menu = (EMailMenu *) closure; - gchar *addr = (gchar *) g_object_get_data (G_OBJECT (w), "addr"); - - menu->current_selection = addr; -} - -static void -email_menu_add_option (EMailMenu *menu, char *addr) -{ - GtkWidget *menu_item; - - g_return_if_fail (menu != NULL); - if (!addr || !*addr) - return; - - menu->options = g_list_append (menu->options, addr); - - menu_item = gtk_menu_item_new_with_label (addr); - g_object_set_data (G_OBJECT (menu_item), "addr", addr); - gtk_widget_show_all (menu_item); - gtk_menu_shell_append (GTK_MENU_SHELL (gtk_option_menu_get_menu (GTK_OPTION_MENU (menu->option_menu))), menu_item); - - g_signal_connect (menu_item, - "activate", - G_CALLBACK (menu_activate_cb), - menu); -} - -static void -email_menu_add_options_from_contact (EMailMenu *menu, EContact *contact, const gchar *extra_addr) -{ - g_return_if_fail (contact && E_IS_CONTACT (contact)); - - /* If any of these three e-mail fields are NULL, email_menu_add_option will just - return without doing anything. */ - email_menu_add_option (menu, e_contact_get (contact, E_CONTACT_EMAIL_1)); - email_menu_add_option (menu, e_contact_get (contact, E_CONTACT_EMAIL_2)); - email_menu_add_option (menu, e_contact_get (contact, E_CONTACT_EMAIL_3)); - email_menu_add_option (menu, g_strdup (extra_addr)); - email_menu_add_option (menu, g_strdup (EMPTY_ENTRY)); -} - -static void -email_menu_set_option (EMailMenu *menu, const gchar *addr) -{ - guint count = 0; - GList *iter; - - g_return_if_fail (menu != NULL); - - if (addr == NULL) { - email_menu_set_option (menu, EMPTY_ENTRY); - return; - } - - iter = menu->options; - while (iter && strcmp (addr, (gchar *) iter->data)) { - ++count; - iter = g_list_next (iter); - } - - if (iter) { - gtk_option_menu_set_history (GTK_OPTION_MENU (menu->option_menu), count); - menu->current_selection = (gchar *) iter->data; - } -} - -typedef struct _EMailTable EMailTable; -struct _EMailTable { - GtkWidget *table; - EContact *contact; - EMailMenu *primary; - EMailMenu *email2; - EMailMenu *email3; -}; - -static void -email_table_cleanup_cb (gpointer closure) -{ - EMailTable *et = (EMailTable *) closure; - - if (et == NULL) - return; - - g_object_unref (et->contact); - email_menu_free (et->primary); - email_menu_free (et->email2); - email_menu_free (et->email3); - - g_free (et); -} - -static void -email_table_from_contact (EMailTable *et) -{ - g_return_if_fail (et != NULL); - - email_menu_set_option (et->primary, e_contact_get_const (et->contact, E_CONTACT_EMAIL_1)); - email_menu_set_option (et->email2, e_contact_get_const (et->contact, E_CONTACT_EMAIL_2)); - email_menu_set_option (et->email3, e_contact_get_const (et->contact, E_CONTACT_EMAIL_3)); -} - -static void -email_table_to_contact (EMailTable *et) -{ - gchar *curr; - - g_return_if_fail (et != NULL); - - curr = et->primary->current_selection; - if (curr && !strcmp (curr, _(EMPTY_ENTRY))) - curr = NULL; - e_contact_set (et->contact, E_CONTACT_EMAIL_1, curr); - - curr = et->email2->current_selection; - if (curr && !strcmp (curr, _(EMPTY_ENTRY))) - curr = NULL; - e_contact_set (et->contact, E_CONTACT_EMAIL_2, curr); - - curr = et->email3->current_selection; - if (curr && !strcmp (curr, _(EMPTY_ENTRY))) - curr = NULL; - e_contact_set (et->contact, E_CONTACT_EMAIL_3, curr); -} - -static void -email_table_save_contact_cb (EBook *book, EBookStatus status, gpointer closure) -{ - EContact *contact = E_CONTACT (closure); - - if (status == E_BOOK_ERROR_OK) { - e_book_async_commit_contact (book, contact, NULL, NULL); - } - if (book) - g_object_unref (book); - g_object_unref (contact); -} - -static void -email_table_ok_cb (MiniWizard *wiz, gpointer closure) -{ - EMailTable *et = (EMailTable *) closure; - - email_table_to_contact (et); - - g_object_ref (et->contact); - - addressbook_load_default_book (email_table_save_contact_cb, et->contact); - - mini_wizard_destroy (wiz); -} - -static void -email_table_init (MiniWizard *wiz, EContact *contact, const gchar *extra_address) -{ - EMailTable *et; - - gchar *name_str; - gint xpad, ypad; - GtkAttachOptions label_x_opts, label_y_opts; - GtkAttachOptions menu_x_opts, menu_y_opts; - - g_return_if_fail (contact && E_IS_CONTACT (contact)); - - et = g_new (EMailTable, 1); - - et->contact = contact; - g_object_ref (et->contact); - - et->table = gtk_table_new (4, 2, FALSE); - - et->primary = email_menu_new (); - et->email2 = email_menu_new (); - et->email3 = email_menu_new (); - - email_menu_add_options_from_contact (et->primary, et->contact, extra_address); - email_menu_add_options_from_contact (et->email2, et->contact, extra_address); - email_menu_add_options_from_contact (et->email3, et->contact, extra_address); - - email_table_from_contact (et); - - label_x_opts = GTK_FILL; - label_y_opts = GTK_FILL; - menu_x_opts = GTK_EXPAND | GTK_FILL; - menu_y_opts = GTK_EXPAND | GTK_FILL; - xpad = 3; - ypad = 3; - - name_str = e_contact_get (et->contact, E_CONTACT_FULL_NAME); - gtk_table_attach (GTK_TABLE (et->table), - gtk_label_new (name_str), - 0, 2, 0, 1, - label_x_opts, label_y_opts, xpad, ypad); - g_free (name_str); - - gtk_table_attach (GTK_TABLE (et->table), - gtk_label_new (_("Primary Email")), - 0, 1, 1, 2, - label_x_opts, label_y_opts, xpad, ypad); - - gtk_table_attach (GTK_TABLE (et->table), - et->primary->option_menu, - 1, 2, 1, 2, - menu_x_opts, menu_y_opts, xpad, ypad); - - gtk_table_attach (GTK_TABLE (et->table), - gtk_label_new (_("Email 2")), - 0, 1, 2, 3, - label_x_opts, label_y_opts, xpad, ypad); - - gtk_table_attach (GTK_TABLE (et->table), - et->email2->option_menu, - 1, 2, 2, 3, - menu_x_opts, menu_y_opts, xpad, ypad); - - gtk_table_attach (GTK_TABLE (et->table), - gtk_label_new (_("Email 3")), - 0, 1, 3, 4, - label_x_opts, label_y_opts, xpad, ypad); - - gtk_table_attach (GTK_TABLE (et->table), - et->email3->option_menu, - 1, 2, 3, 4, - menu_x_opts, menu_y_opts, xpad, ypad); - - gtk_widget_show_all (et->primary->option_menu); - gtk_widget_show_all (et->email2->option_menu); - gtk_widget_show_all (et->email3->option_menu); - - gtk_widget_show_all (et->table); - mini_wizard_container_add (wiz, et->table); - wiz->ok_cb = email_table_ok_cb; - wiz->cleanup_cb = email_table_cleanup_cb; - wiz->closure = et; -} - -/* - * This code is for the little UI thing that lets you pick from a set of contacts - * and decide which one you want to add the e-mail address to. - */ - -typedef struct _ContactPicker ContactPicker; -struct _ContactPicker { - GtkWidget *body; - GtkWidget *list; - GtkListStore *model; - GList *contacts; - gchar *new_name; - gchar *new_email; - - EContact *current_contact; -}; - -enum { - COLUMN_ACTION, - COLUMN_CONTACT -}; - -static void -contact_picker_selection_changed (GtkTreeSelection *selection, gpointer closure) -{ - MiniWizard *wiz = (MiniWizard *) closure; - ContactPicker *pick = (ContactPicker *) wiz->closure; - gboolean selected; - GtkTreeIter iter; - - selected = gtk_tree_selection_get_selected (selection, NULL, &iter); - - gtk_widget_set_sensitive (wiz->ok_button, selected); - - if (selected) { - gtk_tree_model_get (GTK_TREE_MODEL (pick->model), &iter, - COLUMN_CONTACT, &pick->current_contact, - -1); - } - else { - pick->current_contact = NULL; - } -} - -static void -contact_picker_ok_cb (MiniWizard *wiz, gpointer closure) -{ - ContactPicker *pick = (ContactPicker *) closure; - - if (pick->current_contact == NULL) { - e_contact_quick_add (pick->new_name, pick->new_email, NULL, NULL); - mini_wizard_destroy (wiz); - } else { - email_table_init (wiz, pick->current_contact, pick->new_email); - } -} - -static void -contact_picker_cleanup_cb (gpointer closure) -{ - ContactPicker *pick = (ContactPicker *) closure; - - g_list_foreach (pick->contacts, (GFunc) g_object_unref, NULL); - g_list_free (pick->contacts); - - g_free (pick->new_name); - g_free (pick->new_email); -} - -static void -free_str (gpointer data, - GObject *where_the_object_was) -{ - g_free (data); -} - -static void -contact_picker_init (MiniWizard *wiz, const GList *contacts, const gchar *new_name, const gchar *new_email) -{ - ContactPicker *pick; - gchar *str; - GtkWidget *w; - GtkTreeIter iter; - - pick = g_new (ContactPicker, 1); - - pick->body = gtk_vbox_new (FALSE, 2); - - pick->model = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_POINTER); - - pick->list = gtk_tree_view_new_with_model (GTK_TREE_MODEL (pick->model)); - - gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (pick->list), TRUE); - - gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (pick->list), - COLUMN_ACTION, - _("Select an Action"), - gtk_cell_renderer_text_new (), - "text", COLUMN_ACTION, - NULL); - - gtk_tree_selection_set_mode (gtk_tree_view_get_selection (GTK_TREE_VIEW (pick->list)), - GTK_SELECTION_SINGLE); - - str = g_strdup_printf (_("Create a new contact \"%s\""), new_name); - gtk_list_store_append (pick->model, &iter); - gtk_list_store_set (pick->model, &iter, - COLUMN_ACTION, str, - COLUMN_CONTACT, NULL, - -1); - g_object_weak_ref (G_OBJECT (pick->model), free_str, str); - - pick->contacts = NULL; - while (contacts) { - EContact *contact = (EContact *) contacts->data; - gchar *name_str = e_contact_get (contact, E_CONTACT_FULL_NAME); - - pick->contacts = g_list_append (pick->contacts, contact); - g_object_ref (contact); - - str = g_strdup_printf (_("Add address to existing contact \"%s\""), name_str); - gtk_list_store_append (pick->model, &iter); - gtk_list_store_set (pick->model, &iter, - COLUMN_ACTION, str, - COLUMN_CONTACT, contact, - -1); - g_free (name_str); - - g_object_weak_ref (G_OBJECT (pick->model), free_str, str); - - contacts = g_list_next (contacts); - } - - pick->new_name = g_strdup (new_name); - pick->new_email = g_strdup (new_email); - - pick->current_contact = NULL; - gtk_widget_set_sensitive (wiz->ok_button, FALSE); - - /* Connect some signals & callbacks */ - - wiz->ok_cb = contact_picker_ok_cb; - wiz->cleanup_cb = contact_picker_cleanup_cb; - - g_signal_connect (gtk_tree_view_get_selection (GTK_TREE_VIEW (pick->list)), - "changed", G_CALLBACK (contact_picker_selection_changed), - wiz); - - /* Build our widget */ - - w = gtk_label_new (new_email); - gtk_box_pack_start (GTK_BOX (pick->body), w, FALSE, TRUE, 3); - - gtk_box_pack_start (GTK_BOX (pick->body), pick->list, TRUE, TRUE, 2); - gtk_widget_show_all (pick->body); - - - /* Put it in our mini-wizard */ - - wiz->closure = pick; - mini_wizard_container_add (wiz, pick->body); -} - -/* ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** */ - -/* - * The code for the actual EABPopupControl widget begins here. - */ - -/* ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** */ - - -static GtkObjectClass *parent_class; - -static void eab_popup_control_dispose (GObject *); -static void eab_popup_control_query (EABPopupControl *); - - -static void -eab_popup_control_class_init (EABPopupControlClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - parent_class = g_type_class_peek_parent (klass); - - object_class->dispose = eab_popup_control_dispose; -} - -static void -eab_popup_control_init (EABPopupControl *pop) -{ - pop->transitory = TRUE; -} - -static void -eab_popup_control_cleanup (EABPopupControl *pop) -{ - if (pop->contact) { - g_object_unref (pop->contact); - pop->contact = NULL; - } - - if (pop->scheduled_refresh) { - g_source_remove (pop->scheduled_refresh); - pop->scheduled_refresh = 0; - } - - if (pop->query_tag) { -#if notyet - e_book_simple_query_cancel (pop->book, pop->query_tag); -#endif - pop->query_tag = 0; - } - - if (pop->book) { - g_object_unref (pop->book); - pop->book = NULL; - } - - g_free (pop->name); - pop->name = NULL; - - g_free (pop->email); - pop->email = NULL; -} - -static void -eab_popup_control_dispose (GObject *obj) -{ - EABPopupControl *pop = EAB_POPUP_CONTROL (obj); - - eab_popup_control_cleanup (pop); - - if (G_OBJECT_CLASS (parent_class)->dispose) - G_OBJECT_CLASS (parent_class)->dispose (obj); -} - -GType -eab_popup_control_get_type (void) -{ - static GType pop_type = 0; - - if (!pop_type) { - static const GTypeInfo pop_info = { - sizeof (EABPopupControlClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) eab_popup_control_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (EABPopupControl), - 0, /* n_preallocs */ - (GInstanceInitFunc) eab_popup_control_init, - }; - - pop_type = g_type_register_static (gtk_event_box_get_type (), "EABPopupControl", &pop_info, 0); - } - - return pop_type; -} - -static void -eab_popup_control_refresh_names (EABPopupControl *pop) -{ - if (pop->name_widget) { - if (pop->name && *pop->name) { - gtk_label_set_text (GTK_LABEL (pop->name_widget), pop->name); - gtk_widget_show (pop->name_widget); - } else { - gtk_widget_hide (pop->name_widget); - } - } - - if (pop->email_widget) { - if (pop->email && *pop->email) { - gtk_label_set_text (GTK_LABEL (pop->email_widget), pop->email); - gtk_widget_show (pop->email_widget); - } else { - gtk_widget_hide (pop->email_widget); - } - } - - eab_popup_control_query (pop); -} - -static gint -refresh_timeout_cb (gpointer ptr) -{ - EABPopupControl *pop = EAB_POPUP_CONTROL (ptr); - eab_popup_control_refresh_names (pop); - pop->scheduled_refresh = 0; - return 0; -} - -static void -eab_popup_control_schedule_refresh (EABPopupControl *pop) -{ - if (pop->scheduled_refresh == 0) - pop->scheduled_refresh = g_timeout_add (20, refresh_timeout_cb, pop); -} - -/* If we are handed something of the form "Foo <bar@bar.com>", - do the right thing. */ -static gboolean -eab_popup_control_set_free_form (EABPopupControl *pop, const gchar *txt) -{ - gchar *lt, *gt = NULL; - - g_return_val_if_fail (pop && EAB_IS_POPUP_CONTROL (pop), FALSE); - - if (txt == NULL) - return FALSE; - - lt = strchr (txt, '<'); - if (lt) - gt = strchr (txt, '>'); - - if (lt && gt && lt+1 < gt) { - gchar *name = g_strndup (txt, lt-txt); - gchar *email = g_strndup (lt+1, gt-lt-1); - eab_popup_control_set_name (pop, name); - eab_popup_control_set_email (pop, email); - - return TRUE; - } - - return FALSE; -} - -static void -eab_popup_control_set_name (EABPopupControl *pop, const gchar *name) -{ - g_return_if_fail (pop && EAB_IS_POPUP_CONTROL (pop)); - - /* We only allow the name to be set once. */ - if (pop->name) - return; - - if (!eab_popup_control_set_free_form (pop, name)) { - pop->name = g_strdup (name); - if (pop->name) - g_strstrip (pop->name); - } - - eab_popup_control_schedule_refresh (pop); -} - -static void -eab_popup_control_set_email (EABPopupControl *pop, const gchar *email) -{ - g_return_if_fail (pop && EAB_IS_POPUP_CONTROL (pop)); - - /* We only allow the e-mail to be set once. */ - if (pop->email) - return; - - if (!eab_popup_control_set_free_form (pop, email)) { - pop->email = g_strdup (email); - if (pop->email) - g_strstrip (pop->email); - } - - eab_popup_control_schedule_refresh (pop); -} - -void -eab_popup_control_construct (EABPopupControl *pop) -{ - GtkWidget *vbox, *name_holder; - GdkColor color = { 0x0, 0xffff, 0xffff, 0xffff }; - - g_return_if_fail (pop && EAB_IS_POPUP_CONTROL (pop)); - - pop->main_vbox = gtk_vbox_new (FALSE, 0); - - /* Build Generic View */ - - name_holder = gtk_event_box_new (); - vbox = gtk_vbox_new (FALSE, 2); - pop->name_widget = gtk_label_new (""); - pop->email_widget = gtk_label_new (""); - - gtk_box_pack_start (GTK_BOX (vbox), pop->name_widget, TRUE, TRUE, 2); - gtk_box_pack_start (GTK_BOX (vbox), pop->email_widget, TRUE, TRUE, 2); - gtk_container_add (GTK_CONTAINER (name_holder), GTK_WIDGET (vbox)); - - if (gdk_colormap_alloc_color (gtk_widget_get_colormap (GTK_WIDGET (name_holder)), &color, FALSE, TRUE)) { - GtkStyle *style = gtk_style_copy (gtk_widget_get_style (GTK_WIDGET (name_holder))); - style->bg[0] = color; - gtk_widget_set_style (GTK_WIDGET (name_holder), style); - g_object_unref (style); - } - - pop->generic_view = gtk_frame_new (NULL); - gtk_container_add (GTK_CONTAINER (pop->generic_view), name_holder); - gtk_box_pack_start (GTK_BOX (pop->main_vbox), pop->generic_view, TRUE, TRUE, 0); - gtk_widget_show_all (pop->generic_view); - - pop->query_msg = gtk_label_new (_("Querying Address Book...")); - gtk_box_pack_start (GTK_BOX (pop->main_vbox), pop->query_msg, TRUE, TRUE, 0); - gtk_widget_show (pop->query_msg); - - /* Build ContactDisplay */ - pop->contact_display = eab_contact_display_new (); - gtk_box_pack_start (GTK_BOX (pop->main_vbox), pop->contact_display, TRUE, TRUE, 0); - - - /* Final assembly */ - - gtk_container_add (GTK_CONTAINER (pop), pop->main_vbox); - gtk_widget_show (pop->main_vbox); - - gtk_container_set_border_width (GTK_CONTAINER (vbox), 3); - gtk_container_set_border_width (GTK_CONTAINER (pop), 2); -} - -static GtkWidget * -eab_popup_new (void) -{ - EABPopupControl *pop = g_object_new (EAB_TYPE_POPUP_CONTROL, NULL); - eab_popup_control_construct (pop); - return GTK_WIDGET (pop); -} - -static void -emit_event (EABPopupControl *pop, const char *event) -{ - if (pop->es) { - BonoboArg *arg; - - arg = bonobo_arg_new (BONOBO_ARG_BOOLEAN); - BONOBO_ARG_SET_BOOLEAN (arg, TRUE); - bonobo_event_source_notify_listeners_full (pop->es, - "GNOME/Evolution/Addressbook/AddressPopup", - "Event", - event, - arg, NULL); - bonobo_arg_release (arg); - } -} - -static void -contact_editor_cb (EBook *book, EBookStatus status, gpointer closure) -{ - if (status == E_BOOK_ERROR_OK) { - EABPopupControl *pop = EAB_POPUP_CONTROL (closure); - eab_show_contact_editor (book, pop->contact, FALSE, TRUE); - eab_popup_control_cleanup (pop); - emit_event (pop, "Destroy"); - } - - if (book) - g_object_unref (book); -} - -static void -edit_contact_info_cb (GtkWidget *button, EABPopupControl *pop) -{ - emit_event (pop, "Hide"); - - addressbook_load_default_book (contact_editor_cb, pop); -} - -static void -eab_popup_control_display_contact (EABPopupControl *pop, EContact *contact) -{ - GtkWidget *b; - - g_return_if_fail (pop && EAB_IS_POPUP_CONTROL (pop)); - g_return_if_fail (contact && E_IS_CONTACT (contact)); - g_return_if_fail (pop->contact == NULL); - - pop->contact = contact; - g_object_ref (pop->contact); - - eab_contact_display_render (EAB_CONTACT_DISPLAY (pop->contact_display), - contact, - EAB_CONTACT_DISPLAY_RENDER_COMPACT); - gtk_widget_show (pop->contact_display); - gtk_widget_hide (pop->generic_view); - - b = gtk_button_new_with_label (_("Edit Contact Info")); - gtk_box_pack_start (GTK_BOX (pop->main_vbox), b, TRUE, TRUE, 0); - g_signal_connect (b, - "clicked", - G_CALLBACK (edit_contact_info_cb), - pop); - gtk_widget_show (b); -} - -static void -add_contacts_cb (GtkWidget *button, EABPopupControl *pop) -{ - if (pop->email && *pop->email) { - if (pop->name && *pop->name) - e_contact_quick_add (pop->name, pop->email, NULL, NULL); - else - e_contact_quick_add_free_form (pop->email, NULL, NULL); - - } - eab_popup_control_cleanup (pop); - emit_event (pop, "Destroy"); -} - -static void -eab_popup_control_no_matches (EABPopupControl *pop) -{ - GtkWidget *b; - - g_return_if_fail (pop && EAB_IS_POPUP_CONTROL (pop)); - - b = e_button_new_with_stock_icon (_("Add to Contacts"), "gtk-add"); - - gtk_box_pack_start (GTK_BOX (pop->main_vbox), b, TRUE, TRUE, 0); - g_signal_connect (b, - "clicked", - G_CALLBACK (add_contacts_cb), - pop); - gtk_widget_show (b); -} - -static void -wizard_destroy_cb (MiniWizard *wiz, gpointer closure) -{ - gtk_widget_destroy (GTK_WIDGET (closure)); -} - -static void -eab_popup_control_ambiguous_email_add (EABPopupControl *pop, const GList *contacts) -{ - MiniWizard *wiz = mini_wizard_new (); - GtkWidget *win = gtk_window_new (GTK_WINDOW_TOPLEVEL); - - wiz->destroy_cb = wizard_destroy_cb; - wiz->destroy_closure = win; - - gtk_window_set_title (GTK_WINDOW (win), _("Merge E-Mail Address")); - gtk_window_set_position (GTK_WINDOW (win), GTK_WIN_POS_MOUSE); - - contact_picker_init (wiz, contacts, pop->name, pop->email); - - eab_popup_control_cleanup (pop); - emit_event (pop, "Destroy"); - - gtk_container_add (GTK_CONTAINER (win), wiz->body); - gtk_widget_show_all (win); -} - -static void -eab_popup_control_multiple_matches (EABPopupControl *pop, const GList *contacts) -{ - pop->multiple_matches = TRUE; - - eab_popup_control_ambiguous_email_add (pop, contacts); -} - -/** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **/ - -/* - * Addressbook Query Fun - */ - -static void -name_only_query_cb (EBook *book, EBookStatus status, GList *contacts, gpointer closure) -{ - EABPopupControl *pop; - - if (status != E_BOOK_ERROR_OK) - return; - - pop = EAB_POPUP_CONTROL (closure); - - pop->query_tag = 0; - - if (contacts == NULL) { - eab_popup_control_no_matches (pop); - } else { - eab_popup_control_ambiguous_email_add (pop, contacts); - } -} - -static void -query_cb (EBook *book, EBookStatus status, GList *contacts, gpointer closure) -{ - EABPopupControl *pop; - - if (status != E_BOOK_ERROR_OK) - return; - - pop = EAB_POPUP_CONTROL (closure); - - pop->query_tag = 0; - gtk_widget_hide (pop->query_msg); - - if (contacts == NULL) { - - /* Do a name-only query if: - (1) The name is non-empty. - (2) The e-mail is also non-empty (so that the query we just did wasn't actually a name-only query. - */ - if (pop->name && *pop->name && pop->email && *pop->email) { - pop->query_tag = eab_name_and_email_query (book, pop->name, NULL, name_only_query_cb, pop); - } else { - eab_popup_control_no_matches (pop); - } - - } else { - if (g_list_length ((GList *) contacts) == 1) - eab_popup_control_display_contact (pop, E_CONTACT (contacts->data)); - else - eab_popup_control_multiple_matches (pop, contacts); - } -} - -static void -start_query (EBook *book, EBookStatus status, gpointer closure) -{ - EABPopupControl *pop = EAB_POPUP_CONTROL (closure); - - if (status != E_BOOK_ERROR_OK) { - eab_popup_control_no_matches (pop); - if (book) - g_object_unref (book); - return; - } - -#if notyet - if (pop->query_tag) - e_book_simple_query_cancel (book, pop->query_tag); -#endif - - if (pop->book != book) { - g_object_ref (book); - if (pop->book) - g_object_unref (pop->book); - pop->book = book; - } - - pop->query_tag = eab_name_and_email_query (book, pop->name, pop->email, query_cb, pop); - - g_object_unref (pop); -} - -static void -eab_popup_control_query (EABPopupControl *pop) -{ - g_return_if_fail (pop && EAB_IS_POPUP_CONTROL (pop)); - - g_object_ref (pop); - - addressbook_load_default_book (start_query, pop); -} - -/** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **/ - -enum { - PROPERTY_NAME, - PROPERTY_EMAIL, - PROPERTY_TRANSITORY -}; - -static void -set_prop (BonoboPropertyBag *bag, const BonoboArg *arg, guint arg_id, CORBA_Environment *ev, gpointer user_data) -{ - EABPopupControl *pop = EAB_POPUP_CONTROL (user_data); - - switch (arg_id) { - - case PROPERTY_NAME: - eab_popup_control_set_name (pop, BONOBO_ARG_GET_STRING (arg)); - break; - - case PROPERTY_EMAIL: - eab_popup_control_set_email (pop, BONOBO_ARG_GET_STRING (arg)); - break; - - default: - g_assert_not_reached (); - } -} - -static void -get_prop (BonoboPropertyBag *bag, BonoboArg *arg, guint arg_id, CORBA_Environment *ev, gpointer user_data) -{ - EABPopupControl *pop = EAB_POPUP_CONTROL (user_data); - - switch (arg_id) { - - case PROPERTY_NAME: - BONOBO_ARG_SET_STRING (arg, pop->name); - break; - - case PROPERTY_EMAIL: - BONOBO_ARG_SET_STRING (arg, pop->email); - break; - - case PROPERTY_TRANSITORY: - BONOBO_ARG_SET_BOOLEAN (arg, pop->transitory); - break; - - default: - g_assert_not_reached (); - } -} - -BonoboControl * -eab_popup_control_new (void) -{ - BonoboControl *control; - BonoboPropertyBag *bag; - EABPopupControl *addy; - GtkWidget *w; - - w = eab_popup_new (); - addy = EAB_POPUP_CONTROL (w); - - control = bonobo_control_new (w); - gtk_widget_show (w); - - bag = bonobo_property_bag_new (get_prop, set_prop, w); - bonobo_property_bag_add (bag, "name", PROPERTY_NAME, - BONOBO_ARG_STRING, NULL, NULL, - BONOBO_PROPERTY_WRITEABLE | BONOBO_PROPERTY_READABLE); - - bonobo_property_bag_add (bag, "email", PROPERTY_EMAIL, - BONOBO_ARG_STRING, NULL, NULL, - BONOBO_PROPERTY_WRITEABLE | BONOBO_PROPERTY_READABLE); - - bonobo_property_bag_add (bag, "transitory", PROPERTY_TRANSITORY, - BONOBO_ARG_BOOLEAN, NULL, NULL, - BONOBO_PROPERTY_READABLE); - - bonobo_control_set_properties (control, bonobo_object_corba_objref (BONOBO_OBJECT (bag)), NULL); - bonobo_object_unref (BONOBO_OBJECT (bag)); - - addy->es = bonobo_event_source_new (); - bonobo_object_add_interface (BONOBO_OBJECT (control), - BONOBO_OBJECT (addy->es)); - - return control; -} diff --git a/addressbook/gui/widgets/eab-popup-control.h b/addressbook/gui/widgets/eab-popup-control.h deleted file mode 100644 index 1f4f22558f..0000000000 --- a/addressbook/gui/widgets/eab-popup-control.h +++ /dev/null @@ -1,86 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * eab-popup-control.h - * - * Copyright (C) 2001-2003, Ximian, Inc. - * - * Authors: Jon Trowbridge <trow@ximian.com> - * Chris Toshok <toshok@ximian.com> - */ - -/* - * 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. - */ - -#ifndef __EAB_POPUP_CONTROL_H__ -#define __EAB_POPUP_CONTROL_H__ - -#include <bonobo/bonobo-event-source.h> -#include <libebook/e-book.h> -#include <libebook/e-contact.h> - -#include <gtk/gtkeventbox.h> - -G_BEGIN_DECLS - -#define EAB_TYPE_POPUP_CONTROL (eab_popup_control_get_type ()) -#define EAB_POPUP_CONTROL(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EAB_TYPE_POPUP_CONTROL, EABPopupControl)) -#define EAB_POPUP_CONTROL_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), EAB_TYPE_POPUP_CONTROL, EABPopupControlClass)) -#define EAB_IS_POPUP_CONTROL(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EAB_TYPE_POPUP_CONTROL)) -#define EAB_IS_POPUP_CONTROL_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EAB_TYPE_POPUP_CONTROL)) - -typedef struct _EABPopupControl EABPopupControl; -typedef struct _EABPopupControlClass EABPopupControlClass; - -struct _EABPopupControl { - GtkEventBox parent; - - gchar *name; - gchar *email; - - GtkWidget *name_widget; - GtkWidget *email_widget; - GtkWidget *query_msg; - - GtkWidget *main_vbox; - GtkWidget *generic_view; - GtkWidget *contact_display; - - gboolean transitory; - - guint scheduled_refresh; - EBook *book; - guint query_tag; - gboolean multiple_matches; - EContact *contact; - - BonoboEventSource *es; -}; - -struct _EABPopupControlClass { - GtkEventBoxClass parent_class; -}; - -GType eab_popup_control_get_type (void); - -void eab_popup_control_construct (EABPopupControl *); - -BonoboControl *eab_popup_control_new (void); - -G_END_DECLS - -#endif /* __EAB_POPUP_CONTROL_H__ */ - diff --git a/addressbook/gui/widgets/eab-popup.c b/addressbook/gui/widgets/eab-popup.c deleted file mode 100644 index 9bda77d162..0000000000 --- a/addressbook/gui/widgets/eab-popup.c +++ /dev/null @@ -1,311 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Authors: Michael Zucchi <notzed@ximian.com> - * - * Copyright 2004 Novell, Inc. (www.novell.com) - * - * 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; version 2 of the License. - * - * 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 Street #330, Boston, MA 02111-1307, USA. - * - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <string.h> -#include <stdlib.h> - -#include <glib.h> - -#include "eab-popup.h" -#include <libedataserverui/e-source-selector.h> -#include <libebook/e-contact.h> - -static GObjectClass *eabp_parent; - -static void -eabp_init(GObject *o) -{ - /*EABPopup *eabp = (EABPopup *)o; */ -} - -static void -eabp_finalise(GObject *o) -{ - ((GObjectClass *)eabp_parent)->finalize(o); -} - -static void -eabp_target_free(EPopup *ep, EPopupTarget *t) -{ - switch (t->type) { - case EAB_POPUP_TARGET_SELECT: { - EABPopupTargetSelect *s = (EABPopupTargetSelect *)t; - int i; - - for (i=0;i<s->cards->len;i++) - g_object_unref(s->cards->pdata[i]); - g_ptr_array_free(s->cards, TRUE); - g_object_unref(s->book); - - break; } - case EAB_POPUP_TARGET_SOURCE: { - EABPopupTargetSource *s = (EABPopupTargetSource *)t; - - g_object_unref(s->selector); - break; } - case EAB_POPUP_TARGET_SELECT_NAMES: { - EABPopupTargetSelectNames *s = (EABPopupTargetSelectNames *)t; - - g_object_unref(s->model); - break; } - } - - ((EPopupClass *)eabp_parent)->target_free(ep, t); -} - -static void -eabp_class_init(GObjectClass *klass) -{ - klass->finalize = eabp_finalise; - ((EPopupClass *)klass)->target_free = eabp_target_free; -} - -GType -eab_popup_get_type(void) -{ - static GType type = 0; - - if (type == 0) { - static const GTypeInfo info = { - sizeof(EABPopupClass), - NULL, NULL, - (GClassInitFunc)eabp_class_init, - NULL, NULL, - sizeof(EABPopup), 0, - (GInstanceInitFunc)eabp_init - }; - eabp_parent = g_type_class_ref(e_popup_get_type()); - type = g_type_register_static(e_popup_get_type(), "EABPopup", &info, 0); - } - - return type; -} - -EABPopup *eab_popup_new(const char *menuid) -{ - EABPopup *eabp = g_object_new(eab_popup_get_type(), 0); - - e_popup_construct(&eabp->popup, menuid); - - return eabp; -} - -/** - * eab_popup_target_new_select: - * @eabp: Address book popup. - * @book: Book the cards belong to. - * @readonly: Book is read-only mode. FIXME: Why can't we just get this off the book? - * @cards: Cards selected. This will be freed on completion. - * - * Create a new selection popup target. - * - * Return value: - **/ -EABPopupTargetSelect * -eab_popup_target_new_select(EABPopup *eabp, struct _EBook *book, int readonly, GPtrArray *cards) -{ - EABPopupTargetSelect *t = e_popup_target_new(&eabp->popup, EAB_POPUP_TARGET_SELECT, sizeof(*t)); - guint32 mask = ~0; - int has_email = FALSE, i; - - /* FIXME: duplicated in eab-menu.c */ - - t->book = book; - g_object_ref(book); - t->cards = cards; - - for (i=0;i<cards->len && !has_email;i++) { - EContact *contact = cards->pdata[i]; - GList *email; - - email = e_contact_get(E_CONTACT(contact), E_CONTACT_EMAIL); - if (email) { - has_email = TRUE; - - g_list_foreach(email, (GFunc)g_free, NULL); - g_list_free(email); - } - } - - if (has_email) - mask &= ~EAB_POPUP_SELECT_EMAIL; - - if (!readonly) - mask &= ~EAB_POPUP_SELECT_EDITABLE; - - if (cards->len == 1) - mask &= ~EAB_POPUP_SELECT_ONE; - - if (cards->len > 1) - mask &= ~EAB_POPUP_SELECT_MANY; - - if (cards->len >= 1) - mask &= ~EAB_POPUP_SELECT_ANY; - - t->target.mask = mask; - - return t; -} - -EABPopupTargetSource * -eab_popup_target_new_source(EABPopup *eabp, ESourceSelector *selector) -{ - EABPopupTargetSource *t = e_popup_target_new(&eabp->popup, EAB_POPUP_TARGET_SOURCE, sizeof(*t)); - guint32 mask = ~0; - const char *source_uri; - ESource *source; - - /* TODO: this is duplicated for calendar and tasks too */ - - t->selector = selector; - g_object_ref(selector); - - /* TODO: perhaps we need to copy this so it doesn't change during the lifecycle */ - source = e_source_selector_peek_primary_selection(selector); - if (source) - mask &= ~EAB_POPUP_SOURCE_PRIMARY; - - /* FIXME Gross hack, should have a property or something */ - source_uri = e_source_peek_relative_uri(source); - if (source_uri && !strcmp("system", source_uri)) - mask &= ~EAB_POPUP_SOURCE_SYSTEM; - else - mask &= ~EAB_POPUP_SOURCE_USER; - - t->target.mask = mask; - - return t; -} - -EABPopupTargetSelectNames * -eab_popup_target_new_select_names(EABPopup *eabp, struct _ESelectNamesModel *model, int row) -{ - EABPopupTargetSelectNames *t = e_popup_target_new(&eabp->popup, EAB_POPUP_TARGET_SELECT_NAMES, sizeof(*t)); - - /* TODO: this is sort of not very useful, maybe the popup which uses it doesn't - need to be pluggable */ - - t->model = model; - g_object_ref(model); - t->row = row; - - return t; -} - -/* ********************************************************************** */ -/* Popup menu plugin handler */ - -/* -<e-plugin - class="org.gnome.mail.plugin.popup:1.0" - id="org.gnome.mail.plugin.popup.iteab:1.0" - type="shlib" - location="/opt/gnome2/lib/camel/1.0/libcamelimap.so" - name="imap" - description="IMAP4 and IMAP4v1 mail store"> - <hook class="org.gnome.mail.popupMenu:1.0" - handler="HandlePopup"> - <menu id="any" target="select"> - <iteab - type="iteab|toggle|radio|image|submenu|bar" - active - path="foo/bar" - label="label" - icon="foo" - mask="select_one" - activate="eabp_view_eabacs"/> - </menu> - </extension> - -*/ - -static void *eabph_parent_class; -#define eabph ((EABPopupHook *)eph) - -static const EPopupHookTargetMask eabph_select_masks[] = { - { "one", EAB_POPUP_SELECT_ONE }, - { "many", EAB_POPUP_SELECT_MANY }, - { "any", EAB_POPUP_SELECT_ANY }, - { "editable", EAB_POPUP_SELECT_EDITABLE }, - { "email", EAB_POPUP_SELECT_EMAIL }, - { 0 } -}; - -static const EPopupHookTargetMask eabph_source_masks[] = { - { "primary", EAB_POPUP_SOURCE_PRIMARY }, - { "system", EAB_POPUP_SOURCE_SYSTEM }, - { 0 } -}; - -static const EPopupHookTargetMask eabph_select_names_masks[] = { - { 0 } -}; - -static const EPopupHookTargetMap eabph_targets[] = { - { "select", EAB_POPUP_TARGET_SELECT, eabph_select_masks }, - { "source", EAB_POPUP_TARGET_SOURCE, eabph_source_masks }, - { "select-names", EAB_POPUP_TARGET_SELECT_NAMES, eabph_select_names_masks }, - { 0 } -}; - -static void -eabph_finalise(GObject *o) -{ - /*EPluginHook *eph = (EPluginHook *)o;*/ - - ((GObjectClass *)eabph_parent_class)->finalize(o); -} - -static void -eabph_class_init(EPluginHookClass *klass) -{ - int i; - - ((GObjectClass *)klass)->finalize = eabph_finalise; - ((EPluginHookClass *)klass)->id = "org.gnome.evolution.addressbook.popup:1.0"; - - for (i=0;eabph_targets[i].type;i++) - e_popup_hook_class_add_target_map((EPopupHookClass *)klass, &eabph_targets[i]); - - ((EPopupHookClass *)klass)->popup_class = g_type_class_ref(eab_popup_get_type()); -} - -GType -eab_popup_hook_get_type(void) -{ - static GType type = 0; - - if (!type) { - static const GTypeInfo info = { - sizeof(EABPopupHookClass), NULL, NULL, (GClassInitFunc) eabph_class_init, NULL, NULL, - sizeof(EABPopupHook), 0, (GInstanceInitFunc) NULL, - }; - - eabph_parent_class = g_type_class_ref(e_popup_hook_get_type()); - type = g_type_register_static(e_popup_hook_get_type(), "EABPopupHook", &info, 0); - } - - return type; -} diff --git a/addressbook/gui/widgets/eab-popup.h b/addressbook/gui/widgets/eab-popup.h deleted file mode 100644 index 7fec4cc742..0000000000 --- a/addressbook/gui/widgets/eab-popup.h +++ /dev/null @@ -1,173 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Authors: Michael Zucchi <notzed@ximian.com> - * - * Copyright 2004 Novell, Inc. (www.novell.com) - * - * 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; version 2 of the License. - * - * 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 Street #330, Boston, MA 02111-1307, USA. - * - */ - -#ifndef __EAB_POPUP_H__ -#define __EAB_POPUP_H__ - -#include <glib-object.h> - -#include "e-util/e-popup.h" - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - -typedef struct _EABPopup EABPopup; -typedef struct _EABPopupClass EABPopupClass; - -/** - * enum _eab_popup_target_t - A list of mail popup target types. - * - * @EAB_POPUP_TARGET_SELECT: A selection of cards - * @EAB_POPUP_TARGET_SOURCE: A source selection. - * - * Defines the value of the targetid for all EABPopup target types. - **/ -enum _eab_popup_target_t { - EAB_POPUP_TARGET_SELECT, - EAB_POPUP_TARGET_SOURCE, - EAB_POPUP_TARGET_SELECT_NAMES, -}; - -/** - * enum _eab_popup_target_select_t - EABPopupTargetSelect qualifiers. - * - * @EAB_POPUP_SELECT_ONE: Only one item is selected. - * @EAB_POPUP_SELECT_MANY: Two or more items are selected. - * @EAB_POPUP_SELECT_ANY: One or more items are selected. - * @EAB_POPUP_SELECT_EDITABLE: Read/writable source. - * @EAB_POPUP_SELECT_EMAIL: Has an email address. - **/ -enum _eab_popup_target_select_t { - EAB_POPUP_SELECT_ONE = 1<<0, - EAB_POPUP_SELECT_MANY = 1<<1, - EAB_POPUP_SELECT_ANY = 1<<2, - EAB_POPUP_SELECT_EDITABLE = 1<<3, - EAB_POPUP_SELECT_EMAIL = 1<<4, -}; - -/** - * enum _eab_popup_target_source_t - EABPopupTargetSource qualifiers. - * - * @EAB_POPUP_SOURCE_PRIMARY: Has a primary selection. - * @EAB_POPUP_SOURCE_SYSTEM: Is a 'system' folder. - * - **/ -enum _eab_popup_target_source_t { - EAB_POPUP_SOURCE_PRIMARY = 1<<0, - EAB_POPUP_SOURCE_SYSTEM = 1<<1, /* system folder */ - EAB_POPUP_SOURCE_USER = 1<<2, /* user folder (!system) */ -}; - -typedef struct _EABPopupTargetSelect EABPopupTargetSelect; -typedef struct _EABPopupTargetSource EABPopupTargetSource; -typedef struct _EABPopupTargetSelectNames EABPopupTargetSelectNames; - -/** - * struct _EABPopupTargetSelect - A list of address cards. - * - * @target: Superclass. - * @book: Book the cards belong to. - * @cards: All selected cards. - * - * Used to represent a selection of cards as context for a popup - * menu. - **/ -struct _EABPopupTargetSelect { - EPopupTarget target; - - struct _EBook *book; - GPtrArray *cards; -}; - -/** - * struct _EABPopupTargetSource - A source target. - * - * @target: Superclass. - * @selector: Selector holding the source selection. - * - * This target is used to represent a source selection. - **/ -struct _EABPopupTargetSource { - EPopupTarget target; - - struct _ESourceSelector *selector; -}; - -/** - * struct _EABPopupTargetSelectNames - A select names target. - * - * @target: Superclass. - * @model: Select names model. - * @row: Row of item selected. - * - * This target is used to represent an item selected in an - * ESelectNames model. - **/ -struct _EABPopupTargetSelectNames { - EPopupTarget target; - - struct _ESelectNamesModel *model; - int row; -}; - -typedef struct _EPopupItem EABPopupItem; - -/* The object */ -struct _EABPopup { - EPopup popup; - - struct _EABPopupPrivate *priv; -}; - -struct _EABPopupClass { - EPopupClass popup_class; -}; - -GType eab_popup_get_type(void); - -EABPopup *eab_popup_new(const char *menuid); - -EABPopupTargetSelect *eab_popup_target_new_select(EABPopup *eabp, struct _EBook *book, int readonly, GPtrArray *cards); -EABPopupTargetSource *eab_popup_target_new_source(EABPopup *eabp, struct _ESourceSelector *selector); -EABPopupTargetSelectNames *eab_popup_target_new_select_names(EABPopup *eabp, struct _ESelectNamesModel *model, int row); - -/* ********************************************************************** */ - -typedef struct _EABPopupHook EABPopupHook; -typedef struct _EABPopupHookClass EABPopupHookClass; - -struct _EABPopupHook { - EPopupHook hook; -}; - -struct _EABPopupHookClass { - EPopupHookClass hook_class; -}; - -GType eab_popup_hook_get_type(void); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* __EAB_POPUP_H__ */ diff --git a/addressbook/gui/widgets/eab-vcard-control.c b/addressbook/gui/widgets/eab-vcard-control.c deleted file mode 100644 index 3e2cdddcc9..0000000000 --- a/addressbook/gui/widgets/eab-vcard-control.c +++ /dev/null @@ -1,311 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * eab-vcard-control.c - * - * Copyright (C) 1999, 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. - * - * Authors: - * Chris Lahey <clahey@ximian.com> - * Chris Toshok <toshok@ximian.com> - */ - -#include <config.h> -#include <string.h> - -#include <gtk/gtk.h> -#include <bonobo/bonobo-generic-factory.h> -#include <bonobo/bonobo-persist.h> -#include <bonobo/bonobo-persist-stream.h> -#include <bonobo/bonobo-stream-client.h> -#include <gal/util/e-util.h> - -#include <libebook/e-book.h> -#include <libebook/e-contact.h> -#include <addressbook/gui/component/addressbook.h> -#include <addressbook/gui/widgets/eab-contact-display.h> -#include <addressbook/util/eab-book-util.h> - -#include "eab-vcard-control.h" -#include "eab-contact-merging.h" - -typedef struct { - EABContactDisplay *display; - GList *card_list; - GtkWidget *label; - EABContactDisplayRenderMode render_mode; -} EABVCardControl; - -#define VCARD_CONTROL_ID "OAFIID:GNOME_Evolution_Addressbook_VCard_Control:" BASE_VERSION - -/* - * Bonobo::PersistStream - * - * These two functions implement the Bonobo::PersistStream load and - * save methods which allow data to be loaded into and out of the - * BonoboObject. - */ -static char * -stream_read (Bonobo_Stream stream) -{ - Bonobo_Stream_iobuf *buffer; - CORBA_Environment ev; - char *data = NULL; - gint length = 0; - - CORBA_exception_init (&ev); - do { -#define READ_CHUNK_SIZE 65536 - Bonobo_Stream_read (stream, READ_CHUNK_SIZE, - &buffer, &ev); - - if (ev._major != CORBA_NO_EXCEPTION) { - CORBA_exception_free (&ev); - return NULL; - } - - if (buffer->_length <= 0) - break; - - data = g_realloc (data, length + buffer->_length + 1); - - memcpy (data + length, buffer->_buffer, buffer->_length); - - length += buffer->_length; - - CORBA_free (buffer); - } while (1); - - CORBA_free (buffer); - CORBA_exception_free (&ev); - - if (data) - data[length] = '\0'; - else - data = g_strdup(""); - - return data; -} /* stream_read */ - -/* - * This function implements the Bonobo::PersistStream:load method. - */ -static void -pstream_load (BonoboPersistStream *ps, const Bonobo_Stream stream, - Bonobo_Persist_ContentType type, void *data, - CORBA_Environment *ev) -{ - GList *list; - char *vcard; - EABVCardControl *vcard_control = data; - - if (type && g_ascii_strcasecmp (type, "text/vCard") != 0 && - g_ascii_strcasecmp (type, "text/x-vCard") != 0) { - CORBA_exception_set (ev, CORBA_USER_EXCEPTION, - ex_Bonobo_Persist_WrongDataType, NULL); - return; - } - - if ((vcard = stream_read (stream)) == NULL) { - CORBA_exception_set (ev, CORBA_USER_EXCEPTION, - ex_Bonobo_Persist_FileNotFound, NULL); - return; - } - - e_free_object_list (vcard_control->card_list); - list = eab_contact_list_from_string (vcard); - g_free(vcard); - vcard_control->card_list = list; - if (list) { - eab_contact_display_render (vcard_control->display, E_CONTACT (list->data), - vcard_control->render_mode); - } - if (list && list->next) { - char *message; - int length = g_list_length (list) - 1; - message = g_strdup_printf (ngettext("and one other contact.", - "and %d other contacts.", length), - length); - gtk_label_set_text (GTK_LABEL (vcard_control->label), message); - g_free (message); - gtk_widget_show (vcard_control->label); - } else { - gtk_widget_hide (vcard_control->label); - } -} /* pstream_load */ - -/* - * This function implements the Bonobo::PersistStream:save method. - */ -static void -pstream_save (BonoboPersistStream *ps, const Bonobo_Stream stream, - Bonobo_Persist_ContentType type, void *data, - CORBA_Environment *ev) -{ - EABVCardControl *vcard_control = data; - char *vcard; - int length; - - if (type && g_ascii_strcasecmp (type, "text/vCard") != 0 && - g_ascii_strcasecmp (type, "text/x-vCard") != 0) { - CORBA_exception_set (ev, CORBA_USER_EXCEPTION, - ex_Bonobo_Persist_WrongDataType, NULL); - return; - } - - vcard = eab_contact_list_to_string (vcard_control->card_list); - length = strlen (vcard); - bonobo_stream_client_write (stream, vcard, length, ev); - g_free (vcard); -} /* pstream_save */ - -static Bonobo_Persist_ContentTypeList * -pstream_get_content_types (BonoboPersistStream *ps, void *closure, - CORBA_Environment *ev) -{ - return bonobo_persist_generate_content_types (2, "text/vCard", "text/x-vCard"); -} - -static void -book_open_cb (EBook *book, EBookStatus status, gpointer closure) -{ - GList *list = closure; - if (status == E_BOOK_ERROR_OK) { - GList *p; - for (p = list; p; p = p->next) { - /* XXX argh, more passing of NULL's for callbacks */ - eab_merging_book_add_contact (book, E_CONTACT (p->data), NULL, NULL); - } - } - if (book) - g_object_unref (book); - e_free_object_list (list); -} - -static void -save_in_addressbook(GtkWidget *button, gpointer data) -{ - EABVCardControl *vcard_control = data; - GList *list, *p; - - list = g_list_copy (vcard_control->card_list); - - for (p = list; p; p = p->next) - g_object_ref (p->data); - - addressbook_load_default_book (book_open_cb, list); -} - -static void -toggle_full_vcard(GtkWidget *button, gpointer data) -{ - EABVCardControl *vcard_control = data; - char *label; - - if (!vcard_control->card_list) - return; - - if (vcard_control->render_mode == EAB_CONTACT_DISPLAY_RENDER_NORMAL) { - vcard_control->render_mode = EAB_CONTACT_DISPLAY_RENDER_COMPACT; - label = _("Show Full VCard"); - } - else { - vcard_control->render_mode = EAB_CONTACT_DISPLAY_RENDER_NORMAL; - label = _("Show Compact VCard"); - } - - gtk_button_set_label (GTK_BUTTON (button), label); - eab_contact_display_render (vcard_control->display, E_CONTACT (vcard_control->card_list->data), - vcard_control->render_mode); -} - -static void -free_struct (gpointer data, GObject *where_object_was) -{ - EABVCardControl *vcard_control = data; - e_free_object_list (vcard_control->card_list); - g_free (vcard_control); -} - -BonoboControl * -eab_vcard_control_new (void) -{ - BonoboControl *control; - BonoboPersistStream *stream; - GtkWidget *display; - GtkWidget *button1, *button2; - GtkWidget *bbox; - GtkWidget *vbox; - - EABVCardControl *vcard_control = g_new (EABVCardControl, 1); - - printf ("inside eab_vcard_control_new\n"); - - vcard_control->card_list = NULL; - vcard_control->display = NULL; - vcard_control->label = NULL; - - vcard_control->render_mode = EAB_CONTACT_DISPLAY_RENDER_COMPACT; - - /* Create the control. */ - - display = eab_contact_display_new (); - vcard_control->display = EAB_CONTACT_DISPLAY (display); - - bbox = gtk_hbutton_box_new (); - gtk_button_box_set_layout (GTK_BUTTON_BOX (bbox), GTK_BUTTONBOX_START); - gtk_box_set_spacing (GTK_BOX (bbox), 12); - - button1 = gtk_button_new_with_label(_("Show Full VCard")); - g_signal_connect (button1, "clicked", - G_CALLBACK (toggle_full_vcard), vcard_control); - gtk_box_pack_start (GTK_BOX (bbox), button1, FALSE, FALSE, 0); - - button2 = gtk_button_new_with_label(_("Save in addressbook")); - g_signal_connect (button2, "clicked", - G_CALLBACK (save_in_addressbook), vcard_control); - gtk_box_pack_start (GTK_BOX (bbox), button2, FALSE, FALSE, 0); - - /* This is intentionally not shown. */ - vcard_control->label = gtk_label_new (""); - - vbox = gtk_vbox_new (FALSE, 0); - gtk_box_pack_start (GTK_BOX (vbox), bbox, FALSE, FALSE, 0); - gtk_box_pack_start (GTK_BOX (vbox), display, TRUE, TRUE, 0); - gtk_box_pack_start (GTK_BOX (vbox), vcard_control->label, TRUE, TRUE, 0); - gtk_widget_show_all (bbox); - gtk_widget_show (display); - gtk_widget_show (vbox); - - control = bonobo_control_new (vbox); - - g_object_weak_ref (G_OBJECT (control), free_struct, vcard_control); - - stream = bonobo_persist_stream_new (pstream_load, pstream_save, - pstream_get_content_types, - VCARD_CONTROL_ID, - vcard_control); - - if (stream == NULL) { - bonobo_object_unref (BONOBO_OBJECT (control)); - return NULL; - } - - bonobo_object_add_interface (BONOBO_OBJECT (control), - BONOBO_OBJECT (stream)); - - return control; -} diff --git a/addressbook/gui/widgets/eab-vcard-control.h b/addressbook/gui/widgets/eab-vcard-control.h deleted file mode 100644 index 5f6643c1ca..0000000000 --- a/addressbook/gui/widgets/eab-vcard-control.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef __EAB_VCARD_CONTROL_H__ -#define __EAB_VCARD_CONTROL_H__ - -#include <bonobo/bonobo-control.h> - -BonoboControl *eab_vcard_control_new (void); - -#endif /* __EAB_VCARD_CONTROL_H__ */ diff --git a/addressbook/gui/widgets/gal-view-factory-minicard.c b/addressbook/gui/widgets/gal-view-factory-minicard.c deleted file mode 100644 index 212ac79b53..0000000000 --- a/addressbook/gui/widgets/gal-view-factory-minicard.c +++ /dev/null @@ -1,85 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * gal-view-factory-minicard.c: A View Factory - * - * Authors: - * Chris Lahey <clahey@ximian.com> - * - * (C) 2000, 2001 Ximian, Inc. - */ -#include <config.h> -#include <glib.h> -#include <libgnome/gnome-i18n.h> -#include "gal-view-factory-minicard.h" -#include "gal-view-minicard.h" -#include "gal/util/e-util.h" - -#define PARENT_TYPE GAL_VIEW_FACTORY_TYPE - -static GalViewFactoryClass *gal_view_factory_minicard_parent_class; - -static const char * -gal_view_factory_minicard_get_title (GalViewFactory *factory) -{ - return _("Card View"); -} - -static GalView * -gal_view_factory_minicard_new_view (GalViewFactory *factory, - const char *name) -{ - return gal_view_minicard_new(name); -} - -static const char * -gal_view_factory_minicard_get_type_code (GalViewFactory *factory) -{ - return "minicard"; -} - -static void -gal_view_factory_minicard_class_init (GObjectClass *object_class) -{ - GalViewFactoryClass *view_factory_class = GAL_VIEW_FACTORY_CLASS(object_class); - gal_view_factory_minicard_parent_class = g_type_class_ref (PARENT_TYPE); - - view_factory_class->get_title = gal_view_factory_minicard_get_title; - view_factory_class->new_view = gal_view_factory_minicard_new_view; - view_factory_class->get_type_code = gal_view_factory_minicard_get_type_code; -} - -static void -gal_view_factory_minicard_init (GalViewFactoryMinicard *factory) -{ -} - -/** - * gal_view_minicard_new - * - * A new GalViewFactory for creating Minicard views. Create one of - * these and pass it to GalViewCollection for use. - * - * Returns: The new GalViewFactoryMinicard. - */ -GalViewFactory * -gal_view_factory_minicard_new (void) -{ - return gal_view_factory_minicard_construct (g_object_new (GAL_TYPE_VIEW_FACTORY_MINICARD, NULL)); -} - -/** - * gal_view_minicard_construct - * @factory: The factory to construct - * - * constructs the GalViewFactoryMinicard. To be used by subclasses and - * language bindings. - * - * Returns: The GalViewFactoryMinicard. - */ -GalViewFactory * -gal_view_factory_minicard_construct (GalViewFactoryMinicard *factory) -{ - return GAL_VIEW_FACTORY(factory); -} - -E_MAKE_TYPE(gal_view_factory_minicard, "GalViewFactoryMinicard", GalViewFactoryMinicard, gal_view_factory_minicard_class_init, gal_view_factory_minicard_init, PARENT_TYPE) diff --git a/addressbook/gui/widgets/gal-view-factory-minicard.h b/addressbook/gui/widgets/gal-view-factory-minicard.h deleted file mode 100644 index 02eea99e47..0000000000 --- a/addressbook/gui/widgets/gal-view-factory-minicard.h +++ /dev/null @@ -1,35 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * gal-view-factory-minicard.c: A View Factory - * - * Authors: - * Chris Lahey <clahey@ximian.com> - * - * (C) 2000, 2001 Ximian, Inc. - */ -#ifndef _GAL_VIEW_FACTORY_MINICARD_H_ -#define _GAL_VIEW_FACTORY_MINICARD_H_ - -#include <gtk/gtkobject.h> -#include <gal/menus/gal-view-factory.h> - -#define GAL_TYPE_VIEW_FACTORY_MINICARD (gal_view_factory_minicard_get_type ()) -#define GAL_VIEW_FACTORY_MINICARD(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GAL_TYPE_VIEW_FACTORY_MINICARD, GalViewFactoryMinicard)) -#define GAL_VIEW_FACTORY_MINICARD_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GAL_TYPE_VIEW_FACTORY_MINICARD, GalViewFactoryMinicardClass)) -#define GAL_IS_VIEW_FACTORY_MINICARD(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GAL_TYPE_VIEW_FACTORY_MINICARD)) -#define GAL_IS_VIEW_FACTORY_MINICARD_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GAL_TYPE_VIEW_FACTORY_MINICARD)) - -typedef struct { - GalViewFactory base; -} GalViewFactoryMinicard; - -typedef struct { - GalViewFactoryClass parent_class; -} GalViewFactoryMinicardClass; - -/* Standard functions */ -GType gal_view_factory_minicard_get_type (void); -GalViewFactory *gal_view_factory_minicard_new (void); -GalViewFactory *gal_view_factory_minicard_construct (GalViewFactoryMinicard *factory); - -#endif /* _GAL_VIEW_FACTORY_MINICARD_H_ */ diff --git a/addressbook/gui/widgets/gal-view-factory-treeview.c b/addressbook/gui/widgets/gal-view-factory-treeview.c deleted file mode 100644 index b14c8dec59..0000000000 --- a/addressbook/gui/widgets/gal-view-factory-treeview.c +++ /dev/null @@ -1,86 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 - -*- */ -/* - * gal-view-factory-treeview.c: A View Factory - * - * Authors: - * Chris Lahey <clahey@ximian.com> - * - * (C) 2000, 2001 Ximian, Inc. - */ -#include <config.h> -#include <glib.h> -#include <libgnome/gnome-i18n.h> -#include <gal/util/e-util.h> -#include "gal-view-factory-treeview.h" -#include "gal-view-treeview.h" - -#define PARENT_TYPE GAL_VIEW_FACTORY_TYPE - -static GalViewFactoryClass *gal_view_factory_treeview_parent_class; - -static const char * -gal_view_factory_treeview_get_title (GalViewFactory *factory) -{ - return _("GTK Tree View"); -} - -static GalView * -gal_view_factory_treeview_new_view (GalViewFactory *factory, - const char *name) -{ - return gal_view_treeview_new(name); -} - -static const char * -gal_view_factory_treeview_get_type_code (GalViewFactory *factory) -{ - return "treeview"; -} - -static void -gal_view_factory_treeview_class_init (GObjectClass *object_class) -{ - GalViewFactoryClass *view_factory_class = GAL_VIEW_FACTORY_CLASS(object_class); - gal_view_factory_treeview_parent_class = g_type_class_ref (PARENT_TYPE); - - view_factory_class->get_title = gal_view_factory_treeview_get_title; - view_factory_class->new_view = gal_view_factory_treeview_new_view; - view_factory_class->get_type_code = gal_view_factory_treeview_get_type_code; -} - -static void -gal_view_factory_treeview_init (GalViewFactoryTreeView *factory) -{ -} - -/** - * gal_view_treeview_new - * - * A new GalViewFactory for creating TreeView views. Create one of - * these and pass it to GalViewCollection for use. - * - * Returns: The new GalViewFactoryTreeView. - */ -GalViewFactory * -gal_view_factory_treeview_new (void) -{ - return gal_view_factory_treeview_construct (g_object_new (GAL_TYPE_VIEW_FACTORY_TREEVIEW, NULL)); -} - -/** - * gal_view_treeview_construct - * @factory: The factory to construct - * - * constructs the GalViewFactoryTreeView. To be used by subclasses and - * language bindings. - * - * Returns: The GalViewFactoryTreeView. - */ -GalViewFactory * -gal_view_factory_treeview_construct (GalViewFactoryTreeView *factory) -{ - return GAL_VIEW_FACTORY(factory); -} - -E_MAKE_TYPE(gal_view_factory_treeview, "GalViewFactoryTreeView", GalViewFactoryTreeView, gal_view_factory_treeview_class_init, gal_view_factory_treeview_init, PARENT_TYPE) diff --git a/addressbook/gui/widgets/gal-view-factory-treeview.h b/addressbook/gui/widgets/gal-view-factory-treeview.h deleted file mode 100644 index 4795c6d3aa..0000000000 --- a/addressbook/gui/widgets/gal-view-factory-treeview.h +++ /dev/null @@ -1,35 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * gal-view-factory-treeview.c: A View Factory - * - * Authors: - * Chris Toshok <toshok@ximian.com> - * - * (C) 2000, 2001 Ximian, Inc. - */ -#ifndef _GAL_VIEW_FACTORY_TREEVIEW_H_ -#define _GAL_VIEW_FACTORY_TREEVIEW_H_ - -#include <gtk/gtkobject.h> -#include <gal/menus/gal-view-factory.h> - -#define GAL_TYPE_VIEW_FACTORY_TREEVIEW (gal_view_factory_treeview_get_type ()) -#define GAL_VIEW_FACTORY_TREEVIEW(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GAL_TYPE_VIEW_FACTORY_TREEVIEW, GalViewFactoryTreeView)) -#define GAL_VIEW_FACTORY_TREEVIEW_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GAL_TYPE_VIEW_FACTORY_TREEVIEW, GalViewFactoryTreeViewClass)) -#define GAL_IS_VIEW_FACTORY_TREEVIEW(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GAL_TYPE_VIEW_FACTORY_TREEVIEW)) -#define GAL_IS_VIEW_FACTORY_TREEVIEW_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GAL_TYPE_VIEW_FACTORY_TREEVIEW)) - -typedef struct { - GalViewFactory base; -} GalViewFactoryTreeView; - -typedef struct { - GalViewFactoryClass parent_class; -} GalViewFactoryTreeViewClass; - -/* Standard functions */ -GType gal_view_factory_treeview_get_type (void); -GalViewFactory *gal_view_factory_treeview_new (void); -GalViewFactory *gal_view_factory_treeview_construct (GalViewFactoryTreeView *factory); - -#endif /* _GAL_VIEW_FACTORY_TREEVIEW_H_ */ diff --git a/addressbook/gui/widgets/gal-view-minicard.c b/addressbook/gui/widgets/gal-view-minicard.c deleted file mode 100644 index da60497cdb..0000000000 --- a/addressbook/gui/widgets/gal-view-minicard.c +++ /dev/null @@ -1,227 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * gal-view-minicard.c: An Minicard View - * - * Authors: - * Chris Lahey <clahey@ximian.com> - * - * (C) 2000, 2001 Ximian, Inc. - */ -#include <config.h> -#include "gal-view-minicard.h" -#include <libxml/parser.h> -#include <gal/util/e-xml-utils.h> - -#define PARENT_TYPE gal_view_get_type () -#define d(x) x - -static GalViewClass *gal_view_minicard_parent_class; - -static void -gal_view_minicard_edit (GalView *view, GtkWindow *parent_window) -{ - /* GalViewMinicard *minicard_view = GAL_VIEW_MINICARD(view); */ -} - -static void -gal_view_minicard_load (GalView *view, - const char *filename) -{ - xmlDoc *doc; - doc = xmlParseFile (filename); - if (doc) { - xmlNode *root = xmlDocGetRootElement(doc); - GAL_VIEW_MINICARD (view)->column_width = e_xml_get_double_prop_by_name_with_default (root, "column_width", 150); - xmlFreeDoc(doc); - } -} - -static void -gal_view_minicard_save (GalView *view, - const char *filename) -{ - xmlDoc *doc; - xmlNode *root; - - doc = xmlNewDoc("1.0"); - root = xmlNewNode (NULL, "EMinicardViewState"); - e_xml_set_double_prop_by_name (root, "column_width", GAL_VIEW_MINICARD (view)->column_width); - xmlDocSetRootElement(doc, root); - xmlSaveFile(filename, doc); - xmlFreeDoc(doc); -} - -static const char * -gal_view_minicard_get_title (GalView *view) -{ - return GAL_VIEW_MINICARD(view)->title; -} - -static void -gal_view_minicard_set_title (GalView *view, - const char *title) -{ - g_free(GAL_VIEW_MINICARD(view)->title); - GAL_VIEW_MINICARD(view)->title = g_strdup(title); -} - -static const char * -gal_view_minicard_get_type_code (GalView *view) -{ - return "minicard"; -} - -static GalView * -gal_view_minicard_clone (GalView *view) -{ - GalViewMinicard *gvm, *new; - - gvm = GAL_VIEW_MINICARD(view); - - new = g_object_new (GAL_TYPE_VIEW_MINICARD, NULL); - new->title = g_strdup (gvm->title); - new->column_width = gvm->column_width; - - return GAL_VIEW(new); -} - -static void -gal_view_minicard_dispose (GObject *object) -{ - GalViewMinicard *view = GAL_VIEW_MINICARD(object); - - if (view->title != NULL) { - gal_view_minicard_detach (view); - g_free(view->title); - view->title = NULL; - } - - if (G_OBJECT_CLASS (gal_view_minicard_parent_class)->dispose) - (* G_OBJECT_CLASS (gal_view_minicard_parent_class)->dispose) (object); -} - -static void -gal_view_minicard_class_init (GObjectClass *object_class) -{ - GalViewClass *gal_view_class = GAL_VIEW_CLASS(object_class); - gal_view_minicard_parent_class = g_type_class_ref (PARENT_TYPE); - - gal_view_class->edit = gal_view_minicard_edit ; - gal_view_class->load = gal_view_minicard_load ; - gal_view_class->save = gal_view_minicard_save ; - gal_view_class->get_title = gal_view_minicard_get_title ; - gal_view_class->set_title = gal_view_minicard_set_title ; - gal_view_class->get_type_code = gal_view_minicard_get_type_code; - gal_view_class->clone = gal_view_minicard_clone ; - - object_class->dispose = gal_view_minicard_dispose ; -} - -static void -gal_view_minicard_init (GalViewMinicard *gvm) -{ - gvm->title = NULL; - gvm->column_width = 150.0; - - gvm->emvw = NULL; - gvm->emvw_column_width_changed_id = 0; -} - -/** - * gal_view_minicard_new - * @title: The name of the new view. - * - * Returns a new GalViewMinicard. This is primarily for use by - * GalViewFactoryMinicard. - * - * Returns: The new GalViewMinicard. - */ -GalView * -gal_view_minicard_new (const gchar *title) -{ - return gal_view_minicard_construct (g_object_new (GAL_TYPE_VIEW_MINICARD, NULL), title); -} - -/** - * gal_view_minicard_construct - * @view: The view to construct. - * @title: The name of the new view. - * - * constructs the GalViewMinicard. To be used by subclasses and - * language bindings. - * - * Returns: The GalViewMinicard. - */ -GalView * -gal_view_minicard_construct (GalViewMinicard *view, - const gchar *title) -{ - view->title = g_strdup(title); - return GAL_VIEW(view); -} - -GType -gal_view_minicard_get_type (void) -{ - static GType type = 0; - - if (!type) { - static const GTypeInfo info = { - sizeof (GalViewMinicardClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gal_view_minicard_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GalViewMinicard), - 0, /* n_preallocs */ - (GInstanceInitFunc) gal_view_minicard_init, - }; - - type = g_type_register_static (PARENT_TYPE, "GalViewMinicard", &info, 0); - } - - return type; -} - -static void -column_width_changed (EMinicardViewWidget *w, double width, GalViewMinicard *view) -{ - d(g_print("%s: Old width = %f, New width = %f\n", G_GNUC_FUNCTION, view->column_width, width)); - if (view->column_width != width) { - view->column_width = width; - gal_view_changed(GAL_VIEW(view)); - } -} - -void -gal_view_minicard_attach (GalViewMinicard *view, EMinicardViewWidget *emvw) -{ - gal_view_minicard_detach (view); - - view->emvw = emvw; - - g_object_ref (view->emvw); - - g_object_set (view->emvw, - "column_width", view->column_width, - NULL); - - view->emvw_column_width_changed_id = - g_signal_connect(view->emvw, "column_width_changed", - G_CALLBACK (column_width_changed), view); -} - -void -gal_view_minicard_detach (GalViewMinicard *view) -{ - if (view->emvw == NULL) - return; - if (view->emvw_column_width_changed_id) { - g_signal_handler_disconnect (view->emvw, - view->emvw_column_width_changed_id); - view->emvw_column_width_changed_id = 0; - } - g_object_unref (view->emvw); - view->emvw = NULL; -} diff --git a/addressbook/gui/widgets/gal-view-minicard.h b/addressbook/gui/widgets/gal-view-minicard.h deleted file mode 100644 index e586012f73..0000000000 --- a/addressbook/gui/widgets/gal-view-minicard.h +++ /dev/null @@ -1,45 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * gal-view-minicard.h: An Minicard View - * - * Authors: - * Chris Lahey <clahey@ximian.com> - * - * (C) 2000, 2001 Ximian, Inc. - */ -#ifndef _GAL_VIEW_MINICARD_H_ -#define _GAL_VIEW_MINICARD_H_ - -#include <gal/menus/gal-view.h> -#include <e-minicard-view-widget.h> - -#define GAL_TYPE_VIEW_MINICARD (gal_view_minicard_get_type ()) -#define GAL_VIEW_MINICARD(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GAL_TYPE_VIEW_MINICARD, GalViewMinicard)) -#define GAL_VIEW_MINICARD_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GAL_TYPE_VIEW_MINICARD, GalViewMinicardClass)) -#define GAL_IS_VIEW_MINICARD(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GAL_TYPE_VIEW_MINICARD)) -#define GAL_IS_VIEW_MINICARD_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GAL_TYPE_VIEW_MINICARD)) - -typedef struct { - GalView base; - - char *title; - double column_width; - - EMinicardViewWidget *emvw; - guint emvw_column_width_changed_id; -} GalViewMinicard; - -typedef struct { - GalViewClass parent_class; -} GalViewMinicardClass; - -/* Standard functions */ -GType gal_view_minicard_get_type (void); -GalView *gal_view_minicard_new (const gchar *title); -GalView *gal_view_minicard_construct (GalViewMinicard *view, - const gchar *title); -void gal_view_minicard_attach (GalViewMinicard *view, - EMinicardViewWidget *emvw); -void gal_view_minicard_detach (GalViewMinicard *view); - -#endif /* _GAL_VIEW_MINICARD_H_ */ diff --git a/addressbook/gui/widgets/gal-view-treeview.c b/addressbook/gui/widgets/gal-view-treeview.c deleted file mode 100644 index e18ae6341b..0000000000 --- a/addressbook/gui/widgets/gal-view-treeview.c +++ /dev/null @@ -1,234 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * gal-view-treeview.c: An TreeView View - * - * Authors: - * Chris Lahey <clahey@ximian.com> - * - * (C) 2000, 2001 Ximian, Inc. - */ -#include <config.h> -#include "gal-view-treeview.h" -#include <libxml/parser.h> -#include <gal/util/e-xml-utils.h> - -#define PARENT_TYPE gal_view_get_type () -#define d(x) x - -static GalViewClass *gal_view_treeview_parent_class; - -static void -gal_view_treeview_edit (GalView *view, GtkWindow *parent_window) -{ - /* GalViewTreeView *treeview_view = GAL_VIEW_TREEVIEW(view); */ -} - -static void -gal_view_treeview_load (GalView *view, - const char *filename) -{ -#if 0 - xmlDoc *doc; - doc = xmlParseFile (filename); - if (doc) { - xmlNode *root = xmlDocGetRootElement(doc); - GAL_VIEW_TREEVIEW (view)->column_width = e_xml_get_double_prop_by_name_with_default (root, "column_width", 150); - xmlFreeDoc(doc); - } -#endif -} - -static void -gal_view_treeview_save (GalView *view, - const char *filename) -{ -#if 0 - xmlDoc *doc; - xmlNode *root; - - doc = xmlNewDoc("1.0"); - root = xmlNewNode (NULL, "ETreeViewViewState"); - e_xml_set_double_prop_by_name (root, "column_width", GAL_VIEW_TREEVIEW (view)->column_width); - xmlDocSetRootElement(doc, root); - xmlSaveFile(filename, doc); - xmlFreeDoc(doc); -#endif -} - -static const char * -gal_view_treeview_get_title (GalView *view) -{ - return GAL_VIEW_TREEVIEW(view)->title; -} - -static void -gal_view_treeview_set_title (GalView *view, - const char *title) -{ - g_free(GAL_VIEW_TREEVIEW(view)->title); - GAL_VIEW_TREEVIEW(view)->title = g_strdup(title); -} - -static const char * -gal_view_treeview_get_type_code (GalView *view) -{ - return "treeview"; -} - -static GalView * -gal_view_treeview_clone (GalView *view) -{ - GalViewTreeView *gvm, *new; - - gvm = GAL_VIEW_TREEVIEW(view); - - new = g_object_new (GAL_TYPE_VIEW_TREEVIEW, NULL); - new->title = g_strdup (gvm->title); - - return GAL_VIEW(new); -} - -static void -gal_view_treeview_dispose (GObject *object) -{ - GalViewTreeView *view = GAL_VIEW_TREEVIEW(object); - - if (view->title != NULL) { - gal_view_treeview_detach (view); - g_free(view->title); - view->title = NULL; - } - - if (G_OBJECT_CLASS (gal_view_treeview_parent_class)->dispose) - (* G_OBJECT_CLASS (gal_view_treeview_parent_class)->dispose) (object); -} - -static void -gal_view_treeview_class_init (GObjectClass *object_class) -{ - GalViewClass *gal_view_class = GAL_VIEW_CLASS(object_class); - gal_view_treeview_parent_class = g_type_class_ref (PARENT_TYPE); - - gal_view_class->edit = gal_view_treeview_edit ; - gal_view_class->load = gal_view_treeview_load ; - gal_view_class->save = gal_view_treeview_save ; - gal_view_class->get_title = gal_view_treeview_get_title ; - gal_view_class->set_title = gal_view_treeview_set_title ; - gal_view_class->get_type_code = gal_view_treeview_get_type_code; - gal_view_class->clone = gal_view_treeview_clone ; - - object_class->dispose = gal_view_treeview_dispose ; -} - -static void -gal_view_treeview_init (GalViewTreeView *gvm) -{ - gvm->title = NULL; - - gvm->tree = NULL; -} - -/** - * gal_view_treeview_new - * @title: The name of the new view. - * - * Returns a new GalViewTreeView. This is primarily for use by - * GalViewFactoryTreeView. - * - * Returns: The new GalViewTreeView. - */ -GalView * -gal_view_treeview_new (const gchar *title) -{ - return gal_view_treeview_construct (g_object_new (GAL_TYPE_VIEW_TREEVIEW, NULL), title); -} - -/** - * gal_view_treeview_construct - * @view: The view to construct. - * @title: The name of the new view. - * - * constructs the GalViewTreeView. To be used by subclasses and - * language bindings. - * - * Returns: The GalViewTreeView. - */ -GalView * -gal_view_treeview_construct (GalViewTreeView *view, - const gchar *title) -{ - view->title = g_strdup(title); - return GAL_VIEW(view); -} - -GType -gal_view_treeview_get_type (void) -{ - static GType type = 0; - - if (!type) { - static const GTypeInfo info = { - sizeof (GalViewTreeViewClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gal_view_treeview_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GalViewTreeView), - 0, /* n_preallocs */ - (GInstanceInitFunc) gal_view_treeview_init, - }; - - type = g_type_register_static (PARENT_TYPE, "GalViewTreeView", &info, 0); - } - - return type; -} - -#if 0 -static void -column_width_changed (ETable *table, double width, GalViewMinicard *view) -{ - d(g_print("%s: Old width = %f, New width = %f\n", G_GNUC_FUNCTION, view->column_width, width)); - if (view->column_width != width) { - view->column_width = width; - gal_view_changed(GAL_VIEW(view)); - } -} -#endif - -void -gal_view_treeview_attach (GalViewTreeView *view, GtkTreeView *tree) -{ -#if 0 - gal_view_treeview_detach (view); - - view->emvw = emvw; - - g_object_ref (view->emvw); - - g_object_set (view->emvw, - "column_width", view->column_width, - NULL); - - view->emvw_column_width_changed_id = - g_signal_connect(view->emvw, "column_width_changed", - G_CALLBACK (column_width_changed), view); -#endif -} - -void -gal_view_treeview_detach (GalViewTreeView *view) -{ -#if 0 - if (view->emvw == NULL) - return; - if (view->emvw_column_width_changed_id) { - g_signal_handler_disconnect (view->emvw, - view->emvw_column_width_changed_id); - view->emvw_column_width_changed_id = 0; - } - g_object_unref (view->emvw); - view->emvw = NULL; -#endif -} diff --git a/addressbook/gui/widgets/gal-view-treeview.h b/addressbook/gui/widgets/gal-view-treeview.h deleted file mode 100644 index a0313856a6..0000000000 --- a/addressbook/gui/widgets/gal-view-treeview.h +++ /dev/null @@ -1,43 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * gal-view-treeview.h: An TreeView View - * - * Authors: - * Chris Toshok <toshok@ximian.com> - * - * (C) 2000, 2001 Ximian, Inc. - */ -#ifndef _GAL_VIEW_TREEVIEW_H_ -#define _GAL_VIEW_TREEVIEW_H_ - -#include <gal/menus/gal-view.h> -#include <gtk/gtktreeview.h> - -#define GAL_TYPE_VIEW_TREEVIEW (gal_view_treeview_get_type ()) -#define GAL_VIEW_TREEVIEW(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GAL_TYPE_VIEW_TREEVIEW, GalViewTreeView)) -#define GAL_VIEW_TREEVIEW_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GAL_TYPE_VIEW_TREEVIEW, GalViewTreeViewClass)) -#define GAL_IS_VIEW_TREEVIEW(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GAL_TYPE_VIEW_TREEVIEW)) -#define GAL_IS_VIEW_TREEVIEW_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GAL_TYPE_VIEW_TREEVIEW)) - -typedef struct { - GalView base; - - char *title; - - GtkTreeView *tree; -} GalViewTreeView; - -typedef struct { - GalViewClass parent_class; -} GalViewTreeViewClass; - -/* Standard functions */ -GType gal_view_treeview_get_type (void); -GalView *gal_view_treeview_new (const gchar *title); -GalView *gal_view_treeview_construct (GalViewTreeView *view, - const gchar *title); -void gal_view_treeview_attach (GalViewTreeView *view, - GtkTreeView *tree); -void gal_view_treeview_detach (GalViewTreeView *view); - -#endif /* _GAL_VIEW_TREEVIEW_H_ */ diff --git a/addressbook/gui/widgets/test-reflow.c b/addressbook/gui/widgets/test-reflow.c deleted file mode 100644 index 66f003fe2c..0000000000 --- a/addressbook/gui/widgets/test-reflow.c +++ /dev/null @@ -1,199 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* test-reflow.c - * - * Copyright (C) 2000 Ximian, Inc. - * Author: Chris Lahey <clahey@ximian.com> - * - * 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. - */ - -#define TEST_VCARD \ -"BEGIN:VCARD -" \ -"FN:Nat -" \ -"N:Friedman;Nat;D;Mr. -" \ -"TITLE:Head Geek -" \ -"BDAY:1977-08-06 -" \ -"TEL;WORK:617 679 1984 -" \ -"TEL;CELL:123 456 7890 -" \ -"EMAIL;INTERNET:nat@nat.org -" \ -"EMAIL;INTERNET:nat@ximian.com -" \ -"ADR;WORK;POSTAL:P.O. Box 101;;;Any Town;CA;91921-1234; -" \ -"ADR;HOME;POSTAL;INTL:P.O. Box 202;;;Any Town 2;MI;12344-4321;USA -" \ -"END:VCARD -" \ -" -" - - -#include "config.h" - -#include <gtk/gtkmain.h> -#include <gtk/gtkvbox.h> -#include <libgnomeui/gnome-canvas-rect-ellipse.h> -#include <libgnomeui/gnome-init.h> -#include <gal/widgets/e-canvas.h> -#include <gal/widgets/e-reflow.h> -#include <gal/widgets/e-scroll-frame.h> - -#include "e-minicard.h" - -/* This is a horrible thing to do, but it is just a test. */ -GnomeCanvasItem *reflow; -GnomeCanvasItem *rect; -GtkAllocation last_alloc; - -static void destroy_callback(gpointer data, GObject *where_object_was) -{ - exit(0); -} - -static void allocate_callback(GtkWidget *canvas, GtkAllocation *allocation, gpointer data) -{ - double width; - last_alloc = *allocation; - gnome_canvas_item_set( reflow, - "height", (double) allocation->height, - NULL ); - gnome_canvas_item_set( reflow, - "minimum_width", (double) allocation->width, - NULL ); - g_object_get(reflow, - "width", &width, - NULL); - width = MAX(width, allocation->width); - gnome_canvas_set_scroll_region(GNOME_CANVAS( canvas ), 0, 0, width - 1, allocation->height - 1); - gnome_canvas_item_set( rect, - "x2", (double) width, - "y2", (double) allocation->height, - NULL ); -} - -static void resize(GnomeCanvas *canvas, gpointer data) -{ - double width; - g_object_get(reflow, - "width", &width, - NULL); - width = MAX(width, last_alloc.width); - gnome_canvas_set_scroll_region(canvas , 0, 0, width - 1, last_alloc.height - 1); - gnome_canvas_item_set( rect, - "x2", (double) width, - "y2", (double) last_alloc.height, - NULL ); -} - -#if 0 -static void about_callback( GtkWidget *widget, gpointer data ) -{ - - const gchar *authors[] = - { - "Christopher James Lahey <clahey@umich.edu>", - NULL - }; - - GtkWidget *about = - gnome_about_new ( _( "Reflow Test" ), VERSION, - _( "Copyright (C) 2000, Ximian, Inc." ), - authors, - _( "This should test the reflow canvas item" ), - NULL); - gtk_widget_show (about); -} -#endif - -int main( int argc, char *argv[] ) -{ - GtkWidget *app; - GtkWidget *canvas; - GtkWidget *vbox; - GtkWidget *scrollframe; - int i; - - /* bindtextdomain (PACKAGE, GNOMELOCALEDIR); - textdomain (PACKAGE);*/ - - gnome_init( "Reflow Test", VERSION, argc, argv); - app = gnome_app_new("Reflow Test", NULL); - - vbox = gtk_vbox_new(FALSE, 0); - - canvas = e_canvas_new(); - rect = gnome_canvas_item_new( gnome_canvas_root( GNOME_CANVAS( canvas ) ), - gnome_canvas_rect_get_type(), - "x1", (double) 0, - "y1", (double) 0, - "x2", (double) 100, - "y2", (double) 100, - "fill_color", "white", - NULL ); - reflow = gnome_canvas_item_new( gnome_canvas_root( GNOME_CANVAS( canvas ) ), - e_reflow_get_type(), - "height", (double) 100, - "minimum_width", (double) 100, - NULL ); - g_signal_connect( canvas, "reflow", - G_CALLBACK ( resize ), - ( gpointer ) app); - for ( i = 0; i < 200; i++ ) - { - GnomeCanvasItem *item; - ECard *card = e_card_new (TEST_VCARD); - item = gnome_canvas_item_new( GNOME_CANVAS_GROUP(reflow), - e_minicard_get_type(), - "card", card, - NULL); - e_reflow_add_item(E_REFLOW(reflow), item, NULL); - } - gnome_canvas_set_scroll_region ( GNOME_CANVAS( canvas ), - 0, 0, - 100, 100 ); - - scrollframe = e_scroll_frame_new (gtk_layout_get_hadjustment(GTK_LAYOUT(canvas)), - gtk_layout_get_vadjustment(GTK_LAYOUT(canvas))); - e_scroll_frame_set_policy (E_SCROLL_FRAME (scrollframe), - GTK_POLICY_AUTOMATIC, - GTK_POLICY_NEVER); - - gtk_container_add (GTK_CONTAINER (scrollframe), canvas); - - gnome_app_set_contents( GNOME_APP( app ), scrollframe ); - - /* Connect the signals */ - g_object_weak_ref (app, destroy_callback, app); - - g_signal_connect( canvas, "size_allocate", - G_CALLBACK ( allocate_callback ), - ( gpointer ) app ); - - gtk_widget_show_all( app ); - gdk_window_set_back_pixmap( GTK_LAYOUT(canvas)->bin_window, NULL, FALSE); - - gtk_main(); - - /* Not reached. */ - return 0; -} |