diff options
author | nobody <nobody@localhost> | 2001-12-14 12:59:04 +0800 |
---|---|---|
committer | nobody <nobody@localhost> | 2001-12-14 12:59:04 +0800 |
commit | dcc8171fd4c8df52faff322827876acf30c35a4a (patch) | |
tree | 32cb6f4702fe446ea804947fa4479b5431a3d24a /addressbook/gui/contact-list-editor | |
parent | 969ffa703d70be312a9b9b2f7a6d2b7a8ac87c17 (diff) | |
download | gsoc2013-evolution-EOG_0_109_1.tar gsoc2013-evolution-EOG_0_109_1.tar.gz gsoc2013-evolution-EOG_0_109_1.tar.bz2 gsoc2013-evolution-EOG_0_109_1.tar.lz gsoc2013-evolution-EOG_0_109_1.tar.xz gsoc2013-evolution-EOG_0_109_1.tar.zst gsoc2013-evolution-EOG_0_109_1.zip |
This commit was manufactured by cvs2svn to create tag 'EOG_0_109_1'.EOG_0_109_1
svn path=/tags/EOG_0_109_1/; revision=15041
Diffstat (limited to 'addressbook/gui/contact-list-editor')
7 files changed, 0 insertions, 1695 deletions
diff --git a/addressbook/gui/contact-list-editor/.cvsignore b/addressbook/gui/contact-list-editor/.cvsignore deleted file mode 100644 index e440fafdac..0000000000 --- a/addressbook/gui/contact-list-editor/.cvsignore +++ /dev/null @@ -1,3 +0,0 @@ -Makefile.in -Makefile -.deps diff --git a/addressbook/gui/contact-list-editor/Makefile.am b/addressbook/gui/contact-list-editor/Makefile.am deleted file mode 100644 index 1164f2c594..0000000000 --- a/addressbook/gui/contact-list-editor/Makefile.am +++ /dev/null @@ -1,30 +0,0 @@ -INCLUDES = \ - $(BONOBO_GNOME_CFLAGS) \ - $(EXTRA_GNOME_CFLAGS) \ - -I$(top_srcdir) \ - -I$(top_srcdir)/addressbook/ \ - -I$(top_srcdir)/addressbook/backend \ - -I$(top_srcdir)/addressbook/gui/merging \ - -I$(top_srcdir)/addressbook/gui/contact-editor \ - -I$(top_builddir)/shell \ - -DEVOLUTION_GLADEDIR=\""$(gladedir)"\" \ - -DDATADIR=\""$(datadir)"\" \ - -DEVOLUTION_DATADIR=\""$(datadir)"\" \ - -DEVOLUTIONDIR=\""$(evolutiondir)"\" \ - -DG_LOG_DOMAIN=\"contact-list-editor\" - -noinst_LIBRARIES = \ - libecontactlisteditor.a - -libecontactlisteditor_a_SOURCES = \ - e-contact-list-editor.c \ - e-contact-list-editor.h \ - e-contact-list-model.c \ - e-contact-list-model.h - -gladedir = $(datadir)/evolution/glade - -glade_DATA = \ - contact-list-editor.glade - -EXTRA_DIST = $(glade_DATA) diff --git a/addressbook/gui/contact-list-editor/contact-list-editor.glade b/addressbook/gui/contact-list-editor/contact-list-editor.glade deleted file mode 100644 index 92c6aa013f..0000000000 --- a/addressbook/gui/contact-list-editor/contact-list-editor.glade +++ /dev/null @@ -1,272 +0,0 @@ -<?xml version="1.0"?> -<GTK-Interface> - -<project> - <name>contact-list-editor</name> - <program_name>contact-list-editor</program_name> - <directory></directory> - <source_directory>src</source_directory> - <pixmaps_directory>pixmaps</pixmaps_directory> - <language>C</language> - <gnome_support>True</gnome_support> - <gettext_support>True</gettext_support> -</project> - -<widget> - <class>GnomeApp</class> - <name>contact list editor</name> - <title>contact-list-editor</title> - <type>GTK_WINDOW_TOPLEVEL</type> - <position>GTK_WIN_POS_NONE</position> - <modal>False</modal> - <default_width>426</default_width> - <default_height>304</default_height> - <allow_shrink>True</allow_shrink> - <allow_grow>True</allow_grow> - <auto_shrink>False</auto_shrink> - <enable_layout_config>True</enable_layout_config> - - <widget> - <class>GnomeDock</class> - <child_name>GnomeApp:dock</child_name> - <name>dock1</name> - <allow_floating>True</allow_floating> - <child> - <padding>0</padding> - <expand>True</expand> - <fill>True</fill> - </child> - - <widget> - <class>GtkVBox</class> - <child_name>GnomeDock:contents</child_name> - <name>vbox8</name> - <border_width>3</border_width> - <homogeneous>False</homogeneous> - <spacing>0</spacing> - - <widget> - <class>GtkHBox</class> - <name>hbox6</name> - <border_width>3</border_width> - <homogeneous>False</homogeneous> - <spacing>3</spacing> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - - <widget> - <class>GtkLabel</class> - <name>label10</name> - <label>List _name:</label> - <justify>GTK_JUSTIFY_LEFT</justify> - <wrap>False</wrap> - <xalign>0</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <default_focus_target>list-name-entry</default_focus_target> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkEntry</class> - <name>list-name-entry</name> - <can_focus>True</can_focus> - <has_focus>True</has_focus> - <editable>True</editable> - <text_visible>True</text_visible> - <text_max_length>0</text_max_length> - <text></text> - <child> - <padding>0</padding> - <expand>True</expand> - <fill>True</fill> - </child> - </widget> - - <widget> - <class>Custom</class> - <name>custom7</name> - <creation_function>e_create_image_widget</creation_function> - <string1>evolution-contacts-plain.png</string1> - <int1>0</int1> - <int2>0</int2> - <last_modification_time>Sat, 23 Jun 2001 05:59:21 GMT</last_modification_time> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>True</fill> - </child> - </widget> - </widget> - - <widget> - <class>GtkFrame</class> - <name>frame3</name> - <border_width>3</border_width> - <label>Members</label> - <label_xalign>0</label_xalign> - <shadow_type>GTK_SHADOW_ETCHED_IN</shadow_type> - <child> - <padding>0</padding> - <expand>True</expand> - <fill>True</fill> - </child> - - <widget> - <class>GtkHBox</class> - <name>hbox7</name> - <homogeneous>False</homogeneous> - <spacing>0</spacing> - - <widget> - <class>GtkVBox</class> - <name>vbox9</name> - <border_width>3</border_width> - <homogeneous>False</homogeneous> - <spacing>3</spacing> - <child> - <padding>0</padding> - <expand>True</expand> - <fill>True</fill> - </child> - - <widget> - <class>GtkLabel</class> - <name>label11</name> - <label>Type an email address or drag a contact into the list below:</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkEntry</class> - <name>email-entry</name> - <can_focus>True</can_focus> - <editable>True</editable> - <text_visible>True</text_visible> - <text_max_length>0</text_max_length> - <text></text> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>Custom</class> - <name>contact-list-table</name> - <creation_function>e_contact_list_editor_create_table</creation_function> - <string1></string1> - <int1>0</int1> - <int2>0</int2> - <last_modification_time>Sat, 23 Jun 2001 06:00:16 GMT</last_modification_time> - <child> - <padding>0</padding> - <expand>True</expand> - <fill>True</fill> - </child> - </widget> - - <widget> - <class>GtkCheckButton</class> - <name>visible-addrs-checkbutton</name> - <can_focus>True</can_focus> - <label>_Hide addresses when sending mail to this list</label> - <active>False</active> - <draw_indicator>True</draw_indicator> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - </widget> - - <widget> - <class>GtkVBox</class> - <name>vbox10</name> - <homogeneous>False</homogeneous> - <spacing>0</spacing> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - - <widget> - <class>GtkLabel</class> - <name>label12</name> - <label> -</label> - <justify>GTK_JUSTIFY_CENTER</justify> - <wrap>False</wrap> - <xalign>0.5</xalign> - <yalign>0.5</yalign> - <xpad>0</xpad> - <ypad>0</ypad> - <child> - <padding>0</padding> - <expand>False</expand> - <fill>False</fill> - </child> - </widget> - - <widget> - <class>GtkVButtonBox</class> - <name>vbuttonbox4</name> - <layout_style>GTK_BUTTONBOX_START</layout_style> - <spacing>0</spacing> - <child_min_width>85</child_min_width> - <child_min_height>27</child_min_height> - <child_ipad_x>7</child_ipad_x> - <child_ipad_y>0</child_ipad_y> - <child> - <padding>0</padding> - <expand>True</expand> - <fill>True</fill> - </child> - - <widget> - <class>GtkButton</class> - <name>add-email-button</name> - <can_default>True</can_default> - <can_focus>True</can_focus> - <label>_Add</label> - <relief>GTK_RELIEF_NORMAL</relief> - </widget> - - <widget> - <class>GtkButton</class> - <name>remove-button</name> - <can_default>True</can_default> - <can_focus>True</can_focus> - <label>_Remove</label> - <relief>GTK_RELIEF_NORMAL</relief> - </widget> - </widget> - </widget> - </widget> - </widget> - </widget> - </widget> -</widget> - -</GTK-Interface> diff --git a/addressbook/gui/contact-list-editor/e-contact-list-editor.c b/addressbook/gui/contact-list-editor/e-contact-list-editor.c deleted file mode 100644 index a5676e1f19..0000000000 --- a/addressbook/gui/contact-list-editor/e-contact-list-editor.c +++ /dev/null @@ -1,980 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* e-contact-list-editor.c - * Copyright (C) 2001 Ximian, Inc. - * Author: Chris Toshok <toshok@ximian.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include <config.h> - -#include "e-contact-list-editor.h" - -#include <glib.h> -#include <libgnome/gnome-defs.h> -#include <libgnome/gnome-i18n.h> -#include <bonobo/bonobo-ui-container.h> -#include <bonobo/bonobo-ui-util.h> -#include <gal/e-table/e-table-scrolled.h> -#include <gal/widgets/e-unicode.h> -#include "shell/evolution-shell-component-utils.h" - -#include "addressbook/gui/widgets/e-addressbook-util.h" - -#include "e-contact-editor.h" -#include "e-contact-save-as.h" -#include "e-contact-list-model.h" - -/* Signal IDs */ -enum { - LIST_ADDED, - LIST_MODIFIED, - LIST_DELETED, - EDITOR_CLOSED, - LAST_SIGNAL -}; - -static void e_contact_list_editor_init (EContactListEditor *editor); -static void e_contact_list_editor_class_init (EContactListEditorClass *klass); -static void e_contact_list_editor_set_arg (GtkObject *o, GtkArg *arg, guint arg_id); -static void e_contact_list_editor_get_arg (GtkObject *object, GtkArg *arg, guint arg_id); -static void e_contact_list_editor_destroy (GtkObject *object); - -static void create_ui (EContactListEditor *ce); -static void set_editable (EContactListEditor *editor); -static void command_state_changed (EContactListEditor *editor); -static void close_dialog (EContactListEditor *cle); -static void extract_info(EContactListEditor *editor); -static void fill_in_info(EContactListEditor *editor); - -static void add_email_cb (GtkWidget *w, EContactListEditor *editor); -static void remove_entry_cb (GtkWidget *w, EContactListEditor *editor); -static void list_name_changed_cb (GtkWidget *w, EContactListEditor *editor); -static void visible_addrs_toggled_cb (GtkWidget *w, EContactListEditor *editor); - -static gint app_delete_event_cb (GtkWidget *widget, GdkEvent *event, gpointer data); -static gboolean table_drag_drop_cb (ETable *table, int row, int col, GdkDragContext *context, - gint x, gint y, guint time, EContactListEditor *editor); -static gboolean table_drag_motion_cb (ETable *table, int row, int col, GdkDragContext *context, - gint x, gint y, guint time, EContactListEditor *editor); -static void table_drag_data_received_cb (ETable *table, int row, int col, - GdkDragContext *context, - gint x, gint y, - GtkSelectionData *selection_data, guint info, guint time, - EContactListEditor *editor); - -static GtkObjectClass *parent_class = NULL; - -static guint contact_list_editor_signals[LAST_SIGNAL]; - -enum DndTargetType { - DND_TARGET_TYPE_VCARD, -}; -#define VCARD_TYPE "text/x-vcard" -static GtkTargetEntry drag_types[] = { - { VCARD_TYPE, 0, DND_TARGET_TYPE_VCARD }, -}; -static const int num_drag_types = sizeof (drag_types) / sizeof (drag_types[0]); - -/* The arguments we take */ -enum { - ARG_0, - ARG_BOOK, - ARG_CARD, - ARG_IS_NEW_LIST, - ARG_EDITABLE -}; - -GtkType -e_contact_list_editor_get_type (void) -{ - static GtkType contact_list_editor_type = 0; - - if (!contact_list_editor_type) - { - static const GtkTypeInfo contact_list_editor_info = - { - "EContactListEditor", - sizeof (EContactListEditor), - sizeof (EContactListEditorClass), - (GtkClassInitFunc) e_contact_list_editor_class_init, - (GtkObjectInitFunc) e_contact_list_editor_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - contact_list_editor_type = gtk_type_unique (GTK_TYPE_OBJECT, &contact_list_editor_info); - } - - return contact_list_editor_type; -} - - -typedef void (*GtkSignal_NONE__INT_OBJECT) (GtkObject * object, - gint arg1, - GtkObject *arg2, - gpointer user_data); - -static void -e_marshal_NONE__INT_OBJECT (GtkObject * object, - GtkSignalFunc func, - gpointer func_data, GtkArg * args) -{ - GtkSignal_NONE__INT_OBJECT rfunc; - rfunc = (GtkSignal_NONE__INT_OBJECT) func; - (*rfunc) (object, - GTK_VALUE_INT (args[0]), - GTK_VALUE_OBJECT (args[1]), - func_data); -} - -static void -e_contact_list_editor_class_init (EContactListEditorClass *klass) -{ - GtkObjectClass *object_class; - - object_class = (GtkObjectClass*) klass; - - parent_class = gtk_type_class (GTK_TYPE_OBJECT); - - gtk_object_add_arg_type ("EContactListEditor::book", GTK_TYPE_OBJECT, - GTK_ARG_READWRITE, ARG_BOOK); - gtk_object_add_arg_type ("EContactListEditor::card", GTK_TYPE_OBJECT, - GTK_ARG_READWRITE, ARG_CARD); - gtk_object_add_arg_type ("EContactListEditor::is_new_list", GTK_TYPE_BOOL, - GTK_ARG_READWRITE, ARG_IS_NEW_LIST); - gtk_object_add_arg_type ("EContactListEditor::editable", GTK_TYPE_BOOL, - GTK_ARG_READWRITE, ARG_EDITABLE); - - contact_list_editor_signals[LIST_ADDED] = - gtk_signal_new ("list_added", - GTK_RUN_FIRST, - object_class->type, - GTK_SIGNAL_OFFSET (EContactListEditorClass, list_added), - e_marshal_NONE__INT_OBJECT, - GTK_TYPE_NONE, 2, - GTK_TYPE_INT, GTK_TYPE_OBJECT); - - contact_list_editor_signals[LIST_MODIFIED] = - gtk_signal_new ("list_modified", - GTK_RUN_FIRST, - object_class->type, - GTK_SIGNAL_OFFSET (EContactListEditorClass, list_modified), - e_marshal_NONE__INT_OBJECT, - GTK_TYPE_NONE, 2, - GTK_TYPE_INT, GTK_TYPE_OBJECT); - - contact_list_editor_signals[LIST_DELETED] = - gtk_signal_new ("list_deleted", - GTK_RUN_FIRST, - object_class->type, - GTK_SIGNAL_OFFSET (EContactListEditorClass, list_deleted), - e_marshal_NONE__INT_OBJECT, - GTK_TYPE_NONE, 2, - GTK_TYPE_INT, GTK_TYPE_OBJECT); - - contact_list_editor_signals[EDITOR_CLOSED] = - gtk_signal_new ("editor_closed", - GTK_RUN_FIRST, - object_class->type, - GTK_SIGNAL_OFFSET (EContactListEditorClass, editor_closed), - gtk_marshal_NONE__NONE, - GTK_TYPE_NONE, 0); - - gtk_object_class_add_signals (object_class, contact_list_editor_signals, LAST_SIGNAL); - - object_class->set_arg = e_contact_list_editor_set_arg; - object_class->get_arg = e_contact_list_editor_get_arg; - object_class->destroy = e_contact_list_editor_destroy; -} - -static void -e_contact_list_editor_init (EContactListEditor *editor) -{ - GladeXML *gui; - GtkWidget *bonobo_win; - BonoboUIContainer *container; - - editor->card = NULL; - editor->changed = FALSE; - editor->editable = TRUE; - editor->in_async_call = FALSE; - editor->is_new_list = FALSE; - - gui = glade_xml_new (EVOLUTION_GLADEDIR "/contact-list-editor.glade", NULL); - editor->gui = gui; - - editor->app = glade_xml_get_widget (gui, "contact list editor"); - - editor->table = glade_xml_get_widget (gui, "contact-list-table"); - editor->model = gtk_object_get_data (GTK_OBJECT(editor->table), "model"); - - editor->add_button = glade_xml_get_widget (editor->gui, "add-email-button"); - editor->remove_button = glade_xml_get_widget (editor->gui, "remove-button"); - - editor->email_entry = glade_xml_get_widget (gui, "email-entry"); - editor->list_name_entry = glade_xml_get_widget (gui, "list-name-entry"); - - editor->visible_addrs_checkbutton = glade_xml_get_widget (gui, "visible-addrs-checkbutton"); - - /* Construct the app */ - bonobo_win = bonobo_window_new ("contact-list-editor", _("Contact List Editor")); - - /* FIXME: The sucking bit */ - { - GtkWidget *contents; - - contents = gnome_dock_get_client_area ( - GNOME_DOCK (GNOME_APP (editor->app)->dock)); - if (!contents) { - g_message ("contact_list_editor_construct(): Could not get contents"); - return; - } - gtk_widget_ref (contents); - gtk_container_remove (GTK_CONTAINER (contents->parent), contents); - bonobo_window_set_contents (BONOBO_WINDOW (bonobo_win), contents); - gtk_widget_destroy (editor->app); - editor->app = bonobo_win; - } - - /* Build the menu and toolbar */ - - container = bonobo_ui_container_new (); - bonobo_ui_container_set_win (container, BONOBO_WINDOW (editor->app)); - - editor->uic = bonobo_ui_component_new_default (); - if (!editor->uic) { - g_message ("e_contact_list_editor_init(): eeeeek, could not create the UI handler!"); - return; - } - bonobo_ui_component_set_container (editor->uic, - bonobo_object_corba_objref ( - BONOBO_OBJECT (container))); - - create_ui (editor); - - /* connect signals */ - gtk_signal_connect (GTK_OBJECT(editor->add_button), - "clicked", GTK_SIGNAL_FUNC(add_email_cb), editor); - gtk_signal_connect (GTK_OBJECT(editor->email_entry), - "activate", GTK_SIGNAL_FUNC(add_email_cb), editor); - gtk_signal_connect (GTK_OBJECT(editor->remove_button), - "clicked", GTK_SIGNAL_FUNC(remove_entry_cb), editor); - gtk_signal_connect (GTK_OBJECT(editor->list_name_entry), - "changed", GTK_SIGNAL_FUNC(list_name_changed_cb), editor); - gtk_signal_connect (GTK_OBJECT(editor->visible_addrs_checkbutton), - "toggled", GTK_SIGNAL_FUNC(visible_addrs_toggled_cb), editor); - - e_table_drag_dest_set (e_table_scrolled_get_table (E_TABLE_SCROLLED (editor->table)), - 0, drag_types, num_drag_types, GDK_ACTION_LINK); - - gtk_signal_connect (GTK_OBJECT(e_table_scrolled_get_table (E_TABLE_SCROLLED (editor->table))), - "table_drag_motion", GTK_SIGNAL_FUNC(table_drag_motion_cb), editor); - gtk_signal_connect (GTK_OBJECT(e_table_scrolled_get_table (E_TABLE_SCROLLED (editor->table))), - "table_drag_drop", GTK_SIGNAL_FUNC(table_drag_drop_cb), editor); - gtk_signal_connect (GTK_OBJECT(e_table_scrolled_get_table (E_TABLE_SCROLLED (editor->table))), - "table_drag_data_received", GTK_SIGNAL_FUNC(table_drag_data_received_cb), editor); - - command_state_changed (editor); - - /* Connect to the deletion of the dialog */ - - gtk_signal_connect (GTK_OBJECT (editor->app), "delete_event", - GTK_SIGNAL_FUNC (app_delete_event_cb), editor); -} - -static void -e_contact_list_editor_destroy (GtkObject *object) -{ -} - -typedef struct { - EContactListEditor *cle; - gboolean should_close; -} EditorCloseStruct; - -static void -list_added_cb (EBook *book, EBookStatus status, const char *id, EditorCloseStruct *ecs) -{ - EContactListEditor *cle = ecs->cle; - gboolean should_close = ecs->should_close; - - if (cle->app) - gtk_widget_set_sensitive (cle->app, TRUE); - cle->in_async_call = FALSE; - - e_card_set_id (cle->card, id); - - gtk_signal_emit (GTK_OBJECT (cle), contact_list_editor_signals[LIST_ADDED], - status, cle->card); - - if (status == E_BOOK_STATUS_SUCCESS) { - cle->is_new_list = FALSE; - - if (should_close) - close_dialog (cle); - else - command_state_changed (cle); - } - - gtk_object_unref (GTK_OBJECT (cle)); - g_free (ecs); -} - -static void -list_modified_cb (EBook *book, EBookStatus status, EditorCloseStruct *ecs) -{ - EContactListEditor *cle = ecs->cle; - gboolean should_close = ecs->should_close; - - if (cle->app) - gtk_widget_set_sensitive (cle->app, TRUE); - cle->in_async_call = FALSE; - - gtk_signal_emit (GTK_OBJECT (cle), contact_list_editor_signals[LIST_MODIFIED], - status, cle->card); - - if (status == E_BOOK_STATUS_SUCCESS) { - if (should_close) - close_dialog (cle); - } - - gtk_object_unref (GTK_OBJECT (cle)); /* release ref held for ebook callback */ - g_free (ecs); -} - -static void -save_card (EContactListEditor *cle, gboolean should_close) -{ - extract_info (cle); - - if (cle->book) { - EditorCloseStruct *ecs = g_new(EditorCloseStruct, 1); - - ecs->cle = cle; - gtk_object_ref (GTK_OBJECT (cle)); - ecs->should_close = should_close; - - if (cle->app) - gtk_widget_set_sensitive (cle->app, FALSE); - cle->in_async_call = TRUE; - - if (cle->is_new_list) - e_book_add_card (cle->book, cle->card, GTK_SIGNAL_FUNC(list_added_cb), ecs); - else - e_book_commit_card (cle->book, cle->card, GTK_SIGNAL_FUNC(list_modified_cb), ecs); - - cle->changed = FALSE; - } -} - -static gboolean -prompt_to_save_changes (EContactListEditor *editor) -{ - if (!editor->changed) - return TRUE; - - switch (e_addressbook_prompt_save_dialog (GTK_WINDOW(editor->app))) { - case 0: /* Save */ - save_card (editor, FALSE); - return TRUE; - case 1: /* Discard */ - return TRUE; - case 2: /* Cancel */ - default: - return FALSE; - } -} - -static void -file_close_cb (GtkWidget *widget, gpointer data) -{ - EContactListEditor *cle = E_CONTACT_LIST_EDITOR (data); - - if (!prompt_to_save_changes (cle)) - return; - - close_dialog (cle); -} - -static void -file_save_cb (GtkWidget *widget, gpointer data) -{ - EContactListEditor *cle = E_CONTACT_LIST_EDITOR (data); - - save_card (cle, FALSE); -} - -static void -file_save_as_cb (GtkWidget *widget, gpointer data) -{ - EContactListEditor *cle = E_CONTACT_LIST_EDITOR (data); - - extract_info (cle); - - e_contact_save_as(_("Save List as VCard"), cle->card); -} - -static void -file_send_as_cb (GtkWidget *widget, gpointer data) -{ - EContactListEditor *cle = E_CONTACT_LIST_EDITOR (data); - - extract_info (cle); - - e_card_send(cle->card, E_CARD_DISPOSITION_AS_ATTACHMENT); -} - -static void -file_send_to_cb (GtkWidget *widget, gpointer data) -{ - EContactListEditor *cle = E_CONTACT_LIST_EDITOR (data); - - extract_info (cle); - - e_card_send(cle->card, E_CARD_DISPOSITION_AS_TO); -} - -static void -tb_save_and_close_cb (GtkWidget *widget, gpointer data) -{ - EContactListEditor *cle = E_CONTACT_LIST_EDITOR (data); - save_card (cle, TRUE); -} - -static void -list_deleted_cb (EBook *book, EBookStatus status, EContactListEditor *cle) -{ - if (cle->app) - gtk_widget_set_sensitive (cle->app, TRUE); - cle->in_async_call = FALSE; - - gtk_signal_emit (GTK_OBJECT (cle), contact_list_editor_signals[LIST_DELETED], - status, cle->card); - - /* always close the dialog after we successfully delete a list */ - if (status == E_BOOK_STATUS_SUCCESS) - close_dialog (cle); - - gtk_object_unref (GTK_OBJECT (cle)); /* release reference held for callback */ -} - -static void -delete_cb (GtkWidget *widget, gpointer data) -{ - EContactListEditor *cle = E_CONTACT_LIST_EDITOR (data); - ECard *card = cle->card; - - gtk_object_ref(GTK_OBJECT(card)); - - if (e_contact_editor_confirm_delete(GTK_WINDOW(cle->app))) { - - extract_info (cle); - - if (!cle->is_new_list) { - gtk_widget_set_sensitive (cle->app, FALSE); - cle->in_async_call = TRUE; - - gtk_object_ref (GTK_OBJECT (cle)); /* hold reference for callback */ - e_book_remove_card (cle->book, card, GTK_SIGNAL_FUNC(list_deleted_cb), cle); - } - } - - gtk_object_unref(GTK_OBJECT(card)); -} - -static -BonoboUIVerb verbs [] = { - BONOBO_UI_UNSAFE_VERB ("ContactListEditorSave", file_save_cb), - BONOBO_UI_UNSAFE_VERB ("ContactListEditorSaveClose", tb_save_and_close_cb), - BONOBO_UI_UNSAFE_VERB ("ContactListEditorDelete", delete_cb), - BONOBO_UI_UNSAFE_VERB ("ContactEditorSaveAs", file_save_as_cb), - BONOBO_UI_UNSAFE_VERB ("ContactEditorSendAs", file_send_as_cb), - BONOBO_UI_UNSAFE_VERB ("ContactEditorSendTo", file_send_to_cb), - BONOBO_UI_UNSAFE_VERB ("ContactListEditorClose", file_close_cb), - BONOBO_UI_VERB_END -}; - -static EPixmap pixmaps[] = { - E_PIXMAP ("/commands/ContactListEditorSave", "save-16.png"), - E_PIXMAP ("/commands/ContactListEditorSaveClose", "save-16.png"), - E_PIXMAP ("/commands/ContactListEditorSaveAs", "save-as-16.png"), - - E_PIXMAP ("/commands/ContactListEditorDelete", "evolution-trash-mini.png"), -#if 0 /* Envelope printing is disabled for Evolution 1.0. */ - E_PIXMAP ("/commands/ContactListEditorPrint", "print.xpm"), - E_PIXMAP ("/commands/ContactListEditorPrintEnvelope", "print.xpm"), -#endif - E_PIXMAP ("/Toolbar/ContactListEditorSaveClose", "buttons/save-24.png"), - E_PIXMAP ("/Toolbar/ContactListEditorDelete", "buttons/delete-message.png"), - E_PIXMAP ("/Toolbar/ContactListEditorPrint", "buttons/print.png"), - - E_PIXMAP_END -}; - -static void -create_ui (EContactListEditor *ce) -{ - bonobo_ui_component_add_verb_list_with_data ( - ce->uic, verbs, ce); - - bonobo_ui_util_set_ui (ce->uic, EVOLUTION_DATADIR, - "evolution-contact-list-editor.xml", - "evolution-contact-list-editor"); - - e_pixmaps_update (ce->uic, pixmaps); -} - -EContactListEditor * -e_contact_list_editor_new (EBook *book, - ECard *list_card, - gboolean is_new_list, - gboolean editable) -{ - EContactListEditor *ce; - - ce = E_CONTACT_LIST_EDITOR (gtk_type_new (E_CONTACT_LIST_EDITOR_TYPE)); - - gtk_object_set (GTK_OBJECT (ce), - "book", book, - "card", list_card, - "is_new_list", is_new_list, - "editable", editable, - NULL); - - return ce; -} - -static void -e_contact_list_editor_set_arg (GtkObject *o, GtkArg *arg, guint arg_id) -{ - EContactListEditor *editor; - - editor = E_CONTACT_LIST_EDITOR (o); - - switch (arg_id){ - case ARG_BOOK: - if (editor->book) - gtk_object_unref(GTK_OBJECT(editor->book)); - editor->book = E_BOOK(GTK_VALUE_OBJECT (*arg)); - gtk_object_ref (GTK_OBJECT (editor->book)); - /* XXX more here about editable/etc. */ - break; - case ARG_CARD: - if (editor->card) - gtk_object_unref(GTK_OBJECT(editor->card)); - editor->card = e_card_duplicate(E_CARD(GTK_VALUE_OBJECT (*arg))); - fill_in_info(editor); - editor->changed = FALSE; - command_state_changed (editor); - break; - - case ARG_IS_NEW_LIST: { - gboolean new_value = GTK_VALUE_BOOL (*arg) ? TRUE : FALSE; - gboolean changed = (editor->is_new_list != new_value); - - editor->is_new_list = new_value; - - if (changed) - command_state_changed (editor); - break; - } - - case ARG_EDITABLE: { - gboolean new_value = GTK_VALUE_BOOL (*arg) ? TRUE : FALSE; - gboolean changed = (editor->editable != new_value); - - editor->editable = new_value; - - if (changed) { - set_editable (editor); - command_state_changed (editor); - } - break; - } - - } -} - -static void -e_contact_list_editor_get_arg (GtkObject *object, GtkArg *arg, guint arg_id) -{ - EContactListEditor *editor; - - editor = E_CONTACT_LIST_EDITOR (object); - - switch (arg_id) { - case ARG_BOOK: - GTK_VALUE_OBJECT (*arg) = GTK_OBJECT(editor->book); - break; - - case ARG_CARD: - extract_info(editor); - GTK_VALUE_OBJECT (*arg) = GTK_OBJECT(editor->card); - break; - - case ARG_IS_NEW_LIST: - GTK_VALUE_BOOL (*arg) = editor->is_new_list ? TRUE : FALSE; - break; - - case ARG_EDITABLE: - GTK_VALUE_BOOL (*arg) = editor->editable ? TRUE : FALSE; - break; - default: - arg->type = GTK_TYPE_INVALID; - break; - } -} - -void -e_contact_list_editor_show (EContactListEditor *editor) -{ - gtk_widget_show (editor->app); -} - -void -e_contact_list_editor_raise (EContactListEditor *editor) -{ - gdk_window_raise (GTK_WIDGET (editor->app)->window); -} - -#define SPEC "<ETableSpecification no-headers=\"true\" cursor-mode=\"line\" selection-mode=\"single\"> \ - <ETableColumn model_col= \"0\" _title=\"Contact\" expansion=\"1.0\" minimum_width=\"20\" resizable=\"true\" cell=\"string\" compare=\"string\" /> \ - <ETableState> \ - <column source=\"0\"/> \ - <grouping> </grouping> \ - </ETableState> \ -</ETableSpecification>" - -GtkWidget * -e_contact_list_editor_create_table(gchar *name, - gchar *string1, gchar *string2, - gint int1, gint int2); - -GtkWidget * -e_contact_list_editor_create_table(gchar *name, - gchar *string1, gchar *string2, - gint int1, gint int2) -{ - - ETableModel *model; - GtkWidget *table; - - model = e_contact_list_model_new (); - - table = e_table_scrolled_new (model, NULL, SPEC, NULL); - - gtk_object_set_data(GTK_OBJECT(table), "model", model); - - return table; -} - -static void -add_email_cb (GtkWidget *w, EContactListEditor *editor) -{ - GtkAdjustment *adj = e_scroll_frame_get_vadjustment (E_SCROLL_FRAME (editor->table)); - char *text = gtk_entry_get_text (GTK_ENTRY(editor->email_entry)); - - if (text && *text) { - e_contact_list_model_add_email (E_CONTACT_LIST_MODEL(editor->model), text); - - /* Skip to the end of the list */ - if (adj->upper - adj->lower > adj->page_size) - gtk_adjustment_set_value (adj, adj->upper); - } - - gtk_entry_set_text (GTK_ENTRY(editor->email_entry), ""); - - if (!editor->changed) { - editor->changed = TRUE; - command_state_changed (editor); - } -} - -static void -remove_row (int model_row, EContactListEditor *editor) -{ - e_contact_list_model_remove_row (E_CONTACT_LIST_MODEL (editor->model), model_row); -} - -static void -remove_entry_cb (GtkWidget *w, EContactListEditor *editor) -{ - e_table_selected_row_foreach (e_table_scrolled_get_table(E_TABLE_SCROLLED(editor->table)), - (EForeachFunc)remove_row, editor); - if (!editor->changed) { - editor->changed = TRUE; - command_state_changed (editor); - } -} - -static void -list_name_changed_cb (GtkWidget *w, EContactListEditor *editor) -{ - if (!editor->changed) { - editor->changed = TRUE; - command_state_changed (editor); - } -} - -static void -visible_addrs_toggled_cb (GtkWidget *w, EContactListEditor *editor) -{ - if (!editor->changed) { - editor->changed = TRUE; - command_state_changed (editor); - } -} - -static void -set_editable (EContactListEditor *editor) -{ - gtk_widget_set_sensitive (editor->email_entry, editor->editable); - gtk_widget_set_sensitive (editor->list_name_entry, editor->editable); - gtk_widget_set_sensitive (editor->add_button, editor->editable); - gtk_widget_set_sensitive (editor->remove_button, editor->editable); - gtk_widget_set_sensitive (editor->table, editor->editable); -} - -/* Closes the dialog box and emits the appropriate signals */ -static void -close_dialog (EContactListEditor *cle) -{ - g_assert (cle->app != NULL); - - gtk_widget_destroy (cle->app); - cle->app = NULL; - - gtk_signal_emit (GTK_OBJECT (cle), contact_list_editor_signals[EDITOR_CLOSED]); -} - -/* Callback used when the editor is destroyed */ -static gint -app_delete_event_cb (GtkWidget *widget, GdkEvent *event, gpointer data) -{ - EContactListEditor *ce; - - ce = E_CONTACT_LIST_EDITOR (data); - - /* if we're in an async call, don't allow the dialog to close */ - if (ce->in_async_call) - return TRUE; - - if (!prompt_to_save_changes (ce)) - return TRUE; - - close_dialog (ce); - return TRUE; -} - -static gboolean -table_drag_motion_cb (ETable *table, int row, int col, - GdkDragContext *context, - gint x, gint y, guint time, EContactListEditor *editor) -{ - GList *p; - - for (p = context->targets; p != NULL; p = p->next) { - char *possible_type; - - possible_type = gdk_atom_name ((GdkAtom) p->data); - if (!strcmp (possible_type, VCARD_TYPE)) { - g_free (possible_type); - gdk_drag_status (context, GDK_ACTION_LINK, time); - return TRUE; - } - - g_free (possible_type); - } - - return FALSE; -} - -static gboolean -table_drag_drop_cb (ETable *table, int row, int col, - GdkDragContext *context, - gint x, gint y, guint time, EContactListEditor *editor) -{ - if (context->targets != NULL) { - gtk_drag_get_data (GTK_WIDGET (table), context, - GPOINTER_TO_INT (context->targets->data), - time); - return TRUE; - } - - return FALSE; -} - -static void -table_drag_data_received_cb (ETable *table, int row, int col, - GdkDragContext *context, - gint x, gint y, - GtkSelectionData *selection_data, - guint info, guint time, EContactListEditor *editor) -{ - GtkAdjustment *adj = e_scroll_frame_get_vadjustment (E_SCROLL_FRAME (editor->table)); - char *target_type; - gboolean changed = FALSE; - - target_type = gdk_atom_name (selection_data->target); - - if (!strcmp (target_type, VCARD_TYPE)) { - - GList *card_list = e_card_load_cards_from_string_with_default_charset (selection_data->data, "ISO-8859-1"); - GList *c; - - for (c = card_list; c; c = c->next) { - ECard *ecard = c->data; - - if (!e_card_evolution_list (ecard)) { - ECardSimple *simple = e_card_simple_new (ecard); - - e_contact_list_model_add_card (E_CONTACT_LIST_MODEL (editor->model), - simple); - - gtk_object_unref (GTK_OBJECT (simple)); - - changed = TRUE; - } - } - g_list_foreach (card_list, (GFunc)gtk_object_unref, NULL); - g_list_free (card_list); - - /* Skip to the end of the list */ - if (adj->upper - adj->lower > adj->page_size) - gtk_adjustment_set_value (adj, adj->upper); - } - - if (changed && !editor->changed) { - editor->changed = TRUE; - command_state_changed (editor); - } -} - -static void -command_state_changed (EContactListEditor *editor) -{ - bonobo_ui_component_set_prop (editor->uic, - "/commands/ContactListEditorSaveClose", - "sensitive", - editor->changed && editor->editable ? "1" : "0", NULL); - - bonobo_ui_component_set_prop (editor->uic, - "/commands/ContactListEditorSave", - "sensitive", - editor->changed && editor->editable ? "1" : "0", NULL); - - bonobo_ui_component_set_prop (editor->uic, - "/commands/ContactListEditorDelete", - "sensitive", - editor->editable && !editor->is_new_list ? "1" : "0", NULL); -} - -static void -extract_info(EContactListEditor *editor) -{ - ECard *card = editor->card; - if (card) { - int i; - EList *email_list; - EIterator *email_iter; - char *string = e_utf8_gtk_editable_get_chars(GTK_EDITABLE (editor->list_name_entry), 0, -1); - - if (string && *string) - gtk_object_set(GTK_OBJECT(card), - "file_as", string, - "full_name", string, - NULL); - - g_free (string); - - - gtk_object_set (GTK_OBJECT(card), - "list", GINT_TO_POINTER (TRUE), - "list_show_addresses", - GINT_TO_POINTER (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(editor->visible_addrs_checkbutton))), - NULL); - - gtk_object_get (GTK_OBJECT(card), - "email", &email_list, - NULL); - - /* clear the email list */ - email_iter = e_list_get_iterator (email_list); - e_iterator_last (email_iter); - while (e_iterator_is_valid (E_ITERATOR (email_iter))) { - e_iterator_delete (E_ITERATOR (email_iter)); - } - gtk_object_unref (GTK_OBJECT (email_iter)); - - /* then refill it from the contact list model */ - for (i = 0; i < e_table_model_row_count (editor->model); i ++) { - const EDestination *dest = e_contact_list_model_get_destination (E_CONTACT_LIST_MODEL (editor->model), i); - gchar *dest_xml = e_destination_export (dest); - if (dest_xml) { - e_list_append (email_list, dest_xml); - } - g_free (dest_xml); - } - } -} - -static void -fill_in_info(EContactListEditor *editor) -{ - if (editor->card) { - char *file_as; - gboolean show_addresses = FALSE; - gboolean is_evolution_list = FALSE; - EList *email_list; - EIterator *email_iter; - - gtk_object_get (GTK_OBJECT (editor->card), - "file_as", &file_as, - "email", &email_list, - "list", &is_evolution_list, - "list_show_addresses", &show_addresses, - NULL); - - gtk_editable_delete_text (GTK_EDITABLE (editor->list_name_entry), 0, -1); - if (file_as) { - int position = 0; - gchar *u = e_utf8_to_gtk_string (editor->list_name_entry, file_as); - gtk_editable_insert_text (GTK_EDITABLE (editor->list_name_entry), u, strlen (u), &position); - g_free (u); - } - - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(editor->visible_addrs_checkbutton), !show_addresses); - - e_contact_list_model_remove_all (E_CONTACT_LIST_MODEL (editor->model)); - - email_iter = e_list_get_iterator (email_list); - - while (e_iterator_is_valid (email_iter)) { - const char *dest_xml = e_iterator_get (email_iter); - EDestination *dest; - - /* g_message ("incoming xml: [%s]", dest_xml); */ - dest = e_destination_import (dest_xml); - - if (dest != NULL) { - e_contact_list_model_add_destination (E_CONTACT_LIST_MODEL (editor->model), dest); - } - - e_iterator_next (email_iter); - } - } -} diff --git a/addressbook/gui/contact-list-editor/e-contact-list-editor.h b/addressbook/gui/contact-list-editor/e-contact-list-editor.h deleted file mode 100644 index 37f54df170..0000000000 --- a/addressbook/gui/contact-list-editor/e-contact-list-editor.h +++ /dev/null @@ -1,110 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* e-contact-list-editor.h - * Copyright (C) 2001 Ximian, Inc. - * Author: Chris Toshok <toshok@ximian.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of version 2 of the GNU General Public - * License as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ -#ifndef __E_CONTACT_LIST_EDITOR_H__ -#define __E_CONTACT_LIST_EDITOR_H__ - -#include <libgnomeui/gnome-app.h> -#include <libgnomeui/gnome-app-helper.h> -#include <bonobo/bonobo-ui-component.h> -#include <glade/glade.h> -#include <gal/e-table/e-table-model.h> - -#include "addressbook/backend/ebook/e-book.h" -#include "addressbook/backend/ebook/e-card.h" -#include "addressbook/backend/ebook/e-card-simple.h" - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - -#define E_CONTACT_LIST_EDITOR_TYPE (e_contact_list_editor_get_type ()) -#define E_CONTACT_LIST_EDITOR(obj) (GTK_CHECK_CAST ((obj), E_CONTACT_LIST_EDITOR_TYPE, EContactListEditor)) -#define E_CONTACT_LIST_EDITOR_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_CONTACT_LIST_EDITOR_TYPE, EContactListEditorClass)) -#define E_IS_CONTACT_LIST_EDITOR(obj) (GTK_CHECK_TYPE ((obj), E_CONTACT_LIST_EDITOR_TYPE)) -#define E_IS_CONTACT_LIST_EDITOR_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), E_CONTACT_LIST_EDITOR_TYPE)) - - -typedef struct _EContactListEditor EContactListEditor; -typedef struct _EContactListEditorClass EContactListEditorClass; - -struct _EContactListEditor -{ - GtkObject object; - - /* item specific fields */ - EBook *book; - ECard *card; - - /* UI handler */ - BonoboUIComponent *uic; - - GladeXML *gui; - GtkWidget *app; - - GtkWidget *table; - ETableModel *model; - GtkWidget *email_entry; - GtkWidget *list_name_entry; - GtkWidget *add_button; - GtkWidget *remove_button; - GtkWidget *visible_addrs_checkbutton; - - /* Whether we are editing a new card or an existing one */ - guint is_new_list : 1; - - /* Whether the card has been changed since bringing up the contact editor */ - guint changed : 1; - - /* Whether the contact editor will accept modifications */ - guint editable : 1; - - /* Whether an async wombat call is in progress */ - guint in_async_call : 1; -}; - -struct _EContactListEditorClass -{ - GtkObjectClass parent_class; - - /* Notification signals */ - - void (* list_added) (EContactListEditor *cle, EBookStatus status, ECard *card); - void (* list_modified) (EContactListEditor *cle, EBookStatus status, ECard *card); - void (* list_deleted) (EContactListEditor *cle, EBookStatus status, ECard *card); - void (* editor_closed) (EContactListEditor *cle); -}; - -EContactListEditor *e_contact_list_editor_new (EBook *book, - ECard *list_card, - gboolean is_new_list, - gboolean editable); -GtkType e_contact_list_editor_get_type (void); -void e_contact_list_editor_show (EContactListEditor *editor); -void e_contact_list_editor_raise (EContactListEditor *editor); - -gboolean e_contact_list_editor_confirm_delete (GtkWindow *parent); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - - -#endif /* __E_CONTACT_LIST_EDITOR_H__ */ diff --git a/addressbook/gui/contact-list-editor/e-contact-list-model.c b/addressbook/gui/contact-list-editor/e-contact-list-model.c deleted file mode 100644 index c4321c2820..0000000000 --- a/addressbook/gui/contact-list-editor/e-contact-list-model.c +++ /dev/null @@ -1,253 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -#include <config.h> -#include "e-contact-list-model.h" - -#define PARENT_TYPE e_table_model_get_type() -static ETableModelClass *parent_class; - -#define COLS 1 - -/* This function returns the number of columns in our ETableModel. */ -static int -contact_list_col_count (ETableModel *etc) -{ - return COLS; -} - -/* This function returns the number of rows in our ETableModel. */ -static int -contact_list_row_count (ETableModel *etc) -{ - EContactListModel *model = E_CONTACT_LIST_MODEL (etc); - return model->data_count; -} - -/* This function returns the value at a particular point in our ETableModel. */ -static void * -contact_list_value_at (ETableModel *etc, int col, int row) -{ - EContactListModel *model = E_CONTACT_LIST_MODEL (etc); - - return (void *) e_destination_get_address (model->data[row]); -} - -/* This function sets the value at a particular point in our ETableModel. */ -static void -contact_list_set_value_at (ETableModel *etc, int col, int row, const void *val) -{ - /* nothing */ -} - -/* This function returns whether a particular cell is editable. */ -static gboolean -contact_list_is_cell_editable (ETableModel *etc, int col, int row) -{ - return FALSE; -} - -/* This function duplicates the value passed to it. */ -static void * -contact_list_duplicate_value (ETableModel *etc, int col, const void *value) -{ - return g_strdup(value); -} - -/* This function frees the value passed to it. */ -static void -contact_list_free_value (ETableModel *etc, int col, void *value) -{ - g_free(value); -} - -static void * -contact_list_initialize_value (ETableModel *etc, int col) -{ - return g_strdup(""); -} - -static gboolean -contact_list_value_is_empty (ETableModel *etc, int col, const void *value) -{ - return !(value && *(char *)value); -} - -static char * -contact_list_value_to_string (ETableModel *etc, int col, const void *value) -{ - return g_strdup(value); -} - -static void -contact_list_model_destroy (GtkObject *o) -{ - EContactListModel *model = E_CONTACT_LIST_MODEL (o); - int i; - - for (i = 0; i < model->data_count; i ++) { - gtk_object_unref (GTK_OBJECT (model->data[i])); - } - g_free (model->data); - - model->data_count = 0; - model->data_alloc = 0; -} - -static void -e_contact_list_model_class_init (GtkObjectClass *object_class) -{ - ETableModelClass *model_class = (ETableModelClass *) object_class; - - parent_class = gtk_type_class (PARENT_TYPE); - - object_class->destroy = contact_list_model_destroy; - - model_class->column_count = contact_list_col_count; - model_class->row_count = contact_list_row_count; - model_class->value_at = contact_list_value_at; - model_class->set_value_at = contact_list_set_value_at; - model_class->is_cell_editable = contact_list_is_cell_editable; - model_class->duplicate_value = contact_list_duplicate_value; - model_class->free_value = contact_list_free_value; - model_class->initialize_value = contact_list_initialize_value; - model_class->value_is_empty = contact_list_value_is_empty; - model_class->value_to_string = contact_list_value_to_string; -} - -static void -e_contact_list_model_init (GtkObject *object) -{ - EContactListModel *model = E_CONTACT_LIST_MODEL(object); - - model->data_alloc = 10; - model->data_count = 0; - model->data = g_new (EDestination*, model->data_alloc); -} - -GtkType -e_contact_list_model_get_type (void) -{ - static GtkType type = 0; - - if (!type){ - GtkTypeInfo info = { - "EContactListModel", - sizeof (EContactListModel), - sizeof (EContactListModelClass), - (GtkClassInitFunc) e_contact_list_model_class_init, - (GtkObjectInitFunc) e_contact_list_model_init, - NULL, /* reserved 1 */ - NULL, /* reserved 2 */ - (GtkClassInitFunc) NULL - }; - - type = gtk_type_unique (PARENT_TYPE, &info); - } - - return type; -} - -void -e_contact_list_model_construct (EContactListModel *model) -{ -} - -ETableModel * -e_contact_list_model_new () -{ - EContactListModel *model; - - model = gtk_type_new (e_contact_list_model_get_type ()); - - e_contact_list_model_construct (model); - - return E_TABLE_MODEL(model); -} - -void -e_contact_list_model_add_destination (EContactListModel *model, EDestination *dest) -{ - g_return_if_fail (E_IS_CONTACT_LIST_MODEL (model)); - g_return_if_fail (E_IS_DESTINATION (dest)); - - if (model->data_count + 1 >= model->data_alloc) { - model->data_alloc *= 2; - model->data = g_renew (EDestination*, model->data, model->data_alloc); - } - - model->data[model->data_count ++] = dest; - gtk_object_ref (GTK_OBJECT (dest)); - gtk_object_sink (GTK_OBJECT (dest)); - - e_table_model_changed (E_TABLE_MODEL (model)); -} - -void -e_contact_list_model_add_email (EContactListModel *model, - const char *email) -{ - EDestination *new_dest; - - g_return_if_fail (E_IS_CONTACT_LIST_MODEL (model)); - g_return_if_fail (email != NULL); - - new_dest = e_destination_new (); - e_destination_set_email (new_dest, email); - - e_contact_list_model_add_destination (model, new_dest); -} - -void -e_contact_list_model_add_card (EContactListModel *model, - ECardSimple *simple) -{ - EDestination *new_dest; - - g_return_if_fail (E_IS_CONTACT_LIST_MODEL (model)); - g_return_if_fail (E_IS_CARD_SIMPLE (simple)); - - new_dest = e_destination_new (); - e_destination_set_card (new_dest, simple->card, 0); /* Hard-wired for default e-mail */ - - e_contact_list_model_add_destination (model, new_dest); -} - -void -e_contact_list_model_remove_row (EContactListModel *model, int row) -{ - g_return_if_fail (E_IS_CONTACT_LIST_MODEL (model)); - g_return_if_fail (0 <= row && row < model->data_count); - - gtk_object_unref (GTK_OBJECT (model->data[row])); - memmove (model->data + row, model->data + row + 1, sizeof (EDestination*) * (model->data_count - row - 1)); - model->data_count --; - - e_table_model_changed (E_TABLE_MODEL (model)); -} - -void -e_contact_list_model_remove_all (EContactListModel *model) -{ - int i; - - g_return_if_fail (E_IS_CONTACT_LIST_MODEL (model)); - - for (i = 0; i < model->data_count; i ++) { - gtk_object_unref (GTK_OBJECT (model->data[i])); - model->data[i] = NULL; - } - - model->data_count = 0; - - e_table_model_changed (E_TABLE_MODEL (model)); -} - - -const EDestination * -e_contact_list_model_get_destination (EContactListModel *model, int row) -{ - g_return_val_if_fail (E_IS_CONTACT_LIST_MODEL (model), NULL); - g_return_val_if_fail (0 <= row && row < model->data_count, NULL); - - return model->data[row]; -} diff --git a/addressbook/gui/contact-list-editor/e-contact-list-model.h b/addressbook/gui/contact-list-editor/e-contact-list-model.h deleted file mode 100644 index 1c2d6ac8d0..0000000000 --- a/addressbook/gui/contact-list-editor/e-contact-list-model.h +++ /dev/null @@ -1,47 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -#ifndef _E_CONTACT_LIST_MODEL_H_ -#define _E_CONTACT_LIST_MODEL_H_ - -#include <gal/e-table/e-table-model.h> -#include "addressbook/backend/ebook/e-book.h" -#include "addressbook/backend/ebook/e-book-view.h" -#include "addressbook/backend/ebook/e-card-simple.h" -#include "addressbook/backend/ebook/e-destination.h" - -#define E_CONTACT_LIST_MODEL_TYPE (e_contact_list_model_get_type ()) -#define E_CONTACT_LIST_MODEL(o) (GTK_CHECK_CAST ((o), E_CONTACT_LIST_MODEL_TYPE, EContactListModel)) -#define E_CONTACT_LIST_MODEL_CLASS(k) (GTK_CHECK_CLASS_CAST((k), E_CONTACT_LIST_MODEL_TYPE, EContactListModelClass)) -#define E_IS_CONTACT_LIST_MODEL(o) (GTK_CHECK_TYPE ((o), E_CONTACT_LIST_MODEL_TYPE)) -#define E_IS_CONTACT_LIST_MODEL_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), E_CONTACT_LIST_MODEL_TYPE)) - -typedef struct _EContactListModel EContactListModel; -typedef struct _EContactListModelClass EContactListModelClass; - -struct _EContactListModel { - ETableModel parent; - - EDestination **data; - int data_count; - int data_alloc; -}; - - -struct _EContactListModelClass { - ETableModelClass parent_class; -}; - - -GtkType e_contact_list_model_get_type (void); -void e_contact_list_model_construct (EContactListModel *model); -ETableModel *e_contact_list_model_new (void); - -void e_contact_list_model_add_destination (EContactListModel *model, EDestination *dest); -void e_contact_list_model_add_email (EContactListModel *model, const char *email); -void e_contact_list_model_add_card (EContactListModel *model, ECardSimple *simple); - -void e_contact_list_model_remove_row (EContactListModel *model, int row); -void e_contact_list_model_remove_all (EContactListModel *model); - -const EDestination *e_contact_list_model_get_destination (EContactListModel *model, int row); - -#endif /* _E_CONTACT_LIST_MODEL_H_ */ |