From dcc8171fd4c8df52faff322827876acf30c35a4a Mon Sep 17 00:00:00 2001 From: nobody Date: Fri, 14 Dec 2001 04:59:04 +0000 Subject: This commit was manufactured by cvs2svn to create tag 'EOG_0_109_1'. svn path=/tags/EOG_0_109_1/; revision=15041 --- addressbook/gui/component/.cvsignore | 11 - .../component/GNOME_Evolution_Addressbook.oaf.in | 134 -- addressbook/gui/component/Makefile.am | 97 -- addressbook/gui/component/addressbook-component.c | 555 --------- addressbook/gui/component/addressbook-component.h | 32 - addressbook/gui/component/addressbook-config.c | 487 -------- addressbook/gui/component/addressbook-config.glade | 926 -------------- addressbook/gui/component/addressbook-config.h | 31 - addressbook/gui/component/addressbook-factory.c | 101 -- addressbook/gui/component/addressbook-storage.c | 602 --------- addressbook/gui/component/addressbook-storage.h | 77 -- addressbook/gui/component/addressbook.c | 1157 ------------------ addressbook/gui/component/addressbook.h | 23 - addressbook/gui/component/e-address-popup.c | 1274 ------------------- addressbook/gui/component/e-address-popup.h | 89 -- addressbook/gui/component/e-address-widget.c | 576 --------- addressbook/gui/component/e-address-widget.h | 102 -- addressbook/gui/component/e-cardlist-model.c | 229 ---- addressbook/gui/component/e-cardlist-model.h | 42 - addressbook/gui/component/select-names/.cvsignore | 12 - .../Evolution-Addressbook-SelectNames.idl | 42 - .../GNOME_Evolution_Addressbook_SelectNames.oaf.in | 29 - addressbook/gui/component/select-names/Makefile.am | 85 -- .../component/select-names/e-select-names-bonobo.c | 465 ------- .../component/select-names/e-select-names-bonobo.h | 66 - .../select-names/e-select-names-completion.c | 1283 -------------------- .../select-names/e-select-names-completion.h | 67 - .../select-names/e-select-names-factory.c | 58 - .../select-names/e-select-names-factory.h | 30 - .../select-names/e-select-names-manager.c | 614 ---------- .../select-names/e-select-names-manager.h | 63 - .../component/select-names/e-select-names-model.c | 897 -------------- .../component/select-names/e-select-names-model.h | 91 -- .../component/select-names/e-select-names-popup.c | 561 --------- .../component/select-names/e-select-names-popup.h | 35 - .../select-names/e-select-names-table-model.c | 348 ------ .../select-names/e-select-names-table-model.h | 51 - .../select-names/e-select-names-text-model.c | 739 ----------- .../select-names/e-select-names-text-model.h | 47 - .../gui/component/select-names/e-select-names.c | 955 --------------- .../gui/component/select-names/e-select-names.h | 108 -- .../gui/component/select-names/recipient.glade | 61 - .../gui/component/select-names/select-names.glade | 444 ------- 43 files changed, 13696 deletions(-) delete mode 100644 addressbook/gui/component/.cvsignore delete mode 100644 addressbook/gui/component/GNOME_Evolution_Addressbook.oaf.in delete mode 100644 addressbook/gui/component/Makefile.am delete mode 100644 addressbook/gui/component/addressbook-component.c delete mode 100644 addressbook/gui/component/addressbook-component.h delete mode 100644 addressbook/gui/component/addressbook-config.c delete mode 100644 addressbook/gui/component/addressbook-config.glade delete mode 100644 addressbook/gui/component/addressbook-config.h delete mode 100644 addressbook/gui/component/addressbook-factory.c delete mode 100644 addressbook/gui/component/addressbook-storage.c delete mode 100644 addressbook/gui/component/addressbook-storage.h delete mode 100644 addressbook/gui/component/addressbook.c delete mode 100644 addressbook/gui/component/addressbook.h delete mode 100644 addressbook/gui/component/e-address-popup.c delete mode 100644 addressbook/gui/component/e-address-popup.h delete mode 100644 addressbook/gui/component/e-address-widget.c delete mode 100644 addressbook/gui/component/e-address-widget.h delete mode 100644 addressbook/gui/component/e-cardlist-model.c delete mode 100644 addressbook/gui/component/e-cardlist-model.h delete mode 100644 addressbook/gui/component/select-names/.cvsignore delete mode 100644 addressbook/gui/component/select-names/Evolution-Addressbook-SelectNames.idl delete mode 100644 addressbook/gui/component/select-names/GNOME_Evolution_Addressbook_SelectNames.oaf.in delete mode 100644 addressbook/gui/component/select-names/Makefile.am delete mode 100644 addressbook/gui/component/select-names/e-select-names-bonobo.c delete mode 100644 addressbook/gui/component/select-names/e-select-names-bonobo.h delete mode 100644 addressbook/gui/component/select-names/e-select-names-completion.c delete mode 100644 addressbook/gui/component/select-names/e-select-names-completion.h delete mode 100644 addressbook/gui/component/select-names/e-select-names-factory.c delete mode 100644 addressbook/gui/component/select-names/e-select-names-factory.h delete mode 100644 addressbook/gui/component/select-names/e-select-names-manager.c delete mode 100644 addressbook/gui/component/select-names/e-select-names-manager.h delete mode 100644 addressbook/gui/component/select-names/e-select-names-model.c delete mode 100644 addressbook/gui/component/select-names/e-select-names-model.h delete mode 100644 addressbook/gui/component/select-names/e-select-names-popup.c delete mode 100644 addressbook/gui/component/select-names/e-select-names-popup.h delete mode 100644 addressbook/gui/component/select-names/e-select-names-table-model.c delete mode 100644 addressbook/gui/component/select-names/e-select-names-table-model.h delete mode 100644 addressbook/gui/component/select-names/e-select-names-text-model.c delete mode 100644 addressbook/gui/component/select-names/e-select-names-text-model.h delete mode 100644 addressbook/gui/component/select-names/e-select-names.c delete mode 100644 addressbook/gui/component/select-names/e-select-names.h delete mode 100644 addressbook/gui/component/select-names/recipient.glade delete mode 100644 addressbook/gui/component/select-names/select-names.glade (limited to 'addressbook/gui/component') diff --git a/addressbook/gui/component/.cvsignore b/addressbook/gui/component/.cvsignore deleted file mode 100644 index 8bcb766191..0000000000 --- a/addressbook/gui/component/.cvsignore +++ /dev/null @@ -1,11 +0,0 @@ -.deps -.libs -.pure -Makefile -Makefile.in -*.lo -*.la -evolution-addressbook -evolution-addressbook.pure -test-addressbook -GNOME_Evolution_Addressbook.oaf \ No newline at end of file diff --git a/addressbook/gui/component/GNOME_Evolution_Addressbook.oaf.in b/addressbook/gui/component/GNOME_Evolution_Addressbook.oaf.in deleted file mode 100644 index b050e8ebb8..0000000000 --- a/addressbook/gui/component/GNOME_Evolution_Addressbook.oaf.in +++ /dev/null @@ -1,134 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/addressbook/gui/component/Makefile.am b/addressbook/gui/component/Makefile.am deleted file mode 100644 index 8d8c7198bc..0000000000 --- a/addressbook/gui/component/Makefile.am +++ /dev/null @@ -1,97 +0,0 @@ -SUBDIRS = select-names - -INCLUDES = \ - -DG_LOG_DOMAIN=\"evolution-addressbook\" \ - $(EXTRA_GNOME_CFLAGS) \ - $(GNOME_INCLUDEDIR) \ - -I$(top_srcdir) \ - -I$(top_builddir) \ - -I$(top_srcdir)/shell \ - -I$(top_builddir)/shell \ - -I$(top_srcdir)/widgets/misc \ - -I$(top_srcdir)/addressbook/gui/contact-editor \ - -I$(top_srcdir)/addressbook/gui/contact-list-editor \ - -I$(top_srcdir)/addressbook/gui/minicard \ - -I$(top_srcdir)/addressbook/gui/widgets \ - -I$(top_srcdir)/addressbook/backend \ - -I$(top_builddir)/addressbook/backend \ - $(BONOBO_HTML_GNOME_CFLAGS) \ - $(GNOME_VFS_CFLAGS) \ - -DEVOLUTION_DATADIR=\""$(datadir)"\" \ - -DEVOLUTION_GLADEDIR=\""$(gladedir)"\" \ - -DEVOLUTION_ICONSDIR=\""$(iconsdir)"\" \ - -DEVOLUTION_LOCALEDIR=\""$(localedir)"\" \ - -DCAMEL_PROVIDERDIR=\""$(providerdir)"\" \ - -DEVOLUTION_IMAGESDIR=\""$(datadir)"/images/evolution\" - - -bin_PROGRAMS = \ - evolution-addressbook - -evolution_addressbook_SOURCES = \ - addressbook-component.c \ - addressbook-component.h \ - addressbook-config.c \ - addressbook-config.h \ - addressbook-factory.c \ - addressbook-storage.c \ - addressbook-storage.h \ - addressbook.c \ - addressbook.h \ - e-cardlist-model.c \ - e-cardlist-model.h \ - e-address-widget.h \ - e-address-widget.c \ - e-address-popup.h \ - e-address-popup.c - -evolution_addressbook_LDADD = \ - select-names/libeselectnames.la \ - $(top_builddir)/shell/libeshell.la \ - $(EXTRA_GNOME_LIBS) \ - $(BONOBO_HTML_GNOME_LIBS) \ - $(GNOME_VFS_LIBS) \ - $(BONOBO_CONF_LIBS) \ - $(top_builddir)/addressbook/gui/widgets/libeminicard.a \ - $(top_builddir)/addressbook/backend/ebook/libebook.la \ - $(top_builddir)/camel/libcamel.la \ - $(top_builddir)/libibex/libibex.la \ - $(top_builddir)/e-util/ename/libename.la \ - $(top_builddir)/addressbook/gui/contact-list-editor/libecontactlisteditor.a \ - $(top_builddir)/addressbook/gui/contact-editor/libecontacteditor.a \ - $(top_builddir)/libversit/libversit.la \ - $(top_builddir)/widgets/misc/libemiscwidgets.a \ - $(top_builddir)/addressbook/printing/libecontactprint.a \ - $(top_builddir)/addressbook/gui/search/libeaddressbooksearch.a \ - $(top_builddir)/addressbook/gui/merging/libecardmerging.a \ - $(top_builddir)/filter/libfilter.la \ - $(top_builddir)/e-util/libeutil.la \ - $(top_builddir)/widgets/menus/libmenus.la - -evolution_addressbook_LDFLAGS = `gnome-config --libs gdk_pixbuf` -export-dynamic - -@XML_I18N_MERGE_OAF_RULE@ - -oafdir = $(datadir)/oaf -oaf_in_files = GNOME_Evolution_Addressbook.oaf.in -oaf_DATA = $(oaf_in_files:.oaf.in=.oaf) - -gladedir = $(datadir)/evolution/glade -glade_DATA = addressbook-config.glade - -EXTRA_DIST = \ - $(glade_DATA) \ - $(oaf_DATA) \ - addressbook-config.glade\ - $(oaf_in_files) - -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 b1815dc794..0000000000 --- a/addressbook/gui/component/addressbook-component.c +++ /dev/null @@ -1,555 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* addressbook-component.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 -#endif - -#include -#include -#include -#include -#include - -#include -#include -#include - -#include - -#include "evolution-shell-component.h" -#include "evolution-shell-component-dnd.h" -#include "evolution-storage.h" - -#include "ebook/e-book.h" -#include "ebook/e-card.h" -#include "ebook/e-book-util.h" - -#include "addressbook-storage.h" -#include "addressbook-component.h" -#include "addressbook.h" -#include "addressbook/gui/merging/e-card-merging.h" -#include "addressbook/gui/widgets/e-addressbook-util.h" - - - -#define GNOME_EVOLUTION_ADDRESSBOOK_COMPONENT_ID "OAFIID:GNOME_Evolution_Addressbook_ShellComponent" - -EvolutionShellClient *global_shell_client = NULL; - -EvolutionShellClient * -addressbook_component_get_shell_client (void) -{ - return global_shell_client; -} - -static char *accepted_dnd_types[] = { - "text/x-vcard", - NULL -}; - -static const EvolutionShellComponentFolderType folder_types[] = { - { "contacts", "evolution-contacts.png", N_("Contacts"), N_("Folder containing contact information"), - TRUE, accepted_dnd_types, NULL }, - { "ldap-contacts", "ldap.png", N_("LDAP Server"), N_("LDAP server containing contact information"), - FALSE, accepted_dnd_types, NULL }, - { NULL } -}; - -#define IS_CONTACT_TYPE(x) (g_strcasecmp((x), "contacts") == 0 || g_strcasecmp ((x), "ldap-contacts") == 0) - -/* EvolutionShellComponent methods and signals. */ - -static EvolutionShellComponentResult -create_view (EvolutionShellComponent *shell_component, - const char *physical_uri, - const char *type, - BonoboControl **control_return, - void *closure) -{ - BonoboControl *control; - - if (!IS_CONTACT_TYPE (type)) - return EVOLUTION_SHELL_COMPONENT_UNSUPPORTEDTYPE; - - control = addressbook_factory_new_control (); - bonobo_control_set_property (control, "folder_uri", physical_uri, NULL); - - *control_return = control; - - return EVOLUTION_SHELL_COMPONENT_OK; -} - -static void -create_folder (EvolutionShellComponent *shell_component, - const char *physical_uri, - const char *type, - const GNOME_Evolution_ShellComponentListener listener, - void *closure) -{ - CORBA_Environment ev; - GNOME_Evolution_ShellComponentListener_Result result; - - if (!IS_CONTACT_TYPE (type)) - result = GNOME_Evolution_ShellComponentListener_UNSUPPORTED_TYPE; - else - result = GNOME_Evolution_ShellComponentListener_OK; - - CORBA_exception_init(&ev); - GNOME_Evolution_ShellComponentListener_notifyResult(listener, result, &ev); - CORBA_exception_free(&ev); -} - -static void -remove_folder (EvolutionShellComponent *shell_component, - const char *physical_uri, - const char *type, - const GNOME_Evolution_ShellComponentListener listener, - void *closure) -{ - CORBA_Environment ev; - char *addressbook_db_path, *subdir_path; - struct stat sb; - int rv; - - CORBA_exception_init(&ev); - - if (!IS_CONTACT_TYPE (type)) { - GNOME_Evolution_ShellComponentListener_notifyResult (listener, - GNOME_Evolution_ShellComponentListener_UNSUPPORTED_TYPE, - &ev); - CORBA_exception_free(&ev); - return; - } - - if (!strncmp (physical_uri, "ldap://", 7)) { - GNOME_Evolution_ShellComponentListener_notifyResult (listener, - GNOME_Evolution_ShellComponentListener_UNSUPPORTED_OPERATION, - &ev); - CORBA_exception_free(&ev); - return; - } - if (strncmp (physical_uri, "file://", 7)) { - GNOME_Evolution_ShellComponentListener_notifyResult (listener, - GNOME_Evolution_ShellComponentListener_INVALID_URI, - &ev); - CORBA_exception_free(&ev); - return; - } - - subdir_path = g_concat_dir_and_file (physical_uri + 7, "subfolders"); - rv = stat (subdir_path, &sb); - g_free (subdir_path); - if (rv != -1) { - GNOME_Evolution_ShellComponentListener_notifyResult (listener, - GNOME_Evolution_ShellComponentListener_HAS_SUBFOLDERS, - &ev); - CORBA_exception_free(&ev); - return; - } - - addressbook_db_path = g_concat_dir_and_file (physical_uri + 7, "addressbook.db"); - rv = unlink (addressbook_db_path); - g_free (addressbook_db_path); - if (rv == 0) { - GNOME_Evolution_ShellComponentListener_notifyResult (listener, - GNOME_Evolution_ShellComponentListener_OK, - &ev); - } - else { - if (errno == EACCES || errno == EPERM) - GNOME_Evolution_ShellComponentListener_notifyResult (listener, - GNOME_Evolution_ShellComponentListener_PERMISSION_DENIED, - &ev); - else - GNOME_Evolution_ShellComponentListener_notifyResult (listener, - GNOME_Evolution_ShellComponentListener_INVALID_URI, /*XXX*/ - &ev); - } - CORBA_exception_free(&ev); -} - -/* ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** */ - -/* This code is cut & pasted from calendar/gui/component-factory.c */ - -static GNOME_Evolution_ShellComponentListener_Result -xfer_file (GnomeVFSURI *base_src_uri, - GnomeVFSURI *base_dest_uri, - const char *file_name, - int remove_source) -{ - GnomeVFSURI *src_uri, *dest_uri; - GnomeVFSHandle *hin, *hout; - GnomeVFSResult result; - GnomeVFSFileInfo file_info; - GnomeVFSFileSize size; - char *buffer; - - src_uri = gnome_vfs_uri_append_file_name (base_src_uri, file_name); - - result = gnome_vfs_open_uri (&hin, src_uri, GNOME_VFS_OPEN_READ); - if (result == GNOME_VFS_ERROR_NOT_FOUND) { - gnome_vfs_uri_unref (src_uri); - return GNOME_Evolution_ShellComponentListener_OK; /* No need to xfer anything. */ - } - if (result != GNOME_VFS_OK) { - gnome_vfs_uri_unref (src_uri); - return GNOME_Evolution_ShellComponentListener_PERMISSION_DENIED; - } - - result = gnome_vfs_get_file_info_uri (src_uri, &file_info, GNOME_VFS_FILE_INFO_DEFAULT); - if (result != GNOME_VFS_OK) { - gnome_vfs_uri_unref (src_uri); - return GNOME_Evolution_ShellComponentListener_PERMISSION_DENIED; - } - - dest_uri = gnome_vfs_uri_append_file_name (base_dest_uri, file_name); - - result = gnome_vfs_create_uri (&hout, dest_uri, GNOME_VFS_OPEN_WRITE, FALSE, 0600); - if (result != GNOME_VFS_OK) { - gnome_vfs_close (hin); - gnome_vfs_uri_unref (src_uri); - gnome_vfs_uri_unref (dest_uri); - return GNOME_Evolution_ShellComponentListener_PERMISSION_DENIED; - } - - /* write source file to destination file */ - buffer = g_malloc (file_info.size); - result = gnome_vfs_read (hin, buffer, file_info.size, &size); - if (result != GNOME_VFS_OK) { - gnome_vfs_close (hin); - gnome_vfs_close (hout); - gnome_vfs_uri_unref (src_uri); - gnome_vfs_uri_unref (dest_uri); - g_free (buffer); - return GNOME_Evolution_ShellComponentListener_PERMISSION_DENIED; - } - - result = gnome_vfs_write (hout, buffer, file_info.size, &size); - if (result != GNOME_VFS_OK) { - gnome_vfs_close (hin); - gnome_vfs_close (hout); - gnome_vfs_uri_unref (src_uri); - gnome_vfs_uri_unref (dest_uri); - g_free (buffer); - return GNOME_Evolution_ShellComponentListener_PERMISSION_DENIED; - } - - if (remove_source) { - char *text_uri; - - /* Sigh, we have to do this as there is no gnome_vfs_unlink_uri(). :-( */ - - text_uri = gnome_vfs_uri_to_string (src_uri, GNOME_VFS_URI_HIDE_NONE); - result = gnome_vfs_unlink (text_uri); - g_free (text_uri); - } - - gnome_vfs_close (hin); - gnome_vfs_close (hout); - gnome_vfs_uri_unref (src_uri); - gnome_vfs_uri_unref (dest_uri); - g_free (buffer); - - return GNOME_Evolution_ShellComponentListener_OK; -} - -static void -xfer_folder (EvolutionShellComponent *shell_component, - const char *source_physical_uri, - const char *destination_physical_uri, - const char *type, - gboolean remove_source, - const GNOME_Evolution_ShellComponentListener listener, - void *closure) -{ - CORBA_Environment ev; - - GnomeVFSURI *src_uri; - GnomeVFSURI *dest_uri; - GnomeVFSResult result; - - CORBA_exception_init (&ev); - - if (!IS_CONTACT_TYPE (type)) { - GNOME_Evolution_ShellComponentListener_notifyResult (listener, - GNOME_Evolution_ShellComponentListener_UNSUPPORTED_TYPE, - &ev); - CORBA_exception_free(&ev); - return; - } - - if (!strncmp (source_physical_uri, "ldap://", 7) - || !strncmp (destination_physical_uri, "ldap://", 7)) { - GNOME_Evolution_ShellComponentListener_notifyResult (listener, - GNOME_Evolution_ShellComponentListener_UNSUPPORTED_OPERATION, - &ev); - CORBA_exception_free(&ev); - return; - } - - if (strncmp (source_physical_uri, "file://", 7) - || strncmp (destination_physical_uri, "file://", 7)) { - GNOME_Evolution_ShellComponentListener_notifyResult (listener, - GNOME_Evolution_ShellComponentListener_INVALID_URI, - &ev); - CORBA_exception_free(&ev); - return; - } - - /* check URIs */ - src_uri = gnome_vfs_uri_new (source_physical_uri); - dest_uri = gnome_vfs_uri_new (destination_physical_uri); - if (!src_uri || ! dest_uri) { - GNOME_Evolution_ShellComponentListener_notifyResult ( - listener, - GNOME_Evolution_ShellComponentListener_INVALID_URI, - &ev); - gnome_vfs_uri_unref (src_uri); - gnome_vfs_uri_unref (dest_uri); - CORBA_exception_free (&ev); - return; - } - - result = xfer_file (src_uri, dest_uri, "addressbook.db", remove_source); - - GNOME_Evolution_ShellComponentListener_notifyResult (listener, result, &ev); - - gnome_vfs_uri_unref (src_uri); - gnome_vfs_uri_unref (dest_uri); - - CORBA_exception_free (&ev); -} - -static char* -get_dnd_selection (EvolutionShellComponent *shell_component, - const char *physical_uri, - int type, - int *format_return, - const char **selection_return, - int *selection_length_return, - void *closure) -{ - /* g_print ("should get dnd selection for %s\n", physical_uri); */ - return NULL; -} - -static int owner_count = 0; - -static void -owner_set_cb (EvolutionShellComponent *shell_component, - EvolutionShellClient *shell_client, - const char *evolution_homedir, - gpointer user_data) -{ - owner_count ++; - - if (global_shell_client == NULL) - global_shell_client = shell_client; - - addressbook_storage_setup (shell_component, evolution_homedir); -} - -static gboolean -gtk_main_quit_cb (gpointer closure) -{ - gtk_main_quit (); - return TRUE; -} - -static void -owner_unset_cb (EvolutionShellComponent *shell_component, - GNOME_Evolution_Shell shell_interface, - gpointer user_data) -{ - owner_count --; - if (owner_count == 0) { - g_idle_add (gtk_main_quit_cb, NULL); - } -} - -/* FIXME We should perhaps take the time to figure out if the book is editable. */ -static void -local_addressbook_cb (EBook *book, gpointer closure) -{ - gboolean is_list = GPOINTER_TO_INT (closure); - if (book == NULL) - return; - if (is_list) - e_addressbook_show_contact_list_editor (book, e_card_new(""), TRUE, TRUE); - else - e_addressbook_show_contact_editor (book, e_card_new(""), TRUE, TRUE); -} - -static void -nonlocal_addressbook_cb (EBook *book, EBookStatus status, gpointer closure) -{ - if (status == E_BOOK_STATUS_SUCCESS) - local_addressbook_cb (book, closure); - else - local_addressbook_cb (NULL, closure); -} - -static void -user_create_new_item_cb (EvolutionShellComponent *shell_component, - const char *id, - const char *parent_folder_physical_uri, - const char *parent_folder_type, - gpointer data) -{ - gboolean is_contact_list; - if (!strcmp (id, "contact")) { - is_contact_list = FALSE; - } else if (!strcmp (id, "contact_list")) { - is_contact_list = TRUE; - } else { - g_warning ("Don't know how to create item of type \"%s\"", id); - return; - } - if (IS_CONTACT_TYPE (parent_folder_type)) { - EBook *book; - gchar *uri; - - book = e_book_new (); - uri = g_strdup_printf ("%s/addressbook.db", parent_folder_physical_uri); - - if (addressbook_load_uri (book, uri, nonlocal_addressbook_cb, GINT_TO_POINTER (is_contact_list)) == 0) - g_warning ("Couldn't load addressbook %s", uri); - - g_free (uri); - } else { - e_book_use_local_address_book (local_addressbook_cb, GINT_TO_POINTER (is_contact_list)); - } -} - - -/* Destination side DnD */ - -static CORBA_boolean -destination_folder_handle_motion (EvolutionShellComponentDndDestinationFolder *folder, - const char *physical_uri, - const char *folder_type, - const GNOME_Evolution_ShellComponentDnd_DestinationFolder_Context * destination_context, - GNOME_Evolution_ShellComponentDnd_Action * suggested_action_return, - gpointer user_data) -{ - *suggested_action_return = GNOME_Evolution_ShellComponentDnd_ACTION_MOVE; - return TRUE; -} - -static void -dnd_drop_book_open_cb (EBook *book, EBookStatus status, GList *card_list) -{ - GList *l; - - for (l = card_list; l; l = l->next) { - ECard *card = l->data; - - e_card_merging_book_add_card (book, card, NULL /* XXX */, NULL); - } -} - -static CORBA_boolean -destination_folder_handle_drop (EvolutionShellComponentDndDestinationFolder *folder, - const char *physical_uri, - const char *folder_type, - const GNOME_Evolution_ShellComponentDnd_DestinationFolder_Context * destination_context, - const GNOME_Evolution_ShellComponentDnd_Action action, - const GNOME_Evolution_ShellComponentDnd_Data * data, - gpointer user_data) -{ - EBook *book; - GList *card_list; - char *expanded_uri; - - if (action == GNOME_Evolution_ShellComponentDnd_ACTION_LINK) - return FALSE; /* we can't create links in our addressbook format */ - - /* g_print ("in destination_folder_handle_drop (%s)\n", physical_uri); */ - - card_list = e_card_load_cards_from_string_with_default_charset (data->bytes._buffer, "ISO-8859-1"); - - expanded_uri = addressbook_expand_uri (physical_uri); - - book = e_book_new (); - addressbook_load_uri (book, expanded_uri, - (EBookCallback)dnd_drop_book_open_cb, card_list); - - g_free (expanded_uri); - - return TRUE; -} - - -/* The factory function. */ - -static BonoboObject * -create_component (void) -{ - EvolutionShellComponent *shell_component; - EvolutionShellComponentDndDestinationFolder *destination_interface; - - shell_component = evolution_shell_component_new (folder_types, NULL, - create_view, create_folder, - remove_folder, xfer_folder, - NULL, - get_dnd_selection, - NULL); - - destination_interface = evolution_shell_component_dnd_destination_folder_new (destination_folder_handle_motion, - destination_folder_handle_drop, - shell_component); - - bonobo_object_add_interface (BONOBO_OBJECT (shell_component), - BONOBO_OBJECT (destination_interface)); - - evolution_shell_component_add_user_creatable_item (shell_component, "contact", _("New Contact"), _("New _Contact"), 'c'); - evolution_shell_component_add_user_creatable_item (shell_component, "contact_list", _("New Contact List"), _("New Contact _List"), 'l'); - - gtk_signal_connect (GTK_OBJECT (shell_component), "owner_set", - GTK_SIGNAL_FUNC (owner_set_cb), NULL); - gtk_signal_connect (GTK_OBJECT (shell_component), "owner_unset", - GTK_SIGNAL_FUNC (owner_unset_cb), NULL); - gtk_signal_connect (GTK_OBJECT (shell_component), "user_create_new_item", - GTK_SIGNAL_FUNC (user_create_new_item_cb), NULL); - - return BONOBO_OBJECT (shell_component); -} - - -/* FIXME this should probably be renamed as we don't use factories anymore. */ -void -addressbook_component_factory_init (void) -{ - BonoboObject *object; - int result; - - object = create_component (); - - /* FIXME: Handle errors better? */ - - result = oaf_active_server_register (GNOME_EVOLUTION_ADDRESSBOOK_COMPONENT_ID, - bonobo_object_corba_objref (object)); - if (result == OAF_REG_ERROR) - g_error ("Cannot register -- %s", GNOME_EVOLUTION_ADDRESSBOOK_COMPONENT_ID); -} diff --git a/addressbook/gui/component/addressbook-component.h b/addressbook/gui/component/addressbook-component.h deleted file mode 100644 index 9b36873902..0000000000 --- a/addressbook/gui/component/addressbook-component.h +++ /dev/null @@ -1,32 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* addressbook-component.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 _ADDRESSBOOK_COMPONENT_H -#define _ADDRESSBOOK_COMPONENT_H - -#include "evolution-shell-component.h" -#include "evolution-storage.h" - -void addressbook_component_factory_init (void); -EvolutionShellClient *addressbook_component_get_shell_client (void); - -#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 de65019a97..0000000000 --- a/addressbook/gui/component/addressbook-config.c +++ /dev/null @@ -1,487 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "addressbook-config.h" -#include "addressbook-storage.h" - -typedef struct _AddressbookSourceDialog AddressbookSourceDialog; -typedef struct _AddressbookSourcePageItem AddressbookSourcePageItem; - -struct _AddressbookSourceDialog { - GladeXML *gui; - - GtkWidget *dialog; - - GtkWidget *notebook; - GtkWidget *basic_notebook; - GtkWidget *advanced_notebook; - - GtkWidget *name; - GtkWidget *host; - GtkWidget *email; - GtkWidget *email_label; - - GtkWidget *port; - GtkWidget *rootdn; - GtkWidget *scope_optionmenu; - AddressbookLDAPScopeType ldap_scope; - GtkWidget *auth_checkbutton; - - gint id; /* button we closed the dialog with */ - - AddressbookSource *source; /* our result if the Ok button was clicked */ -}; - -static void -addressbook_source_edit_changed (GtkWidget *item, AddressbookSourceDialog *dialog) -{ - char *data; - gboolean complete = TRUE; - - if (complete) { - data = e_utf8_gtk_editable_get_chars (GTK_EDITABLE (dialog->name), 0, -1); - if (!data || !*data) - complete = FALSE; - g_free (data); - } - - if (complete) { - if (complete) { - data = e_utf8_gtk_editable_get_chars (GTK_EDITABLE (dialog->host), 0, -1); - if (!data || !*data) - complete = FALSE; - g_free (data); - } - - if (complete) { - data = e_utf8_gtk_editable_get_chars (GTK_EDITABLE (dialog->port), 0, -1); - if (!data || !*data) - complete = FALSE; - /* XXX more validation on port here */ - g_free (data); - } - } - - gnome_dialog_set_sensitive (GNOME_DIALOG (dialog->dialog), 0, complete); -} - -static void -auth_checkbutton_changed (GtkWidget *item, AddressbookSourceDialog *dialog) -{ - /* make sure the change is reflected by the state of the dialog's OK button */ - addressbook_source_edit_changed (item, dialog); - - gtk_widget_set_sensitive (dialog->email_label, - gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(dialog->auth_checkbutton))); - gtk_entry_set_editable (GTK_ENTRY(dialog->email), - gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(dialog->auth_checkbutton))); -} - -static void -option_menuitem_activated (GtkWidget *item, AddressbookSourceDialog *dialog) -{ - /* make sure the change is reflected by the state of the dialog's OK button */ - addressbook_source_edit_changed (item, dialog); - - dialog->ldap_scope = g_list_index (gtk_container_children (GTK_CONTAINER (item->parent)), - item); -} - -typedef struct { - GtkWidget *notebook; - int page_num; -} FocusHelpClosure; - -static void -focus_help (GtkWidget *w, GdkEventFocus *event, FocusHelpClosure *closure) -{ - gtk_notebook_set_page (GTK_NOTEBOOK(closure->notebook), closure->page_num); -} - -static void -add_focus_handler (GtkWidget *widget, GtkWidget *notebook, int page_num) -{ - FocusHelpClosure *focus_closure = g_new0 (FocusHelpClosure, 1); - focus_closure->notebook = notebook; - focus_closure->page_num = page_num; - - gtk_signal_connect_full (GTK_OBJECT (widget), - "focus_in_event" /* XXX */, - (GtkSignalFunc) focus_help, NULL, - focus_closure, - (GtkDestroyNotify) g_free, - FALSE, FALSE); -} - -static void -addressbook_source_dialog_set_source (AddressbookSourceDialog *dialog, AddressbookSource *source) -{ - e_utf8_gtk_entry_set_text (GTK_ENTRY (dialog->name), source ? source->name : ""); - e_utf8_gtk_entry_set_text (GTK_ENTRY (dialog->host), source ? source->host : ""); - e_utf8_gtk_entry_set_text (GTK_ENTRY (dialog->email), source ? source->email_addr : ""); - e_utf8_gtk_entry_set_text (GTK_ENTRY (dialog->port), source ? source->port : "389"); - e_utf8_gtk_entry_set_text (GTK_ENTRY (dialog->rootdn), source ? source->rootdn : ""); - - gtk_option_menu_set_history (GTK_OPTION_MENU(dialog->scope_optionmenu), source ? source->scope : ADDRESSBOOK_LDAP_SCOPE_ONELEVEL); - dialog->ldap_scope = source ? source->scope : ADDRESSBOOK_LDAP_SCOPE_ONELEVEL; - - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(dialog->auth_checkbutton), source && source->auth == ADDRESSBOOK_LDAP_AUTH_SIMPLE); - gtk_widget_set_sensitive (dialog->email_label, source && source->auth == ADDRESSBOOK_LDAP_AUTH_SIMPLE); - gtk_entry_set_editable (GTK_ENTRY(dialog->email), source && source->auth == ADDRESSBOOK_LDAP_AUTH_SIMPLE); -} - -static AddressbookSource * -addressbook_source_dialog_get_source (AddressbookSourceDialog *dialog) -{ - AddressbookSource *source = g_new0 (AddressbookSource, 1); - - source->name = e_utf8_gtk_entry_get_text (GTK_ENTRY (dialog->name)); - source->host = e_utf8_gtk_entry_get_text (GTK_ENTRY (dialog->host)); - source->email_addr = e_utf8_gtk_entry_get_text (GTK_ENTRY (dialog->email)); - source->port = e_utf8_gtk_entry_get_text (GTK_ENTRY (dialog->port)); - source->rootdn = e_utf8_gtk_entry_get_text (GTK_ENTRY (dialog->rootdn)); - source->scope = dialog->ldap_scope; - source->auth = (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->auth_checkbutton)) - ? ADDRESSBOOK_LDAP_AUTH_SIMPLE : ADDRESSBOOK_LDAP_AUTH_NONE); - - addressbook_storage_init_source_uri (source); - - return source; -} - -static void -addressbook_source_dialog_ok_clicked (GtkWidget *widget, AddressbookSourceDialog *dialog) -{ - dialog->source = addressbook_source_dialog_get_source (dialog); -} - -static void -add_activate_cb (GtkWidget *item, AddressbookSourceDialog *dialog) -{ - gtk_signal_connect (GTK_OBJECT (item), "activate", - GTK_SIGNAL_FUNC (option_menuitem_activated), dialog); -} - -static AddressbookSourceDialog* -addressbook_source_dialog (GladeXML *gui, AddressbookSource *source, GtkWidget *parent) -{ - AddressbookSourceDialog *dialog = g_new0 (AddressbookSourceDialog, 1); - GtkWidget *menu; - - dialog->gui = gui; - - dialog->dialog = glade_xml_get_widget (gui, "add_addressbook"); - - if (source) - gtk_window_set_title (GTK_WINDOW (dialog->dialog), _("Edit Addressbook")); - - gtk_window_set_modal (GTK_WINDOW (dialog->dialog), TRUE); - gtk_window_set_policy (GTK_WINDOW (dialog->dialog), - FALSE, TRUE, FALSE); - - gnome_dialog_set_parent (GNOME_DIALOG (dialog->dialog), - GTK_WINDOW (parent)); - - dialog->notebook = glade_xml_get_widget (gui, "add-addressbook-notebook"); - dialog->basic_notebook = glade_xml_get_widget (gui, "basic-notebook"); - dialog->advanced_notebook = glade_xml_get_widget (gui, "advanced-notebook"); - - /* BASIC STUFF */ - dialog->name = glade_xml_get_widget (gui, "account-name-entry"); - gtk_signal_connect (GTK_OBJECT (dialog->name), "changed", - GTK_SIGNAL_FUNC (addressbook_source_edit_changed), dialog); - add_focus_handler (dialog->name, dialog->basic_notebook, 0); - - dialog->host = glade_xml_get_widget (gui, "server-name-entry"); - gtk_signal_connect (GTK_OBJECT (dialog->host), "changed", - GTK_SIGNAL_FUNC (addressbook_source_edit_changed), dialog); - add_focus_handler (dialog->host, dialog->basic_notebook, 1); - - dialog->email = glade_xml_get_widget (gui, "email-address-entry"); - gtk_signal_connect (GTK_OBJECT (dialog->email), "changed", - GTK_SIGNAL_FUNC (addressbook_source_edit_changed), dialog); - add_focus_handler (dialog->email, dialog->basic_notebook, 2); - - dialog->email_label = glade_xml_get_widget (gui, "email-address-label"); - - dialog->auth_checkbutton = glade_xml_get_widget (gui, "auth-checkbutton"); - add_focus_handler (dialog->auth_checkbutton, dialog->basic_notebook, 2); - gtk_signal_connect (GTK_OBJECT (dialog->auth_checkbutton), "toggled", - GTK_SIGNAL_FUNC (auth_checkbutton_changed), dialog); - - /* ADVANCED STUFF */ - dialog->port = glade_xml_get_widget (gui, "port-entry"); - gtk_signal_connect (GTK_OBJECT (dialog->port), "changed", - GTK_SIGNAL_FUNC (addressbook_source_edit_changed), dialog); - add_focus_handler (dialog->port, dialog->advanced_notebook, 0); - - dialog->rootdn = glade_xml_get_widget (gui, "rootdn-entry"); - gtk_signal_connect (GTK_OBJECT (dialog->rootdn), "changed", - GTK_SIGNAL_FUNC (addressbook_source_edit_changed), dialog); - add_focus_handler (dialog->rootdn, dialog->advanced_notebook, 1); - - dialog->scope_optionmenu = glade_xml_get_widget (gui, "scope-optionmenu"); - add_focus_handler (dialog->scope_optionmenu, dialog->advanced_notebook, 2); - menu = gtk_option_menu_get_menu (GTK_OPTION_MENU(dialog->scope_optionmenu)); - gtk_container_foreach (GTK_CONTAINER (menu), (GtkCallback)add_activate_cb, dialog); - - /* fill in source info if there is some */ - addressbook_source_dialog_set_source (dialog, source); - - /* always start out on the first page. */ - gtk_notebook_set_page (GTK_NOTEBOOK (dialog->notebook), 0); - - gnome_dialog_set_sensitive (GNOME_DIALOG (dialog->dialog), 0, FALSE); - - gnome_dialog_button_connect( GNOME_DIALOG (dialog->dialog), 0, - GTK_SIGNAL_FUNC (addressbook_source_dialog_ok_clicked), - dialog); - - /* and set focus to be the Account field (the first editable - field on the first page) */ - gtk_widget_grab_focus (dialog->name); - - return dialog; -} - -static AddressbookSourceDialog * -addressbook_config_source_with_gui (GladeXML *gui, AddressbookSource *source, GtkWidget *parent) -{ - AddressbookSourceDialog* dialog; - - dialog = addressbook_source_dialog (gui, source, parent); - - gnome_dialog_close_hides (GNOME_DIALOG(dialog->dialog), TRUE); - - dialog->id = gnome_dialog_run_and_close (GNOME_DIALOG (dialog->dialog)); - - return dialog; -} - -void -addressbook_create_new_source (const char *new_source, GtkWidget *parent) -{ - AddressbookSourceDialog *dialog; - GladeXML *gui; - - gui = glade_xml_new (EVOLUTION_GLADEDIR "/addressbook-config.glade", NULL); - - dialog = addressbook_source_dialog (gui, NULL, parent); - - e_utf8_gtk_entry_set_text (GTK_ENTRY (dialog->name), new_source); - - gnome_dialog_close_hides (GNOME_DIALOG(dialog->dialog), TRUE); - - dialog->id = gnome_dialog_run_and_close (GNOME_DIALOG (dialog->dialog)); - - gtk_object_unref (GTK_OBJECT (dialog->gui)); - - if (dialog->id == 0) { - /* Ok was clicked */ - addressbook_storage_add_source (addressbook_source_copy(dialog->source)); - addressbook_storage_write_sources(); - } -} - - - -typedef struct { - GladeXML *gui; - GNOME_Evolution_Shell shell; - GtkWidget *dialog; - GtkWidget *clistSources; - GtkWidget *addSource; - GtkWidget *editSource; - GtkWidget *deleteSource; - gint source_row; -} AddressbookDialog; - -static void -update_sensitivity (AddressbookDialog *dialog) -{ - gboolean sensitive = dialog->source_row != -1; - - gtk_widget_set_sensitive (dialog->editSource, sensitive); - gtk_widget_set_sensitive (dialog->deleteSource, sensitive); -} - -static void -add_source_clicked (GtkWidget *widget, AddressbookDialog *dialog) -{ - AddressbookSourceDialog *sdialog; - - sdialog = addressbook_config_source_with_gui (dialog->gui, NULL, dialog->dialog); - if (sdialog->id == 0) { - /* Ok was clicked */ - AddressbookSource *source = addressbook_source_copy(sdialog->source); - gint row; - gchar *text[2]; - - text[0] = source->name; - text[1] = source->host; - - row = e_utf8_gtk_clist_append (GTK_CLIST(dialog->clistSources), text); - gtk_clist_set_row_data_full (GTK_CLIST(dialog->clistSources), row, source, (GtkDestroyNotify) addressbook_source_free); - gnome_dialog_set_sensitive (GNOME_DIALOG(dialog->dialog), 0, TRUE); - gnome_dialog_set_sensitive (GNOME_DIALOG(dialog->dialog), 1, TRUE); - update_sensitivity (dialog); - } -} - -static void -edit_source_clicked (GtkWidget *widget, AddressbookDialog *dialog) -{ - AddressbookSource *source; - AddressbookSourceDialog *sdialog; - - source = gtk_clist_get_row_data (GTK_CLIST (dialog->clistSources), dialog->source_row); - - sdialog = addressbook_config_source_with_gui (dialog->gui, source, dialog->dialog); - if (sdialog->id == 0) { - /* Ok was clicked */ - source = addressbook_source_copy(sdialog->source); - - e_utf8_gtk_clist_set_text (GTK_CLIST (dialog->clistSources), dialog->source_row, 0, source->name); - e_utf8_gtk_clist_set_text (GTK_CLIST (dialog->clistSources), dialog->source_row, 1, source->host); - gtk_clist_set_row_data (GTK_CLIST (dialog->clistSources), dialog->source_row, source); - gnome_dialog_set_sensitive (GNOME_DIALOG(dialog->dialog), 0, TRUE); - gnome_dialog_set_sensitive (GNOME_DIALOG(dialog->dialog), 1, TRUE); - update_sensitivity (dialog); - } -} - -static void -delete_source_clicked (GtkWidget *widget, AddressbookDialog *dialog) -{ - gtk_clist_remove (GTK_CLIST (dialog->clistSources), dialog->source_row); - dialog->source_row = -1; - gnome_dialog_set_sensitive (GNOME_DIALOG(dialog->dialog), 0, TRUE); - gnome_dialog_set_sensitive (GNOME_DIALOG(dialog->dialog), 1, TRUE); - update_sensitivity (dialog); -} - -static void -sources_select_row (GtkWidget *widget, gint row, gint column, - GdkEventButton *event, AddressbookDialog *dialog) -{ - dialog->source_row = row; - - update_sensitivity (dialog); -} - -static void -addressbook_dialog_close (GtkWidget *w, AddressbookDialog *dialog) -{ - gtk_widget_destroy (dialog->dialog); - gtk_object_unref (GTK_OBJECT (dialog->gui)); - g_free (dialog); -} - -static void -addressbook_dialog_apply (GtkWidget *w, AddressbookDialog *dialog) -{ - int i; - - addressbook_storage_clear_sources(); - - for (i = 0; i < GTK_CLIST(dialog->clistSources)->rows; i ++) { - AddressbookSource *source = (AddressbookSource*)gtk_clist_get_row_data (GTK_CLIST (dialog->clistSources), i); - addressbook_storage_add_source (addressbook_source_copy (source)); - } - - addressbook_storage_write_sources(); - - gnome_dialog_set_sensitive (GNOME_DIALOG(dialog->dialog), 0, FALSE); - gnome_dialog_set_sensitive (GNOME_DIALOG(dialog->dialog), 1, FALSE); -} - -static void -addressbook_dialog_ok (GtkWidget *w, AddressbookDialog *dialog) -{ - addressbook_dialog_apply(w, dialog); - addressbook_dialog_close(w, dialog); -} - -void -addressbook_config (GNOME_Evolution_Shell shell) -{ - AddressbookDialog *dialog; - GladeXML *gui; - GtkWidget *clist; - GList *l; - - dialog = g_new0 (AddressbookDialog, 1); - - dialog->source_row = -1; - - gui = glade_xml_new (EVOLUTION_GLADEDIR "/addressbook-config.glade", NULL); - dialog->gui = gui; - dialog->shell = shell; - - dialog->dialog = glade_xml_get_widget (gui, "addressbook_sources"); - - clist = glade_xml_get_widget (gui, "clistSources"); - dialog->clistSources = clist; - - gtk_clist_column_titles_passive (GTK_CLIST (clist)); - gtk_clist_set_column_width (GTK_CLIST (clist), 0, 80); - - dialog->addSource = glade_xml_get_widget (gui, "addSource"); - gtk_signal_connect (GTK_OBJECT(dialog->addSource), "clicked", - GTK_SIGNAL_FUNC (add_source_clicked), - dialog); - - dialog->editSource = glade_xml_get_widget (gui, "editSource"); - gtk_signal_connect (GTK_OBJECT(dialog->editSource), "clicked", - GTK_SIGNAL_FUNC (edit_source_clicked), - dialog); - - dialog->deleteSource = glade_xml_get_widget (gui, "deleteSource"); - gtk_signal_connect (GTK_OBJECT(dialog->deleteSource), "clicked", - GTK_SIGNAL_FUNC (delete_source_clicked), - dialog); - - gnome_dialog_set_sensitive (GNOME_DIALOG(dialog->dialog), 0, FALSE); - gnome_dialog_set_sensitive (GNOME_DIALOG(dialog->dialog), 1, FALSE); - update_sensitivity (dialog); - - l = addressbook_storage_get_sources (); - for (; l != NULL; l = l->next) { - AddressbookSource *source; - gint row; - gchar *text[2]; - - source = addressbook_source_copy ((AddressbookSource*)l->data); - - text[0] = source->name; - text[1] = source->host; - - row = e_utf8_gtk_clist_append (GTK_CLIST(clist), text); - gtk_clist_set_row_data_full (GTK_CLIST(clist), row, source, (GtkDestroyNotify) addressbook_source_free); - } - - gtk_signal_connect (GTK_OBJECT (clist), "select_row", - GTK_SIGNAL_FUNC (sources_select_row), - dialog); - - gnome_dialog_button_connect (GNOME_DIALOG(dialog->dialog), - 0 /* OK */, addressbook_dialog_ok, dialog); - - gnome_dialog_button_connect (GNOME_DIALOG(dialog->dialog), - 1 /* APPLY */, addressbook_dialog_apply, dialog); - - gnome_dialog_button_connect (GNOME_DIALOG(dialog->dialog), - 2 /* CLOSE */, addressbook_dialog_close, dialog); - - gnome_dialog_run (GNOME_DIALOG(dialog->dialog)); -} diff --git a/addressbook/gui/component/addressbook-config.glade b/addressbook/gui/component/addressbook-config.glade deleted file mode 100644 index 50241167c2..0000000000 --- a/addressbook/gui/component/addressbook-config.glade +++ /dev/null @@ -1,926 +0,0 @@ - - - - - - src - pixmaps - C - True - True - - - - GnomeDialog - add_addressbook - False - Add Addressbook - GTK_WINDOW_TOPLEVEL - GTK_WIN_POS_NONE - False - 417 - 332 - False - True - False - False - False - - - GtkVBox - GnomeDialog:vbox - dialog-vbox1 - False - 8 - - 4 - True - True - - - - GtkHButtonBox - GnomeDialog:action_area - dialog-action_area1 - GTK_BUTTONBOX_END - 8 - 85 - 27 - 7 - 0 - - 0 - False - True - GTK_PACK_END - - - - GtkButton - button1 - True - True - GNOME_STOCK_BUTTON_OK - - - - GtkButton - button3 - True - True - GNOME_STOCK_BUTTON_CANCEL - - - - - GtkNotebook - notebook2 - True - True - True - GTK_POS_TOP - False - 2 - 2 - False - - 0 - True - True - - - - GtkVBox - vbox1 - 3 - False - 6 - - - GtkLabel - label29 - - GTK_JUSTIFY_CENTER - True - 0.5 - 0.5 - 0 - 0 - - 0 - False - False - - - - - GtkTable - table1 - 3 - 3 - 2 - False - 3 - 3 - - 0 - False - True - - - - GtkLabel - label15 - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - account-name-entry - - 0 - 1 - 0 - 1 - 0 - 0 - False - False - False - False - True - False - - - - - GtkEntry - account-name-entry - True - True - True - 0 - - - 1 - 2 - 0 - 1 - 0 - 0 - True - False - False - False - True - False - - - - - GtkLabel - label16 - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - server-name-entry - - 0 - 1 - 1 - 2 - 0 - 0 - False - False - False - False - True - False - - - - - GtkEntry - server-name-entry - True - True - True - 0 - - - 1 - 2 - 1 - 2 - 0 - 0 - True - False - False - False - True - False - - - - - GtkCheckButton - auth-checkbutton - True - - False - True - - 0 - 2 - 2 - 3 - 0 - 0 - False - False - False - False - True - False - - - - - - GtkHBox - hbox4 - False - 0 - - 0 - False - False - - - - GtkLabel - email-address-label - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 0 - 0 - - 0 - False - False - - - - - GtkEntry - email-address-entry - True - True - True - 0 - - - 0 - True - True - - - - - - GtkNotebook - basic-notebook - False - False - GTK_POS_TOP - False - 2 - 2 - False - - 0 - True - True - - - - GtkLabel - label28 - - GTK_JUSTIFY_CENTER - True - 0.5 - 0.5 - 0 - 0 - - - - GtkLabel - Notebook:tab - label18 - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 0 - 0 - - - - GtkLabel - label31 - - GTK_JUSTIFY_CENTER - True - 0.5 - 0.5 - 0 - 0 - - - - GtkLabel - Notebook:tab - label19 - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 0 - 0 - - - - GtkLabel - label48 - - GTK_JUSTIFY_CENTER - True - 0.5 - 0.5 - 0 - 0 - - - - GtkLabel - Notebook:tab - label47 - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 0 - 0 - - - - - - GtkLabel - Notebook:tab - label12 - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 0 - 0 - - - - GtkVBox - vbox2 - 3 - False - 3 - - - GtkLabel - label30 - - GTK_JUSTIFY_CENTER - True - 0.5 - 0.5 - 0 - 0 - - 0 - False - False - - - - - GtkTable - table2 - 3 - 3 - 2 - False - 3 - 3 - - 0 - False - False - - - - GtkLabel - label22 - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - port-entry - - 0 - 1 - 0 - 1 - 0 - 0 - False - False - False - False - True - False - - - - - GtkEntry - port-entry - True - True - True - 0 - 389 - - 1 - 2 - 0 - 1 - 0 - 0 - True - False - False - False - True - False - - - - - GtkLabel - label23 - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - rootdn-entry - - 0 - 1 - 1 - 2 - 0 - 0 - False - False - False - False - True - False - - - - - GtkEntry - rootdn-entry - True - True - True - 0 - - - 1 - 2 - 1 - 2 - 0 - 0 - True - False - False - False - True - False - - - - - GtkLabel - label24 - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - - 0 - 1 - 2 - 3 - 0 - 0 - False - False - False - False - True - False - - - - - GtkAlignment - alignment1 - 7.45058e-09 - 7.45058e-09 - 0 - 1 - - 1 - 2 - 2 - 3 - 0 - 0 - True - False - False - False - True - False - - - - GtkOptionMenu - scope-optionmenu - True - One -Base -Sub - - 0 - - - - - - GtkNotebook - advanced-notebook - False - False - GTK_POS_TOP - False - 2 - 2 - False - - 0 - True - True - - - - GtkLabel - label35 - - GTK_JUSTIFY_CENTER - True - 0.5 - 0.5 - 0 - 0 - - - - GtkLabel - Notebook:tab - label25 - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 0 - 0 - - - - GtkLabel - label36 - - GTK_JUSTIFY_CENTER - True - 0.5 - 0.5 - 0 - 0 - - - - GtkLabel - Notebook:tab - label26 - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 0 - 0 - - - - GtkLabel - label37 - - GTK_JUSTIFY_CENTER - True - 0.5 - 0.5 - 0 - 0 - - - - GtkLabel - Notebook:tab - label27 - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 0 - 0 - - - - - - GtkLabel - Notebook:tab - label13 - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 0 - 0 - - - - - - - GnomeDialog - addressbook_sources - False - Addressbook Sources - GTK_WINDOW_TOPLEVEL - GTK_WIN_POS_NONE - False - 355 - 285 - True - True - False - False - False - - - GtkVBox - GnomeDialog:vbox - dialog-vbox2 - False - 8 - - 4 - True - True - - - - GtkHButtonBox - GnomeDialog:action_area - dialog-action_area2 - GTK_BUTTONBOX_END - 8 - 85 - 27 - 7 - 0 - - 0 - False - True - GTK_PACK_END - - - - GtkButton - button7 - True - True - GNOME_STOCK_BUTTON_OK - - - - GtkButton - button8 - True - True - GNOME_STOCK_BUTTON_APPLY - - - - GtkButton - button9 - True - True - GNOME_STOCK_BUTTON_CLOSE - - - - - GtkHBox - hbox3 - False - 0 - - 0 - True - True - - - - GtkScrolledWindow - scrolledwindow2 - GTK_POLICY_AUTOMATIC - GTK_POLICY_AUTOMATIC - GTK_UPDATE_CONTINUOUS - GTK_UPDATE_CONTINUOUS - - 0 - True - True - - - - GtkCList - clistSources - True - 2 - 100,80 - GTK_SELECTION_SINGLE - True - GTK_SHADOW_IN - - - GtkLabel - CList:title - label43 - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 0 - 0 - - - - GtkLabel - CList:title - label44 - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 0 - 0 - - - - - - GtkVBox - vbox4 - False - 0 - - 0 - False - False - - - - GtkLabel - label45 - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 0 - 0 - - 0 - False - False - - - - - GtkVButtonBox - vbuttonbox3 - GTK_BUTTONBOX_START - 0 - 85 - 27 - 7 - 0 - - 0 - True - True - - - - GtkButton - addSource - True - True - - GTK_RELIEF_NORMAL - - - - GtkButton - editSource - True - True - - GTK_RELIEF_NORMAL - - - - GtkButton - deleteSource - True - True - - GTK_RELIEF_NORMAL - - - - - - - - diff --git a/addressbook/gui/component/addressbook-config.h b/addressbook/gui/component/addressbook-config.h deleted file mode 100644 index b0adbd7330..0000000000 --- a/addressbook/gui/component/addressbook-config.h +++ /dev/null @@ -1,31 +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. - * - * Author: Chris Toshok - */ - -#ifndef __ADDRESSBOOK_CONFIG_H__ -#define __ADDRESSBOOK_CONFIG_H__ - -#include "addressbook-storage.h" - -void addressbook_config (GNOME_Evolution_Shell shell); -void addressbook_create_new_source (const char *new_source, GtkWidget *parent); - -#endif /* __ADDRESSBOOK_CONFIG_H__ */ diff --git a/addressbook/gui/component/addressbook-factory.c b/addressbook/gui/component/addressbook-factory.c deleted file mode 100644 index d7a52c9a6d..0000000000 --- a/addressbook/gui/component/addressbook-factory.c +++ /dev/null @@ -1,101 +0,0 @@ -/** - * sample-control-factory.c - * - * Copyright 1999, Ximian, Inc. - * - * Author: - * Nat Friedman (nat@nat.org) - * - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#ifdef GTKHTML_HAVE_GCONF -#include -#endif - -#include "addressbook.h" -#include "addressbook-component.h" -#include "e-address-widget.h" -#include "e-address-popup.h" -#include "addressbook/gui/widgets/e-minicard-control.h" -#include "select-names/e-select-names-factory.h" - - -static void -init_corba (int *argc, char **argv) -{ - gnome_init_with_popt_table ("evolution-addressbook", "0.0", - *argc, argv, oaf_popt_options, 0, NULL); - - oaf_init (*argc, argv); -} - -static void -init_bonobo (int argc, char **argv) -{ - if (bonobo_init (CORBA_OBJECT_NIL, CORBA_OBJECT_NIL, CORBA_OBJECT_NIL) == FALSE) - g_error (_("Could not initialize Bonobo")); - -#ifdef GTKHTML_HAVE_GCONF - gconf_init (argc, argv, NULL); -#endif - - glade_gnome_init (); -} - -int -main (int argc, char **argv) -{ - bindtextdomain (PACKAGE, EVOLUTION_LOCALEDIR); - textdomain (PACKAGE); - - init_corba (&argc, argv); - - init_bonobo (argc, argv); - - if (!gnome_vfs_init ()) - g_error (_("Could not initialize gnome-vfs")); - - /* FIXME: Messy names here. This file should be `main.c'. `addressbook.c' should - be `addressbook-control-factory.c' and the functions should be called - `addressbook_control_factory_something()'. And `addressbook-component.c' - should be `addressbook-component-factory.c'. */ - - addressbook_factory_init (); - addressbook_component_factory_init (); - - e_select_names_factory_init (); - - e_minicard_control_factory_init (); - - e_address_widget_factory_init (); - e_address_popup_factory_init (); - - e_cursors_init(); - - e_passwords_init("Addressbook"); - -#if 0 - g_log_set_always_fatal (G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING); -#endif - - /*g_thread_init (NULL);*/ - camel_type_init (); - - bonobo_main (); - - return 0; -} diff --git a/addressbook/gui/component/addressbook-storage.c b/addressbook/gui/component/addressbook-storage.c deleted file mode 100644 index 8f22ac359a..0000000000 --- a/addressbook/gui/component/addressbook-storage.c +++ /dev/null @@ -1,602 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-ldap-storage.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: Chris Toshok - */ - -/* The addressbook-sources.xml file goes like this: - - - - - LDAP Server - ldap.server.com - 389 - - simple - toshok@blubag.com - - - - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include "addressbook-storage.h" - -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include -#include -#include - -#include "evolution-shell-component.h" - -#include "addressbook-config.h" - -#define ADDRESSBOOK_SOURCES_XML "addressbook-sources.xml" - -#ifdef HAVE_LDAP -static gboolean load_source_data (const char *file_path); -#endif - -static gboolean save_source_data (const char *file_path); -static void deregister_storage (void); - -static GList *sources; -static EvolutionStorage *storage; -static char *storage_path; -static GNOME_Evolution_Shell corba_shell; - -void -addressbook_storage_setup (EvolutionShellComponent *shell_component, - const char *evolution_homedir) -{ - EvolutionShellClient *shell_client; - - shell_client = evolution_shell_component_get_owner (shell_component); - if (shell_client == CORBA_OBJECT_NIL) { - g_warning ("We have no shell!?"); - return; - } - - corba_shell = bonobo_object_corba_objref (BONOBO_OBJECT (shell_client)); - - sources = NULL; - - if (storage_path) - g_free (storage_path); - storage_path = g_concat_dir_and_file (evolution_homedir, ADDRESSBOOK_SOURCES_XML); -#ifdef HAVE_LDAP - if (!load_source_data (storage_path)) - deregister_storage (); -#endif -} - -#ifdef HAVE_LDAP -static void -notify_listener (const Bonobo_Listener listener, - GNOME_Evolution_Storage_Result corba_result) -{ - CORBA_any any; - CORBA_Environment ev; - - CORBA_exception_init (&ev); - - any._type = TC_GNOME_Evolution_Storage_Result; - any._value = &corba_result; - - Bonobo_Listener_event (listener, "result", &any, &ev); - - CORBA_exception_free (&ev); -} - -static void -remove_ldap_folder (EvolutionStorage *storage, const Bonobo_Listener listener, - const CORBA_char *path, const CORBA_char *physical_uri, - gpointer data) -{ - - addressbook_storage_remove_source (path + 1); - addressbook_storage_write_sources(); - - notify_listener (listener, GNOME_Evolution_Storage_OK); -} - -static void -create_ldap_folder (EvolutionStorage *storage, const Bonobo_Listener listener, - const CORBA_char *path, const CORBA_char *type, - const CORBA_char *description, const CORBA_char *parent_physical_uri, - gpointer data) -{ - if (strcmp (type, "ldap-contacts")) { - notify_listener (listener, GNOME_Evolution_Storage_UNSUPPORTED_TYPE); - return; - } - - if (strcmp (parent_physical_uri, "")) {/* ldap servers can't have subfolders */ - notify_listener (listener, GNOME_Evolution_Storage_INVALID_URI); - return; - } - addressbook_create_new_source (path + 1, NULL); - - notify_listener (listener, GNOME_Evolution_Storage_OK); -} -#endif - - -EvolutionStorage * -addressbook_get_other_contact_storage (void) -{ -#ifdef HAVE_LDAP - EvolutionStorageResult result; - - if (storage == NULL) { - storage = evolution_storage_new (U_("Other Contacts"), NULL, NULL); - gtk_signal_connect (GTK_OBJECT (storage), - "remove_folder", - GTK_SIGNAL_FUNC(remove_ldap_folder), NULL); - gtk_signal_connect (GTK_OBJECT (storage), - "create_folder", - GTK_SIGNAL_FUNC(create_ldap_folder), NULL); - result = evolution_storage_register_on_shell (storage, corba_shell); - switch (result) { - case EVOLUTION_STORAGE_OK: - break; - case EVOLUTION_STORAGE_ERROR_GENERIC : - g_warning("register_storage: generic error"); - break; - case EVOLUTION_STORAGE_ERROR_CORBA : - g_warning("register_storage: corba error"); - break; - case EVOLUTION_STORAGE_ERROR_ALREADYREGISTERED : - g_warning("register_storage: already registered error"); - break; - case EVOLUTION_STORAGE_ERROR_EXISTS : - g_warning("register_storage: already exists error"); - break; - default: - g_warning("register_storage: other error"); - break; - } - } -#endif - - return storage; -} - -static void -deregister_storage (void) -{ - if (evolution_storage_deregister_on_shell (storage, corba_shell) != - EVOLUTION_STORAGE_OK) { - g_warning("couldn't deregister storage"); - } - - storage = NULL; -} - -#ifdef HAVE_LDAP -static char * -get_string_value (xmlNode *node, - const char *name) -{ - xmlNode *p; - xmlChar *xml_string; - char *retval; - - p = e_xml_get_child_by_name (node, (xmlChar *) name); - if (p == NULL) - return NULL; - - p = e_xml_get_child_by_name (p, (xmlChar *) "text"); - if (p == NULL) /* 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; -} -#endif - -static char * -ldap_unparse_auth (AddressbookLDAPAuthType auth_type) -{ - switch (auth_type) { - case ADDRESSBOOK_LDAP_AUTH_NONE: - return "none"; - case ADDRESSBOOK_LDAP_AUTH_SIMPLE: - return "simple"; - default: - g_assert(0); - return "none"; - } -} - -#ifdef HAVE_LDAP -static AddressbookLDAPAuthType -ldap_parse_auth (const char *auth) -{ - if (!auth) - return ADDRESSBOOK_LDAP_AUTH_NONE; - - if (!strcmp (auth, "simple")) - return ADDRESSBOOK_LDAP_AUTH_SIMPLE; - else - return ADDRESSBOOK_LDAP_AUTH_NONE; -} -#endif - -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 ""; - } -} - -#ifdef HAVE_LDAP -static AddressbookLDAPScopeType -ldap_parse_scope (const char *scope) -{ - if (!scope) - return ADDRESSBOOK_LDAP_SCOPE_SUBTREE; /* XXX good default? */ - - if (!strcmp (scope, "base")) - return ADDRESSBOOK_LDAP_SCOPE_BASE; - else if (!strcmp (scope, "one")) - return ADDRESSBOOK_LDAP_SCOPE_ONELEVEL; - else - return ADDRESSBOOK_LDAP_SCOPE_SUBTREE; -} -#endif - -void -addressbook_storage_init_source_uri (AddressbookSource *source) -{ - if (source->uri) - g_free (source->uri); - - source->uri = g_strdup_printf ("ldap://%s:%s/%s??%s", - source->host, source->port, - source->rootdn, ldap_unparse_scope(source->scope)); -} - -#ifdef HAVE_LDAP -static gboolean -load_source_data (const char *file_path) -{ - xmlDoc *doc; - xmlNode *root; - xmlNode *child; - - addressbook_get_other_contact_storage(); - - tryagain: - doc = xmlParseFile (file_path); - if (doc == NULL) { - /* Check to see if a addressbook-sources.xml.new file - exists. If it does, rename it and try loading it */ - char *new_path = g_strdup_printf ("%s.new", file_path); - struct stat sb; - - if (stat (new_path, &sb) == 0) { - int rv; - - rv = rename (new_path, file_path); - g_free (new_path); - - if (rv < 0) { - g_error ("Failed to rename %s: %s\n", - ADDRESSBOOK_SOURCES_XML, - strerror(errno)); - return FALSE; - } else - goto tryagain; - } - - g_free (new_path); - return FALSE; - } - - root = xmlDocGetRootElement (doc); - if (root == NULL || strcmp (root->name, "addressbooks") != 0) { - xmlFreeDoc (doc); - return FALSE; - } - - for (child = root->childs; child; child = child->next) { - char *path; - AddressbookSource *source; - - source = g_new0 (AddressbookSource, 1); - - if (!strcmp (child->name, "contactserver")) { - source->type = ADDRESSBOOK_SOURCE_LDAP; - source->port = get_string_value (child, "port"); - source->host = get_string_value (child, "host"); - source->rootdn = get_string_value (child, "rootdn"); - source->scope = ldap_parse_scope (get_string_value (child, "scope")); - source->auth = ldap_parse_auth (get_string_value (child, "authmethod")); - source->email_addr = get_string_value (child, "emailaddr"); - } - else { - g_warning ("unknown node '%s' in %s", child->name, file_path); - g_free (source); - continue; - } - - addressbook_storage_init_source_uri (source); - - source->name = get_string_value (child, "name"); - source->description = get_string_value (child, "description"); - - path = g_strdup_printf ("/%s", source->name); - evolution_storage_new_folder (storage, path, source->name, - "ldap-contacts", source->uri, - source->description, 0); - - sources = g_list_append (sources, source); - - g_free (path); - } - - if (g_list_length (sources) == 0) - deregister_storage(); - - xmlFreeDoc (doc); - return TRUE; -} -#endif - -static void -ldap_source_foreach(AddressbookSource *source, xmlNode *root) -{ - xmlNode *source_root = xmlNewNode (NULL, - (xmlChar *) "contactserver"); - - xmlAddChild (root, source_root); - - xmlNewChild (source_root, NULL, (xmlChar *) "name", - (xmlChar *) source->name); - xmlNewChild (source_root, NULL, (xmlChar *) "description", - (xmlChar *) source->description); - - xmlNewChild (source_root, NULL, (xmlChar *) "port", - (xmlChar *) source->port); - xmlNewChild (source_root, NULL, (xmlChar *) "host", - (xmlChar *) source->host); - xmlNewChild (source_root, NULL, (xmlChar *) "rootdn", - (xmlChar *) source->rootdn); - xmlNewChild (source_root, NULL, (xmlChar *) "scope", - (xmlChar *) ldap_unparse_scope(source->scope)); - xmlNewChild (source_root, NULL, (xmlChar *) "authmethod", - (xmlChar *) ldap_unparse_auth(source->auth)); - if (source->auth == ADDRESSBOOK_LDAP_AUTH_SIMPLE) { - xmlNewChild (source_root, NULL, (xmlChar *) "emailaddr", - (xmlChar *) source->email_addr); - if (source->remember_passwd) - xmlNewChild (source_root, NULL, (xmlChar *) "rememberpass", - NULL); - } -} - -static gboolean -save_source_data (const char *file_path) -{ - xmlDoc *doc; - xmlNode *root; - int fd, rv; - xmlChar *buf; - int buf_size; - char *new_path = g_strdup_printf ("%s.new", file_path); - - doc = xmlNewDoc ((xmlChar *) "1.0"); - root = xmlNewDocNode (doc, NULL, (xmlChar *) "addressbooks", NULL); - xmlDocSetRootElement (doc, root); - - g_list_foreach (sources, (GFunc)ldap_source_foreach, root); - - fd = open (new_path, O_CREAT | O_TRUNC | O_WRONLY, 0600); - fchmod (fd, 0600); - - xmlDocDumpMemory (doc, &buf, &buf_size); - - if (buf == NULL) { - g_error ("Failed to write %s: xmlBufferCreate() == NULL", ADDRESSBOOK_SOURCES_XML); - return FALSE; - } - - rv = write (fd, buf, buf_size); - xmlFree (buf); - close (fd); - - if (0 > rv) { - g_error ("Failed to write new %s: %s\n", ADDRESSBOOK_SOURCES_XML, strerror(errno)); - unlink (new_path); - return FALSE; - } - else { - if (0 > rename (new_path, file_path)) { - g_error ("Failed to rename %s: %s\n", ADDRESSBOOK_SOURCES_XML, strerror(errno)); - unlink (new_path); - return FALSE; - } - return TRUE; - } -} - -void -addressbook_storage_add_source (AddressbookSource *source) -{ - char *path; - - sources = g_list_append (sources, source); - - /* And then to the ui */ - addressbook_get_other_contact_storage(); - path = g_strdup_printf ("/%s", source->name); - evolution_storage_new_folder (storage, path, source->name, "ldap-contacts", - source->uri, source->description, 0); - - g_free (path); -} - -void -addressbook_storage_remove_source (const char *name) -{ - char *path; - AddressbookSource *source = NULL; - GList *l; - - /* remove it from our hashtable */ - for (l = sources; l; l = l->next) { - AddressbookSource *s = l->data; - if (!strcmp (s->name, name)) { - source = s; - break; - } - } - - if (!source) - return; - - sources = g_list_remove_link (sources, l); - g_list_free_1 (l); - - addressbook_source_free (source); - - /* and then from the ui */ - path = g_strdup_printf ("/%s", name); - evolution_storage_removed_folder (storage, path); - - if (g_list_length (sources) == 0) - deregister_storage (); - - g_free (path); -} - -GList * -addressbook_storage_get_sources () -{ - return sources; -} - -AddressbookSource * -addressbook_storage_get_source_by_uri (const char *uri) -{ - GList *l; - - for (l = sources; l ; l = l->next) { - AddressbookSource *source = l->data; - if (!strcmp (uri, source->uri)) - return source; - } - - return NULL; -} - -void -addressbook_source_free (AddressbookSource *source) -{ - g_free (source->name); - g_free (source->description); - g_free (source->uri); - g_free (source->host); - g_free (source->port); - g_free (source->rootdn); - g_free (source->email_addr); - - g_free (source); -} - -static void -addressbook_source_foreach (AddressbookSource *source, gpointer data) -{ - char *path = g_strdup_printf ("/%s", source->name); - - evolution_storage_removed_folder (storage, path); - - g_free (path); - - addressbook_source_free (source); -} - -void -addressbook_storage_clear_sources (void) -{ - g_list_foreach (sources, (GFunc)addressbook_source_foreach, NULL); - g_list_free (sources); - deregister_storage (); - sources = NULL; -} - -void -addressbook_storage_write_sources (void) -{ - save_source_data (storage_path); -} - -AddressbookSource * -addressbook_source_copy (const AddressbookSource *source) -{ - AddressbookSource *copy; - - copy = g_new0 (AddressbookSource, 1); - copy->name = g_strdup (source->name); - copy->description = g_strdup (source->description); - copy->type = source->type; - copy->uri = g_strdup (source->uri); - - copy->host = g_strdup (source->host); - copy->port = g_strdup (source->port); - copy->rootdn = g_strdup (source->rootdn); - copy->scope = source->scope; - copy->auth = source->auth; - copy->email_addr = g_strdup (source->email_addr); - copy->remember_passwd = source->remember_passwd; - - return copy; -} diff --git a/addressbook/gui/component/addressbook-storage.h b/addressbook/gui/component/addressbook-storage.h deleted file mode 100644 index 8416d4de83..0000000000 --- a/addressbook/gui/component/addressbook-storage.h +++ /dev/null @@ -1,77 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 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. - * - * Author: Chris Toshok - */ - -#ifndef __ADDRESSBOOK_STORAGE_H__ -#define __ADDRESSBOOK_STORAGE_H__ - -#include "evolution-shell-component.h" -#include "evolution-storage.h" - -typedef enum { - ADDRESSBOOK_SOURCE_LDAP, - ADDRESSBOOK_SOURCE_FILE, - ADDRESSBOOK_SOURCE_LAST -} AddressbookSourceType; - -typedef enum { - ADDRESSBOOK_LDAP_AUTH_NONE, - ADDRESSBOOK_LDAP_AUTH_SIMPLE, - ADDRESSBOOK_LDAP_AUTH_LAST -} AddressbookLDAPAuthType; - -typedef enum { - ADDRESSBOOK_LDAP_SCOPE_ONELEVEL, - ADDRESSBOOK_LDAP_SCOPE_BASE, - ADDRESSBOOK_LDAP_SCOPE_SUBTREE, - ADDRESSBOOK_LDAP_SCOPE_LAST -} AddressbookLDAPScopeType; - -typedef struct { - AddressbookSourceType type; - char *name; - char *description; - char *host; - char *port; - char *rootdn; - AddressbookLDAPScopeType scope; - AddressbookLDAPAuthType auth; - char *email_addr; /* used in AUTH_SIMPLE */ - gboolean remember_passwd; - char *uri; /* filled in from the above */ -} AddressbookSource; - -void addressbook_storage_setup (EvolutionShellComponent *shell_component, - const char *evolution_homedir); - -EvolutionStorage *addressbook_get_other_contact_storage (void); -GList *addressbook_storage_get_sources (void); -AddressbookSource *addressbook_storage_get_source_by_uri (const char *uri); -void addressbook_storage_clear_sources (void); -void addressbook_storage_write_sources (void); -AddressbookSource *addressbook_source_copy (const AddressbookSource *source); -void addressbook_source_free (AddressbookSource *source); -void addressbook_storage_init_source_uri (AddressbookSource *source); - -void addressbook_storage_add_source (AddressbookSource *source); -void addressbook_storage_remove_source (const char *name); - -#endif /* __ADDRESSBOOK_STORAGE_H__ */ diff --git a/addressbook/gui/component/addressbook.c b/addressbook/gui/component/addressbook.c deleted file mode 100644 index 4741e5196a..0000000000 --- a/addressbook/gui/component/addressbook.c +++ /dev/null @@ -1,1157 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * addressbook.c: - * - * Author: - * Chris Lahey (clahey@ximian.com) - * - * (C) 2000 Ximian, Inc. - */ - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "e-util/e-categories-master-list-wombat.h" -#include "e-util/e-sexp.h" -#include "e-util/e-passwords.h" -#include "select-names/e-select-names.h" -#include "select-names/e-select-names-manager.h" - -#include "evolution-shell-component-utils.h" -#include "evolution-activity-client.h" -#include "e-contact-editor.h" -#include "e-contact-save-as.h" -#include "addressbook-config.h" -#include "addressbook.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/e-addressbook-util.h" -#include "addressbook/printing/e-contact-print.h" - -#include -#include -#include -#include - -/* This is used for the addressbook status bar */ -#define EVOLUTION_CONTACTS_PROGRESS_IMAGE "evolution-contacts-mini.png" -static GdkPixbuf *progress_icon[2] = { NULL, NULL }; - -#define d(x) - -#define PROPERTY_FOLDER_URI "folder_uri" - -#define PROPERTY_FOLDER_URI_IDX 1 - -typedef struct { - gint refs; - EAddressbookView *view; - ESearchBar *search; - gint ecml_changed_id; - GtkWidget *vbox; - EvolutionActivityClient *activity; - BonoboControl *control; - BonoboPropertyBag *properties; - char *uri; - char *passwd; -} AddressbookView; - -static void addressbook_view_ref (AddressbookView *); -static void addressbook_view_unref (AddressbookView *); - -static void -new_contact_cb (BonoboUIComponent *uih, void *user_data, const char *path) -{ - EBook *book; - AddressbookView *view = (AddressbookView *) user_data; - - if (view->view) { - gtk_object_get(GTK_OBJECT(view->view), - "book", &book, - NULL); - - g_assert (E_IS_BOOK (book)); - - e_addressbook_show_contact_editor (book, e_card_new(""), TRUE, e_addressbook_view_can_create(view->view)); - } -} - -static void -new_contact_list_cb (BonoboUIComponent *uih, void *user_data, const char *path) -{ - EBook *book; - AddressbookView *view = (AddressbookView *) user_data; - - if (view->view) { - gtk_object_get(GTK_OBJECT(view->view), - "book", &book, - NULL); - - g_assert (E_IS_BOOK (book)); - - e_addressbook_show_contact_list_editor (book, e_card_new(""), TRUE, e_addressbook_view_can_create(view->view)); - } -} - -static void -save_contact_cb (BonoboUIComponent *uih, void *user_data, const char *path) -{ - AddressbookView *view = (AddressbookView *) user_data; - if (view->view) - e_addressbook_view_save_as(view->view); -} - -static void -config_cb (BonoboUIComponent *uih, void *user_data, const char *path) -{ - addressbook_config (NULL /* XXX */); -} - -static void -search_cb (BonoboUIComponent *uih, void *user_data, const char *path) -{ - AddressbookView *view = (AddressbookView *) user_data; - - if (view->view) - gtk_widget_show(e_addressbook_search_dialog_new(view->view)); -} - -static void -delete_contact_cb (BonoboUIComponent *uih, void *user_data, const char *path) -{ - AddressbookView *view = (AddressbookView *) user_data; - if (view->view) - e_addressbook_view_delete_selection(view->view); -} - -static void -print_cb (BonoboUIComponent *uih, void *user_data, const char *path) -{ - AddressbookView *view = (AddressbookView *) user_data; - if (view->view) - e_addressbook_view_print(view->view); -} - -static void -print_preview_cb (BonoboUIComponent *uih, void *user_data, const char *path) -{ - AddressbookView *view = (AddressbookView *) user_data; - if (view->view) - e_addressbook_view_print_preview(view->view); -} - -static void -stop_loading_cb (BonoboUIComponent *uih, void *user_data, const char *path) -{ - AddressbookView *view = (AddressbookView *) user_data; - if (view->view) - e_addressbook_view_stop(view->view); -} - -static void -cut_contacts_cb (BonoboUIComponent *uih, void *user_data, const char *path) -{ - AddressbookView *view = (AddressbookView *) user_data; - if (view->view) - e_addressbook_view_cut(view->view); -} - -static void -copy_contacts_cb (BonoboUIComponent *uih, void *user_data, const char *path) -{ - AddressbookView *view = (AddressbookView *) user_data; - if (view->view) - e_addressbook_view_copy(view->view); -} - -static void -paste_contacts_cb (BonoboUIComponent *uih, void *user_data, const char *path) -{ - AddressbookView *view = (AddressbookView *) user_data; - if (view->view) - e_addressbook_view_paste(view->view); -} - -static void -select_all_contacts_cb (BonoboUIComponent *uih, void *user_data, const char *path) -{ - AddressbookView *view = (AddressbookView *) user_data; - if (view->view) - e_addressbook_view_select_all (view->view); -} - -static void -send_contact_cb (BonoboUIComponent *uih, void *user_data, const char *path) -{ - AddressbookView *view = (AddressbookView *) user_data; - if (view->view) - e_addressbook_view_send (view->view); -} - -static void -send_contact_to_cb (BonoboUIComponent *uih, void *user_data, const char *path) -{ - AddressbookView *view = (AddressbookView *) user_data; - if (view->view) - e_addressbook_view_send_to (view->view); -} - -static void -forget_passwords_cb (BonoboUIComponent *uih, void *user_data, const char *path) -{ - e_passwords_forget_passwords(); -} - -static void -update_command_state (EAddressbookView *eav, AddressbookView *view) -{ - BonoboUIComponent *uic; - - if (view->view == NULL) - return; - - addressbook_view_ref (view); - - uic = bonobo_control_get_ui_component (view->control); - - if (bonobo_ui_component_get_container (uic) != CORBA_OBJECT_NIL) { - - /* New Contact */ - bonobo_ui_component_set_prop (uic, - "/commands/ContactNew", - "sensitive", - e_addressbook_view_can_create (view->view) ? "1" : "0", NULL); - bonobo_ui_component_set_prop (uic, - "/commands/ContactNewList", - "sensitive", - e_addressbook_view_can_create (view->view) ? "1" : "0", NULL); - - bonobo_ui_component_set_prop (uic, - "/commands/ContactsSaveAsVCard", - "sensitive", - e_addressbook_view_can_save_as (view->view) ? "1" : "0", NULL); - - /* Print Contact */ - bonobo_ui_component_set_prop (uic, - "/commands/ContactsPrint", - "sensitive", - e_addressbook_view_can_print (view->view) ? "1" : "0", NULL); - - /* Print Contact */ - bonobo_ui_component_set_prop (uic, - "/commands/ContactsPrintPreview", - "sensitive", - e_addressbook_view_can_print (view->view) ? "1" : "0", NULL); - - /* Delete Contact */ - bonobo_ui_component_set_prop (uic, - "/commands/ContactDelete", - "sensitive", - e_addressbook_view_can_delete (view->view) ? "1" : "0", NULL); - - bonobo_ui_component_set_prop (uic, - "/commands/ContactsCut", - "sensitive", - e_addressbook_view_can_cut (view->view) ? "1" : "0", NULL); - bonobo_ui_component_set_prop (uic, - "/commands/ContactsCopy", - "sensitive", - e_addressbook_view_can_copy (view->view) ? "1" : "0", NULL); - bonobo_ui_component_set_prop (uic, - "/commands/ContactsPaste", - "sensitive", - e_addressbook_view_can_paste (view->view) ? "1" : "0", NULL); - bonobo_ui_component_set_prop (uic, - "/commands/ContactsSelectAll", - "sensitive", - e_addressbook_view_can_select_all (view->view) ? "1" : "0", NULL); - - bonobo_ui_component_set_prop (uic, - "/commands/ContactsSendContactToOther", - "sensitive", - e_addressbook_view_can_send (view->view) ? "1" : "0", NULL); - - bonobo_ui_component_set_prop (uic, - "/commands/ContactsSendMessageToContact", - "sensitive", - e_addressbook_view_can_send_to (view->view) ? "1" : "0", NULL); - - - /* Stop */ - bonobo_ui_component_set_prop (uic, - "/commands/ContactStop", - "sensitive", - e_addressbook_view_can_stop (view->view) ? "1" : "0", NULL); - - } - - addressbook_view_unref (view); -} - -static void -change_view_type (AddressbookView *view, EAddressbookViewType view_type) -{ - gtk_object_set (GTK_OBJECT (view->view), "type", view_type, NULL); -} - -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 ("ToolSearch", search_cb), - - BONOBO_UI_UNSAFE_VERB ("AddressbookConfig", config_cb), - - BONOBO_UI_UNSAFE_VERB ("ContactNew", new_contact_cb), - BONOBO_UI_UNSAFE_VERB ("ContactNewList", new_contact_list_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 ("ContactsForgetPasswords", forget_passwords_cb), - - BONOBO_UI_VERB_END -}; - -static EPixmap pixmaps [] = { - E_PIXMAP ("/menu/File/New/NewFirstItem/ContactNew", "evolution-contacts-mini.png"), - E_PIXMAP ("/menu/File/FileOps/ContactsSaveAsVCard", "save-as-16.png"), - E_PIXMAP ("/menu/File/Print/ContactsPrint", "print.xpm"), - E_PIXMAP ("/menu/File/Print/ContactsPrintPreview", "print-preview.xpm"), - - E_PIXMAP ("/menu/EditPlaceholder/Edit/ContactsCut", "16_cut.png"), - E_PIXMAP ("/menu/EditPlaceholder/Edit/ContactsCopy", "16_copy.png"), - E_PIXMAP ("/menu/EditPlaceholder/Edit/ContactsPaste", "16_paste.png"), - E_PIXMAP ("/menu/EditPlaceholder/Edit/ContactDelete", "evolution-trash-mini.png"), - - E_PIXMAP ("/menu/Tools/ComponentPlaceholder/ToolSearch", "search-16.png"), - E_PIXMAP ("/menu/Tools/ComponentPlaceholder/AddressbookConfig", "configure_16_addressbook.xpm"), - - E_PIXMAP ("/Toolbar/ContactNew", "new_contact.xpm"), - E_PIXMAP ("/Toolbar/ContactNewList", "all_contacts.xpm"), - E_PIXMAP ("/Toolbar/ContactsPrint", "buttons/print.png"), - E_PIXMAP ("/Toolbar/ContactDelete", "buttons/delete-message.png"), - - E_PIXMAP_END -}; - -static void -control_activate (BonoboControl *control, - BonoboUIComponent *uic, - AddressbookView *view) -{ - Bonobo_UIContainer remote_ui_container; - - remote_ui_container = bonobo_control_get_remote_ui_container (control); - bonobo_ui_component_set_container (uic, remote_ui_container); - 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, EVOLUTION_DATADIR, - "evolution-addressbook.xml", - "evolution-addressbook"); - - e_addressbook_view_setup_menus (view->view, uic); - - e_pixmaps_update (uic, pixmaps); - - bonobo_ui_component_thaw (uic, NULL); - - update_command_state (view->view, view); -} - -static void -control_activate_cb (BonoboControl *control, - gboolean activate, - AddressbookView *view) -{ - BonoboUIComponent *uic; - - uic = bonobo_control_get_ui_component (control); - g_assert (uic != NULL); - - if (activate) { - - control_activate (control, uic, view); - if (activate && view->view && view->view->model) - e_addressbook_model_force_folder_bar_message (view->view->model); - - } else { - bonobo_ui_component_unset_container (uic); - e_addressbook_view_discard_menus (view->view); - } -} - -static void -addressbook_view_ref (AddressbookView *view) -{ - g_assert (view->refs > 0); - ++view->refs; -} - -static void -addressbook_view_unref (AddressbookView *view) -{ - g_assert (view->refs > 0); - --view->refs; - if (view->refs == 0) - g_free (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 -addressbook_view_clear (AddressbookView *view) -{ - EBook *book; - - if (view->uri && view->view) { - gtk_object_get(GTK_OBJECT(view->view), - "book", &book, - NULL); - gtk_object_unref (GTK_OBJECT (book)); - } - - if (view->properties) { - bonobo_object_unref (BONOBO_OBJECT(view->properties)); - view->properties = NULL; - } - - if (view->view) { - gtk_widget_destroy (GTK_WIDGET (view->view)); - view->view = NULL; - } - - g_free(view->passwd); - view->passwd = NULL; - - g_free(view->uri); - view->uri = NULL; - - if (view->refs == 0) - g_free(view); - - if (view->ecml_changed_id != 0) { - gtk_signal_disconnect (GTK_OBJECT(get_master_list()), - view->ecml_changed_id); - view->ecml_changed_id = 0; - } -} - -static void -book_open_cb (EBook *book, EBookStatus status, gpointer closure) -{ - AddressbookView *view = closure; - - if (status == E_BOOK_STATUS_SUCCESS) { - gtk_object_set(GTK_OBJECT(view->view), - "book", book, - NULL); - } else { - AddressbookSource *source; - GtkWidget *warning_dialog, *label; - - warning_dialog = gnome_dialog_new ( - _("Unable to open addressbook"), - GNOME_STOCK_BUTTON_CLOSE, - NULL); - - source = addressbook_storage_get_source_by_uri (view->uri); - - if (source && source->type == ADDRESSBOOK_SOURCE_LDAP) { -#if HAVE_LDAP - label = gtk_label_new ( - _("We were unable to open this addressbook. This either\n" - "means you have entered an incorrect URI, or the LDAP server\n" - "is down")); -#else - label = gtk_label_new ( - _("This version of Evolution does not have LDAP support\n" - "compiled in to it. If you want to use LDAP in Evolution\n" - "you must compile the program from the CVS sources after\n" - "retrieving OpenLDAP from the link below.\n")); -#endif - } - else { - label = gtk_label_new ( - _("We were unable to open this addressbook. Please check that the\n" - "path exists and that you have permission to access it.")); - } - - gtk_misc_set_alignment(GTK_MISC(label), - 0, .5); - gtk_label_set_justify(GTK_LABEL(label), - GTK_JUSTIFY_LEFT); - - gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (warning_dialog)->vbox), - label, TRUE, TRUE, 0); - gtk_widget_show (label); - -#ifndef HAVE_LDAP - if (source && source->type == ADDRESSBOOK_SOURCE_LDAP) { - GtkWidget *href; - href = gnome_href_new ("http://www.openldap.org/", "OpenLDAP at http://www.openldap.org/"); - gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (warning_dialog)->vbox), - href, FALSE, FALSE, 0); - gtk_widget_show (href); - } -#endif - gnome_dialog_run (GNOME_DIALOG (warning_dialog)); - - gtk_object_destroy (GTK_OBJECT (warning_dialog)); - } -} - -static void -destroy_callback(GtkWidget *widget, gpointer data) -{ - AddressbookView *view = data; - if (view->view && view->view->model && view->view->model->book_view) - e_book_view_stop (view->view->model->book_view); - addressbook_view_clear (view); - addressbook_view_unref (view); -} - -static void -get_prop (BonoboPropertyBag *bag, - BonoboArg *arg, - guint arg_id, - CORBA_Environment *ev, - gpointer user_data) -{ - AddressbookView *view = user_data; - - switch (arg_id) { - - case PROPERTY_FOLDER_URI_IDX: - if (view && view->uri) - BONOBO_ARG_SET_STRING (arg, view->uri); - else - BONOBO_ARG_SET_STRING (arg, ""); - break; - - default: - g_warning ("Unhandled arg %d\n", arg_id); - } -} - -char * -addressbook_expand_uri (const char *uri) -{ - char *new_uri; - - if (!strncmp (uri, "file:", 5)) { - if (strlen (uri + 7) > 3 - && !strcmp (uri + strlen(uri) - 3, ".db")) { - /* it's a .db file */ - new_uri = g_strdup (uri); - } - else { - char *file_name; - /* we assume it's a dir and glom addressbook.db onto the end. */ - file_name = g_concat_dir_and_file(uri + 7, "addressbook.db"); - new_uri = g_strdup_printf("file://%s", file_name); - g_free(file_name); - } - } - else { - new_uri = g_strdup (uri); - } - - return new_uri; -} - -typedef struct { - char *uri; - EBookCallback cb; - gpointer closure; -} LoadUriData; - -static void -load_uri_auth_cb (EBook *book, EBookStatus status, gpointer closure) -{ - LoadUriData *data = closure; - - if (status != E_BOOK_STATUS_SUCCESS) { - /* pop up a nice dialog, or redo the authentication - bit some number of times. */ - } - - data->cb (book, status, data->closure); - - g_free (data->uri); - g_free (data); -} - - -static void -load_uri_cb (EBook *book, EBookStatus status, gpointer closure) -{ - AddressbookSource *source; - LoadUriData *load_uri_data = closure; - - source = addressbook_storage_get_source_by_uri (load_uri_data->uri); - - if (status == E_BOOK_STATUS_SUCCESS) { - /* check if the addressbook needs authentication */ - - if (source && - source->type == ADDRESSBOOK_SOURCE_LDAP && - source->auth == ADDRESSBOOK_LDAP_AUTH_SIMPLE) { - const char *password; - char *pass_dup = NULL; - - password = e_passwords_get_password(load_uri_data->uri); - - if (!password) { - char *prompt; - gboolean remember; - - prompt = g_strdup_printf (_("Enter password for %s (user %s)"), source->name, source->email_addr); - remember = source->remember_passwd; - pass_dup = e_passwords_ask_password ( - prompt, load_uri_data->uri, prompt, TRUE, - E_PASSWORDS_REMEMBER_FOREVER, &remember, - NULL); - if (remember != source->remember_passwd) { - source->remember_passwd = remember; - addressbook_storage_write_sources (); - } - g_free (prompt); - } - - if (password || pass_dup) { - e_book_authenticate_user (book, source->email_addr, password ? password : pass_dup, - load_uri_auth_cb, closure); - g_free (pass_dup); - return; - } - } - } - - load_uri_data->cb (book, status, load_uri_data->closure); - g_free (load_uri_data->uri); - g_free (load_uri_data); -} - -gboolean -addressbook_load_uri (EBook *book, const char *uri, - EBookCallback cb, gpointer closure) -{ - LoadUriData *load_uri_data = g_new (LoadUriData, 1); - gboolean rv; - - load_uri_data->uri = g_strdup (uri); - load_uri_data->cb = cb; - load_uri_data->closure = closure; - - rv = e_book_load_uri (book, uri, load_uri_cb, load_uri_data); - - if (!rv) { - g_free (load_uri_data->uri); - g_free (load_uri_data); - } - - return rv; -} - -typedef struct { - gpointer closure; - EBookCallback open_response; -} DefaultBookClosure; - -static void -addressbook_default_book_open (EBook *book, EBookStatus status, gpointer closure) -{ - DefaultBookClosure *default_book_closure = closure; - gpointer user_closure = default_book_closure->closure; - EBookCallback user_response = default_book_closure->open_response; - - g_free (default_book_closure); - - if (status != E_BOOK_STATUS_SUCCESS) { - e_book_load_local_address_book (book, user_response, user_closure); - } - else { - user_response (book, status, user_closure); - } -} - -gboolean -addressbook_load_default_book (EBook *book, EBookCallback open_response, gpointer closure) -{ - char *val; - gboolean rv; - CORBA_Environment ev; - Bonobo_ConfigDatabase config_db; - - g_return_val_if_fail (book != NULL, FALSE); - g_return_val_if_fail (E_IS_BOOK (book), FALSE); - g_return_val_if_fail (open_response != NULL, FALSE); - - CORBA_exception_init (&ev); - config_db = addressbook_config_database (&ev); - val = bonobo_config_get_string (config_db, "/Addressbook/default_book_uri", &ev); - CORBA_exception_free (&ev); - - if (val) { - DefaultBookClosure *default_book_closure = g_new (DefaultBookClosure, 1); - default_book_closure->closure = closure; - default_book_closure->open_response = open_response; - rv = addressbook_load_uri (book, val, - addressbook_default_book_open, default_book_closure); - g_free (val); - } - else { - rv = e_book_load_local_address_book (book, open_response, closure); - } - - if (!rv) { - g_warning ("Couldn't load default addressbook"); - } - - return rv; -} - -static void -set_prop (BonoboPropertyBag *bag, - const BonoboArg *arg, - guint arg_id, - CORBA_Environment *ev, - gpointer user_data) -{ - AddressbookView *view = user_data; - - char *uri_data; - EBook *book; - - switch (arg_id) { - - case PROPERTY_FOLDER_URI_IDX: - gtk_object_get(GTK_OBJECT(view->view), - "book", &book, - NULL); - if (view->uri) { - /* we've already had a uri set on this view, so unload it */ - e_book_unload_uri (book); - g_free (view->uri); - } else { - book = e_book_new (); - } - - view->uri = g_strdup(BONOBO_ARG_GET_STRING (arg)); - - uri_data = addressbook_expand_uri (view->uri); - - if (! addressbook_load_uri (book, uri_data, book_open_cb, view)) - printf ("error calling load_uri!\n"); - - g_free(uri_data); - - break; - - default: - g_warning ("Unhandled arg %d\n", arg_id); - break; - } -} - -static ESearchBarItem addressbook_search_menu_items[] = { - E_FILTERBAR_RESET, - { NULL, -1, NULL }, -}; - -enum { - ESB_ANY, - ESB_FULL_NAME, - ESB_EMAIL, - ESB_CATEGORY, - ESB_ADVANCED -}; - -static ESearchBarItem addressbook_search_option_items[] = { - { N_("Any field contains"), ESB_ANY, NULL }, - { N_("Name contains"), ESB_FULL_NAME, NULL }, - { N_("Email contains"), ESB_EMAIL, NULL }, - { N_("Category is"), ESB_CATEGORY, NULL }, /* We attach subitems below */ - { N_("Advanced..."), ESB_ADVANCED, NULL }, - { NULL, -1, NULL } -}; - -static void -addressbook_menu_activated (ESearchBar *esb, int id, AddressbookView *view) -{ - switch (id) { - case E_FILTERBAR_RESET_ID: - /* e_addressbook_view_show_all(view->view); */ - - /* Fix option menu if we are using "Category is" */ - if (e_search_bar_get_item_id (esb) == ESB_CATEGORY) { - - e_search_bar_set_subitem_id (esb, G_MAXINT); - - } else { - - e_search_bar_set_text (esb, ""); - - } - - break; - } -} - -static void -addressbook_query_changed (ESearchBar *esb, AddressbookView *view) -{ - ECategoriesMasterList *master_list; - char *search_word, *search_query; - const char *category_name; - int search_type, subid; - - gtk_object_get(GTK_OBJECT(esb), - "text", &search_word, - "item_id", &search_type, - NULL); - - if (search_type == ESB_ADVANCED) { - gtk_widget_show(e_addressbook_search_dialog_new(view->view)); - } - 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 ("(contains \"full_name\" %s)", - s->str); - break; - case ESB_EMAIL: - search_query = g_strdup_printf ("(contains \"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 ("(contains \"category\" \"%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) - gtk_object_set (GTK_OBJECT(view->view), - "query", search_query, - NULL); - - g_free (search_query); - g_free (search_word); - } -} - -static GNOME_Evolution_ShellView -retrieve_shell_view_interface_from_control (BonoboControl *control) -{ - Bonobo_ControlFrame control_frame; - GNOME_Evolution_ShellView shell_view_interface; - CORBA_Environment ev; - - shell_view_interface = gtk_object_get_data (GTK_OBJECT (control), - "shell_view_interface"); - - if (shell_view_interface) - return shell_view_interface; - - control_frame = bonobo_control_get_control_frame (control); - - if (control_frame == NULL) - return CORBA_OBJECT_NIL; - - CORBA_exception_init (&ev); - shell_view_interface = Bonobo_Unknown_queryInterface (control_frame, - "IDL:GNOME/Evolution/ShellView:1.0", - &ev); - CORBA_exception_free (&ev); - - if (shell_view_interface != CORBA_OBJECT_NIL) - gtk_object_set_data (GTK_OBJECT (control), - "shell_view_interface", - shell_view_interface); - else - g_warning ("Control frame doesn't have Evolution/ShellView."); - - return shell_view_interface; -} - -static void -set_status_message (EAddressbookView *eav, const char *message, AddressbookView *view) -{ - - if (!message || !*message) { - if (view->activity) { - gtk_object_unref (GTK_OBJECT (view->activity)); - view->activity = NULL; - } - } - else if (!view->activity) { - int display; - char *clientid = g_strdup_printf ("%p", view); - - if (progress_icon[0] == NULL) - progress_icon[0] = gdk_pixbuf_new_from_file (EVOLUTION_IMAGESDIR "/" EVOLUTION_CONTACTS_PROGRESS_IMAGE); - - view->activity = evolution_activity_client_new (addressbook_component_get_shell_client(), clientid, - progress_icon, message, TRUE, &display); - - g_free (clientid); - } - else { - evolution_activity_client_update (view->activity, message, -1.0); - } - -} - -static void -set_folder_bar_label (EAddressbookView *eav, const char *message, AddressbookView *view) -{ - CORBA_Environment ev; - GNOME_Evolution_ShellView shell_view_interface; - - CORBA_exception_init (&ev); - - shell_view_interface = retrieve_shell_view_interface_from_control (view->control); - if (!shell_view_interface) { - CORBA_exception_free (&ev); - return; - } - - d(g_message("Updating via ShellView")); - - if (message == NULL || message[0] == 0) { - GNOME_Evolution_ShellView_setFolderBarLabel (shell_view_interface, - "", - &ev); - } - else { - GNOME_Evolution_ShellView_setFolderBarLabel (shell_view_interface, - message, - &ev); - } - - if (BONOBO_EX (&ev)) - g_warning ("Exception in label update: %s", - bonobo_exception_get_text (&ev)); - - CORBA_exception_free (&ev); -} - -/* Our global singleton config database */ -static Bonobo_ConfigDatabase config_db = NULL; - -Bonobo_ConfigDatabase -addressbook_config_database (CORBA_Environment *ev) -{ - if (config_db == NULL) - config_db = bonobo_get_object ("wombat:", "Bonobo/ConfigDatabase", ev); - - return config_db; -} - -static int -compare_subitems (const void *a, const void *b) -{ - const ESearchBarSubitem *subitem_a = a; - const ESearchBarSubitem *subitem_b = b; - - return strcoll (subitem_a->text, subitem_b->text); -} - -static void -make_suboptions (AddressbookView *view) -{ - ESearchBarSubitem *subitems; - 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; isearch, ESB_CATEGORY, subitems); -} - -static void -ecml_changed (ECategoriesMasterList *ecml, AddressbookView *view) -{ - make_suboptions (view); -} - -static void -connect_master_list_changed (AddressbookView *view) -{ - view->ecml_changed_id = - gtk_signal_connect (GTK_OBJECT (get_master_list()), "changed", - GTK_SIGNAL_FUNC (ecml_changed), view); -} - -BonoboControl * -addressbook_factory_new_control (void) -{ - AddressbookView *view; - GtkWidget *frame; - - frame = gtk_frame_new (NULL); - gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN); - - view = g_new0 (AddressbookView, 1); - view->refs = 1; - - view->vbox = gtk_vbox_new (FALSE, 0); - - gtk_signal_connect (GTK_OBJECT (view->vbox), "destroy", - GTK_SIGNAL_FUNC (destroy_callback), - (gpointer) view); - - /* Create the control. */ - view->control = bonobo_control_new (view->vbox); - - view->search = E_SEARCH_BAR(e_search_bar_new(addressbook_search_menu_items, - addressbook_search_option_items)); - make_suboptions (view); - connect_master_list_changed (view); - - gtk_box_pack_start (GTK_BOX (view->vbox), GTK_WIDGET (view->search), - FALSE, FALSE, 0); - gtk_signal_connect (GTK_OBJECT (view->search), "query_changed", - GTK_SIGNAL_FUNC (addressbook_query_changed), view); - gtk_signal_connect (GTK_OBJECT (view->search), "menu_activated", - GTK_SIGNAL_FUNC (addressbook_menu_activated), view); - - view->view = E_ADDRESSBOOK_VIEW(e_addressbook_view_new()); - gtk_container_add (GTK_CONTAINER (frame), GTK_WIDGET (view->view)); - gtk_box_pack_start (GTK_BOX (view->vbox), frame, - TRUE, TRUE, 0); - - /* create the initial view */ - change_view_type (view, E_ADDRESSBOOK_VIEW_MINICARD); - - gtk_widget_show (frame); - gtk_widget_show (view->vbox); - gtk_widget_show (GTK_WIDGET(view->view)); - gtk_widget_show (GTK_WIDGET(view->search)); - - view->properties = bonobo_property_bag_new (get_prop, set_prop, view); - - bonobo_property_bag_add (view->properties, - PROPERTY_FOLDER_URI, PROPERTY_FOLDER_URI_IDX, - BONOBO_ARG_STRING, NULL, _("The URI that the Folder Browser will display"), 0); - - bonobo_control_set_properties (view->control, - view->properties); - - gtk_signal_connect (GTK_OBJECT (view->view), - "status_message", - GTK_SIGNAL_FUNC(set_status_message), - view); - - gtk_signal_connect (GTK_OBJECT (view->view), - "folder_bar_message", - GTK_SIGNAL_FUNC(set_folder_bar_label), - view); - - gtk_signal_connect (GTK_OBJECT (view->view), - "command_state_change", - GTK_SIGNAL_FUNC(update_command_state), - view); - - view->uri = NULL; - - gtk_signal_connect (GTK_OBJECT (view->control), "activate", - control_activate_cb, view); - - return view->control; -} - -static BonoboObject * -addressbook_factory (BonoboGenericFactory *Factory, void *closure) -{ - return BONOBO_OBJECT (addressbook_factory_new_control ()); -} - -void -addressbook_factory_init (void) -{ - static BonoboGenericFactory *addressbook_control_factory = NULL; - - if (addressbook_control_factory != NULL) - return; - - addressbook_control_factory = bonobo_generic_factory_new ( - "OAFIID:GNOME_Evolution_Addressbook_ControlFactory", - addressbook_factory, NULL); - - if (addressbook_control_factory == NULL) { - g_error ("I could not register a Addressbook factory."); - } -} - diff --git a/addressbook/gui/component/addressbook.h b/addressbook/gui/component/addressbook.h deleted file mode 100644 index 9a99589578..0000000000 --- a/addressbook/gui/component/addressbook.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef __ADDRESSBOOK_H__ -#define __ADDRESSBOOK_H__ - -#include -#include -#include -#include -#include - -Bonobo_ConfigDatabase addressbook_config_database (CORBA_Environment *ev); - -/* expand file:///foo/foo/ to file:///foo/foo/addressbook.db */ -char * addressbook_expand_uri (const char *uri); - -/* use this instead of e_book_load_uri everywhere where you want the - authentication to be handled for you. */ -gboolean addressbook_load_uri (EBook *book, const char *uri, EBookCallback cb, gpointer closure); -gboolean addressbook_load_default_book (EBook *book, EBookCallback open_response, gpointer closure); - -BonoboControl *addressbook_factory_new_control (void); -void addressbook_factory_init (void); - -#endif /* __ADDRESSBOOK_H__ */ diff --git a/addressbook/gui/component/e-address-popup.c b/addressbook/gui/component/e-address-popup.c deleted file mode 100644 index 7c04cc0130..0000000000 --- a/addressbook/gui/component/e-address-popup.c +++ /dev/null @@ -1,1274 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * e-address-popup.c - * - * Copyright (C) 2001 Ximian, Inc. - * - * Developed by Jon Trowbridge - */ - -/* - * 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 -#include "addressbook.h" -#include "e-address-popup.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/* - * 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_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_widget_destroy (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 (GtkWidget *w, gpointer closure) -{ - 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 *hbox; - - wiz->body = gtk_vbox_new (FALSE, 2); - wiz->vbox = gtk_vbox_new (FALSE, 2); - wiz->ok_button = gnome_stock_button (GNOME_STOCK_BUTTON_OK); - wiz->cancel_button = gnome_stock_button (GNOME_STOCK_BUTTON_CANCEL); - - wiz->ok_cb = NULL; - wiz->cleanup_cb = NULL; - wiz->closure = NULL; - - wiz->destroy_cb = NULL; - wiz->destroy_closure = NULL; - - hbox = gtk_hbox_new (FALSE, 2); - gtk_box_pack_start (GTK_BOX (hbox), wiz->ok_button, TRUE, FALSE, 2); - gtk_box_pack_start (GTK_BOX (hbox), wiz->cancel_button, TRUE, FALSE, 2); - - 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), hbox, FALSE, TRUE, 2); - - gtk_widget_show_all (wiz->body); - - gtk_signal_connect (GTK_OBJECT (wiz->ok_button), - "clicked", - GTK_SIGNAL_FUNC (mini_wizard_ok_cb), - wiz); - gtk_signal_connect (GTK_OBJECT (wiz->cancel_button), - "clicked", - GTK_SIGNAL_FUNC (mini_wizard_cancel_cb), - wiz); - gtk_signal_connect (GTK_OBJECT (wiz->body), - "destroy", - GTK_SIGNAL_FUNC (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 - * card. - */ - -#define EMPTY_ENTRY N_("(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 *) gtk_object_get_data (GTK_OBJECT (w), "addr"); - - menu->current_selection = addr; -} - -static void -email_menu_add_option (EMailMenu *menu, const gchar *addr) -{ - GtkWidget *menu_item; - gchar *addr_cpy; - - g_return_if_fail (menu != NULL); - if (addr == NULL) - return; - - addr_cpy = g_strdup (addr); - menu->options = g_list_append (menu->options, addr_cpy); - - menu_item = gtk_menu_item_new_with_label (addr); - gtk_object_set_data (GTK_OBJECT (menu_item), "addr", addr_cpy); - gtk_widget_show_all (menu_item); - gtk_menu_append (GTK_MENU (gtk_option_menu_get_menu (GTK_OPTION_MENU (menu->option_menu))), menu_item); - - gtk_signal_connect (GTK_OBJECT (menu_item), - "activate", - menu_activate_cb, - menu); -} - -static void -email_menu_add_options_from_card (EMailMenu *menu, ECard *card, const gchar *extra_addr) -{ - ECardSimple *simple; - - g_return_if_fail (card && E_IS_CARD (card)); - - simple = e_card_simple_new (card); - - /* 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_card_simple_get_email (simple, E_CARD_SIMPLE_EMAIL_ID_EMAIL)); - email_menu_add_option (menu, e_card_simple_get_email (simple, E_CARD_SIMPLE_EMAIL_ID_EMAIL_2)); - email_menu_add_option (menu, e_card_simple_get_email (simple, E_CARD_SIMPLE_EMAIL_ID_EMAIL_3)); - email_menu_add_option (menu, extra_addr); - email_menu_add_option (menu, EMPTY_ENTRY); - - gtk_object_unref (GTK_OBJECT (simple)); -} - -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; - } -} - -#ifdef UNDEFINED_FUNCTIONS_SHOULD_PLEASE_BE_INCLUDED -static void -email_menu_unset_option (EMailMenu *menu, const gchar *addr) -{ - GList *iter; - - g_return_if_fail (menu != NULL); - g_return_if_fail (addr != NULL); - - if (menu->current_selection == NULL || strcmp (addr, menu->current_selection)) - return; - - iter = menu->options; - while (iter && strcmp (addr, (gchar *) iter->data)) { - iter = g_list_next (iter); - } - if (iter) { - iter = g_list_next (iter); - if (iter) { - email_menu_set_option (menu, (gchar *) iter->data); - } else { - email_menu_set_option (menu, EMPTY_ENTRY); - } - } -} -#endif - - - -typedef struct _EMailTable EMailTable; -struct _EMailTable { - GtkWidget *table; - ECard *card; - EMailMenu *primary; - EMailMenu *email2; - EMailMenu *email3; -}; - -static void -email_table_cleanup_cb (gpointer closure) -{ - EMailTable *et = (EMailTable *) closure; - - if (et == NULL) - return; - - gtk_object_unref (GTK_OBJECT (et->card)); - email_menu_free (et->primary); - email_menu_free (et->email2); - email_menu_free (et->email3); - - g_free (et); -} - -static void -email_table_from_card (EMailTable *et) -{ - ECardSimple *simple; - - g_return_if_fail (et != NULL); - - simple = e_card_simple_new (et->card); - email_menu_set_option (et->primary, e_card_simple_get_email (simple, E_CARD_SIMPLE_EMAIL_ID_EMAIL)); - email_menu_set_option (et->email2, e_card_simple_get_email (simple, E_CARD_SIMPLE_EMAIL_ID_EMAIL_2)); - email_menu_set_option (et->email3, e_card_simple_get_email (simple, E_CARD_SIMPLE_EMAIL_ID_EMAIL_3)); - gtk_object_unref (GTK_OBJECT (simple)); -} - -static void -email_table_to_card (EMailTable *et) -{ - ECardSimple *simple; - gchar *curr; - - g_return_if_fail (et != NULL); - - simple = e_card_simple_new (et->card); - - curr = et->primary->current_selection; - if (curr && !strcmp (curr, _(EMPTY_ENTRY))) - curr = NULL; - e_card_simple_set_email (simple, E_CARD_SIMPLE_EMAIL_ID_EMAIL, curr); - - curr = et->email2->current_selection; - if (curr && !strcmp (curr, _(EMPTY_ENTRY))) - curr = NULL; - e_card_simple_set_email (simple, E_CARD_SIMPLE_EMAIL_ID_EMAIL_2, curr); - - curr = et->email3->current_selection; - if (curr && !strcmp (curr, _(EMPTY_ENTRY))) - curr = NULL; - e_card_simple_set_email (simple, E_CARD_SIMPLE_EMAIL_ID_EMAIL_3, curr); - - e_card_simple_sync_card (simple); - gtk_object_unref (GTK_OBJECT (simple)); -} - -static void -email_table_save_card_cb (EBook *book, EBookStatus status, gpointer closure) -{ - ECard *card = E_CARD (closure); - - if (book) { - e_book_commit_card (book, card, NULL, NULL); - gtk_object_unref (GTK_OBJECT (book)); - } - gtk_object_unref (GTK_OBJECT (card)); -} - -/* - * We have to do this in an idle function because of what might be a - * re-entrancy problems with EBook. - */ -static gint -add_card_idle_cb (gpointer closure) -{ - EBook *book; - - book = e_book_new (); - if (!addressbook_load_default_book (book, email_table_save_card_cb, closure)) { - gtk_object_unref (GTK_OBJECT (book)); - email_table_save_card_cb (NULL, E_BOOK_STATUS_OTHER_ERROR, closure); - } - - return 0; -} - -static void -email_table_ok_cb (MiniWizard *wiz, gpointer closure) -{ - EMailTable *et = (EMailTable *) closure; - - email_table_to_card (et); - - gtk_object_ref (GTK_OBJECT (et->card)); - gtk_idle_add (add_card_idle_cb, et->card); - - mini_wizard_destroy (wiz); -} - -static void -email_table_init (MiniWizard *wiz, ECard *card, 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 (card && E_IS_CARD (card)); - - et = g_new (EMailTable, 1); - - et->card = card; - gtk_object_ref (GTK_OBJECT (et->card)); - - 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_card (et->primary, et->card, extra_address); - email_menu_add_options_from_card (et->email2, et->card, extra_address); - email_menu_add_options_from_card (et->email3, et->card, extra_address); - - email_table_from_card (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_card_name_to_string (et->card->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 cards - * and decide which one you want to add the e-mail address to. - */ - -typedef struct _CardPicker CardPicker; -struct _CardPicker { - GtkWidget *body; - GtkWidget *clist; - GList *cards; - gchar *new_name; - gchar *new_email; - - gint current_row; -}; - -static void -card_picker_row_select_cb (GtkCList *clist, gint row, gint col, GdkEventButton *ev, gpointer closure) -{ - MiniWizard *wiz = (MiniWizard *) closure; - CardPicker *pick = (CardPicker *) wiz->closure; - pick->current_row = row; - gtk_widget_set_sensitive (wiz->ok_button, TRUE); -} - -static void -card_picker_row_unselect_cb (GtkCList *clist, gint row, gint col, GdkEventButton *ev, gpointer closure) -{ - MiniWizard *wiz = (MiniWizard *) closure; - CardPicker *pick = (CardPicker *) wiz->closure; - pick->current_row = -1; - gtk_widget_set_sensitive (wiz->ok_button, FALSE); -} - -static void -card_picker_ok_cb (MiniWizard *wiz, gpointer closure) -{ - CardPicker *pick = (CardPicker *) closure; - g_return_if_fail (pick->current_row >= 0); - - if (pick->current_row == 0) { - e_contact_quick_add (pick->new_name, pick->new_email, NULL, NULL); - mini_wizard_destroy (wiz); - } else { - ECard *card = (ECard *) g_list_nth_data (pick->cards, pick->current_row-1); - email_table_init (wiz, card, pick->new_email); - } -} - -static void -card_picker_cleanup_cb (gpointer closure) -{ - CardPicker *pick = (CardPicker *) closure; - - g_list_foreach (pick->cards, (GFunc) gtk_object_unref, NULL); - g_list_free (pick->cards); - - g_free (pick->new_name); - g_free (pick->new_email); -} - -static void -card_picker_init (MiniWizard *wiz, const GList *cards, const gchar *new_name, const gchar *new_email) -{ - CardPicker *pick; - gchar *str; - GtkWidget *w, *swin; - - pick = g_new (CardPicker, 1); - - pick->body = gtk_vbox_new (FALSE, 2); - - pick->clist = gtk_clist_new (1); - gtk_clist_set_column_title (GTK_CLIST (pick->clist), 0, _("Select an Action")); - gtk_clist_column_titles_show (GTK_CLIST (pick->clist)); - gtk_clist_set_selection_mode (GTK_CLIST (pick->clist), GTK_SELECTION_SINGLE); - - gtk_clist_freeze (GTK_CLIST (pick->clist)); - - str = g_strdup_printf (_("Create a new contact \"%s\""), new_name); - gtk_clist_append (GTK_CLIST (pick->clist), &str); - g_free (str); - - pick->cards = NULL; - while (cards) { - ECard *card = (ECard *) cards->data; - gchar *name_str = e_card_name_to_string (card->name); - - pick->cards = g_list_append (pick->cards, card); - gtk_object_ref (GTK_OBJECT (card)); - - str = g_strdup_printf (_("Add address to existing contact \"%s\""), name_str); - gtk_clist_append (GTK_CLIST (pick->clist), &str); - g_free (name_str); - g_free (str); - - cards = g_list_next (cards); - } - - gtk_clist_thaw (GTK_CLIST (pick->clist)); - - pick->new_name = g_strdup (new_name); - pick->new_email = g_strdup (new_email); - - pick->current_row = -1; - gtk_widget_set_sensitive (wiz->ok_button, FALSE); - - /* Connect some signals & callbacks */ - - wiz->ok_cb = card_picker_ok_cb; - wiz->cleanup_cb = card_picker_cleanup_cb; - - gtk_signal_connect (GTK_OBJECT (pick->clist), - "select-row", - GTK_SIGNAL_FUNC (card_picker_row_select_cb), - wiz); - gtk_signal_connect (GTK_OBJECT (pick->clist), - "unselect-row", - GTK_SIGNAL_FUNC (card_picker_row_unselect_cb), - wiz); - - /* Build our widget */ - - w = gtk_label_new (new_email); - gtk_box_pack_start (GTK_BOX (pick->body), w, FALSE, TRUE, 3); - - swin = gtk_scrolled_window_new (NULL, NULL); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (swin), - GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - - gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (swin), pick->clist); - - gtk_box_pack_start (GTK_BOX (pick->body), swin, 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 EAddressPopup widget begins here. - */ - -/* ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** */ - - -static GtkObjectClass *parent_class; - -static void e_address_popup_destroy (GtkObject *); -static void e_address_popup_query (EAddressPopup *); - - -static void -e_address_popup_class_init (EAddressPopupClass *klass) -{ - GtkObjectClass *object_class = (GtkObjectClass *) klass; - - parent_class = GTK_OBJECT_CLASS (gtk_type_class (gtk_event_box_get_type ())); - - object_class->destroy = e_address_popup_destroy; -} - -static void -e_address_popup_init (EAddressPopup *pop) -{ - pop->transitory = TRUE; -} - -static void -e_address_popup_cleanup (EAddressPopup *pop) -{ - if (pop->card) { - gtk_object_unref (GTK_OBJECT (pop->card)); - pop->card = NULL; - } - - if (pop->scheduled_refresh) { - gtk_timeout_remove (pop->scheduled_refresh); - pop->scheduled_refresh = 0; - } - - if (pop->query_tag) { - e_book_simple_query_cancel (pop->book, pop->query_tag); - pop->query_tag = 0; - } - - if (pop->book) { - gtk_object_unref (GTK_OBJECT (pop->book)); - pop->book = NULL; - } - - g_free (pop->name); - pop->name = NULL; - - g_free (pop->email); - pop->email = NULL; -} - -static void -e_address_popup_destroy (GtkObject *obj) -{ - EAddressPopup *pop = E_ADDRESS_POPUP (obj); - - e_address_popup_cleanup (pop); - - if (GTK_OBJECT_CLASS (parent_class)->destroy) - GTK_OBJECT_CLASS (parent_class)->destroy (obj); -} - -GtkType -e_address_popup_get_type (void) -{ - static GtkType pop_type = 0; - - if (!pop_type) { - GtkTypeInfo pop_info = { - "EAddressPopup", - sizeof (EAddressPopup), - sizeof (EAddressPopupClass), - (GtkClassInitFunc) e_address_popup_class_init, - (GtkObjectInitFunc) e_address_popup_init, - NULL, NULL, - (GtkClassInitFunc) NULL - }; - - pop_type = gtk_type_unique (gtk_event_box_get_type (), &pop_info); - } - - return pop_type; -} - -static void -e_address_popup_refresh_names (EAddressPopup *pop) -{ - if (pop->name_widget) { - if (pop->name && *pop->name) { - gchar *s = e_utf8_to_gtk_string (pop->name_widget, pop->name); - gtk_label_set_text (GTK_LABEL (pop->name_widget), s); - g_free (s); - gtk_widget_show (pop->name_widget); - } else { - gtk_widget_hide (pop->name_widget); - } - } - - if (pop->email_widget) { - if (pop->email && *pop->email) { - gchar *s = e_utf8_to_gtk_string (pop->email_widget, pop->email); - gtk_label_set_text (GTK_LABEL (pop->email_widget), s); - g_free (s); - gtk_widget_show (pop->email_widget); - } else { - gtk_widget_hide (pop->email_widget); - } - } - - e_address_popup_query (pop); -} - -static gint -refresh_timeout_cb (gpointer ptr) -{ - EAddressPopup *pop = E_ADDRESS_POPUP (ptr); - e_address_popup_refresh_names (pop); - pop->scheduled_refresh = 0; - return 0; -} - -static void -e_address_popup_schedule_refresh (EAddressPopup *pop) -{ - if (pop->scheduled_refresh == 0) - pop->scheduled_refresh = gtk_timeout_add (20, refresh_timeout_cb, pop); -} - -/* If we are handed something of the form "Foo ", - do the right thing. */ -static gboolean -e_address_popup_set_free_form (EAddressPopup *pop, const gchar *txt) -{ - gchar *lt, *gt = NULL; - - g_return_val_if_fail (pop && E_IS_ADDRESS_POPUP (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); - e_address_popup_set_name (pop, name); - e_address_popup_set_email (pop, email); - - return TRUE; - } - - return FALSE; -} - -void -e_address_popup_set_name (EAddressPopup *pop, const gchar *name) -{ - g_return_if_fail (pop && E_IS_ADDRESS_POPUP (pop)); - - /* We only allow the name to be set once. */ - if (pop->name) - return; - - if (!e_address_popup_set_free_form (pop, name)) { - pop->name = g_strdup (name); - if (pop->name) - g_strstrip (pop->name); - } - - e_address_popup_schedule_refresh (pop); -} - -void -e_address_popup_set_email (EAddressPopup *pop, const gchar *email) -{ - g_return_if_fail (pop && E_IS_ADDRESS_POPUP (pop)); - - /* We only allow the e-mail to be set once. */ - if (pop->email) - return; - - if (!e_address_popup_set_free_form (pop, email)) { - pop->email = g_strdup (email); - if (pop->email) - g_strstrip (pop->email); - } - - e_address_popup_schedule_refresh (pop); -} - -void -e_address_popup_construct (EAddressPopup *pop) -{ - GtkWidget *vbox, *name_holder; - GdkColor color = { 0x0, 0xffff, 0xffff, 0xffff }; - - g_return_if_fail (pop && E_IS_ADDRESS_POPUP (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); - gtk_style_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 Addressbook...")); - gtk_box_pack_start (GTK_BOX (pop->main_vbox), pop->query_msg, TRUE, TRUE, 0); - gtk_widget_show (pop->query_msg); - - /* Build Minicard View */ - pop->minicard_view = e_minicard_widget_new (); - gtk_box_pack_start (GTK_BOX (pop->main_vbox), pop->minicard_view, 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); -} - -GtkWidget * -e_address_popup_new (void) -{ - EAddressPopup *pop = gtk_type_new (E_ADDRESS_POPUP_TYPE); - e_address_popup_construct (pop); - return GTK_WIDGET (pop); -} - -static void -emit_event (EAddressPopup *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) -{ - EAddressPopup *pop = E_ADDRESS_POPUP (closure); - EContactEditor *ce = e_addressbook_show_contact_editor (book, pop->card, FALSE, TRUE); - e_address_popup_cleanup (pop); - emit_event (pop, "Destroy"); - e_contact_editor_raise (ce); -} - -static void -edit_contact_info_cb (EAddressPopup *pop) -{ - EBook *book; - emit_event (pop, "Hide"); - - book = e_book_new (); - if (!addressbook_load_default_book (book, contact_editor_cb, pop)) { - gtk_object_unref (GTK_OBJECT (book)); - contact_editor_cb (NULL, E_BOOK_STATUS_OTHER_ERROR, pop); - } -} - -static void -e_address_popup_cardify (EAddressPopup *pop, ECard *card) -{ - GtkWidget *b; - - g_return_if_fail (pop && E_IS_ADDRESS_POPUP (pop)); - g_return_if_fail (card && E_IS_CARD (card)); - g_return_if_fail (pop->card == NULL); - - pop->card = card; - gtk_object_ref (GTK_OBJECT (pop->card)); - - e_minicard_widget_set_card (E_MINICARD_WIDGET (pop->minicard_view), card); - gtk_widget_show (pop->minicard_view); - 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); - gtk_signal_connect_object (GTK_OBJECT (b), - "clicked", - GTK_SIGNAL_FUNC (edit_contact_info_cb), - GTK_OBJECT (pop)); - gtk_widget_show (b); -} - -static void -add_contacts_cb (EAddressPopup *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); - - } - e_address_popup_cleanup (pop); - emit_event (pop, "Destroy"); -} - -static void -e_address_popup_no_matches (EAddressPopup *pop) -{ - GtkWidget *b; - - g_return_if_fail (pop && E_IS_ADDRESS_POPUP (pop)); - - b = gtk_button_new_with_label (_("Add to Contacts")); - gtk_box_pack_start (GTK_BOX (pop->main_vbox), b, TRUE, TRUE, 0); - gtk_signal_connect_object (GTK_OBJECT (b), - "clicked", - GTK_SIGNAL_FUNC (add_contacts_cb), - GTK_OBJECT (pop)); - gtk_widget_show (b); -} - -static void -wizard_destroy_cb (MiniWizard *wiz, gpointer closure) -{ - gtk_widget_destroy (GTK_WIDGET (closure)); -} - -static void -popup_size_allocate_cb (GtkWidget *widget, GtkAllocation *alloc, gpointer user_data) -{ - gint x, y, w, h, xmax, ymax; - - xmax = gdk_screen_width (); - ymax = gdk_screen_height (); - - if (gtk_object_get_data (GTK_OBJECT (widget), "size_allocate") == NULL) { - gdk_window_get_pointer (NULL, &x, &y, NULL); - w = alloc->width; - h = alloc->height; - x = CLAMP (x - w/2, 0, xmax - w); - y = CLAMP (y - h/2, 0, ymax - h); - gtk_widget_set_uposition (widget, x, y); - gtk_object_set_data (GTK_OBJECT (widget), "size_allocate", widget); - } -} - -static void -e_address_popup_ambiguous_email_add (EAddressPopup *pop, const GList *cards) -{ - 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_signal_connect (GTK_OBJECT (win), - "size_allocate", - GTK_SIGNAL_FUNC (popup_size_allocate_cb), - NULL); - - /* FIXME: This hard-wired size is evil. */ - gtk_widget_set_usize (win, 275, 170); - - card_picker_init (wiz, cards, pop->name, pop->email); - - e_address_popup_cleanup (pop); - emit_event (pop, "Destroy"); - - gtk_container_add (GTK_CONTAINER (win), wiz->body); - gtk_widget_show_all (win); -} - -static void -e_address_popup_multiple_matches (EAddressPopup *pop, const GList *cards) -{ - pop->multiple_matches = TRUE; - - e_address_popup_ambiguous_email_add (pop, cards); -} - -/** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **/ - -/* - * Addressbook Query Fun - */ - -static void -name_only_query_cb (EBook *book, EBookSimpleQueryStatus status, const GList *cards, gpointer closure) -{ - EAddressPopup *pop; - - if (status != E_BOOK_SIMPLE_QUERY_STATUS_SUCCESS) - return; - - pop = E_ADDRESS_POPUP (closure); - - pop->query_tag = 0; - - if (cards == NULL) { - e_address_popup_no_matches (pop); - } else { - e_address_popup_ambiguous_email_add (pop, cards); - } -} - -static void -query_cb (EBook *book, EBookSimpleQueryStatus status, const GList *cards, gpointer closure) -{ - EAddressPopup *pop; - - if (status != E_BOOK_SIMPLE_QUERY_STATUS_SUCCESS) - return; - - pop = E_ADDRESS_POPUP (closure); - - pop->query_tag = 0; - gtk_widget_hide (pop->query_msg); - - if (cards == 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 = e_book_name_and_email_query (book, pop->name, NULL, name_only_query_cb, pop); - } else { - e_address_popup_no_matches (pop); - } - - } else { - if (g_list_length ((GList *) cards) == 1) - e_address_popup_cardify (pop, E_CARD (cards->data)); - else - e_address_popup_multiple_matches (pop, cards); - } -} - -static void -start_query (EBook *book, EBookStatus status, gpointer closure) -{ - EAddressPopup *pop = E_ADDRESS_POPUP (closure); - - if (pop->query_tag) - e_book_simple_query_cancel (book, pop->query_tag); - - if (pop->book != book) { - gtk_object_ref (GTK_OBJECT (book)); - if (pop->book) - gtk_object_unref (GTK_OBJECT (pop->book)); - pop->book = book; - } - - pop->query_tag = e_book_name_and_email_query (book, pop->name, pop->email, query_cb, pop); - - gtk_object_unref (GTK_OBJECT (pop)); -} - -static void -e_address_popup_query (EAddressPopup *pop) -{ - EBook *book; - - g_return_if_fail (pop && E_IS_ADDRESS_POPUP (pop)); - - book = e_book_new (); - gtk_object_ref (GTK_OBJECT (pop)); - - if (!addressbook_load_default_book (book, start_query, pop)) { - gtk_object_unref (GTK_OBJECT (book)); - start_query (NULL, E_BOOK_STATUS_OTHER_ERROR, 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) -{ - EAddressPopup *pop = E_ADDRESS_POPUP (user_data); - - switch (arg_id) { - - case PROPERTY_NAME: - e_address_popup_set_name (pop, BONOBO_ARG_GET_STRING (arg)); - break; - - case PROPERTY_EMAIL: - e_address_popup_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) -{ - EAddressPopup *pop = E_ADDRESS_POPUP (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 (); - } -} - -static BonoboControl * -e_address_popup_factory_new_control (void) -{ - BonoboControl *control; - BonoboPropertyBag *bag; - EAddressPopup *addy; - GtkWidget *w; - - w = e_address_popup_new (); - addy = E_ADDRESS_POPUP (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, bag); - 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; -} - -static BonoboObject * -e_address_popup_factory (BonoboGenericFactory *factory, gpointer user_data) -{ - return BONOBO_OBJECT (e_address_popup_factory_new_control ()); -} - -void -e_address_popup_factory_init (void) -{ - static BonoboGenericFactory *factory = NULL; - - if (factory != NULL) - return; - - factory = bonobo_generic_factory_new ("OAFIID:GNOME_Evolution_Addressbook_AddressPopupFactory", - e_address_popup_factory, NULL); - - if (factory == NULL) - g_error ("I could not register an AddressPopup factory."); -} diff --git a/addressbook/gui/component/e-address-popup.h b/addressbook/gui/component/e-address-popup.h deleted file mode 100644 index b648b79d4f..0000000000 --- a/addressbook/gui/component/e-address-popup.h +++ /dev/null @@ -1,89 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * e-address-popup.h - * - * Copyright (C) 2001 Ximian, Inc. - * - * Developed by Jon Trowbridge - */ - -/* - * 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_ADDRESS_POPUP_H__ -#define __E_ADDRESS_POPUP_H__ - -#include -#include -#include -#include -#include - -BEGIN_GNOME_DECLS - -#define E_ADDRESS_POPUP_TYPE (e_address_popup_get_type ()) -#define E_ADDRESS_POPUP(o) (GTK_CHECK_CAST ((o), E_ADDRESS_POPUP_TYPE, EAddressPopup)) -#define E_ADDRESS_POPUP_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), E_ADDRESS_POPUP_TYPE, EAddressPopupClass)) -#define E_IS_ADDRESS_POPUP(o) (GTK_CHECK_TYPE ((o), E_ADDRESS_POPUP_TYPE)) -#define E_IS_ADDRESS_POPUP_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), E_ADDRESS_POPUP_TYPE)) - -typedef struct _EAddressPopup EAddressPopup; -typedef struct _EAddressPopupClass EAddressPopupClass; - -struct _EAddressPopup { - GtkEventBox parent; - - gchar *name; - gchar *email; - - GtkWidget *name_widget; - GtkWidget *email_widget; - GtkWidget *query_msg; - - GtkWidget *main_vbox; - GtkWidget *generic_view; - GtkWidget *minicard_view; - - gboolean transitory; - - guint scheduled_refresh; - EBook *book; - guint query_tag; - gboolean multiple_matches; - ECard *card; - - BonoboEventSource *es; -}; - -struct _EAddressPopupClass { - GtkEventBoxClass parent_class; -}; - -GtkType e_address_popup_get_type (void); - -void e_address_popup_set_name (EAddressPopup *, const gchar *name); -void e_address_popup_set_email (EAddressPopup *, const gchar *email); - -void e_address_popup_construct (EAddressPopup *); -GtkWidget *e_address_popup_new (void); - -void e_address_popup_factory_init (void); - -END_GNOME_DECLS - -#endif /* __E_ADDRESS_POPUP_H__ */ - diff --git a/addressbook/gui/component/e-address-widget.c b/addressbook/gui/component/e-address-widget.c deleted file mode 100644 index d044ddf7b9..0000000000 --- a/addressbook/gui/component/e-address-widget.c +++ /dev/null @@ -1,576 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * e-address-widget.c - * - * Copyright (C) 2001 Ximian, Inc. - * - * Developed by Jon Trowbridge - */ - -/* - * 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 -#include -#include -#include -#include -#include -#include "e-address-widget.h" - -static void e_address_widget_class_init (EAddressWidgetClass *klass); -static void e_address_widget_init (EAddressWidget *obj); -static void e_address_widget_destroy (GtkObject *obj); - -static gint e_address_widget_button_press_handler (GtkWidget *w, GdkEventButton *ev); -static void e_address_widget_popup (EAddressWidget *, GdkEventButton *ev); -static void e_address_widget_schedule_query (EAddressWidget *); - -static GtkObjectClass *parent_class; - -static EBook *common_book = NULL; /* sort of lame */ - -static gboolean doing_queries = FALSE; - -static void -e_address_widget_class_init (EAddressWidgetClass *klass) -{ - GtkObjectClass *object_class = (GtkObjectClass *) klass; - GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); - - parent_class = GTK_OBJECT_CLASS (gtk_type_class (gtk_event_box_get_type ())); - - object_class->destroy = e_address_widget_destroy; - - widget_class->button_press_event = e_address_widget_button_press_handler; -} - -static void -e_address_widget_init (EAddressWidget *addr) -{ - -} - -static void -e_address_widget_destroy (GtkObject *obj) -{ - EAddressWidget *addr = E_ADDRESS_WIDGET (obj); - - g_free (addr->name); - g_free (addr->email); - - if (addr->query_tag) - e_book_simple_query_cancel (common_book, addr->query_tag); - - if (addr->query_idle_tag) - gtk_idle_remove (addr->query_idle_tag); -} - -static gint -e_address_widget_button_press_handler (GtkWidget *w, GdkEventButton *ev) -{ - EAddressWidget *addr = E_ADDRESS_WIDGET (w); - if (ev->button == 3 && ev->state == 0) { - e_address_widget_popup (addr, ev); - return TRUE; - } - - return FALSE; -} - -GtkType -e_address_widget_get_type (void) -{ - static GtkType aw_type = 0; - - if (!aw_type) { - GtkTypeInfo aw_info = { - "EAddressWidget", - sizeof (EAddressWidget), - sizeof (EAddressWidgetClass), - (GtkClassInitFunc) e_address_widget_class_init, - (GtkObjectInitFunc) e_address_widget_init, - NULL, NULL, /* reserved... but for what sinister purpose? */ - (GtkClassInitFunc) NULL - }; - - aw_type = gtk_type_unique (gtk_event_box_get_type (), &aw_info); - } - - return aw_type; -} - -static void -gtk_widget_visible (GtkWidget *w, gboolean x) -{ - if (x) - gtk_widget_show (w); - else - gtk_widget_hide (w); -} - -static void -e_address_widget_refresh (EAddressWidget *addr) -{ - gchar *str; - gboolean have_name, have_email; - - g_return_if_fail (addr && E_IS_ADDRESS_WIDGET (addr)); - - have_name = addr->name && *addr->name; - have_email = addr->email && *addr->email && (addr->card == NULL || !addr->known_email); - - gtk_label_set_text (GTK_LABEL (addr->name_widget), have_name ? addr->name : ""); - gtk_widget_visible (addr->name_widget, have_name); - if (addr->card) { - gint i, N = strlen (addr->name); - gchar *pattern = g_malloc (N+1); - for (i=0; iname_widget), pattern); - g_free (pattern); - } else { - gtk_label_set_pattern (GTK_LABEL (addr->name_widget), ""); - } - - if (have_email) { - str = g_strdup_printf (have_name ? "<%s>" : "%s", addr->email); - gtk_label_set_text (GTK_LABEL (addr->email_widget), str); - g_free (str); - } else { - gtk_label_set_text (GTK_LABEL (addr->email_widget), ""); - } - gtk_widget_visible (addr->email_widget, have_email); - - gtk_widget_visible (addr->spacer, have_name && have_email); - - /* Launch a query to find the appropriate card, if necessary. */ - if (addr->card == NULL) - e_address_widget_schedule_query (addr); -} - -void -e_address_widget_set_name (EAddressWidget *addr, const gchar *name) -{ - g_return_if_fail (addr && E_IS_ADDRESS_WIDGET (addr)); - - g_free (addr->name); - addr->name = g_strdup (name); - - e_address_widget_refresh (addr); -} - -void -e_address_widget_set_email (EAddressWidget *addr, const gchar *email) -{ - g_return_if_fail (addr && E_IS_ADDRESS_WIDGET (addr)); - - g_free (addr->email); - addr->email = g_strdup (email); - - e_address_widget_refresh (addr); -} - - -void -e_address_widget_set_text (EAddressWidget *addr, const gchar *text) -{ - g_return_if_fail (addr && E_IS_ADDRESS_WIDGET (addr)); - - e_address_widget_set_email (addr, text); /* CRAP */ -} - -void -e_address_widget_construct (EAddressWidget *addr) -{ - GtkWidget *box; - - g_return_if_fail (addr && E_IS_ADDRESS_WIDGET (addr)); - - box = gtk_hbox_new (FALSE, 2); - - addr->name_widget = gtk_label_new (""); - addr->spacer = gtk_label_new (" "); - addr->email_widget = gtk_label_new (""); - - gtk_box_pack_start (GTK_BOX (box), addr->name_widget, FALSE, FALSE, 0); - gtk_box_pack_start (GTK_BOX (box), addr->spacer, FALSE, FALSE, 0); - gtk_box_pack_start (GTK_BOX (box), addr->email_widget, FALSE, FALSE, 0); - - gtk_container_add (GTK_CONTAINER (addr), box); - - gtk_widget_show (box); - gtk_widget_show (addr->name_widget); - gtk_widget_show (addr->email_widget); -} - -GtkWidget * -e_address_widget_new (void) -{ - EAddressWidget *addr = gtk_type_new (e_address_widget_get_type ()); - e_address_widget_construct (addr); - return GTK_WIDGET (addr); -} - -/* - * - * Cardification - * - */ - -static void -e_address_widget_cardify (EAddressWidget *addr, ECard *card, gboolean known_email) -{ - if (addr->card != card || addr->known_email != known_email) { - - if (addr->card != card) { - if (addr->card) - gtk_object_unref (GTK_OBJECT (addr->card)); - addr->card = card; - gtk_object_ref (GTK_OBJECT (addr->card)); - } - - addr->known_email = known_email; - - if (!(addr->name && *addr->name)) { - gchar *s = e_card_name_to_string (card->name); - e_address_widget_set_name (addr, s); - g_free (s); - } - - e_address_widget_refresh (addr); - } -} - -static void -query_results_cb (EBook *book, EBookSimpleQueryStatus status, const GList *cards, gpointer user_data) -{ - EAddressWidget *addr = user_data; - - if (g_list_length ((GList *) cards) == 1) { - ECard *card = E_CARD (cards->data); - e_address_widget_cardify (addr, card, TRUE); - } - - addr->query_tag = 0; -} - -static void -e_address_widget_do_query (EAddressWidget *addr) -{ - e_book_name_and_email_query (common_book, addr->name, addr->email, query_results_cb, addr); -} - -static void -book_ready_cb (EBook *book, EBookStatus status, gpointer user_data) -{ - EAddressWidget *addr = E_ADDRESS_WIDGET (user_data); - - if (common_book == NULL) { - common_book = book; - gtk_object_ref (GTK_OBJECT (common_book)); - } else - gtk_object_unref (GTK_OBJECT (book)); - - e_address_widget_do_query (addr); -} - -static gint -query_idle_fn (gpointer ptr) -{ - EAddressWidget *addr = E_ADDRESS_WIDGET (ptr); - - if (common_book) { - e_address_widget_do_query (addr); - } else { - e_book_load_local_address_book (e_book_new (), book_ready_cb, addr); - } - - addr->query_idle_tag = 0; - return FALSE; -} - -static void -e_address_widget_schedule_query (EAddressWidget *addr) -{ - if (addr->query_idle_tag || !doing_queries) - return; - addr->query_idle_tag = gtk_idle_add (query_idle_fn, addr); -} - -/* - * - * Popup Menu - * - */ - -#define ARBITRARY_UIINFO_LIMIT 64 - -static gint -popup_add_name_and_address (EAddressWidget *addr, GnomeUIInfo *uiinfo, gint i) -{ - gboolean flag = FALSE; - - if (addr->name && *addr->name) { - uiinfo[i].type = GNOME_APP_UI_ITEM; - uiinfo[i].label = addr->name; - ++i; - flag = TRUE; - } - - if (addr->email && *addr->email) { - uiinfo[i].type = GNOME_APP_UI_ITEM; - uiinfo[i].label = addr->email; - ++i; - flag = TRUE; - } - - if (flag) { - uiinfo[i].type = GNOME_APP_UI_SEPARATOR; - ++i; - } - - return i; -} - -static void -flip_queries_flag_cb (GtkWidget *w, gpointer user_data) -{ - doing_queries = !doing_queries; -} - -static gint -popup_add_query_change (EAddressWidget *addr, GnomeUIInfo *uiinfo, gint i) -{ - uiinfo[i].type = GNOME_APP_UI_SEPARATOR; - ++i; - - uiinfo[i].type = GNOME_APP_UI_ITEM; - uiinfo[i].label = doing_queries ? _("Disable Queries") : _("Enable Queries (Dangerous!)"); - uiinfo[i].moreinfo = flip_queries_flag_cb; - ++i; - - return i; -} - - -static GtkWidget * -popup_menu_card (EAddressWidget *addr) -{ - GnomeUIInfo uiinfo[ARBITRARY_UIINFO_LIMIT]; - GtkWidget *pop; - gint i=0; - ECard *card = E_CARD (addr->card); - - g_return_val_if_fail (card != NULL, NULL); - - memset (uiinfo, 0, sizeof (uiinfo)); - - i = popup_add_name_and_address (addr, uiinfo, i); - - uiinfo[i].type = GNOME_APP_UI_ITEM; - uiinfo[i].label = _("Edit Contact Info"); - ++i; - - i = popup_add_query_change (addr, uiinfo, i); - - uiinfo[i].type = GNOME_APP_UI_ENDOFINFO; - pop = gnome_popup_menu_new (uiinfo); - return pop; -} - -static void -post_quick_add_cb (ECard *card, gpointer user_data) -{ - e_address_widget_cardify (E_ADDRESS_WIDGET (user_data), card, TRUE); -} - -static void -add_contacts_cb (GtkWidget *w, gpointer user_data) -{ - EAddressWidget *addr = E_ADDRESS_WIDGET (user_data); - - e_contact_quick_add (addr->name, addr->email, post_quick_add_cb, addr); -} - -static GtkWidget * -popup_menu_nocard (EAddressWidget *addr) -{ - GnomeUIInfo uiinfo[ARBITRARY_UIINFO_LIMIT]; - GtkWidget *pop; - gint i=0; - - memset (uiinfo, 0, sizeof (uiinfo)); - - i = popup_add_name_and_address (addr, uiinfo, i); - - uiinfo[i].type = GNOME_APP_UI_ITEM; - uiinfo[i].label = _("Add to Contacts"); - uiinfo[i].moreinfo = add_contacts_cb; - ++i; - - i = popup_add_query_change (addr, uiinfo, i); - - uiinfo[i].type = GNOME_APP_UI_ENDOFINFO; - pop = gnome_popup_menu_new (uiinfo); - return pop; -} - -static void -e_address_widget_popup (EAddressWidget *addr, GdkEventButton *ev) -{ - GtkWidget *pop; - - g_return_if_fail (addr && E_IS_ADDRESS_WIDGET (addr)); - - pop = addr->card ? popup_menu_card (addr) : popup_menu_nocard (addr); - - if (pop) - gnome_popup_menu_do_popup (pop, NULL, NULL, ev, addr); -} - -/* - * - * Bonobo Control Magic - * - */ - -enum { - ADDRESS_PROPERTY_NAME, - ADDRESS_PROPERTY_EMAIL, - ADDRESS_PROPERTY_TEXT, - ADDRESS_PROPERTY_BACKGROUND_RGB -}; - - -static void -get_prop (BonoboPropertyBag *bag, BonoboArg *arg, guint arg_id, CORBA_Environment *ev, gpointer user_data) -{ - EAddressWidget *addr = E_ADDRESS_WIDGET (user_data); - - switch (arg_id) { - - case ADDRESS_PROPERTY_NAME: - BONOBO_ARG_SET_STRING (arg, addr->name ? addr->name :""); - break; - - case ADDRESS_PROPERTY_EMAIL: - BONOBO_ARG_SET_STRING (arg, addr->email ? addr->email : ""); - break; - - case ADDRESS_PROPERTY_TEXT: - BONOBO_ARG_SET_STRING (arg, "?"); - break; - } -} - -static void -set_prop (BonoboPropertyBag *bag, const BonoboArg *arg, guint arg_id, CORBA_Environment *ev, gpointer user_data) -{ - EAddressWidget *addr = E_ADDRESS_WIDGET (user_data); - - switch (arg_id) { - case ADDRESS_PROPERTY_NAME: - e_address_widget_set_name (addr, BONOBO_ARG_GET_STRING (arg)); - break; - - case ADDRESS_PROPERTY_EMAIL: - e_address_widget_set_email (addr, BONOBO_ARG_GET_STRING (arg)); - break; - - case ADDRESS_PROPERTY_TEXT: - e_address_widget_set_text (addr, BONOBO_ARG_GET_STRING (arg)); - break; - - - case ADDRESS_PROPERTY_BACKGROUND_RGB: - { - gint bg = BONOBO_ARG_GET_INT (arg); - GdkColor color; - - color.red = (bg & 0xff0000) >> 8; - color.green = (bg & 0x00ff00); - color.blue = (bg & 0x0000ff) << 8; - - if (gdk_colormap_alloc_color (gtk_widget_get_colormap (GTK_WIDGET (addr)), &color, FALSE, TRUE)) { - GtkStyle *style = gtk_style_copy (gtk_widget_get_style (GTK_WIDGET (addr))); - style->bg[0] = color; - gtk_widget_set_style (GTK_WIDGET (addr), style); - } - } - - break; - } -} - -static BonoboControl * -e_address_widget_factory_new_control (void) -{ - BonoboControl *control; - BonoboPropertyBag *bag; - GtkWidget *w; - - w = e_address_widget_new (); - gtk_widget_show (w); - - control = bonobo_control_new (w); - - bag = bonobo_property_bag_new (get_prop, set_prop, w); - bonobo_property_bag_add (bag, "name", ADDRESS_PROPERTY_NAME, - BONOBO_ARG_STRING, NULL, NULL, - BONOBO_PROPERTY_READABLE | BONOBO_PROPERTY_WRITEABLE); - - bonobo_property_bag_add (bag, "email", ADDRESS_PROPERTY_EMAIL, - BONOBO_ARG_STRING, NULL, NULL, - BONOBO_PROPERTY_READABLE | BONOBO_PROPERTY_WRITEABLE); - - bonobo_property_bag_add (bag, "text", ADDRESS_PROPERTY_TEXT, - BONOBO_ARG_STRING, NULL, NULL, - BONOBO_PROPERTY_READABLE | BONOBO_PROPERTY_WRITEABLE); - - bonobo_property_bag_add (bag, "background_rgb", ADDRESS_PROPERTY_BACKGROUND_RGB, - BONOBO_ARG_INT, NULL, NULL, - BONOBO_PROPERTY_WRITEABLE); - - bonobo_control_set_properties (control, bag); - bonobo_object_unref (BONOBO_OBJECT (bag)); - - return control; -} - -static BonoboObject * -e_address_widget_factory (BonoboGenericFactory *factory, gpointer user_data) -{ - return BONOBO_OBJECT (e_address_widget_factory_new_control ()); -} - -void -e_address_widget_factory_init (void) -{ - static BonoboGenericFactory *factory = NULL; - - if (factory != NULL) - return; - - factory = bonobo_generic_factory_new ("OAFIID:GNOME_Evolution_Addressbook_AddressWidgetFactory", - e_address_widget_factory, NULL); - - if (factory == NULL) - g_error ("I could not register an AddressWidget factory."); -} - diff --git a/addressbook/gui/component/e-address-widget.h b/addressbook/gui/component/e-address-widget.h deleted file mode 100644 index 535e51028c..0000000000 --- a/addressbook/gui/component/e-address-widget.h +++ /dev/null @@ -1,102 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * e-address-widget.h - * - * Copyright (C) 2001 Ximian, Inc. - * - * Developed by Jon Trowbridge - */ - -/* - * 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_ADDRESS_WIDGET_H__ -#define __E_ADDRESS_WIDGET_H__ - -#include -#include -#include -#include -#include -#include -#include -#include - -BEGIN_GNOME_DECLS - -#define E_ADDRESS_WIDGET_TYPE (e_address_widget_get_type ()) -#define E_ADDRESS_WIDGET(o) (GTK_CHECK_CAST ((o), E_ADDRESS_WIDGET_TYPE, EAddressWidget)) -#define E_ADDRESS_WIDGET_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), E_ADDRESS_WIDGET_TYPE, EAddressWidgetClass)) -#define E_IS_ADDRESS_WIDGET(o) (GTK_CHECK_TYPE ((o), E_ADDRESS_WIDGET_TYPE)) -#define E_IS_ADDRESS_WIDGET_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), E_ADDRESS_WIDGET_TYPE)) - -typedef struct _EAddressWidget EAddressWidget; -typedef struct _EAddressWidgetClass EAddressWidgetClass; - -struct _EAddressWidget { - GtkEventBox parent; - - gchar *name; - gchar *email; - - GtkWidget *name_widget; - GtkWidget *email_widget; - GtkWidget *spacer; - - guint query_idle_tag; - guint query_tag; - - ECard *card; - gboolean known_email; -}; - -struct _EAddressWidgetClass { - GtkEventBoxClass parent_class; -}; - -GtkType e_address_widget_get_type (void); - -void e_address_widget_set_name (EAddressWidget *, const gchar *name); -void e_address_widget_set_email (EAddressWidget *, const gchar *email); -void e_address_widget_set_text (EAddressWidget *, const gchar *text); - -void e_address_widget_construct (EAddressWidget *); -GtkWidget *e_address_widget_new (void); - - -void e_address_widget_factory_init (void); - - - -END_GNOME_DECLS - -#endif /* __E_ADDRESS_WIDGET_H__ */ - - - - - - - - - - - - - - - diff --git a/addressbook/gui/component/e-cardlist-model.c b/addressbook/gui/component/e-cardlist-model.c deleted file mode 100644 index 5d9b053934..0000000000 --- a/addressbook/gui/component/e-cardlist-model.c +++ /dev/null @@ -1,229 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * - * Author: - * Christopher James Lahey - * - * (C) 1999 Ximian, Inc. - */ - -#include -#include -#include -#include -#include "e-cardlist-model.h" - -#define PARENT_TYPE e_table_model_get_type() - -static void -e_cardlist_model_destroy(GtkObject *object) -{ - ECardlistModel *model = E_CARDLIST_MODEL(object); - int i; - - for ( i = 0; i < model->data_count; i++ ) { - gtk_object_unref(GTK_OBJECT(model->data[i])); - } - g_free(model->data); -} - -/* This function returns the number of columns in our ETableModel. */ -static int -e_cardlist_model_col_count (ETableModel *etc) -{ - return E_CARD_SIMPLE_FIELD_LAST; -} - -/* This function returns the number of rows in our ETableModel. */ -static int -e_cardlist_model_row_count (ETableModel *etc) -{ - ECardlistModel *e_cardlist_model = E_CARDLIST_MODEL(etc); - return e_cardlist_model->data_count; -} - -/* This function returns the value at a particular point in our ETableModel. */ -static void * -e_cardlist_model_value_at (ETableModel *etc, int col, int row) -{ - ECardlistModel *e_cardlist_model = E_CARDLIST_MODEL(etc); - const char *value; - if ( col >= E_CARD_SIMPLE_FIELD_LAST - 1|| row >= e_cardlist_model->data_count ) - return NULL; - value = e_card_simple_get_const(e_cardlist_model->data[row], - col + 1); - return (void *)(value ? value : ""); -} - -/* This function sets the value at a particular point in our ETableModel. */ -static void -e_cardlist_model_set_value_at (ETableModel *etc, int col, int row, const void *val) -{ - ECardlistModel *e_cardlist_model = E_CARDLIST_MODEL(etc); - ECard *card; - if ( col >= E_CARD_SIMPLE_FIELD_LAST - 1|| row >= e_cardlist_model->data_count ) - return; - e_table_model_pre_change(etc); - e_card_simple_set(e_cardlist_model->data[row], - col + 1, - val); - gtk_object_get(GTK_OBJECT(e_cardlist_model->data[row]), - "card", &card, - NULL); - - e_table_model_cell_changed(etc, col, row); -} - -/* This function returns whether a particular cell is editable. */ -static gboolean -e_cardlist_model_is_cell_editable (ETableModel *etc, int col, int row) -{ - return TRUE; -} - -/* This function duplicates the value passed to it. */ -static void * -e_cardlist_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_cardlist_model_free_value (ETableModel *etc, int col, void *value) -{ - g_free(value); -} - -static void * -e_cardlist_model_initialize_value (ETableModel *etc, int col) -{ - return g_strdup(""); -} - -static gboolean -e_cardlist_model_value_is_empty (ETableModel *etc, int col, const void *value) -{ - return !(value && *(char *)value); -} - -static char * -e_cardlist_model_value_to_string (ETableModel *etc, int col, const void *value) -{ - return g_strdup(value); -} - -void -e_cardlist_model_add(ECardlistModel *model, - ECard **cards, - int count) -{ - int i; - model->data = g_realloc(model->data, model->data_count + count * sizeof(ECard *)); - for (i = 0; i < count; i++) { - gboolean found = FALSE; - const gchar *id = e_card_get_id(cards[i]); - for ( i = 0; i < model->data_count; i++) { - if ( !strcmp(e_card_simple_get_id(model->data[i]), id) ) { - found = TRUE; - break; - } - } - if (!found) { - e_table_model_pre_change(E_TABLE_MODEL(model)); - gtk_object_ref(GTK_OBJECT(cards[i])); - model->data[model->data_count++] = e_card_simple_new (cards[i]); - e_table_model_row_inserted(E_TABLE_MODEL(model), model->data_count - 1); - } - } -} - -void -e_cardlist_model_remove(ECardlistModel *model, - const char *id) -{ - int i; - for ( i = 0; i < model->data_count; i++) { - if ( !strcmp(e_card_simple_get_id(model->data[i]), id) ) { - e_table_model_pre_change(E_TABLE_MODEL(model)); - gtk_object_unref(GTK_OBJECT(model->data[i])); - memmove(model->data + i, model->data + i + 1, (model->data_count - i - 1) * sizeof (ECard *)); - e_table_model_row_deleted(E_TABLE_MODEL(model), i); - } - } -} - -static void -e_cardlist_model_class_init (GtkObjectClass *object_class) -{ - ETableModelClass *model_class = (ETableModelClass *) object_class; - - object_class->destroy = e_cardlist_model_destroy; - - model_class->column_count = e_cardlist_model_col_count; - model_class->row_count = e_cardlist_model_row_count; - model_class->value_at = e_cardlist_model_value_at; - model_class->set_value_at = e_cardlist_model_set_value_at; - model_class->is_cell_editable = e_cardlist_model_is_cell_editable; - model_class->duplicate_value = e_cardlist_model_duplicate_value; - model_class->free_value = e_cardlist_model_free_value; - model_class->initialize_value = e_cardlist_model_initialize_value; - model_class->value_is_empty = e_cardlist_model_value_is_empty; - model_class->value_to_string = e_cardlist_model_value_to_string; -} - -static void -e_cardlist_model_init (GtkObject *object) -{ - ECardlistModel *model = E_CARDLIST_MODEL(object); - model->data = NULL; - model->data_count = 0; -} - -ECard * -e_cardlist_model_get(ECardlistModel *model, - int row) -{ - if (model->data && row < model->data_count) { - ECard *card; - gtk_object_get(GTK_OBJECT(model->data[row]), - "card", &card, - NULL); - gtk_object_ref(GTK_OBJECT(card)); - return card; - } - return NULL; -} - -GtkType -e_cardlist_model_get_type (void) -{ - static GtkType type = 0; - - if (!type){ - GtkTypeInfo info = { - "ECardlistModel", - sizeof (ECardlistModel), - sizeof (ECardlistModelClass), - (GtkClassInitFunc) e_cardlist_model_class_init, - (GtkObjectInitFunc) e_cardlist_model_init, - NULL, /* reserved 1 */ - NULL, /* reserved 2 */ - (GtkClassInitFunc) NULL - }; - - type = gtk_type_unique (PARENT_TYPE, &info); - } - - return type; -} - -ETableModel * -e_cardlist_model_new (void) -{ - ECardlistModel *et; - - et = gtk_type_new (e_cardlist_model_get_type ()); - - return E_TABLE_MODEL(et); -} diff --git a/addressbook/gui/component/e-cardlist-model.h b/addressbook/gui/component/e-cardlist-model.h deleted file mode 100644 index 0b9a7a2265..0000000000 --- a/addressbook/gui/component/e-cardlist-model.h +++ /dev/null @@ -1,42 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -#ifndef _E_CARDLIST_MODEL_H_ -#define _E_CARDLIST_MODEL_H_ - -#include -#include -#include -#include - -#define E_CARDLIST_MODEL_TYPE (e_cardlist_model_get_type ()) -#define E_CARDLIST_MODEL(o) (GTK_CHECK_CAST ((o), E_CARDLIST_MODEL_TYPE, ECardlistModel)) -#define E_CARDLIST_MODEL_CLASS(k) (GTK_CHECK_CLASS_CAST((k), E_CARDLIST_MODEL_TYPE, ECardlistModelClass)) -#define E_IS_CARDLIST_MODEL(o) (GTK_CHECK_TYPE ((o), E_CARDLIST_MODEL_TYPE)) -#define E_IS_CARDLIST_MODEL_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), E_CARDLIST_MODEL_TYPE)) - -typedef struct { - ETableModel parent; - - /* item specific fields */ - ECardSimple **data; - int data_count; -} ECardlistModel; - - -typedef struct { - ETableModelClass parent_class; -} ECardlistModelClass; - - -GtkType e_cardlist_model_get_type (void); -ETableModel *e_cardlist_model_new (void); - -/* Returns object with an extra ref count. */ -ECard *e_cardlist_model_get (ECardlistModel *model, - int row); -void e_cardlist_model_add (ECardlistModel *model, - ECard **card, - int count); -void e_cardlist_model_remove (ECardlistModel *model, - const char *id); - -#endif /* _E_CARDLIST_MODEL_H_ */ diff --git a/addressbook/gui/component/select-names/.cvsignore b/addressbook/gui/component/select-names/.cvsignore deleted file mode 100644 index cd669499fa..0000000000 --- a/addressbook/gui/component/select-names/.cvsignore +++ /dev/null @@ -1,12 +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.oaf 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 244799deb2..0000000000 --- a/addressbook/gui/component/select-names/Evolution-Addressbook-SelectNames.idl +++ /dev/null @@ -1,42 +0,0 @@ -/* -*- Mode: IDL; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * CORBA interface for the SelectNames dialog. - * - * Authors: - * Ettore Perazzoli - * - * Copyright (C) 2000 Ximian, Inc. - */ - -#include - -module GNOME { -module Evolution { -module Addressbook { - - interface SelectNames : Bonobo::Unknown { - struct Section { - string id; - string title; - }; - - typedef sequence
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.oaf.in b/addressbook/gui/component/select-names/GNOME_Evolution_Addressbook_SelectNames.oaf.in deleted file mode 100644 index 7f26e2aaed..0000000000 --- a/addressbook/gui/component/select-names/GNOME_Evolution_Addressbook_SelectNames.oaf.in +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/addressbook/gui/component/select-names/Makefile.am b/addressbook/gui/component/select-names/Makefile.am deleted file mode 100644 index 6c3ed1674e..0000000000 --- a/addressbook/gui/component/select-names/Makefile.am +++ /dev/null @@ -1,85 +0,0 @@ -# CORBA stuff - -IDLS = \ - Evolution-Addressbook-SelectNames.idl - -IDL_GENERATED = \ - Evolution-Addressbook-SelectNames.h \ - Evolution-Addressbook-SelectNames-common.c \ - Evolution-Addressbook-SelectNames-skels.c \ - Evolution-Addressbook-SelectNames-stubs.c - -Evolution-Addressbook-SelectNames-impl.o: Evolution-Addressbook-SelectNames.h - -$(IDL_GENERATED): $(IDLS) - $(ORBIT_IDL) -I $(srcdir) -I $(datadir)/idl `$(GNOME_CONFIG) --cflags idl` \ - $(srcdir)/Evolution-Addressbook-SelectNames.idl - -oafdir = $(datadir)/oaf - -oaf_in_files = GNOME_Evolution_Addressbook_SelectNames.oaf.in -oaf_DATA = $(oaf_in_files:.oaf.in=.oaf) - -@XML_I18N_MERGE_OAF_RULE@ - - -INCLUDES = \ - -DG_LOG_DOMAIN=\"evolution-addressbook\" \ - $(EXTRA_GNOME_CFLAGS) \ - $(GNOME_INCLUDEDIR) \ - -I$(top_srcdir) \ - -I$(top_builddir) \ - -I$(top_srcdir)/shell \ - -I$(top_builddir)/shell \ - -I$(top_srcdir)/widgets/e-text \ - -I$(top_srcdir)/widgets/e-table \ - -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 \ - $(BONOBO_HTML_GNOME_CFLAGS) \ - -DEVOLUTION_GLADEDIR=\""$(gladedir)"\" \ - -DEVOLUTION_ICONSDIR=\""$(iconsdir)"\" \ - -DEVOLUTION_LOCALEDIR=\""$(localedir)"\" \ - -DCAMEL_PROVIDERDIR=\""$(providerdir)"\" - -lib_LTLIBRARIES = libeselectnames.la - -libeselectnames_la_SOURCES = \ - $(IDL_GENERATED) \ - e-select-names-bonobo.c \ - e-select-names-bonobo.h \ - e-select-names-completion.c \ - e-select-names-completion.h \ - e-select-names-factory.c \ - e-select-names-factory.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 - -gladedir = $(datadir)/evolution/glade -glade_DATA = select-names.glade - - - -EXTRA_DIST = \ - $(glade_DATA) \ - $(oaf_in_files) \ - $(oaf_DATA) \ - $(IDLS) - -BUILT_SOURCES = $(IDL_GENERATED) -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 55ef3ec89a..0000000000 --- a/addressbook/gui/component/select-names/e-select-names-bonobo.c +++ /dev/null @@ -1,465 +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 -#endif - -#include "e-select-names-bonobo.h" - -#include -#include -#include - -#include -#include - -#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" - - - -#define PARENT_TYPE bonobo_object_get_type () -static BonoboObjectClass *parent_class = NULL; - -struct _ESelectNamesBonoboPrivate { - ESelectNamesManager *manager; - BonoboEventSource *event_source; -}; - -enum _EntryPropertyID { - ENTRY_PROPERTY_ID_TEXT, - 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: - { - ESelectNamesModel *model; - model = E_SELECT_NAMES_MODEL (gtk_object_get_data (GTK_OBJECT (w), "select_names_model")); - g_assert (model != NULL); - - BONOBO_ARG_SET_STRING (arg, e_select_names_model_get_textification (model)); - break; - } - - case ENTRY_PROPERTY_ID_DESTINATIONS: - { - ESelectNamesModel *model; - char *text; - - model = E_SELECT_NAMES_MODEL (gtk_object_get_data (GTK_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 (gtk_object_get_data (GTK_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: - { - ESelectNamesModel *model; - model = E_SELECT_NAMES_MODEL (gtk_object_get_data (GTK_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_cardify_all (model, NULL, 0); - break; - } - - case ENTRY_PROPERTY_ID_DESTINATIONS: - { - ESelectNamesModel *model; - model = E_SELECT_NAMES_MODEL (gtk_object_get_data (GTK_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_cardify_all (model, NULL, 0); - break; - } - - case ENTRY_PROPERTY_ID_ALLOW_CONTACT_LISTS: - { - ESelectNamesCompletion *comp; - comp = E_SELECT_NAMES_COMPLETION (gtk_object_get_data (GTK_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: - gtk_object_set_data (GTK_OBJECT (w), "entry_property_id_changed", GUINT_TO_POINTER (1)); - break; - - default: - break; - } -} - - -/* CORBA interface implementation. */ - -static POA_GNOME_Evolution_Addressbook_SelectNames__vepv SelectNames_vepv; - -static POA_GNOME_Evolution_Addressbook_SelectNames * -create_servant (void) -{ - POA_GNOME_Evolution_Addressbook_SelectNames *servant; - CORBA_Environment ev; - - servant = (POA_GNOME_Evolution_Addressbook_SelectNames *) g_new0 (BonoboObjectServant, 1); - servant->vepv = &SelectNames_vepv; - - CORBA_exception_init (&ev); - - POA_GNOME_Evolution_Addressbook_SelectNames__init ((PortableServer_Servant) servant, &ev); - if (ev._major != CORBA_NO_EXCEPTION) { - g_free (servant); - CORBA_exception_free (&ev); - return NULL; - } - - CORBA_exception_free (&ev); - - return servant; -} - -static void -impl_SelectNames_add_section (PortableServer_Servant servant, - const CORBA_char *id, - const CORBA_char *title, - CORBA_Environment *ev) -{ - BonoboObject *bonobo_object; - ESelectNamesBonobo *select_names; - ESelectNamesBonoboPrivate *priv; - - bonobo_object = bonobo_object_from_servant (servant); - select_names = E_SELECT_NAMES_BONOBO (bonobo_object); - 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) -{ - BonoboObject *bonobo_object; - ESelectNamesBonobo *select_names; - ESelectNamesBonoboPrivate *priv; - - bonobo_object = bonobo_object_from_servant (servant); - select_names = E_SELECT_NAMES_BONOBO (bonobo_object); - 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 (gtk_object_get_data (GTK_OBJECT (widget), "entry_property_id_changed")); - - if (!changed) - bonobo_control_set_property (control, "entry_changed", 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 Bonobo_Control -impl_SelectNames_get_entry_for_section (PortableServer_Servant servant, - const CORBA_char *section_id, - CORBA_Environment *ev) -{ - BonoboObject *bonobo_object; - ESelectNamesBonobo *select_names; - ESelectNamesBonoboPrivate *priv; - GtkWidget *entry_widget; - BonoboControl *control; - BonoboPropertyBag *property_bag; - - bonobo_object = bonobo_object_from_servant (servant); - select_names = E_SELECT_NAMES_BONOBO (bonobo_object); - 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, "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, property_bag); - - gtk_signal_connect (GTK_OBJECT (entry_widget), "changed", GTK_SIGNAL_FUNC (entry_changed), control); - - 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) -{ - BonoboObject *bonobo_object; - ESelectNamesBonobo *select_names; - ESelectNamesBonoboPrivate *priv; - - bonobo_object = bonobo_object_from_servant (servant); - select_names = E_SELECT_NAMES_BONOBO (bonobo_object); - priv = select_names->priv; - - e_select_names_manager_activate_dialog (priv->manager, section_id); -} - - -/* GtkObject methods. */ - -static void -impl_destroy (GtkObject *object) -{ - ESelectNamesBonobo *select_names; - ESelectNamesBonoboPrivate *priv; - - select_names = E_SELECT_NAMES_BONOBO (object); - priv = select_names->priv; - - if (priv->manager->names) { - gtk_widget_destroy (GTK_WIDGET (priv->manager->names)); - priv->manager->names = NULL; - } - - gtk_object_unref (GTK_OBJECT (priv->manager)); - - g_free (priv); -} - - -static void -corba_class_init () -{ - POA_GNOME_Evolution_Addressbook_SelectNames__vepv *vepv; - POA_GNOME_Evolution_Addressbook_SelectNames__epv *epv; - PortableServer_ServantBase__epv *base_epv; - - base_epv = g_new0 (PortableServer_ServantBase__epv, 1); - base_epv->_private = NULL; - base_epv->finalize = NULL; - base_epv->default_POA = NULL; - - epv = g_new0 (POA_GNOME_Evolution_Addressbook_SelectNames__epv, 1); - 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; - - vepv = &SelectNames_vepv; - vepv->Bonobo_Unknown_epv = bonobo_object_get_epv (); - vepv->GNOME_Evolution_Addressbook_SelectNames_epv = epv; -} - -static void -class_init (ESelectNamesBonoboClass *klass) -{ - GtkObjectClass *object_class; - - object_class = GTK_OBJECT_CLASS (klass); - parent_class = gtk_type_class (bonobo_object_get_type ()); - - object_class->destroy = impl_destroy; - - corba_class_init (); -} - -static void -init (ESelectNamesBonobo *select_names) -{ - ESelectNamesBonoboPrivate *priv; - - priv = g_new (ESelectNamesBonoboPrivate, 1); - - priv->manager = e_select_names_manager_new (); - priv->event_source = NULL; - - gtk_signal_connect (GTK_OBJECT (priv->manager), - "changed", - GTK_SIGNAL_FUNC (manager_changed_cb), - select_names); - - gtk_signal_connect (GTK_OBJECT (priv->manager), - "ok", - GTK_SIGNAL_FUNC (manager_ok_cb), - select_names); - - select_names->priv = priv; -} - - -void -e_select_names_bonobo_construct (ESelectNamesBonobo *select_names, - GNOME_Evolution_Addressbook_SelectNames corba_object) -{ - g_return_if_fail (select_names != NULL); - g_return_if_fail (E_IS_SELECT_NAMES_BONOBO (select_names)); - - bonobo_object_construct (BONOBO_OBJECT (select_names), corba_object); - - 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) -{ - POA_GNOME_Evolution_Addressbook_SelectNames *servant; - GNOME_Evolution_Addressbook_SelectNames corba_object; - ESelectNamesBonobo *select_names; - - servant = create_servant (); - if (servant == NULL) - return NULL; - - select_names = gtk_type_new (e_select_names_bonobo_get_type ()); - - corba_object = bonobo_object_activate_servant (BONOBO_OBJECT (select_names), servant); - e_select_names_bonobo_construct (select_names, corba_object); - - return select_names; -} - - -E_MAKE_TYPE (e_select_names_bonobo, "ESelectNamesBonobo", ESelectNamesBonobo, class_init, init, PARENT_TYPE) 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 f254dd6e94..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 - -#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) (GTK_CHECK_CAST ((obj), E_TYPE_SELECT_NAMES_BONOBO, ESelectNamesBonobo)) -#define E_SELECT_NAMES_BONOBO_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_TYPE_SELECT_NAMES_BONOBO, ESelectNamesBonoboClass)) -#define E_IS_SELECT_NAMES_BONOBO(obj) (GTK_CHECK_TYPE ((obj), E_TYPE_SELECT_NAMES_BONOBO)) -#define E_IS_SELECT_NAMES_BONOBO_CLASS(klass) (GTK_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; -}; - - -GtkType e_select_names_bonobo_get_type (void); -void e_select_names_bonobo_construct (ESelectNamesBonobo *select_names, - GNOME_Evolution_Addressbook_SelectNames corba_object); -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 8e7843f149..0000000000 --- a/addressbook/gui/component/select-names/e-select-names-completion.c +++ /dev/null @@ -1,1283 +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 - */ - -/* - * 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 -#include "e-select-names-completion.h" - -#include -#include -#include -#include - -#include -#include -#include - -#include - -#include -#include -#include -#include - -typedef struct { - EBook *book; - guint book_view_tag; - EBookView *book_view; - ESelectNamesCompletion *comp; - guint card_added_tag; - guint seq_complete_tag; - gboolean sequence_complete_received; -} ESelectNamesCompletionBookData; - -struct _ESelectNamesCompletionPrivate { - - ESelectNamesModel *model; - - GList *book_data; - gint books_not_ready; - gint pending_completion_seq; - - gchar *waiting_query; - gint waiting_pos, waiting_limit; - gchar *query_text; - - gchar *cached_query_text; - GList *cached_cards; - - gboolean match_contact_lists; - gboolean primary_only; - - gboolean can_fail_due_to_too_many_hits; /* like LDAP, for example... */ -}; - -static void e_select_names_completion_class_init (ESelectNamesCompletionClass *); -static void e_select_names_completion_init (ESelectNamesCompletion *); -static void e_select_names_completion_destroy (GtkObject *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_card_added_cb (EBookView *, const GList *cards, gpointer user_data); -static void e_select_names_completion_seq_complete_cb (EBookView *, 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 GtkObjectClass *parent_class; - -static FILE *out; - -/* - * - * Query builders - * - */ - -typedef gchar *(*BookQuerySExp) (ESelectNamesCompletion *); -typedef ECompletionMatch *(*BookQueryMatchTester) (ESelectNamesCompletion *, EDestination *); - -static void -our_match_destroy (ECompletionMatch *match) -{ - gtk_object_unref (GTK_OBJECT (match->user_data)); -} - -static ECompletionMatch * -make_match (EDestination *dest, const gchar *menu_form, double score) -{ - ECompletionMatch *match; - ECard *card = e_destination_get_card (dest); - - 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))) { - gtk_object_unref (GTK_OBJECT (match)); - return NULL; - } - - /* Since we sort low to high, we negate so that larger use scores will come first */ - match->sort_major = card ? -floor (e_card_get_use_score (card)) : 0; - - match->sort_minor = e_destination_get_email_num (dest); - - match->user_data = dest; - gtk_object_ref (GTK_OBJECT (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; - ECard *card = e_destination_get_card (dest); - double score; - - if (card->nickname == NULL) - return NULL; - - len = g_utf8_strlen (comp->priv->query_text, -1); - if (card->nickname && !g_utf8_strncasecmp (comp->priv->query_text, card->nickname, len)) { - const gchar *name; - gchar *str; - - score = len * 2; /* nickname gives 2 points per matching character */ - - if (len == g_utf8_strlen (card->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>", card->nickname, name, e_destination_get_email (dest)); - else - str = g_strdup_printf ("'%s' <%s>", card->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 - && !g_utf8_strncasecmp (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, count=0; - - for (c = cpy; *c; ++c) { - if (*c == ',') - *c = ' '; - } - - strv = g_strsplit (cpy, " ", 0); - for (i=0; strv[i]; ++i) { - gchar *old; - ++count; - g_strstrip (strv[i]); - old = strv[i]; - strv[i] = g_strdup_printf ("(contains \"%s\" \"%s\")", field, old); - g_free (old); - } - - if (count == 1) { - query = strv[0]; - strv[0] = NULL; - } else { - gchar *joined = g_strjoinv (" ", strv); - query = g_strdup_printf ("(and %s)", joined); - g_free (joined); - } - - 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; - ECard *card; - const gchar *email; - gint match_len = 0; - ECardMatchType match; - ECardMatchPart first_match; - double score = 0; - gboolean have_given, have_additional, have_family; - - card = e_destination_get_card (dest); - - if (card->name == NULL) - return NULL; - - email = e_destination_get_email (dest); - - match = e_card_compare_name_to_string_full (card, comp->priv->query_text, TRUE /* yes, allow partial matches */, - NULL, &first_match, &match_len); - - if (match <= E_CARD_MATCH_NONE) - return NULL; - - score = match_len * 3; /* three points per match character */ - -#if 0 - if (card->nickname) { - /* We massively boost the score if the nickname exists and is the same as one of the "real" names. This keeps the - nickname from matching ahead of the real name for this card. */ - len = strlen (card->nickname); - if ((card->name->given && !g_utf8_strncasecmp (card->name->given, card->nickname, MIN (strlen (card->name->given), len))) - || (card->name->family && !g_utf8_strncasecmp (card->name->family, card->nickname, MIN (strlen (card->name->family), len))) - || (card->name->additional && !g_utf8_strncasecmp (card->name->additional, card->nickname, MIN (strlen (card->name->additional), len)))) - score *= 100; - } -#endif - - have_given = card->name->given && *card->name->given; - have_additional = card->name->additional && *card->name->additional; - have_family = card->name->family && *card->name->family; - - if (e_card_evolution_list (card)) { - - menu_text = e_card_name_to_string (card->name); - - } else if (first_match == E_CARD_MATCH_PART_GIVEN_NAME) { - - if (have_family) - menu_text = g_strdup_printf ("%s %s <%s>", card->name->given, card->name->family, email); - else - menu_text = g_strdup_printf ("%s <%s>", card->name->given, email); - - } else if (first_match == E_CARD_MATCH_PART_ADDITIONAL_NAME) { - - if (have_given) { - - menu_text = g_strdup_printf ("%s%s%s, %s <%s>", - card->name->additional, - have_family ? " " : "", - have_family ? card->name->family : "", - card->name->given, - email); - } else { - - menu_text = g_strdup_printf ("%s%s%s <%s>", - card->name->additional, - have_family ? " " : "", - have_family ? card->name->family : "", - email); - } - - } else if (first_match == E_CARD_MATCH_PART_FAMILY_NAME) { - - if (have_given) - menu_text = g_strdup_printf ("%s, %s%s%s <%s>", - card->name->family, - card->name->given, - have_additional ? " " : "", - have_additional ? card->name->additional : "", - email); - else - menu_text = g_strdup_printf ("%s <%s>", card->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); - } - - 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 (!g_utf8_strncasecmp (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; -} - -/* - * Initials Query - */ - -static gchar * -sexp_initials (ESelectNamesCompletion *comp) -{ - return NULL; -} - -static ECompletionMatch * -match_initials (ESelectNamesCompletion *comp, EDestination *dest) -{ - return NULL; -} - - -typedef struct _BookQuery BookQuery; -struct _BookQuery { - gboolean primary; - BookQuerySExp builder; - BookQueryMatchTester tester; -}; - -static BookQuery book_queries[] = { - { TRUE, sexp_nickname, match_nickname}, - { TRUE, sexp_email, match_email }, - { TRUE, sexp_name, match_name }, - { TRUE, sexp_file_as, match_file_as }, - { FALSE, sexp_initials, match_initials } -}; -static gint book_query_count = sizeof (book_queries) / sizeof (BookQuery); - -/* - * Build up a big compound sexp corresponding to all of our queries. - */ -static gchar * -book_query_sexp (ESelectNamesCompletion *comp) -{ - gint i, j, count = 0; - gchar **queryv, *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; - - if (comp->priv->primary_only) { - for (i=0; ipriv->query_text && *comp->priv->query_text)) - return NULL; - - for (i=0; ipriv->primary_only) { - if (book_queries[i].tester && e_destination_get_card (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 *cards) -{ - while (cards) { - ECard *card = E_CARD (cards->data); - - if (e_card_evolution_list (card)) { - - if (comp->priv->match_contact_lists) { - - EDestination *dest = e_destination_new (); - ECompletionMatch *match; - e_destination_set_card (dest, card, 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); - } - gtk_object_unref (GTK_OBJECT (dest)); - - } - - } else if (card->email) { - gint i; - for (i=0; iemail); ++i) { - EDestination *dest = e_destination_new (); - const gchar *email; - ECompletionMatch *match; - - e_destination_set_card (dest, card, i); - email = e_destination_get_email (dest); - - if (email && *email) { - - 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); - } - } - - gtk_object_unref (GTK_OBJECT (dest)); - } - } - - cards = g_list_next (cards); - } -} - -#if 0 -static gchar * -initials_query_match_cb (QueryInfo *qi, ECard *card, double *score) -{ - gint len; - gchar f='\0', m='\0', l='\0'; /* initials */ - gchar cf, cm, cl; - - len = strlen (qi->comp->priv->query_text); - - if (len == 2) { - - f = qi->comp->priv->query_text[0]; - m = '\0'; - l = qi->comp->priv->query_text[1]; - - } else if (len == 3) { - - f = qi->comp->priv->query_text[0]; - m = qi->comp->priv->query_text[1]; - l = qi->comp->priv->query_text[2]; - - } else { - return NULL; - } - - cf = card->name->given ? *card->name->given : '\0'; - cm = card->name->additional ? *card->name->additional : '\0'; - cl = card->name->family ? *card->name->family : '\0'; - - if (f && isupper ((gint) f)) - f = tolower ((gint) f); - if (m && isupper ((gint) m)) - m = tolower ((gint) m); - if (l && isupper ((gint) l)) - l = tolower ((gint) l); - - if (cf && isupper ((gint) cf)) - cf = tolower ((gint) cf); - if (cm && isupper ((gint) cm)) - cm = tolower ((gint) cm); - if (cl && isupper ((gint) cl)) - cl = tolower ((gint) cl); - - if ((f == '\0' || (f == cf)) && (m == '\0' || (m == cm)) && (l == '\0' || (l == cl))) { - if (score) - *score = 3; - if (m) - return g_strdup_printf ("%s %s %s", card->name->given, card->name->additional, card->name->family); - else - return g_strdup_printf ("%s %s", card->name->given, card->name->family); - } - - return NULL; -} - -static gboolean -start_initials_query (ESelectNamesCompletion *comp) -{ - gint len; - gchar *query; - - if (comp && comp->priv->query_text && *(comp->priv->query_text)) { - - len = strlen (comp->priv->query_text); - if (len < 2 || len > 3) - return FALSE; - - query = g_strdup_printf ("(contains \"x-evolution-any-field\" \"%c\")", *(comp->priv->query_text)); - query_info_start (comp, comp->priv->query_text, query, initials_query_match_cb); - g_free (query); - return TRUE; - } - - return FALSE; -} -#endif - - -/* - * - * ESelectNamesCompletion code - * - */ - - -GtkType -e_select_names_completion_get_type (void) -{ - static GtkType select_names_complete_type = 0; - - if (!select_names_complete_type) { - GtkTypeInfo select_names_complete_info = { - "ESelectNamesCompletion", - sizeof (ESelectNamesCompletion), - sizeof (ESelectNamesCompletionClass), - (GtkClassInitFunc) e_select_names_completion_class_init, - (GtkObjectInitFunc) e_select_names_completion_init, - NULL, NULL, /* reserved */ - (GtkClassInitFunc) NULL - }; - - select_names_complete_type = gtk_type_unique (e_completion_get_type (), &select_names_complete_info); - } - - return select_names_complete_type; -} - -static void -e_select_names_completion_class_init (ESelectNamesCompletionClass *klass) -{ - GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass); - ECompletionClass *completion_class = E_COMPLETION_CLASS (klass); - - parent_class = GTK_OBJECT_CLASS (gtk_type_class (e_completion_get_type ())); - - object_class->destroy = e_select_names_completion_destroy; - - 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_destroy (GtkObject *object) -{ - ESelectNamesCompletion *comp = E_SELECT_NAMES_COMPLETION (object); - GList *l; - - if (comp->priv->model) - gtk_object_unref (GTK_OBJECT (comp->priv->model)); - - for (l = comp->priv->book_data; l; l = l->next) { - ESelectNamesCompletionBookData *book_data = l->data; - - if (book_data->card_added_tag) { - gtk_signal_disconnect (GTK_OBJECT (book_data->book_view), book_data->card_added_tag); - book_data->card_added_tag = 0; - } - - if (book_data->seq_complete_tag) { - gtk_signal_disconnect (GTK_OBJECT (book_data->book_view), book_data->seq_complete_tag); - book_data->seq_complete_tag = 0; - } - - gtk_object_unref (GTK_OBJECT (book_data->book)); - - if (book_data->book_view) - gtk_object_unref (GTK_OBJECT (book_data->book_view)); - - g_free (book_data); - } - g_list_free (comp->priv->book_data); - - g_free (comp->priv->waiting_query); - g_free (comp->priv->query_text); - - g_free (comp->priv->cached_query_text); - g_list_foreach (comp->priv->cached_cards, (GFunc)gtk_object_unref, NULL); - g_list_free (comp->priv->cached_cards); - - g_free (comp->priv); - - if (parent_class->destroy) - parent_class->destroy (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 (ESelectNamesCompletion *comp) -{ - g_free (comp->priv->cached_query_text); - comp->priv->cached_query_text = NULL; - - g_list_foreach (comp->priv->cached_cards, (GFunc)gtk_object_unref, NULL); - g_list_free (comp->priv->cached_cards); - comp->priv->cached_cards = NULL; -} - -static void -e_select_names_completion_got_book_view_cb (EBook *book, EBookStatus status, EBookView *view, gpointer user_data) -{ - ESelectNamesCompletion *comp; - ESelectNamesCompletionBookData *book_data; - - if (status != E_BOOK_STATUS_SUCCESS) - return; - - book_data = (ESelectNamesCompletionBookData*)user_data; - comp = book_data->comp; - - book_data->book_view_tag = 0; - - if (book_data->card_added_tag) { - gtk_signal_disconnect (GTK_OBJECT (book_data->book_view), book_data->card_added_tag); - book_data->card_added_tag = 0; - } - if (book_data->seq_complete_tag) { - gtk_signal_disconnect (GTK_OBJECT (book_data->book_view), book_data->seq_complete_tag); - book_data->seq_complete_tag = 0; - } - - gtk_object_ref (GTK_OBJECT (view)); - if (book_data->book_view) - gtk_object_unref (GTK_OBJECT (book_data->book_view)); - book_data->book_view = view; - - book_data->card_added_tag = - gtk_signal_connect (GTK_OBJECT (view), - "card_added", - GTK_SIGNAL_FUNC (e_select_names_completion_card_added_cb), - book_data); - - book_data->seq_complete_tag = - gtk_signal_connect (GTK_OBJECT (view), - "sequence_complete", - GTK_SIGNAL_FUNC (e_select_names_completion_seq_complete_cb), - book_data); - book_data->sequence_complete_received = FALSE; - comp->priv->pending_completion_seq++; -} - -static void -e_select_names_completion_card_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) { - comp->priv->cached_cards = g_list_prepend (comp->priv->cached_cards, cards->data); - gtk_object_ref (GTK_OBJECT (cards->data)); - cards = g_list_next (cards); - } - } -} - -static void -e_select_names_completion_seq_complete_cb (EBookView *book_view, gpointer user_data) -{ - ESelectNamesCompletionBookData *book_data = user_data; - ESelectNamesCompletion *comp = E_SELECT_NAMES_COMPLETION(book_data->comp); - - /* - * 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))) { - e_select_names_completion_clear_cache (comp); - return; - } - - if (!book_data->sequence_complete_received) { - book_data->sequence_complete_received = TRUE; - comp->priv->pending_completion_seq --; - if (comp->priv->pending_completion_seq > 0) - return; - } - - g_free (comp->priv->query_text); - comp->priv->query_text = NULL; - - if (out) - fprintf (out, "ending search\n"); - - 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_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) { - if (out) - fprintf (out, "cancelled book view creation\n"); - e_book_cancel (book_data->book, book_data->book_view_tag); - book_data->book_view_tag = 0; - } - if (book_data->book_view) { - if (out) - fprintf (out, "disconnecting book view signals\n"); - - if (book_data->card_added_tag) { - gtk_signal_disconnect (GTK_OBJECT (book_data->book_view), book_data->card_added_tag); - book_data->card_added_tag = 0; - } - if (book_data->seq_complete_tag) { - gtk_signal_disconnect (GTK_OBJECT (book_data->book_view), book_data->seq_complete_tag); - book_data->seq_complete_tag = 0; - } - - if (out) - fprintf (out, "unrefed book view\n"); - gtk_object_unref (GTK_OBJECT (book_data->book_view)); - book_data->book_view = NULL; - } - } - - /* Clear the cache, which may contain partial results. */ - e_select_names_completion_clear_cache (comp); - -} - -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) { - gchar *sexp; - - g_free (comp->priv->query_text); - comp->priv->query_text = g_strdup (query_text); - - g_free (comp->priv->cached_query_text); - comp->priv->cached_query_text = g_strdup (query_text); - - sexp = book_query_sexp (comp); - if (sexp && *sexp) { - 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; - book_data->book_view_tag = e_book_get_book_view (book_data->book, sexp, - e_select_names_completion_got_book_view_cb, book_data); - if (! book_data->book_view_tag) - g_warning ("Exception calling e_book_get_book_view"); - } - - } else { - g_free (comp->priv->query_text); - comp->priv->query_text = NULL; - } - g_free (sexp); - - } else { - - 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; - gboolean query_is_still_running, can_reuse_cached_cards; - GList *l; - - 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; - } - - query_is_still_running = FALSE; - for (l = comp->priv->book_data; l; l = l->next) { - ESelectNamesCompletionBookData *book_data = l->data; - query_is_still_running = book_data->book_view_tag; - if (query_is_still_running) - break; - } - - if (out) { - fprintf (out, "do_query: %s => %s\n", query_text, clean); - if (query_is_still_running) - fprintf (out, "a query is still running!\n"); - } - if (comp->priv->cached_query_text && out) - fprintf (out, "cached: %s\n", comp->priv->cached_query_text); - - can_reuse_cached_cards = (comp->priv->cached_query_text - && (!comp->priv->can_fail_due_to_too_many_hits || comp->priv->cached_cards != NULL) - && (strlen (comp->priv->cached_query_text) <= strlen (clean)) - && !g_utf8_strncasecmp (comp->priv->cached_query_text, clean, strlen (comp->priv->cached_query_text))); - - - if (can_reuse_cached_cards) { - - if (out) - fprintf (out, "can reuse cached card!\n"); - - if (query_is_still_running) { - g_free (comp->priv->waiting_query); - comp->priv->waiting_query = clean; - comp->priv->waiting_pos = pos; - comp->priv->waiting_limit = limit; - if (out) - fprintf (out, "waiting for running query to complete: %s\n", comp->priv->waiting_query); - return; - } - - g_free (comp->priv->query_text); - comp->priv->query_text = clean; - if (out) - fprintf (out, "using existing query info: %s (vs %s)\n", comp->priv->query_text, comp->priv->cached_query_text); - book_query_process_card_list (comp, comp->priv->cached_cards); - e_completion_end_search (E_COMPLETION (comp)); - return; - } - - 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 !g_utf8_strcasecmp (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->model, pos, &index, NULL, NULL); - str = index >= 0 ? e_select_names_model_get_string (selcomp->priv->model, 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"); -} - -static void -check_capabilities (ESelectNamesCompletion *comp, EBook *book) -{ - gchar *cap = e_book_get_static_capabilities (book); - comp->priv->can_fail_due_to_too_many_hits = !strcmp (cap, "net"); - if (comp->priv->can_fail_due_to_too_many_hits) { - g_message ("using LDAP source for completion!"); - } - g_free (cap); -} - -static void -e_select_names_completion_book_ready (EBook *book, EBookStatus status, ESelectNamesCompletion *comp) -{ - comp->priv->books_not_ready--; - - g_return_if_fail (E_IS_BOOK (book)); - g_return_if_fail (E_IS_SELECT_NAMES_COMPLETION (comp)); - - check_capabilities (comp, book); - - /* If waiting_query is non-NULL, someone tried to start a query before the book was ready. - Now that it is, get started. */ - if (comp->priv->books_not_ready == 0 && comp->priv->waiting_query) { - e_select_names_completion_start_query (comp, comp->priv->waiting_query); - g_free (comp->priv->waiting_query); - comp->priv->waiting_query = NULL; - } - - gtk_object_unref (GTK_OBJECT (comp)); /* post-async unref */ -} - - -/* - * - * Our Pseudo-Constructor - * - */ - -ECompletion * -e_select_names_completion_new (EBook *book, ESelectNamesModel *model) -{ - ESelectNamesCompletion *comp; - - g_return_val_if_fail (book == NULL || E_IS_BOOK (book), NULL); - g_return_val_if_fail (model, NULL); - g_return_val_if_fail (E_IS_SELECT_NAMES_MODEL (model), NULL); - - comp = (ESelectNamesCompletion *) gtk_type_new (e_select_names_completion_get_type ()); - - if (book == NULL) { - ESelectNamesCompletionBookData *book_data = g_new0 (ESelectNamesCompletionBookData, 1); - - book_data->book = e_book_new (); - book_data->comp = comp; - gtk_object_ref (GTK_OBJECT (book_data->book)); - gtk_object_sink (GTK_OBJECT (book_data->book)); - - comp->priv->book_data = g_list_append (comp->priv->book_data, book_data); - comp->priv->books_not_ready++; - - gtk_object_ref (GTK_OBJECT (comp)); /* ref ourself before our async call */ - e_book_load_local_address_book (book_data->book, (EBookCallback) e_select_names_completion_book_ready, comp); - - } else { - e_select_names_completion_add_book (comp, book); - } - - comp->priv->model = model; - gtk_object_ref (GTK_OBJECT (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; - check_capabilities (comp, book); - gtk_object_ref (GTK_OBJECT (book_data->book)); - comp->priv->book_data = g_list_append (comp->priv->book_data, book_data); -} - -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 03a30c3cc2..0000000000 --- a/addressbook/gui/component/select-names/e-select-names-completion.h +++ /dev/null @@ -1,67 +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 - */ - -/* - * 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 -#include -#include "e-select-names-model.h" - -BEGIN_GNOME_DECLS - -#define E_SELECT_NAMES_COMPLETION_TYPE (e_select_names_completion_get_type ()) -#define E_SELECT_NAMES_COMPLETION(o) (GTK_CHECK_CAST ((o), E_SELECT_NAMES_COMPLETION_TYPE, ESelectNamesCompletion)) -#define E_SELECT_NAMES_COMPLETION_CLASS(k) (GTK_CHECK_CLASS_CAST ((k), E_SELECT_NAMES_COMPLETION_TYPE, ESelectNamesCompletionClass)) -#define E_IS_SELECT_NAMES_COMPLETION(o) (GTK_CHECK_TYPE ((o), E_SELECT_NAMES_COMPLETION_TYPE)) -#define E_IS_SELECT_NAMES_COMPLETION_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), E_SELECT_NAMES_COMPLETION_TYPE)) - -typedef struct _ESelectNamesCompletion ESelectNamesCompletion; -typedef struct _ESelectNamesCompletionClass ESelectNamesCompletionClass; -struct _ESelectNamesCompletionPrivate; - -struct _ESelectNamesCompletion { - ECompletion parent; - - struct _ESelectNamesCompletionPrivate *priv; -}; - -struct _ESelectNamesCompletionClass { - ECompletionClass parent_class; - -}; - -GtkType e_select_names_completion_get_type (void); - -ECompletion *e_select_names_completion_new (EBook *, ESelectNamesModel *); -void e_select_names_completion_add_book (ESelectNamesCompletion *, EBook *); -gboolean e_select_names_completion_get_match_contact_lists (ESelectNamesCompletion *); -void e_select_names_completion_set_match_contact_lists (ESelectNamesCompletion *, gboolean); - -END_GNOME_DECLS - -#endif /* E_SELECT_NAMES_COMPLETION_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 d6560d6366..0000000000 --- a/addressbook/gui/component/select-names/e-select-names-factory.c +++ /dev/null @@ -1,58 +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 -#endif - -#include - -#include "e-select-names-bonobo.h" -#include "e-select-names-factory.h" - - -#define COMPONENT_FACTORY_ID "OAFIID:GNOME_Evolution_Addressbook_SelectNamesFactory" - -static BonoboGenericFactory *factory = NULL; - - -static BonoboObject * -factory_fn (BonoboGenericFactory *factory, - 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 - -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 54d7344ece..0000000000 --- a/addressbook/gui/component/select-names/e-select-names-manager.c +++ /dev/null @@ -1,614 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Authors: - * Chris Lahey - * Jon Trowbridge - -#include -#include -#include - -#include - -#include "e-select-names-manager.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 -#include -#include -#include -#include - -enum { - CHANGED, - OK, - CANCEL, - LAST_SIGNAL -}; - -static guint e_select_names_manager_signals[LAST_SIGNAL] = { 0 }; - - -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; -} 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_destroy (GtkObject *object); - -/* ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** */ - -/* ESelectNamesManagerSection routines */ - -static void -section_model_changed_cb (ESelectNamesModel *model, gpointer closure) -{ - ESelectNamesManagerSection *section = closure; - gtk_signal_emit (GTK_OBJECT (section->manager), - e_select_names_manager_signals[CHANGED], - 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; - gtk_object_ref (GTK_OBJECT (section->model)); - section->changed_tag = - gtk_signal_connect (GTK_OBJECT (section->model), - "changed", - GTK_SIGNAL_FUNC (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) { - gtk_signal_disconnect (GTK_OBJECT (section->model), section->changed_tag); - gtk_object_unref (GTK_OBJECT (section->model)); - } - - if (section->original_model) { - gtk_object_unref (GTK_OBJECT (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 *) gtk_object_get_data (GTK_OBJECT (entry), "entry_info"); -} - -static void -popup_cb (EEntry *eentry, GdkEventButton *ev, gint pos, gpointer user_data) -{ - ESelectNamesManagerEntry *entry = user_data; - - e_select_names_popup (entry->model, ev, pos); -} - -static gint -focus_in_cb (GtkWidget *w, GdkEventFocus *ev, gpointer user_data) -{ - ESelectNamesManagerEntry *entry = user_data; - - e_select_names_model_cancel_cardify_all (entry->model); - - return FALSE; -} - -static gint -focus_out_cb (GtkWidget *w, GdkEventFocus *ev, gpointer user_data) -{ - ESelectNamesManagerEntry *entry = user_data; - - e_select_names_model_clean (entry->model); - - if (!e_entry_completion_popup_is_visible (entry->entry)) - e_select_names_model_cardify_all (entry->model, entry->manager->completion_book, 100); - - return FALSE; -} - -static void -completion_popup_cb (EEntry *w, gint visible, gpointer user_data) -{ - ESelectNamesManagerEntry *entry = user_data; - - if (!visible && !GTK_WIDGET_HAS_FOCUS (GTK_WIDGET (entry->entry->canvas))) - e_select_names_model_cardify_all (entry->model, entry->manager->completion_book, 0); -} - -static void -completion_handler (EEntry *entry, ECompletionMatch *match) -{ - ESelectNamesManagerEntry *mgr_entry; - 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. */ - gtk_object_ref (GTK_OBJECT (dest)); - - pos = e_entry_get_position (entry); - e_select_names_model_text_pos (mgr_entry->model, pos, &i, NULL, NULL); - e_select_names_model_replace (mgr_entry->model, i, dest); - e_select_names_model_name_pos (mgr_entry->model, 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; - ECompletion *comp; - - 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); - gtk_object_set(GTK_OBJECT(entry->entry), - "model", text_model, /* The entry takes ownership of the text model */ - "editable", TRUE, - "use_ellipsis", TRUE, - "allow_newlines", FALSE, - NULL); - - gtk_object_ref (GTK_OBJECT (entry->entry)); - - comp = e_select_names_completion_new (NULL, model); - if (manager->completion_book) - e_select_names_completion_add_book (E_SELECT_NAMES_COMPLETION (comp), - manager->completion_book); - - e_entry_enable_completion_full (entry->entry, comp, 50, completion_handler); - - entry->manager = manager; - - entry->model = model; - gtk_object_ref (GTK_OBJECT (model)); - - gtk_signal_connect (GTK_OBJECT (entry->entry), - "popup", - GTK_SIGNAL_FUNC (popup_cb), - entry); - - gtk_signal_connect (GTK_OBJECT (entry->entry->canvas), - "focus_in_event", - GTK_SIGNAL_FUNC (focus_in_cb), - entry); - - gtk_signal_connect (GTK_OBJECT (entry->entry->canvas), - "focus_out_event", - GTK_SIGNAL_FUNC (focus_out_cb), - entry); - - gtk_signal_connect (GTK_OBJECT (entry->entry), - "completion_popup", - GTK_SIGNAL_FUNC (completion_popup_cb), - entry); - - gtk_object_set_data (GTK_OBJECT (entry->entry), "entry_info", entry); - gtk_object_set_data (GTK_OBJECT (entry->entry), "select_names_model", model); - gtk_object_set_data (GTK_OBJECT (entry->entry), "completion_handler", comp); - - return entry; -} - -static void -e_select_names_manager_entry_free (ESelectNamesManagerEntry *entry) -{ - if (entry == NULL) - return; - - g_free (entry->id); - gtk_object_unref (GTK_OBJECT (entry->model)); - gtk_object_unref (GTK_OBJECT (entry->entry)); - - 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); - gtk_object_unref (GTK_OBJECT (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) { - gtk_object_unref (GTK_OBJECT (section->original_model)); - section->original_model = NULL; - } - } -} - -/* ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** */ - - -static void -open_book_cb (EBook *book, EBookStatus status, ESelectNamesManager *manager) -{ - if (status != E_BOOK_STATUS_SUCCESS) { - gtk_object_unref (GTK_OBJECT (book)); - manager->completion_book = NULL; - } - - gtk_object_unref (GTK_OBJECT (manager)); /* unref ourself (matches ref before the load_uri call below) */ -} - -/** - * e_select_names_manager_new: - * @VCard: a string in vCard format - * - * Returns: a new #ESelectNamesManager that wraps the @VCard. - */ -ESelectNamesManager * -e_select_names_manager_new (void) -{ - ESelectNamesManager *manager = E_SELECT_NAMES_MANAGER(gtk_type_new(e_select_names_manager_get_type())); - Bonobo_ConfigDatabase db; - CORBA_Environment ev; - char *val; - - CORBA_exception_init (&ev); - - db = addressbook_config_database (&ev); - - val = bonobo_config_get_string (db, "/Addressbook/Completion/uri", &ev); - - CORBA_exception_free (&ev); - - if (val) { - manager->completion_book = e_book_new (); - gtk_object_ref (GTK_OBJECT (manager)); /* ref ourself before our async call */ - addressbook_load_uri (manager->completion_book, val, (EBookCallback)open_book_cb, manager); - g_free (val); - } - else - manager->completion_book = 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); - - gtk_object_unref (GTK_OBJECT (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_clicked(ESelectNames *dialog, gint button, ESelectNamesManager *manager) -{ - gnome_dialog_close(GNOME_DIALOG(dialog)); - - switch(button) { - case 0: - e_select_names_manager_discard_saved_models (manager); - gtk_signal_emit (GTK_OBJECT (manager), e_select_names_manager_signals[OK]); - break; - - case 1: - e_select_names_manager_revert_to_saved_models (manager); - gtk_signal_emit (GTK_OBJECT (manager), e_select_names_manager_signals[CANCEL]); - break; - } -} - -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); - - gtk_signal_connect(GTK_OBJECT(manager->names), - "clicked", - GTK_SIGNAL_FUNC(e_select_names_clicked), - manager); - - gtk_signal_connect(GTK_OBJECT(manager->names), - "destroy", - GTK_SIGNAL_FUNC(gtk_widget_destroyed), - &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) -{ - manager->sections = NULL; - manager->entries = NULL; -} - -static void -e_select_names_manager_destroy (GtkObject *object) -{ - ESelectNamesManager *manager; - - manager = E_SELECT_NAMES_MANAGER (object); - - if (manager->names) { - gtk_widget_destroy (GTK_WIDGET (manager->names)); - manager->names = NULL; - } - - g_list_foreach (manager->sections, (GFunc) e_select_names_manager_section_free, NULL); - g_list_free (manager->sections); - manager->sections = NULL; - - g_list_foreach (manager->entries, (GFunc) e_select_names_manager_entry_free, NULL); - g_list_free (manager->entries); - manager->entries = NULL; -} - -static void -e_select_names_manager_class_init (ESelectNamesManagerClass *klass) -{ - GtkObjectClass *object_class; - - object_class = GTK_OBJECT_CLASS(klass); - - object_class->destroy = e_select_names_manager_destroy; - - e_select_names_manager_signals[CHANGED] = - gtk_signal_new ("changed", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (ESelectNamesManagerClass, changed), - gtk_marshal_NONE__POINTER_INT, - GTK_TYPE_NONE, 2, - GTK_TYPE_POINTER, - GTK_TYPE_INT); - - e_select_names_manager_signals[OK] = - gtk_signal_new ("ok", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (ESelectNamesManagerClass, ok), - gtk_marshal_NONE__NONE, - GTK_TYPE_NONE, 0); - - e_select_names_manager_signals[CANCEL] = - gtk_signal_new ("cancel", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (ESelectNamesManagerClass, cancel), - gtk_marshal_NONE__NONE, - GTK_TYPE_NONE, 0); - - gtk_object_class_add_signals (object_class, e_select_names_manager_signals, LAST_SIGNAL); -} - -/** - * 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. - **/ -GtkType -e_select_names_manager_get_type (void) -{ - static GtkType manager_type = 0; - - if (!manager_type) { - GtkTypeInfo manager_info = { - "ESelectNamesManager", - sizeof (ESelectNamesManager), - sizeof (ESelectNamesManagerClass), - (GtkClassInitFunc) e_select_names_manager_class_init, - (GtkObjectInitFunc) e_select_names_manager_init, - NULL, /* reserved_1 */ - NULL, /* reserved_2 */ - (GtkClassInitFunc) NULL - }; - - manager_type = gtk_type_unique (gtk_object_get_type (), &manager_info); - } - - 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 9fdad2c304..0000000000 --- a/addressbook/gui/component/select-names/e-select-names-manager.h +++ /dev/null @@ -1,63 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Authors: - * Chris Lahey - * - * Copyright (C) 2000 Ximian, Inc. - */ - -#ifndef __E_SELECT_NAMES_MANAGER_H__ -#define __E_SELECT_NAMES_MANAGER_H__ - -#include -#include -#include -#include -#include "e-select-names.h" - -#define E_TYPE_SELECT_NAMES_MANAGER (e_select_names_manager_get_type ()) -#define E_SELECT_NAMES_MANAGER(obj) (GTK_CHECK_CAST ((obj), E_TYPE_SELECT_NAMES_MANAGER, ESelectNamesManager)) -#define E_SELECT_NAMES_MANAGER_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_TYPE_SELECT_NAMES_MANAGER, ESelectNamesManagerClass)) -#define E_IS_SELECT_NAMES_MANAGER(obj) (GTK_CHECK_TYPE ((obj), E_TYPE_SELECT_NAMES_MANAGER)) -#define E_IS_SELECT_NAMES_MANAGER_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), E_TYPE_SELECT_NAMES_MANAGER)) - -typedef struct _ESelectNamesManager ESelectNamesManager; -typedef struct _ESelectNamesManagerClass ESelectNamesManagerClass; - -struct _ESelectNamesManager { - GtkObject object; - - GList *sections; - GList *entries; - - ESelectNames *names; - - EBook *completion_book; -}; - -struct _ESelectNamesManagerClass { - GtkObjectClass 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 */ -GtkType e_select_names_manager_get_type (void); - -#endif /* ! __E_SELECT_NAMES_MANAGER_H__ */ 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 138b0d73ad..0000000000 --- a/addressbook/gui/component/select-names/e-select-names-model.c +++ /dev/null @@ -1,897 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Authors: - * Chris Lahey - * Jon Trowbidge - * - * Copyright (C) 2000, 2001 Ximian, Inc. - */ - -#include - -#include -#include -#include -#include -#include - -#include - -#include "e-select-names-model.h" -#include "addressbook/backend/ebook/e-card-simple.h" - -#define SEPARATOR ", " -#define SEPLEN (strlen(SEPARATOR)) - -#define MAX_LENGTH 2047 - - -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_CARD, -}; - -enum { - NAME_DATA_BLANK, - NAME_DATA_CARD, - NAME_DATA_STRING -}; - -enum { - NAME_FORMAT_GIVEN_FIRST, - NAME_FORMAT_FAMILY_FIRST -}; - -struct _ESelectNamesModelPrivate { - gchar *id; - gchar *title; - - GList *data; /* of EDestination */ - gchar *text; - gchar *addr_text; - - gint limit; - - gint freeze_count; - gboolean pending_changed; -}; - - -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_destroy (GtkObject *object); -static void e_select_names_model_set_arg (GtkObject *object, GtkArg *arg, guint arg_id); -static void e_select_names_model_get_arg (GtkObject *object, GtkArg *arg, guint arg_id); - -GtkType -e_select_names_model_get_type (void) -{ - static GtkType model_type = 0; - - if (!model_type) { - GtkTypeInfo model_info = { - "ESelectNamesModel", - sizeof (ESelectNamesModel), - sizeof (ESelectNamesModelClass), - (GtkClassInitFunc) e_select_names_model_class_init, - (GtkObjectInitFunc) e_select_names_model_init, - NULL, /* reserved_1 */ - NULL, /* reserved_2 */ - (GtkClassInitFunc) NULL - }; - - model_type = gtk_type_unique (gtk_object_get_type (), &model_info); - } - - return model_type; -} - -typedef void (*GtkSignal_NONE__INT_INT_INT) (GtkObject *object, gint arg1, gint arg2, gint arg3, gpointer user_data); -static void -local_gtk_marshal_NONE__INT_INT_INT (GtkObject *object, - GtkSignalFunc func, - gpointer func_data, - GtkArg *args) -{ - GtkSignal_NONE__INT_INT_INT rfunc; - rfunc = (GtkSignal_NONE__INT_INT_INT) func; - (* rfunc) (object, - GTK_VALUE_INT(args[0]), - GTK_VALUE_INT(args[1]), - GTK_VALUE_INT(args[2]), - func_data); -} - - -static void -e_select_names_model_class_init (ESelectNamesModelClass *klass) -{ - GtkObjectClass *object_class; - - object_class = GTK_OBJECT_CLASS(klass); - - e_select_names_model_signals[E_SELECT_NAMES_MODEL_CHANGED] = - gtk_signal_new ("changed", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (ESelectNamesModelClass, changed), - gtk_marshal_NONE__NONE, - GTK_TYPE_NONE, 0); - - e_select_names_model_signals[E_SELECT_NAMES_MODEL_RESIZED] = - gtk_signal_new ("resized", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (ESelectNamesModelClass, resized), - local_gtk_marshal_NONE__INT_INT_INT, - GTK_TYPE_NONE, 3, GTK_TYPE_INT, GTK_TYPE_INT, GTK_TYPE_INT); - - gtk_object_class_add_signals (object_class, e_select_names_model_signals, E_SELECT_NAMES_MODEL_LAST_SIGNAL); - - gtk_object_add_arg_type ("ESelectNamesModel::card", - GTK_TYPE_OBJECT, GTK_ARG_READWRITE, ARG_CARD); - - klass->changed = NULL; - - object_class->destroy = e_select_names_model_destroy; - object_class->get_arg = e_select_names_model_get_arg; - object_class->set_arg = e_select_names_model_set_arg; -} - -/** - * 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_destroy (GtkObject *object) -{ - ESelectNamesModel *model = E_SELECT_NAMES_MODEL (object); - - g_free (model->priv->title); - g_free (model->priv->id); - - g_list_foreach (model->priv->data, (GFunc) gtk_object_unref, NULL); - g_list_free (model->priv->data); - - g_free (model->priv->text); - g_free (model->priv->addr_text); - - g_free (model->priv); - -} - - -/* Set_arg handler for the model */ -static void -e_select_names_model_set_arg (GtkObject *object, GtkArg *arg, guint arg_id) -{ - ESelectNamesModel *model; - - model = E_SELECT_NAMES_MODEL (object); - - switch (arg_id) { - case ARG_CARD: - break; - default: - return; - } -} - -/* Get_arg handler for the model */ -static void -e_select_names_model_get_arg (GtkObject *object, GtkArg *arg, guint arg_id) -{ - ESelectNamesModel *model; - - model = E_SELECT_NAMES_MODEL (object); - - switch (arg_id) { - case ARG_CARD: - break; - default: - arg->type = GTK_TYPE_INVALID; - break; - } -} - - -static void -e_select_names_model_changed (ESelectNamesModel *model) -{ - g_free (model->priv->text); - model->priv->text = NULL; - - g_free (model->priv->addr_text); - model->priv->addr_text = NULL; - - if (model->priv->freeze_count > 0) { - model->priv->pending_changed = TRUE; - } else { - gtk_signal_emit (GTK_OBJECT(model), e_select_names_model_signals[E_SELECT_NAMES_MODEL_CHANGED]); - model->priv->pending_changed = FALSE; - } -} - -static void -destination_changed_proxy (EDestination *dest, gpointer closure) -{ - e_select_names_model_changed (E_SELECT_NAMES_MODEL (closure)); -} - -/** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **/ - -ESelectNamesModel * -e_select_names_model_new (void) -{ - ESelectNamesModel *model; - model = E_SELECT_NAMES_MODEL (gtk_type_new (e_select_names_model_get_type ())); - return model; -} - -ESelectNamesModel * -e_select_names_model_duplicate (ESelectNamesModel *old) -{ - ESelectNamesModel *model = E_SELECT_NAMES_MODEL(gtk_type_new(e_select_names_model_get_type())); - 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; -} - -const gchar * -e_select_names_model_get_textification (ESelectNamesModel *model) -{ - g_return_val_if_fail (model != NULL, NULL); - g_return_val_if_fail (E_IS_SELECT_NAMES_MODEL (model), NULL); - - if (model->priv->text == NULL) { - - if (model->priv->data == NULL) { - - model->priv->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); - ++i; - iter = g_list_next (iter); - } - - model->priv->text = g_strjoinv (SEPARATOR, strv); - - if (strlen(model->priv->text) > MAX_LENGTH) { - model->priv->text[MAX_LENGTH] = 0; - g_realloc (model->priv->text, MAX_LENGTH + 1); - } - - g_free (strv); - } - } - - return model->priv->text; -} - -const gchar * -e_select_names_model_get_address_text (ESelectNamesModel *model) -{ - g_return_val_if_fail (model != NULL, NULL); - g_return_val_if_fail (E_IS_SELECT_NAMES_MODEL (model), NULL); - - if (model->priv->addr_text == NULL) { - - if (model->priv->data == NULL) { - - model->priv->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); - } - - model->priv->addr_text = g_strjoinv (SEPARATOR, strv); - - g_free (strv); - } - } - - return model->priv->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; -} - -static -void send_changed (EDestination *dest, ECard *card, gpointer closure) -{ - ESelectNamesModel *model = closure; - e_select_names_model_changed (model); -} - -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_destination_use_card (destv[i], send_changed, model); - e_select_names_model_append (model, destv[i]); - } - g_free (destv); -} - -ECard * -e_select_names_model_get_card (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_card (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) : ""; -} - -static void -connect_destination (ESelectNamesModel *model, EDestination *dest) -{ - gtk_signal_connect (GTK_OBJECT (dest), - "changed", - destination_changed_proxy, - model); -} - -static void -disconnect_destination (ESelectNamesModel *model, EDestination *dest) -{ - gtk_signal_disconnect_by_func (GTK_OBJECT (dest), destination_changed_proxy, model); -} - -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. */ - gtk_object_unref (GTK_OBJECT (dest)); - return; - } - - connect_destination (model, dest); - - model->priv->data = g_list_insert (model->priv->data, dest, index); - - gtk_object_ref (GTK_OBJECT (dest)); - gtk_object_sink (GTK_OBJECT (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. */ - gtk_object_unref (GTK_OBJECT (dest)); - return; - } - - connect_destination (model, dest); - - model->priv->data = g_list_append (model->priv->data, dest); - - gtk_object_ref (GTK_OBJECT (dest)); - gtk_object_sink (GTK_OBJECT (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); - new_strlen = new_str ? strlen (new_str) : 0; - - if (model->priv->data == NULL) { - - connect_destination (model, dest); - - model->priv->data = g_list_append (model->priv->data, dest); - gtk_object_ref (GTK_OBJECT (dest)); - gtk_object_sink (GTK_OBJECT (dest)); - - } else { - - node = g_list_nth (model->priv->data, index); - - if (node->data != dest) { - - disconnect_destination (model, E_DESTINATION (node->data)); - connect_destination (model, dest); - - old_str = e_destination_get_textrep (E_DESTINATION (node->data)); - old_strlen = old_str ? strlen (old_str) : 0; - - gtk_object_unref (GTK_OBJECT (node->data)); - - node->data = dest; - gtk_object_ref (GTK_OBJECT (dest)); - gtk_object_sink (GTK_OBJECT (dest)); - } - } - - e_select_names_model_changed (model); - - gtk_signal_emit (GTK_OBJECT (model), e_select_names_model_signals[E_SELECT_NAMES_MODEL_RESIZED], - 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); - - disconnect_destination (model, dest); - gtk_object_unref (GTK_OBJECT (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) -{ - 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); - dest = iter->data ? E_DESTINATION (iter->data) : NULL; - - if (dest == NULL || e_destination_is_empty (dest)) { - if (dest) { - disconnect_destination (model, dest); - gtk_object_unref (GTK_OBJECT (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); -} - -static void -delete_all_iter (gpointer data, gpointer closure) -{ - disconnect_destination (E_SELECT_NAMES_MODEL (closure), E_DESTINATION (data)); - gtk_object_unref (GTK_OBJECT (data)); -} - -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, delete_all_iter, 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)); - } -} - -void -e_select_names_model_name_pos (ESelectNamesModel *model, gint index, gint *pos, gint *length) -{ - gint rp = 0, i, len = 0; - GList *iter; - const gchar *str; - - g_return_if_fail (model != NULL); - g_return_if_fail (E_IS_SELECT_NAMES_MODEL (model)); - - 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)); - len = str ? strlen (str) : 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 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 (model != NULL); - g_return_if_fail (E_IS_SELECT_NAMES_MODEL (model)); - - iter = model->priv->data; - - while (iter != NULL) { - str = e_destination_get_textrep (E_DESTINATION (iter->data)); - len = str ? strlen (str) : 0; - - if (sp <= pos && pos <= sp + len + adj) { - break; - } - - sp += len + adj + 1; - adj = 1; - ++i; - - iter = g_list_next (iter); - } - - if (i != 0) - ++sp; /* 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_cardify (ESelectNamesModel *model, EBook *book, gint index, gint delay) -{ - EDestination *dest; - - g_return_if_fail (E_IS_SELECT_NAMES_MODEL (model)); - g_return_if_fail (book == NULL || E_IS_BOOK (book)); - g_return_if_fail (0 <= index && index < g_list_length (model->priv->data)); - - dest = E_DESTINATION (g_list_nth_data (model->priv->data, index)); - - if (!e_destination_is_empty (dest)) { - - if (delay > 0) - e_destination_cardify_delayed (dest, book, delay); - else - e_destination_cardify (dest, book); - } -} - -gboolean -e_select_names_model_uncardify (ESelectNamesModel *model, gint index) -{ - EDestination *dest; - gboolean rv = FALSE; - - g_return_val_if_fail (E_IS_SELECT_NAMES_MODEL (model), FALSE); - g_return_val_if_fail (0 <= index && index < g_list_length (model->priv->data), FALSE); - - dest = E_DESTINATION (g_list_nth_data (model->priv->data, index)); - - if (!e_destination_is_empty (dest)) { - EDestination *cpy_dest = e_destination_copy (dest); - - rv = e_destination_uncardify (cpy_dest); - - if (rv) { - e_select_names_model_replace (model, index, cpy_dest); - } - - } - - return rv; -} - -void -e_select_names_model_cancel_cardify (ESelectNamesModel *model, gint index) -{ - EDestination *dest; - - g_return_if_fail (E_IS_SELECT_NAMES_MODEL (model)); - g_return_if_fail (0 <= index && index < g_list_length (model->priv->data)); - - dest = E_DESTINATION (g_list_nth_data (model->priv->data, index)); - - e_destination_cancel_cardify (dest); -} - -void -e_select_names_model_cardify_all (ESelectNamesModel *model, EBook *book, gint delay) -{ - GList *iter; - - g_return_if_fail (E_IS_SELECT_NAMES_MODEL (model)); - g_return_if_fail (book == NULL || E_IS_BOOK (book)); - - for (iter = model->priv->data; iter != NULL; iter = g_list_next (iter)) { - EDestination *dest = E_DESTINATION (iter->data); - if (!e_destination_is_empty (dest)) { - - if (delay > 0) - e_destination_cardify_delayed (dest, book, delay); - else - e_destination_cardify (dest, book); - } - } -} - -void -e_select_names_model_cancel_cardify_all (ESelectNamesModel *model) -{ - GList *iter; - - g_return_if_fail (E_IS_SELECT_NAMES_MODEL (model)); - - for (iter = model->priv->data; iter != NULL; iter = g_list_next (iter)) { - EDestination *dest = E_DESTINATION (iter->data); - e_destination_cancel_cardify (dest); - } -} - -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 b7fa04d6cd..0000000000 --- a/addressbook/gui/component/select-names/e-select-names-model.h +++ /dev/null @@ -1,91 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * Authors: - * Chris Lahey - * Jon Trowbridge - * - * Copyright (C) 2000, 2001 Ximian, Inc. - */ - -#ifndef __E_SELECT_NAMES_MODEL_H__ -#define __E_SELECT_NAMES_MODEL_H__ - -#include -#include -#include -#include -#include -#include - -#define E_TYPE_SELECT_NAMES_MODEL (e_select_names_model_get_type ()) -#define E_SELECT_NAMES_MODEL(obj) (GTK_CHECK_CAST ((obj), E_TYPE_SELECT_NAMES_MODEL, ESelectNamesModel)) -#define E_SELECT_NAMES_MODEL_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_TYPE_SELECT_NAMES_MODEL, ESelectNamesModelClass)) -#define E_IS_SELECT_NAMES_MODEL(obj) (GTK_CHECK_TYPE ((obj), E_TYPE_SELECT_NAMES_MODEL)) -#define E_IS_SELECT_NAMES_MODEL_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), E_TYPE_SELECT_NAMES_MODEL)) - -typedef struct _ESelectNamesModel ESelectNamesModel; -typedef struct _ESelectNamesModelClass ESelectNamesModelClass; -struct _ESelectNamesModelPrivate; - -struct _ESelectNamesModel { - GtkObject object; - - struct _ESelectNamesModelPrivate *priv; -}; - -struct _ESelectNamesModelClass { - GtkObjectClass parent_class; - - void (*changed) (ESelectNamesModel *model); - void (*resized) (ESelectNamesModel *model, gint index, gint old_len, gint new_len); -}; - -GtkType e_select_names_model_get_type (void); - -ESelectNamesModel *e_select_names_model_new (void); -ESelectNamesModel *e_select_names_model_duplicate (ESelectNamesModel *old); - -const gchar *e_select_names_model_get_textification (ESelectNamesModel *model); -const gchar *e_select_names_model_get_address_text (ESelectNamesModel *model); - -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); -ECard *e_select_names_model_get_card (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); - -void e_select_names_model_name_pos (ESelectNamesModel *model, gint index, gint *pos, gint *length); -void e_select_names_model_text_pos (ESelectNamesModel *model, gint pos, gint *index, gint *start_pos, gint *length); - -void e_select_names_model_cardify (ESelectNamesModel *model, EBook *book, gint index, gint delay); -gboolean e_select_names_model_uncardify (ESelectNamesModel *model, gint index); -void e_select_names_model_cancel_cardify (ESelectNamesModel *model, gint index); -void e_select_names_model_cardify_all (ESelectNamesModel *model, EBook *book, gint delay); -void e_select_names_model_cancel_cardify_all (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 a6e6bdea8e..0000000000 --- a/addressbook/gui/component/select-names/e-select-names-popup.c +++ /dev/null @@ -1,561 +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 - */ - -/* - * 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 - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include "e-addressbook-util.h" -#include "e-select-names-popup.h" - -typedef struct _PopupInfo PopupInfo; -struct _PopupInfo { - ESelectNamesModel *model; - const EDestination *dest; - gint pos; - gint index; -}; - -static PopupInfo * -popup_info_new (ESelectNamesModel *model, const EDestination *dest, gint pos, gint index) -{ - PopupInfo *info = g_new0 (PopupInfo, 1); - info->model = model; - info->dest = dest; - info->pos = pos; - info->index = index; - - if (model) - gtk_object_ref (GTK_OBJECT (model)); - - if (dest) - gtk_object_ref (GTK_OBJECT (dest)); - - return info; -} - -static void -popup_info_free (PopupInfo *info) -{ - if (info) { - - if (info->model) - gtk_object_unref (GTK_OBJECT (info->model)); - - if (info->dest) - gtk_object_unref (GTK_OBJECT (info->dest)); - - g_free (info); - } -} - -static void -popup_info_cleanup (GtkWidget *w, gpointer info) -{ - popup_info_free ((PopupInfo *) info); -} - -/* You are in a maze of twisty little callbacks, all alike... */ - -static void -make_contact_editor_cb (EBook *book, gpointer user_data) -{ - if (book) { - EDestination *dest = E_DESTINATION (user_data); - ECard *card; - - card = (ECard *) e_destination_get_card (dest); - if (e_card_evolution_list (card)) { - EContactListEditor *ce; - ce = e_addressbook_show_contact_list_editor (book, card, FALSE, TRUE); - e_contact_list_editor_raise (ce); - } - else { - EContactEditor *ce; - ce = e_addressbook_show_contact_editor (book, card, FALSE, TRUE); - e_contact_editor_raise (ce); - } - gtk_object_unref (GTK_OBJECT (dest)); - } -} - -static void -edit_contact_info_cb (GtkWidget *w, gpointer user_data) -{ - PopupInfo *info = (PopupInfo *) user_data; - if (info == NULL) - return; - - gtk_object_ref (GTK_OBJECT (info->dest)); - e_book_use_local_address_book (make_contact_editor_cb, (gpointer) info->dest); -} - -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 (gtk_object_get_data (GTK_OBJECT (w), "number")); - - if (n != e_destination_get_email_num (info->dest)) { - dest = e_destination_new (); - e_destination_set_card (dest, e_destination_get_card (info->dest), n); - e_select_names_model_replace (info->model, info->index, dest); - - } -} - -static void -remove_recipient_cb (GtkWidget *w, gpointer user_data) -{ - PopupInfo *info = (PopupInfo *) user_data; - e_select_names_model_delete (info->model, info->index); -} - -static void -add_remove_recipient (GnomeUIInfo *uiinfo, PopupInfo *info) -{ - uiinfo->type = GNOME_APP_UI_ITEM; - uiinfo->label = _("Remove"); - uiinfo->moreinfo = remove_recipient_cb; -} - -static void -remove_all_recipients_cb (GtkWidget *w, gpointer user_data) -{ - PopupInfo *info = (PopupInfo *) user_data; - e_select_names_model_delete_all (info->model); -} - -static void -add_remove_all_recipients (GnomeUIInfo *uiinfo, PopupInfo *info) -{ - uiinfo->type = GNOME_APP_UI_ITEM; - uiinfo->label = _("Remove All"); - uiinfo->moreinfo = remove_all_recipients_cb; -} - -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); -} - -static void -add_html_mail (GnomeUIInfo *uiinfo, PopupInfo *info) -{ - uiinfo->type = GNOME_APP_UI_TOGGLEITEM; - uiinfo->label = _("Send HTML Mail?"); - uiinfo->moreinfo = toggle_html_mail_cb; -} - -static void -init_html_mail (GnomeUIInfo *uiinfo, PopupInfo *info) -{ - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (uiinfo->widget), - e_destination_get_html_mail_pref (info->dest)); - gtk_check_menu_item_set_show_toggle (GTK_CHECK_MENU_ITEM (uiinfo->widget), TRUE); - -} - -static void -set_uiinfo_label (GnomeUIInfo *uiinfo, const gchar *str) -{ - GtkWidget *label; - gchar *label_txt; - GList *item_children; - - label_txt = e_utf8_to_locale_string (str); - item_children = gtk_container_children (GTK_CONTAINER (uiinfo->widget)); - label = item_children->data; - g_list_free (item_children); - gtk_label_set_text (GTK_LABEL (label), label_txt); - g_free (label_txt); -} - -#define ARBITRARY_UIINFO_LIMIT 64 -static GtkWidget * -popup_menu_card (PopupInfo *info) -{ - GnomeUIInfo uiinfo[ARBITRARY_UIINFO_LIMIT]; - GnomeUIInfo radioinfo[ARBITRARY_UIINFO_LIMIT]; - gboolean using_radio = FALSE; - ECard *card; - gint i=0; - GtkWidget *pop; - EIterator *iterator; - gint html_toggle; - gint mail_label = -1; - const gchar *mail_label_str = NULL; - - /* - * Build up our GnomeUIInfo array. - */ - - memset (uiinfo, 0, sizeof (uiinfo)); - memset (radioinfo, 0, sizeof (radioinfo)); - - card = e_destination_get_card (info->dest); - - /* Use an empty label for now, we'll fill it later. - If we set uiinfo label to contact name here, gnome_popup_menu_new - could screw it up trying make a "translation". */ - uiinfo[i].type = GNOME_APP_UI_ITEM; - uiinfo[i].label = ""; - ++i; - - uiinfo[i].type = GNOME_APP_UI_SEPARATOR; - ++i; - - if (card->email) { - - if (e_list_length (card->email) > 1) { - gint j = 0; - - using_radio = TRUE; - - iterator = e_list_get_iterator (card->email); - for (e_iterator_reset (iterator); e_iterator_is_valid (iterator); e_iterator_next (iterator)) { - gchar *label = (gchar *)e_iterator_get (iterator); - if (label && *label) { - radioinfo[j].label = ""; - radioinfo[j].type = GNOME_APP_UI_ITEM; - radioinfo[j].moreinfo = change_email_num_cb; - ++j; - } - } - gtk_object_unref (GTK_OBJECT (iterator)); - - radioinfo[j].type = GNOME_APP_UI_ENDOFINFO; - - uiinfo[i].type = GNOME_APP_UI_RADIOITEMS; - uiinfo[i].moreinfo = radioinfo; - ++i; - - } else { - uiinfo[i].type = GNOME_APP_UI_ITEM; - uiinfo[i].label = ""; - mail_label_str = e_destination_get_email (info->dest); - mail_label = i; - ++i; - } - - uiinfo[i].type = GNOME_APP_UI_SEPARATOR; - ++i; - } - - add_html_mail (&(uiinfo[i]), info); - html_toggle = i; - ++i; - - uiinfo[i].type = GNOME_APP_UI_ITEM; - uiinfo[i].label = N_("Edit Contact Info"); - uiinfo[i].moreinfo = edit_contact_info_cb; - ++i; - - add_remove_recipient (&(uiinfo[i]), info); - ++i; - - add_remove_all_recipients (&(uiinfo[i]), info); - ++i; - - uiinfo[i].type = GNOME_APP_UI_ENDOFINFO; - - /* - * Now do something with it... - */ - - pop = gnome_popup_menu_new (uiinfo); - - init_html_mail (&(uiinfo[html_toggle]), info); - - /* Properly handle the names & e-mail addresses so that they don't get leaked and so that - underscores are interpreted as key accelerators. This sucks. */ - - set_uiinfo_label (&(uiinfo[0]), e_destination_get_name (info->dest)); - - if (mail_label >= 0) { - set_uiinfo_label (&(uiinfo[mail_label]), e_destination_get_email (info->dest)); - } - - if (using_radio) { - gint n = e_destination_get_email_num (info->dest); - gint j = 0; - iterator = e_list_get_iterator (card->email); - for (e_iterator_reset (iterator); e_iterator_is_valid (iterator); e_iterator_next (iterator)) { - gchar *label = (gchar *)e_iterator_get (iterator); - if (label && *label) { - set_uiinfo_label (&(radioinfo[j]), label); - - gtk_object_set_data (GTK_OBJECT (radioinfo[j].widget), "number", GINT_TO_POINTER (j)); - - if (j == n) - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (radioinfo[n].widget), TRUE); - - ++j; - } - } - gtk_object_unref (GTK_OBJECT (iterator)); - } - - return pop; -} - -static GtkWidget * -popup_menu_list (PopupInfo *info) -{ - GnomeUIInfo uiinfo[ARBITRARY_UIINFO_LIMIT]; - GtkWidget *pop; - const gchar *str; - gchar *gs; - gint i = 0, subcount = 0, max_subcount = 10; - ECard *card; - EIterator *iterator; - - memset (uiinfo, 0, sizeof (uiinfo)); - - uiinfo[i].type = GNOME_APP_UI_ITEM; - uiinfo[i].label = ""; - ++i; - - uiinfo[i].type = GNOME_APP_UI_SEPARATOR; - ++i; - - card = e_destination_get_card (info->dest); - - if (card->email) { - - iterator = e_list_get_iterator (card->email); - for (e_iterator_reset (iterator); e_iterator_is_valid (iterator) && subcount < max_subcount; e_iterator_next (iterator)) { - gchar *label = (gchar *) e_iterator_get (iterator); - if (label && *label) { - uiinfo[i].type = GNOME_APP_UI_ITEM; - uiinfo[i].label = ""; - ++i; - ++subcount; - } - } - if (e_iterator_is_valid (iterator)) { - uiinfo[i].type = GNOME_APP_UI_ITEM; - uiinfo[i].label = ""; - ++i; - } - - uiinfo[i].type = GNOME_APP_UI_SEPARATOR; - ++i; - - gtk_object_unref (GTK_OBJECT (iterator)); - } - - uiinfo[i].type = GNOME_APP_UI_ITEM; - uiinfo[i].label = N_("Edit Contact List"); - uiinfo[i].moreinfo = edit_contact_info_cb; - ++i; - - add_remove_recipient (&(uiinfo[i]), info); - ++i; - - add_remove_all_recipients (&(uiinfo[i]), info); - ++i; - - uiinfo[i].type = GNOME_APP_UI_ENDOFINFO; - - pop = gnome_popup_menu_new (uiinfo); - - /* Now set labels properly. */ - - str = e_destination_get_name (info->dest); - if (!(str && *str)) - str = _("Unnamed Contact List"); - set_uiinfo_label (&(uiinfo[0]), str); - - if (card->email) { - - iterator = e_list_get_iterator (card->email); - i = 2; - for (e_iterator_reset (iterator); e_iterator_is_valid (iterator) && subcount < max_subcount; e_iterator_next (iterator)) { - gchar *label = (gchar *) e_iterator_get (iterator); - if (label && *label) { - EDestination *subdest = e_destination_import (label); - set_uiinfo_label (&(uiinfo[i]), e_destination_get_address (subdest)); - ++i; - gtk_object_unref (GTK_OBJECT (subdest)); - } - } - if (e_iterator_is_valid (iterator)) { - gs = g_strdup_printf (N_("(%d not shown)"), e_list_length (card->email) - max_subcount); - set_uiinfo_label (&(uiinfo[i]), gs); - g_free (gs); - } - - gtk_object_unref (GTK_OBJECT (iterator)); - } - - - return pop; -} - -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 GtkWidget * -popup_menu_nocard (PopupInfo *info) -{ - GnomeUIInfo uiinfo[ARBITRARY_UIINFO_LIMIT]; - gint i=0; - GtkWidget *pop; - const gchar *str; - gint html_toggle; - - memset (uiinfo, 0, sizeof (uiinfo)); - - /* Use an empty label for now, we'll fill it later. - If we set uiinfo label to contact name here, gnome_popup_menu_new - could screw it up trying make a "translation". */ - uiinfo[i].type = GNOME_APP_UI_ITEM; - uiinfo[i].label = ""; - ++i; - - uiinfo[i].type = GNOME_APP_UI_SEPARATOR; - ++i; - - add_html_mail (&(uiinfo[i]), info); - html_toggle = i; - ++i; - - uiinfo[i].type = GNOME_APP_UI_ITEM; - uiinfo[i].label = _("Add to Contacts"); - uiinfo[i].moreinfo = quick_add_cb; - ++i; - - add_remove_recipient (&(uiinfo[i]), info); - ++i; - - add_remove_all_recipients (&(uiinfo[i]), info); - ++i; - - uiinfo[i].type = GNOME_APP_UI_ENDOFINFO; - - pop = gnome_popup_menu_new (uiinfo); - - init_html_mail (&(uiinfo[html_toggle]), info); - - /* Now set label of the first item to contact name */ - str = e_destination_get_name (info->dest); - if (! (str && *str)) - str = e_destination_get_email (info->dest); - if (! (str && *str)) - str = _("Unnamed Contact"); - - set_uiinfo_label (&(uiinfo[0]), str); - - return pop; -} - -void -e_select_names_popup (ESelectNamesModel *model, GdkEventButton *ev, gint pos) -{ - GtkWidget *popup; - PopupInfo *info; - const EDestination *dest; - ECard *card; - gint index; - - g_return_if_fail (model && E_IS_SELECT_NAMES_MODEL (model)); - g_return_if_fail (ev); - g_return_if_fail (0 <= pos); - - e_select_names_model_text_pos (model, pos, &index, NULL, NULL); - if (index < 0 || index >= e_select_names_model_count (model)) - return; - - dest = e_select_names_model_get_destination (model, index); - if (e_destination_is_empty (dest)) - return; - - card = e_destination_get_card (dest); - - info = popup_info_new (model, dest, pos, index); - - if (e_destination_contains_card (dest)) { - if (e_destination_is_evolution_list (dest)) - popup = popup_menu_list (info); - else - popup = popup_menu_card (info); - } else { - popup = popup_menu_nocard (info); - } - - if (popup) { - /* Clean up our info item after we've made our selection. */ - gtk_signal_connect (GTK_OBJECT (popup), - "selection-done", - GTK_SIGNAL_FUNC (popup_info_cleanup), - info); - - gnome_popup_menu_do_popup (popup, NULL, NULL, ev, info); - - } else { - - popup_info_free (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 5a4685f8cb..0000000000 --- a/addressbook/gui/component/select-names/e-select-names-popup.h +++ /dev/null @@ -1,35 +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 - */ - -/* - * 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-model.h" - -void e_select_names_popup (ESelectNamesModel *model, GdkEventButton *ev, gint pos); - -#endif /* __E_SELECT_NAMES_POPUP_H__ */ - 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 a4faf69503..0000000000 --- a/addressbook/gui/component/select-names/e-select-names-table-model.c +++ /dev/null @@ -1,348 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Authors: - * Chris Lahey - * - * Copyright (C) 2000 Ximian, Inc. - */ - -#include -#include -#include -#include - -#include -#include - -#include "e-select-names-table-model.h" -#include "addressbook/backend/ebook/e-card-simple.h" - -/* Object argument IDs */ -enum { - ARG_0, - ARG_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_destroy (GtkObject *object); -static void e_select_names_table_model_set_arg (GtkObject *object, GtkArg *arg, guint arg_id); -static void e_select_names_table_model_get_arg (GtkObject *object, GtkArg *arg, guint arg_id); - -static void e_select_names_table_model_model_changed (ESelectNamesModel *source, - ESelectNamesTableModel *model); - - -static void -e_select_names_table_model_add_source (ESelectNamesTableModel *model, - ESelectNamesModel *source) -{ - model->source = source; - if (model->source) - gtk_object_ref(GTK_OBJECT(model->source)); - model->source_changed_id = gtk_signal_connect(GTK_OBJECT(model->source), "changed", - GTK_SIGNAL_FUNC(e_select_names_table_model_model_changed), - model); -} - -static void -e_select_names_table_model_drop_source (ESelectNamesTableModel *model) -{ - if (model->source_changed_id) - gtk_signal_disconnect(GTK_OBJECT(model->source), model->source_changed_id); - if (model->source) - gtk_object_unref(GTK_OBJECT(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. - **/ -GtkType -e_select_names_table_model_get_type (void) -{ - static GtkType model_type = 0; - - if (!model_type) { - GtkTypeInfo model_info = { - "ESelectNamesTableModel", - sizeof (ESelectNamesTableModel), - sizeof (ESelectNamesTableModelClass), - (GtkClassInitFunc) e_select_names_table_model_class_init, - (GtkObjectInitFunc) e_select_names_table_model_init, - NULL, /* reserved_1 */ - NULL, /* reserved_2 */ - (GtkClassInitFunc) NULL - }; - - model_type = gtk_type_unique (e_table_model_get_type (), &model_info); - } - - return model_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 = E_TABLE_MODEL(gtk_type_new(e_select_names_table_model_get_type())); - gtk_object_set(GTK_OBJECT(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); - ECard *card = dest ? e_destination_get_card (dest) : NULL; - - if (card) { - ECardSimple *simple = e_card_simple_new(card); - model->data[i].name = e_card_simple_get(simple, E_CARD_SIMPLE_FIELD_NAME_OR_ORG); - if (model->data[i].name == 0) - model->data[i].name = g_strdup(""); - model->data[i].email = e_card_simple_get(simple, E_CARD_SIMPLE_FIELD_EMAIL); - if (model->data[i].email == 0) - model->data[i].email = g_strdup(""); - gtk_object_unref(GTK_OBJECT(simple)); - } 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) -{ - 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_destroy (GtkObject *object) -{ - ESelectNamesTableModel *model; - - model = E_SELECT_NAMES_TABLE_MODEL (object); - - e_select_names_table_model_drop_source (model); - clear_info(model); -} - -/* This function returns the number of columns in our ETableModel. */ -static int -e_select_names_table_model_col_count (ETableModel *etc) -{ - return 2; -} - -/* 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; - } - 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_arg (GtkObject *object, GtkArg *arg, guint arg_id) -{ - ESelectNamesTableModel *model; - - model = E_SELECT_NAMES_TABLE_MODEL (object); - - switch (arg_id) { - case ARG_SOURCE: - e_select_names_table_model_drop_source (model); - e_select_names_table_model_add_source (model, E_SELECT_NAMES_MODEL(GTK_VALUE_OBJECT (*arg))); - break; - default: - return; - } -} - -/* Get_arg handler for the model */ -static void -e_select_names_table_model_get_arg (GtkObject *object, GtkArg *arg, guint arg_id) -{ - ESelectNamesTableModel *model; - - model = E_SELECT_NAMES_TABLE_MODEL (object); - - switch (arg_id) { - case ARG_SOURCE: - GTK_VALUE_OBJECT(*arg) = GTK_OBJECT(model->source); - break; - default: - arg->type = GTK_TYPE_INVALID; - 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) -{ - GtkObjectClass *object_class; - ETableModelClass *table_model_class; - - object_class = GTK_OBJECT_CLASS(klass); - table_model_class = E_TABLE_MODEL_CLASS(klass); - - gtk_object_add_arg_type ("ESelectNamesTableModel::source", - GTK_TYPE_OBJECT, GTK_ARG_READWRITE, ARG_SOURCE); - - object_class->destroy = e_select_names_table_model_destroy; - object_class->get_arg = e_select_names_table_model_get_arg; - object_class->set_arg = e_select_names_table_model_set_arg; - - 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 f917ff17d8..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 - * - * Copyright (C) 2000 Ximian, Inc. - */ - -#ifndef __E_SELECT_NAMES_TABLE_MODEL_H__ -#define __E_SELECT_NAMES_TABLE_MODEL_H__ - -#include -#include -#include -#include -#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) (GTK_CHECK_CAST ((obj), E_TYPE_SELECT_NAMES_TABLE_MODEL, ESelectNamesTableModel)) -#define E_SELECT_NAMES_TABLE_MODEL_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_TYPE_SELECT_NAMES_TABLE_MODEL, ESelectNamesTableModelClass)) -#define E_IS_SELECT_NAMES_TABLE_MODEL(obj) (GTK_CHECK_TYPE ((obj), E_TYPE_SELECT_NAMES_TABLE_MODEL)) -#define E_IS_SELECT_NAMES_TABLE_MODEL_CLASS(klass) (GTK_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 */ -GtkType 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 d2e77d6316..0000000000 --- a/addressbook/gui/component/select-names/e-select-names-text-model.c +++ /dev/null @@ -1,739 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Authors: - * Chris Lahey - * Jon Trowbridge - * - * Copyright (C) 2000, 2001 Ximian, Inc. - */ - -#include - -#include -#include -#include -#include - -#include - -#include -#include "e-select-names-text-model.h" -#include "e-addressbook-util.h" - -static FILE *out = NULL; /* stream for debugging spew */ - -#define SEPLEN 2 - -/* Object argument IDs */ -enum { - ARG_0, - ARG_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_destroy (GtkObject *object); -static void e_select_names_text_model_set_arg (GtkObject *object, GtkArg *arg, guint arg_id); -static void e_select_names_text_model_get_arg (GtkObject *object, GtkArg *arg, guint arg_id); - -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); - - -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 GtkType model_type = 0; - - if (!model_type) { - GtkTypeInfo model_info = { - "ESelectNamesTextModel", - sizeof (ESelectNamesTextModel), - sizeof (ESelectNamesTextModelClass), - (GtkClassInitFunc) e_select_names_text_model_class_init, - (GtkObjectInitFunc) e_select_names_text_model_init, - NULL, /* reserved_1 */ - NULL, /* reserved_2 */ - (GtkClassInitFunc) NULL - }; - - model_type = gtk_type_unique (PARENT_TYPE, &model_info); - } - - return model_type; -} - -static void -e_select_names_text_model_class_init (ESelectNamesTextModelClass *klass) -{ - GtkObjectClass *object_class; - ETextModelClass *text_model_class; - - object_class = GTK_OBJECT_CLASS(klass); - text_model_class = E_TEXT_MODEL_CLASS(klass); - - parent_class = gtk_type_class(PARENT_TYPE); - - gtk_object_add_arg_type ("ESelectNamesTextModel::source", - GTK_TYPE_OBJECT, GTK_ARG_READWRITE, ARG_SOURCE); - - object_class->destroy = e_select_names_text_model_destroy; - object_class->get_arg = e_select_names_text_model_get_arg; - object_class->set_arg = e_select_names_text_model_set_arg; - - 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" : ""); - fprintf (out, "\n"); -} - -static void -e_select_names_text_model_init (ESelectNamesTextModel *model) -{ - model->last_magic_comma_pos = -1; -} - -static void -e_select_names_text_model_destroy (GtkObject *object) -{ - ESelectNamesTextModel *model; - - model = E_SELECT_NAMES_TEXT_MODEL (object); - - e_select_names_text_model_set_source (model, NULL); - - if (GTK_OBJECT_CLASS(parent_class)->destroy) - GTK_OBJECT_CLASS(parent_class)->destroy(object); -} - -static void -e_select_names_text_model_set_arg (GtkObject *object, GtkArg *arg, guint arg_id) -{ - ESelectNamesTextModel *model; - - model = E_SELECT_NAMES_TEXT_MODEL (object); - - switch (arg_id) { - case ARG_SOURCE: - e_select_names_text_model_set_source(model, E_SELECT_NAMES_MODEL (GTK_VALUE_OBJECT (*arg))); - break; - default: - return; - } -} - -static void -e_select_names_text_model_get_arg (GtkObject *object, GtkArg *arg, guint arg_id) -{ - ESelectNamesTextModel *model; - - model = E_SELECT_NAMES_TEXT_MODEL (object); - - switch (arg_id) { - case ARG_SOURCE: - GTK_VALUE_OBJECT(*arg) = GTK_OBJECT(model->source); - break; - default: - arg->type = GTK_TYPE_INVALID; - 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; - - e_select_names_model_name_pos (source, 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 -e_select_names_text_model_set_source (ESelectNamesTextModel *model, - ESelectNamesModel *source) -{ - if (source == model->source) - return; - - if (model->source) { - gtk_signal_disconnect (GTK_OBJECT (model->source), model->source_changed_id); - gtk_signal_disconnect (GTK_OBJECT (model->source), model->source_resize_id); - gtk_object_unref (GTK_OBJECT (model->source)); - } - - model->source = source; - - if (model->source) { - gtk_object_ref (GTK_OBJECT (model->source)); - model->source_changed_id = gtk_signal_connect_object (GTK_OBJECT(model->source), - "changed", - GTK_SIGNAL_FUNC (e_text_model_changed), - GTK_OBJECT (model)); - model->source_resize_id = gtk_signal_connect (GTK_OBJECT(model->source), - "resized", - GTK_SIGNAL_FUNC (resize_cb), - model); - } -} - -ETextModel * -e_select_names_text_model_new (ESelectNamesModel *source) -{ - ETextModel *model = E_TEXT_MODEL (gtk_type_new (e_select_names_text_model_get_type())); - e_select_names_text_model_set_source (E_SELECT_NAMES_TEXT_MODEL (model), source); - return model; -} - -static const gchar * -e_select_names_text_model_get_text (ETextModel *model) -{ - ESelectNamesTextModel *snm = E_SELECT_NAMES_TEXT_MODEL(model); - - return snm ? e_select_names_model_get_textification (snm->source) : ""; -} - -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, strlen (text)); -} - -static void -e_select_names_text_model_insert_length (ETextModel *model, gint pos, const gchar *text, gint length) -{ - ESelectNamesModel *source = E_SELECT_NAMES_TEXT_MODEL (model)->source; - gint i; - - g_return_if_fail (model != NULL); - g_return_if_fail (E_IS_SELECT_NAMES_TEXT_MODEL (model)); - - if (out) { - gchar *tmp = g_strndup (text, length); - fprintf (out, ">> insert \"%s\" (len=%d) at %d\n", tmp, length, pos); - g_free (tmp); - } - - pos = CLAMP (pos, 0, strlen (e_select_names_model_get_textification (source))); - - /* We want to control all cursor motions ourselves, rather than taking hints - from the ESelectNamesModel. */ - gtk_signal_handler_block (GTK_OBJECT (source), E_SELECT_NAMES_TEXT_MODEL (model)->source_resize_id); - - /* We handle this one character at a time. */ - - for (i = 0; i < length && text[i]; ++i) { - gint index, start_pos, text_len; - gboolean inside_quote = FALSE; - - E_SELECT_NAMES_TEXT_MODEL (model)->last_magic_comma_pos = -1; - - if (out) - fprintf (out, "processing [%c]\n", text[i]); - - e_select_names_model_text_pos (source, pos, &index, &start_pos, &text_len); - - if (out) - fprintf (out, "index=%d start_pos=%d text_len=%d\n", index, start_pos, text_len); - - if (text[i] == ',' && index >= 0) { /* Is this a quoted or an unquoted comma we are dealing with? */ - const EDestination *dest = e_select_names_model_get_destination (source, index); - if (dest) { - const gchar *str = e_destination_get_textrep (dest); - gint j; - if (out) - fprintf (out, "str=%s pos=%d\n", str, pos); - for (j=0; j 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 = SEPLEN; - e_text_model_reposition (model, e_repos_insert_shift, &repos); - pos += 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 = SEPLEN; - e_text_model_reposition (model, e_repos_insert_shift, &repos); - pos += SEPLEN; - } - - E_SELECT_NAMES_TEXT_MODEL (model)->last_magic_comma_pos = pos; - - } else { - EReposInsertShift repos; - gint offset = MAX (pos - start_pos, 0); - const gchar *str; - gchar *new_str = NULL; - gint this_length = 1; - gboolean whitespace = isspace ((gint) text[i]); - - 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" */ - new_str = g_strdup_printf("%c%s%s", text[i], pos < start_pos ? " " : "", str); - if (pos < start_pos) - ++this_length; - } - } else { - new_str = g_strdup_printf ("%.*s%c%s", offset, str, text[i], str + offset); - } - } else { - if (whitespace) { - /* swallow leading whitespace */ - this_length = 0; - } else { - new_str = g_strdup_printf ("%c", text[i]); - } - } - - if (new_str) { - - EDestination *dest; - dest = index >= 0 ? e_destination_copy (e_select_names_model_get_destination (source, index)) : e_destination_new (); - e_destination_set_raw (dest, new_str); - e_select_names_model_replace (source, index, dest); - - /* 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_free (new_str); - } - } - } - - dump_model (E_SELECT_NAMES_TEXT_MODEL (model)); - - gtk_signal_handler_unblock (GTK_OBJECT (source), E_SELECT_NAMES_TEXT_MODEL (model)->source_resize_id); -} - - -static void -e_select_names_text_model_delete (ETextModel *model, gint pos, gint length) -{ - ESelectNamesModel *source = E_SELECT_NAMES_TEXT_MODEL (model)->source; - gint index, start_pos, text_len, offset; - - if (out) { - const gchar *str = e_select_names_model_get_textification (source); - gint i, len; - - fprintf (out, ">> delete %d at pos %d\n", length, pos); - - len = strlen (str); - for (i=0; ilast_magic_comma_pos == pos+1 - && length == 1) { - --pos; - if (pos >= 0) - ++length; - E_SELECT_NAMES_TEXT_MODEL (model)->last_magic_comma_pos = -1; - } - - e_select_names_model_text_pos (source, 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. */ - gtk_signal_handler_block (GTK_OBJECT (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", str1, 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 = SEPLEN - 1; - - 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 + SEPLEN; - - e_text_model_reposition (model, e_repos_delete_shift, &repos); - - length -= text_len + 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); - new_str = str ? g_strdup_printf ("%.*s%s", offset, str, str + offset + length) : NULL; - - if (new_str) { - EReposDeleteShift repos; - EDestination *dest; - - dest = index >= 0 ? e_destination_copy (e_select_names_model_get_destination (source, index)) : 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 = SEPLEN; - - e_text_model_reposition (model, e_repos_delete_shift, &repos); - } - } - - finished: - E_SELECT_NAMES_TEXT_MODEL (model)->last_magic_comma_pos = -1; - gtk_signal_handler_unblock (GTK_OBJECT (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_card (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_card (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) -{ - ESelectNamesModel *source = E_SELECT_NAMES_TEXT_MODEL (model)->source; - const gchar *txt; - gint i, pos; - - i = nth_obj_index (source, n); - if (i < 0) - return NULL; - - e_select_names_model_name_pos (source, i, &pos, len); - if (pos < 0) - return NULL; - - txt = e_select_names_model_get_textification (source); - return txt + pos; -} - -static void -e_select_names_text_model_activate_obj (ETextModel *model, gint n) -{ - ESelectNamesModel *source = E_SELECT_NAMES_TEXT_MODEL (model)->source; - EContactEditor *contact_editor; - ECard *card; - gint i; - - i = nth_obj_index (source, n); - g_return_if_fail (i >= 0); - - card = e_select_names_model_get_card (source, i); - g_return_if_fail (card != NULL); - - /* present read-only contact editor when someone double clicks from here */ - contact_editor = e_addressbook_show_contact_editor (e_card_get_book (card), card, FALSE, FALSE); - e_contact_editor_raise (contact_editor); -} - - - 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 fa6ab11a63..0000000000 --- a/addressbook/gui/component/select-names/e-select-names-text-model.h +++ /dev/null @@ -1,47 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Authors: - * Chris Lahey - * Jon Trowbridge - * - * Copyright (C) 2000, 2001 Ximian, Inc. - */ - -#ifndef __E_SELECT_NAMES_TEXT_MODEL_H__ -#define __E_SELECT_NAMES_TEXT_MODEL_H__ - -#include -#include -#include -#include -#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) (GTK_CHECK_CAST ((obj), E_TYPE_SELECT_NAMES_TEXT_MODEL, ESelectNamesTextModel)) -#define E_SELECT_NAMES_TEXT_MODEL_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_TYPE_SELECT_NAMES_TEXT_MODEL, ESelectNamesTextModelClass)) -#define E_IS_SELECT_NAMES_TEXT_MODEL(obj) (GTK_CHECK_TYPE ((obj), E_TYPE_SELECT_NAMES_TEXT_MODEL)) -#define E_IS_SELECT_NAMES_TEXT_MODEL_CLASS(klass) (GTK_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; - - gint last_magic_comma_pos; -}; - -struct _ESelectNamesTextModelClass { - ETextModelClass parent_class; -}; - -ETextModel *e_select_names_text_model_new (ESelectNamesModel *source); - -/* Standard Gtk function */ -GtkType 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 5d6baa26fa..0000000000 --- a/addressbook/gui/component/select-names/e-select-names.c +++ /dev/null @@ -1,955 +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 - * - * 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 -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "e-select-names.h" -#include -#include "e-select-names-table-model.h" -#include -#include -#include -#include - -static void e_select_names_init (ESelectNames *card); -static void e_select_names_class_init (ESelectNamesClass *klass); -static void e_select_names_set_arg (GtkObject *o, GtkArg *arg, guint arg_id); -static void e_select_names_get_arg (GtkObject *object, GtkArg *arg, guint arg_id); -static void e_select_names_destroy (GtkObject *object); - -static GnomeDialogClass *parent_class = NULL; -#define PARENT_TYPE gnome_dialog_get_type() - -/* The arguments we take */ -enum { - ARG_0, -}; - -typedef struct { - char *title; - ETableModel *model; - ESelectNamesModel *source; - ESelectNames *names; - GtkWidget *label; -} ESelectNamesChild; - -GtkType -e_select_names_get_type (void) -{ - static GtkType type = 0; - - if (!type) { - static const GtkTypeInfo info = - { - "ESelectNames", - sizeof (ESelectNames), - sizeof (ESelectNamesClass), - (GtkClassInitFunc) e_select_names_class_init, - (GtkObjectInitFunc) e_select_names_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - type = gtk_type_unique (PARENT_TYPE, &info); - } - - return type; -} - -static void -e_select_names_class_init (ESelectNamesClass *klass) -{ - GtkObjectClass *object_class; - - object_class = (GtkObjectClass*) klass; - - parent_class = gtk_type_class (PARENT_TYPE); - - object_class->set_arg = e_select_names_set_arg; - object_class->get_arg = e_select_names_get_arg; - object_class->destroy = e_select_names_destroy; -} - -#define SPEC " \ - \ - \ - \ - \ - \ -" - -#define SPEC2 " \ - \ - \ - \ - \ - \ -" - -GtkWidget *e_addressbook_create_ebook_table(char *name, char *string1, char *string2, int num1, int num2); - -static void -set_book(EBook *book, EBookStatus status, EAddressbookModel *model) -{ - gtk_object_set(GTK_OBJECT(model), - "book", book, - NULL); - gtk_object_unref(GTK_OBJECT(book)); - gtk_object_unref(GTK_OBJECT(model)); -} - -static void -addressbook_model_set_uri(EAddressbookModel *model, char *uri) -{ - EBook *book; - - /* If uri == the current uri, then we don't have to do anything */ - book = e_addressbook_model_get_ebook (model); - if (book) { - const gchar *current_uri = e_book_get_uri (book); - if (uri && current_uri && !strcmp (uri, current_uri)) - return; - } - - book = e_book_new(); - gtk_object_ref(GTK_OBJECT(model)); - addressbook_load_uri(book, uri, (EBookCallback) set_book, model); -} - -static void * -card_key (ECard *card) -{ - EBook *book; - const gchar *book_uri; - - if (card == NULL) - return NULL; - - g_assert (E_IS_CARD (card)); - - book = e_card_get_book (card); - book_uri = book ? e_book_get_uri (book) : "NoBook"; - return g_strdup_printf ("%s|%s", book_uri ? book_uri : "NoURI", e_card_get_id (card)); -} - -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; - ECard *card; - void *key; - - count = e_select_names_model_count (model); - for (i = 0; i < count; ++i) { - card = e_select_names_model_get_card (model, i); - if (card) { - key = card_key (card); - 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; - ECard *card; - EDestination *dest = e_destination_new (); - gint mapped_row; - - mapped_row = e_table_subset_view_to_model_row (E_TABLE_SUBSET (names->without), model_row); - - card = e_addressbook_model_get_card (E_ADDRESSBOOK_MODEL(names->model), mapped_row); - - if (card != NULL) { - e_destination_set_card (dest, card, 0); - - e_select_names_model_append (child->source, dest); - e_select_names_model_clean (child->source); - - gtk_object_unref(GTK_OBJECT(card)); - } -} - -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 * -esn_get_key_fn (ETableModel *source, int row, void *closure) -{ - EAddressbookModel *model = E_ADDRESSBOOK_MODEL (closure); - ECard *card = e_addressbook_model_get_card (model, row); - void *key = card_key (card); - gtk_object_unref (GTK_OBJECT (card)); - 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; - EAddressbookModel *model; - GtkWidget *table; - char *filename; - char *uri; - char *spec; - - model = e_addressbook_model_new (); - adapter = E_TABLE_MODEL (e_addressbook_table_adapter_new (model)); - - filename = gnome_util_prepend_user_home("evolution/local/Contacts/addressbook.db"); - uri = g_strdup_printf("file://%s", filename); - - addressbook_model_set_uri(model, uri); - - g_free(uri); - g_free(filename); - - gtk_object_set(GTK_OBJECT(model), - "editable", FALSE, - "query", "(contains \"email\" \"\")", - 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); - - spec = g_strdup_printf(SPEC, E_CARD_SIMPLE_FIELD_NAME_OR_ORG); - table = e_table_scrolled_new (without, NULL, spec, NULL); - g_free(spec); - - gtk_object_set_data(GTK_OBJECT(table), "adapter", adapter); - gtk_object_set_data(GTK_OBJECT(table), "without", without); - gtk_object_set_data(GTK_OBJECT(table), "model", model); - - return table; -} - -typedef struct { - char *description; - char *display_name; - char *uri; - -} ESelectNamesFolder; - -static void -e_select_names_folder_free(ESelectNamesFolder *e_folder) -{ - g_free(e_folder->description ); - g_free(e_folder->display_name); - g_free(e_folder->uri); - g_free(e_folder); -} - -static void -e_select_names_option_activated(GtkWidget *widget, ESelectNames *e_select_names) -{ - ESelectNamesFolder *e_folder = gtk_object_get_data (GTK_OBJECT (widget), "EsnChoiceFolder"); - - addressbook_model_set_uri(e_select_names->model, e_folder->uri); -} - -typedef struct { - ESelectNames *names; - GtkWidget *menu; -} NamesAndMenu; - -static void -add_menu_item (gpointer key, - gpointer value, - gpointer user_data) -{ - GtkWidget *menu; - GtkWidget *item; - ESelectNamesFolder *e_folder; - NamesAndMenu *nnm; - ESelectNames *e_select_names; - gchar *label; - - nnm = user_data; - e_folder = value; - menu = nnm->menu; - e_select_names = nnm->names; - - label = e_utf8_to_locale_string (_(e_folder->display_name)); - item = gtk_menu_item_new_with_label (label); - g_free (label); - - gtk_menu_append (GTK_MENU (menu), item); - gtk_object_set_data (GTK_OBJECT (item), "EsnChoiceFolder", e_folder); - - gtk_signal_connect (GTK_OBJECT (item), "activate", - GTK_SIGNAL_FUNC (e_select_names_option_activated), - e_select_names); -} - -static void -update_option_menu(ESelectNames *e_select_names) -{ - GtkWidget *menu; - GtkWidget *option; - - option = glade_xml_get_widget (e_select_names->gui, - "optionmenu-folder"); - if (option) { - NamesAndMenu nnm; - menu = gtk_menu_new (); - - nnm.names = e_select_names; - nnm.menu = menu; - - g_hash_table_foreach (e_select_names->folders, - add_menu_item, - &nnm); - - gtk_widget_show_all (menu); - - gtk_option_menu_set_menu (GTK_OPTION_MENU (option), - menu); - gtk_option_menu_set_history (GTK_OPTION_MENU (option), 0); - gtk_widget_set_sensitive (option, TRUE); - } -} - -static void -new_folder (EvolutionStorageListener *storage_listener, - const char *path, - const GNOME_Evolution_Folder *folder, - ESelectNames *e_select_names) -{ - if (!strcmp(folder->type, "contacts") - || !strcmp(folder->type, "ldap-contacts")) { - ESelectNamesFolder *e_folder = g_new(ESelectNamesFolder, 1); - e_folder->description = g_strdup(folder->description ); - e_folder->display_name = g_strdup(folder->displayName); - if (!strncmp (folder->physicalUri, "file:", 5)) - e_folder->uri = g_strdup_printf ("%s/addressbook.db", folder->physicalUri); - else - e_folder->uri = g_strdup(folder->physicalUri); - g_hash_table_insert(e_select_names->folders, - g_strdup(path), e_folder); - update_option_menu(e_select_names); - } -} - -static void -removed_folder (EvolutionStorageListener *storage_listener, - const char *path, - ESelectNames *e_select_names) -{ - ESelectNamesFolder *e_folder; - char *orig_path; - - if (g_hash_table_lookup_extended(e_select_names->folders, path, (void **) &orig_path, (void **) &e_folder)) { - g_hash_table_remove(e_select_names->folders, path); - e_select_names_folder_free(e_folder); - g_free(orig_path); - update_option_menu(e_select_names); - } -} - -static void -update_query (GtkWidget *button, ESelectNames *e_select_names) -{ - char *category = ""; - char *search = ""; - char *query; - char *q_array[4]; - int i; - if (e_select_names->categories_entry) { - category = gtk_entry_get_text (GTK_ENTRY (e_select_names->categories_entry)); - } - if (e_select_names->search_entry) { - search = gtk_entry_get_text (GTK_ENTRY (e_select_names->search_entry)); - } - i = 0; - q_array[i++] = "(contains \"email\" \"\")"; - if (category && *category) - q_array[i++] = g_strdup_printf ("(is \"category\" \"%s\")", category); - if (search && *search) - q_array[i++] = g_strdup_printf ("(contains \"x-evolution-any-field\" \"%s\")", search); - q_array[i++] = NULL; - if (i > 2) { - char *temp = g_strjoinv (" ", q_array); - query = g_strdup_printf ("(and %s)", temp); - g_free (temp); - } else { - query = g_strdup (q_array[0]); - } - gtk_object_set (GTK_OBJECT (e_select_names->model), - "query", query, - NULL); - for (i = 1; q_array[i]; i++) { - g_free (q_array[i]); - } - g_free (query); -} - -static void -hookup_listener (ESelectNames *e_select_names, - GNOME_Evolution_Storage storage, - EvolutionStorageListener *listener, - CORBA_Environment *ev) -{ - GNOME_Evolution_StorageListener corba_listener; - - g_return_if_fail (storage != CORBA_OBJECT_NIL); - - corba_listener = evolution_storage_listener_corba_objref(listener); - - gtk_signal_connect(GTK_OBJECT(listener), "new_folder", - GTK_SIGNAL_FUNC(new_folder), e_select_names); - gtk_signal_connect(GTK_OBJECT(listener), "removed_folder", - GTK_SIGNAL_FUNC(removed_folder), e_select_names); - - GNOME_Evolution_Storage_addListener(storage, corba_listener, ev); - - if (ev->_major != CORBA_NO_EXCEPTION) { - g_warning ("e_select_names_init: Exception adding listener to " - "remote GNOME_Evolution_Storage interface.\n"); - return; - } -} - -static void -e_select_names_hookup_shell_listeners (ESelectNames *e_select_names) -{ - EvolutionStorage *other_contact_storage; - GNOME_Evolution_Storage storage; - CORBA_Environment ev; - - CORBA_exception_init(&ev); - - storage = (GNOME_Evolution_Storage) (evolution_shell_client_get_local_storage(addressbook_component_get_shell_client())); - e_select_names->local_listener = evolution_storage_listener_new(); - - /* This should really never happen, but a bug report (ximian #5193) came in w/ a backtrace suggesting that it did in - fact happen to someone, so the best we can do is try to avoid crashing in this case. */ - if (storage == CORBA_OBJECT_NIL) { - GtkWidget *oh_shit; - -#if 0 - oh_shit = gnome_error_dialog (_("Evolution is unable to get the addressbook local storage.\n" - "This may have been caused by the evolution-addressbook component crashing.\n" - "To help us better understand and ultimately resolve this problem,\n" - "please send an e-mail to Jon Trowbridge with a\n" - "detailed description of the circumstances under which this error\n" - "occurred. Thank you.")); -#endif - - oh_shit = gnome_error_dialog (_("Evolution is unable to get the addressbook local storage.\n" - "Under normal circumstances, this should never happen.\n" - "You may need to exit and restart Evolution in order to\n" - "correct this problem.")); - gtk_widget_show (oh_shit); - return; - } - else { - hookup_listener (e_select_names, storage, e_select_names->local_listener, &ev); - bonobo_object_release_unref(storage, &ev); - if (ev._major != CORBA_NO_EXCEPTION) { - g_warning ("e_select_names_init: Exception unref'ing " - "remote GNOME_Evolution_Storage interface.\n"); - CORBA_exception_free (&ev); - return; - } - } - - other_contact_storage = addressbook_get_other_contact_storage (); - if (other_contact_storage) { - storage = bonobo_object_corba_objref (BONOBO_OBJECT (other_contact_storage)); - e_select_names->other_contacts_listener = evolution_storage_listener_new(); - - hookup_listener (e_select_names, storage, e_select_names->other_contacts_listener, &ev); - } - - CORBA_exception_free(&ev); -} - -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 *combo; - - ecml = e_categories_master_list_wombat_new (); - combo = e_categories_master_list_combo_new (ecml); - gtk_object_unref (GTK_OBJECT (ecml)); - - return combo; -} - -static void -e_select_names_init (ESelectNames *e_select_names) -{ - GladeXML *gui; - GtkWidget *widget, *button; - - gui = glade_xml_new (EVOLUTION_GLADEDIR "/select-names.glade", NULL); - e_select_names->gui = gui; - - 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; - - widget = glade_xml_get_widget(gui, "table-top"); - if (!widget) { - return; - } - gtk_widget_ref(widget); - gtk_widget_unparent(widget); - gtk_box_pack_start(GTK_BOX(GNOME_DIALOG(e_select_names)->vbox), widget, TRUE, TRUE, 0); - gtk_widget_unref(widget); - - gnome_dialog_append_buttons(GNOME_DIALOG(e_select_names), - GNOME_STOCK_BUTTON_OK, - GNOME_STOCK_BUTTON_CANCEL, - NULL); - gnome_dialog_set_default(GNOME_DIALOG(e_select_names), 0); - - gtk_window_set_title(GTK_WINDOW(e_select_names), _("Select Contacts from Addressbook")); - gtk_window_set_policy(GTK_WINDOW(e_select_names), FALSE, TRUE, FALSE); - - e_select_names->table = E_TABLE_SCROLLED(glade_xml_get_widget(gui, "table-source")); - e_select_names->model = gtk_object_get_data(GTK_OBJECT(e_select_names->table), "model"); - e_select_names->adapter = gtk_object_get_data(GTK_OBJECT(e_select_names->table), "adapter"); - e_select_names->without = gtk_object_get_data(GTK_OBJECT(e_select_names->table), "without"); - - e_select_names->categories = glade_xml_get_widget (gui, "custom-categories"); - if (e_select_names->categories && !GTK_IS_COMBO (e_select_names->categories)) - e_select_names->categories = NULL; - if (e_select_names->categories) { - e_select_names->categories_entry = GTK_COMBO (e_select_names->categories)->entry; - } else - e_select_names->categories_entry = NULL; - e_select_names->search_entry = glade_xml_get_widget (gui, "entry-find"); - if (e_select_names->search_entry && !GTK_IS_ENTRY (e_select_names->search_entry)) - e_select_names->search_entry = NULL; - if (e_select_names->search_entry) - gtk_signal_connect(GTK_OBJECT(e_select_names->search_entry), "activate", - GTK_SIGNAL_FUNC(update_query), e_select_names); - if (e_select_names->categories_entry) - gtk_signal_connect(GTK_OBJECT(e_select_names->categories_entry), "changed", - GTK_SIGNAL_FUNC(update_query), e_select_names); - - button = glade_xml_get_widget (gui, "button-find"); - if (button) - gtk_signal_connect(GTK_OBJECT(button), "clicked", - GTK_SIGNAL_FUNC(update_query), e_select_names); - - e_select_names->folders = g_hash_table_new(g_str_hash, g_str_equal); - - e_select_names_hookup_shell_listeners (e_select_names); - - gtk_signal_connect (GTK_OBJECT (e_table_scrolled_get_table (e_select_names->table)), "double_click", - GTK_SIGNAL_FUNC (add_address), e_select_names); -} - -static void e_select_names_child_free(char *key, ESelectNamesChild *child, ESelectNames *e_select_names) -{ - gtk_signal_disconnect_by_func (GTK_OBJECT (child->source), GTK_SIGNAL_FUNC (sync_table_and_models), e_select_names); - g_free(child->title); - gtk_object_unref(GTK_OBJECT(child->model)); - gtk_object_unref(GTK_OBJECT(child->source)); - g_free(key); -} - -static void -e_select_names_destroy (GtkObject *object) -{ - ESelectNames *e_select_names = E_SELECT_NAMES(object); - - if (e_select_names->local_listener) { - gtk_signal_disconnect_by_data(GTK_OBJECT(e_select_names->local_listener), e_select_names); - gtk_object_unref(GTK_OBJECT(e_select_names->local_listener)); - } - - if (e_select_names->other_contacts_listener) { - gtk_signal_disconnect_by_data(GTK_OBJECT(e_select_names->other_contacts_listener), e_select_names); - gtk_object_unref(GTK_OBJECT(e_select_names->other_contacts_listener)); - } - - gtk_object_unref(GTK_OBJECT(e_select_names->gui)); - 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); - - g_free(e_select_names->def); -} - -GtkWidget* -e_select_names_new (void) -{ - GtkWidget *widget = GTK_WIDGET (gtk_type_new (e_select_names_get_type ())); - return widget; -} - -static void -e_select_names_set_arg (GtkObject *o, GtkArg *arg, guint arg_id) -{ - ESelectNames *editor; - - editor = E_SELECT_NAMES (o); - - switch (arg_id){ - default: - return; - } -} - -static void -e_select_names_get_arg (GtkObject *object, GtkArg *arg, guint arg_id) -{ - ESelectNames *e_select_names; - - e_select_names = E_SELECT_NAMES (object); - - switch (arg_id) { - default: - arg->type = GTK_TYPE_INVALID; - break; - } -} - -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); -} - -struct _RightClickData { - ETable *table; - ESelectNamesChild *child; -}; -typedef struct _RightClickData RightClickData; - -static GSList *selected_rows = NULL; - -static void -etable_selection_foreach_cb (int row, void *data) -{ - /* Build a list of rows in reverse order, then remove them, - necessary because otherwise it'll start trying to delete - rows out of index in ETableModel */ - selected_rows = g_slist_prepend (selected_rows, GINT_TO_POINTER (row)); -} - -static void -selected_rows_foreach_cb (void *row, void *data) -{ - ESelectNamesChild *child = data; - - remove_address (NULL, GPOINTER_TO_INT (row), 0, NULL, child); -} - -static void -remove_cb (GtkWidget *widget, void *data) -{ - RightClickData *rcdata = (RightClickData *)data; - - e_select_names_model_freeze (rcdata->child->source); - - /* Build a list of selected rows */ - e_table_selected_row_foreach (rcdata->table, - etable_selection_foreach_cb, - rcdata->child); - - /* Now process the list we made, removing each selected row */ - g_slist_foreach (selected_rows, - (GFunc)selected_rows_foreach_cb, - rcdata->child); - - e_select_names_model_thaw (rcdata->child->source); - - /* Free everything we've created */ - g_free (rcdata); - g_slist_free (selected_rows); - selected_rows = NULL; -} - -static void -section_right_click_cb (ETable *table, gint row, gint col, GdkEvent *event, ESelectNamesChild *child) -{ - EPopupMenu right_click_menu[] = { - { N_("Remove"), NULL, - GTK_SIGNAL_FUNC (remove_cb), NULL, 0 }, - { NULL, NULL, NULL, 0 } - }; - - RightClickData *rcdata = g_new0 (RightClickData, 1); - rcdata->table = table; - rcdata->child = child; - - e_popup_menu_run (right_click_menu, event, 0, 0, - rcdata); -} - -void -e_select_names_add_section(ESelectNames *e_select_names, char *name, char *id, ESelectNamesModel *source) -{ - ESelectNamesChild *child; - GtkWidget *button; - GtkWidget *alignment; - GtkWidget *label; - GtkTable *table; - char *label_text; - - ETableModel *model; - GtkWidget *etable; - - 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 = e_utf8_from_locale_string(_(name)); - - e_select_names->child_count++; - - alignment = gtk_alignment_new(0, 0, 1, 0); - - button = gtk_button_new (); - - label = e_entry_new (); - gtk_object_set(GTK_OBJECT(label), - "draw_background", FALSE, - "draw_borders", FALSE, - "draw_button", TRUE, - "editable", FALSE, - "text", "", - "use_ellipsis", FALSE, - "justification", GTK_JUSTIFY_CENTER, - NULL); - - label_text = g_strconcat (child->title, " ->", NULL); - gtk_object_set (GTK_OBJECT (label), - "text", label_text, - "emulate_label_resize", TRUE, - NULL); - g_free (label_text); - gtk_container_add (GTK_CONTAINER (button), label); - child->label = label; - - gtk_container_add(GTK_CONTAINER(alignment), button); - gtk_widget_show_all(alignment); - gtk_signal_connect(GTK_OBJECT(button), "clicked", - GTK_SIGNAL_FUNC(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); - - model = e_select_names_table_model_new(source); - etable = e_table_scrolled_new (model, NULL, SPEC2, NULL); - - gtk_signal_connect(GTK_OBJECT(e_table_scrolled_get_table(E_TABLE_SCROLLED(etable))), "right_click", - GTK_SIGNAL_FUNC(section_right_click_cb), child); - gtk_signal_connect(GTK_OBJECT(e_table_scrolled_get_table(E_TABLE_SCROLLED(etable))), "double_click", - GTK_SIGNAL_FUNC(remove_address), child); - - child->model = model; - child->source = source; - gtk_object_ref(GTK_OBJECT(child->model)); - gtk_object_ref(GTK_OBJECT(child->source)); - - gtk_signal_connect (GTK_OBJECT (child->source), - "changed", - GTK_SIGNAL_FUNC (sync_table_and_models), - e_select_names); - - gtk_widget_show(etable); - - gtk_table_attach(table, etable, - 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); -} - -static void * -card_copy(const void *value, void *closure) -{ - gtk_object_ref(GTK_OBJECT(value)); - return (void *)value; -} - -static void -card_free(void *value, void *closure) -{ - gtk_object_unref(GTK_OBJECT(value)); -} - -EList * -e_select_names_get_section(ESelectNames *e_select_names, char *id) -{ - ESelectNamesChild *child; - int i; - int rows; - EList *list; - - child = g_hash_table_lookup(e_select_names->children, id); - if (!child) - return NULL; - rows = e_table_model_row_count(child->model); - - list = e_list_new(card_copy, card_free, NULL); - for (i = 0; i < rows; i++) { - ECard *card = e_cardlist_model_get(E_CARDLIST_MODEL(child->model), i); - e_list_append(list, card); - gtk_object_unref(GTK_OBJECT(card)); - } - return list; -} - -ESelectNamesModel * -e_select_names_get_source(ESelectNames *e_select_names, - char *id) -{ - ESelectNamesChild *child = g_hash_table_lookup(e_select_names->children, id); - if (child) { - if (child->source) - gtk_object_ref(GTK_OBJECT(child->source)); - return child->source; - } else - return NULL; -} - -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) - gtk_object_set (GTK_OBJECT (E_ENTRY (child->label)->item), - "bold", FALSE, - NULL); - } - - 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) - gtk_object_set (GTK_OBJECT (E_ENTRY (child->label)->item), - "bold", TRUE, - NULL); - } -} 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 379a9ef137..0000000000 --- a/addressbook/gui/component/select-names/e-select-names.h +++ /dev/null @@ -1,108 +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 - * - * 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 -#include -#include -#include -#include -#include -#include -#include - -#include - -#include "e-select-names-model.h" -#include "e-util/e-list.h" -#include "shell/evolution-storage-listener.h" - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - -/* ESelectNames - A dialog displaying information about a contact. - * - * The following arguments are available: - * - * name type read/write description - * -------------------------------------------------------------------------------- - */ - -#define E_SELECT_NAMES_TYPE (e_select_names_get_type ()) -#define E_SELECT_NAMES(obj) (GTK_CHECK_CAST ((obj), E_SELECT_NAMES_TYPE, ESelectNames)) -#define E_SELECT_NAMES_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_SELECT_NAMES_TYPE, ESelectNamesClass)) -#define E_IS_SELECT_NAMES(obj) (GTK_CHECK_TYPE ((obj), E_SELECT_NAMES_TYPE)) -#define E_IS_SELECT_NAMES_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), E_SELECT_NAMES_TYPE)) - -typedef struct _ESelectNames ESelectNames; -typedef struct _ESelectNamesClass ESelectNamesClass; - -struct _ESelectNames -{ - GnomeDialog parent; - - /* item specific fields */ - GladeXML *gui; - - GHashTable *children; /* Of type char * to ESelectNamesChild */ - int child_count; - ETableScrolled *table; - ETableModel *adapter; - ETableModel *without; - EAddressbookModel *model; - GtkWidget *categories; - GtkWidget *categories_entry; - GtkWidget *search_entry; - EvolutionStorageListener *local_listener; - EvolutionStorageListener *other_contacts_listener; - GHashTable *folders; - char *def; -}; - -struct _ESelectNamesClass -{ - GnomeDialogClass parent_class; -}; - - -GtkWidget *e_select_names_new (void); -GtkType e_select_names_get_type (void); - -void e_select_names_add_section (ESelectNames *e_select_names, - char *name, - char *id, - ESelectNamesModel *source); -ESelectNamesModel *e_select_names_get_source (ESelectNames *e_select_names, - char *id); -void e_select_names_set_default (ESelectNames *e_select_names, - const char *id); -/* Returns a ref counted list of addresses. */ -EList *e_select_names_get_section (ESelectNames *e_select_names, - char *id); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - - -#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 b60972d094..0000000000 --- a/addressbook/gui/component/select-names/recipient.glade +++ /dev/null @@ -1,61 +0,0 @@ - - - - - Recipient - recipient - - src - pixmaps - C - True - True - True - False - False - False - True - - - - GtkWindow - window1 - False - window1 - GTK_WINDOW_TOPLEVEL - GTK_WIN_POS_NONE - False - False - True - False - - - GtkHBox - hbox-top - False - 4 - - - GtkAlignment - alignment1 - 1.08033e-07 - 0 - 1 - 0 - - 0 - False - True - - - - GtkButton - text-button - True - - - - - - - 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 dbfd36f86f..0000000000 --- a/addressbook/gui/component/select-names/select-names.glade +++ /dev/null @@ -1,444 +0,0 @@ - - - - - Select-names - select-names - - src - pixmaps - C - True - True - False - False - False - - - - GnomeDialog - dialog-top - False - Select Names - GTK_WINDOW_TOPLEVEL - GTK_WIN_POS_NONE - False - 417 - 332 - False - True - False - False - False - - - GtkVBox - GnomeDialog:vbox - dialog-vbox1 - False - 8 - - 4 - True - True - - - - GtkHButtonBox - GnomeDialog:action_area - dialog-action_area1 - GTK_BUTTONBOX_END - 8 - 85 - 27 - 7 - 0 - - 0 - False - True - GTK_PACK_END - - - - GtkButton - button4 - True - True - True - GNOME_STOCK_BUTTON_OK - - - - GtkButton - button5 - True - GNOME_STOCK_BUTTON_CANCEL - - - - - GtkTable - table-top - 2 - 1 - False - 0 - 0 - - 0 - True - True - - - - GtkVBox - vbox5 - False - 0 - - 0 - 1 - 1 - 2 - 0 - 0 - False - True - False - False - True - True - - - - GtkTable - table4 - 2 - 2 - False - 6 - 6 - - 0 - True - True - - - - GtkTable - table-recipients - 1 - 2 - False - 4 - 4 - - 1 - 2 - 0 - 2 - 0 - 0 - True - False - False - False - True - True - - - - GtkLabel - label20 - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - - 1 - 2 - 0 - 1 - 0 - 0 - False - False - False - False - True - False - - - - - - GtkVBox - vbox6 - False - 3 - - 0 - 1 - 0 - 2 - 0 - 0 - True - True - False - False - True - True - - - - GtkLabel - label22 - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - - 0 - False - False - - - - - Custom - table-source - e_addressbook_create_ebook_table - 0 - 0 - Sat, 10 Jun 2000 22:02:57 GMT - - 0 - True - True - - - - - - - - GtkVBox - dialog-vbox1 - False - 0 - - 0 - 1 - 0 - 1 - 0 - 0 - True - False - False - False - True - False - - - - GtkVBox - vbox3 - 3 - False - 3 - - 0 - False - False - - - - GtkLabel - label4 - - GTK_JUSTIFY_LEFT - False - 0 - 0.5 - 0 - 0 - - 0 - False - False - - - - - GtkHBox - hbox1 - 3 - False - 8 - - 0 - False - True - - - - GtkLabel - label5 - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 0 - 0 - optionmenu-folder - - 0 - False - False - - - - - GtkOptionMenu - optionmenu-folder - True - - 0 - - 0 - True - True - - - - - GtkLabel - label6 - - GTK_JUSTIFY_RIGHT - False - 1 - 0.5 - 0 - 0 - custom-categories - - 0 - False - True - - - - - Custom - custom-categories - True - e_select_names_create_categories - 0 - 0 - Wed, 27 Jun 2001 01:47:01 GMT - - 0 - True - True - - - - - - GtkHBox - hbox2 - 3 - False - 3 - - 0 - True - True - - - - GtkLabel - label7 - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 0 - 0 - entry-find - - 0 - False - False - - - - - GtkEntry - entry-find - True - True - True - 0 - - - 0 - True - True - - - - - GtkHButtonBox - hbuttonbox1 - GTK_BUTTONBOX_DEFAULT_STYLE - 0 - 85 - 27 - 7 - 0 - - 0 - False - False - - - - GtkButton - button-find - True - True - - GTK_RELIEF_NORMAL - - - - - - - GtkHSeparator - hseparator1 - - 8 - False - False - - - - - - - - -- cgit v1.2.3