diff options
Diffstat (limited to 'addressbook/gui/component/select-names')
29 files changed, 0 insertions, 7621 deletions
diff --git a/addressbook/gui/component/select-names/.cvsignore b/addressbook/gui/component/select-names/.cvsignore deleted file mode 100644 index d9b150c040..0000000000 --- a/addressbook/gui/component/select-names/.cvsignore +++ /dev/null @@ -1,15 +0,0 @@ -.deps -.libs -.pure -Makefile -Makefile.in -*.lo -*.la -Evolution-Addressbook-SelectNames-stubs.c -Evolution-Addressbook-SelectNames-skels.c -Evolution-Addressbook-SelectNames-common.c -Evolution-Addressbook-SelectNames.h -GNOME_Evolution_Addressbook_SelectNames.server -GNOME_Evolution_Addressbook_SelectNames.server.in -e-select-names-marshal.c -e-select-names-marshal.h diff --git a/addressbook/gui/component/select-names/Evolution-Addressbook-SelectNames.idl b/addressbook/gui/component/select-names/Evolution-Addressbook-SelectNames.idl deleted file mode 100644 index 2959597cc5..0000000000 --- a/addressbook/gui/component/select-names/Evolution-Addressbook-SelectNames.idl +++ /dev/null @@ -1,114 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * CORBA interface for the SelectNames dialog. - * - * Authors: - * Ettore Perazzoli <ettore@ximian.com> - * - * Copyright (C) 2000 Ximian, Inc. - */ - -#include <Bonobo.idl> - -module GNOME { -module Evolution { -module Addressbook { - - interface SimpleCard : Bonobo::Unknown { - struct Arbitrary { - string key; - string type; - string value; - }; - - enum Field { - FileAs, - FullName, - Email, - PhonePrimary, - PhoneAssistant, - PhoneBusiness, - PhoneCallback, - PhoneCompany, - PhoneHome, - Org, - AddressBusiness, - AddressHome, - PhoneMobile, - PhoneCar, - PhoneBusinessFax, - PhoneHomeFax, - PhoneBusiness2, - PhoneHome2, - PhoneIsdn, - PhoneOther, - PhoneOtherFax, - PhonePager, - PhoneRadio, - PhoneTelex, - PhoneTtytdd, - AddressOther, - Email2, - Email3, - Url, - OrgUnit, - Office, - Title, - Role, - Manager, - Assistant, - Nickname, - Spouse, - Note, - Caluri, - Fburl, - Icscalendar, - Anniversary, - BirthDate, - Mailer, - NameOrOrg, - Categories, - FamilyName, - GivenName, - AdditionalName, - NameSuffix, - WantsHtml, - IsList, - Last - }; - - Arbitrary getArbitrary (in string key); - void setArbitrary (in string key, in string type, in string value); - - string get (in Field field); - void set (in Field field, in string value); - }; - - typedef sequence<SimpleCard> SimpleCardList; - - interface SelectNames : Bonobo::Unknown { - struct Section { - string id; - string title; - }; - - typedef sequence<Section> SectionList; - - exception DuplicateID {}; - exception SectionNotFound {}; - - void addSection (in string id, in string title) - raises (DuplicateID); - void addSectionWithLimit (in string id, in string title, in short limit) - raises (DuplicateID); - - Bonobo::Control getEntryBySection (in string section_id) - raises (SectionNotFound); - - void activateDialog (in string section_id); - }; - - -}; -}; -}; diff --git a/addressbook/gui/component/select-names/GNOME_Evolution_Addressbook_SelectNames.server.in.in b/addressbook/gui/component/select-names/GNOME_Evolution_Addressbook_SelectNames.server.in.in deleted file mode 100644 index 6e4d156051..0000000000 --- a/addressbook/gui/component/select-names/GNOME_Evolution_Addressbook_SelectNames.server.in.in +++ /dev/null @@ -1,31 +0,0 @@ -<oaf_info> - -<!-- -<oaf_server iid="OAFIID:GNOME_Evolution_Addressbook_SelectNamesFactory" - type="shlib" - location="@COMPONENTDIR@/libevolution-addressbook.so"> - - <oaf_attribute name="repo_ids" type="stringv"> - <item value="IDL:GNOME/ObjectFactory:1.0"/> - </oaf_attribute> - - <oaf_attribute name="name" type="string" - _value="Evolution Addressbook name selection interface"/> - -</oaf_server> ---> - -<oaf_server iid="OAFIID:GNOME_Evolution_Addressbook_SelectNames" - type="factory" - location="OAFIID:GNOME_Evolution_Addressbook_Factory"> - - <oaf_attribute name="repo_ids" type="stringv"> - <item value="IDL:GNOME/Evolution/Addressbook/SelectNames"/> - </oaf_attribute> - - <oaf_attribute name="name" type="string" - _value="Evolution Addressbook name selection interface"/> - -</oaf_server> - -</oaf_info>
\ 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 72a09715ca..0000000000 --- a/addressbook/gui/component/select-names/Makefile.am +++ /dev/null @@ -1,115 +0,0 @@ -# CORBA stuff - -idl_DATA = \ - Evolution-Addressbook-SelectNames.idl - -IDL_GENERATED_H = \ - Evolution-Addressbook-SelectNames.h -IDL_GENERATED_C = \ - Evolution-Addressbook-SelectNames-common.c \ - Evolution-Addressbook-SelectNames-skels.c \ - Evolution-Addressbook-SelectNames-stubs.c -IDL_GENERATED = $(IDL_GENERATED_C) $(IDL_GENERATED_H) - -$(IDL_GENERATED_H): $(idl_DATA) - $(ORBIT_IDL) -I $(srcdir) $(IDL_INCLUDES) \ - $(srcdir)/Evolution-Addressbook-SelectNames.idl -$(IDL_GENERATED_C): $(IDL_GENERATED_H) - -server_in_files = GNOME_Evolution_Addressbook_SelectNames.server.in.in - -server_DATA = $(server_in_files:.server.in.in=.server) -%.server.in: %.server.in.in - sed -e "s|\@COMPONENTDIR\@|$(componentdir)|" $< > $@ - -@INTLTOOL_SERVER_RULE@ - -INCLUDES = \ - -DG_LOG_DOMAIN=\"evolution-addressbook\" \ - -I$(top_srcdir) \ - -I$(top_builddir) \ - -I$(top_srcdir)/shell \ - -I$(top_builddir)/shell \ - -I$(top_srcdir)/widgets/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 \ - -DEVOLUTION_IMAGESDIR=\""$(imagesdir)"\" \ - -DEVOLUTION_DATADIR=\""$(datadir)"\" \ - -DEVOLUTION_GLADEDIR=\""$(gladedir)"\" \ - -DEVOLUTION_ETSPECDIR=\""$(etspecdir)"\" \ - -DEVOLUTION_UIDIR=\""$(evolutionuidir)"\" \ - -DPREFIX=\""$(prefix)"\" \ - -DG_DISABLE_DEPRECATED \ - -DGTK_DISABLE_DEPRECATED \ - -DLIBGNOME_DISABLE_DEPRECATED \ - -DLIBGNOMEUI_DISABLE_DEPRECATED \ - $(EVOLUTION_ADDRESSBOOK_CFLAGS) - -privlib_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-manager.c \ - e-select-names-manager.h \ - e-select-names-marshal.c \ - 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 \ - e-simple-card-bonobo.c \ - e-simple-card-bonobo.h - -libeselectnames_la_LIBADD = \ - $(top_builddir)/addressbook/backend/ebook/libebook.la \ - $(EVOLUTION_ADDRESSBOOK_LIBS) - -# We'll need these again when we split out the select names control -# into its own shlib factory, but for now they're redundant. -# -# e-select-names-factory.c -# e-select-names-factory.h - -# GLib marshalling cruft - -e-select-names-marshal.h: e-select-names-marshal.list - ( @GLIB_GENMARSHAL@ --prefix=e_select_names_marshal e-select-names-marshal.list --header > e-select-names-marshal.tmp \ - && mv e-select-names-marshal.tmp e-select-names-marshal.h ) \ - || ( rm -f e-select-names-marshal.tmp && exit 1 ) - -e-select-names-marshal.c: e-select-names-marshal.h - ( @GLIB_GENMARSHAL@ --prefix=e_select_names_marshal e-select-names-marshal.list --body > e-select-names-marshal.tmp \ - && mv e-select-names-marshal.tmp e-select-names-marshal.c ) \ - || ( rm -f e-select-names-marshal.tmp && exit 1 ) - -MARSHAL_GENERATED = e-select-names-marshal.c e-select-names-marshal.h - -glade_DATA = select-names.glade -etspec_DATA = e-select-names.etspec e-select-names-section.etspec - -EXTRA_DIST = \ - $(glade_DATA) \ - $(server_in_files) \ - $(server_DATA) \ - $(idl_DATA) \ - $(etspec_DATA) \ - e-select-names-marshal.list - -BUILT_SOURCES = $(IDL_GENERATED) $(MARSHAL_GENERATED) $(server_DATA) -CLEANFILES = $(BUILT_SOURCES) - -dist-hook: - cd $(distdir); rm -f $(BUILT_SOURCES) diff --git a/addressbook/gui/component/select-names/e-select-names-bonobo.c b/addressbook/gui/component/select-names/e-select-names-bonobo.c deleted file mode 100644 index 10fc9caee7..0000000000 --- a/addressbook/gui/component/select-names/e-select-names-bonobo.c +++ /dev/null @@ -1,651 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-select-names-bonobo.c - * - * Copyright (C) 2000 Ximian, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Author: Ettore Perazzoli - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include "e-select-names-bonobo.h" -#include "e-simple-card-bonobo.h" - -#include <bonobo-activation/bonobo-activation-activate.h> - -#include <bonobo/bonobo-property-bag.h> -#include <bonobo/bonobo-control.h> -#include <bonobo/bonobo-exception.h> -#include <bonobo/bonobo-event-source.h> -#include <bonobo/bonobo-ui-util.h> - -#include <gal/util/e-util.h> -#include <gal/e-text/e-entry.h> -#include <gal/util/e-text-event-processor.h> - -#include "evolution-shell-client.h" - -#include "Evolution-Addressbook-SelectNames.h" - -#include "e-select-names-manager.h" -#include "e-select-names-model.h" -#include "e-select-names-text-model.h" -#include "e-select-names-completion.h" - -#include <string.h> - - -#define PARENT_TYPE BONOBO_TYPE_OBJECT -static BonoboObjectClass *parent_class = NULL; - -struct _ESelectNamesBonoboPrivate { - ESelectNamesManager *manager; - BonoboEventSource *event_source; -}; - -enum _EntryPropertyID { - ENTRY_PROPERTY_ID_TEXT, - ENTRY_PROPERTY_ID_ADDRESSES, - ENTRY_PROPERTY_ID_DESTINATIONS, - ENTRY_PROPERTY_ID_SIMPLE_CARD_LIST, - ENTRY_PROPERTY_ID_ALLOW_CONTACT_LISTS, - ENTRY_PROPERTY_ID_ENTRY_CHANGED -}; -typedef enum _EntryPropertyID EntryPropertyID; - - -/* PropertyBag implementation for the entry widgets. */ - -static void -entry_get_property_fn (BonoboPropertyBag *bag, - BonoboArg *arg, - unsigned int arg_id, - CORBA_Environment *ev, - void *user_data) -{ - GtkWidget *w; - - w = GTK_WIDGET (user_data); - - switch (arg_id) { - case ENTRY_PROPERTY_ID_TEXT: - { - ETextModel *text_model; - text_model = E_TEXT_MODEL (g_object_get_data (G_OBJECT (w), "select_names_text_model")); - g_assert (text_model != NULL); - - BONOBO_ARG_SET_STRING (arg, e_text_model_get_text (text_model)); - break; - } - - case ENTRY_PROPERTY_ID_ADDRESSES: - { - ESelectNamesModel *model; - char *text; - - model = E_SELECT_NAMES_MODEL (g_object_get_data (G_OBJECT (w), "select_names_model")); - g_assert (model != NULL); - - text = e_select_names_model_get_address_text (model, ", "); - BONOBO_ARG_SET_STRING (arg, text); - g_free (text); - } - break; - - case ENTRY_PROPERTY_ID_DESTINATIONS: - { - ESelectNamesModel *model; - char *text; - - model = E_SELECT_NAMES_MODEL (g_object_get_data (G_OBJECT (w), "select_names_model")); - g_assert (model != NULL); - - text = e_select_names_model_export_destinationv (model); - BONOBO_ARG_SET_STRING (arg, text); - g_free (text); - } - break; - - case ENTRY_PROPERTY_ID_SIMPLE_CARD_LIST: - { - ESelectNamesModel *model; - int count; - int i; - GNOME_Evolution_Addressbook_SimpleCardList *card_list; - - model = E_SELECT_NAMES_MODEL (g_object_get_data (G_OBJECT (w), "select_names_model")); - g_assert (model != NULL); - - count = e_select_names_model_count (model); - - card_list = GNOME_Evolution_Addressbook_SimpleCardList__alloc (); - card_list->_buffer = CORBA_sequence_GNOME_Evolution_Addressbook_SimpleCard_allocbuf (count); - card_list->_maximum = count; - card_list->_length = count; - - for (i = 0; i < count; i++) { - const EDestination *destination = e_select_names_model_get_destination (model, i); - const ECard *card = e_destination_get_card (destination); - ECardSimple *simple = e_card_simple_new ((ECard *) card); - ESimpleCardBonobo *simple_card = e_simple_card_bonobo_new (simple); - g_object_unref (simple); - - card_list->_buffer[i] = bonobo_object_corba_objref (BONOBO_OBJECT (simple_card)); - } - - CORBA_free (*(GNOME_Evolution_Addressbook_SimpleCardList **)arg->_value); - BONOBO_ARG_SET_GENERAL (arg, *card_list, TC_GNOME_Evolution_Addressbook_SimpleCardList, GNOME_Evolution_Addressbook_SimpleCardList, NULL); - } - break; - - case ENTRY_PROPERTY_ID_ALLOW_CONTACT_LISTS: - { - ESelectNamesCompletion *comp; - comp = E_SELECT_NAMES_COMPLETION (g_object_get_data (G_OBJECT (w), "completion_handler")); - g_assert (comp != NULL); - - BONOBO_ARG_SET_BOOLEAN (arg, e_select_names_completion_get_match_contact_lists (comp)); - break; - } - - case ENTRY_PROPERTY_ID_ENTRY_CHANGED: - /* This is a read-only property. */ - g_assert_not_reached (); - break; - - default: - break; - } -} - -static void -entry_set_property_fn (BonoboPropertyBag *bag, - const BonoboArg *arg, - guint arg_id, - CORBA_Environment *ev, - gpointer user_data) -{ - GtkWidget *w; - - w = GTK_WIDGET (user_data); - - switch (arg_id) { - - case ENTRY_PROPERTY_ID_TEXT: - case ENTRY_PROPERTY_ID_ADDRESSES: - { - ESelectNamesModel *model; - model = E_SELECT_NAMES_MODEL (g_object_get_data (G_OBJECT (w), "select_names_model")); - g_assert (model != NULL); - - e_entry_set_text (E_ENTRY (w), BONOBO_ARG_GET_STRING (arg)); - e_select_names_model_cardify_all (model, NULL, 0); - break; - } - - case ENTRY_PROPERTY_ID_DESTINATIONS: - { - ESelectNamesModel *model; - model = E_SELECT_NAMES_MODEL (g_object_get_data (G_OBJECT (w), "select_names_model")); - g_assert (model != NULL); - - e_select_names_model_import_destinationv (model, BONOBO_ARG_GET_STRING (arg)); - e_select_names_model_cardify_all (model, NULL, 0); - break; - } - - case ENTRY_PROPERTY_ID_ALLOW_CONTACT_LISTS: - { - ESelectNamesCompletion *comp; - comp = E_SELECT_NAMES_COMPLETION (g_object_get_data (G_OBJECT (w), "completion_handler")); - g_assert (comp != NULL); - - e_select_names_completion_set_match_contact_lists (comp, BONOBO_ARG_GET_BOOLEAN (arg)); - break; - } - - case ENTRY_PROPERTY_ID_ENTRY_CHANGED: - g_object_set_data (G_OBJECT (w), "entry_property_id_changed", GUINT_TO_POINTER (1)); - break; - - default: - break; - } -} - -static void -impl_SelectNames_add_section (PortableServer_Servant servant, - const CORBA_char *id, - const CORBA_char *title, - CORBA_Environment *ev) -{ - ESelectNamesBonobo *select_names; - ESelectNamesBonoboPrivate *priv; - - select_names = E_SELECT_NAMES_BONOBO (bonobo_object (servant)); - priv = select_names->priv; - - e_select_names_manager_add_section (priv->manager, id, title); -} - -static void -impl_SelectNames_add_section_with_limit (PortableServer_Servant servant, - const CORBA_char *id, - const CORBA_char *title, - CORBA_short limit, - CORBA_Environment *ev) -{ - ESelectNamesBonobo *select_names; - ESelectNamesBonoboPrivate *priv; - - select_names = E_SELECT_NAMES_BONOBO (bonobo_object (servant)); - priv = select_names->priv; - - e_select_names_manager_add_section_with_limit (priv->manager, id, title, limit); -} - -static void -entry_changed (GtkWidget *widget, BonoboControl *control) -{ - gboolean changed = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (widget), "entry_property_id_changed")); - - if (!changed) - bonobo_control_set_property (control, NULL, "entry_changed", TC_CORBA_boolean, TRUE, NULL); -} - -static void -manager_changed_cb (ESelectNamesManager *manager, const gchar *section_id, gint changed_working_copy, gpointer closure) -{ - ESelectNamesBonobo *select_names = E_SELECT_NAMES_BONOBO (closure); - BonoboArg *arg; - - arg = bonobo_arg_new (BONOBO_ARG_STRING); - BONOBO_ARG_SET_STRING (arg, section_id); - - bonobo_event_source_notify_listeners_full (select_names->priv->event_source, - "GNOME/Evolution", - "changed", - changed_working_copy ? "working_copy" : "model", - arg, NULL); - - bonobo_arg_release (arg); -} - -static void -manager_ok_cb (ESelectNamesManager *manager, gpointer closure) -{ - ESelectNamesBonobo *select_names = E_SELECT_NAMES_BONOBO (closure); - BonoboArg *arg; - - arg = bonobo_arg_new (BONOBO_ARG_NULL); - - bonobo_event_source_notify_listeners_full (select_names->priv->event_source, - "GNOME/Evolution", - "ok", - "dialog", - arg, - NULL); - - bonobo_arg_release (arg); -} - -static void -copy_cb (BonoboUIComponent *ui, gpointer user_data, const char *command) -{ - EEntry *entry = E_ENTRY (user_data); - - e_text_copy_clipboard (entry->item); -} - -static void -cut_cb (BonoboUIComponent *ui, gpointer user_data, const char *command) -{ - EEntry *entry = E_ENTRY (user_data); - - e_text_cut_clipboard (entry->item); -} - -static void -paste_cb (BonoboUIComponent *ui, gpointer user_data, const char *command) -{ - EEntry *entry = E_ENTRY (user_data); - - e_text_paste_clipboard (entry->item); -} - -static void -select_all_cb (BonoboUIComponent *ui, gpointer user_data, const char *command) -{ - EEntry *entry = E_ENTRY (user_data); - - e_text_select_all (entry->item); -} - -static BonoboUIVerb verbs [] = { - BONOBO_UI_VERB ("EditCut", cut_cb), - BONOBO_UI_VERB ("EditCopy", copy_cb), - BONOBO_UI_VERB ("EditPaste", paste_cb), - BONOBO_UI_VERB ("EditSelectAll", select_all_cb), - BONOBO_UI_VERB_END -}; - -typedef struct { - GtkWidget *widget; - BonoboControl *control; - Bonobo_UIContainer remote_ui_container; - char *ui_xml_path; - char *app_name; - BonoboUIVerb *verbs; - gpointer user_data; -} ControlUIClosure; - -static void -free_closure (ControlUIClosure *closure, - GtkObject *where_object_was) -{ - bonobo_object_release_unref (closure->remote_ui_container, NULL); - g_free (closure->ui_xml_path); - g_free (closure->app_name); - g_free (closure); -} - -static void -merge_menu_items (BonoboControl *control, BonoboUIComponent *uic, ControlUIClosure *closure) -{ - if (closure->remote_ui_container) { - bonobo_ui_component_set_container (uic, closure->remote_ui_container, NULL); - - bonobo_ui_component_add_verb_list_with_data (uic, closure->verbs, closure->user_data); - - bonobo_ui_component_freeze (uic, NULL); - - bonobo_ui_util_set_ui (uic, PREFIX, - closure->ui_xml_path, - closure->app_name, NULL); - - bonobo_ui_component_thaw (uic, NULL); - } -} - -static void -unmerge_menu_items (BonoboControl *control, BonoboUIComponent *uic, ControlUIClosure *closure) -{ - bonobo_ui_component_unset_container (uic, NULL); -} - -static void -control_set_frame_cb (BonoboControl *control, - ControlUIClosure *closure) -{ - Bonobo_ControlFrame frame = bonobo_control_get_control_frame (control, - NULL); - if (!frame) - return; - closure->remote_ui_container = bonobo_control_get_remote_ui_container (control, NULL); -} - -static void -control_activate_cb (BonoboControl *control, - gboolean activate, - ControlUIClosure *closure) -{ - if (activate) - gtk_widget_grab_focus (closure->widget); /* the ECanvas */ -} - -static gboolean -widget_focus_cb (GtkWidget *w, GdkEventFocus *focus, ControlUIClosure *closure) -{ - BonoboUIComponent *uic; - - uic = bonobo_control_get_ui_component (closure->control); - - if (GTK_WIDGET_HAS_FOCUS (w)) { - merge_menu_items (closure->control, uic, closure); - } else { - unmerge_menu_items (closure->control, uic, closure); - } - - return FALSE; -} - -static void -e_bonobo_control_automerge_ui (GtkWidget *w, - BonoboControl *control, - const char *ui_xml_path, - const char *app_name, - BonoboUIVerb *verbs, - gpointer data) -{ - ControlUIClosure *closure; - - g_return_if_fail (GTK_IS_WIDGET (w)); - g_return_if_fail (BONOBO_IS_CONTROL (control)); - g_return_if_fail (ui_xml_path != NULL); - g_return_if_fail (app_name != NULL); - g_return_if_fail (verbs != NULL); - - closure = g_new (ControlUIClosure, 1); - - closure->widget = w; - closure->control = control; - closure->ui_xml_path = g_strdup (ui_xml_path); - closure->app_name = g_strdup (app_name); - closure->verbs = verbs; - closure->user_data = data; - - g_signal_connect (w, "focus_in_event", - G_CALLBACK (widget_focus_cb), closure); - g_signal_connect (w, "focus_out_event", - G_CALLBACK (widget_focus_cb), closure); - g_signal_connect (control, "activate", - G_CALLBACK (control_activate_cb), closure); - g_signal_connect (control, "set_frame", - G_CALLBACK (control_set_frame_cb), closure); - - g_object_weak_ref (G_OBJECT (control), (GWeakNotify)free_closure, closure); -} - -static Bonobo_Control -impl_SelectNames_get_entry_for_section (PortableServer_Servant servant, - const CORBA_char *section_id, - CORBA_Environment *ev) -{ - ESelectNamesBonobo *select_names; - ESelectNamesBonoboPrivate *priv; - GtkWidget *entry_widget; - BonoboControl *control; - BonoboPropertyBag *property_bag; - - select_names = E_SELECT_NAMES_BONOBO (bonobo_object (servant)); - priv = select_names->priv; - - entry_widget = e_select_names_manager_create_entry (priv->manager, section_id); - gtk_widget_show (entry_widget); - - if (entry_widget == NULL) { - CORBA_exception_set (ev, - CORBA_USER_EXCEPTION, - ex_GNOME_Evolution_Addressbook_SelectNames_SectionNotFound, - NULL); - return CORBA_OBJECT_NIL; - } - - control = bonobo_control_new (entry_widget); - - property_bag = bonobo_property_bag_new (entry_get_property_fn, entry_set_property_fn, entry_widget); - bonobo_property_bag_add (property_bag, "text", ENTRY_PROPERTY_ID_TEXT, - BONOBO_ARG_STRING, NULL, NULL, - BONOBO_PROPERTY_READABLE | BONOBO_PROPERTY_WRITEABLE); - bonobo_property_bag_add (property_bag, "addresses", ENTRY_PROPERTY_ID_ADDRESSES, - BONOBO_ARG_STRING, NULL, NULL, - BONOBO_PROPERTY_READABLE | BONOBO_PROPERTY_WRITEABLE); - bonobo_property_bag_add (property_bag, "destinations", ENTRY_PROPERTY_ID_DESTINATIONS, - BONOBO_ARG_STRING, NULL, NULL, - BONOBO_PROPERTY_READABLE | BONOBO_PROPERTY_WRITEABLE); - bonobo_property_bag_add (property_bag, "simple_card_list", ENTRY_PROPERTY_ID_SIMPLE_CARD_LIST, - TC_GNOME_Evolution_Addressbook_SimpleCardList, NULL, NULL, - BONOBO_PROPERTY_READABLE); - bonobo_property_bag_add (property_bag, "allow_contact_lists", ENTRY_PROPERTY_ID_ALLOW_CONTACT_LISTS, - BONOBO_ARG_BOOLEAN, NULL, NULL, - BONOBO_PROPERTY_READABLE | BONOBO_PROPERTY_WRITEABLE); - bonobo_property_bag_add (property_bag, "entry_changed", ENTRY_PROPERTY_ID_ENTRY_CHANGED, - BONOBO_ARG_BOOLEAN, NULL, NULL, - BONOBO_PROPERTY_WRITEABLE); - - bonobo_control_set_properties (control, bonobo_object_corba_objref (BONOBO_OBJECT (property_bag)), NULL); - bonobo_object_unref (BONOBO_OBJECT (property_bag)); - - g_signal_connect (entry_widget, "changed", G_CALLBACK (entry_changed), control); - - e_bonobo_control_automerge_ui (GTK_WIDGET (E_ENTRY (entry_widget)->canvas), - control, - EVOLUTION_UIDIR "/evolution-composer-entries.xml", - "evolution-addressbook", - verbs, entry_widget); - - return CORBA_Object_duplicate (bonobo_object_corba_objref (BONOBO_OBJECT (control)), ev); -} - -static void -impl_SelectNames_activate_dialog (PortableServer_Servant servant, - const CORBA_char *section_id, - CORBA_Environment *ev) -{ - ESelectNamesBonobo *select_names; - ESelectNamesBonoboPrivate *priv; - EvolutionShellClient *shell_client; - GNOME_Evolution_Shell shell; - - select_names = E_SELECT_NAMES_BONOBO (bonobo_object (servant)); - priv = select_names->priv; - - shell = bonobo_activation_activate_from_id ( - "OAFIID:GNOME_Evolution_Shell", - Bonobo_ACTIVATION_FLAG_EXISTING_ONLY, - NULL, ev); - if (BONOBO_EX (ev)) - return; - - shell_client = evolution_shell_client_new (shell); - e_select_names_manager_activate_dialog (priv->manager, shell_client, - section_id); - g_object_unref (shell_client); -} - - -/* GtkObject methods. */ - -static void -impl_dispose (GObject *object) -{ - ESelectNamesBonobo *select_names; - ESelectNamesBonoboPrivate *priv; - - select_names = E_SELECT_NAMES_BONOBO (object); - priv = select_names->priv; - - if (priv) { - if (priv->manager->names) { - gtk_widget_destroy (GTK_WIDGET (priv->manager->names)); - priv->manager->names = NULL; - } - - g_object_unref (priv->manager); - - g_free (priv); - select_names->priv = NULL; - } - - if (G_OBJECT_CLASS (parent_class)->dispose) - G_OBJECT_CLASS (parent_class)->dispose (object); -} - - -static void -e_select_names_bonobo_class_init (ESelectNamesBonoboClass *klass) -{ - GObjectClass *object_class; - POA_GNOME_Evolution_Addressbook_SelectNames__epv *epv; - - object_class = G_OBJECT_CLASS (klass); - parent_class = g_type_class_peek_parent (klass); - - object_class->dispose = impl_dispose; - - epv = &klass->epv; - epv->addSection = impl_SelectNames_add_section; - epv->addSectionWithLimit = impl_SelectNames_add_section_with_limit; - epv->getEntryBySection = impl_SelectNames_get_entry_for_section; - epv->activateDialog = impl_SelectNames_activate_dialog; -} - -static void -e_select_names_bonobo_init (ESelectNamesBonobo *select_names) -{ - ESelectNamesBonoboPrivate *priv; - - priv = g_new (ESelectNamesBonoboPrivate, 1); - - priv->manager = e_select_names_manager_new (); - priv->event_source = NULL; - - g_signal_connect (priv->manager, - "changed", - G_CALLBACK (manager_changed_cb), - select_names); - - g_signal_connect (priv->manager, - "ok", - G_CALLBACK (manager_ok_cb), - select_names); - - select_names->priv = priv; -} - - -static void -e_select_names_bonobo_construct (ESelectNamesBonobo *select_names) -{ - g_return_if_fail (select_names != NULL); - g_return_if_fail (E_IS_SELECT_NAMES_BONOBO (select_names)); - - g_assert (select_names->priv->event_source == NULL); - select_names->priv->event_source = bonobo_event_source_new (); - bonobo_object_add_interface (BONOBO_OBJECT (select_names), BONOBO_OBJECT (select_names->priv->event_source)); -} - -ESelectNamesBonobo * -e_select_names_bonobo_new (void) -{ - ESelectNamesBonobo *select_names; - - select_names = g_object_new (E_TYPE_SELECT_NAMES_BONOBO, NULL); - - e_select_names_bonobo_construct (select_names); - - return select_names; -} - - -BONOBO_TYPE_FUNC_FULL ( - ESelectNamesBonobo, - GNOME_Evolution_Addressbook_SelectNames, - PARENT_TYPE, - e_select_names_bonobo); diff --git a/addressbook/gui/component/select-names/e-select-names-bonobo.h b/addressbook/gui/component/select-names/e-select-names-bonobo.h deleted file mode 100644 index 5b04ed5b2e..0000000000 --- a/addressbook/gui/component/select-names/e-select-names-bonobo.h +++ /dev/null @@ -1,66 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-select-names-bonobo.h - * - * Copyright (C) 2000 Ximian, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Author: Ettore Perazzoli - */ - -#ifndef __E_SELECT_NAMES_BONOBO_H__ -#define __E_SELECT_NAMES_BONOBO_H__ - -#include <bonobo/bonobo-object.h> - -#include "Evolution-Addressbook-SelectNames.h" - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - -#define E_TYPE_SELECT_NAMES_BONOBO (e_select_names_bonobo_get_type ()) -#define E_SELECT_NAMES_BONOBO(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_SELECT_NAMES_BONOBO, ESelectNamesBonobo)) -#define E_SELECT_NAMES_BONOBO_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_SELECT_NAMES_BONOBO, ESelectNamesBonoboClass)) -#define E_IS_SELECT_NAMES_BONOBO(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_SELECT_NAMES_BONOBO)) -#define E_IS_SELECT_NAMES_BONOBO_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), E_TYPE_SELECT_NAMES_BONOBO)) - - -typedef struct _ESelectNamesBonobo ESelectNamesBonobo; -typedef struct _ESelectNamesBonoboPrivate ESelectNamesBonoboPrivate; -typedef struct _ESelectNamesBonoboClass ESelectNamesBonoboClass; - -struct _ESelectNamesBonobo { - BonoboObject parent; - - ESelectNamesBonoboPrivate *priv; -}; - -struct _ESelectNamesBonoboClass { - BonoboObjectClass parent_class; - - POA_GNOME_Evolution_Addressbook_SelectNames__epv epv; -}; - - -GType e_select_names_bonobo_get_type (void); -ESelectNamesBonobo *e_select_names_bonobo_new (void); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* __E_SELECT_NAMES_BONOBO_H__ */ diff --git a/addressbook/gui/component/select-names/e-select-names-completion.c b/addressbook/gui/component/select-names/e-select-names-completion.c deleted file mode 100644 index 5a9fc2deb4..0000000000 --- a/addressbook/gui/component/select-names/e-select-names-completion.c +++ /dev/null @@ -1,1207 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * e-select-names-completion.c - * - * Copyright (C) 2001 Ximian, Inc. - * - * Developed by Jon Trowbridge <trow@ximian.com> - */ - -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - */ - -#include <config.h> -#include "e-select-names-completion.h" - -#include <ctype.h> -#include <stdio.h> -#include <string.h> -#include <math.h> - -#include <gtk/gtksignal.h> - -#include <addressbook/backend/ebook/e-book-util.h> -#include <addressbook/backend/ebook/e-destination.h> -#include <addressbook/backend/ebook/e-card-simple.h> -#include <addressbook/backend/ebook/e-card-compare.h> - -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; - - gchar *cached_query_text; - GList *cached_cards; - gboolean cache_complete; - -} ESelectNamesCompletionBookData; - -struct _ESelectNamesCompletionPrivate { - - ESelectNamesTextModel *text_model; - - GList *book_data; - gint books_not_ready; - gint pending_completion_seq; - - gchar *waiting_query; - gint waiting_pos, waiting_limit; - gchar *query_text; - - gboolean match_contact_lists; - - gint minimum_query_length; -}; - -static void e_select_names_completion_class_init (ESelectNamesCompletionClass *); -static void e_select_names_completion_init (ESelectNamesCompletion *); -static void e_select_names_completion_dispose (GObject *object); - -static void e_select_names_completion_got_book_view_cb (EBook *book, EBookStatus status, EBookView *view, gpointer user_data); -static void e_select_names_completion_card_added_cb (EBookView *, const GList *cards, gpointer user_data); -static void e_select_names_completion_seq_complete_cb (EBookView *, EBookViewStatus status, gpointer user_data); - -static void e_select_names_completion_do_query (ESelectNamesCompletion *, const gchar *query_text, gint pos, gint limit); - -static void e_select_names_completion_handle_request (ECompletion *, const gchar *txt, gint pos, gint limit); -static void e_select_names_completion_end (ECompletion *); - -static GObjectClass *parent_class; - -static FILE *out; - -/* - * - * Query builders - * - */ - -typedef gchar *(*BookQuerySExp) (ESelectNamesCompletion *); -typedef ECompletionMatch *(*BookQueryMatchTester) (ESelectNamesCompletion *, EDestination *); - -static int -utf8_casefold_collate_len (const gchar *str1, const gchar *str2, int len) -{ - gchar *s1 = g_utf8_casefold(str1, len); - gchar *s2 = g_utf8_casefold(str2, len); - int rv; - - rv = g_utf8_collate (s1, s2); - - g_free (s1); - g_free (s2); - - return rv; -} - -static int -utf8_casefold_collate (const gchar *str1, const gchar *str2) -{ - return utf8_casefold_collate_len (str1, str2, -1); -} - -static void -our_match_destroy (ECompletionMatch *match) -{ - g_object_unref (match->user_data); -} - -static ECompletionMatch * -make_match (EDestination *dest, const gchar *menu_form, double score) -{ - ECompletionMatch *match; - 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))) { - g_object_unref (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; - g_object_ref (dest); - - match->destroy = our_match_destroy; - - return match; -} - -/* - * Nickname query - */ - -static gchar * -sexp_nickname (ESelectNamesCompletion *comp) -{ - gchar *query = g_strdup_printf ("(beginswith \"nickname\" \"%s\")", comp->priv->query_text); - - return query; -} - -static ECompletionMatch * -match_nickname (ESelectNamesCompletion *comp, EDestination *dest) -{ - ECompletionMatch *match = NULL; - gint len; - 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 && !utf8_casefold_collate_len (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 - && !utf8_casefold_collate_len (comp->priv->query_text, email, len) - && !e_destination_is_evolution_list (dest)) { - - gchar *str; - - score = len * 2; /* 2 points for each matching character */ - - if (name && *name) - str = g_strdup_printf ("<%s> %s", email, name); - else - str = g_strdup (email); - - match = make_match (dest, str, score); - - g_free (str); - - return match; - } - - return NULL; -} - -/* - * Name Query - */ - -static gchar * -name_style_query (ESelectNamesCompletion *comp, const gchar *field) -{ - if (comp && comp->priv->query_text && *comp->priv->query_text) { - gchar *cpy = g_strdup (comp->priv->query_text), *c; - gchar **strv; - gchar *query; - gint i, 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 ("(beginswith \"%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 */ - - 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 (!utf8_casefold_collate_len (name, strv[i], len)) - score += len; /* one point per character of the match */ - else - score = 0; - } - - g_free (cpy); - g_strfreev (strv); - - if (score <= 0) - return NULL; - - menu_text = g_strdup_printf ("%s <%s>", name, email); - g_strstrip (menu_text); - match = make_match (dest, menu_text, score); - g_free (menu_text); - - return match; -} - -typedef struct _BookQuery BookQuery; -struct _BookQuery { - BookQuerySExp builder; - BookQueryMatchTester tester; -}; - -static BookQuery book_queries[] = { - { sexp_nickname, match_nickname}, - { sexp_email, match_email }, - { sexp_name, match_name }, - { sexp_file_as, match_file_as }, -}; -static gint book_query_count = sizeof (book_queries) / sizeof (BookQuery); - -/* - * Build up a big compound sexp corresponding to all of our queries. - */ -static gchar * -book_query_sexp (ESelectNamesCompletion *comp) -{ - gint i, j; - 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; - - queryv = g_new0 (gchar *, book_query_count+1); - for (i=0, j=0; i<book_query_count; ++i) { - queryv[j] = book_queries[i].builder (comp); - if (queryv[j]) - ++j; - } - - if (j == 0) { - query = NULL; - } else if (j == 1) { - query = queryv[0]; - queryv[0] = NULL; - } else { - gchar *tmp = g_strjoinv (" ", queryv); - query = g_strdup_printf ("(or %s)", tmp); - g_free (tmp); - } - - for (i=0; i<book_query_count; ++i) - g_free (queryv[i]); - g_free (queryv); - - return query; -} - -/* - * Sweep across all of our query rules and find the best score/match - * string that applies to a given destination. - */ -static ECompletionMatch * -book_query_score (ESelectNamesCompletion *comp, EDestination *dest) -{ - ECompletionMatch *best_match = NULL; - gint i; - - g_return_val_if_fail (E_IS_SELECT_NAMES_COMPLETION (comp), NULL); - g_return_val_if_fail (E_IS_DESTINATION (dest), NULL); - - if (! (comp->priv->query_text && *comp->priv->query_text)) - return NULL; - - for (i=0; i<book_query_count; ++i) { - - ECompletionMatch *this_match = NULL; - - if (book_queries[i].tester && e_destination_get_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); - } - g_object_unref (dest); - - } - - } else if (card->email) { - gint i; - for (i=0; i<e_list_length (card->email); ++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); - } - } - - g_object_unref (dest); - } - } - - cards = g_list_next (cards); - } -} - -/* - * - * ESelectNamesCompletion code - * - */ - - -GType -e_select_names_completion_get_type (void) -{ - static GType type = 0; - - if (!type) { - static const GTypeInfo info = { - sizeof (ESelectNamesCompletionClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) e_select_names_completion_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (ESelectNamesCompletion), - 0, /* n_preallocs */ - (GInstanceInitFunc) e_select_names_completion_init, - }; - - type = g_type_register_static (e_completion_get_type (), "ESelectNamesCompletion", &info, 0); - } - - return type; -} - -static void -e_select_names_completion_class_init (ESelectNamesCompletionClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - ECompletionClass *completion_class = E_COMPLETION_CLASS (klass); - - parent_class = g_type_class_peek_parent (klass); - - object_class->dispose = e_select_names_completion_dispose; - - completion_class->request_completion = e_select_names_completion_handle_request; - completion_class->end_completion = e_select_names_completion_end; - - if (getenv ("EVO_DEBUG_SELECT_NAMES_COMPLETION")) { - out = fopen ("/tmp/evo-debug-select-names-completion", "w"); - if (out) - setvbuf (out, NULL, _IONBF, 0); - } -} - -static void -e_select_names_completion_init (ESelectNamesCompletion *comp) -{ - comp->priv = g_new0 (struct _ESelectNamesCompletionPrivate, 1); - comp->priv->match_contact_lists = TRUE; -} - -static void -e_select_names_completion_clear_book_data (ESelectNamesCompletion *comp) -{ - GList *l; - - for (l = comp->priv->book_data; l; l = l->next) { - ESelectNamesCompletionBookData *book_data = l->data; - - if (book_data->card_added_tag) { - g_signal_handler_disconnect (book_data->book_view, book_data->card_added_tag); - book_data->card_added_tag = 0; - } - - if (book_data->seq_complete_tag) { - g_signal_handler_disconnect (book_data->book_view, book_data->seq_complete_tag); - book_data->seq_complete_tag = 0; - } - - g_object_unref (book_data->book); - - if (book_data->book_view) { - e_book_view_stop (book_data->book_view); - g_object_unref (book_data->book_view); - } - - g_free (book_data->cached_query_text); - g_list_foreach (book_data->cached_cards, (GFunc)g_object_unref, NULL); - g_list_free (book_data->cached_cards); - - g_free (book_data); - } - g_list_free (comp->priv->book_data); - comp->priv->book_data = NULL; -} - -static void -e_select_names_completion_dispose (GObject *object) -{ - ESelectNamesCompletion *comp = E_SELECT_NAMES_COMPLETION (object); - - if (comp->priv) { - if (comp->priv->text_model) - g_object_unref (comp->priv->text_model); - - e_select_names_completion_clear_book_data (comp); - - g_free (comp->priv->waiting_query); - g_free (comp->priv->query_text); - - g_free (comp->priv); - comp->priv = NULL; - } - - if (parent_class->dispose) - parent_class->dispose (object); -} - - -/* - * - * EBook/EBookView Callbacks & Query Stuff - * - */ - -static gchar * -clean_query_text (const gchar *s) -{ - gchar *q = g_new (gchar, strlen(s)+1), *t; - - t = q; - while (*s) { - if (*s != ',' && *s != '"') { - *t = *s; - ++t; - } - ++s; - } - *t = '\0'; - - g_strstrip (q); - - return q; -} - -static void -e_select_names_completion_clear_cache (ESelectNamesCompletionBookData *book_data) -{ - if (out) - fprintf (out, "** clearing cache on book %s\n", e_book_get_uri (book_data->book)); - - g_free (book_data->cached_query_text); - g_list_foreach (book_data->cached_cards, (GFunc)g_object_unref, NULL); - g_list_free (book_data->cached_cards); - - book_data->cached_query_text = NULL; - book_data->cached_cards = NULL; -} - -static void -e_select_names_completion_done (ESelectNamesCompletion *comp) -{ - g_free (comp->priv->query_text); - comp->priv->query_text = NULL; - - e_completion_end_search (E_COMPLETION (comp)); /* That's all folks! */ - - /* Need to launch a new completion if another one is pending. */ - if (comp->priv->waiting_query) { - gchar *s = comp->priv->waiting_query; - comp->priv->waiting_query = NULL; - e_completion_begin_search (E_COMPLETION (comp), s, comp->priv->waiting_pos, comp->priv->waiting_limit); - g_free (s); - } -} - -static void -e_select_names_completion_got_book_view_cb (EBook *book, EBookStatus status, EBookView *view, gpointer user_data) -{ - ESelectNamesCompletion *comp; - ESelectNamesCompletionBookData *book_data; - - book_data = (ESelectNamesCompletionBookData*)user_data; - comp = book_data->comp; - - if (status != E_BOOK_STATUS_SUCCESS) { - comp->priv->pending_completion_seq--; - if (!comp->priv->pending_completion_seq) - e_select_names_completion_done (comp); - return; - } - - book_data->book_view_tag = 0; - - if (book_data->card_added_tag) { - g_signal_handler_disconnect (book_data->book_view, book_data->card_added_tag); - book_data->card_added_tag = 0; - } - if (book_data->seq_complete_tag) { - g_signal_handler_disconnect (book_data->book_view, book_data->seq_complete_tag); - book_data->seq_complete_tag = 0; - } - - g_object_ref (view); - if (book_data->book_view) { - e_book_view_stop (book_data->book_view); - g_object_unref (book_data->book_view); - } - book_data->book_view = view; - - book_data->card_added_tag = - g_signal_connect (view, - "card_added", - G_CALLBACK (e_select_names_completion_card_added_cb), - book_data); - - book_data->seq_complete_tag = - g_signal_connect (view, - "sequence_complete", - G_CALLBACK (e_select_names_completion_seq_complete_cb), - book_data); - book_data->sequence_complete_received = FALSE; -} - -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) { - book_data->cached_cards = g_list_prepend (book_data->cached_cards, cards->data); - g_object_ref (cards->data); - cards = g_list_next (cards); - } - } -} - -static void -e_select_names_completion_seq_complete_cb (EBookView *book_view, EBookViewStatus status, gpointer user_data) -{ - ESelectNamesCompletionBookData *book_data = user_data; - ESelectNamesCompletion *comp = book_data->comp; - - if (out) - fprintf (out, "** got sequence_complete (status = %d) on book %s\n", status, e_book_get_uri (book_data->book)); - - /* - * We aren't searching, but the addressbook has changed -- clear our card cache so that - * future completion requests will take the changes into account. - */ - if (! e_completion_searching (E_COMPLETION (comp))) { - if (out) - fprintf (out, "\t we weren't searching, clearing the cache\n"); - e_select_names_completion_clear_cache (book_data); - return; - } - - if (book_data->cached_query_text - && status == E_BOOK_STATUS_SUCCESS - && !book_data->cache_complete - && !strcmp (book_data->cached_query_text, comp->priv->query_text)) - book_data->cache_complete = TRUE; - - if (out) - fprintf (out, "\tending search, book_data->cache_complete == %d\n", book_data->cache_complete); - - if (!book_data->sequence_complete_received) { - book_data->sequence_complete_received = TRUE; - - if (book_data->card_added_tag) { - g_signal_handler_disconnect (book_data->book_view, book_data->card_added_tag); - book_data->card_added_tag = 0; - } - if (book_data->seq_complete_tag) { - g_signal_handler_disconnect (book_data->book_view, book_data->seq_complete_tag); - book_data->seq_complete_tag = 0; - } - - if (out) - fprintf (out, "\t %d remaining book view's\n", comp->priv->pending_completion_seq - 1); - - comp->priv->pending_completion_seq --; - if (comp->priv->pending_completion_seq > 0) - return; - } - - e_select_names_completion_done (comp); -} - -static void -e_select_names_completion_stop_query (ESelectNamesCompletion *comp) -{ - GList *l; - - g_return_if_fail (comp && E_IS_SELECT_NAMES_COMPLETION (comp)); - - if (out) - fprintf (out, "stopping query\n"); - - if (comp->priv->waiting_query) { - if (out) - fprintf (out, "stopped waiting query\n"); - g_free (comp->priv->waiting_query); - comp->priv->waiting_query = NULL; - } - - g_free (comp->priv->query_text); - comp->priv->query_text = NULL; - - for (l = comp->priv->book_data; l; l = l->next) { - ESelectNamesCompletionBookData *book_data = l->data; - if (book_data->book_view_tag) { - e_book_cancel (book_data->book, book_data->book_view_tag); - book_data->book_view_tag = 0; - } - if (book_data->book_view) { - if (book_data->card_added_tag) { - g_signal_handler_disconnect (book_data->book_view, book_data->card_added_tag); - book_data->card_added_tag = 0; - } - if (book_data->seq_complete_tag) { - g_signal_handler_disconnect (book_data->book_view, book_data->seq_complete_tag); - book_data->seq_complete_tag = 0; - } - - e_book_view_stop (book_data->book_view); - g_object_unref (book_data->book_view); - book_data->book_view = NULL; - } - } - - comp->priv->pending_completion_seq = 0; -} - -static void -e_select_names_completion_start_query (ESelectNamesCompletion *comp, const gchar *query_text) -{ - g_return_if_fail (comp && E_IS_SELECT_NAMES_COMPLETION (comp)); - g_return_if_fail (query_text); - - e_select_names_completion_stop_query (comp); /* Stop any prior queries. */ - - if (comp->priv->books_not_ready == 0) { - gchar *sexp; - - if (strlen (query_text) < comp->priv->minimum_query_length) { - e_completion_end_search (E_COMPLETION (comp)); - return; - } - - g_free (comp->priv->query_text); - comp->priv->query_text = g_strdup (query_text); - - 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; - gboolean can_reuse_cached_cards; - - if (out) { - fprintf (out, - "book == %s[\n" - "\tbook_data->cached_query_text == `%s'\n" - "\tbook_data->cache_complete == %d\n" - "\tbook_data->cached_cards == %p\n", - e_book_get_uri (book_data->book), - book_data->cached_query_text, - book_data->cache_complete, - book_data->cached_cards); - } - - /* for lack of a better place, we invalidate the cache here if we - notice that the text is different. */ - if (book_data->cached_query_text - && (strlen (book_data->cached_query_text) > strlen (query_text) - || utf8_casefold_collate_len (book_data->cached_query_text, query_text, - strlen (book_data->cached_query_text)))) - book_data->cache_complete = FALSE; - - can_reuse_cached_cards = (book_data->cached_query_text - && book_data->cache_complete - && book_data->cached_cards != NULL); - - if (can_reuse_cached_cards) { - - if (out) - fprintf (out, "\t*** can reuse cached cards (%d cards cached)!\n", g_list_length (book_data->cached_cards)); - - if (out) - fprintf (out, "\tusing existing query info: %s (vs %s)\n", query_text, book_data->cached_query_text); - book_query_process_card_list (comp, book_data->cached_cards); - } - else { - e_select_names_completion_clear_cache (book_data); - book_data->cached_query_text = g_strdup (query_text); - - book_data->book_view_tag = e_book_get_completion_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_completion_view"); - else - comp->priv->pending_completion_seq++; - } - - if (out) - fprintf (out, "]\n"); - } - - /* if we looped through all the books - and were able to complete based - solely on our cached cards, signal - that the search is over. */ - if (!comp->priv->pending_completion_seq) - e_select_names_completion_done (E_SELECT_NAMES_COMPLETION (comp)); - } 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; - - g_return_if_fail (comp != NULL); - g_return_if_fail (E_IS_SELECT_NAMES_COMPLETION (comp)); - - clean = clean_query_text (query_text); - if (! (clean && *clean)) { - g_free (clean); - e_completion_end_search (E_COMPLETION (comp)); - return; - } - - if (out) - fprintf (out, "do_query: %s => %s\n", query_text, clean); - - e_select_names_completion_start_query (comp, clean); - g_free (clean); -} - - -/* - * - * Completion Search Override - a Framework for Christian-Resurrection-Holiday Edible-Chicken-Ova - * - */ - -typedef struct _SearchOverride SearchOverride; -struct _SearchOverride { - const gchar *trigger; - const gchar *text[4]; -}; -static SearchOverride override[] = { - { "why?", { "\"I must create a system, or be enslaved by another man's.\"", - " -- Wiliam Blake, \"Jerusalem\"", - NULL } }, - { "easter-egg?", { "What were you expecting, a flight simulator?", NULL } }, - { NULL, { NULL } } }; - -static gboolean -search_override_check (SearchOverride *over, const gchar *text) -{ - /* The g_utf8_validate is needed because as of 2001-06-11, - * EText doesn't translate from locale->UTF8 when you paste - * into it. - */ - if (over == NULL || text == NULL || !g_utf8_validate (text, -1, NULL)) - return FALSE; - - return !utf8_casefold_collate (over->trigger, text); -} - - -/* - * - * Completion Callbacks - * - */ - -static void -e_select_names_completion_handle_request (ECompletion *comp, const gchar *text, gint pos, gint limit) -{ - ESelectNamesCompletion *selcomp = E_SELECT_NAMES_COMPLETION (comp); - const gchar *str; - gint index, j; - - g_return_if_fail (comp != NULL); - g_return_if_fail (E_IS_SELECT_NAMES_COMPLETION (comp)); - g_return_if_fail (text != NULL); - - if (out) { - fprintf (out, "\n\n**** requesting completion\n"); - fprintf (out, "text=\"%s\" pos=%d limit=%d\n", text, pos, limit); - } - - e_select_names_model_text_pos (selcomp->priv->text_model->source, - selcomp->priv->text_model->seplen, - pos, &index, NULL, NULL); - str = index >= 0 ? e_select_names_model_get_string (selcomp->priv->text_model->source, index) : NULL; - - if (out) - fprintf (out, "index=%d str=\"%s\"\n", index, str); - - if (str == NULL || *str == '\0') { - if (out) - fprintf (out, "aborting empty query\n"); - e_completion_end_search (comp); - return; - } - - for (j=0; override[j].trigger; ++j) { - if (search_override_check (&(override[j]), str)) { - gint k; - - for (k=0; override[j].text[k]; ++k) { - ECompletionMatch *match = g_new (ECompletionMatch, 1); - e_completion_match_construct (match); - e_completion_match_set_text (match, text, override[j].text[k]); - match->score = 1 / (double) (k + 1); - e_completion_found_match (comp, match); - } - - e_completion_end_search (comp); - return; - } - } - - e_select_names_completion_do_query (selcomp, str, pos, limit); -} - -static void -e_select_names_completion_end (ECompletion *comp) -{ - g_return_if_fail (comp != NULL); - g_return_if_fail (E_IS_COMPLETION (comp)); - - if (out) - fprintf (out, "completion ended\n"); -} - -/* - * - * Our Pseudo-Constructor - * - */ - -ECompletion * -e_select_names_completion_new (ESelectNamesTextModel *text_model) -{ - ESelectNamesCompletion *comp; - - g_return_val_if_fail (E_IS_SELECT_NAMES_TEXT_MODEL (text_model), NULL); - - comp = g_object_new (E_TYPE_SELECT_NAMES_COMPLETION, NULL); - - comp->priv->text_model = text_model; - g_object_ref (text_model); - - return E_COMPLETION (comp); -} - -void -e_select_names_completion_add_book (ESelectNamesCompletion *comp, EBook *book) -{ - ESelectNamesCompletionBookData *book_data; - - g_return_if_fail (book != NULL); - - book_data = g_new0 (ESelectNamesCompletionBookData, 1); - book_data->book = book; - book_data->comp = comp; - g_object_ref (book_data->book); - comp->priv->book_data = g_list_append (comp->priv->book_data, book_data); - - /* XXX toshok - this doesn't work properly. need to rethink this next bit. */ - /* if the user is typing as we're adding books, restart the - query after the new book has been added */ - if (comp->priv->query_text && *comp->priv->query_text) { - char *query_text = g_strdup (comp->priv->query_text); - e_select_names_completion_stop_query (comp); - e_select_names_completion_start_query (comp, query_text); - g_free (query_text); - } -} - -void -e_select_names_completion_clear_books (ESelectNamesCompletion *comp) -{ - e_select_names_completion_stop_query (comp); - e_select_names_completion_clear_book_data (comp); -} - -void -e_select_names_completion_set_minimum_query_length (ESelectNamesCompletion *comp, int query_length) -{ - g_return_if_fail (E_IS_SELECT_NAMES_COMPLETION (comp)); - comp->priv->minimum_query_length = query_length; -} - -gboolean -e_select_names_completion_get_match_contact_lists (ESelectNamesCompletion *comp) -{ - g_return_val_if_fail (E_IS_SELECT_NAMES_COMPLETION (comp), FALSE); - return comp->priv->match_contact_lists; -} - - -void -e_select_names_completion_set_match_contact_lists (ESelectNamesCompletion *comp, gboolean x) -{ - g_return_if_fail (E_IS_SELECT_NAMES_COMPLETION (comp)); - comp->priv->match_contact_lists = x; -} - diff --git a/addressbook/gui/component/select-names/e-select-names-completion.h b/addressbook/gui/component/select-names/e-select-names-completion.h deleted file mode 100644 index 6565208378..0000000000 --- a/addressbook/gui/component/select-names/e-select-names-completion.h +++ /dev/null @@ -1,68 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * e-select-names-completion.h - * - * Copyright (C) 2001 Ximian, Inc. - * - * Developed by Jon Trowbridge <trow@ximian.com> - */ - -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - */ - -#ifndef E_SELECT_NAMES_COMPLETION_H -#define E_SELECT_NAMES_COMPLETION_H - -#include <gal/e-text/e-completion.h> -#include <addressbook/backend/ebook/e-book.h> -#include "e-select-names-text-model.h" - -G_BEGIN_DECLS - -#define E_TYPE_SELECT_NAMES_COMPLETION (e_select_names_completion_get_type ()) -#define E_SELECT_NAMES_COMPLETION(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), E_TYPE_SELECT_NAMES_COMPLETION, ESelectNamesCompletion)) -#define E_SELECT_NAMES_COMPLETION_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), E_TYPE_SELECT_NAMES_COMPLETION, ESelectNamesCompletionClass)) -#define E_IS_SELECT_NAMES_COMPLETION(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), E_TYPE_SELECT_NAMES_COMPLETION)) -#define E_IS_SELECT_NAMES_COMPLETION_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), E_TYPE_SELECT_NAMES_COMPLETION)) - -typedef struct _ESelectNamesCompletion ESelectNamesCompletion; -typedef struct _ESelectNamesCompletionClass ESelectNamesCompletionClass; -struct _ESelectNamesCompletionPrivate; - -struct _ESelectNamesCompletion { - ECompletion parent; - - struct _ESelectNamesCompletionPrivate *priv; -}; - -struct _ESelectNamesCompletionClass { - ECompletionClass parent_class; - -}; - -GType e_select_names_completion_get_type (void); - -ECompletion *e_select_names_completion_new (ESelectNamesTextModel *); -void e_select_names_completion_add_book (ESelectNamesCompletion *, EBook *); -void e_select_names_completion_clear_books (ESelectNamesCompletion *); -void e_select_names_completion_set_minimum_query_length (ESelectNamesCompletion *, int); -gboolean e_select_names_completion_get_match_contact_lists (ESelectNamesCompletion *); -void e_select_names_completion_set_match_contact_lists (ESelectNamesCompletion *, gboolean); - -G_END_DECLS - -#endif /* E_SELECT_NAMES_COMPLETION_H */ diff --git a/addressbook/gui/component/select-names/e-select-names-factory.c b/addressbook/gui/component/select-names/e-select-names-factory.c deleted file mode 100644 index 2416e42750..0000000000 --- a/addressbook/gui/component/select-names/e-select-names-factory.c +++ /dev/null @@ -1,59 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-select-names-factory.c - * - * Copyright (C) 2000 Ximian, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Author: Ettore Perazzoli - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <bonobo/bonobo-generic-factory.h> - -#include "e-select-names-bonobo.h" -#include "e-select-names-factory.h" - - -#define COMPONENT_FACTORY_ID "OAFIID:GNOME_Evolution_Addressbook_SelectNamesFactory" - -static BonoboGenericFactory *factory = NULL; - - -static BonoboObject * -factory_fn (BonoboGenericFactory *factory, - const char *component_id, - void *closure) -{ - return BONOBO_OBJECT (e_select_names_bonobo_new ()); -} - - -gboolean -e_select_names_factory_init (void) -{ - if (factory != NULL) - return TRUE; - - factory = bonobo_generic_factory_new (COMPONENT_FACTORY_ID, factory_fn, NULL); - - if (factory == NULL) - return FALSE; - - return TRUE; -} diff --git a/addressbook/gui/component/select-names/e-select-names-factory.h b/addressbook/gui/component/select-names/e-select-names-factory.h deleted file mode 100644 index 0fe85c8361..0000000000 --- a/addressbook/gui/component/select-names/e-select-names-factory.h +++ /dev/null @@ -1,30 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-select-names-factory.h - * - * Copyright (C) 2000 Ximian, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Author: Ettore Perazzoli - */ - -#ifndef _E_SECELT_NAMES_FACTORY_H -#define _E_SECELT_NAMES_FACTORY_H - -#include <glib.h> - -gboolean e_select_names_factory_init (void); - -#endif diff --git a/addressbook/gui/component/select-names/e-select-names-manager.c b/addressbook/gui/component/select-names/e-select-names-manager.c deleted file mode 100644 index a3875cea97..0000000000 --- a/addressbook/gui/component/select-names/e-select-names-manager.c +++ /dev/null @@ -1,775 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Authors: - * Chris Lahey <clahey@ximian.com> - * Jon Trowbridge <trow@ximian.com. - * - * Copyright (C) 2000, 2001 Ximian, Inc. - */ - -#include <config.h> - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#include <gal/e-text/e-entry.h> - -#include <libgnome/gnome-i18n.h> -#include "e-select-names-manager.h" -#include "e-select-names-marshal.h" -#include "e-select-names-model.h" -#include "e-select-names-text-model.h" -#include "e-select-names.h" -#include "e-select-names-completion.h" -#include "e-select-names-popup.h" -#include "e-folder-list.h" -#include <addressbook/backend/ebook/e-book-util.h> -#include <addressbook/backend/ebook/e-destination.h> -#include "addressbook/gui/component/addressbook.h" -#include <bonobo/bonobo-object.h> - -#define DEFAULT_MINIMUM_QUERY_LENGTH 3 - -enum { - CHANGED, - OK, - CANCEL, - LAST_SIGNAL -}; - -static guint e_select_names_manager_signals[LAST_SIGNAL] = { 0 }; - -static GObjectClass *parent_class = NULL; - -typedef struct { - char *id; - char *title; - ESelectNamesModel *model; - ESelectNamesModel *original_model; - ESelectNamesManager *manager; - guint changed_tag; -} ESelectNamesManagerSection; - -typedef struct { - char *id; - EEntry *entry; - ESelectNamesManager *manager; - ESelectNamesModel *model; - ECompletion *comp; - guint cleaning_tag; -} ESelectNamesManagerEntry; - -static void e_select_names_manager_init (ESelectNamesManager *manager); -static void e_select_names_manager_class_init (ESelectNamesManagerClass *klass); - -static void e_select_names_manager_dispose (GObject *object); - -/* ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** */ - -/* ESelectNamesManagerSection routines */ - -static void -section_model_changed_cb (ESelectNamesModel *model, gpointer closure) -{ - ESelectNamesManagerSection *section = closure; - g_signal_emit (section->manager, - e_select_names_manager_signals[CHANGED], 0, - section->id, - FALSE); -} - -static ESelectNamesManagerSection * -e_select_names_manager_section_new (ESelectNamesManager *manager, - const gchar *id, - const gchar *title, - ESelectNamesModel *model) -{ - ESelectNamesManagerSection *section; - - g_return_val_if_fail (E_IS_SELECT_NAMES_MANAGER (manager), NULL); - g_return_val_if_fail (E_IS_SELECT_NAMES_MODEL (model), NULL); - - section = g_new0 (ESelectNamesManagerSection, 1); - - section->id = g_strdup (id); - section->title = g_strdup (title); - - section->manager = manager; - - section->model = model; - g_object_ref (section->model); - section->changed_tag = - g_signal_connect (section->model, - "changed", - G_CALLBACK (section_model_changed_cb), - section); - - return section; -} - -static void -e_select_names_manager_section_free (ESelectNamesManagerSection *section) -{ - if (section == NULL) - return; - - g_free (section->id); - g_free (section->title); - - if (section->model) { - g_signal_handler_disconnect (section->model, section->changed_tag); - g_object_unref (section->model); - } - - if (section->original_model) { - g_object_unref (section->original_model); - } - - g_free (section); -} - -/* ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** */ - -/* ESelectNamesManagerEntry routines */ - -static ESelectNamesManagerEntry * -get_entry_info (EEntry *entry) -{ - g_return_val_if_fail (E_IS_ENTRY (entry), NULL); - return (ESelectNamesManagerEntry *) g_object_get_data (G_OBJECT (entry), "entry_info"); -} - -static void -populate_popup_cb (EEntry *eentry, GdkEventButton *ev, gint pos, GtkWidget *menu, gpointer user_data) -{ - ESelectNamesTextModel *text_model; - - g_object_get (eentry, - "model", &text_model, - NULL); - g_assert (E_IS_SELECT_NAMES_TEXT_MODEL (text_model)); - - e_select_names_populate_popup (menu, text_model, ev, pos, GTK_WIDGET (eentry)); -} - -#if 0 -static gboolean -clean_cb (gpointer ptr) -{ - ESelectNamesManagerEntry *entry = ptr; - - e_select_names_model_clean (entry->model, TRUE); - entry->cleaning_tag = 0; - return FALSE; -} -#endif - -static gint -focus_in_cb (GtkWidget *w, GdkEventFocus *ev, gpointer user_data) -{ - ESelectNamesManagerEntry *entry = user_data; - - if (entry->cleaning_tag) { - g_source_remove (entry->cleaning_tag); - entry->cleaning_tag = 0; - } - - e_select_names_model_cancel_cardify_all (entry->model); - - return FALSE; -} - -static gint -focus_out_cb (GtkWidget *w, GdkEventFocus *ev, gpointer user_data) -{ -#if 0 - /* XXX fix me */ - ESelectNamesManagerEntry *entry = user_data; - gboolean visible = e_entry_completion_popup_is_visible (entry->entry); - - if (! visible) { - e_select_names_model_cardify_all (entry->model, entry->manager->completion_book, 100); - if (entry->cleaning_tag == 0) - entry->cleaning_tag = gtk_timeout_add (100, clean_cb, entry); - } -#endif - return FALSE; -} - -static void -completion_popup_cb (EEntry *w, gint visible, gpointer user_data) -{ -#if 0 - /* XXX fix me */ - 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); -#endif -} - -static void -completion_handler (EEntry *entry, ECompletionMatch *match) -{ - ESelectNamesManagerEntry *mgr_entry; - ESelectNamesTextModel *text_model; - EDestination *dest; - gint i, pos, start_pos, len; - - if (match == NULL || match->user_data == NULL) - return; - - mgr_entry = get_entry_info (entry); - dest = E_DESTINATION (match->user_data); - - /* Sometimes I really long for garbage collection. Reference - counting makes you feel 31337, but sometimes it is just a - bitch. */ - g_object_ref (dest); - - g_object_get (entry, - "model", &text_model, - NULL); - g_assert (E_IS_SELECT_NAMES_TEXT_MODEL (text_model)); - - pos = e_entry_get_position (entry); - e_select_names_model_text_pos (mgr_entry->model, text_model->seplen, pos, &i, NULL, NULL); - e_select_names_model_replace (mgr_entry->model, i, dest); - e_select_names_model_name_pos (mgr_entry->model, text_model->seplen, i, &start_pos, &len); - e_entry_set_position (entry, start_pos+len); -} - -static ESelectNamesManagerEntry * -e_select_names_manager_entry_new (ESelectNamesManager *manager, ESelectNamesModel *model, const gchar *id) -{ - ESelectNamesManagerEntry *entry; - ETextModel *text_model; - GList *l; - - g_return_val_if_fail (E_IS_SELECT_NAMES_MANAGER (manager), NULL); - g_return_val_if_fail (E_IS_SELECT_NAMES_MODEL (model), NULL); - - entry = g_new0 (ESelectNamesManagerEntry, 1); - - entry->id = g_strdup (id); - - entry->entry = E_ENTRY (e_entry_new ()); - text_model = e_select_names_text_model_new (model); - g_object_set(entry->entry, - "model", text_model, /* The entry takes ownership of the text model */ - "editable", TRUE, - "use_ellipsis", TRUE, - "allow_newlines", FALSE, - NULL); - - g_object_ref (entry->entry); - - entry->comp = e_select_names_completion_new (E_SELECT_NAMES_TEXT_MODEL (text_model)); - - for (l = manager->completion_books; l; l = l->next) { - EBook *book = l->data; - e_select_names_completion_add_book (E_SELECT_NAMES_COMPLETION(entry->comp), book); - } - - e_select_names_completion_set_minimum_query_length (E_SELECT_NAMES_COMPLETION(entry->comp), - manager->minimum_query_length); - - e_entry_enable_completion_full (entry->entry, entry->comp, 100, completion_handler); - - entry->manager = manager; - - entry->model = model; - g_object_ref (model); - - g_signal_connect (entry->entry, - "populate_popup", - G_CALLBACK (populate_popup_cb), - entry); - - g_signal_connect (entry->entry->canvas, - "focus_in_event", - G_CALLBACK (focus_in_cb), - entry); - - g_signal_connect (entry->entry->canvas, - "focus_out_event", - G_CALLBACK (focus_out_cb), - entry); - - g_signal_connect (entry->entry, - "completion_popup", - G_CALLBACK (completion_popup_cb), - entry); - - g_object_set_data (G_OBJECT (entry->entry), "entry_info", entry); - g_object_set_data (G_OBJECT (entry->entry), "select_names_model", model); - g_object_set_data (G_OBJECT (entry->entry), "select_names_text_model", text_model); - g_object_set_data (G_OBJECT (entry->entry), "completion_handler", entry->comp); - - return entry; -} - -static void -e_select_names_manager_entry_free (ESelectNamesManagerEntry *entry) -{ - if (entry == NULL) - return; - - g_free (entry->id); - g_object_unref (entry->model); - g_object_unref (entry->entry); - - if (entry->cleaning_tag) - g_source_remove (entry->cleaning_tag); - - g_free (entry); -} - -/* ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** */ - -static void -e_select_names_manager_save_models (ESelectNamesManager *manager) -{ - GList *iter; - - for (iter = manager->sections; iter != NULL; iter = g_list_next (iter)) { - ESelectNamesManagerSection *section = iter->data; - - if (section->original_model == NULL && section->model != NULL) - section->original_model = e_select_names_model_duplicate (section->model); - - } -} - -static void -e_select_names_manager_revert_to_saved_models (ESelectNamesManager *manager) -{ - GList *iter; - - for (iter = manager->sections; iter != NULL; iter = g_list_next (iter)) { - ESelectNamesManagerSection *section = iter->data; - if (section->model && section->original_model) { - e_select_names_model_overwrite_copy (section->model, section->original_model); - g_object_unref (section->original_model); - section->original_model = NULL; - } - } -} - -static void -e_select_names_manager_discard_saved_models (ESelectNamesManager *manager) -{ - GList *iter; - - for (iter = manager->sections; iter != NULL; iter = g_list_next (iter)) { - ESelectNamesManagerSection *section = iter->data; - if (section->original_model) { - g_object_unref (section->original_model); - section->original_model = NULL; - } - } -} - -/* ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** */ - - -static void -open_book_cb (EBook *book, EBookStatus status, ESelectNamesManager *manager) -{ - if (status == E_BOOK_STATUS_SUCCESS) { - GList *l; - for (l = manager->entries; l; l = l->next) { - ESelectNamesManagerEntry *entry = l->data; - e_select_names_completion_add_book (E_SELECT_NAMES_COMPLETION(entry->comp), book); - } - - manager->completion_books = g_list_append (manager->completion_books, book); - g_object_ref (book); - } - - g_object_unref (manager); /* unref ourself (matches ref before the load_uri call below) */ -} - -static void -load_completion_books (ESelectNamesManager *manager) -{ - EFolderListItem *folders = e_folder_list_parse_xml (manager->cached_folder_list); - EFolderListItem *f; - - for (f = folders; f && f->physical_uri; f++) { - char *uri; - EBook *book = e_book_new (); - g_object_ref (manager); /* ref ourself before our async call */ - - uri = e_book_expand_uri (f->physical_uri); - - addressbook_load_uri (book, uri, (EBookCallback)open_book_cb, manager); - - g_free (uri); - } - e_folder_list_free_items (folders); -} - -static void -read_completion_settings_from_db (ESelectNamesManager *manager, EConfigListener *db) -{ - char *val; - long ival; - - val = e_config_listener_get_string (db, "/apps/evolution/addressbook/completion/uris"); - - if (val) { - g_free (manager->cached_folder_list); - manager->cached_folder_list = val; - load_completion_books(manager); - } - - ival = e_config_listener_get_long (db, "/apps/evolution/addressbook/completion/minimum_query_length"); - if (ival <= 0) ival = DEFAULT_MINIMUM_QUERY_LENGTH; - - manager->minimum_query_length = ival; -} - -static void -db_listener (EConfigListener *db, const char *key, - ESelectNamesManager *manager) -{ - GList *l; - - if (!strcmp (key, "/apps/evolution/addressbook/completion/uris")) { - char *val = e_config_listener_get_string (db, key); - - if (!val) - return; - - if (!manager->cached_folder_list || strcmp (val, manager->cached_folder_list)) { - for (l = manager->entries; l; l = l->next) { - ESelectNamesManagerEntry *entry = l->data; - e_select_names_completion_clear_books (E_SELECT_NAMES_COMPLETION (entry->comp)); - } - - g_list_foreach (manager->completion_books, (GFunc)g_object_unref, NULL); - g_list_free (manager->completion_books); - manager->completion_books = NULL; - - g_free (manager->cached_folder_list); - manager->cached_folder_list = val; - load_completion_books (manager); - } - } - else if (!strcmp (key, "/apps/evolution/addressbook/completion/minimum_query_length")) { - long ival = e_config_listener_get_long (db, key); - - if (ival <= 0) - ival = DEFAULT_MINIMUM_QUERY_LENGTH; - - manager->minimum_query_length = ival; - - for (l = manager->entries; l; l = l->next) { - ESelectNamesManagerEntry *entry = l->data; - e_select_names_completion_set_minimum_query_length (E_SELECT_NAMES_COMPLETION(entry->comp), - manager->minimum_query_length); - } - } -} - -/** - * e_select_names_manager_new: - * - * Returns: a new #ESelectNamesManager - */ -ESelectNamesManager * -e_select_names_manager_new (void) -{ - ESelectNamesManager *manager = g_object_new (E_TYPE_SELECT_NAMES_MANAGER, NULL); - EConfigListener *db; - - db = e_book_get_config_database(); - - manager->listener_id = g_signal_connect (db, - "key_changed", - G_CALLBACK (db_listener), manager); - - read_completion_settings_from_db (manager, db); - - return manager; -} - - -/* - * ESelectNamesManager lifecycle management and vcard loading/saving. - */ - - -void -e_select_names_manager_add_section (ESelectNamesManager *manager, - const char *id, - const char *title) -{ - g_return_if_fail (E_IS_SELECT_NAMES_MANAGER (manager)); - g_return_if_fail (id != NULL); - g_return_if_fail (title != NULL); - - e_select_names_manager_add_section_with_limit (manager, id, title, -1); -} - -void -e_select_names_manager_add_section_with_limit (ESelectNamesManager *manager, - const char *id, - const char *title, - gint limit) -{ - ESelectNamesManagerSection *section; - ESelectNamesModel *model; - - g_return_if_fail (E_IS_SELECT_NAMES_MANAGER (manager)); - g_return_if_fail (id != NULL); - g_return_if_fail (title != NULL); - - model = e_select_names_model_new (); - e_select_names_model_set_limit (model, limit); - - section = e_select_names_manager_section_new (manager, id, title, model); - - manager->sections = g_list_append (manager->sections, section); - - g_object_unref (model); -} - -ESelectNamesModel * -e_select_names_manager_get_source (ESelectNamesManager *manager, - const char *id) -{ - GList *iter; - - g_return_val_if_fail (E_IS_SELECT_NAMES_MANAGER (manager), NULL); - g_return_val_if_fail (id != NULL, NULL); - - for (iter = manager->sections; iter != NULL; iter = g_list_next (iter)) { - ESelectNamesManagerSection *section = iter->data; - if (!strcmp (section->id, id)) - return section->model; - } - return NULL; -} - -GtkWidget * -e_select_names_manager_create_entry (ESelectNamesManager *manager, const char *id) -{ - GList *iter; - - g_return_val_if_fail (E_IS_SELECT_NAMES_MANAGER (manager), NULL); - g_return_val_if_fail (id != NULL, NULL); - - for (iter = manager->sections; iter != NULL; iter = g_list_next (iter)) { - ESelectNamesManagerSection *section = iter->data; - if (!strcmp(section->id, id)) { - ESelectNamesManagerEntry *entry; - - entry = e_select_names_manager_entry_new (manager, section->model, section->id); - manager->entries = g_list_append (manager->entries, entry); - - return GTK_WIDGET(entry->entry); - } - } - - return NULL; -} - -static void -e_select_names_response(ESelectNames *dialog, gint response_id, ESelectNamesManager *manager) -{ - gtk_widget_destroy (GTK_WIDGET (dialog)); - - switch(response_id) { - case GTK_RESPONSE_OK: - e_select_names_manager_discard_saved_models (manager); - g_signal_emit (manager, e_select_names_manager_signals[OK], 0); - break; - - case GTK_RESPONSE_CANCEL: - e_select_names_manager_revert_to_saved_models (manager); - g_signal_emit (manager, e_select_names_manager_signals[CANCEL], 0); - break; - } -} - -static void -clear_widget (gpointer data, GObject *where_object_was) -{ - GtkWidget **widget_ref = data; - *widget_ref = NULL; -} - -void -e_select_names_manager_activate_dialog (ESelectNamesManager *manager, - EvolutionShellClient *shell_client, - 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 (shell_client)); - - for (iter = manager->sections; iter != NULL; iter = g_list_next (iter)) { - ESelectNamesManagerSection *section = iter->data; - e_select_names_add_section (manager->names, section->id, section->title, section->model); - } - - e_select_names_set_default (manager->names, id); - - g_signal_connect(manager->names, - "response", - G_CALLBACK(e_select_names_response), - manager); - - g_object_weak_ref (G_OBJECT (manager->names), clear_widget, &manager->names); - - gtk_widget_show(GTK_WIDGET(manager->names)); - } - - e_select_names_manager_save_models (manager); -} - -/* ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** */ - -static void -e_select_names_manager_init (ESelectNamesManager *manager) -{ - manager->sections = NULL; - manager->entries = NULL; - manager->completion_books = NULL; - manager->cached_folder_list = NULL; -} - -static void -e_select_names_manager_dispose (GObject *object) -{ - ESelectNamesManager *manager; - - manager = E_SELECT_NAMES_MANAGER (object); - - if (manager->names) { - gtk_widget_destroy (GTK_WIDGET (manager->names)); - manager->names = NULL; - } - - if (manager->sections) { - g_list_foreach (manager->sections, (GFunc) e_select_names_manager_section_free, NULL); - g_list_free (manager->sections); - manager->sections = NULL; - } - - if (manager->entries) { - g_list_foreach (manager->entries, (GFunc) e_select_names_manager_entry_free, NULL); - g_list_free (manager->entries); - manager->entries = NULL; - } - - if (manager->completion_books) { - g_list_foreach (manager->completion_books, (GFunc) g_object_unref, NULL); - g_list_free (manager->completion_books); - manager->completion_books = NULL; - } - - if (manager->listener_id) { - g_signal_handler_disconnect (e_book_get_config_database(), manager->listener_id); - manager->listener_id = 0; - } - - if (manager->cached_folder_list) { - g_free (manager->cached_folder_list); - manager->cached_folder_list = NULL; - } - - if (G_OBJECT_CLASS (parent_class)->dispose) - G_OBJECT_CLASS (parent_class)->dispose (object); -} - -static void -e_select_names_manager_class_init (ESelectNamesManagerClass *klass) -{ - GObjectClass *object_class; - - object_class = G_OBJECT_CLASS(klass); - parent_class = g_type_class_peek_parent (klass); - - object_class->dispose = e_select_names_manager_dispose; - - e_select_names_manager_signals[CHANGED] = - g_signal_new ("changed", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (ESelectNamesManagerClass, changed), - NULL, NULL, - e_select_names_marshal_NONE__POINTER_INT, - G_TYPE_NONE, 2, - G_TYPE_POINTER, - G_TYPE_INT); - - e_select_names_manager_signals[OK] = - g_signal_new ("ok", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (ESelectNamesManagerClass, ok), - NULL, NULL, - e_select_names_marshal_NONE__NONE, - G_TYPE_NONE, 0); - - e_select_names_manager_signals[CANCEL] = - g_signal_new ("cancel", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (ESelectNamesManagerClass, cancel), - NULL, NULL, - e_select_names_marshal_NONE__NONE, - G_TYPE_NONE, 0); -} - -/** - * e_select_names_manager_get_type: - * @void: - * - * Registers the &ESelectNamesManager class if necessary, and returns the type ID - * associated to it. - * - * Return value: The type ID of the &ESelectNamesManager class. - **/ -GType -e_select_names_manager_get_type (void) -{ - static GType manager_type = 0; - - if (!manager_type) { - static const GTypeInfo manager_info = { - sizeof (ESelectNamesManagerClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) e_select_names_manager_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (ESelectNamesManager), - 0, /* n_preallocs */ - (GInstanceInitFunc) e_select_names_manager_init, - }; - - manager_type = g_type_register_static (G_TYPE_OBJECT, "ESelectNamesManager", &manager_info, 0); - } - - return manager_type; -} - - - diff --git a/addressbook/gui/component/select-names/e-select-names-manager.h b/addressbook/gui/component/select-names/e-select-names-manager.h deleted file mode 100644 index b48f597cb3..0000000000 --- a/addressbook/gui/component/select-names/e-select-names-manager.h +++ /dev/null @@ -1,70 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Authors: - * Chris Lahey <clahey@ximian.com> - * - * Copyright (C) 2000 Ximian, Inc. - */ - -#ifndef __E_SELECT_NAMES_MANAGER_H__ -#define __E_SELECT_NAMES_MANAGER_H__ - -#include <stdio.h> -#include <time.h> -#include <gtk/gtkobject.h> -#include <e-util/e-list.h> -#include "e-select-names.h" - -#define E_TYPE_SELECT_NAMES_MANAGER (e_select_names_manager_get_type ()) -#define E_SELECT_NAMES_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_SELECT_NAMES_MANAGER, ESelectNamesManager)) -#define E_SELECT_NAMES_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_SELECT_NAMES_MANAGER, ESelectNamesManagerClass)) -#define E_IS_SELECT_NAMES_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_SELECT_NAMES_MANAGER)) -#define E_IS_SELECT_NAMES_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), E_TYPE_SELECT_NAMES_MANAGER)) - -typedef struct _ESelectNamesManager ESelectNamesManager; -typedef struct _ESelectNamesManagerClass ESelectNamesManagerClass; - -struct _ESelectNamesManager { - GObject object; - - GList *sections; - GList *entries; - - ESelectNames *names; - - GList *completion_books; - - int minimum_query_length; - - gulong listener_id; - - char *cached_folder_list; -}; - -struct _ESelectNamesManagerClass { - GObjectClass parent_class; - - void (*changed) (ESelectNamesManager *, const gchar *section_id, gint changed_working_copy); - void (*ok) (ESelectNamesManager *); - void (*cancel) (ESelectNamesManager *); -}; - -ESelectNamesManager *e_select_names_manager_new (void); -void e_select_names_manager_add_section (ESelectNamesManager *manager, - const char *id, - const char *title); -void e_select_names_manager_add_section_with_limit (ESelectNamesManager *manager, - const char *id, - const char *title, - gint limit); -ESelectNamesModel *e_select_names_manager_get_source (ESelectNamesManager *manager, - const char *id); -GtkWidget *e_select_names_manager_create_entry (ESelectNamesManager *manager, - const char *id); -void e_select_names_manager_activate_dialog (ESelectNamesManager *manager, - EvolutionShellClient *shell_client, - const char *id); -/* Standard Gtk function */ -GType e_select_names_manager_get_type (void); - -#endif /* ! __E_SELECT_NAMES_MANAGER_H__ */ diff --git a/addressbook/gui/component/select-names/e-select-names-marshal.list b/addressbook/gui/component/select-names/e-select-names-marshal.list deleted file mode 100644 index 8e751dc27d..0000000000 --- a/addressbook/gui/component/select-names/e-select-names-marshal.list +++ /dev/null @@ -1,3 +0,0 @@ -NONE:POINTER,INT -NONE:NONE -NONE:INT,INT,INT diff --git a/addressbook/gui/component/select-names/e-select-names-model.c b/addressbook/gui/component/select-names/e-select-names-model.c deleted file mode 100644 index 6c3cb0f9c6..0000000000 --- a/addressbook/gui/component/select-names/e-select-names-model.c +++ /dev/null @@ -1,829 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Authors: - * Chris Lahey <clahey@ximian.com> - * Jon Trowbidge <trow@ximian.com> - * - * Copyright (C) 2000, 2001 Ximian, Inc. - */ - -#include <config.h> - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <gtk/gtkmarshal.h> -#include <gtk/gtksignal.h> - -#include <gal/util/e-util.h> - -#include "e-select-names-model.h" -#include "e-select-names-marshal.h" -#include "addressbook/backend/ebook/e-card-simple.h" - -#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, -}; - -struct _ESelectNamesModelPrivate { - gchar *id; - gchar *title; - - GList *data; /* of EDestination */ - - gint limit; - - gint freeze_count; - gboolean pending_changed; -}; - -static GObjectClass *parent_class = NULL; - -static void e_select_names_model_init (ESelectNamesModel *model); -static void e_select_names_model_class_init (ESelectNamesModelClass *klass); - -static void e_select_names_model_dispose (GObject *object); - -GType -e_select_names_model_get_type (void) -{ - static GType type = 0; - - if (!type) { - static const GTypeInfo info = { - sizeof (ESelectNamesModelClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) e_select_names_model_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (ESelectNamesModel), - 0, /* n_preallocs */ - (GInstanceInitFunc) e_select_names_model_init, - }; - - type = g_type_register_static (G_TYPE_OBJECT, "ESelectNamesModel", &info, 0); - } - - return type; -} - -static void -e_select_names_model_class_init (ESelectNamesModelClass *klass) -{ - GObjectClass *object_class; - - object_class = G_OBJECT_CLASS(klass); - parent_class = g_type_class_peek_parent (klass); - - e_select_names_model_signals[E_SELECT_NAMES_MODEL_CHANGED] = - g_signal_new ("changed", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (ESelectNamesModelClass, changed), - NULL, NULL, - e_select_names_marshal_NONE__NONE, - G_TYPE_NONE, 0); - - e_select_names_model_signals[E_SELECT_NAMES_MODEL_RESIZED] = - g_signal_new ("resized", - G_OBJECT_CLASS_TYPE (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (ESelectNamesModelClass, resized), - NULL, NULL, - e_select_names_marshal_NONE__INT_INT_INT, - G_TYPE_NONE, 3, - G_TYPE_INT, - G_TYPE_INT, - G_TYPE_INT); - - klass->changed = NULL; - - object_class->dispose = e_select_names_model_dispose; -} - -/** - * e_select_names_model_init: - */ -static void -e_select_names_model_init (ESelectNamesModel *model) -{ - model->priv = g_new0 (struct _ESelectNamesModelPrivate, 1); - - model->priv->limit = -1; -} - -static void -e_select_names_model_dispose (GObject *object) -{ - ESelectNamesModel *model = E_SELECT_NAMES_MODEL (object); - - if (model->priv) { - g_free (model->priv->title); - g_free (model->priv->id); - - g_list_foreach (model->priv->data, (GFunc) g_object_unref, NULL); - g_list_free (model->priv->data); - - g_free (model->priv); - model->priv = NULL; - } - - if (G_OBJECT_CLASS (parent_class)->dispose) - G_OBJECT_CLASS (parent_class)->dispose (object); -} - - -static void -e_select_names_model_changed (ESelectNamesModel *model) -{ - if (model->priv->freeze_count > 0) { - model->priv->pending_changed = TRUE; - } else { - g_signal_emit (model, e_select_names_model_signals[E_SELECT_NAMES_MODEL_CHANGED], 0); - model->priv->pending_changed = FALSE; - } -} - -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 = g_object_new (E_TYPE_SELECT_NAMES_MODEL, NULL); - return model; -} - -ESelectNamesModel * -e_select_names_model_duplicate (ESelectNamesModel *old) -{ - ESelectNamesModel *model = e_select_names_model_new (); - GList *iter; - - model->priv->id = g_strdup (old->priv->id); - model->priv->title = g_strdup (old->priv->title); - - for (iter = old->priv->data; iter != NULL; iter = g_list_next (iter)) { - EDestination *dup = e_destination_copy (E_DESTINATION (iter->data)); - e_select_names_model_append (model, dup); - } - - model->priv->limit = old->priv->limit; - - return model; -} - -gchar * -e_select_names_model_get_textification (ESelectNamesModel *model, const char *separator) -{ - gchar *text; - - g_return_val_if_fail (model != NULL, NULL); - g_return_val_if_fail (E_IS_SELECT_NAMES_MODEL (model), NULL); - g_return_val_if_fail (separator && *separator, NULL); - - if (model->priv->data == NULL) { - - text = g_strdup (""); - - } else { - gchar **strv = g_new0 (gchar *, g_list_length (model->priv->data)+1); - gint i = 0; - GList *iter = model->priv->data; - - while (iter) { - EDestination *dest = E_DESTINATION (iter->data); - strv[i] = (gchar *) e_destination_get_textrep (dest, FALSE); - ++i; - iter = g_list_next (iter); - } - - text = g_strjoinv (separator, strv); - - if (g_utf8_strlen(text, -1) > MAX_LENGTH) { - char *p = g_utf8_offset_to_pointer (text, MAX_LENGTH); - *p = '\0'; - text = g_realloc (text, p - text + 1); - } - - g_free (strv); - - } - - return text; -} - -gchar * -e_select_names_model_get_address_text (ESelectNamesModel *model, const char *separator) -{ - gchar *addr_text; - - g_return_val_if_fail (model != NULL, NULL); - g_return_val_if_fail (E_IS_SELECT_NAMES_MODEL (model), NULL); - g_return_val_if_fail (separator && *separator, NULL); - - if (model->priv->data == NULL) { - - addr_text = g_strdup (""); - - } else { - gchar **strv = g_new0 (gchar *, g_list_length (model->priv->data)+1); - gint i = 0; - GList *iter = model->priv->data; - - while (iter) { - EDestination *dest = E_DESTINATION (iter->data); - strv[i] = (gchar *) e_destination_get_address (dest); - if (strv[i]) - ++i; - iter = g_list_next (iter); - } - - addr_text = g_strjoinv (separator, strv); - - g_free (strv); - - } - - return addr_text; -} - -gint -e_select_names_model_count (ESelectNamesModel *model) -{ - g_return_val_if_fail (model != NULL, 0); - g_return_val_if_fail (E_IS_SELECT_NAMES_MODEL (model), 0); - - return g_list_length (model->priv->data); -} - -gint -e_select_names_model_get_limit (ESelectNamesModel *model) -{ - g_return_val_if_fail (model != NULL, 0); - g_return_val_if_fail (E_IS_SELECT_NAMES_MODEL (model), 0); - - return model->priv->limit; -} - -void -e_select_names_model_set_limit (ESelectNamesModel *model, gint limit) -{ - g_return_if_fail (model != NULL); - g_return_if_fail (E_IS_SELECT_NAMES_MODEL (model)); - - model->priv->limit = MAX (limit, -1); -} - -gboolean -e_select_names_model_at_limit (ESelectNamesModel *model) -{ - g_return_val_if_fail (model != NULL, TRUE); - g_return_val_if_fail (E_IS_SELECT_NAMES_MODEL (model), TRUE); - - return model->priv->limit >= 0 && g_list_length (model->priv->data) >= model->priv->limit; -} - -const EDestination * -e_select_names_model_get_destination (ESelectNamesModel *model, gint index) -{ - g_return_val_if_fail (model && E_IS_SELECT_NAMES_MODEL (model), NULL); - g_return_val_if_fail (0 <= index, NULL); - g_return_val_if_fail (index < g_list_length (model->priv->data), NULL); - - return E_DESTINATION (g_list_nth_data (model->priv->data, index)); -} - -gchar * -e_select_names_model_export_destinationv (ESelectNamesModel *model) -{ - EDestination **destv; - gchar *str; - gint i, len = 0; - GList *j; - g_return_val_if_fail (model && E_IS_SELECT_NAMES_MODEL (model), NULL); - - len = g_list_length (model->priv->data); - destv = g_new0 (EDestination *, len+1); - - for (i=0, j = model->priv->data; j != NULL; j = g_list_next (j)) { - EDestination *dest = E_DESTINATION (j->data); - - if (dest) - destv[i++] = dest; - } - - str = e_destination_exportv (destv); - g_free (destv); - - return str; -} - -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, FALSE) : ""; -} - -static void -connect_destination (ESelectNamesModel *model, EDestination *dest) -{ - g_signal_connect (dest, - "changed", - G_CALLBACK (destination_changed_proxy), - model); -} - -static void -disconnect_destination (ESelectNamesModel *model, EDestination *dest) -{ - g_signal_handlers_disconnect_by_func (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. */ - g_object_unref (dest); - return; - } - - connect_destination (model, dest); - - model->priv->data = g_list_insert (model->priv->data, dest, index); - - g_object_ref (dest); - - e_select_names_model_changed (model); -} - -void -e_select_names_model_append (ESelectNamesModel *model, EDestination *dest) -{ - g_return_if_fail (model && E_IS_SELECT_NAMES_MODEL (model)); - g_return_if_fail (dest && E_IS_DESTINATION (dest)); - - if (e_select_names_model_at_limit (model)) { - /* FIXME: This is bad. */ - g_object_unref (dest); - return; - } - - connect_destination (model, dest); - - model->priv->data = g_list_append (model->priv->data, dest); - - g_object_ref (dest); - - e_select_names_model_changed (model); -} - -void -e_select_names_model_replace (ESelectNamesModel *model, gint index, EDestination *dest) -{ - GList *node; - const gchar *new_str, *old_str; - gint old_strlen=0, new_strlen=0; - - g_return_if_fail (model != NULL); - g_return_if_fail (E_IS_SELECT_NAMES_MODEL (model)); - g_return_if_fail (model->priv->data == NULL || (0 <= index && index < g_list_length (model->priv->data))); - g_return_if_fail (dest && E_IS_DESTINATION (dest)); - - new_str = e_destination_get_textrep (dest, FALSE); - new_strlen = new_str ? strlen (new_str) : 0; - - if (model->priv->data == NULL) { - - connect_destination (model, dest); - - model->priv->data = g_list_append (model->priv->data, dest); - g_object_ref (dest); - - } else { - - node = g_list_nth (model->priv->data, index); - - if (node->data != dest) { - - disconnect_destination (model, E_DESTINATION (node->data)); - connect_destination (model, dest); - - old_str = e_destination_get_textrep (E_DESTINATION (node->data), FALSE); - old_strlen = old_str ? strlen (old_str) : 0; - - g_object_unref (node->data); - - node->data = dest; - g_object_ref (dest); - } - } - - e_select_names_model_changed (model); - - g_signal_emit (model, e_select_names_model_signals[E_SELECT_NAMES_MODEL_RESIZED], 0, - index, old_strlen, new_strlen); -} - -void -e_select_names_model_delete (ESelectNamesModel *model, gint index) -{ - GList *node; - EDestination *dest; - - g_return_if_fail (model != NULL); - g_return_if_fail (E_IS_SELECT_NAMES_MODEL (model)); - g_return_if_fail (0 <= index && index < g_list_length (model->priv->data)); - - node = g_list_nth (model->priv->data, index); - dest = E_DESTINATION (node->data); - - disconnect_destination (model, dest); - g_object_unref (dest); - - model->priv->data = g_list_remove_link (model->priv->data, node); - g_list_free_1 (node); - - e_select_names_model_changed (model); -} - -void -e_select_names_model_clean (ESelectNamesModel *model, gboolean clean_last_entry) -{ - GList *iter, *next; - gboolean changed = FALSE; - - g_return_if_fail (model != NULL && E_IS_SELECT_NAMES_MODEL (model)); - - iter = model->priv->data; - - while (iter) { - EDestination *dest; - - next = g_list_next (iter); - - if (next == NULL && !clean_last_entry) - break; - - dest = iter->data ? E_DESTINATION (iter->data) : NULL; - - if (dest == NULL || e_destination_is_empty (dest)) { - if (dest) { - disconnect_destination (model, dest); - g_object_unref (dest); - } - model->priv->data = g_list_remove_link (model->priv->data, iter); - g_list_free_1 (iter); - changed = TRUE; - } - - iter = next; - } - - if (changed) - e_select_names_model_changed (model); -} - -static void -delete_all_iter (gpointer data, gpointer closure) -{ - disconnect_destination (E_SELECT_NAMES_MODEL (closure), E_DESTINATION (data)); - g_object_unref (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 seplen, gint index, gint *pos, gint *length) -{ - gint rp = 0, i, len = 0; - GList *iter; - const gchar *str; - - g_return_if_fail (E_IS_SELECT_NAMES_MODEL (model)); - g_return_if_fail (seplen > 0); - - i = 0; - iter = model->priv->data; - while (iter && i <= index) { - rp += len + (i > 0 ? seplen : 0); - str = e_destination_get_textrep (E_DESTINATION (iter->data), FALSE); - len = str ? g_utf8_strlen (str, -1) : 0; - ++i; - iter = g_list_next (iter); - } - - if (i <= index) { - rp = -1; - len = 0; - } - - if (pos) - *pos = rp; - if (length) - *length = len; -} - -void -e_select_names_model_text_pos (ESelectNamesModel *model, gint seplen, gint pos, gint *index, gint *start_pos, gint *length) -{ - GList *iter; - const gchar *str; - gint len = 0, i = 0, sp = 0, adj = 0; - - g_return_if_fail (E_IS_SELECT_NAMES_MODEL (model)); - g_return_if_fail (seplen > 0); - - iter = model->priv->data; - - while (iter != NULL) { - str = e_destination_get_textrep (E_DESTINATION (iter->data), FALSE); - len = str ? g_utf8_strlen (str, -1) : 0; - - if (sp <= pos && pos <= sp + len + adj) { - break; - } - - sp += len + adj + 1; - adj = seplen-1; - ++i; - - iter = g_list_next (iter); - } - - if (i != 0) - sp += seplen-1; /* skip past "magic space" */ - - if (iter == NULL) { -#if 0 - g_print ("text_pos ended NULL\n"); -#endif - i = -1; - sp = -1; - len = 0; - } else { -#if 0 - g_print ("text_pos got index %d\n", i); -#endif - } - - if (index) - *index = i; - if (start_pos) - *start_pos = sp; - if (length) - *length = len; -} - -void -e_select_names_model_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 8a3c5381b7..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 <clahey@ximian.com> - * Jon Trowbridge <trow@ximian.com> - * - * Copyright (C) 2000, 2001 Ximian, Inc. - */ - -#ifndef __E_SELECT_NAMES_MODEL_H__ -#define __E_SELECT_NAMES_MODEL_H__ - -#include <time.h> -#include <gtk/gtkobject.h> -#include <stdio.h> -#include <e-util/e-list.h> -#include <addressbook/backend/ebook/e-card.h> -#include <addressbook/backend/ebook/e-destination.h> - -#define E_TYPE_SELECT_NAMES_MODEL (e_select_names_model_get_type ()) -#define E_SELECT_NAMES_MODEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_SELECT_NAMES_MODEL, ESelectNamesModel)) -#define E_SELECT_NAMES_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_SELECT_NAMES_MODEL, ESelectNamesModelClass)) -#define E_IS_SELECT_NAMES_MODEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_SELECT_NAMES_MODEL)) -#define E_IS_SELECT_NAMES_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), E_TYPE_SELECT_NAMES_MODEL)) - -typedef struct _ESelectNamesModel ESelectNamesModel; -typedef struct _ESelectNamesModelClass ESelectNamesModelClass; -struct _ESelectNamesModelPrivate; - -struct _ESelectNamesModel { - GObject object; - - struct _ESelectNamesModelPrivate *priv; -}; - -struct _ESelectNamesModelClass { - GObjectClass parent_class; - - void (*changed) (ESelectNamesModel *model); - void (*resized) (ESelectNamesModel *model, gint index, gint old_len, gint new_len); -}; - -GType e_select_names_model_get_type (void); - -ESelectNamesModel *e_select_names_model_new (void); -ESelectNamesModel *e_select_names_model_duplicate (ESelectNamesModel *old); - -gchar *e_select_names_model_get_textification (ESelectNamesModel *model, const char *separator); -gchar *e_select_names_model_get_address_text (ESelectNamesModel *model, const char *separator); - -gint e_select_names_model_count (ESelectNamesModel *model); -gint e_select_names_model_get_limit (ESelectNamesModel *model); -void e_select_names_model_set_limit (ESelectNamesModel *model, gint limit); -gboolean e_select_names_model_at_limit (ESelectNamesModel *model); - -const EDestination *e_select_names_model_get_destination (ESelectNamesModel *model, gint index); -gchar *e_select_names_model_export_destinationv (ESelectNamesModel *model); -void e_select_names_model_import_destinationv (ESelectNamesModel *model, - gchar *destinationv); -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, gboolean clean_last_entry); - -void e_select_names_model_name_pos (ESelectNamesModel *model, gint seplen, gint index, gint *pos, gint *length); -void e_select_names_model_text_pos (ESelectNamesModel *model, gint seplen, gint pos, gint *index, gint *start_pos, gint *length); - -void e_select_names_model_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 d7fabd9426..0000000000 --- a/addressbook/gui/component/select-names/e-select-names-popup.c +++ /dev/null @@ -1,395 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * e-select-names-popup.c - * - * Copyright (C) 2001 Ximian, Inc. - * - * Developed by Jon Trowbridge <trow@ximian.com> - */ - -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - */ - -#include <config.h> - -#include <stdio.h> -#include <string.h> - -#include <glib.h> -#include <gtk/gtkimage.h> -#include <gtk/gtkmenuitem.h> -#include <gtk/gtkimagemenuitem.h> -#include <gtk/gtkcheckmenuitem.h> -#include <gtk/gtkradiomenuitem.h> -#include <gtk/gtkseparatormenuitem.h> -#include <gtk/gtklabel.h> -#include <libgnome/gnome-i18n.h> - -#include <addressbook/backend/ebook/e-book-util.h> -#include <addressbook/gui/contact-editor/e-contact-editor.h> -#include <addressbook/gui/contact-editor/e-contact-quick-add.h> -#include "e-addressbook-util.h" -#include "e-select-names-popup.h" - -#define LIST_ICON_FILENAME "contact-list-16.png" -#define CONTACT_ICON_FILENAME "evolution-contacts-mini.png" - -typedef struct _PopupInfo PopupInfo; -struct _PopupInfo { - ESelectNamesTextModel *text_model; - EDestination *dest; - gint pos; - gint index; -}; - -static PopupInfo * -popup_info_new (ESelectNamesTextModel *text_model, EDestination *dest, gint pos, gint index) -{ - PopupInfo *info = g_new0 (PopupInfo, 1); - info->text_model = text_model; - info->dest = dest; - info->pos = pos; - info->index = index; - - if (text_model) - g_object_ref (text_model); - - if (dest) - g_object_ref (dest); - - return info; -} - -static void -popup_info_free (PopupInfo *info) -{ - if (info) { - - if (info->text_model) - g_object_unref (info->text_model); - - if (info->dest) - g_object_unref (info->dest); - - g_free (info); - } -} - -static void -popup_info_cleanup (GtkWidget *w, gpointer info) -{ - 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); - } - g_object_unref (dest); - } -} - -#if TOO_MANY_MENU_ITEMS -static void -edit_contact_info_cb (GtkWidget *w, gpointer user_data) -{ - PopupInfo *info = (PopupInfo *) user_data; - if (info == NULL) - return; - - g_object_ref (info->dest); - e_book_use_default_book (make_contact_editor_cb, (gpointer) info->dest); -} -#endif - -static void -change_email_num_cb (GtkWidget *w, gpointer user_data) -{ - PopupInfo *info = (PopupInfo *) user_data; - gint n; - EDestination *dest; - - if (info == NULL) - return; - - if (! GTK_CHECK_MENU_ITEM (w)->active) - return; - - n = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (w), "number")); - - if (n != e_destination_get_email_num (info->dest)) { - dest = e_destination_new (); - e_destination_set_card (dest, e_destination_get_card (info->dest), n); - e_select_names_model_replace (info->text_model->source, info->index, dest); - } -} - -#if TOO_MANY_MENU_ITEMS -static void -remove_recipient_cb (GtkWidget *w, gpointer user_data) -{ - PopupInfo *info = (PopupInfo *) user_data; - e_select_names_model_delete (info->text_model->source, info->index); -} - -static void -remove_all_recipients_cb (GtkWidget *w, gpointer user_data) -{ - PopupInfo *info = (PopupInfo *) user_data; - e_select_names_model_delete_all (info->text_model->source); -} - -static void -toggle_html_mail_cb (GtkWidget *w, gpointer user_data) -{ - PopupInfo *info = (PopupInfo *) user_data; - GtkCheckMenuItem *item = GTK_CHECK_MENU_ITEM (w); - const EDestination *dest; - - if (info == NULL) - return; - - dest = info->dest; - - item = GTK_CHECK_MENU_ITEM (item); - e_destination_set_html_mail_pref ((EDestination *) dest, item->active); -} -#endif - -static void -populate_popup_card (GtkWidget *pop, gboolean list, PopupInfo *info) -{ - GtkWidget *image; - ECard *card; - EIterator *iterator; - GtkWidget *menuitem; - - card = e_destination_get_card (info->dest); - -#if TOO_MANY_MENU_ITEMS - menuitem = gtk_separator_menu_item_new(); - gtk_widget_show (menuitem); - gtk_menu_shell_prepend (GTK_MENU_SHELL (pop), menuitem); - - menuitem = gtk_menu_item_new_with_label (_("Remove All")); - g_signal_connect (menuitem, "activate", - G_CALLBACK (remove_all_recipients_cb), - info); - gtk_widget_show (menuitem); - gtk_menu_shell_prepend (GTK_MENU_SHELL (pop), menuitem); - - menuitem = gtk_menu_item_new_with_label (_("Remove")); - g_signal_connect (menuitem, "activate", - G_CALLBACK (remove_recipient_cb), - info); - gtk_widget_show (menuitem); - gtk_menu_shell_prepend (GTK_MENU_SHELL (pop), menuitem); - - menuitem = gtk_menu_item_new_with_label (list ? _("View Contact List") : _("View Contact Info")); - g_signal_connect (menuitem, "activate", - G_CALLBACK (edit_contact_info_cb), - info); - gtk_widget_show (menuitem); - gtk_menu_shell_prepend (GTK_MENU_SHELL (pop), menuitem); - - menuitem = gtk_check_menu_item_new_with_label (_("Send HTML Mail?")); - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menuitem), - e_destination_get_html_mail_pref (info->dest)); - g_signal_connect (menuitem, "toggled", - G_CALLBACK (toggle_html_mail_cb), - info); - gtk_widget_show (menuitem); - gtk_menu_shell_prepend (GTK_MENU_SHELL (pop), menuitem); -#endif - - if (card->email) { - menuitem = gtk_separator_menu_item_new(); - gtk_widget_show (menuitem); - gtk_menu_shell_prepend (GTK_MENU_SHELL (pop), menuitem); - - if (e_list_length (card->email) > 1) { - GSList *radiogroup = NULL; - gint n = e_destination_get_email_num (info->dest); - gint j = e_list_length (card->email) - 1; - - iterator = e_list_get_iterator (card->email); - for (e_iterator_last (iterator); e_iterator_is_valid (iterator); e_iterator_prev (iterator)) { - char *email = (char *)e_iterator_get (iterator); - char *label = NULL; - - if (!strncmp (email, "<?xml", 5)) { - EDestination *dest = e_destination_import (email); - if (dest) { - label = g_strdup (e_destination_get_textrep (dest, TRUE)); - g_object_unref (dest); - } - } - else { - label = g_strdup (email); - } - - if (list) { - menuitem = gtk_menu_item_new_with_label (label); - } - else { - menuitem = gtk_radio_menu_item_new_with_label (radiogroup, label); - g_signal_connect (menuitem, "toggled", - G_CALLBACK (change_email_num_cb), - info); - if (j == n) - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menuitem), TRUE); - - g_object_set_data (G_OBJECT (menuitem), "number", GINT_TO_POINTER (j)); - radiogroup = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (menuitem)); - } - - gtk_widget_show (menuitem); - gtk_menu_shell_prepend (GTK_MENU_SHELL (pop), menuitem); - - j--; - - g_free (label); - } - - g_object_unref (iterator); - } else { - menuitem = gtk_menu_item_new_with_label (e_destination_get_email (info->dest)); - gtk_widget_show (menuitem); - gtk_menu_shell_prepend (GTK_MENU_SHELL (pop), menuitem); - } - } - - menuitem = gtk_separator_menu_item_new (); - gtk_widget_show (menuitem); - gtk_menu_shell_prepend (GTK_MENU_SHELL (pop), menuitem); - - image = gtk_image_new_from_file (list - ? EVOLUTION_IMAGESDIR "/" LIST_ICON_FILENAME - : EVOLUTION_IMAGESDIR "/" CONTACT_ICON_FILENAME); - gtk_widget_show (image); - menuitem = gtk_image_menu_item_new_with_label (e_destination_get_name (info->dest)); - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem), - image); - gtk_widget_show (menuitem); - gtk_menu_shell_prepend (GTK_MENU_SHELL (pop), menuitem); -} - -static void -quick_add_cb (GtkWidget *w, gpointer user_data) -{ - PopupInfo *info = (PopupInfo *) user_data; - e_contact_quick_add_free_form (e_destination_get_address (info->dest), NULL, NULL); -} - -static void -populate_popup_nocard (GtkWidget *pop, PopupInfo *info) -{ - const gchar *str; - GtkWidget *menuitem; - - menuitem = gtk_separator_menu_item_new (); - gtk_widget_show (menuitem); - gtk_menu_shell_prepend (GTK_MENU_SHELL (pop), menuitem); - - menuitem = gtk_menu_item_new_with_label (_("Add to Contacts")); - gtk_widget_show (menuitem); - gtk_menu_shell_prepend (GTK_MENU_SHELL (pop), menuitem); - g_signal_connect (menuitem, "activate", - G_CALLBACK (quick_add_cb), - info); - -#if TOO_MANY_MENU_ITEMS - menuitem = gtk_check_menu_item_new_with_label (_("Send HTML Mail?")); - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menuitem), - e_destination_get_html_mail_pref (info->dest)); - g_signal_connect (menuitem, "toggled", - G_CALLBACK (toggle_html_mail_cb), - info); - gtk_widget_show (menuitem); - gtk_menu_shell_prepend (GTK_MENU_SHELL (pop), menuitem); -#endif - - menuitem = gtk_separator_menu_item_new (); - gtk_widget_show (menuitem); - gtk_menu_shell_prepend (GTK_MENU_SHELL (pop), menuitem); - - str = e_destination_get_name (info->dest); - if (! (str && *str)) - str = e_destination_get_email (info->dest); - if (! (str && *str)) - str = _("Unnamed Contact"); - - menuitem = gtk_menu_item_new_with_label (str); - gtk_widget_show (menuitem); - gtk_menu_shell_prepend (GTK_MENU_SHELL (pop), menuitem); -} - -void -e_select_names_populate_popup (GtkWidget *menu, ESelectNamesTextModel *text_model, - GdkEventButton *ev, gint pos, GtkWidget *for_widget) -{ - ESelectNamesModel *model; - PopupInfo *info; - EDestination *dest; - gint index; - - g_return_if_fail (GTK_IS_MENU_SHELL (menu)); - g_return_if_fail (E_IS_SELECT_NAMES_TEXT_MODEL (text_model)); - g_return_if_fail (ev); - g_return_if_fail (0 <= pos); - - model = text_model->source; - - e_select_names_model_text_pos (model, text_model->seplen, pos, &index, NULL, NULL); - if (index < 0 || index >= e_select_names_model_count (model)) - return; - - /* XXX yuck, why does this return a const? */ - dest = (EDestination *)e_select_names_model_get_destination (model, index); - if (e_destination_is_empty (dest)) - return; - - info = popup_info_new (text_model, dest, pos, index); - - if (e_destination_contains_card (dest)) { - populate_popup_card (menu, e_destination_is_evolution_list (dest), info); - } else { - populate_popup_nocard (menu, info); - } - - /* Clean up our info item after we've made our selection. */ - g_signal_connect (menu, - "selection-done", - G_CALLBACK (popup_info_cleanup), - info); -} diff --git a/addressbook/gui/component/select-names/e-select-names-popup.h b/addressbook/gui/component/select-names/e-select-names-popup.h deleted file mode 100644 index 531275190b..0000000000 --- a/addressbook/gui/component/select-names/e-select-names-popup.h +++ /dev/null @@ -1,36 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * e-select-names-popup.h - * - * Copyright (C) 2001 Ximian, Inc. - * - * Developed by Jon Trowbridge <trow@ximian.com> - */ - -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - */ - -#ifndef __E_SELECT_NAMES_POPUP_H__ -#define __E_SELECT_NAMES_POPUP_H__ - -#include "e-select-names-text-model.h" - -void e_select_names_populate_popup (GtkWidget *menu, ESelectNamesTextModel *text_model, - GdkEventButton *ev, gint pos, GtkWidget *for_widget); - -#endif /* __E_SELECT_NAMES_POPUP_H__ */ - diff --git a/addressbook/gui/component/select-names/e-select-names-section.etspec b/addressbook/gui/component/select-names/e-select-names-section.etspec deleted file mode 100644 index 9d7b038892..0000000000 --- a/addressbook/gui/component/select-names/e-select-names-section.etspec +++ /dev/null @@ -1,7 +0,0 @@ -<ETableSpecification no-headers="true" cursor-mode="line" alternating-row-colors="false"> - <ETableColumn model_col= "0" _title="Name" expansion="1.0" minimum_width="20" resizable="true" cell="string" compare="collate" search="string"/> - <ETableState> - <column source="0"/> - <grouping> <leaf column="0" ascending="true"/> </grouping> - </ETableState> -</ETableSpecification> diff --git a/addressbook/gui/component/select-names/e-select-names-table-model.c b/addressbook/gui/component/select-names/e-select-names-table-model.c deleted file mode 100644 index 1c55c3804d..0000000000 --- a/addressbook/gui/component/select-names/e-select-names-table-model.c +++ /dev/null @@ -1,369 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Authors: - * Chris Lahey <clahey@ximian.com> - * - * Copyright (C) 2000 Ximian, Inc. - */ - -#include <config.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#include <gtk/gtksignal.h> -#include <gal/util/e-util.h> -#include <libgnome/gnome-i18n.h> - -#include "e-select-names-table-model.h" -#include "addressbook/backend/ebook/e-card-simple.h" - -/* Object argument IDs */ -enum { - PROP_0, - PROP_SOURCE, -}; - -static void e_select_names_table_model_init (ESelectNamesTableModel *model); -static void e_select_names_table_model_class_init (ESelectNamesTableModelClass *klass); - -static void e_select_names_table_model_dispose (GObject *object); -static void e_select_names_table_model_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec); -static void e_select_names_table_model_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); -static void e_select_names_table_model_model_changed (ESelectNamesModel *source, - ESelectNamesTableModel *model); - -static ETableModelClass *parent_class = NULL; - -static void -e_select_names_table_model_add_source (ESelectNamesTableModel *model, - ESelectNamesModel *source) -{ - model->source = source; - if (model->source) - g_object_ref(model->source); - model->source_changed_id = g_signal_connect(model->source, "changed", - G_CALLBACK(e_select_names_table_model_model_changed), - model); -} - -static void -e_select_names_table_model_drop_source (ESelectNamesTableModel *model) -{ - if (model->source_changed_id) - g_signal_handler_disconnect(model->source, model->source_changed_id); - if (model->source) - g_object_unref(model->source); - model->source = NULL; - model->source_changed_id = 0; -} - -/** - * e_select_names_table_model_get_type: - * @void: - * - * Registers the &ESelectNamesTableModel class if necessary, and returns the type ID - * associated to it. - * - * Return value: The type ID of the &ESelectNamesTableModel class. - **/ -GType -e_select_names_table_model_get_type (void) -{ - static GType type = 0; - - if (!type) { - static const GTypeInfo info = { - sizeof (ESelectNamesTableModelClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) e_select_names_table_model_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (ESelectNamesTableModel), - 0, /* n_preallocs */ - (GInstanceInitFunc) e_select_names_table_model_init, - }; - - type = g_type_register_static (e_table_model_get_type (), "ESelectNamesTableModel", &info, 0); - } - - return type; -} - -/** - * e_select_names_table_model_new: - * @VCard: a string in vCard format - * - * Returns: a new #ESelectNamesTableModel that wraps the @VCard. - */ -ETableModel * -e_select_names_table_model_new (ESelectNamesModel *source) -{ - ETableModel *model = g_object_new (E_TYPE_SELECT_NAMES_TABLE_MODEL, NULL); - g_object_set(model, - "source", source, - NULL); - return model; -} - -static void -fill_in_info (ESelectNamesTableModel *model) -{ - if (model->source) { - int count = e_select_names_model_count (model->source); - gint i; - - model->count = count; - model->data = g_new(ESelectNamesTableModelData, count); - - for (i = 0; i < count; ++i) { - const EDestination *dest = e_select_names_model_get_destination (model->source, i); - 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(""); - g_object_unref(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) -{ - if (model->data) { - int i; - for (i = 0; i < model->count; i++) { - g_free(model->data[i].name); - g_free(model->data[i].email); - } - g_free(model->data); - model->data = NULL; - } - - model->count = -1; -} - -/* - * ESelectNamesTableModel lifecycle management and vcard loading/saving. - */ - -static void -e_select_names_table_model_dispose (GObject *object) -{ - ESelectNamesTableModel *model; - - model = E_SELECT_NAMES_TABLE_MODEL (object); - - e_select_names_table_model_drop_source (model); - clear_info(model); - - if (G_OBJECT_CLASS (parent_class)->dispose) - G_OBJECT_CLASS (parent_class)->dispose (object); -} - -/* This function returns the number of columns in our ETableModel. */ -static int -e_select_names_table_model_col_count (ETableModel *etc) -{ - return 3; -} - -/* This function returns the number of rows in our ETableModel. */ -static int -e_select_names_table_model_row_count (ETableModel *etc) -{ - ESelectNamesTableModel *e_select_names_table_model = E_SELECT_NAMES_TABLE_MODEL(etc); - if (e_select_names_table_model->count == -1) { - if (e_select_names_table_model->source) { - fill_in_info(e_select_names_table_model); - } else { - return 0; - } - } - return e_select_names_table_model->count; -} - -/* This function returns the value at a particular point in our ETableModel. */ -static void * -e_select_names_table_model_value_at (ETableModel *etc, int col, int row) -{ - ESelectNamesTableModel *e_select_names_table_model = E_SELECT_NAMES_TABLE_MODEL(etc); - if (e_select_names_table_model->data == NULL) { - fill_in_info(e_select_names_table_model); - } - switch (col) { - case 0: - if (e_select_names_table_model->data[row].name == NULL) { - fill_in_info(e_select_names_table_model); - } - return e_select_names_table_model->data[row].name; - break; - case 1: - if (e_select_names_table_model->data[row].email == NULL) { - fill_in_info(e_select_names_table_model); - } - return e_select_names_table_model->data[row].email; - break; - case 2: - /* underline column*/ - return (void*)TRUE; - break; - } - return ""; -} - -/* This function sets the value at a particular point in our ETableModel. */ -static void -e_select_names_table_model_set_value_at (ETableModel *etc, int col, int row, const void *val) -{ -} - -/* This function returns whether a particular cell is editable. */ -static gboolean -e_select_names_table_model_is_cell_editable (ETableModel *etc, int col, int row) -{ - return FALSE; -} - -/* This function duplicates the value passed to it. */ -static void * -e_select_names_table_model_duplicate_value (ETableModel *etc, int col, const void *value) -{ - return g_strdup(value); -} - -/* This function frees the value passed to it. */ -static void -e_select_names_table_model_free_value (ETableModel *etc, int col, void *value) -{ - g_free(value); -} - -static void * -e_select_names_table_model_initialize_value (ETableModel *etc, int col) -{ - return g_strdup(""); -} - -static gboolean -e_select_names_table_model_value_is_empty (ETableModel *etc, int col, const void *value) -{ - return !(value && *(char *)value); -} - -static char * -e_select_names_table_model_value_to_string (ETableModel *etc, int col, const void *value) -{ - return g_strdup(value); -} - -static void -e_select_names_table_model_model_changed (ESelectNamesModel *source, - ESelectNamesTableModel *model) -{ - e_table_model_pre_change(E_TABLE_MODEL(model)); - clear_info(model); - e_table_model_changed(E_TABLE_MODEL(model)); -} - -/* Set_arg handler for the model */ -static void -e_select_names_table_model_set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec) -{ - ESelectNamesTableModel *model; - - model = E_SELECT_NAMES_TABLE_MODEL (object); - - switch (prop_id) { - case PROP_SOURCE: - e_select_names_table_model_drop_source (model); - e_select_names_table_model_add_source (model, E_SELECT_NAMES_MODEL(g_value_get_object (value))); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -/* Get_arg handler for the model */ -static void -e_select_names_table_model_get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec) -{ - ESelectNamesTableModel *model; - - model = E_SELECT_NAMES_TABLE_MODEL (object); - - switch (prop_id) { - case PROP_SOURCE: - g_value_set_object (value, model->source); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -/** - * e_select_names_table_model_init: - */ -static void -e_select_names_table_model_init (ESelectNamesTableModel *model) -{ - model->source = NULL; - model->source_changed_id = 0; - - model->count = -1; - model->data = NULL; -} - -static void -e_select_names_table_model_class_init (ESelectNamesTableModelClass *klass) -{ - GObjectClass *object_class; - ETableModelClass *table_model_class; - - object_class = G_OBJECT_CLASS(klass); - table_model_class = E_TABLE_MODEL_CLASS(klass); - - parent_class = g_type_class_peek_parent (klass); - - object_class->dispose = e_select_names_table_model_dispose; - object_class->get_property = e_select_names_table_model_get_property; - object_class->set_property = e_select_names_table_model_set_property; - - g_object_class_install_property (object_class, PROP_SOURCE, - g_param_spec_object ("source", - _("Source"), - /*_( */"XXX blurb" /*)*/, - E_TYPE_SELECT_NAMES_MODEL, - G_PARAM_READWRITE)); - - table_model_class->column_count = e_select_names_table_model_col_count; - table_model_class->row_count = e_select_names_table_model_row_count; - table_model_class->value_at = e_select_names_table_model_value_at; - table_model_class->set_value_at = e_select_names_table_model_set_value_at; - table_model_class->is_cell_editable = e_select_names_table_model_is_cell_editable; - table_model_class->duplicate_value = e_select_names_table_model_duplicate_value; - table_model_class->free_value = e_select_names_table_model_free_value; - table_model_class->initialize_value = e_select_names_table_model_initialize_value; - table_model_class->value_is_empty = e_select_names_table_model_value_is_empty; - table_model_class->value_to_string = e_select_names_table_model_value_to_string; -} diff --git a/addressbook/gui/component/select-names/e-select-names-table-model.h b/addressbook/gui/component/select-names/e-select-names-table-model.h deleted file mode 100644 index 1fd1026f19..0000000000 --- a/addressbook/gui/component/select-names/e-select-names-table-model.h +++ /dev/null @@ -1,51 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Authors: - * Chris Lahey <clahey@ximian.com> - * - * Copyright (C) 2000 Ximian, Inc. - */ - -#ifndef __E_SELECT_NAMES_TABLE_MODEL_H__ -#define __E_SELECT_NAMES_TABLE_MODEL_H__ - -#include <time.h> -#include <stdio.h> -#include <gtk/gtkobject.h> -#include <gal/e-table/e-table-model.h> -#include "e-select-names-model.h" - -#define E_TYPE_SELECT_NAMES_TABLE_MODEL (e_select_names_table_model_get_type ()) -#define E_SELECT_NAMES_TABLE_MODEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_SELECT_NAMES_TABLE_MODEL, ESelectNamesTableModel)) -#define E_SELECT_NAMES_TABLE_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_SELECT_NAMES_TABLE_MODEL, ESelectNamesTableModelClass)) -#define E_IS_SELECT_NAMES_TABLE_MODEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_SELECT_NAMES_TABLE_MODEL)) -#define E_IS_SELECT_NAMES_TABLE_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), E_TYPE_SELECT_NAMES_TABLE_MODEL)) - -typedef struct { - char *name; - char *email; -} ESelectNamesTableModelData; - -typedef struct _ESelectNamesTableModel ESelectNamesTableModel; -typedef struct _ESelectNamesTableModelClass ESelectNamesTableModelClass; - -struct _ESelectNamesTableModel { - ETableModel parent; - - ESelectNamesModel *source; - int source_changed_id; - - int count; - ESelectNamesTableModelData *data; /* This is used as an array. */ -}; - -struct _ESelectNamesTableModelClass { - ETableModelClass parent_class; -}; - -ETableModel *e_select_names_table_model_new (ESelectNamesModel *source); - -/* Standard Gtk function */ -GType e_select_names_table_model_get_type (void); - -#endif /* ! __E_SELECT_NAMES_TABLE_MODEL_H__ */ diff --git a/addressbook/gui/component/select-names/e-select-names-text-model.c b/addressbook/gui/component/select-names/e-select-names-text-model.c deleted file mode 100644 index 7859d5b056..0000000000 --- a/addressbook/gui/component/select-names/e-select-names-text-model.c +++ /dev/null @@ -1,847 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Authors: - * Chris Lahey <clahey@ximian.com> - * Jon Trowbridge <trow@ximian.com> - * - * Copyright (C) 2000, 2001 Ximian, Inc. - */ - -#include <config.h> - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <ctype.h> - -#include <gal/e-text/e-text-model-repos.h> -#include <libgnome/gnome-i18n.h> - -#include <addressbook/gui/contact-editor/e-contact-editor.h> -#include "e-select-names-text-model.h" -#include "e-addressbook-util.h" - -static FILE *out = NULL; /* stream for debugging spew */ - -/* Object argument IDs */ -enum { - PROP_0, - PROP_SOURCE, -}; - -static void e_select_names_text_model_class_init (ESelectNamesTextModelClass *klass); -static void e_select_names_text_model_init (ESelectNamesTextModel *model); -static void e_select_names_text_model_dispose (GObject *object); -static void e_select_names_text_model_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec); -static void e_select_names_text_model_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); - -static void e_select_names_text_model_set_source (ESelectNamesTextModel *model, ESelectNamesModel *source); - -static const gchar *e_select_names_text_model_get_text (ETextModel *model); -static void e_select_names_text_model_set_text (ETextModel *model, const gchar *text); -static void e_select_names_text_model_insert (ETextModel *model, gint position, const gchar *text); -static void e_select_names_text_model_insert_length (ETextModel *model, gint position, const gchar *text, gint length); -static void e_select_names_text_model_delete (ETextModel *model, gint position, gint length); - -static gint e_select_names_text_model_obj_count (ETextModel *model); -static const gchar *e_select_names_text_model_get_nth_obj (ETextModel *model, gint n, gint *len); -static void e_select_names_text_model_activate_obj (ETextModel *model, gint n); - - -static ETextModelClass *parent_class; -#define PARENT_TYPE e_text_model_get_type() - -/** - * e_select_names_text_model_get_type: - * @void: - * - * Registers the &ESelectNamesTextModel class if necessary, and returns the type ID - * associated to it. - * - * Return value: The type ID of the &ESelectNamesTextModel class. - **/ -GtkType -e_select_names_text_model_get_type (void) -{ - static GType type = 0; - - if (!type) { - static const GTypeInfo info = { - sizeof (ESelectNamesTextModelClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) e_select_names_text_model_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (ESelectNamesTextModel), - 0, /* n_preallocs */ - (GInstanceInitFunc) e_select_names_text_model_init, - }; - - type = g_type_register_static (PARENT_TYPE, "ESelectNamesTextModel", &info, 0); - } - - return type; -} - -static void -e_select_names_text_model_class_init (ESelectNamesTextModelClass *klass) -{ - GObjectClass *object_class; - ETextModelClass *text_model_class; - - object_class = G_OBJECT_CLASS(klass); - text_model_class = E_TEXT_MODEL_CLASS(klass); - - parent_class = g_type_class_peek_parent (klass); - - object_class->dispose = e_select_names_text_model_dispose; - object_class->get_property = e_select_names_text_model_get_property; - object_class->set_property = e_select_names_text_model_set_property; - - g_object_class_install_property (object_class, PROP_SOURCE, - g_param_spec_object ("source", - _("Source"), - /*_( */"XXX blurb" /*)*/, - E_TYPE_SELECT_NAMES_MODEL, - G_PARAM_READWRITE)); - - text_model_class->get_text = e_select_names_text_model_get_text; - text_model_class->set_text = e_select_names_text_model_set_text; - text_model_class->insert = e_select_names_text_model_insert; - text_model_class->insert_length = e_select_names_text_model_insert_length; - text_model_class->delete = e_select_names_text_model_delete; - - text_model_class->obj_count = e_select_names_text_model_obj_count; - text_model_class->get_nth_obj = e_select_names_text_model_get_nth_obj; - text_model_class->object_activated = e_select_names_text_model_activate_obj; - - if (getenv ("EVO_DEBUG_SELECT_NAMES_TEXT_MODEL")) { - out = fopen ("/tmp/evo-debug-select-names-text-model", "w"); - if (out) - setvbuf (out, NULL, _IONBF, 0); - } -} - -static void -dump_model (ESelectNamesTextModel *text_model) -{ - ESelectNamesModel *model = text_model->source; - gint i; - - if (out == NULL) - return; - - fprintf (out, "\n*** Model State: count=%d\n", e_select_names_model_count (model)); - - for (i=0; i<e_select_names_model_count (model); ++i) - fprintf (out, "[%d] \"%s\" %s\n", i, - e_select_names_model_get_string (model, i), - e_select_names_model_get_card (model, i) ? "<card>" : ""); - fprintf (out, "\n"); -} - -static void -e_select_names_text_model_init (ESelectNamesTextModel *model) -{ - const gchar *default_sep; - - model->last_magic_comma_pos = -1; - - if (getenv ("EVOLUTION_DISABLE_MAGIC_COMMA")) - default_sep = ","; - else - default_sep = ", "; - - e_select_names_text_model_set_separator (model, default_sep); -} - -static void -e_select_names_text_model_dispose (GObject *object) -{ - ESelectNamesTextModel *model; - - model = E_SELECT_NAMES_TEXT_MODEL (object); - - if (model->text) { - g_free (model->text); - model->text = NULL; - } - if (model->sep) { - g_free (model->sep); - model->sep = NULL; - } - - e_select_names_text_model_set_source (model, NULL); - - if (G_OBJECT_CLASS(parent_class)->dispose) - G_OBJECT_CLASS(parent_class)->dispose(object); -} - -static void -e_select_names_text_model_set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec) -{ - ESelectNamesTextModel *model; - - model = E_SELECT_NAMES_TEXT_MODEL (object); - - switch (prop_id) { - case PROP_SOURCE: - e_select_names_text_model_set_source(model, E_SELECT_NAMES_MODEL (g_value_get_object(value))); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -e_select_names_text_model_get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec) -{ - ESelectNamesTextModel *model; - - model = E_SELECT_NAMES_TEXT_MODEL (object); - - switch (prop_id) { - case PROP_SOURCE: - g_value_set_object (value, model->source); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -resize_cb (ESelectNamesModel *source, gint index, gint old_len, gint new_len, ETextModel *model) -{ - EReposDeleteShift repos_del; - EReposInsertShift repos_ins; - gint pos; - gint seplen = E_SELECT_NAMES_TEXT_MODEL (model)->seplen; - - e_select_names_model_name_pos (source, seplen, index, &pos, NULL); - - if (new_len < old_len) { - - repos_del.model = model; - repos_del.pos = pos; - repos_del.len = old_len - new_len; - e_text_model_reposition (model, e_repos_delete_shift, &repos_del); - - } else if (old_len < new_len) { - - repos_ins.model = model; - repos_ins.pos = pos; - repos_ins.len = new_len - old_len; - e_text_model_reposition (model, e_repos_insert_shift, &repos_ins); - - } -} - -static void -changed_cb (ESelectNamesModel *source, ETextModel *model) -{ - ESelectNamesTextModel *text_model = E_SELECT_NAMES_TEXT_MODEL (model); - - g_free (text_model->text); - text_model->text = NULL; - - e_text_model_changed (model); -} - - -static void -e_select_names_text_model_set_source (ESelectNamesTextModel *model, - ESelectNamesModel *source) -{ - if (source == model->source) - return; - - if (model->source) { - g_signal_handler_disconnect (model->source, model->source_changed_id); - g_signal_handler_disconnect (model->source, model->source_resize_id); - g_object_unref (model->source); - } - - model->source = source; - - if (model->source) { - g_object_ref (model->source); - model->source_changed_id = g_signal_connect (model->source, - "changed", - G_CALLBACK (changed_cb), - model); - model->source_resize_id = g_signal_connect (model->source, - "resized", - G_CALLBACK (resize_cb), - model); - } -} - -ETextModel * -e_select_names_text_model_new (ESelectNamesModel *source) -{ - ETextModel *model = g_object_new (E_TYPE_SELECT_NAMES_TEXT_MODEL, NULL); - e_select_names_text_model_set_source (E_SELECT_NAMES_TEXT_MODEL (model), source); - return model; -} - -void -e_select_names_text_model_set_separator (ESelectNamesTextModel *model, const char *sep) -{ - g_return_if_fail (E_IS_SELECT_NAMES_TEXT_MODEL (model)); - g_return_if_fail (sep && *sep); - - g_free (model->sep); - model->sep = g_strdup (sep); - model->seplen = g_utf8_strlen (sep, -1); -} - -static const gchar * -e_select_names_text_model_get_text (ETextModel *model) -{ - ESelectNamesTextModel *snm = E_SELECT_NAMES_TEXT_MODEL(model); - - if (snm == NULL) - return ""; - else if (snm->text == NULL) - snm->text = e_select_names_model_get_textification (snm->source, snm->sep); - - return snm->text; -} - -static void -e_select_names_text_model_set_text (ETextModel *model, const gchar *text) -{ - ESelectNamesTextModel *snm = E_SELECT_NAMES_TEXT_MODEL(model); - - e_select_names_model_delete_all (snm->source); - e_select_names_text_model_insert (model, 0, text); -} - -static void -e_select_names_text_model_insert (ETextModel *model, gint position, const gchar *text) -{ - e_select_names_text_model_insert_length (model, position, text, g_utf8_strlen (text, -1)); -} - -static void -e_select_names_text_model_insert_length (ETextModel *model, gint pos, const gchar *text, gint length) -{ - ESelectNamesTextModel *text_model = E_SELECT_NAMES_TEXT_MODEL (model); - ESelectNamesModel *source = text_model->source; - const char *t; - gchar *tmp; - - if (out) { - tmp = g_strndup (text, length); - fprintf (out, ">> insert \"%s\" (len=%d) at %d\n", tmp, length, pos); - g_free (tmp); - } - - tmp = e_select_names_model_get_textification (source, text_model->sep); - pos = CLAMP (pos, 0, g_utf8_strlen (tmp, -1)); - g_free (tmp); - - /* We want to control all cursor motions ourselves, rather than taking hints - from the ESelectNamesModel. */ - g_signal_handler_block (source, text_model->source_resize_id); - - /* We handle this one character at a time. */ - - for (t = text; length >= 0; t = g_utf8_next_char (t), length--) { - gint index, start_pos, text_len; - gboolean inside_quote = FALSE; - gunichar ut = g_utf8_get_char (t); - - if (ut == 0) - break; - - text_model->last_magic_comma_pos = -1; - - if (out) - fprintf (out, "processing [%d]\n", ut); - - e_select_names_model_text_pos (source, text_model->seplen, pos, &index, &start_pos, &text_len); - - if (out) - fprintf (out, "index=%d start_pos=%d text_len=%d\n", index, start_pos, text_len); - - /* Is this a quoted or an unquoted separator we are dealing with? */ - if (ut == g_utf8_get_char(text_model->sep) && index >= 0) { - const EDestination *dest = e_select_names_model_get_destination (source, index); - if (dest) { - const gchar *str = e_destination_get_textrep (dest, FALSE); - int j; - const char *jp; - - if (out) - fprintf (out, "str=%s pos=%d\n", str, pos); - - for (jp = str, j = 0; j<pos-start_pos && *jp; jp = g_utf8_next_char (jp), ++j) { - if (*jp == '"') { - inside_quote = !inside_quote; - if (out) - fprintf (out, "flip to %d at %d\n", start_pos+j, inside_quote); - } - } - } - if (out) - fprintf (out, inside_quote ? "inside quote\n" : "not inside quote\n"); - } - - - if (ut == g_utf8_get_char (text_model->sep) && !inside_quote) { - - /* This is the case of hitting , first thing in an empty entry */ - if (index == -1) { - EReposAbsolute repos; - - e_select_names_model_insert (source, 0, e_destination_new ()); - e_select_names_model_insert (source, 0, e_destination_new ()); - - repos.model = model; - repos.pos = -1; /* At end */ - e_text_model_reposition (model, e_repos_absolute, &repos); - - - } else if (pos <= start_pos || pos == start_pos + text_len) { - EReposInsertShift repos; - gint ins_point = index; - - if (text_len != 0 && pos == start_pos + text_len) - ++ins_point; - - /* Block adjacent blank cards. */ - if (! ((ins_point < e_select_names_model_count (source) && - (e_select_names_model_get_string (source, ins_point) == NULL)) - || (ins_point > 0 && (e_select_names_model_get_string (source, ins_point-1) == NULL)))) { - - e_select_names_model_insert (source, ins_point, e_destination_new ()); - - repos.model = model; - repos.pos = pos; - repos.len = text_model->seplen; - e_text_model_reposition (model, e_repos_insert_shift, &repos); - pos += text_model->seplen; - } - - } else { - EReposInsertShift repos; - gint offset = MAX (pos - start_pos, 0); - const gchar *str = e_select_names_model_get_string (source, index); - gchar *str1 = g_strndup (str, offset); - gchar *str2 = g_strdup (str+offset); - EDestination *d1 = e_destination_new (), *d2 = e_destination_new (); - - e_destination_set_raw (d1, str1); - e_destination_set_raw (d2, str2); - - e_select_names_model_replace (source, index, d1); - e_select_names_model_insert (source, index+1, d2); - - g_free (str1); - g_free (str2); - - repos.model = model; - repos.pos = pos; - repos.len = text_model->seplen; - e_text_model_reposition (model, e_repos_insert_shift, &repos); - pos += text_model->seplen; - } - - if (text_model->seplen > 1) - text_model->last_magic_comma_pos = pos; - - } else { - EReposInsertShift repos; - gint offset = MAX (pos - start_pos, 0); - const gchar *str; - GString *new_str = g_string_new (NULL); - gint this_length = 1; - gboolean whitespace = g_unichar_isspace (ut); - - str = index >= 0 ? e_select_names_model_get_string (source, index) : NULL; - if (str && *str) { - if (pos <= start_pos) { - if (whitespace) { - /* swallow leading whitespace */ - this_length = 0; - } else { - /* Adjust for our "magic white space" */ - /* FIXME: This code does the wrong thing if seplen > 2 */ - g_string_append_unichar (new_str, ut); - g_string_append (new_str, pos < start_pos ? " " : ""); - g_string_append (new_str, str); - if (pos < start_pos) - ++this_length; - } - } else { - const char *u; - int n; - for (u = str, n = 0; n < offset; u = g_utf8_next_char (u), n++) - g_string_append_unichar (new_str, g_utf8_get_char (u)); - g_string_append_unichar (new_str, ut); - g_string_append (new_str, u); - } - } else { - if (whitespace) { - /* swallow leading whitespace */ - this_length = 0; - } else { - g_string_append_unichar (new_str, ut); - } - } - - if (new_str->len) { - - EDestination *dest; - dest = index >= 0 ? e_destination_copy (e_select_names_model_get_destination (source, index)) : e_destination_new (); - e_destination_set_raw (dest, new_str->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_string_free (new_str, TRUE); - } - } - - dump_model (text_model); - - g_signal_handler_unblock (source, text_model->source_resize_id); -} - - -static void -e_select_names_text_model_delete (ETextModel *model, gint pos, gint length) -{ - ESelectNamesTextModel *text_model = E_SELECT_NAMES_TEXT_MODEL (model); - ESelectNamesModel *source = text_model->source; - gint index, start_pos, text_len, offset; - - if (out) { - const gchar *str = e_select_names_model_get_textification (source, text_model->sep); - gint i, len; - - fprintf (out, ">> delete %d at pos %d\n", length, pos); - - len = strlen (str); - for (i=0; i<pos && i<len; ++i) - fprintf (out, "%c", str[i]); - fprintf (out, "["); - for (i=pos; i<pos+length && i<len; ++i) - fprintf (out, "%c", str[i]); - fprintf (out, "]"); - for (i=pos+length; i<len; ++i) - fprintf (out, "%c", str[i]); - fprintf (out, "\n"); - } - - if (length < 0) - return; - - if (text_model->last_magic_comma_pos == pos+1 && length == 1) { - pos -= text_model->seplen-1; - if (pos >= 0) - length = text_model->seplen; - text_model->last_magic_comma_pos = -1; - } - - e_select_names_model_text_pos (source, text_model->seplen, pos, &index, &start_pos, &text_len); - - if (out) - fprintf (out, "index=%d, start_pos=%d, text_len=%d\n", index, start_pos, text_len); - - /* We want to control all cursor motions ourselves, rather than taking hints - from the ESelectNamesModel. */ - g_signal_handler_block (source, E_SELECT_NAMES_TEXT_MODEL (model)->source_resize_id); - - /* First, we handle a few tricky cases. */ - - if (pos < start_pos) { - EReposAbsolute repos; - - repos.model = model; - repos.pos = pos; - e_text_model_reposition (model, e_repos_absolute, &repos); - - length -= start_pos - pos; - - if (length > 0) - e_select_names_text_model_delete (model, start_pos, length); - goto finished; - } - - if (pos == start_pos + text_len) { - /* We are positioned right at the end of an entry, possibly right in front of a comma. */ - - if (index+1 < e_select_names_model_count (source)) { - EReposDeleteShift repos; - EDestination *new_dest; - const gchar *str1 = e_select_names_model_get_string (source, index); - const gchar *str2 = e_select_names_model_get_string (source, index+1); - gchar *new_str; - - while (str1 && *str1 && isspace ((gint) *str1)) - ++str1; - while (str2 && *str2 && isspace ((gint) *str2)) - ++str2; - - if (str1 && str2) - new_str = g_strdup_printf ("%s%s%s", str1, text_model->sep+1, str2); - else if (str1) - new_str = g_strdup (str1); - else if (str2) - new_str = g_strdup (str2); - else - new_str = g_strdup (""); - - if (out) - fprintf (out, "joining \"%s\" and \"%s\" to \"%s\"\n", str1, str2, new_str); - - e_select_names_model_delete (source, index+1); - - new_dest = e_destination_new (); - e_destination_set_raw (new_dest, new_str); - e_select_names_model_replace (source, index, new_dest); - g_free (new_str); - - repos.model = model; - repos.pos = pos; - repos.len = text_model->seplen; - - e_text_model_reposition (model, e_repos_delete_shift, &repos); - - if (length > 1) - e_select_names_text_model_delete (model, pos, length-1); - } else { - /* If we are at the end of the last entry (which we must be if we end up in this block), - we can just do nothing. So this else-block is here just to give us a place to - put this comment. */ - } - - goto finished; - } - - if (pos + length > start_pos + text_len) { - /* Uh oh... our changes straddle two objects. */ - - if (pos == start_pos) { /* Delete the whole thing */ - EReposDeleteShift repos; - - e_select_names_model_delete (source, index); - - if (out) - fprintf (out, "deleted all of %d\n", index); - - repos.model = model; - repos.pos = pos; - repos.len = text_len + text_model->seplen; - - e_text_model_reposition (model, e_repos_delete_shift, &repos); - - length -= text_len + text_model->seplen; - if (length > 0) - e_select_names_text_model_delete (model, pos, length); - - } else { - /* Delete right up to the end, and then call e_select_names_text_model_delete again - to finish the job. */ - gint len1, len2; - - len1 = text_len - (pos - start_pos); - len2 = length - len1; - - if (out) - fprintf (out, "two-stage delete: %d, %d\n", len1, len2); - - - e_select_names_text_model_delete (model, pos, len1); - e_select_names_text_model_delete (model, pos, len2); - } - - goto finished; - } - - /* Our changes are confined to just one entry. */ - if (length > 0) { - const gchar *str; - gchar *new_str; - - offset = pos - start_pos; - - str = e_select_names_model_get_string (source, index); - - if (str) { - const char *p; - char *np; - int i; - EReposDeleteShift repos; - EDestination *dest; - - new_str = g_new0 (char, strlen (str) * 6 + 1); /* worse case it can't be any longer than this */ - - /* copy the region before the deletion */ - for (p = str, i = 0, np = new_str; i < offset; i++) { - gunichar ch; - - ch = g_utf8_get_char (p); - g_unichar_to_utf8 (ch, np); - - np = g_utf8_next_char (np); - p = g_utf8_next_char (p); - } - - /* skip the deleted segment */ - for (i = 0; i < length; i++) - p = g_utf8_next_char (p); - - /* copy the region after the deletion */ - for (; *p; p = g_utf8_next_char (p)) { - gunichar ch; - - ch = g_utf8_get_char (p); - g_unichar_to_utf8 (ch, np); - - np = g_utf8_next_char (np); - } - - dest = 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 = text_model->seplen; - - e_text_model_reposition (model, e_repos_delete_shift, &repos); - } - } - - finished: - E_SELECT_NAMES_TEXT_MODEL (model)->last_magic_comma_pos = -1; - g_signal_handler_unblock (source, E_SELECT_NAMES_TEXT_MODEL (model)->source_resize_id); - dump_model (E_SELECT_NAMES_TEXT_MODEL (model)); -} - -static gint -e_select_names_text_model_obj_count (ETextModel *model) -{ - ESelectNamesModel *source = E_SELECT_NAMES_TEXT_MODEL (model)->source; - gint i, count; - - count = i = e_select_names_model_count (source); - while (i > 0) { - const EDestination *dest; - --i; - dest = e_select_names_model_get_destination (source, i); - if (e_destination_get_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) -{ - ESelectNamesTextModel *text_model = E_SELECT_NAMES_TEXT_MODEL (model); - ESelectNamesModel *source = text_model->source; - gint i, pos; - - i = nth_obj_index (source, n); - if (i < 0) - return NULL; - - e_select_names_model_name_pos (source, text_model->seplen, i, &pos, len); - if (pos < 0) - return NULL; - - if (text_model->text == NULL) - text_model->text = e_select_names_model_get_textification (source, text_model->sep); - return g_utf8_offset_to_pointer (text_model->text, pos); -} - -static void -e_select_names_text_model_activate_obj (ETextModel *model, gint n) -{ - ESelectNamesModel *source = E_SELECT_NAMES_TEXT_MODEL (model)->source; - 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 */ - if (e_card_evolution_list (card)) { - EContactListEditor *ce; - ce = e_addressbook_show_contact_list_editor (e_card_get_book(card), card, FALSE, FALSE); - e_contact_list_editor_raise (ce); - } - else { - EContactEditor *ce; - ce = e_addressbook_show_contact_editor (e_card_get_book(card), card, FALSE, FALSE); - e_contact_editor_raise (ce); - } -} - - - diff --git a/addressbook/gui/component/select-names/e-select-names-text-model.h b/addressbook/gui/component/select-names/e-select-names-text-model.h deleted file mode 100644 index eec062aee6..0000000000 --- a/addressbook/gui/component/select-names/e-select-names-text-model.h +++ /dev/null @@ -1,53 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Authors: - * Chris Lahey <clahey@ximian.com> - * Jon Trowbridge <trow@ximian.com> - * - * Copyright (C) 2000, 2001 Ximian, Inc. - */ - -#ifndef __E_SELECT_NAMES_TEXT_MODEL_H__ -#define __E_SELECT_NAMES_TEXT_MODEL_H__ - -#include <time.h> -#include <stdio.h> -#include <gtk/gtkobject.h> -#include <gal/e-text/e-text-model.h> -#include "e-select-names-model.h" - -#define E_TYPE_SELECT_NAMES_TEXT_MODEL (e_select_names_text_model_get_type ()) -#define E_SELECT_NAMES_TEXT_MODEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_SELECT_NAMES_TEXT_MODEL, ESelectNamesTextModel)) -#define E_SELECT_NAMES_TEXT_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_SELECT_NAMES_TEXT_MODEL, ESelectNamesTextModelClass)) -#define E_IS_SELECT_NAMES_TEXT_MODEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_SELECT_NAMES_TEXT_MODEL)) -#define E_IS_SELECT_NAMES_TEXT_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), E_TYPE_SELECT_NAMES_TEXT_MODEL)) - -typedef struct _ESelectNamesTextModel ESelectNamesTextModel; -typedef struct _ESelectNamesTextModelClass ESelectNamesTextModelClass; - -struct _ESelectNamesTextModel { - ETextModel parent; - - ESelectNamesModel *source; - gint source_changed_id; - gint source_resize_id; - - gchar *text; - - gchar *sep; - gint seplen; - - gint last_magic_comma_pos; -}; - -struct _ESelectNamesTextModelClass { - ETextModelClass parent_class; -}; - -ETextModel *e_select_names_text_model_new (ESelectNamesModel *source); -void e_select_names_text_model_set_separator (ESelectNamesTextModel *model, const char *sep); - -/* Standard Gtk function */ -GType e_select_names_text_model_get_type (void); - -#endif /* ! __E_SELECT_NAMES_TEXT_MODEL_H__ */ diff --git a/addressbook/gui/component/select-names/e-select-names.c b/addressbook/gui/component/select-names/e-select-names.c deleted file mode 100644 index f009fbbd63..0000000000 --- a/addressbook/gui/component/select-names/e-select-names.c +++ /dev/null @@ -1,845 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* e-select-names.c - * Copyright (C) 2000 Ximian, Inc. - * Author: Chris Lahey <clahey@ximian.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include <config.h> -#include <string.h> -#include <glib.h> -#include <gtk/gtk.h> -#include <libgnome/gnome-i18n.h> - -#include <gal/e-table/e-table-simple.h> -#include <gal/e-table/e-table-without.h> -#include <gal/widgets/e-popup-menu.h> - -#include <addressbook/gui/widgets/e-addressbook-model.h> -#include <addressbook/gui/widgets/e-addressbook-table-adapter.h> -#include <addressbook/gui/component/e-cardlist-model.h> -#include <addressbook/backend/ebook/e-book.h> -#include <addressbook/backend/ebook/e-book-util.h> -#include <addressbook/gui/component/addressbook-component.h> -#include <addressbook/gui/component/addressbook-storage.h> -#include <addressbook/gui/component/addressbook.h> -#include <shell/evolution-shell-client.h> -#include <shell/evolution-folder-selector-button.h> - -#include "e-select-names.h" -#include <addressbook/backend/ebook/e-card-simple.h> -#include "e-select-names-table-model.h" -#include <gal/widgets/e-categories-master-list-option-menu.h> -#include <gal/e-text/e-entry.h> -#include <e-util/e-categories-master-list-wombat.h> -#include "e-util/e-sexp.h" - -static void e_select_names_init (ESelectNames *names); -static void e_select_names_class_init (ESelectNamesClass *klass); -static void e_select_names_dispose (GObject *object); -static void update_query (GtkWidget *widget, ESelectNames *e_select_names); - -static void sync_table_and_models (ESelectNamesModel *triggering_model, ESelectNames *esl); - -static GtkDialogClass *parent_class = NULL; -#define PARENT_TYPE gtk_dialog_get_type() - -/* The arguments we take */ -enum { - ARG_0, -}; - -typedef struct { - char *title; - ESelectNamesModel *source; - ESelectNamesTableModel *table_model; - ESelectNames *names; - GtkWidget *label; - GtkWidget *button; - GtkWidget *recipient_table; - gulong changed_id; -} ESelectNamesChild; - -GType -e_select_names_get_type (void) -{ - static GType type = 0; - - if (!type) { - static const GTypeInfo info = { - sizeof (ESelectNamesClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) e_select_names_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (ESelectNames), - 0, /* n_preallocs */ - (GInstanceInitFunc) e_select_names_init, - }; - - type = g_type_register_static (PARENT_TYPE, "ESelectNames", &info, 0); - } - - return type; -} - -static void -e_select_names_class_init (ESelectNamesClass *klass) -{ - GObjectClass *object_class; - - object_class = G_OBJECT_CLASS (klass); - - parent_class = g_type_class_peek_parent (klass); - - object_class->dispose = e_select_names_dispose; -} - -GtkWidget *e_addressbook_create_ebook_table(char *name, char *string1, char *string2, int num1, int num2); -GtkWidget *e_addressbook_create_folder_selector(char *name, char *string1, char *string2, int num1, int num2); - -static void -search_result (EAddressbookModel *model, EBookViewStatus status, ESelectNames *esn) -{ - sync_table_and_models (NULL, esn); -} - -static void -set_book(EBook *book, EBookStatus status, ESelectNames *esn) -{ - g_object_set(esn->model, - "book", book, - NULL); - update_query (NULL, esn); - g_object_unref(book); - g_object_unref(esn->model); - g_object_unref(esn); -} - -static void -addressbook_model_set_uri(ESelectNames *e_select_names, EAddressbookModel *model, const char *uri) -{ - EBook *book; - char *book_uri; - - book_uri = e_book_expand_uri (uri); - - /* 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 (current_uri && !strcmp (book_uri, current_uri)) { - g_free (book_uri); - return; - } - } - - book = e_book_new(); - - g_object_ref(e_select_names); - g_object_ref(model); - addressbook_load_uri(book, book_uri, (EBookCallback) set_book, e_select_names); - - g_free (book_uri); -} - -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, FALSE); - - g_object_unref(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 -sensitize_button (gpointer key, gpointer data, gpointer user_data) -{ - gboolean *sensitive = user_data; - ESelectNamesChild *child = data; - - gtk_widget_set_sensitive (child->button, *sensitive); -} - -static void -selection_change (ETable *table, ESelectNames *names) -{ - gboolean sensitive; - - sensitive = e_table_selected_count (table) > 0; - - g_hash_table_foreach (names->children, sensitize_button, &sensitive); -} - -static void * -esn_get_key_fn (ETableModel *source, int row, void *closure) -{ - EAddressbookModel *model = E_ADDRESSBOOK_MODEL (closure); - ECard *card = e_addressbook_model_get_card (model, row); - void *key = card_key (card); - g_object_unref (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; - - model = e_addressbook_model_new (); - adapter = E_TABLE_MODEL (e_addressbook_table_adapter_new (model)); - - g_object_set(model, - "editable", FALSE, - NULL); - - without = e_table_without_new (adapter, - g_str_hash, - g_str_equal, - esn_get_key_fn, - esn_dup_key_fn, - esn_free_gotten_key_fn, - esn_free_duped_key_fn, - model); - - table = e_table_scrolled_new_from_spec_file (without, - NULL, - EVOLUTION_ETSPECDIR "/e-select-names.etspec", - NULL); - - g_object_set_data(G_OBJECT(table), "adapter", adapter); - g_object_set_data(G_OBJECT(table), "without", without); - g_object_set_data(G_OBJECT(table), "model", model); - - return table; -} - -GtkWidget * -e_addressbook_create_folder_selector(char *name, char *string1, char *string2, int num1, int num2) -{ - return g_object_new (EVOLUTION_TYPE_FOLDER_SELECTOR_BUTTON, NULL); -} - -static void -folder_selected (EvolutionFolderSelectorButton *button, GNOME_Evolution_Folder *folder, - ESelectNames *e_select_names) -{ - addressbook_model_set_uri(e_select_names, e_select_names->model, folder->physicalUri); - - e_config_listener_set_string (e_book_get_config_database(), - "/apps/evolution/addressbook/select_names/last_used_uri", folder->physicalUri); -} - -static void -update_query (GtkWidget *widget, ESelectNames *e_select_names) -{ - char *category = ""; - const char *search = ""; - char *query; - char *q_array[4]; - int i; - GString *s = g_string_new (""); - - if (e_select_names->categories) { - category = e_categories_master_list_option_menu_get_category (E_CATEGORIES_MASTER_LIST_OPTION_MENU (e_select_names->categories)); - } - if (e_select_names->select_entry) { - search = gtk_entry_get_text (GTK_ENTRY (e_select_names->select_entry)); - } - - e_sexp_encode_string (s, search); - - 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 ("(or (beginswith \"email\" %s) " - " (beginswith \"full_name\" %s) " - " (beginswith \"nickname\" %s)" - " (beginswith \"file_as\" %s))", - s->str, s->str, s->str, s->str); - 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]); - } - g_object_set (e_select_names->model, - "query", query, - NULL); - for (i = 1; q_array[i]; i++) { - g_free (q_array[i]); - } - g_free (query); - g_string_free (s, TRUE); -} - -static void -status_message (EAddressbookModel *model, const gchar *message, ESelectNames *e_select_names) -{ - if (message == NULL) - gtk_label_set_text (GTK_LABEL (e_select_names->status_message), ""); - else - gtk_label_set_text (GTK_LABEL (e_select_names->status_message), message); -} - -static void -categories_changed (GtkWidget *widget, ESelectNames *e_select_names) -{ - update_query (widget, e_select_names); -} - -static void -select_entry_changed (GtkWidget *widget, ESelectNames *e_select_names) -{ - if (e_select_names->select_entry) { - const char *select_string = gtk_entry_get_text (GTK_ENTRY (e_select_names->select_entry)); - char *select_strcoll_string = g_utf8_collate_key (select_string, -1); - int count; - ETable *table; - int i; - - table = e_table_scrolled_get_table (e_select_names->table); - - count = e_table_model_row_count (e_select_names->without); - - for (i = 0; i < count; i++) { - int model_row = e_table_view_to_model_row (table, i); - char *row_strcoll_string = - g_utf8_collate_key (e_table_model_value_at (e_select_names->without, - E_CARD_SIMPLE_FIELD_NAME_OR_ORG, - model_row), - -1); - if (g_utf8_collate (select_strcoll_string, row_strcoll_string) <= 0) { - g_free (row_strcoll_string); - break; - } - g_free (row_strcoll_string); - } - g_free (select_strcoll_string); - if (i == count) - i --; - - if (count > 0) { - i = e_table_view_to_model_row (table, i); - e_table_set_cursor_row (table, i); - } - } -} - -GtkWidget *e_select_names_create_categories (gchar *name, - gchar *string1, gchar *string2, - gint int1, gint int2); - -GtkWidget * -e_select_names_create_categories (gchar *name, - gchar *string1, gchar *string2, - gint int1, gint int2) -{ - ECategoriesMasterList *ecml; - GtkWidget *option_menu; - - ecml = e_categories_master_list_wombat_new (); - option_menu = e_categories_master_list_option_menu_new (ecml); - g_object_unref (ecml); - - return option_menu; -} - -static void -clear_widget (gpointer data, GObject *where_object_was) -{ - GtkWidget **widget_ref = data; - *widget_ref = NULL; -} - -static void -e_select_names_init (ESelectNames *e_select_names) -{ - GladeXML *gui; - GtkWidget *widget, *button; - - gui = glade_xml_new (EVOLUTION_GLADEDIR "/select-names.glade", NULL, 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_container_remove(GTK_CONTAINER(widget->parent), widget); - gtk_box_pack_start(GTK_BOX(GTK_DIALOG(e_select_names)->vbox), widget, TRUE, TRUE, 0); - gtk_widget_unref(widget); - - gtk_dialog_add_buttons (GTK_DIALOG (e_select_names), - GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, - GTK_STOCK_OK, GTK_RESPONSE_OK, - NULL); - - gtk_dialog_set_default_response (GTK_DIALOG (e_select_names), - GTK_RESPONSE_OK); - - gtk_container_set_border_width (GTK_CONTAINER (e_select_names), 12); - gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (e_select_names)->vbox), 6); - gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (e_select_names)->action_area), 12); - - gtk_window_set_modal (GTK_WINDOW (e_select_names), TRUE); - - gtk_window_set_title(GTK_WINDOW(e_select_names), _("Select Contacts from Addressbook")); - gtk_window_set_resizable(GTK_WINDOW(e_select_names), TRUE); - - e_select_names->table = E_TABLE_SCROLLED(glade_xml_get_widget(gui, "table-source")); - e_select_names->model = g_object_get_data(G_OBJECT(e_select_names->table), "model"); - e_select_names->adapter = g_object_get_data(G_OBJECT(e_select_names->table), "adapter"); - e_select_names->without = g_object_get_data(G_OBJECT(e_select_names->table), "without"); - gtk_widget_show (GTK_WIDGET (e_select_names->table)); - - e_select_names->status_message = glade_xml_get_widget (gui, "status-message"); - if (e_select_names->status_message && !GTK_IS_LABEL (e_select_names->status_message)) - e_select_names->status_message = NULL; - if (e_select_names->status_message) { - e_select_names->status_id = g_signal_connect (e_select_names->model, "status_message", - G_CALLBACK (status_message), e_select_names); - g_object_weak_ref (G_OBJECT (e_select_names->status_message), clear_widget, &e_select_names->status_message); - } - - e_select_names->search_id = g_signal_connect (e_select_names->model, - "search_result", G_CALLBACK (search_result), - e_select_names); - - e_select_names->categories = glade_xml_get_widget (gui, "custom-categories"); - if (e_select_names->categories && !E_IS_CATEGORIES_MASTER_LIST_OPTION_MENU (e_select_names->categories)) - e_select_names->categories = NULL; - if (e_select_names->categories) { - g_signal_connect(e_select_names->categories, "changed", - G_CALLBACK(categories_changed), e_select_names); - g_object_weak_ref (G_OBJECT (e_select_names->categories), clear_widget, &e_select_names->categories); - } - gtk_widget_show (e_select_names->categories); - - e_select_names->select_entry = glade_xml_get_widget (gui, "entry-select"); - if (e_select_names->select_entry && !GTK_IS_ENTRY (e_select_names->select_entry)) - e_select_names->select_entry = NULL; - if (e_select_names->select_entry) { - g_signal_connect(e_select_names->select_entry, "changed", - G_CALLBACK(select_entry_changed), e_select_names); - g_signal_connect(e_select_names->select_entry, "activate", - G_CALLBACK(update_query), e_select_names); - g_object_weak_ref (G_OBJECT (e_select_names->select_entry), clear_widget, &e_select_names->select_entry); - } - - button = glade_xml_get_widget (gui, "button-find"); - if (button && GTK_IS_BUTTON (button)) - g_signal_connect(button, "clicked", - G_CALLBACK(update_query), e_select_names); - - button = glade_xml_get_widget (gui, "folder-selector"); - if (button && EVOLUTION_IS_FOLDER_SELECTOR_BUTTON (button)) - g_signal_connect(button, "selected", - G_CALLBACK(folder_selected), e_select_names); - gtk_widget_show (button); - - g_signal_connect (e_table_scrolled_get_table (e_select_names->table), "double_click", - G_CALLBACK (add_address), e_select_names); - g_signal_connect (e_table_scrolled_get_table (e_select_names->table), "selection_change", - G_CALLBACK (selection_change), e_select_names); - selection_change (e_table_scrolled_get_table (e_select_names->table), e_select_names); -} - -static void e_select_names_child_free(char *key, ESelectNamesChild *child, ESelectNames *e_select_names) -{ - g_signal_handler_disconnect(child->source, child->changed_id); - - g_free(child->title); - g_object_unref(child->table_model); - g_object_unref(child->source); - g_free(key); - g_free(child); -} - -static void -e_select_names_dispose (GObject *object) -{ - ESelectNames *e_select_names = E_SELECT_NAMES(object); - - if (e_select_names->status_id) { - g_signal_handler_disconnect(e_select_names->model, e_select_names->status_id); - e_select_names->status_id = 0; - } - - if (e_select_names->search_id) { - g_signal_handler_disconnect(e_select_names->model, e_select_names->search_id); - e_select_names->search_id = 0; - } - - if (e_select_names->gui) { - g_object_unref(e_select_names->gui); - e_select_names->gui = NULL; - } - - if (e_select_names->children) { - g_hash_table_foreach(e_select_names->children, (GHFunc) e_select_names_child_free, e_select_names); - g_hash_table_destroy(e_select_names->children); - e_select_names->children = NULL; - } - - if (e_select_names->without) { - g_object_unref(e_select_names->without); - e_select_names->without = NULL; - } - if (e_select_names->adapter) { - g_object_unref(e_select_names->adapter); - e_select_names->adapter = NULL; - } - if (e_select_names->model) { - g_object_unref(e_select_names->model); - e_select_names->model = NULL; - } - - if (e_select_names->def) { - g_free(e_select_names->def); - e_select_names->def = NULL; - } - - if (G_OBJECT_CLASS(parent_class)->dispose) - G_OBJECT_CLASS(parent_class)->dispose(object); -} - -GtkWidget* -e_select_names_new (EvolutionShellClient *shell_client) -{ - ESelectNames *e_select_names; - const char *selector_types[] = { "contacts/*", NULL }; - char *contacts_uri; - GtkWidget *button; - EConfigListener *db; - - e_select_names = g_object_new (E_TYPE_SELECT_NAMES, NULL); - - db = e_book_get_config_database (); - contacts_uri = e_config_listener_get_string_with_default ( - db, "/apps/evolution/addressbook/select_names/last_used_uri", - NULL, NULL); - if (!contacts_uri) - contacts_uri = g_strdup (e_book_get_default_book_uri ()); - - button = glade_xml_get_widget (e_select_names->gui, "folder-selector"); - evolution_folder_selector_button_construct (EVOLUTION_FOLDER_SELECTOR_BUTTON (button), - shell_client, - _("Find contact in"), - contacts_uri, - selector_types); - - addressbook_model_set_uri(e_select_names, e_select_names->model, contacts_uri); - - g_free (contacts_uri); - - return GTK_WIDGET (e_select_names); -} - -static void -button_clicked(GtkWidget *button, ESelectNamesChild *child) -{ - real_add_address(child->names, child); -} - -static void -remove_address(ETable *table, int row, int col, GdkEvent *event, ESelectNamesChild *child) -{ - e_select_names_model_delete (child->source, row); -} - -struct _RightClickData { - ESelectNamesChild *child; - int row; -}; -typedef struct _RightClickData RightClickData; - -static void -remove_cb (GtkWidget *widget, void *data) -{ - RightClickData *rcdata = (RightClickData *)data; - - e_select_names_model_delete (rcdata->child->source, rcdata->row); - - /* Free everything we've created */ - g_free (rcdata); -} - -static void -section_right_click_cb (ETable *et, int row, int col, GdkEvent *ev, ESelectNamesChild *child) -{ - static EPopupMenu right_click_menu[] = { - E_POPUP_ITEM (N_("Remove"), G_CALLBACK (remove_cb), 0), - E_POPUP_TERMINATOR - }; - RightClickData *rcdata = g_new0 (RightClickData, 1); - - rcdata->row = row; - rcdata->child = child; - - e_popup_menu_run (right_click_menu, (GdkEvent *)ev, 0, 0, rcdata); -} - -void -e_select_names_add_section (ESelectNames *e_select_names, - const char *name, const char *id, - ESelectNamesModel *source) -{ - ESelectNamesChild *child; - GtkWidget *button; - GtkWidget *label; - GtkWidget *alignment; - GtkTable *table; - char *label_text; - ETable *etable; - ETableExtras *extras; - ECell *string_cell; - - GtkWidget *sw; - - if (g_hash_table_lookup(e_select_names->children, id)) { - return; - } - - table = GTK_TABLE(glade_xml_get_widget (e_select_names->gui, "table-recipients")); - - child = g_new(ESelectNamesChild, 1); - - child->names = e_select_names; - child->title = g_strdup (_(name)); - - child->table_model = (ESelectNamesTableModel*)e_select_names_table_model_new (source); - - child->source = source; - g_object_ref(child->source); - - e_select_names->child_count++; - - alignment = gtk_alignment_new(0, 0, 1, 0); - - label_text = g_strconcat (child->title, " ->", NULL); - - label = gtk_label_new (""); - - gtk_label_set_markup (GTK_LABEL(label), label_text); - - g_free (label_text); - - button = gtk_button_new (); - gtk_container_add (GTK_CONTAINER (button), label); - child->label = label; - child->button = button; - - gtk_container_add(GTK_CONTAINER(alignment), button); - gtk_widget_show_all(alignment); - g_signal_connect(button, "clicked", - G_CALLBACK(button_clicked), child); - gtk_table_attach(table, alignment, - 0, 1, - e_select_names->child_count, - e_select_names->child_count + 1, - GTK_FILL, GTK_FILL, - 0, 0); - - etable = e_table_scrolled_get_table (e_select_names->table); - gtk_widget_set_sensitive (button, e_table_selected_count (etable) > 0); - - extras = e_table_extras_new (); - string_cell = e_table_extras_get_cell (extras, "string"); - - g_object_set (string_cell, - "underline_column", 2, - NULL); - - sw = e_table_scrolled_new_from_spec_file (E_TABLE_MODEL (child->table_model), - extras, - EVOLUTION_ETSPECDIR "/e-select-names-section.etspec", - NULL); - g_object_unref (extras); - - child->recipient_table = GTK_WIDGET (e_table_scrolled_get_table (E_TABLE_SCROLLED (sw))); - - g_signal_connect (child->recipient_table, - "right_click", - G_CALLBACK (section_right_click_cb), - child); - - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), - GTK_POLICY_AUTOMATIC, - GTK_POLICY_AUTOMATIC); - - g_signal_connect(child->recipient_table, "double_click", - G_CALLBACK(remove_address), child); - - child->changed_id = g_signal_connect (child->source, - "changed", - G_CALLBACK (sync_table_and_models), - e_select_names); - - gtk_widget_show_all (sw); - - gtk_table_attach(table, sw, - 1, 2, - e_select_names->child_count, - e_select_names->child_count + 1, - GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_EXPAND, - 0, 0); - - g_hash_table_insert(e_select_names->children, g_strdup(id), child); - - sync_table_and_models (child->source, e_select_names); -} - -void -e_select_names_set_default (ESelectNames *e_select_names, - const char *id) -{ - ESelectNamesChild *child; - - if (e_select_names->def) { - child = g_hash_table_lookup(e_select_names->children, e_select_names->def); - if (child) { - GtkWidget *label = child->label; - - /* set the previous default to non-bold */ - gtk_label_set_markup (GTK_LABEL (label), child->title); - } - } - - g_free(e_select_names->def); - e_select_names->def = g_strdup(id); - - if (e_select_names->def) { - child = g_hash_table_lookup(e_select_names->children, e_select_names->def); - if (child) { - GtkWidget *label = child->label; - char *markup = g_strconcat ("<b>", child->title, "</b>", NULL); - - /* set the new default to bold */ - gtk_label_set_markup (GTK_LABEL (label), markup); - g_free (markup); - } - } -} diff --git a/addressbook/gui/component/select-names/e-select-names.etspec b/addressbook/gui/component/select-names/e-select-names.etspec deleted file mode 100644 index 114f84cc8c..0000000000 --- a/addressbook/gui/component/select-names/e-select-names.etspec +++ /dev/null @@ -1,7 +0,0 @@ -<ETableSpecification no-headers="true" cursor-mode="line"> - <ETableColumn model_col= "44" _title="Name" expansion="1.0" minimum_width="20" resizable="true" cell="string" compare="collate" search="string"/> - <ETableState> - <column source="0"/> - <grouping> <leaf column="0" ascending="true"/> </grouping> - </ETableState> -</ETableSpecification> diff --git a/addressbook/gui/component/select-names/e-select-names.h b/addressbook/gui/component/select-names/e-select-names.h deleted file mode 100644 index 8e672da92a..0000000000 --- a/addressbook/gui/component/select-names/e-select-names.h +++ /dev/null @@ -1,103 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* e-select-names.h - * Copyright (C) 2000 Ximian, Inc. - * Author: Chris Lahey <clahey@ximian.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ -#ifndef __E_SELECT_NAMES_H__ -#define __E_SELECT_NAMES_H__ - -#include <glib.h> -#include <gtk/gtkwidget.h> -#include <gtk/gtkdialog.h> -#include <glade/glade.h> -#include <gal/e-table/e-table.h> -#include <gal/e-table/e-table-scrolled.h> - -#include "evolution-shell-client.h" -#include "e-addressbook-model.h" - -#include "e-select-names-model.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_TYPE_SELECT_NAMES (e_select_names_get_type ()) -#define E_SELECT_NAMES(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_SELECT_NAMES, ESelectNames)) -#define E_SELECT_NAMES_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_SELECT_NAMES, ESelectNamesClass)) -#define E_IS_SELECT_NAMES(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_SELECT_NAMES)) -#define E_IS_SELECT_NAMES_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), E_TYPE_SELECT_NAMES)) - -typedef struct _ESelectNames ESelectNames; -typedef struct _ESelectNamesClass ESelectNamesClass; -typedef struct _ESelectNamesFolder ESelectNamesFolder; - -struct _ESelectNames -{ - GtkDialog parent; - - /* 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 *select_entry; - GtkWidget *status_message; - char *def; - ESelectNamesFolder *current_folder; - - /* signal handlers */ - gulong status_id; - gulong search_id; -}; - -struct _ESelectNamesClass -{ - GtkDialogClass parent_class; -}; - - -GtkWidget *e_select_names_new (EvolutionShellClient *shell_client); -GType e_select_names_get_type (void); - -void e_select_names_add_section (ESelectNames *e_select_names, - const char *name, - const char *id, - ESelectNamesModel *source); -void e_select_names_set_default (ESelectNames *e_select_names, - const char *id); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - - -#endif /* __E_SELECT_NAMES_H__ */ diff --git a/addressbook/gui/component/select-names/e-simple-card-bonobo.c b/addressbook/gui/component/select-names/e-simple-card-bonobo.c deleted file mode 100644 index 07203618b3..0000000000 --- a/addressbook/gui/component/select-names/e-simple-card-bonobo.c +++ /dev/null @@ -1,216 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-simple-card-bonobo.c - * - * Copyright (C) 2000 Ximian, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Authors: - * Ettore Perazzoli <ettore@ximian.com> - * Chris Lahey <clahey@ximian.com> - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include "e-simple-card-bonobo.h" - -#include <gal/util/e-util.h> - -#include "Evolution-Addressbook-SelectNames.h" - - -#define PARENT_TYPE BONOBO_TYPE_OBJECT -static BonoboObjectClass *parent_class = NULL; - -struct _ESimpleCardBonoboPrivate { - ECardSimple *card_simple; -}; - - - -static GNOME_Evolution_Addressbook_SimpleCard_Arbitrary * -impl_SimpleCard_get_arbitrary (PortableServer_Servant servant, - const CORBA_char *key, - CORBA_Environment *ev) -{ - ESimpleCardBonobo *simple_card; - ESimpleCardBonoboPrivate *priv; - GNOME_Evolution_Addressbook_SimpleCard_Arbitrary *ret_val = GNOME_Evolution_Addressbook_SimpleCard_Arbitrary__alloc (); - - simple_card = E_SIMPLE_CARD_BONOBO (bonobo_object (servant)); - priv = simple_card->priv; - - if (priv->card_simple) { - const ECardArbitrary *arbitrary = e_card_simple_get_arbitrary (priv->card_simple, key); - ret_val->key = CORBA_string_dup (arbitrary->key); - ret_val->value = CORBA_string_dup (arbitrary->value); - ret_val->type = CORBA_string_dup (arbitrary->type); - } else { - ret_val->key = CORBA_string_dup (""); - ret_val->value = CORBA_string_dup (""); - ret_val->type = CORBA_string_dup (""); - } - - return ret_val; -} - -static void -impl_SimpleCard_set_arbitrary (PortableServer_Servant servant, - const CORBA_char *key, - const CORBA_char *type, - const CORBA_char *value, - CORBA_Environment *ev) -{ - ESimpleCardBonobo *simple_card; - ESimpleCardBonoboPrivate *priv; - - simple_card = E_SIMPLE_CARD_BONOBO (bonobo_object (servant)); - priv = simple_card->priv; - - if (priv->card_simple) { - e_card_simple_set_arbitrary (priv->card_simple, key, type, value); - } -} - -static CORBA_char * -impl_SimpleCard_get (PortableServer_Servant servant, - GNOME_Evolution_Addressbook_SimpleCard_Field field, - CORBA_Environment *ev) -{ - ESimpleCardBonobo *simple_card; - ESimpleCardBonoboPrivate *priv; - - simple_card = E_SIMPLE_CARD_BONOBO (bonobo_object (servant)); - priv = simple_card->priv; - - if (priv->card_simple) { - char *value = e_card_simple_get (priv->card_simple, - field); - char *ret_val = CORBA_string_dup (value ? value : ""); - g_free (value); - return ret_val; - } else { - return CORBA_string_dup (""); - } -} - -static void -impl_SimpleCard_set (PortableServer_Servant servant, - GNOME_Evolution_Addressbook_SimpleCard_Field field, - const CORBA_char *value, - CORBA_Environment *ev) -{ - - ESimpleCardBonobo *simple_card; - ESimpleCardBonoboPrivate *priv; - - simple_card = E_SIMPLE_CARD_BONOBO (bonobo_object (servant)); - priv = simple_card->priv; - - if (priv->card_simple) { - e_card_simple_set (priv->card_simple, - field, - value); - } -} - - -/* GtkObject methods. */ - -static void -impl_dispose (GObject *object) -{ - ESimpleCardBonobo *simple_card; - ESimpleCardBonoboPrivate *priv; - - simple_card = E_SIMPLE_CARD_BONOBO (object); - priv = simple_card->priv; - - if (priv) { - if (priv->card_simple) { - g_object_unref (priv->card_simple); - } - - g_free (priv); - simple_card->priv = NULL; - } - - if (G_OBJECT_CLASS(parent_class)->dispose) - G_OBJECT_CLASS(parent_class)->dispose(object); -} - - -static void -e_simple_card_bonobo_class_init (ESimpleCardBonoboClass *klass) -{ - GObjectClass *object_class; - POA_GNOME_Evolution_Addressbook_SimpleCard__epv *epv; - - object_class = G_OBJECT_CLASS (klass); - parent_class = g_type_class_ref (BONOBO_TYPE_OBJECT); - - object_class->dispose = impl_dispose; - - epv = &klass->epv; - epv->getArbitrary = impl_SimpleCard_get_arbitrary; - epv->setArbitrary = impl_SimpleCard_set_arbitrary; - epv->get = impl_SimpleCard_get; - epv->set = impl_SimpleCard_set; -} - -static void -e_simple_card_bonobo_init (ESimpleCardBonobo *simple_card) -{ - ESimpleCardBonoboPrivate *priv; - - priv = g_new (ESimpleCardBonoboPrivate, 1); - - priv->card_simple = NULL; - - simple_card->priv = priv; -} - - -void -e_simple_card_bonobo_construct (ESimpleCardBonobo *simple_card, - ECardSimple *card_simple) -{ - g_return_if_fail (simple_card != NULL); - g_return_if_fail (E_IS_SIMPLE_CARD_BONOBO (simple_card)); - - simple_card->priv->card_simple = card_simple; - g_object_ref (card_simple); -} - -ESimpleCardBonobo * -e_simple_card_bonobo_new (ECardSimple *card_simple) -{ - ESimpleCardBonobo *simple_card; - - simple_card = g_object_new (E_TYPE_SIMPLE_CARD_BONOBO, NULL); - - e_simple_card_bonobo_construct (simple_card, card_simple); - - return simple_card; -} - - -BONOBO_TYPE_FUNC_FULL ( - ESimpleCardBonobo, - GNOME_Evolution_Addressbook_SimpleCard, - PARENT_TYPE, - e_simple_card_bonobo); diff --git a/addressbook/gui/component/select-names/e-simple-card-bonobo.h b/addressbook/gui/component/select-names/e-simple-card-bonobo.h deleted file mode 100644 index 7bc2d65830..0000000000 --- a/addressbook/gui/component/select-names/e-simple-card-bonobo.h +++ /dev/null @@ -1,71 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-simple-card-bonobo.h - * - * Copyright (C) 2000 Ximian, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Authors: - * Ettore Perazzoli <ettore@ximian.com> - * Chris Lahey <clahey@ximian.com> - */ - -#ifndef __E_SIMPLE_CARD_BONOBO_H__ -#define __E_SIMPLE_CARD_BONOBO_H__ - -#include <bonobo/bonobo-object.h> - -#include "Evolution-Addressbook-SelectNames.h" -#include <addressbook/backend/ebook/e-card-simple.h> - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - -#define E_TYPE_SIMPLE_CARD_BONOBO (e_simple_card_bonobo_get_type ()) -#define E_SIMPLE_CARD_BONOBO(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_SIMPLE_CARD_BONOBO, ESimpleCardBonobo)) -#define E_SIMPLE_CARD_BONOBO_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_SIMPLE_CARD_BONOBO, ESimpleCardBonoboClass)) -#define E_IS_SIMPLE_CARD_BONOBO(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_SIMPLE_CARD_BONOBO)) -#define E_IS_SIMPLE_CARD_BONOBO_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), E_TYPE_SIMPLE_CARD_BONOBO)) - - -typedef struct _ESimpleCardBonobo ESimpleCardBonobo; -typedef struct _ESimpleCardBonoboPrivate ESimpleCardBonoboPrivate; -typedef struct _ESimpleCardBonoboClass ESimpleCardBonoboClass; - -struct _ESimpleCardBonobo { - BonoboObject parent; - - ESimpleCardBonoboPrivate *priv; -}; - -struct _ESimpleCardBonoboClass { - BonoboObjectClass parent_class; - - POA_GNOME_Evolution_Addressbook_SimpleCard__epv epv; -}; - - -GType e_simple_card_bonobo_get_type (void); -ESimpleCardBonobo *e_simple_card_bonobo_new (ECardSimple *card_simple); -void e_simple_card_bonobo_construct (ESimpleCardBonobo *simple_card, - ECardSimple *card_simple); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* __E_SIMPLE_CARD_BONOBO_H__ */ diff --git a/addressbook/gui/component/select-names/recipient.glade b/addressbook/gui/component/select-names/recipient.glade deleted file mode 100644 index edcf6bbab0..0000000000 --- a/addressbook/gui/component/select-names/recipient.glade +++ /dev/null @@ -1,45 +0,0 @@ -<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*--> -<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd" > - -<glade-interface> - <widget class="GtkWindow" id="window1"> - <property name="visible">no</property> - <property name="title" translatable="yes">window1</property> - <property name="type">GTK_WINDOW_TOPLEVEL</property> - <property name="modal">no</property> - <property name="allow_shrink">no</property> - <property name="allow_grow">yes</property> - <property name="window-position">GTK_WIN_POS_NONE</property> - - <child> - <widget class="GtkHBox" id="hbox-top"> - <property name="homogeneous">no</property> - <property name="spacing">4</property> - <property name="visible">yes</property> - - <child> - <widget class="GtkAlignment" id="alignment1"> - <property name="xalign">1.08033e-07</property> - <property name="yalign">0</property> - <property name="xscale">1</property> - <property name="yscale">0</property> - <property name="visible">yes</property> - - <child> - <widget class="GtkButton" id="text-button"> - <property name="can_focus">yes</property> - <property name="label" translatable="yes">-></property> - <property name="visible">yes</property> - </widget> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">no</property> - <property name="fill">yes</property> - </packing> - </child> - </widget> - </child> - </widget> -</glade-interface> diff --git a/addressbook/gui/component/select-names/select-names.glade b/addressbook/gui/component/select-names/select-names.glade deleted file mode 100644 index 7ff1b4ebc7..0000000000 --- a/addressbook/gui/component/select-names/select-names.glade +++ /dev/null @@ -1,452 +0,0 @@ -<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*--> -<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd"> - -<glade-interface> - -<widget class="GtkDialog" id="dialog-top"> - <property name="border_width">12</property> - <property name="title" translatable="yes">Select Names</property> - <property name="type">GTK_WINDOW_TOPLEVEL</property> - <property name="window_position">GTK_WIN_POS_NONE</property> - <property name="modal">False</property> - <property name="default_width">417</property> - <property name="default_height">332</property> - <property name="resizable">True</property> - <property name="destroy_with_parent">False</property> - <property name="has_separator">True</property> - - <child internal-child="vbox"> - <widget class="GtkVBox" id="dialog-vbox1"> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">6</property> - - <child internal-child="action_area"> - <widget class="GtkHButtonBox" id="dialog-action_area1"> - <property name="visible">True</property> - <property name="layout_style">GTK_BUTTONBOX_END</property> - - <child> - <widget class="GtkButton" id="button4"> - <property name="visible">True</property> - <property name="can_default">True</property> - <property name="has_default">True</property> - <property name="can_focus">True</property> - <property name="label">gtk-ok</property> - <property name="use_stock">True</property> - <property name="relief">GTK_RELIEF_NORMAL</property> - <property name="response_id">0</property> - </widget> - </child> - - <child> - <widget class="GtkButton" id="button5"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="label">gtk-cancel</property> - <property name="use_stock">True</property> - <property name="relief">GTK_RELIEF_NORMAL</property> - <property name="response_id">0</property> - </widget> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="pack_type">GTK_PACK_END</property> - </packing> - </child> - - <child> - <widget class="GtkTable" id="table-top"> - <property name="visible">True</property> - <property name="n_rows">3</property> - <property name="n_columns">1</property> - <property name="homogeneous">False</property> - <property name="row_spacing">6</property> - <property name="column_spacing">6</property> - - <child> - <widget class="GtkHSeparator" id="hseparator1"> - <property name="visible">True</property> - </widget> - <packing> - <property name="left_attach">0</property> - <property name="right_attach">1</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="x_options"></property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkVBox" id="vbox5"> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">6</property> - - <child> - <widget class="GtkTable" id="table4"> - <property name="visible">True</property> - <property name="n_rows">2</property> - <property name="n_columns">2</property> - <property name="homogeneous">False</property> - <property name="row_spacing">6</property> - <property name="column_spacing">3</property> - - <child> - <widget class="GtkLabel" id="label32"> - <property name="visible">True</property> - <property name="label" translatable="yes">Type a name into the entry, or -select one from the list below:</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="left_attach">0</property> - <property name="right_attach">1</property> - <property name="top_attach">0</property> - <property name="bottom_attach">1</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkTable" id="table-recipients"> - <property name="visible">True</property> - <property name="n_rows">1</property> - <property name="n_columns">2</property> - <property name="homogeneous">False</property> - <property name="row_spacing">6</property> - <property name="column_spacing">6</property> - - <child> - <widget class="GtkLabel" id="label20"> - <property name="visible">True</property> - <property name="label" translatable="yes">Selected Contacts:</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_CENTER</property> - <property name="wrap">True</property> - <property name="selectable">False</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">0</property> - <property name="bottom_attach">1</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> - </child> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - </packing> - </child> - - <child> - <widget class="GtkAlignment" id="alignment4"> - <property name="visible">True</property> - <property name="xalign">7.45058e-09</property> - <property name="yalign">0.5</property> - <property name="xscale">1</property> - <property name="yscale">1</property> - - <child> - <widget class="GtkVBox" id="vbox6"> - <property name="border_width">3</property> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">6</property> - - <child> - <widget class="GtkHBox" id="hbox1"> - <property name="visible">True</property> - <property name="homogeneous">False</property> - <property name="spacing">6</property> - - <child> - <widget class="GtkEntry" id="entry-select"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="editable">True</property> - <property name="visibility">True</property> - <property name="max_length">0</property> - <property name="text" translatable="yes"></property> - <property name="has_frame">True</property> - <property name="invisible_char" translatable="yes">*</property> - <property name="activates_default">False</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">True</property> - <property name="fill">True</property> - </packing> - </child> - - <child> - <widget class="GtkButton" id="button-find"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="label" translatable="yes">Find</property> - <property name="use_underline">True</property> - <property name="relief">GTK_RELIEF_NORMAL</property> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">False</property> - <property name="fill">False</property> - </packing> - </child> - - <child> - <widget class="GtkAlignment" id="alignment3"> - <property name="visible">True</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xscale">1</property> - <property name="yscale">1</property> - - <child> - <widget class="Custom" id="table-source"> - <property name="visible">True</property> - <property name="creation_function">e_addressbook_create_ebook_table</property> - <property name="int1">0</property> - <property name="int2">0</property> - <property name="last_modification_time">Sat, 10 Jun 2000 22:02:57 GMT</property> - </widget> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">True</property> - <property name="fill">True</property> - </packing> - </child> - </widget> - </child> - </widget> - <packing> - <property name="left_attach">0</property> - <property name="right_attach">1</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - </packing> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">True</property> - <property name="fill">True</property> - </packing> - </child> - </widget> - <packing> - <property name="left_attach">0</property> - <property name="right_attach">1</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="x_options">fill</property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="status-message"> - <property name="visible">True</property> - <property name="label" translatable="yes"></property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">3</property> - </widget> - <packing> - <property name="left_attach">0</property> - <property name="right_attach">1</property> - <property name="top_attach">2</property> - <property name="bottom_attach">3</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkFrame" id="frame1"> - <property name="visible">True</property> - <property name="label_xalign">0</property> - <property name="label_yalign">0.5</property> - <property name="shadow_type">GTK_SHADOW_ETCHED_IN</property> - - <child> - <widget class="GtkTable" id="table5"> - <property name="border_width">6</property> - <property name="visible">True</property> - <property name="n_rows">2</property> - <property name="n_columns">2</property> - <property name="homogeneous">False</property> - <property name="row_spacing">6</property> - <property name="column_spacing">6</property> - - <child> - <widget class="GtkLabel" id="label30"> - <property name="visible">True</property> - <property name="label" translatable="yes">_Folder:</property> - <property name="use_underline">True</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_CENTER</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="left_attach">0</property> - <property name="right_attach">1</property> - <property name="top_attach">0</property> - <property name="bottom_attach">1</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkLabel" id="label31"> - <property name="visible">True</property> - <property name="label" translatable="yes">_Category:</property> - <property name="use_underline">True</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_CENTER</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="left_attach">0</property> - <property name="right_attach">1</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="x_options">fill</property> - <property name="y_options"></property> - </packing> - </child> - - <child> - <widget class="GtkAlignment" id="alignment5"> - <property name="visible">True</property> - <property name="xalign">7.45058e-09</property> - <property name="yalign">0.5</property> - <property name="xscale">0</property> - <property name="yscale">1</property> - - <child> - <widget class="Custom" id="custom-categories"> - <property name="visible">True</property> - <property name="creation_function">e_select_names_create_categories</property> - <property name="int1">0</property> - <property name="int2">0</property> - <property name="last_modification_time">Tue, 19 Feb 2002 23:06:24 GMT</property> - </widget> - </child> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - <property name="y_options">fill</property> - </packing> - </child> - - <child> - <widget class="Custom" id="folder-selector"> - <property name="visible">True</property> - <property name="creation_function">e_addressbook_create_folder_selector</property> - <property name="int1">0</property> - <property name="int2">0</property> - <property name="last_modification_time">Mon, 15 Jul 2002 02:21:32 GMT</property> - </widget> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">0</property> - <property name="bottom_attach">1</property> - <property name="x_options">fill</property> - <property name="y_options">fill</property> - </packing> - </child> - </widget> - </child> - - <child> - <widget class="GtkLabel" id="label1"> - <property name="visible">True</property> - <property name="label" translatable="yes">Show Contacts</property> - <property name="use_underline">False</property> - <property name="use_markup">False</property> - <property name="justify">GTK_JUSTIFY_LEFT</property> - <property name="wrap">False</property> - <property name="selectable">False</property> - <property name="xalign">0.5</property> - <property name="yalign">0.5</property> - <property name="xpad">0</property> - <property name="ypad">0</property> - </widget> - <packing> - <property name="type">label_item</property> - </packing> - </child> - </widget> - <packing> - <property name="left_attach">0</property> - <property name="right_attach">1</property> - <property name="top_attach">0</property> - <property name="bottom_attach">1</property> - <property name="y_options"></property> - </packing> - </child> - </widget> - <packing> - <property name="padding">0</property> - <property name="expand">True</property> - <property name="fill">True</property> - </packing> - </child> - </widget> - </child> -</widget> - -</glade-interface> |