From 6f31d60289f5d3def0cae26fd7ac0afe4d1f95ab Mon Sep 17 00:00:00 2001 From: nobody Date: Sun, 23 Apr 2000 19:19:31 +0000 Subject: This commit was manufactured by cvs2svn to create tag 'GNOME_GAMES_1_1_0'. svn path=/tags/GNOME_GAMES_1_1_0/; revision=2566 --- addressbook/.cvsignore | 6 - addressbook/ChangeLog | 28 - addressbook/Makefile.am | 2 - addressbook/backend/.cvsignore | 6 - addressbook/backend/Makefile.am | 1 - addressbook/backend/ebook/.cvsignore | 13 - addressbook/backend/ebook/Makefile.am | 101 - addressbook/backend/ebook/TODO | 2 - addressbook/backend/ebook/e-book-listener.c | 583 ----- addressbook/backend/ebook/e-book-listener.h | 95 - addressbook/backend/ebook/e-book-types.h | 29 - addressbook/backend/ebook/e-book-view-listener.c | 345 --- addressbook/backend/ebook/e-book-view-listener.h | 72 - addressbook/backend/ebook/e-book-view.c | 281 --- addressbook/backend/ebook/e-book-view.h | 55 - addressbook/backend/ebook/e-book.c | 999 -------- addressbook/backend/ebook/e-book.h | 123 - addressbook/backend/ebook/e-card-cursor.c | 235 -- addressbook/backend/ebook/e-card-cursor.h | 52 - addressbook/backend/ebook/e-card-iterator.c | 169 -- addressbook/backend/ebook/e-card-iterator.h | 61 - addressbook/backend/ebook/e-card-list-iterator.c | 199 -- addressbook/backend/ebook/e-card-list-iterator.h | 44 - addressbook/backend/ebook/e-card-list.c | 134 - addressbook/backend/ebook/e-card-list.h | 59 - addressbook/backend/ebook/e-card-pairs.h | 118 - addressbook/backend/ebook/e-card-types.h | 251 -- addressbook/backend/ebook/e-card.c | 2622 -------------------- addressbook/backend/ebook/e-card.h | 130 - addressbook/backend/ebook/test-card.c | 194 -- addressbook/backend/ebook/test-client-list.c | 77 - addressbook/backend/ebook/test-client.c | 172 -- addressbook/backend/idl/.cvsignore | 6 - addressbook/backend/idl/Makefile.am | 6 - addressbook/backend/idl/addressbook.idl | 118 - addressbook/backend/pas/.cvsignore | 10 - addressbook/backend/pas/Makefile.am | 46 - addressbook/backend/pas/TODO | 2 - addressbook/backend/pas/pas-backend-file.c | 1084 -------- addressbook/backend/pas/pas-backend-file.h | 32 - addressbook/backend/pas/pas-backend-ldap.c | 1039 -------- addressbook/backend/pas/pas-backend-ldap.h | 32 - addressbook/backend/pas/pas-backend.c | 99 - addressbook/backend/pas/pas-backend.h | 66 - addressbook/backend/pas/pas-book-factory.c | 475 ---- addressbook/backend/pas/pas-book-factory.h | 44 - addressbook/backend/pas/pas-book-view.c | 262 -- addressbook/backend/pas/pas-book-view.h | 53 - addressbook/backend/pas/pas-book.c | 622 ----- addressbook/backend/pas/pas-book.h | 91 - addressbook/backend/pas/pas-card-cursor.c | 227 -- addressbook/backend/pas/pas-card-cursor.h | 58 - addressbook/contact-editor/.cvsignore | 7 - addressbook/contact-editor/Makefile.am | 44 - addressbook/contact-editor/arrow.png | Bin 122 -> 0 bytes addressbook/contact-editor/briefcase.png | Bin 390 -> 0 bytes addressbook/contact-editor/contact-editor.glade | 2205 ---------------- .../contact-editor/e-contact-editor-strings.h | 48 - addressbook/contact-editor/e-contact-editor.c | 906 ------- addressbook/contact-editor/e-contact-editor.h | 85 - addressbook/contact-editor/email.png | Bin 331 -> 0 bytes addressbook/contact-editor/head.png | Bin 493 -> 0 bytes addressbook/contact-editor/netfreebusy.png | Bin 755 -> 0 bytes addressbook/contact-editor/netmeeting.png | Bin 803 -> 0 bytes addressbook/contact-editor/phone.png | Bin 506 -> 0 bytes addressbook/contact-editor/snailmail.png | Bin 516 -> 0 bytes addressbook/contact-editor/test-editor.c | 158 -- addressbook/contact-editor/web.png | Bin 573 -> 0 bytes addressbook/demo/.cvsignore | 8 - addressbook/demo/Makefile.am | 62 - addressbook/demo/addressbook-factory.c | 47 - addressbook/demo/addressbook-widget.c | 537 ---- addressbook/demo/addressbook-widget.h | 52 - addressbook/demo/addressbook.c | 199 -- addressbook/demo/addressbook.gnorba | 11 - addressbook/demo/addressbook.h | 8 - addressbook/demo/demo.c | 466 ---- addressbook/demo/e-test-model.c | 385 --- addressbook/demo/e-test-model.h | 64 - addressbook/demo/spec | 12 - addressbook/ename/Makefile.am | 43 - addressbook/ename/TODO | 2 - addressbook/ename/e-name-western-tables.h | 53 - addressbook/ename/e-name-western.h | 23 - addressbook/ename/test-ename-western-gtk.c | 148 -- addressbook/ename/test-ename-western.c | 70 - addressbook/gui/.cvsignore | 6 - addressbook/gui/Makefile.am | 1 - addressbook/gui/component/.cvsignore | 8 - addressbook/gui/component/Makefile.am | 39 - addressbook/gui/component/addressbook-factory.c | 49 - addressbook/gui/component/addressbook.c | 462 ---- addressbook/gui/component/addressbook.gnorba | 11 - addressbook/gui/component/addressbook.h | 8 - addressbook/gui/contact-editor/.cvsignore | 7 - addressbook/gui/contact-editor/Makefile.am | 44 - addressbook/gui/contact-editor/arrow.png | Bin 122 -> 0 bytes addressbook/gui/contact-editor/briefcase.png | Bin 390 -> 0 bytes .../gui/contact-editor/contact-editor.glade | 2205 ---------------- .../gui/contact-editor/e-contact-editor-strings.h | 48 - addressbook/gui/contact-editor/e-contact-editor.c | 906 ------- addressbook/gui/contact-editor/e-contact-editor.h | 85 - addressbook/gui/contact-editor/email.png | Bin 331 -> 0 bytes addressbook/gui/contact-editor/head.png | Bin 493 -> 0 bytes addressbook/gui/contact-editor/netfreebusy.png | Bin 755 -> 0 bytes addressbook/gui/contact-editor/netmeeting.png | Bin 803 -> 0 bytes addressbook/gui/contact-editor/phone.png | Bin 506 -> 0 bytes addressbook/gui/contact-editor/snailmail.png | Bin 516 -> 0 bytes addressbook/gui/contact-editor/test-editor.c | 158 -- addressbook/gui/contact-editor/web.png | Bin 573 -> 0 bytes addressbook/gui/minicard/.cvsignore | 10 - addressbook/gui/minicard/Makefile.am | 82 - addressbook/gui/minicard/e-minicard-label.c | 421 ---- addressbook/gui/minicard/e-minicard-label.h | 82 - addressbook/gui/minicard/e-minicard-view.c | 281 --- addressbook/gui/minicard/e-minicard-view.h | 91 - addressbook/gui/minicard/e-minicard.c | 625 ----- addressbook/gui/minicard/e-minicard.h | 97 - addressbook/gui/minicard/e-reflow-sorted.c | 186 -- addressbook/gui/minicard/e-reflow-sorted.h | 87 - addressbook/gui/minicard/e-reflow.c | 772 ------ addressbook/gui/minicard/e-reflow.h | 106 - addressbook/gui/minicard/test-minicard-label.c | 128 - addressbook/gui/minicard/test-minicard-view.c | 206 -- addressbook/gui/minicard/test-minicard.c | 117 - addressbook/gui/minicard/test-reflow.c | 193 -- addressbook/gui/widgets/Makefile.am | 82 - addressbook/gui/widgets/e-minicard-label.c | 421 ---- addressbook/gui/widgets/e-minicard-label.h | 82 - addressbook/gui/widgets/e-minicard-view.c | 281 --- addressbook/gui/widgets/e-minicard-view.h | 91 - addressbook/gui/widgets/e-minicard.c | 625 ----- addressbook/gui/widgets/e-minicard.h | 97 - addressbook/gui/widgets/test-minicard-label.c | 128 - addressbook/gui/widgets/test-minicard-view.c | 206 -- addressbook/gui/widgets/test-minicard.c | 117 - addressbook/gui/widgets/test-reflow.c | 193 -- addressbook/printing/.cvsignore | 8 - addressbook/printing/Makefile.am | 44 - .../printing/e-contact-print-style-editor.c | 150 -- .../printing/e-contact-print-style-editor.h | 74 - addressbook/printing/e-contact-print-types.h | 74 - addressbook/printing/e-contact-print.c | 957 ------- addressbook/printing/e-contact-print.glade | 1993 --------------- addressbook/printing/e-contact-print.h | 31 - addressbook/printing/medbook.ecps | 30 - addressbook/printing/phonelist.ecps | 29 - addressbook/printing/smallbook.ecps | 30 - .../printing/test-contact-print-style-editor.c | 87 - addressbook/printing/test-print.c | 82 - 150 files changed, 30706 deletions(-) delete mode 100644 addressbook/.cvsignore delete mode 100644 addressbook/ChangeLog delete mode 100644 addressbook/Makefile.am delete mode 100644 addressbook/backend/.cvsignore delete mode 100644 addressbook/backend/Makefile.am delete mode 100644 addressbook/backend/ebook/.cvsignore delete mode 100644 addressbook/backend/ebook/Makefile.am delete mode 100644 addressbook/backend/ebook/TODO delete mode 100644 addressbook/backend/ebook/e-book-listener.c delete mode 100644 addressbook/backend/ebook/e-book-listener.h delete mode 100644 addressbook/backend/ebook/e-book-types.h delete mode 100644 addressbook/backend/ebook/e-book-view-listener.c delete mode 100644 addressbook/backend/ebook/e-book-view-listener.h delete mode 100644 addressbook/backend/ebook/e-book-view.c delete mode 100644 addressbook/backend/ebook/e-book-view.h delete mode 100644 addressbook/backend/ebook/e-book.c delete mode 100644 addressbook/backend/ebook/e-book.h delete mode 100644 addressbook/backend/ebook/e-card-cursor.c delete mode 100644 addressbook/backend/ebook/e-card-cursor.h delete mode 100644 addressbook/backend/ebook/e-card-iterator.c delete mode 100644 addressbook/backend/ebook/e-card-iterator.h delete mode 100644 addressbook/backend/ebook/e-card-list-iterator.c delete mode 100644 addressbook/backend/ebook/e-card-list-iterator.h delete mode 100644 addressbook/backend/ebook/e-card-list.c delete mode 100644 addressbook/backend/ebook/e-card-list.h delete mode 100644 addressbook/backend/ebook/e-card-pairs.h delete mode 100644 addressbook/backend/ebook/e-card-types.h delete mode 100644 addressbook/backend/ebook/e-card.c delete mode 100644 addressbook/backend/ebook/e-card.h delete mode 100644 addressbook/backend/ebook/test-card.c delete mode 100644 addressbook/backend/ebook/test-client-list.c delete mode 100644 addressbook/backend/ebook/test-client.c delete mode 100644 addressbook/backend/idl/.cvsignore delete mode 100644 addressbook/backend/idl/Makefile.am delete mode 100644 addressbook/backend/idl/addressbook.idl delete mode 100644 addressbook/backend/pas/.cvsignore delete mode 100644 addressbook/backend/pas/Makefile.am delete mode 100644 addressbook/backend/pas/TODO delete mode 100644 addressbook/backend/pas/pas-backend-file.c delete mode 100644 addressbook/backend/pas/pas-backend-file.h delete mode 100644 addressbook/backend/pas/pas-backend-ldap.c delete mode 100644 addressbook/backend/pas/pas-backend-ldap.h delete mode 100644 addressbook/backend/pas/pas-backend.c delete mode 100644 addressbook/backend/pas/pas-backend.h delete mode 100644 addressbook/backend/pas/pas-book-factory.c delete mode 100644 addressbook/backend/pas/pas-book-factory.h delete mode 100644 addressbook/backend/pas/pas-book-view.c delete mode 100644 addressbook/backend/pas/pas-book-view.h delete mode 100644 addressbook/backend/pas/pas-book.c delete mode 100644 addressbook/backend/pas/pas-book.h delete mode 100644 addressbook/backend/pas/pas-card-cursor.c delete mode 100644 addressbook/backend/pas/pas-card-cursor.h delete mode 100644 addressbook/contact-editor/.cvsignore delete mode 100644 addressbook/contact-editor/Makefile.am delete mode 100644 addressbook/contact-editor/arrow.png delete mode 100644 addressbook/contact-editor/briefcase.png delete mode 100644 addressbook/contact-editor/contact-editor.glade delete mode 100644 addressbook/contact-editor/e-contact-editor-strings.h delete mode 100644 addressbook/contact-editor/e-contact-editor.c delete mode 100644 addressbook/contact-editor/e-contact-editor.h delete mode 100644 addressbook/contact-editor/email.png delete mode 100644 addressbook/contact-editor/head.png delete mode 100644 addressbook/contact-editor/netfreebusy.png delete mode 100644 addressbook/contact-editor/netmeeting.png delete mode 100644 addressbook/contact-editor/phone.png delete mode 100644 addressbook/contact-editor/snailmail.png delete mode 100644 addressbook/contact-editor/test-editor.c delete mode 100644 addressbook/contact-editor/web.png delete mode 100644 addressbook/demo/.cvsignore delete mode 100644 addressbook/demo/Makefile.am delete mode 100644 addressbook/demo/addressbook-factory.c delete mode 100644 addressbook/demo/addressbook-widget.c delete mode 100644 addressbook/demo/addressbook-widget.h delete mode 100644 addressbook/demo/addressbook.c delete mode 100644 addressbook/demo/addressbook.gnorba delete mode 100644 addressbook/demo/addressbook.h delete mode 100644 addressbook/demo/demo.c delete mode 100644 addressbook/demo/e-test-model.c delete mode 100644 addressbook/demo/e-test-model.h delete mode 100644 addressbook/demo/spec delete mode 100644 addressbook/ename/Makefile.am delete mode 100644 addressbook/ename/TODO delete mode 100644 addressbook/ename/e-name-western-tables.h delete mode 100644 addressbook/ename/e-name-western.h delete mode 100644 addressbook/ename/test-ename-western-gtk.c delete mode 100644 addressbook/ename/test-ename-western.c delete mode 100644 addressbook/gui/.cvsignore delete mode 100644 addressbook/gui/Makefile.am delete mode 100644 addressbook/gui/component/.cvsignore delete mode 100644 addressbook/gui/component/Makefile.am delete mode 100644 addressbook/gui/component/addressbook-factory.c delete mode 100644 addressbook/gui/component/addressbook.c delete mode 100644 addressbook/gui/component/addressbook.gnorba delete mode 100644 addressbook/gui/component/addressbook.h delete mode 100644 addressbook/gui/contact-editor/.cvsignore delete mode 100644 addressbook/gui/contact-editor/Makefile.am delete mode 100644 addressbook/gui/contact-editor/arrow.png delete mode 100644 addressbook/gui/contact-editor/briefcase.png delete mode 100644 addressbook/gui/contact-editor/contact-editor.glade delete mode 100644 addressbook/gui/contact-editor/e-contact-editor-strings.h delete mode 100644 addressbook/gui/contact-editor/e-contact-editor.c delete mode 100644 addressbook/gui/contact-editor/e-contact-editor.h delete mode 100644 addressbook/gui/contact-editor/email.png delete mode 100644 addressbook/gui/contact-editor/head.png delete mode 100644 addressbook/gui/contact-editor/netfreebusy.png delete mode 100644 addressbook/gui/contact-editor/netmeeting.png delete mode 100644 addressbook/gui/contact-editor/phone.png delete mode 100644 addressbook/gui/contact-editor/snailmail.png delete mode 100644 addressbook/gui/contact-editor/test-editor.c delete mode 100644 addressbook/gui/contact-editor/web.png delete mode 100644 addressbook/gui/minicard/.cvsignore delete mode 100644 addressbook/gui/minicard/Makefile.am delete mode 100644 addressbook/gui/minicard/e-minicard-label.c delete mode 100644 addressbook/gui/minicard/e-minicard-label.h delete mode 100644 addressbook/gui/minicard/e-minicard-view.c delete mode 100644 addressbook/gui/minicard/e-minicard-view.h delete mode 100644 addressbook/gui/minicard/e-minicard.c delete mode 100644 addressbook/gui/minicard/e-minicard.h delete mode 100644 addressbook/gui/minicard/e-reflow-sorted.c delete mode 100644 addressbook/gui/minicard/e-reflow-sorted.h delete mode 100644 addressbook/gui/minicard/e-reflow.c delete mode 100644 addressbook/gui/minicard/e-reflow.h delete mode 100644 addressbook/gui/minicard/test-minicard-label.c delete mode 100644 addressbook/gui/minicard/test-minicard-view.c delete mode 100644 addressbook/gui/minicard/test-minicard.c delete mode 100644 addressbook/gui/minicard/test-reflow.c delete mode 100644 addressbook/gui/widgets/Makefile.am delete mode 100644 addressbook/gui/widgets/e-minicard-label.c delete mode 100644 addressbook/gui/widgets/e-minicard-label.h delete mode 100644 addressbook/gui/widgets/e-minicard-view.c delete mode 100644 addressbook/gui/widgets/e-minicard-view.h delete mode 100644 addressbook/gui/widgets/e-minicard.c delete mode 100644 addressbook/gui/widgets/e-minicard.h delete mode 100644 addressbook/gui/widgets/test-minicard-label.c delete mode 100644 addressbook/gui/widgets/test-minicard-view.c delete mode 100644 addressbook/gui/widgets/test-minicard.c delete mode 100644 addressbook/gui/widgets/test-reflow.c delete mode 100644 addressbook/printing/.cvsignore delete mode 100644 addressbook/printing/Makefile.am delete mode 100644 addressbook/printing/e-contact-print-style-editor.c delete mode 100644 addressbook/printing/e-contact-print-style-editor.h delete mode 100644 addressbook/printing/e-contact-print-types.h delete mode 100644 addressbook/printing/e-contact-print.c delete mode 100644 addressbook/printing/e-contact-print.glade delete mode 100644 addressbook/printing/e-contact-print.h delete mode 100644 addressbook/printing/medbook.ecps delete mode 100644 addressbook/printing/phonelist.ecps delete mode 100644 addressbook/printing/smallbook.ecps delete mode 100644 addressbook/printing/test-contact-print-style-editor.c delete mode 100644 addressbook/printing/test-print.c (limited to 'addressbook') diff --git a/addressbook/.cvsignore b/addressbook/.cvsignore deleted file mode 100644 index 09980ae6ba..0000000000 --- a/addressbook/.cvsignore +++ /dev/null @@ -1,6 +0,0 @@ -.deps -.libs -Makefile -Makefile.in -*.lo -*.la diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog deleted file mode 100644 index f0bd6f790f..0000000000 --- a/addressbook/ChangeLog +++ /dev/null @@ -1,28 +0,0 @@ -2000-04-18 Federico Mena Quintero - - * gui/minicard/Makefile.am (INCLUDES): Use "e-minicard" as the log - domain. - - * gui/component/Makefile.am (INCLUDES): Use - "evolution-addressbook" as the log domain. - - * backend/pas/Makefile.am: Build libpas.a, not a shared library. - Do not install any header files. - (INCLUDES): Remove spurious include paths. - - * backend/pas/*.[ch]: Fix includes. - - * backend/ebook/Makefile.am: Do not install the test programs. - Fixed some include weirdness. - - * backend/ebook/*.[ch]: Fix includes. - - * contact-editor/Makefile.am (INCLUDES): Set the log domain to - "contact-editor". - (INCLUDES): Fix. - - * contact-editor/*.[ch]: Fix includes. - - * gui/minicard/*.[ch]: Fix includes. - - * ChangeLog: Started a ChangeLog here. diff --git a/addressbook/Makefile.am b/addressbook/Makefile.am deleted file mode 100644 index 22f0922618..0000000000 --- a/addressbook/Makefile.am +++ /dev/null @@ -1,2 +0,0 @@ -SUBDIRS = \ - backend contact-editor gui printing diff --git a/addressbook/backend/.cvsignore b/addressbook/backend/.cvsignore deleted file mode 100644 index 09980ae6ba..0000000000 --- a/addressbook/backend/.cvsignore +++ /dev/null @@ -1,6 +0,0 @@ -.deps -.libs -Makefile -Makefile.in -*.lo -*.la diff --git a/addressbook/backend/Makefile.am b/addressbook/backend/Makefile.am deleted file mode 100644 index b2807b2480..0000000000 --- a/addressbook/backend/Makefile.am +++ /dev/null @@ -1 +0,0 @@ -SUBDIRS = idl ebook pas diff --git a/addressbook/backend/ebook/.cvsignore b/addressbook/backend/ebook/.cvsignore deleted file mode 100644 index f1033573bb..0000000000 --- a/addressbook/backend/ebook/.cvsignore +++ /dev/null @@ -1,13 +0,0 @@ -.deps -.libs -Makefile -Makefile.in -*.lo -*.la -addressbook-stubs.c -addressbook-skels.c -addressbook-common.c -addressbook.h -test-card -test-client -test-client-list diff --git a/addressbook/backend/ebook/Makefile.am b/addressbook/backend/ebook/Makefile.am deleted file mode 100644 index fb064888cd..0000000000 --- a/addressbook/backend/ebook/Makefile.am +++ /dev/null @@ -1,101 +0,0 @@ -noinst_PROGRAMS = test-card test-client test-client-list - -corbadir = $(sysconfdir)/CORBA/servers - -CORBA_SOURCE = \ - addressbook.h \ - addressbook-common.c \ - addressbook-stubs.c \ - addressbook-skels.c - -idls = \ - $(srcdir)/../idl/addressbook.idl - -idl_flags = `$(GNOME_CONFIG) --cflags idl` - -$(CORBA_SOURCE): $(idls) - $(ORBIT_IDL) $(srcdir)/../idl/addressbook.idl $(idl_flags) - -INCLUDES = \ - -DGNOMELOCALEDIR=\""$(datadir)/locale"\" \ - -DG_LOG_DOMAIN=\"EBook\" \ - -I$(top_srcdir) \ - -I$(top_srcdir)/addressbook/backend \ - -I$(top_builddir)/addressbook/backend \ - $(GNOME_INCLUDEDIR) - -gnome_libs = \ - $(GNOME_LIBDIR) \ - $(GNOMEUI_LIBS) \ - $(GNOMEGNORBA_LIBS) \ - $(INTLLIBS) - -ebook_libs = \ - libebook.la \ - $(gnome_libs) - -lib_LTLIBRARIES = libebook.la - -libebook_la_SOURCES = \ - $(CORBA_SOURCE) \ - e-book-listener.c \ - e-book-view-listener.c \ - e-book-view.c \ - e-book.c \ - e-card-cursor.c \ - e-card-iterator.c \ - e-card-list-iterator.c \ - e-card-list.c \ - e-card.c - -libebookincludedir = $(includedir)/evolution/ebook - -libebookinclude_HEADERS = \ - e-book-listener.h \ - e-book-view-listener.h \ - e-book-view.h \ - e-book.h \ - e-card-cursor.h \ - e-card-iterator.h \ - e-card-list-iterator.h \ - e-card-list.h \ - e-card.h - -test_client_SOURCES = \ - test-client.c - -test_client_LDADD = \ - $(GTK_LIBS) \ - $(GNOME_LIBDIR) \ - $(GNOMEGNORBA_LIBS) \ - $(INTLLIBS) \ - -lbonobo \ - $(ebook_libs) \ - $(top_builddir)/libversit/libversit.la - -test_client_list_SOURCES = \ - test-client-list.c - -test_client_list_LDADD = \ - $(GTK_LIBS) \ - $(GNOME_LIBDIR) \ - $(GNOMEGNORBA_LIBS) \ - $(INTLLIBS) \ - -lbonobo \ - $(ebook_libs) \ - $(top_builddir)/libversit/libversit.la - -test_card_SOURCES = \ - test-card.c - -test_card_LDADD = \ - $(GTK_LIBS) \ - $(GNOME_LIBDIR) \ - $(GNOMEGNORBA_LIBS) \ - $(INTLLIBS) \ - -lbonobo \ - $(ebook_libs) \ - $(top_builddir)/libversit/libversit.la - -BUILT_SOURCES = $(CORBA_SOURCE) -CLEANFILES += $(BUILT_SOURCES) diff --git a/addressbook/backend/ebook/TODO b/addressbook/backend/ebook/TODO deleted file mode 100644 index a69703cd92..0000000000 --- a/addressbook/backend/ebook/TODO +++ /dev/null @@ -1,2 +0,0 @@ -* Make sure open_book_progress does not use the EBook op queue; make - sure it works. diff --git a/addressbook/backend/ebook/e-book-listener.c b/addressbook/backend/ebook/e-book-listener.c deleted file mode 100644 index d0ccc46944..0000000000 --- a/addressbook/backend/ebook/e-book-listener.c +++ /dev/null @@ -1,583 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Exports the BookListener interface. Maintains a queue of messages - * which come in on the interface. - * - * Author: - * Nat Friedman (nat@helixcode.com) - * - * Copyright 2000, Helix Code, Inc. - */ - -#include -#include -#include "e-book-listener.h" - -static EBookStatus e_book_listener_convert_status (Evolution_BookListener_CallStatus status); - -enum { - RESPONSES_QUEUED, - LAST_SIGNAL -}; - -static guint e_book_listener_signals [LAST_SIGNAL]; - -static BonoboObjectClass *e_book_listener_parent_class; -POA_Evolution_BookListener__vepv e_book_listener_vepv; - -struct _EBookListenerPrivate { - GList *response_queue; - gint idle_id; -}; - -static gboolean -e_book_listener_check_queue (EBookListener *listener) -{ - if (listener->priv->response_queue != NULL) { - gtk_signal_emit (GTK_OBJECT (listener), - e_book_listener_signals [RESPONSES_QUEUED]); - } - - if (listener->priv->response_queue == NULL) { - listener->priv->idle_id = 0; - return FALSE; - } - - return TRUE; -} - -static void -e_book_listener_queue_response (EBookListener *listener, - EBookListenerResponse *response) -{ - listener->priv->response_queue = - g_list_append (listener->priv->response_queue, - response); - - if (listener->priv->idle_id == 0) { - listener->priv->idle_id = g_idle_add ( - (GSourceFunc) e_book_listener_check_queue, listener); - } -} - -/* Add, Remove, Modify */ -static void -e_book_listener_queue_generic_response (EBookListener *listener, - EBookListenerOperation op, - EBookStatus status) -{ - EBookListenerResponse *resp; - - resp = g_new0 (EBookListenerResponse, 1); - - resp->op = op; - resp->status = status; - - e_book_listener_queue_response (listener, resp); -} - -static void -e_book_listener_queue_open_response (EBookListener *listener, - EBookStatus status, - Evolution_Book book) -{ - EBookListenerResponse *resp; - - resp = g_new0 (EBookListenerResponse, 1); - - resp->op = OpenBookResponse; - resp->status = status; - resp->book = book; - - e_book_listener_queue_response (listener, resp); -} - -static void -e_book_listener_queue_open_progress (EBookListener *listener, - const char *msg, - short percent) -{ - EBookListenerResponse *resp; - - resp = g_new0 (EBookListenerResponse, 1); - - resp->op = OpenProgressEvent; - resp->msg = g_strdup (msg); - resp->percent = percent; - - e_book_listener_queue_response (listener, resp); -} - - -static void -e_book_listener_queue_create_card_response (EBookListener *listener, - EBookStatus status, - const char *id) -{ - EBookListenerResponse *resp; - - resp = g_new0 (EBookListenerResponse, 1); - - resp->op = CreateCardResponse; - resp->status = status; - resp->id = g_strdup (id); - - e_book_listener_queue_response (listener, resp); -} - -static void -e_book_listener_queue_get_cursor_response (EBookListener *listener, - EBookStatus status, - Evolution_CardCursor cursor) -{ - EBookListenerResponse *resp; - - resp = g_new0 (EBookListenerResponse, 1); - - resp->op = GetCursorResponse; - resp->status = status; - resp->cursor = cursor; - - e_book_listener_queue_response (listener, resp); -} - -static void -e_book_listener_queue_get_view_response (EBookListener *listener, - EBookStatus status, - Evolution_BookView book_view) -{ - EBookListenerResponse *resp; - - resp = g_new0 (EBookListenerResponse, 1); - - resp->op = GetBookViewResponse; - resp->status = status; - resp->book_view = book_view; - - e_book_listener_queue_response (listener, resp); -} - -static void -e_book_listener_queue_link_status (EBookListener *listener, - gboolean connected) -{ - EBookListenerResponse *resp; - - resp = g_new0 (EBookListenerResponse, 1); - - resp->op = LinkStatusEvent; - resp->connected = connected; - - e_book_listener_queue_response (listener, resp); -} - -static void -impl_BookListener_respond_create_card (PortableServer_Servant servant, - const Evolution_BookListener_CallStatus status, - const Evolution_CardId id, - CORBA_Environment *ev) -{ - EBookListener *listener = E_BOOK_LISTENER (bonobo_object_from_servant (servant)); - - e_book_listener_queue_create_card_response ( - listener, - e_book_listener_convert_status (status), - id); -} - -static void -impl_BookListener_respond_remove_card (PortableServer_Servant servant, - const Evolution_BookListener_CallStatus status, - CORBA_Environment *ev) -{ - EBookListener *listener = E_BOOK_LISTENER (bonobo_object_from_servant (servant)); - - e_book_listener_queue_generic_response ( - listener, RemoveCardResponse, - e_book_listener_convert_status (status)); -} - -static void -impl_BookListener_respond_modify_card (PortableServer_Servant servant, - const Evolution_BookListener_CallStatus status, - CORBA_Environment *ev) -{ - EBookListener *listener = E_BOOK_LISTENER (bonobo_object_from_servant (servant)); - - e_book_listener_queue_generic_response ( - listener, ModifyCardResponse, - e_book_listener_convert_status (status)); -} - -static void -impl_BookListener_respond_get_cursor (PortableServer_Servant servant, - const Evolution_BookListener_CallStatus status, - const Evolution_CardCursor cursor, - CORBA_Environment *ev) -{ - EBookListener *listener = E_BOOK_LISTENER (bonobo_object_from_servant (servant)); - Evolution_CardCursor cursor_copy; - - cursor_copy = CORBA_Object_duplicate (cursor, ev); - - if (ev->_major != CORBA_NO_EXCEPTION) { - g_warning ("EBookListener: Exception while duplicating CardCursor!\n"); - return; - } - - e_book_listener_queue_get_cursor_response ( - listener, - e_book_listener_convert_status (status), - cursor_copy); -} - -static void -impl_BookListener_respond_get_view (PortableServer_Servant servant, - const Evolution_BookListener_CallStatus status, - const Evolution_BookView book_view, - CORBA_Environment *ev) -{ - EBookListener *listener = E_BOOK_LISTENER (bonobo_object_from_servant (servant)); - Evolution_BookView book_view_copy; - - book_view_copy = CORBA_Object_duplicate (book_view, ev); - - if (ev->_major != CORBA_NO_EXCEPTION) { - g_warning ("EBookListener: Exception while duplicating BookView.\n"); - return; - } - - e_book_listener_queue_get_view_response ( - listener, - e_book_listener_convert_status (status), - book_view_copy); -} - -static void -impl_BookListener_respond_open_book (PortableServer_Servant servant, - const Evolution_BookListener_CallStatus status, - const Evolution_Book book, - CORBA_Environment *ev) -{ - EBookListener *listener = E_BOOK_LISTENER (bonobo_object_from_servant (servant)); - Evolution_Book book_copy; - - book_copy = CORBA_Object_duplicate (book, ev); - - if (ev->_major != CORBA_NO_EXCEPTION) { - g_warning ("EBookListener: Exception while duplicating Book!\n"); - return; - } - - e_book_listener_queue_open_response ( - listener, - e_book_listener_convert_status (status), - book_copy); -} - -static void -impl_BookListener_report_open_book_progress (PortableServer_Servant servant, - const CORBA_char *status_message, - const CORBA_short percent, - CORBA_Environment *ev) -{ - EBookListener *listener = E_BOOK_LISTENER (bonobo_object_from_servant (servant)); - - e_book_listener_queue_open_progress ( - listener, status_message, percent); -} - -static void -impl_BookListener_report_connection_status (PortableServer_Servant servant, - const CORBA_boolean connected, - CORBA_Environment *ev) -{ - EBookListener *listener = E_BOOK_LISTENER (bonobo_object_from_servant (servant)); - - e_book_listener_queue_link_status ( - listener, connected); -} - -/** - * e_book_listener_check_pending: - * @listener: the #EBookListener - * - * Returns: the number of items on the response queue, - * or -1 if the @listener is isn't an #EBookListener. - */ -int -e_book_listener_check_pending (EBookListener *listener) -{ - g_return_val_if_fail (listener != NULL, -1); - g_return_val_if_fail (E_IS_BOOK_LISTENER (listener), -1); - - return g_list_length (listener->priv->response_queue); -} - -/** - * e_book_listener_pop_response: - * @listener: the #EBookListener for which a request is to be popped - * - * Returns: an #EBookListenerResponse if there are responses on the - * queue to be returned; %NULL if there aren't, or if the @listener - * isn't an EBookListener. - */ -EBookListenerResponse * -e_book_listener_pop_response (EBookListener *listener) -{ - EBookListenerResponse *resp; - GList *popped; - - g_return_val_if_fail (listener != NULL, NULL); - g_return_val_if_fail (E_IS_BOOK_LISTENER (listener), NULL); - - if (listener->priv->response_queue == NULL) - return NULL; - - resp = listener->priv->response_queue->data; - - popped = listener->priv->response_queue; - listener->priv->response_queue = - g_list_remove_link (listener->priv->response_queue, - listener->priv->response_queue); - g_list_free_1 (popped); - - return resp; -} - -static EBookStatus -e_book_listener_convert_status (const Evolution_BookListener_CallStatus status) -{ - switch (status) { - case Evolution_BookListener_Success: - return E_BOOK_STATUS_SUCCESS; - case Evolution_BookListener_RepositoryOffline: - return E_BOOK_STATUS_REPOSITORY_OFFLINE; - case Evolution_BookListener_PermissionDenied: - return E_BOOK_STATUS_PERMISSION_DENIED; - case Evolution_BookListener_CardNotFound: - return E_BOOK_STATUS_CARD_NOT_FOUND; - default: - g_warning ("e_book_listener_convert_status: Unknown status " - "from card server: %d\n", (int) status); - return E_BOOK_STATUS_UNKNOWN; - - } -} - -static EBookListener * -e_book_listener_construct (EBookListener *listener) -{ - POA_Evolution_BookListener *servant; - CORBA_Environment ev; - CORBA_Object obj; - - g_assert (listener != NULL); - g_assert (E_IS_BOOK_LISTENER (listener)); - - servant = (POA_Evolution_BookListener *) g_new0 (BonoboObjectServant, 1); - servant->vepv = &e_book_listener_vepv; - - CORBA_exception_init (&ev); - - POA_Evolution_BookListener__init ((PortableServer_Servant) servant, &ev); - if (ev._major != CORBA_NO_EXCEPTION) { - g_free (servant); - CORBA_exception_free (&ev); - - return NULL; - } - - CORBA_exception_free (&ev); - - obj = bonobo_object_activate_servant (BONOBO_OBJECT (listener), servant); - if (obj == CORBA_OBJECT_NIL) { - g_free (servant); - - return NULL; - } - - bonobo_object_construct (BONOBO_OBJECT (listener), obj); - - return listener; -} - -/** - * e_book_listener_new: - * @book: the #EBook for which the listener is to be bound - * - * Creates and returns a new #EBookListener for the book. - * - * Returns: a new #EBookListener - */ -EBookListener * -e_book_listener_new () -{ - EBookListener *listener; - EBookListener *retval; - - listener = gtk_type_new (E_BOOK_LISTENER_TYPE); - - retval = e_book_listener_construct (listener); - - if (retval == NULL) { - g_warning ("e_book_listener_new: Error constructing " - "EBookListener!\n"); - gtk_object_unref (GTK_OBJECT (listener)); - return NULL; - } - - return retval; -} - -static void -e_book_listener_init (EBookListener *listener) -{ - listener->priv = g_new0 (EBookListenerPrivate, 1); -} - -static void -e_book_listener_destroy (GtkObject *object) -{ - EBookListener *listener = E_BOOK_LISTENER (object); - GList *l; - - for (l = listener->priv->response_queue; l != NULL; l = l->next) { - EBookListenerResponse *resp = l->data; - - g_free (resp->msg); - g_free (resp->id); - - if (resp->book != CORBA_OBJECT_NIL) { - CORBA_Environment ev; - - CORBA_exception_init (&ev); - - CORBA_Object_release (resp->book, &ev); - - if (ev._major != CORBA_NO_EXCEPTION) { - g_warning ("e_book_listener_destroy: " - "Exception destroying book " - "in response queue!\n"); - } - - CORBA_exception_free (&ev); - } - - if (resp->cursor != CORBA_OBJECT_NIL) { - CORBA_Environment ev; - - CORBA_exception_init (&ev); - - CORBA_Object_release (resp->cursor, &ev); - - if (ev._major != CORBA_NO_EXCEPTION) { - g_warning ("e_book_listener_destroy: " - "Exception destroying cursor " - "in response queue!\n"); - } - - CORBA_exception_free (&ev); - } - - if (resp->book_view != CORBA_OBJECT_NIL) { - CORBA_Environment ev; - - CORBA_exception_init (&ev); - - CORBA_Object_release (resp->book_view, &ev); - - if (ev._major != CORBA_NO_EXCEPTION) { - g_warning ("e_book_listener_destroy: " - "Exception destroying book_view " - "in response queue!\n"); - } - - CORBA_exception_free (&ev); - } - - g_free (resp); - } - g_list_free (listener->priv->response_queue); - - g_free (listener->priv); - - GTK_OBJECT_CLASS (e_book_listener_parent_class)->destroy (object); -} - -POA_Evolution_BookListener__epv * -e_book_listener_get_epv (void) -{ - POA_Evolution_BookListener__epv *epv; - - epv = g_new0 (POA_Evolution_BookListener__epv, 1); - - epv->report_open_book_progress = impl_BookListener_report_open_book_progress; - epv->respond_open_book = impl_BookListener_respond_open_book; - - epv->respond_create_card = impl_BookListener_respond_create_card; - epv->respond_remove_card = impl_BookListener_respond_remove_card; - epv->respond_modify_card = impl_BookListener_respond_modify_card; - - epv->respond_get_cursor = impl_BookListener_respond_get_cursor; - epv->respond_get_view = impl_BookListener_respond_get_view; - - epv->report_connection_status = impl_BookListener_report_connection_status; - - return epv; -} - -static void -e_book_listener_corba_class_init (void) -{ - e_book_listener_vepv.Bonobo_Unknown_epv = bonobo_object_get_epv (); - e_book_listener_vepv.Evolution_BookListener_epv = e_book_listener_get_epv (); -} - -static void -e_book_listener_class_init (EBookListenerClass *klass) -{ - GtkObjectClass *object_class = (GtkObjectClass *) klass; - - e_book_listener_parent_class = gtk_type_class (bonobo_object_get_type ()); - - e_book_listener_signals [RESPONSES_QUEUED] = - gtk_signal_new ("responses_queued", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (EBookListenerClass, responses_queued), - gtk_marshal_NONE__NONE, - GTK_TYPE_NONE, 0); - - gtk_object_class_add_signals (object_class, e_book_listener_signals, LAST_SIGNAL); - - object_class->destroy = e_book_listener_destroy; - - e_book_listener_corba_class_init (); -} - -/** - * e_book_listener_get_type: - */ -GtkType -e_book_listener_get_type (void) -{ - static GtkType type = 0; - - if (! type) { - GtkTypeInfo info = { - "EBookListener", - sizeof (EBookListener), - sizeof (EBookListenerClass), - (GtkClassInitFunc) e_book_listener_class_init, - (GtkObjectInitFunc) e_book_listener_init, - NULL, /* reserved 1 */ - NULL, /* reserved 2 */ - (GtkClassInitFunc) NULL - }; - - type = gtk_type_unique (bonobo_object_get_type (), &info); - } - - return type; -} diff --git a/addressbook/backend/ebook/e-book-listener.h b/addressbook/backend/ebook/e-book-listener.h deleted file mode 100644 index eb0432e360..0000000000 --- a/addressbook/backend/ebook/e-book-listener.h +++ /dev/null @@ -1,95 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * A client-side GtkObject which exposes the - * Evolution:BookListener interface. - * - * Author: - * Nat Friedman (nat@helixcode.com) - * - * Copyright 2000, Helix Code, Inc. - */ - -#ifndef __E_BOOK_LISTENER_H__ -#define __E_BOOK_LISTENER_H__ - -#include -#include -#include -#include - -BEGIN_GNOME_DECLS - -typedef struct _EBookListener EBookListener; -typedef struct _EBookListenerClass EBookListenerClass; -typedef struct _EBookListenerPrivate EBookListenerPrivate; - -struct _EBookListener { - BonoboObject parent; - EBookListenerPrivate *priv; -}; - -struct _EBookListenerClass { - BonoboObjectClass parent; - - /* - * Signals - */ - void (*responses_queued) (void); -}; - -typedef enum { - /* Async responses */ - OpenBookResponse, - CreateCardResponse, - RemoveCardResponse, - ModifyCardResponse, - GetCursorResponse, - GetBookViewResponse, - - /* Async events */ - LinkStatusEvent, - OpenProgressEvent, -} EBookListenerOperation; - -typedef struct { - EBookListenerOperation op; - - /* For most Response notifications */ - EBookStatus status; - - /* For OpenBookResponse */ - Evolution_Book book; - - /* For GetCursorResponse */ - Evolution_CardCursor cursor; - - /* For GetBookViewReponse */ - Evolution_BookView book_view; - - /* For OpenProgressEvent */ - char *msg; - short percent; - - /* For LinkStatusEvent */ - gboolean connected; - - /* For Card[Added|Removed|Modified]Event */ - char *id; -} EBookListenerResponse; - -EBookListener *e_book_listener_new (void); -int e_book_listener_check_pending (EBookListener *listener); -EBookListenerResponse *e_book_listener_pop_response (EBookListener *listener); -GtkType e_book_listener_get_type (void); - -POA_Evolution_BookListener__epv *e_book_listener_get_epv (void); - -#define E_BOOK_LISTENER_TYPE (e_book_listener_get_type ()) -#define E_BOOK_LISTENER(o) (GTK_CHECK_CAST ((o), E_BOOK_LISTENER_TYPE, EBookListener)) -#define E_BOOK_LISTENER_CLASS(k) (GTK_CHECK_CLASS_CAST((k), E_BOOK_LISTENER_TYPE, EBookListenerClass)) -#define E_IS_BOOK_LISTENER(o) (GTK_CHECK_TYPE ((o), E_BOOK_LISTENER_TYPE)) -#define E_IS_BOOK_LISTENER_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), E_BOOK_LISTENER_TYPE)) - -END_GNOME_DECLS - -#endif /* ! __E_BOOK_LISTENER_H__ */ diff --git a/addressbook/backend/ebook/e-book-types.h b/addressbook/backend/ebook/e-book-types.h deleted file mode 100644 index 1d86a5bd4d..0000000000 --- a/addressbook/backend/ebook/e-book-types.h +++ /dev/null @@ -1,29 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * A client-side GtkObject which exposes the - * Evolution:BookListener interface. - * - * Author: - * Nat Friedman (nat@helixcode.com) - * - * Copyright 2000, Helix Code, Inc. - */ - -#ifndef __E_BOOK_TYPES_H__ -#define __E_BOOK_TYPES_H__ - -#include - -BEGIN_GNOME_DECLS - -typedef enum { - E_BOOK_STATUS_SUCCESS, - E_BOOK_STATUS_UNKNOWN, - E_BOOK_STATUS_REPOSITORY_OFFLINE, - E_BOOK_STATUS_PERMISSION_DENIED, - E_BOOK_STATUS_CARD_NOT_FOUND -} EBookStatus; - -END_GNOME_DECLS - -#endif /* ! __E_BOOK_TYPES_H__ */ diff --git a/addressbook/backend/ebook/e-book-view-listener.c b/addressbook/backend/ebook/e-book-view-listener.c deleted file mode 100644 index c84bf160c5..0000000000 --- a/addressbook/backend/ebook/e-book-view-listener.c +++ /dev/null @@ -1,345 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Exports the BookViewListener interface. Maintains a queue of messages - * which come in on the interface. - * - * Author: - * Nat Friedman (nat@helixcode.com) - * - * Copyright 2000, Helix Code, Inc. - */ - -#include -#include -#include "e-book-view-listener.h" -#include "e-book-view.h" -#include "e-card.h" - -enum { - RESPONSES_QUEUED, - LAST_SIGNAL -}; - -static guint e_book_view_listener_signals [LAST_SIGNAL]; - -static BonoboObjectClass *e_book_view_listener_parent_class; -POA_Evolution_BookViewListener__vepv e_book_view_listener_vepv; - -struct _EBookViewListenerPrivate { - GList *response_queue; - gint idle_id; -}; - -static gboolean -e_book_view_listener_check_queue (EBookViewListener *listener) -{ - if (listener->priv->response_queue != NULL) { - gtk_signal_emit (GTK_OBJECT (listener), - e_book_view_listener_signals [RESPONSES_QUEUED]); - } - - if (listener->priv->response_queue == NULL) { - listener->priv->idle_id = 0; - return FALSE; - } - - return TRUE; -} - -static void -e_book_view_listener_queue_response (EBookViewListener *listener, - EBookViewListenerResponse *response) -{ - listener->priv->response_queue = - g_list_append (listener->priv->response_queue, - response); - - if (listener->priv->idle_id == 0) { - listener->priv->idle_id = g_idle_add ( - (GSourceFunc) e_book_view_listener_check_queue, listener); - } -} - -/* Add, Remove, Modify */ -static void -e_book_view_listener_queue_id_event (EBookViewListener *listener, - EBookViewListenerOperation op, - const char *id) -{ - EBookViewListenerResponse *resp; - - resp = g_new0 (EBookViewListenerResponse, 1); - - resp->op = op; - resp->id = g_strdup (id); - resp->cards = NULL; - - e_book_view_listener_queue_response (listener, resp); -} - -/* Add, Remove, Modify */ -static void -e_book_view_listener_queue_sequence_event (EBookViewListener *listener, - EBookViewListenerOperation op, - const Evolution_VCardList *cards) -{ - EBookViewListenerResponse *resp; - int i; - - resp = g_new0 (EBookViewListenerResponse, 1); - - resp->op = op; - resp->id = NULL; - resp->cards = NULL; - - for ( i = 0; i < cards->_length; i++ ) { - resp->cards = g_list_append(resp->cards, e_card_new(cards->_buffer[i])); - } - - e_book_view_listener_queue_response (listener, resp); -} - -static void -impl_BookViewListener_signal_card_added (PortableServer_Servant servant, - const Evolution_VCardList *cards, - CORBA_Environment *ev) -{ - EBookViewListener *listener = E_BOOK_VIEW_LISTENER (bonobo_object_from_servant (servant)); - - e_book_view_listener_queue_sequence_event ( - listener, CardAddedEvent, cards); -} - -static void -impl_BookViewListener_signal_card_removed (PortableServer_Servant servant, - const Evolution_CardId id, - CORBA_Environment *ev) -{ - EBookViewListener *listener = E_BOOK_VIEW_LISTENER (bonobo_object_from_servant (servant)); - - e_book_view_listener_queue_id_event ( - listener, CardRemovedEvent, (const char *) id); -} - -static void -impl_BookViewListener_signal_card_changed (PortableServer_Servant servant, - const Evolution_VCardList *cards, - CORBA_Environment *ev) -{ - EBookViewListener *listener = E_BOOK_VIEW_LISTENER (bonobo_object_from_servant (servant)); - - e_book_view_listener_queue_sequence_event ( - listener, CardModifiedEvent, cards); -} - -/** - * e_book_view_listener_check_pending: - * @listener: the #EBookViewListener - * - * Returns: the number of items on the response queue, - * or -1 if the @listener is isn't an #EBookViewListener. - */ -int -e_book_view_listener_check_pending (EBookViewListener *listener) -{ - g_return_val_if_fail (listener != NULL, -1); - g_return_val_if_fail (E_IS_BOOK_VIEW_LISTENER (listener), -1); - - return g_list_length (listener->priv->response_queue); -} - -/** - * e_book_view_listener_pop_response: - * @listener: the #EBookViewListener for which a request is to be popped - * - * Returns: an #EBookViewListenerResponse if there are responses on the - * queue to be returned; %NULL if there aren't, or if the @listener - * isn't an EBookViewListener. - */ -EBookViewListenerResponse * -e_book_view_listener_pop_response (EBookViewListener *listener) -{ - EBookViewListenerResponse *resp; - GList *popped; - - g_return_val_if_fail (listener != NULL, NULL); - g_return_val_if_fail (E_IS_BOOK_VIEW_LISTENER (listener), NULL); - - if (listener->priv->response_queue == NULL) - return NULL; - - resp = listener->priv->response_queue->data; - - popped = listener->priv->response_queue; - listener->priv->response_queue = - g_list_remove_link (listener->priv->response_queue, - listener->priv->response_queue); - g_list_free_1 (popped); - - return resp; -} - -static EBookViewListener * -e_book_view_listener_construct (EBookViewListener *listener) -{ - POA_Evolution_BookViewListener *servant; - CORBA_Environment ev; - CORBA_Object obj; - - g_assert (listener != NULL); - g_assert (E_IS_BOOK_VIEW_LISTENER (listener)); - - servant = (POA_Evolution_BookViewListener *) g_new0 (BonoboObjectServant, 1); - servant->vepv = &e_book_view_listener_vepv; - - CORBA_exception_init (&ev); - - POA_Evolution_BookViewListener__init ((PortableServer_Servant) servant, &ev); - if (ev._major != CORBA_NO_EXCEPTION) { - g_free (servant); - CORBA_exception_free (&ev); - - return NULL; - } - - CORBA_exception_free (&ev); - - obj = bonobo_object_activate_servant (BONOBO_OBJECT (listener), servant); - if (obj == CORBA_OBJECT_NIL) { - g_free (servant); - - return NULL; - } - - bonobo_object_construct (BONOBO_OBJECT (listener), obj); - - return listener; -} - -/** - * e_book_view_listener_new: - * @book: the #EBookView for which the listener is to be bound - * - * Creates and returns a new #EBookViewListener for the book. - * - * Returns: a new #EBookViewListener - */ -EBookViewListener * -e_book_view_listener_new () -{ - EBookViewListener *listener; - EBookViewListener *retval; - - listener = gtk_type_new (E_BOOK_VIEW_LISTENER_TYPE); - - retval = e_book_view_listener_construct (listener); - - if (retval == NULL) { - g_warning ("e_book_view_listener_new: Error constructing " - "EBookViewListener!\n"); - gtk_object_unref (GTK_OBJECT (listener)); - return NULL; - } - - return retval; -} - -static void -e_book_view_listener_init (EBookViewListener *listener) -{ - listener->priv = g_new0 (EBookViewListenerPrivate, 1); - listener->priv->response_queue = NULL; - listener->priv->idle_id = 0; -} - -static void -e_book_view_listener_destroy (GtkObject *object) -{ - EBookViewListener *listener = E_BOOK_VIEW_LISTENER (object); - GList *l; - - for (l = listener->priv->response_queue; l != NULL; l = l->next) { - EBookViewListenerResponse *resp = l->data; - if (resp->id) - g_free(resp->id); - if (resp->cards) { - g_list_foreach(resp->cards, (GFunc) gtk_object_unref, NULL); - g_list_free(resp->cards); - } - g_free (resp); - } - g_list_free (listener->priv->response_queue); - - g_free (listener->priv); - - GTK_OBJECT_CLASS (e_book_view_listener_parent_class)->destroy (object); -} - -POA_Evolution_BookViewListener__epv * -e_book_view_listener_get_epv (void) -{ - POA_Evolution_BookViewListener__epv *epv; - - epv = g_new0 (POA_Evolution_BookViewListener__epv, 1); - - epv->signal_card_changed = impl_BookViewListener_signal_card_changed; - epv->signal_card_removed = impl_BookViewListener_signal_card_removed; - epv->signal_card_added = impl_BookViewListener_signal_card_added; - - return epv; -} - -static void -e_book_view_listener_corba_class_init (void) -{ - e_book_view_listener_vepv.Bonobo_Unknown_epv = bonobo_object_get_epv (); - e_book_view_listener_vepv.Evolution_BookViewListener_epv = e_book_view_listener_get_epv (); -} - -static void -e_book_view_listener_class_init (EBookViewListenerClass *klass) -{ - GtkObjectClass *object_class = (GtkObjectClass *) klass; - - e_book_view_listener_parent_class = gtk_type_class (bonobo_object_get_type ()); - - e_book_view_listener_signals [RESPONSES_QUEUED] = - gtk_signal_new ("responses_queued", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (EBookViewListenerClass, responses_queued), - gtk_marshal_NONE__NONE, - GTK_TYPE_NONE, 0); - - gtk_object_class_add_signals (object_class, e_book_view_listener_signals, LAST_SIGNAL); - - object_class->destroy = e_book_view_listener_destroy; - - e_book_view_listener_corba_class_init (); -} - -/** - * e_book_view_listener_get_type: - */ -GtkType -e_book_view_listener_get_type (void) -{ - static GtkType type = 0; - - if (! type) { - GtkTypeInfo info = { - "EBookViewListener", - sizeof (EBookViewListener), - sizeof (EBookViewListenerClass), - (GtkClassInitFunc) e_book_view_listener_class_init, - (GtkObjectInitFunc) e_book_view_listener_init, - NULL, /* reserved 1 */ - NULL, /* reserved 2 */ - (GtkClassInitFunc) NULL - }; - - type = gtk_type_unique (bonobo_object_get_type (), &info); - } - - return type; -} diff --git a/addressbook/backend/ebook/e-book-view-listener.h b/addressbook/backend/ebook/e-book-view-listener.h deleted file mode 100644 index 85542217df..0000000000 --- a/addressbook/backend/ebook/e-book-view-listener.h +++ /dev/null @@ -1,72 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * A client-side GtkObject which exposes the - * Evolution:BookViewListener interface. - * - * Author: - * Nat Friedman (nat@helixcode.com) - * - * Copyright 2000, Helix Code, Inc. - */ - -#ifndef __E_BOOK_VIEW_LISTENER_H__ -#define __E_BOOK_VIEW_LISTENER_H__ - -#include -#include -#include - -BEGIN_GNOME_DECLS - -typedef struct _EBookViewListener EBookViewListener; -typedef struct _EBookViewListenerClass EBookViewListenerClass; -typedef struct _EBookViewListenerPrivate EBookViewListenerPrivate; - -struct _EBookViewListener { - BonoboObject parent; - EBookViewListenerPrivate *priv; -}; - -struct _EBookViewListenerClass { - BonoboObjectClass parent; - - /* - * Signals - */ - void (*responses_queued) (void); -}; - -typedef enum { - /* Async events */ - CardAddedEvent, - CardRemovedEvent, - CardModifiedEvent -} EBookViewListenerOperation; - -typedef struct { - EBookViewListenerOperation op; - - /* For CardRemovedEvent */ - char *id; - - /* For Card[Added|Modified]Event */ - GList *cards; /* Of type ECard. */ - -} EBookViewListenerResponse; - -EBookViewListener *e_book_view_listener_new (void); -int e_book_view_listener_check_pending (EBookViewListener *listener); -EBookViewListenerResponse *e_book_view_listener_pop_response (EBookViewListener *listener); -GtkType e_book_view_listener_get_type (void); - -POA_Evolution_BookViewListener__epv *e_book_view_listener_get_epv (void); - -#define E_BOOK_VIEW_LISTENER_TYPE (e_book_view_listener_get_type ()) -#define E_BOOK_VIEW_LISTENER(o) (GTK_CHECK_CAST ((o), E_BOOK_VIEW_LISTENER_TYPE, EBookViewListener)) -#define E_BOOK_VIEW_LISTENER_CLASS(k) (GTK_CHECK_CLASS_CAST((k), E_BOOK_VIEW_LISTENER_TYPE, EBookViewListenerClass)) -#define E_IS_BOOK_VIEW_LISTENER(o) (GTK_CHECK_TYPE ((o), E_BOOK_VIEW_LISTENER_TYPE)) -#define E_IS_BOOK_VIEW_LISTENER_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), E_BOOK_VIEW_LISTENER_TYPE)) - -END_GNOME_DECLS - -#endif /* ! __E_BOOK_VIEW_LISTENER_H__ */ diff --git a/addressbook/backend/ebook/e-book-view.c b/addressbook/backend/ebook/e-book-view.c deleted file mode 100644 index db7e1b9e67..0000000000 --- a/addressbook/backend/ebook/e-book-view.c +++ /dev/null @@ -1,281 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * The Evolution addressbook client object. - * - * Author: - * Nat Friedman (nat@helixcode.com) - * - * Copyright 1999, 2000, Helix Code, Inc. - */ - -#include -#include -#include -#include -#include "addressbook.h" -#include "e-card-cursor.h" -#include "e-book-view-listener.h" -#include "e-book-view.h" - -GtkObjectClass *e_book_view_parent_class; - -struct _EBookViewPrivate { - Evolution_BookView corba_book_view; - - EBookViewListener *listener; - - int responses_queued_id; -}; - -enum { - CARD_CHANGED, - CARD_REMOVED, - CARD_ADDED, - LAST_SIGNAL -}; - -static guint e_book_view_signals [LAST_SIGNAL]; - -static void -e_book_view_do_added_event (EBookView *book_view, - EBookViewListenerResponse *resp) -{ - gtk_signal_emit (GTK_OBJECT (book_view), e_book_view_signals [CARD_ADDED], - resp->cards); - - g_list_foreach (resp->cards, (GFunc) gtk_object_unref, NULL); - g_list_free (resp->cards); -} - -static void -e_book_view_do_modified_event (EBookView *book_view, - EBookViewListenerResponse *resp) -{ - gtk_signal_emit (GTK_OBJECT (book_view), e_book_view_signals [CARD_CHANGED], - resp->cards); - - g_list_foreach (resp->cards, (GFunc) gtk_object_unref, NULL); - g_list_free (resp->cards); -} - -static void -e_book_view_do_removed_event (EBookView *book_view, - EBookViewListenerResponse *resp) -{ - gtk_signal_emit (GTK_OBJECT (book_view), e_book_view_signals [CARD_REMOVED], - resp->id); - - g_free(resp->id); -} - - -/* - * Reading notices out of the EBookViewListener's queue. - */ -static void -e_book_view_check_listener_queue (EBookViewListener *listener, EBookView *book_view) -{ - EBookViewListenerResponse *resp; - - resp = e_book_view_listener_pop_response (listener); - - if (resp == NULL) - return; - - switch (resp->op) { - case CardAddedEvent: - e_book_view_do_added_event (book_view, resp); - break; - case CardModifiedEvent: - e_book_view_do_modified_event (book_view, resp); - break; - case CardRemovedEvent: - e_book_view_do_removed_event (book_view, resp); - break; - default: - g_error ("EBookView: Unknown operation %d in listener queue!\n", - resp->op); - } - - g_free (resp); -} - -static gboolean -e_book_view_construct (EBookView *book_view, Evolution_BookView corba_book_view, EBookViewListener *listener) -{ - CORBA_Environment ev; - g_return_val_if_fail (book_view != NULL, FALSE); - g_return_val_if_fail (E_IS_BOOK_VIEW (book_view), FALSE); - - /* - * Copy in the corba_book_view. - */ - CORBA_exception_init (&ev); - - book_view->priv->corba_book_view = CORBA_Object_duplicate(corba_book_view, &ev); - - if (ev._major != CORBA_NO_EXCEPTION) { - g_warning ("e_book_view_construct: Exception duplicating corba_book_view.\n"); - CORBA_exception_free (&ev); - return FALSE; - } - - Evolution_BookView_ref(book_view->priv->corba_book_view, &ev); - - if (ev._major != CORBA_NO_EXCEPTION) { - g_warning ("e_book_view_construct: Exception reffing corba_book_view.\n"); - CORBA_exception_free (&ev); - CORBA_exception_init (&ev); - CORBA_Object_release (book_view->priv->corba_book_view, &ev); - if (ev._major != CORBA_NO_EXCEPTION) { - g_warning ("e_book_view_construct: Exception releasing corba_book_view.\n"); - } - CORBA_exception_free (&ev); - book_view->priv->corba_book_view = NULL; - return FALSE; - } - - CORBA_exception_free (&ev); - - /* - * Create our local BookListener interface. - */ - book_view->priv->listener = listener; - - bonobo_object_ref(BONOBO_OBJECT(book_view->priv->listener)); - book_view->priv->responses_queued_id = gtk_signal_connect (GTK_OBJECT (book_view->priv->listener), "responses_queued", - e_book_view_check_listener_queue, book_view); - - return TRUE; -} - -/** - * e_book_view_new: - */ -EBookView * -e_book_view_new (Evolution_BookView corba_book_view, EBookViewListener *listener) -{ - EBookView *book_view; - - book_view = gtk_type_new (E_BOOK_VIEW_TYPE); - - if (! e_book_view_construct (book_view, corba_book_view, listener)) { - gtk_object_unref (GTK_OBJECT (book_view)); - return NULL; - } - - return book_view; -} - -static void -e_book_view_init (EBookView *book_view) -{ - book_view->priv = g_new0 (EBookViewPrivate, 1); - book_view->priv->corba_book_view = CORBA_OBJECT_NIL; - book_view->priv->listener = NULL; - book_view->priv->responses_queued_id = 0; -} - -static void -e_book_view_destroy (GtkObject *object) -{ - EBookView *book_view = E_BOOK_VIEW (object); - CORBA_Environment ev; - - if (book_view->priv->corba_book_view) { - CORBA_exception_init (&ev); - - Evolution_BookView_unref(book_view->priv->corba_book_view, &ev); - if (ev._major != CORBA_NO_EXCEPTION) { - g_warning ("EBookView: Exception while unreffing BookView\n"); - - CORBA_exception_free (&ev); - CORBA_exception_init (&ev); - } - - CORBA_Object_release (book_view->priv->corba_book_view, &ev); - if (ev._major != CORBA_NO_EXCEPTION) { - g_warning ("EBookView: Exception while releasing BookView\n"); - } - - CORBA_exception_free (&ev); - } - - if (book_view->priv->listener) { - if (book_view->priv->responses_queued_id) - gtk_signal_disconnect(GTK_OBJECT(book_view->priv->listener), - book_view->priv->responses_queued_id); - bonobo_object_unref (BONOBO_OBJECT(book_view->priv->listener)); - } - - g_free (book_view->priv); - - if (GTK_OBJECT_CLASS (e_book_view_parent_class)->destroy) - GTK_OBJECT_CLASS (e_book_view_parent_class)->destroy (object); -} - -static void -e_book_view_class_init (EBookViewClass *klass) -{ - GtkObjectClass *object_class = (GtkObjectClass *) klass; - - e_book_view_parent_class = gtk_type_class (gtk_object_get_type ()); - - e_book_view_signals [CARD_CHANGED] = - gtk_signal_new ("card_changed", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (EBookViewClass, card_changed), - gtk_marshal_NONE__POINTER, - GTK_TYPE_NONE, 1, - GTK_TYPE_POINTER); - - e_book_view_signals [CARD_ADDED] = - gtk_signal_new ("card_added", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (EBookViewClass, card_added), - gtk_marshal_NONE__STRING, - GTK_TYPE_NONE, 1, - GTK_TYPE_STRING); - - e_book_view_signals [CARD_REMOVED] = - gtk_signal_new ("card_removed", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (EBookViewClass, card_removed), - gtk_marshal_NONE__POINTER, - GTK_TYPE_NONE, 1, - GTK_TYPE_POINTER); - - gtk_object_class_add_signals (object_class, e_book_view_signals, - LAST_SIGNAL); - - object_class->destroy = e_book_view_destroy; -} - -/** - * e_book_view_get_type: - */ -GtkType -e_book_view_get_type (void) -{ - static GtkType type = 0; - - if (! type) { - GtkTypeInfo info = { - "EBookView", - sizeof (EBookView), - sizeof (EBookViewClass), - (GtkClassInitFunc) e_book_view_class_init, - (GtkObjectInitFunc) e_book_view_init, - NULL, /* reserved 1 */ - NULL, /* reserved 2 */ - (GtkClassInitFunc) NULL - }; - - type = gtk_type_unique (gtk_object_get_type (), &info); - } - - return type; -} diff --git a/addressbook/backend/ebook/e-book-view.h b/addressbook/backend/ebook/e-book-view.h deleted file mode 100644 index 5ae20e1521..0000000000 --- a/addressbook/backend/ebook/e-book-view.h +++ /dev/null @@ -1,55 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * The Evolution addressbook client object. - * - * Author: - * Nat Friedman (nat@helixcode.com) - * - * Copyright 1999, 2000, Helix Code, Inc. - */ - -#ifndef __E_BOOK_VIEW_H__ -#define __E_BOOK_VIEW_H__ - -#include - -#include -#include - -BEGIN_GNOME_DECLS - -typedef struct _EBookView EBookView; -typedef struct _EBookViewClass EBookViewClass; -typedef struct _EBookViewPrivate EBookViewPrivate; - -struct _EBookView { - GtkObject parent; - EBookViewPrivate *priv; -}; - -struct _EBookViewClass { - GtkObjectClass parent; - - /* - * Signals. - */ - void (* card_changed) (EBookView *book_view, const GList *cards); - void (* card_removed) (EBookView *book_view, const char *id); - void (* card_added) (EBookView *book_view, const GList *cards); -}; - -/* Creating a new addressbook. */ -EBookView *e_book_view_new (Evolution_BookView corba_book_view, EBookViewListener *listener); - -GtkType e_book_view_get_type (void); -void e_book_view_get_book_view_listener (EBookView *book_view); - -#define E_BOOK_VIEW_TYPE (e_book_view_get_type ()) -#define E_BOOK_VIEW(o) (GTK_CHECK_CAST ((o), E_BOOK_VIEW_TYPE, EBookView)) -#define E_BOOK_VIEW_CLASS(k) (GTK_CHECK_CLASS_CAST((k), E_BOOK_VIEW_TYPE, EBookViewClass)) -#define E_IS_BOOK_VIEW(o) (GTK_CHECK_TYPE ((o), E_BOOK_VIEW_TYPE)) -#define E_IS_BOOK_VIEW_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), E_BOOK_VIEW_TYPE)) - -END_GNOME_DECLS - -#endif /* ! __E_BOOK_VIEW_H__ */ diff --git a/addressbook/backend/ebook/e-book.c b/addressbook/backend/ebook/e-book.c deleted file mode 100644 index 1b6411ae0a..0000000000 --- a/addressbook/backend/ebook/e-book.c +++ /dev/null @@ -1,999 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * The Evolution addressbook client object. - * - * Author: - * Nat Friedman (nat@helixcode.com) - * - * Copyright 1999, 2000, Helix Code, Inc. - */ - -#include -#include -#include -#include -#include "addressbook.h" -#include "e-card-cursor.h" -#include "e-book-listener.h" -#include "e-book.h" - -GtkObjectClass *e_book_parent_class; - -#define CARDSERVER_GOAD_ID "evolution:addressbook-server" - -typedef enum { - URINotLoaded, - URILoading, - URILoaded -} EBookLoadState; - -struct _EBookPrivate { - Evolution_BookFactory book_factory; - EBookListener *listener; - - Evolution_Book corba_book; - - EBookLoadState load_state; - - /* - * The operation queue. New operations are appended to the - * end of the queue. When responses come back from the PAS, - * the op structures are popped off the front of the queue. - */ - GList *pending_ops; -}; - -enum { - OPEN_PROGRESS, - LINK_STATUS, - LAST_SIGNAL -}; - -static guint e_book_signals [LAST_SIGNAL]; - -typedef struct { - gpointer cb; - gpointer closure; - EBookViewListener *listener; -} EBookOp; - -/* - * Local response queue management. - */ -static void -e_book_queue_op (EBook *book, - gpointer cb, - gpointer closure, - EBookViewListener *listener) -{ - EBookOp *op; - - op = g_new0 (EBookOp, 1); - op->cb = cb; - op->closure = closure; - op->listener = listener; - - book->priv->pending_ops = - g_list_append (book->priv->pending_ops, op); -} - -static EBookOp * -e_book_pop_op (EBook *book) -{ - GList *popped; - EBookOp *op; - - if (book->priv->pending_ops == NULL) - return NULL; - - op = book->priv->pending_ops->data; - - popped = book->priv->pending_ops; - book->priv->pending_ops = - g_list_remove_link (book->priv->pending_ops, - book->priv->pending_ops); - - g_list_free_1 (popped); - - return op; -} - -static void -e_book_do_response_create_card (EBook *book, - EBookListenerResponse *resp) -{ - EBookOp *op; - - op = e_book_pop_op (book); - - if (op == NULL) { - g_warning ("e_book_do_response_create_card: Cannot find operation " - "in local op queue!\n"); - return; - } - - ((EBookIdCallback) op->cb) (book, resp->status, resp->id, op->closure); - g_free (resp->id); - g_free (op); -} - -static void -e_book_do_response_generic (EBook *book, - EBookListenerResponse *resp) -{ - EBookOp *op; - - op = e_book_pop_op (book); - - if (op == NULL) { - g_warning ("e_book_do_response_generic: Cannot find operation " - "in local op queue!\n"); - } - - ((EBookCallback) op->cb) (book, resp->status, op->closure); - - g_free (op); -} - -static void -e_book_do_response_get_cursor (EBook *book, - EBookListenerResponse *resp) -{ - CORBA_Environment ev; - EBookOp *op; - ECardCursor *cursor; - - op = e_book_pop_op (book); - - if (op == NULL) { - g_warning ("e_book_do_response_get_cursor: Cannot find operation " - "in local op queue!\n"); - return; - } - - cursor = e_card_cursor_new(resp->cursor); - - ((EBookCursorCallback) op->cb) (book, resp->status, cursor, op->closure); - - /* - * Release the remote Evolution_Book in the PAS. - */ - CORBA_exception_init (&ev); - - Bonobo_Unknown_unref (resp->cursor, &ev); - - if (ev._major != CORBA_NO_EXCEPTION) { - g_warning ("e_book_do_response_get_cursor: Exception unref'ing " - "remote Evolution_CardCursor interface!\n"); - CORBA_exception_free (&ev); - CORBA_exception_init (&ev); - } - - CORBA_Object_release (resp->cursor, &ev); - - if (ev._major != CORBA_NO_EXCEPTION) { - g_warning ("e_book_do_response_get_cursor: Exception releasing " - "remote Evolution_CardCursor interface!\n"); - } - - CORBA_exception_free (&ev); - - gtk_object_unref(GTK_OBJECT(cursor)); - - g_free (op); -} - -static void -e_book_do_response_get_view (EBook *book, - EBookListenerResponse *resp) -{ - CORBA_Environment ev; - EBookOp *op; - EBookView *book_view; - - op = e_book_pop_op (book); - - if (op == NULL) { - g_warning ("e_book_do_response_get_view: Cannot find operation " - "in local op queue!\n"); - return; - } - - book_view = e_book_view_new(resp->book_view, op->listener); - - ((EBookBookViewCallback) op->cb) (book, resp->status, book_view, op->closure); - - /* - * Release the remote Evolution_Book in the PAS. - */ - CORBA_exception_init (&ev); - - Bonobo_Unknown_unref (resp->book_view, &ev); - - if (ev._major != CORBA_NO_EXCEPTION) { - g_warning ("e_book_do_response_get_view: Exception unref'ing " - "remote Evolution_BookView interface!\n"); - CORBA_exception_free (&ev); - CORBA_exception_init (&ev); - } - - CORBA_Object_release (resp->book_view, &ev); - - if (ev._major != CORBA_NO_EXCEPTION) { - g_warning ("e_book_do_response_get_view: Exception releasing " - "remote Evolution_BookView interface!\n"); - } - - CORBA_exception_free (&ev); - - gtk_object_unref(GTK_OBJECT(book_view)); - bonobo_object_unref(BONOBO_OBJECT(op->listener)); - - g_free (op); -} - -static void -e_book_do_response_open (EBook *book, - EBookListenerResponse *resp) -{ - EBookOp *op; - - if (resp->status == E_BOOK_STATUS_SUCCESS) { - book->priv->corba_book = resp->book; - book->priv->load_state = URILoaded; - } - - op = e_book_pop_op (book); - - if (op == NULL) { - g_warning ("e_book_do_response_open: Cannot find operation " - "in local op queue!\n"); - return; - } - - ((EBookCallback) op->cb) (book, resp->status, op->closure); - g_free (op); -} - -static void -e_book_do_progress_event (EBook *book, - EBookListenerResponse *resp) -{ - gtk_signal_emit (GTK_OBJECT (book), e_book_signals [OPEN_PROGRESS], - resp->msg, resp->percent); - - g_free (resp->msg); -} - -static void -e_book_do_link_event (EBook *book, - EBookListenerResponse *resp) -{ - gtk_signal_emit (GTK_OBJECT (book), e_book_signals [LINK_STATUS], - resp->connected); -} - - -/* - * Reading notices out of the EBookListener's queue. - */ -static void -e_book_check_listener_queue (EBookListener *listener, EBook *book) -{ - EBookListenerResponse *resp; - - resp = e_book_listener_pop_response (listener); - - if (resp == NULL) - return; - - switch (resp->op) { - case CreateCardResponse: - e_book_do_response_create_card (book, resp); - break; - case RemoveCardResponse: - case ModifyCardResponse: - e_book_do_response_generic (book, resp); - break; - case GetCursorResponse: - e_book_do_response_get_cursor (book, resp); - break; - case GetBookViewResponse: - e_book_do_response_get_view(book, resp); - break; - case OpenBookResponse: - e_book_do_response_open (book, resp); - break; - - case OpenProgressEvent: - e_book_do_progress_event (book, resp); - break; - case LinkStatusEvent: - e_book_do_link_event (book, resp); - break; - default: - g_error ("EBook: Unknown operation %d in listener queue!\n", - resp->op); - } - - g_free (resp); -} - -/** - * e_book_load_uri: - */ -gboolean -e_book_load_uri (EBook *book, - const char *uri, - EBookCallback open_response, - gpointer closure) -{ - CORBA_Environment ev; - - g_return_val_if_fail (book != NULL, FALSE); - g_return_val_if_fail (E_IS_BOOK (book), FALSE); - g_return_val_if_fail (uri != NULL, FALSE); - g_return_val_if_fail (open_response != NULL, FALSE); - - if (book->priv->load_state != URINotLoaded) { - g_warning ("e_book_load_uri: Attempted to load a URI " - "on a book which already has a URI loaded!\n"); - return FALSE; - } - - /* - * Load the addressbook into the PAS. - */ - CORBA_exception_init (&ev); - - Evolution_BookFactory_open_book ( - book->priv->book_factory, uri, - bonobo_object_corba_objref (BONOBO_OBJECT (book->priv->listener)), - &ev); - - if (ev._major != CORBA_NO_EXCEPTION) { - g_warning ("e_book_load_uri: CORBA exception while opening addressbook!\n"); - CORBA_exception_free (&ev); - return FALSE; - } - - CORBA_exception_free (&ev); - - book->priv->load_state = URILoading; - - e_book_queue_op (book, open_response, closure, NULL); - - /* Now we play the waiting game. */ - - return TRUE; -} - -/** - * e_book_unload_uri: - */ -void -e_book_unload_uri (EBook *book) -{ - CORBA_Environment ev; - - g_return_if_fail (book != NULL); - g_return_if_fail (E_IS_BOOK (book)); - - /* - * FIXME: Make sure this works if the URI is still being - * loaded. - */ - if (book->priv->load_state == URINotLoaded) { - g_warning ("e_book_unload_uri: No URI is loaded!\n"); - return; - } - - /* - * Release the remote Evolution_Book in the PAS. - */ - CORBA_exception_init (&ev); - - Bonobo_Unknown_unref (book->priv->corba_book, &ev); - - if (ev._major != CORBA_NO_EXCEPTION) { - g_warning ("e_book_unload_uri: Exception unref'ing " - "remote Evolution_Book interface!\n"); - CORBA_exception_free (&ev); - CORBA_exception_init (&ev); - } - - CORBA_Object_release (book->priv->corba_book, &ev); - - if (ev._major != CORBA_NO_EXCEPTION) { - g_warning ("e_book_unload_uri: Exception releasing " - "remote book interface!\n"); - } - - CORBA_exception_free (&ev); - - bonobo_object_unref (BONOBO_OBJECT (book->priv->listener)); - - book->priv->listener = NULL; - book->priv->load_state = URINotLoaded; -} - -static gboolean -e_book_construct (EBook *book) -{ - g_return_val_if_fail (book != NULL, FALSE); - g_return_val_if_fail (E_IS_BOOK (book), FALSE); - - /* - * Connect to the Personal Addressbook Server. - */ - book->priv->book_factory = (Evolution_BookFactory) - goad_server_activate_with_id (NULL, CARDSERVER_GOAD_ID, 0, NULL); - - if (book->priv->book_factory == CORBA_OBJECT_NIL) { - g_warning ("e_book_construct: Could not obtain a handle " - "to the Personal Addressbook Server!\n"); - return FALSE; - } - - /* - * Create our local BookListener interface. - */ - book->priv->listener = e_book_listener_new (); - if (book->priv->listener == NULL) { - g_warning ("e_book_construct: Could not create EBookListener!\n"); - return FALSE; - } - - gtk_signal_connect (GTK_OBJECT (book->priv->listener), "responses_queued", - e_book_check_listener_queue, book); - - return TRUE; -} - -/** - * e_book_new: - */ -EBook * -e_book_new (void) -{ - EBook *book; - - book = gtk_type_new (E_BOOK_TYPE); - - if (! e_book_construct (book)) { - gtk_object_unref (GTK_OBJECT (book)); - return NULL; - } - - return book; -} - -/* Fetching cards */ - -/** - * e_book_get_card: - */ -ECard * -e_book_get_card (EBook *book, - const char *id) -{ - char *vcard; - ECard *card; - - g_return_val_if_fail (book != NULL, NULL); - g_return_val_if_fail (E_IS_BOOK (book), NULL); - - if (book->priv->load_state != URILoaded) { - g_warning ("e_book_get_card: No URI loaded!\n"); - return NULL; - } - - vcard = e_book_get_vcard (book, id); - - if (vcard == NULL) { - g_warning ("e_book_get_card: Got bogus VCard from PAS!\n"); - return NULL; - } - - card = e_card_new (vcard); - g_free(vcard); - - e_card_set_id(card, id); - - return card; -} - -/** - * e_book_get_vcard: - */ -char * -e_book_get_vcard (EBook *book, - const char *id) -{ - CORBA_Environment ev; - char *retval; - char *vcard; - - g_return_val_if_fail (book != NULL, NULL); - g_return_val_if_fail (E_IS_BOOK (book), NULL); - - if (book->priv->load_state != URILoaded) { - g_warning ("e_book_get_vcard: No URI loaded!\n"); - return NULL; - } - - CORBA_exception_init (&ev); - - vcard = Evolution_Book_get_vcard (book->priv->corba_book, - (Evolution_CardId) id, - &ev); - - if (ev._major != CORBA_NO_EXCEPTION) { - g_warning ("e_book_get_vcard: Exception getting VCard from PAS!\n"); - CORBA_exception_free (&ev); - return NULL; - } - - CORBA_exception_free (&ev); - - if (vcard == NULL || strlen (vcard) == 0) { - g_warning ("e_book_get_vcard: Got NULL VCard from PAS!\n"); - return NULL; - } - - retval = g_strdup (vcard); - CORBA_free (vcard); - - return retval; -} - -/* Deleting cards. */ - -/** - * e_book_remove_card: - */ -gboolean -e_book_remove_card (EBook *book, - ECard *card, - EBookCallback cb, - gpointer closure) -{ - const char *id; - - g_return_val_if_fail (book != NULL, FALSE); - g_return_val_if_fail (E_IS_BOOK (book), FALSE); - g_return_val_if_fail (card != NULL, FALSE); - g_return_val_if_fail (E_IS_CARD (card), FALSE); - g_return_val_if_fail (cb != NULL, FALSE); - - if (book->priv->load_state != URILoaded) { - g_warning ("e_book_remove_card: No URI loaded!\n"); - return FALSE; - } - - id = e_card_get_id (card); - g_assert (id != NULL); - - return e_book_remove_card_by_id (book, id, cb, closure); -} - -/** - * e_book_remove_card_by_id: - */ -gboolean -e_book_remove_card_by_id (EBook *book, - const char *id, - EBookCallback cb, - gpointer closure) - -{ - CORBA_Environment ev; - - g_return_val_if_fail (book != NULL, FALSE); - g_return_val_if_fail (E_IS_BOOK (book), FALSE); - g_return_val_if_fail (id != NULL, FALSE); - g_return_val_if_fail (cb != NULL, FALSE); - - if (book->priv->load_state != URILoaded) { - g_warning ("e_book_remove_card_by_id: No URI loaded!\n"); - return FALSE; - } - - CORBA_exception_init (&ev); - - Evolution_Book_remove_card ( - book->priv->corba_book, (const Evolution_CardId) id, &ev); - - if (ev._major != CORBA_NO_EXCEPTION) { - g_warning ("e_book_remove_card_by_id: CORBA exception " - "talking to PAS!\n"); - CORBA_exception_free (&ev); - return FALSE; - } - - CORBA_exception_free (&ev); - - e_book_queue_op (book, cb, closure, NULL); - - return TRUE; -} - -/* Adding cards. */ - -/** - * e_book_add_card: - */ -gboolean -e_book_add_card (EBook *book, - ECard *card, - EBookIdCallback cb, - gpointer closure) - -{ - char *vcard; - gboolean retval; - - g_return_val_if_fail (book != NULL, FALSE); - g_return_val_if_fail (E_IS_BOOK (book), FALSE); - g_return_val_if_fail (card != NULL, FALSE); - g_return_val_if_fail (E_IS_CARD (card), FALSE); - g_return_val_if_fail (cb != NULL, FALSE); - - if (book->priv->load_state != URILoaded) { - g_warning ("e_book_add_card: No URI loaded!\n"); - return FALSE; - } - - vcard = e_card_get_vcard (card); - - if (vcard == NULL) { - g_warning ("e_book_add_card: Cannot convert card to VCard string!\n"); - return FALSE; - } - - retval = e_book_add_vcard (book, vcard, cb, closure); - - g_free (vcard); - - return retval; -} - -/** - * e_book_add_vcard: - */ -gboolean -e_book_add_vcard (EBook *book, - const char *vcard, - EBookIdCallback cb, - gpointer closure) -{ - CORBA_Environment ev; - - g_return_val_if_fail (book != NULL, FALSE); - g_return_val_if_fail (E_IS_BOOK (book), FALSE); - g_return_val_if_fail (vcard != NULL, FALSE); - g_return_val_if_fail (cb != NULL, FALSE); - - if (book->priv->load_state != URILoaded) { - g_warning ("e_book_add_vcard: No URI loaded!\n"); - return FALSE; - } - - CORBA_exception_init (&ev); - - Evolution_Book_create_card ( - book->priv->corba_book, (const Evolution_VCard) vcard, &ev); - - if (ev._major != CORBA_NO_EXCEPTION) { - g_warning ("e_book_add_vcard: Exception adding card to PAS!\n"); - CORBA_exception_free (&ev); - return FALSE; - } - - CORBA_exception_free (&ev); - - e_book_queue_op (book, (EBookCallback) cb, closure, NULL); - - return TRUE; -} - -/* Modifying cards. */ - -/** - * e_book_commit_card: - */ -gboolean -e_book_commit_card (EBook *book, - ECard *card, - EBookCallback cb, - gpointer closure) -{ - char *vcard; - gboolean retval; - - g_return_val_if_fail (book != NULL, FALSE); - g_return_val_if_fail (E_IS_BOOK (book), FALSE); - g_return_val_if_fail (card != NULL, FALSE); - g_return_val_if_fail (E_IS_CARD (card), FALSE); - g_return_val_if_fail (cb != NULL, FALSE); - - if (book->priv->load_state != URILoaded) { - g_warning ("e_book_commit_card: No URI loaded!\n"); - return FALSE; - } - - vcard = e_card_get_vcard (card); - - if (vcard == NULL) { - g_warning ("e_book_commit_card: Error " - "getting VCard for card!\n"); - return FALSE; - } - - retval = e_book_commit_vcard (book, vcard, cb, closure); - - g_free (vcard); - - return retval; -} - -/** - * e_book_commit_vcard: - */ -gboolean -e_book_commit_vcard (EBook *book, - const char *vcard, - EBookCallback cb, - gpointer closure) -{ - CORBA_Environment ev; - - g_return_val_if_fail (book != NULL, FALSE); - g_return_val_if_fail (E_IS_BOOK (book), FALSE); - g_return_val_if_fail (vcard != NULL, FALSE); - g_return_val_if_fail (cb != NULL, FALSE); - - if (book->priv->load_state != URILoaded) { - g_warning ("e_book_commit_vcard: No URI loaded!\n"); - return FALSE; - } - - CORBA_exception_init (&ev); - - Evolution_Book_modify_card ( - book->priv->corba_book, (const Evolution_VCard) vcard, &ev); - - if (ev._major != CORBA_NO_EXCEPTION) { - g_warning ("e_book_commit_vcard: Exception " - "modifying card in PAS!\n"); - CORBA_exception_free (&ev); - return FALSE; - } - - CORBA_exception_free (&ev); - - e_book_queue_op (book, cb, closure, NULL); - - return TRUE; -} - -/** - * e_book_check_connection: - */ -gboolean -e_book_check_connection (EBook *book) -{ - CORBA_Environment ev; - - g_return_val_if_fail (book != NULL, FALSE); - g_return_val_if_fail (E_IS_BOOK (book), FALSE); - - if (book->priv->load_state != URILoaded) { - g_warning ("e_book_check_connection: No URI loaded!\n"); - return FALSE; - } - - CORBA_exception_init (&ev); - - Evolution_Book_check_connection (book->priv->corba_book, &ev); - - if (ev._major != CORBA_NO_EXCEPTION) { - g_warning ("e_book_check_connection: Exception " - "querying the PAS!\n"); - CORBA_exception_free (&ev); - return FALSE; - } - - CORBA_exception_free (&ev); - - return TRUE; -} - -gboolean e_book_get_cursor (EBook *book, - gchar *query, - EBookCursorCallback cb, - gpointer closure) -{ - CORBA_Environment ev; - - g_return_val_if_fail (book != NULL, FALSE); - g_return_val_if_fail (E_IS_BOOK (book), FALSE); - - if (book->priv->load_state != URILoaded) { - g_warning ("e_book_check_connection: No URI loaded!\n"); - return FALSE; - } - - CORBA_exception_init (&ev); - - Evolution_Book_get_cursor (book->priv->corba_book, query, &ev); - - if (ev._major != CORBA_NO_EXCEPTION) { - g_warning ("e_book_get_all_cards: Exception " - "querying list of cards!\n"); - CORBA_exception_free (&ev); - return FALSE; - } - - CORBA_exception_free (&ev); - - e_book_queue_op (book, cb, closure, NULL); - - return TRUE; -} - -gboolean e_book_get_book_view (EBook *book, - gchar *query, - EBookBookViewCallback cb, - gpointer closure) -{ - CORBA_Environment ev; - EBookViewListener *listener; - - g_return_val_if_fail (book != NULL, FALSE); - g_return_val_if_fail (E_IS_BOOK (book), FALSE); - - if (book->priv->load_state != URILoaded) { - g_warning ("e_book_get_book_view: No URI loaded!\n"); - return FALSE; - } - - listener = e_book_view_listener_new(); - - CORBA_exception_init (&ev); - - Evolution_Book_get_book_view (book->priv->corba_book, bonobo_object_corba_objref(BONOBO_OBJECT(listener)), query, &ev); - - if (ev._major != CORBA_NO_EXCEPTION) { - g_warning ("e_book_get_book_view: Exception " - "getting book_view!\n"); - CORBA_exception_free (&ev); - return FALSE; - } - - CORBA_exception_free (&ev); - - e_book_queue_op (book, cb, closure, listener); - - return TRUE; -} - -/** - * e_book_get_name: - */ -char * -e_book_get_name (EBook *book) -{ - CORBA_Environment ev; - char *retval; - char *name; - - g_return_val_if_fail (book != NULL, NULL); - g_return_val_if_fail (E_IS_BOOK (book), NULL); - - if (book->priv->load_state != URILoaded) { - g_warning ("e_book_get_name: No URI loaded!\n"); - return NULL; - } - - CORBA_exception_init (&ev); - - name = Evolution_Book_get_name (book->priv->corba_book, &ev); - - if (ev._major != CORBA_NO_EXCEPTION) { - g_warning ("e_book_get_name: Exception getting name from PAS!\n"); - CORBA_exception_free (&ev); - return NULL; - } - - CORBA_exception_free (&ev); - - if (name == NULL) { - g_warning ("e_book_get_name: Got NULL name from PAS!\n"); - return NULL; - } - - retval = g_strdup (name); - CORBA_free (name); - - return retval; -} - -static void -e_book_init (EBook *book) -{ - book->priv = g_new0 (EBookPrivate, 1); - book->priv->load_state = URINotLoaded; -} - -static void -e_book_destroy (GtkObject *object) -{ - EBook *book = E_BOOK (object); - CORBA_Environment ev; - - if (book->priv->load_state != URINotLoaded) - e_book_unload_uri (book); - - CORBA_exception_init (&ev); - - CORBA_Object_release (book->priv->book_factory, &ev); - if (ev._major != CORBA_NO_EXCEPTION) { - g_warning ("EBook: Exception while releasing BookFactory\n"); - - CORBA_exception_free (&ev); - CORBA_exception_init (&ev); - } - - g_free (book->priv); - - GTK_OBJECT_CLASS (e_book_parent_class)->destroy (object); -} - -static void -e_book_class_init (EBookClass *klass) -{ - GtkObjectClass *object_class = (GtkObjectClass *) klass; - - e_book_parent_class = gtk_type_class (gtk_object_get_type ()); - - e_book_signals [LINK_STATUS] = - gtk_signal_new ("link_status", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (EBookClass, link_status), - gtk_marshal_NONE__BOOL, - GTK_TYPE_NONE, 1, - GTK_TYPE_BOOL); - - gtk_object_class_add_signals (object_class, e_book_signals, - LAST_SIGNAL); - - object_class->destroy = e_book_destroy; -} - -/** - * e_book_get_type: - */ -GtkType -e_book_get_type (void) -{ - static GtkType type = 0; - - if (! type) { - GtkTypeInfo info = { - "EBook", - sizeof (EBook), - sizeof (EBookClass), - (GtkClassInitFunc) e_book_class_init, - (GtkObjectInitFunc) e_book_init, - NULL, /* reserved 1 */ - NULL, /* reserved 2 */ - (GtkClassInitFunc) NULL - }; - - type = gtk_type_unique (gtk_object_get_type (), &info); - } - - return type; -} diff --git a/addressbook/backend/ebook/e-book.h b/addressbook/backend/ebook/e-book.h deleted file mode 100644 index 4cab606239..0000000000 --- a/addressbook/backend/ebook/e-book.h +++ /dev/null @@ -1,123 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * The Evolution addressbook client object. - * - * Author: - * Nat Friedman (nat@helixcode.com) - * - * Copyright 1999, 2000, Helix Code, Inc. - */ - -#ifndef __E_BOOK_H__ -#define __E_BOOK_H__ - -#include - -#include -#include -#include -#include - -BEGIN_GNOME_DECLS - -typedef struct _EBook EBook; -typedef struct _EBookClass EBookClass; -typedef struct _EBookPrivate EBookPrivate; - -struct _EBook { - GtkObject parent; - EBookPrivate *priv; -}; - -struct _EBookClass { - GtkObjectClass parent; - - /* - * Signals. - */ - void (* open_progress) (EBook *book, const char *msg, short percent); - void (* link_status) (EBook *book, gboolean connected); -}; - -/* Callbacks for asynchronous functions. */ -typedef void (*EBookCallback) (EBook *book, EBookStatus status, gpointer closure); -typedef void (*EBookOpenProgressCallback) (EBook *book, - const char *status_message, - short percent, - gpointer closure); -typedef void (*EBookIdCallback) (EBook *book, EBookStatus status, const char *id, gpointer closure); -typedef void (*EBookCursorCallback) (EBook *book, EBookStatus status, ECardCursor *cursor, gpointer closure); -typedef void (*EBookBookViewCallback) (EBook *book, EBookStatus status, EBookView *book_view, gpointer closure); - - -/* Creating a new addressbook. */ -EBook *e_book_new (void); -gboolean e_book_load_uri (EBook *book, - const char *uri, - EBookCallback open_response, - gpointer closure); -void e_book_unload_uri (EBook *book); - -/* Fetching cards. */ -ECard *e_book_get_card (EBook *book, - const char *id); -char *e_book_get_vcard (EBook *book, - const char *id); - -/* Deleting cards. */ -gboolean e_book_remove_card (EBook *book, - ECard *card, - EBookCallback cb, - gpointer closure); -gboolean e_book_remove_card_by_id (EBook *book, - const char *id, - EBookCallback cb, - gpointer closure); - -/* Adding cards. */ -gboolean e_book_add_card (EBook *book, - ECard *card, - EBookIdCallback cb, - gpointer closure); -gboolean e_book_add_vcard (EBook *book, - const char *vcard, - EBookIdCallback cb, - gpointer closure); - -/* Modifying cards. */ -gboolean e_book_commit_card (EBook *book, - ECard *card, - EBookCallback cb, - gpointer closure); -gboolean e_book_commit_vcard (EBook *book, - const char *vcard, - EBookCallback cb, - gpointer closure); - -/* Checking to see if we're connected to the card repository. */ -gboolean e_book_check_connection (EBook *book); - -gboolean e_book_get_cursor (EBook *book, - char *query, - EBookCursorCallback cb, - gpointer closure); - -gboolean e_book_get_book_view (EBook *book, - char *query, - EBookBookViewCallback cb, - gpointer closure); - -/* Getting the name of the repository. */ -char *e_book_get_name (EBook *book); - -GtkType e_book_get_type (void); - -#define E_BOOK_TYPE (e_book_get_type ()) -#define E_BOOK(o) (GTK_CHECK_CAST ((o), E_BOOK_TYPE, EBook)) -#define E_BOOK_CLASS(k) (GTK_CHECK_CLASS_CAST((k), E_BOOK_TYPE, EBookClass)) -#define E_IS_BOOK(o) (GTK_CHECK_TYPE ((o), E_BOOK_TYPE)) -#define E_IS_BOOK_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), E_BOOK_TYPE)) - -END_GNOME_DECLS - -#endif /* ! __E_BOOK_H__ */ diff --git a/addressbook/backend/ebook/e-card-cursor.c b/addressbook/backend/ebook/e-card-cursor.c deleted file mode 100644 index 1618a6ddee..0000000000 --- a/addressbook/backend/ebook/e-card-cursor.c +++ /dev/null @@ -1,235 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * e-card-cursor.c: Implements card cursors. - * - * Author: - * Christopher James Lahey -#include -#include "addressbook.h" -#include "e-card-cursor.h" - -struct _ECardCursorPrivate { - Evolution_CardCursor corba_cursor; -}; - -/* - * A pointer to our parent object class - */ -static GtkObjectClass *parent_class; - -/* - * Implemented GtkObject::destroy - */ -static void -e_card_cursor_destroy (GtkObject *object) -{ - ECardCursor *cursor = E_CARD_CURSOR (object); - CORBA_Environment ev; - - CORBA_exception_init (&ev); - - Evolution_CardCursor_unref( cursor->priv->corba_cursor, &ev ); - - if (ev._major != CORBA_NO_EXCEPTION) { - g_warning("e_card_cursor_destroy: Exception unreffing " - "corba cursor.\n"); - CORBA_exception_free (&ev); - CORBA_exception_init (&ev); - } - - CORBA_Object_release (cursor->priv->corba_cursor, &ev); - - if (ev._major != CORBA_NO_EXCEPTION) { - g_warning("e_card_cursor_destroy: Exception releasing " - "corba cursor.\n"); - } - - CORBA_exception_free (&ev); - - if ( cursor->priv ) - g_free ( cursor->priv ); - - GTK_OBJECT_CLASS (parent_class)->destroy (object); -} - -/** - * e_card_cursor_get_length: - * @cursor: the #ECardCursor whose length is being queried - * - * Returns: the number of items the cursor references, or -1 there's - * an error. - */ -long -e_card_cursor_get_length (ECardCursor *cursor) -{ - if ( cursor->priv->corba_cursor != CORBA_OBJECT_NIL ) { - CORBA_Environment ev; - long ret_val; - - CORBA_exception_init (&ev); - - ret_val = Evolution_CardCursor_get_length(cursor->priv->corba_cursor, &ev); - - if (ev._major != CORBA_NO_EXCEPTION) { - g_warning("e_card_cursor_get_length: Exception during " - "get_length corba call.\n"); - ret_val = -1; - } - - CORBA_exception_free (&ev); - - return ret_val; - } - else - return -1; -} - -/** - * e_card_cursor_get_nth: - * @cursor: an #ECardCursor object - * @n: the index of the item requested - * - * Gets an #ECard based on an index. - * - * Returns: a new #ECard on success, or %NULL on failure. - */ -ECard * -e_card_cursor_get_nth (ECardCursor *cursor, - const long n) -{ - if ( cursor->priv->corba_cursor != CORBA_OBJECT_NIL ) { - CORBA_Environment en; - CORBA_char *vcard; - ECard *card; - - CORBA_exception_init (&en); - - vcard = Evolution_CardCursor_get_nth(cursor->priv->corba_cursor, n, &en); - - if (en._major != CORBA_NO_EXCEPTION) { - g_warning("e_card_cursor_get_nth: Exception during " - "get_nth corba call.\n"); - } - - CORBA_exception_free (&en); - - card = e_card_new (vcard); - - CORBA_free(vcard); - - return card; - } - else - return e_card_new(""); -} - -static void -e_card_cursor_class_init (ECardCursorClass *klass) -{ - GtkObjectClass *object_class = (GtkObjectClass *) klass; - - parent_class = gtk_type_class (gtk_object_get_type ()); - - object_class->destroy = e_card_cursor_destroy; -} - -static void -e_card_cursor_init (ECardCursor *cursor) -{ - cursor->priv = g_new(ECardCursorPrivate, 1); - cursor->priv->corba_cursor = CORBA_OBJECT_NIL; -} - -GtkType -e_card_cursor_get_type (void) -{ - static GtkType type = 0; - - if (!type){ - GtkTypeInfo info = { - "ECardCursor", - sizeof (ECardCursor), - sizeof (ECardCursorClass), - (GtkClassInitFunc) e_card_cursor_class_init, - (GtkObjectInitFunc) e_card_cursor_init, - NULL, /* reserved 1 */ - NULL, /* reserved 2 */ - (GtkClassInitFunc) NULL - }; - - type = gtk_type_unique (gtk_object_get_type (), &info); - } - - return type; -} - -/** - * e_card_cursor_construct: - * @cursor: an #ECardCursor object - * @corba_cursor: an #Evolution_CardCursor - * - * Wraps an #Evolution_CardCursor object inside the #ECardCursor - * @cursor object. - * - * Returns: a new #ECardCursor on success, or %NULL on failure. - */ -ECardCursor * -e_card_cursor_construct (ECardCursor *cursor, - Evolution_CardCursor corba_cursor) -{ - CORBA_Environment ev; - g_return_val_if_fail (cursor != NULL, NULL); - g_return_val_if_fail (E_IS_CARD_CURSOR (cursor), NULL); - g_return_val_if_fail (corba_cursor != CORBA_OBJECT_NIL, NULL); - - CORBA_exception_init (&ev); - - /* - * Initialize cursor - */ - cursor->priv->corba_cursor = CORBA_Object_duplicate(corba_cursor, &ev); - - if (ev._major != CORBA_NO_EXCEPTION) { - g_warning("e_card_cursor_construct: Exception duplicating " - "corba cursor.\n"); - CORBA_exception_free (&ev); - CORBA_exception_init (&ev); - } - - Evolution_CardCursor_ref(cursor->priv->corba_cursor, &ev); - - if (ev._major != CORBA_NO_EXCEPTION) { - g_warning("e_card_cursor_construct: Exception reffing " - "corba cursor.\n"); - } - - CORBA_exception_free (&ev); - - /* - * Success: return the GtkType we were given - */ - return cursor; -} - -/** - * e_card_cursor_new: - * @cursor: the #Evolution_CardCursor to be wrapped - * - * Creates a new #ECardCursor, which wraps an #Evolution_CardCursor - * object. - * - * Returns: a new #ECardCursor on success, or %NULL on failure. - */ -ECardCursor * -e_card_cursor_new (Evolution_CardCursor corba_cursor) -{ - ECardCursor *cursor; - - cursor = gtk_type_new (e_card_cursor_get_type ()); - - return e_card_cursor_construct (cursor, - corba_cursor); -} diff --git a/addressbook/backend/ebook/e-card-cursor.h b/addressbook/backend/ebook/e-card-cursor.h deleted file mode 100644 index 67020071d1..0000000000 --- a/addressbook/backend/ebook/e-card-cursor.h +++ /dev/null @@ -1,52 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * - * Author: - * Nat Friedman (nat@helixcode.com) - * - * Copyright 2000, Helix Code, Inc. - */ - -#ifndef __E_CARD_CURSOR_H__ -#define __E_CARD_CURSOR_H__ - -#include -#include -#include -#include - -BEGIN_GNOME_DECLS - -typedef struct _ECardCursor ECardCursor; -typedef struct _ECardCursorPrivate ECardCursorPrivate; -typedef struct _ECardCursorClass ECardCursorClass; - -struct _ECardCursor { - GtkObject parent; - ECardCursorPrivate *priv; -}; - -struct _ECardCursorClass { - GtkObjectClass parent; -}; - -/* Creating a new addressbook. */ -ECardCursor *e_card_cursor_new (Evolution_CardCursor corba_cursor); -ECardCursor *e_card_cursor_construct (ECardCursor *cursor, - Evolution_CardCursor corba_cursor); - -GtkType e_card_cursor_get_type (void); - -/* Fetching cards. */ -long e_card_cursor_get_length (ECardCursor *cursor); -ECard *e_card_cursor_get_nth (ECardCursor *cursor, - const long nth); -#define E_CARD_CURSOR_TYPE (e_card_cursor_get_type ()) -#define E_CARD_CURSOR(o) (GTK_CHECK_CAST ((o), E_CARD_CURSOR_TYPE, ECardCursor)) -#define E_CARD_CURSOR_CLASS(k) (GTK_CHECK_CLASS_CAST((k), E_CARD_CURSOR_TYPE, ECardCursorClass)) -#define E_IS_CARD_CURSOR(o) (GTK_CHECK_TYPE ((o), E_CARD_CURSOR_TYPE)) -#define E_IS_CARD_CURSOR_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), E_CARD_CURSOR_TYPE)) - -END_GNOME_DECLS - -#endif /* ! __E_CARD_CURSOR_H__ */ diff --git a/addressbook/backend/ebook/e-card-iterator.c b/addressbook/backend/ebook/e-card-iterator.c deleted file mode 100644 index b5a023b5c1..0000000000 --- a/addressbook/backend/ebook/e-card-iterator.c +++ /dev/null @@ -1,169 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Authors: - * Christopher James Lahey - * - * Copyright (C) 2000 Helix Code, Inc. - * Copyright (C) 1999 The Free Software Foundation - */ - -#include -#include - -#include "e-card-iterator.h" - -#define ECI_CLASS(object) (E_CARD_ITERATOR_CLASS(GTK_OBJECT((object))->klass)) - -static void e_card_iterator_init (ECardIterator *card); -static void e_card_iterator_class_init (ECardIteratorClass *klass); - -#define PARENT_TYPE (gtk_object_get_type ()) - -static GtkObjectClass *parent_class; - -enum { - INVALIDATE, - LAST_SIGNAL -}; - -static guint e_card_iterator_signals [LAST_SIGNAL] = { 0, }; - -/** - * e_card_iterator_get_type: - * @void: - * - * Registers the &ECardIterator class if necessary, and returns the type ID - * associated to it. - * - * Return value: The type ID of the &ECardIterator class. - **/ -GtkType -e_card_iterator_get_type (void) -{ - static GtkType type = 0; - - if (!type) { - GtkTypeInfo info = { - "ECardIterator", - sizeof (ECardIterator), - sizeof (ECardIteratorClass), - (GtkClassInitFunc) e_card_iterator_class_init, - (GtkObjectInitFunc) e_card_iterator_init, - NULL, /* reserved_1 */ - NULL, /* reserved_2 */ - (GtkClassInitFunc) NULL - }; - - type = gtk_type_unique (PARENT_TYPE, &info); - } - - return type; -} - -static void -e_card_iterator_class_init (ECardIteratorClass *klass) -{ - GtkObjectClass *object_class; - - object_class = GTK_OBJECT_CLASS(klass); - - parent_class = gtk_type_class (PARENT_TYPE); - - e_card_iterator_signals [INVALIDATE] = - gtk_signal_new ("invalidate", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (ECardIteratorClass, invalidate), - gtk_marshal_NONE__NONE, - GTK_TYPE_NONE, 0); - - gtk_object_class_add_signals (object_class, e_card_iterator_signals, LAST_SIGNAL); - - klass->invalidate = NULL; - klass->get = NULL; - klass->reset = NULL; - klass->next = NULL; - klass->prev = NULL; - klass->delete = NULL; - klass->set = NULL; - klass->is_valid = NULL; -} - -/** - * e_card_iterator_init: - */ -static void -e_card_iterator_init (ECardIterator *card) -{ -} - -/* - * Virtual functions: - */ -const void * -e_card_iterator_get (ECardIterator *iterator) -{ - if (ECI_CLASS(iterator)->get) - return ECI_CLASS(iterator)->get(iterator); - else - return NULL; -} - -void -e_card_iterator_reset (ECardIterator *iterator) -{ - if (ECI_CLASS(iterator)->reset) - ECI_CLASS(iterator)->reset(iterator); -} - -gboolean -e_card_iterator_next (ECardIterator *iterator) -{ - if (ECI_CLASS(iterator)->next) - return ECI_CLASS(iterator)->next(iterator); - else - return FALSE; -} - -gboolean -e_card_iterator_prev (ECardIterator *iterator) -{ - if (ECI_CLASS(iterator)->prev) - return ECI_CLASS(iterator)->prev(iterator); - else - return FALSE; -} - -void -e_card_iterator_delete (ECardIterator *iterator) -{ - if (ECI_CLASS(iterator)->delete) - ECI_CLASS(iterator)->delete(iterator); -} - -void -e_card_iterator_set (ECardIterator *iterator, - const void *object) -{ - if (ECI_CLASS(iterator)->set) - ECI_CLASS(iterator)->set(iterator, object); -} - -gboolean -e_card_iterator_is_valid (ECardIterator *iterator) -{ - if (ECI_CLASS(iterator)->is_valid) - return ECI_CLASS(iterator)->is_valid(iterator); - else - return FALSE; -} - -void -e_card_iterator_invalidate (ECardIterator *iterator) -{ - g_return_if_fail (iterator != NULL); - g_return_if_fail (E_IS_CARD_ITERATOR (iterator)); - - gtk_signal_emit (GTK_OBJECT (iterator), - e_card_iterator_signals [INVALIDATE]); -} diff --git a/addressbook/backend/ebook/e-card-iterator.h b/addressbook/backend/ebook/e-card-iterator.h deleted file mode 100644 index 9d657e03ef..0000000000 --- a/addressbook/backend/ebook/e-card-iterator.h +++ /dev/null @@ -1,61 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Authors: - * Chris Lahey - * - * Copyright (C) 2000 Helix Code, Inc. - * Copyright (C) 1999 The Free Software Foundation - */ - -#ifndef __E_CARD_ITERATOR_H__ -#define __E_CARD_ITERATOR_H__ - -#include -#include -#include - -#define E_TYPE_CARD_ITERATOR (e_card_iterator_get_type ()) -#define E_CARD_ITERATOR(obj) (GTK_CHECK_CAST ((obj), E_TYPE_CARD_ITERATOR, ECardIterator)) -#define E_CARD_ITERATOR_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_TYPE_CARD_ITERATOR, ECardIteratorClass)) -#define E_IS_CARD_ITERATOR(obj) (GTK_CHECK_TYPE ((obj), E_TYPE_CARD_ITERATOR)) -#define E_IS_CARD_ITERATOR_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), E_TYPE_CARD_ITERATOR)) - -typedef struct _ECardIterator ECardIterator; -typedef struct _ECardIteratorClass ECardIteratorClass; - -struct _ECardIterator { - GtkObject object; -}; - -struct _ECardIteratorClass { - GtkObjectClass parent_class; - - /* Signals */ - void (*invalidate) (ECardIterator *iterator); - - /* Virtual functions */ - const void * (*get) (ECardIterator *iterator); - void (*reset) (ECardIterator *iterator); - gboolean (*next) (ECardIterator *iterator); - gboolean (*prev) (ECardIterator *iterator); - void (*delete) (ECardIterator *iterator); - void (*set) (ECardIterator *iterator, - const void *object); - gboolean (*is_valid) (ECardIterator *iterator); -}; - -const void *e_card_iterator_get (ECardIterator *iterator); -void e_card_iterator_reset (ECardIterator *iterator); -gboolean e_card_iterator_next (ECardIterator *iterator); -gboolean e_card_iterator_prev (ECardIterator *iterator); -void e_card_iterator_delete (ECardIterator *iterator); -void e_card_iterator_set (ECardIterator *iterator, - const void *object); -gboolean e_card_iterator_is_valid (ECardIterator *iterator); - -void e_card_iterator_invalidate (ECardIterator *iterator); - -/* Standard Gtk function */ -GtkType e_card_iterator_get_type (void); - -#endif /* ! __E_CARD_ITERATOR_H__ */ diff --git a/addressbook/backend/ebook/e-card-list-iterator.c b/addressbook/backend/ebook/e-card-list-iterator.c deleted file mode 100644 index d23060fda2..0000000000 --- a/addressbook/backend/ebook/e-card-list-iterator.c +++ /dev/null @@ -1,199 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Authors: - * Christopher James Lahey - * - * Copyright (C) 2000 Helix Code, Inc. - * Copyright (C) 1999 The Free Software Foundation - */ - -#include -#include - -#include "e-card-list-iterator.h" -#include "e-card-list.h" - -static void e_card_list_iterator_init (ECardListIterator *card); -static void e_card_list_iterator_class_init (ECardListIteratorClass *klass); - -static void e_card_list_iterator_invalidate (ECardIterator *iterator); -static gboolean e_card_list_iterator_is_valid (ECardIterator *iterator); -static void e_card_list_iterator_set (ECardIterator *iterator, - const void *object); -static void e_card_list_iterator_delete (ECardIterator *iterator); -static gboolean e_card_list_iterator_prev (ECardIterator *iterator); -static gboolean e_card_list_iterator_next (ECardIterator *iterator); -static void e_card_list_iterator_reset (ECardIterator *iterator); -static const void *e_card_list_iterator_get (ECardIterator *iterator); -static void e_card_list_iterator_destroy (GtkObject *object); - -#define PARENT_TYPE (e_card_iterator_get_type ()) - -static GtkObjectClass *parent_class; -#define PARENT_CLASS (E_CARD_LIST_ITERATOR_CLASS(parent_class)) - -/** - * e_card_list_iterator_get_type: - * @void: - * - * Registers the &ECardListIterator class if necessary, and returns the type ID - * associated to it. - * - * Return value: The type ID of the &ECardListIterator class. - **/ -GtkType -e_card_list_iterator_get_type (void) -{ - static GtkType type = 0; - - if (!type) { - GtkTypeInfo info = { - "ECardListIterator", - sizeof (ECardListIterator), - sizeof (ECardListIteratorClass), - (GtkClassInitFunc) e_card_list_iterator_class_init, - (GtkObjectInitFunc) e_card_list_iterator_init, - NULL, /* reserved_1 */ - NULL, /* reserved_2 */ - (GtkClassInitFunc) NULL - }; - - type = gtk_type_unique (PARENT_TYPE, &info); - } - - return type; -} - -static void -e_card_list_iterator_class_init (ECardListIteratorClass *klass) -{ - GtkObjectClass *object_class; - ECardIteratorClass *iterator_class; - - object_class = GTK_OBJECT_CLASS(klass); - iterator_class = E_CARD_ITERATOR_CLASS(klass); - - parent_class = gtk_type_class (PARENT_TYPE); - - object_class->destroy = e_card_list_iterator_destroy; - - iterator_class->invalidate = e_card_list_iterator_invalidate; - iterator_class->get = e_card_list_iterator_get; - iterator_class->reset = e_card_list_iterator_reset; - iterator_class->next = e_card_list_iterator_next; - iterator_class->prev = e_card_list_iterator_prev; - iterator_class->delete = e_card_list_iterator_delete; - iterator_class->set = e_card_list_iterator_set; - iterator_class->is_valid = e_card_list_iterator_is_valid; -} - - - -/** - * e_card_list_iterator_init: - */ -static void -e_card_list_iterator_init (ECardListIterator *card) -{ -} - -ECardIterator * -e_card_list_iterator_new (ECardList *list) -{ - ECardListIterator *iterator = gtk_type_new(e_card_list_iterator_get_type()); - - iterator->list = list; - gtk_object_ref(GTK_OBJECT(list)); - iterator->iterator = list->list; - - return E_CARD_ITERATOR(iterator); -} - -/* - * Virtual functions: - */ -static void -e_card_list_iterator_destroy (GtkObject *object) -{ - ECardListIterator *iterator = E_CARD_LIST_ITERATOR(object); - e_card_list_remove_iterator(iterator->list, E_CARD_ITERATOR(iterator)); - gtk_object_unref(GTK_OBJECT(iterator->list)); -} - -static const void * -e_card_list_iterator_get (ECardIterator *_iterator) -{ - ECardListIterator *iterator = E_CARD_LIST_ITERATOR(_iterator); - if (iterator->iterator) - return iterator->iterator->data; - else - return NULL; -} - -static void -e_card_list_iterator_reset (ECardIterator *_iterator) -{ - ECardListIterator *iterator = E_CARD_LIST_ITERATOR(_iterator); - iterator->iterator = iterator->list->list; -} - -static gboolean -e_card_list_iterator_next (ECardIterator *_iterator) -{ - ECardListIterator *iterator = E_CARD_LIST_ITERATOR(_iterator); - if (iterator->iterator) - iterator->iterator = g_list_next(iterator->iterator); - return (iterator->iterator != NULL); -} - -static gboolean -e_card_list_iterator_prev (ECardIterator *_iterator) -{ - ECardListIterator *iterator = E_CARD_LIST_ITERATOR(_iterator); - if (iterator->iterator) - iterator->iterator = g_list_previous(iterator->iterator); - return (iterator->iterator != NULL); -} - -static void -e_card_list_iterator_delete (ECardIterator *_iterator) -{ - ECardListIterator *iterator = E_CARD_LIST_ITERATOR(_iterator); - if (iterator->iterator) { - GList *temp = iterator->iterator->next; - if (iterator->list->free) - iterator->list->free(iterator->iterator->data, iterator->list->closure); - iterator->list->list = g_list_remove_link(iterator->list->list, iterator->iterator); - iterator->iterator = temp; - e_card_list_invalidate_iterators(iterator->list, E_CARD_ITERATOR(iterator)); - } -} - -static void -e_card_list_iterator_set (ECardIterator *_iterator, - const void *object) -{ - ECardListIterator *iterator = E_CARD_LIST_ITERATOR(_iterator); - if (iterator->iterator) { - if (iterator->list->free) - iterator->list->free(iterator->iterator->data, iterator->list->closure); - if (iterator->list->copy) - iterator->iterator->data = iterator->list->copy(object, iterator->list->closure); - else - iterator->iterator->data = (void *) object; - } -} - -static gboolean -e_card_list_iterator_is_valid (ECardIterator *_iterator) -{ - ECardListIterator *iterator = E_CARD_LIST_ITERATOR(_iterator); - return iterator->iterator != NULL; -} - -static void -e_card_list_iterator_invalidate (ECardIterator *_iterator) -{ - ECardListIterator *iterator = E_CARD_LIST_ITERATOR(_iterator); - iterator->iterator = NULL; -} diff --git a/addressbook/backend/ebook/e-card-list-iterator.h b/addressbook/backend/ebook/e-card-list-iterator.h deleted file mode 100644 index 38a7d77f21..0000000000 --- a/addressbook/backend/ebook/e-card-list-iterator.h +++ /dev/null @@ -1,44 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Authors: - * Chris Lahey - * - * Copyright (C) 2000 Helix Code, Inc. - * Copyright (C) 1999 The Free Software Foundation - */ - -#ifndef __E_CARD_LIST_ITERATOR_H__ -#define __E_CARD_LIST_ITERATOR_H__ - -#include -#include -#include -#include -#include - -#define E_TYPE_CARD_LIST_ITERATOR (e_card_list_iterator_get_type ()) -#define E_CARD_LIST_ITERATOR(obj) (GTK_CHECK_CAST ((obj), E_TYPE_CARD_LIST_ITERATOR, ECardListIterator)) -#define E_CARD_LIST_ITERATOR_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_TYPE_CARD_LIST_ITERATOR, ECardListIteratorClass)) -#define E_IS_CARD_LIST_ITERATOR(obj) (GTK_CHECK_TYPE ((obj), E_TYPE_CARD_LIST_ITERATOR)) -#define E_IS_CARD_LIST_ITERATOR_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), E_TYPE_CARD_LIST_ITERATOR)) - -typedef struct _ECardListIterator ECardListIterator; -typedef struct _ECardListIteratorClass ECardListIteratorClass; - -struct _ECardListIterator { - ECardIterator parent; - - ECardList *list; - GList *iterator; -}; - -struct _ECardListIteratorClass { - ECardIteratorClass parent_class; -}; - -ECardIterator *e_card_list_iterator_new (ECardList *list); - -/* Standard Gtk function */ -GtkType e_card_list_iterator_get_type (void); - -#endif /* ! __E_CARD_LIST_ITERATOR_H__ */ diff --git a/addressbook/backend/ebook/e-card-list.c b/addressbook/backend/ebook/e-card-list.c deleted file mode 100644 index 9bec3b7bd5..0000000000 --- a/addressbook/backend/ebook/e-card-list.c +++ /dev/null @@ -1,134 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Authors: - * Christopher James Lahey - * - * Copyright (C) 2000 Helix Code, Inc. - * Copyright (C) 1999 The Free Software Foundation - */ - -#include -#include - -#include "e-card-list.h" -#include "e-card-list-iterator.h" - -#define ECL_CLASS(object) (E_CARD_LIST_CLASS(GTK_OBJECT((object))->klass)) - -static void e_card_list_init (ECardList *card); -static void e_card_list_class_init (ECardListClass *klass); -static void e_card_list_destroy (GtkObject *object); - -#define PARENT_TYPE (gtk_object_get_type ()) - -static GtkObjectClass *parent_class; - -/** - * e_card_list_get_type: - * @void: - * - * Registers the &ECardList class if necessary, and returns the type ID - * associated to it. - * - * Return value: The type ID of the &ECardList class. - **/ -GtkType -e_card_list_get_type (void) -{ - static GtkType type = 0; - - if (!type) { - GtkTypeInfo info = { - "ECardList", - sizeof (ECardList), - sizeof (ECardListClass), - (GtkClassInitFunc) e_card_list_class_init, - (GtkObjectInitFunc) e_card_list_init, - NULL, /* reserved_1 */ - NULL, /* reserved_2 */ - (GtkClassInitFunc) NULL - }; - - type = gtk_type_unique (PARENT_TYPE, &info); - } - - return type; -} - -static void -e_card_list_class_init (ECardListClass *klass) -{ - GtkObjectClass *object_class; - - object_class = GTK_OBJECT_CLASS(klass); - - parent_class = gtk_type_class (PARENT_TYPE); - - object_class->destroy = e_card_list_destroy; -} - -/** - * e_card_list_init: - */ -static void -e_card_list_init (ECardList *list) -{ - list->list = NULL; - list->iterators = NULL; -} - -ECardList * -e_card_list_new (ECardListCopyFunc copy, ECardListFreeFunc free, void *closure) -{ - ECardList *list = gtk_type_new(e_card_list_get_type()); - list->copy = copy; - list->free = free; - list->closure = closure; - return list; -} - -ECardIterator * -e_card_list_get_iterator (ECardList *list) -{ - ECardIterator *iterator = e_card_list_iterator_new(list); - list->iterators = g_list_append(list->iterators, iterator); - return iterator; -} - -void -e_card_list_append (ECardList *list, const void *data) -{ - e_card_list_invalidate_iterators(list, NULL); - if (list->copy) - list->list = g_list_append(list->list, list->copy(data, list->closure)); - else - list->list = g_list_append(list->list, (void *) data); -} - -void -e_card_list_invalidate_iterators (ECardList *list, ECardIterator *skip) -{ - GList *iterators = list->iterators; - for (; iterators; iterators = iterators->next) { - if (iterators->data != skip) { - e_card_iterator_invalidate(E_CARD_ITERATOR(iterators->data)); - } - } -} - -void -e_card_list_remove_iterator (ECardList *list, ECardIterator *iterator) -{ - list->iterators = g_list_remove(list->iterators, iterator); -} - -/* - * Virtual functions - */ -static void -e_card_list_destroy (GtkObject *object) -{ - ECardList *list = E_CARD_LIST(object); - g_list_foreach(list->list, (GFunc) list->free, list->closure); - g_list_free(list->list); -} diff --git a/addressbook/backend/ebook/e-card-list.h b/addressbook/backend/ebook/e-card-list.h deleted file mode 100644 index 18b69b2a3e..0000000000 --- a/addressbook/backend/ebook/e-card-list.h +++ /dev/null @@ -1,59 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Authors: - * Chris Lahey - * - * Copyright (C) 2000 Helix Code, Inc. - * Copyright (C) 1999 The Free Software Foundation - */ - -#ifndef __E_CARD_LIST_H__ -#define __E_CARD_LIST_H__ - -#include -#include -#include -#include - -#define E_TYPE_CARD_LIST (e_card_list_get_type ()) -#define E_CARD_LIST(obj) (GTK_CHECK_CAST ((obj), E_TYPE_CARD_LIST, ECardList)) -#define E_CARD_LIST_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_TYPE_CARD_LIST, ECardListClass)) -#define E_IS_CARD_LIST(obj) (GTK_CHECK_TYPE ((obj), E_TYPE_CARD_LIST)) -#define E_IS_CARD_LIST_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), E_TYPE_CARD_LIST)) - -typedef void *(*ECardListCopyFunc) (const void *data, void *closure); -typedef void (*ECardListFreeFunc) (void *data, void *closure); - -typedef struct _ECardList ECardList; -typedef struct _ECardListClass ECardListClass; - -struct _ECardList { - GtkObject object; - GList *list; - GList *iterators; - ECardListCopyFunc copy; - ECardListFreeFunc free; - void *closure; -}; - -struct _ECardListClass { - GtkObjectClass parent_class; -}; - -ECardList *e_card_list_new (ECardListCopyFunc copy, - ECardListFreeFunc free, - void *closure); -ECardIterator *e_card_list_get_iterator (ECardList *list); -void e_card_list_append (ECardList *list, - const void *data); - -/* For iterators to call. */ -void e_card_list_invalidate_iterators (ECardList *list, - ECardIterator *skip); -void e_card_list_remove_iterator (ECardList *list, - ECardIterator *iterator); - -/* Standard Gtk function */ -GtkType e_card_list_get_type (void); - -#endif /* ! __E_CARD_LIST_H__ */ diff --git a/addressbook/backend/ebook/e-card-pairs.h b/addressbook/backend/ebook/e-card-pairs.h deleted file mode 100644 index 0f379d3477..0000000000 --- a/addressbook/backend/ebook/e-card-pairs.h +++ /dev/null @@ -1,118 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* GnomeCard - a graphical contact manager. - * - * pairs.h: This file is part of GnomeCard. - * - * Copyright (C) 1999 The Free Software Foundation - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#ifndef __E_CARD_PAIRS_H__ -#define __E_CARD_PAIRS_H__ - -#include -#include - - -#if 0 -struct pair -{ - char *str; - ECardPropertyType i ; -}; - -struct pair prop_lookup[] = { - { VCFullNameProp, PROP_FNAME }, - { VCNameProp, PROP_NAME }, - { VCPhotoProp, PROP_PHOTO }, - { VCBirthDateProp, PROP_BDAY }, - { VCAdrProp, PROP_DELADDR }, - { VCDeliveryLabelProp, PROP_DELLABEL }, - { VCTelephoneProp, PROP_PHONE }, - { VCEmailAddressProp, PROP_EMAIL }, - { VCMailerProp, PROP_MAILER }, - { VCTimeZoneProp, PROP_TIMEZN }, - { VCGeoProp, PROP_GEOPOS }, - { VCTitleProp, PROP_TITLE }, - { VCBusinessRoleProp, PROP_ROLE }, - { VCLogoProp, PROP_LOGO }, - { VCAgentProp, PROP_AGENT }, - { VCOrgProp, PROP_ORG }, - { VCCategoriesProp, PROP_CATEGORIES }, - { VCCommentProp, PROP_COMMENT }, - { VCLastRevisedProp, PROP_REV }, - { VCPronunciationProp, PROP_SOUND }, - { VCURLProp, PROP_URL }, - { VCUniqueStringProp, PROP_UID }, - { VCVersionProp, PROP_VERSION }, - { VCPublicKeyProp, PROP_KEY }, - { VCValueProp, PROP_VALUE }, - { VCEncodingProp, PROP_ENCODING }, - { VCQuotedPrintableProp, PROP_QUOTED_PRINTABLE }, - { VC8bitProp, PROP_8BIT }, - { VCBase64Prop, PROP_BASE64 }, - { VCLanguageProp, PROP_LANG }, - { VCCharSetProp, PROP_CHARSET }, - { NULL, PROP_NONE} }; - -struct pair photo_pairs[] = { - { VCGIFProp, PHOTO_GIF }, - { VCCGMProp, PHOTO_CGM }, - { VCWMFProp, PHOTO_WMF }, - { VCBMPProp, PHOTO_BMP }, - { VCMETProp, PHOTO_MET }, - { VCPMBProp, PHOTO_PMB }, - { VCDIBProp, PHOTO_DIB }, - { VCPICTProp, PHOTO_PICT }, - { VCTIFFProp, PHOTO_TIFF }, - { VCPDFProp, PHOTO_PDF }, - { VCPSProp, PHOTO_PS }, - { VCJPEGProp, PHOTO_JPEG }, - { VCMPEGProp, PHOTO_MPEG }, - { VCMPEG2Prop, PHOTO_MPEG2 }, - { VCAVIProp, PHOTO_AVI }, - { VCQuickTimeProp, PHOTO_QTIME }, - { NULL, 0 } }; - -struct pair email_pairs[] = { - { VCAOLProp, EMAIL_AOL }, - { VCAppleLinkProp, EMAIL_APPLE_LINK }, - { VCATTMailProp, EMAIL_ATT }, - { VCCISProp, EMAIL_CIS }, - { VCEWorldProp, EMAIL_EWORLD }, - { VCInternetProp, EMAIL_INET }, - { VCIBMMailProp, EMAIL_IBM }, - { VCMCIMailProp, EMAIL_MCI }, - { VCPowerShareProp, EMAIL_POWERSHARE }, - { VCProdigyProp, EMAIL_PRODIGY }, - { VCTLXProp, EMAIL_TLX }, - { VCX400Prop, EMAIL_X400 }, - { NULL, 0 } }; - -struct pair sound_pairs[] = { - { VCAIFFProp, SOUND_AIFF }, - { VCPCMProp, SOUND_PCM }, - { VCWAVEProp, SOUND_WAVE }, - { NULL, 0 } }; - -struct pair key_pairs[] = { - { VCX509Prop, KEY_X509 }, - { VCPGPProp, KEY_PGP }, - { NULL, 0 } }; - - -#endif -#endif /* ! __E_CARD_PAIRS_H__ */ diff --git a/addressbook/backend/ebook/e-card-types.h b/addressbook/backend/ebook/e-card-types.h deleted file mode 100644 index 1fce805e91..0000000000 --- a/addressbook/backend/ebook/e-card-types.h +++ /dev/null @@ -1,251 +0,0 @@ -/* - * Authors: - * Arturo Espinosa - * Nat Friedman (nat@helixcode.com) - * - * Copyright (C) 2000 Helix Code, Inc. - * Copyright (C) 1999 The Free Software Foundation - */ - -#ifndef __E_CARD_TYPES_H__ -#define __E_CARD_TYPES_H__ -#if 0 -typedef enum -{ - PROP_NONE = 0, /* Must always be the first, with value = 0. */ - PROP_CARD = 1, - PROP_FNAME = 2, - PROP_NAME = 3, - PROP_PHOTO = 4, - PROP_BDAY = 5, - PROP_DELADDR_LIST = 6, - PROP_DELADDR = 7, - PROP_DELLABEL_LIST = 8, - PROP_DELLABEL = 9, - PROP_PHONE_LIST = 10, - PROP_PHONE = 11, - PROP_EMAIL_LIST = 12, - PROP_EMAIL = 13, - PROP_MAILER = 14, - PROP_TIMEZN = 15, - PROP_GEOPOS = 16, - PROP_TITLE = 17, - PROP_ROLE = 18, - PROP_LOGO = 19, - PROP_AGENT = 20, - PROP_ORG = 21, - PROP_COMMENT = 22, - PROP_REV = 23, - PROP_SOUND = 24, - PROP_URL = 25, - PROP_UID = 26, - PROP_VERSION = 27, - PROP_KEY = 28, - PROP_CATEGORIES = 29, - PROP_XTENSION_LIST = 30, - PROP_VALUE = 31, - PROP_ENCODING = 32, - PROP_QUOTED_PRINTABLE = 33, - PROP_8BIT = 34, - PROP_BASE64 = 35, - PROP_LANG = 36, - PROP_CHARSET = 37, - PROP_LAST = 38 /* Must always be the last, with the gratest value. */ -} ECardPropertyType; - -typedef enum -{ - ENC_NONE = 0, - ENC_BASE64 = 1, - ENC_QUOTED_PRINTABLE = 2, - ENC_8BIT = 3, - ENC_7BIT = 4, - ENC_LAST = 5 -} ECardEncodeType; - -typedef enum -{ - VAL_NONE = 0, - VAL_INLINE = 1, - VAL_CID = 2, - VAL_URL = 3, - VAL_LAST = 4 -} ECardValueType; - -typedef enum { - PHOTO_GIF, PHOTO_CGM, PHOTO_WMF, PHOTO_BMP, PHOTO_MET, PHOTO_PMB, - PHOTO_DIB, PHOTO_PICT, PHOTO_TIFF, PHOTO_PS, PHOTO_PDF, PHOTO_JPEG, - PHOTO_MPEG, PHOTO_MPEG2, PHOTO_AVI, PHOTO_QTIME -} ECardPhotoType; - -typedef struct { - gboolean used; - ECardPropertyType type; - ECardEncodeType encode; - ECardValueType value; - char *charset; - char *lang; - GList *xtension; - - void *user_data; -} CardProperty; - -typedef struct { - char *name; - char *data; -} CardXAttribute; - -typedef struct { - CardProperty prop; - - char *name; - char *data; -} ECardXProperty; - -typedef struct { - CardProperty prop; - - GList *l; -} ECardList; - -#endif - -/* IDENTIFICATION PROPERTIES */ - - -typedef struct { - char *prefix; /* Mr. */ - char *given; /* John */ - char *additional; /* Quinlan */ - char *family; /* Public */ - char *suffix; /* Esq. */ -} ECardName; - -#if 0 -typedef struct { - CardProperty prop; - - ECardPhotoType type; - guint size; - char *data; - -} ECardPhoto; -#endif - -typedef struct { - int year; - int month; - int day; -} ECardDate; - -/* TELECOMMUNICATIONS ADDRESSING PROPERTIES */ - -typedef enum { - E_CARD_PHONE_PREF = 1 << 0, - E_CARD_PHONE_WORK = 1 << 1, - E_CARD_PHONE_HOME = 1 << 2, - E_CARD_PHONE_VOICE = 1 << 3, - E_CARD_PHONE_FAX = 1 << 4, - E_CARD_PHONE_MSG = 1 << 5, - E_CARD_PHONE_CELL = 1 << 6, - E_CARD_PHONE_PAGER = 1 << 7, - E_CARD_PHONE_BBS = 1 << 8, - E_CARD_PHONE_MODEM = 1 << 9, - E_CARD_PHONE_CAR = 1 << 10, - E_CARD_PHONE_ISDN = 1 << 11, - E_CARD_PHONE_VIDEO = 1 << 12 -} ECardPhoneFlags; - -typedef struct { - ECardPhoneFlags flags; - char *number; -} ECardPhone; - -#if 0 - -typedef struct { - int sign; /* 1 or -1 */ - int hours; /* Mexico General is at -6:00 UTC */ - int mins; /* sign -1, hours 6, mins 0 */ -} ECardTimeZone; - -typedef struct { - CardProperty prop; - - float lon; - float lat; -} ECardGeoPos; - -#endif -/* DELIVERY ADDRESSING PROPERTIES */ - -typedef enum { - ADDR_HOME = 1 << 0, - ADDR_WORK = 1 << 1, - ADDR_POSTAL = 1 << 2, - ADDR_PARCEL = 1 << 3, - ADDR_DOM = 1 << 4, - ADDR_INTL = 1 << 5 -} ECardAddressFlags; - -typedef struct { - ECardAddressFlags flags; - - char *po; - char *ext; - char *street; - char *city; - char *region; - char *code; - char *country; -} ECardDeliveryAddress; - -#if 0 -typedef struct { - ECardAddressFlags flags; - char *data; -} ECardAddrLabel; - -/* ORGANIZATIONAL PROPERTIES */ - -typedef struct { - char *name; - char *unit1; - char *unit2; - char *unit3; - char *unit4; -} ECardOrg; - -typedef enum { - SOUND_AIFF, - SOUND_PCM, - SOUND_WAVE, - SOUND_PHONETIC -} ECardSoundType; - -typedef enum { - KEY_X509, - KEY_PGP -} ECardKeyType; - -typedef struct { - int utc; - struct tm tm; -} ECardRev; - - -typedef struct { - ECardSoundType type; - unsigned int size; - char *data; -} ECardSound; - -typedef struct { - CardProperty prop; - - ECardKeyType type; - char *data; -} ECardKey; - -#endif /* 0 */ -#endif /* __E_CARD_TYPES_H__ */ diff --git a/addressbook/backend/ebook/e-card.c b/addressbook/backend/ebook/e-card.c deleted file mode 100644 index 683c4add13..0000000000 --- a/addressbook/backend/ebook/e-card.c +++ /dev/null @@ -1,2622 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Authors: - * Arturo Espinosa (arturo@nuclecu.unam.mx) - * Nat Friedman (nat@helixcode.com) - * - * Copyright (C) 2000 Helix Code, Inc. - * Copyright (C) 1999 The Free Software Foundation - */ - -#include -#include -#include -#include -#include - -#include -#include "e-card.h" -#include "e-card-pairs.h" - -#define is_a_prop_of(obj,prop) (isAPropertyOf ((obj),(prop))) -#define str_val(obj) (the_str = (vObjectValueType (obj))? fakeCString (vObjectUStringZValue (obj)) : calloc (1, 1)) -#define has(obj,prop) (vo = isAPropertyOf ((obj), (prop))) - -/* Object argument IDs */ -enum { - ARG_0, - ARG_FULL_NAME, - ARG_NAME, - ARG_ADDRESS, - ARG_PHONE, - ARG_EMAIL, - ARG_BIRTH_DATE, - ARG_URL, - ARG_ORG, - ARG_ORG_UNIT, - ARG_TITLE, - ARG_ROLE, - ARG_NICKNAME, - ARG_FBURL, - ARG_NOTE, - ARG_ID -}; - -#if 0 -static VObject *card_convert_to_vobject (ECard *crd); -#endif -static void parse(ECard *card, VObject *vobj); -static void e_card_init (ECard *card); -static void e_card_class_init (ECardClass *klass); - -static void e_card_destroy (GtkObject *object); -static void e_card_set_arg (GtkObject *object, GtkArg *arg, guint arg_id); -static void e_card_get_arg (GtkObject *object, GtkArg *arg, guint arg_id); - -static void assign_string(VObject *vobj, char **string); - -static void e_card_name_free(ECardName *name); -char *e_v_object_get_child_value(VObject *vobj, char *name); -static ECardDate e_card_date_from_string (char *str); - -static void parse_bday(ECard *card, VObject *object); -static void parse_full_name(ECard *card, VObject *object); -static void parse_name(ECard *card, VObject *object); -static void parse_email(ECard *card, VObject *object); -static void parse_phone(ECard *card, VObject *object); -static void parse_address(ECard *card, VObject *object); -static void parse_url(ECard *card, VObject *object); -static void parse_org(ECard *card, VObject *object); -static void parse_title(ECard *card, VObject *object); -static void parse_role(ECard *card, VObject *object); -static void parse_nickname(ECard *card, VObject *object); -static void parse_fburl(ECard *card, VObject *object); -static void parse_note(ECard *card, VObject *object); -static void parse_id(ECard *card, VObject *object); - -static ECardPhoneFlags get_phone_flags (VObject *vobj); -static void set_phone_flags (VObject *vobj, ECardPhoneFlags flags); -static ECardAddressFlags get_address_flags (VObject *vobj); -static void set_address_flags (VObject *vobj, ECardAddressFlags flags); - -typedef void (* ParsePropertyFunc) (ECard *card, VObject *object); - -struct { - char *key; - ParsePropertyFunc function; -} attribute_jump_array[] = -{ - { VCFullNameProp, parse_full_name }, - { VCNameProp, parse_name }, - { VCBirthDateProp, parse_bday }, - { VCEmailAddressProp, parse_email }, - { VCTelephoneProp, parse_phone }, - { VCAdrProp, parse_address }, - { VCURLProp, parse_url }, - { VCOrgProp, parse_org }, - { VCTitleProp, parse_title }, - { VCBusinessRoleProp, parse_role }, - { "NICKNAME", parse_nickname }, - { "FBURL", parse_fburl }, - { VCNoteProp, parse_note }, - { VCUniqueStringProp, parse_id } -}; - -/** - * e_card_get_type: - * @void: - * - * Registers the &ECard class if necessary, and returns the type ID - * associated to it. - * - * Return value: The type ID of the &ECard class. - **/ -GtkType -e_card_get_type (void) -{ - static GtkType card_type = 0; - - if (!card_type) { - GtkTypeInfo card_info = { - "ECard", - sizeof (ECard), - sizeof (ECardClass), - (GtkClassInitFunc) e_card_class_init, - (GtkObjectInitFunc) e_card_init, - NULL, /* reserved_1 */ - NULL, /* reserved_2 */ - (GtkClassInitFunc) NULL - }; - - card_type = gtk_type_unique (gtk_object_get_type (), &card_info); - } - - return card_type; -} - -/** - * e_card_new: - * @vcard: a string in vCard format - * - * Returns: a new #ECard that wraps the @vcard. - */ -ECard * -e_card_new (char *vcard) -{ - ECard *card = E_CARD(gtk_type_new(e_card_get_type())); - VObject *vobj = Parse_MIME(vcard, strlen(vcard)); - while(vobj) { - VObject *next; - parse(card, vobj); - next = nextVObjectInList(vobj); - cleanVObject(vobj); - vobj = next; - } - return card; -} - -ECard *e_card_duplicate(ECard *card) -{ - char *vcard = e_card_get_vcard(card); - ECard *new_card = e_card_new(vcard); - g_free (vcard); - return new_card; -} - -/** - * e_card_get_id: - * @card: an #ECard - * - * Returns: a string representing the id of the card, which is unique - * within its book. - */ -char * -e_card_get_id (ECard *card) -{ - return card->id; -} - -/** - * e_card_get_id: - * @card: an #ECard - * @id: a id in string format - * - * Sets the identifier of a card, which should be unique within its - * book. - */ -void -e_card_set_id (ECard *card, const char *id) -{ - if ( card->id ) - g_free(card->id); - card->id = g_strdup(id); -} - -/** - * e_card_get_vcard: - * @card: an #ECard - * - * Returns: a string in vCard format, which is wrapped by the @card. - */ -char -*e_card_get_vcard (ECard *card) -{ - VObject *vobj; /*, *vprop; */ - char *temp, *ret_val; - - vobj = newVObject (VCCardProp); - - if ( card->fname ) - addPropValue(vobj, VCFullNameProp, card->fname); - - if ( card->name ) { - VObject *nameprop; - nameprop = addProp(vobj, VCNameProp); - if ( card->name->prefix ) - addPropValue(nameprop, VCNamePrefixesProp, card->name->prefix); - if ( card->name->given ) - addPropValue(nameprop, VCGivenNameProp, card->name->given); - if ( card->name->additional ) - addPropValue(nameprop, VCAdditionalNamesProp, card->name->additional); - if ( card->name->family ) - addPropValue(nameprop, VCFamilyNameProp, card->name->family); - if ( card->name->suffix ) - addPropValue(nameprop, VCNameSuffixesProp, card->name->suffix); - } - - - if ( card->address ) { - ECardIterator *iterator = e_card_list_get_iterator(card->address); - for ( ; e_card_iterator_is_valid(iterator) ;e_card_iterator_next(iterator) ) { - VObject *addressprop; - ECardDeliveryAddress *address = (ECardDeliveryAddress *) e_card_iterator_get(iterator); - addressprop = addProp(vobj, VCAdrProp); - - set_address_flags (addressprop, address->flags); - if ( address->po ) - addPropValue(addressprop, VCPostalBoxProp, address->po); - if ( address->ext ) - addPropValue(addressprop, VCExtAddressProp, address->ext); - if ( address->street ) - addPropValue(addressprop, VCStreetAddressProp, address->street); - if ( address->city ) - addPropValue(addressprop, VCCityProp, address->city); - if ( address->region ) - addPropValue(addressprop, VCRegionProp, address->region); - if ( address->code ) - addPropValue(addressprop, VCPostalCodeProp, address->code); - if ( address->country ) - addPropValue(addressprop, VCCountryNameProp, address->country); - } - gtk_object_unref(GTK_OBJECT(iterator)); - } - - if ( card->phone ) { - ECardIterator *iterator = e_card_list_get_iterator(card->phone); - for ( ; e_card_iterator_is_valid(iterator) ;e_card_iterator_next(iterator) ) { - VObject *phoneprop; - ECardPhone *phone = (ECardPhone *) e_card_iterator_get(iterator); - phoneprop = addPropValue(vobj, VCTelephoneProp, phone->number); - - set_phone_flags (phoneprop, phone->flags); - } - gtk_object_unref(GTK_OBJECT(iterator)); - } - - if ( card->email ) { - ECardIterator *iterator = e_card_list_get_iterator(card->email); - for ( ; e_card_iterator_is_valid(iterator) ;e_card_iterator_next(iterator) ) { - VObject *emailprop; - emailprop = addPropValue(vobj, VCEmailAddressProp, (char *) e_card_iterator_get(iterator)); - addProp (emailprop, VCInternetProp); - } - gtk_object_unref(GTK_OBJECT(iterator)); - } - - if ( card->bday ) { - ECardDate date; - char *value; - date = *card->bday; - date.year = MIN(date.year, 9999); - date.month = MIN(date.month, 12); - date.day = MIN(date.day, 31); - value = g_strdup_printf("%04d-%02d-%02d", date.year, date.month, date.day); - addPropValue(vobj, VCBirthDateProp, value); - g_free(value); - } - - if (card->url) - addPropValue(vobj, VCURLProp, card->url); - - if (card->org || card->org_unit) { - VObject *orgprop; - orgprop = addProp(vobj, VCOrgProp); - - if (card->org) - addPropValue(orgprop, VCOrgNameProp, card->org); - if (card->org_unit) - addPropValue(orgprop, VCOrgUnitProp, card->org_unit); - } - - if (card->title) - addPropValue(vobj, VCTitleProp, card->title); - - if (card->role) - addPropValue(vobj, VCBusinessRoleProp, card->role); - - if (card->nickname) - addPropValue(vobj, "NICKNAME", card->nickname); - - if (card->fburl) - addPropValue(vobj, "FBURL", card->fburl); - - if (card->note) - addPropValue(vobj, VCNoteProp, card->note); - - if (card->id) - addPropValue (vobj, VCUniqueStringProp, card->id); - -#if 0 - - - if (crd->photo.prop.used) { - vprop = addPropSizedValue (vobj, VCPhotoProp, - crd->photo.data, crd->photo.size); - add_PhotoType (vprop, crd->photo.type); - add_CardProperty (vprop, &crd->photo.prop); - } - - if (crd->xtension.l) { - GList *node; - - for (node = crd->xtension.l; node; node = node->next) { - CardXProperty *xp = (CardXProperty *) node->data; - addPropValue (vobj, xp->name, xp->data); - add_CardProperty (vobj, &xp->prop); - } - } - - if (crd->dellabel.l) { - GList *node; - - for (node = crd->dellabel.l; node; node = node->next) { - CardDelLabel *dellabel = (CardDelLabel *) node->data; - - vprop = add_strProp (vobj, VCDeliveryLabelProp, - dellabel->data); - add_AddrType (vprop, dellabel->type); - add_CardProperty (vprop, &dellabel->prop); - } - } - - add_CardStrProperty (vobj, VCMailerProp, &crd->mailer); - - if (crd->timezn.prop.used) { - char *str; - - str = card_timezn_str (crd->timezn); - vprop = addPropValue (vobj, VCTimeZoneProp, str); - free (str); - add_CardProperty (vprop, &crd->timezn.prop); - } - - if (crd->geopos.prop.used) { - char *str; - - str = card_geopos_str (crd->geopos); - vprop = addPropValue (vobj, VCGeoLocationProp, str); - free (str); - add_CardProperty (vprop, &crd->geopos.prop); - } - - add_CardStrProperty (vobj, VCBusinessRoleProp, &crd->role); - - if (crd->logo.prop.used) { - vprop = addPropSizedValue (vobj, VCLogoProp, - crd->logo.data, crd->logo.size); - add_PhotoType (vprop, crd->logo.type); - add_CardProperty (vprop, &crd->logo.prop); - } - - if (crd->agent) - addVObjectProp (vobj, card_convert_to_vobject (crd->agent)); - - if (crd->org.prop.used) { - vprop = addProp (vobj, VCOrgProp); - add_strProp (vprop, VCOrgNameProp, crd->org.name); - add_strProp (vprop, VCOrgUnitProp, crd->org.unit1); - add_strProp (vprop, VCOrgUnit2Prop, crd->org.unit2); - add_strProp (vprop, VCOrgUnit3Prop, crd->org.unit3); - add_strProp (vprop, VCOrgUnit4Prop, crd->org.unit4); - add_CardProperty (vprop, &crd->org.prop); - } - - add_CardStrProperty (vobj, VCCategoriesProp, &crd->categories); - add_CardStrProperty (vobj, VCCommentProp, &crd->comment); - - if (crd->sound.prop.used) { - if (crd->sound.type != SOUND_PHONETIC) - vprop = addPropSizedValue (vobj, VCPronunciationProp, - crd->sound.data, crd->sound.size); - else - vprop = addPropValue (vobj, VCPronunciationProp, - crd->sound.data); - - add_SoundType (vprop, crd->sound.type); - add_CardProperty (vprop, &crd->sound.prop); - } - - if (crd->key.prop.used) { - vprop = addPropValue (vobj, VCPublicKeyProp, crd->key.data); - add_KeyType (vprop, crd->key.type); - add_CardProperty (vprop, &crd->key.prop); - } -#endif - temp = writeMemVObject(NULL, NULL, vobj); - ret_val = g_strdup(temp); - free(temp); - return ret_val; -} - -static void -parse_name(ECard *card, VObject *vobj) -{ - if ( card->name ) { - e_card_name_free(card->name); - } - card->name = g_new(ECardName, 1); - - card->name->family = e_v_object_get_child_value (vobj, VCFamilyNameProp); - card->name->given = e_v_object_get_child_value (vobj, VCGivenNameProp); - card->name->additional = e_v_object_get_child_value (vobj, VCAdditionalNamesProp); - card->name->prefix = e_v_object_get_child_value (vobj, VCNamePrefixesProp); - card->name->suffix = e_v_object_get_child_value (vobj, VCNameSuffixesProp); -} - -static void -parse_full_name(ECard *card, VObject *vobj) -{ - if ( card->fname ) - g_free(card->fname); - assign_string(vobj, &(card->fname)); -} - -static void -parse_email(ECard *card, VObject *vobj) -{ - char *next_email; - ECardList *list; - - assign_string(vobj, &next_email); - gtk_object_get(GTK_OBJECT(card), - "email", &list, - NULL); - e_card_list_append(list, next_email); - g_free (next_email); -} - -static void -parse_bday(ECard *card, VObject *vobj) -{ - if ( vObjectValueType (vobj) ) { - char *str = fakeCString (vObjectUStringZValue (vobj)); - if ( card->bday ) - g_free(card->bday); - card->bday = g_new(ECardDate, 1); - *(card->bday) = e_card_date_from_string(str); - free(str); - } -} - -static void -parse_phone(ECard *card, VObject *vobj) -{ - ECardPhone *next_phone = g_new(ECardPhone, 1); - ECardList *list; - - assign_string(vobj, &(next_phone->number)); - next_phone->flags = get_phone_flags(vobj); - - gtk_object_get(GTK_OBJECT(card), - "phone", &list, - NULL); - e_card_list_append(list, next_phone); - e_card_phone_free (next_phone); -} - -static void -parse_address(ECard *card, VObject *vobj) -{ - ECardDeliveryAddress *next_addr = g_new(ECardDeliveryAddress, 1); - ECardList *list; - - next_addr->flags = get_address_flags (vobj); - next_addr->po = e_v_object_get_child_value (vobj, VCPostalBoxProp); - next_addr->ext = e_v_object_get_child_value (vobj, VCExtAddressProp); - next_addr->street = e_v_object_get_child_value (vobj, VCStreetAddressProp); - next_addr->city = e_v_object_get_child_value (vobj, VCCityProp); - next_addr->region = e_v_object_get_child_value (vobj, VCRegionProp); - next_addr->code = e_v_object_get_child_value (vobj, VCPostalCodeProp); - next_addr->country = e_v_object_get_child_value (vobj, VCCountryNameProp); - - gtk_object_get(GTK_OBJECT(card), - "address", &list, - NULL); - e_card_list_append(list, next_addr); - e_card_delivery_address_free (next_addr); -} - -static void -parse_url(ECard *card, VObject *vobj) -{ - if (card->url) - g_free(card->url); - assign_string(vobj, &(card->url)); -} - -static void -parse_org(ECard *card, VObject *vobj) -{ - char *temp; - - temp = e_v_object_get_child_value(vobj, VCOrgNameProp); - if (temp) { - if (card->org) - g_free(card->org); - card->org = temp; - } - temp = e_v_object_get_child_value(vobj, VCOrgUnitProp); - if (temp) { - if (card->org_unit) - g_free(card->org_unit); - card->org_unit = temp; - } -} - -static void -parse_title(ECard *card, VObject *vobj) -{ - if ( card->title ) - g_free(card->title); - assign_string(vobj, &(card->title)); -} - -static void -parse_role(ECard *card, VObject *vobj) -{ - if (card->role) - g_free(card->role); - assign_string(vobj, &(card->role)); -} - -static void -parse_nickname(ECard *card, VObject *vobj) -{ - if (card->nickname) - g_free(card->nickname); - assign_string(vobj, &(card->nickname)); -} - -static void -parse_fburl(ECard *card, VObject *vobj) -{ - if (card->fburl) - g_free(card->fburl); - assign_string(vobj, &(card->fburl)); -} - -static void -parse_note(ECard *card, VObject *vobj) -{ - if (card->note) - g_free(card->note); - assign_string(vobj, &(card->note)); -} - -static void -parse_id(ECard *card, VObject *vobj) -{ - if ( card->id ) - g_free(card->id); - assign_string(vobj, &(card->id)); -} - -static void -parse_attribute(ECard *card, VObject *vobj) -{ - ParsePropertyFunc function = g_hash_table_lookup(E_CARD_CLASS(GTK_OBJECT(card)->klass)->attribute_jump_table, vObjectName(vobj)); - if ( function ) - function(card, vobj); -} - -static void -parse(ECard *card, VObject *vobj) -{ - VObjectIterator iterator; - initPropIterator(&iterator, vobj); - while(moreIteration (&iterator)) { - parse_attribute(card, nextVObject(&iterator)); - } -} - -static void -e_card_class_init (ECardClass *klass) -{ - int i; - GtkObjectClass *object_class; - - object_class = GTK_OBJECT_CLASS(klass); - - klass->attribute_jump_table = g_hash_table_new(g_str_hash, g_str_equal); - - for ( i = 0; i < sizeof(attribute_jump_array) / sizeof(attribute_jump_array[0]); i++ ) { - g_hash_table_insert(klass->attribute_jump_table, attribute_jump_array[i].key, attribute_jump_array[i].function); - } - - gtk_object_add_arg_type ("ECard::full_name", - GTK_TYPE_STRING, GTK_ARG_READWRITE, ARG_FULL_NAME); - gtk_object_add_arg_type ("ECard::name", - GTK_TYPE_POINTER, GTK_ARG_READWRITE, ARG_NAME); - gtk_object_add_arg_type ("ECard::address", - GTK_TYPE_OBJECT, GTK_ARG_READABLE, ARG_ADDRESS); - gtk_object_add_arg_type ("ECard::phone", - GTK_TYPE_OBJECT, GTK_ARG_READABLE, ARG_PHONE); - gtk_object_add_arg_type ("ECard::email", - GTK_TYPE_OBJECT, GTK_ARG_READABLE, ARG_EMAIL); - gtk_object_add_arg_type ("ECard::birth_date", - GTK_TYPE_POINTER, GTK_ARG_READWRITE, ARG_BIRTH_DATE); - gtk_object_add_arg_type ("ECard::url", - GTK_TYPE_STRING, GTK_ARG_READWRITE, ARG_URL); - gtk_object_add_arg_type ("ECard::org", - GTK_TYPE_STRING, GTK_ARG_READWRITE, ARG_ORG); - gtk_object_add_arg_type ("ECard::org_unit", - GTK_TYPE_STRING, GTK_ARG_READWRITE, ARG_ORG_UNIT); - gtk_object_add_arg_type ("ECard::title", - GTK_TYPE_STRING, GTK_ARG_READWRITE, ARG_TITLE); - gtk_object_add_arg_type ("ECard::role", - GTK_TYPE_STRING, GTK_ARG_READWRITE, ARG_ROLE); - gtk_object_add_arg_type ("ECard::nickname", - GTK_TYPE_STRING, GTK_ARG_READWRITE, ARG_NICKNAME); - gtk_object_add_arg_type ("ECard::fburl", - GTK_TYPE_STRING, GTK_ARG_READWRITE, ARG_FBURL); - gtk_object_add_arg_type ("ECard::note", - GTK_TYPE_STRING, GTK_ARG_READWRITE, ARG_NOTE); - gtk_object_add_arg_type ("ECard::id", - GTK_TYPE_STRING, GTK_ARG_READWRITE, ARG_ID); - - - object_class->destroy = e_card_destroy; - object_class->get_arg = e_card_get_arg; - object_class->set_arg = e_card_set_arg; -} - -void -e_card_phone_free (ECardPhone *phone) -{ - if ( phone ) { - if ( phone->number ) - g_free(phone->number); - g_free(phone); - } -} - -ECardPhone * -e_card_phone_copy (const ECardPhone *phone) -{ - if ( phone ) { - ECardPhone *phone_copy = g_new(ECardPhone, 1); - phone_copy->number = g_strdup(phone->number); - phone_copy->flags = phone->flags; - return phone_copy; - } else - return NULL; -} - -void -e_card_delivery_address_free (ECardDeliveryAddress *addr) -{ - if ( addr ) { - if ( addr->po ) - g_free(addr->po); - if ( addr->ext ) - g_free(addr->ext); - if ( addr->street ) - g_free(addr->street); - if ( addr->city ) - g_free(addr->city); - if ( addr->region ) - g_free(addr->region); - if ( addr->code ) - g_free(addr->code); - if ( addr->country ) - g_free(addr->country); - g_free(addr); - } -} - -ECardDeliveryAddress * -e_card_delivery_address_copy (const ECardDeliveryAddress *addr) -{ - if ( addr ) { - ECardDeliveryAddress *addr_copy = g_new(ECardDeliveryAddress, 1); - addr_copy->po = g_strdup(addr->po ); - addr_copy->ext = g_strdup(addr->ext ); - addr_copy->street = g_strdup(addr->street ); - addr_copy->city = g_strdup(addr->city ); - addr_copy->region = g_strdup(addr->region ); - addr_copy->code = g_strdup(addr->code ); - addr_copy->country = g_strdup(addr->country); - addr_copy->flags = addr->flags; - return addr_copy; - } else - return NULL; -} - -/* - * ECard lifecycle management and vCard loading/saving. - */ - -static void -e_card_destroy (GtkObject *object) -{ - ECard *card = E_CARD(object); - if ( card->id ) - g_free(card->id); - if ( card->fname ) - g_free(card->fname); - if ( card->name ) - e_card_name_free(card->name); - if ( card->bday ) - g_free(card->bday); - - if (card->url) - g_free(card->url); - if (card->org) - g_free(card->org); - if (card->org_unit) - g_free(card->org_unit); - if (card->title) - g_free(card->title); - if (card->role) - g_free(card->role); - if (card->nickname) - g_free(card->nickname); - if (card->fburl) - g_free(card->fburl); - if (card->note) - g_free(card->note); - - if (card->email) - gtk_object_unref(GTK_OBJECT(card->email)); - if (card->phone) - gtk_object_unref(GTK_OBJECT(card->phone)); - if (card->address) - gtk_object_unref(GTK_OBJECT(card->address)); -} - - -/* Set_arg handler for the card */ -static void -e_card_set_arg (GtkObject *object, GtkArg *arg, guint arg_id) -{ - ECard *card; - - card = E_CARD (object); - - switch (arg_id) { - case ARG_FULL_NAME: - if ( card->fname ) - g_free(card->fname); - card->fname = g_strdup(GTK_VALUE_STRING(*arg)); - break; - case ARG_NAME: - if ( card->name ) - e_card_name_free(card->name); - card->name = GTK_VALUE_POINTER(*arg); - break; - case ARG_BIRTH_DATE: - if ( card->bday ) - g_free(card->bday); - card->bday = GTK_VALUE_POINTER(*arg); - break; - case ARG_URL: - if ( card->url ) - g_free(card->url); - card->url = g_strdup(GTK_VALUE_STRING(*arg)); - break; - case ARG_ORG: - if (card->org) - g_free(card->org); - card->org = g_strdup(GTK_VALUE_STRING(*arg)); - break; - case ARG_ORG_UNIT: - if (card->org_unit) - g_free(card->org_unit); - card->org_unit = g_strdup(GTK_VALUE_STRING(*arg)); - break; - case ARG_TITLE: - if ( card->title ) - g_free(card->title); - card->title = g_strdup(GTK_VALUE_STRING(*arg)); - break; - case ARG_ROLE: - if (card->role) - g_free(card->role); - card->role = g_strdup(GTK_VALUE_STRING(*arg)); - break; - case ARG_NICKNAME: - if (card->nickname) - g_free(card->nickname); - card->nickname = g_strdup(GTK_VALUE_STRING(*arg)); - break; - case ARG_FBURL: - if (card->fburl) - g_free(card->fburl); - card->fburl = g_strdup(GTK_VALUE_STRING(*arg)); - break; - case ARG_NOTE: - if (card->note) - g_free (card->note); - card->note = g_strdup(GTK_VALUE_STRING(*arg)); - break; - case ARG_ID: - if (card->id) - g_free(card->id); - card->id = g_strdup(GTK_VALUE_STRING(*arg)); - break; - default: - return; - } -} - -/* Get_arg handler for the card */ -static void -e_card_get_arg (GtkObject *object, GtkArg *arg, guint arg_id) -{ - ECard *card; - - card = E_CARD (object); - - switch (arg_id) { - case ARG_FULL_NAME: - GTK_VALUE_STRING (*arg) = card->fname; - break; - case ARG_NAME: - GTK_VALUE_POINTER(*arg) = card->name; - break; - case ARG_ADDRESS: - if (!card->address) - card->address = e_card_list_new((ECardListCopyFunc) e_card_delivery_address_copy, - (ECardListFreeFunc) e_card_delivery_address_free, - NULL); - GTK_VALUE_OBJECT(*arg) = GTK_OBJECT(card->address); - break; - case ARG_PHONE: - if (!card->phone) - card->phone = e_card_list_new((ECardListCopyFunc) e_card_phone_copy, - (ECardListFreeFunc) e_card_phone_free, - NULL); - GTK_VALUE_OBJECT(*arg) = GTK_OBJECT(card->phone); - break; - case ARG_EMAIL: - if (!card->email) - card->email = e_card_list_new((ECardListCopyFunc) g_strdup, - (ECardListFreeFunc) g_free, - NULL); - GTK_VALUE_OBJECT(*arg) = GTK_OBJECT(card->email); - break; - case ARG_BIRTH_DATE: - GTK_VALUE_POINTER(*arg) = card->bday; - break; - case ARG_URL: - GTK_VALUE_STRING(*arg) = card->url; - break; - case ARG_ORG: - GTK_VALUE_STRING(*arg) = card->org; - break; - case ARG_ORG_UNIT: - GTK_VALUE_STRING(*arg) = card->org_unit; - break; - case ARG_TITLE: - GTK_VALUE_STRING(*arg) = card->title; - break; - case ARG_ROLE: - GTK_VALUE_STRING(*arg) = card->role; - break; - case ARG_NICKNAME: - GTK_VALUE_STRING(*arg) = card->nickname; - break; - case ARG_FBURL: - GTK_VALUE_STRING(*arg) = card->fburl; - break; - case ARG_NOTE: - GTK_VALUE_STRING(*arg) = card->note; - break; - case ARG_ID: - GTK_VALUE_STRING(*arg) = card->id; - break; - default: - arg->type = GTK_TYPE_INVALID; - break; - } -} - - -/** - * e_card_init: - */ -static void -e_card_init (ECard *card) -{ - card->id = g_strdup(""); - - card->fname = NULL; - card->name = NULL; - card->bday = NULL; - card->email = NULL; - card->phone = NULL; - card->address = NULL; - card->url = NULL; - card->org = NULL; - card->org_unit = NULL; - card->title = NULL; - card->role = NULL; - card->nickname = NULL; - card->fburl = NULL; - card->note = NULL; -#if 0 - - c = g_new0 (ECard, 1); - - c->fname = - c->mailer = - c->role = - c->comment = - c->categories = - c->uid = e_card_prop_str_empty (); - - c->photo.type = PHOTO_JPEG; - c->logo.type = PHOTO_JPEG; - c->rev.utc = -1; - c->sound.type = SOUND_PHONETIC; - c->key.type = KEY_PGP; - - c->categories.prop.encod = ENC_QUOTED_PRINTABLE; - c->comment.prop.encod = ENC_QUOTED_PRINTABLE; - - c->name.prop = c->photo.prop = c->bday.prop = c->timezn.prop = - c->geopos.prop = c->logo.prop = c->org.prop = c->rev.prop = - c->sound.prop = c->key.prop = c->deladdr.prop = c->dellabel.prop = - c->phone.prop = c->email.prop = c->xtension.prop = c->prop = e_card_prop_empty (); - - c->prop.type = PROP_CARD; - c->fname.prop.type = PROP_FNAME; - c->name.prop.type = PROP_NAME; - c->photo.prop.type = PROP_PHOTO; - c->bday.prop.type = PROP_BDAY; - - c->deladdr.prop.type = PROP_DELADDR_LIST; - c->dellabel.prop.type = PROP_DELLABEL_LIST; - c->phone.prop.type = PROP_PHONE_LIST; - c->email.prop.type = PROP_EMAIL_LIST; - c->xtension.prop.type = PROP_XTENSION_LIST; - c->mailer.prop.type = PROP_MAILER; - c->timezn.prop.type = PROP_TIMEZN; - c->geopos.prop.type = PROP_GEOPOS; - c->role.prop.type = PROP_ROLE; - c->logo.prop.type = PROP_LOGO; - c->org.prop.type = PROP_ORG; - c->categories.prop.type = PROP_CATEGORIES; - c->comment.prop.type = PROP_COMMENT; - c->rev.prop.type = PROP_REV; - c->sound.prop.type = PROP_SOUND; - c->uid.prop.type = PROP_UID; - c->key.prop.type = PROP_KEY; - - return c; -#endif -} - -static void -assign_string(VObject *vobj, char **string) -{ - char *str = (vObjectValueType (vobj) ? fakeCString (vObjectUStringZValue (vobj)) : calloc(1, 1)); - *string = g_strdup(str); - free(str); -} - -#if 0 -static void -e_card_str_free (CardStrProperty *sp) -{ - g_free (sp->str); - - e_card_prop_free (sp->prop); -} - -static void -e_card_name_free (CardName *name) -{ - g_free (name->family); - g_free (name->given); - g_free (name->additional); - g_free (name->prefix); - g_free (name->suffix); - - e_card_prop_free (name->prop); -} - -static void -e_card_photo_free (CardPhoto *photo) -{ - g_free (photo->data); - - e_card_prop_free (photo->prop); -} - -/** - * e_card_free: - */ -void -e_card_free (ECard *card) -{ - GList *l; - - g_return_if_fail (card != NULL); - - e_card_name_free (& card->name); - e_card_str_free (& card->fname); - - e_card_photo_free (card->photo); - - e_card_logo_free (card->logo); - e_card_org_free (card->org); - e_card_key_free (card->key); - e_card_sound_free (card->sound); - - e_card_prop_str_free (& card->mailer); - e_card_prop_str_free (& card->role); - e_card_prop_str_free (& card->categories); - e_card_prop_str_free (& card->comment); - e_card_prop_str_free (& card->uid); - - /* address is a little more complicated */ - card_prop_free (card->deladdr.prop); - while ((l = card->deladdr.l)) { - - e_card_deladdr_free ((CardDelAddr *) l->data); - - card->deladdr.l = g_list_remove_link (card->deladdr.l, l); - g_list_free (l); - } - - g_free (card); -} - -typedef struct -{ - char c; - int id; - - GList *sons; -} tree; - -extern CardProperty -e_card_prop_empty (void) -{ - CardProperty prop; - - prop.used = FALSE; - - prop.type = PROP_NONE; - prop.encod = ENC_7BIT; - prop.value = VAL_INLINE; - prop.charset = NULL; - prop.lang = NULL; - prop.grp = NULL; - prop.xtension = NULL; - - prop.user_data = NULL; - - return prop; -} - -static CardStrProperty -e_card_prop_str_empty (void) -{ - CardStrProperty strprop; - - strprop.prop = card_prop_empty (); - strprop.str = NULL; - - return strprop; -} - -/* Intended to check asserts. */ -extern int card_check_prop (ECardProperty prop) -{ - if (((prop.used == FALSE) || (prop.used == TRUE)) && - ((prop.type >= PROP_NONE) && (prop.type <= PROP_LAST)) && - ((prop.encod >= ENC_NONE) && (prop.encod <= ENC_LAST)) && - ((prop.value >= VAL_NONE) && (prop.value <= VAL_LAST))) - return TRUE; - - return FALSE; -} - -extern void -card_prop_free (CardProperty prop) -{ - GList *l; - - g_free (prop.charset); - g_free (prop.lang); - - for (l = prop.xtension; l; l = l->next) { - CardXAttribute *xa = (CardXAttribute *) l->data; - g_free (xa->name); - g_free (xa->data); - } - - g_list_free (l); - - prop.used = FALSE; -} - -e_card_deladdr_free (ECardDelAddr *c) -{ - card_prop_free (c->prop); - - g_free (p->pobox); - g_free (p->ext); - g_free (p->street); - g_free (p->city); - g_free (p->region); - g_free (p->code); - g_free (p->country); -} - -void -card_free (Card *crd) -{ -} - -static tree * -new_tree (char c, int id) -{ - tree *t; - - t = malloc (sizeof (tree)); - t->c = c; - t->id = id; - t->sons = NULL; - - return t; -} - -static void -add_branch (tree *t, char *str, int id) -{ - tree *tmp; - char *end; - - end = str + strlen (str) + 1; - - while (str != end) { - tmp = new_tree (*str, id); - t->sons = g_list_append (t->sons, (gpointer) tmp); - t = tmp; - - str ++; - } -} - -static tree * -add_to_tree (tree *t, struct pair p) -{ - GList *node; - char *c, *end; - tree *tmp; - - c = p.str; - end = c + strlen (c) + 1; - tmp = t; - - while (c != end) { - for (node = tmp->sons; node; node = node->next) - if (((tree *) node->data)->c == *c) { - break; - } - - if (node) { - tmp = (tree *) node->data; - tmp->id = 0; - c++; - } - else { - add_branch (tmp, c, p.id); - break; - } - } - - return t; -} - -static tree * -create_search_tree (void) -{ - tree *t; - int i; - - t = new_tree (0, 0); - for (i = 0; prop_lookup[i].str; i++) - t = add_to_tree (t, prop_lookup[i]); - - return t; -} - -static int -card_lookup_name (const char *c) -{ - static tree *search_tree = NULL; - GList *node; - tree *tmp; - const char *end; - - if (!search_tree) - search_tree = create_search_tree (); - - tmp = search_tree; - end = c + strlen (c) + 1; - - while (tmp->id == 0 && c != end) { - for (node = tmp->sons; node; node = node->next) - if (((tree *) node->data)->c == *c) { - break; - } - - if (node) { - tmp = (tree *) node->data; - c++; - } - else - return 0; - } - - return tmp->id; -} - -static enum PhotoType -get_photo_type (VObject *o) -{ - VObject *vo; - int i; - - for (i = 0; photo_pairs[i].str; i++) - if (has (o, photo_pairs[i].str)) - return photo_pairs[i].id; - - g_warning ("? < No PhotoType for Photo property. Falling back to JPEG."); - return PHOTO_JPEG; -} - -static CardProperty -get_CardProperty (VObject *o) -{ - VObjectIterator i; - CardProperty prop; - - prop = card_prop_empty (); - prop.used = TRUE; - - initPropIterator (&i, o); - while (moreIteration (&i)) { - VObject *vo = nextVObject (&i); - const char *n = vObjectName (vo); - int propid; - - propid = card_lookup_name (n); - - switch (propid) { - - case PROP_VALUE: - - if (has (vo, VCContentIDProp)) - prop.value = VAL_CID; - break; - - case PROP_ENCODING: - if (has (vo, VCQuotedPrintableProp)) - prop.encod = ENC_QUOTED_PRINTABLE; - else if (has (vo, VC8bitProp)) - prop.encod = ENC_8BIT; - else if (has (vo, VCBase64Prop)) - prop.encod = ENC_BASE64; - break; - - case PROP_QUOTED_PRINTABLE: - prop.encod = ENC_QUOTED_PRINTABLE; - break; - - case PROP_8BIT: - prop.encod = ENC_8BIT; - break; - - case PROP_BASE64: - prop.encod = ENC_BASE64; - break; - - case PROP_LANG: - if (vObjectValueType (vo)) { - prop.lang = - g_strdup (vObjectStringZValue (vo)); - } else - g_warning ("? < No value for LANG attribute."); - break; - - case PROP_CHARSET: - if (vObjectValueType (vo)) { - prop.charset = - g_strdup (vObjectStringZValue (vo)); - g_warning (prop.charset); - } else - g_warning ("? < No value for CHARSET attribute."); - break; - default: - { - CardXAttribute *c; - - c = malloc (sizeof (CardXAttribute)); - c->name = g_strdup (n); - - if (vObjectValueType (vo)) - c->data = - g_strdup (vObjectStringZValue (vo)); - else - c->data = NULL; - - prop.xtension = - g_list_append (prop.xtension, c); - } - } - } - - return prop; -} - -static gboolean -e_card_prop_has (VObject *o, - const char *id) -{ - g_assert (o != NULL); - g_assert (id != NULL); - - if (isAPropertyOf (o, id) == NULL) - return FALSE; - - return TRUE; -} - -static const char * -e_card_prop_get_str (VObject *o, - const char *id) -{ - VObject *strobj; - - g_assert (o != NULL); - g_assert (id != NULL); - - strobj = isAPropertyOf (o, id); - - if (strobj == NULL) - return g_strdup (""); - - if (vObjectValueType (strobj) != NULL) { - char *str; - char *g_str; - - str = fakeCString (vObjectStringZValue (strobj)); - g_str = g_strdup (str); - free (str); - - return g_str; - } - - return g_strdup (""); -} - -static ECardName * -e_card_get_name (VObject *o) -{ - CardName *name; - VObject *vo; - char *the_str; - - name = g_new0 (ECardName, 1); - - name->family = e_card_prop_get_substr (o, VCFamilyNameProp); - name->given = e_card_prop_get_substr (o, VCGivenNameProp); - name->additional = e_card_prop_get_substr (o, VCAdditionalNamesProp); - name->prefix = e_card_prop_get_substr (o, VCNamePrefixesProp); - name->suffix = e_card_prop_get_substr (o, VCNameSuffixesProp); - - return name; -} - -static CardDelLabel * -get_CardDelLabel (VObject *o) -{ - CardDelLabel *dellabel; - char *the_str; - - dellabel = malloc (sizeof (CardDelLabel)); - - dellabel->type = get_addr_type (o); - dellabel->data = g_strdup (str_val (o)); - - free (the_str); - return dellabel; -} - -static CardPhone * -get_CardPhone (VObject *o) -{ - CardPhone *ret; - char *the_str; - - ret = malloc (sizeof (CardPhone)); - ret->type = get_phone_type (o); - ret->data = g_strdup (str_val (o)); - - free (the_str); - - return ret; -} - -static CardEMail * -get_CardEMail (VObject *o) -{ - CardEMail *ret; - char *the_str; - - ret = malloc (sizeof (CardEMail)); - ret->type = get_email_type (o); - ret->data = g_strdup (str_val (o)); - - free (the_str); - - return ret; -} - -static CardTimeZone -strtoCardTimeZone (char *str) -{ - char s[3]; - CardTimeZone tz; - - if (*str == '-') { - tz.sign = -1; - str++; - } else - tz.sign = 1; - - tz.hours = 0; - tz.mins = 0; - - s[2] = 0; - if (strlen (str) > 2) { - s[0] = str[0]; - s[1] = str[1]; - tz.hours = atoi (s); - } else { - g_warning ("? < TimeZone value is too short."); - return tz; - } - - str += 2; - if (*str == ':') - str++; - - if (strlen (str) >= 2) { - s[0] = str[0]; - s[1] = str[1]; - tz.mins = atoi (s); - } else { - g_warning ("? < TimeZone value is too short."); - return tz; - } - - if (strlen (str) > 3) - g_warning ("? < TimeZone value is too long."); - - return tz; -} - -static CardGeoPos -strtoCardGeoPos (char *str) -{ - CardGeoPos gp; - char *s; - - gp.lon = 0; - gp.lat = 0; - - s = strchr (str, ','); - - if (! s) { - g_warning ("? < Bad format for GeoPos property."); - return gp; - } - - *s = 0; - s++; - - gp.lon = atof (str); - gp.lat = atof (s); - - return gp; -} - -static CardOrg * -e_card_vobject_to_org (VObject *o) -{ - VObject *vo; - char *the_str; - CardOrg *org; - - org = g_new0 (CardOrg, 1); - - if (has (o, VCOrgNameProp)) { - org.name = g_strdup (str_val (vo)); - free (the_str); - } - if (has (o, VCOrgUnitProp)) { - org.unit1 = g_strdup (str_val (vo)); - free (the_str); - } - if (has (o, VCOrgUnit2Prop)) { - org.unit2 = g_strdup (str_val (vo)); - free (the_str); - } - if (has (o, VCOrgUnit3Prop)) { - org.unit3 = g_strdup (str_val (vo)); - free (the_str); - } - if (has (o, VCOrgUnit4Prop)) { - org.unit4 = g_strdup (str_val (vo)); - free (the_str); - } - - return org; -} - -static CardXProperty * -get_XProp (VObject *o) -{ - char *the_str; - CardXProperty *ret; - - ret = malloc (sizeof (CardXProperty)); - ret->name = g_strdup (vObjectName (o)); - ret->data = g_strdup (str_val (o)); - free (the_str); - - return ret; -} - -static CardRev -strtoCardRev (char *str) -{ - char s[3], *t, *ss; - int len, i; - CardRev rev; - - rev.utc = 0; - len = strlen (str); - - if (str[len] == 'Z') { /* Is it UTC? */ - rev.utc = 1; - str[len] = 0; - } - - s[2] = 0; - t = strchr (str, 'T'); - if (t) { /* Take the Time */ - *t = 0; - t++; - if (strlen (t) > 2) { - s[0] = t[0]; - s[1] = t[1]; - rev.tm.tm_hour = atoi (s); - } else { - g_warning ("? < Rev value is too short."); - return rev; - } - - t += 2; - if (*t == ':') /* Ignore ':' separator */ - t++; - - if (strlen (t) > 2) { - s[0] = t[0]; - s[1] = t[1]; - rev.tm.tm_min = atoi (s); - } else { - g_warning ("? < Rev value is too short."); - return rev; - } - - t += 2; - if (*t == ':') - t++; - - if (strlen (t) > 2) { - s[0] = t[0]; - s[1] = t[1]; - rev.tm.tm_sec = atoi (s); - } else { - g_warning ("? < Rev value is too short."); - return rev; - } - - if (strlen (str) > 3) - g_warning ("? < Rev value is too long."); - - } else { - g_warning ("? < No time value for Rev property."); - } - - /* Now the date (the part before the T) */ - - if (strchr (str, '-')) { /* extended iso 8601 */ - for (ss = strtok (str, "-"), i = 0; ss; - ss = strtok (NULL, "-"), i++) - switch (i) { - case 0: - rev.tm.tm_year = atoi (ss); - break; - case 1: - rev.tm.tm_mon = atoi (ss); - break; - case 2: - rev.tm.tm_mday = atoi (ss); - break; - default: - g_warning ("? < Too many values for Rev property."); - } - - if (i < 2) - g_warning ("? < Too few values for Rev property."); - } else { - if (strlen (str) >= 8) { /* short representation */ - rev.tm.tm_mday = atoi (str + 6); - str[6] = 0; - rev.tm.tm_mon = atoi (str + 4); - str[4] = 0; - rev.tm.tm_year = atoi (str); - } else - g_warning ("? < Bad format for Rev property."); - } - - return rev; -} - -static enum KeyType -get_key_type (VObject *o) -{ - VObject *vo; - int i; - - for (i = 0; key_pairs[i].str; i++) - if (has (o, key_pairs[i].str)) - return key_pairs[i].id; - - g_warning ("? < No KeyType for Key property. Falling back to PGP."); - return KEY_PGP; -} - -static CardPhoto -get_CardPhoto (VObject *o) -{ - VObject *vo; - char *the_str; - CardPhoto photo; - - photo.type = get_photo_type (o); - - if (has (o, VCDataSizeProp)) { - photo.size = vObjectIntegerValue (vo); - photo.data = malloc (photo.size); - memcpy (photo.data, vObjectAnyValue (o), photo.size); - } else { - photo.size = strlen (str_val (o)) + 1; - photo.data = g_strdup (the_str); - free (the_str); - } - - return photo; -} - -static enum SoundType -get_sound_type (VObject *o) -{ - VObject *vo; - int i; - - for (i = 0; sound_pairs[i].str; i++) - if (has (o, sound_pairs[i].str)) - return sound_pairs[i].id; - - return SOUND_PHONETIC; -} - -static CardSound -get_CardSound (VObject *o) -{ - VObject *vo; - char *the_str; - CardSound sound; - - sound.type = get_sound_type (o); - - if (has (o, VCDataSizeProp)) { - sound.size = vObjectIntegerValue (vo); - sound.data = malloc (sound.size); - memcpy (sound.data, vObjectAnyValue (o), sound.size); - } else { - sound.size = strlen (str_val (o)); - sound.data = g_strdup (the_str); - free (the_str); - } - - return sound; -} - -/* Loads our card contents from a VObject */ -static ECard * -e_card_construct_from_vobject (ECard *card, - VObject *vcrd) -{ - VObjectIterator i; - Card *crd; - char *the_str; - - initPropIterator (&i, vcrd); - crd = card_new (); - - while (moreIteration (&i)) { - VObject *o = nextVObject (&i); - const char *n = vObjectName (o); - int propid; - CardProperty *prop = NULL; - - propid = card_lookup_name (n); - - switch (propid) { - case PROP_FNAME: - prop = &crd->fname.prop; - crd->fname.str = g_strdup (str_val (o)); - free (the_str); - break; - case PROP_NAME: - prop = &crd->name.prop; - crd->name = e_card_get_name (o); - break; - case PROP_PHOTO: - prop = &crd->photo.prop; - crd->photo = get_CardPhoto (o); - break; - case PROP_BDAY: - prop = &crd->bday.prop; - crd->bday = strtoCardBDay (str_val (o)); - free (the_str); - break; - case PROP_DELADDR: - { - CardDelAddr *c; - c = get_CardDelAddr (o); - prop = &c->prop; - crd->deladdr.l = g_list_append (crd->deladdr.l, c); - } - break; - case PROP_DELLABEL: - { - CardDelLabel *c; - c = get_CardDelLabel (o); - prop = &c->prop; - crd->dellabel.l = g_list_append (crd->dellabel.l, c); - } - break; - case PROP_PHONE: - { - CardPhone *c; - - c = get_CardPhone (o); - prop = &c->prop; - crd->phone.l = g_list_append (crd->phone.l, c); - } - break; - case PROP_EMAIL: - { - CardEMail *c; - - c = get_CardEMail (o); - prop = &c->prop; - crd->email.l = g_list_append (crd->email.l, c); - } - break; - case PROP_MAILER: - prop = &crd->mailer.prop; - crd->mailer.str = g_strdup (str_val (o)); - free (the_str); - break; - case PROP_TIMEZN: - prop = &crd->timezn.prop; - crd->timezn = strtoCardTimeZone (str_val (o)); - free (the_str); - break; - case PROP_GEOPOS: - prop = &crd->geopos.prop; - crd->geopos = strtoCardGeoPos (str_val (o)); - break; - case PROP_ROLE: - prop = &crd->role.prop; - crd->role.str = g_strdup (str_val (o)); - free (the_str); - break; - case PROP_LOGO: - prop = &crd->logo.prop; - crd->logo = get_CardPhoto (o); - break; - case PROP_AGENT: - crd->agent = card_create_from_vobject (o); - break; - case PROP_ORG: - prop = &crd->org.prop; - crd->org = get_CardOrg (o); - break; - case PROP_CATEGORIES: - prop = &crd->categories.prop; - crd->categories.str = g_strdup (str_val (o)); - crd->categories.prop.encod = ENC_QUOTED_PRINTABLE; - free (the_str); - break; - case PROP_COMMENT: - prop = &crd->comment.prop; - crd->comment.str = g_strdup (str_val (o)); - crd->comment.prop.encod = ENC_QUOTED_PRINTABLE; - free (the_str); - break; - case PROP_REV: - prop = &crd->rev.prop; - crd->rev = strtoCardRev (str_val (o)); - free (the_str); - break; - case PROP_SOUND: - prop = &crd->sound.prop; - crd->sound = get_CardSound (o); - break; - case PROP_VERSION: - { - char *str; - str = str_val (o); - if (strcmp (str, "2.1")) - g_warning ("? < Version doesn't match."); - free (the_str); - } - break; - case PROP_KEY: - prop = &crd->key.prop; - crd->key.type = get_key_type (o); - crd->key.data = g_strdup (str_val (o)); - free (the_str); - break; - default: - { - CardXProperty *c; - - c = get_XProp (o); - prop = &c->prop; - crd->xtension.l = g_list_append (crd->xtension.l, c); - } - break; - } - - if (prop) { - *prop = get_CardProperty (o); - prop->type = propid; - } - } - - return crd; -} - -/* Loads a card from a file */ -GList * -card_load (GList *crdlist, char *fname) -{ - VObject *vobj, *tmp; - - vobj = Parse_MIME_FromFileName (fname); - if (!vobj) { - g_warning ("Could not load the cardfile"); - return NULL; - } - - while (vobj) { - const char *n = vObjectName (vobj); - - if (strcmp (n, VCCardProp) == 0) { - crdlist = g_list_append (crdlist, (gpointer) - card_create_from_vobject (vobj)); - } - tmp = vobj; - vobj = nextVObjectInList (vobj); - cleanVObject (tmp); - } - - cleanVObject (vobj); - cleanStrTbl (); - return crdlist; -} - -static VObject * -add_strProp (VObject *o, const char *id, char *val) -{ - VObject *vo = NULL; - - if (val) - vo = addPropValue (o, id, val); - - return vo; -} - -static VObject * -add_CardProperty (VObject *o, CardProperty *prop) -{ - GList *node; - - switch (prop->encod) { - case ENC_BASE64: - addProp (o, VCBase64Prop); - break; - case ENC_QUOTED_PRINTABLE: - addProp (o, VCQuotedPrintableProp); - break; - case ENC_8BIT: - addProp (o, VC8bitProp); - break; - case ENC_7BIT: - /* Do nothing: 7BIT is the default. Avoids file clutter. */ - break; - default: - g_warning ("? < Card had invalid encoding type."); - } - - switch (prop->value) { - case VAL_CID: - addProp (o, VCContentIDProp); - break; - case VAL_INLINE: - /* Do nothing: INLINE is the default. Avoids file clutter. */ - break; - default: - g_warning ("? < Card had invalid value type."); - } - - for (node = prop->xtension; node; node = node->next) { - CardXAttribute *xa = (CardXAttribute *) node->data; - if (xa->data) - addPropValue (o, xa->name, xa->data); - else - addProp (o, xa->name); - } - - add_strProp (o, VCCharSetProp, prop->charset); - add_strProp (o, VCLanguageProp, prop->lang); - - return o; -} - -static VObject * -add_CardStrProperty (VObject *vobj, const char *id, CardStrProperty *strprop) -{ - VObject *vprop; - - if (strprop->prop.used) { - vprop = add_strProp (vobj, id, strprop->str); - add_CardProperty (vprop, &strprop->prop); - } - - return vobj; -} - -static VObject * -add_PhotoType (VObject *o, enum PhotoType photo_type) -{ - int i; - - for (i = 0; photo_pairs[i].str; i++) - if (photo_type == photo_pairs[i].id) { - addProp (o, photo_pairs[i].str); - return o; - } - - g_warning ("? > No PhotoType for Photo property. Falling back to JPEG."); - addProp (o, VCJPEGProp); - - return o; -} - -static VObject * -add_AddrType (VObject *o, int addr_type) -{ - int i; - - for (i = 0; addr_pairs[i].str; i++) - if (addr_type & addr_pairs[i].id) - addProp (o, addr_pairs[i].str); - - return o; -} - -static void -add_strAddrType (GString *string, int addr_type) -{ - int i, first = 1; - char *str; - - if (addr_type) { - g_string_append (string, " ("); - - for (i = 0; addr_pairs[i].str; i++) - if (addr_type & addr_pairs[i].id) { - if (!first) - g_string_append (string, ", "); - first = 0; - str = my_cap (addr_pairs[i].str); - g_string_append (string, str); - g_free (str); - } - - g_string_append_c (string, ')'); - } -} - -static VObject * -add_PhoneType (VObject *o, int phone_type) -{ - int i; - - for (i = 0; phone_pairs[i].str; i++) - if (phone_type & phone_pairs[i].id) - addProp (o, phone_pairs[i].str); - - return o; -} - -static void -add_strPhoneType (GString *string, int phone_type) -{ - int i, first = 1; - char *str; - - if (phone_type) { - g_string_append (string, " ("); - - for (i = 0; phone_pairs[i].str; i++) - if (phone_type & phone_pairs[i].id) { - if (!first) - g_string_append (string, ", "); - first = 0; - str = my_cap (phone_pairs[i].str); - g_string_append (string, str); - g_free (str); - } - - g_string_append_c (string, ')'); - } -} - -static VObject * -add_EMailType (VObject *o, enum EMailType email_type) -{ - int i; - - for (i = 0; email_pairs[i].str; i++) - if (email_type == email_pairs[i].id) { - addProp (o, email_pairs[i].str); - return o; - } - - g_warning ("? > No EMailType for EMail property. Falling back to INET."); - addProp (o, VCInternetProp); - - return o; -} - -static void -add_strEMailType (GString *string, int email_type) -{ - int i; - char *str; - - if (email_type) { - g_string_append (string, " ("); - - for (i = 0; email_pairs[i].str; i++) - if (email_type == email_pairs[i].id) { - str = my_cap (email_pairs[i].str); - g_string_append (string, str); - g_free (str); - break; - } - - g_string_append_c (string, ')'); - } -} - -static VObject * -add_KeyType (VObject *o, enum KeyType key_type) -{ - int i; - - for (i = 0; key_pairs[i].str; i++) - if (key_type == key_pairs[i].id) { - addProp (o, key_pairs[i].str); - return o; - } - - g_warning ("? > No KeyType for Key property. Falling back to PGP."); - addProp (o, VCPGPProp); - - return o; -} - -static void -add_strKeyType (GString *string, int key_type) -{ - int i; - char *str; - - if (key_type) { - g_string_append (string, " ("); - - for (i = 0; key_pairs[i].str; i++) - if (key_type == key_pairs[i].id) { - str = my_cap (key_pairs[i].str); - g_string_append (string, str); - g_free (str); - break; - } - - g_string_append_c (string, ')'); - } -} - -static VObject * -add_SoundType (VObject *o, enum SoundType sound_type) -{ - int i; - - for (i = 0; sound_pairs[i].str; i++) - if (sound_type == sound_pairs[i].id) { - addProp (o, sound_pairs[i].str); - return o; - } - - return o; -} - -char *card_bday_str (CardBDay bday) -{ - char *str; - - str = malloc (12); - snprintf (str, 12, "%04d-%02d-%02d", bday.year, bday.month, bday.day); - - return str; -} - -char *card_timezn_str (CardTimeZone timezn) -{ - char *str; - - str = malloc (7); - snprintf (str, 7, (timezn.sign == -1)? "-%02d:%02d" : "%02d:%02d", - timezn.hours, timezn.mins); - return str; -} - -char *card_geopos_str (CardGeoPos geopos) -{ - char *str; - - str = malloc (15); - snprintf (str, 15, "%03.02f,%03.02f", geopos.lon, geopos.lat); - return str; -} - -static void add_CardStrProperty_to_string (GString *string, char *prop_name, - CardStrProperty *strprop) -{ - if (strprop->prop.used) { - if (prop_name) - g_string_append (string, prop_name); - - g_string_append (string, strprop->str); - } -} - -static void add_strProp_to_string (GString *string, char *prop_name, char *val) -{ - if (val) { - if (prop_name) - g_string_append (string, prop_name); - - g_string_append (string, val); - } -} - -static void addProp_to_string (GString *string, char *prop_name) -{ - if (prop_name) - g_string_append (string, prop_name); -} - -char * -card_to_string (Card *crd) -{ - GString *string; - char *ret; - - string = g_string_new (""); - - add_CardStrProperty_to_string (string, _ ("Card: "), &crd->fname); - if (crd->name.prop.used) { - addProp_to_string (string, _ ("\nName: ")); - add_strProp_to_string (string, _ ("\n Prefix: "), crd->name.prefix); - add_strProp_to_string (string, _ ("\n Given: "), crd->name.given); - add_strProp_to_string (string, _ ("\n Additional: "), crd->name.additional); - add_strProp_to_string (string, _ ("\n Family: "), crd->name.family); - add_strProp_to_string (string, _ ("\n Suffix: "), crd->name.suffix); - g_string_append_c (string, '\n'); - } - -/* if (crd->photo.prop.used) { - addPropSizedValue (string, _ ("\nPhoto: "), - crd->photo.data, crd->photo.size); - add_PhotoType (string, crd->photo.type); - }*/ - - if (crd->bday.prop.used) { - char *date_str; - - date_str = card_bday_str (crd->bday); - add_strProp_to_string (string, _ ("\nBirth Date: "), date_str); - free (date_str); - } - - if (crd->deladdr.l) { - GList *node; - - for (node = crd->deladdr.l; node; node = node->next) { - CardDelAddr *deladdr = (CardDelAddr *) node->data; - - if (deladdr->prop.used) { - addProp_to_string (string, _ ("\nAddress:")); - add_strAddrType (string, deladdr->type); - add_strProp_to_string (string, _ ("\n Postal Box: "), deladdr->po); - add_strProp_to_string (string, _ ("\n Ext: "),deladdr->ext); - add_strProp_to_string (string, _ ("\n Street: "),deladdr->street); - add_strProp_to_string (string, _ ("\n City: "), deladdr->city); - add_strProp_to_string (string, _ ("\n Region: "), deladdr->region); - add_strProp_to_string (string, _ ("\n Postal Code: "), deladdr->code); - add_strProp_to_string (string, _ ("\n Country: "), deladdr->country); - } - } - - g_string_append_c (string, '\n'); - } - - if (crd->dellabel.l) { - GList *node; - - for (node = crd->dellabel.l; node; node = node->next) { - CardDelLabel *dellabel = (CardDelLabel *) node->data; - - add_strProp_to_string (string, _ ("\nDelivery Label: "), - dellabel->data); - add_strAddrType (string, dellabel->type); - } - } - - if (crd->phone.l) { - GList *node; - char *sep; - - if (crd->phone.l->next) { - sep = " "; - g_string_append (string, _ ("\nTelephones:\n")); - } else { - sep = " "; - g_string_append (string, _ ("\nTelephone:")); - } - - for (node = crd->phone.l; node; node = node->next) { - CardPhone *phone = (CardPhone *) node->data; - - if (phone->prop.used) { - g_string_append (string, sep); - g_string_append (string, phone->data); - add_strPhoneType (string, phone->type); - g_string_append_c (string, '\n'); - } - } - - if (crd->phone.l->next) - g_string_append_c (string, '\n'); - } - - if (crd->email.l) { - GList *node; - char *sep; - - if (crd->email.l->next) { - sep = " "; - g_string_append (string, _ ("\nE-mail:\n")); - } else { - sep = " "; - g_string_append (string, _ ("\nE-mail:")); - } - - - for (node = crd->email.l; node; node = node->next) { - CardEMail *email = (CardEMail *) node->data; - - if (email->prop.used) { - g_string_append (string, sep); - g_string_append (string, email->data); - add_strEMailType (string, email->type); - g_string_append_c (string, '\n'); - } - } - - if (crd->email.l->next) - g_string_append_c (string, '\n'); - } - - add_CardStrProperty_to_string (string, _ ("\nMailer: "), &crd->mailer); - - if (crd->timezn.prop.used) { - char *str; - - str = card_timezn_str (crd->timezn); - add_strProp_to_string (string, _ ("\nTime Zone: "), str); - free (str); - } - - if (crd->geopos.prop.used) { - char *str; - - str = card_geopos_str (crd->geopos); - add_strProp_to_string (string, _ ("\nGeo Location: "), str); - free (str); - } - - add_CardStrProperty_to_string (string, _ ("\nBusiness Role: "), &crd->role); - -/* if (crd->logo.prop.used) { - addPropSizedValue (string, _ ("\nLogo: "), - crd->logo.data, crd->logo.size); - add_PhotoType (string, crd->logo.type); - }*/ - -/* if (crd->agent) - addstringectProp (string, card_convert_to_stringect (crd->agent));*/ - - if (crd->org.prop.used) { - addProp_to_string (string, _ ("\nOrg: ")); - add_strProp_to_string (string, _ ("\n Name: "), crd->org.name); - add_strProp_to_string (string, _ ("\n Unit: "), crd->org.unit1); - add_strProp_to_string (string, _ ("\n Unit2: "), crd->org.unit2); - add_strProp_to_string (string, _ ("\n Unit3: "), crd->org.unit3); - add_strProp_to_string (string, _ ("\n Unit4: "), crd->org.unit4); - g_string_append_c (string, '\n'); - } - - add_CardStrProperty_to_string (string, _ ("\nCategories: "), &crd->categories); - add_CardStrProperty_to_string (string, _ ("\nComment: "), &crd->comment); - -/* if (crd->sound.prop.used) { - if (crd->sound.type != SOUND_PHONETIC) - addPropSizedValue (string, _ ("\nPronunciation: "), - crd->sound.data, crd->sound.size); - else - add_strProp_to_string (string, _ ("\nPronunciation: "), - crd->sound.data); - - add_SoundType (string, crd->sound.type); - }*/ - - add_CardStrProperty_to_string (string, _ ("\nUnique String: "), &crd->uid); - - if (crd->key.prop.used) { - add_strProp_to_string (string, _ ("\nPublic Key: "), crd->key.data); - add_strKeyType (string, crd->key.type); - } - - ret = g_strdup (string->str); - g_string_free (string, TRUE); - - return ret; -} - -char * -card_to_vobj_string (Card *crd) -{ - VObject *object; - char *data, *ret_val; - - g_assert (crd != NULL); - - object = card_convert_to_vobject (crd); - data = writeMemVObject (0, 0, object); - ret_val = g_strdup (data); - free (data); - - cleanVObject (object); - - return ret_val; -} - -void -card_save (Card *crd, FILE *fp) -{ - VObject *object; - - g_return_if_fail (crd != NULL); - - object = card_convert_to_vobject (crd); - writeVObject (fp, object); - cleanVObject (object); -} -#endif - -static ECardDate -e_card_date_from_string (char *str) -{ - ECardDate date; - int length; - - date.year = 0; - date.month = 0; - date.day = 0; - - length = strlen(str); - - if (length == 10 ) { - date.year = str[0] * 1000 + str[1] * 100 + str[2] * 10 + str[3] - '0' * 1111; - date.month = str[5] * 10 + str[6] - '0' * 11; - date.day = str[8] * 10 + str[9] - '0' * 11; - } else if ( length == 8 ) { - date.year = str[0] * 1000 + str[1] * 100 + str[2] * 10 + str[3] - '0' * 1111; - date.month = str[4] * 10 + str[5] - '0' * 11; - date.day = str[6] * 10 + str[7] - '0' * 11; - } - - return date; -} - -static void -e_card_name_free(ECardName *name) -{ - if ( name ) { - if ( name->prefix ) - g_free(name->prefix); - if ( name->given ) - g_free(name->given); - if ( name->additional ) - g_free(name->additional); - if ( name->family ) - g_free(name->family); - if ( name->suffix ) - g_free(name->suffix); - g_free ( name ); - } -} - -char * -e_v_object_get_child_value(VObject *vobj, char *name) -{ - char *ret_val; - VObjectIterator iterator; - initPropIterator(&iterator, vobj); - while(moreIteration (&iterator)) { - VObject *attribute = nextVObject(&iterator); - const char *id = vObjectName(attribute); - if ( ! strcmp(id, name) ) { - assign_string(attribute, &ret_val); - return ret_val; - } - } - ret_val = g_new(char, 1); - *ret_val = 0; - return ret_val; -} - -static ECardPhoneFlags -get_phone_flags (VObject *vobj) -{ - ECardPhoneFlags ret = 0; - int i; - - struct { - char *id; - ECardPhoneFlags flag; - } phone_pairs[] = { - { VCPreferredProp, E_CARD_PHONE_PREF }, - { VCWorkProp, E_CARD_PHONE_WORK }, - { VCHomeProp, E_CARD_PHONE_HOME }, - { VCVoiceProp, E_CARD_PHONE_VOICE }, - { VCFaxProp, E_CARD_PHONE_FAX }, - { VCMessageProp, E_CARD_PHONE_MSG }, - { VCCellularProp, E_CARD_PHONE_CELL }, - { VCPagerProp, E_CARD_PHONE_PAGER }, - { VCBBSProp, E_CARD_PHONE_BBS }, - { VCModemProp, E_CARD_PHONE_MODEM }, - { VCCarProp, E_CARD_PHONE_CAR }, - { VCISDNProp, E_CARD_PHONE_ISDN }, - { VCVideoProp, E_CARD_PHONE_VIDEO }, - }; - - for (i = 0; i < sizeof(phone_pairs) / sizeof(phone_pairs[0]); i++) { - if (isAPropertyOf (vobj, phone_pairs[i].id)) { - ret |= phone_pairs[i].flag; - } - } - - return ret; -} - -static void -set_phone_flags (VObject *vobj, ECardPhoneFlags flags) -{ - int i; - - struct { - char *id; - ECardPhoneFlags flag; - } phone_pairs[] = { - { VCPreferredProp, E_CARD_PHONE_PREF }, - { VCWorkProp, E_CARD_PHONE_WORK }, - { VCHomeProp, E_CARD_PHONE_HOME }, - { VCVoiceProp, E_CARD_PHONE_VOICE }, - { VCFaxProp, E_CARD_PHONE_FAX }, - { VCMessageProp, E_CARD_PHONE_MSG }, - { VCCellularProp, E_CARD_PHONE_CELL }, - { VCPagerProp, E_CARD_PHONE_PAGER }, - { VCBBSProp, E_CARD_PHONE_BBS }, - { VCModemProp, E_CARD_PHONE_MODEM }, - { VCCarProp, E_CARD_PHONE_CAR }, - { VCISDNProp, E_CARD_PHONE_ISDN }, - { VCVideoProp, E_CARD_PHONE_VIDEO }, - }; - - for (i = 0; i < sizeof(phone_pairs) / sizeof(phone_pairs[0]); i++) { - if (flags & phone_pairs[i].flag) { - addProp (vobj, phone_pairs[i].id); - } - } -} - -static ECardAddressFlags -get_address_flags (VObject *vobj) -{ - ECardAddressFlags ret = 0; - int i; - - struct { - char *id; - ECardAddressFlags flag; - } addr_pairs[] = { - { VCDomesticProp, ADDR_DOM }, - { VCInternationalProp, ADDR_INTL }, - { VCPostalProp, ADDR_POSTAL }, - { VCParcelProp, ADDR_PARCEL }, - { VCHomeProp, ADDR_HOME }, - { VCWorkProp, ADDR_WORK }, - }; - - for (i = 0; i < sizeof(addr_pairs) / sizeof(addr_pairs[0]); i++) { - if (isAPropertyOf (vobj, addr_pairs[i].id)) { - ret |= addr_pairs[i].flag; - } - } - - return ret; -} - -static void -set_address_flags (VObject *vobj, ECardAddressFlags flags) -{ - int i; - - struct { - char *id; - ECardAddressFlags flag; - } addr_pairs[] = { - { VCDomesticProp, ADDR_DOM }, - { VCInternationalProp, ADDR_INTL }, - { VCPostalProp, ADDR_POSTAL }, - { VCParcelProp, ADDR_PARCEL }, - { VCHomeProp, ADDR_HOME }, - { VCWorkProp, ADDR_WORK }, - }; - - for (i = 0; i < sizeof(addr_pairs) / sizeof(addr_pairs[0]); i++) { - if (flags & addr_pairs[i].flag) { - addProp (vobj, addr_pairs[i].id); - } - } -} diff --git a/addressbook/backend/ebook/e-card.h b/addressbook/backend/ebook/e-card.h deleted file mode 100644 index b10585c4a8..0000000000 --- a/addressbook/backend/ebook/e-card.h +++ /dev/null @@ -1,130 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Authors: - * Chris Lahey - * Arturo Espinosa - * Nat Friedman (nat@helixcode.com) - * - * Copyright (C) 2000 Helix Code, Inc. - * Copyright (C) 1999 The Free Software Foundation - */ - -#ifndef __E_CARD_H__ -#define __E_CARD_H__ - -#include -#include -#include -#include -#include - -#define E_TYPE_CARD (e_card_get_type ()) -#define E_CARD(obj) (GTK_CHECK_CAST ((obj), E_TYPE_CARD, ECard)) -#define E_CARD_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_TYPE_CARD, ECardClass)) -#define E_IS_CARD(obj) (GTK_CHECK_TYPE ((obj), E_TYPE_CARD)) -#define E_IS_CARD_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), E_TYPE_CARD)) - -typedef struct _ECard ECard; -typedef struct _ECardClass ECardClass; - -struct _ECard { - GtkObject object; - char *id; - - char *fname; /* The full name. */ - ECardName *name; /* The structured name. */ - ECardList *address; /* Delivery addresses (ECardDeliveryAddress *) */ -#if 0 - GList *del_labels; /* Delivery address labels - * (ECardAddrLabel *) */ -#endif - ECardList *phone; /* Phone numbers (ECardPhone *) */ - ECardList *email; /* Email addresses (char *) */ - char *url; /* The person's web page. */ - - ECardDate *bday; /* The person's birthday. */ - - char *note; - - - char *org; /* The person's organization. */ - char *org_unit; /* The person's organization unit. */ - char *role; /* The person's role w/in his org */ - char *title; /* The person's title w/in his org */ - - char *nickname; /* The person's nickname */ - - char *fburl; /* Free Busy URL */ - -#if 0 - ECardOrg *org; /* The person's organization. */ - - char *role; /* The person's role w/in his org */ - ECardPhoto *logo; /* This person's org's logo. */ - - ECardPhoto *photo; /* A photo of the person. */ - - ECard *agent; /* A person who sereves as this - guy's agent/secretary/etc. */ - - - char *categories; /* A list of the categories to which - this card belongs. */ - - char *comment; /* An unstructured comment string. */ - - ECardSound *sound; - - ECardKey *key; /* The person's public key. */ - ECardTimeZone *timezn; /* The person's time zone. */ - ECardGeoPos *geopos; /* The person's long/lat. */ - - char *mailer; /* The user's mailer. */ - - char *uid; /* This card's unique identifier. */ - ECardRev *rev; /* The time this card was last - modified. */ - - ECardList xtension; -#endif -}; - -struct _ECardClass { - GtkObjectClass parent_class; - GHashTable *attribute_jump_table; -}; - - -ECard *e_card_new (char *vcard); -char *e_card_get_id (ECard *card); -void e_card_set_id (ECard *card, const gchar *character); -char *e_card_get_vcard (ECard *card); - -ECard *e_card_duplicate (ECard *card); - -void e_card_phone_free (ECardPhone *phone); -ECardPhone *e_card_phone_copy (const ECardPhone *phone); -void e_card_delivery_address_free (ECardDeliveryAddress *addr); -ECardDeliveryAddress *e_card_delivery_address_copy (const ECardDeliveryAddress *addr); - - -/* Standard Gtk function */ -GtkType e_card_get_type (void); - - -#if 0 -void e_card_free (ECard *crd); -void e_card_prop_free (CardProperty prop); -CardProperty e_card_prop_empty (void); -int e_card_check_prop (CardProperty prop); -GList *e_card_load (GList *crdlist, char *fname); -void e_card_save (ECard *crd, FILE *fp); -char *e_card_to_vobj_string (ECard *card); -char *e_card_to_string (ECard *card); - -char *e_card_bday_str (ECardDate bday); -char *e_card_timezn_str (ECardTimeZone timezn); -char *e_card_geopos_str (ECardGeoPos geopos); -#endif - -#endif /* ! __E_CARD_H__ */ diff --git a/addressbook/backend/ebook/test-card.c b/addressbook/backend/ebook/test-card.c deleted file mode 100644 index c6ee6e9ff1..0000000000 --- a/addressbook/backend/ebook/test-card.c +++ /dev/null @@ -1,194 +0,0 @@ -#include -#include "e-card.h" - -#define TEST_VCARD \ -"BEGIN:VCARD -" \ -"FN:Nat -" \ -"N:Friedman;Nat;D;Mr. -" \ -"ORG:Helix Code, Inc. -" \ -"TITLE:Head Geek -" \ -"ROLE:Programmer/Executive -" \ -"BDAY:1977-08-06 -" \ -"TEL;WORK:617 679 1984 -" \ -"TEL;CELL:123 456 7890 -" \ -"EMAIL;INTERNET:nat@nat.org -" \ -"EMAIL;INTERNET:nat@helixcode.com -" \ -"ADR;WORK;POSTAL:P.O. Box 101;;;Any Town;CA;91921-1234; -" \ -"ADR;HOME;POSTAL;INTL:P.O. Box 202;;;Any Town 2;MI;12344-4321;USA -" \ -"END:VCARD -" \ -" -" - -static char * -read_file (char *name) -{ - int len; - char buff[65536]; - char line[1024]; - FILE *f; - - f = fopen (name, "r"); - if (f == NULL) - g_error ("Unable to open %s!\n", name); - - len = 0; - while (fgets (line, sizeof (line), f) != NULL) { - strcpy (buff + len, line); - len += strlen (line); - } - - fclose (f); - - return g_strdup (buff); -} - - - -int -main (int argc, char **argv) -{ - char *cardstr; - ECard *card; - - /* Fields */ - char *fname; - char *org; - char *org_unit; - char *title; - char *role; - char *nickname; - char *fburl; - ECardName *name; - ECardList *address; - ECardList *phone; - ECardList *email; - ECardIterator *iterator; - ECardDate *bday; - - gnome_init ("TestCard", "0.0", argc, argv); - - cardstr = NULL; - if (argc == 2) - cardstr = read_file (argv [1]); - - if (cardstr == NULL) - cardstr = TEST_VCARD; -#if 0 - { - int i; - for ( i = 0; i < 100000; i++ ) { - card = e_card_new (cardstr); - - gtk_object_unref (GTK_OBJECT (card)); - } - } -#endif - card = e_card_new (cardstr); - gtk_object_get(GTK_OBJECT(card), - "full_name", &fname, - "name", &name, - "address", &address, - "phone", &phone, - "email", &email, - "org", &org, - "org_unit", &org_unit, - "title", &title, - "role", &role, - "nickname", &nickname, - "fburl", &fburl, - "birth_date", &bday, - NULL); - if ( fname ) { - printf("Name : %s\n", fname); - g_free(fname); - } - if ( name ) { - printf("Full Name:\n"); - if ( name->prefix ) - printf(" prefix : %s\n", name->prefix); - if ( name->given ) - printf(" given : %s\n", name->given); - if ( name->additional ) - printf(" additional : %s\n", name->additional); - if ( name->family ) - printf(" family : %s\n", name->family); - if ( name->suffix ) - printf(" suffix : %s\n", name->suffix); - } - if ( org ) { - printf("Company : %s\n", org); - } - if ( org_unit ) { - printf("Department : %s\n", org_unit); - } - if ( title ) { - printf("Title : %s\n", title); - } - if ( role ) { - printf("Profession : %s\n", role); - } - if ( nickname ) { - printf("Nickname : %s\n", nickname); - } - if ( fburl ) { - printf("Free Busy URL : %s\n", fburl); - } - if ( bday ) { - printf("BDay : %4d-%02d-%02d\n", bday->year, bday->month, bday->day); - } - if ( email ) { - iterator = e_card_list_get_iterator(address); - for (; e_card_iterator_is_valid(iterator); e_card_iterator_next(iterator)) { - printf("Email : %s\n", (char *) e_card_iterator_get(iterator)); - } - gtk_object_unref(GTK_OBJECT(iterator)); - } - if ( phone ) { - iterator = e_card_list_get_iterator(address); - for (; e_card_iterator_is_valid(iterator); e_card_iterator_next(iterator)) { - ECardPhone *e_card_phone = (ECardPhone *) e_card_iterator_get(iterator); - printf("Phone ; %d : %s\n", e_card_phone->flags, e_card_phone->number); - } - gtk_object_unref(GTK_OBJECT(iterator)); - } - if ( address ) { - iterator = e_card_list_get_iterator(address); - for (; e_card_iterator_is_valid(iterator); e_card_iterator_next(iterator)) { - ECardDeliveryAddress *del_address = (ECardDeliveryAddress *) e_card_iterator_get(iterator); - printf("Address ; %d:\n", del_address->flags); - if ( del_address->po ) - printf(" Po : %s\n", del_address->po); - if ( del_address->ext ) - printf(" Ext : %s\n", del_address->ext); - if ( del_address->street ) - printf(" Street : %s\n", del_address->street); - if ( del_address->city ) - printf(" City : %s\n", del_address->city); - if ( del_address->region ) - printf(" Region : %s\n", del_address->region); - if ( del_address->code ) - printf(" Code : %s\n", del_address->code); - if ( del_address->country ) - printf(" Country : %s\n", del_address->country); - } - gtk_object_unref(GTK_OBJECT(iterator)); - } - printf("%s", e_card_get_vcard(card)); - gtk_object_unref (GTK_OBJECT (card)); - - return 0; -} diff --git a/addressbook/backend/ebook/test-client-list.c b/addressbook/backend/ebook/test-client-list.c deleted file mode 100644 index eaa6e41c94..0000000000 --- a/addressbook/backend/ebook/test-client-list.c +++ /dev/null @@ -1,77 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -#include -#include -#include -#include - -#include "e-book.h" - -CORBA_Environment ev; -CORBA_ORB orb; - -static void -init_bonobo (int argc, char **argv) -{ - - gnome_CORBA_init_with_popt_table ( - "blah", "0.0", - &argc, argv, NULL, 0, NULL, GNORBA_INIT_SERVER_FUNC, &ev); - - orb = gnome_CORBA_ORB (); - - if (bonobo_init (orb, NULL, NULL) == FALSE) - g_error (_("Could not initialize Bonobo")); - -} - -static void -get_cursor_cb (EBook *book, EBookStatus status, ECardCursor *cursor, gpointer closure) -{ - long length = e_card_cursor_get_length(cursor); - long i; - - printf ("Length: %d\n", (int) length); - for ( i = 0; i < length; i++ ) { - ECard *card = e_card_cursor_get_nth(cursor, i); - char *vcard = e_card_get_vcard(card); - printf("[%s]\n", vcard); - g_free(vcard); - gtk_object_unref(GTK_OBJECT(card)); - } -} - -static void -book_open_cb (EBook *book, EBookStatus status, gpointer closure) -{ - printf ("Book opened.\n"); - e_book_get_cursor(book, "", get_cursor_cb, NULL); -} - -static guint -ebook_create (void) -{ - EBook *book; - - book = e_book_new (); - - if (! e_book_load_uri (book, "file:/tmp/test.db", book_open_cb, NULL)) { - printf ("error calling load_uri!\n"); - } - - - return FALSE; -} - -int -main (int argc, char **argv) -{ - - CORBA_exception_init (&ev); - init_bonobo (argc, argv); - - gtk_idle_add ((GtkFunction) ebook_create, NULL); - - bonobo_main (); - - return 0; -} diff --git a/addressbook/backend/ebook/test-client.c b/addressbook/backend/ebook/test-client.c deleted file mode 100644 index 15c5410146..0000000000 --- a/addressbook/backend/ebook/test-client.c +++ /dev/null @@ -1,172 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -#include -#include -#include -#include - -#include - -#define TEST_VCARD \ -"BEGIN:VCARD -" \ -"FN:Nat -" \ -"N:Friedman;Nat;D;Mr. -" \ -"BDAY:1977-08-06 -" \ -"TEL;WORK:617 679 1984 -" \ -"TEL;CELL:123 456 7890 -" \ -"EMAIL;INTERNET:nat@nat.org -" \ -"EMAIL;INTERNET:nat@helixcode.com -" \ -"ADR;WORK;POSTAL:P.O. Box 101;;;Any Town;CA;91921-1234; -" \ -"END:VCARD -" \ -" -" - -static CORBA_Environment ev; -static CORBA_ORB orb; -static char *cardstr; - -static void -init_bonobo (int argc, char **argv) -{ - - gnome_CORBA_init_with_popt_table ( - "blah", "0.0", - &argc, argv, NULL, 0, NULL, GNORBA_INIT_SERVER_FUNC, &ev); - - orb = gnome_CORBA_ORB (); - - if (bonobo_init (orb, NULL, NULL) == FALSE) - g_error (_("Could not initialize Bonobo")); - -} - -static void -get_cursor_cb (EBook *book, EBookStatus status, ECardCursor *cursor, gpointer closure) -{ - long length = e_card_cursor_get_length(cursor); - long i; - - /* we just added a card, so the length should be >1 */ - printf ("\n%s: %s(): Number of cards is %ld\n", - __FILE__, __FUNCTION__, length); - if (length < 1) - printf ("*** Why isn't this above zero?? ***\n\n"); - - for ( i = 0; i < length; i++ ) { - ECard *card = e_card_cursor_get_nth(cursor, i); - char *vcard = e_card_get_vcard(card); - printf("Get all cards callback: [%s]\n", vcard); - g_free(vcard); - gtk_object_unref(GTK_OBJECT(card)); - } -} - -static void -add_card_cb (EBook *book, EBookStatus status, const gchar *id, gpointer closure) -{ - char *vcard; - ECard *card; - GTimer *timer; - - printf ("Status: %d\n", status); - - printf ("Id: %s\n", id); - - timer = g_timer_new (); - g_timer_start (timer); - card = e_book_get_card (book, id); - g_timer_stop (timer); - - vcard = e_card_get_vcard(card); - printf ("%g\n", g_timer_elapsed (timer, NULL)); - printf ("Card added: [%s]\n", vcard); - g_free(vcard); - gtk_object_unref(GTK_OBJECT(card)); - - printf ("Getting cards..\n"); - e_book_get_cursor(book, "", get_cursor_cb, NULL); - printf ("Done getting all cards.\n"); -} - -static void -book_open_cb (EBook *book, EBookStatus status, gpointer closure) -{ - e_book_add_vcard(book, cardstr, add_card_cb, NULL); -} - -static guint -ebook_create (void) -{ - EBook *book; - - book = e_book_new (); - - if (!book) { - printf ("%s: %s(): Couldn't create EBook, bailing.\n", - __FILE__, - __FUNCTION__); - return FALSE; - } - - - if (! e_book_load_uri (book, "file:/tmp/test.db", book_open_cb, NULL)) { - printf ("error calling load_uri!\n"); - } - - - return FALSE; -} - -static char * -read_file (char *name) -{ - int len; - char buff[65536]; - char line[1024]; - FILE *f; - - f = fopen (name, "r"); - if (f == NULL) - g_error ("Unable to open %s!\n", name); - - len = 0; - while (fgets (line, sizeof (line), f) != NULL) { - strcpy (buff + len, line); - len += strlen (line); - } - - fclose (f); - - return g_strdup (buff); -} - - -int -main (int argc, char **argv) -{ - - CORBA_exception_init (&ev); - init_bonobo (argc, argv); - - cardstr = NULL; - if (argc == 2) - cardstr = read_file (argv [1]); - - if (cardstr == NULL) - cardstr = TEST_VCARD; - - gtk_idle_add ((GtkFunction) ebook_create, NULL); - - bonobo_main (); - - return 0; -} diff --git a/addressbook/backend/idl/.cvsignore b/addressbook/backend/idl/.cvsignore deleted file mode 100644 index 09980ae6ba..0000000000 --- a/addressbook/backend/idl/.cvsignore +++ /dev/null @@ -1,6 +0,0 @@ -.deps -.libs -Makefile -Makefile.in -*.lo -*.la diff --git a/addressbook/backend/idl/Makefile.am b/addressbook/backend/idl/Makefile.am deleted file mode 100644 index db61d2c30c..0000000000 --- a/addressbook/backend/idl/Makefile.am +++ /dev/null @@ -1,6 +0,0 @@ -idldir = $(datadir)/idl - -idl_DATA = \ - addressbook.idl - -EXTRA_DIST = $(idl_DATA) diff --git a/addressbook/backend/idl/addressbook.idl b/addressbook/backend/idl/addressbook.idl deleted file mode 100644 index 44987a76fb..0000000000 --- a/addressbook/backend/idl/addressbook.idl +++ /dev/null @@ -1,118 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * - * Author: - * Nat Friedman (nat@helixcode.com) - * - * Copyright 2000, Helix Code, Inc. - */ - -#include - -module Evolution { - - typedef string CardId; - typedef string VCard; - typedef sequence VCardList; - - interface CardCursor : Bonobo::Unknown { - long get_length (); - string get_nth (in long n); - }; - - /* - * A book view is a live view of a book. It's either a view - * of all the cards in the book or a view of a query. When - * created, it will get a series of signal_card_added calls - * for all objects in the initial set. After that, it will - * get added, removed, or changed signals whenever the book - * changes (if it affects the set of viewed cards.) - */ - interface BookViewListener : Bonobo::Unknown { - void signal_card_added (in VCardList cards); - void signal_card_removed (in CardId id); - void signal_card_changed (in VCardList cards); - }; - - interface BookView : Bonobo::Unknown { - }; - - interface Book : Bonobo::Unknown { - /* - * Fetching cards in the addresbook. - */ - VCard get_vcard (in CardId id); - - /* - * Adding and deleting cards in the book. - */ - void create_card (in VCard vcard); - void remove_card (in CardId Id); - - /* - * Modifying cards in the addressbook. - */ - void modify_card (in VCard vcard); - - /* - * These two functions return a cursor to the book - * listener. This is for people who want a snapshot - * of the addressbook. The syntax for the query - * string is not yet defined. - */ - void get_cursor (in string query); - - /* - * These two functions return a book view to the book - * listener. This is for people who want a live view - * of the addressbook. - */ - void get_book_view(in BookViewListener listener, in string query); - - void check_connection (); - - string get_name (); - }; - - interface BookListener : Bonobo::Unknown { - - enum CallStatus { - Success, - RepositoryOffline, - PermissionDenied, - CardNotFound - }; - - void respond_create_card (in CallStatus status, in CardId Id); - - void respond_remove_card (in CallStatus status); - - void respond_modify_card (in CallStatus status); - - void report_open_book_progress (in string status_message, in short percent); - - void respond_open_book (in CallStatus status, in Book book); - - void respond_get_cursor (in CallStatus status, in CardCursor cursor); - - void respond_get_view (in CallStatus status, in BookView view); - - /** - * report_connection_status: - * - * Used to report changes in the connection to the - * contact repository. This is often a response to a - * call to check_connection() on the Book, but wombat - * is free to report the connection status without - * being asked. - */ - void report_connection_status (in boolean connected); - }; - - interface BookFactory : Bonobo::Unknown { - exception ProtocolNotSupported {}; - - void open_book (in string uri, in BookListener listener) - raises (ProtocolNotSupported); - }; -}; diff --git a/addressbook/backend/pas/.cvsignore b/addressbook/backend/pas/.cvsignore deleted file mode 100644 index 7d29b58859..0000000000 --- a/addressbook/backend/pas/.cvsignore +++ /dev/null @@ -1,10 +0,0 @@ -.deps -.libs -Makefile -Makefile.in -addressbook-stubs.c -addressbook-skels.c -addressbook-common.c -addressbook.h -*.lo -*.la diff --git a/addressbook/backend/pas/Makefile.am b/addressbook/backend/pas/Makefile.am deleted file mode 100644 index 44cb5a66a1..0000000000 --- a/addressbook/backend/pas/Makefile.am +++ /dev/null @@ -1,46 +0,0 @@ -CORBA_SOURCE = \ - addressbook.h \ - addressbook-common.c \ - addressbook-stubs.c \ - addressbook-skels.c - -idls = \ - $(srcdir)/../idl/addressbook.idl - -idl_flags = `$(GNOME_CONFIG) --cflags idl` - -$(CORBA_SOURCE): $(idls) - $(ORBIT_IDL) $(srcdir)/../idl/addressbook.idl $(idl_flags) - -INCLUDES = \ - -DGNOMELOCALEDIR=\""$(datadir)/locale"\" \ - -DG_LOG_DOMAIN=\"wombat-pas\" \ - -I$(top_srcdir) \ - -I$(top_srcdir)/addressbook/backend \ - -I$(top_builddir)/addressbook/backend \ - $(GNOME_INCLUDEDIR) - -if ENABLE_LDAP -LDAP_BACKEND = pas-backend-ldap.c -endif - -noinst_LIBRARIES = libpas.a - -libpas_a_SOURCES = \ - $(CORBA_SOURCE) \ - pas-book-factory.c \ - pas-book-factory.h \ - pas-book-view.c \ - pas-book-view.h \ - pas-book.c \ - pas-book.h \ - pas-backend-file.c \ - pas-backend-file.h \ - $(LDAP_BACKEND) \ - pas-backend.c \ - pas-backend.h \ - pas-card-cursor.c \ - pas-card-cursor.h - -BUILT_SOURCES = $(CORBA_SOURCE) -CLEANFILES += $(BUILT_SOURCES) diff --git a/addressbook/backend/pas/TODO b/addressbook/backend/pas/TODO deleted file mode 100644 index 0c77c1b200..0000000000 --- a/addressbook/backend/pas/TODO +++ /dev/null @@ -1,2 +0,0 @@ -* Implement pas_book_factory_activate -* Authentication \ No newline at end of file diff --git a/addressbook/backend/pas/pas-backend-file.c b/addressbook/backend/pas/pas-backend-file.c deleted file mode 100644 index a1435f9251..0000000000 --- a/addressbook/backend/pas/pas-backend-file.c +++ /dev/null @@ -1,1084 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Author: - * Nat Friedman (nat@helixcode.com) - * - * Copyright 2000, Helix Code, Inc. - */ - -#include "config.h" -#include -#include -#include -#ifdef HAVE_DB_185_H -#include -#else -#include -#endif - -#include "pas-backend-file.h" -#include "pas-book.h" -#include "pas-card-cursor.h" -#include -#include - -#define PAS_BACKEND_FILE_VERSION_NAME "PAS-DB-VERSION" -#define PAS_BACKEND_FILE_VERSION "0.1" - -static PASBackendClass *pas_backend_file_parent_class; -typedef struct _PASBackendFileCursorPrivate PASBackendFileCursorPrivate; -typedef struct _PASBackendFileBookView PASBackendFileBookView; -typedef struct _PASBackendFileSearchContext PASBackendFileSearchContext; - -struct _PASBackendFilePrivate { - GList *clients; - gboolean loaded; - DB *file_db; - GList *book_views; -}; - -struct _PASBackendFileCursorPrivate { - PASBackend *backend; - PASBook *book; - - GList *elements; - guint32 num_elements; -}; - -struct _PASBackendFileBookView { - PASBookView *book_view; - gchar *search; - ESExp *search_sexp; - PASBackendFileSearchContext *search_context; -}; - -struct _PASBackendFileSearchContext { - ECard *ecard; -}; - -static long -get_length(PASCardCursor *cursor, gpointer data) -{ - PASBackendFileCursorPrivate *cursor_data = (PASBackendFileCursorPrivate *) data; - - return cursor_data->num_elements; -} - -static char * -get_nth(PASCardCursor *cursor, long n, gpointer data) -{ - PASBackendFileCursorPrivate *cursor_data = (PASBackendFileCursorPrivate *) data; - GList *nth_item = g_list_nth(cursor_data->elements, n); - - return g_strdup((char*)nth_item->data); -} - -static void -cursor_destroy(GtkObject *object, gpointer data) -{ - CORBA_Environment ev; - Evolution_Book corba_book; - PASBackendFileCursorPrivate *cursor_data = (PASBackendFileCursorPrivate *) data; - - corba_book = bonobo_object_corba_objref(BONOBO_OBJECT(cursor_data->book)); - - CORBA_exception_init(&ev); - - Evolution_Book_unref(corba_book, &ev); - - if (ev._major != CORBA_NO_EXCEPTION) { - g_warning("cursor_destroy: Exception unreffing " - "corba book.\n"); - } - - CORBA_exception_free(&ev); - - g_list_foreach(cursor_data->elements, (GFunc)g_free, NULL); - g_list_free (cursor_data->elements); - - g_free(cursor_data); -} - -static void -view_destroy(GtkObject *object, gpointer data) -{ - CORBA_Environment ev; - Evolution_Book corba_book; - PASBook *book = (PASBook *)data; - PASBackendFile *bf; - GList *list; - - bf = PAS_BACKEND_FILE(pas_book_get_backend(book)); - for (list = bf->priv->book_views; list; list = g_list_next(list)) { - PASBackendFileBookView *view = list->data; - if (view->book_view == PAS_BOOK_VIEW(object)) { - gtk_object_unref((GtkObject *)view->search_sexp); - g_free (view->search_context); - g_free (view->search); - g_free (view); - bf->priv->book_views = g_list_remove_link(bf->priv->book_views, list); - g_list_free_1(list); - break; - } - } - - corba_book = bonobo_object_corba_objref(BONOBO_OBJECT(book)); - - CORBA_exception_init(&ev); - - Evolution_Book_unref(corba_book, &ev); - - if (ev._major != CORBA_NO_EXCEPTION) { - g_warning("view_destroy: Exception unreffing " - "corba book.\n"); - } - - CORBA_exception_free(&ev); -} - -static void -string_to_dbt(const char *str, DBT *dbt) -{ - dbt->data = (void*)str; - dbt->size = strlen (str) + 1; -} - -static char * -pas_backend_file_create_unique_id (char *vcard) -{ - /* use a 32 counter and the 32 bit timestamp to make an id. - it's doubtful 2^32 id's will be created in a second, so we - should be okay. */ - static guint c = 0; - return g_strdup_printf ("pas-id-%08lX%08X", time(NULL), c++); -} - -static gboolean -compare_email (ECard *ecard, const char *str, - char *(*compare)(const char*, const char*)) -{ - ECardList *prop_list; - ECardIterator *iter; - gboolean truth = FALSE; - - gtk_object_get(GTK_OBJECT(ecard), - "email", &prop_list, NULL); - - iter = e_card_list_get_iterator(prop_list); - - while (e_card_iterator_is_valid(iter)) { - - if (compare((char*)e_card_iterator_get(iter), str)) { - truth = TRUE; - break; - } - else { - e_card_iterator_next(iter); - } - } - - gtk_object_unref (GTK_OBJECT(iter)); - - return truth; -} - -static gboolean -compare_phone (ECard *ecard, const char *str, - char *(*compare)(const char*, const char*)) -{ - ECardList *prop_list; - ECardIterator *iter; - gboolean truth = FALSE; - - gtk_object_get(GTK_OBJECT(ecard), - "phone", &prop_list, NULL); - - iter = e_card_list_get_iterator(prop_list); - - while (e_card_iterator_is_valid(iter)) { - ECardPhone *phone = (ECardPhone*)e_card_iterator_get(iter); - if (compare(phone->number, str)) { - truth = TRUE; - break; - } - else { - e_card_iterator_next(iter); - } - } - - gtk_object_unref (GTK_OBJECT(iter)); - - return truth; -} - -static gboolean -compare_address (ECard *ecard, const char *str, - char *(*compare)(const char*, const char*)) -{ - g_warning("address searching not implemented\n"); - return FALSE; -} - -static struct prop_info { - const char *query_prop; - const char *ecard_prop; -#define PROP_TYPE_NORMAL 0x01 -#define PROP_TYPE_LIST 0x02 -#define PROP_TYPE_LISTITEM 0x03 - int prop_type; - gboolean (*list_compare)(ECard *ecard, const char *str, - char *(*compare)(const char*, const char*)); - -} prop_info_table[] = { - /* query prop, ecard prop, type, list compare function */ - { "full_name", "full_name", PROP_TYPE_NORMAL, NULL }, - { "url", "url", PROP_TYPE_NORMAL, NULL }, - { "mailer", "mailer", PROP_TYPE_NORMAL, NULL }, - { "org", "org", PROP_TYPE_NORMAL, NULL }, - { "org_unit", "org_unit", PROP_TYPE_NORMAL, NULL }, - { "title", "title", PROP_TYPE_NORMAL, NULL }, - { "role", "role", PROP_TYPE_NORMAL, NULL }, - { "nickname", "nickname", PROP_TYPE_NORMAL, NULL }, - { "email", "email", PROP_TYPE_LIST, compare_email }, - { "phone", "phone", PROP_TYPE_LIST, compare_phone }, - { "address", "address", PROP_TYPE_LIST, compare_address }, - { "note", "note", PROP_TYPE_NORMAL, NULL }, -}; -static int num_prop_infos = sizeof(prop_info_table) / sizeof(prop_info_table[0]); - -static ESExpResult * -entry_compare(PASBackendFileSearchContext *ctx, struct _ESExp *f, - int argc, struct _ESExpResult **argv, - char *(*compare)(const char*, const char*)) -{ - ESExpResult *r; - int truth = FALSE; - - if (argc == 2 - && argv[0]->type == ESEXP_RES_STRING - && argv[1]->type == ESEXP_RES_STRING) { - char *propname; - struct prop_info *info = NULL; - int i; - - propname = argv[0]->value.string; - - for (i = 0; i < num_prop_infos; i ++) { - if (!strcmp (prop_info_table[i].query_prop, propname)) { - info = &prop_info_table[i]; - break; - } - } - - if (info) { - if (info->prop_type == PROP_TYPE_NORMAL) { - char *prop = NULL; - /* searches where the query's property - maps directly to an ecard property */ - - gtk_object_get(GTK_OBJECT(ctx->ecard), - info->ecard_prop, &prop, NULL); - - if (prop && compare(prop, argv[1]->value.string)) { - truth = TRUE; - } - } - else if (info->prop_type == PROP_TYPE_LIST) { - /* the special searches that match any of the list elements */ - truth = info->list_compare (ctx->ecard, argv[1]->value.string, compare); - } - } - - } - r = e_sexp_result_new(ESEXP_RES_BOOL); - r->value.bool = truth; - - return r; -} - -static ESExpResult * -func_contains(struct _ESExp *f, int argc, struct _ESExpResult **argv, void *data) -{ - PASBackendFileSearchContext *ctx = data; - - return entry_compare (ctx, f, argc, argv, strstr); -} - -static char * -is_helper (const char *s1, const char *s2) -{ - if (!strcmp(s1, s2)) - return (char*)s1; - else - return NULL; -} - -static ESExpResult * -func_is(struct _ESExp *f, int argc, struct _ESExpResult **argv, void *data) -{ - PASBackendFileSearchContext *ctx = data; - - return entry_compare (ctx, f, argc, argv, is_helper); -} - -static char * -endswith_helper (const char *s1, const char *s2) -{ - char *p; - if ((p = strstr(s1, s2)) - && (strlen(p) == strlen(s2))) - return p; - else - return NULL; -} - -static ESExpResult * -func_endswith(struct _ESExp *f, int argc, struct _ESExpResult **argv, void *data) -{ - PASBackendFileSearchContext *ctx = data; - - return entry_compare (ctx, f, argc, argv, endswith_helper); -} - -static char * -beginswith_helper (const char *s1, const char *s2) -{ - char *p; - if ((p = strstr(s1, s2)) - && (p == s1)) - return p; - else - return NULL; -} - -static ESExpResult * -func_beginswith(struct _ESExp *f, int argc, struct _ESExpResult **argv, void *data) -{ - PASBackendFileSearchContext *ctx = data; - - return entry_compare (ctx, f, argc, argv, beginswith_helper); -} - -/* 'builtin' functions */ -static struct { - char *name; - ESExpFunc *func; - int type; /* set to 1 if a function can perform shortcut evaluation, or - doesn't execute everything, 0 otherwise */ -} symbols[] = { - { "contains", func_contains, 0 }, - { "is", func_is, 0 }, - { "beginswith", func_beginswith, 0 }, - { "endswith", func_endswith, 0 }, -}; - -static gboolean -vcard_matches_search (PASBackendFileBookView *view, char *vcard_string) -{ - ESExpResult *r; - gboolean retval; - - view->search_context->ecard = e_card_new (vcard_string); - - /* if it's not a valid vcard why is it in our db? :) */ - if (!view->search_context->ecard) - return FALSE; - - r = e_sexp_eval(view->search_sexp); - - retval = (r && r->type == ESEXP_RES_BOOL && r->value.bool); - - gtk_object_unref(GTK_OBJECT(view->search_context->ecard)); - - e_sexp_result_free(r); - - return retval; -} - -static void -pas_backend_file_search (PASBackendFile *bf, - PASBook *book, - PASBackendFileBookView *view) -{ - int db_error = 0; - GList *cards = NULL; - DB *db = bf->priv->file_db; - DBT id_dbt, vcard_dbt; - int i; - - view->search_sexp = e_sexp_new(); - view->search_context = g_new0(PASBackendFileSearchContext, 1); - - for(i=0;isearch_sexp, 0, symbols[i].name, - (ESExpIFunc *)symbols[i].func, view->search_context); - } else { - e_sexp_add_function(view->search_sexp, 0, symbols[i].name, - symbols[i].func, view->search_context); - } - } - - e_sexp_input_text(view->search_sexp, view->search, strlen(view->search)); - e_sexp_parse(view->search_sexp); - - db_error = db->seq(db, &id_dbt, &vcard_dbt, R_FIRST); - - while (db_error == 0) { - - /* don't include the version in the list of cards */ - if (id_dbt.size != strlen(PAS_BACKEND_FILE_VERSION_NAME + 1) - || strcmp (id_dbt.data, PAS_BACKEND_FILE_VERSION_NAME)) { - char *vcard_string = vcard_dbt.data; - - /* check if the vcard matches the search sexp */ - if (vcard_matches_search (view, vcard_string)) { - cards = g_list_append (cards, strdup(vcard_string)); - } - } - - db_error = db->seq(db, &id_dbt, &vcard_dbt, R_NEXT); - } - - if (db_error == -1) { - g_warning ("pas_backend_file_search: error building list\n"); - } - else { - pas_book_view_notify_add (view->book_view, cards); - } - - /* - ** It's fine to do this now since the data has been handed off. - */ - g_list_foreach (cards, (GFunc)g_free, NULL); - g_list_free (cards); -} - -static void -pas_backend_file_process_create_card (PASBackend *backend, - PASBook *book, - PASRequest *req) -{ - PASBackendFile *bf = PAS_BACKEND_FILE (backend); - DB *db = bf->priv->file_db; - DBT id_dbt, vcard_dbt; - int db_error; - char *id; - GList *list; - ECard *card; - char *vcard; - - id = pas_backend_file_create_unique_id (req->vcard); - - string_to_dbt (id, &id_dbt); - - card = e_card_new(req->vcard); - e_card_set_id(card, id); - vcard = e_card_get_vcard(card); - - string_to_dbt (vcard, &vcard_dbt); - - db_error = db->put (db, &id_dbt, &vcard_dbt, 0); - - if (0 == db_error) { - db_error = db->sync (db, 0); - if (db_error != 0) - g_warning ("db->sync failed.\n"); - - for (list = bf->priv->book_views; list; list = g_list_next(list)) { - PASBackendFileBookView *view = list->data; - if (vcard_matches_search (view, vcard)) - pas_book_view_notify_add_1 (view->book_view, req->vcard); - } - - pas_book_respond_create ( - book, - Evolution_BookListener_Success, - id); - - } - else { - /* XXX need a different call status for this case, i - think */ - pas_book_respond_create ( - book, - Evolution_BookListener_CardNotFound, - ""); - } - - g_free (id); - g_free (vcard); - g_free (req->vcard); - - gtk_object_unref(GTK_OBJECT(card)); - card = NULL; -} - -static void -pas_backend_file_process_remove_card (PASBackend *backend, - PASBook *book, - PASRequest *req) -{ - PASBackendFile *bf = PAS_BACKEND_FILE (backend); - DB *db = bf->priv->file_db; - DBT id_dbt, vcard_dbt; - int db_error; - GList *list; - char *vcard_string; - - string_to_dbt (req->id, &id_dbt); - - db_error = db->get (db, &id_dbt, &vcard_dbt, 0); - if (0 != db_error) { - pas_book_respond_remove ( - book, - Evolution_BookListener_CardNotFound); - g_free (req->id); - return; - } - - db_error = db->del (db, &id_dbt, 0); - if (0 != db_error) { - pas_book_respond_remove ( - book, - Evolution_BookListener_CardNotFound); - g_free (req->id); - return; - } - - db_error = db->sync (db, 0); - if (db_error != 0) - g_warning ("db->sync failed.\n"); - - - vcard_string = vcard_dbt.data; - for (list = bf->priv->book_views; list; list = g_list_next(list)) { - PASBackendFileBookView *view = list->data; - if (vcard_matches_search (view, vcard_string)) - pas_book_view_notify_remove (view->book_view, req->id); - } - - pas_book_respond_remove ( - book, - Evolution_BookListener_Success); - - g_free (req->id); -} - -static void -pas_backend_file_process_modify_card (PASBackend *backend, - PASBook *book, - PASRequest *req) -{ - PASBackendFile *bf = PAS_BACKEND_FILE (backend); - DB *db = bf->priv->file_db; - DBT id_dbt, vcard_dbt; - int db_error; - GList *list; - ECard *card; - char *id; - char *old_vcard_string; - - /* create a new ecard from the request data */ - card = e_card_new(req->vcard); - id = e_card_get_id(card); - - string_to_dbt (id, &id_dbt); - - /* get the old ecard - the one that's presently in the db */ - db_error = db->get (db, &id_dbt, &vcard_dbt, 0); - if (0 != db_error) { - pas_book_respond_modify ( - book, - Evolution_BookListener_CardNotFound); - g_free (req->id); - return; - } - old_vcard_string = g_strdup(vcard_dbt.data); - - string_to_dbt (req->vcard, &vcard_dbt); - - db_error = db->put (db, &id_dbt, &vcard_dbt, 0); - - if (0 == db_error) { - db_error = db->sync (db, 0); - if (db_error != 0) - g_warning ("db->sync failed.\n"); - - for (list = bf->priv->book_views; list; list = g_list_next(list)) { - PASBackendFileBookView *view = list->data; - gboolean old_match, new_match; - - old_match = vcard_matches_search (view, old_vcard_string); - new_match = vcard_matches_search (view, req->vcard); - if (old_match && new_match) - pas_book_view_notify_change_1 (view->book_view, req->vcard); - else if (new_match) - pas_book_view_notify_add_1 (view->book_view, req->vcard); - else /* if (old_match) */ - pas_book_view_notify_remove (view->book_view, id); - } - - pas_book_respond_modify ( - book, - Evolution_BookListener_Success); - } - else { - pas_book_respond_modify ( - book, - Evolution_BookListener_CardNotFound); - } - - gtk_object_unref(GTK_OBJECT(card)); - g_free (req->vcard); -} - -static void -pas_backend_file_build_all_cards_list(PASBackend *backend, - PASBackendFileCursorPrivate *cursor_data) -{ - PASBackendFile *bf = PAS_BACKEND_FILE (backend); - DB *db = bf->priv->file_db; - int db_error; - DBT id_dbt, vcard_dbt; - - cursor_data->elements = NULL; - - db_error = db->seq(db, &id_dbt, &vcard_dbt, R_FIRST); - - while (db_error == 0) { - - /* don't include the version in the list of cards */ - if (id_dbt.size != strlen(PAS_BACKEND_FILE_VERSION_NAME + 1) - || strcmp (id_dbt.data, PAS_BACKEND_FILE_VERSION_NAME)) { - - cursor_data->elements = g_list_append(cursor_data->elements, - g_strdup(vcard_dbt.data)); - - } - - db_error = db->seq(db, &id_dbt, &vcard_dbt, R_NEXT); - - } - - if (db_error == -1) { - g_warning ("pas_backend_file_build_all_cards_list: error building list\n"); - } - else { - cursor_data->num_elements = g_list_length (cursor_data->elements); - } -} - -static void -pas_backend_file_process_get_cursor (PASBackend *backend, - PASBook *book, - PASRequest *req) -{ - /* - PASBackendFile *bf = PAS_BACKEND_FILE (backend); - DB *db = bf->priv->file_db; - DBT id_dbt, vcard_dbt; - */ - CORBA_Environment ev; - int db_error = 0; - PASBackendFileCursorPrivate *cursor_data; - PASCardCursor *cursor; - Evolution_Book corba_book; - - cursor_data = g_new(PASBackendFileCursorPrivate, 1); - cursor_data->backend = backend; - cursor_data->book = book; - - pas_backend_file_build_all_cards_list(backend, cursor_data); - - corba_book = bonobo_object_corba_objref(BONOBO_OBJECT(book)); - - CORBA_exception_init(&ev); - - Evolution_Book_ref(corba_book, &ev); - - if (ev._major != CORBA_NO_EXCEPTION) { - g_warning("pas_backend_file_process_get_cursor: Exception reffing " - "corba book.\n"); - } - - CORBA_exception_free(&ev); - - cursor = pas_card_cursor_new(get_length, - get_nth, - cursor_data); - - gtk_signal_connect(GTK_OBJECT(cursor), "destroy", - GTK_SIGNAL_FUNC(cursor_destroy), cursor_data); - - pas_book_respond_get_cursor ( - book, - (db_error == 0 - ? Evolution_BookListener_Success - : Evolution_BookListener_CardNotFound), - cursor); -} - -static void -pas_backend_file_process_get_book_view (PASBackend *backend, - PASBook *book, - PASRequest *req) -{ - PASBackendFile *bf = PAS_BACKEND_FILE (backend); - CORBA_Environment ev; - PASBookView *book_view; - Evolution_Book corba_book; - PASBackendFileBookView *view; - - g_return_if_fail (req->listener != NULL); - - corba_book = bonobo_object_corba_objref(BONOBO_OBJECT(book)); - - CORBA_exception_init(&ev); - - Evolution_Book_ref(corba_book, &ev); - - if (ev._major != CORBA_NO_EXCEPTION) { - g_warning("pas_backend_file_process_get_book_view: Exception reffing " - "corba book.\n"); - } - - CORBA_exception_free(&ev); - - book_view = pas_book_view_new (req->listener); - - gtk_signal_connect(GTK_OBJECT(book_view), "destroy", - GTK_SIGNAL_FUNC(view_destroy), book); - - pas_book_respond_get_book_view (book, - (book_view != NULL - ? Evolution_BookListener_Success - : Evolution_BookListener_CardNotFound /* XXX */), - book_view); - - view = g_new(PASBackendFileBookView, 1); - view->book_view = book_view; - view->search = g_strdup(req->search); - - bf->priv->book_views = g_list_prepend(bf->priv->book_views, view); - - pas_backend_file_search (bf, book, view); -} - -static void -pas_backend_file_process_check_connection (PASBackend *backend, - PASBook *book, - PASRequest *req) -{ - PASBackendFile *bf = PAS_BACKEND_FILE (backend); - - pas_book_report_connection (book, bf->priv->file_db != NULL); -} - -static void -pas_backend_file_process_client_requests (PASBook *book) -{ - PASBackend *backend; - PASRequest *req; - - backend = pas_book_get_backend (book); - - req = pas_book_pop_request (book); - if (req == NULL) - return; - - switch (req->op) { - case CreateCard: - pas_backend_file_process_create_card (backend, book, req); - break; - - case RemoveCard: - pas_backend_file_process_remove_card (backend, book, req); - break; - - case ModifyCard: - pas_backend_file_process_modify_card (backend, book, req); - break; - - case CheckConnection: - pas_backend_file_process_check_connection (backend, book, req); - break; - - case GetCursor: - pas_backend_file_process_get_cursor (backend, book, req); - break; - - case GetBookView: - pas_backend_file_process_get_book_view (backend, book, req); - break; - } - - g_free (req); -} - -static void -pas_backend_file_book_destroy_cb (PASBook *book) -{ - PASBackendFile *backend; - - backend = PAS_BACKEND_FILE (pas_book_get_backend (book)); - - pas_backend_remove_client (PAS_BACKEND (backend), book); -} - -static char * -pas_backend_file_get_vcard (PASBook *book, const char *id) -{ - PASBackendFile *bf; - DBT id_dbt, vcard_dbt; - DB *db; - int db_error; - - bf = PAS_BACKEND_FILE (pas_book_get_backend (book)); - db = bf->priv->file_db; - - string_to_dbt (id, &id_dbt); - - db_error = db->get (db, &id_dbt, &vcard_dbt, 0); - if (db_error == 0) { - /* success */ - return g_strdup (vcard_dbt.data); - } - else if (db_error == 1) { - /* key was not in file */ - return g_strdup (""); /* XXX */ - } - else /* if (db_error < 0)*/ { - /* error */ - return g_strdup (""); /* XXX */ - } -} - -static char * -pas_backend_file_extract_path_from_uri (const char *uri) -{ - g_assert (strncasecmp (uri, "file:", 5) == 0); - - return g_strdup (uri + 5); -} - -static gboolean -pas_backend_file_upgrade_db (PASBackendFile *bf, char *old_version) -{ - if (!strcmp (old_version, "0.0")) { - /* 0.0 is the same as 0.1, we just need to add the version */ - DB *db = bf->priv->file_db; - DBT version_name_dbt, version_dbt; - int db_error; - - string_to_dbt (PAS_BACKEND_FILE_VERSION_NAME, &version_name_dbt); - string_to_dbt (PAS_BACKEND_FILE_VERSION, &version_dbt); - - db_error = db->put (db, &version_name_dbt, &version_dbt, 0); - if (db_error == 0) - return TRUE; - else - return FALSE; - } - else { - g_warning ("unsupported version '%s' found in PAS backend file\n", - old_version); - return FALSE; - } -} - -static gboolean -pas_backend_file_maybe_upgrade_db (PASBackendFile *bf) -{ - DB *db = bf->priv->file_db; - DBT version_name_dbt, version_dbt; - int db_error; - char *version; - gboolean ret_val = TRUE; - - string_to_dbt (PAS_BACKEND_FILE_VERSION_NAME, &version_name_dbt); - - db_error = db->get (db, &version_name_dbt, &version_dbt, 0); - if (db_error == 0) { - /* success */ - version = g_strdup (version_dbt.data); - } - else { - /* key was not in file */ - version = g_strdup ("0.0"); - } - - if (strcmp (version, PAS_BACKEND_FILE_VERSION)) - ret_val = pas_backend_file_upgrade_db (bf, version); - - g_free (version); - - return ret_val; -} - -static void -pas_backend_file_load_uri (PASBackend *backend, - const char *uri) -{ - PASBackendFile *bf = PAS_BACKEND_FILE (backend); - char *filename; - - g_assert (bf->priv->loaded == FALSE); - - filename = pas_backend_file_extract_path_from_uri (uri); - - bf->priv->file_db = dbopen (filename, O_RDWR | O_CREAT, 0666, DB_HASH, NULL); - - if (bf->priv->file_db != NULL) { - if (pas_backend_file_maybe_upgrade_db (bf)) - bf->priv->loaded = TRUE; - /* XXX what if we fail to upgrade it? */ - } - else - g_warning ("pas_backend_file_load_uri failed for '%s'\n", filename); - - g_free (filename); -} - -static void -pas_backend_file_add_client (PASBackend *backend, - Evolution_BookListener listener) -{ - PASBackendFile *bf; - PASBook *book; - - g_assert (backend != NULL); - g_assert (PAS_IS_BACKEND_FILE (backend)); - - bf = PAS_BACKEND_FILE (backend); - - book = pas_book_new ( - backend, listener, - pas_backend_file_get_vcard); - - g_assert (book != NULL); - - gtk_signal_connect (GTK_OBJECT (book), "destroy", - pas_backend_file_book_destroy_cb, NULL); - - gtk_signal_connect (GTK_OBJECT (book), "requests_queued", - pas_backend_file_process_client_requests, NULL); - - bf->priv->clients = g_list_prepend ( - bf->priv->clients, book); - - if (bf->priv->loaded) { - pas_book_respond_open ( - book, Evolution_BookListener_Success); - } else { - /* Open the book. */ - pas_book_respond_open ( - book, Evolution_BookListener_Success); - } -} - -static void -pas_backend_file_remove_client (PASBackend *backend, - PASBook *book) -{ - g_return_if_fail (backend != NULL); - g_return_if_fail (PAS_IS_BACKEND (backend)); - g_return_if_fail (book != NULL); - g_return_if_fail (PAS_IS_BOOK (book)); - - g_warning ("pas_backend_file_remove_client: Unimplemented!\n"); -} - -static gboolean -pas_backend_file_construct (PASBackendFile *backend) -{ - g_assert (backend != NULL); - g_assert (PAS_IS_BACKEND_FILE (backend)); - - if (! pas_backend_construct (PAS_BACKEND (backend))) - return FALSE; - - return TRUE; -} - -/** - * pas_backend_file_new: - */ -PASBackend * -pas_backend_file_new (void) -{ - PASBackendFile *backend; - - backend = gtk_type_new (pas_backend_file_get_type ()); - - if (! pas_backend_file_construct (backend)) { - gtk_object_unref (GTK_OBJECT (backend)); - - return NULL; - } - - return PAS_BACKEND (backend); -} - -static void -pas_backend_file_destroy (GtkObject *object) -{ - GTK_OBJECT_CLASS (pas_backend_file_parent_class)->destroy (object); -} - -static void -pas_backend_file_class_init (PASBackendFileClass *klass) -{ - GtkObjectClass *object_class = (GtkObjectClass *) klass; - PASBackendClass *parent_class; - - pas_backend_file_parent_class = gtk_type_class (pas_backend_get_type ()); - - parent_class = PAS_BACKEND_CLASS (klass); - - /* Set the virtual methods. */ - parent_class->load_uri = pas_backend_file_load_uri; - parent_class->add_client = pas_backend_file_add_client; - parent_class->remove_client = pas_backend_file_remove_client; - - object_class->destroy = pas_backend_file_destroy; -} - -static void -pas_backend_file_init (PASBackendFile *backend) -{ - PASBackendFilePrivate *priv; - - priv = g_new0 (PASBackendFilePrivate, 1); - priv->loaded = FALSE; - priv->clients = NULL; - priv->book_views = NULL; - - backend->priv = priv; -} - -/** - * pas_backend_file_get_type: - */ -GtkType -pas_backend_file_get_type (void) -{ - static GtkType type = 0; - - if (! type) { - GtkTypeInfo info = { - "PASBackendFile", - sizeof (PASBackendFile), - sizeof (PASBackendFileClass), - (GtkClassInitFunc) pas_backend_file_class_init, - (GtkObjectInitFunc) pas_backend_file_init, - NULL, /* reserved 1 */ - NULL, /* reserved 2 */ - (GtkClassInitFunc) NULL - }; - - type = gtk_type_unique (pas_backend_get_type (), &info); - } - - return type; -} diff --git a/addressbook/backend/pas/pas-backend-file.h b/addressbook/backend/pas/pas-backend-file.h deleted file mode 100644 index 4da9a29cc5..0000000000 --- a/addressbook/backend/pas/pas-backend-file.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright 2000, Helix Code, Inc. - */ - -#ifndef __PAS_BACKEND_FILE_H__ -#define __PAS_BACKEND_FILE_H__ - -#include -#include "pas-backend.h" - -typedef struct _PASBackendFilePrivate PASBackendFilePrivate; - -typedef struct { - PASBackend parent_object; - PASBackendFilePrivate *priv; -} PASBackendFile; - -typedef struct { - PASBackendClass parent_class; -} PASBackendFileClass; - -PASBackend *pas_backend_file_new (void); -GtkType pas_backend_file_get_type (void); - -#define PAS_BACKEND_FILE_TYPE (pas_backend_file_get_type ()) -#define PAS_BACKEND_FILE(o) (GTK_CHECK_CAST ((o), PAS_BACKEND_FILE_TYPE, PASBackendFile)) -#define PAS_BACKEND_FILE_CLASS(k) (GTK_CHECK_CLASS_CAST((k), PAS_BACKEND_TYPE, PASBackendFileClass)) -#define PAS_IS_BACKEND_FILE(o) (GTK_CHECK_TYPE ((o), PAS_BACKEND_FILE_TYPE)) -#define PAS_IS_BACKEND_FILE_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), PAS_BACKEND_FILE_TYPE)) - -#endif /* ! __PAS_BACKEND_FILE_H__ */ - diff --git a/addressbook/backend/pas/pas-backend-ldap.c b/addressbook/backend/pas/pas-backend-ldap.c deleted file mode 100644 index 95d80d898d..0000000000 --- a/addressbook/backend/pas/pas-backend-ldap.c +++ /dev/null @@ -1,1039 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Author: - * Nat Friedman (nat@helixcode.com) - * - * Copyright 2000, Helix Code, Inc. - */ - -#include "config.h" -#include -#include -#include -#include -#include - -#include "pas-backend-ldap.h" -#include "pas-book.h" -#include "pas-card-cursor.h" - -#include -#include - -#define LDAP_MAX_SEARCH_RESPONSES 500 - -static gchar *map_e_card_prop_to_ldap(gchar *e_card_prop); - -static PASBackendClass *pas_backend_ldap_parent_class; -typedef struct _PASBackendLDAPCursorPrivate PASBackendLDAPCursorPrivate; -typedef struct _PASBackendLDAPBookView PASBackendLDAPBookView; - -struct _PASBackendLDAPPrivate { - gboolean connected; - GList *clients; - LDAP *ldap; - gchar *ldap_host; - int ldap_port; - GList *book_views; -}; - -struct _PASBackendLDAPCursorPrivate { - PASBackend *backend; - PASBook *book; - - GList *elements; - long num_elements; -}; - -struct _PASBackendLDAPBookView { - PASBookView *book_view; - PASBackendLDAPPrivate *blpriv; - gchar *search; - int search_idle; - int search_msgid; -}; - -static long -get_length(PASCardCursor *cursor, gpointer data) -{ - PASBackendLDAPCursorPrivate *cursor_data = (PASBackendLDAPCursorPrivate *) data; - - return cursor_data->num_elements; -} - -static char * -get_nth(PASCardCursor *cursor, long n, gpointer data) -{ - return g_strdup(""); -} - -static void -cursor_destroy(GtkObject *object, gpointer data) -{ - CORBA_Environment ev; - Evolution_Book corba_book; - PASBackendLDAPCursorPrivate *cursor_data = (PASBackendLDAPCursorPrivate *) data; - - corba_book = bonobo_object_corba_objref(BONOBO_OBJECT(cursor_data->book)); - - CORBA_exception_init(&ev); - - Evolution_Book_unref(corba_book, &ev); - - if (ev._major != CORBA_NO_EXCEPTION) { - g_warning("cursor_destroy: Exception unreffing " - "corba book.\n"); - } - - CORBA_exception_free(&ev); - - /* free the ldap specific cursor information */ - - - g_free(cursor_data); -} - -static void -view_destroy(GtkObject *object, gpointer data) -{ - CORBA_Environment ev; - Evolution_Book corba_book; - PASBook *book = (PASBook *)data; - PASBackendLDAP *bl; - GList *list; - - bl = PAS_BACKEND_LDAP(pas_book_get_backend(book)); - for (list = bl->priv->book_views; list; list = g_list_next(list)) { - PASBackendLDAPBookView *view = list->data; - if (view->book_view == PAS_BOOK_VIEW(object)) { - g_free (view->search); - g_free (view); - if (view->search_idle != 0) - g_source_remove(view->search_idle); - bl->priv->book_views = g_list_remove_link(bl->priv->book_views, list); - g_list_free_1(list); - break; - } - } - - corba_book = bonobo_object_corba_objref(BONOBO_OBJECT(book)); - - CORBA_exception_init(&ev); - - Evolution_Book_unref(corba_book, &ev); - - if (ev._major != CORBA_NO_EXCEPTION) { - g_warning("view_destroy: Exception unreffing " - "corba book.\n"); - } - - CORBA_exception_free(&ev); -} - -static void -pas_backend_ldap_ensure_connected (PASBackendLDAP *bl) -{ - LDAP *ldap = bl->priv->ldap; - - /* the connection has gone down, or wasn't ever opened */ - if (ldap == NULL || - (ldap_simple_bind_s(ldap, NULL /*binddn*/, NULL /*passwd*/) != LDAP_SUCCESS)) { - - /* close connection first if it's open first */ - if (ldap) - ldap_unbind (ldap); - - bl->priv->ldap = ldap_open (bl->priv->ldap_host, bl->priv->ldap_port); - if (NULL != bl->priv->ldap) { - ldap_simple_bind_s(bl->priv->ldap, - NULL /*binddn*/, NULL /*passwd*/); - bl->priv->connected = TRUE; - } - else - g_warning ("pas_backend_ldap_ensure_connected failed for " - "'ldap://%s:%d/' (error %s)\n", - bl->priv->ldap_host, - bl->priv->ldap_port, - ldap_err2string(ldap->ld_errno)); - - } -} - -static void -pas_backend_ldap_process_create_card (PASBackend *backend, - PASBook *book, - PASRequest *req) -{ - g_warning ("pas_backend_ldap_process_create_card not implemented\n"); - - pas_book_respond_create ( - book, - Evolution_BookListener_CardNotFound, - ""); - - g_free (req->vcard); -} - -static void -pas_backend_ldap_process_remove_card (PASBackend *backend, - PASBook *book, - PASRequest *req) -{ - g_warning ("pas_backend_ldap_process_remove_card not implemented\n"); - - pas_book_respond_remove ( - book, - Evolution_BookListener_CardNotFound); - - g_free (req->id); -} - -static void -pas_backend_ldap_build_all_cards_list(PASBackend *backend, - PASBackendLDAPCursorPrivate *cursor_data) -{ - PASBackendLDAP *bl = PAS_BACKEND_LDAP (backend); - LDAP *ldap; - int ldap_error; - LDAPMessage *res, *e; - - pas_backend_ldap_ensure_connected(bl); - - ldap = bl->priv->ldap; - - if (ldap) { - ldap->ld_sizelimit = LDAP_MAX_SEARCH_RESPONSES; - - if ((ldap_error = ldap_search_s (ldap, - NULL, - LDAP_SCOPE_ONELEVEL, - "(objectclass=*)", - NULL, 0, &res)) == -1) { - g_warning ("ldap error '%s' in " - "pas_backend_ldap_build_all_cards_list\n", - ldap_err2string(ldap_error)); - } - - cursor_data->elements = NULL; - - cursor_data->num_elements = ldap_count_entries (ldap, res); - - e = ldap_first_entry(ldap, res); - - while (NULL != e) { - - /* for now just make a list of the dn's */ -#if 0 - for ( a = ldap_first_attribute( ldap, e, &ber ); a != NULL; - a = ldap_next_attribute( ldap, e, ber ) ) { - } -#else - cursor_data->elements = g_list_prepend(cursor_data->elements, - g_strdup(ldap_get_dn(ldap, e))); -#endif - - e = ldap_next_entry(ldap, e); - } - - ldap_msgfree(res); - } -} - -static void -pas_backend_ldap_process_modify_card (PASBackend *backend, - PASBook *book, - PASRequest *req) -{ - g_warning ("pas_backend_ldap_process_modify_card not implemented\n"); - - pas_book_respond_modify ( - book, - Evolution_BookListener_CardNotFound); - g_free (req->vcard); -} - -static void -pas_backend_ldap_process_get_cursor (PASBackend *backend, - PASBook *book, - PASRequest *req) -{ - CORBA_Environment ev; - PASBackendLDAPCursorPrivate *cursor_data; - int ldap_error = 0; - PASCardCursor *cursor; - Evolution_Book corba_book; - - cursor_data = g_new(PASBackendLDAPCursorPrivate, 1); - cursor_data->backend = backend; - cursor_data->book = book; - - pas_backend_ldap_build_all_cards_list(backend, cursor_data); - - corba_book = bonobo_object_corba_objref(BONOBO_OBJECT(book)); - - CORBA_exception_init(&ev); - - Evolution_Book_ref(corba_book, &ev); - - if (ev._major != CORBA_NO_EXCEPTION) { - g_warning("pas_backend_file_process_get_cursor: Exception reffing " - "corba book.\n"); - } - - CORBA_exception_free(&ev); - - cursor = pas_card_cursor_new(get_length, - get_nth, - cursor_data); - - gtk_signal_connect(GTK_OBJECT(cursor), "destroy", - GTK_SIGNAL_FUNC(cursor_destroy), cursor_data); - - pas_book_respond_get_cursor ( - book, - (ldap_error == 0 - ? Evolution_BookListener_Success - : Evolution_BookListener_CardNotFound), - cursor); -} - -static ESExpResult * -func_and(struct _ESExp *f, int argc, struct _ESExpResult **argv, void *data) -{ - GList **list = data; - ESExpResult *r; - char ** strings; - - if (argc > 0) { - int i; - - strings = g_new(char*, argc+3); - strings[0] = g_strdup ("(&"); - strings[argc+3 - 2] = g_strdup (")"); - strings[argc+3 - 1] = NULL; - - for (i = 0; i < argc; i ++) { - GList *list_head = *list; - strings[argc - i] = (*list)->data; - *list = g_list_remove_link(*list, *list); - g_list_free_1(list_head); - } - - *list = g_list_prepend(*list, g_strjoinv(" ", strings)); - - for (i = 0 ; i < argc + 2; i ++) - g_free (strings[i]); - - g_free (strings); - } - - r = e_sexp_result_new(ESEXP_RES_BOOL); - r->value.bool = FALSE; - - return r; -} - -static ESExpResult * -func_or(struct _ESExp *f, int argc, struct _ESExpResult **argv, void *data) -{ - GList **list = data; - ESExpResult *r; - char ** strings; - - if (argc > 0) { - int i; - - strings = g_new(char*, argc+3); - strings[0] = g_strdup ("(|"); - strings[argc+3 - 2] = g_strdup (")"); - strings[argc+3 - 1] = NULL; - for (i = 0; i < argc; i ++) { - GList *list_head = *list; - strings[argc - i] = (*list)->data; - *list = g_list_remove_link(*list, *list); - g_list_free_1(list_head); - } - - *list = g_list_prepend(*list, g_strjoinv(" ", strings)); - - for (i = 0 ; i < argc + 2; i ++) - g_free (strings[i]); - - g_free (strings); - } - - r = e_sexp_result_new(ESEXP_RES_BOOL); - r->value.bool = FALSE; - - return r; -} - -static ESExpResult * -func_not(struct _ESExp *f, int argc, struct _ESExpResult **argv, void *data) -{ - GList **list = data; - ESExpResult *r; - - /* just replace the head of the list with the NOT of it. */ - if (argc > 0) { - char *term = (*list)->data; - (*list)->data = g_strdup_printf("(!%s)", term); - g_free (term); - } - - r = e_sexp_result_new(ESEXP_RES_BOOL); - r->value.bool = FALSE; - - return r; -} - -static ESExpResult * -func_contains(struct _ESExp *f, int argc, struct _ESExpResult **argv, void *data) -{ - GList **list = data; - ESExpResult *r; - - if (argc == 2 - && argv[0]->type == ESEXP_RES_STRING - && argv[1]->type == ESEXP_RES_STRING) { - char *propname = argv[0]->value.string; - char *str = argv[1]->value.string; - char *ldap_attr = map_e_card_prop_to_ldap(propname); - gboolean one_star = FALSE; - - if (strlen(str) == 0) - one_star = TRUE; - - if (ldap_attr) - *list = g_list_prepend(*list, - g_strdup_printf("(%s=*%s%s)", - ldap_attr, - str, - one_star ? "" : "*")); - } - - r = e_sexp_result_new(ESEXP_RES_BOOL); - r->value.bool = FALSE; - - return r; -} - -static ESExpResult * -func_is(struct _ESExp *f, int argc, struct _ESExpResult **argv, void *data) -{ - GList **list = data; - ESExpResult *r; - - if (argc == 2 - && argv[0]->type == ESEXP_RES_STRING - && argv[1]->type == ESEXP_RES_STRING) { - char *propname = argv[0]->value.string; - char *str = argv[1]->value.string; - char *ldap_attr = map_e_card_prop_to_ldap(propname); - - if (ldap_attr) - *list = g_list_prepend(*list, - g_strdup_printf("(%s=%s)", - ldap_attr, str)); - } - - r = e_sexp_result_new(ESEXP_RES_BOOL); - r->value.bool = FALSE; - - return r; -} - -static ESExpResult * -func_beginswith(struct _ESExp *f, int argc, struct _ESExpResult **argv, void *data) -{ - GList **list = data; - ESExpResult *r; - - if (argc == 2 - && argv[0]->type == ESEXP_RES_STRING - && argv[1]->type == ESEXP_RES_STRING) { - char *propname = argv[0]->value.string; - char *str = argv[1]->value.string; - char *ldap_attr = map_e_card_prop_to_ldap(propname); - gboolean one_star = FALSE; - - if (strlen(str) == 0) - one_star = TRUE; - - if (ldap_attr) - *list = g_list_prepend(*list, - g_strdup_printf("(%s=%s*)", - ldap_attr, - str)); - } - - r = e_sexp_result_new(ESEXP_RES_BOOL); - r->value.bool = FALSE; - - return r; -} - -static ESExpResult * -func_endswith(struct _ESExp *f, int argc, struct _ESExpResult **argv, void *data) -{ - GList **list = data; - ESExpResult *r; - - if (argc == 2 - && argv[0]->type == ESEXP_RES_STRING - && argv[1]->type == ESEXP_RES_STRING) { - char *propname = argv[0]->value.string; - char *str = argv[1]->value.string; - char *ldap_attr = map_e_card_prop_to_ldap(propname); - gboolean one_star = FALSE; - - if (strlen(str) == 0) - one_star = TRUE; - - if (ldap_attr) - *list = g_list_prepend(*list, - g_strdup_printf("(%s=*%s)", - ldap_attr, - str)); - } - - r = e_sexp_result_new(ESEXP_RES_BOOL); - r->value.bool = FALSE; - - return r; -} - -/* 'builtin' functions */ -static struct { - char *name; - ESExpFunc *func; - int type; /* set to 1 if a function can perform shortcut evaluation, or - doesn't execute everything, 0 otherwise */ -} symbols[] = { - { "and", func_and, 0 }, - { "or", func_or, 0 }, - { "not", func_not, 0 }, - { "contains", func_contains, 0 }, - { "is", func_is, 0 }, - { "beginswith", func_beginswith, 0 }, - { "endswith", func_endswith, 0 }, -}; - -static gchar * -pas_backend_ldap_build_query (gchar *query) -{ - ESExp *sexp; - ESExpResult *r; - gchar *retval; - GList *list = NULL; - int i; - - sexp = e_sexp_new(); - - for(i=0;inext) { - g_warning ("conversion to ldap query string failed"); - retval = NULL; - g_list_foreach (list, (GFunc)g_free, NULL); - } - else { - retval = list->data; - } - - g_list_free (list); - return retval; -} - -static void -construct_email_list(ECard *card, const char *prop, char **values) -{ - ECardList *list; - int i; - - gtk_object_get(GTK_OBJECT(card), - "email", &list, - NULL); - - for (i = 0; values[i]; i ++) { - e_card_list_append(list, values[i]); - } -} - -static void -construct_phone_list(ECard *card, const char *prop, char **values) -{ - ECardList *list; - int i; - - gtk_object_get(GTK_OBJECT(card), - "phone", &list, - NULL); - - for (i = 0; values[i]; i ++) { - ECardPhone *phone_entry = g_new0(ECardPhone, 1); - phone_entry->number = g_strdup (values[i]); - e_card_list_append(list, phone_entry); - } -} - -struct prop_info { - char *query_prop; - char *ldap_attr; -#define PROP_TYPE_NORMAL 0x01 -#define PROP_TYPE_LIST 0x02 -#define PROP_TYPE_LISTITEM 0x03 - int prop_type; - void (*construct_list_func)(ECard *card, const char *prop, char **values); -} prop_info_table[] = { - /* query prop, ldap attr, type, list construct function */ - { "full_name", "cn", PROP_TYPE_NORMAL, NULL }, - { "title", "title", PROP_TYPE_NORMAL, NULL }, - { "email", "mail", PROP_TYPE_LIST, construct_email_list }, - { "phone", "telephoneNumber", PROP_TYPE_LIST, construct_phone_list }, -}; - -static int num_prop_infos = sizeof(prop_info_table) / sizeof(prop_info_table[0]); - -static gchar * -map_e_card_prop_to_ldap(gchar *e_card_prop) -{ - int i; - - for (i = 0; i < num_prop_infos; i ++) - if (!strcmp (e_card_prop, prop_info_table[i].query_prop)) - return prop_info_table[i].ldap_attr; - - return NULL; -} - -static gboolean -poll_ldap (PASBackendLDAPBookView *view) -{ - LDAP *ldap; - int rc; - LDAPMessage *res, *e; - GList *cards = NULL; - - printf ("polling ldap server\n"); - - ldap = view->blpriv->ldap; - - if ((rc = ldap_result (ldap, view->search_msgid, 0, NULL, &res)) - != LDAP_RES_SEARCH_ENTRY) { - view->search_idle = 0; - return FALSE; - } - - e = ldap_first_entry(ldap, res); - - while (NULL != e) { - ECard *card = E_CARD(gtk_type_new(e_card_get_type())); - char *dn = ldap_get_dn(ldap, e); - char *attr; - BerElement *ber = NULL; - - e_card_set_id (card, dn); - - for (attr = ldap_first_attribute (ldap, e, &ber); attr; - attr = ldap_next_attribute (ldap, e, ber)) { - int i; - struct prop_info *info = NULL; - - for (i = 0; i < num_prop_infos; i ++) - if (!strcmp (attr, prop_info_table[i].ldap_attr)) - info = &prop_info_table[i]; - - if (info) { - char **values; - values = ldap_get_values (ldap, e, attr); - - if (info->prop_type == PROP_TYPE_NORMAL) { - /* if it's a normal property just set the string */ - gtk_object_set(GTK_OBJECT(card), - info->query_prop, values[0], NULL); - - } - else if (info->prop_type == PROP_TYPE_LIST) { - /* if it's a list call the construction function, - which calls gtk_object_set to set the property */ - info->construct_list_func(card, - info->query_prop, - values); - } - - ldap_value_free (values); - } - } - - /* if ldap->ld_errno == LDAP_DECODING_ERROR there was an - error decoding an attribute, and we shouldn't free ber, - since the ldap library already did it. */ - if (ldap->ld_errno != LDAP_DECODING_ERROR && ber) - ber_free (ber, 0); - - cards = g_list_append(cards, e_card_get_vcard(card)); - - gtk_object_unref (GTK_OBJECT(card)); - - e = ldap_next_entry(ldap, e); - } - - if (cards) { - pas_book_view_notify_add (view->book_view, cards); - - g_list_foreach (cards, (GFunc)g_free, NULL); - g_list_free (cards); - cards = NULL; - } - - ldap_msgfree(res); - - return TRUE; -} - -static void -pas_backend_ldap_search (PASBackendLDAP *bl, - PASBook *book, - PASBackendLDAPBookView *view) -{ - char *ldap_query = pas_backend_ldap_build_query(view->search); - - if (ldap_query != NULL) { - LDAP *ldap; - - pas_backend_ldap_ensure_connected(bl); - - ldap = bl->priv->ldap; - - if (ldap) { - ldap->ld_sizelimit = LDAP_MAX_SEARCH_RESPONSES; - - if ((view->search_msgid = ldap_search (ldap, - NULL, - LDAP_SCOPE_ONELEVEL, - ldap_query, - NULL, 0)) == -1) { - g_warning ("ldap error '%s' in pas_backend_ldap_search\n", ldap_err2string(ldap->ld_errno)); - } - else { - view->search_idle = g_idle_add((GSourceFunc)poll_ldap, view); - } - } - } -} - -static void -pas_backend_ldap_process_get_book_view (PASBackend *backend, - PASBook *book, - PASRequest *req) -{ - PASBackendLDAP *bl = PAS_BACKEND_LDAP (backend); - CORBA_Environment ev; - Evolution_Book corba_book; - PASBookView *book_view; - PASBackendLDAPBookView *view; - - g_return_if_fail (req->listener != NULL); - - corba_book = bonobo_object_corba_objref(BONOBO_OBJECT(book)); - - CORBA_exception_init(&ev); - - Evolution_Book_ref(corba_book, &ev); - - if (ev._major != CORBA_NO_EXCEPTION) { - g_warning("pas_backend_file_process_get_book_view: Exception reffing " - "corba book.\n"); - } - - CORBA_exception_free(&ev); - - book_view = pas_book_view_new (req->listener); - - gtk_signal_connect(GTK_OBJECT(book_view), "destroy", - GTK_SIGNAL_FUNC(view_destroy), book); - - pas_book_respond_get_book_view (book, - (book_view != NULL - ? Evolution_BookListener_Success - : Evolution_BookListener_CardNotFound /* XXX */), - book_view); - - view = g_new(PASBackendLDAPBookView, 1); - view->book_view = book_view; - view->search = g_strdup(req->search); - view->blpriv = bl->priv; - - bl->priv->book_views = g_list_prepend(bl->priv->book_views, view); - - pas_backend_ldap_search (bl, book, view); - -} - -static void -pas_backend_ldap_process_check_connection (PASBackend *backend, - PASBook *book, - PASRequest *req) -{ - PASBackendLDAP *bl = PAS_BACKEND_LDAP (backend); - - pas_book_report_connection (book, bl->priv->connected); -} - -static void -pas_backend_ldap_process_client_requests (PASBook *book) -{ - PASBackend *backend; - PASRequest *req; - - backend = pas_book_get_backend (book); - - req = pas_book_pop_request (book); - if (req == NULL) - return; - - switch (req->op) { - case CreateCard: - pas_backend_ldap_process_create_card (backend, book, req); - break; - - case RemoveCard: - pas_backend_ldap_process_remove_card (backend, book, req); - break; - - case ModifyCard: - pas_backend_ldap_process_modify_card (backend, book, req); - break; - - case CheckConnection: - pas_backend_ldap_process_check_connection (backend, book, req); - break; - - case GetCursor: - pas_backend_ldap_process_get_cursor (backend, book, req); - break; - - case GetBookView: - pas_backend_ldap_process_get_book_view (backend, book, req); - break; - } - - g_free (req); -} - -static void -pas_backend_ldap_book_destroy_cb (PASBook *book) -{ - PASBackendLDAP *backend; - - backend = PAS_BACKEND_LDAP (pas_book_get_backend (book)); - - pas_backend_remove_client (PAS_BACKEND (backend), book); -} - -static char * -pas_backend_ldap_get_vcard (PASBook *book, const char *id) -{ - PASBackendLDAP *bl; - LDAP *ldap; - int ldap_error = LDAP_SUCCESS; /* XXX */ - - bl = PAS_BACKEND_LDAP (pas_book_get_backend (book)); - ldap = bl->priv->ldap; - - /* XXX use ldap_search */ - - if (LDAP_SUCCESS == ldap_error) { - /* success */ - return g_strdup (""); - } - else { - return g_strdup (""); - } -} - -static void -pas_backend_ldap_load_uri (PASBackend *backend, - const char *uri) -{ - PASBackendLDAP *bl = PAS_BACKEND_LDAP (backend); - LDAPURLDesc *lud; - int ldap_error; - - g_assert (bl->priv->connected == FALSE); - - ldap_error = ldap_url_parse ((char*)uri, &lud); - if (LDAP_SUCCESS == ldap_error) { - bl->priv->ldap_host = g_strdup(lud->lud_host); - bl->priv->ldap_port = lud->lud_port; - - ldap_free_urldesc(lud); - - pas_backend_ldap_ensure_connected(bl); - } - else { - g_warning ("pas_backend_ldap_load_uri failed for '%s' (error %s)\n", - uri, ldap_err2string(ldap_error)); - } -} - -static void -pas_backend_ldap_add_client (PASBackend *backend, - Evolution_BookListener listener) -{ - PASBackendLDAP *bl; - PASBook *book; - - g_assert (backend != NULL); - g_assert (PAS_IS_BACKEND_LDAP (backend)); - - bl = PAS_BACKEND_LDAP (backend); - - book = pas_book_new ( - backend, listener, - pas_backend_ldap_get_vcard); - - g_assert (book != NULL); - - gtk_signal_connect (GTK_OBJECT (book), "destroy", - pas_backend_ldap_book_destroy_cb, NULL); - - gtk_signal_connect (GTK_OBJECT (book), "requests_queued", - pas_backend_ldap_process_client_requests, NULL); - - bl->priv->clients = g_list_prepend ( - bl->priv->clients, book); - - if (bl->priv->connected) { - pas_book_respond_open ( - book, Evolution_BookListener_Success); - } else { - /* Open the book. */ - pas_book_respond_open ( - book, Evolution_BookListener_Success); - } -} - -static void -pas_backend_ldap_remove_client (PASBackend *backend, - PASBook *book) -{ - g_return_if_fail (backend != NULL); - g_return_if_fail (PAS_IS_BACKEND (backend)); - g_return_if_fail (book != NULL); - g_return_if_fail (PAS_IS_BOOK (book)); - - g_warning ("pas_backend_ldap_remove_client: Unimplemented!\n"); -} - -static gboolean -pas_backend_ldap_construct (PASBackendLDAP *backend) -{ - g_assert (backend != NULL); - g_assert (PAS_IS_BACKEND_LDAP (backend)); - - if (! pas_backend_construct (PAS_BACKEND (backend))) - return FALSE; - - return TRUE; -} - -/** - * pas_backend_ldap_new: - */ -PASBackend * -pas_backend_ldap_new (void) -{ - PASBackendLDAP *backend; - - backend = gtk_type_new (pas_backend_ldap_get_type ()); - - if (! pas_backend_ldap_construct (backend)) { - gtk_object_unref (GTK_OBJECT (backend)); - - return NULL; - } - - backend->priv->ldap = NULL; - - return PAS_BACKEND (backend); -} - -static void -pas_backend_ldap_destroy (GtkObject *object) -{ - GTK_OBJECT_CLASS (pas_backend_ldap_parent_class)->destroy (object); -} - -static void -pas_backend_ldap_class_init (PASBackendLDAPClass *klass) -{ - GtkObjectClass *object_class = (GtkObjectClass *) klass; - PASBackendClass *parent_class; - - pas_backend_ldap_parent_class = gtk_type_class (pas_backend_get_type ()); - - parent_class = PAS_BACKEND_CLASS (klass); - - /* Set the virtual methods. */ - parent_class->load_uri = pas_backend_ldap_load_uri; - parent_class->add_client = pas_backend_ldap_add_client; - parent_class->remove_client = pas_backend_ldap_remove_client; - - object_class->destroy = pas_backend_ldap_destroy; -} - -static void -pas_backend_ldap_init (PASBackendLDAP *backend) -{ - PASBackendLDAPPrivate *priv; - - priv = g_new0 (PASBackendLDAPPrivate, 1); - priv->connected = FALSE; - priv->clients = NULL; - - backend->priv = priv; -} - -/** - * pas_backend_ldap_get_type: - */ -GtkType -pas_backend_ldap_get_type (void) -{ - static GtkType type = 0; - - if (! type) { - GtkTypeInfo info = { - "PASBackendLDAP", - sizeof (PASBackendLDAP), - sizeof (PASBackendLDAPClass), - (GtkClassInitFunc) pas_backend_ldap_class_init, - (GtkObjectInitFunc) pas_backend_ldap_init, - NULL, /* reserved 1 */ - NULL, /* reserved 2 */ - (GtkClassInitFunc) NULL - }; - - type = gtk_type_unique (pas_backend_get_type (), &info); - } - - return type; -} diff --git a/addressbook/backend/pas/pas-backend-ldap.h b/addressbook/backend/pas/pas-backend-ldap.h deleted file mode 100644 index a59cdf3857..0000000000 --- a/addressbook/backend/pas/pas-backend-ldap.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright 2000, Helix Code, Inc. - */ - -#ifndef __PAS_BACKEND_LDAP_H__ -#define __PAS_BACKEND_LDAP_H__ - -#include -#include "pas-backend.h" - -typedef struct _PASBackendLDAPPrivate PASBackendLDAPPrivate; - -typedef struct { - PASBackend parent_object; - PASBackendLDAPPrivate *priv; -} PASBackendLDAP; - -typedef struct { - PASBackendClass parent_class; -} PASBackendLDAPClass; - -PASBackend *pas_backend_ldap_new (void); -GtkType pas_backend_ldap_get_type (void); - -#define PAS_BACKEND_LDAP_TYPE (pas_backend_ldap_get_type ()) -#define PAS_BACKEND_LDAP(o) (GTK_CHECK_CAST ((o), PAS_BACKEND_LDAP_TYPE, PASBackendLDAP)) -#define PAS_BACKEND_LDAP_CLASS(k) (GTK_CHECK_CLASS_CAST((k), PAS_BACKEND_TYPE, PASBackendLDAPClass)) -#define PAS_IS_BACKEND_LDAP(o) (GTK_CHECK_TYPE ((o), PAS_BACKEND_LDAP_TYPE)) -#define PAS_IS_BACKEND_LDAP_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), PAS_BACKEND_LDAP_TYPE)) - -#endif /* ! __PAS_BACKEND_LDAP_H__ */ - diff --git a/addressbook/backend/pas/pas-backend.c b/addressbook/backend/pas/pas-backend.c deleted file mode 100644 index d8aa23fb37..0000000000 --- a/addressbook/backend/pas/pas-backend.c +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Author: - * Nat Friedman (nat@helixcode.com) - * - * Copyright 2000, Helix Code, Inc. - */ - -#include -#include -#include "pas-backend.h" - -#define CLASS(o) PAS_BACKEND_CLASS (GTK_OBJECT (o)->klass) - -gboolean -pas_backend_construct (PASBackend *backend) -{ - return TRUE; -} - -void -pas_backend_load_uri (PASBackend *backend, - const char *uri) -{ - g_return_if_fail (backend != NULL); - g_return_if_fail (PAS_IS_BACKEND (backend)); - g_return_if_fail (uri != NULL); - - g_assert (CLASS (backend)->load_uri != NULL); - - CLASS (backend)->load_uri (backend, uri); -} - -/** - * pas_backend_add_client: - * @backend: - * @listener: - */ -void -pas_backend_add_client (PASBackend *backend, - Evolution_BookListener listener) -{ - g_return_if_fail (backend != NULL); - g_return_if_fail (PAS_IS_BACKEND (backend)); - g_return_if_fail (listener != CORBA_OBJECT_NIL); - - g_assert (CLASS (backend)->add_client != NULL); - - CLASS (backend)->add_client (backend, listener); -} - -void -pas_backend_remove_client (PASBackend *backend, - PASBook *book) -{ - g_return_if_fail (backend != NULL); - g_return_if_fail (PAS_IS_BACKEND (backend)); - g_return_if_fail (book != NULL); - g_return_if_fail (PAS_IS_BOOK (book)); - - g_assert (CLASS (backend)->remove_client != NULL); - - CLASS (backend)->remove_client (backend, book); -} - -static void -pas_backend_init (PASBackend *backend) -{ -} - -static void -pas_backend_class_init (PASBackendClass *klass) -{ -} - -/** - * pas_backend_get_type: - */ -GtkType -pas_backend_get_type (void) -{ - static GtkType type = 0; - - if (! type) { - GtkTypeInfo info = { - "PASBackend", - sizeof (PASBackend), - sizeof (PASBackendClass), - (GtkClassInitFunc) pas_backend_class_init, - (GtkObjectInitFunc) pas_backend_init, - NULL, /* reserved 1 */ - NULL, /* reserved 2 */ - (GtkClassInitFunc) NULL - }; - - type = gtk_type_unique (gtk_object_get_type (), &info); - } - - return type; -} diff --git a/addressbook/backend/pas/pas-backend.h b/addressbook/backend/pas/pas-backend.h deleted file mode 100644 index 46cce03e03..0000000000 --- a/addressbook/backend/pas/pas-backend.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - * An abstract class which defines the API to a given backend. - * There will be one PASBackend object for every URI which is loaded. - * - * Two people will call into the PASBackend API: - * - * 1. The PASBookFactory, when it has been asked to load a book. - * It will create a new PASBackend if one is not already running - * for the requested URI. It will call pas_backend_add_client to - * add a new client to an existing PASBackend server. - * - * 2. A PASBook, when a client has requested an operation on the - * Evolution_Book interface. - * - * Author: - * Nat Friedman (nat@helixcode.com) - * - * Copyright 2000, Helix Code, Inc. - */ - -#ifndef __PAS_BACKEND_H__ -#define __PAS_BACKEND_H__ - -#include -#include -#include - -typedef struct _PASBackend PASBackend; -typedef struct _PASBackendPrivate PASBackendPrivate; - -#include - -struct _PASBackend { - GtkObject parent_object; - PASBackendPrivate *priv; -}; - -typedef struct { - GtkObjectClass parent_class; - - /* Virtual methods */ - void (*load_uri) (PASBackend *backend, const char *uri); - void (*add_client) (PASBackend *backend, Evolution_BookListener listener); - void (*remove_client) (PASBackend *backend, PASBook *book); -} PASBackendClass; - -typedef PASBackend * (*PASBackendFactoryFn) (void); - -gboolean pas_backend_construct (PASBackend *backend); -void pas_backend_load_uri (PASBackend *backend, - const char *uri); -void pas_backend_add_client (PASBackend *backend, - Evolution_BookListener listener); -void pas_backend_remove_client (PASBackend *backend, - PASBook *book); - -GtkType pas_backend_get_type (void); - -#define PAS_BACKEND_TYPE (pas_backend_get_type ()) -#define PAS_BACKEND(o) (GTK_CHECK_CAST ((o), PAS_BACKEND_TYPE, PASBackend)) -#define PAS_BACKEND_CLASS(k) (GTK_CHECK_CLASS_CAST((k), PAS_BACKEND_TYPE, PASBackendClass)) -#define PAS_IS_BACKEND(o) (GTK_CHECK_TYPE ((o), PAS_BACKEND_TYPE)) -#define PAS_IS_BACKEND_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), PAS_BACKEND_TYPE)) - -#endif /* ! __PAS_BACKEND_H__ */ - diff --git a/addressbook/backend/pas/pas-book-factory.c b/addressbook/backend/pas/pas-book-factory.c deleted file mode 100644 index 6542ffc48b..0000000000 --- a/addressbook/backend/pas/pas-book-factory.c +++ /dev/null @@ -1,475 +0,0 @@ -/* - * - * Author: - * Nat Friedman (nat@helixcode.com) - * - * Copyright 2000, Helix Code, Inc. - */ - -#include -#include -#include -#include "addressbook.h" -#include "pas-book-factory.h" - -#define PAS_BOOK_FACTORY_GOAD_ID "evolution:addressbook-server" - -static BonoboObjectClass *pas_book_factory_parent_class; -POA_Evolution_BookFactory__vepv pas_book_factory_vepv; - -typedef struct { - char *uri; - Evolution_BookListener listener; -} PASBookFactoryQueuedRequest; - -struct _PASBookFactoryPrivate { - gint idle_id; - GHashTable *backends; - GHashTable *active_server_map; - GList *queued_requests; -}; - -static char * -pas_book_factory_canonicalize_uri (const char *uri) -{ - /* FIXME: What do I do here? */ - - return g_strdup (uri); -} - -static char * -pas_book_factory_extract_proto_from_uri (const char *uri) -{ - char *proto; - char *p; - - p = strchr (uri, ':'); - - if (p == NULL) - return NULL; - - proto = g_malloc0 (p - uri + 1); - - strncpy (proto, uri, p - uri); - - return proto; -} - -/** - * pas_book_factory_register_backend: - * @factory: - * @proto: - * @backend: - */ -void -pas_book_factory_register_backend (PASBookFactory *factory, - const char *proto, - PASBackendFactoryFn backend) -{ - g_return_if_fail (factory != NULL); - g_return_if_fail (PAS_IS_BOOK_FACTORY (factory)); - g_return_if_fail (proto != NULL); - g_return_if_fail (backend != NULL); - - - - if (g_hash_table_lookup (factory->priv->backends, proto) != NULL) { - g_warning ("pas_book_factory_register_backend: " - "Proto \"%s\" already registered!\n", proto); - } - - g_hash_table_insert (factory->priv->backends, - g_strdup (proto), backend); -} - -static PASBackendFactoryFn -pas_book_factory_lookup_backend_factory (PASBookFactory *factory, - const char *uri) -{ - PASBackendFactoryFn backend; - char *proto; - char *canonical_uri; - - g_assert (factory != NULL); - g_assert (PAS_IS_BOOK_FACTORY (factory)); - g_assert (uri != NULL); - - canonical_uri = pas_book_factory_canonicalize_uri (uri); - if (canonical_uri == NULL) - return NULL; - - proto = pas_book_factory_extract_proto_from_uri (canonical_uri); - if (proto == NULL) { - g_free (canonical_uri); - return NULL; - } - - backend = g_hash_table_lookup (factory->priv->backends, proto); - - g_free (proto); - g_free (canonical_uri); - - return backend; -} - -static PASBackend * -pas_book_factory_launch_backend (PASBookFactory *factory, - PASBookFactoryQueuedRequest *request) -{ - PASBackendFactoryFn backend_factory; - PASBackend *backend; - - backend_factory = pas_book_factory_lookup_backend_factory ( - factory, request->uri); - g_assert (backend_factory != NULL); - - backend = (backend_factory) (); - g_assert (backend != NULL); - - g_hash_table_insert (factory->priv->active_server_map, - g_strdup (request->uri), - backend); - - return backend; -} - -static void -pas_book_factory_process_request (PASBookFactory *factory, - PASBookFactoryQueuedRequest *request) -{ - PASBackend *backend; - - request = factory->priv->queued_requests->data; - - backend = g_hash_table_lookup (factory->priv->active_server_map, request->uri); - - if (backend == NULL) { - - backend = pas_book_factory_launch_backend (factory, request); - pas_backend_add_client (backend, request->listener); - pas_backend_load_uri (backend, request->uri); - g_free (request->uri); - - return; - } - - g_free (request->uri); - - pas_backend_add_client (backend, request->listener); -} - -static gboolean -pas_book_factory_process_queue (PASBookFactory *factory) -{ - /* Process pending Book-creation requests. */ - if (factory->priv->queued_requests != NULL) { - PASBookFactoryQueuedRequest *request; - - request = factory->priv->queued_requests->data; - - pas_book_factory_process_request (factory, request); - - factory->priv->queued_requests = g_list_remove ( - factory->priv->queued_requests, request); - - g_free (request); - } - - if (factory->priv->queued_requests == NULL) { - - factory->priv->idle_id = 0; - return FALSE; - } - - return TRUE; -} - -static void -pas_book_factory_queue_request (PASBookFactory *factory, - const char *uri, - const Evolution_BookListener listener) -{ - PASBookFactoryQueuedRequest *request; - Evolution_BookListener listener_copy; - CORBA_Environment ev; - - CORBA_exception_init (&ev); - - listener_copy = CORBA_Object_duplicate (listener, &ev); - - if (ev._major != CORBA_NO_EXCEPTION) { - g_warning ("PASBookFactory: Could not duplicate BookListener!\n"); - CORBA_exception_free (&ev); - return; - } - - CORBA_exception_free (&ev); - - request = g_new0 (PASBookFactoryQueuedRequest, 1); - request->listener = listener_copy; - request->uri = g_strdup (uri); - - factory->priv->queued_requests = - g_list_prepend (factory->priv->queued_requests, request); - - if (! factory->priv->idle_id) { - factory->priv->idle_id = - g_idle_add ((GSourceFunc) pas_book_factory_process_queue, factory); - } -} - - -static void -impl_Evolution_BookFactory_open_book (PortableServer_Servant servant, - const CORBA_char *uri, - const Evolution_BookListener listener, - CORBA_Environment *ev) -{ - PASBookFactory *factory = - PAS_BOOK_FACTORY (bonobo_object_from_servant (servant)); - PASBackendFactoryFn backend_factory; - - backend_factory = pas_book_factory_lookup_backend_factory (factory, uri); - - if (backend_factory == NULL) { - g_warning ("PASBookFactory: No backend found for uri: %s\n", uri); - - CORBA_exception_set ( - ev, CORBA_USER_EXCEPTION, - ex_Evolution_BookFactory_ProtocolNotSupported, NULL); - - return; - } - - pas_book_factory_queue_request (factory, uri, listener); -} - -static gboolean -pas_book_factory_construct (PASBookFactory *factory) -{ - POA_Evolution_BookFactory *servant; - CORBA_Environment ev; - CORBA_Object obj; - - g_assert (factory != NULL); - g_assert (PAS_IS_BOOK_FACTORY (factory)); - - servant = (POA_Evolution_BookFactory *) g_new0 (BonoboObjectServant, 1); - servant->vepv = &pas_book_factory_vepv; - - CORBA_exception_init (&ev); - - POA_Evolution_BookFactory__init ((PortableServer_Servant) servant, &ev); - if (ev._major != CORBA_NO_EXCEPTION) { - g_free (servant); - CORBA_exception_free (&ev); - - return FALSE; - } - - CORBA_exception_free (&ev); - - obj = bonobo_object_activate_servant (BONOBO_OBJECT (factory), servant); - if (obj == CORBA_OBJECT_NIL) { - g_free (servant); - - return FALSE; - } - - bonobo_object_construct (BONOBO_OBJECT (factory), obj); - - return TRUE; -} - -/** - * pas_book_factory_new: - */ -PASBookFactory * -pas_book_factory_new (void) -{ - PASBookFactory *factory; - - factory = gtk_type_new (pas_book_factory_get_type ()); - - if (! pas_book_factory_construct (factory)) { - g_warning ("pas_book_factory_new: Could not construct PASBookFactory!\n"); - gtk_object_unref (GTK_OBJECT (factory)); - - return NULL; - } - - return factory; -} - -/** - * pas_book_factory_activate: - */ -void -pas_book_factory_activate (PASBookFactory *factory) -{ - CORBA_Environment ev; - int ret; - - g_return_if_fail (factory != NULL); - g_return_if_fail (PAS_IS_BOOK_FACTORY (factory)); - - CORBA_exception_init (&ev); - - ret = goad_server_register ( - NULL, - bonobo_object_corba_objref (BONOBO_OBJECT (factory)), - PAS_BOOK_FACTORY_GOAD_ID, "server", - &ev); - - if (ev._major != CORBA_NO_EXCEPTION) { - g_message ("pas_book_factory_activate: Exception " - "registering PASBookFactory!\n"); - CORBA_exception_free (&ev); - return; - } - - CORBA_exception_free (&ev); - - if (ret == -1) { - g_message ("pas_book_factory_activate: Error " - "registering PASBookFactory!\n"); - return; - } - - if (ret == -2) { - g_message ("pas_book_factory_activate: Another " - "PASBookFactory is already running.\n"); - return; - - } - - return; -} - - -static void -pas_book_factory_init (PASBookFactory *factory) -{ - factory->priv = g_new0 (PASBookFactoryPrivate, 1); - - factory->priv->active_server_map = g_hash_table_new (g_str_hash, g_str_equal); - factory->priv->backends = g_hash_table_new (g_str_hash, g_str_equal); - factory->priv->queued_requests = NULL; -} - -static gboolean -pas_book_factory_remove_asm_entry (gpointer key, gpointer value, - gpointer data) -{ - CORBA_Environment ev; - - g_free (key); - - CORBA_exception_init (&ev); - CORBA_Object_release ((CORBA_Object) value, &ev); - CORBA_exception_free (&ev); - - return TRUE; -} - -static gboolean -pas_book_factory_remove_backend_entry (gpointer key, gpointer value, - gpointer data) -{ - g_free (key); - return TRUE; -} - -static void -pas_book_factory_destroy (GtkObject *object) -{ - PASBookFactory *factory = PAS_BOOK_FACTORY (object); - GList *l; - - for (l = factory->priv->queued_requests; l != NULL; l = l->next) { - PASBookFactoryQueuedRequest *request = l->data; - CORBA_Environment ev; - - g_free (request->uri); - - CORBA_exception_init (&ev); - CORBA_Object_release (request->listener, &ev); - CORBA_exception_free (&ev); - - g_free (request); - } - g_list_free (factory->priv->queued_requests); - factory->priv->queued_requests = NULL; - - g_hash_table_foreach_remove (factory->priv->active_server_map, - pas_book_factory_remove_asm_entry, - NULL); - g_hash_table_destroy (factory->priv->active_server_map); - - g_hash_table_foreach_remove (factory->priv->backends, - pas_book_factory_remove_backend_entry, - NULL); - g_hash_table_destroy (factory->priv->backends); - - g_free (factory->priv); - - GTK_OBJECT_CLASS (pas_book_factory_parent_class)->destroy (object); -} - -static POA_Evolution_BookFactory__epv * -pas_book_factory_get_epv (void) -{ - POA_Evolution_BookFactory__epv *epv; - - epv = g_new0 (POA_Evolution_BookFactory__epv, 1); - - epv->open_book = impl_Evolution_BookFactory_open_book; - - return epv; - -} - -static void -pas_book_factory_corba_class_init (void) -{ - pas_book_factory_vepv.Bonobo_Unknown_epv = bonobo_object_get_epv (); - pas_book_factory_vepv.Evolution_BookFactory_epv = pas_book_factory_get_epv (); -} - -static void -pas_book_factory_class_init (PASBookFactoryClass *klass) -{ - GtkObjectClass *object_class = (GtkObjectClass *) klass; - - pas_book_factory_parent_class = gtk_type_class (bonobo_object_get_type ()); - - object_class->destroy = pas_book_factory_destroy; - - pas_book_factory_corba_class_init (); -} - -/** - * pas_book_factory_get_type: - */ -GtkType -pas_book_factory_get_type (void) -{ - static GtkType type = 0; - - if (! type) { - GtkTypeInfo info = { - "PASBookFactory", - sizeof (PASBookFactory), - sizeof (PASBookFactoryClass), - (GtkClassInitFunc) pas_book_factory_class_init, - (GtkObjectInitFunc) pas_book_factory_init, - NULL, /* reserved 1 */ - NULL, /* reserved 2 */ - (GtkClassInitFunc) NULL - }; - - type = gtk_type_unique (bonobo_object_get_type (), &info); - } - - return type; -} diff --git a/addressbook/backend/pas/pas-book-factory.h b/addressbook/backend/pas/pas-book-factory.h deleted file mode 100644 index c9607298f5..0000000000 --- a/addressbook/backend/pas/pas-book-factory.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2000, Helix Code, Inc. - */ - -#include -#include - -#include - -#ifndef __PAS_BOOK_FACTORY_H__ -#define __PAS_BOOK_FACTORY_H__ - -BEGIN_GNOME_DECLS - -typedef struct _PASBookFactoryPrivate PASBookFactoryPrivate; - -typedef struct { - BonoboObject parent_object; - PASBookFactoryPrivate *priv; -} PASBookFactory; - -typedef struct { - BonoboObjectClass parent_class; -} PASBookFactoryClass; - -PASBookFactory *pas_book_factory_new (void); - -void pas_book_factory_register_backend (PASBookFactory *factory, - const char *proto, - PASBackendFactoryFn backend_factory); - -void pas_book_factory_activate (PASBookFactory *factory); - -GtkType pas_book_factory_get_type (void); - -#define PAS_BOOK_FACTORY_TYPE (pas_book_factory_get_type ()) -#define PAS_BOOK_FACTORY(o) (GTK_CHECK_CAST ((o), PAS_BOOK_FACTORY_TYPE, PASBookFactory)) -#define PAS_BOOK_FACTORY_CLASS(k) (GTK_CHECK_CLASS_CAST((k), PAS_BOOK_FACTORY_TYPE, PASBookFactoryClass)) -#define PAS_IS_BOOK_FACTORY(o) (GTK_CHECK_TYPE ((o), PAS_BOOK_FACTORY_TYPE)) -#define PAS_IS_BOOK_FACTORY_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), PAS_BOOK_FACTORY_TYPE)) - -END_GNOME_DECLS - -#endif /* ! __PAS_BOOK_FACTORY_H__ */ diff --git a/addressbook/backend/pas/pas-book-view.c b/addressbook/backend/pas/pas-book-view.c deleted file mode 100644 index d218112555..0000000000 --- a/addressbook/backend/pas/pas-book-view.c +++ /dev/null @@ -1,262 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * pas-book-view.c - * - * Copyright 2000, Helix Code, Inc. - */ - -#include -#include -#include "pas-book-view.h" - -static BonoboObjectClass *pas_book_view_parent_class; -POA_Evolution_BookView__vepv pas_book_view_vepv; - -struct _PASBookViewPrivate { - Evolution_BookViewListener listener; -}; - -/** - * pas_book_view_notify_change: - */ -void -pas_book_view_notify_change (PASBookView *book_view, - const GList *cards) -{ - CORBA_Environment ev; - gint i, length; - CORBA_sequence_Evolution_VCard card_sequence; - - length = g_list_length((GList *) cards); - - card_sequence._buffer = CORBA_sequence_Evolution_VCard_allocbuf(length); - card_sequence._maximum = length; - card_sequence._length = length; - - for ( i = 0; cards; cards = g_list_next(cards), i++ ) { - card_sequence._buffer[i] = CORBA_string_dup((char *) cards->data); - } - - CORBA_exception_init (&ev); - - Evolution_BookViewListener_signal_card_changed ( - book_view->priv->listener, &card_sequence, &ev); - - if (ev._major != CORBA_NO_EXCEPTION) { - g_warning ("pas_book_view_notify_change: Exception signaling BookViewListener!\n"); - } - - CORBA_exception_free (&ev); - - CORBA_free(card_sequence._buffer); -} - -void -pas_book_view_notify_change_1 (PASBookView *book_view, - const char *card) -{ - GList *list = g_list_append(NULL, (char *) card); - pas_book_view_notify_change(book_view, list); - g_list_free(list); -} - -/** - * pas_book_view_notify_remove: - */ -void -pas_book_view_notify_remove (PASBookView *book_view, - const char *id) -{ - CORBA_Environment ev; - - CORBA_exception_init (&ev); - - Evolution_BookViewListener_signal_card_removed ( - book_view->priv->listener, (Evolution_CardId) id, &ev); - - if (ev._major != CORBA_NO_EXCEPTION) { - g_warning ("pas_book_view_notify_remove: Exception signaling BookViewListener!\n"); - } - - CORBA_exception_free (&ev); -} - -/** - * pas_book_view_notify_add: - */ -void -pas_book_view_notify_add (PASBookView *book_view, - const GList *cards) -{ - CORBA_Environment ev; - gint i, length; - CORBA_sequence_Evolution_VCard card_sequence; - - length = g_list_length((GList *)cards); - - card_sequence._buffer = CORBA_sequence_Evolution_VCard_allocbuf(length); - card_sequence._maximum = length; - card_sequence._length = length; - - for ( i = 0; cards; cards = g_list_next(cards), i++ ) { - card_sequence._buffer[i] = CORBA_string_dup((char *) cards->data); - } - - CORBA_exception_init (&ev); - - Evolution_BookViewListener_signal_card_added ( - book_view->priv->listener, &card_sequence, &ev); - - if (ev._major != CORBA_NO_EXCEPTION) { - g_warning ("pas_book_view_notify_add: Exception signaling BookViewListener!\n"); - } - - CORBA_exception_free (&ev); - - CORBA_free(card_sequence._buffer); -} - -void -pas_book_view_notify_add_1 (PASBookView *book_view, - const char *card) -{ - GList *list = g_list_append(NULL, (char *) card); - pas_book_view_notify_add(book_view, list); - g_list_free(list); -} - -static gboolean -pas_book_view_construct (PASBookView *book_view, - Evolution_BookViewListener listener) -{ - POA_Evolution_BookView *servant; - CORBA_Environment ev; - CORBA_Object obj; - - g_assert (book_view != NULL); - g_assert (PAS_IS_BOOK_VIEW (book_view)); - g_assert (listener != CORBA_OBJECT_NIL); - - servant = (POA_Evolution_BookView *) g_new0 (BonoboObjectServant, 1); - servant->vepv = &pas_book_view_vepv; - - CORBA_exception_init (&ev); - - POA_Evolution_BookView__init ((PortableServer_Servant) servant, &ev); - if (ev._major != CORBA_NO_EXCEPTION) { - g_free (servant); - CORBA_exception_free (&ev); - - return FALSE; - } - - CORBA_exception_free (&ev); - - obj = bonobo_object_activate_servant (BONOBO_OBJECT (book_view), servant); - if (obj == CORBA_OBJECT_NIL) { - g_free (servant); - - return FALSE; - } - - bonobo_object_construct (BONOBO_OBJECT (book_view), obj); - - book_view->priv->listener = listener; - - return TRUE; -} - -/** - * pas_book_view_new: - */ -PASBookView * -pas_book_view_new (Evolution_BookViewListener listener) -{ - PASBookView *book_view; - - g_return_val_if_fail (listener != CORBA_OBJECT_NIL, NULL); - - book_view = gtk_type_new (pas_book_view_get_type ()); - - if (! pas_book_view_construct (book_view, listener)) { - gtk_object_unref (GTK_OBJECT (book_view)); - - return NULL; - } - - return book_view; -} - -static void -pas_book_view_destroy (GtkObject *object) -{ - PASBookView *book_view = PAS_BOOK_VIEW (object); - - g_free (book_view->priv); - - GTK_OBJECT_CLASS (pas_book_view_parent_class)->destroy (object); -} - -static POA_Evolution_BookView__epv * -pas_book_view_get_epv (void) -{ - POA_Evolution_BookView__epv *epv; - - epv = g_new0 (POA_Evolution_BookView__epv, 1); - - return epv; - -} - -static void -pas_book_view_corba_class_init (void) -{ - pas_book_view_vepv.Bonobo_Unknown_epv = bonobo_object_get_epv (); - pas_book_view_vepv.Evolution_BookView_epv = pas_book_view_get_epv (); -} - -static void -pas_book_view_class_init (PASBookViewClass *klass) -{ - GtkObjectClass *object_class = (GtkObjectClass *) klass; - - pas_book_view_parent_class = gtk_type_class (bonobo_object_get_type ()); - - object_class->destroy = pas_book_view_destroy; - - pas_book_view_corba_class_init (); -} - -static void -pas_book_view_init (PASBookView *book_view) -{ - book_view->priv = g_new0 (PASBookViewPrivate, 1); - book_view->priv->listener = CORBA_OBJECT_NIL; -} - -/** - * pas_book_view_get_type: - */ -GtkType -pas_book_view_get_type (void) -{ - static GtkType type = 0; - - if (! type) { - GtkTypeInfo info = { - "PASBookView", - sizeof (PASBookView), - sizeof (PASBookViewClass), - (GtkClassInitFunc) pas_book_view_class_init, - (GtkObjectInitFunc) pas_book_view_init, - NULL, /* reserved 1 */ - NULL, /* reserved 2 */ - (GtkClassInitFunc) NULL - }; - - type = gtk_type_unique (bonobo_object_get_type (), &info); - } - - return type; -} - diff --git a/addressbook/backend/pas/pas-book-view.h b/addressbook/backend/pas/pas-book-view.h deleted file mode 100644 index 55023b48ed..0000000000 --- a/addressbook/backend/pas/pas-book-view.h +++ /dev/null @@ -1,53 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * A wrapper object which exports the Evolution_Book CORBA interface - * and which maintains a request queue. - * - * Author: - * Nat Friedman (nat@helixcode.com) - * - * Copyright 2000, Helix Code, Inc. - */ - -#ifndef __PAS_BOOK_VIEW_H__ -#define __PAS_BOOK_VIEW_H__ - -#include -#include -#include - -typedef struct _PASBookView PASBookView; -typedef struct _PASBookViewClass PASBookViewClass; -typedef struct _PASBookViewPrivate PASBookViewPrivate; - -struct _PASBookView { - BonoboObject parent_object; - PASBookViewPrivate *priv; -}; - -struct _PASBookViewClass { - BonoboObjectClass parent_class; -}; - -PASBookView *pas_book_view_new (Evolution_BookViewListener listener); - -void pas_book_view_notify_change (PASBookView *book_view, - const GList *cards); -void pas_book_view_notify_change_1 (PASBookView *book_view, - const char *card); -void pas_book_view_notify_remove (PASBookView *book_view, - const char *id); -void pas_book_view_notify_add (PASBookView *book_view, - const GList *cards); -void pas_book_view_notify_add_1 (PASBookView *book_view, - const char *card); - -GtkType pas_book_view_get_type (void); - -#define PAS_BOOK_VIEW_TYPE (pas_book_view_get_type ()) -#define PAS_BOOK_VIEW(o) (GTK_CHECK_CAST ((o), PAS_BOOK_VIEW_TYPE, PASBookView)) -#define PAS_BOOK_VIEW_CLASS(k) (GTK_CHECK_CLASS_CAST((k), PAS_BOOK_VIEW_FACTORY_TYPE, PASBookViewClass)) -#define PAS_IS_BOOK_VIEW(o) (GTK_CHECK_TYPE ((o), PAS_BOOK_VIEW_TYPE)) -#define PAS_IS_BOOK_VIEW_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), PAS_BOOK_VIEW_TYPE)) - -#endif /* ! __PAS_BOOK_VIEW_H__ */ diff --git a/addressbook/backend/pas/pas-book.c b/addressbook/backend/pas/pas-book.c deleted file mode 100644 index 8aea0197cc..0000000000 --- a/addressbook/backend/pas/pas-book.c +++ /dev/null @@ -1,622 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * pas-book.c - * - * Copyright 2000, Helix Code, Inc. - */ - -#include -#include -#include "pas-book.h" - -static BonoboObjectClass *pas_book_parent_class; -POA_Evolution_Book__vepv pas_book_vepv; - -enum { - REQUESTS_QUEUED, - LAST_SIGNAL -}; - -static guint pas_book_signals [LAST_SIGNAL]; - -struct _PASBookPrivate { - PASBackend *backend; - Evolution_BookListener listener; - PASBookGetVCardFn get_vcard; - - GList *request_queue; - gint idle_id; -}; - -static gboolean -pas_book_check_queue (PASBook *book) -{ - if (book->priv->request_queue != NULL) { - gtk_signal_emit (GTK_OBJECT (book), - pas_book_signals [REQUESTS_QUEUED]); - } - - if (book->priv->request_queue == NULL) { - book->priv->idle_id = 0; - return FALSE; - } - - return TRUE; -} - -static void -pas_book_queue_request (PASBook *book, PASRequest *req) -{ - book->priv->request_queue = - g_list_append (book->priv->request_queue, req); - - if (book->priv->idle_id == 0) { - book->priv->idle_id = g_idle_add ((GSourceFunc) pas_book_check_queue, book); - } -} - -static void -pas_book_queue_create_card (PASBook *book, const char *vcard) -{ - PASRequest *req; - - req = g_new0 (PASRequest, 1); - req->op = CreateCard; - req->vcard = g_strdup (vcard); - - pas_book_queue_request (book, req); -} - -static void -pas_book_queue_remove_card (PASBook *book, const char *id) -{ - PASRequest *req; - - req = g_new0 (PASRequest, 1); - req->op = RemoveCard; - req->id = g_strdup (id); - - pas_book_queue_request (book, req); -} - -static void -pas_book_queue_modify_card (PASBook *book, const char *vcard) -{ - PASRequest *req; - - req = g_new0 (PASRequest, 1); - req->op = ModifyCard; - req->vcard = g_strdup (vcard); - - pas_book_queue_request (book, req); -} - -static void -pas_book_queue_get_cursor (PASBook *book, const char *search) -{ - PASRequest *req; - - req = g_new0 (PASRequest, 1); - req->op = GetCursor; - req->search = g_strdup(search); - - pas_book_queue_request (book, req); -} - -static void -pas_book_queue_get_book_view (PASBook *book, const Evolution_BookViewListener listener, const char *search) -{ - PASRequest *req; - CORBA_Environment ev; - - req = g_new0 (PASRequest, 1); - req->op = GetBookView; - req->search = g_strdup(search); - - CORBA_exception_init (&ev); - - req->listener = CORBA_Object_duplicate(listener, &ev); - - if (ev._major != CORBA_NO_EXCEPTION) { - g_warning ("pas_book_queue_get_book_view: Exception " - "duplicating BookViewListener!\n"); - } - - CORBA_exception_free (&ev); - - pas_book_queue_request (book, req); -} - -static void -pas_book_queue_check_connection (PASBook *book) -{ - PASRequest *req; - - req = g_new0 (PASRequest, 1); - req->op = CheckConnection; - - pas_book_queue_request (book, req); -} - -static CORBA_char * -impl_Evolution_Book_get_vcard (PortableServer_Servant servant, - const Evolution_CardId id, - CORBA_Environment *ev) -{ - PASBook *book = PAS_BOOK (bonobo_object_from_servant (servant)); - char *vcard; - CORBA_char *retval; - - vcard = (book->priv->get_vcard) (book, (const char *) id); - retval = CORBA_string_dup (vcard); - g_free (vcard); - - return retval; -} - -static void -impl_Evolution_Book_create_card (PortableServer_Servant servant, - const Evolution_VCard vcard, - CORBA_Environment *ev) -{ - PASBook *book = PAS_BOOK (bonobo_object_from_servant (servant)); - - pas_book_queue_create_card (book, (const char *) vcard); -} - -static void -impl_Evolution_Book_remove_card (PortableServer_Servant servant, - const Evolution_CardId id, - CORBA_Environment *ev) -{ - PASBook *book = PAS_BOOK (bonobo_object_from_servant (servant)); - - pas_book_queue_remove_card (book, (const char *) id); -} - -static void -impl_Evolution_Book_modify_card (PortableServer_Servant servant, - const Evolution_VCard vcard, - CORBA_Environment *ev) -{ - PASBook *book = PAS_BOOK (bonobo_object_from_servant (servant)); - - pas_book_queue_modify_card (book, (const char *) vcard); -} - -static void -impl_Evolution_Book_get_cursor (PortableServer_Servant servant, - const CORBA_char *search, - CORBA_Environment *ev) -{ - PASBook *book = PAS_BOOK (bonobo_object_from_servant (servant)); - - pas_book_queue_get_cursor (book, search); -} - -static void -impl_Evolution_Book_get_book_view (PortableServer_Servant servant, - const Evolution_BookViewListener listener, - const CORBA_char *search, - CORBA_Environment *ev) -{ - PASBook *book = PAS_BOOK (bonobo_object_from_servant (servant)); - - pas_book_queue_get_book_view (book, listener, search); -} - -static void -impl_Evolution_Book_check_connection (PortableServer_Servant servant, - CORBA_Environment *ev) -{ - PASBook *book = PAS_BOOK (bonobo_object_from_servant (servant)); - - pas_book_queue_check_connection (book); -} - -/** - * pas_book_get_backend: - */ -PASBackend * -pas_book_get_backend (PASBook *book) -{ - g_return_val_if_fail (book != NULL, NULL); - g_return_val_if_fail (PAS_IS_BOOK (book), NULL); - - return book->priv->backend; -} - -/** - * pas_book_get_listener: - */ -Evolution_BookListener -pas_book_get_listener (PASBook *book) -{ - g_return_val_if_fail (book != NULL, CORBA_OBJECT_NIL); - g_return_val_if_fail (PAS_IS_BOOK (book), CORBA_OBJECT_NIL); - - return book->priv->listener; -} - -/** - * pas_book_check_pending - */ -gint -pas_book_check_pending (PASBook *book) -{ - g_return_val_if_fail (book != NULL, -1); - g_return_val_if_fail (PAS_IS_BOOK (book), -1); - - return g_list_length (book->priv->request_queue); -} - -/** - * pas_book_pop_request: - */ -PASRequest * -pas_book_pop_request (PASBook *book) -{ - GList *popped; - PASRequest *req; - - g_return_val_if_fail (book != NULL, NULL); - g_return_val_if_fail (PAS_IS_BOOK (book), NULL); - - if (book->priv->request_queue == NULL) - return NULL; - - req = book->priv->request_queue->data; - - popped = book->priv->request_queue; - book->priv->request_queue = - g_list_remove_link (book->priv->request_queue, popped); - - g_list_free_1 (popped); - - return req; -} - -/** - * pas_book_respond_open: - */ -void -pas_book_respond_open (PASBook *book, - Evolution_BookListener_CallStatus status) -{ - CORBA_Environment ev; - - CORBA_exception_init (&ev); - - if (status == Evolution_BookListener_Success) { - Evolution_BookListener_respond_open_book ( - book->priv->listener, status, - bonobo_object_corba_objref (BONOBO_OBJECT (book)), - &ev); - } else { - Evolution_BookListener_respond_open_book ( - book->priv->listener, status, - CORBA_OBJECT_NIL, &ev); - } - - - if (ev._major != CORBA_NO_EXCEPTION) { - g_warning ("pas_book_respond_open: Exception " - "responding to BookListener!\n"); - } - - CORBA_exception_free (&ev); -} - -/** - * pas_book_respond_create: - */ -void -pas_book_respond_create (PASBook *book, - Evolution_BookListener_CallStatus status, - const char *id) -{ - CORBA_Environment ev; - - CORBA_exception_init (&ev); - - Evolution_BookListener_respond_create_card ( - book->priv->listener, status, (char *)id, &ev); - - if (ev._major != CORBA_NO_EXCEPTION) { - g_warning ("pas_book_respond_create: Exception " - "responding to BookListener!\n"); - } - - CORBA_exception_free (&ev); -} - -/** - * pas_book_respond_remove: - */ -void -pas_book_respond_remove (PASBook *book, - Evolution_BookListener_CallStatus status) -{ - CORBA_Environment ev; - - CORBA_exception_init (&ev); - - Evolution_BookListener_respond_remove_card ( - book->priv->listener, status, &ev); - - if (ev._major != CORBA_NO_EXCEPTION) { - g_warning ("pas_book_respond_remove: Exception " - "responding to BookListener!\n"); - } - - CORBA_exception_free (&ev); -} - -/** - * pas_book_respond_modify: - */ -void -pas_book_respond_modify (PASBook *book, - Evolution_BookListener_CallStatus status) -{ - CORBA_Environment ev; - - CORBA_exception_init (&ev); - - Evolution_BookListener_respond_modify_card ( - book->priv->listener, status, &ev); - - if (ev._major != CORBA_NO_EXCEPTION) { - g_warning ("pas_book_respond_modify: Exception " - "responding to BookListener!\n"); - } - - CORBA_exception_free (&ev); -} - -/** - * pas_book_respond_get_cursor: - */ -void -pas_book_respond_get_cursor (PASBook *book, - Evolution_BookListener_CallStatus status, - PASCardCursor *cursor) -{ - CORBA_Environment ev; - CORBA_Object object; - - CORBA_exception_init (&ev); - - object = bonobo_object_corba_objref(BONOBO_OBJECT(cursor)); - - Evolution_BookListener_respond_get_cursor ( - book->priv->listener, status, object, &ev); - - if (ev._major != CORBA_NO_EXCEPTION) { - g_warning ("pas_book_respond_get_cursor: Exception " - "responding to BookListener!\n"); - } - - CORBA_exception_free (&ev); -} - -/** - * pas_book_respond_get_cursor: - */ -void -pas_book_respond_get_book_view (PASBook *book, - Evolution_BookListener_CallStatus status, - PASBookView *book_view) -{ - CORBA_Environment ev; - CORBA_Object object; - - CORBA_exception_init (&ev); - - object = bonobo_object_corba_objref(BONOBO_OBJECT(book_view)); - - Evolution_BookListener_respond_get_view ( - book->priv->listener, status, object, &ev); - - if (ev._major != CORBA_NO_EXCEPTION) { - g_warning ("pas_book_respond_get_cursor: Exception " - "responding to BookListener!\n"); - } - - CORBA_exception_free (&ev); -} - -/** - * pas_book_report_connection: - */ -void -pas_book_report_connection (PASBook *book, - gboolean connected) -{ - CORBA_Environment ev; - - CORBA_exception_init (&ev); - - Evolution_BookListener_report_connection_status ( - book->priv->listener, (CORBA_boolean) connected, &ev); - - if (ev._major != CORBA_NO_EXCEPTION) { - g_warning ("pas_book_report_connection: Exception " - "responding to BookListener!\n"); - } - - CORBA_exception_free (&ev); -} - -static gboolean -pas_book_construct (PASBook *book, - PASBackend *backend, - Evolution_BookListener listener, - PASBookGetVCardFn get_vcard) -{ - POA_Evolution_Book *servant; - CORBA_Environment ev; - CORBA_Object obj; - - g_assert (book != NULL); - g_assert (PAS_IS_BOOK (book)); - g_assert (listener != CORBA_OBJECT_NIL); - g_assert (get_vcard != NULL); - - servant = (POA_Evolution_Book *) g_new0 (BonoboObjectServant, 1); - servant->vepv = &pas_book_vepv; - - CORBA_exception_init (&ev); - - POA_Evolution_Book__init ((PortableServer_Servant) servant, &ev); - if (ev._major != CORBA_NO_EXCEPTION) { - g_free (servant); - CORBA_exception_free (&ev); - - return FALSE; - } - - CORBA_exception_free (&ev); - - obj = bonobo_object_activate_servant (BONOBO_OBJECT (book), servant); - if (obj == CORBA_OBJECT_NIL) { - g_free (servant); - - return FALSE; - } - - bonobo_object_construct (BONOBO_OBJECT (book), obj); - - book->priv->listener = listener; - book->priv->get_vcard = get_vcard; - book->priv->backend = backend; - - return TRUE; -} - -/** - * pas_book_new: - */ -PASBook * -pas_book_new (PASBackend *backend, - Evolution_BookListener listener, - PASBookGetVCardFn get_vcard) -{ - PASBook *book; - - g_return_val_if_fail (listener != CORBA_OBJECT_NIL, NULL); - g_return_val_if_fail (get_vcard != NULL, NULL); - - book = gtk_type_new (pas_book_get_type ()); - - if (! pas_book_construct (book, backend, listener, get_vcard)) { - gtk_object_unref (GTK_OBJECT (book)); - - return NULL; - } - - return book; -} - -static void -pas_book_destroy (GtkObject *object) -{ - PASBook *book = PAS_BOOK (object); - GList *l; - - for (l = book->priv->request_queue; l != NULL; l = l->next) { - PASRequest *req = l->data; - - g_free (req->id); - g_free (req->vcard); - g_free (req); - } - g_list_free (book->priv->request_queue); - - g_free (book->priv); - - GTK_OBJECT_CLASS (pas_book_parent_class)->destroy (object); -} - -static POA_Evolution_Book__epv * -pas_book_get_epv (void) -{ - POA_Evolution_Book__epv *epv; - - epv = g_new0 (POA_Evolution_Book__epv, 1); - - epv->get_vcard = impl_Evolution_Book_get_vcard; - epv->create_card = impl_Evolution_Book_create_card; - epv->remove_card = impl_Evolution_Book_remove_card; - epv->modify_card = impl_Evolution_Book_modify_card; - epv->check_connection = impl_Evolution_Book_check_connection; - epv->get_cursor = impl_Evolution_Book_get_cursor; - epv->get_book_view = impl_Evolution_Book_get_book_view; - - return epv; - -} - -static void -pas_book_corba_class_init (void) -{ - pas_book_vepv.Bonobo_Unknown_epv = bonobo_object_get_epv (); - pas_book_vepv.Evolution_Book_epv = pas_book_get_epv (); -} - -static void -pas_book_class_init (PASBookClass *klass) -{ - GtkObjectClass *object_class = (GtkObjectClass *) klass; - - pas_book_parent_class = gtk_type_class (bonobo_object_get_type ()); - - pas_book_signals [REQUESTS_QUEUED] = - gtk_signal_new ("requests_queued", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (PASBookClass, requests_queued), - gtk_marshal_NONE__NONE, - GTK_TYPE_NONE, 0); - - gtk_object_class_add_signals (object_class, pas_book_signals, LAST_SIGNAL); - - object_class->destroy = pas_book_destroy; - - pas_book_corba_class_init (); -} - -static void -pas_book_init (PASBook *book) -{ - book->priv = g_new0 (PASBookPrivate, 1); - book->priv->idle_id = 0; - book->priv->request_queue = NULL; -} - -/** - * pas_book_get_type: - */ -GtkType -pas_book_get_type (void) -{ - static GtkType type = 0; - - if (! type) { - GtkTypeInfo info = { - "PASBook", - sizeof (PASBook), - sizeof (PASBookClass), - (GtkClassInitFunc) pas_book_class_init, - (GtkObjectInitFunc) pas_book_init, - NULL, /* reserved 1 */ - NULL, /* reserved 2 */ - (GtkClassInitFunc) NULL - }; - - type = gtk_type_unique (bonobo_object_get_type (), &info); - } - - return type; -} - diff --git a/addressbook/backend/pas/pas-book.h b/addressbook/backend/pas/pas-book.h deleted file mode 100644 index 094df79857..0000000000 --- a/addressbook/backend/pas/pas-book.h +++ /dev/null @@ -1,91 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * A wrapper object which exports the Evolution_Book CORBA interface - * and which maintains a request queue. - * - * Author: - * Nat Friedman (nat@helixcode.com) - * - * Copyright 2000, Helix Code, Inc. - */ - -#ifndef __PAS_BOOK_H__ -#define __PAS_BOOK_H__ - -#include -#include -#include -#include - -typedef struct _PASBook PASBook; -typedef struct _PASBookPrivate PASBookPrivate; - -#include -#include - -typedef enum { - CreateCard, - RemoveCard, - ModifyCard, - GetCursor, - GetBookView, - CheckConnection -} PASOperation; - -typedef struct { - PASOperation op; - char *id; - char *vcard; - char *search; - Evolution_BookViewListener listener; -} PASRequest; - -struct _PASBook { - BonoboObject parent_object; - PASBookPrivate *priv; -}; - -typedef struct { - BonoboObjectClass parent_class; - - /* Signals */ - void (*requests_queued) (void); -} PASBookClass; - -typedef char * (*PASBookGetVCardFn) (PASBook *book, const char *id); - -PASBook *pas_book_new (PASBackend *backend, - Evolution_BookListener listener, - PASBookGetVCardFn get_vcard); -PASBackend *pas_book_get_backend (PASBook *book); -Evolution_BookListener pas_book_get_listener (PASBook *book); -int pas_book_check_pending (PASBook *book); -PASRequest *pas_book_pop_request (PASBook *book); - -void pas_book_respond_open (PASBook *book, - Evolution_BookListener_CallStatus status); -void pas_book_respond_create (PASBook *book, - Evolution_BookListener_CallStatus status, - const char *id); -void pas_book_respond_remove (PASBook *book, - Evolution_BookListener_CallStatus status); -void pas_book_respond_modify (PASBook *book, - Evolution_BookListener_CallStatus status); -void pas_book_respond_get_cursor (PASBook *book, - Evolution_BookListener_CallStatus status, - PASCardCursor *cursor); -void pas_book_respond_get_book_view (PASBook *book, - Evolution_BookListener_CallStatus status, - PASBookView *book_view); -void pas_book_report_connection (PASBook *book, - gboolean connected); - -GtkType pas_book_get_type (void); - -#define PAS_BOOK_TYPE (pas_book_get_type ()) -#define PAS_BOOK(o) (GTK_CHECK_CAST ((o), PAS_BOOK_TYPE, PASBook)) -#define PAS_BOOK_CLASS(k) (GTK_CHECK_CLASS_CAST((k), PAS_BOOK_FACTORY_TYPE, PASBookClass)) -#define PAS_IS_BOOK(o) (GTK_CHECK_TYPE ((o), PAS_BOOK_TYPE)) -#define PAS_IS_BOOK_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), PAS_BOOK_TYPE)) - -#endif /* ! __PAS_BOOK_H__ */ diff --git a/addressbook/backend/pas/pas-card-cursor.c b/addressbook/backend/pas/pas-card-cursor.c deleted file mode 100644 index c2bbe1c9b0..0000000000 --- a/addressbook/backend/pas/pas-card-cursor.c +++ /dev/null @@ -1,227 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * pas-card-cursor.c: Implements card cursors. - * - * Author: - * Christopher James Lahey -#include -#include "addressbook.h" -#include "pas-card-cursor.h" - -struct _PASCardCursorPrivate { - long (*get_length) (PASCardCursor *cursor, gpointer data); - char * (*get_nth) (PASCardCursor *cursor, long n, gpointer data); - gpointer data; -}; - -/* - * A pointer to our parent object class - */ -static BonoboObjectClass *parent_class; - -/* - * The VEPV for the CardCursor object - */ -static POA_Evolution_CardCursor__vepv cursor_vepv; - -/* - * Implemented GtkObject::destroy - */ -static void -pas_card_cursor_destroy (GtkObject *object) -{ - PASCardCursor *cursor = PAS_CARD_CURSOR (object); - - if ( cursor->priv ) - g_free ( cursor->priv ); - - GTK_OBJECT_CLASS (parent_class)->destroy (object); -} - -/* - * CORBA Demo::Echo::echo method implementation - */ -static CORBA_long -impl_pas_card_cursor_get_length (PortableServer_Servant servant, - CORBA_Environment *ev) -{ - PASCardCursor *cursor = PAS_CARD_CURSOR (bonobo_object_from_servant (servant)); - if ( cursor->priv->get_length ) - return cursor->priv->get_length( cursor, cursor->priv->data ); - else - return 0; -} - -/* - * CORBA Demo::Echo::echo method implementation - */ -static char * -impl_pas_card_cursor_get_nth (PortableServer_Servant servant, - const CORBA_long n, - CORBA_Environment *ev) -{ - PASCardCursor *cursor = PAS_CARD_CURSOR (bonobo_object_from_servant (servant)); - if ( cursor->priv->get_nth ) { - char *vcard = cursor->priv->get_nth( cursor, n, cursor->priv->data ); - char *retval = CORBA_string_dup (vcard); - g_free (vcard); - return retval; - } else - return CORBA_string_dup (""); -} - -/* - * If you want users to derive classes from your implementation - * you need to support this method. - */ -POA_Evolution_CardCursor__epv * -pas_card_cursor_get_epv (void) -{ - POA_Evolution_CardCursor__epv *epv; - - epv = g_new0 (POA_Evolution_CardCursor__epv, 1); - - /* - * This is the method invoked by CORBA - */ - epv->get_length = impl_pas_card_cursor_get_length; - epv->get_nth = impl_pas_card_cursor_get_nth; - - return epv; -} - -static void -init_pas_card_cursor_corba_class (void) -{ - cursor_vepv.Bonobo_Unknown_epv = bonobo_object_get_epv (); - cursor_vepv.Evolution_CardCursor_epv = pas_card_cursor_get_epv (); -} - -static void -pas_card_cursor_class_init (PASCardCursorClass *klass) -{ - GtkObjectClass *object_class = (GtkObjectClass *) klass; - - parent_class = gtk_type_class (bonobo_object_get_type ()); - - object_class->destroy = pas_card_cursor_destroy; - - init_pas_card_cursor_corba_class (); -} - -static void -pas_card_cursor_init (PASCardCursor *cursor) -{ - cursor->priv = g_new(PASCardCursorPrivate, 1); - cursor->priv->get_length = NULL; - cursor->priv->get_nth = NULL; - cursor->priv->data = NULL; -} - -GtkType -pas_card_cursor_get_type (void) -{ - static GtkType type = 0; - - if (!type){ - GtkTypeInfo info = { - "PASCardCursor", - sizeof (PASCardCursor), - sizeof (PASCardCursorClass), - (GtkClassInitFunc) pas_card_cursor_class_init, - (GtkObjectInitFunc) pas_card_cursor_init, - NULL, /* reserved 1 */ - NULL, /* reserved 2 */ - (GtkClassInitFunc) NULL - }; - - type = gtk_type_unique (bonobo_object_get_type (), &info); - } - - return type; -} - -PASCardCursor * -pas_card_cursor_construct (PASCardCursor *cursor, - Evolution_CardCursor corba_cursor, - PASCardCursorLengthFunc get_length, - PASCardCursorNthFunc get_nth, - gpointer data) -{ - g_return_val_if_fail (cursor != NULL, NULL); - g_return_val_if_fail (PAS_IS_CARD_CURSOR (cursor), NULL); - g_return_val_if_fail (corba_cursor != CORBA_OBJECT_NIL, NULL); - - /* - * Call parent constructor - */ - if (!bonobo_object_construct (BONOBO_OBJECT (cursor), (CORBA_Object) corba_cursor)) - return NULL; - - /* - * Initialize cursor - */ - cursor->priv->get_length = get_length; - cursor->priv->get_nth = get_nth; - cursor->priv->data = data; - - /* - * Success: return the GtkType we were given - */ - return cursor; -} - -/* - * This routine creates the ORBit CORBA server and initializes the - * CORBA side of things - */ -static Evolution_CardCursor -create_cursor (BonoboObject *cursor) -{ - POA_Evolution_CardCursor *servant; - CORBA_Environment ev; - - servant = (POA_Evolution_CardCursor *) g_new0 (BonoboObjectServant, 1); - servant->vepv = &cursor_vepv; - - CORBA_exception_init (&ev); - POA_Evolution_CardCursor__init ((PortableServer_Servant) servant, &ev); - if (ev._major != CORBA_NO_EXCEPTION){ - g_free (servant); - CORBA_exception_free (&ev); - return CORBA_OBJECT_NIL; - } - - CORBA_exception_free (&ev); - - /* - * Activates the CORBA object. - */ - return (Evolution_CardCursor) bonobo_object_activate_servant (cursor, servant); -} - -PASCardCursor * -pas_card_cursor_new (PASCardCursorLengthFunc get_length, - PASCardCursorNthFunc get_nth, - gpointer data) -{ - PASCardCursor *cursor; - Evolution_CardCursor corba_cursor; - - cursor = gtk_type_new (pas_card_cursor_get_type ()); - corba_cursor = create_cursor (BONOBO_OBJECT (cursor)); - - if (corba_cursor == CORBA_OBJECT_NIL){ - gtk_object_unref (GTK_OBJECT (cursor)); - return NULL; - } - - return pas_card_cursor_construct (cursor, - corba_cursor, - get_length, - get_nth, - data); -} diff --git a/addressbook/backend/pas/pas-card-cursor.h b/addressbook/backend/pas/pas-card-cursor.h deleted file mode 100644 index 300e3e3ce1..0000000000 --- a/addressbook/backend/pas/pas-card-cursor.h +++ /dev/null @@ -1,58 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * - * Author: - * Nat Friedman (nat@helixcode.com) - * - * Copyright 2000, Helix Code, Inc. - */ - -#ifndef __PAS_CARD_CURSOR_H__ -#define __PAS_CARD_CURSOR_H__ - -#include -#include -#include - -BEGIN_GNOME_DECLS - -typedef struct _PASCardCursor PASCardCursor; -typedef struct _PASCardCursorPrivate PASCardCursorPrivate; -typedef struct _PASCardCursorClass PASCardCursorClass; - -typedef long (*PASCardCursorLengthFunc) (PASCardCursor *cursor, gpointer data); -typedef char * (*PASCardCursorNthFunc) (PASCardCursor *cursor, long n, gpointer data); - -struct _PASCardCursor { - BonoboObject parent; - PASCardCursorPrivate *priv; -}; - -struct _PASCardCursorClass { - BonoboObjectClass parent; -}; - -/* Creating a new addressbook. */ -PASCardCursor *pas_card_cursor_new (PASCardCursorLengthFunc get_length, - PASCardCursorNthFunc get_nth, - gpointer data); -PASCardCursor *pas_card_cursor_construct (PASCardCursor *cursor, - Evolution_CardCursor corba_cursor, - PASCardCursorLengthFunc get_length, - PASCardCursorNthFunc get_nth, - gpointer data); - -GtkType pas_card_cursor_get_type (void); -POA_Evolution_CardCursor__epv * - pas_card_cursor_get_epv (void); - -/* Fetching cards. */ -#define PAS_CARD_CURSOR_TYPE (pas_card_cursor_get_type ()) -#define PAS_CARD_CURSOR(o) (GTK_CHECK_CAST ((o), PAS_CARD_CURSOR_TYPE, PASCardCursor)) -#define PAS_CARD_CURSOR_CLASS(k) (GTK_CHECK_CLASS_CAST((k), PAS_CARD_CURSOR_TYPE, PASCardCursorClass)) -#define PAS_IS_CARD_CURSOR(o) (GTK_CHECK_TYPE ((o), PAS_CARD_CURSOR_TYPE)) -#define PAS_IS_CARD_CURSOR_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), PAS_CARD_CURSOR_TYPE)) - -END_GNOME_DECLS - -#endif /* ! __PAS_CARD_CURSOR_H__ */ diff --git a/addressbook/contact-editor/.cvsignore b/addressbook/contact-editor/.cvsignore deleted file mode 100644 index 1771e82554..0000000000 --- a/addressbook/contact-editor/.cvsignore +++ /dev/null @@ -1,7 +0,0 @@ -.deps -.libs -Makefile -Makefile.in -*.lo -*.la -contact-editor-test \ No newline at end of file diff --git a/addressbook/contact-editor/Makefile.am b/addressbook/contact-editor/Makefile.am deleted file mode 100644 index 0a8b3a8489..0000000000 --- a/addressbook/contact-editor/Makefile.am +++ /dev/null @@ -1,44 +0,0 @@ -imagesdir = $(datadir)/images/evolution -images = email.png head.png phone.png snailmail.png web.png arrow.png briefcase.png netmeeting.png netfreebusy.png - -EXTRA_DIST = $(images) -pkgdata_DATA = $(images) - -CPPFLAGS = \ - -DEVOLUTION_GLADEDIR=\""$(gladedir)"\" \ - -DDATADIR=\""$(datadir)"\" - -INCLUDES = \ - $(GNOME_INCLUDEDIR) \ - -I$(top_srcdir) \ - -I$(top_srcdir)/addressbook/ \ - -I$(top_srcdir)/addressbook/backend \ - -DEVOLUTION_IMAGES=\""$(imagesdir)"\" \ - -DG_LOG_DOMAIN=\"contact-editor\" - -noinst_LIBRARIES = \ - libecontacteditor.a - -libecontacteditor_a_SOURCES = \ - e-contact-editor.c \ - e-contact-editor.h - -noinst_PROGRAMS = \ - contact-editor-test - -contact_editor_test_SOURCES = \ - test-editor.c - -contact_editor_test_LDADD = \ - $(top_builddir)/addressbook/backend/ebook/libebook.la \ - $(top_builddir)/libversit/libversit.la \ - $(GNOMEGNORBA_LIBS) \ - -lbonobo \ - $(top_builddir)/e-util/libeutil.la \ - libecontacteditor.a \ - $(EXTRA_GNOME_LIBS) - -gladedir = $(datadir)/evolution/glade - -glade_DATA = \ - contact-editor.glade diff --git a/addressbook/contact-editor/arrow.png b/addressbook/contact-editor/arrow.png deleted file mode 100644 index b7f782c1e5..0000000000 Binary files a/addressbook/contact-editor/arrow.png and /dev/null differ diff --git a/addressbook/contact-editor/briefcase.png b/addressbook/contact-editor/briefcase.png deleted file mode 100644 index dd59b8fd39..0000000000 Binary files a/addressbook/contact-editor/briefcase.png and /dev/null differ diff --git a/addressbook/contact-editor/contact-editor.glade b/addressbook/contact-editor/contact-editor.glade deleted file mode 100644 index e97c6999dd..0000000000 --- a/addressbook/contact-editor/contact-editor.glade +++ /dev/null @@ -1,2205 +0,0 @@ - - - - - Contact-editor - contact-editor - - src - pixmaps - C - True - True - True - False - False - False - False - True - e-contact-editor-strings.h - - - - GtkWindow - contact editor - False - Contact Editor - GTK_WINDOW_TOPLEVEL - GTK_WIN_POS_NONE - False - False - True - False - - - GtkNotebook - notebook-contact-editor - True - True - True - GTK_POS_TOP - False - 2 - 2 - False - - - GtkTable - table-contact-editor-general - 7 - 12 - 8 - False - 4 - 4 - - - GtkEntry - entry-phone1 - True - True - True - 0 - - - 7 - 8 - 0 - 1 - 0 - 0 - True - False - False - False - True - False - - - - - GtkEntry - entry-phone2 - True - True - True - 0 - - - 7 - 8 - 1 - 2 - 0 - 0 - True - False - False - False - True - False - - - - - GtkEntry - entry-phone3 - True - True - True - 0 - - - 7 - 8 - 2 - 3 - 0 - 0 - True - False - False - False - True - False - - - - - GtkEntry - entry-phone4 - True - True - True - 0 - - - 7 - 8 - 3 - 4 - 0 - 0 - True - False - False - False - True - False - - - - - GtkEntry - entry-fullname - True - True - True - 0 - - - 3 - 4 - 0 - 1 - 0 - 0 - True - False - False - False - True - False - - - - - GtkEntry - entry-web - True - True - True - 0 - - - 3 - 4 - 8 - 9 - 0 - 0 - True - False - False - False - True - False - - - - - GtkLabel - label-phone3 - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - - 5 - 6 - 2 - 3 - 0 - 0 - False - False - False - False - True - True - - - - - GtkLabel - label-phone2 - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - - 5 - 6 - 1 - 2 - 0 - 0 - False - False - False - False - True - True - - - - - GtkLabel - label-phone1 - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - - 5 - 6 - 0 - 1 - 0 - 0 - False - False - False - False - True - True - - - - - GtkLabel - label-phone4 - - GTK_JUSTIFY_LEFT - False - 0 - 0.5 - 0 - 0 - - 5 - 6 - 3 - 4 - 0 - 0 - False - False - False - False - True - True - - - - - GtkText - text-address - 1 - 1 - True - True - - - 7 - 8 - 5 - 9 - 0 - 0 - True - False - False - False - True - True - - - - - GtkLabel - label-email1 - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - - 1 - 2 - 5 - 6 - 0 - 0 - False - False - False - False - True - True - - - - - GtkButton - button-fullname - True - - - 1 - 3 - 0 - 1 - 0 - 0 - False - False - False - False - True - True - - - - - GtkAccelLabel - accellabel-jobtitle - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - - 1 - 3 - 1 - 2 - 0 - 0 - False - False - False - False - True - True - - - - - GtkAccelLabel - accellabel-company - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - - 1 - 3 - 2 - 3 - 0 - 0 - False - False - False - False - True - True - - - - - GtkAccelLabel - accellabel-fileas - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - - 1 - 3 - 3 - 4 - 0 - 0 - False - False - False - False - True - True - - - - - GtkAccelLabel - accellabel-web - - GTK_JUSTIFY_LEFT - False - 0 - 0.5 - 0 - 0 - - 1 - 3 - 8 - 9 - 0 - 0 - False - False - False - False - True - True - - - - - GtkHBox - hbox5 - False - 0 - - 0 - 8 - 10 - 11 - 0 - 0 - True - True - False - False - True - True - - - - GtkText - text-comments - True - True - - - 0 - True - True - - - - - GtkVScrollbar - vscrollbar-comments - GTK_UPDATE_CONTINUOUS - 0 - 0 - 0 - 0 - 0 - 0 - - 0 - False - False - - - - - - GtkHBox - hbox3 - False - 6 - - 0 - 8 - 11 - 12 - 0 - 0 - True - False - False - False - True - True - - - - GtkButton - button-contacts - True - - - 0 - False - False - - - - - GtkEntry - entry-contacts - True - True - True - 0 - - - 0 - True - True - - - - - GtkButton - button-categories - True - - - 0 - False - False - - - - - GtkEntry - entry-categories - True - True - True - 0 - - - 0 - False - False - - - - - - GtkAlignment - alignment2 - 0 - 0 - 0 - 0 - - 7 - 8 - 9 - 10 - 0 - 0 - True - False - False - False - True - True - - - - GtkCheckButton - checkbutton-mailingaddress - True - - False - True - - - - - GtkButton - button-address - True - - - 5 - 7 - 5 - 6 - 0 - 0 - False - False - False - False - True - True - - - - - GtkEntry - entry-jobtitle - True - True - True - 0 - - - 3 - 4 - 1 - 2 - 0 - 0 - True - False - False - False - True - False - - - - - GtkEntry - entry-company - True - True - True - 0 - - - 3 - 4 - 2 - 3 - 0 - 0 - True - False - False - False - True - False - - - - - GtkCombo - combo-fileas - True - False - True - True - True - False - - - 3 - 4 - 3 - 4 - 0 - 0 - True - False - False - False - True - False - - - - GtkEntry - GtkCombo:entry - entry-fileas - True - True - True - 0 - - - - - - GtkHBox - hbox4 - False - 4 - - 3 - 4 - 5 - 6 - 0 - 0 - True - False - False - False - True - False - - - - GtkEntry - entry-email1 - True - True - True - 0 - - - 0 - True - True - - - - - GtkButton - button23 - - 0 - False - False - - - - Placeholder - - - - - - GtkAlignment - alignment3 - 1 - 0.5 - 0 - 1 - - 2 - 3 - 5 - 6 - 0 - 0 - False - False - False - False - True - True - - - - GtkButton - button-email1 - - - Placeholder - - - - - - GtkAlignment - alignment4 - 1 - 0.5 - 0 - 1 - - 6 - 7 - 6 - 7 - 0 - 0 - False - False - False - False - True - True - - - - GtkButton - button-address1 - - - Placeholder - - - - - - GtkAlignment - alignment5 - 1 - 0.5 - 0 - 0 - - 6 - 7 - 3 - 4 - 0 - 0 - False - False - False - False - True - True - - - - GtkButton - button-phone4 - - - Placeholder - - - - - - GtkAlignment - alignment7 - 1 - 0.5 - 0 - 0 - - 6 - 7 - 1 - 2 - 0 - 0 - False - False - False - False - True - True - - - - GtkButton - button-phone2 - - - Placeholder - - - - - - GtkAlignment - alignment8 - 1 - 0.5 - 0 - 0 - - 6 - 7 - 0 - 1 - 0 - 0 - False - False - False - False - True - True - - - - GtkButton - button-phone1 - - - Placeholder - - - - - - GtkLabel - label-address1 - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - - 5 - 6 - 6 - 7 - 0 - 0 - False - False - False - False - True - True - - - - - GtkHSeparator - hseparator6 - - 0 - 4 - 7 - 8 - 0 - 2 - True - False - False - False - True - True - - - - - GtkHSeparator - hseparator4 - - 4 - 8 - 4 - 5 - 0 - 2 - True - False - False - False - True - False - - - - - GtkHSeparator - hseparator5 - - 0 - 4 - 4 - 5 - 0 - 2 - True - False - False - False - True - False - - - - - GtkAlignment - alignment6 - 1 - 0.5 - 0 - 0 - - 6 - 7 - 2 - 3 - 0 - 0 - False - False - False - False - True - True - - - - GtkButton - button-phone3 - - - Placeholder - - - - - - - GtkLabel - Notebook:tab - label15 - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 0 - 0 - - - - GtkTable - table-contact-editor-details - 7 - 12 - 6 - False - 4 - 4 - - - GtkLabel - label21 - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - - 1 - 2 - 0 - 1 - 0 - 0 - False - False - False - False - True - True - - - - - GtkLabel - label22 - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - - 1 - 2 - 1 - 2 - 0 - 0 - False - False - False - False - True - True - - - - - GtkLabel - label23 - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - - 1 - 2 - 2 - 3 - 0 - 0 - False - False - False - False - True - True - - - - - GtkLabel - label24 - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - - 1 - 2 - 4 - 5 - 0 - 0 - False - False - False - False - True - True - - - - - GtkLabel - label25 - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - - 1 - 2 - 5 - 6 - 0 - 0 - False - False - False - False - True - True - - - - - GtkLabel - label26 - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - - 1 - 2 - 7 - 8 - 0 - 0 - False - False - False - False - True - True - - - - - GtkLabel - label27 - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - - 1 - 2 - 8 - 9 - 0 - 0 - False - False - False - False - True - True - - - - - GtkLabel - label28 - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - - 1 - 2 - 10 - 11 - 0 - 0 - False - False - False - False - True - True - - - - - GtkLabel - label31 - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - - 3 - 4 - 4 - 5 - 0 - 0 - False - False - False - False - True - True - - - - - GtkLabel - label30 - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - - 3 - 4 - 1 - 2 - 0 - 0 - False - False - False - False - True - True - - - - - GtkLabel - label29 - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - - 3 - 4 - 0 - 1 - 0 - 0 - False - False - False - False - True - True - - - - - GtkLabel - label32 - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - - 3 - 4 - 5 - 6 - 0 - 0 - False - False - False - False - True - True - - - - - GtkEntry - entry4 - True - True - True - 0 - - - 2 - 3 - 5 - 6 - 0 - 0 - True - False - False - False - True - False - - - - - GtkEntry - entry-department - True - True - True - 0 - - - 2 - 3 - 0 - 1 - 0 - 0 - True - False - False - False - True - False - - - - - GtkEntry - entry-office - True - True - True - 0 - - - 2 - 3 - 1 - 2 - 0 - 0 - True - False - False - False - True - False - - - - - GtkEntry - entry-profession - True - True - True - 0 - - - 2 - 3 - 2 - 3 - 0 - 0 - True - False - False - False - True - False - - - - - GtkEntry - entry-nickname - True - True - True - 0 - - - 2 - 3 - 4 - 5 - 0 - 0 - True - False - False - False - True - False - - - - - GtkEntry - entry9 - True - True - True - 0 - - - 2 - 6 - 7 - 8 - 0 - 0 - True - False - False - False - True - False - - - - - GtkEntry - entry10 - True - True - True - 0 - - - 2 - 5 - 8 - 9 - 0 - 0 - True - False - False - False - True - False - - - - - GtkEntry - entry-fburl - True - True - True - 0 - - - 2 - 6 - 10 - 11 - 0 - 0 - True - False - False - False - True - False - - - - - GnomeDateEdit - dateedit-anniversary - False - False - False - 7 - 19 - - 4 - 6 - 5 - 6 - 0 - 0 - True - False - False - False - True - False - - - - - GnomeDateEdit - dateedit-birthday - False - False - False - 7 - 19 - - 4 - 6 - 4 - 5 - 0 - 0 - True - False - False - False - True - False - - - - - GtkEntry - entry13 - True - True - True - 0 - - - 4 - 6 - 1 - 2 - 0 - 0 - True - False - False - False - True - False - - - - - GtkEntry - entry12 - True - True - True - 0 - - - 4 - 6 - 0 - 1 - 0 - 0 - True - False - False - False - True - False - - - - - GtkButton - button-callnow - True - - - 5 - 6 - 8 - 9 - 0 - 0 - False - False - False - False - True - True - - - - - GtkHBox - hbox7 - False - 6 - - 0 - 6 - 9 - 10 - 0 - 0 - True - False - False - False - True - True - - - - GtkLabel - label33 - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 0 - 2 - - 0 - False - False - - - - - GtkHSeparator - hseparator8 - - 0 - True - True - - - - - - GtkHBox - hbox8 - False - 6 - - 0 - 6 - 6 - 7 - 0 - 0 - True - False - False - False - True - True - - - - GtkLabel - label34 - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 0 - 2 - - 0 - False - False - - - - - GtkHSeparator - hseparator9 - - 0 - True - True - - - - - - GtkHSeparator - hseparator7 - - 0 - 6 - 3 - 4 - 0 - 2 - False - False - False - False - True - True - - - - - - GtkLabel - Notebook:tab - label16 - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 0 - 0 - - - - GtkText - text3 - True - False - - - - - GtkLabel - Notebook:tab - label17 - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 0 - 0 - - - - GtkText - text2 - True - False - - - - - GtkLabel - Notebook:tab - label18 - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 0 - 0 - - - - GtkText - text4 - True - False - - - - - GtkLabel - Notebook:tab - label19 - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 0 - 0 - - - - - - GnomeDialog - dialog2 - False - GTK_WINDOW_TOPLEVEL - GTK_WIN_POS_NONE - False - False - False - False - False - False - - - GtkVBox - GnomeDialog:vbox - dialog-vbox2 - False - 8 - - 4 - True - True - - - - GtkHButtonBox - GnomeDialog:action_area - dialog-action_area2 - GTK_BUTTONBOX_END - 8 - 85 - 27 - 7 - 0 - - 0 - False - True - GTK_PACK_END - - - - GtkButton - button28 - True - True - GNOME_STOCK_BUTTON_OK - - - - GtkButton - button29 - True - True - GNOME_STOCK_BUTTON_APPLY - - - - GtkButton - button30 - True - True - GNOME_STOCK_BUTTON_CANCEL - - - - - GtkTable - table2 - 2 - 2 - False - 0 - 0 - - 0 - True - True - - - - GtkEntry - entry2 - True - True - True - 0 - - - 0 - 2 - 1 - 2 - 0 - 0 - True - False - False - False - True - False - - - - - GtkVBox - vbox1 - False - 0 - - 1 - 2 - 0 - 1 - 0 - 0 - False - True - False - False - True - True - - - - GtkButton - button31 - True - - - 0 - False - False - - - - - GtkButton - button32 - True - - - 0 - False - False - - - - - - GtkScrolledWindow - scrolledwindow1 - 200 - GTK_POLICY_ALWAYS - GTK_POLICY_ALWAYS - GTK_UPDATE_CONTINUOUS - GTK_UPDATE_CONTINUOUS - - 0 - 1 - 0 - 1 - 0 - 0 - True - True - False - False - True - True - - - - GtkCList - clist1 - True - 1 - 80 - GTK_SELECTION_SINGLE - True - GTK_SHADOW_NONE - - - GtkLabel - CList:title - label20 - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 0 - 0 - - - - - - - - - GnomeDialog - dialog-add-phone - False - New phone type - GTK_WINDOW_TOPLEVEL - GTK_WIN_POS_NONE - False - False - False - False - False - False - - - GtkVBox - GnomeDialog:vbox - vbox2 - False - 8 - - 4 - True - True - - - - GtkHButtonBox - GnomeDialog:action_area - hbuttonbox1 - GTK_BUTTONBOX_END - 8 - 85 - 27 - 7 - 0 - - 0 - False - True - GTK_PACK_END - - - - GtkButton - button43 - True - True - - GNOME_STOCK_PIXMAP_ADD - - - - GtkButton - button44 - True - True - GNOME_STOCK_BUTTON_CANCEL - - - - - GtkFrame - frame-add-phone - 4 - - 0 - GTK_SHADOW_ETCHED_IN - - 0 - True - True - - - - GtkAlignment - alignment9 - 9 - 0.5 - 0.5 - 1 - 1 - - - GtkEntry - entry-add-phone - True - True - True - 0 - - - - - - - - diff --git a/addressbook/contact-editor/e-contact-editor-strings.h b/addressbook/contact-editor/e-contact-editor-strings.h deleted file mode 100644 index b0795c166b..0000000000 --- a/addressbook/contact-editor/e-contact-editor-strings.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Translatable strings file generated by Glade. - * Add this file to your project's POTFILES.in. - * DO NOT compile it as part of your application. - */ - -gchar *s = N_("Contact Editor"); -gchar *s = N_("Business Fax"); -gchar *s = N_("Home"); -gchar *s = N_("Business"); -gchar *s = N_("Mobile"); -gchar *s = N_("Email"); -gchar *s = N_("\tFull Name..."); -gchar *s = N_("Job Title:"); -gchar *s = N_("Company:"); -gchar *s = N_("File As:"); -gchar *s = N_("Web page address:"); -gchar *s = N_("Contacts..."); -gchar *s = N_("Categories..."); -gchar *s = N_("This is the mailing address"); -gchar *s = N_("A_ddress..."); -gchar *s = N_("Business"); -gchar *s = N_("General"); -gchar *s = N_("Department:"); -gchar *s = N_("Office:"); -gchar *s = N_("Profession:"); -gchar *s = N_("Nickname:"); -gchar *s = N_("Spouse's name:"); -gchar *s = N_("Directory Server:"); -gchar *s = N_("Email alias:"); -gchar *s = N_("Address:"); -gchar *s = N_("Birthday:"); -gchar *s = N_("Assistant's name:"); -gchar *s = N_("Manager's name:"); -gchar *s = N_("Anniversary:"); -gchar *s = N_("Call Now"); -gchar *s = N_("Internet Free-Busy"); -gchar *s = N_("Online NetMeeting settings"); -gchar *s = N_("Details"); -gchar *s = N_("Activities"); -gchar *s = N_("Certificates"); -gchar *s = N_("All Fields"); -gchar *s = N_("Add"); -gchar *s = N_("Delete"); -gchar *s = N_("Phone Types"); -gchar *s = N_("New phone type"); -gchar *s = N_("Add"); -gchar *s = N_("New phone type"); diff --git a/addressbook/contact-editor/e-contact-editor.c b/addressbook/contact-editor/e-contact-editor.c deleted file mode 100644 index 5067b4ff25..0000000000 --- a/addressbook/contact-editor/e-contact-editor.c +++ /dev/null @@ -1,906 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * e-contact-editor.c - * Copyright (C) 2000 Helix Code, Inc. - * Author: Chris Lahey - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include -#include -#include "e-contact-editor.h" - -static void e_contact_editor_init (EContactEditor *card); -static void e_contact_editor_class_init (EContactEditorClass *klass); -static void e_contact_editor_set_arg (GtkObject *o, GtkArg *arg, guint arg_id); -static void e_contact_editor_get_arg (GtkObject *object, GtkArg *arg, guint arg_id); -static void e_contact_editor_destroy (GtkObject *object); - -static GtkWidget *e_contact_editor_build_dialog(EContactEditor *editor, gchar *entry_id, gchar *label_id, gchar *title, GList **list, GnomeUIInfo **info); -static void _email_arrow_pressed (GtkWidget *widget, GdkEventButton *button, EContactEditor *editor); -static void _phone_arrow_pressed (GtkWidget *widget, GdkEventButton *button, EContactEditor *editor); -static void _address_arrow_pressed (GtkWidget *widget, GdkEventButton *button, EContactEditor *editor); -static void fill_in_info(EContactEditor *editor); -static void extract_info(EContactEditor *editor); - -static GtkVBoxClass *parent_class = NULL; - -#if 0 -enum { - E_CONTACT_EDITOR_RESIZE, - E_CONTACT_EDITOR_LAST_SIGNAL -}; - -static guint e_contact_editor_signals[E_CONTACT_EDITOR_LAST_SIGNAL] = { 0 }; -#endif - -/* The arguments we take */ -enum { - ARG_0, - ARG_CARD -}; - -enum { - DYNAMIC_LIST_EMAIL, - DYNAMIC_LIST_PHONE, - DYNAMIC_LIST_ADDRESS -}; - -GtkType -e_contact_editor_get_type (void) -{ - static GtkType contact_editor_type = 0; - - if (!contact_editor_type) - { - static const GtkTypeInfo contact_editor_info = - { - "EContactEditor", - sizeof (EContactEditor), - sizeof (EContactEditorClass), - (GtkClassInitFunc) e_contact_editor_class_init, - (GtkObjectInitFunc) e_contact_editor_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - contact_editor_type = gtk_type_unique (gtk_vbox_get_type (), &contact_editor_info); - } - - return contact_editor_type; -} - -static void -e_contact_editor_class_init (EContactEditorClass *klass) -{ - GtkObjectClass *object_class; - GtkVBoxClass *vbox_class; - - object_class = (GtkObjectClass*) klass; - vbox_class = (GtkVBoxClass *) klass; - - parent_class = gtk_type_class (gtk_vbox_get_type ()); - -#if 0 - e_contact_editor_signals[E_CONTACT_EDITOR_RESIZE] = - gtk_signal_new ("resize", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (EContactEditorClass, resize), - gtk_marshal_NONE__NONE, - GTK_TYPE_NONE, 0); - - - gtk_object_class_add_signals (object_class, e_contact_editor_signals, E_CONTACT_EDITOR_LAST_SIGNAL); -#endif - - gtk_object_add_arg_type ("EContactEditor::card", GTK_TYPE_OBJECT, - GTK_ARG_READWRITE, ARG_CARD); - - object_class->set_arg = e_contact_editor_set_arg; - object_class->get_arg = e_contact_editor_get_arg; - object_class->destroy = e_contact_editor_destroy; -} - -static void -_add_image(GtkTable *table, gchar *image, int left, int right, int top, int bottom) -{ - gtk_table_attach(table, - gtk_widget_new(gtk_alignment_get_type(), - "child", gnome_pixmap_new_from_file(image), - "xalign", (double) 0, - "yalign", (double) 0, - "xscale", (double) 0, - "yscale", (double) 0, - NULL), - left, right, top, bottom, - GTK_FILL, GTK_FILL, - 0, 0); -} - -static void -_add_images(GtkTable *table) -{ - _add_image(table, EVOLUTION_IMAGES "/malehead.png", 0, 1, 0, 4); - _add_image(table, EVOLUTION_IMAGES "/cellphone.png", 4, 5, 0, 4); - _add_image(table, EVOLUTION_IMAGES "/envelope.png", 0, 1, 5, 7); - _add_image(table, EVOLUTION_IMAGES "/globe.png", - 0, 1, 8, 10); - _add_image(table, EVOLUTION_IMAGES "/house.png", 4, 5, 5, 10); -} - -static void -_add_details_images(GtkTable *table) -{ - _add_image(table, DATADIR "/evolution/briefcase.png", 0, 1, 0, 2); - _add_image(table, DATADIR "/evolution/head.png", 0, 1, 4, 6); - _add_image(table, DATADIR "/evolution/netmeeting.png", 0, 1, 7, 9); - _add_image(table, DATADIR "/evolution/netfreebusy.png", 0, 1, 10, 12); -} - -static void -_replace_button(EContactEditor *editor, gchar *button_xml, gchar *image, GtkSignalFunc func) -{ - GladeXML *gui = editor->gui; - GtkWidget *button = glade_xml_get_widget(gui, button_xml); - gchar *image_temp; - image_temp = g_strdup_printf("%s%s", DATADIR "/evolution/", image); - gtk_container_add(GTK_CONTAINER(button), - gnome_pixmap_new_from_file(image_temp)); - g_free(image_temp); - gtk_signal_connect(GTK_OBJECT(button), "button_press_event", func, editor); - -} - -static void -_replace_buttons(EContactEditor *editor) -{ - _replace_button(editor, "button-phone1", "arrow.png", _phone_arrow_pressed); - _replace_button(editor, "button-phone2", "arrow.png", _phone_arrow_pressed); - _replace_button(editor, "button-phone3", "arrow.png", _phone_arrow_pressed); - _replace_button(editor, "button-phone4", "arrow.png", _phone_arrow_pressed); - _replace_button(editor, "button-address1", "arrow.png", _address_arrow_pressed); - _replace_button(editor, "button-email1", "arrow.png", _email_arrow_pressed); -} - -static void -e_contact_editor_init (EContactEditor *e_contact_editor) -{ - GladeXML *gui; - GtkAdjustment *adjustment; - - e_contact_editor->card = NULL; - gui = glade_xml_new (EVOLUTION_GLADEDIR "/contact-editor.glade", NULL); - e_contact_editor->gui = gui; - gtk_widget_reparent(glade_xml_get_widget(gui, "notebook-contact-editor"), - GTK_WIDGET(e_contact_editor)); - - _add_images(GTK_TABLE(glade_xml_get_widget(gui, "table-contact-editor-general"))); - _add_details_images(GTK_TABLE(glade_xml_get_widget(gui, "table-contact-editor-details"))); - _replace_buttons(e_contact_editor); - - gtk_object_get(GTK_OBJECT(glade_xml_get_widget(gui, "text-comments")), - "vadjustment", &adjustment, - NULL); - gtk_range_set_adjustment(GTK_RANGE(glade_xml_get_widget(gui, "vscrollbar-comments")), - adjustment); - - e_contact_editor->email_info = NULL; - e_contact_editor->phone_info = NULL; - e_contact_editor->address_info = NULL; - e_contact_editor->email_popup = NULL; - e_contact_editor->phone_popup = NULL; - e_contact_editor->address_popup = NULL; - e_contact_editor->email_list = NULL; - e_contact_editor->phone_list = NULL; - e_contact_editor->address_list = NULL; -} - -void -e_contact_editor_destroy (GtkObject *object) { - EContactEditor *e_contact_editor = E_CONTACT_EDITOR(object); - - if (e_contact_editor->email_list) { - g_list_foreach(e_contact_editor->email_list, (GFunc) g_free, NULL); - g_list_free(e_contact_editor->email_list); - } - if (e_contact_editor->email_info) { - g_free(e_contact_editor->email_info); - } - if (e_contact_editor->email_popup) { - gtk_widget_unref(e_contact_editor->email_popup); - } - - if (e_contact_editor->phone_list) { - g_list_foreach(e_contact_editor->phone_list, (GFunc) g_free, NULL); - g_list_free(e_contact_editor->phone_list); - } - if (e_contact_editor->phone_info) { - g_free(e_contact_editor->phone_info); - } - if (e_contact_editor->phone_popup) { - gtk_widget_unref(e_contact_editor->phone_popup); - } - - if (e_contact_editor->address_list) { - g_list_foreach(e_contact_editor->address_list, (GFunc) g_free, NULL); - g_list_free(e_contact_editor->address_list); - } - if (e_contact_editor->address_info) { - g_free(e_contact_editor->address_info); - } - if (e_contact_editor->address_popup) { - gtk_widget_unref(e_contact_editor->address_popup); - } - - gtk_object_unref(GTK_OBJECT(e_contact_editor->gui)); -} - -GtkWidget* -e_contact_editor_new (ECard *card) -{ - GtkWidget *widget = GTK_WIDGET (gtk_type_new (e_contact_editor_get_type ())); - gtk_object_set (GTK_OBJECT(widget), - "card", card, - NULL); - return widget; -} - -static void -e_contact_editor_set_arg (GtkObject *o, GtkArg *arg, guint arg_id) -{ - EContactEditor *e_contact_editor; - - e_contact_editor = E_CONTACT_EDITOR (o); - - switch (arg_id){ - case ARG_CARD: - if (e_contact_editor->card) - gtk_object_unref(GTK_OBJECT(e_contact_editor->card)); - e_contact_editor->card = e_card_duplicate(E_CARD(GTK_VALUE_OBJECT (*arg))); - fill_in_info(e_contact_editor); - break; - } -} - -static void -e_contact_editor_get_arg (GtkObject *object, GtkArg *arg, guint arg_id) -{ - EContactEditor *e_contact_editor; - - e_contact_editor = E_CONTACT_EDITOR (object); - - switch (arg_id) { - case ARG_CARD: - extract_info(e_contact_editor); - GTK_VALUE_OBJECT (*arg) = GTK_OBJECT(e_contact_editor->card); - break; - default: - arg->type = GTK_TYPE_INVALID; - break; - } -} - -static void -_popup_position(GtkMenu *menu, - gint *x, - gint *y, - gpointer data) -{ - GtkWidget *button = GTK_WIDGET(data); - GtkRequisition request; - int mh, mw; - gdk_window_get_origin (button->window, x, y); - *x += button->allocation.width; - *y += button->allocation.height; - - gtk_widget_size_request(GTK_WIDGET(menu), &request); - - mh = request.height; - mw = request.width; - - *x -= mw; - if (*x < 0) - *x = 0; - - if (*y < 0) - *y = 0; - - if ((*x + mw) > gdk_screen_width ()) - *x = gdk_screen_width () - mw; - - if ((*y + mh) > gdk_screen_height ()) - *y = gdk_screen_height () - mh; -} - -static void -_arrow_pressed (GtkWidget *widget, GdkEventButton *button, EContactEditor *editor, GtkWidget *popup, GList **list, GnomeUIInfo **info, gchar *label, gchar *entry, gchar *dialog_title) -{ - gint menu_item; - gtk_signal_emit_stop_by_name(GTK_OBJECT(widget), "button_press_event"); - gtk_widget_realize(popup); - menu_item = gnome_popup_menu_do_popup_modal(popup, _popup_position, widget, button, editor); - if ( menu_item != -1 ) { - if (menu_item == g_list_length (*list)) { - e_contact_editor_build_dialog(editor, entry, label, dialog_title, list, info); - } else { - gtk_object_set(GTK_OBJECT(glade_xml_get_widget(editor->gui, label)), - "label", g_list_nth_data(*list, menu_item), - NULL); - } - } -} - -static void -e_contact_editor_build_ui_info(GList *list, GnomeUIInfo **infop) -{ - GnomeUIInfo *info; - GnomeUIInfo singleton = { GNOME_APP_UI_ITEM, NULL, NULL, NULL, NULL, NULL, GNOME_APP_PIXMAP_NONE, 0, 0, 0, NULL }; - GnomeUIInfo end = GNOMEUIINFO_END; - int length; - int i; - - info = *infop; - - if ( info ) - g_free(info); - length = g_list_length( list ); - info = g_new(GnomeUIInfo, length + 2); - for (i = 0; i < length; i++) { - info[i] = singleton; - info[i].label = _(list->data); - list = list->next; - } - info[i] = singleton; - info[i].label = N_("Other..."); - i++; - info[i] = end; - - *infop = info; -} - -static void -_dialog_clicked(GtkWidget *dialog, gint button, EContactEditor *editor) -{ - GtkWidget *label = gtk_object_get_data(GTK_OBJECT(dialog), - "e_contact_editor_label"); -#if 0 - GtkWidget *entry = gtk_object_get_data(GTK_OBJECT(dialog), - "e_contact_editor_entry"); -#endif - GtkWidget *dialog_entry = gtk_object_get_data(GTK_OBJECT(dialog), - "e_contact_editor_dialog_entry"); - GList **list = gtk_object_get_data(GTK_OBJECT(dialog), - "e_contact_editor_list"); - GList **info = gtk_object_get_data(GTK_OBJECT(dialog), - "e_contact_editor_info"); - switch (button) { - case 0: - gtk_object_set(GTK_OBJECT(label), - "label", gtk_entry_get_text(GTK_ENTRY(dialog_entry)), - NULL); - *list = g_list_append(*list, g_strdup(gtk_entry_get_text(GTK_ENTRY(dialog_entry)))); - g_free(*info); - *info = NULL; - break; - } - gnome_dialog_close(GNOME_DIALOG(dialog)); -} - -static void -_dialog_destroy(EContactEditor *editor, GtkWidget *dialog) -{ - gnome_dialog_close(GNOME_DIALOG(dialog)); -} - -static GtkWidget * -e_contact_editor_build_dialog(EContactEditor *editor, gchar *entry_id, gchar *label_id, gchar *title, GList **list, GnomeUIInfo **info) -{ - GtkWidget *dialog_entry = gtk_entry_new(); - GtkWidget *entry = glade_xml_get_widget(editor->gui, entry_id); - GtkWidget *label = glade_xml_get_widget(editor->gui, label_id); - - GtkWidget *dialog = gnome_dialog_new(title, - NULL); - - gtk_container_add(GTK_CONTAINER(GNOME_DIALOG(dialog)->vbox), - gtk_widget_new (gtk_frame_get_type(), - "border_width", 4, - "label", title, - "child", gtk_widget_new(gtk_alignment_get_type(), - "child", dialog_entry, - "xalign", .5, - "yalign", .5, - "xscale", 1.0, - "yscale", 1.0, - "border_width", 9, - NULL), - NULL)); - - gnome_dialog_append_button_with_pixmap(GNOME_DIALOG(dialog), - "Add", - GNOME_STOCK_PIXMAP_ADD); - gnome_dialog_append_button(GNOME_DIALOG(dialog), GNOME_STOCK_BUTTON_CANCEL); - gnome_dialog_set_default(GNOME_DIALOG(dialog), 0); - - gtk_signal_connect(GTK_OBJECT(dialog), "clicked", - _dialog_clicked, editor); - gtk_signal_connect_while_alive(GTK_OBJECT(editor), "destroy", - _dialog_destroy, GTK_OBJECT(dialog), GTK_OBJECT(dialog)); - - gtk_object_set_data(GTK_OBJECT(dialog), - "e_contact_editor_entry", entry); - gtk_object_set_data(GTK_OBJECT(dialog), - "e_contact_editor_label", label); - gtk_object_set_data(GTK_OBJECT(dialog), - "e_contact_editor_dialog_entry", dialog_entry); - gtk_object_set_data(GTK_OBJECT(dialog), - "e_contact_editor_list", list); - gtk_object_set_data(GTK_OBJECT(dialog), - "e_contact_editor_info", info); - - gtk_widget_show_all(dialog); - return dialog; -} - -static void -_phone_arrow_pressed (GtkWidget *widget, GdkEventButton *button, EContactEditor *editor) -{ - int which; - int i; - gchar *label; - gchar *entry; - if ( widget == glade_xml_get_widget(editor->gui, "button-phone1") ) { - which = 1; - } else if ( widget == glade_xml_get_widget(editor->gui, "button-phone2") ) { - which = 2; - } else if ( widget == glade_xml_get_widget(editor->gui, "button-phone3") ) { - which = 3; - } else if ( widget == glade_xml_get_widget(editor->gui, "button-phone4") ) { - which = 4; - } else - return; - - label = g_strdup_printf("label-phone%d", which); - entry = g_strdup_printf("entry-phone%d", which); - - if (editor->phone_list == NULL) { - static char *info[] = { - N_("Assistant"), - N_("Business"), - N_("Business 2"), - N_("Business Fax"), - N_("Callback"), - N_("Car"), - N_("Company"), - N_("Home"), - N_("Home 2"), - N_("Home Fax"), - N_("ISDN"), - N_("Mobile"), - N_("Other"), - N_("Other Fax"), - N_("Pager"), - N_("Primary"), - N_("Radio"), - N_("Telex"), - N_("TTY/TDD") - }; - - for (i = 0; i < sizeof(info) / sizeof(info[0]); i++) { - editor->phone_list = g_list_append(editor->phone_list, g_strdup(info[i])); - } - } - if (editor->phone_info == NULL) { - e_contact_editor_build_ui_info(editor->phone_list, &editor->phone_info); - - if ( editor->phone_popup ) - gtk_widget_unref(editor->phone_popup); - - editor->phone_popup = gnome_popup_menu_new(editor->phone_info); - } - - _arrow_pressed (widget, button, editor, editor->phone_popup, &editor->phone_list, &editor->phone_info, label, entry, "Add new phone number type"); - - g_free(label); - g_free(entry); -} - -static void -_email_arrow_pressed (GtkWidget *widget, GdkEventButton *button, EContactEditor *editor) -{ - int i; - if (editor->email_list == NULL) { - static char *info[] = { - N_("Email"), - N_("Email 2"), - N_("Email 3") - }; - - for (i = 0; i < sizeof(info) / sizeof(info[0]); i++) { - editor->email_list = g_list_append(editor->email_list, g_strdup(info[i])); - } - } - if (editor->email_info == NULL) { - e_contact_editor_build_ui_info(editor->email_list, &editor->email_info); - - if ( editor->email_popup ) - gtk_widget_unref(editor->email_popup); - - editor->email_popup = gnome_popup_menu_new(editor->email_info); - } - - _arrow_pressed (widget, button, editor, editor->email_popup, &editor->email_list, &editor->email_info, "label-email1", "entry-email1", "Add new Email type"); -} - -static void -_address_arrow_pressed (GtkWidget *widget, GdkEventButton *button, EContactEditor *editor) -{ - int i; - if (editor->address_list == NULL) { - static char *info[] = { - N_("Business"), - N_("Home"), - N_("Other") - }; - - for (i = 0; i < sizeof(info) / sizeof(info[0]); i++) { - editor->address_list = g_list_append(editor->address_list, g_strdup(info[i])); - } - } - if (editor->address_info == NULL) { - e_contact_editor_build_ui_info(editor->address_list, &editor->address_info); - - if ( editor->address_popup ) - gtk_widget_unref(editor->address_popup); - - editor->address_popup = gnome_popup_menu_new(editor->address_info); - } - - _arrow_pressed (widget, button, editor, editor->address_popup, &editor->address_list, &editor->address_info, "label-address1", "entry-address1", "Add new Address type"); -} - -static void -fill_in_info(EContactEditor *editor) -{ - ECard *card = editor->card; - if (card) { - char *fname; - ECardList *address_list; - ECardList *phone_list; - ECardList *email_list; - char *title; - char *org; - char *org_unit; - char *url; - char *role; - char *nickname; - char *fburl; - char *note; - const ECardDeliveryAddress *address; - const ECardPhone *phone; - const ECardDate *bday; - GtkEditable *editable; - int position = 0; - const char *email; - - ECardIterator *iterator; - - gtk_object_get(GTK_OBJECT(card), - "full_name", &fname, - "address", &address_list, - "phone", &phone_list, - "email", &email_list, - "url", &url, - "org", &org, - "org_unit", &org_unit, - "title", &title, - "role", &role, - "nickname", &nickname, - "fburl", &fburl, - "note", ¬e, - "birth_date", &bday, - NULL); - - position = 0; - editable = GTK_EDITABLE(glade_xml_get_widget(editor->gui, "entry-fullname")); - gtk_editable_delete_text(editable, 0, -1); - if (fname) - gtk_editable_insert_text(editable, fname, strlen(fname), &position); - - position = 0; - iterator = e_card_list_get_iterator(address_list); - address = e_card_iterator_get(iterator); - editable = GTK_EDITABLE(glade_xml_get_widget(editor->gui, "text-address")); - gtk_editable_delete_text(editable, 0, -1); - if (address) - gtk_editable_insert_text(editable, address->city, strlen(address->city), &position); - gtk_object_unref(GTK_OBJECT(iterator)); - - position = 0; - iterator = e_card_list_get_iterator(phone_list); - phone = e_card_iterator_get(iterator); - editable = GTK_EDITABLE(glade_xml_get_widget(editor->gui, "entry-phone1")); - gtk_editable_delete_text(editable, 0, -1); - if (phone) - gtk_editable_insert_text(editable, phone->number, strlen(phone->number), &position); - gtk_object_unref(GTK_OBJECT(iterator)); - - position = 0; - iterator = e_card_list_get_iterator(email_list); - email = e_card_iterator_get(iterator); - editable = GTK_EDITABLE(glade_xml_get_widget(editor->gui, "entry-email1")); - gtk_editable_delete_text(editable, 0, -1); - if (email) - gtk_editable_insert_text(editable, email, strlen(email), &position); - gtk_object_unref(GTK_OBJECT(iterator)); - - position = 0; - editable = GTK_EDITABLE(glade_xml_get_widget(editor->gui, "entry-web")); - gtk_editable_delete_text(editable, 0, -1); - if (url) - gtk_editable_insert_text(editable, url, strlen(url), &position); - - position = 0; - editable = GTK_EDITABLE(glade_xml_get_widget(editor->gui, "entry-company")); - gtk_editable_delete_text(editable, 0, -1); - if (org) - gtk_editable_insert_text(editable, org, strlen(org), &position); - - position = 0; - editable = GTK_EDITABLE(glade_xml_get_widget(editor->gui, "entry-department")); - gtk_editable_delete_text(editable, 0, -1); - if (org_unit) - gtk_editable_insert_text(editable, org_unit, strlen(org_unit), &position); - - position = 0; - editable = GTK_EDITABLE(glade_xml_get_widget(editor->gui, "entry-jobtitle")); - gtk_editable_delete_text(editable, 0, -1); - if (title) - gtk_editable_insert_text(editable, title, strlen(title), &position); - - position = 0; - editable = GTK_EDITABLE(glade_xml_get_widget(editor->gui, "entry-nickname")); - gtk_editable_delete_text(editable, 0, -1); - if (nickname) - gtk_editable_insert_text(editable, nickname, strlen(nickname), &position); - - position = 0; - editable = GTK_EDITABLE(glade_xml_get_widget(editor->gui, "entry-fburl")); - gtk_editable_delete_text(editable, 0, -1); - if (fburl) - gtk_editable_insert_text(editable, fburl, strlen(fburl), &position); - - position = 0; - editable = GTK_EDITABLE(glade_xml_get_widget(editor->gui, "entry-profession")); - gtk_editable_delete_text(editable, 0, -1); - if (role) - gtk_editable_insert_text(editable, role, strlen(role), &position); - - position = 0; - editable = GTK_EDITABLE(glade_xml_get_widget(editor->gui, "text-comments")); - gtk_editable_delete_text(editable, 0, -1); - if (note) - gtk_editable_insert_text(editable, note, strlen(note), &position); - - if (bday) { - struct tm time_struct = {0,0,0,0,0,0,0,0,0}; - time_t time_val; - GnomeDateEdit *dateedit; - time_struct.tm_mday = bday->day; - time_struct.tm_mon = bday->month; - time_struct.tm_year = bday->year; - time_val = mktime(&time_struct); - dateedit = GNOME_DATE_EDIT(glade_xml_get_widget(editor->gui, "dateedit-birthday")); - gnome_date_edit_set_time(dateedit, time_val); - } - } -} - -static void -extract_info(EContactEditor *editor) -{ - ECard *card = editor->card; - if (card) { - char *fname; - char *string; - ECardList *address_list; - ECardList *phone_list; - ECardList *email_list; - char *url; - char *org; - char *org_unit; - char *title; - char *role; - char *nickname; - char *fburl; - char *note; - const ECardDeliveryAddress *address; - const ECardPhone *phone; - ECardDeliveryAddress *address_copy; - ECardPhone *phone_copy; - char *email; - ECardDate *bday; - GtkEditable *editable; - GnomeDateEdit *dateedit; - int position = 0; - struct tm time_struct; - time_t time_val; - - ECardIterator *iterator; - - gtk_object_get(GTK_OBJECT(card), - "address", &address_list, - "phone", &phone_list, - "email", &email_list, - NULL); - - position = 0; - editable = GTK_EDITABLE(glade_xml_get_widget(editor->gui, "entry-fullname")); - fname = gtk_editable_get_chars(editable, 0, -1); - if (fname && *fname) - gtk_object_set(GTK_OBJECT(card), - "full_name", fname, - NULL); - g_free(fname); - - iterator = e_card_list_get_iterator(address_list); - address = e_card_iterator_get(iterator); - editable = GTK_EDITABLE(glade_xml_get_widget(editor->gui, "text-address")); - string = gtk_editable_get_chars(editable, 0, -1); - if (string && *string) { - if (address) { - address_copy = e_card_delivery_address_copy(address); - if (address_copy->city) - g_free(address_copy->city); - address_copy->city = string; - e_card_iterator_set(iterator, address_copy); - e_card_delivery_address_free(address_copy); - } else { - address_copy = g_new0(ECardDeliveryAddress, 1); - address_copy->city = string; - e_card_list_append(address_list, address_copy); - e_card_delivery_address_free(address_copy); - } - } else - g_free(string); - gtk_object_unref(GTK_OBJECT(iterator)); - - position = 0; - iterator = e_card_list_get_iterator(phone_list); - phone = e_card_iterator_get(iterator); - editable = GTK_EDITABLE(glade_xml_get_widget(editor->gui, "entry-phone1")); - string = gtk_editable_get_chars(editable, 0, -1); - if (string && *string) { - if (phone) { - phone_copy = e_card_phone_copy(phone); - if (phone_copy->number) - g_free(phone_copy->number); - phone_copy->number = string; - e_card_iterator_set(iterator, phone_copy); - e_card_phone_free(phone_copy); - } else { - phone_copy = g_new0(ECardPhone, 1); - phone_copy->number = string; - e_card_list_append(phone_list, phone_copy); - e_card_phone_free(phone_copy); - } - } else - g_free(string); - gtk_object_unref(GTK_OBJECT(iterator)); - - position = 0; - iterator = e_card_list_get_iterator(email_list); - editable = GTK_EDITABLE(glade_xml_get_widget(editor->gui, "entry-email1")); - email = gtk_editable_get_chars(editable, 0, -1); - if (email && *email) { - if (e_card_iterator_is_valid(iterator)) - e_card_iterator_set(iterator, email); - else - e_card_list_append(email_list, email); - } - g_free(email); - gtk_object_unref(GTK_OBJECT(iterator)); - - position = 0; - editable = GTK_EDITABLE(glade_xml_get_widget(editor->gui, "entry-web")); - url = gtk_editable_get_chars(editable, 0, -1); - if (url && *url) - gtk_object_set(GTK_OBJECT(card), - "url", url, - NULL); - g_free(url); - - editable = GTK_EDITABLE(glade_xml_get_widget(editor->gui, "entry-company")); - org = gtk_editable_get_chars(editable, 0, -1); - if (org && *org) - gtk_object_set(GTK_OBJECT(card), - "org", org, - NULL); - g_free(org); - - editable = GTK_EDITABLE(glade_xml_get_widget(editor->gui, "entry-department")); - org_unit = gtk_editable_get_chars(editable, 0, -1); - if (org_unit && *org_unit) - gtk_object_set(GTK_OBJECT(card), - "org_unit", org_unit, - NULL); - g_free(org_unit); - - editable = GTK_EDITABLE(glade_xml_get_widget(editor->gui, "entry-jobtitle")); - title = gtk_editable_get_chars(editable, 0, -1); - if (title && *title) - gtk_object_set(GTK_OBJECT(card), - "title", title, - NULL); - g_free(title); - - editable = GTK_EDITABLE(glade_xml_get_widget(editor->gui, "entry-profession")); - role = gtk_editable_get_chars(editable, 0, -1); - if (role && *role) - gtk_object_set(GTK_OBJECT(card), - "role", role, - NULL); - g_free(role); - - editable = GTK_EDITABLE(glade_xml_get_widget(editor->gui, "entry-nickname")); - nickname = gtk_editable_get_chars(editable, 0, -1); - if (nickname && *nickname) - gtk_object_set(GTK_OBJECT(card), - "nickname", nickname, - NULL); - g_free(nickname); - - editable = GTK_EDITABLE(glade_xml_get_widget(editor->gui, "entry-fburl")); - fburl = gtk_editable_get_chars(editable, 0, -1); - if (fburl && *fburl) - gtk_object_set(GTK_OBJECT(card), - "fburl", fburl, - NULL); - g_free(fburl); - - editable = GTK_EDITABLE(glade_xml_get_widget(editor->gui, "text-comments")); - note = gtk_editable_get_chars(editable, 0, -1); - if (note && *note) - gtk_object_set(GTK_OBJECT(card), - "note", note, - NULL); - g_free(note); - - dateedit = GNOME_DATE_EDIT(glade_xml_get_widget(editor->gui, "dateedit-birthday")); - time_val = gnome_date_edit_get_date(dateedit); - gmtime_r(&time_val, - &time_struct); - bday = g_new(ECardDate, 1); - bday->day = time_struct.tm_mday; - bday->month = time_struct.tm_mon; - bday->year = time_struct.tm_year; - gtk_object_set(GTK_OBJECT(card), - "birth_date", bday, - NULL); - } -} - - - - - - - - - diff --git a/addressbook/contact-editor/e-contact-editor.h b/addressbook/contact-editor/e-contact-editor.h deleted file mode 100644 index 82f4a22623..0000000000 --- a/addressbook/contact-editor/e-contact-editor.h +++ /dev/null @@ -1,85 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* e-contact-editor.h - * Copyright (C) 2000 Helix Code, Inc. - * Author: Chris Lahey - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ -#ifndef __E_CONTACT_EDITOR_H__ -#define __E_CONTACT_EDITOR_H__ - -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - -/* EContactEditor - A dialog displaying information about a contact. - * - * The following arguments are available: - * - * name type read/write description - * -------------------------------------------------------------------------------- - * card ECard * R The card currently being edited - */ - -#define E_CONTACT_EDITOR_TYPE (e_contact_editor_get_type ()) -#define E_CONTACT_EDITOR(obj) (GTK_CHECK_CAST ((obj), E_CONTACT_EDITOR_TYPE, EContactEditor)) -#define E_CONTACT_EDITOR_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_CONTACT_EDITOR_TYPE, EContactEditorClass)) -#define E_IS_CONTACT_EDITOR(obj) (GTK_CHECK_TYPE ((obj), E_CONTACT_EDITOR_TYPE)) -#define E_IS_CONTACT_EDITOR_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), E_CONTACT_EDITOR_TYPE)) - - -typedef struct _EContactEditor EContactEditor; -typedef struct _EContactEditorClass EContactEditorClass; - -struct _EContactEditor -{ - GtkVBox parent; - - /* item specific fields */ - ECard *card; - - GladeXML *gui; - GnomeUIInfo *email_info; - GnomeUIInfo *phone_info; - GnomeUIInfo *address_info; - GtkWidget *email_popup; - GtkWidget *phone_popup; - GtkWidget *address_popup; - GList *email_list; - GList *phone_list; - GList *address_list; -}; - -struct _EContactEditorClass -{ - GtkVBoxClass parent_class; -}; - - -GtkWidget *e_contact_editor_new(ECard *card); -GtkType e_contact_editor_get_type (void); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - - -#endif /* __E_CONTACT_EDITOR_H__ */ diff --git a/addressbook/contact-editor/email.png b/addressbook/contact-editor/email.png deleted file mode 100644 index f3ff02e343..0000000000 Binary files a/addressbook/contact-editor/email.png and /dev/null differ diff --git a/addressbook/contact-editor/head.png b/addressbook/contact-editor/head.png deleted file mode 100644 index ca00b75f92..0000000000 Binary files a/addressbook/contact-editor/head.png and /dev/null differ diff --git a/addressbook/contact-editor/netfreebusy.png b/addressbook/contact-editor/netfreebusy.png deleted file mode 100644 index 09ec8a2a5c..0000000000 Binary files a/addressbook/contact-editor/netfreebusy.png and /dev/null differ diff --git a/addressbook/contact-editor/netmeeting.png b/addressbook/contact-editor/netmeeting.png deleted file mode 100644 index 4cb90c121e..0000000000 Binary files a/addressbook/contact-editor/netmeeting.png and /dev/null differ diff --git a/addressbook/contact-editor/phone.png b/addressbook/contact-editor/phone.png deleted file mode 100644 index ebec84ba0b..0000000000 Binary files a/addressbook/contact-editor/phone.png and /dev/null differ diff --git a/addressbook/contact-editor/snailmail.png b/addressbook/contact-editor/snailmail.png deleted file mode 100644 index 647ae8f68c..0000000000 Binary files a/addressbook/contact-editor/snailmail.png and /dev/null differ diff --git a/addressbook/contact-editor/test-editor.c b/addressbook/contact-editor/test-editor.c deleted file mode 100644 index 5b48c1a92f..0000000000 --- a/addressbook/contact-editor/test-editor.c +++ /dev/null @@ -1,158 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * test-editor.c - * Copyright (C) 2000 Helix Code, Inc. - * Author: Chris Lahey - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include "config.h" - -#include -#include -#include "e-contact-editor.h" - -#define TEST_VCARD \ -"BEGIN:VCARD -" \ -"FN:Nat -" \ -"N:Friedman;Nat;D;Mr. -" \ -"BDAY:1977-08-06 -" \ -"TEL;WORK:617 679 1984 -" \ -"TEL;CELL:123 456 7890 -" \ -"EMAIL;INTERNET:nat@nat.org -" \ -"EMAIL;INTERNET:nat@helixcode.com -" \ -"ADR;WORK;POSTAL:P.O. Box 101;;;Any Town;CA;91921-1234; -" \ -"ADR;HOME;POSTAL;INTL:P.O. Box 202;;;Any Town 2;MI;12344-4321;USA -" \ -"END:VCARD -" \ -" -" - -static char * -read_file (char *name) -{ - int len; - char buff[65536]; - char line[1024]; - FILE *f; - - f = fopen (name, "r"); - if (f == NULL) - g_error ("Unable to open %s!\n", name); - - len = 0; - while (fgets (line, sizeof (line), f) != NULL) { - strcpy (buff + len, line); - len += strlen (line); - } - - fclose (f); - - return g_strdup (buff); -} - -/* This is a horrible thing to do, but it is just a test. */ -GtkWidget *editor; - -static void destroy_callback(GtkWidget *app, gpointer data) -{ - static int count = 2; - count --; - if ( count <= 0 ) - exit(0); -} - -#if 0 -static void about_callback( GtkWidget *widget, gpointer data ) -{ - - const gchar *authors[] = - { - "Christopher James Lahey ", - NULL - }; - - GtkWidget *about = - gnome_about_new ( _( "Contact Editor Test" ), VERSION, - _( "Copyright (C) 2000, Helix Code, Inc." ), - authors, - _( "This should test the contact editor canvas item" ), - NULL); - gtk_widget_show (about); -} -#endif - -int main( int argc, char *argv[] ) -{ - char *cardstr; - GtkWidget *app; - - /* bindtextdomain (PACKAGE, GNOMELOCALEDIR); - textdomain (PACKAGE);*/ - - gnome_init( "Contact Editor Test", VERSION, argc, argv); - - glade_gnome_init (); - - app = gnome_app_new("Contact Editor Test", NULL); - - cardstr = NULL; - if (argc == 2) - cardstr = read_file (argv [1]); - - if (cardstr == NULL) - cardstr = TEST_VCARD; - - editor = e_contact_editor_new(e_card_new(cardstr)); - - gnome_app_set_contents( GNOME_APP( app ), editor ); - - /* Connect the signals */ - gtk_signal_connect( GTK_OBJECT( app ), "destroy", - GTK_SIGNAL_FUNC( destroy_callback ), - ( gpointer ) app ); - - gtk_widget_show_all( app ); - - app = gnome_app_new("Contact Editor Test", NULL); - - editor = e_contact_editor_new(e_card_new(cardstr)); - - gnome_app_set_contents( GNOME_APP( app ), editor ); - - /* Connect the signals */ - gtk_signal_connect( GTK_OBJECT( app ), "destroy", - GTK_SIGNAL_FUNC( destroy_callback ), - ( gpointer ) app ); - - gtk_widget_show_all( app ); - - gtk_main(); - - /* Not reached. */ - return 0; -} diff --git a/addressbook/contact-editor/web.png b/addressbook/contact-editor/web.png deleted file mode 100644 index 3211a11b19..0000000000 Binary files a/addressbook/contact-editor/web.png and /dev/null differ diff --git a/addressbook/demo/.cvsignore b/addressbook/demo/.cvsignore deleted file mode 100644 index a0427f184f..0000000000 --- a/addressbook/demo/.cvsignore +++ /dev/null @@ -1,8 +0,0 @@ -.deps -.libs -Makefile -Makefile.in -*.lo -*.la -evolution-addressbook -test-addressbook \ No newline at end of file diff --git a/addressbook/demo/Makefile.am b/addressbook/demo/Makefile.am deleted file mode 100644 index 84869488cc..0000000000 --- a/addressbook/demo/Makefile.am +++ /dev/null @@ -1,62 +0,0 @@ -INCLUDES = \ - $(EXTRA_GNOME_CFLAGS) \ - $(GNOME_INCLUDEDIR) \ - -I$(top_srcdir)/widgets/e-text \ - -I$(top_srcdir)/e-util \ - -I$(top_srcdir)/widgets/e-table \ - -I$(top_srcdir) \ - -I$(top_srcdir)/widgets/e-minicard \ - -I$(top_srcdir)/addressbook/backend/ebook \ - $(BONOBO_HTML_GNOME_CFLAGS) \ - -DEVOLUTION_VERSION=\""$(VERSION)"\" \ - -DEVOLUTION_GLADEDIR=\""$(gladedir)"\" \ - -DEVOLUTION_ICONSDIR=\""$(iconsdir)"\" \ - -DEVOLUTION_LOCALEDIR=\""$(datadir)/locale"\" \ - -DCAMEL_PROVIDERDIR=\""$(providerdir)"\" - -noinst_PROGRAMS = \ - test-addressbook - -test_addressbook_SOURCES = \ - demo.c \ - e-test-model.c \ - e-test-model.h - -test_addressbook_LDADD = \ - $(EXTRA_GNOME_LIBS) \ - $(BONOBO_HTML_GNOME_LIBS) \ - $(top_builddir)/widgets/e-minicard/libeminicard.a \ - $(top_builddir)/widgets/e-table/libetable.a \ - $(top_builddir)/widgets/e-text/libetext.a \ - $(top_builddir)/e-util/libeutil.la \ - $(top_builddir)/addressbook/backend/ebook/libebook.la \ - $(top_builddir)/libversit/libversit.la - -test_addressbook_LDFLAGS = `gnome-config --libs gdk_pixbuf` - -bin_PROGRAMS = \ - evolution-addressbook - -evolution_addressbook_SOURCES = \ - addressbook-factory.c \ - addressbook-widget.c \ - addressbook-widget.h \ - addressbook.c \ - addressbook.h \ - e-test-model.c \ - e-test-model.h - -evolution_addressbook_LDADD = \ - $(EXTRA_GNOME_LIBS) \ - $(BONOBO_HTML_GNOME_LIBS) \ - $(top_builddir)/widgets/e-minicard/libeminicard.a \ - $(top_builddir)/widgets/e-table/libetable.a \ - $(top_builddir)/widgets/e-text/libetext.a \ - $(top_builddir)/e-util/libeutil.la \ - $(top_builddir)/addressbook/backend/ebook/libebook.la \ - $(top_builddir)/libversit/libversit.la - -evolution_addressbook_LDFLAGS = `gnome-config --libs gdk_pixbuf` - -gnorbadir = $(sysconfdir)/CORBA/servers -gnorba_DATA = addressbook.gnorba diff --git a/addressbook/demo/addressbook-factory.c b/addressbook/demo/addressbook-factory.c deleted file mode 100644 index cf59177f84..0000000000 --- a/addressbook/demo/addressbook-factory.c +++ /dev/null @@ -1,47 +0,0 @@ -/** - * sample-control-factory.c - * - * Copyright 1999, Helix Code, Inc. - * - * Author: - * Nat Friedman (nat@nat.org) - * - */ - -#include -#include -#include -#include - -#include "addressbook.h" - -CORBA_Environment ev; -CORBA_ORB orb; - -static void -init_bonobo (int argc, char **argv) -{ - - gnome_CORBA_init_with_popt_table ( - "evolution-addressbook", "0.0", - &argc, argv, NULL, 0, NULL, GNORBA_INIT_SERVER_FUNC, &ev); - - orb = gnome_CORBA_ORB (); - - if (bonobo_init (orb, NULL, NULL) == FALSE) - g_error (_("Could not initialize Bonobo")); -} - -int -main (int argc, char **argv) -{ - CORBA_exception_init (&ev); - - init_bonobo (argc, argv); - - addressbook_factory_init (); - - bonobo_main (); - - return 0; -} diff --git a/addressbook/demo/addressbook-widget.c b/addressbook/demo/addressbook-widget.c deleted file mode 100644 index dfe531c787..0000000000 --- a/addressbook/demo/addressbook-widget.c +++ /dev/null @@ -1,537 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * demo.c - * Copyright (C) 2000 Helix Code, Inc. - * Author: Chris Lahey - * - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#include -#include -#include -#include -#include -#include -#include "e-util/e-cursors.h" -#include "e-canvas.h" -#include "e-table-simple.h" -#include "e-table-header.h" -#include "e-table-header-item.h" -#include "e-table-item.h" -#include "e-cell-text.h" -#include "e-cell-checkbox.h" -#include "e-table.h" -#include "e-reflow.h" -#include "e-minicard.h" -#include - -#include "e-test-model.h" - -#include "addressbook-widget.h" - -#define COLS 4 - -/* Here we define the initial layout of the table. This is an xml - format that allows you to change the initial ordering of the - columns or to do sorting or grouping initially. This specification - shows all 5 columns, but moves the importance column nearer to the - front. It also sorts by the "Full Name" column (ascending.) - Sorting and grouping take the model column as their arguments - (sorting is specified by the "column" argument to the leaf elemnt. */ -#define INITIAL_SPEC " \ - \ - 0 \ - 1 \ - 2 \ - 3 \ - \ - \ -" - -char *headers[COLS] = { - "Email", - "Full Name", - "Address", - "Phone" -}; - -static int window_count = 0; -static GHashTable *models = NULL; - -static void -remove_model(ETableModel *model, gchar *filename) -{ - g_hash_table_remove(models, filename); - g_free(filename); -} - -static ETestModel * -get_model(char *filename) -{ - ETestModel *model; - gboolean free_filename = FALSE; - - if ( filename == NULL ) { - filename = gnome_util_prepend_user_home("addressbook.xml"); - free_filename = TRUE; - } - - if ( models == NULL ) { - models = g_hash_table_new(g_str_hash, g_str_equal); - } - - model = g_hash_table_lookup(models, filename); - if ( model ) { - if (free_filename) - g_free(filename); - return model; - } - - if ( !free_filename ) - filename = g_strdup(filename); - - model = E_TEST_MODEL(e_test_model_new(filename)); - g_hash_table_insert(models, - filename, model); - gtk_signal_connect(GTK_OBJECT(model), "destroy", - GTK_SIGNAL_FUNC(remove_model), filename); - - return model; -} - -static void -add_address_cb(GtkWidget *button, gpointer data) -{ - View *view = (View *) data; - Address *newadd = g_new(Address, 1); - newadd->email = g_strdup(""); - newadd->phone = g_strdup(""); - newadd->full_name = g_strdup(""); - newadd->street = g_strdup(""); - e_test_model_add_column (view->model, newadd); -} - -static void -rebuild_reflow(ETableModel *model, gpointer data) -{ - int i; - View *view = (View *) data; - Reflow *reflow = view->reflow; - if (!reflow) - return; - gtk_object_destroy(GTK_OBJECT(reflow->reflow)); - reflow->reflow = gnome_canvas_item_new( gnome_canvas_root( GNOME_CANVAS( reflow->canvas ) ), - e_reflow_get_type(), - "x", (double) 0, - "y", (double) 0, - "height", (double) reflow->last_alloc.height, - "minimum_width", (double) reflow->last_alloc.width, - NULL ); - - for ( i = 0; i < view->model->data_count; i++ ) - { - GnomeCanvasItem *item; - item = gnome_canvas_item_new( GNOME_CANVAS_GROUP(reflow->reflow), - e_minicard_get_type(), - "model", view->model, - "row", i, - NULL); - e_reflow_add_item(E_REFLOW(reflow->reflow), item); - } - e_canvas_item_request_reflow(reflow->reflow); -} - -static void -destroy_reflow(View *view) -{ - Reflow *reflow = view->reflow; - if ( !reflow ) - return; - - gtk_signal_disconnect(GTK_OBJECT(view->model), - reflow->model_changed_id); - g_free(reflow); - gtk_object_unref(GTK_OBJECT(view->model)); - view->reflow = NULL; -} - -static void -destroy_callback(GtkWidget *app, gpointer data) -{ - View *view = (View *)data; - if ( view->reflow ) { - destroy_reflow(view); - } - gtk_object_unref(GTK_OBJECT(view->model)); - g_free(view); - window_count --; - if ( window_count <= 0 ) - gtk_main_quit(); -} - -static void allocate_callback(GtkWidget *canvas, GtkAllocation *allocation, gpointer data) -{ - double width; - View *view = (View *)data; - Reflow *reflow = view->reflow; - if ( !reflow ) - return; - reflow->last_alloc = *allocation; - gnome_canvas_item_set( reflow->reflow, - "height", (double) allocation->height, - NULL ); - gnome_canvas_item_set( reflow->reflow, - "minimum_width", (double) allocation->width, - NULL ); - gtk_object_get(GTK_OBJECT(reflow->reflow), - "width", &width, - NULL); - width = MAX(width, allocation->width); - gnome_canvas_set_scroll_region(GNOME_CANVAS( reflow->canvas ), 0, 0, width, allocation->height ); - gnome_canvas_item_set( reflow->rect, - "x2", (double) width, - "y2", (double) allocation->height, - NULL ); -} - -static void resize(ECanvas *canvas, gpointer data) -{ - double width; - View *view = (View *)data; - Reflow *reflow = view->reflow; - if ( !reflow ) - return; - gtk_object_get(GTK_OBJECT(reflow->reflow), - "width", &width, - NULL); - width = MAX(width, reflow->last_alloc.width); - gnome_canvas_set_scroll_region(GNOME_CANVAS(reflow->canvas), 0, 0, width, reflow->last_alloc.height ); - gnome_canvas_item_set( reflow->rect, - "x2", (double) width, - "y2", (double) reflow->last_alloc.height, - NULL ); -} - -static void -canvas_realized(GtkLayout *layout, View *view) -{ - gdk_window_set_back_pixmap( layout->bin_window, NULL, FALSE); -} - -static GtkWidget * -create_reflow(View *view) -{ - GtkWidget *inner_vbox; - GtkWidget *scrollbar; - int i; - Reflow *reflow = g_new(Reflow, 1); - view->reflow = reflow; - - view->type = VIEW_TYPE_REFLOW; - - /* Next we create our model. This uses the functions we defined - earlier. */ - - inner_vbox = gtk_vbox_new(FALSE, 0); - reflow->canvas = e_canvas_new(); - reflow->rect = gnome_canvas_item_new( gnome_canvas_root( GNOME_CANVAS( reflow->canvas ) ), - gnome_canvas_rect_get_type(), - "x1", (double) 0, - "y1", (double) 0, - "x2", (double) 100, - "y2", (double) 100, - "fill_color", "white", - NULL ); - reflow->reflow = gnome_canvas_item_new( gnome_canvas_root( GNOME_CANVAS( reflow->canvas ) ), - e_reflow_get_type(), - "x", (double) 0, - "y", (double) 0, - "height", (double) 100, - "minimum_width", (double) 100, - NULL ); - /* Connect the signals */ - gtk_signal_connect( GTK_OBJECT( reflow->canvas ), "reflow", - GTK_SIGNAL_FUNC( resize ), - ( gpointer ) view); - - for ( i = 0; i < view->model->data_count; i++ ) - { - GnomeCanvasItem *item; - item = gnome_canvas_item_new( GNOME_CANVAS_GROUP(reflow->reflow), - e_minicard_get_type(), - "model", view->model, - "row", i, - NULL); - e_reflow_add_item(E_REFLOW(reflow->reflow), item); - } - gnome_canvas_set_scroll_region ( GNOME_CANVAS( reflow->canvas ), - 0, 0, - 100, 100 ); - - scrollbar = gtk_hscrollbar_new(gtk_layout_get_hadjustment(GTK_LAYOUT(reflow->canvas))); - - gtk_signal_connect( GTK_OBJECT( reflow->canvas ), "size_allocate", - GTK_SIGNAL_FUNC( allocate_callback ), - ( gpointer ) view ); - - gtk_signal_connect( GTK_OBJECT(reflow->canvas), "realize", - GTK_SIGNAL_FUNC(canvas_realized), view); - - reflow->model_changed_id = gtk_signal_connect(GTK_OBJECT( view->model ), "model_changed", - GTK_SIGNAL_FUNC(rebuild_reflow), view); - - gtk_object_ref(GTK_OBJECT(view->model)); - - /* Build the gtk widget hierarchy. */ - gtk_box_pack_start(GTK_BOX(inner_vbox), reflow->canvas, TRUE, TRUE, 0); - gtk_box_pack_start(GTK_BOX(inner_vbox), scrollbar, FALSE, FALSE, 0); - - return inner_vbox; -} - -/* We create a window containing our new table. */ -static GtkWidget * -create_table(View *view) -{ - ECell *cell_left_just; - ETableHeader *e_table_header; - GtkWidget *e_table; - int i; - - view->type = VIEW_TYPE_TABLE; - - /* - Next we create a header. The ETableHeader is used in two - different way. The first is the full_header. This is the - list of possible columns in the view. The second use is - completely internal. Many of the ETableHeader functions are - for that purpose. The only functions we really need are - e_table_header_new and e_table_header_add_col. - - First we create the header. */ - e_table_header = e_table_header_new (); - - /* Next we have to build renderers for all of the columns. - Since all our columns are text columns, we can simply use - the same renderer over and over again. If we had different - types of columns, we could use a different renderer for - each column. */ - cell_left_just = e_cell_text_new (E_TABLE_MODEL(view->model), NULL, GTK_JUSTIFY_LEFT); - - /* Next we create a column object for each view column and add - them to the header. We don't create a column object for - the importance column since it will not be shown. */ - for (i = 0; i < LAST_COL; i++){ - /* Create the column. */ - ETableCol *ecol = e_table_col_new ( - i, headers [i], - 80, 20, cell_left_just, - g_str_compare, TRUE); - /* Add it to the header. */ - e_table_header_add_column (e_table_header, ecol, i); - } - - /* Here we create the table. We give it the three pieces of - the table we've created, the header, the model, and the - initial layout. It does the rest. */ - e_table = e_table_new_from_spec_file (e_table_header, E_TABLE_MODEL(view->model), "spec"); - -#if 0 - gtk_signal_connect(GTK_OBJECT(E_TABLE(e_table)->sort_info), "sort_info_changed", - GTK_SIGNAL_FUNC(queue_header_save), e_table->sort_info); - - gtk_signal_connect(GTK_OBJECT(E_TABLE(e_table)->header), "structure_change", - GTK_SIGNAL_FUNC(queue_header_save), e_table->sort_info); - gtk_signal_connect(GTK_OBJECT(E_TABLE(e_table)->header), "dimension_change", - GTK_SIGNAL_FUNC(queue_header_save), e_table->sort_info); -#endif - - return e_table; -} - -void -change_type(View *view, ViewType type) -{ - gtk_object_ref(GTK_OBJECT(view->model)); - if (view->reflow) - destroy_reflow(view); - gtk_widget_destroy(view->child); - switch(type) { - case VIEW_TYPE_REFLOW: - view->child = create_reflow(view); - break; - case VIEW_TYPE_TABLE: - view->child = create_table(view); - break; - } - gtk_container_add(GTK_CONTAINER(view->frame), view->child); - gtk_widget_show_all(view->child); - gtk_object_unref(GTK_OBJECT(view->model)); -} - -View * -create_view(void) -{ - View *view = g_new(View, 1); - ViewType type = VIEW_TYPE_REFLOW; - GtkWidget *button; - - view->reflow = NULL; - - view->model = get_model(NULL); - - /* This frame is simply to get a bevel around our table. */ - view->frame = gtk_frame_new (NULL); - - switch(type) { - case VIEW_TYPE_REFLOW: - view->child = create_reflow(view); - break; - case VIEW_TYPE_TABLE: - view->child = create_table(view); - break; - } - - - gtk_signal_connect( GTK_OBJECT( view->child ), "destroy", - GTK_SIGNAL_FUNC( destroy_callback ), - view ); - - /* - vbox = gtk_vbox_new(FALSE, 0); - button = gtk_button_new_with_label("Add address"); - gtk_signal_connect(GTK_OBJECT(button), "clicked", - GTK_SIGNAL_FUNC(add_address_cb), view); - - change_button = gtk_button_new_with_label("Change View"); - gtk_signal_connect(GTK_OBJECT(change_button), "clicked", - GTK_SIGNAL_FUNC(change_callback), view); - */ - /* Build the gtk widget hierarchy. */ - - view->widget = gtk_vbox_new(FALSE, 0); - - button = gtk_button_new_with_label("Add address"); - gtk_signal_connect(GTK_OBJECT(button), "clicked", - GTK_SIGNAL_FUNC(add_address_cb), view); - - gtk_container_add (GTK_CONTAINER (view->frame), view->child); - gtk_box_pack_start (GTK_BOX (view->widget), view->frame, TRUE, TRUE, 0); - gtk_box_pack_start (GTK_BOX (view->widget), button, FALSE, FALSE, 0); - /* - gtk_box_pack_start (GTK_BOX (vbox), change_button, FALSE, FALSE, 0); - */ - /* Show it all. */ - gtk_widget_show_all (view->widget); - gtk_object_ref(GTK_OBJECT(view->model)); - gtk_object_sink(GTK_OBJECT(view->model)); - window_count ++; - return view; - -} - -#if 0 -static void -change_callback(GtkWidget *button, View *view) -{ - if (view->type == VIEW_TYPE_REFLOW) - change_type(view, VIEW_TYPE_TABLE); - else - change_type(view, VIEW_TYPE_REFLOW); -} - -static GtkWidget * -create_window(char *filename, ViewType type) -{ - GtkWidget *button; - GtkWidget *change_button; - GtkWidget *vbox; - View *view = g_new(View, 1); - - view->reflow = NULL; - - view->model = get_model(filename); - - /* Here we create a window for our new table. This window - will get shown and the person will be able to test their - item. */ - view->window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - - gtk_signal_connect( GTK_OBJECT( view->window ), "destroy", - GTK_SIGNAL_FUNC( destroy_callback ), - view ); - - /* This frame is simply to get a bevel around our table. */ - view->frame = gtk_frame_new (NULL); - - switch(type) { - case VIEW_TYPE_REFLOW: - view->child = create_reflow(view); - break; - case VIEW_TYPE_TABLE: - view->child = create_table(view); - break; - } - - - vbox = gtk_vbox_new(FALSE, 0); - - button = gtk_button_new_with_label("Add address"); - gtk_signal_connect(GTK_OBJECT(button), "clicked", - GTK_SIGNAL_FUNC(add_address_cb), view); - - change_button = gtk_button_new_with_label("Change View"); - gtk_signal_connect(GTK_OBJECT(change_button), "clicked", - GTK_SIGNAL_FUNC(change_callback), view); - - /* Build the gtk widget hierarchy. */ - - gtk_container_add (GTK_CONTAINER (view->frame), view->child); - gtk_box_pack_start (GTK_BOX (vbox), view->frame, TRUE, TRUE, 0); - gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); - gtk_box_pack_start (GTK_BOX (vbox), change_button, FALSE, FALSE, 0); - gtk_container_add (GTK_CONTAINER (view->window), vbox); - - /* Size the initial window. */ - gtk_widget_set_usize (view->window, 200, 200); - /* Show it all. */ - gtk_widget_show_all (view->window); - gtk_object_sink(GTK_OBJECT(view->model)); - window_count ++; - return view->window; -} - -/* This is the main function which just initializes gnome and call our create_table function */ - -int -main (int argc, char *argv []) -{ - gnome_init ("TableExample", "TableExample", argc, argv); - e_cursors_init (); - - gtk_widget_push_visual (gdk_rgb_get_visual ()); - gtk_widget_push_colormap (gdk_rgb_get_cmap ()); - - create_window("addressbook.xml", VIEW_TYPE_TABLE); - create_window("addressbook.xml", VIEW_TYPE_TABLE); - create_window("addressbook.xml", VIEW_TYPE_TABLE); - create_window("addressbook.xml", VIEW_TYPE_REFLOW); - create_window("addressbook2.xml", VIEW_TYPE_TABLE); - create_window("addressbook2.xml", VIEW_TYPE_REFLOW); - - gtk_main (); - - e_cursors_shutdown (); - return 0; -} -#endif diff --git a/addressbook/demo/addressbook-widget.h b/addressbook/demo/addressbook-widget.h deleted file mode 100644 index 9111713da5..0000000000 --- a/addressbook/demo/addressbook-widget.h +++ /dev/null @@ -1,52 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * demo.h - * Copyright (C) 2000 Helix Code, Inc. - * Author: Chris Lahey - * - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#ifndef __DEMO_H__ -#define __DEMO_H__ - -#include "e-test-model.h" - -typedef struct _View View; - -typedef enum { - VIEW_TYPE_REFLOW, - VIEW_TYPE_TABLE -} ViewType; - -typedef struct { - GtkAllocation last_alloc; - GnomeCanvasItem *reflow; - GtkWidget *canvas; - GnomeCanvasItem *rect; - int model_changed_id; -} Reflow; - -struct _View { - ViewType type; - ETestModel *model; - GtkWidget *child; - GtkWidget *frame; - Reflow *reflow; - - GtkWidget *widget; -}; - -void change_type(View *view, ViewType type); -View *create_view(void); - -#endif /* __DEMO_H__ */ diff --git a/addressbook/demo/addressbook.c b/addressbook/demo/addressbook.c deleted file mode 100644 index 38cb6c7121..0000000000 --- a/addressbook/demo/addressbook.c +++ /dev/null @@ -1,199 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * folder-browser-factory.c: A Bonobo Control factory for Folder Browsers - * - * Author: - * Miguel de Icaza (miguel@helixcode.com) - * - * (C) 2000 Helix Code, Inc. - */ -/* - * bonobo-clock-control.c - * - * Copyright 1999, Helix Code, Inc. - * - * Author: - * Nat Friedman (nat@nat.org) - */ - -#include -#include -#include -#include - -#include - -#include "addressbook-widget.h" -#include "addressbook.h" - - - -#if 0 -static void -bonobo_clock_control_prop_value_changed_cb (BonoboPropertyBag *pb, char *name, char *type, - gpointer old_value, gpointer new_value, - gpointer user_data) -{ - GtkClock *clock = user_data; - - if (! strcmp (name, "running")) { - gboolean *b = new_value; - - if (*b) - gtk_clock_start (clock); - else - gtk_clock_stop (clock); - } -} - -/* - * Callback routine used to release any values we associated with the control - * dynamically. - */ -static void -release_data (GtkObject *object, void *data) -{ - g_free (data); -} -#endif - - -static void -control_deactivate (BonoboControl *control, BonoboUIHandler *uih) -{ - /* how to remove a menu item */ - bonobo_ui_handler_menu_remove (uih, "/Actions/New Contact"); - - /* remove our toolbar */ - bonobo_ui_handler_dock_remove (uih, "/Toolbar"); -} - -static void -do_nothing_cb (BonoboUIHandler *uih, void *user_data, const char *path) -{ - printf ("Yow! I am called back!\n"); -} - -static GnomeUIInfo gnome_toolbar [] = { - GNOMEUIINFO_ITEM_STOCK (N_("New"), N_("Create a new contact"), do_nothing_cb, GNOME_STOCK_PIXMAP_NEW), - - GNOMEUIINFO_SEPARATOR, - - GNOMEUIINFO_ITEM_STOCK (N_("Find"), N_("Find a contact"), do_nothing_cb, GNOME_STOCK_PIXMAP_SEARCH), - GNOMEUIINFO_ITEM_STOCK (N_("Print"), N_("Print contacts"), do_nothing_cb, GNOME_STOCK_PIXMAP_PRINT), - GNOMEUIINFO_ITEM_STOCK (N_("Delete"), N_("Delete a contact"), do_nothing_cb, GNOME_STOCK_PIXMAP_TRASH), - - GNOMEUIINFO_END -}; - - - - -static void -control_activate (BonoboControl *control, BonoboUIHandler *uih) -{ - Bonobo_UIHandler remote_uih; - GtkWidget *toolbar; - BonoboControl *toolbar_control; - - remote_uih = bonobo_control_get_remote_ui_handler (control); - bonobo_ui_handler_set_container (uih, remote_uih); - - bonobo_ui_handler_menu_new_item (uih, "/Actions/New Contact", N_("_New Contact"), - NULL, -1, - BONOBO_UI_HANDLER_PIXMAP_NONE, NULL, - 0, 0, do_nothing_cb, NULL); - - toolbar = gtk_toolbar_new (GTK_ORIENTATION_HORIZONTAL, - GTK_TOOLBAR_BOTH); - - gnome_app_fill_toolbar (GTK_TOOLBAR (toolbar), - gnome_toolbar, - NULL); - - gtk_widget_show_all (toolbar); - - toolbar_control = bonobo_control_new (toolbar); - bonobo_ui_handler_dock_add ( - uih, "/Toolbar", - bonobo_object_corba_objref (BONOBO_OBJECT (toolbar_control)), - GNOME_DOCK_ITEM_BEH_LOCKED | - GNOME_DOCK_ITEM_BEH_EXCLUSIVE, - GNOME_DOCK_TOP, - 1, 1, 0); -} - -static void -control_activate_cb (BonoboControl *control, - gboolean activate, - gpointer user_data) -{ - BonoboUIHandler *uih; - - uih = bonobo_control_get_ui_handler (control); - g_assert (uih); - - if (activate) - control_activate (control, uih); - else - control_deactivate (control, uih); -} - - -static BonoboObject * -addressbook_factory (BonoboGenericFactory *Factory, void *closure) -{ -#if 0 - BonoboPropertyBag *pb; - CORBA_boolean *running; -#endif - BonoboControl *control; - View *view; - - /* Create the control. */ - view = create_view(); - control = bonobo_control_new (view->widget); - - gtk_signal_connect (GTK_OBJECT (control), "activate", - control_activate_cb, NULL); -#if 0 - /* Create the properties. */ - pb = bonobo_property_bag_new (); - bonobo_control_set_property_bag (control, pb); - - gtk_signal_connect (GTK_OBJECT (pb), "value_changed", - bonobo_clock_control_prop_value_changed_cb, - clock); - - running = g_new0 (CORBA_boolean, 1); - *running = TRUE; - bonobo_property_bag_add (pb, "running", "boolean", - (gpointer) running, - NULL, "Whether or not the clock is running", 0); - - /* - * Release "running" when the object is destroyed - */ - gtk_signal_connect (GTK_OBJECT (pb), "destroy", GTK_SIGNAL_FUNC (release_data), running); -#endif - - return BONOBO_OBJECT (control); -} - -void -addressbook_factory_init (void) -{ - static BonoboGenericFactory *addressbook_control_factory = NULL; - - if (addressbook_control_factory != NULL) - return; - - addressbook_control_factory = - bonobo_generic_factory_new ( - "control-factory:addressbook", - addressbook_factory, NULL); - - if (addressbook_control_factory == NULL) { - g_error ("I could not register a Addressbook factory."); - } -} diff --git a/addressbook/demo/addressbook.gnorba b/addressbook/demo/addressbook.gnorba deleted file mode 100644 index 7114b1c332..0000000000 --- a/addressbook/demo/addressbook.gnorba +++ /dev/null @@ -1,11 +0,0 @@ -[control-factory:addressbook] -type=exe -repo_id=IDL:GNOME/GenericFactory:1.0 -description=Factory for the sample Addressbook control -location_info=evolution-addressbook - -[control:addressbook] -type=factory -repo_id=IDL:BonoboControl/addressbook-control:1.0 IDL:GNOME/Control:1.0 -description=A sample Bonobo control which displays an addressbook. -location_info=control-factory:addressbook diff --git a/addressbook/demo/addressbook.h b/addressbook/demo/addressbook.h deleted file mode 100644 index e9289128a6..0000000000 --- a/addressbook/demo/addressbook.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef __ADDRESSBOOK_H__ -#define __ADDRESSBOOK_H__ - -#include - -void addressbook_factory_init (void); - -#endif /* __ADDRESSBOOK_H__ */ diff --git a/addressbook/demo/demo.c b/addressbook/demo/demo.c deleted file mode 100644 index e6f7246b2f..0000000000 --- a/addressbook/demo/demo.c +++ /dev/null @@ -1,466 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -#include -#include -#include -#include -#include -#include -#include "e-util/e-cursors.h" -#include "e-canvas.h" -#include "e-table-simple.h" -#include "e-table-header.h" -#include "e-table-header-item.h" -#include "e-table-item.h" -#include "e-cell-text.h" -#include "e-cell-checkbox.h" -#include "e-table.h" -#include "e-reflow.h" -#include "e-minicard.h" - -#include - -#include "table-test.h" - -#include "e-test-model.h" - -#define COLS 4 - -/* Here we define the initial layout of the table. This is an xml - format that allows you to change the initial ordering of the - columns or to do sorting or grouping initially. This specification - shows all 5 columns, but moves the importance column nearer to the - front. It also sorts by the "Full Name" column (ascending.) - Sorting and grouping take the model column as their arguments - (sorting is specified by the "column" argument to the leaf elemnt. */ -#define INITIAL_SPEC " \ - \ - 0 \ - 1 \ - 2 \ - 3 \ - \ - \ -" - -char *headers[COLS] = { - "Email", - "Full Name", - "Address", - "Phone" -}; - -typedef struct _View View; - -typedef enum { - VIEW_TYPE_REFLOW, - VIEW_TYPE_TABLE -} ViewType; - -typedef struct { - GtkAllocation last_alloc; - GnomeCanvasItem *reflow; - GtkWidget *canvas; - GnomeCanvasItem *rect; - int model_changed_id; -} Reflow; - -struct _View { - ETestModel *model; - GtkWidget *window; - GtkWidget *frame; - GtkWidget *child; - - ViewType type; - - Reflow *reflow; -}; - -static int window_count = 0; -static GHashTable *models = NULL; - -static void -remove_model(ETableModel *model, gchar *filename) -{ - g_hash_table_remove(models, filename); - g_free(filename); -} - -static ETestModel * -get_model(char *filename) -{ - ETestModel *model; - if ( models == NULL ) { - models = g_hash_table_new(g_str_hash, g_str_equal); - } - - model = g_hash_table_lookup(models, filename); - if ( model ) - return model; - - filename = g_strdup(filename); - - model = E_TEST_MODEL(e_test_model_new(filename)); - g_hash_table_insert(models, - filename, model); - gtk_signal_connect(GTK_OBJECT(model), "destroy", - GTK_SIGNAL_FUNC(remove_model), filename); - return model; -} - -static void -add_address_cb(GtkWidget *button, gpointer data) -{ - View *view = (View *) data; - Address *newadd = g_new(Address, 1); - newadd->email = g_strdup(""); - newadd->phone = g_strdup(""); - newadd->full_name = g_strdup(""); - newadd->street = g_strdup(""); - e_test_model_add_column (view->model, newadd); -} - -static void -rebuild_reflow(ETableModel *model, gpointer data) -{ - int i; - View *view = (View *) data; - Reflow *reflow = view->reflow; - if (!reflow) - return; - gtk_object_destroy(GTK_OBJECT(reflow->reflow)); - reflow->reflow = gnome_canvas_item_new( gnome_canvas_root( GNOME_CANVAS( reflow->canvas ) ), - e_reflow_get_type(), - "x", (double) 0, - "y", (double) 0, - "height", (double) reflow->last_alloc.height, - "minimum_width", (double) reflow->last_alloc.width, - NULL ); - - for ( i = 0; i < view->model->data_count; i++ ) - { - GnomeCanvasItem *item; - item = gnome_canvas_item_new( GNOME_CANVAS_GROUP(reflow->reflow), - e_minicard_get_type(), - "model", view->model, - "row", i, - NULL); - e_reflow_add_item(E_REFLOW(reflow->reflow), item); - } - e_canvas_item_request_reflow(reflow->reflow); -} - -static void -destroy_reflow(View *view) -{ - Reflow *reflow = view->reflow; - if ( !reflow ) - return; - - gtk_signal_disconnect(GTK_OBJECT(view->model), - reflow->model_changed_id); - g_free(reflow); - gtk_object_unref(GTK_OBJECT(view->model)); - view->reflow = NULL; -} - -static void destroy_callback(GtkWidget *app, gpointer data) -{ - View *view = (View *)data; - if ( view->reflow ) { - destroy_reflow(view); - } - gtk_object_unref(GTK_OBJECT(view->model)); - g_free(view); - window_count --; - if ( window_count <= 0 ) - exit(0); -} - -static void allocate_callback(GtkWidget *canvas, GtkAllocation *allocation, gpointer data) -{ - double width; - View *view = (View *)data; - Reflow *reflow = view->reflow; - if ( !reflow ) - return; - reflow->last_alloc = *allocation; - gnome_canvas_item_set( reflow->reflow, - "height", (double) allocation->height, - NULL ); - gnome_canvas_item_set( reflow->reflow, - "minimum_width", (double) allocation->width, - NULL ); - gtk_object_get(GTK_OBJECT(reflow->reflow), - "width", &width, - NULL); - width = MAX(width, allocation->width); - gnome_canvas_set_scroll_region(GNOME_CANVAS( reflow->canvas ), 0, 0, width, allocation->height ); - gnome_canvas_item_set( reflow->rect, - "x2", (double) width, - "y2", (double) allocation->height, - NULL ); -} - -static void resize(ECanvas *canvas, gpointer data) -{ - double width; - View *view = (View *)data; - Reflow *reflow = view->reflow; - if ( !reflow ) - return; - gtk_object_get(GTK_OBJECT(reflow->reflow), - "width", &width, - NULL); - width = MAX(width, reflow->last_alloc.width); - gnome_canvas_set_scroll_region(GNOME_CANVAS(reflow->canvas), 0, 0, width, reflow->last_alloc.height ); - gnome_canvas_item_set( reflow->rect, - "x2", (double) width, - "y2", (double) reflow->last_alloc.height, - NULL ); -} - -static GtkWidget * -create_reflow(View *view) -{ - GtkWidget *inner_vbox; - GtkWidget *scrollbar; - int i; - Reflow *reflow = g_new(Reflow, 1); - view->reflow = reflow; - - view->type = VIEW_TYPE_REFLOW; - - /* Next we create our model. This uses the functions we defined - earlier. */ - - inner_vbox = gtk_vbox_new(FALSE, 0); - reflow->canvas = e_canvas_new(); - reflow->rect = gnome_canvas_item_new( gnome_canvas_root( GNOME_CANVAS( reflow->canvas ) ), - gnome_canvas_rect_get_type(), - "x1", (double) 0, - "y1", (double) 0, - "x2", (double) 100, - "y2", (double) 100, - "fill_color", "white", - NULL ); - reflow->reflow = gnome_canvas_item_new( gnome_canvas_root( GNOME_CANVAS( reflow->canvas ) ), - e_reflow_get_type(), - "x", (double) 0, - "y", (double) 0, - "height", (double) 100, - "minimum_width", (double) 100, - NULL ); - /* Connect the signals */ - gtk_signal_connect( GTK_OBJECT( reflow->canvas ), "reflow", - GTK_SIGNAL_FUNC( resize ), - ( gpointer ) view); - - for ( i = 0; i < view->model->data_count; i++ ) - { - GnomeCanvasItem *item; - item = gnome_canvas_item_new( GNOME_CANVAS_GROUP(reflow->reflow), - e_minicard_get_type(), - "model", view->model, - "row", i, - NULL); - e_reflow_add_item(E_REFLOW(reflow->reflow), item); - } - gnome_canvas_set_scroll_region ( GNOME_CANVAS( reflow->canvas ), - 0, 0, - 100, 100 ); - - scrollbar = gtk_hscrollbar_new(gtk_layout_get_hadjustment(GTK_LAYOUT(reflow->canvas))); - - gtk_signal_connect( GTK_OBJECT( reflow->canvas ), "size_allocate", - GTK_SIGNAL_FUNC( allocate_callback ), - ( gpointer ) view ); - - gdk_window_set_back_pixmap( GTK_LAYOUT(reflow->canvas)->bin_window, NULL, FALSE); - - reflow->model_changed_id = gtk_signal_connect(GTK_OBJECT( view->model ), "model_changed", - GTK_SIGNAL_FUNC(rebuild_reflow), view); - - gtk_object_ref(GTK_OBJECT(view->model)); - - /* Build the gtk widget hierarchy. */ - gtk_box_pack_start(GTK_BOX(inner_vbox), reflow->canvas, TRUE, TRUE, 0); - gtk_box_pack_start(GTK_BOX(inner_vbox), scrollbar, FALSE, FALSE, 0); - - return inner_vbox; -} - -/* We create a window containing our new table. */ -static GtkWidget * -create_table(View *view) -{ - ECell *cell_left_just; - ETableHeader *e_table_header; - GtkWidget *e_table; - int i; - - view->type = VIEW_TYPE_TABLE; - - /* - Next we create a header. The ETableHeader is used in two - different way. The first is the full_header. This is the - list of possible columns in the view. The second use is - completely internal. Many of the ETableHeader functions are - for that purpose. The only functions we really need are - e_table_header_new and e_table_header_add_col. - - First we create the header. */ - e_table_header = e_table_header_new (); - - /* Next we have to build renderers for all of the columns. - Since all our columns are text columns, we can simply use - the same renderer over and over again. If we had different - types of columns, we could use a different renderer for - each column. */ - cell_left_just = e_cell_text_new (E_TABLE_MODEL(view->model), NULL, GTK_JUSTIFY_LEFT); - - /* Next we create a column object for each view column and add - them to the header. We don't create a column object for - the importance column since it will not be shown. */ - for (i = 0; i < LAST_COL; i++){ - /* Create the column. */ - ETableCol *ecol = e_table_col_new ( - i, headers [i], - 80, 20, cell_left_just, - g_str_compare, TRUE); - /* Add it to the header. */ - e_table_header_add_column (e_table_header, ecol, i); - } - - /* Here we create the table. We give it the three pieces of - the table we've created, the header, the model, and the - initial layout. It does the rest. */ - e_table = e_table_new_from_spec_file (e_table_header, E_TABLE_MODEL(view->model), "spec"); - -#if 0 - gtk_signal_connect(GTK_OBJECT(E_TABLE(e_table)->sort_info), "sort_info_changed", - GTK_SIGNAL_FUNC(queue_header_save), e_table->sort_info); - - gtk_signal_connect(GTK_OBJECT(E_TABLE(e_table)->header), "structure_change", - GTK_SIGNAL_FUNC(queue_header_save), e_table->sort_info); - gtk_signal_connect(GTK_OBJECT(E_TABLE(e_table)->header), "dimension_change", - GTK_SIGNAL_FUNC(queue_header_save), e_table->sort_info); -#endif - - return e_table; -} - -static void -change_type(View *view, ViewType type) -{ - gtk_object_ref(GTK_OBJECT(view->model)); - if (view->reflow) - destroy_reflow(view); - gtk_widget_destroy(view->child); - switch(type) { - case VIEW_TYPE_REFLOW: - view->child = create_reflow(view); - break; - case VIEW_TYPE_TABLE: - view->child = create_table(view); - break; - } - gtk_container_add(GTK_CONTAINER(view->frame), view->child); - gtk_widget_show_all(view->child); - gtk_object_unref(GTK_OBJECT(view->model)); -} - -static void -change_callback(GtkWidget *button, View *view) -{ - if (view->type == VIEW_TYPE_REFLOW) - change_type(view, VIEW_TYPE_TABLE); - else - change_type(view, VIEW_TYPE_REFLOW); -} - -static GtkWidget * -create_window(char *filename, ViewType type) -{ - GtkWidget *button; - GtkWidget *change_button; - GtkWidget *vbox; - View *view = g_new(View, 1); - - view->reflow = NULL; - - view->model = get_model(filename); - - /* Here we create a window for our new table. This window - will get shown and the person will be able to test their - item. */ - view->window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - - gtk_signal_connect( GTK_OBJECT( view->window ), "destroy", - GTK_SIGNAL_FUNC( destroy_callback ), - view ); - - /* This frame is simply to get a bevel around our table. */ - view->frame = gtk_frame_new (NULL); - - switch(type) { - case VIEW_TYPE_REFLOW: - view->child = create_reflow(view); - break; - case VIEW_TYPE_TABLE: - view->child = create_table(view); - break; - } - - - vbox = gtk_vbox_new(FALSE, 0); - - button = gtk_button_new_with_label("Add address"); - gtk_signal_connect(GTK_OBJECT(button), "clicked", - GTK_SIGNAL_FUNC(add_address_cb), view); - - change_button = gtk_button_new_with_label("Change View"); - gtk_signal_connect(GTK_OBJECT(change_button), "clicked", - GTK_SIGNAL_FUNC(change_callback), view); - - /* Build the gtk widget hierarchy. */ - - gtk_container_add (GTK_CONTAINER (view->frame), view->child); - gtk_box_pack_start (GTK_BOX (vbox), view->frame, TRUE, TRUE, 0); - gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); - gtk_box_pack_start (GTK_BOX (vbox), change_button, FALSE, FALSE, 0); - gtk_container_add (GTK_CONTAINER (view->window), vbox); - - /* Size the initial window. */ - gtk_widget_set_usize (view->window, 200, 200); - /* Show it all. */ - gtk_widget_show_all (view->window); - gtk_object_ref(GTK_OBJECT(view->model)); - gtk_object_sink(GTK_OBJECT(view->model)); - window_count ++; - return view->window; -} - -/* This is the main function which just initializes gnome and call our create_table function */ - -int -main (int argc, char *argv []) -{ - gnome_init ("TableExample", "TableExample", argc, argv); - e_cursors_init (); - - gtk_widget_push_visual (gdk_rgb_get_visual ()); - gtk_widget_push_colormap (gdk_rgb_get_cmap ()); - - create_window("addressbook.xml", VIEW_TYPE_TABLE); - create_window("addressbook.xml", VIEW_TYPE_TABLE); - create_window("addressbook.xml", VIEW_TYPE_TABLE); - create_window("addressbook.xml", VIEW_TYPE_REFLOW); - create_window("addressbook.xml", VIEW_TYPE_REFLOW); - create_window("addressbook2.xml", VIEW_TYPE_TABLE); - create_window("addressbook2.xml", VIEW_TYPE_REFLOW); - - gtk_main (); - - e_cursors_shutdown (); - return 0; -} diff --git a/addressbook/demo/e-test-model.c b/addressbook/demo/e-test-model.c deleted file mode 100644 index 941e1c006f..0000000000 --- a/addressbook/demo/e-test-model.c +++ /dev/null @@ -1,385 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * - * Author: - * Miguel de Icaza (miguel@gnu.org) - * - * (C) 1999 Helix Code, Inc. - */ - -#include -#include "e-test-model.h" -#include -#include -#include -#include - -#define PARENT_TYPE e_table_model_get_type() -/* - * ETestModel callbacks -n * These are the callbacks that define the behavior of our custom model. - */ - -static void -test_destroy(GtkObject *object) -{ - ETestModel *model = E_TEST_MODEL(object); - int i; - if (model->book) - gtk_object_unref(GTK_OBJECT(model->book)); - if (model->book_view) - gtk_object_unref(GTK_OBJECT(model->book_view)); - for ( i = 0; i < model->data_count; i++ ) { - gtk_object_unref(GTK_OBJECT(model->data[i])); - } - g_free(model->data); - g_free(model->uri); -} - -/* This function returns the number of columns in our ETableModel. */ -static int -test_col_count (ETableModel *etc) -{ - return LAST_COL; -} - -/* This function returns the number of rows in our ETableModel. */ -static int -test_row_count (ETableModel *etc) -{ - ETestModel *test = E_TEST_MODEL(etc); - return test->data_count; -} - -/* This function returns the value at a particular point in our ETableModel. */ -static void * -test_value_at (ETableModel *etc, int col, int row) -{ - ETestModel *test = E_TEST_MODEL(etc); - ECardList *list; - ECardIterator *iterator; - gchar *string; - if ( col >= LAST_COL || row >= test->data_count ) - return NULL; - switch (col) { - case EMAIL: - gtk_object_get(GTK_OBJECT(test->data[row]), - "email", &list, - NULL); - iterator = e_card_list_get_iterator(list); - if (e_card_iterator_get(iterator)) - return (void *) e_card_iterator_get(iterator); - else - return ""; - gtk_object_unref(GTK_OBJECT(iterator)); - break; - case FULL_NAME: - gtk_object_get(GTK_OBJECT(test->data[row]), - "full_name", &string, - NULL); - if (string) - return string; - else - return ""; - break; - case STREET: - gtk_object_get(GTK_OBJECT(test->data[row]), - "street", &list, - NULL); - iterator = e_card_list_get_iterator(list); - if (e_card_iterator_get(iterator)) - return ((ECardDeliveryAddress *)e_card_iterator_get(iterator))->street; - else - return ""; - gtk_object_unref(GTK_OBJECT(iterator)); - break; - case PHONE: - gtk_object_get(GTK_OBJECT(test->data[row]), - "phone", &list, - NULL); - iterator = e_card_list_get_iterator(list); - if (e_card_iterator_get(iterator)) - return ((ECardPhone *)e_card_iterator_get(iterator))->number; - else - return ""; - gtk_object_unref(GTK_OBJECT(iterator)); - break; - default: - return NULL; - } -} - -/* This function sets the value at a particular point in our ETableModel. */ -static void -test_set_value_at (ETableModel *etc, int col, int row, const void *val) -{ - ETestModel *test = E_TEST_MODEL(etc); - ECardList *list; - ECardIterator *iterator; - if ( col >= LAST_COL || row >= test->data_count ) - return; - switch (col) { - case EMAIL: - gtk_object_get(GTK_OBJECT(test->data[row]), - "email", &list, - NULL); - iterator = e_card_list_get_iterator(list); - if (e_card_iterator_is_valid(iterator)) { - e_card_iterator_set(iterator, val); - } else { - e_card_list_append(list, val); - } - gtk_object_unref(GTK_OBJECT(iterator)); - break; - case FULL_NAME: - gtk_object_set(GTK_OBJECT(test->data[row]), - "full_name", val, - NULL); - break; - case STREET: - gtk_object_get(GTK_OBJECT(test->data[row]), - "address", &list, - NULL); - iterator = e_card_list_get_iterator(list); - if (e_card_iterator_is_valid(iterator)) { - const ECardDeliveryAddress *address = e_card_iterator_get(iterator); - ECardDeliveryAddress *address_copy = e_card_delivery_address_copy(address); - g_free(address_copy->street); - address_copy->street = g_strdup(val); - e_card_iterator_set(iterator, address_copy); - e_card_delivery_address_free(address_copy); - } else { - ECardDeliveryAddress *address = g_new(ECardDeliveryAddress, 1); - address->po = NULL; - address->ext = NULL; - address->street = g_strdup(val); - address->city = NULL; - address->region = NULL; - address->code = NULL; - address->country = NULL; - address->flags = 0; - e_card_list_append(list, address); - e_card_delivery_address_free(address); - } - gtk_object_unref(GTK_OBJECT(iterator)); - break; - case PHONE: - gtk_object_get(GTK_OBJECT(test->data[row]), - "phone", &list, - NULL); - iterator = e_card_list_get_iterator(list); - if (e_card_iterator_is_valid(iterator)) { - const ECardPhone *phone = e_card_iterator_get(iterator); - ECardPhone *phone_copy = e_card_phone_copy(phone); - g_free(phone_copy->number); - phone_copy->number = g_strdup(val); - e_card_iterator_set(iterator, phone_copy); - e_card_phone_free(phone_copy); - } else { - ECardPhone *phone = g_new(ECardPhone, 1); - phone->number = g_strdup(val); - phone->flags = 0; - e_card_list_append(list, phone); - e_card_phone_free(phone); - } - gtk_object_unref(GTK_OBJECT(iterator)); - break; - default: - return; - } - e_book_commit_card(test->book, test->data[row], NULL, NULL); - if ( !etc->frozen ) - e_table_model_cell_changed(etc, col, row); -} - -/* This function returns whether a particular cell is editable. */ -static gboolean -test_is_cell_editable (ETableModel *etc, int col, int row) -{ - return TRUE; -} - -/* This function duplicates the value passed to it. */ -static void * -test_duplicate_value (ETableModel *etc, int col, const void *value) -{ - return g_strdup(value); -} - -/* This function frees the value passed to it. */ -static void -test_free_value (ETableModel *etc, int col, void *value) -{ - g_free(value); -} - -/* This function is for when the model is unfrozen. This can mostly - be ignored for simple models. */ -static void -test_thaw (ETableModel *etc) -{ - e_table_model_changed(etc); -} - -static void -e_test_model_class_init (GtkObjectClass *object_class) -{ - ETableModelClass *model_class = (ETableModelClass *) object_class; - - object_class->destroy = test_destroy; - - model_class->column_count = test_col_count; - model_class->row_count = test_row_count; - model_class->value_at = test_value_at; - model_class->set_value_at = test_set_value_at; - model_class->is_cell_editable = test_is_cell_editable; - model_class->duplicate_value = test_duplicate_value; - model_class->free_value = test_free_value; - model_class->thaw = test_thaw; -} - -static void -e_test_model_init (GtkObject *object) -{ - ETestModel *model = E_TEST_MODEL(object); - model->data = NULL; - model->data_count = 0; - model->book = NULL; - model->book_view = NULL; -} - -GtkType -e_test_model_get_type (void) -{ - static GtkType type = 0; - - if (!type){ - GtkTypeInfo info = { - "ETestModel", - sizeof (ETestModel), - sizeof (ETestModelClass), - (GtkClassInitFunc) e_test_model_class_init, - (GtkObjectInitFunc) e_test_model_init, - NULL, /* reserved 1 */ - NULL, /* reserved 2 */ - (GtkClassInitFunc) NULL - }; - - type = gtk_type_unique (PARENT_TYPE, &info); - } - - return type; -} - -void -e_test_model_add_column (ETestModel *model, Address *newadd) -{ -#if 0 - model->data = g_realloc(model->data, (++model->data_count) * sizeof(Address *)); - model->data[model->data_count - 1] = newadd; - e_test_model_queue_save(model); - if ( model && !E_TABLE_MODEL(model)->frozen ) - e_table_model_changed(E_TABLE_MODEL(model)); -#endif -} - -static void -e_test_model_card_added(EBookView *book_view, - const GList *cards, - ETestModel *model) -{ - model->data = g_realloc(model->data, (model->data_count + g_list_length((GList *)cards)) * sizeof(ECard *)); - for ( ; cards; cards = cards->next) { - gtk_object_ref(GTK_OBJECT(cards->data)); - model->data[model->data_count++] = E_CARD (cards->data); - } - e_table_model_changed(E_TABLE_MODEL(model)); -} - -static void -e_test_model_card_removed(EBookView *book_view, - const char *id, - ETestModel *model) -{ - int i; - for ( i = 0; i < model->data_count; i++) { - if ( !strcmp(e_card_get_id(model->data[i]), id) ) { - gtk_object_unref(GTK_OBJECT(model->data[i])); - memmove(model->data + i, model->data + i + 1, (model->data_count - i - 1) * sizeof (ECard *)); - } - } - e_table_model_changed(E_TABLE_MODEL(model)); -} - -static void -e_test_model_card_changed(EBookView *book_view, - const GList *cards, - ETestModel *model) -{ - for ( ; cards; cards = cards->next) { - int i; - for ( i = 0; i < model->data_count; i++) { - if ( !strcmp(e_card_get_id(model->data[i]), e_card_get_id(E_CARD(cards->data))) ) { - gtk_object_unref(GTK_OBJECT(model->data[i])); - model->data[i] = E_CARD(cards->data); - gtk_object_ref(GTK_OBJECT(model->data[i])); - e_table_model_row_changed(E_TABLE_MODEL(model), i); - break; - } - } - } -} - -static void -e_test_model_book_respond_get_view(EBook *book, - EBookStatus status, - EBookView *book_view, - ETestModel *model) -{ - if (status == E_BOOK_STATUS_SUCCESS) { - model->book_view = book_view; - gtk_object_ref(GTK_OBJECT(book_view)); - gtk_signal_connect(GTK_OBJECT(book_view), - "card_changed", - GTK_SIGNAL_FUNC(e_test_model_card_changed), - model); - gtk_signal_connect(GTK_OBJECT(book_view), - "card_removed", - GTK_SIGNAL_FUNC(e_test_model_card_removed), - model); - gtk_signal_connect(GTK_OBJECT(book_view), - "card_added", - GTK_SIGNAL_FUNC(e_test_model_card_added), - model); - } -} - -static void -e_test_model_uri_loaded(EBook *book, - EBookStatus status, - ETestModel *model) -{ - if (status == E_BOOK_STATUS_SUCCESS) { - e_book_get_book_view (book, - "", - (EBookBookViewCallback) e_test_model_book_respond_get_view, - model); - } -} - -ETableModel * -e_test_model_new (gchar *uri) -{ - ETestModel *et; - - et = gtk_type_new (e_test_model_get_type ()); - - et->uri = g_strdup(uri); - et->book = e_book_new(); - e_book_load_uri(et->book, - et->uri, - (EBookCallback) e_test_model_uri_loaded, - et); - - return E_TABLE_MODEL(et); -} diff --git a/addressbook/demo/e-test-model.h b/addressbook/demo/e-test-model.h deleted file mode 100644 index 871ea11de8..0000000000 --- a/addressbook/demo/e-test-model.h +++ /dev/null @@ -1,64 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -#ifndef _E_TEST_MODEL_H_ -#define _E_TEST_MODEL_H_ - -#include "e-table-model.h" -#include -#include -#include - -#define E_TEST_MODEL_TYPE (e_test_model_get_type ()) -#define E_TEST_MODEL(o) (GTK_CHECK_CAST ((o), E_TEST_MODEL_TYPE, ETestModel)) -#define E_TEST_MODEL_CLASS(k) (GTK_CHECK_CLASS_CAST((k), E_TEST_MODEL_TYPE, ETestModelClass)) -#define E_IS_TEST_MODEL(o) (GTK_CHECK_TYPE ((o), E_TEST_MODEL_TYPE)) -#define E_IS_TEST_MODEL_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), E_TEST_MODEL_TYPE)) - -/* Virtual Column list: - 0 Email - 1 Full Name - 2 Street - 3 Phone -*/ -typedef struct _Address Address; -typedef enum _Rows Rows; - -struct _Address { - gchar *email; - gchar *full_name; - gchar *street; - gchar *phone; -}; - -enum _Rows { - EMAIL, - FULL_NAME, - STREET, - PHONE, - LAST_COL -}; - -typedef struct { - ETableModel parent; - - EBook *book; - - EBookView *book_view; - - ECard **data; - int data_count; - - char *uri; -} ETestModel; - - -typedef struct { - ETableModelClass parent_class; -} ETestModelClass; - - -GtkType e_test_model_get_type (void); -ETableModel *e_test_model_new (char *uri); - -void e_test_model_add_column (ETestModel *model, Address *newadd); - -#endif /* _E_TEST_MODEL_H_ */ diff --git a/addressbook/demo/spec b/addressbook/demo/spec deleted file mode 100644 index 2d366ed75f..0000000000 --- a/addressbook/demo/spec +++ /dev/null @@ -1,12 +0,0 @@ - - - - 1 - 0 - 2 - 3 - - - - - diff --git a/addressbook/ename/Makefile.am b/addressbook/ename/Makefile.am deleted file mode 100644 index 17a542d9c5..0000000000 --- a/addressbook/ename/Makefile.am +++ /dev/null @@ -1,43 +0,0 @@ -INCLUDES = \ - -DGNOMELOCALEDIR=\""$(datadir)/locale"\" \ - -DG_LOG_DOMAIN=\"EName\" \ - -I$(srcdir) -I$(top_srcdir) \ - -I. \ - -I.. \ - -I$(top_builddir) \ - -I$(includedir) \ - $(GNOME_INCLUDEDIR) - -gnome_libs = \ - $(GNOME_LIBDIR) \ - $(GNOMEUI_LIBS) \ - $(GNOMEGNORBA_LIBS) \ - $(INTLLIBS) - -ename_libs = \ - libename.la \ - $(gnome_libs) - -lib_LTLIBRARIES = libename.la - -libename_la_SOURCES = \ - e-name-western.c - -libenameincludedir = $(includedir)/ename - -libenameinclude_HEADERS = \ - e-name-western.h - -noinst_PROGRAMS = \ - test-ename-western \ - test-ename-western-gtk - -test_ename_western_SOURCES = \ - test-ename-western.c - -test_ename_western_LDADD = $(ename_libs) - -test_ename_western_gtk_SOURCES = \ - test-ename-western-gtk.c - -test_ename_western_gtk_LDADD = $(ename_libs) $(gnome_libs) diff --git a/addressbook/ename/TODO b/addressbook/ename/TODO deleted file mode 100644 index 669661eea7..0000000000 --- a/addressbook/ename/TODO +++ /dev/null @@ -1,2 +0,0 @@ -* Support other naming systems. -* Handle misspelled suffixes better. diff --git a/addressbook/ename/e-name-western-tables.h b/addressbook/ename/e-name-western-tables.h deleted file mode 100644 index 369d530edc..0000000000 --- a/addressbook/ename/e-name-western-tables.h +++ /dev/null @@ -1,53 +0,0 @@ -#ifndef __E_NAME_WESTERN_TABLES_H__ -#define __E_NAME_WESTERN_TABLES_H__ - -char *e_name_western_pfx_table[] = { - - /* - * English. - */ - "mister", "miss.", "mr.", "mrs.", "ms.", - "miss", "mr", "mrs", "ms", "sir", - "professor", "prof.", "dr", "dr.", "doctor", - "reverend", "president", "judge", "senator", - "congressman", "congresswoman", - - "the honorable", "the reverend", "his holiness", - "his eminence", - - - /* - * French. - */ - "monsieur", "mr.", "mademoiselle", "melle.", - "madame", "mme.", "professeur", - - /* - * Spanish. - */ - "senor", "senora", "senorita", - - NULL}; - -char *e_name_western_sfx_table[] = { - - /* - * English. - */ - "junior", "senior", "jr", "sr", "I", "II", "III", "IV", "V", - "phd", "ms", "md", "esq", "esq.", "esquire", - - NULL}; - -char *e_name_western_twopart_sfx_table[] = { - - /* - * English. - */ - "the first", "the second", "the third", - - NULL}; - -char *e_name_western_complex_last_table[] = {"van", "von", "de", NULL}; - -#endif /* ! __E_NAME_WESTERN_TABLES_H__ */ diff --git a/addressbook/ename/e-name-western.h b/addressbook/ename/e-name-western.h deleted file mode 100644 index 695719b1c0..0000000000 --- a/addressbook/ename/e-name-western.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef __E_NAME_WESTERN_H__ -#define __E_NAME_WESTERN_H__ - -#include - -typedef struct { - - /* Public */ - char *prefix; - char *first; - char *middle; - char *nick; - char *last; - char *suffix; - - /* Private */ - char *full; -} ENameWestern; - -ENameWestern *e_name_western_parse (const char *full_name); -void e_name_western_free (ENameWestern *w); - -#endif /* ! __E_NAME_WESTERN_H__ */ diff --git a/addressbook/ename/test-ename-western-gtk.c b/addressbook/ename/test-ename-western-gtk.c deleted file mode 100644 index 15db38ce10..0000000000 --- a/addressbook/ename/test-ename-western-gtk.c +++ /dev/null @@ -1,148 +0,0 @@ -#include -#include - -ENameWestern *name; -GtkWidget *full; -GtkWidget *prefix; -GtkWidget *first; -GtkWidget *middle; -GtkWidget *nick; -GtkWidget *last; -GtkWidget *suffix; - -static void -fill_entries (void) -{ - -#define SET(a,b) (gtk_entry_set_text (GTK_ENTRY (a), (b) == NULL ? "" : (b))) - SET(prefix, name->prefix); - SET(first, name->first); - SET(middle, name->middle); - SET(nick, name->nick); - SET(last, name->last); - SET(suffix, name->suffix); -} - -static void -full_changed_cb (GtkEntry *fulle) -{ - e_name_western_free (name); - name = e_name_western_parse (gtk_entry_get_text (fulle)); - fill_entries (); -} - -static void -create_window (void) -{ - GtkWidget *app; - GtkTable *table; - - GtkWidget *prefix_label; - GtkWidget *first_label; - GtkWidget *middle_label; - GtkWidget *nick_label; - GtkWidget *last_label; - GtkWidget *suffix_label; - - app = gnome_app_new ("test", "Evolution Western Name Parser"); - - table = GTK_TABLE (gtk_table_new (3, 6, FALSE)); - - full = gtk_entry_new (); - prefix = gtk_entry_new (); - first = gtk_entry_new (); - middle = gtk_entry_new (); - nick = gtk_entry_new (); - last = gtk_entry_new (); - suffix = gtk_entry_new (); - - gtk_widget_set_usize (prefix, 100, 0); - gtk_widget_set_usize (first, 100, 0); - gtk_widget_set_usize (middle, 100, 0); - gtk_widget_set_usize (nick, 100, 0); - gtk_widget_set_usize (last, 100, 0); - gtk_widget_set_usize (suffix, 100, 0); - - gtk_table_attach (table, full, 0, 6, 0, 1, - GTK_EXPAND | GTK_FILL, 0, - 0, 0); - - gtk_table_attach (table, prefix, 0, 1, 1, 2, - GTK_EXPAND | GTK_FILL | GTK_SHRINK, 0, - 0, 0); - - gtk_table_attach (table, first, 1, 2, 1, 2, - GTK_EXPAND | GTK_FILL | GTK_SHRINK, 0, - 0, 0); - - gtk_table_attach (table, middle, 2, 3, 1, 2, - GTK_EXPAND | GTK_FILL | GTK_SHRINK, 0, - 0, 0); - - gtk_table_attach (table, nick, 3, 4, 1, 2, - GTK_EXPAND | GTK_FILL | GTK_SHRINK, 0, - 0, 0); - - gtk_table_attach (table, last, 4, 5, 1, 2, - GTK_EXPAND | GTK_FILL | GTK_SHRINK, 0, - 0, 0); - - gtk_table_attach (table, suffix, 5, 6, 1, 2, - GTK_EXPAND | GTK_FILL | GTK_SHRINK, 0, - 0, 0); - - prefix_label = gtk_label_new ("Prefix"); - first_label = gtk_label_new ("First"); - middle_label = gtk_label_new ("Middle"); - nick_label = gtk_label_new ("Nick"); - last_label = gtk_label_new ("Last"); - suffix_label = gtk_label_new ("Suffix"); - - gtk_table_attach (table, prefix_label, 0, 1, 2, 3, - GTK_SHRINK, 0, - 0, 0); - - gtk_table_attach (table, first_label, 1, 2, 2, 3, - GTK_SHRINK, 0, - 0, 0); - - gtk_table_attach (table, middle_label, 2, 3, 2, 3, - GTK_SHRINK, 0, - 0, 0); - - gtk_table_attach (table, nick_label, 3, 4, 2, 3, - GTK_SHRINK, 0, - 0, 0); - - gtk_table_attach (table, last_label, 4, 5, 2, 3, - GTK_SHRINK, 0, - 0, 0); - - gtk_table_attach (table, suffix_label, 5, 6, 2, 3, - GTK_SHRINK, 0, - 0, 0); - - gnome_app_set_contents (GNOME_APP (app), GTK_WIDGET (table)); - - gtk_widget_show_all (app); - - gtk_entry_set_text (GTK_ENTRY (full), - "The Honorable Doctor van Jacobsen, Albert Roderick \"The Clenched Fist\" Jr, MD, PhD, Esquire"); - - name = e_name_western_parse ("The Honorable Doctor van Jacobsen, Albert Roderick \"The Clenched Fist\" Jr, MD, PhD, Esquire"); - fill_entries (); - - gtk_signal_connect (GTK_OBJECT (full), "changed", full_changed_cb, NULL); -} - -int -main (int argc, char **argv) -{ - gnome_init ("Test EName", "Test EName", argc, argv); - - create_window (); - - gtk_main (); - - return 0; -} diff --git a/addressbook/ename/test-ename-western.c b/addressbook/ename/test-ename-western.c deleted file mode 100644 index 17ff91dbf2..0000000000 --- a/addressbook/ename/test-ename-western.c +++ /dev/null @@ -1,70 +0,0 @@ -#include -#include - -#include - -static void -do_name (char *n) -{ - ENameWestern *wname; - - wname = e_name_western_parse (n); - - printf ("Full Name: [%s]\n", n); - - printf ("Prefix: [%s]\n", wname->prefix); - printf ("First: [%s]\n", wname->first); - printf ("Middle: [%s]\n", wname->middle); - printf ("Nick: [%s]\n", wname->nick); - printf ("Last: [%s]\n", wname->last); - printf ("Suffix: [%s]\n", wname->suffix); - - printf ("\n"); - - e_name_western_free (wname); -} - -int -main (int argc, char **argv) -{ - if (argc == 2) { - while (! feof (stdin)) { - char s[256]; - - if (fgets (s, sizeof (s), stdin) == NULL) - return 0; - - g_strstrip (s); - - do_name (s); - } - - return 0; - } - - do_name ("Nat"); - do_name ("Karl Anders Carlsson"); - do_name ("Miguel de Icaza Amozorrutia"); - do_name ("The Honorable Doctor de Icaza, Miguel \"Sparky\" Junior, PhD, MD"); - do_name ("Nat Friedman MD, Phd"); - do_name ("Nat Friedman PhD"); - do_name ("Friedman, Nat"); - do_name ("Miguel de Icaza Esquire"); - do_name ("Dr Miguel \"Sparky\" de Icaza"); - do_name ("Robert H.B. Netzer"); - do_name ("W. Richard Stevens"); - do_name ("Nat Friedman"); - do_name ("N. Friedman"); - do_name ("Miguel de Icaza"); - do_name ("Drew Johnson"); - do_name ("President Bill \"Slick Willy\" Clinton"); - do_name ("The Honorable Mark J. Einstein Jr"); - do_name ("Friedman, Nat"); - do_name ("de Icaza, Miguel"); - do_name ("Mr de Icaza, Miguel"); - do_name ("Smith, John Jr"); - do_name ("Nick Glennie-Smith"); - do_name ("Dr von Johnson, Albert Roderick Jr"); - - return 0; -} diff --git a/addressbook/gui/.cvsignore b/addressbook/gui/.cvsignore deleted file mode 100644 index 09980ae6ba..0000000000 --- a/addressbook/gui/.cvsignore +++ /dev/null @@ -1,6 +0,0 @@ -.deps -.libs -Makefile -Makefile.in -*.lo -*.la diff --git a/addressbook/gui/Makefile.am b/addressbook/gui/Makefile.am deleted file mode 100644 index 50c258b544..0000000000 --- a/addressbook/gui/Makefile.am +++ /dev/null @@ -1 +0,0 @@ -SUBDIRS = minicard component \ No newline at end of file diff --git a/addressbook/gui/component/.cvsignore b/addressbook/gui/component/.cvsignore deleted file mode 100644 index a0427f184f..0000000000 --- a/addressbook/gui/component/.cvsignore +++ /dev/null @@ -1,8 +0,0 @@ -.deps -.libs -Makefile -Makefile.in -*.lo -*.la -evolution-addressbook -test-addressbook \ No newline at end of file diff --git a/addressbook/gui/component/Makefile.am b/addressbook/gui/component/Makefile.am deleted file mode 100644 index c20864912b..0000000000 --- a/addressbook/gui/component/Makefile.am +++ /dev/null @@ -1,39 +0,0 @@ -INCLUDES = \ - -DG_LOG_DOMAIN=\"evolution-addressbook\" \ - $(EXTRA_GNOME_CFLAGS) \ - $(GNOME_INCLUDEDIR) \ - -I$(top_srcdir) \ - -I$(top_srcdir)/widgets/e-text \ - -I$(top_srcdir)/addressbook/gui/minicard \ - -I$(top_srcdir)/addressbook/contact-editor \ - -I$(top_srcdir)/addressbook/backend \ - -I$(top_builddir)/addressbook/backend \ - $(BONOBO_HTML_GNOME_CFLAGS) \ - -DEVOLUTION_VERSION=\""$(VERSION)"\" \ - -DEVOLUTION_GLADEDIR=\""$(gladedir)"\" \ - -DEVOLUTION_ICONSDIR=\""$(iconsdir)"\" \ - -DEVOLUTION_LOCALEDIR=\""$(datadir)/locale"\" \ - -DCAMEL_PROVIDERDIR=\""$(providerdir)"\" - -bin_PROGRAMS = \ - evolution-addressbook - -evolution_addressbook_SOURCES = \ - addressbook-factory.c \ - addressbook.c \ - addressbook.h - -evolution_addressbook_LDADD = \ - $(EXTRA_GNOME_LIBS) \ - $(BONOBO_HTML_GNOME_LIBS) \ - $(top_builddir)/addressbook/gui/minicard/libeminicard.a \ - $(top_builddir)/widgets/e-text/libetext.a \ - $(top_builddir)/e-util/libeutil.la \ - $(top_builddir)/addressbook/backend/ebook/libebook.la \ - $(top_builddir)/addressbook/contact-editor/libecontacteditor.a \ - $(top_builddir)/libversit/libversit.la - -evolution_addressbook_LDFLAGS = `gnome-config --libs gdk_pixbuf` - -gnorbadir = $(sysconfdir)/CORBA/servers -gnorba_DATA = addressbook.gnorba diff --git a/addressbook/gui/component/addressbook-factory.c b/addressbook/gui/component/addressbook-factory.c deleted file mode 100644 index 83257b1189..0000000000 --- a/addressbook/gui/component/addressbook-factory.c +++ /dev/null @@ -1,49 +0,0 @@ -/** - * sample-control-factory.c - * - * Copyright 1999, Helix Code, Inc. - * - * Author: - * Nat Friedman (nat@nat.org) - * - */ - -#include -#include -#include -#include -#include -#include "addressbook.h" - -CORBA_Environment ev; -CORBA_ORB orb; - -static void -init_bonobo (int argc, char **argv) -{ - - gnome_CORBA_init_with_popt_table ( - "evolution-addressbook", "0.0", - &argc, argv, NULL, 0, NULL, GNORBA_INIT_SERVER_FUNC, &ev); - - orb = gnome_CORBA_ORB (); - - if (bonobo_init (orb, NULL, NULL) == FALSE) - g_error (_("Could not initialize Bonobo")); - - glade_gnome_init (); -} - -int -main (int argc, char **argv) -{ - CORBA_exception_init (&ev); - - init_bonobo (argc, argv); - - addressbook_factory_init (); - - bonobo_main (); - - return 0; -} diff --git a/addressbook/gui/component/addressbook.c b/addressbook/gui/component/addressbook.c deleted file mode 100644 index bb4b20406f..0000000000 --- a/addressbook/gui/component/addressbook.c +++ /dev/null @@ -1,462 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * addressbook.c: - * - * Author: - * Chris Lahey (clahey@helixcode.com) - * - * (C) 2000 Helix Code, Inc. - */ - -#include -#include -#include -#include - -#include "addressbook.h" - -#include -#include -#include "e-minicard-view.h" -#include "e-contact-editor.h" - -static void -control_deactivate (BonoboControl *control, BonoboUIHandler *uih) -{ - /* how to remove a menu item */ - bonobo_ui_handler_menu_remove (uih, "/Actions/New Contact"); - - /* remove our toolbar */ - bonobo_ui_handler_dock_remove (uih, "/Toolbar"); -} - -static void -do_nothing_cb (BonoboUIHandler *uih, void *user_data, const char *path) -{ - printf ("Yow! I am called back!\n"); -} - - -#define BLANK_VCARD \ -"BEGIN:VCARD -" \ -"FN: -" \ -"N: -" \ -"BDAY: -" \ -"TEL;WORK: -" \ -"TEL;CELL: -" \ -"EMAIL;INTERNET: -" \ -"EMAIL;INTERNET: -" \ -"ADR;WORK;POSTAL: -" \ -"ADR;HOME;POSTAL;INTL: -" \ -"END:VCARD -" \ -" -" - - -static void -card_added_cb (EBook* book, EBookStatus status, const char *id, - gpointer user_data) -{ - g_print ("%s: %s(): a card was added\n", __FILE__, __FUNCTION__); -} - -static void -new_contact_cb (BonoboUIHandler *uih, void *user_data, const char *path) -{ - gint result; - GtkWidget* contact_editor = - e_contact_editor_new(e_card_new("")); - EMinicardView *minicard_view = E_MINICARD_VIEW (user_data); - EBook *book; - - GtkWidget* dlg = gnome_dialog_new ("Contact Editor", "Save", "Cancel", NULL); - - gtk_object_get(GTK_OBJECT(minicard_view), "book", &book, NULL); - - g_assert (E_IS_BOOK (book)); - - gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (dlg)->vbox), - contact_editor, TRUE, TRUE, 0); - - gtk_widget_show_all (dlg); - - gnome_dialog_close_hides (GNOME_DIALOG (dlg), TRUE); - result = gnome_dialog_run_and_close (GNOME_DIALOG (dlg)); - - - /* If the user clicks "okay"...*/ - if (result == 0) { - ECard *card; - g_assert (contact_editor); - g_assert (GTK_IS_OBJECT (contact_editor)); - gtk_object_get(GTK_OBJECT(contact_editor), - "card", &card, - NULL); - - /* Add the card in the contact editor to our ebook */ - e_book_add_card ( - book, - card, - card_added_cb, - NULL); - } - -} - -static void -find_contact_cb (BonoboUIHandler *uih, void *user_data, const char *path) -{ - gint result; - GtkWidget* search_entry = gtk_entry_new(); - EMinicardView *minicard_view = E_MINICARD_VIEW (user_data); - gchar* search_text; - - GtkWidget* dlg = gnome_dialog_new ("Search Contacts", "Find", "Cancel", NULL); - - gtk_object_get (GTK_OBJECT(minicard_view), "query", &search_text, NULL); - gtk_entry_set_text(GTK_ENTRY(search_entry), search_text); - g_free (search_text); - - gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (dlg)->vbox), - search_entry, TRUE, TRUE, 0); - - gtk_widget_show_all (dlg); - - gnome_dialog_close_hides (GNOME_DIALOG (dlg), TRUE); - result = gnome_dialog_run_and_close (GNOME_DIALOG (dlg)); - - - /* If the user clicks "okay"...*/ - if (result == 0) { - search_text = gtk_entry_get_text(GTK_ENTRY(search_entry)); - gtk_object_set (GTK_OBJECT(minicard_view), "query", search_text, NULL); - } - -} - -static void -card_deleted_cb (EBook* book, EBookStatus status, gpointer user_data) -{ - g_print ("%s: %s(): a card was deleted\n", __FILE__, __FUNCTION__); -} - -static void -delete_contact_cb (BonoboUIHandler *uih, void *user_data, const char *path) -{ - EMinicardView *minicard_view = E_MINICARD_VIEW (user_data); - - e_minicard_view_remove_selection (minicard_view, card_deleted_cb, NULL); -} - -static GnomeUIInfo gnome_toolbar [] = { - GNOMEUIINFO_ITEM_STOCK (N_("New"), N_("Create a new contact"), new_contact_cb, GNOME_STOCK_PIXMAP_NEW), - - GNOMEUIINFO_SEPARATOR, - - GNOMEUIINFO_ITEM_STOCK (N_("Find"), N_("Find a contact"), find_contact_cb, GNOME_STOCK_PIXMAP_SEARCH), - GNOMEUIINFO_ITEM_STOCK (N_("Print"), N_("Print contacts"), do_nothing_cb, GNOME_STOCK_PIXMAP_PRINT), - GNOMEUIINFO_ITEM_STOCK (N_("Delete"), N_("Delete a contact"), delete_contact_cb, GNOME_STOCK_PIXMAP_TRASH), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_END -}; - -static void -search_entry_activated (GtkWidget* widget, EMinicardView* minicard_view) -{ - char* search_word = gtk_entry_get_text(GTK_ENTRY(widget)); - char* search_query; - - if (search_word && strlen (search_word)) - search_query = g_strdup_printf ( - "(contains \"full_name\" \"%s\")", - search_word); - else - search_query = g_strdup ( - "(contains \"full_name\" \"\")"); - - gtk_object_set (GTK_OBJECT(minicard_view), "query", - search_query, NULL); - g_free (search_query); -} - -static GtkWidget* -make_quick_search_widget (GtkSignalFunc start_search_func, - gpointer user_data_for_search) -{ - GtkWidget *search_vbox = gtk_vbox_new (FALSE, 0); - GtkWidget *search_entry = gtk_entry_new (); - - if (start_search_func) - { - gtk_signal_connect (GTK_OBJECT (search_entry), "activate", - (GtkSignalFunc) search_entry_activated, - user_data_for_search); - } - - /* add the search entry to the our search_vbox */ - gtk_box_pack_start (GTK_BOX (search_vbox), search_entry, - FALSE, TRUE, 3); - gtk_box_pack_start (GTK_BOX (search_vbox), - gtk_label_new("Quick Search"), - FALSE, TRUE, 0); - - return search_vbox; -} - - -static void -control_activate (BonoboControl *control, BonoboUIHandler *uih, - EMinicardView *minicard_view) -{ - Bonobo_UIHandler remote_uih; - GtkWidget *toolbar; - BonoboControl *toolbar_control; - GtkWidget *hbox = gtk_hbox_new (FALSE, 0); - GtkWidget *quick_search_widget; - - remote_uih = bonobo_control_get_remote_ui_handler (control); - bonobo_ui_handler_set_container (uih, remote_uih); - - bonobo_ui_handler_menu_new_item (uih, "/Actions/New Contact", - N_("_New Contact"), - NULL, -1, - BONOBO_UI_HANDLER_PIXMAP_NONE, NULL, - 0, 0, new_contact_cb, - (gpointer)minicard_view); - - toolbar = gtk_toolbar_new (GTK_ORIENTATION_HORIZONTAL, - GTK_TOOLBAR_BOTH); - - gnome_app_fill_toolbar_with_data (GTK_TOOLBAR (toolbar), - gnome_toolbar, - NULL, minicard_view); - - gtk_box_pack_start (GTK_BOX (hbox), toolbar, FALSE, TRUE, 0); - - - /* add the search_vbox to the hbox which will be our toolbar */ - quick_search_widget = make_quick_search_widget ( - search_entry_activated, minicard_view); - - gtk_box_pack_start (GTK_BOX (hbox), - quick_search_widget, - FALSE, TRUE, 0); - - gtk_widget_show_all (hbox); - - toolbar_control = bonobo_control_new (hbox); - bonobo_ui_handler_dock_add ( - uih, "/Toolbar", - bonobo_object_corba_objref (BONOBO_OBJECT (toolbar_control)), - GNOME_DOCK_ITEM_BEH_LOCKED | - GNOME_DOCK_ITEM_BEH_EXCLUSIVE, - GNOME_DOCK_TOP, - 1, 1, 0); -} - -static void -control_activate_cb (BonoboControl *control, - gboolean activate, - EMinicardView* minicard_view) -{ - BonoboUIHandler *uih; - - uih = bonobo_control_get_ui_handler (control); - g_assert (uih); - - if (activate) - control_activate (control, uih, minicard_view); - else - control_deactivate (control, uih); -} - -typedef struct { - GtkWidget *canvas; - GnomeCanvasItem *view; - GnomeCanvasItem *rect; - GtkAllocation last_alloc; -} AddressbookView; - -static void -book_open_cb (EBook *book, EBookStatus status, gpointer closure) -{ - AddressbookView *view = closure; - if (status == E_BOOK_STATUS_SUCCESS) - gnome_canvas_item_set(view->view, - "book", book, - NULL); -} - -static EBook * -ebook_create (AddressbookView *view) -{ - EBook *book; - - book = e_book_new (); - - if (!book) { - printf ("%s: %s(): Couldn't create EBook, bailing.\n", - __FILE__, - __FUNCTION__); - return NULL; - } - - - - if (! e_book_load_uri (book, "file:/tmp/test.db", book_open_cb, view)) - { - printf ("error calling load_uri!\n"); - } - - - return book; -} - -static void destroy_callback(GtkWidget *widget, gpointer data) -{ - AddressbookView *view = data; - g_free(view); -} - -static void allocate_callback(GtkWidget *canvas, GtkAllocation *allocation, gpointer data) -{ - double width; - AddressbookView *view = data; - view->last_alloc = *allocation; - gnome_canvas_item_set( view->view, - "height", (double) allocation->height, - NULL ); - gnome_canvas_item_set( view->view, - "minimum_width", (double) allocation->width, - NULL ); - gtk_object_get(GTK_OBJECT(view->view), - "width", &width, - NULL); - width = MAX(width, allocation->width); - gnome_canvas_set_scroll_region(GNOME_CANVAS( view->canvas ), 0, 0, width, allocation->height ); - gnome_canvas_item_set( view->rect, - "x2", (double) width, - "y2", (double) allocation->height, - NULL ); -} - -static void resize(GnomeCanvas *canvas, gpointer data) -{ - double width; - AddressbookView *view = data; - gtk_object_get(GTK_OBJECT(view->view), - "width", &width, - NULL); - width = MAX(width, view->last_alloc.width); - gnome_canvas_set_scroll_region(GNOME_CANVAS(view->canvas), 0, 0, width, view->last_alloc.height ); - gnome_canvas_item_set( view->rect, - "x2", (double) width, - "y2", (double) view->last_alloc.height, - NULL ); -} - -static BonoboObject * -addressbook_factory (BonoboGenericFactory *Factory, void *closure) -{ - BonoboControl *control; - EBook *book; - GtkWidget *vbox, *scrollbar; - AddressbookView *view; - - gtk_widget_push_visual (gdk_rgb_get_visual ()); - gtk_widget_push_colormap (gdk_rgb_get_cmap ()); - - view = g_new (AddressbookView, 1); - - vbox = gtk_vbox_new(FALSE, 0); - - view->canvas = e_canvas_new(); - view->rect = gnome_canvas_item_new( - gnome_canvas_root( GNOME_CANVAS( view->canvas ) ), - gnome_canvas_rect_get_type(), - "x1", (double) 0, - "y1", (double) 0, - "x2", (double) 100, - "y2", (double) 100, - "fill_color", "white", - NULL ); - - view->view = gnome_canvas_item_new( - gnome_canvas_root( GNOME_CANVAS( view->canvas ) ), - e_minicard_view_get_type(), - "height", (double) 100, - "minimum_width", (double) 100, - NULL ); - - gtk_signal_connect( GTK_OBJECT( view->canvas ), "reflow", - GTK_SIGNAL_FUNC( resize ), - view); - - gnome_canvas_set_scroll_region ( GNOME_CANVAS( view->canvas ), - 0, 0, - 100, 100 ); - - gtk_box_pack_start(GTK_BOX(vbox), view->canvas, TRUE, TRUE, 0); - - scrollbar = gtk_hscrollbar_new( - gtk_layout_get_hadjustment(GTK_LAYOUT(view->canvas))); - - gtk_box_pack_start(GTK_BOX(vbox), scrollbar, FALSE, FALSE, 0); - - /* Connect the signals */ - gtk_signal_connect( GTK_OBJECT( vbox ), "destroy", - GTK_SIGNAL_FUNC( destroy_callback ), - ( gpointer ) view ); - - gtk_signal_connect( GTK_OBJECT( view->canvas ), "size_allocate", - GTK_SIGNAL_FUNC( allocate_callback ), - ( gpointer ) view ); - - gtk_widget_show_all( vbox ); -#if 0 - gdk_window_set_back_pixmap( - GTK_LAYOUT(view->canvas)->bin_window, NULL, FALSE); -#endif - - book = ebook_create(view); - - /* Create the control. */ - control = bonobo_control_new(vbox); - - gtk_signal_connect (GTK_OBJECT (control), "activate", - control_activate_cb, view->view); - - gtk_widget_pop_visual (); - gtk_widget_pop_colormap (); - - return BONOBO_OBJECT (control); -} - -void -addressbook_factory_init (void) -{ - static BonoboGenericFactory *addressbook_control_factory = NULL; - - if (addressbook_control_factory != NULL) - return; - - addressbook_control_factory = - bonobo_generic_factory_new ( - "control-factory:addressbook", - addressbook_factory, NULL); - - if (addressbook_control_factory == NULL) { - g_error ("I could not register a Addressbook factory."); - } -} diff --git a/addressbook/gui/component/addressbook.gnorba b/addressbook/gui/component/addressbook.gnorba deleted file mode 100644 index 7114b1c332..0000000000 --- a/addressbook/gui/component/addressbook.gnorba +++ /dev/null @@ -1,11 +0,0 @@ -[control-factory:addressbook] -type=exe -repo_id=IDL:GNOME/GenericFactory:1.0 -description=Factory for the sample Addressbook control -location_info=evolution-addressbook - -[control:addressbook] -type=factory -repo_id=IDL:BonoboControl/addressbook-control:1.0 IDL:GNOME/Control:1.0 -description=A sample Bonobo control which displays an addressbook. -location_info=control-factory:addressbook diff --git a/addressbook/gui/component/addressbook.h b/addressbook/gui/component/addressbook.h deleted file mode 100644 index e9289128a6..0000000000 --- a/addressbook/gui/component/addressbook.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef __ADDRESSBOOK_H__ -#define __ADDRESSBOOK_H__ - -#include - -void addressbook_factory_init (void); - -#endif /* __ADDRESSBOOK_H__ */ diff --git a/addressbook/gui/contact-editor/.cvsignore b/addressbook/gui/contact-editor/.cvsignore deleted file mode 100644 index 1771e82554..0000000000 --- a/addressbook/gui/contact-editor/.cvsignore +++ /dev/null @@ -1,7 +0,0 @@ -.deps -.libs -Makefile -Makefile.in -*.lo -*.la -contact-editor-test \ No newline at end of file diff --git a/addressbook/gui/contact-editor/Makefile.am b/addressbook/gui/contact-editor/Makefile.am deleted file mode 100644 index 0a8b3a8489..0000000000 --- a/addressbook/gui/contact-editor/Makefile.am +++ /dev/null @@ -1,44 +0,0 @@ -imagesdir = $(datadir)/images/evolution -images = email.png head.png phone.png snailmail.png web.png arrow.png briefcase.png netmeeting.png netfreebusy.png - -EXTRA_DIST = $(images) -pkgdata_DATA = $(images) - -CPPFLAGS = \ - -DEVOLUTION_GLADEDIR=\""$(gladedir)"\" \ - -DDATADIR=\""$(datadir)"\" - -INCLUDES = \ - $(GNOME_INCLUDEDIR) \ - -I$(top_srcdir) \ - -I$(top_srcdir)/addressbook/ \ - -I$(top_srcdir)/addressbook/backend \ - -DEVOLUTION_IMAGES=\""$(imagesdir)"\" \ - -DG_LOG_DOMAIN=\"contact-editor\" - -noinst_LIBRARIES = \ - libecontacteditor.a - -libecontacteditor_a_SOURCES = \ - e-contact-editor.c \ - e-contact-editor.h - -noinst_PROGRAMS = \ - contact-editor-test - -contact_editor_test_SOURCES = \ - test-editor.c - -contact_editor_test_LDADD = \ - $(top_builddir)/addressbook/backend/ebook/libebook.la \ - $(top_builddir)/libversit/libversit.la \ - $(GNOMEGNORBA_LIBS) \ - -lbonobo \ - $(top_builddir)/e-util/libeutil.la \ - libecontacteditor.a \ - $(EXTRA_GNOME_LIBS) - -gladedir = $(datadir)/evolution/glade - -glade_DATA = \ - contact-editor.glade diff --git a/addressbook/gui/contact-editor/arrow.png b/addressbook/gui/contact-editor/arrow.png deleted file mode 100644 index b7f782c1e5..0000000000 Binary files a/addressbook/gui/contact-editor/arrow.png and /dev/null differ diff --git a/addressbook/gui/contact-editor/briefcase.png b/addressbook/gui/contact-editor/briefcase.png deleted file mode 100644 index dd59b8fd39..0000000000 Binary files a/addressbook/gui/contact-editor/briefcase.png and /dev/null differ diff --git a/addressbook/gui/contact-editor/contact-editor.glade b/addressbook/gui/contact-editor/contact-editor.glade deleted file mode 100644 index e97c6999dd..0000000000 --- a/addressbook/gui/contact-editor/contact-editor.glade +++ /dev/null @@ -1,2205 +0,0 @@ - - - - - Contact-editor - contact-editor - - src - pixmaps - C - True - True - True - False - False - False - False - True - e-contact-editor-strings.h - - - - GtkWindow - contact editor - False - Contact Editor - GTK_WINDOW_TOPLEVEL - GTK_WIN_POS_NONE - False - False - True - False - - - GtkNotebook - notebook-contact-editor - True - True - True - GTK_POS_TOP - False - 2 - 2 - False - - - GtkTable - table-contact-editor-general - 7 - 12 - 8 - False - 4 - 4 - - - GtkEntry - entry-phone1 - True - True - True - 0 - - - 7 - 8 - 0 - 1 - 0 - 0 - True - False - False - False - True - False - - - - - GtkEntry - entry-phone2 - True - True - True - 0 - - - 7 - 8 - 1 - 2 - 0 - 0 - True - False - False - False - True - False - - - - - GtkEntry - entry-phone3 - True - True - True - 0 - - - 7 - 8 - 2 - 3 - 0 - 0 - True - False - False - False - True - False - - - - - GtkEntry - entry-phone4 - True - True - True - 0 - - - 7 - 8 - 3 - 4 - 0 - 0 - True - False - False - False - True - False - - - - - GtkEntry - entry-fullname - True - True - True - 0 - - - 3 - 4 - 0 - 1 - 0 - 0 - True - False - False - False - True - False - - - - - GtkEntry - entry-web - True - True - True - 0 - - - 3 - 4 - 8 - 9 - 0 - 0 - True - False - False - False - True - False - - - - - GtkLabel - label-phone3 - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - - 5 - 6 - 2 - 3 - 0 - 0 - False - False - False - False - True - True - - - - - GtkLabel - label-phone2 - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - - 5 - 6 - 1 - 2 - 0 - 0 - False - False - False - False - True - True - - - - - GtkLabel - label-phone1 - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - - 5 - 6 - 0 - 1 - 0 - 0 - False - False - False - False - True - True - - - - - GtkLabel - label-phone4 - - GTK_JUSTIFY_LEFT - False - 0 - 0.5 - 0 - 0 - - 5 - 6 - 3 - 4 - 0 - 0 - False - False - False - False - True - True - - - - - GtkText - text-address - 1 - 1 - True - True - - - 7 - 8 - 5 - 9 - 0 - 0 - True - False - False - False - True - True - - - - - GtkLabel - label-email1 - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - - 1 - 2 - 5 - 6 - 0 - 0 - False - False - False - False - True - True - - - - - GtkButton - button-fullname - True - - - 1 - 3 - 0 - 1 - 0 - 0 - False - False - False - False - True - True - - - - - GtkAccelLabel - accellabel-jobtitle - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - - 1 - 3 - 1 - 2 - 0 - 0 - False - False - False - False - True - True - - - - - GtkAccelLabel - accellabel-company - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - - 1 - 3 - 2 - 3 - 0 - 0 - False - False - False - False - True - True - - - - - GtkAccelLabel - accellabel-fileas - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - - 1 - 3 - 3 - 4 - 0 - 0 - False - False - False - False - True - True - - - - - GtkAccelLabel - accellabel-web - - GTK_JUSTIFY_LEFT - False - 0 - 0.5 - 0 - 0 - - 1 - 3 - 8 - 9 - 0 - 0 - False - False - False - False - True - True - - - - - GtkHBox - hbox5 - False - 0 - - 0 - 8 - 10 - 11 - 0 - 0 - True - True - False - False - True - True - - - - GtkText - text-comments - True - True - - - 0 - True - True - - - - - GtkVScrollbar - vscrollbar-comments - GTK_UPDATE_CONTINUOUS - 0 - 0 - 0 - 0 - 0 - 0 - - 0 - False - False - - - - - - GtkHBox - hbox3 - False - 6 - - 0 - 8 - 11 - 12 - 0 - 0 - True - False - False - False - True - True - - - - GtkButton - button-contacts - True - - - 0 - False - False - - - - - GtkEntry - entry-contacts - True - True - True - 0 - - - 0 - True - True - - - - - GtkButton - button-categories - True - - - 0 - False - False - - - - - GtkEntry - entry-categories - True - True - True - 0 - - - 0 - False - False - - - - - - GtkAlignment - alignment2 - 0 - 0 - 0 - 0 - - 7 - 8 - 9 - 10 - 0 - 0 - True - False - False - False - True - True - - - - GtkCheckButton - checkbutton-mailingaddress - True - - False - True - - - - - GtkButton - button-address - True - - - 5 - 7 - 5 - 6 - 0 - 0 - False - False - False - False - True - True - - - - - GtkEntry - entry-jobtitle - True - True - True - 0 - - - 3 - 4 - 1 - 2 - 0 - 0 - True - False - False - False - True - False - - - - - GtkEntry - entry-company - True - True - True - 0 - - - 3 - 4 - 2 - 3 - 0 - 0 - True - False - False - False - True - False - - - - - GtkCombo - combo-fileas - True - False - True - True - True - False - - - 3 - 4 - 3 - 4 - 0 - 0 - True - False - False - False - True - False - - - - GtkEntry - GtkCombo:entry - entry-fileas - True - True - True - 0 - - - - - - GtkHBox - hbox4 - False - 4 - - 3 - 4 - 5 - 6 - 0 - 0 - True - False - False - False - True - False - - - - GtkEntry - entry-email1 - True - True - True - 0 - - - 0 - True - True - - - - - GtkButton - button23 - - 0 - False - False - - - - Placeholder - - - - - - GtkAlignment - alignment3 - 1 - 0.5 - 0 - 1 - - 2 - 3 - 5 - 6 - 0 - 0 - False - False - False - False - True - True - - - - GtkButton - button-email1 - - - Placeholder - - - - - - GtkAlignment - alignment4 - 1 - 0.5 - 0 - 1 - - 6 - 7 - 6 - 7 - 0 - 0 - False - False - False - False - True - True - - - - GtkButton - button-address1 - - - Placeholder - - - - - - GtkAlignment - alignment5 - 1 - 0.5 - 0 - 0 - - 6 - 7 - 3 - 4 - 0 - 0 - False - False - False - False - True - True - - - - GtkButton - button-phone4 - - - Placeholder - - - - - - GtkAlignment - alignment7 - 1 - 0.5 - 0 - 0 - - 6 - 7 - 1 - 2 - 0 - 0 - False - False - False - False - True - True - - - - GtkButton - button-phone2 - - - Placeholder - - - - - - GtkAlignment - alignment8 - 1 - 0.5 - 0 - 0 - - 6 - 7 - 0 - 1 - 0 - 0 - False - False - False - False - True - True - - - - GtkButton - button-phone1 - - - Placeholder - - - - - - GtkLabel - label-address1 - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - - 5 - 6 - 6 - 7 - 0 - 0 - False - False - False - False - True - True - - - - - GtkHSeparator - hseparator6 - - 0 - 4 - 7 - 8 - 0 - 2 - True - False - False - False - True - True - - - - - GtkHSeparator - hseparator4 - - 4 - 8 - 4 - 5 - 0 - 2 - True - False - False - False - True - False - - - - - GtkHSeparator - hseparator5 - - 0 - 4 - 4 - 5 - 0 - 2 - True - False - False - False - True - False - - - - - GtkAlignment - alignment6 - 1 - 0.5 - 0 - 0 - - 6 - 7 - 2 - 3 - 0 - 0 - False - False - False - False - True - True - - - - GtkButton - button-phone3 - - - Placeholder - - - - - - - GtkLabel - Notebook:tab - label15 - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 0 - 0 - - - - GtkTable - table-contact-editor-details - 7 - 12 - 6 - False - 4 - 4 - - - GtkLabel - label21 - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - - 1 - 2 - 0 - 1 - 0 - 0 - False - False - False - False - True - True - - - - - GtkLabel - label22 - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - - 1 - 2 - 1 - 2 - 0 - 0 - False - False - False - False - True - True - - - - - GtkLabel - label23 - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - - 1 - 2 - 2 - 3 - 0 - 0 - False - False - False - False - True - True - - - - - GtkLabel - label24 - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - - 1 - 2 - 4 - 5 - 0 - 0 - False - False - False - False - True - True - - - - - GtkLabel - label25 - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - - 1 - 2 - 5 - 6 - 0 - 0 - False - False - False - False - True - True - - - - - GtkLabel - label26 - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - - 1 - 2 - 7 - 8 - 0 - 0 - False - False - False - False - True - True - - - - - GtkLabel - label27 - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - - 1 - 2 - 8 - 9 - 0 - 0 - False - False - False - False - True - True - - - - - GtkLabel - label28 - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - - 1 - 2 - 10 - 11 - 0 - 0 - False - False - False - False - True - True - - - - - GtkLabel - label31 - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - - 3 - 4 - 4 - 5 - 0 - 0 - False - False - False - False - True - True - - - - - GtkLabel - label30 - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - - 3 - 4 - 1 - 2 - 0 - 0 - False - False - False - False - True - True - - - - - GtkLabel - label29 - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - - 3 - 4 - 0 - 1 - 0 - 0 - False - False - False - False - True - True - - - - - GtkLabel - label32 - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - - 3 - 4 - 5 - 6 - 0 - 0 - False - False - False - False - True - True - - - - - GtkEntry - entry4 - True - True - True - 0 - - - 2 - 3 - 5 - 6 - 0 - 0 - True - False - False - False - True - False - - - - - GtkEntry - entry-department - True - True - True - 0 - - - 2 - 3 - 0 - 1 - 0 - 0 - True - False - False - False - True - False - - - - - GtkEntry - entry-office - True - True - True - 0 - - - 2 - 3 - 1 - 2 - 0 - 0 - True - False - False - False - True - False - - - - - GtkEntry - entry-profession - True - True - True - 0 - - - 2 - 3 - 2 - 3 - 0 - 0 - True - False - False - False - True - False - - - - - GtkEntry - entry-nickname - True - True - True - 0 - - - 2 - 3 - 4 - 5 - 0 - 0 - True - False - False - False - True - False - - - - - GtkEntry - entry9 - True - True - True - 0 - - - 2 - 6 - 7 - 8 - 0 - 0 - True - False - False - False - True - False - - - - - GtkEntry - entry10 - True - True - True - 0 - - - 2 - 5 - 8 - 9 - 0 - 0 - True - False - False - False - True - False - - - - - GtkEntry - entry-fburl - True - True - True - 0 - - - 2 - 6 - 10 - 11 - 0 - 0 - True - False - False - False - True - False - - - - - GnomeDateEdit - dateedit-anniversary - False - False - False - 7 - 19 - - 4 - 6 - 5 - 6 - 0 - 0 - True - False - False - False - True - False - - - - - GnomeDateEdit - dateedit-birthday - False - False - False - 7 - 19 - - 4 - 6 - 4 - 5 - 0 - 0 - True - False - False - False - True - False - - - - - GtkEntry - entry13 - True - True - True - 0 - - - 4 - 6 - 1 - 2 - 0 - 0 - True - False - False - False - True - False - - - - - GtkEntry - entry12 - True - True - True - 0 - - - 4 - 6 - 0 - 1 - 0 - 0 - True - False - False - False - True - False - - - - - GtkButton - button-callnow - True - - - 5 - 6 - 8 - 9 - 0 - 0 - False - False - False - False - True - True - - - - - GtkHBox - hbox7 - False - 6 - - 0 - 6 - 9 - 10 - 0 - 0 - True - False - False - False - True - True - - - - GtkLabel - label33 - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 0 - 2 - - 0 - False - False - - - - - GtkHSeparator - hseparator8 - - 0 - True - True - - - - - - GtkHBox - hbox8 - False - 6 - - 0 - 6 - 6 - 7 - 0 - 0 - True - False - False - False - True - True - - - - GtkLabel - label34 - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 0 - 2 - - 0 - False - False - - - - - GtkHSeparator - hseparator9 - - 0 - True - True - - - - - - GtkHSeparator - hseparator7 - - 0 - 6 - 3 - 4 - 0 - 2 - False - False - False - False - True - True - - - - - - GtkLabel - Notebook:tab - label16 - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 0 - 0 - - - - GtkText - text3 - True - False - - - - - GtkLabel - Notebook:tab - label17 - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 0 - 0 - - - - GtkText - text2 - True - False - - - - - GtkLabel - Notebook:tab - label18 - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 0 - 0 - - - - GtkText - text4 - True - False - - - - - GtkLabel - Notebook:tab - label19 - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 0 - 0 - - - - - - GnomeDialog - dialog2 - False - GTK_WINDOW_TOPLEVEL - GTK_WIN_POS_NONE - False - False - False - False - False - False - - - GtkVBox - GnomeDialog:vbox - dialog-vbox2 - False - 8 - - 4 - True - True - - - - GtkHButtonBox - GnomeDialog:action_area - dialog-action_area2 - GTK_BUTTONBOX_END - 8 - 85 - 27 - 7 - 0 - - 0 - False - True - GTK_PACK_END - - - - GtkButton - button28 - True - True - GNOME_STOCK_BUTTON_OK - - - - GtkButton - button29 - True - True - GNOME_STOCK_BUTTON_APPLY - - - - GtkButton - button30 - True - True - GNOME_STOCK_BUTTON_CANCEL - - - - - GtkTable - table2 - 2 - 2 - False - 0 - 0 - - 0 - True - True - - - - GtkEntry - entry2 - True - True - True - 0 - - - 0 - 2 - 1 - 2 - 0 - 0 - True - False - False - False - True - False - - - - - GtkVBox - vbox1 - False - 0 - - 1 - 2 - 0 - 1 - 0 - 0 - False - True - False - False - True - True - - - - GtkButton - button31 - True - - - 0 - False - False - - - - - GtkButton - button32 - True - - - 0 - False - False - - - - - - GtkScrolledWindow - scrolledwindow1 - 200 - GTK_POLICY_ALWAYS - GTK_POLICY_ALWAYS - GTK_UPDATE_CONTINUOUS - GTK_UPDATE_CONTINUOUS - - 0 - 1 - 0 - 1 - 0 - 0 - True - True - False - False - True - True - - - - GtkCList - clist1 - True - 1 - 80 - GTK_SELECTION_SINGLE - True - GTK_SHADOW_NONE - - - GtkLabel - CList:title - label20 - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 0 - 0 - - - - - - - - - GnomeDialog - dialog-add-phone - False - New phone type - GTK_WINDOW_TOPLEVEL - GTK_WIN_POS_NONE - False - False - False - False - False - False - - - GtkVBox - GnomeDialog:vbox - vbox2 - False - 8 - - 4 - True - True - - - - GtkHButtonBox - GnomeDialog:action_area - hbuttonbox1 - GTK_BUTTONBOX_END - 8 - 85 - 27 - 7 - 0 - - 0 - False - True - GTK_PACK_END - - - - GtkButton - button43 - True - True - - GNOME_STOCK_PIXMAP_ADD - - - - GtkButton - button44 - True - True - GNOME_STOCK_BUTTON_CANCEL - - - - - GtkFrame - frame-add-phone - 4 - - 0 - GTK_SHADOW_ETCHED_IN - - 0 - True - True - - - - GtkAlignment - alignment9 - 9 - 0.5 - 0.5 - 1 - 1 - - - GtkEntry - entry-add-phone - True - True - True - 0 - - - - - - - - diff --git a/addressbook/gui/contact-editor/e-contact-editor-strings.h b/addressbook/gui/contact-editor/e-contact-editor-strings.h deleted file mode 100644 index b0795c166b..0000000000 --- a/addressbook/gui/contact-editor/e-contact-editor-strings.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Translatable strings file generated by Glade. - * Add this file to your project's POTFILES.in. - * DO NOT compile it as part of your application. - */ - -gchar *s = N_("Contact Editor"); -gchar *s = N_("Business Fax"); -gchar *s = N_("Home"); -gchar *s = N_("Business"); -gchar *s = N_("Mobile"); -gchar *s = N_("Email"); -gchar *s = N_("\tFull Name..."); -gchar *s = N_("Job Title:"); -gchar *s = N_("Company:"); -gchar *s = N_("File As:"); -gchar *s = N_("Web page address:"); -gchar *s = N_("Contacts..."); -gchar *s = N_("Categories..."); -gchar *s = N_("This is the mailing address"); -gchar *s = N_("A_ddress..."); -gchar *s = N_("Business"); -gchar *s = N_("General"); -gchar *s = N_("Department:"); -gchar *s = N_("Office:"); -gchar *s = N_("Profession:"); -gchar *s = N_("Nickname:"); -gchar *s = N_("Spouse's name:"); -gchar *s = N_("Directory Server:"); -gchar *s = N_("Email alias:"); -gchar *s = N_("Address:"); -gchar *s = N_("Birthday:"); -gchar *s = N_("Assistant's name:"); -gchar *s = N_("Manager's name:"); -gchar *s = N_("Anniversary:"); -gchar *s = N_("Call Now"); -gchar *s = N_("Internet Free-Busy"); -gchar *s = N_("Online NetMeeting settings"); -gchar *s = N_("Details"); -gchar *s = N_("Activities"); -gchar *s = N_("Certificates"); -gchar *s = N_("All Fields"); -gchar *s = N_("Add"); -gchar *s = N_("Delete"); -gchar *s = N_("Phone Types"); -gchar *s = N_("New phone type"); -gchar *s = N_("Add"); -gchar *s = N_("New phone type"); diff --git a/addressbook/gui/contact-editor/e-contact-editor.c b/addressbook/gui/contact-editor/e-contact-editor.c deleted file mode 100644 index 5067b4ff25..0000000000 --- a/addressbook/gui/contact-editor/e-contact-editor.c +++ /dev/null @@ -1,906 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * e-contact-editor.c - * Copyright (C) 2000 Helix Code, Inc. - * Author: Chris Lahey - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include -#include -#include "e-contact-editor.h" - -static void e_contact_editor_init (EContactEditor *card); -static void e_contact_editor_class_init (EContactEditorClass *klass); -static void e_contact_editor_set_arg (GtkObject *o, GtkArg *arg, guint arg_id); -static void e_contact_editor_get_arg (GtkObject *object, GtkArg *arg, guint arg_id); -static void e_contact_editor_destroy (GtkObject *object); - -static GtkWidget *e_contact_editor_build_dialog(EContactEditor *editor, gchar *entry_id, gchar *label_id, gchar *title, GList **list, GnomeUIInfo **info); -static void _email_arrow_pressed (GtkWidget *widget, GdkEventButton *button, EContactEditor *editor); -static void _phone_arrow_pressed (GtkWidget *widget, GdkEventButton *button, EContactEditor *editor); -static void _address_arrow_pressed (GtkWidget *widget, GdkEventButton *button, EContactEditor *editor); -static void fill_in_info(EContactEditor *editor); -static void extract_info(EContactEditor *editor); - -static GtkVBoxClass *parent_class = NULL; - -#if 0 -enum { - E_CONTACT_EDITOR_RESIZE, - E_CONTACT_EDITOR_LAST_SIGNAL -}; - -static guint e_contact_editor_signals[E_CONTACT_EDITOR_LAST_SIGNAL] = { 0 }; -#endif - -/* The arguments we take */ -enum { - ARG_0, - ARG_CARD -}; - -enum { - DYNAMIC_LIST_EMAIL, - DYNAMIC_LIST_PHONE, - DYNAMIC_LIST_ADDRESS -}; - -GtkType -e_contact_editor_get_type (void) -{ - static GtkType contact_editor_type = 0; - - if (!contact_editor_type) - { - static const GtkTypeInfo contact_editor_info = - { - "EContactEditor", - sizeof (EContactEditor), - sizeof (EContactEditorClass), - (GtkClassInitFunc) e_contact_editor_class_init, - (GtkObjectInitFunc) e_contact_editor_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - contact_editor_type = gtk_type_unique (gtk_vbox_get_type (), &contact_editor_info); - } - - return contact_editor_type; -} - -static void -e_contact_editor_class_init (EContactEditorClass *klass) -{ - GtkObjectClass *object_class; - GtkVBoxClass *vbox_class; - - object_class = (GtkObjectClass*) klass; - vbox_class = (GtkVBoxClass *) klass; - - parent_class = gtk_type_class (gtk_vbox_get_type ()); - -#if 0 - e_contact_editor_signals[E_CONTACT_EDITOR_RESIZE] = - gtk_signal_new ("resize", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (EContactEditorClass, resize), - gtk_marshal_NONE__NONE, - GTK_TYPE_NONE, 0); - - - gtk_object_class_add_signals (object_class, e_contact_editor_signals, E_CONTACT_EDITOR_LAST_SIGNAL); -#endif - - gtk_object_add_arg_type ("EContactEditor::card", GTK_TYPE_OBJECT, - GTK_ARG_READWRITE, ARG_CARD); - - object_class->set_arg = e_contact_editor_set_arg; - object_class->get_arg = e_contact_editor_get_arg; - object_class->destroy = e_contact_editor_destroy; -} - -static void -_add_image(GtkTable *table, gchar *image, int left, int right, int top, int bottom) -{ - gtk_table_attach(table, - gtk_widget_new(gtk_alignment_get_type(), - "child", gnome_pixmap_new_from_file(image), - "xalign", (double) 0, - "yalign", (double) 0, - "xscale", (double) 0, - "yscale", (double) 0, - NULL), - left, right, top, bottom, - GTK_FILL, GTK_FILL, - 0, 0); -} - -static void -_add_images(GtkTable *table) -{ - _add_image(table, EVOLUTION_IMAGES "/malehead.png", 0, 1, 0, 4); - _add_image(table, EVOLUTION_IMAGES "/cellphone.png", 4, 5, 0, 4); - _add_image(table, EVOLUTION_IMAGES "/envelope.png", 0, 1, 5, 7); - _add_image(table, EVOLUTION_IMAGES "/globe.png", - 0, 1, 8, 10); - _add_image(table, EVOLUTION_IMAGES "/house.png", 4, 5, 5, 10); -} - -static void -_add_details_images(GtkTable *table) -{ - _add_image(table, DATADIR "/evolution/briefcase.png", 0, 1, 0, 2); - _add_image(table, DATADIR "/evolution/head.png", 0, 1, 4, 6); - _add_image(table, DATADIR "/evolution/netmeeting.png", 0, 1, 7, 9); - _add_image(table, DATADIR "/evolution/netfreebusy.png", 0, 1, 10, 12); -} - -static void -_replace_button(EContactEditor *editor, gchar *button_xml, gchar *image, GtkSignalFunc func) -{ - GladeXML *gui = editor->gui; - GtkWidget *button = glade_xml_get_widget(gui, button_xml); - gchar *image_temp; - image_temp = g_strdup_printf("%s%s", DATADIR "/evolution/", image); - gtk_container_add(GTK_CONTAINER(button), - gnome_pixmap_new_from_file(image_temp)); - g_free(image_temp); - gtk_signal_connect(GTK_OBJECT(button), "button_press_event", func, editor); - -} - -static void -_replace_buttons(EContactEditor *editor) -{ - _replace_button(editor, "button-phone1", "arrow.png", _phone_arrow_pressed); - _replace_button(editor, "button-phone2", "arrow.png", _phone_arrow_pressed); - _replace_button(editor, "button-phone3", "arrow.png", _phone_arrow_pressed); - _replace_button(editor, "button-phone4", "arrow.png", _phone_arrow_pressed); - _replace_button(editor, "button-address1", "arrow.png", _address_arrow_pressed); - _replace_button(editor, "button-email1", "arrow.png", _email_arrow_pressed); -} - -static void -e_contact_editor_init (EContactEditor *e_contact_editor) -{ - GladeXML *gui; - GtkAdjustment *adjustment; - - e_contact_editor->card = NULL; - gui = glade_xml_new (EVOLUTION_GLADEDIR "/contact-editor.glade", NULL); - e_contact_editor->gui = gui; - gtk_widget_reparent(glade_xml_get_widget(gui, "notebook-contact-editor"), - GTK_WIDGET(e_contact_editor)); - - _add_images(GTK_TABLE(glade_xml_get_widget(gui, "table-contact-editor-general"))); - _add_details_images(GTK_TABLE(glade_xml_get_widget(gui, "table-contact-editor-details"))); - _replace_buttons(e_contact_editor); - - gtk_object_get(GTK_OBJECT(glade_xml_get_widget(gui, "text-comments")), - "vadjustment", &adjustment, - NULL); - gtk_range_set_adjustment(GTK_RANGE(glade_xml_get_widget(gui, "vscrollbar-comments")), - adjustment); - - e_contact_editor->email_info = NULL; - e_contact_editor->phone_info = NULL; - e_contact_editor->address_info = NULL; - e_contact_editor->email_popup = NULL; - e_contact_editor->phone_popup = NULL; - e_contact_editor->address_popup = NULL; - e_contact_editor->email_list = NULL; - e_contact_editor->phone_list = NULL; - e_contact_editor->address_list = NULL; -} - -void -e_contact_editor_destroy (GtkObject *object) { - EContactEditor *e_contact_editor = E_CONTACT_EDITOR(object); - - if (e_contact_editor->email_list) { - g_list_foreach(e_contact_editor->email_list, (GFunc) g_free, NULL); - g_list_free(e_contact_editor->email_list); - } - if (e_contact_editor->email_info) { - g_free(e_contact_editor->email_info); - } - if (e_contact_editor->email_popup) { - gtk_widget_unref(e_contact_editor->email_popup); - } - - if (e_contact_editor->phone_list) { - g_list_foreach(e_contact_editor->phone_list, (GFunc) g_free, NULL); - g_list_free(e_contact_editor->phone_list); - } - if (e_contact_editor->phone_info) { - g_free(e_contact_editor->phone_info); - } - if (e_contact_editor->phone_popup) { - gtk_widget_unref(e_contact_editor->phone_popup); - } - - if (e_contact_editor->address_list) { - g_list_foreach(e_contact_editor->address_list, (GFunc) g_free, NULL); - g_list_free(e_contact_editor->address_list); - } - if (e_contact_editor->address_info) { - g_free(e_contact_editor->address_info); - } - if (e_contact_editor->address_popup) { - gtk_widget_unref(e_contact_editor->address_popup); - } - - gtk_object_unref(GTK_OBJECT(e_contact_editor->gui)); -} - -GtkWidget* -e_contact_editor_new (ECard *card) -{ - GtkWidget *widget = GTK_WIDGET (gtk_type_new (e_contact_editor_get_type ())); - gtk_object_set (GTK_OBJECT(widget), - "card", card, - NULL); - return widget; -} - -static void -e_contact_editor_set_arg (GtkObject *o, GtkArg *arg, guint arg_id) -{ - EContactEditor *e_contact_editor; - - e_contact_editor = E_CONTACT_EDITOR (o); - - switch (arg_id){ - case ARG_CARD: - if (e_contact_editor->card) - gtk_object_unref(GTK_OBJECT(e_contact_editor->card)); - e_contact_editor->card = e_card_duplicate(E_CARD(GTK_VALUE_OBJECT (*arg))); - fill_in_info(e_contact_editor); - break; - } -} - -static void -e_contact_editor_get_arg (GtkObject *object, GtkArg *arg, guint arg_id) -{ - EContactEditor *e_contact_editor; - - e_contact_editor = E_CONTACT_EDITOR (object); - - switch (arg_id) { - case ARG_CARD: - extract_info(e_contact_editor); - GTK_VALUE_OBJECT (*arg) = GTK_OBJECT(e_contact_editor->card); - break; - default: - arg->type = GTK_TYPE_INVALID; - break; - } -} - -static void -_popup_position(GtkMenu *menu, - gint *x, - gint *y, - gpointer data) -{ - GtkWidget *button = GTK_WIDGET(data); - GtkRequisition request; - int mh, mw; - gdk_window_get_origin (button->window, x, y); - *x += button->allocation.width; - *y += button->allocation.height; - - gtk_widget_size_request(GTK_WIDGET(menu), &request); - - mh = request.height; - mw = request.width; - - *x -= mw; - if (*x < 0) - *x = 0; - - if (*y < 0) - *y = 0; - - if ((*x + mw) > gdk_screen_width ()) - *x = gdk_screen_width () - mw; - - if ((*y + mh) > gdk_screen_height ()) - *y = gdk_screen_height () - mh; -} - -static void -_arrow_pressed (GtkWidget *widget, GdkEventButton *button, EContactEditor *editor, GtkWidget *popup, GList **list, GnomeUIInfo **info, gchar *label, gchar *entry, gchar *dialog_title) -{ - gint menu_item; - gtk_signal_emit_stop_by_name(GTK_OBJECT(widget), "button_press_event"); - gtk_widget_realize(popup); - menu_item = gnome_popup_menu_do_popup_modal(popup, _popup_position, widget, button, editor); - if ( menu_item != -1 ) { - if (menu_item == g_list_length (*list)) { - e_contact_editor_build_dialog(editor, entry, label, dialog_title, list, info); - } else { - gtk_object_set(GTK_OBJECT(glade_xml_get_widget(editor->gui, label)), - "label", g_list_nth_data(*list, menu_item), - NULL); - } - } -} - -static void -e_contact_editor_build_ui_info(GList *list, GnomeUIInfo **infop) -{ - GnomeUIInfo *info; - GnomeUIInfo singleton = { GNOME_APP_UI_ITEM, NULL, NULL, NULL, NULL, NULL, GNOME_APP_PIXMAP_NONE, 0, 0, 0, NULL }; - GnomeUIInfo end = GNOMEUIINFO_END; - int length; - int i; - - info = *infop; - - if ( info ) - g_free(info); - length = g_list_length( list ); - info = g_new(GnomeUIInfo, length + 2); - for (i = 0; i < length; i++) { - info[i] = singleton; - info[i].label = _(list->data); - list = list->next; - } - info[i] = singleton; - info[i].label = N_("Other..."); - i++; - info[i] = end; - - *infop = info; -} - -static void -_dialog_clicked(GtkWidget *dialog, gint button, EContactEditor *editor) -{ - GtkWidget *label = gtk_object_get_data(GTK_OBJECT(dialog), - "e_contact_editor_label"); -#if 0 - GtkWidget *entry = gtk_object_get_data(GTK_OBJECT(dialog), - "e_contact_editor_entry"); -#endif - GtkWidget *dialog_entry = gtk_object_get_data(GTK_OBJECT(dialog), - "e_contact_editor_dialog_entry"); - GList **list = gtk_object_get_data(GTK_OBJECT(dialog), - "e_contact_editor_list"); - GList **info = gtk_object_get_data(GTK_OBJECT(dialog), - "e_contact_editor_info"); - switch (button) { - case 0: - gtk_object_set(GTK_OBJECT(label), - "label", gtk_entry_get_text(GTK_ENTRY(dialog_entry)), - NULL); - *list = g_list_append(*list, g_strdup(gtk_entry_get_text(GTK_ENTRY(dialog_entry)))); - g_free(*info); - *info = NULL; - break; - } - gnome_dialog_close(GNOME_DIALOG(dialog)); -} - -static void -_dialog_destroy(EContactEditor *editor, GtkWidget *dialog) -{ - gnome_dialog_close(GNOME_DIALOG(dialog)); -} - -static GtkWidget * -e_contact_editor_build_dialog(EContactEditor *editor, gchar *entry_id, gchar *label_id, gchar *title, GList **list, GnomeUIInfo **info) -{ - GtkWidget *dialog_entry = gtk_entry_new(); - GtkWidget *entry = glade_xml_get_widget(editor->gui, entry_id); - GtkWidget *label = glade_xml_get_widget(editor->gui, label_id); - - GtkWidget *dialog = gnome_dialog_new(title, - NULL); - - gtk_container_add(GTK_CONTAINER(GNOME_DIALOG(dialog)->vbox), - gtk_widget_new (gtk_frame_get_type(), - "border_width", 4, - "label", title, - "child", gtk_widget_new(gtk_alignment_get_type(), - "child", dialog_entry, - "xalign", .5, - "yalign", .5, - "xscale", 1.0, - "yscale", 1.0, - "border_width", 9, - NULL), - NULL)); - - gnome_dialog_append_button_with_pixmap(GNOME_DIALOG(dialog), - "Add", - GNOME_STOCK_PIXMAP_ADD); - gnome_dialog_append_button(GNOME_DIALOG(dialog), GNOME_STOCK_BUTTON_CANCEL); - gnome_dialog_set_default(GNOME_DIALOG(dialog), 0); - - gtk_signal_connect(GTK_OBJECT(dialog), "clicked", - _dialog_clicked, editor); - gtk_signal_connect_while_alive(GTK_OBJECT(editor), "destroy", - _dialog_destroy, GTK_OBJECT(dialog), GTK_OBJECT(dialog)); - - gtk_object_set_data(GTK_OBJECT(dialog), - "e_contact_editor_entry", entry); - gtk_object_set_data(GTK_OBJECT(dialog), - "e_contact_editor_label", label); - gtk_object_set_data(GTK_OBJECT(dialog), - "e_contact_editor_dialog_entry", dialog_entry); - gtk_object_set_data(GTK_OBJECT(dialog), - "e_contact_editor_list", list); - gtk_object_set_data(GTK_OBJECT(dialog), - "e_contact_editor_info", info); - - gtk_widget_show_all(dialog); - return dialog; -} - -static void -_phone_arrow_pressed (GtkWidget *widget, GdkEventButton *button, EContactEditor *editor) -{ - int which; - int i; - gchar *label; - gchar *entry; - if ( widget == glade_xml_get_widget(editor->gui, "button-phone1") ) { - which = 1; - } else if ( widget == glade_xml_get_widget(editor->gui, "button-phone2") ) { - which = 2; - } else if ( widget == glade_xml_get_widget(editor->gui, "button-phone3") ) { - which = 3; - } else if ( widget == glade_xml_get_widget(editor->gui, "button-phone4") ) { - which = 4; - } else - return; - - label = g_strdup_printf("label-phone%d", which); - entry = g_strdup_printf("entry-phone%d", which); - - if (editor->phone_list == NULL) { - static char *info[] = { - N_("Assistant"), - N_("Business"), - N_("Business 2"), - N_("Business Fax"), - N_("Callback"), - N_("Car"), - N_("Company"), - N_("Home"), - N_("Home 2"), - N_("Home Fax"), - N_("ISDN"), - N_("Mobile"), - N_("Other"), - N_("Other Fax"), - N_("Pager"), - N_("Primary"), - N_("Radio"), - N_("Telex"), - N_("TTY/TDD") - }; - - for (i = 0; i < sizeof(info) / sizeof(info[0]); i++) { - editor->phone_list = g_list_append(editor->phone_list, g_strdup(info[i])); - } - } - if (editor->phone_info == NULL) { - e_contact_editor_build_ui_info(editor->phone_list, &editor->phone_info); - - if ( editor->phone_popup ) - gtk_widget_unref(editor->phone_popup); - - editor->phone_popup = gnome_popup_menu_new(editor->phone_info); - } - - _arrow_pressed (widget, button, editor, editor->phone_popup, &editor->phone_list, &editor->phone_info, label, entry, "Add new phone number type"); - - g_free(label); - g_free(entry); -} - -static void -_email_arrow_pressed (GtkWidget *widget, GdkEventButton *button, EContactEditor *editor) -{ - int i; - if (editor->email_list == NULL) { - static char *info[] = { - N_("Email"), - N_("Email 2"), - N_("Email 3") - }; - - for (i = 0; i < sizeof(info) / sizeof(info[0]); i++) { - editor->email_list = g_list_append(editor->email_list, g_strdup(info[i])); - } - } - if (editor->email_info == NULL) { - e_contact_editor_build_ui_info(editor->email_list, &editor->email_info); - - if ( editor->email_popup ) - gtk_widget_unref(editor->email_popup); - - editor->email_popup = gnome_popup_menu_new(editor->email_info); - } - - _arrow_pressed (widget, button, editor, editor->email_popup, &editor->email_list, &editor->email_info, "label-email1", "entry-email1", "Add new Email type"); -} - -static void -_address_arrow_pressed (GtkWidget *widget, GdkEventButton *button, EContactEditor *editor) -{ - int i; - if (editor->address_list == NULL) { - static char *info[] = { - N_("Business"), - N_("Home"), - N_("Other") - }; - - for (i = 0; i < sizeof(info) / sizeof(info[0]); i++) { - editor->address_list = g_list_append(editor->address_list, g_strdup(info[i])); - } - } - if (editor->address_info == NULL) { - e_contact_editor_build_ui_info(editor->address_list, &editor->address_info); - - if ( editor->address_popup ) - gtk_widget_unref(editor->address_popup); - - editor->address_popup = gnome_popup_menu_new(editor->address_info); - } - - _arrow_pressed (widget, button, editor, editor->address_popup, &editor->address_list, &editor->address_info, "label-address1", "entry-address1", "Add new Address type"); -} - -static void -fill_in_info(EContactEditor *editor) -{ - ECard *card = editor->card; - if (card) { - char *fname; - ECardList *address_list; - ECardList *phone_list; - ECardList *email_list; - char *title; - char *org; - char *org_unit; - char *url; - char *role; - char *nickname; - char *fburl; - char *note; - const ECardDeliveryAddress *address; - const ECardPhone *phone; - const ECardDate *bday; - GtkEditable *editable; - int position = 0; - const char *email; - - ECardIterator *iterator; - - gtk_object_get(GTK_OBJECT(card), - "full_name", &fname, - "address", &address_list, - "phone", &phone_list, - "email", &email_list, - "url", &url, - "org", &org, - "org_unit", &org_unit, - "title", &title, - "role", &role, - "nickname", &nickname, - "fburl", &fburl, - "note", ¬e, - "birth_date", &bday, - NULL); - - position = 0; - editable = GTK_EDITABLE(glade_xml_get_widget(editor->gui, "entry-fullname")); - gtk_editable_delete_text(editable, 0, -1); - if (fname) - gtk_editable_insert_text(editable, fname, strlen(fname), &position); - - position = 0; - iterator = e_card_list_get_iterator(address_list); - address = e_card_iterator_get(iterator); - editable = GTK_EDITABLE(glade_xml_get_widget(editor->gui, "text-address")); - gtk_editable_delete_text(editable, 0, -1); - if (address) - gtk_editable_insert_text(editable, address->city, strlen(address->city), &position); - gtk_object_unref(GTK_OBJECT(iterator)); - - position = 0; - iterator = e_card_list_get_iterator(phone_list); - phone = e_card_iterator_get(iterator); - editable = GTK_EDITABLE(glade_xml_get_widget(editor->gui, "entry-phone1")); - gtk_editable_delete_text(editable, 0, -1); - if (phone) - gtk_editable_insert_text(editable, phone->number, strlen(phone->number), &position); - gtk_object_unref(GTK_OBJECT(iterator)); - - position = 0; - iterator = e_card_list_get_iterator(email_list); - email = e_card_iterator_get(iterator); - editable = GTK_EDITABLE(glade_xml_get_widget(editor->gui, "entry-email1")); - gtk_editable_delete_text(editable, 0, -1); - if (email) - gtk_editable_insert_text(editable, email, strlen(email), &position); - gtk_object_unref(GTK_OBJECT(iterator)); - - position = 0; - editable = GTK_EDITABLE(glade_xml_get_widget(editor->gui, "entry-web")); - gtk_editable_delete_text(editable, 0, -1); - if (url) - gtk_editable_insert_text(editable, url, strlen(url), &position); - - position = 0; - editable = GTK_EDITABLE(glade_xml_get_widget(editor->gui, "entry-company")); - gtk_editable_delete_text(editable, 0, -1); - if (org) - gtk_editable_insert_text(editable, org, strlen(org), &position); - - position = 0; - editable = GTK_EDITABLE(glade_xml_get_widget(editor->gui, "entry-department")); - gtk_editable_delete_text(editable, 0, -1); - if (org_unit) - gtk_editable_insert_text(editable, org_unit, strlen(org_unit), &position); - - position = 0; - editable = GTK_EDITABLE(glade_xml_get_widget(editor->gui, "entry-jobtitle")); - gtk_editable_delete_text(editable, 0, -1); - if (title) - gtk_editable_insert_text(editable, title, strlen(title), &position); - - position = 0; - editable = GTK_EDITABLE(glade_xml_get_widget(editor->gui, "entry-nickname")); - gtk_editable_delete_text(editable, 0, -1); - if (nickname) - gtk_editable_insert_text(editable, nickname, strlen(nickname), &position); - - position = 0; - editable = GTK_EDITABLE(glade_xml_get_widget(editor->gui, "entry-fburl")); - gtk_editable_delete_text(editable, 0, -1); - if (fburl) - gtk_editable_insert_text(editable, fburl, strlen(fburl), &position); - - position = 0; - editable = GTK_EDITABLE(glade_xml_get_widget(editor->gui, "entry-profession")); - gtk_editable_delete_text(editable, 0, -1); - if (role) - gtk_editable_insert_text(editable, role, strlen(role), &position); - - position = 0; - editable = GTK_EDITABLE(glade_xml_get_widget(editor->gui, "text-comments")); - gtk_editable_delete_text(editable, 0, -1); - if (note) - gtk_editable_insert_text(editable, note, strlen(note), &position); - - if (bday) { - struct tm time_struct = {0,0,0,0,0,0,0,0,0}; - time_t time_val; - GnomeDateEdit *dateedit; - time_struct.tm_mday = bday->day; - time_struct.tm_mon = bday->month; - time_struct.tm_year = bday->year; - time_val = mktime(&time_struct); - dateedit = GNOME_DATE_EDIT(glade_xml_get_widget(editor->gui, "dateedit-birthday")); - gnome_date_edit_set_time(dateedit, time_val); - } - } -} - -static void -extract_info(EContactEditor *editor) -{ - ECard *card = editor->card; - if (card) { - char *fname; - char *string; - ECardList *address_list; - ECardList *phone_list; - ECardList *email_list; - char *url; - char *org; - char *org_unit; - char *title; - char *role; - char *nickname; - char *fburl; - char *note; - const ECardDeliveryAddress *address; - const ECardPhone *phone; - ECardDeliveryAddress *address_copy; - ECardPhone *phone_copy; - char *email; - ECardDate *bday; - GtkEditable *editable; - GnomeDateEdit *dateedit; - int position = 0; - struct tm time_struct; - time_t time_val; - - ECardIterator *iterator; - - gtk_object_get(GTK_OBJECT(card), - "address", &address_list, - "phone", &phone_list, - "email", &email_list, - NULL); - - position = 0; - editable = GTK_EDITABLE(glade_xml_get_widget(editor->gui, "entry-fullname")); - fname = gtk_editable_get_chars(editable, 0, -1); - if (fname && *fname) - gtk_object_set(GTK_OBJECT(card), - "full_name", fname, - NULL); - g_free(fname); - - iterator = e_card_list_get_iterator(address_list); - address = e_card_iterator_get(iterator); - editable = GTK_EDITABLE(glade_xml_get_widget(editor->gui, "text-address")); - string = gtk_editable_get_chars(editable, 0, -1); - if (string && *string) { - if (address) { - address_copy = e_card_delivery_address_copy(address); - if (address_copy->city) - g_free(address_copy->city); - address_copy->city = string; - e_card_iterator_set(iterator, address_copy); - e_card_delivery_address_free(address_copy); - } else { - address_copy = g_new0(ECardDeliveryAddress, 1); - address_copy->city = string; - e_card_list_append(address_list, address_copy); - e_card_delivery_address_free(address_copy); - } - } else - g_free(string); - gtk_object_unref(GTK_OBJECT(iterator)); - - position = 0; - iterator = e_card_list_get_iterator(phone_list); - phone = e_card_iterator_get(iterator); - editable = GTK_EDITABLE(glade_xml_get_widget(editor->gui, "entry-phone1")); - string = gtk_editable_get_chars(editable, 0, -1); - if (string && *string) { - if (phone) { - phone_copy = e_card_phone_copy(phone); - if (phone_copy->number) - g_free(phone_copy->number); - phone_copy->number = string; - e_card_iterator_set(iterator, phone_copy); - e_card_phone_free(phone_copy); - } else { - phone_copy = g_new0(ECardPhone, 1); - phone_copy->number = string; - e_card_list_append(phone_list, phone_copy); - e_card_phone_free(phone_copy); - } - } else - g_free(string); - gtk_object_unref(GTK_OBJECT(iterator)); - - position = 0; - iterator = e_card_list_get_iterator(email_list); - editable = GTK_EDITABLE(glade_xml_get_widget(editor->gui, "entry-email1")); - email = gtk_editable_get_chars(editable, 0, -1); - if (email && *email) { - if (e_card_iterator_is_valid(iterator)) - e_card_iterator_set(iterator, email); - else - e_card_list_append(email_list, email); - } - g_free(email); - gtk_object_unref(GTK_OBJECT(iterator)); - - position = 0; - editable = GTK_EDITABLE(glade_xml_get_widget(editor->gui, "entry-web")); - url = gtk_editable_get_chars(editable, 0, -1); - if (url && *url) - gtk_object_set(GTK_OBJECT(card), - "url", url, - NULL); - g_free(url); - - editable = GTK_EDITABLE(glade_xml_get_widget(editor->gui, "entry-company")); - org = gtk_editable_get_chars(editable, 0, -1); - if (org && *org) - gtk_object_set(GTK_OBJECT(card), - "org", org, - NULL); - g_free(org); - - editable = GTK_EDITABLE(glade_xml_get_widget(editor->gui, "entry-department")); - org_unit = gtk_editable_get_chars(editable, 0, -1); - if (org_unit && *org_unit) - gtk_object_set(GTK_OBJECT(card), - "org_unit", org_unit, - NULL); - g_free(org_unit); - - editable = GTK_EDITABLE(glade_xml_get_widget(editor->gui, "entry-jobtitle")); - title = gtk_editable_get_chars(editable, 0, -1); - if (title && *title) - gtk_object_set(GTK_OBJECT(card), - "title", title, - NULL); - g_free(title); - - editable = GTK_EDITABLE(glade_xml_get_widget(editor->gui, "entry-profession")); - role = gtk_editable_get_chars(editable, 0, -1); - if (role && *role) - gtk_object_set(GTK_OBJECT(card), - "role", role, - NULL); - g_free(role); - - editable = GTK_EDITABLE(glade_xml_get_widget(editor->gui, "entry-nickname")); - nickname = gtk_editable_get_chars(editable, 0, -1); - if (nickname && *nickname) - gtk_object_set(GTK_OBJECT(card), - "nickname", nickname, - NULL); - g_free(nickname); - - editable = GTK_EDITABLE(glade_xml_get_widget(editor->gui, "entry-fburl")); - fburl = gtk_editable_get_chars(editable, 0, -1); - if (fburl && *fburl) - gtk_object_set(GTK_OBJECT(card), - "fburl", fburl, - NULL); - g_free(fburl); - - editable = GTK_EDITABLE(glade_xml_get_widget(editor->gui, "text-comments")); - note = gtk_editable_get_chars(editable, 0, -1); - if (note && *note) - gtk_object_set(GTK_OBJECT(card), - "note", note, - NULL); - g_free(note); - - dateedit = GNOME_DATE_EDIT(glade_xml_get_widget(editor->gui, "dateedit-birthday")); - time_val = gnome_date_edit_get_date(dateedit); - gmtime_r(&time_val, - &time_struct); - bday = g_new(ECardDate, 1); - bday->day = time_struct.tm_mday; - bday->month = time_struct.tm_mon; - bday->year = time_struct.tm_year; - gtk_object_set(GTK_OBJECT(card), - "birth_date", bday, - NULL); - } -} - - - - - - - - - diff --git a/addressbook/gui/contact-editor/e-contact-editor.h b/addressbook/gui/contact-editor/e-contact-editor.h deleted file mode 100644 index 82f4a22623..0000000000 --- a/addressbook/gui/contact-editor/e-contact-editor.h +++ /dev/null @@ -1,85 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* e-contact-editor.h - * Copyright (C) 2000 Helix Code, Inc. - * Author: Chris Lahey - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ -#ifndef __E_CONTACT_EDITOR_H__ -#define __E_CONTACT_EDITOR_H__ - -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - -/* EContactEditor - A dialog displaying information about a contact. - * - * The following arguments are available: - * - * name type read/write description - * -------------------------------------------------------------------------------- - * card ECard * R The card currently being edited - */ - -#define E_CONTACT_EDITOR_TYPE (e_contact_editor_get_type ()) -#define E_CONTACT_EDITOR(obj) (GTK_CHECK_CAST ((obj), E_CONTACT_EDITOR_TYPE, EContactEditor)) -#define E_CONTACT_EDITOR_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_CONTACT_EDITOR_TYPE, EContactEditorClass)) -#define E_IS_CONTACT_EDITOR(obj) (GTK_CHECK_TYPE ((obj), E_CONTACT_EDITOR_TYPE)) -#define E_IS_CONTACT_EDITOR_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), E_CONTACT_EDITOR_TYPE)) - - -typedef struct _EContactEditor EContactEditor; -typedef struct _EContactEditorClass EContactEditorClass; - -struct _EContactEditor -{ - GtkVBox parent; - - /* item specific fields */ - ECard *card; - - GladeXML *gui; - GnomeUIInfo *email_info; - GnomeUIInfo *phone_info; - GnomeUIInfo *address_info; - GtkWidget *email_popup; - GtkWidget *phone_popup; - GtkWidget *address_popup; - GList *email_list; - GList *phone_list; - GList *address_list; -}; - -struct _EContactEditorClass -{ - GtkVBoxClass parent_class; -}; - - -GtkWidget *e_contact_editor_new(ECard *card); -GtkType e_contact_editor_get_type (void); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - - -#endif /* __E_CONTACT_EDITOR_H__ */ diff --git a/addressbook/gui/contact-editor/email.png b/addressbook/gui/contact-editor/email.png deleted file mode 100644 index f3ff02e343..0000000000 Binary files a/addressbook/gui/contact-editor/email.png and /dev/null differ diff --git a/addressbook/gui/contact-editor/head.png b/addressbook/gui/contact-editor/head.png deleted file mode 100644 index ca00b75f92..0000000000 Binary files a/addressbook/gui/contact-editor/head.png and /dev/null differ diff --git a/addressbook/gui/contact-editor/netfreebusy.png b/addressbook/gui/contact-editor/netfreebusy.png deleted file mode 100644 index 09ec8a2a5c..0000000000 Binary files a/addressbook/gui/contact-editor/netfreebusy.png and /dev/null differ diff --git a/addressbook/gui/contact-editor/netmeeting.png b/addressbook/gui/contact-editor/netmeeting.png deleted file mode 100644 index 4cb90c121e..0000000000 Binary files a/addressbook/gui/contact-editor/netmeeting.png and /dev/null differ diff --git a/addressbook/gui/contact-editor/phone.png b/addressbook/gui/contact-editor/phone.png deleted file mode 100644 index ebec84ba0b..0000000000 Binary files a/addressbook/gui/contact-editor/phone.png and /dev/null differ diff --git a/addressbook/gui/contact-editor/snailmail.png b/addressbook/gui/contact-editor/snailmail.png deleted file mode 100644 index 647ae8f68c..0000000000 Binary files a/addressbook/gui/contact-editor/snailmail.png and /dev/null differ diff --git a/addressbook/gui/contact-editor/test-editor.c b/addressbook/gui/contact-editor/test-editor.c deleted file mode 100644 index 5b48c1a92f..0000000000 --- a/addressbook/gui/contact-editor/test-editor.c +++ /dev/null @@ -1,158 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * test-editor.c - * Copyright (C) 2000 Helix Code, Inc. - * Author: Chris Lahey - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include "config.h" - -#include -#include -#include "e-contact-editor.h" - -#define TEST_VCARD \ -"BEGIN:VCARD -" \ -"FN:Nat -" \ -"N:Friedman;Nat;D;Mr. -" \ -"BDAY:1977-08-06 -" \ -"TEL;WORK:617 679 1984 -" \ -"TEL;CELL:123 456 7890 -" \ -"EMAIL;INTERNET:nat@nat.org -" \ -"EMAIL;INTERNET:nat@helixcode.com -" \ -"ADR;WORK;POSTAL:P.O. Box 101;;;Any Town;CA;91921-1234; -" \ -"ADR;HOME;POSTAL;INTL:P.O. Box 202;;;Any Town 2;MI;12344-4321;USA -" \ -"END:VCARD -" \ -" -" - -static char * -read_file (char *name) -{ - int len; - char buff[65536]; - char line[1024]; - FILE *f; - - f = fopen (name, "r"); - if (f == NULL) - g_error ("Unable to open %s!\n", name); - - len = 0; - while (fgets (line, sizeof (line), f) != NULL) { - strcpy (buff + len, line); - len += strlen (line); - } - - fclose (f); - - return g_strdup (buff); -} - -/* This is a horrible thing to do, but it is just a test. */ -GtkWidget *editor; - -static void destroy_callback(GtkWidget *app, gpointer data) -{ - static int count = 2; - count --; - if ( count <= 0 ) - exit(0); -} - -#if 0 -static void about_callback( GtkWidget *widget, gpointer data ) -{ - - const gchar *authors[] = - { - "Christopher James Lahey ", - NULL - }; - - GtkWidget *about = - gnome_about_new ( _( "Contact Editor Test" ), VERSION, - _( "Copyright (C) 2000, Helix Code, Inc." ), - authors, - _( "This should test the contact editor canvas item" ), - NULL); - gtk_widget_show (about); -} -#endif - -int main( int argc, char *argv[] ) -{ - char *cardstr; - GtkWidget *app; - - /* bindtextdomain (PACKAGE, GNOMELOCALEDIR); - textdomain (PACKAGE);*/ - - gnome_init( "Contact Editor Test", VERSION, argc, argv); - - glade_gnome_init (); - - app = gnome_app_new("Contact Editor Test", NULL); - - cardstr = NULL; - if (argc == 2) - cardstr = read_file (argv [1]); - - if (cardstr == NULL) - cardstr = TEST_VCARD; - - editor = e_contact_editor_new(e_card_new(cardstr)); - - gnome_app_set_contents( GNOME_APP( app ), editor ); - - /* Connect the signals */ - gtk_signal_connect( GTK_OBJECT( app ), "destroy", - GTK_SIGNAL_FUNC( destroy_callback ), - ( gpointer ) app ); - - gtk_widget_show_all( app ); - - app = gnome_app_new("Contact Editor Test", NULL); - - editor = e_contact_editor_new(e_card_new(cardstr)); - - gnome_app_set_contents( GNOME_APP( app ), editor ); - - /* Connect the signals */ - gtk_signal_connect( GTK_OBJECT( app ), "destroy", - GTK_SIGNAL_FUNC( destroy_callback ), - ( gpointer ) app ); - - gtk_widget_show_all( app ); - - gtk_main(); - - /* Not reached. */ - return 0; -} diff --git a/addressbook/gui/contact-editor/web.png b/addressbook/gui/contact-editor/web.png deleted file mode 100644 index 3211a11b19..0000000000 Binary files a/addressbook/gui/contact-editor/web.png and /dev/null differ diff --git a/addressbook/gui/minicard/.cvsignore b/addressbook/gui/minicard/.cvsignore deleted file mode 100644 index 1c59f4a4ec..0000000000 --- a/addressbook/gui/minicard/.cvsignore +++ /dev/null @@ -1,10 +0,0 @@ -.deps -.libs -Makefile -Makefile.in -*.lo -*.la -minicard-label-test -minicard-test -minicard-view-test -reflow-test \ No newline at end of file diff --git a/addressbook/gui/minicard/Makefile.am b/addressbook/gui/minicard/Makefile.am deleted file mode 100644 index 44cbed0819..0000000000 --- a/addressbook/gui/minicard/Makefile.am +++ /dev/null @@ -1,82 +0,0 @@ -INCLUDES = \ - -DG_LOG_DOMAIN=\"e-minicard\" \ - -I$(top_srcdir) \ - -I$(top_srcdir)/addressbook/backend \ - -I$(top_builddir)/addressbook/backend \ - -I$(top_srcdir)/addressbook/contact-editor \ - -I$(top_srcdir)/widgets/e-text \ - $(GNOME_INCLUDEDIR) - -noinst_LIBRARIES = \ - libeminicard.a - -libeminicard_a_SOURCES = \ - e-minicard.c \ - e-minicard.h \ - e-minicard-label.c \ - e-minicard-label.h \ - e-minicard-view.c \ - e-minicard-view.h \ - e-reflow-sorted.c \ - e-reflow-sorted.h \ - e-reflow.c \ - e-reflow.h - -noinst_PROGRAMS = \ - minicard-label-test \ - minicard-test \ - reflow-test \ - minicard-view-test - -minicard_label_test_SOURCES = \ - test-minicard-label.c - -minicard_label_test_LDADD = \ - $(EXTRA_GNOME_LIBS) \ - $(GNOMEGNORBA_LIBS) \ - libeminicard.a \ - -lbonobo \ - $(top_builddir)/e-util/libeutil.la \ - $(top_builddir)/widgets/e-text/libetext.a - -minicard_test_SOURCES = \ - test-minicard.c - -minicard_test_LDADD = \ - $(EXTRA_GNOME_LIBS) \ - $(GNOMEGNORBA_LIBS) \ - libeminicard.a \ - -lbonobo \ - $(top_builddir)/e-util/libeutil.la \ - $(top_builddir)/addressbook/backend/ebook/libebook.la \ - $(top_builddir)/libversit/libversit.la \ - $(top_builddir)/addressbook/contact-editor/libecontacteditor.a \ - $(top_builddir)/widgets/e-text/libetext.a - -reflow_test_SOURCES = \ - test-reflow.c - -reflow_test_LDADD = \ - $(EXTRA_GNOME_LIBS) \ - $(GNOMEGNORBA_LIBS) \ - libeminicard.a \ - -lbonobo \ - $(top_builddir)/e-util/libeutil.la \ - $(top_builddir)/addressbook/backend/ebook/libebook.la \ - $(top_builddir)/libversit/libversit.la \ - $(top_builddir)/addressbook/contact-editor/libecontacteditor.a \ - $(top_builddir)/widgets/e-text/libetext.a - -minicard_view_test_SOURCES = \ - test-minicard-view.c - -minicard_view_test_LDADD = \ - $(EXTRA_GNOME_LIBS) \ - $(GNOMEGNORBA_LIBS) \ - libeminicard.a \ - -lbonobo \ - $(top_builddir)/e-util/libeutil.la \ - $(top_builddir)/addressbook/backend/ebook/libebook.la \ - $(top_builddir)/libversit/libversit.la \ - $(top_builddir)/addressbook/contact-editor/libecontacteditor.a \ - $(top_builddir)/widgets/e-text/libetext.a diff --git a/addressbook/gui/minicard/e-minicard-label.c b/addressbook/gui/minicard/e-minicard-label.c deleted file mode 100644 index e0e5c98118..0000000000 --- a/addressbook/gui/minicard/e-minicard-label.c +++ /dev/null @@ -1,421 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * e-minicard-label.c - * Copyright (C) 2000 Helix Code, Inc. - * Author: Chris Lahey - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include -#include -#include "e-minicard-label.h" -#include "e-text.h" -#include -#include -#include - -static void e_minicard_label_init (EMinicardLabel *card); -static void e_minicard_label_class_init (EMinicardLabelClass *klass); -static void e_minicard_label_set_arg (GtkObject *o, GtkArg *arg, guint arg_id); -static void e_minicard_label_get_arg (GtkObject *object, GtkArg *arg, guint arg_id); -static gboolean e_minicard_label_event (GnomeCanvasItem *item, GdkEvent *event); -static void e_minicard_label_realize (GnomeCanvasItem *item); -static void e_minicard_label_unrealize (GnomeCanvasItem *item); -static void e_minicard_label_reflow(GnomeCanvasItem *item, int flags); - -static void e_minicard_label_resize_children( EMinicardLabel *e_minicard_label ); - -static GnomeCanvasGroupClass *parent_class = NULL; - -/* The arguments we take */ -enum { - ARG_0, - ARG_WIDTH, - ARG_HEIGHT, - ARG_HAS_FOCUS, - ARG_FIELD, - ARG_FIELDNAME, - ARG_TEXT_MODEL -}; - -GtkType -e_minicard_label_get_type (void) -{ - static GtkType minicard_label_type = 0; - - if (!minicard_label_type) - { - static const GtkTypeInfo minicard_label_info = - { - "EMinicardLabel", - sizeof (EMinicardLabel), - sizeof (EMinicardLabelClass), - (GtkClassInitFunc) e_minicard_label_class_init, - (GtkObjectInitFunc) e_minicard_label_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - minicard_label_type = gtk_type_unique (gnome_canvas_group_get_type (), &minicard_label_info); - } - - return minicard_label_type; -} - -static void -e_minicard_label_class_init (EMinicardLabelClass *klass) -{ - GtkObjectClass *object_class; - GnomeCanvasItemClass *item_class; - - object_class = (GtkObjectClass*) klass; - item_class = (GnomeCanvasItemClass *) klass; - - parent_class = gtk_type_class (gnome_canvas_group_get_type ()); - - gtk_object_add_arg_type ("EMinicardLabel::width", GTK_TYPE_DOUBLE, - GTK_ARG_READWRITE, ARG_WIDTH); - gtk_object_add_arg_type ("EMinicardLabel::height", GTK_TYPE_DOUBLE, - GTK_ARG_READABLE, ARG_HEIGHT); - gtk_object_add_arg_type ("EMinicardLabel::has_focus", GTK_TYPE_BOOL, - GTK_ARG_READWRITE, ARG_HAS_FOCUS); - gtk_object_add_arg_type ("EMinicardLabel::field", GTK_TYPE_STRING, - GTK_ARG_READWRITE, ARG_FIELD); - gtk_object_add_arg_type ("EMinicardLabel::fieldname", GTK_TYPE_STRING, - GTK_ARG_READWRITE, ARG_FIELDNAME); - gtk_object_add_arg_type ("EMinicardLabel::text_model", GTK_TYPE_OBJECT, - GTK_ARG_READWRITE, ARG_TEXT_MODEL); - - object_class->set_arg = e_minicard_label_set_arg; - object_class->get_arg = e_minicard_label_get_arg; - /* object_class->destroy = e_minicard_label_destroy; */ - - /* GnomeCanvasItem method overrides */ - item_class->realize = e_minicard_label_realize; - item_class->unrealize = e_minicard_label_unrealize; - item_class->event = e_minicard_label_event; -} - -static void -e_minicard_label_init (EMinicardLabel *minicard_label) -{ - minicard_label->width = 10; - minicard_label->height = 10; - minicard_label->rect = NULL; - minicard_label->fieldname = NULL; - minicard_label->field = NULL; - - e_canvas_item_set_reflow_callback(GNOME_CANVAS_ITEM(minicard_label), e_minicard_label_reflow); -} - -static void -e_minicard_label_set_arg (GtkObject *o, GtkArg *arg, guint arg_id) -{ - GnomeCanvasItem *item; - EMinicardLabel *e_minicard_label; - - item = GNOME_CANVAS_ITEM (o); - e_minicard_label = E_MINICARD_LABEL (o); - - switch (arg_id){ - case ARG_WIDTH: - e_minicard_label->width = GTK_VALUE_DOUBLE (*arg); - e_minicard_label_resize_children(e_minicard_label); - e_canvas_item_request_reflow (item); - break; - case ARG_HAS_FOCUS: - if (e_minicard_label->field && (GTK_VALUE_ENUM(*arg) != E_FOCUS_NONE)) - e_canvas_item_grab_focus(e_minicard_label->field); - break; - case ARG_FIELD: - gnome_canvas_item_set( e_minicard_label->field, "text", GTK_VALUE_STRING (*arg), NULL ); - break; - case ARG_FIELDNAME: - gnome_canvas_item_set( e_minicard_label->fieldname, "text", GTK_VALUE_STRING (*arg), NULL ); - break; - case ARG_TEXT_MODEL: - gnome_canvas_item_set( e_minicard_label->field, "model", GTK_VALUE_OBJECT (*arg), NULL); - break; - } -} - -static void -e_minicard_label_get_arg (GtkObject *object, GtkArg *arg, guint arg_id) -{ - EMinicardLabel *e_minicard_label; - char *temp; - ETextModel *tempmodel; - - e_minicard_label = E_MINICARD_LABEL (object); - - switch (arg_id) { - case ARG_WIDTH: - GTK_VALUE_DOUBLE (*arg) = e_minicard_label->width; - break; - case ARG_HEIGHT: - GTK_VALUE_DOUBLE (*arg) = e_minicard_label->height; - break; - case ARG_HAS_FOCUS: - GTK_VALUE_ENUM (*arg) = e_minicard_label->has_focus ? E_FOCUS_CURRENT : E_FOCUS_NONE; - break; - case ARG_FIELD: - gtk_object_get( GTK_OBJECT( e_minicard_label->field ), "text", &temp, NULL ); - GTK_VALUE_STRING (*arg) = temp; - break; - case ARG_FIELDNAME: - gtk_object_get( GTK_OBJECT( e_minicard_label->fieldname ), "text", &temp, NULL ); - GTK_VALUE_STRING (*arg) = temp; - break; - case ARG_TEXT_MODEL: - gtk_object_get( GTK_OBJECT( e_minicard_label->field ), "model", &tempmodel, NULL ); - GTK_VALUE_OBJECT (*arg) = GTK_OBJECT(tempmodel); - break; - default: - arg->type = GTK_TYPE_INVALID; - break; - } -} - -static void -e_minicard_label_realize (GnomeCanvasItem *item) -{ - if (GNOME_CANVAS_ITEM_CLASS( parent_class )->realize) - (* GNOME_CANVAS_ITEM_CLASS( parent_class )->realize) (item); - - e_canvas_item_request_reflow(item); - - if (!item->canvas->aa) - { - } -} - -void -e_minicard_label_construct (GnomeCanvasItem *item) -{ - EMinicardLabel *e_minicard_label; - GnomeCanvasGroup *group; - static GdkFont *font = NULL; - - if ( font == NULL ) { - font = gdk_font_load("lucidasans-10"); - } - - e_minicard_label = E_MINICARD_LABEL (item); - group = GNOME_CANVAS_GROUP( item ); - - e_minicard_label->rect = - gnome_canvas_item_new( group, - gnome_canvas_rect_get_type(), - "x1", (double) 0, - "y1", (double) 0, - "x2", (double) e_minicard_label->width - 1, - "y2", (double) e_minicard_label->height - 1, - "outline_color", NULL, - NULL ); - e_minicard_label->fieldname = - gnome_canvas_item_new( group, - e_text_get_type(), - "anchor", GTK_ANCHOR_NW, - "clip_width", (double) ( e_minicard_label->width / 2 - 4 ), - "clip", TRUE, - "use_ellipsis", TRUE, - "font_gdk", font, - "fill_color", "black", - NULL ); - e_canvas_item_move_absolute(e_minicard_label->fieldname, 2, 1); - - e_minicard_label->field = - gnome_canvas_item_new( group, - e_text_get_type(), - "anchor", GTK_ANCHOR_NW, - "clip_width", (double) ( ( e_minicard_label->width + 1 ) / 2 - 4 ), - "clip", TRUE, - "use_ellipsis", TRUE, - "font_gdk", font, - "fill_color", "black", - "editable", TRUE, - NULL ); - e_canvas_item_move_absolute(e_minicard_label->field, ( e_minicard_label->width / 2 + 2), 1); - - e_canvas_item_request_reflow(item); -} - -static void -e_minicard_label_unrealize (GnomeCanvasItem *item) -{ - EMinicardLabel *e_minicard_label; - - e_minicard_label = E_MINICARD_LABEL (item); - - if (!item->canvas->aa) - { - } - - if (GNOME_CANVAS_ITEM_CLASS( parent_class )->unrealize) - (* GNOME_CANVAS_ITEM_CLASS( parent_class )->unrealize) (item); -} - -static gboolean -e_minicard_label_event (GnomeCanvasItem *item, GdkEvent *event) -{ - EMinicardLabel *e_minicard_label; - - e_minicard_label = E_MINICARD_LABEL (item); - - switch( event->type ) - { - case GDK_FOCUS_CHANGE: - { - GdkEventFocus *focus_event = (GdkEventFocus *) event; - if ( focus_event->in ) - { - gnome_canvas_item_set( e_minicard_label->rect, - "outline_color", "grey50", - "fill_color", "grey90", - NULL ); - e_minicard_label->has_focus = TRUE; - } - else - { - gnome_canvas_item_set( e_minicard_label->rect, - "outline_color", NULL, - "fill_color", NULL, - NULL ); - e_minicard_label->has_focus = FALSE; - } - } - break; - case GDK_BUTTON_PRESS: - case GDK_BUTTON_RELEASE: - case GDK_MOTION_NOTIFY: - case GDK_ENTER_NOTIFY: - case GDK_LEAVE_NOTIFY: { - gboolean return_val; -#if 0 - GnomeCanvasItem *field; - ArtPoint p; - double inv[6], affine[6]; - - field = e_minicard_label->field; - art_affine_identity (affine); - - if (field->xform != NULL) { - if (field->object.flags & GNOME_CANVAS_ITEM_AFFINE_FULL) { - art_affine_multiply (affine, affine, field->xform); - } else { - affine[4] += field->xform[0]; - affine[5] += field->xform[1]; - } - } - - art_affine_invert (inv, affine); - switch(event->type) { - case GDK_MOTION_NOTIFY: - p.x = event->motion.x; - p.y = event->motion.y; - art_affine_point (&p, &p, inv); - event->motion.x = p.x; - event->motion.y = p.y; - break; - case GDK_BUTTON_PRESS: - case GDK_BUTTON_RELEASE: - p.x = event->button.x; - p.y = event->button.y; - art_affine_point (&p, &p, inv); - event->button.x = p.x; - event->button.y = p.y; - break; - case GDK_ENTER_NOTIFY: - case GDK_LEAVE_NOTIFY: - p.x = event->crossing.x; - p.y = event->crossing.y; - art_affine_point (&p, &p, inv); - event->crossing.x = p.x; - event->crossing.y = p.y; - break; - default: - break; - } -#endif - gtk_signal_emit_by_name(GTK_OBJECT(e_minicard_label->field), "event", event, &return_val); - return return_val; - break; - } - default: - break; - } - - if (GNOME_CANVAS_ITEM_CLASS( parent_class )->event) - return (* GNOME_CANVAS_ITEM_CLASS( parent_class )->event) (item, event); - else - return 0; -} - -static void -e_minicard_label_resize_children(EMinicardLabel *e_minicard_label) -{ - gnome_canvas_item_set( e_minicard_label->fieldname, - "clip_width", (double) ( e_minicard_label->width / 2 - 4 ), - NULL ); - gnome_canvas_item_set( e_minicard_label->field, - "clip_width", (double) ( ( e_minicard_label->width + 1 ) / 2 - 4 ), - NULL ); -} - -static void -e_minicard_label_reflow(GnomeCanvasItem *item, int flags) -{ - EMinicardLabel *e_minicard_label = E_MINICARD_LABEL(item); - - gint old_height; - gdouble text_height; - old_height = e_minicard_label->height; - - gtk_object_get(GTK_OBJECT(e_minicard_label->fieldname), - "text_height", &text_height, - NULL); - - e_minicard_label->height = text_height; - - - gtk_object_get(GTK_OBJECT(e_minicard_label->field), - "text_height", &text_height, - NULL); - - if (e_minicard_label->height < text_height) - e_minicard_label->height = text_height; - e_minicard_label->height += 3; - - gnome_canvas_item_set( e_minicard_label->rect, - "x2", (double) e_minicard_label->width - 1, - "y2", (double) e_minicard_label->height - 1, - NULL ); - e_canvas_item_move_absolute(e_minicard_label->field, ( e_minicard_label->width / 2 + 2), 1); - - if (old_height != e_minicard_label->height) - e_canvas_item_request_parent_reflow(item); -} - -GnomeCanvasItem * -e_minicard_label_new(GnomeCanvasGroup *parent) -{ - GnomeCanvasItem *item = gnome_canvas_item_new(parent, e_minicard_label_get_type(), NULL); - e_minicard_label_construct(item); - return item; -} - diff --git a/addressbook/gui/minicard/e-minicard-label.h b/addressbook/gui/minicard/e-minicard-label.h deleted file mode 100644 index 1790414a54..0000000000 --- a/addressbook/gui/minicard/e-minicard-label.h +++ /dev/null @@ -1,82 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* e-minicard-label.h - * Copyright (C) 2000 Helix Code, Inc. - * Author: Chris Lahey - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ -#ifndef __E_MINICARD_LABEL_H__ -#define __E_MINICARD_LABEL_H__ - -#include - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - -/* EMinicardLabel - A label doing focus with non-marching ants. - * - * The following arguments are available: - * - * name type read/write description - * -------------------------------------------------------------------------------- - * width double RW width of the label - * height double R height of the label - * field string RW text in the field label - * fieldname string RW text in the fieldname label - */ - -#define E_MINICARD_LABEL_TYPE (e_minicard_label_get_type ()) -#define E_MINICARD_LABEL(obj) (GTK_CHECK_CAST ((obj), E_MINICARD_LABEL_TYPE, EMinicardLabel)) -#define E_MINICARD_LABEL_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_MINICARD_LABEL_TYPE, EMiniCardLabelClass)) -#define E_IS_MINICARD_LABEL(obj) (GTK_CHECK_TYPE ((obj), E_MINICARD_LABEL_TYPE)) -#define E_IS_MINICARD_LABEL_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), E_MINICARD_LABEL_TYPE)) - - -typedef struct _EMinicardLabel EMinicardLabel; -typedef struct _EMinicardLabelClass EMinicardLabelClass; - -struct _EMinicardLabel -{ - GnomeCanvasGroup parent; - - /* item specific fields */ - double width; - double height; - GnomeCanvasItem *fieldname; - GnomeCanvasItem *field; - GnomeCanvasItem *rect; - - gboolean has_focus; -}; - -struct _EMinicardLabelClass -{ - GnomeCanvasGroupClass parent_class; -}; - - -GtkType e_minicard_label_get_type (void); -GnomeCanvasItem *e_minicard_label_new(GnomeCanvasGroup *parent); -void e_minicard_label_construct (GnomeCanvasItem *item); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - - -#endif /* __E_MINICARD_LABEL_H__ */ diff --git a/addressbook/gui/minicard/e-minicard-view.c b/addressbook/gui/minicard/e-minicard-view.c deleted file mode 100644 index 35024d9564..0000000000 --- a/addressbook/gui/minicard/e-minicard-view.c +++ /dev/null @@ -1,281 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * e-minicard-view.c - * Copyright (C) 2000 Helix Code, Inc. - * Author: Chris Lahey - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include -#include -#include -#include "e-minicard-view.h" -#include "e-minicard.h" -static void e_minicard_view_init (EMinicardView *reflow); -static void e_minicard_view_class_init (EMinicardViewClass *klass); -static void e_minicard_view_set_arg (GtkObject *o, GtkArg *arg, guint arg_id); -static void e_minicard_view_get_arg (GtkObject *object, GtkArg *arg, guint arg_id); -static void e_minicard_view_destroy (GtkObject *object); - -#define E_MINICARD_VIEW_DIVIDER_WIDTH 2 -#define E_MINICARD_VIEW_BORDER_WIDTH 7 -#define E_MINICARD_VIEW_FULL_GUTTER (E_MINICARD_VIEW_DIVIDER_WIDTH + E_MINICARD_VIEW_BORDER_WIDTH * 2) - -static EReflowSortedClass *parent_class = NULL; - -/* The arguments we take */ -enum { - ARG_0, - ARG_BOOK, - ARG_QUERY -}; - -GtkType -e_minicard_view_get_type (void) -{ - static GtkType reflow_type = 0; - - if (!reflow_type) - { - static const GtkTypeInfo reflow_info = - { - "EMinicardView", - sizeof (EMinicardView), - sizeof (EMinicardViewClass), - (GtkClassInitFunc) e_minicard_view_class_init, - (GtkObjectInitFunc) e_minicard_view_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - reflow_type = gtk_type_unique (e_reflow_sorted_get_type (), &reflow_info); - } - - return reflow_type; -} - -static void -e_minicard_view_class_init (EMinicardViewClass *klass) -{ - GtkObjectClass *object_class; - GnomeCanvasItemClass *item_class; - - object_class = (GtkObjectClass*) klass; - item_class = (GnomeCanvasItemClass *) klass; - - parent_class = gtk_type_class (e_reflow_sorted_get_type ()); - - gtk_object_add_arg_type ("EMinicardView::book", GTK_TYPE_OBJECT, - GTK_ARG_READWRITE, ARG_BOOK); - gtk_object_add_arg_type ("EMinicardView::query", GTK_TYPE_STRING, - GTK_ARG_READWRITE, ARG_QUERY); - - object_class->set_arg = e_minicard_view_set_arg; - object_class->get_arg = e_minicard_view_get_arg; - object_class->destroy = e_minicard_view_destroy; - - /* GnomeCanvasItem method overrides */ -} - -static void -e_minicard_view_init (EMinicardView *view) -{ - view->book = NULL; - view->query = g_strdup("(contains \"full_name\" \"\")"); - view->book_view = NULL; - view->get_view_idle = 0; - view->create_card_id = 0; - view->remove_card_id = 0; - view->modify_card_id = 0; - - E_REFLOW_SORTED(view)->compare_func = (GCompareFunc) e_minicard_compare; - E_REFLOW_SORTED(view)->string_func = (EReflowStringFunc) e_minicard_get_card_id; -} - -static void -create_card(EBookView *book_view, const GList *cards, EMinicardView *view) -{ - for (; cards; cards = g_list_next(cards)) { - GnomeCanvasItem *item = gnome_canvas_item_new(GNOME_CANVAS_GROUP(view), - e_minicard_get_type(), - "card", cards->data, - NULL); - e_reflow_add_item(E_REFLOW(view), item); - } -} - -static void -modify_card(EBookView *book_view, const GList *cards, EMinicardView *view) -{ - for (; cards; cards = g_list_next(cards)) { - GnomeCanvasItem *item = gnome_canvas_item_new(GNOME_CANVAS_GROUP(view), - e_minicard_get_type(), - "card", cards->data, - NULL); - e_reflow_sorted_replace_item(E_REFLOW_SORTED(view), item); - } -} - -static void -remove_card(EBookView *book_view, const char *id, EMinicardView *view) -{ - e_reflow_sorted_remove_item(E_REFLOW_SORTED(view), id); -} - -static void -book_view_loaded (EBook *book, EBookStatus status, EBookView *book_view, gpointer closure) -{ - EMinicardView *view = closure; - if (view->book_view && view->create_card_id) - gtk_signal_disconnect(GTK_OBJECT (view->book_view), - view->create_card_id); - if (view->book_view && view->remove_card_id) - gtk_signal_disconnect(GTK_OBJECT (view->book_view), - view->remove_card_id); - if (view->book_view && view->modify_card_id) - gtk_signal_disconnect(GTK_OBJECT (view->book_view), - view->modify_card_id); - if (view->book_view) - gtk_object_unref(GTK_OBJECT(view->book_view)); - view->book_view = book_view; - if (view->book_view) - gtk_object_ref(GTK_OBJECT(view->book_view)); - view->create_card_id = gtk_signal_connect(GTK_OBJECT(view->book_view), - "card_added", - GTK_SIGNAL_FUNC(create_card), - view); - view->remove_card_id = gtk_signal_connect(GTK_OBJECT(view->book_view), - "card_removed", - GTK_SIGNAL_FUNC(remove_card), - view); - view->modify_card_id = gtk_signal_connect(GTK_OBJECT(view->book_view), - "card_changed", - GTK_SIGNAL_FUNC(modify_card), - view); - g_list_foreach(E_REFLOW(view)->items, (GFunc) gtk_object_destroy, NULL); - g_list_free(E_REFLOW(view)->items); - E_REFLOW(view)->items = NULL; - e_canvas_item_request_reflow(GNOME_CANVAS_ITEM(view)); -} - -static gboolean -get_view(EMinicardView *view) -{ - e_book_get_book_view(view->book, view->query, book_view_loaded, view); - - view->get_view_idle = 0; - return FALSE; -} - -static void -e_minicard_view_set_arg (GtkObject *o, GtkArg *arg, guint arg_id) -{ - GnomeCanvasItem *item; - EMinicardView *view; - - item = GNOME_CANVAS_ITEM (o); - view = E_MINICARD_VIEW (o); - - switch (arg_id){ - case ARG_BOOK: - if (view->book) - gtk_object_unref(GTK_OBJECT(view->book)); - view->book = E_BOOK(GTK_VALUE_OBJECT (*arg)); - if (view->book) { - gtk_object_ref(GTK_OBJECT(view->book)); - if (view->get_view_idle == 0) - view->get_view_idle = g_idle_add((GSourceFunc)get_view, view); - } - break; - case ARG_QUERY: - if (view->query) - g_free(view->query); - view->query = g_strdup(GTK_VALUE_STRING (*arg)); - if (view->get_view_idle == 0) - view->get_view_idle = g_idle_add((GSourceFunc)get_view, view); - break; - } -} - -static void -e_minicard_view_get_arg (GtkObject *object, GtkArg *arg, guint arg_id) -{ - EMinicardView *e_minicard_view; - - e_minicard_view = E_MINICARD_VIEW (object); - - switch (arg_id) { - case ARG_BOOK: - GTK_VALUE_OBJECT (*arg) = GTK_OBJECT(e_minicard_view->book); - break; - case ARG_QUERY: - GTK_VALUE_STRING (*arg) = g_strdup(e_minicard_view->query); - break; - default: - arg->type = GTK_TYPE_INVALID; - break; - } -} - -static void -e_minicard_view_destroy (GtkObject *object) -{ - EMinicardView *view = E_MINICARD_VIEW(object); - - if (view->get_view_idle) - g_source_remove(view->get_view_idle); - if (view->book) - gtk_object_unref(GTK_OBJECT(view->book)); - if (view->book_view && view->create_card_id) - gtk_signal_disconnect(GTK_OBJECT (view->book_view), - view->create_card_id); - if (view->book_view && view->remove_card_id) - gtk_signal_disconnect(GTK_OBJECT (view->book_view), - view->remove_card_id); - if (view->book_view && view->modify_card_id) - gtk_signal_disconnect(GTK_OBJECT (view->book_view), - view->modify_card_id); - if (view->book_view) - gtk_object_unref(GTK_OBJECT(view->book_view)); -} - -void -e_minicard_view_remove_selection(EMinicardView *view, - EBookCallback cb, - gpointer closure) -{ - if (view->book) { - EReflow *reflow = E_REFLOW(view); - GList *list; - for (list = reflow->items; list; list = g_list_next(list)) { - GnomeCanvasItem *item = list->data; - gboolean has_focus; - gtk_object_get(GTK_OBJECT(item), - "has_focus", &has_focus, - NULL); - if (has_focus) { - ECard *card; - gtk_object_get(GTK_OBJECT(item), - "card", &card, - NULL); - e_book_remove_card(view->book, card, cb, closure); - return; - } - } - } -} diff --git a/addressbook/gui/minicard/e-minicard-view.h b/addressbook/gui/minicard/e-minicard-view.h deleted file mode 100644 index ab0eeb892d..0000000000 --- a/addressbook/gui/minicard/e-minicard-view.h +++ /dev/null @@ -1,91 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* e-minicard-view.h - * Copyright (C) 2000 Helix Code, Inc. - * Author: Chris Lahey - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ -#ifndef __E_MINICARD_VIEW_H__ -#define __E_MINICARD_VIEW_H__ - -#include -#include "e-reflow-sorted.h" -#include - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - -/* EMinicardView - A canvas item container. - * - * The following arguments are available: - * - * name type read/write description - * -------------------------------------------------------------------------------- - * book EBook RW book to query - * query string RW query string - * - * From EReflowSorted: (you should really know what you're doing if you set these.) - * compare_func GCompareFunc RW compare function - * string_func EReflowStringFunc RW string function - * - * From EReflow: - * minimum_width double RW minimum width of the reflow. width >= minimum_width - * width double R width of the reflow - * height double RW height of the reflow - */ - -#define E_MINICARD_VIEW_TYPE (e_minicard_view_get_type ()) -#define E_MINICARD_VIEW(obj) (GTK_CHECK_CAST ((obj), E_MINICARD_VIEW_TYPE, EMinicardView)) -#define E_MINICARD_VIEW_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_MINICARD_VIEW_TYPE, EMinicardViewClass)) -#define E_IS_MINICARD_VIEW(obj) (GTK_CHECK_TYPE ((obj), E_MINICARD_VIEW_TYPE)) -#define E_IS_MINICARD_VIEW_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), E_MINICARD_VIEW_TYPE)) - - -typedef struct _EMinicardView EMinicardView; -typedef struct _EMinicardViewClass EMinicardViewClass; - -struct _EMinicardView -{ - EReflowSorted parent; - - /* item specific fields */ - EBook *book; - char *query; - EBookView *book_view; - - int get_view_idle; - - int create_card_id, remove_card_id, modify_card_id; -}; - -struct _EMinicardViewClass -{ - EReflowSortedClass parent_class; -}; - -GtkType e_minicard_view_get_type (void); -void e_minicard_view_remove_selection (EMinicardView *view, - EBookCallback cb, - gpointer closure); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - - -#endif /* __E_MINICARD_VIEW_H__ */ diff --git a/addressbook/gui/minicard/e-minicard.c b/addressbook/gui/minicard/e-minicard.c deleted file mode 100644 index addb019510..0000000000 --- a/addressbook/gui/minicard/e-minicard.c +++ /dev/null @@ -1,625 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * e-minicard.c - * Copyright (C) 2000 Helix Code, Inc. - * Author: Chris Lahey - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include -#include -#include "e-minicard.h" -#include "e-minicard-label.h" -#include "e-text.h" -#include -#include -#include -#include -#include "e-contact-editor.h" -#include "e-minicard-view.h" - -static void e_minicard_init (EMinicard *card); -static void e_minicard_class_init (EMinicardClass *klass); -static void e_minicard_set_arg (GtkObject *o, GtkArg *arg, guint arg_id); -static void e_minicard_get_arg (GtkObject *object, GtkArg *arg, guint arg_id); -static void e_minicard_destroy (GtkObject *object); -static gboolean e_minicard_event (GnomeCanvasItem *item, GdkEvent *event); -static void e_minicard_realize (GnomeCanvasItem *item); -static void e_minicard_unrealize (GnomeCanvasItem *item); -static void e_minicard_reflow ( GnomeCanvasItem *item, int flags ); - -static void e_minicard_resize_children( EMinicard *e_minicard ); -static void remodel( EMinicard *e_minicard ); - -static GnomeCanvasGroupClass *parent_class = NULL; - -/* The arguments we take */ -enum { - ARG_0, - ARG_WIDTH, - ARG_HEIGHT, - ARG_HAS_FOCUS, - ARG_CARD -}; - -GtkType -e_minicard_get_type (void) -{ - static GtkType minicard_type = 0; - - if (!minicard_type) - { - static const GtkTypeInfo minicard_info = - { - "EMinicard", - sizeof (EMinicard), - sizeof (EMinicardClass), - (GtkClassInitFunc) e_minicard_class_init, - (GtkObjectInitFunc) e_minicard_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - minicard_type = gtk_type_unique (gnome_canvas_group_get_type (), &minicard_info); - } - - return minicard_type; -} - -static void -e_minicard_class_init (EMinicardClass *klass) -{ - GtkObjectClass *object_class; - GnomeCanvasItemClass *item_class; - - object_class = (GtkObjectClass*) klass; - item_class = (GnomeCanvasItemClass *) klass; - - parent_class = gtk_type_class (gnome_canvas_group_get_type ()); - - gtk_object_add_arg_type ("EMinicard::width", GTK_TYPE_DOUBLE, - GTK_ARG_READWRITE, ARG_WIDTH); - gtk_object_add_arg_type ("EMinicard::height", GTK_TYPE_DOUBLE, - GTK_ARG_READABLE, ARG_HEIGHT); - gtk_object_add_arg_type ("EMinicard::has_focus", GTK_TYPE_ENUM, - GTK_ARG_READWRITE, ARG_HAS_FOCUS); - gtk_object_add_arg_type ("EMinicard::card", GTK_TYPE_OBJECT, - GTK_ARG_READWRITE, ARG_CARD); - - object_class->set_arg = e_minicard_set_arg; - object_class->get_arg = e_minicard_get_arg; - object_class->destroy = e_minicard_destroy; - - /* GnomeCanvasItem method overrides */ - item_class->realize = e_minicard_realize; - item_class->unrealize = e_minicard_unrealize; - item_class->event = e_minicard_event; -} - -static void -e_minicard_init (EMinicard *minicard) -{ - /* minicard->card = NULL;*/ - minicard->rect = NULL; - minicard->fields = NULL; - minicard->width = 10; - minicard->height = 10; - minicard->has_focus = FALSE; - - minicard->card = NULL; - - e_canvas_item_set_reflow_callback(GNOME_CANVAS_ITEM(minicard), e_minicard_reflow); -} - -static void -e_minicard_set_arg (GtkObject *o, GtkArg *arg, guint arg_id) -{ - GnomeCanvasItem *item; - EMinicard *e_minicard; - - item = GNOME_CANVAS_ITEM (o); - e_minicard = E_MINICARD (o); - - switch (arg_id){ - case ARG_WIDTH: - if (e_minicard->width != GTK_VALUE_DOUBLE (*arg)) { - e_minicard->width = GTK_VALUE_DOUBLE (*arg); - e_minicard_resize_children(e_minicard); - if ( GTK_OBJECT_FLAGS( e_minicard ) & GNOME_CANVAS_ITEM_REALIZED ) - e_canvas_item_request_reflow(item); - } - break; - case ARG_HAS_FOCUS: - if (e_minicard->fields) { - if ( GTK_VALUE_ENUM(*arg) == E_FOCUS_START || - GTK_VALUE_ENUM(*arg) == E_FOCUS_CURRENT) { - gnome_canvas_item_set(GNOME_CANVAS_ITEM(e_minicard->fields->data), - "has_focus", GTK_VALUE_ENUM(*arg), - NULL); - } else if ( GTK_VALUE_ENUM(*arg) == E_FOCUS_END ) { - gnome_canvas_item_set(GNOME_CANVAS_ITEM(g_list_last(e_minicard->fields)->data), - "has_focus", GTK_VALUE_ENUM(*arg), - NULL); - } - } - else - e_canvas_item_grab_focus(item); - break; - case ARG_CARD: - if (e_minicard->card) - gtk_object_unref (GTK_OBJECT(e_minicard->card)); - e_minicard->card = E_CARD(GTK_VALUE_OBJECT (*arg)); - if (e_minicard->card) - gtk_object_ref (GTK_OBJECT(e_minicard->card)); - remodel(e_minicard); - e_canvas_item_request_reflow(item); - break; - } -} - -static void -e_minicard_get_arg (GtkObject *object, GtkArg *arg, guint arg_id) -{ - EMinicard *e_minicard; - - e_minicard = E_MINICARD (object); - - switch (arg_id) { - case ARG_WIDTH: - GTK_VALUE_DOUBLE (*arg) = e_minicard->width; - break; - case ARG_HEIGHT: - GTK_VALUE_DOUBLE (*arg) = e_minicard->height; - break; - case ARG_HAS_FOCUS: - GTK_VALUE_ENUM (*arg) = e_minicard->has_focus ? E_FOCUS_CURRENT : E_FOCUS_NONE; - break; - case ARG_CARD: - GTK_VALUE_OBJECT (*arg) = GTK_OBJECT(e_minicard->card); - break; - default: - arg->type = GTK_TYPE_INVALID; - break; - } -} - -static void -e_minicard_destroy (GtkObject *object) -{ - EMinicard *e_minicard; - - g_return_if_fail (object != NULL); - g_return_if_fail (E_IS_MINICARD (object)); - - e_minicard = E_MINICARD (object); - - if (e_minicard->card) - gtk_object_unref (GTK_OBJECT(e_minicard->card)); - - if (GTK_OBJECT_CLASS (parent_class)->destroy) - (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); -} - -static void -e_minicard_realize (GnomeCanvasItem *item) -{ - EMinicard *e_minicard; - GnomeCanvasGroup *group; - - e_minicard = E_MINICARD (item); - group = GNOME_CANVAS_GROUP( item ); - - if (GNOME_CANVAS_ITEM_CLASS(parent_class)->realize) - (* GNOME_CANVAS_ITEM_CLASS(parent_class)->realize) (item); - - e_minicard->rect = - gnome_canvas_item_new( group, - gnome_canvas_rect_get_type(), - "x1", (double) 0, - "y1", (double) 0, - "x2", (double) e_minicard->width - 1, - "y2", (double) e_minicard->height - 1, - "outline_color", NULL, - NULL ); - - e_minicard->header_rect = - gnome_canvas_item_new( group, - gnome_canvas_rect_get_type(), - "x1", (double) 2, - "y1", (double) 2, - "x2", (double) e_minicard->width - 3, - "y2", (double) e_minicard->height - 3, - "fill_color", "grey70", - NULL ); - - e_minicard->header_text = - gnome_canvas_item_new( group, - e_text_get_type(), - "anchor", GTK_ANCHOR_NW, - "width", (double) ( e_minicard->width - 12 ), - "clip", TRUE, - "use_ellipsis", TRUE, - "font", "lucidasans-bold-10", - "fill_color", "black", - "text", "", - NULL ); - e_canvas_item_move_absolute(e_minicard->header_text, 6, 6); - - remodel(e_minicard); - e_canvas_item_request_reflow(item); - - if (!item->canvas->aa) { - } -} - -static void -e_minicard_unrealize (GnomeCanvasItem *item) -{ - EMinicard *e_minicard; - - e_minicard = E_MINICARD (item); - - if (!item->canvas->aa) - { - } - - if (GNOME_CANVAS_ITEM_CLASS(parent_class)->unrealize) - (* GNOME_CANVAS_ITEM_CLASS(parent_class)->unrealize) (item); -} - -static void -card_changed_cb (EBook* book, EBookStatus status, gpointer user_data) -{ - g_print ("%s: %s(): a card was changed\n", __FILE__, __FUNCTION__); -} - -static gboolean -e_minicard_event (GnomeCanvasItem *item, GdkEvent *event) -{ - EMinicard *e_minicard; - - e_minicard = E_MINICARD (item); - - switch( event->type ) { - case GDK_FOCUS_CHANGE: - { - GdkEventFocus *focus_event = (GdkEventFocus *) event; - if ( focus_event->in ) { - gnome_canvas_item_set( e_minicard->rect, - "outline_color", "grey50", - NULL ); - gnome_canvas_item_set( e_minicard->header_rect, - "fill_color", "darkblue", - NULL ); - gnome_canvas_item_set( e_minicard->header_text, - "fill_color", "white", - NULL ); - e_minicard->has_focus = TRUE; - } else { - gnome_canvas_item_set( e_minicard->rect, - "outline_color", NULL, - NULL ); - gnome_canvas_item_set( e_minicard->header_rect, - "fill_color", "grey70", - NULL ); - gnome_canvas_item_set( e_minicard->header_text, - "fill_color", "black", - NULL ); - e_minicard->has_focus = FALSE; - } - } - break; - case GDK_BUTTON_PRESS: - if (event->button.button == 1) { - e_canvas_item_grab_focus(item); - } - break; - case GDK_2BUTTON_PRESS: - if (E_IS_MINICARD_VIEW(item->parent)) { - gint result; - GtkWidget* contact_editor = - e_contact_editor_new(e_minicard->card); - EBook *book; - GtkWidget *dlg; - gtk_object_get(GTK_OBJECT(item->parent), - "book", &book, - NULL); - - dlg = gnome_dialog_new ("Contact Editor", "Save", "Cancel", NULL); - - g_assert (E_IS_BOOK (book)); - - gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (dlg)->vbox), - contact_editor, TRUE, TRUE, 0); - - gtk_widget_show_all (dlg); - - gnome_dialog_close_hides (GNOME_DIALOG (dlg), TRUE); - result = gnome_dialog_run_and_close (GNOME_DIALOG (dlg)); - - - /* If the user clicks "okay"...*/ - if (result == 0) { - ECard *card; - g_assert (contact_editor); - g_assert (GTK_IS_OBJECT (contact_editor)); - gtk_object_get(GTK_OBJECT(contact_editor), - "card", &card, - NULL); - - /* Add the card in the contact editor to our ebook */ - e_book_commit_card (book, - card, - card_changed_cb, - NULL); - } - } - break; - case GDK_KEY_PRESS: - if (event->key.keyval == GDK_Tab || - event->key.keyval == GDK_KP_Tab || - event->key.keyval == GDK_ISO_Left_Tab) { - GList *list; - for (list = e_minicard->fields; list; list = list->next) { - GnomeCanvasItem *item = GNOME_CANVAS_ITEM (list->data); - EFocus has_focus; - gtk_object_get(GTK_OBJECT(item), - "has_focus", &has_focus, - NULL); - if (has_focus != E_FOCUS_NONE) { - if (event->key.state & GDK_SHIFT_MASK) - list = list->prev; - else - list = list->next; - if (list) { - item = GNOME_CANVAS_ITEM (list->data); - gnome_canvas_item_set(item, - "has_focus", (event->key.state & GDK_SHIFT_MASK) ? E_FOCUS_END : E_FOCUS_START, - NULL); - return 1; - } else { - return 0; - } - } - } - } - default: - break; - } - - if (GNOME_CANVAS_ITEM_CLASS( parent_class )->event) - return (* GNOME_CANVAS_ITEM_CLASS( parent_class )->event) (item, event); - else - return 0; -} - -static void -e_minicard_resize_children( EMinicard *e_minicard ) -{ - if ( GTK_OBJECT_FLAGS( e_minicard ) & GNOME_CANVAS_ITEM_REALIZED ) { - GList *list; - - gnome_canvas_item_set( e_minicard->header_text, - "width", (double) e_minicard->width - 12, - NULL ); - for ( list = e_minicard->fields; list; list = g_list_next( list ) ) { - gnome_canvas_item_set( GNOME_CANVAS_ITEM( list->data ), - "width", (double) e_minicard->width - 4.0, - NULL ); - } - } -} - -static void -add_field (EMinicard *e_minicard, char *fieldname, char* field) -{ - GnomeCanvasItem *new_item; - GnomeCanvasGroup *group; - - group = GNOME_CANVAS_GROUP( e_minicard ); - - new_item = e_minicard_label_new(group); - gnome_canvas_item_set( new_item, - "width", e_minicard->width - 4.0, - "fieldname", fieldname, - "field", field, - NULL ); - e_minicard->fields = g_list_append( e_minicard->fields, new_item); - e_canvas_item_move_absolute(new_item, 2, e_minicard->height); -} - - -static void -remodel( EMinicard *e_minicard ) -{ - if (e_minicard->card) { - char *fname; - char *url; - char *org; - char *title; - char *role; - ECardList *address_list; - ECardList *phone_list; - ECardList *email_list; - - ECardIterator *iterator; - - GList *list; - - for ( list = e_minicard->fields; list; list = g_list_next( list ) ) { - gtk_object_destroy( GTK_OBJECT( list->data ) ); - } - g_list_free(e_minicard->fields); - e_minicard->fields = NULL; - - gtk_object_get(GTK_OBJECT(e_minicard->card), - "full_name", &fname, - "address", &address_list, - "phone", &phone_list, - "email", &email_list, - "url", &url, - "org", &org, - "title", &title, - "role", &role, - NULL); - - if (fname) { - add_field(e_minicard, "Name:", fname); - if (e_minicard->header_text) - gnome_canvas_item_set(e_minicard->header_text, - "text", fname, - NULL); - } else - if (e_minicard->header_text) - gnome_canvas_item_set(e_minicard->header_text, - "text", "", - NULL); - - if (org) - add_field(e_minicard, "Company:", org); - - if (title) - add_field(e_minicard, "Title:", title); - - if (role) - add_field(e_minicard, "Profession:", role); - - if (address_list) { - for (iterator = e_card_list_get_iterator(address_list); e_card_iterator_is_valid(iterator); e_card_iterator_next(iterator)) { - const ECardDeliveryAddress *address = e_card_iterator_get(iterator); - if (address->flags & ADDR_WORK) { - add_field(e_minicard, "Work Address:", address->city); - } else if (address->flags & ADDR_HOME) { - add_field(e_minicard, "Home Address:", address->city); - } else { - add_field(e_minicard, "Address:", address->city); - } - } - } - if (phone_list) { - for (iterator = e_card_list_get_iterator(phone_list); e_card_iterator_is_valid(iterator); e_card_iterator_next(iterator)) { - const ECardPhone *phone = e_card_iterator_get(iterator); - if (phone->flags & E_CARD_PHONE_WORK) { - add_field(e_minicard, "Work Phone:", phone->number); - } else if (phone->flags & E_CARD_PHONE_HOME) { - add_field(e_minicard, "Home Phone:", phone->number); - } else if (phone->flags & E_CARD_PHONE_CELL) { - add_field(e_minicard, "Mobile Phone:", phone->number); - } else { - add_field(e_minicard, "Phone:", phone->number); - } - } - } - if (email_list) { - for (iterator = e_card_list_get_iterator(email_list); e_card_iterator_is_valid(iterator); e_card_iterator_next(iterator)) { - add_field(e_minicard, "Email:", (char *) e_card_iterator_get(iterator)); - } - } - - if (url) - add_field(e_minicard, "Web page:", url); - } -} - -static void -e_minicard_reflow( GnomeCanvasItem *item, int flags ) -{ - EMinicard *e_minicard = E_MINICARD(item); - if ( GTK_OBJECT_FLAGS( e_minicard ) & GNOME_CANVAS_ITEM_REALIZED ) { - GList *list; - gdouble text_height; - gint old_height; - - old_height = e_minicard->height; - - gtk_object_get( GTK_OBJECT( e_minicard->header_text ), - "text_height", &text_height, - NULL ); - - e_minicard->height = text_height + 10.0; - - gnome_canvas_item_set( e_minicard->header_rect, - "y2", text_height + 9.0, - NULL ); - - for(list = e_minicard->fields; list; list = g_list_next(list)) { - gtk_object_get (GTK_OBJECT(list->data), - "height", &text_height, - NULL); - e_canvas_item_move_absolute(GNOME_CANVAS_ITEM(list->data), 2, e_minicard->height); - e_minicard->height += text_height; - } - e_minicard->height += 2; - - gnome_canvas_item_set( e_minicard->rect, - "y2", (double) e_minicard->height - 1, - NULL ); - - gnome_canvas_item_set( e_minicard->rect, - "x2", (double) e_minicard->width - 1.0, - "y2", (double) e_minicard->height - 1.0, - NULL ); - gnome_canvas_item_set( e_minicard->header_rect, - "x2", (double) e_minicard->width - 3.0, - NULL ); - - if (old_height != e_minicard->height) - e_canvas_item_request_parent_reflow(item); - } -} - -char * -e_minicard_get_card_id (EMinicard *minicard) -{ - g_return_val_if_fail(minicard != NULL, NULL); - g_return_val_if_fail(E_IS_MINICARD(minicard), NULL); - - if (minicard->card) { - return e_card_get_id(minicard->card); - } else { - return NULL; - } -} - -int -e_minicard_compare (EMinicard *minicard1, EMinicard *minicard2) -{ - g_return_val_if_fail(minicard1 != NULL, 0); - g_return_val_if_fail(E_IS_MINICARD(minicard1), 0); - g_return_val_if_fail(minicard2 != NULL, 0); - g_return_val_if_fail(E_IS_MINICARD(minicard2), 0); - - if (minicard1->card && minicard2->card) { - char *fname1, *fname2; - gtk_object_get(GTK_OBJECT(minicard1->card), - "full_name", &fname1, - NULL); - gtk_object_get(GTK_OBJECT(minicard2->card), - "full_name", &fname2, - NULL); - if (fname1 && fname2) - return strcmp(fname1, fname2); - if (fname1) - return -1; - if (fname2) - return 1; - return 0; - } else { - return 0; - } -} diff --git a/addressbook/gui/minicard/e-minicard.h b/addressbook/gui/minicard/e-minicard.h deleted file mode 100644 index 6844e136bd..0000000000 --- a/addressbook/gui/minicard/e-minicard.h +++ /dev/null @@ -1,97 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* e-minicard.h - * Copyright (C) 2000 Helix Code, Inc. - * Author: Chris Lahey - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ -#ifndef __E_MINICARD_H__ -#define __E_MINICARD_H__ - -#include -#include - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - -/* EMinicard - A small card displaying information about a contact. - * - * The following arguments are available: - * - * name type read/write description - * -------------------------------------------------------------------------------- - * width double RW width of the card - * height double R height of the card - * card ECard* RW Pointer to the ECard - */ - -#define E_MINICARD_TYPE (e_minicard_get_type ()) -#define E_MINICARD(obj) (GTK_CHECK_CAST ((obj), E_MINICARD_TYPE, EMinicard)) -#define E_MINICARD_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_MINICARD_TYPE, EMinicardClass)) -#define E_IS_MINICARD(obj) (GTK_CHECK_TYPE ((obj), E_MINICARD_TYPE)) -#define E_IS_MINICARD_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), E_MINICARD_TYPE)) - - -typedef struct _EMinicard EMinicard; -typedef struct _EMinicardClass EMinicardClass; -typedef enum _EMinicardFocusType EMinicardFocusType; - -enum _EMinicardFocusType { - E_MINICARD_FOCUS_TYPE_START, - E_MINICARD_FOCUS_TYPE_END -}; - -struct _EMinicard -{ - GnomeCanvasGroup parent; - - /* item specific fields */ - /* ECard *card; */ - - GnomeCanvasItem *rect; - GnomeCanvasItem *header_rect; - GnomeCanvasItem *header_text; - GList *fields; /* Of type GnomeCanvasItem. */ - - ECard *card; - guint needs_remodeling : 1; - - gboolean has_focus; - - double width; - double height; -}; - -struct _EMinicardClass -{ - GnomeCanvasGroupClass parent_class; - - void (* resize) (EMinicard *minicard); -}; - - -GtkType e_minicard_get_type (void); -char *e_minicard_get_card_id (EMinicard *minicard); -int e_minicard_compare (EMinicard *minicard1, EMinicard *minicard2); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - - -#endif /* __E_MINICARD_H__ */ diff --git a/addressbook/gui/minicard/e-reflow-sorted.c b/addressbook/gui/minicard/e-reflow-sorted.c deleted file mode 100644 index c70d7b2739..0000000000 --- a/addressbook/gui/minicard/e-reflow-sorted.c +++ /dev/null @@ -1,186 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * e-reflow-sorted.c - * Copyright (C) 2000 Helix Code, Inc. - * Author: Chris Lahey - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include -#include -#include -#include "e-reflow-sorted.h" -#include -#include -#include - -static void e_reflow_sorted_init (EReflowSorted *card); -static void e_reflow_sorted_class_init (EReflowSortedClass *klass); -static void e_reflow_sorted_set_arg (GtkObject *o, GtkArg *arg, guint arg_id); -static void e_reflow_sorted_get_arg (GtkObject *object, GtkArg *arg, guint arg_id); -static void e_reflow_sorted_add_item(EReflow *e_reflow, GnomeCanvasItem *item); - -static EReflowClass *parent_class = NULL; - -/* The arguments we take */ -enum { - ARG_0, - ARG_COMPARE_FUNC, - ARG_STRING_FUNC -}; - -GtkType -e_reflow_sorted_get_type (void) -{ - static GtkType reflow_type = 0; - - if (!reflow_type) - { - static const GtkTypeInfo reflow_info = - { - "EReflowSorted", - sizeof (EReflowSorted), - sizeof (EReflowSortedClass), - (GtkClassInitFunc) e_reflow_sorted_class_init, - (GtkObjectInitFunc) e_reflow_sorted_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - reflow_type = gtk_type_unique (e_reflow_get_type (), &reflow_info); - } - - return reflow_type; -} - -static void -e_reflow_sorted_class_init (EReflowSortedClass *klass) -{ - GtkObjectClass *object_class; - EReflowClass *reflow_class; - - object_class = (GtkObjectClass*) klass; - reflow_class = E_REFLOW_CLASS (klass); - - parent_class = gtk_type_class (e_reflow_get_type ()); - - gtk_object_add_arg_type ("EReflowSorted::compare_func", GTK_TYPE_POINTER, - GTK_ARG_READWRITE, ARG_COMPARE_FUNC); - gtk_object_add_arg_type ("EReflowSorted::string_func", GTK_TYPE_POINTER, - GTK_ARG_READWRITE, ARG_STRING_FUNC); - - reflow_class->add_item = e_reflow_sorted_add_item; - - object_class->set_arg = e_reflow_sorted_set_arg; - object_class->get_arg = e_reflow_sorted_get_arg; -} - -static void -e_reflow_sorted_init (EReflowSorted *reflow) -{ - reflow->compare_func = NULL; - reflow->string_func = NULL; -} - -static void -e_reflow_sorted_set_arg (GtkObject *o, GtkArg *arg, guint arg_id) -{ - GnomeCanvasItem *item; - EReflowSorted *e_reflow_sorted; - - item = GNOME_CANVAS_ITEM (o); - e_reflow_sorted = E_REFLOW_SORTED (o); - - switch (arg_id){ - case ARG_COMPARE_FUNC: - e_reflow_sorted->compare_func = GTK_VALUE_POINTER (*arg); - break; - case ARG_STRING_FUNC: - e_reflow_sorted->string_func = GTK_VALUE_POINTER (*arg); - break; - } -} - -static void -e_reflow_sorted_get_arg (GtkObject *object, GtkArg *arg, guint arg_id) -{ - EReflowSorted *e_reflow_sorted; - - e_reflow_sorted = E_REFLOW_SORTED (object); - - switch (arg_id) { - case ARG_COMPARE_FUNC: - GTK_VALUE_POINTER (*arg) = e_reflow_sorted->compare_func; - break; - case ARG_STRING_FUNC: - GTK_VALUE_POINTER (*arg) = e_reflow_sorted->string_func; - break; - default: - arg->type = GTK_TYPE_INVALID; - break; - } -} - -void -e_reflow_sorted_remove_item(EReflowSorted *e_reflow_sorted, const gchar *id) -{ - if (e_reflow_sorted->string_func) { - EReflow *reflow = E_REFLOW(e_reflow_sorted); - GList *list; - for (list = reflow->items; list; list = g_list_next(list)) { - GnomeCanvasItem *item = list->data; - char *string = e_reflow_sorted->string_func (item); - if (string && !strcmp(string, id)) { - reflow->items = g_list_remove_link(reflow->items, list); - g_list_free_1(list); - gtk_object_destroy(GTK_OBJECT(item)); - if ( GTK_OBJECT_FLAGS( e_reflow_sorted ) & GNOME_CANVAS_ITEM_REALIZED ) { - e_canvas_item_request_reflow(item); - } - return; - } - } - } -} - -void -e_reflow_sorted_replace_item(EReflowSorted *e_reflow_sorted, GnomeCanvasItem *item) -{ - if (e_reflow_sorted->string_func) { - char *string = e_reflow_sorted->string_func (item); - e_reflow_sorted_remove_item(e_reflow_sorted, string); - e_reflow_sorted_add_item(E_REFLOW(e_reflow_sorted), item); - } -} - - -static void -e_reflow_sorted_add_item(EReflow *reflow, GnomeCanvasItem *item) -{ - EReflowSorted *e_reflow_sorted = E_REFLOW_SORTED(reflow); - if ( e_reflow_sorted->compare_func ) { - reflow->items = g_list_insert_sorted(reflow->items, item, e_reflow_sorted->compare_func); - - if ( GTK_OBJECT_FLAGS( e_reflow_sorted ) & GNOME_CANVAS_ITEM_REALIZED ) { - gnome_canvas_item_set(item, - "width", (double) reflow->column_width, - NULL); - e_canvas_item_request_reflow(item); - } - } -} diff --git a/addressbook/gui/minicard/e-reflow-sorted.h b/addressbook/gui/minicard/e-reflow-sorted.h deleted file mode 100644 index 4ffec7579b..0000000000 --- a/addressbook/gui/minicard/e-reflow-sorted.h +++ /dev/null @@ -1,87 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* e-reflow-sorted.h - * Copyright (C) 2000 Helix Code, Inc. - * Author: Chris Lahey - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ -#ifndef __E_REFLOW_SORTED_H__ -#define __E_REFLOW_SORTED_H__ - -#include - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - -/* EReflowSorted - A canvas item container. - * - * The following arguments are available: - * - * name type read/write description - * -------------------------------------------------------------------------------- - * compare_func GCompareFunc RW compare function - * string_func EReflowStringFunc RW string function - * - * From EReflow: - * minimum_width double RW minimum width of the reflow. width >= minimum_width - * width double R width of the reflow - * height double RW height of the reflow - */ - -#define E_REFLOW_SORTED_TYPE (e_reflow_sorted_get_type ()) -#define E_REFLOW_SORTED(obj) (GTK_CHECK_CAST ((obj), E_REFLOW_SORTED_TYPE, EReflowSorted)) -#define E_REFLOW_SORTED_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_REFLOW_SORTED_TYPE, EReflowSortedClass)) -#define E_IS_REFLOW_SORTED(obj) (GTK_CHECK_TYPE ((obj), E_REFLOW_SORTED_TYPE)) -#define E_IS_REFLOW_SORTED_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), E_REFLOW_SORTED_TYPE)) - -typedef char * (* EReflowStringFunc) (GnomeCanvasItem *); - -typedef struct _EReflowSorted EReflowSorted; -typedef struct _EReflowSortedClass EReflowSortedClass; - -/* FIXME: Try reimplementing this as a hash table with key as string - and change EReflow to use a GTree. */ -struct _EReflowSorted -{ - EReflow parent; - - /* item specific fields */ - GCompareFunc compare_func; - EReflowStringFunc string_func; -}; - -struct _EReflowSortedClass -{ - EReflowClass parent_class; -}; - -/* - * To be added to a reflow, an item must have the argument "width" as - * a Read/Write argument and "height" as a Read Only argument. It - * should also do an ECanvas parent reflow request if its size - * changes. - */ -void e_reflow_sorted_remove_item (EReflowSorted *sorted, const char *id); -void e_reflow_sorted_replace_item (EReflowSorted *sorted, GnomeCanvasItem *item); -GtkType e_reflow_sorted_get_type (void); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* __E_REFLOW_SORTED_H__ */ diff --git a/addressbook/gui/minicard/e-reflow.c b/addressbook/gui/minicard/e-reflow.c deleted file mode 100644 index 6706357ede..0000000000 --- a/addressbook/gui/minicard/e-reflow.c +++ /dev/null @@ -1,772 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * e-reflow.c - * Copyright (C) 2000 Helix Code, Inc. - * Author: Chris Lahey - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include -#include -#include -#include "e-reflow.h" -#include -#include -#include - -static void e_reflow_init (EReflow *reflow); -static void e_reflow_class_init (EReflowClass *klass); -static void e_reflow_set_arg (GtkObject *o, GtkArg *arg, guint arg_id); -static void e_reflow_get_arg (GtkObject *object, GtkArg *arg, guint arg_id); -static void e_reflow_destroy (GtkObject *object); -static gboolean e_reflow_event (GnomeCanvasItem *item, GdkEvent *event); -static void e_reflow_realize (GnomeCanvasItem *item); -static void e_reflow_unrealize (GnomeCanvasItem *item); -static void e_reflow_draw (GnomeCanvasItem *item, GdkDrawable *drawable, - int x, int y, int width, int height); -static void e_reflow_update (GnomeCanvasItem *item, double affine[6], ArtSVP *clip_path, gint flags); -static double e_reflow_point (GnomeCanvasItem *item, double x, double y, int cx, int cy, GnomeCanvasItem **actual_item); -static void e_reflow_reflow (GnomeCanvasItem *item, int flags); -static void e_reflow_real_add_item(EReflow *e_reflow, GnomeCanvasItem *item); - -static void e_reflow_resize_children (GnomeCanvasItem *item); - -#define E_REFLOW_DIVIDER_WIDTH 2 -#define E_REFLOW_BORDER_WIDTH 7 -#define E_REFLOW_FULL_GUTTER (E_REFLOW_DIVIDER_WIDTH + E_REFLOW_BORDER_WIDTH * 2) - -static GnomeCanvasGroupClass *parent_class = NULL; - -/* The arguments we take */ -enum { - ARG_0, - ARG_MINIMUM_WIDTH, - ARG_WIDTH, - ARG_HEIGHT -}; - -GtkType -e_reflow_get_type (void) -{ - static GtkType reflow_type = 0; - - if (!reflow_type) - { - static const GtkTypeInfo reflow_info = - { - "EReflow", - sizeof (EReflow), - sizeof (EReflowClass), - (GtkClassInitFunc) e_reflow_class_init, - (GtkObjectInitFunc) e_reflow_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - reflow_type = gtk_type_unique (gnome_canvas_group_get_type (), &reflow_info); - } - - return reflow_type; -} - -static void -e_reflow_class_init (EReflowClass *klass) -{ - GtkObjectClass *object_class; - GnomeCanvasItemClass *item_class; - - object_class = (GtkObjectClass*) klass; - item_class = (GnomeCanvasItemClass *) klass; - - parent_class = gtk_type_class (gnome_canvas_group_get_type ()); - - gtk_object_add_arg_type ("EReflow::minimum_width", GTK_TYPE_DOUBLE, - GTK_ARG_READWRITE, ARG_MINIMUM_WIDTH); - gtk_object_add_arg_type ("EReflow::width", GTK_TYPE_DOUBLE, - GTK_ARG_READABLE, ARG_WIDTH); - gtk_object_add_arg_type ("EReflow::height", GTK_TYPE_DOUBLE, - GTK_ARG_READWRITE, ARG_HEIGHT); - - klass->add_item = e_reflow_real_add_item; - - object_class->set_arg = e_reflow_set_arg; - object_class->get_arg = e_reflow_get_arg; - object_class->destroy = e_reflow_destroy; - - /* GnomeCanvasItem method overrides */ - item_class->event = e_reflow_event; - item_class->realize = e_reflow_realize; - item_class->unrealize = e_reflow_unrealize; - item_class->draw = e_reflow_draw; - item_class->update = e_reflow_update; - item_class->point = e_reflow_point; -} - -static void -e_reflow_init (EReflow *reflow) -{ - reflow->items = NULL; - reflow->columns = NULL; - reflow->column_width = 150; - - reflow->minimum_width = 10; - reflow->width = 10; - reflow->height = 10; - reflow->idle = 0; - - reflow->column_drag = FALSE; - - reflow->need_height_update = FALSE; - reflow->need_column_resize = FALSE; - - reflow->default_cursor_shown = TRUE; - reflow->arrow_cursor = NULL; - reflow->default_cursor = NULL; - - e_canvas_item_set_reflow_callback(GNOME_CANVAS_ITEM(reflow), e_reflow_reflow); -} - -static void -e_reflow_set_arg (GtkObject *o, GtkArg *arg, guint arg_id) -{ - GnomeCanvasItem *item; - EReflow *e_reflow; - - item = GNOME_CANVAS_ITEM (o); - e_reflow = E_REFLOW (o); - - switch (arg_id){ - case ARG_HEIGHT: - e_reflow->height = GTK_VALUE_DOUBLE (*arg); - e_canvas_item_request_reflow(item); - break; - case ARG_MINIMUM_WIDTH: - e_reflow->minimum_width = GTK_VALUE_DOUBLE (*arg); - e_canvas_item_request_reflow(item); - break; - } -} - -static void -e_reflow_get_arg (GtkObject *object, GtkArg *arg, guint arg_id) -{ - EReflow *e_reflow; - - e_reflow = E_REFLOW (object); - - switch (arg_id) { - case ARG_MINIMUM_WIDTH: - GTK_VALUE_DOUBLE (*arg) = e_reflow->minimum_width; - break; - case ARG_WIDTH: - GTK_VALUE_DOUBLE (*arg) = e_reflow->width; - break; - case ARG_HEIGHT: - GTK_VALUE_DOUBLE (*arg) = e_reflow->height; - break; - default: - arg->type = GTK_TYPE_INVALID; - break; - } -} - -static void -e_reflow_destroy (GtkObject *object) -{ - EReflow *reflow = E_REFLOW(object); - - g_list_free(reflow->items); - reflow->items = NULL; -} - -static void -e_reflow_realize (GnomeCanvasItem *item) -{ - EReflow *e_reflow; - GnomeCanvasGroup *group; - GList *list; - GtkAdjustment *adjustment; - - e_reflow = E_REFLOW (item); - group = GNOME_CANVAS_GROUP( item ); - - if (GNOME_CANVAS_ITEM_CLASS(parent_class)->realize) - (* GNOME_CANVAS_ITEM_CLASS(parent_class)->realize) (item); - - e_reflow->arrow_cursor = gdk_cursor_new (GDK_SB_H_DOUBLE_ARROW); - e_reflow->default_cursor = gdk_cursor_new (GDK_LEFT_PTR); - - for(list = e_reflow->items; list; list = g_list_next(list)) { - GnomeCanvasItem *item = GNOME_CANVAS_ITEM(list->data); - gnome_canvas_item_set(item, - "width", (double) e_reflow->column_width, - NULL); - } - - e_canvas_item_request_reflow(item); - - adjustment = gtk_layout_get_hadjustment(GTK_LAYOUT(item->canvas)); - adjustment->step_increment = (e_reflow->column_width + E_REFLOW_FULL_GUTTER) / 2; - adjustment->page_increment = adjustment->page_size - adjustment->step_increment; - gtk_adjustment_changed(adjustment); - - if (!item->canvas->aa) { - } -} - -static void -e_reflow_unrealize (GnomeCanvasItem *item) -{ - EReflow *e_reflow; - - e_reflow = E_REFLOW (item); - - if (!item->canvas->aa) - { - } - - gdk_cursor_destroy (e_reflow->arrow_cursor); - gdk_cursor_destroy (e_reflow->default_cursor); - e_reflow->arrow_cursor = NULL; - e_reflow->default_cursor = NULL; - - g_list_free (e_reflow->columns); - e_reflow->columns = NULL; - - if (GNOME_CANVAS_ITEM_CLASS(parent_class)->unrealize) - (* GNOME_CANVAS_ITEM_CLASS(parent_class)->unrealize) (item); -} - -static gint -e_reflow_pick_line (EReflow *e_reflow, double x) -{ - x += E_REFLOW_BORDER_WIDTH + E_REFLOW_DIVIDER_WIDTH; - x /= e_reflow->column_width + E_REFLOW_FULL_GUTTER; - return x; -} - -static gboolean -e_reflow_event (GnomeCanvasItem *item, GdkEvent *event) -{ - EReflow *e_reflow; - - e_reflow = E_REFLOW (item); - - switch( event->type ) - { - case GDK_KEY_PRESS: - if (event->key.keyval == GDK_Tab || - event->key.keyval == GDK_KP_Tab || - event->key.keyval == GDK_ISO_Left_Tab) { - GList *list; - for (list = e_reflow->items; list; list = list->next) { - GnomeCanvasItem *item = GNOME_CANVAS_ITEM (list->data); - EFocus has_focus; - gtk_object_get(GTK_OBJECT(item), - "has_focus", &has_focus, - NULL); - if (has_focus) { - if (event->key.state & GDK_SHIFT_MASK) - list = list->prev; - else - list = list->next; - if (list) { - item = GNOME_CANVAS_ITEM(list->data); - gnome_canvas_item_set(item, - "has_focus", (event->key.state & GDK_SHIFT_MASK) ? E_FOCUS_END : E_FOCUS_START, - NULL); - return 1; - } else { - return 0; - } - } - } - } - break; - case GDK_BUTTON_PRESS: - switch(event->button.button) - { - case 1: - { - GdkEventButton *button = (GdkEventButton *) event; - double n_x; - n_x = button->x; - n_x += E_REFLOW_BORDER_WIDTH + E_REFLOW_DIVIDER_WIDTH; - n_x = fmod(n_x,(e_reflow->column_width + E_REFLOW_FULL_GUTTER)); - if ( button->y >= E_REFLOW_BORDER_WIDTH && button->y <= e_reflow->height - E_REFLOW_BORDER_WIDTH && n_x < E_REFLOW_FULL_GUTTER ) { - e_reflow->which_column_dragged = e_reflow_pick_line(e_reflow, button->x); - e_reflow->start_x = e_reflow->which_column_dragged * (e_reflow->column_width + E_REFLOW_FULL_GUTTER) - E_REFLOW_DIVIDER_WIDTH / 2; - e_reflow->temp_column_width = e_reflow->column_width; - e_reflow->column_drag = TRUE; - - gnome_canvas_item_grab (item, - GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK, - e_reflow->arrow_cursor, - button->time); - - e_reflow->previous_temp_column_width = -1; - e_reflow->need_column_resize = TRUE; - gnome_canvas_item_request_update(item); - return TRUE; - } - } - break; - case 4: - { - GtkAdjustment *adjustment = gtk_layout_get_hadjustment(GTK_LAYOUT(item->canvas)); - gdouble new_value = adjustment->value; - new_value -= adjustment->step_increment; - gtk_adjustment_set_value(adjustment, new_value); - } - break; - case 5: - { - GtkAdjustment *adjustment = gtk_layout_get_hadjustment(GTK_LAYOUT(item->canvas)); - gdouble new_value = adjustment->value; - new_value += adjustment->step_increment; - if ( new_value > adjustment->upper - adjustment->page_size ) - new_value = adjustment->upper - adjustment->page_size; - gtk_adjustment_set_value(adjustment, new_value); - } - break; - } - break; - case GDK_BUTTON_RELEASE: - if (e_reflow->column_drag) { - gdouble old_width = e_reflow->column_width; - GdkEventButton *button = (GdkEventButton *) event; - GtkAdjustment *adjustment = gtk_layout_get_hadjustment(GTK_LAYOUT(item->canvas)); - e_reflow->temp_column_width = e_reflow->column_width + - (button->x - e_reflow->start_x)/(e_reflow->which_column_dragged - e_reflow_pick_line(e_reflow, adjustment->value)); - if ( e_reflow->temp_column_width < 50 ) - e_reflow->temp_column_width = 50; - e_reflow->column_drag = FALSE; - if ( old_width != e_reflow->temp_column_width ) { - gtk_adjustment_set_value(adjustment, adjustment->value + e_reflow_pick_line(e_reflow, adjustment->value) * (e_reflow->temp_column_width - e_reflow->column_width)); - e_reflow->column_width = e_reflow->temp_column_width; - adjustment->step_increment = (e_reflow->column_width + E_REFLOW_FULL_GUTTER) / 2; - adjustment->page_increment = adjustment->page_size - adjustment->step_increment; - gtk_adjustment_changed(adjustment); - e_reflow_resize_children(item); - e_canvas_item_request_reflow(item); - } - e_reflow->need_column_resize = TRUE; - gnome_canvas_item_request_update(item); - gnome_canvas_item_ungrab (item, button->time); - return TRUE; - } - break; - case GDK_MOTION_NOTIFY: - if (e_reflow->column_drag) { - double old_width = e_reflow->temp_column_width; - GdkEventMotion *motion = (GdkEventMotion *) event; - GtkAdjustment *adjustment = gtk_layout_get_hadjustment(GTK_LAYOUT(item->canvas)); - e_reflow->temp_column_width = e_reflow->column_width + - (motion->x - e_reflow->start_x)/(e_reflow->which_column_dragged - e_reflow_pick_line(e_reflow, adjustment->value)); - if (e_reflow->temp_column_width < 50) - e_reflow->temp_column_width = 50; - if (old_width != e_reflow->temp_column_width) { - e_reflow->need_column_resize = TRUE; - gnome_canvas_item_request_update(item); - } - return TRUE; - } else { - GdkEventMotion *motion = (GdkEventMotion *) event; - double n_x; - n_x = motion->x; - n_x += E_REFLOW_BORDER_WIDTH + E_REFLOW_DIVIDER_WIDTH; - n_x = fmod(n_x,(e_reflow->column_width + E_REFLOW_FULL_GUTTER)); - if ( motion->y >= E_REFLOW_BORDER_WIDTH && motion->y <= e_reflow->height - E_REFLOW_BORDER_WIDTH && n_x < E_REFLOW_FULL_GUTTER ) { - if ( e_reflow->default_cursor_shown ) { - gdk_window_set_cursor(GTK_WIDGET(item->canvas)->window, e_reflow->arrow_cursor); - e_reflow->default_cursor_shown = FALSE; - } - } else - if ( ! e_reflow->default_cursor_shown ) { - gdk_window_set_cursor(GTK_WIDGET(item->canvas)->window, e_reflow->default_cursor); - e_reflow->default_cursor_shown = TRUE; - } - - } - break; - case GDK_ENTER_NOTIFY: - if (!e_reflow->column_drag) { - GdkEventCrossing *crossing = (GdkEventCrossing *) event; - double n_x; - n_x = crossing->x; - n_x += E_REFLOW_BORDER_WIDTH + E_REFLOW_DIVIDER_WIDTH; - n_x = fmod(n_x,(e_reflow->column_width + E_REFLOW_FULL_GUTTER)); - if ( crossing->y >= E_REFLOW_BORDER_WIDTH && crossing->y <= e_reflow->height - E_REFLOW_BORDER_WIDTH && n_x < E_REFLOW_FULL_GUTTER ) { - if ( e_reflow->default_cursor_shown ) { - gdk_window_set_cursor(GTK_WIDGET(item->canvas)->window, e_reflow->arrow_cursor); - e_reflow->default_cursor_shown = FALSE; - } - } - } - break; - case GDK_LEAVE_NOTIFY: - if (!e_reflow->column_drag) { - GdkEventCrossing *crossing = (GdkEventCrossing *) event; - double n_x; - n_x = crossing->x; - n_x += E_REFLOW_BORDER_WIDTH + E_REFLOW_DIVIDER_WIDTH; - n_x = fmod(n_x,(e_reflow->column_width + E_REFLOW_FULL_GUTTER)); - if ( !( crossing->y >= E_REFLOW_BORDER_WIDTH && crossing->y <= e_reflow->height - E_REFLOW_BORDER_WIDTH && n_x < E_REFLOW_FULL_GUTTER ) ) { - if ( ! e_reflow->default_cursor_shown ) { - gdk_window_set_cursor(GTK_WIDGET(item->canvas)->window, e_reflow->default_cursor); - e_reflow->default_cursor_shown = TRUE; - } - } - } - break; - default: - break; - } - - if (GNOME_CANVAS_ITEM_CLASS( parent_class )->event) - return (* GNOME_CANVAS_ITEM_CLASS( parent_class )->event) (item, event); - else - return 0; -} - -static void -e_reflow_real_add_item(EReflow *e_reflow, GnomeCanvasItem *item) -{ - e_reflow->items = g_list_append(e_reflow->items, item); - if ( GTK_OBJECT_FLAGS( e_reflow ) & GNOME_CANVAS_ITEM_REALIZED ) { - gnome_canvas_item_set(item, - "width", (double) e_reflow->column_width, - NULL); - e_canvas_item_request_reflow(item); - } - -} - -static void e_reflow_draw (GnomeCanvasItem *item, GdkDrawable *drawable, - int x, int y, int width, int height) -{ - int x_rect, y_rect, width_rect, height_rect; - gdouble running_width; - EReflow *e_reflow = E_REFLOW(item); - int i; - double column_width; - - if (GNOME_CANVAS_ITEM_CLASS(parent_class)->draw) - GNOME_CANVAS_ITEM_CLASS(parent_class)->draw (item, drawable, x, y, width, height); - column_width = e_reflow->column_width; - running_width = E_REFLOW_BORDER_WIDTH + column_width + E_REFLOW_BORDER_WIDTH; - x_rect = running_width; - y_rect = E_REFLOW_BORDER_WIDTH; - width_rect = E_REFLOW_DIVIDER_WIDTH; - height_rect = e_reflow->height - (E_REFLOW_BORDER_WIDTH * 2); - - /* Compute first column to draw. */ - i = x; - i /= column_width + E_REFLOW_FULL_GUTTER; - running_width += i * (column_width + E_REFLOW_FULL_GUTTER); - - for ( ; i < e_reflow->column_count; i++) { - if ( running_width > x + width ) - break; - x_rect = running_width; - gtk_paint_flat_box(GTK_WIDGET(item->canvas)->style, - drawable, - GTK_STATE_ACTIVE, - GTK_SHADOW_NONE, - NULL, - GTK_WIDGET(item->canvas), - "reflow", - x_rect - x, - y_rect - y, - width_rect, - height_rect); - running_width += E_REFLOW_DIVIDER_WIDTH + E_REFLOW_BORDER_WIDTH + column_width + E_REFLOW_BORDER_WIDTH; - } - if (e_reflow->column_drag) { - int start_line = e_reflow_pick_line(e_reflow, - gtk_layout_get_hadjustment(GTK_LAYOUT(item->canvas))->value); - i = x - start_line * (column_width + E_REFLOW_FULL_GUTTER); - running_width = start_line * (column_width + E_REFLOW_FULL_GUTTER); - column_width = e_reflow->temp_column_width; - running_width -= start_line * (column_width + E_REFLOW_FULL_GUTTER); - i += start_line * (column_width + E_REFLOW_FULL_GUTTER); - running_width += E_REFLOW_BORDER_WIDTH + column_width + E_REFLOW_BORDER_WIDTH; - x_rect = running_width; - y_rect = E_REFLOW_BORDER_WIDTH; - width_rect = E_REFLOW_DIVIDER_WIDTH; - height_rect = e_reflow->height - (E_REFLOW_BORDER_WIDTH * 2); - - /* Compute first column to draw. */ - i /= column_width + E_REFLOW_FULL_GUTTER; - running_width += i * (column_width + E_REFLOW_FULL_GUTTER); - - for ( ; i < e_reflow->column_count; i++) { - if ( running_width > x + width ) - break; - x_rect = running_width; - gdk_draw_rectangle(drawable, - GTK_WIDGET(item->canvas)->style->fg_gc[GTK_STATE_NORMAL], - TRUE, - x_rect - x, - y_rect - y, - width_rect - 1, - height_rect - 1); - running_width += E_REFLOW_DIVIDER_WIDTH + E_REFLOW_BORDER_WIDTH + column_width + E_REFLOW_BORDER_WIDTH; - } - } -} - -static void -e_reflow_update (GnomeCanvasItem *item, double affine[6], ArtSVP *clip_path, gint flags) -{ - EReflow *e_reflow; - double x0, x1, y0, y1; - - e_reflow = E_REFLOW (item); - - if (GNOME_CANVAS_ITEM_CLASS(parent_class)->update) - GNOME_CANVAS_ITEM_CLASS(parent_class)->update (item, affine, clip_path, flags); - - x0 = item->x1; - y0 = item->y1; - x1 = item->x2; - y1 = item->y2; - if ( x1 < x0 + e_reflow->width ) - x1 = x0 + e_reflow->width; - if ( y1 < y0 + e_reflow->height ) - y1 = y0 + e_reflow->height; - item->x2 = x1; - item->y2 = y1; - - if (e_reflow->need_height_update) { - x0 = item->x1; - y0 = item->y1; - x1 = item->x2; - y1 = item->y2; - if ( x0 > 0 ) - x0 = 0; - if ( y0 > 0 ) - y0 = 0; - if ( x1 < E_REFLOW(item)->width ) - x1 = E_REFLOW(item)->width; - if ( x1 < E_REFLOW(item)->height ) - x1 = E_REFLOW(item)->height; - - gnome_canvas_request_redraw(item->canvas, x0, y0, x1, y1); - e_reflow->need_height_update = FALSE; - } else if (e_reflow->need_column_resize) { - int x_rect, y_rect, width_rect, height_rect; - int start_line = e_reflow_pick_line(e_reflow, - gtk_layout_get_hadjustment(GTK_LAYOUT(item->canvas))->value); - gdouble running_width; - int i; - double column_width; - - if ( e_reflow->previous_temp_column_width != -1 ) { - running_width = start_line * (e_reflow->column_width + E_REFLOW_FULL_GUTTER); - column_width = e_reflow->previous_temp_column_width; - running_width -= start_line * (column_width + E_REFLOW_FULL_GUTTER); - running_width += E_REFLOW_BORDER_WIDTH + column_width + E_REFLOW_BORDER_WIDTH; - y_rect = E_REFLOW_BORDER_WIDTH; - width_rect = E_REFLOW_DIVIDER_WIDTH; - height_rect = e_reflow->height - (E_REFLOW_BORDER_WIDTH * 2); - - for ( i = 0; i < e_reflow->column_count; i++) { - x_rect = running_width; - gnome_canvas_request_redraw(item->canvas, x_rect, y_rect, x_rect + width_rect, y_rect + height_rect); - running_width += E_REFLOW_DIVIDER_WIDTH + E_REFLOW_BORDER_WIDTH + column_width + E_REFLOW_BORDER_WIDTH; - } - } - - if ( e_reflow->temp_column_width != -1 ) { - running_width = start_line * (e_reflow->column_width + E_REFLOW_FULL_GUTTER); - column_width = e_reflow->temp_column_width; - running_width -= start_line * (column_width + E_REFLOW_FULL_GUTTER); - running_width += E_REFLOW_BORDER_WIDTH + column_width + E_REFLOW_BORDER_WIDTH; - y_rect = E_REFLOW_BORDER_WIDTH; - width_rect = E_REFLOW_DIVIDER_WIDTH; - height_rect = e_reflow->height - (E_REFLOW_BORDER_WIDTH * 2); - - for ( i = 0; i < e_reflow->column_count; i++) { - x_rect = running_width; - gnome_canvas_request_redraw(item->canvas, x_rect, y_rect, x_rect + width_rect, y_rect + height_rect); - running_width += E_REFLOW_DIVIDER_WIDTH + E_REFLOW_BORDER_WIDTH + column_width + E_REFLOW_BORDER_WIDTH; - } - } - - e_reflow->previous_temp_column_width = e_reflow->temp_column_width; - e_reflow->need_column_resize = FALSE; - } -} - -static void -e_reflow_resize_children (GnomeCanvasItem *item) -{ - GList *list; - EReflow *e_reflow; - - e_reflow = E_REFLOW (item); - for ( list = e_reflow->items; list; list = list->next ) { - GnomeCanvasItem *child = GNOME_CANVAS_ITEM(list->data); - gnome_canvas_item_set(child, - "width", (double) e_reflow->column_width, - NULL); - } -} - -static double -e_reflow_point (GnomeCanvasItem *item, - double x, double y, int cx, int cy, - GnomeCanvasItem **actual_item) -{ - double distance = 1; - - if (GNOME_CANVAS_ITEM_CLASS(parent_class)->point) - distance = GNOME_CANVAS_ITEM_CLASS(parent_class)->point (item, x, y, cx, cy, actual_item); - if (*actual_item) - return 0; - - *actual_item = item; - return 0; -#if 0 - if (y >= E_REFLOW_BORDER_WIDTH && y <= e_reflow->height - E_REFLOW_BORDER_WIDTH) { - float n_x; - n_x = x; - n_x += E_REFLOW_BORDER_WIDTH + E_REFLOW_DIVIDER_WIDTH; - n_x = fmod(n_x, (e_reflow->column_width + E_REFLOW_FULL_GUTTER)); - if (n_x < E_REFLOW_FULL_GUTTER) { - *actual_item = item; - return 0; - } - } - return distance; -#endif -} - -static void -_reflow( EReflow *e_reflow ) -{ - gdouble running_height; - GList *list; - double item_height; - - if (e_reflow->columns) { - g_list_free (e_reflow->columns); - e_reflow->columns = NULL; - } - - e_reflow->column_count = 0; - - if (e_reflow->items == NULL) { - e_reflow->columns = NULL; - e_reflow->column_count = 1; - return; - } - - list = e_reflow->items; - - gtk_object_get (GTK_OBJECT(list->data), - "height", &item_height, - NULL); - running_height = E_REFLOW_BORDER_WIDTH + item_height + E_REFLOW_BORDER_WIDTH; - e_reflow->columns = g_list_append (e_reflow->columns, list); - e_reflow->column_count = 1; - - list = g_list_next(list); - - for ( ; list; list = g_list_next(list)) { - gtk_object_get (GTK_OBJECT(list->data), - "height", &item_height, - NULL); - if (running_height + item_height + E_REFLOW_BORDER_WIDTH > e_reflow->height) { - running_height = E_REFLOW_BORDER_WIDTH + item_height + E_REFLOW_BORDER_WIDTH; - e_reflow->columns = g_list_append (e_reflow->columns, list); - e_reflow->column_count ++; - } else { - running_height += item_height + E_REFLOW_BORDER_WIDTH; - } - } -} - -static void -e_reflow_reflow( GnomeCanvasItem *item, int flags ) -{ - EReflow *e_reflow = E_REFLOW(item); - if ( GTK_OBJECT_FLAGS( e_reflow ) & GNOME_CANVAS_ITEM_REALIZED ) { - - gdouble old_width; - gdouble running_width; - - _reflow (e_reflow); - - old_width = e_reflow->width; - - running_width = E_REFLOW_BORDER_WIDTH; - - if (e_reflow->items == NULL) { - } else { - GList *list; - GList *next_column; - gdouble item_height; - gdouble running_height; - - running_height = E_REFLOW_BORDER_WIDTH; - - list = e_reflow->items; - gtk_object_get (GTK_OBJECT(list->data), - "height", &item_height, - NULL); - e_canvas_item_move_absolute(GNOME_CANVAS_ITEM(list->data), - (double) running_width, - (double) running_height); - running_height += item_height + E_REFLOW_BORDER_WIDTH; - next_column = g_list_next(e_reflow->columns); - list = g_list_next(list); - - for( ; list; list = g_list_next(list)) { - gtk_object_get (GTK_OBJECT(list->data), - "height", &item_height, - NULL); - - if (next_column && (next_column->data == list)) { - next_column = g_list_next (next_column); - running_height = E_REFLOW_BORDER_WIDTH; - running_width += e_reflow->column_width + E_REFLOW_BORDER_WIDTH + E_REFLOW_DIVIDER_WIDTH + E_REFLOW_BORDER_WIDTH; - } - e_canvas_item_move_absolute(GNOME_CANVAS_ITEM(list->data), - (double) running_width, - (double) running_height); - - running_height += item_height + E_REFLOW_BORDER_WIDTH; - } - - } - e_reflow->width = running_width + e_reflow->column_width + E_REFLOW_BORDER_WIDTH; - if ( e_reflow->width < e_reflow->minimum_width ) - e_reflow->width = e_reflow->minimum_width; - if (old_width != e_reflow->width) - e_canvas_item_request_parent_reflow(item); - } -} - -void -e_reflow_add_item(EReflow *e_reflow, GnomeCanvasItem *item) -{ - if (E_REFLOW_CLASS(GTK_OBJECT(e_reflow)->klass)->add_item) - (E_REFLOW_CLASS(GTK_OBJECT(e_reflow)->klass)->add_item) (e_reflow, item); -} diff --git a/addressbook/gui/minicard/e-reflow.h b/addressbook/gui/minicard/e-reflow.h deleted file mode 100644 index 54de59ba55..0000000000 --- a/addressbook/gui/minicard/e-reflow.h +++ /dev/null @@ -1,106 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* e-reflow.h - * Copyright (C) 2000 Helix Code, Inc. - * Author: Chris Lahey - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ -#ifndef __E_REFLOW_H__ -#define __E_REFLOW_H__ - -#include - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - -/* EReflow - A canvas item container. - * - * The following arguments are available: - * - * name type read/write description - * -------------------------------------------------------------------------------- - * minimum_width double RW minimum width of the reflow. width >= minimum_width - * width double R width of the reflow - * height double RW height of the reflow - */ - -#define E_REFLOW_TYPE (e_reflow_get_type ()) -#define E_REFLOW(obj) (GTK_CHECK_CAST ((obj), E_REFLOW_TYPE, EReflow)) -#define E_REFLOW_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_REFLOW_TYPE, EReflowClass)) -#define E_IS_REFLOW(obj) (GTK_CHECK_TYPE ((obj), E_REFLOW_TYPE)) -#define E_IS_REFLOW_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), E_REFLOW_TYPE)) - - -typedef struct _EReflow EReflow; -typedef struct _EReflowClass EReflowClass; - -struct _EReflow -{ - GnomeCanvasGroup parent; - - /* item specific fields */ - GList *items; /* Of type GnomeCanvasItem */ - GList *columns; /* Of type GList of type GnomeCanvasItem (points into items) */ - gint column_count; /* Number of columnns */ - - double minimum_width; - double width; - double height; - - double column_width; - - int idle; - - /* These are all for when the column is being dragged. */ - gboolean column_drag; - gdouble start_x; - gint which_column_dragged; - double temp_column_width; - double previous_temp_column_width; - - guint need_height_update : 1; - guint need_column_resize : 1; - - guint default_cursor_shown : 1; - GdkCursor *arrow_cursor; - GdkCursor *default_cursor; -}; - -struct _EReflowClass -{ - GnomeCanvasGroupClass parent_class; - - /* Virtual methods. */ - void (* add_item) (EReflow *reflow, GnomeCanvasItem *item); -}; - -/* - * To be added to a reflow, an item must have the argument "width" as - * a Read/Write argument and "height" as a Read Only argument. It - * should also do an ECanvas parent reflow request if its size - * changes. - */ -void e_reflow_add_item(EReflow *e_reflow, GnomeCanvasItem *item); -GtkType e_reflow_get_type (void); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - - -#endif /* __E_REFLOW_H__ */ diff --git a/addressbook/gui/minicard/test-minicard-label.c b/addressbook/gui/minicard/test-minicard-label.c deleted file mode 100644 index adf092206c..0000000000 --- a/addressbook/gui/minicard/test-minicard-label.c +++ /dev/null @@ -1,128 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* test-minicard-label.c - * - * Copyright (C) 2000 Helix Code, Inc. - * Author: Chris Lahey - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - - - -#include "config.h" - -#include -#include "e-minicard-label.h" -#include - -/* This is a horrible thing to do, but it is just a test. */ -GnomeCanvasItem *label; -GnomeCanvasItem *rect; - -static void destroy_callback(GtkWidget *app, gpointer data) -{ - exit(0); -} - -static void allocate_callback(GtkWidget *canvas, GtkAllocation *allocation, gpointer data) -{ - gnome_canvas_set_scroll_region(GNOME_CANVAS( canvas ), 0, 0, allocation->width, allocation->height ); - gnome_canvas_item_set( label, - "width", (double) allocation->width, - "height", (double) allocation->height, - NULL ); - gnome_canvas_item_set( rect, - "x2", (double) allocation->width, - "y2", (double) allocation->height, - NULL ); -} - -#if 0 -static void about_callback( GtkWidget *widget, gpointer data ) -{ - - const gchar *authors[] = - { - "Christopher James Lahey ", - NULL - }; - - GtkWidget *about = - gnome_about_new ( _( "Minicard Label Test" ), VERSION, - _( "Copyright (C) 2000, Helix Code, Inc." ), - authors, - _( "This should test the minicard label canvas item" ), - NULL); - gtk_widget_show (about); -} -#endif - -static void button_press_callback( GtkWidget *widget, gpointer data ) -{ - gnome_canvas_item_grab_focus( label ); -} - -int main( int argc, char *argv[] ) -{ - GtkWidget *app; - GtkWidget *canvas; - - /* bindtextdomain (PACKAGE, GNOMELOCALEDIR); - textdomain (PACKAGE);*/ - - gnome_init( "Minicard Label Test", VERSION, argc, argv); - app = gnome_app_new("Minicard Label Test", NULL); - - canvas = e_canvas_new(); - rect = gnome_canvas_item_new( gnome_canvas_root( GNOME_CANVAS( canvas ) ), - gnome_canvas_rect_get_type(), - "x1", (double) 0, - "y1", (double) 0, - "x2", (double) 100, - "y2", (double) 100, - "fill_color", "white", - NULL ); - label = e_minicard_label_new(gnome_canvas_root( GNOME_CANVAS( canvas ) )); - gnome_canvas_item_set( label, - "x", (double) 0, - "y", (double) 0, - "width", (double) 100, - "height", (double) 100, - "fieldname", "Full Name:", - "field", "Christopher James Lahey", - NULL ); - gnome_canvas_set_scroll_region ( GNOME_CANVAS( canvas ), - 0, 0, - 100, 100 ); - - gnome_app_set_contents( GNOME_APP( app ), canvas ); - - - /* Connect the signals */ - gtk_signal_connect( GTK_OBJECT( app ), "destroy", - GTK_SIGNAL_FUNC( destroy_callback ), - ( gpointer ) app ); - - gtk_signal_connect( GTK_OBJECT( canvas ), "size_allocate", - GTK_SIGNAL_FUNC( allocate_callback ), - ( gpointer ) app ); - - gtk_signal_connect( GTK_OBJECT( canvas ), "button_press_event", - GTK_SIGNAL_FUNC( button_press_callback ), - ( gpointer ) app ); - - gtk_widget_show_all( app ); - - gtk_main(); - - /* Not reached. */ - return 0; -} diff --git a/addressbook/gui/minicard/test-minicard-view.c b/addressbook/gui/minicard/test-minicard-view.c deleted file mode 100644 index c03d11d07e..0000000000 --- a/addressbook/gui/minicard/test-minicard-view.c +++ /dev/null @@ -1,206 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* test-reflow.c - * - * Copyright (C) 2000 Helix Code, Inc. - * Author: Chris Lahey - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#include "config.h" - -#include -#include -#include -#include -#include "e-minicard-view.h" - -/* This is a horrible thing to do, but it is just a test. */ -GnomeCanvasItem *reflow; -GnomeCanvasItem *rect; -GtkAllocation last_alloc; - -CORBA_Environment ev; -CORBA_ORB orb; - -static void -init_bonobo (int argc, char **argv) -{ - - gnome_CORBA_init_with_popt_table ( - "Reflow Test", VERSION, - &argc, argv, NULL, 0, NULL, GNORBA_INIT_SERVER_FUNC, &ev); - - orb = gnome_CORBA_ORB (); - - if (bonobo_init (orb, NULL, NULL) == FALSE) - g_error (_("Could not initialize Bonobo")); - -} - -static void destroy_callback(GtkWidget *app, gpointer data) -{ - exit(0); -} - -static void allocate_callback(GtkWidget *canvas, GtkAllocation *allocation, gpointer data) -{ - double width; - last_alloc = *allocation; - gnome_canvas_item_set( reflow, - "height", (double) allocation->height, - NULL ); - gnome_canvas_item_set( reflow, - "minimum_width", (double) allocation->width, - NULL ); - gtk_object_get(GTK_OBJECT(reflow), - "width", &width, - NULL); - width = MAX(width, allocation->width); - gnome_canvas_set_scroll_region(GNOME_CANVAS( canvas ), 0, 0, width, allocation->height ); - gnome_canvas_item_set( rect, - "x2", (double) width, - "y2", (double) allocation->height, - NULL ); -} - -static void resize(GnomeCanvas *canvas, gpointer data) -{ - double width; - gtk_object_get(GTK_OBJECT(reflow), - "width", &width, - NULL); - width = MAX(width, last_alloc.width); - gnome_canvas_set_scroll_region(canvas , 0, 0, width, last_alloc.height ); - gnome_canvas_item_set( rect, - "x2", (double) width, - "y2", (double) last_alloc.height, - NULL ); -} - -#if 0 -static void about_callback( GtkWidget *widget, gpointer data ) -{ - - const gchar *authors[] = - { - "Christopher James Lahey ", - NULL - }; - - GtkWidget *about = - gnome_about_new ( _( "Reflow Test" ), VERSION, - _( "Copyright (C) 2000, Helix Code, Inc." ), - authors, - _( "This should test the reflow canvas item" ), - NULL); - gtk_widget_show (about); -} -#endif - -static void -book_open_cb (EBook *book, EBookStatus status, gpointer closure) -{ - if (status == E_BOOK_STATUS_SUCCESS) - gnome_canvas_item_set(reflow, - "book", book, - NULL); -} - -static guint -ebook_create (void) -{ - EBook *book; - - book = e_book_new (); - - if (!book) { - printf ("%s: %s(): Couldn't create EBook, bailing.\n", - __FILE__, - __FUNCTION__); - return FALSE; - } - - - if (! e_book_load_uri (book, "file:/tmp/test.db", book_open_cb, NULL)) { - printf ("error calling load_uri!\n"); - } - - - return FALSE; -} - -int main( int argc, char *argv[] ) -{ - GtkWidget *app; - GtkWidget *canvas; - GtkWidget *vbox; - GtkWidget *scrollbar; - - /* bindtextdomain (PACKAGE, GNOMELOCALEDIR); - textdomain (PACKAGE);*/ - - CORBA_exception_init (&ev); - init_bonobo (argc, argv); - - app = gnome_app_new("Reflow Test", NULL); - - vbox = gtk_vbox_new(FALSE, 0); - - canvas = e_canvas_new(); - rect = gnome_canvas_item_new( gnome_canvas_root( GNOME_CANVAS( canvas ) ), - gnome_canvas_rect_get_type(), - "x1", (double) 0, - "y1", (double) 0, - "x2", (double) 100, - "y2", (double) 100, - "fill_color", "white", - NULL ); - reflow = gnome_canvas_item_new( gnome_canvas_root( GNOME_CANVAS( canvas ) ), - e_minicard_view_get_type(), - "height", (double) 100, - "minimum_width", (double) 100, - NULL ); - gtk_signal_connect( GTK_OBJECT( canvas ), "reflow", - GTK_SIGNAL_FUNC( resize ), - ( gpointer ) app); - - gnome_canvas_set_scroll_region ( GNOME_CANVAS( canvas ), - 0, 0, - 100, 100 ); - - gtk_box_pack_start(GTK_BOX(vbox), canvas, TRUE, TRUE, 0); - - scrollbar = gtk_hscrollbar_new(gtk_layout_get_hadjustment(GTK_LAYOUT(canvas))); - - gtk_box_pack_start(GTK_BOX(vbox), scrollbar, FALSE, FALSE, 0); - - gnome_app_set_contents( GNOME_APP( app ), vbox ); - - /* Connect the signals */ - gtk_signal_connect( GTK_OBJECT( app ), "destroy", - GTK_SIGNAL_FUNC( destroy_callback ), - ( gpointer ) app ); - - gtk_signal_connect( GTK_OBJECT( canvas ), "size_allocate", - GTK_SIGNAL_FUNC( allocate_callback ), - ( gpointer ) app ); - - gtk_widget_show_all( app ); - gdk_window_set_back_pixmap( GTK_LAYOUT(canvas)->bin_window, NULL, FALSE); - - gtk_idle_add ((GtkFunction) ebook_create, NULL); - - bonobo_main (); - - /* Not reached. */ - return 0; -} diff --git a/addressbook/gui/minicard/test-minicard.c b/addressbook/gui/minicard/test-minicard.c deleted file mode 100644 index 1ad066b3fe..0000000000 --- a/addressbook/gui/minicard/test-minicard.c +++ /dev/null @@ -1,117 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* test-minicard.c - * - * Copyright (C) 2000 Helix Code, Inc. - * Author: Chris Lahey - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - - - -#include "config.h" - -#include -#include "e-minicard.h" - -/* This is a horrible thing to do, but it is just a test. */ -GnomeCanvasItem *card; -GnomeCanvasItem *rect; - -static void destroy_callback(GtkWidget *app, gpointer data) -{ - exit(0); -} - -static void allocate_callback(GtkWidget *canvas, GtkAllocation *allocation, gpointer data) -{ - gnome_canvas_set_scroll_region(GNOME_CANVAS( canvas ), 0, 0, allocation->width, allocation->height ); - gnome_canvas_item_set( card, - "width", (double) allocation->width, - NULL ); - gnome_canvas_item_set( rect, - "x2", (double) allocation->width, - "y2", (double) allocation->height, - NULL ); -} - -#if 0 -static void about_callback( GtkWidget *widget, gpointer data ) -{ - - const gchar *authors[] = - { - "Christopher James Lahey ", - NULL - }; - - GtkWidget *about = - gnome_about_new ( _( "Minicard Test" ), VERSION, - _( "Copyright (C) 2000, Helix Code, Inc." ), - authors, - _( "This should test the minicard canvas item" ), - NULL); - gtk_widget_show (about); -} -#endif - -int main( int argc, char *argv[] ) -{ - GtkWidget *app; - GtkWidget *canvas; - int i; - - /* bindtextdomain (PACKAGE, GNOMELOCALEDIR); - textdomain (PACKAGE);*/ - - gnome_init( "Minicard Test", VERSION, argc, argv); - app = gnome_app_new("Minicard Test", NULL); - - canvas = gnome_canvas_new(); - rect = gnome_canvas_item_new( gnome_canvas_root( GNOME_CANVAS( canvas ) ), - gnome_canvas_rect_get_type(), - "x1", (double) 0, - "y1", (double) 0, - "x2", (double) 100, - "y2", (double) 100, - "fill_color", "white", - NULL ); - for ( i = 0; i < 1; i++ ) - { - card = gnome_canvas_item_new( gnome_canvas_root( GNOME_CANVAS( canvas ) ), - e_minicard_get_type(), - "x", (double) 0, - "y", (double) 0, - "width", (double) 100, - NULL ); - } - gnome_canvas_set_scroll_region ( GNOME_CANVAS( canvas ), - 0, 0, - 100, 100 ); - - gnome_app_set_contents( GNOME_APP( app ), canvas ); - - /* Connect the signals */ - gtk_signal_connect( GTK_OBJECT( app ), "destroy", - GTK_SIGNAL_FUNC( destroy_callback ), - ( gpointer ) app ); - - gtk_signal_connect( GTK_OBJECT( canvas ), "size_allocate", - GTK_SIGNAL_FUNC( allocate_callback ), - ( gpointer ) app ); - - gtk_widget_show_all( app ); - - gtk_main(); - - /* Not reached. */ - return 0; -} diff --git a/addressbook/gui/minicard/test-reflow.c b/addressbook/gui/minicard/test-reflow.c deleted file mode 100644 index 4817d13120..0000000000 --- a/addressbook/gui/minicard/test-reflow.c +++ /dev/null @@ -1,193 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* test-reflow.c - * - * Copyright (C) 2000 Helix Code, Inc. - * Author: Chris Lahey - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - - -#define TEST_VCARD \ -"BEGIN:VCARD -" \ -"FN:Nat -" \ -"N:Friedman;Nat;D;Mr. -" \ -"TITLE:Head Geek -" \ -"BDAY:1977-08-06 -" \ -"TEL;WORK:617 679 1984 -" \ -"TEL;CELL:123 456 7890 -" \ -"EMAIL;INTERNET:nat@nat.org -" \ -"EMAIL;INTERNET:nat@helixcode.com -" \ -"ADR;WORK;POSTAL:P.O. Box 101;;;Any Town;CA;91921-1234; -" \ -"ADR;HOME;POSTAL;INTL:P.O. Box 202;;;Any Town 2;MI;12344-4321;USA -" \ -"END:VCARD -" \ -" -" - - -#include "config.h" - -#include -#include -#include "e-reflow.h" -#include "e-minicard.h" - -/* This is a horrible thing to do, but it is just a test. */ -GnomeCanvasItem *reflow; -GnomeCanvasItem *rect; -GtkAllocation last_alloc; - -static void destroy_callback(GtkWidget *app, gpointer data) -{ - exit(0); -} - -static void allocate_callback(GtkWidget *canvas, GtkAllocation *allocation, gpointer data) -{ - double width; - last_alloc = *allocation; - gnome_canvas_item_set( reflow, - "height", (double) allocation->height, - NULL ); - gnome_canvas_item_set( reflow, - "minimum_width", (double) allocation->width, - NULL ); - gtk_object_get(GTK_OBJECT(reflow), - "width", &width, - NULL); - width = MAX(width, allocation->width); - gnome_canvas_set_scroll_region(GNOME_CANVAS( canvas ), 0, 0, width, allocation->height ); - gnome_canvas_item_set( rect, - "x2", (double) width, - "y2", (double) allocation->height, - NULL ); -} - -static void resize(GnomeCanvas *canvas, gpointer data) -{ - double width; - gtk_object_get(GTK_OBJECT(reflow), - "width", &width, - NULL); - width = MAX(width, last_alloc.width); - gnome_canvas_set_scroll_region(canvas , 0, 0, width, last_alloc.height ); - gnome_canvas_item_set( rect, - "x2", (double) width, - "y2", (double) last_alloc.height, - NULL ); -} - -#if 0 -static void about_callback( GtkWidget *widget, gpointer data ) -{ - - const gchar *authors[] = - { - "Christopher James Lahey ", - NULL - }; - - GtkWidget *about = - gnome_about_new ( _( "Reflow Test" ), VERSION, - _( "Copyright (C) 2000, Helix Code, Inc." ), - authors, - _( "This should test the reflow canvas item" ), - NULL); - gtk_widget_show (about); -} -#endif - -int main( int argc, char *argv[] ) -{ - GtkWidget *app; - GtkWidget *canvas; - GtkWidget *vbox; - GtkWidget *scrollbar; - int i; - - /* bindtextdomain (PACKAGE, GNOMELOCALEDIR); - textdomain (PACKAGE);*/ - - gnome_init( "Reflow Test", VERSION, argc, argv); - app = gnome_app_new("Reflow Test", NULL); - - vbox = gtk_vbox_new(FALSE, 0); - - canvas = e_canvas_new(); - rect = gnome_canvas_item_new( gnome_canvas_root( GNOME_CANVAS( canvas ) ), - gnome_canvas_rect_get_type(), - "x1", (double) 0, - "y1", (double) 0, - "x2", (double) 100, - "y2", (double) 100, - "fill_color", "white", - NULL ); - reflow = gnome_canvas_item_new( gnome_canvas_root( GNOME_CANVAS( canvas ) ), - e_reflow_get_type(), - "x", (double) 0, - "y", (double) 0, - "height", (double) 100, - "minimum_width", (double) 100, - NULL ); - gtk_signal_connect( GTK_OBJECT( canvas ), "reflow", - GTK_SIGNAL_FUNC( resize ), - ( gpointer ) app); - for ( i = 0; i < 200; i++ ) - { - GnomeCanvasItem *item; - ECard *card = e_card_new (TEST_VCARD); - item = gnome_canvas_item_new( GNOME_CANVAS_GROUP(reflow), - e_minicard_get_type(), - "card", card, - NULL); - e_reflow_add_item(E_REFLOW(reflow), item); - } - gnome_canvas_set_scroll_region ( GNOME_CANVAS( canvas ), - 0, 0, - 100, 100 ); - - gtk_box_pack_start(GTK_BOX(vbox), canvas, TRUE, TRUE, 0); - - scrollbar = gtk_hscrollbar_new(gtk_layout_get_hadjustment(GTK_LAYOUT(canvas))); - - gtk_box_pack_start(GTK_BOX(vbox), scrollbar, FALSE, FALSE, 0); - - gnome_app_set_contents( GNOME_APP( app ), vbox ); - - /* Connect the signals */ - gtk_signal_connect( GTK_OBJECT( app ), "destroy", - GTK_SIGNAL_FUNC( destroy_callback ), - ( gpointer ) app ); - - gtk_signal_connect( GTK_OBJECT( canvas ), "size_allocate", - GTK_SIGNAL_FUNC( allocate_callback ), - ( gpointer ) app ); - - gtk_widget_show_all( app ); - gdk_window_set_back_pixmap( GTK_LAYOUT(canvas)->bin_window, NULL, FALSE); - - gtk_main(); - - /* Not reached. */ - return 0; -} diff --git a/addressbook/gui/widgets/Makefile.am b/addressbook/gui/widgets/Makefile.am deleted file mode 100644 index 44cbed0819..0000000000 --- a/addressbook/gui/widgets/Makefile.am +++ /dev/null @@ -1,82 +0,0 @@ -INCLUDES = \ - -DG_LOG_DOMAIN=\"e-minicard\" \ - -I$(top_srcdir) \ - -I$(top_srcdir)/addressbook/backend \ - -I$(top_builddir)/addressbook/backend \ - -I$(top_srcdir)/addressbook/contact-editor \ - -I$(top_srcdir)/widgets/e-text \ - $(GNOME_INCLUDEDIR) - -noinst_LIBRARIES = \ - libeminicard.a - -libeminicard_a_SOURCES = \ - e-minicard.c \ - e-minicard.h \ - e-minicard-label.c \ - e-minicard-label.h \ - e-minicard-view.c \ - e-minicard-view.h \ - e-reflow-sorted.c \ - e-reflow-sorted.h \ - e-reflow.c \ - e-reflow.h - -noinst_PROGRAMS = \ - minicard-label-test \ - minicard-test \ - reflow-test \ - minicard-view-test - -minicard_label_test_SOURCES = \ - test-minicard-label.c - -minicard_label_test_LDADD = \ - $(EXTRA_GNOME_LIBS) \ - $(GNOMEGNORBA_LIBS) \ - libeminicard.a \ - -lbonobo \ - $(top_builddir)/e-util/libeutil.la \ - $(top_builddir)/widgets/e-text/libetext.a - -minicard_test_SOURCES = \ - test-minicard.c - -minicard_test_LDADD = \ - $(EXTRA_GNOME_LIBS) \ - $(GNOMEGNORBA_LIBS) \ - libeminicard.a \ - -lbonobo \ - $(top_builddir)/e-util/libeutil.la \ - $(top_builddir)/addressbook/backend/ebook/libebook.la \ - $(top_builddir)/libversit/libversit.la \ - $(top_builddir)/addressbook/contact-editor/libecontacteditor.a \ - $(top_builddir)/widgets/e-text/libetext.a - -reflow_test_SOURCES = \ - test-reflow.c - -reflow_test_LDADD = \ - $(EXTRA_GNOME_LIBS) \ - $(GNOMEGNORBA_LIBS) \ - libeminicard.a \ - -lbonobo \ - $(top_builddir)/e-util/libeutil.la \ - $(top_builddir)/addressbook/backend/ebook/libebook.la \ - $(top_builddir)/libversit/libversit.la \ - $(top_builddir)/addressbook/contact-editor/libecontacteditor.a \ - $(top_builddir)/widgets/e-text/libetext.a - -minicard_view_test_SOURCES = \ - test-minicard-view.c - -minicard_view_test_LDADD = \ - $(EXTRA_GNOME_LIBS) \ - $(GNOMEGNORBA_LIBS) \ - libeminicard.a \ - -lbonobo \ - $(top_builddir)/e-util/libeutil.la \ - $(top_builddir)/addressbook/backend/ebook/libebook.la \ - $(top_builddir)/libversit/libversit.la \ - $(top_builddir)/addressbook/contact-editor/libecontacteditor.a \ - $(top_builddir)/widgets/e-text/libetext.a diff --git a/addressbook/gui/widgets/e-minicard-label.c b/addressbook/gui/widgets/e-minicard-label.c deleted file mode 100644 index e0e5c98118..0000000000 --- a/addressbook/gui/widgets/e-minicard-label.c +++ /dev/null @@ -1,421 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * e-minicard-label.c - * Copyright (C) 2000 Helix Code, Inc. - * Author: Chris Lahey - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include -#include -#include "e-minicard-label.h" -#include "e-text.h" -#include -#include -#include - -static void e_minicard_label_init (EMinicardLabel *card); -static void e_minicard_label_class_init (EMinicardLabelClass *klass); -static void e_minicard_label_set_arg (GtkObject *o, GtkArg *arg, guint arg_id); -static void e_minicard_label_get_arg (GtkObject *object, GtkArg *arg, guint arg_id); -static gboolean e_minicard_label_event (GnomeCanvasItem *item, GdkEvent *event); -static void e_minicard_label_realize (GnomeCanvasItem *item); -static void e_minicard_label_unrealize (GnomeCanvasItem *item); -static void e_minicard_label_reflow(GnomeCanvasItem *item, int flags); - -static void e_minicard_label_resize_children( EMinicardLabel *e_minicard_label ); - -static GnomeCanvasGroupClass *parent_class = NULL; - -/* The arguments we take */ -enum { - ARG_0, - ARG_WIDTH, - ARG_HEIGHT, - ARG_HAS_FOCUS, - ARG_FIELD, - ARG_FIELDNAME, - ARG_TEXT_MODEL -}; - -GtkType -e_minicard_label_get_type (void) -{ - static GtkType minicard_label_type = 0; - - if (!minicard_label_type) - { - static const GtkTypeInfo minicard_label_info = - { - "EMinicardLabel", - sizeof (EMinicardLabel), - sizeof (EMinicardLabelClass), - (GtkClassInitFunc) e_minicard_label_class_init, - (GtkObjectInitFunc) e_minicard_label_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - minicard_label_type = gtk_type_unique (gnome_canvas_group_get_type (), &minicard_label_info); - } - - return minicard_label_type; -} - -static void -e_minicard_label_class_init (EMinicardLabelClass *klass) -{ - GtkObjectClass *object_class; - GnomeCanvasItemClass *item_class; - - object_class = (GtkObjectClass*) klass; - item_class = (GnomeCanvasItemClass *) klass; - - parent_class = gtk_type_class (gnome_canvas_group_get_type ()); - - gtk_object_add_arg_type ("EMinicardLabel::width", GTK_TYPE_DOUBLE, - GTK_ARG_READWRITE, ARG_WIDTH); - gtk_object_add_arg_type ("EMinicardLabel::height", GTK_TYPE_DOUBLE, - GTK_ARG_READABLE, ARG_HEIGHT); - gtk_object_add_arg_type ("EMinicardLabel::has_focus", GTK_TYPE_BOOL, - GTK_ARG_READWRITE, ARG_HAS_FOCUS); - gtk_object_add_arg_type ("EMinicardLabel::field", GTK_TYPE_STRING, - GTK_ARG_READWRITE, ARG_FIELD); - gtk_object_add_arg_type ("EMinicardLabel::fieldname", GTK_TYPE_STRING, - GTK_ARG_READWRITE, ARG_FIELDNAME); - gtk_object_add_arg_type ("EMinicardLabel::text_model", GTK_TYPE_OBJECT, - GTK_ARG_READWRITE, ARG_TEXT_MODEL); - - object_class->set_arg = e_minicard_label_set_arg; - object_class->get_arg = e_minicard_label_get_arg; - /* object_class->destroy = e_minicard_label_destroy; */ - - /* GnomeCanvasItem method overrides */ - item_class->realize = e_minicard_label_realize; - item_class->unrealize = e_minicard_label_unrealize; - item_class->event = e_minicard_label_event; -} - -static void -e_minicard_label_init (EMinicardLabel *minicard_label) -{ - minicard_label->width = 10; - minicard_label->height = 10; - minicard_label->rect = NULL; - minicard_label->fieldname = NULL; - minicard_label->field = NULL; - - e_canvas_item_set_reflow_callback(GNOME_CANVAS_ITEM(minicard_label), e_minicard_label_reflow); -} - -static void -e_minicard_label_set_arg (GtkObject *o, GtkArg *arg, guint arg_id) -{ - GnomeCanvasItem *item; - EMinicardLabel *e_minicard_label; - - item = GNOME_CANVAS_ITEM (o); - e_minicard_label = E_MINICARD_LABEL (o); - - switch (arg_id){ - case ARG_WIDTH: - e_minicard_label->width = GTK_VALUE_DOUBLE (*arg); - e_minicard_label_resize_children(e_minicard_label); - e_canvas_item_request_reflow (item); - break; - case ARG_HAS_FOCUS: - if (e_minicard_label->field && (GTK_VALUE_ENUM(*arg) != E_FOCUS_NONE)) - e_canvas_item_grab_focus(e_minicard_label->field); - break; - case ARG_FIELD: - gnome_canvas_item_set( e_minicard_label->field, "text", GTK_VALUE_STRING (*arg), NULL ); - break; - case ARG_FIELDNAME: - gnome_canvas_item_set( e_minicard_label->fieldname, "text", GTK_VALUE_STRING (*arg), NULL ); - break; - case ARG_TEXT_MODEL: - gnome_canvas_item_set( e_minicard_label->field, "model", GTK_VALUE_OBJECT (*arg), NULL); - break; - } -} - -static void -e_minicard_label_get_arg (GtkObject *object, GtkArg *arg, guint arg_id) -{ - EMinicardLabel *e_minicard_label; - char *temp; - ETextModel *tempmodel; - - e_minicard_label = E_MINICARD_LABEL (object); - - switch (arg_id) { - case ARG_WIDTH: - GTK_VALUE_DOUBLE (*arg) = e_minicard_label->width; - break; - case ARG_HEIGHT: - GTK_VALUE_DOUBLE (*arg) = e_minicard_label->height; - break; - case ARG_HAS_FOCUS: - GTK_VALUE_ENUM (*arg) = e_minicard_label->has_focus ? E_FOCUS_CURRENT : E_FOCUS_NONE; - break; - case ARG_FIELD: - gtk_object_get( GTK_OBJECT( e_minicard_label->field ), "text", &temp, NULL ); - GTK_VALUE_STRING (*arg) = temp; - break; - case ARG_FIELDNAME: - gtk_object_get( GTK_OBJECT( e_minicard_label->fieldname ), "text", &temp, NULL ); - GTK_VALUE_STRING (*arg) = temp; - break; - case ARG_TEXT_MODEL: - gtk_object_get( GTK_OBJECT( e_minicard_label->field ), "model", &tempmodel, NULL ); - GTK_VALUE_OBJECT (*arg) = GTK_OBJECT(tempmodel); - break; - default: - arg->type = GTK_TYPE_INVALID; - break; - } -} - -static void -e_minicard_label_realize (GnomeCanvasItem *item) -{ - if (GNOME_CANVAS_ITEM_CLASS( parent_class )->realize) - (* GNOME_CANVAS_ITEM_CLASS( parent_class )->realize) (item); - - e_canvas_item_request_reflow(item); - - if (!item->canvas->aa) - { - } -} - -void -e_minicard_label_construct (GnomeCanvasItem *item) -{ - EMinicardLabel *e_minicard_label; - GnomeCanvasGroup *group; - static GdkFont *font = NULL; - - if ( font == NULL ) { - font = gdk_font_load("lucidasans-10"); - } - - e_minicard_label = E_MINICARD_LABEL (item); - group = GNOME_CANVAS_GROUP( item ); - - e_minicard_label->rect = - gnome_canvas_item_new( group, - gnome_canvas_rect_get_type(), - "x1", (double) 0, - "y1", (double) 0, - "x2", (double) e_minicard_label->width - 1, - "y2", (double) e_minicard_label->height - 1, - "outline_color", NULL, - NULL ); - e_minicard_label->fieldname = - gnome_canvas_item_new( group, - e_text_get_type(), - "anchor", GTK_ANCHOR_NW, - "clip_width", (double) ( e_minicard_label->width / 2 - 4 ), - "clip", TRUE, - "use_ellipsis", TRUE, - "font_gdk", font, - "fill_color", "black", - NULL ); - e_canvas_item_move_absolute(e_minicard_label->fieldname, 2, 1); - - e_minicard_label->field = - gnome_canvas_item_new( group, - e_text_get_type(), - "anchor", GTK_ANCHOR_NW, - "clip_width", (double) ( ( e_minicard_label->width + 1 ) / 2 - 4 ), - "clip", TRUE, - "use_ellipsis", TRUE, - "font_gdk", font, - "fill_color", "black", - "editable", TRUE, - NULL ); - e_canvas_item_move_absolute(e_minicard_label->field, ( e_minicard_label->width / 2 + 2), 1); - - e_canvas_item_request_reflow(item); -} - -static void -e_minicard_label_unrealize (GnomeCanvasItem *item) -{ - EMinicardLabel *e_minicard_label; - - e_minicard_label = E_MINICARD_LABEL (item); - - if (!item->canvas->aa) - { - } - - if (GNOME_CANVAS_ITEM_CLASS( parent_class )->unrealize) - (* GNOME_CANVAS_ITEM_CLASS( parent_class )->unrealize) (item); -} - -static gboolean -e_minicard_label_event (GnomeCanvasItem *item, GdkEvent *event) -{ - EMinicardLabel *e_minicard_label; - - e_minicard_label = E_MINICARD_LABEL (item); - - switch( event->type ) - { - case GDK_FOCUS_CHANGE: - { - GdkEventFocus *focus_event = (GdkEventFocus *) event; - if ( focus_event->in ) - { - gnome_canvas_item_set( e_minicard_label->rect, - "outline_color", "grey50", - "fill_color", "grey90", - NULL ); - e_minicard_label->has_focus = TRUE; - } - else - { - gnome_canvas_item_set( e_minicard_label->rect, - "outline_color", NULL, - "fill_color", NULL, - NULL ); - e_minicard_label->has_focus = FALSE; - } - } - break; - case GDK_BUTTON_PRESS: - case GDK_BUTTON_RELEASE: - case GDK_MOTION_NOTIFY: - case GDK_ENTER_NOTIFY: - case GDK_LEAVE_NOTIFY: { - gboolean return_val; -#if 0 - GnomeCanvasItem *field; - ArtPoint p; - double inv[6], affine[6]; - - field = e_minicard_label->field; - art_affine_identity (affine); - - if (field->xform != NULL) { - if (field->object.flags & GNOME_CANVAS_ITEM_AFFINE_FULL) { - art_affine_multiply (affine, affine, field->xform); - } else { - affine[4] += field->xform[0]; - affine[5] += field->xform[1]; - } - } - - art_affine_invert (inv, affine); - switch(event->type) { - case GDK_MOTION_NOTIFY: - p.x = event->motion.x; - p.y = event->motion.y; - art_affine_point (&p, &p, inv); - event->motion.x = p.x; - event->motion.y = p.y; - break; - case GDK_BUTTON_PRESS: - case GDK_BUTTON_RELEASE: - p.x = event->button.x; - p.y = event->button.y; - art_affine_point (&p, &p, inv); - event->button.x = p.x; - event->button.y = p.y; - break; - case GDK_ENTER_NOTIFY: - case GDK_LEAVE_NOTIFY: - p.x = event->crossing.x; - p.y = event->crossing.y; - art_affine_point (&p, &p, inv); - event->crossing.x = p.x; - event->crossing.y = p.y; - break; - default: - break; - } -#endif - gtk_signal_emit_by_name(GTK_OBJECT(e_minicard_label->field), "event", event, &return_val); - return return_val; - break; - } - default: - break; - } - - if (GNOME_CANVAS_ITEM_CLASS( parent_class )->event) - return (* GNOME_CANVAS_ITEM_CLASS( parent_class )->event) (item, event); - else - return 0; -} - -static void -e_minicard_label_resize_children(EMinicardLabel *e_minicard_label) -{ - gnome_canvas_item_set( e_minicard_label->fieldname, - "clip_width", (double) ( e_minicard_label->width / 2 - 4 ), - NULL ); - gnome_canvas_item_set( e_minicard_label->field, - "clip_width", (double) ( ( e_minicard_label->width + 1 ) / 2 - 4 ), - NULL ); -} - -static void -e_minicard_label_reflow(GnomeCanvasItem *item, int flags) -{ - EMinicardLabel *e_minicard_label = E_MINICARD_LABEL(item); - - gint old_height; - gdouble text_height; - old_height = e_minicard_label->height; - - gtk_object_get(GTK_OBJECT(e_minicard_label->fieldname), - "text_height", &text_height, - NULL); - - e_minicard_label->height = text_height; - - - gtk_object_get(GTK_OBJECT(e_minicard_label->field), - "text_height", &text_height, - NULL); - - if (e_minicard_label->height < text_height) - e_minicard_label->height = text_height; - e_minicard_label->height += 3; - - gnome_canvas_item_set( e_minicard_label->rect, - "x2", (double) e_minicard_label->width - 1, - "y2", (double) e_minicard_label->height - 1, - NULL ); - e_canvas_item_move_absolute(e_minicard_label->field, ( e_minicard_label->width / 2 + 2), 1); - - if (old_height != e_minicard_label->height) - e_canvas_item_request_parent_reflow(item); -} - -GnomeCanvasItem * -e_minicard_label_new(GnomeCanvasGroup *parent) -{ - GnomeCanvasItem *item = gnome_canvas_item_new(parent, e_minicard_label_get_type(), NULL); - e_minicard_label_construct(item); - return item; -} - diff --git a/addressbook/gui/widgets/e-minicard-label.h b/addressbook/gui/widgets/e-minicard-label.h deleted file mode 100644 index 1790414a54..0000000000 --- a/addressbook/gui/widgets/e-minicard-label.h +++ /dev/null @@ -1,82 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* e-minicard-label.h - * Copyright (C) 2000 Helix Code, Inc. - * Author: Chris Lahey - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ -#ifndef __E_MINICARD_LABEL_H__ -#define __E_MINICARD_LABEL_H__ - -#include - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - -/* EMinicardLabel - A label doing focus with non-marching ants. - * - * The following arguments are available: - * - * name type read/write description - * -------------------------------------------------------------------------------- - * width double RW width of the label - * height double R height of the label - * field string RW text in the field label - * fieldname string RW text in the fieldname label - */ - -#define E_MINICARD_LABEL_TYPE (e_minicard_label_get_type ()) -#define E_MINICARD_LABEL(obj) (GTK_CHECK_CAST ((obj), E_MINICARD_LABEL_TYPE, EMinicardLabel)) -#define E_MINICARD_LABEL_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_MINICARD_LABEL_TYPE, EMiniCardLabelClass)) -#define E_IS_MINICARD_LABEL(obj) (GTK_CHECK_TYPE ((obj), E_MINICARD_LABEL_TYPE)) -#define E_IS_MINICARD_LABEL_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), E_MINICARD_LABEL_TYPE)) - - -typedef struct _EMinicardLabel EMinicardLabel; -typedef struct _EMinicardLabelClass EMinicardLabelClass; - -struct _EMinicardLabel -{ - GnomeCanvasGroup parent; - - /* item specific fields */ - double width; - double height; - GnomeCanvasItem *fieldname; - GnomeCanvasItem *field; - GnomeCanvasItem *rect; - - gboolean has_focus; -}; - -struct _EMinicardLabelClass -{ - GnomeCanvasGroupClass parent_class; -}; - - -GtkType e_minicard_label_get_type (void); -GnomeCanvasItem *e_minicard_label_new(GnomeCanvasGroup *parent); -void e_minicard_label_construct (GnomeCanvasItem *item); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - - -#endif /* __E_MINICARD_LABEL_H__ */ diff --git a/addressbook/gui/widgets/e-minicard-view.c b/addressbook/gui/widgets/e-minicard-view.c deleted file mode 100644 index 35024d9564..0000000000 --- a/addressbook/gui/widgets/e-minicard-view.c +++ /dev/null @@ -1,281 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * e-minicard-view.c - * Copyright (C) 2000 Helix Code, Inc. - * Author: Chris Lahey - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include -#include -#include -#include "e-minicard-view.h" -#include "e-minicard.h" -static void e_minicard_view_init (EMinicardView *reflow); -static void e_minicard_view_class_init (EMinicardViewClass *klass); -static void e_minicard_view_set_arg (GtkObject *o, GtkArg *arg, guint arg_id); -static void e_minicard_view_get_arg (GtkObject *object, GtkArg *arg, guint arg_id); -static void e_minicard_view_destroy (GtkObject *object); - -#define E_MINICARD_VIEW_DIVIDER_WIDTH 2 -#define E_MINICARD_VIEW_BORDER_WIDTH 7 -#define E_MINICARD_VIEW_FULL_GUTTER (E_MINICARD_VIEW_DIVIDER_WIDTH + E_MINICARD_VIEW_BORDER_WIDTH * 2) - -static EReflowSortedClass *parent_class = NULL; - -/* The arguments we take */ -enum { - ARG_0, - ARG_BOOK, - ARG_QUERY -}; - -GtkType -e_minicard_view_get_type (void) -{ - static GtkType reflow_type = 0; - - if (!reflow_type) - { - static const GtkTypeInfo reflow_info = - { - "EMinicardView", - sizeof (EMinicardView), - sizeof (EMinicardViewClass), - (GtkClassInitFunc) e_minicard_view_class_init, - (GtkObjectInitFunc) e_minicard_view_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - reflow_type = gtk_type_unique (e_reflow_sorted_get_type (), &reflow_info); - } - - return reflow_type; -} - -static void -e_minicard_view_class_init (EMinicardViewClass *klass) -{ - GtkObjectClass *object_class; - GnomeCanvasItemClass *item_class; - - object_class = (GtkObjectClass*) klass; - item_class = (GnomeCanvasItemClass *) klass; - - parent_class = gtk_type_class (e_reflow_sorted_get_type ()); - - gtk_object_add_arg_type ("EMinicardView::book", GTK_TYPE_OBJECT, - GTK_ARG_READWRITE, ARG_BOOK); - gtk_object_add_arg_type ("EMinicardView::query", GTK_TYPE_STRING, - GTK_ARG_READWRITE, ARG_QUERY); - - object_class->set_arg = e_minicard_view_set_arg; - object_class->get_arg = e_minicard_view_get_arg; - object_class->destroy = e_minicard_view_destroy; - - /* GnomeCanvasItem method overrides */ -} - -static void -e_minicard_view_init (EMinicardView *view) -{ - view->book = NULL; - view->query = g_strdup("(contains \"full_name\" \"\")"); - view->book_view = NULL; - view->get_view_idle = 0; - view->create_card_id = 0; - view->remove_card_id = 0; - view->modify_card_id = 0; - - E_REFLOW_SORTED(view)->compare_func = (GCompareFunc) e_minicard_compare; - E_REFLOW_SORTED(view)->string_func = (EReflowStringFunc) e_minicard_get_card_id; -} - -static void -create_card(EBookView *book_view, const GList *cards, EMinicardView *view) -{ - for (; cards; cards = g_list_next(cards)) { - GnomeCanvasItem *item = gnome_canvas_item_new(GNOME_CANVAS_GROUP(view), - e_minicard_get_type(), - "card", cards->data, - NULL); - e_reflow_add_item(E_REFLOW(view), item); - } -} - -static void -modify_card(EBookView *book_view, const GList *cards, EMinicardView *view) -{ - for (; cards; cards = g_list_next(cards)) { - GnomeCanvasItem *item = gnome_canvas_item_new(GNOME_CANVAS_GROUP(view), - e_minicard_get_type(), - "card", cards->data, - NULL); - e_reflow_sorted_replace_item(E_REFLOW_SORTED(view), item); - } -} - -static void -remove_card(EBookView *book_view, const char *id, EMinicardView *view) -{ - e_reflow_sorted_remove_item(E_REFLOW_SORTED(view), id); -} - -static void -book_view_loaded (EBook *book, EBookStatus status, EBookView *book_view, gpointer closure) -{ - EMinicardView *view = closure; - if (view->book_view && view->create_card_id) - gtk_signal_disconnect(GTK_OBJECT (view->book_view), - view->create_card_id); - if (view->book_view && view->remove_card_id) - gtk_signal_disconnect(GTK_OBJECT (view->book_view), - view->remove_card_id); - if (view->book_view && view->modify_card_id) - gtk_signal_disconnect(GTK_OBJECT (view->book_view), - view->modify_card_id); - if (view->book_view) - gtk_object_unref(GTK_OBJECT(view->book_view)); - view->book_view = book_view; - if (view->book_view) - gtk_object_ref(GTK_OBJECT(view->book_view)); - view->create_card_id = gtk_signal_connect(GTK_OBJECT(view->book_view), - "card_added", - GTK_SIGNAL_FUNC(create_card), - view); - view->remove_card_id = gtk_signal_connect(GTK_OBJECT(view->book_view), - "card_removed", - GTK_SIGNAL_FUNC(remove_card), - view); - view->modify_card_id = gtk_signal_connect(GTK_OBJECT(view->book_view), - "card_changed", - GTK_SIGNAL_FUNC(modify_card), - view); - g_list_foreach(E_REFLOW(view)->items, (GFunc) gtk_object_destroy, NULL); - g_list_free(E_REFLOW(view)->items); - E_REFLOW(view)->items = NULL; - e_canvas_item_request_reflow(GNOME_CANVAS_ITEM(view)); -} - -static gboolean -get_view(EMinicardView *view) -{ - e_book_get_book_view(view->book, view->query, book_view_loaded, view); - - view->get_view_idle = 0; - return FALSE; -} - -static void -e_minicard_view_set_arg (GtkObject *o, GtkArg *arg, guint arg_id) -{ - GnomeCanvasItem *item; - EMinicardView *view; - - item = GNOME_CANVAS_ITEM (o); - view = E_MINICARD_VIEW (o); - - switch (arg_id){ - case ARG_BOOK: - if (view->book) - gtk_object_unref(GTK_OBJECT(view->book)); - view->book = E_BOOK(GTK_VALUE_OBJECT (*arg)); - if (view->book) { - gtk_object_ref(GTK_OBJECT(view->book)); - if (view->get_view_idle == 0) - view->get_view_idle = g_idle_add((GSourceFunc)get_view, view); - } - break; - case ARG_QUERY: - if (view->query) - g_free(view->query); - view->query = g_strdup(GTK_VALUE_STRING (*arg)); - if (view->get_view_idle == 0) - view->get_view_idle = g_idle_add((GSourceFunc)get_view, view); - break; - } -} - -static void -e_minicard_view_get_arg (GtkObject *object, GtkArg *arg, guint arg_id) -{ - EMinicardView *e_minicard_view; - - e_minicard_view = E_MINICARD_VIEW (object); - - switch (arg_id) { - case ARG_BOOK: - GTK_VALUE_OBJECT (*arg) = GTK_OBJECT(e_minicard_view->book); - break; - case ARG_QUERY: - GTK_VALUE_STRING (*arg) = g_strdup(e_minicard_view->query); - break; - default: - arg->type = GTK_TYPE_INVALID; - break; - } -} - -static void -e_minicard_view_destroy (GtkObject *object) -{ - EMinicardView *view = E_MINICARD_VIEW(object); - - if (view->get_view_idle) - g_source_remove(view->get_view_idle); - if (view->book) - gtk_object_unref(GTK_OBJECT(view->book)); - if (view->book_view && view->create_card_id) - gtk_signal_disconnect(GTK_OBJECT (view->book_view), - view->create_card_id); - if (view->book_view && view->remove_card_id) - gtk_signal_disconnect(GTK_OBJECT (view->book_view), - view->remove_card_id); - if (view->book_view && view->modify_card_id) - gtk_signal_disconnect(GTK_OBJECT (view->book_view), - view->modify_card_id); - if (view->book_view) - gtk_object_unref(GTK_OBJECT(view->book_view)); -} - -void -e_minicard_view_remove_selection(EMinicardView *view, - EBookCallback cb, - gpointer closure) -{ - if (view->book) { - EReflow *reflow = E_REFLOW(view); - GList *list; - for (list = reflow->items; list; list = g_list_next(list)) { - GnomeCanvasItem *item = list->data; - gboolean has_focus; - gtk_object_get(GTK_OBJECT(item), - "has_focus", &has_focus, - NULL); - if (has_focus) { - ECard *card; - gtk_object_get(GTK_OBJECT(item), - "card", &card, - NULL); - e_book_remove_card(view->book, card, cb, closure); - return; - } - } - } -} diff --git a/addressbook/gui/widgets/e-minicard-view.h b/addressbook/gui/widgets/e-minicard-view.h deleted file mode 100644 index ab0eeb892d..0000000000 --- a/addressbook/gui/widgets/e-minicard-view.h +++ /dev/null @@ -1,91 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* e-minicard-view.h - * Copyright (C) 2000 Helix Code, Inc. - * Author: Chris Lahey - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ -#ifndef __E_MINICARD_VIEW_H__ -#define __E_MINICARD_VIEW_H__ - -#include -#include "e-reflow-sorted.h" -#include - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - -/* EMinicardView - A canvas item container. - * - * The following arguments are available: - * - * name type read/write description - * -------------------------------------------------------------------------------- - * book EBook RW book to query - * query string RW query string - * - * From EReflowSorted: (you should really know what you're doing if you set these.) - * compare_func GCompareFunc RW compare function - * string_func EReflowStringFunc RW string function - * - * From EReflow: - * minimum_width double RW minimum width of the reflow. width >= minimum_width - * width double R width of the reflow - * height double RW height of the reflow - */ - -#define E_MINICARD_VIEW_TYPE (e_minicard_view_get_type ()) -#define E_MINICARD_VIEW(obj) (GTK_CHECK_CAST ((obj), E_MINICARD_VIEW_TYPE, EMinicardView)) -#define E_MINICARD_VIEW_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_MINICARD_VIEW_TYPE, EMinicardViewClass)) -#define E_IS_MINICARD_VIEW(obj) (GTK_CHECK_TYPE ((obj), E_MINICARD_VIEW_TYPE)) -#define E_IS_MINICARD_VIEW_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), E_MINICARD_VIEW_TYPE)) - - -typedef struct _EMinicardView EMinicardView; -typedef struct _EMinicardViewClass EMinicardViewClass; - -struct _EMinicardView -{ - EReflowSorted parent; - - /* item specific fields */ - EBook *book; - char *query; - EBookView *book_view; - - int get_view_idle; - - int create_card_id, remove_card_id, modify_card_id; -}; - -struct _EMinicardViewClass -{ - EReflowSortedClass parent_class; -}; - -GtkType e_minicard_view_get_type (void); -void e_minicard_view_remove_selection (EMinicardView *view, - EBookCallback cb, - gpointer closure); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - - -#endif /* __E_MINICARD_VIEW_H__ */ diff --git a/addressbook/gui/widgets/e-minicard.c b/addressbook/gui/widgets/e-minicard.c deleted file mode 100644 index addb019510..0000000000 --- a/addressbook/gui/widgets/e-minicard.c +++ /dev/null @@ -1,625 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * e-minicard.c - * Copyright (C) 2000 Helix Code, Inc. - * Author: Chris Lahey - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include -#include -#include "e-minicard.h" -#include "e-minicard-label.h" -#include "e-text.h" -#include -#include -#include -#include -#include "e-contact-editor.h" -#include "e-minicard-view.h" - -static void e_minicard_init (EMinicard *card); -static void e_minicard_class_init (EMinicardClass *klass); -static void e_minicard_set_arg (GtkObject *o, GtkArg *arg, guint arg_id); -static void e_minicard_get_arg (GtkObject *object, GtkArg *arg, guint arg_id); -static void e_minicard_destroy (GtkObject *object); -static gboolean e_minicard_event (GnomeCanvasItem *item, GdkEvent *event); -static void e_minicard_realize (GnomeCanvasItem *item); -static void e_minicard_unrealize (GnomeCanvasItem *item); -static void e_minicard_reflow ( GnomeCanvasItem *item, int flags ); - -static void e_minicard_resize_children( EMinicard *e_minicard ); -static void remodel( EMinicard *e_minicard ); - -static GnomeCanvasGroupClass *parent_class = NULL; - -/* The arguments we take */ -enum { - ARG_0, - ARG_WIDTH, - ARG_HEIGHT, - ARG_HAS_FOCUS, - ARG_CARD -}; - -GtkType -e_minicard_get_type (void) -{ - static GtkType minicard_type = 0; - - if (!minicard_type) - { - static const GtkTypeInfo minicard_info = - { - "EMinicard", - sizeof (EMinicard), - sizeof (EMinicardClass), - (GtkClassInitFunc) e_minicard_class_init, - (GtkObjectInitFunc) e_minicard_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - minicard_type = gtk_type_unique (gnome_canvas_group_get_type (), &minicard_info); - } - - return minicard_type; -} - -static void -e_minicard_class_init (EMinicardClass *klass) -{ - GtkObjectClass *object_class; - GnomeCanvasItemClass *item_class; - - object_class = (GtkObjectClass*) klass; - item_class = (GnomeCanvasItemClass *) klass; - - parent_class = gtk_type_class (gnome_canvas_group_get_type ()); - - gtk_object_add_arg_type ("EMinicard::width", GTK_TYPE_DOUBLE, - GTK_ARG_READWRITE, ARG_WIDTH); - gtk_object_add_arg_type ("EMinicard::height", GTK_TYPE_DOUBLE, - GTK_ARG_READABLE, ARG_HEIGHT); - gtk_object_add_arg_type ("EMinicard::has_focus", GTK_TYPE_ENUM, - GTK_ARG_READWRITE, ARG_HAS_FOCUS); - gtk_object_add_arg_type ("EMinicard::card", GTK_TYPE_OBJECT, - GTK_ARG_READWRITE, ARG_CARD); - - object_class->set_arg = e_minicard_set_arg; - object_class->get_arg = e_minicard_get_arg; - object_class->destroy = e_minicard_destroy; - - /* GnomeCanvasItem method overrides */ - item_class->realize = e_minicard_realize; - item_class->unrealize = e_minicard_unrealize; - item_class->event = e_minicard_event; -} - -static void -e_minicard_init (EMinicard *minicard) -{ - /* minicard->card = NULL;*/ - minicard->rect = NULL; - minicard->fields = NULL; - minicard->width = 10; - minicard->height = 10; - minicard->has_focus = FALSE; - - minicard->card = NULL; - - e_canvas_item_set_reflow_callback(GNOME_CANVAS_ITEM(minicard), e_minicard_reflow); -} - -static void -e_minicard_set_arg (GtkObject *o, GtkArg *arg, guint arg_id) -{ - GnomeCanvasItem *item; - EMinicard *e_minicard; - - item = GNOME_CANVAS_ITEM (o); - e_minicard = E_MINICARD (o); - - switch (arg_id){ - case ARG_WIDTH: - if (e_minicard->width != GTK_VALUE_DOUBLE (*arg)) { - e_minicard->width = GTK_VALUE_DOUBLE (*arg); - e_minicard_resize_children(e_minicard); - if ( GTK_OBJECT_FLAGS( e_minicard ) & GNOME_CANVAS_ITEM_REALIZED ) - e_canvas_item_request_reflow(item); - } - break; - case ARG_HAS_FOCUS: - if (e_minicard->fields) { - if ( GTK_VALUE_ENUM(*arg) == E_FOCUS_START || - GTK_VALUE_ENUM(*arg) == E_FOCUS_CURRENT) { - gnome_canvas_item_set(GNOME_CANVAS_ITEM(e_minicard->fields->data), - "has_focus", GTK_VALUE_ENUM(*arg), - NULL); - } else if ( GTK_VALUE_ENUM(*arg) == E_FOCUS_END ) { - gnome_canvas_item_set(GNOME_CANVAS_ITEM(g_list_last(e_minicard->fields)->data), - "has_focus", GTK_VALUE_ENUM(*arg), - NULL); - } - } - else - e_canvas_item_grab_focus(item); - break; - case ARG_CARD: - if (e_minicard->card) - gtk_object_unref (GTK_OBJECT(e_minicard->card)); - e_minicard->card = E_CARD(GTK_VALUE_OBJECT (*arg)); - if (e_minicard->card) - gtk_object_ref (GTK_OBJECT(e_minicard->card)); - remodel(e_minicard); - e_canvas_item_request_reflow(item); - break; - } -} - -static void -e_minicard_get_arg (GtkObject *object, GtkArg *arg, guint arg_id) -{ - EMinicard *e_minicard; - - e_minicard = E_MINICARD (object); - - switch (arg_id) { - case ARG_WIDTH: - GTK_VALUE_DOUBLE (*arg) = e_minicard->width; - break; - case ARG_HEIGHT: - GTK_VALUE_DOUBLE (*arg) = e_minicard->height; - break; - case ARG_HAS_FOCUS: - GTK_VALUE_ENUM (*arg) = e_minicard->has_focus ? E_FOCUS_CURRENT : E_FOCUS_NONE; - break; - case ARG_CARD: - GTK_VALUE_OBJECT (*arg) = GTK_OBJECT(e_minicard->card); - break; - default: - arg->type = GTK_TYPE_INVALID; - break; - } -} - -static void -e_minicard_destroy (GtkObject *object) -{ - EMinicard *e_minicard; - - g_return_if_fail (object != NULL); - g_return_if_fail (E_IS_MINICARD (object)); - - e_minicard = E_MINICARD (object); - - if (e_minicard->card) - gtk_object_unref (GTK_OBJECT(e_minicard->card)); - - if (GTK_OBJECT_CLASS (parent_class)->destroy) - (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); -} - -static void -e_minicard_realize (GnomeCanvasItem *item) -{ - EMinicard *e_minicard; - GnomeCanvasGroup *group; - - e_minicard = E_MINICARD (item); - group = GNOME_CANVAS_GROUP( item ); - - if (GNOME_CANVAS_ITEM_CLASS(parent_class)->realize) - (* GNOME_CANVAS_ITEM_CLASS(parent_class)->realize) (item); - - e_minicard->rect = - gnome_canvas_item_new( group, - gnome_canvas_rect_get_type(), - "x1", (double) 0, - "y1", (double) 0, - "x2", (double) e_minicard->width - 1, - "y2", (double) e_minicard->height - 1, - "outline_color", NULL, - NULL ); - - e_minicard->header_rect = - gnome_canvas_item_new( group, - gnome_canvas_rect_get_type(), - "x1", (double) 2, - "y1", (double) 2, - "x2", (double) e_minicard->width - 3, - "y2", (double) e_minicard->height - 3, - "fill_color", "grey70", - NULL ); - - e_minicard->header_text = - gnome_canvas_item_new( group, - e_text_get_type(), - "anchor", GTK_ANCHOR_NW, - "width", (double) ( e_minicard->width - 12 ), - "clip", TRUE, - "use_ellipsis", TRUE, - "font", "lucidasans-bold-10", - "fill_color", "black", - "text", "", - NULL ); - e_canvas_item_move_absolute(e_minicard->header_text, 6, 6); - - remodel(e_minicard); - e_canvas_item_request_reflow(item); - - if (!item->canvas->aa) { - } -} - -static void -e_minicard_unrealize (GnomeCanvasItem *item) -{ - EMinicard *e_minicard; - - e_minicard = E_MINICARD (item); - - if (!item->canvas->aa) - { - } - - if (GNOME_CANVAS_ITEM_CLASS(parent_class)->unrealize) - (* GNOME_CANVAS_ITEM_CLASS(parent_class)->unrealize) (item); -} - -static void -card_changed_cb (EBook* book, EBookStatus status, gpointer user_data) -{ - g_print ("%s: %s(): a card was changed\n", __FILE__, __FUNCTION__); -} - -static gboolean -e_minicard_event (GnomeCanvasItem *item, GdkEvent *event) -{ - EMinicard *e_minicard; - - e_minicard = E_MINICARD (item); - - switch( event->type ) { - case GDK_FOCUS_CHANGE: - { - GdkEventFocus *focus_event = (GdkEventFocus *) event; - if ( focus_event->in ) { - gnome_canvas_item_set( e_minicard->rect, - "outline_color", "grey50", - NULL ); - gnome_canvas_item_set( e_minicard->header_rect, - "fill_color", "darkblue", - NULL ); - gnome_canvas_item_set( e_minicard->header_text, - "fill_color", "white", - NULL ); - e_minicard->has_focus = TRUE; - } else { - gnome_canvas_item_set( e_minicard->rect, - "outline_color", NULL, - NULL ); - gnome_canvas_item_set( e_minicard->header_rect, - "fill_color", "grey70", - NULL ); - gnome_canvas_item_set( e_minicard->header_text, - "fill_color", "black", - NULL ); - e_minicard->has_focus = FALSE; - } - } - break; - case GDK_BUTTON_PRESS: - if (event->button.button == 1) { - e_canvas_item_grab_focus(item); - } - break; - case GDK_2BUTTON_PRESS: - if (E_IS_MINICARD_VIEW(item->parent)) { - gint result; - GtkWidget* contact_editor = - e_contact_editor_new(e_minicard->card); - EBook *book; - GtkWidget *dlg; - gtk_object_get(GTK_OBJECT(item->parent), - "book", &book, - NULL); - - dlg = gnome_dialog_new ("Contact Editor", "Save", "Cancel", NULL); - - g_assert (E_IS_BOOK (book)); - - gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (dlg)->vbox), - contact_editor, TRUE, TRUE, 0); - - gtk_widget_show_all (dlg); - - gnome_dialog_close_hides (GNOME_DIALOG (dlg), TRUE); - result = gnome_dialog_run_and_close (GNOME_DIALOG (dlg)); - - - /* If the user clicks "okay"...*/ - if (result == 0) { - ECard *card; - g_assert (contact_editor); - g_assert (GTK_IS_OBJECT (contact_editor)); - gtk_object_get(GTK_OBJECT(contact_editor), - "card", &card, - NULL); - - /* Add the card in the contact editor to our ebook */ - e_book_commit_card (book, - card, - card_changed_cb, - NULL); - } - } - break; - case GDK_KEY_PRESS: - if (event->key.keyval == GDK_Tab || - event->key.keyval == GDK_KP_Tab || - event->key.keyval == GDK_ISO_Left_Tab) { - GList *list; - for (list = e_minicard->fields; list; list = list->next) { - GnomeCanvasItem *item = GNOME_CANVAS_ITEM (list->data); - EFocus has_focus; - gtk_object_get(GTK_OBJECT(item), - "has_focus", &has_focus, - NULL); - if (has_focus != E_FOCUS_NONE) { - if (event->key.state & GDK_SHIFT_MASK) - list = list->prev; - else - list = list->next; - if (list) { - item = GNOME_CANVAS_ITEM (list->data); - gnome_canvas_item_set(item, - "has_focus", (event->key.state & GDK_SHIFT_MASK) ? E_FOCUS_END : E_FOCUS_START, - NULL); - return 1; - } else { - return 0; - } - } - } - } - default: - break; - } - - if (GNOME_CANVAS_ITEM_CLASS( parent_class )->event) - return (* GNOME_CANVAS_ITEM_CLASS( parent_class )->event) (item, event); - else - return 0; -} - -static void -e_minicard_resize_children( EMinicard *e_minicard ) -{ - if ( GTK_OBJECT_FLAGS( e_minicard ) & GNOME_CANVAS_ITEM_REALIZED ) { - GList *list; - - gnome_canvas_item_set( e_minicard->header_text, - "width", (double) e_minicard->width - 12, - NULL ); - for ( list = e_minicard->fields; list; list = g_list_next( list ) ) { - gnome_canvas_item_set( GNOME_CANVAS_ITEM( list->data ), - "width", (double) e_minicard->width - 4.0, - NULL ); - } - } -} - -static void -add_field (EMinicard *e_minicard, char *fieldname, char* field) -{ - GnomeCanvasItem *new_item; - GnomeCanvasGroup *group; - - group = GNOME_CANVAS_GROUP( e_minicard ); - - new_item = e_minicard_label_new(group); - gnome_canvas_item_set( new_item, - "width", e_minicard->width - 4.0, - "fieldname", fieldname, - "field", field, - NULL ); - e_minicard->fields = g_list_append( e_minicard->fields, new_item); - e_canvas_item_move_absolute(new_item, 2, e_minicard->height); -} - - -static void -remodel( EMinicard *e_minicard ) -{ - if (e_minicard->card) { - char *fname; - char *url; - char *org; - char *title; - char *role; - ECardList *address_list; - ECardList *phone_list; - ECardList *email_list; - - ECardIterator *iterator; - - GList *list; - - for ( list = e_minicard->fields; list; list = g_list_next( list ) ) { - gtk_object_destroy( GTK_OBJECT( list->data ) ); - } - g_list_free(e_minicard->fields); - e_minicard->fields = NULL; - - gtk_object_get(GTK_OBJECT(e_minicard->card), - "full_name", &fname, - "address", &address_list, - "phone", &phone_list, - "email", &email_list, - "url", &url, - "org", &org, - "title", &title, - "role", &role, - NULL); - - if (fname) { - add_field(e_minicard, "Name:", fname); - if (e_minicard->header_text) - gnome_canvas_item_set(e_minicard->header_text, - "text", fname, - NULL); - } else - if (e_minicard->header_text) - gnome_canvas_item_set(e_minicard->header_text, - "text", "", - NULL); - - if (org) - add_field(e_minicard, "Company:", org); - - if (title) - add_field(e_minicard, "Title:", title); - - if (role) - add_field(e_minicard, "Profession:", role); - - if (address_list) { - for (iterator = e_card_list_get_iterator(address_list); e_card_iterator_is_valid(iterator); e_card_iterator_next(iterator)) { - const ECardDeliveryAddress *address = e_card_iterator_get(iterator); - if (address->flags & ADDR_WORK) { - add_field(e_minicard, "Work Address:", address->city); - } else if (address->flags & ADDR_HOME) { - add_field(e_minicard, "Home Address:", address->city); - } else { - add_field(e_minicard, "Address:", address->city); - } - } - } - if (phone_list) { - for (iterator = e_card_list_get_iterator(phone_list); e_card_iterator_is_valid(iterator); e_card_iterator_next(iterator)) { - const ECardPhone *phone = e_card_iterator_get(iterator); - if (phone->flags & E_CARD_PHONE_WORK) { - add_field(e_minicard, "Work Phone:", phone->number); - } else if (phone->flags & E_CARD_PHONE_HOME) { - add_field(e_minicard, "Home Phone:", phone->number); - } else if (phone->flags & E_CARD_PHONE_CELL) { - add_field(e_minicard, "Mobile Phone:", phone->number); - } else { - add_field(e_minicard, "Phone:", phone->number); - } - } - } - if (email_list) { - for (iterator = e_card_list_get_iterator(email_list); e_card_iterator_is_valid(iterator); e_card_iterator_next(iterator)) { - add_field(e_minicard, "Email:", (char *) e_card_iterator_get(iterator)); - } - } - - if (url) - add_field(e_minicard, "Web page:", url); - } -} - -static void -e_minicard_reflow( GnomeCanvasItem *item, int flags ) -{ - EMinicard *e_minicard = E_MINICARD(item); - if ( GTK_OBJECT_FLAGS( e_minicard ) & GNOME_CANVAS_ITEM_REALIZED ) { - GList *list; - gdouble text_height; - gint old_height; - - old_height = e_minicard->height; - - gtk_object_get( GTK_OBJECT( e_minicard->header_text ), - "text_height", &text_height, - NULL ); - - e_minicard->height = text_height + 10.0; - - gnome_canvas_item_set( e_minicard->header_rect, - "y2", text_height + 9.0, - NULL ); - - for(list = e_minicard->fields; list; list = g_list_next(list)) { - gtk_object_get (GTK_OBJECT(list->data), - "height", &text_height, - NULL); - e_canvas_item_move_absolute(GNOME_CANVAS_ITEM(list->data), 2, e_minicard->height); - e_minicard->height += text_height; - } - e_minicard->height += 2; - - gnome_canvas_item_set( e_minicard->rect, - "y2", (double) e_minicard->height - 1, - NULL ); - - gnome_canvas_item_set( e_minicard->rect, - "x2", (double) e_minicard->width - 1.0, - "y2", (double) e_minicard->height - 1.0, - NULL ); - gnome_canvas_item_set( e_minicard->header_rect, - "x2", (double) e_minicard->width - 3.0, - NULL ); - - if (old_height != e_minicard->height) - e_canvas_item_request_parent_reflow(item); - } -} - -char * -e_minicard_get_card_id (EMinicard *minicard) -{ - g_return_val_if_fail(minicard != NULL, NULL); - g_return_val_if_fail(E_IS_MINICARD(minicard), NULL); - - if (minicard->card) { - return e_card_get_id(minicard->card); - } else { - return NULL; - } -} - -int -e_minicard_compare (EMinicard *minicard1, EMinicard *minicard2) -{ - g_return_val_if_fail(minicard1 != NULL, 0); - g_return_val_if_fail(E_IS_MINICARD(minicard1), 0); - g_return_val_if_fail(minicard2 != NULL, 0); - g_return_val_if_fail(E_IS_MINICARD(minicard2), 0); - - if (minicard1->card && minicard2->card) { - char *fname1, *fname2; - gtk_object_get(GTK_OBJECT(minicard1->card), - "full_name", &fname1, - NULL); - gtk_object_get(GTK_OBJECT(minicard2->card), - "full_name", &fname2, - NULL); - if (fname1 && fname2) - return strcmp(fname1, fname2); - if (fname1) - return -1; - if (fname2) - return 1; - return 0; - } else { - return 0; - } -} diff --git a/addressbook/gui/widgets/e-minicard.h b/addressbook/gui/widgets/e-minicard.h deleted file mode 100644 index 6844e136bd..0000000000 --- a/addressbook/gui/widgets/e-minicard.h +++ /dev/null @@ -1,97 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* e-minicard.h - * Copyright (C) 2000 Helix Code, Inc. - * Author: Chris Lahey - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ -#ifndef __E_MINICARD_H__ -#define __E_MINICARD_H__ - -#include -#include - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - -/* EMinicard - A small card displaying information about a contact. - * - * The following arguments are available: - * - * name type read/write description - * -------------------------------------------------------------------------------- - * width double RW width of the card - * height double R height of the card - * card ECard* RW Pointer to the ECard - */ - -#define E_MINICARD_TYPE (e_minicard_get_type ()) -#define E_MINICARD(obj) (GTK_CHECK_CAST ((obj), E_MINICARD_TYPE, EMinicard)) -#define E_MINICARD_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_MINICARD_TYPE, EMinicardClass)) -#define E_IS_MINICARD(obj) (GTK_CHECK_TYPE ((obj), E_MINICARD_TYPE)) -#define E_IS_MINICARD_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), E_MINICARD_TYPE)) - - -typedef struct _EMinicard EMinicard; -typedef struct _EMinicardClass EMinicardClass; -typedef enum _EMinicardFocusType EMinicardFocusType; - -enum _EMinicardFocusType { - E_MINICARD_FOCUS_TYPE_START, - E_MINICARD_FOCUS_TYPE_END -}; - -struct _EMinicard -{ - GnomeCanvasGroup parent; - - /* item specific fields */ - /* ECard *card; */ - - GnomeCanvasItem *rect; - GnomeCanvasItem *header_rect; - GnomeCanvasItem *header_text; - GList *fields; /* Of type GnomeCanvasItem. */ - - ECard *card; - guint needs_remodeling : 1; - - gboolean has_focus; - - double width; - double height; -}; - -struct _EMinicardClass -{ - GnomeCanvasGroupClass parent_class; - - void (* resize) (EMinicard *minicard); -}; - - -GtkType e_minicard_get_type (void); -char *e_minicard_get_card_id (EMinicard *minicard); -int e_minicard_compare (EMinicard *minicard1, EMinicard *minicard2); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - - -#endif /* __E_MINICARD_H__ */ diff --git a/addressbook/gui/widgets/test-minicard-label.c b/addressbook/gui/widgets/test-minicard-label.c deleted file mode 100644 index adf092206c..0000000000 --- a/addressbook/gui/widgets/test-minicard-label.c +++ /dev/null @@ -1,128 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* test-minicard-label.c - * - * Copyright (C) 2000 Helix Code, Inc. - * Author: Chris Lahey - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - - - -#include "config.h" - -#include -#include "e-minicard-label.h" -#include - -/* This is a horrible thing to do, but it is just a test. */ -GnomeCanvasItem *label; -GnomeCanvasItem *rect; - -static void destroy_callback(GtkWidget *app, gpointer data) -{ - exit(0); -} - -static void allocate_callback(GtkWidget *canvas, GtkAllocation *allocation, gpointer data) -{ - gnome_canvas_set_scroll_region(GNOME_CANVAS( canvas ), 0, 0, allocation->width, allocation->height ); - gnome_canvas_item_set( label, - "width", (double) allocation->width, - "height", (double) allocation->height, - NULL ); - gnome_canvas_item_set( rect, - "x2", (double) allocation->width, - "y2", (double) allocation->height, - NULL ); -} - -#if 0 -static void about_callback( GtkWidget *widget, gpointer data ) -{ - - const gchar *authors[] = - { - "Christopher James Lahey ", - NULL - }; - - GtkWidget *about = - gnome_about_new ( _( "Minicard Label Test" ), VERSION, - _( "Copyright (C) 2000, Helix Code, Inc." ), - authors, - _( "This should test the minicard label canvas item" ), - NULL); - gtk_widget_show (about); -} -#endif - -static void button_press_callback( GtkWidget *widget, gpointer data ) -{ - gnome_canvas_item_grab_focus( label ); -} - -int main( int argc, char *argv[] ) -{ - GtkWidget *app; - GtkWidget *canvas; - - /* bindtextdomain (PACKAGE, GNOMELOCALEDIR); - textdomain (PACKAGE);*/ - - gnome_init( "Minicard Label Test", VERSION, argc, argv); - app = gnome_app_new("Minicard Label Test", NULL); - - canvas = e_canvas_new(); - rect = gnome_canvas_item_new( gnome_canvas_root( GNOME_CANVAS( canvas ) ), - gnome_canvas_rect_get_type(), - "x1", (double) 0, - "y1", (double) 0, - "x2", (double) 100, - "y2", (double) 100, - "fill_color", "white", - NULL ); - label = e_minicard_label_new(gnome_canvas_root( GNOME_CANVAS( canvas ) )); - gnome_canvas_item_set( label, - "x", (double) 0, - "y", (double) 0, - "width", (double) 100, - "height", (double) 100, - "fieldname", "Full Name:", - "field", "Christopher James Lahey", - NULL ); - gnome_canvas_set_scroll_region ( GNOME_CANVAS( canvas ), - 0, 0, - 100, 100 ); - - gnome_app_set_contents( GNOME_APP( app ), canvas ); - - - /* Connect the signals */ - gtk_signal_connect( GTK_OBJECT( app ), "destroy", - GTK_SIGNAL_FUNC( destroy_callback ), - ( gpointer ) app ); - - gtk_signal_connect( GTK_OBJECT( canvas ), "size_allocate", - GTK_SIGNAL_FUNC( allocate_callback ), - ( gpointer ) app ); - - gtk_signal_connect( GTK_OBJECT( canvas ), "button_press_event", - GTK_SIGNAL_FUNC( button_press_callback ), - ( gpointer ) app ); - - gtk_widget_show_all( app ); - - gtk_main(); - - /* Not reached. */ - return 0; -} diff --git a/addressbook/gui/widgets/test-minicard-view.c b/addressbook/gui/widgets/test-minicard-view.c deleted file mode 100644 index c03d11d07e..0000000000 --- a/addressbook/gui/widgets/test-minicard-view.c +++ /dev/null @@ -1,206 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* test-reflow.c - * - * Copyright (C) 2000 Helix Code, Inc. - * Author: Chris Lahey - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#include "config.h" - -#include -#include -#include -#include -#include "e-minicard-view.h" - -/* This is a horrible thing to do, but it is just a test. */ -GnomeCanvasItem *reflow; -GnomeCanvasItem *rect; -GtkAllocation last_alloc; - -CORBA_Environment ev; -CORBA_ORB orb; - -static void -init_bonobo (int argc, char **argv) -{ - - gnome_CORBA_init_with_popt_table ( - "Reflow Test", VERSION, - &argc, argv, NULL, 0, NULL, GNORBA_INIT_SERVER_FUNC, &ev); - - orb = gnome_CORBA_ORB (); - - if (bonobo_init (orb, NULL, NULL) == FALSE) - g_error (_("Could not initialize Bonobo")); - -} - -static void destroy_callback(GtkWidget *app, gpointer data) -{ - exit(0); -} - -static void allocate_callback(GtkWidget *canvas, GtkAllocation *allocation, gpointer data) -{ - double width; - last_alloc = *allocation; - gnome_canvas_item_set( reflow, - "height", (double) allocation->height, - NULL ); - gnome_canvas_item_set( reflow, - "minimum_width", (double) allocation->width, - NULL ); - gtk_object_get(GTK_OBJECT(reflow), - "width", &width, - NULL); - width = MAX(width, allocation->width); - gnome_canvas_set_scroll_region(GNOME_CANVAS( canvas ), 0, 0, width, allocation->height ); - gnome_canvas_item_set( rect, - "x2", (double) width, - "y2", (double) allocation->height, - NULL ); -} - -static void resize(GnomeCanvas *canvas, gpointer data) -{ - double width; - gtk_object_get(GTK_OBJECT(reflow), - "width", &width, - NULL); - width = MAX(width, last_alloc.width); - gnome_canvas_set_scroll_region(canvas , 0, 0, width, last_alloc.height ); - gnome_canvas_item_set( rect, - "x2", (double) width, - "y2", (double) last_alloc.height, - NULL ); -} - -#if 0 -static void about_callback( GtkWidget *widget, gpointer data ) -{ - - const gchar *authors[] = - { - "Christopher James Lahey ", - NULL - }; - - GtkWidget *about = - gnome_about_new ( _( "Reflow Test" ), VERSION, - _( "Copyright (C) 2000, Helix Code, Inc." ), - authors, - _( "This should test the reflow canvas item" ), - NULL); - gtk_widget_show (about); -} -#endif - -static void -book_open_cb (EBook *book, EBookStatus status, gpointer closure) -{ - if (status == E_BOOK_STATUS_SUCCESS) - gnome_canvas_item_set(reflow, - "book", book, - NULL); -} - -static guint -ebook_create (void) -{ - EBook *book; - - book = e_book_new (); - - if (!book) { - printf ("%s: %s(): Couldn't create EBook, bailing.\n", - __FILE__, - __FUNCTION__); - return FALSE; - } - - - if (! e_book_load_uri (book, "file:/tmp/test.db", book_open_cb, NULL)) { - printf ("error calling load_uri!\n"); - } - - - return FALSE; -} - -int main( int argc, char *argv[] ) -{ - GtkWidget *app; - GtkWidget *canvas; - GtkWidget *vbox; - GtkWidget *scrollbar; - - /* bindtextdomain (PACKAGE, GNOMELOCALEDIR); - textdomain (PACKAGE);*/ - - CORBA_exception_init (&ev); - init_bonobo (argc, argv); - - app = gnome_app_new("Reflow Test", NULL); - - vbox = gtk_vbox_new(FALSE, 0); - - canvas = e_canvas_new(); - rect = gnome_canvas_item_new( gnome_canvas_root( GNOME_CANVAS( canvas ) ), - gnome_canvas_rect_get_type(), - "x1", (double) 0, - "y1", (double) 0, - "x2", (double) 100, - "y2", (double) 100, - "fill_color", "white", - NULL ); - reflow = gnome_canvas_item_new( gnome_canvas_root( GNOME_CANVAS( canvas ) ), - e_minicard_view_get_type(), - "height", (double) 100, - "minimum_width", (double) 100, - NULL ); - gtk_signal_connect( GTK_OBJECT( canvas ), "reflow", - GTK_SIGNAL_FUNC( resize ), - ( gpointer ) app); - - gnome_canvas_set_scroll_region ( GNOME_CANVAS( canvas ), - 0, 0, - 100, 100 ); - - gtk_box_pack_start(GTK_BOX(vbox), canvas, TRUE, TRUE, 0); - - scrollbar = gtk_hscrollbar_new(gtk_layout_get_hadjustment(GTK_LAYOUT(canvas))); - - gtk_box_pack_start(GTK_BOX(vbox), scrollbar, FALSE, FALSE, 0); - - gnome_app_set_contents( GNOME_APP( app ), vbox ); - - /* Connect the signals */ - gtk_signal_connect( GTK_OBJECT( app ), "destroy", - GTK_SIGNAL_FUNC( destroy_callback ), - ( gpointer ) app ); - - gtk_signal_connect( GTK_OBJECT( canvas ), "size_allocate", - GTK_SIGNAL_FUNC( allocate_callback ), - ( gpointer ) app ); - - gtk_widget_show_all( app ); - gdk_window_set_back_pixmap( GTK_LAYOUT(canvas)->bin_window, NULL, FALSE); - - gtk_idle_add ((GtkFunction) ebook_create, NULL); - - bonobo_main (); - - /* Not reached. */ - return 0; -} diff --git a/addressbook/gui/widgets/test-minicard.c b/addressbook/gui/widgets/test-minicard.c deleted file mode 100644 index 1ad066b3fe..0000000000 --- a/addressbook/gui/widgets/test-minicard.c +++ /dev/null @@ -1,117 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* test-minicard.c - * - * Copyright (C) 2000 Helix Code, Inc. - * Author: Chris Lahey - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - - - -#include "config.h" - -#include -#include "e-minicard.h" - -/* This is a horrible thing to do, but it is just a test. */ -GnomeCanvasItem *card; -GnomeCanvasItem *rect; - -static void destroy_callback(GtkWidget *app, gpointer data) -{ - exit(0); -} - -static void allocate_callback(GtkWidget *canvas, GtkAllocation *allocation, gpointer data) -{ - gnome_canvas_set_scroll_region(GNOME_CANVAS( canvas ), 0, 0, allocation->width, allocation->height ); - gnome_canvas_item_set( card, - "width", (double) allocation->width, - NULL ); - gnome_canvas_item_set( rect, - "x2", (double) allocation->width, - "y2", (double) allocation->height, - NULL ); -} - -#if 0 -static void about_callback( GtkWidget *widget, gpointer data ) -{ - - const gchar *authors[] = - { - "Christopher James Lahey ", - NULL - }; - - GtkWidget *about = - gnome_about_new ( _( "Minicard Test" ), VERSION, - _( "Copyright (C) 2000, Helix Code, Inc." ), - authors, - _( "This should test the minicard canvas item" ), - NULL); - gtk_widget_show (about); -} -#endif - -int main( int argc, char *argv[] ) -{ - GtkWidget *app; - GtkWidget *canvas; - int i; - - /* bindtextdomain (PACKAGE, GNOMELOCALEDIR); - textdomain (PACKAGE);*/ - - gnome_init( "Minicard Test", VERSION, argc, argv); - app = gnome_app_new("Minicard Test", NULL); - - canvas = gnome_canvas_new(); - rect = gnome_canvas_item_new( gnome_canvas_root( GNOME_CANVAS( canvas ) ), - gnome_canvas_rect_get_type(), - "x1", (double) 0, - "y1", (double) 0, - "x2", (double) 100, - "y2", (double) 100, - "fill_color", "white", - NULL ); - for ( i = 0; i < 1; i++ ) - { - card = gnome_canvas_item_new( gnome_canvas_root( GNOME_CANVAS( canvas ) ), - e_minicard_get_type(), - "x", (double) 0, - "y", (double) 0, - "width", (double) 100, - NULL ); - } - gnome_canvas_set_scroll_region ( GNOME_CANVAS( canvas ), - 0, 0, - 100, 100 ); - - gnome_app_set_contents( GNOME_APP( app ), canvas ); - - /* Connect the signals */ - gtk_signal_connect( GTK_OBJECT( app ), "destroy", - GTK_SIGNAL_FUNC( destroy_callback ), - ( gpointer ) app ); - - gtk_signal_connect( GTK_OBJECT( canvas ), "size_allocate", - GTK_SIGNAL_FUNC( allocate_callback ), - ( gpointer ) app ); - - gtk_widget_show_all( app ); - - gtk_main(); - - /* Not reached. */ - return 0; -} diff --git a/addressbook/gui/widgets/test-reflow.c b/addressbook/gui/widgets/test-reflow.c deleted file mode 100644 index 4817d13120..0000000000 --- a/addressbook/gui/widgets/test-reflow.c +++ /dev/null @@ -1,193 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* test-reflow.c - * - * Copyright (C) 2000 Helix Code, Inc. - * Author: Chris Lahey - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - - -#define TEST_VCARD \ -"BEGIN:VCARD -" \ -"FN:Nat -" \ -"N:Friedman;Nat;D;Mr. -" \ -"TITLE:Head Geek -" \ -"BDAY:1977-08-06 -" \ -"TEL;WORK:617 679 1984 -" \ -"TEL;CELL:123 456 7890 -" \ -"EMAIL;INTERNET:nat@nat.org -" \ -"EMAIL;INTERNET:nat@helixcode.com -" \ -"ADR;WORK;POSTAL:P.O. Box 101;;;Any Town;CA;91921-1234; -" \ -"ADR;HOME;POSTAL;INTL:P.O. Box 202;;;Any Town 2;MI;12344-4321;USA -" \ -"END:VCARD -" \ -" -" - - -#include "config.h" - -#include -#include -#include "e-reflow.h" -#include "e-minicard.h" - -/* This is a horrible thing to do, but it is just a test. */ -GnomeCanvasItem *reflow; -GnomeCanvasItem *rect; -GtkAllocation last_alloc; - -static void destroy_callback(GtkWidget *app, gpointer data) -{ - exit(0); -} - -static void allocate_callback(GtkWidget *canvas, GtkAllocation *allocation, gpointer data) -{ - double width; - last_alloc = *allocation; - gnome_canvas_item_set( reflow, - "height", (double) allocation->height, - NULL ); - gnome_canvas_item_set( reflow, - "minimum_width", (double) allocation->width, - NULL ); - gtk_object_get(GTK_OBJECT(reflow), - "width", &width, - NULL); - width = MAX(width, allocation->width); - gnome_canvas_set_scroll_region(GNOME_CANVAS( canvas ), 0, 0, width, allocation->height ); - gnome_canvas_item_set( rect, - "x2", (double) width, - "y2", (double) allocation->height, - NULL ); -} - -static void resize(GnomeCanvas *canvas, gpointer data) -{ - double width; - gtk_object_get(GTK_OBJECT(reflow), - "width", &width, - NULL); - width = MAX(width, last_alloc.width); - gnome_canvas_set_scroll_region(canvas , 0, 0, width, last_alloc.height ); - gnome_canvas_item_set( rect, - "x2", (double) width, - "y2", (double) last_alloc.height, - NULL ); -} - -#if 0 -static void about_callback( GtkWidget *widget, gpointer data ) -{ - - const gchar *authors[] = - { - "Christopher James Lahey ", - NULL - }; - - GtkWidget *about = - gnome_about_new ( _( "Reflow Test" ), VERSION, - _( "Copyright (C) 2000, Helix Code, Inc." ), - authors, - _( "This should test the reflow canvas item" ), - NULL); - gtk_widget_show (about); -} -#endif - -int main( int argc, char *argv[] ) -{ - GtkWidget *app; - GtkWidget *canvas; - GtkWidget *vbox; - GtkWidget *scrollbar; - int i; - - /* bindtextdomain (PACKAGE, GNOMELOCALEDIR); - textdomain (PACKAGE);*/ - - gnome_init( "Reflow Test", VERSION, argc, argv); - app = gnome_app_new("Reflow Test", NULL); - - vbox = gtk_vbox_new(FALSE, 0); - - canvas = e_canvas_new(); - rect = gnome_canvas_item_new( gnome_canvas_root( GNOME_CANVAS( canvas ) ), - gnome_canvas_rect_get_type(), - "x1", (double) 0, - "y1", (double) 0, - "x2", (double) 100, - "y2", (double) 100, - "fill_color", "white", - NULL ); - reflow = gnome_canvas_item_new( gnome_canvas_root( GNOME_CANVAS( canvas ) ), - e_reflow_get_type(), - "x", (double) 0, - "y", (double) 0, - "height", (double) 100, - "minimum_width", (double) 100, - NULL ); - gtk_signal_connect( GTK_OBJECT( canvas ), "reflow", - GTK_SIGNAL_FUNC( resize ), - ( gpointer ) app); - for ( i = 0; i < 200; i++ ) - { - GnomeCanvasItem *item; - ECard *card = e_card_new (TEST_VCARD); - item = gnome_canvas_item_new( GNOME_CANVAS_GROUP(reflow), - e_minicard_get_type(), - "card", card, - NULL); - e_reflow_add_item(E_REFLOW(reflow), item); - } - gnome_canvas_set_scroll_region ( GNOME_CANVAS( canvas ), - 0, 0, - 100, 100 ); - - gtk_box_pack_start(GTK_BOX(vbox), canvas, TRUE, TRUE, 0); - - scrollbar = gtk_hscrollbar_new(gtk_layout_get_hadjustment(GTK_LAYOUT(canvas))); - - gtk_box_pack_start(GTK_BOX(vbox), scrollbar, FALSE, FALSE, 0); - - gnome_app_set_contents( GNOME_APP( app ), vbox ); - - /* Connect the signals */ - gtk_signal_connect( GTK_OBJECT( app ), "destroy", - GTK_SIGNAL_FUNC( destroy_callback ), - ( gpointer ) app ); - - gtk_signal_connect( GTK_OBJECT( canvas ), "size_allocate", - GTK_SIGNAL_FUNC( allocate_callback ), - ( gpointer ) app ); - - gtk_widget_show_all( app ); - gdk_window_set_back_pixmap( GTK_LAYOUT(canvas)->bin_window, NULL, FALSE); - - gtk_main(); - - /* Not reached. */ - return 0; -} diff --git a/addressbook/printing/.cvsignore b/addressbook/printing/.cvsignore deleted file mode 100644 index eeb58ea38b..0000000000 --- a/addressbook/printing/.cvsignore +++ /dev/null @@ -1,8 +0,0 @@ -.deps -.libs -Makefile -Makefile.in -*.lo -*.la -contact-print-test -contact-print-style-editor-test diff --git a/addressbook/printing/Makefile.am b/addressbook/printing/Makefile.am deleted file mode 100644 index 7095171859..0000000000 --- a/addressbook/printing/Makefile.am +++ /dev/null @@ -1,44 +0,0 @@ - -CPPFLAGS = \ - -DEVOLUTION_GLADEDIR=\""$(gladedir)"\" \ - -DDATADIR=\""$(datadir)"\" \ - $(GNOME_PRINT_CFLAGS) - -INCLUDES = \ - $(GNOME_INCLUDEDIR) - -noinst_LIBRARIES = \ - libecontactprint.a - -libecontactprint_a_SOURCES = \ - e-contact-print.c \ - e-contact-print.h \ - e-contact-print-style-editor.c \ - e-contact-print-style-editor.h \ - e-contact-print-types.h - -noinst_PROGRAMS = \ - contact-print-test \ - contact-print-style-editor-test - -contact_print_test_SOURCES = \ - test-print.c - -contact_print_test_LDADD = \ - $(EXTRA_GNOME_LIBS) \ - libecontactprint.a \ - $(GNOME_PRINT_LIBS) - -contact_print_style_editor_test_SOURCES = \ - test-contact-print-style-editor.c - -contact_print_style_editor_test_LDADD = \ - $(EXTRA_GNOME_LIBS) \ - libecontactprint.a \ - $(GNOME_PRINT_LIBS) - -gladedir = $(datadir)/evolution/glade - -glade_DATA = \ - e-contact-print.glade - diff --git a/addressbook/printing/e-contact-print-style-editor.c b/addressbook/printing/e-contact-print-style-editor.c deleted file mode 100644 index 5eb5cadacf..0000000000 --- a/addressbook/printing/e-contact-print-style-editor.c +++ /dev/null @@ -1,150 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * e-contact-print-style-editor.c - * Copyright (C) 2000 Helix Code, Inc. - * Author: Chris Lahey - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include -#include "e-contact-print-style-editor.h" -static void e_contact_print_style_editor_init (EContactPrintStyleEditor *card); -static void e_contact_print_style_editor_class_init (EContactPrintStyleEditorClass *klass); -static void e_contact_print_style_editor_set_arg (GtkObject *o, GtkArg *arg, guint arg_id); -static void e_contact_print_style_editor_get_arg (GtkObject *object, GtkArg *arg, guint arg_id); -static void e_contact_print_style_editor_destroy (GtkObject *object); - -static GtkVBoxClass *parent_class = NULL; - - -/* The arguments we take */ -enum { - ARG_0, - ARG_CARD -}; - -GtkType -e_contact_print_style_editor_get_type (void) -{ - static GtkType contact_print_style_editor_type = 0; - - if (!contact_print_style_editor_type) - { - static const GtkTypeInfo contact_print_style_editor_info = - { - "EContactPrintStyleEditor", - sizeof (EContactPrintStyleEditor), - sizeof (EContactPrintStyleEditorClass), - (GtkClassInitFunc) e_contact_print_style_editor_class_init, - (GtkObjectInitFunc) e_contact_print_style_editor_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - contact_print_style_editor_type = gtk_type_unique (gtk_vbox_get_type (), &contact_print_style_editor_info); - } - - return contact_print_style_editor_type; -} - -static void -e_contact_print_style_editor_class_init (EContactPrintStyleEditorClass *klass) -{ - GtkObjectClass *object_class; - GtkVBoxClass *vbox_class; - - object_class = (GtkObjectClass*) klass; - vbox_class = (GtkVBoxClass *) klass; - - parent_class = gtk_type_class (gtk_vbox_get_type ()); - - object_class->set_arg = e_contact_print_style_editor_set_arg; - object_class->get_arg = e_contact_print_style_editor_get_arg; - object_class->destroy = e_contact_print_style_editor_destroy; -} - -#if 0 -static void -_add_image(GtkTable *table, gchar *image, int left, int right, int top, int bottom) -{ - gtk_table_attach(table, - gtk_widget_new(gtk_alignment_get_type(), - "child", gnome_pixmap_new_from_file(image), - "xalign", (double) 0, - "yalign", (double) 0, - "xscale", (double) 0, - "yscale", (double) 0, - NULL), - left, right, top, bottom, - GTK_FILL, GTK_FILL, - 0, 0); -} -#endif - -static void -e_contact_print_style_editor_init (EContactPrintStyleEditor *e_contact_print_style_editor) -{ - GladeXML *gui; - - /* e_contact_print_style_editor->card = NULL;*/ - gui = glade_xml_new (EVOLUTION_GLADEDIR "/e-contact-print.glade", NULL); - e_contact_print_style_editor->gui = gui; - gtk_widget_reparent(glade_xml_get_widget(gui, "vbox-contact-print-style-editor"), - GTK_WIDGET(e_contact_print_style_editor)); -} - -void -e_contact_print_style_editor_destroy (GtkObject *object) -{ - EContactPrintStyleEditor *e_contact_print_style_editor = E_CONTACT_PRINT_STYLE_EDITOR(object); - gtk_object_unref(GTK_OBJECT(e_contact_print_style_editor->gui)); -} - -GtkWidget* -e_contact_print_style_editor_new (char *filename) -{ - GtkWidget *widget = GTK_WIDGET (gtk_type_new (e_contact_print_style_editor_get_type ())); - return widget; -} - -static void -e_contact_print_style_editor_set_arg (GtkObject *o, GtkArg *arg, guint arg_id) -{ - EContactPrintStyleEditor *e_contact_print_style_editor; - - e_contact_print_style_editor = E_CONTACT_PRINT_STYLE_EDITOR (o); - - switch (arg_id){ - default: - break; - } -} - -static void -e_contact_print_style_editor_get_arg (GtkObject *object, GtkArg *arg, guint arg_id) -{ - EContactPrintStyleEditor *e_contact_print_style_editor; - - e_contact_print_style_editor = E_CONTACT_PRINT_STYLE_EDITOR (object); - - switch (arg_id) { - default: - arg->type = GTK_TYPE_INVALID; - break; - } -} diff --git a/addressbook/printing/e-contact-print-style-editor.h b/addressbook/printing/e-contact-print-style-editor.h deleted file mode 100644 index cf0f17f889..0000000000 --- a/addressbook/printing/e-contact-print-style-editor.h +++ /dev/null @@ -1,74 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* e-contact-print-style-editor.h - * Copyright (C) 2000 Helix Code, Inc. - * Author: Chris Lahey - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef __E_CONTACT_PRINT_STYLE_EDITOR_H__ -#define __E_CONTACT_PRINT_STYLE_EDITOR_H__ - -#include -#include - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - -/* EContactPrintStyleEditor - A dialog displaying information about a contact. - * - * The following arguments are available: - * - * name type read/write description - * -------------------------------------------------------------------------------- - * card ECard * R The card currently being edited - */ - -#define E_CONTACT_PRINT_STYLE_EDITOR_TYPE (e_contact_print_style_editor_get_type ()) -#define E_CONTACT_PRINT_STYLE_EDITOR(obj) (GTK_CHECK_CAST ((obj), E_CONTACT_PRINT_STYLE_EDITOR_TYPE, EContactPrintStyleEditor)) -#define E_CONTACT_PRINT_STYLE_EDITOR_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_CONTACT_PRINT_STYLE_EDITOR_TYPE, EContactPrintStyleEditorClass)) -#define E_IS_MINICARD(obj) (GTK_CHECK_TYPE ((obj), E_CONTACT_PRINT_STYLE_EDITOR_TYPE)) -#define E_IS_MINICARD_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), E_CONTACT_PRINT_STYLE_EDITOR_TYPE)) - - -typedef struct _EContactPrintStyleEditor EContactPrintStyleEditor; -typedef struct _EContactPrintStyleEditorClass EContactPrintStyleEditorClass; - -struct _EContactPrintStyleEditor -{ - GtkVBox parent; - - /* item specific fields */ - GladeXML *gui; -}; - -struct _EContactPrintStyleEditorClass -{ - GtkVBoxClass parent_class; -}; - - -GtkWidget *e_contact_print_style_editor_new(char *filename); -GtkType e_contact_print_style_editor_get_type (void); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - - -#endif /* __E_CONTACT_PRINT_STYLE_EDITOR_H__ */ diff --git a/addressbook/printing/e-contact-print-types.h b/addressbook/printing/e-contact-print-types.h deleted file mode 100644 index e99cfe6d39..0000000000 --- a/addressbook/printing/e-contact-print-types.h +++ /dev/null @@ -1,74 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * e-contact-print-types.h - * Copyright (C) 2000 Helix Code, Inc. - * Author: Chris Lahey - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef E_CONTACT_PRINT_TYPES_H -#define E_CONTACT_PRINT_TYPES_H - -#include -#include - -typedef struct _EContactPrintStyle EContactPrintStyle; -typedef enum _EContactPrintType EContactPrintType; - -enum _EContactPrintType { - E_CONTACT_PRINT_TYPE_CARDS, - E_CONTACT_PRINT_TYPE_MEMO_STYLE, - E_CONTACT_PRINT_TYPE_PHONE_LIST -}; - -struct _EContactPrintStyle -{ - gchar *title; - EContactPrintType type; - gboolean sections_start_new_page; - guint num_columns; - guint blank_forms; - gboolean letter_tabs; - gboolean letter_headings; - GnomeFont *headings_font; - GnomeFont *body_font; - gboolean print_using_grey; - gint paper_type; - gdouble paper_width; - gdouble paper_height; - gint paper_source; - gdouble top_margin; - gdouble left_margin; - gdouble bottom_margin; - gdouble right_margin; - gint page_size; - gdouble page_width; - gdouble page_height; - gboolean orientation_portrait; - GnomeFont *header_font; - gchar *left_header; - gchar *center_header; - gchar *right_header; - GnomeFont *footer_font; - gchar *left_footer; - gchar *center_footer; - gchar *right_footer; - gboolean reverse_on_even_pages; -}; - -#endif /* E_CONTACT_PRINT_TYPES_H */ - diff --git a/addressbook/printing/e-contact-print.c b/addressbook/printing/e-contact-print.c deleted file mode 100644 index f86d2613b1..0000000000 --- a/addressbook/printing/e-contact-print.c +++ /dev/null @@ -1,957 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * e-contact-print.c - * Copyright (C) 2000 Helix Code, Inc. - * Author: Chris Lahey - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - - -#include "e-contact-print.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define SCALE 5 -#define HYPHEN_PIXELS 20 -#define HYPHEN_PENALTY ( (SCALE) * (SCALE) * (HYPHEN_PIXELS) * (HYPHEN_PIXELS) ) - -typedef struct _EContactPrintContext EContactPrintContext; - -static int cardcount; - -struct _EContactPrintContext -{ - GnomePrintContext *pc; - GnomePrintMaster *master; - gdouble x; - gdouble y; - gint column; - EContactPrintStyle *style; - gboolean first_section; - gchar first_char_on_page; - gchar last_char_on_page; - GnomeFont *letter_heading_font; - GnomeFont *letter_tab_font; -}; - -static gint -e_contact_divide_text(GnomePrintContext *pc, GnomeFont *font, double width, gchar *text, GList **return_val /* Of type char[] */) -{ - if ( width == -1 || gnome_font_get_width_string(font, text) <= width ) { - if ( return_val ) { - *return_val = g_list_append(*return_val, g_strdup(text)); - } - return 1; - } else { -#if 1 - int i, l; - double x = 0; - int lastend = 0; - int linestart = 0; - int firstword = 1; - int linecount = 0; - l = strlen(text); - for ( i = 0; i < l; i++ ) { - if ( text[i] == ' ' ) { - if ( (!firstword) && x + gnome_font_get_width_string_n(font, text + lastend, i - lastend) > width ) { - if (return_val) { - *return_val = g_list_append(*return_val, g_strndup(text + linestart, lastend - linestart)); - } - x = gnome_font_get_width_string(font, " "); - linestart = lastend + 1; - x += gnome_font_get_width_string_n(font, text + linestart, i - linestart); - lastend = i; - linecount ++; - } else { - x += gnome_font_get_width_string_n(font, text + lastend, i - lastend); - lastend = i; - } - firstword = 0; - } else if ( text[i] == '\n' ) { - if ( (!firstword) && x + gnome_font_get_width_string_n(font, text + lastend, i - lastend) > width ) { - if (return_val) { - *return_val = g_list_append(*return_val, g_strndup(text + linestart, lastend - linestart)); - } - linestart = lastend + 1; - lastend = i; - linecount ++; - } - if (return_val) { - *return_val = g_list_append(*return_val, g_strndup(text + linestart, i - linestart)); - } - linestart = i + 1; - lastend = i + 1; - linecount ++; - x = gnome_font_get_width_string(font, " "); - - firstword = 1; - } - } - if ( (!firstword) && x + gnome_font_get_width_string_n(font, text + lastend, i - lastend) > width ) { - if (return_val) { - *return_val = g_list_append(*return_val, g_strndup(text + linestart, lastend - linestart)); - } - linestart = lastend + 1; - lastend = i; - linecount ++; - } - if (return_val) { - *return_val = g_list_append(*return_val, g_strndup(text + linestart, i - linestart)); - } - linecount ++; - return(linecount); -#else - HnjBreak *breaks; - gint *result; - gint *is; - gint n_breaks = 0, n_actual_breaks = 0; - gint i; - gint l; - gchar *hyphenation; - double x = - gnome_font_get_width_string(font, " ") * SCALE; - HnjParams hnjparams; - - hnjparams.set_width = width * SCALE + x; - hnjparams.max_neg_space = 0; - hnjparams.tab_width = 0; - - l = strlen(text); - - /* find possible line breaks. */ - for (i = 0; i < l; i++) { - if (text[i] == '-') - n_breaks++; - else if (text[i] == ' ') - n_breaks++; -#if 0 - else if (hyphenation[i] & 1) - n_breaks++; -#endif - } - - breaks = g_new( HnjBreak, n_breaks + 1 ); - result = g_new( gint, n_breaks + 1 ); - is = g_new( gint, n_breaks + 1 ); - n_breaks = 0; - /* find possible line breaks. */ - - for (i = 0; i < l; i++) { - if ( text[i] == '-' ) { - x += gnome_font_get_width(font, text[i]) * SCALE; - breaks[n_breaks].x0 = x; - breaks[n_breaks].x1 = x; - breaks[n_breaks].penalty = HYPHEN_PENALTY; - breaks[n_breaks].flags = HNJ_JUST_FLAG_ISHYPHEN; - is[n_breaks] = i + 1; - n_breaks++; - } else if ( text[i] == ' ' ) { - breaks[ n_breaks ].x0 = x; - x += gnome_font_get_width(font, text[i]) * SCALE; - breaks[ n_breaks ].x1 = x; - breaks[ n_breaks ].penalty = 0; - breaks[ n_breaks ].flags = HNJ_JUST_FLAG_ISSPACE; - is[ n_breaks ] = i + 1; - n_breaks++; -#if 0 - } else if (word->hyphenation[i] & 1) { - breaks[n_breaks].x0 = x + gnome_font_get_width(font, '-') * SCALE; - breaks[n_breaks].x1 = x; - breaks[n_breaks].penalty = HYPHEN_PENALTY; - breaks[n_breaks].flags = HNJ_JUST_FLAG_ISHYPHEN; - is[n_breaks] = i + 1; - n_breaks++; -#endif - } else - x += gnome_font_get_width(font, text[i]) * SCALE; - - } - is[n_breaks] = i; - breaks[n_breaks].flags = 0; - n_breaks++; - - /* Calculate optimal line breaks. */ - n_actual_breaks = hnj_hs_just (breaks, n_breaks, - &hnjparams, result); - - if ( return_val ) { - gchar *next_val; - if ( breaks[result[0]].flags == HNJ_JUST_FLAG_ISHYPHEN && text[is[result[0]]] != '-' ) { - next_val = g_new(gchar, is[result[0]] + 2); - strncpy(next_val, text, is[result[0]]); - next_val[is[result[0]]] = 0; - strcat(next_val, "-"); - } else { - next_val = g_new(gchar, is[result[0]] + 1); - strncpy(next_val, text, is[result[0]]); - next_val[is[result[0]]] = 0; - } - *return_val = g_list_append(*return_val, next_val); - - for ( i = 1; i < n_actual_breaks; i++ ) { - if ( (breaks[result[i]].flags & HNJ_JUST_FLAG_ISHYPHEN) && (text[is[result[i]]] != '-') ) { - next_val = g_new(gchar, is[result[i]] - is[result[i - 1]] + 2); - strncpy(next_val, text + is[result[i - 1]], is[result[i]] - is[result[i - 1]]); - next_val[is[result[i]] - is[result[i - 1]]] = 0; - strcat(next_val, "-"); - } else { - next_val = g_new(gchar, is[result[i]] - is[result[i - 1]] + 1); - strncpy(next_val, text + is[result[i - 1]], is[result[i]] - is[result[i - 1]]); - next_val[is[result[i]] - is[result[i - 1]]] = 0; - } - *return_val = g_list_append(*return_val, next_val); - } - } - - g_free (breaks); - g_free (result); - g_free (is); - return n_actual_breaks; -#endif - } -} - -static void -e_contact_output(GnomePrintContext *pc, GnomeFont *font, double x, double y, double width, gchar *text) -{ - GList *list = NULL, *list_start; - int first_line = 1; - gnome_print_gsave(pc); - gnome_print_setfont(pc, font); - e_contact_divide_text(pc, font, width, text, &list); - for ( list_start = list; list; list = g_list_next(list)) { - y -= gnome_font_get_ascender(font); - gnome_print_moveto(pc, x, y); - gnome_print_show(pc, (char *)list->data); - y -= gnome_font_get_descender(font); - y -= .2 * font->size; - if ( first_line ) { - x += gnome_font_get_width_string(font, " "); - first_line = 0; - } - } - g_list_foreach( list_start, (GFunc) g_free, NULL ); - g_list_free( list_start ); - gnome_print_grestore(pc); -} - -static gdouble -e_contact_text_height(GnomePrintContext *pc, GnomeFont *font, double width, gchar *text) -{ - int line_count = e_contact_divide_text(pc, font, width, text, NULL); - return line_count * (gnome_font_get_ascender(font) + gnome_font_get_descender(font)) + - line_count * .2 * font->size; -} - -#if 0 -static void -e_contact_output_and_advance(EContactPrintContext *ctxt, GnomeFont *font, double x, double width, gchar *text) -{ - ctxt->y -= .1 * font->size; - e_contact_output(ctxt->pc, font, x, ctxt->y, width, text); - ctxt->y -= e_contact_text_height(ctxt->pc, font, width, text); - ctxt->y -= .1 * font->size; -} -#endif - -static void -e_contact_rectangle(GnomePrintContext *pc, - gdouble x0, - gdouble y0, - gdouble x1, - gdouble y1, - gdouble r, - gdouble g, - gdouble b) -{ - gnome_print_gsave(pc); - gnome_print_setrgbcolor(pc, r, g, b); - gnome_print_moveto(pc, x0, y0); - gnome_print_lineto(pc, x1, y0); - gnome_print_lineto(pc, x1, y1); - gnome_print_lineto(pc, x0, y1); - gnome_print_lineto(pc, x0, y0); - gnome_print_fill(pc); - gnome_print_grestore(pc); -} - -static gchar *e_card_get_string(void *card, gchar *key) -{ - return key; -} - -static gchar *e_card_get_string_fileas(void *card) -{ - if (cardcount < 4) - return "Lahey, Chris"; - else if (cardcount < 20) - return "Rasputin"; - else if (cardcount < 24) - return "Wow, this guy has a really long name. Can you believe it?"; - else - return "Zamboni"; -} - -static double -e_contact_get_letter_tab_width (EContactPrintContext *ctxt) -{ - return gnome_font_get_width_string(ctxt->letter_tab_font, "123") + 4 + 18; -} - -static double -e_contact_print_letter_tab (EContactPrintContext *ctxt) -{ - char character; - gdouble x, y; - gdouble page_width = 72 * (ctxt->style->page_width - ctxt->style->left_margin - ctxt->style->right_margin); - gdouble tab_height, tab_width; - gdouble font_size; - tab_height = 72 * (ctxt->style->page_height - ctxt->style->top_margin - ctxt->style->bottom_margin) / 27.0; - font_size = tab_height / 2; - tab_width = e_contact_get_letter_tab_width(ctxt) - 18; - x = page_width + 72 * (ctxt->style->left_margin) - tab_width; - y = 72 * (ctxt->style->page_height - ctxt->style->top_margin); - - - gnome_print_gsave( ctxt->pc ); - if ( ctxt->style->print_using_grey ) - e_contact_rectangle( ctxt->pc, x, 72 * (ctxt->style->page_height - ctxt->style->top_margin), x + tab_width, ctxt->style->bottom_margin * 72, .85, .85, .85 ); - for ( character = 'A' - 1; character <= 'Z'; character ++ ) { - char string[] = "123"; - if ( character >= 'A' ) { - string[0] = tolower(character); - string[1] = 0; - } - if ( character >= ctxt->first_char_on_page && character <= ctxt->last_char_on_page ) { - e_contact_rectangle( ctxt->pc, x + 1, y - 1, x + tab_width - 1, y - (tab_height - 1), 0, 0, 0 ); - gnome_print_setrgbcolor( ctxt->pc, 1, 1, 1 ); - e_contact_output( ctxt->pc, ctxt->letter_tab_font, x + tab_width / 2 - gnome_font_get_width_string(ctxt->letter_tab_font, string) / 2, y - (tab_height - font_size) / 2, -1, string ); - } else { - gnome_print_setrgbcolor( ctxt->pc, 0, 0, 0 ); - e_contact_output( ctxt->pc, ctxt->letter_tab_font, x + tab_width / 2 - gnome_font_get_width_string(ctxt->letter_tab_font, string) / 2, y - (tab_height - font_size) / 2, -1, string ); - } - y -= tab_height; - } - gnome_print_grestore( ctxt->pc ); - return gnome_font_get_width_string(ctxt->style->body_font, "123") + ctxt->style->body_font->size / 5; -} - -static double -e_contact_get_letter_heading_height (EContactPrintContext *ctxt) -{ - gdouble ascender, descender; - ascender = gnome_font_get_ascender(ctxt->letter_heading_font); - descender = gnome_font_get_descender(ctxt->letter_heading_font); - return ascender + descender + 9; -} - -static void -e_contact_print_letter_heading (EContactPrintContext *ctxt, gchar *character) -{ - gdouble ascender, descender; - gdouble width; - - width = gnome_font_get_width_string(ctxt->letter_heading_font, "m") * 1.7; - ascender = gnome_font_get_ascender(ctxt->letter_heading_font); - descender = gnome_font_get_descender(ctxt->letter_heading_font); - gnome_print_gsave( ctxt->pc ); - e_contact_rectangle( ctxt->pc, ctxt->x, ctxt->y, ctxt->x + width, ctxt->y - (ascender + descender + 6), 0, 0, 0); - gnome_print_setrgbcolor(ctxt->pc, 1, 1, 1); - ctxt->y -= 4; - e_contact_output(ctxt->pc, ctxt->letter_heading_font, ctxt->x + (width - gnome_font_get_width_string(ctxt->letter_heading_font, character))/ 2, ctxt->y, -1, character); - ctxt->y -= ascender + descender; - ctxt->y -= 2; - ctxt->y -= 3; - gnome_print_grestore( ctxt->pc ); -} - -static void -e_contact_start_new_page(EContactPrintContext *ctxt) -{ - ctxt->x = ctxt->style->left_margin * 72; - ctxt->y = (ctxt->style->page_height - ctxt->style->top_margin) * 72; - ctxt->column = 0; - if ( ctxt->style->letter_tabs ) - e_contact_print_letter_tab(ctxt); - gnome_print_showpage(ctxt->pc); - - ctxt->first_char_on_page = ctxt->last_char_on_page + 1; -} - -static double -e_contact_get_card_size(void *card, EContactPrintContext *ctxt, GList *shown_fields) -{ - gdouble height = 0; - gdouble page_width = 72 * (ctxt->style->page_width - ctxt->style->left_margin - ctxt->style->right_margin); - gdouble column_width; - if ( ctxt->style->letter_tabs ) - page_width -= e_contact_get_letter_tab_width(ctxt); - column_width = (page_width + 18) / ctxt->style->num_columns - 18; - - height += ctxt->style->headings_font->size * .2; - - height += ctxt->style->headings_font->size * .2; - - height += e_contact_text_height(ctxt->pc, ctxt->style->headings_font, column_width - 4, e_card_get_string_fileas(card)); - height += ctxt->style->headings_font->size * .2; - - height += ctxt->style->headings_font->size * .2; - - for(; shown_fields; shown_fields = g_list_next(shown_fields)) { - double xoff = 0; - gchar *field = e_card_get_string(card, shown_fields->data); - xoff += gnome_font_get_width_string(ctxt->style->body_font, shown_fields->data); - xoff += gnome_font_get_width_string(ctxt->style->body_font, ": "); - height += e_contact_text_height(ctxt->pc, ctxt->style->body_font, column_width - xoff, field); - height += .2 * ctxt->style->body_font->size; - } - height += ctxt->style->headings_font->size * .4; - return height; -} - - -static void -e_contact_print_card (void *card, EContactPrintContext *ctxt, GList *shown_fields) -{ - gdouble page_width = 72 * (ctxt->style->page_width - ctxt->style->left_margin - ctxt->style->right_margin); - gdouble column_width; - if ( ctxt->style->letter_tabs ) - page_width -= e_contact_get_letter_tab_width(ctxt); - column_width = (page_width + 18) / ctxt->style->num_columns - 18; - - gnome_print_gsave(ctxt->pc); - - ctxt->y -= ctxt->style->headings_font->size * .2; - - ctxt->y -= ctxt->style->headings_font->size * .2; - - if (ctxt->style->print_using_grey) - e_contact_rectangle(ctxt->pc, ctxt->x, ctxt->y + ctxt->style->headings_font->size * .2, ctxt->x + column_width, ctxt->y - e_contact_text_height(ctxt->pc, ctxt->style->headings_font, column_width - 4, e_card_get_string_fileas(card)) - ctxt->style->headings_font->size * .2, .85, .85, .85); - e_contact_output(ctxt->pc, ctxt->style->headings_font, ctxt->x + 2, ctxt->y, column_width - 4, e_card_get_string_fileas(card)); - ctxt->y -= e_contact_text_height(ctxt->pc, ctxt->style->headings_font, column_width - 4, e_card_get_string_fileas(card)); - ctxt->y -= ctxt->style->headings_font->size * .2; - - ctxt->y -= ctxt->style->headings_font->size * .2; - - for(; shown_fields; shown_fields = g_list_next(shown_fields)) { - double xoff = 0; - gchar *field = e_card_get_string(card, shown_fields->data); - e_contact_output(ctxt->pc, ctxt->style->body_font, ctxt->x + xoff, ctxt->y, -1, shown_fields->data); - xoff += gnome_font_get_width_string(ctxt->style->body_font, shown_fields->data); - e_contact_output(ctxt->pc, ctxt->style->body_font, ctxt->x + xoff, ctxt->y, -1, ": "); - xoff += gnome_font_get_width_string(ctxt->style->body_font, ": "); - e_contact_output(ctxt->pc, ctxt->style->body_font, ctxt->x + xoff, ctxt->y, column_width - xoff, field); - ctxt->y -= e_contact_text_height(ctxt->pc, ctxt->style->body_font, column_width - xoff, field); - ctxt->y -= .2 * ctxt->style->body_font->size; - } - ctxt->y -= ctxt->style->headings_font->size * .4; - gnome_print_grestore(ctxt->pc); -} - -static void -e_contact_start_new_column (EContactPrintContext *ctxt) -{ - gdouble page_width = 72 * (ctxt->style->page_width - ctxt->style->left_margin - ctxt->style->right_margin); - gdouble column_offset; - if ( ctxt->style->letter_tabs ) - page_width -= e_contact_get_letter_tab_width(ctxt); - column_offset = (page_width + 18) / ctxt->style->num_columns; - ctxt->column ++; - if (ctxt->column >= ctxt->style->num_columns) { - e_contact_start_new_page(ctxt); - ctxt->column = 0; - } - ctxt->x = (72 * ctxt->style->left_margin) + column_offset * ctxt->column; - ctxt->y = 72 * (ctxt->style->page_height - ctxt->style->top_margin); -} - -static void -e_contact_do_print_cards (void *book, EContactPrintContext *ctxt, GList *shown_fields) -{ - gchar *character = NULL; - void *card = NULL; - gboolean first_contact = TRUE; - gdouble page_width = 72 * (ctxt->style->page_width - ctxt->style->left_margin - ctxt->style->right_margin); - gdouble column_width; - ctxt->y = (ctxt->style->page_height - ctxt->style->top_margin) * 72; - ctxt->x = (ctxt->style->left_margin) * 72; - if ( ctxt->style->letter_tabs ) - page_width -= e_contact_get_letter_tab_width(ctxt); - - ctxt->first_char_on_page = 'A' - 1; - - column_width = (page_width + 18) / ctxt->style->num_columns - 18; - /* - for(card = e_book_get_first(book); card; card = e_book_get_next(book)) { - */ - for (cardcount=0; cardcount < 30; cardcount++) { - gchar *file_as = e_card_get_string_fileas(card); - if ( file_as && (!character || *character != tolower(*file_as)) ) { - if (ctxt->style->sections_start_new_page && ! first_contact) { - e_contact_start_new_page(ctxt); - } - else if ((!first_contact) && (ctxt->y - e_contact_get_letter_heading_height(ctxt) - e_contact_get_card_size(card, ctxt, shown_fields) < ctxt->style->bottom_margin * 72)) - e_contact_start_new_column(ctxt); - if (!character) - character = g_strdup(" "); - *character = tolower(*file_as); - if ( ctxt->style->letter_headings ) - e_contact_print_letter_heading(ctxt, character); - ctxt->first_section = FALSE; - } - else if ( (!first_contact) && (ctxt->y - e_contact_get_card_size(card, ctxt, shown_fields) < ctxt->style->bottom_margin * 72)) { - e_contact_start_new_column(ctxt); - if ( ctxt->style->letter_headings ) - e_contact_print_letter_heading(ctxt, character); - } - ctxt->last_char_on_page = toupper(*file_as); - if ( ctxt->last_char_on_page < ctxt->first_char_on_page ) - ctxt->first_char_on_page = ctxt->last_char_on_page; - e_contact_print_card(card, ctxt, shown_fields); - first_contact = FALSE; - } - ctxt->last_char_on_page = 'Z'; - if ( ctxt->style->letter_tabs ) - e_contact_print_letter_tab(ctxt); - gnome_print_showpage(ctxt->pc); - gnome_print_context_close(ctxt->pc); - g_free(character); -} - -static double -e_contact_get_phone_list_size(void *card, EContactPrintContext *ctxt, GList *shown_fields) -{ - double height = 0; - - height += ctxt->style->headings_font->size * .2; - - height += ctxt->style->headings_font->size * .2; - - for(; shown_fields; shown_fields = g_list_next(shown_fields)) { - if ( 1 ) /* field is a phone field. */ { - gchar *field = e_card_get_string(card, shown_fields->data); - height += e_contact_text_height(ctxt->pc, ctxt->style->body_font, 100, field); - height += .2 * ctxt->style->body_font->size; - } - } - height += ctxt->style->headings_font->size * .4; - return height; -} - - -static void -e_contact_print_phone_list (void *card, EContactPrintContext *ctxt, GList *shown_fields) -{ - gdouble page_width = 72 * (ctxt->style->page_width - ctxt->style->left_margin - ctxt->style->right_margin); - gdouble column_width; - double xoff, dotwidth; - int dotcount; - char *dots; - int i; - if ( ctxt->style->letter_tabs ) - page_width -= e_contact_get_letter_tab_width(ctxt); - column_width = (page_width + 18) / ctxt->style->num_columns - 18; - - gnome_print_gsave(ctxt->pc); - - ctxt->y -= ctxt->style->headings_font->size * .2; - - ctxt->y -= ctxt->style->headings_font->size * .2; - - e_contact_output(ctxt->pc, ctxt->style->body_font, ctxt->x, ctxt->y, -1, e_card_get_string_fileas(card)); - - xoff = column_width - 9 * ctxt->style->body_font->size; - dotwidth = xoff - - gnome_font_get_width_string(ctxt->style->body_font, e_card_get_string_fileas(card)) - - gnome_font_get_width_string(ctxt->style->body_font, " "); - dotcount = dotwidth / gnome_font_get_width(ctxt->style->body_font, '.'); - dots = g_new(gchar, dotcount + 1); - for (i = 0; i < dotcount; i++) - dots[i] = '.'; - dots[dotcount] = 0; - e_contact_output(ctxt->pc, ctxt->style->body_font, ctxt->x + xoff - dotcount * gnome_font_get_width(ctxt->style->body_font, '.'), ctxt->y, -1, dots); - g_free(dots); - - for(; shown_fields; shown_fields = g_list_next(shown_fields)) { - if ( 1 ) /* field is a phone field. */ { - gchar *field = e_card_get_string(card, shown_fields->data); - e_contact_output(ctxt->pc, ctxt->style->body_font, ctxt->x + xoff, ctxt->y, -1, shown_fields->data); - e_contact_output(ctxt->pc, ctxt->style->body_font, - ctxt->x + column_width - gnome_font_get_width_string(ctxt->style->body_font, - field), - ctxt->y, - -1, - field); - ctxt->y -= e_contact_text_height(ctxt->pc, ctxt->style->body_font, 100, field); - ctxt->y -= .2 * ctxt->style->body_font->size; - } - } - ctxt->y -= ctxt->style->headings_font->size * .4; - gnome_print_grestore(ctxt->pc); -} - -static void -e_contact_do_print_phone_list (void *book, EContactPrintContext *ctxt, GList *shown_fields) -{ - gchar *character = NULL; - void *card = NULL; - int i; - gboolean first_contact = TRUE; - gdouble page_width = 72 * (ctxt->style->page_width - ctxt->style->left_margin - ctxt->style->right_margin); - gdouble column_width; - ctxt->y = (ctxt->style->page_height - ctxt->style->top_margin) * 72; - ctxt->x = (ctxt->style->left_margin) * 72; - if ( ctxt->style->letter_tabs ) - page_width -= e_contact_get_letter_tab_width(ctxt); - - ctxt->first_char_on_page = 'A' - 1; - - column_width = (page_width + 18) / ctxt->style->num_columns - 18; - /* - for(card = e_book_get_first(book); card; card = e_book_get_next(book)) { - */ - for (i=0; i < 30; i++) { - gchar *file_as = e_card_get_string_fileas(card); - if ( file_as && (!character || *character != tolower(*file_as)) ) { - if (ctxt->style->sections_start_new_page && ! first_contact) { - e_contact_start_new_page(ctxt); - } - else if ((!first_contact) && (ctxt->y - e_contact_get_letter_heading_height(ctxt) - e_contact_get_phone_list_size(card, ctxt, shown_fields) < ctxt->style->bottom_margin * 72)) - e_contact_start_new_column(ctxt); - if (!character) - character = g_strdup(" "); - *character = tolower(*file_as); - if ( ctxt->style->letter_headings ) - e_contact_print_letter_heading(ctxt, character); - ctxt->first_section = FALSE; - } - else if ( (!first_contact) && (ctxt->y - e_contact_get_card_size(card, ctxt, shown_fields) < ctxt->style->bottom_margin * 72)) { - e_contact_start_new_column(ctxt); - if ( ctxt->style->letter_headings ) - e_contact_print_letter_heading(ctxt, character); - } - ctxt->last_char_on_page = toupper(*file_as); - if ( ctxt->last_char_on_page < ctxt->first_char_on_page ) - ctxt->first_char_on_page = ctxt->last_char_on_page; - e_contact_print_phone_list(card, ctxt, shown_fields); - first_contact = FALSE; - } - ctxt->last_char_on_page = 'Z'; - if ( ctxt->style->letter_tabs ) - e_contact_print_letter_tab(ctxt); - gnome_print_showpage(ctxt->pc); - gnome_print_context_close(ctxt->pc); - g_free(character); -} - -static void -e_contact_do_print (void *book, EContactPrintContext *ctxt, GList *shown_fields) -{ - switch ( ctxt->style->type ) { - case E_CONTACT_PRINT_TYPE_CARDS: - e_contact_do_print_cards( book, ctxt, shown_fields ); - break; - case E_CONTACT_PRINT_TYPE_PHONE_LIST: - e_contact_do_print_phone_list( book, ctxt, shown_fields ); - break; - default: - break; - } -} - -static void lowify( char *data ) -{ - for ( ; *data; data++ ) - *data = tolower(*data); -} - -static gboolean get_bool( char *data ) -{ - if ( data ) { - lowify ( data ); - return ! strcmp(data, "true"); - } else - return FALSE; -} - -static void get_string( char *data, char **variable ) -{ - g_free ( *variable ); - if ( data ) - *variable = g_strdup( data ); - else - *variable = g_strdup( "" ); -} - -static int get_integer( char *data ) -{ - if ( data ) - return atoi(data); - else - return 0; -} - -static double get_float( char *data ) -{ - if ( data ) - return atof(data); - else - return 0; -} - -static void get_font( char *data, GnomeFont **variable ) -{ - if ( data ) { - GnomeFont *font = gnome_font_new_from_full_name( data ); - if ( font ) { - gtk_object_unref( GTK_OBJECT(*variable) ); - *variable = font; - } - } -} - - -static void -e_contact_build_style(EContactPrintStyle *style) -{ - xmlDocPtr styledoc; - style->title = g_strdup(""); - style->type = E_CONTACT_PRINT_TYPE_CARDS; - style->sections_start_new_page = TRUE; - style->num_columns = 2; - style->blank_forms = 2; - style->letter_tabs = TRUE; - style->letter_headings = FALSE; - style->headings_font = gnome_font_new("Helvetica-Bold", 8); - style->body_font = gnome_font_new("Helvetica", 6); - style->print_using_grey = TRUE; - style->paper_type = 0; - style->paper_width = 8.5; - style->paper_height = 11; - style->paper_source = 0; - style->top_margin = .5; - style->left_margin = .5; - style->bottom_margin = .5; - style->right_margin = .5; - style->page_size = 0; - style->page_width = 2.75; - style->page_height = 4.25; -#if 0 - style->page_width = 4.25; - style->page_height = 5.5; -#endif -#if 0 - style->page_width = 5.5; - style->page_height = 8.5; -#endif - style->orientation_portrait = FALSE; - style->header_font = gnome_font_new("Helvetica", 6); - style->left_header = g_strdup(""); - style->center_header = g_strdup(""); - style->right_header = g_strdup(""); - style->footer_font = gnome_font_new("Helvetica", 6); - style->left_footer = g_strdup(""); - style->center_footer = g_strdup(""); - style->right_footer = g_strdup(""); - style->reverse_on_even_pages = FALSE; - styledoc = xmlParseFile("smallbook.ecps"); - if (styledoc) { - xmlNodePtr stylenode = xmlDocGetRootElement(styledoc); - xmlNodePtr node; - for (node = stylenode->childs; node; node = node->next) { - char *data = xmlNodeGetContent ( node ); - if ( !strcmp( node->name, "title" ) ) { - get_string(data, &(style->title)); - } else if ( !strcmp( node->name, "type" ) ) { - lowify( data ); - if ( !strcmp( data, "cards" ) ) - style->type = E_CONTACT_PRINT_TYPE_CARDS; - else if ( !strcmp( data, "memo_style" ) ) - style->type = E_CONTACT_PRINT_TYPE_MEMO_STYLE; - else if ( !strcmp( data, "phone_list" ) ) - style->type = E_CONTACT_PRINT_TYPE_PHONE_LIST; - } else if ( !strcmp( node->name, "sections_start_new_page" ) ) { - style->sections_start_new_page = get_bool(data); - } else if ( !strcmp( node->name, "num_columns" ) ) { - style->num_columns = get_integer(data); - } else if ( !strcmp( node->name, "blank_forms" ) ) { - style->blank_forms = get_integer(data); - } else if ( !strcmp( node->name, "letter_tabs" ) ) { - style->letter_tabs = get_bool(data); - } else if ( !strcmp( node->name, "letter_headings" ) ) { - style->letter_headings = get_bool(data); - } else if ( !strcmp( node->name, "headings_font" ) ) { - get_font( data, &(style->headings_font) ); - } else if ( !strcmp( node->name, "body_font" ) ) { - get_font( data, &(style->body_font) ); - } else if ( !strcmp( node->name, "print_using_grey" ) ) { - style->print_using_grey = get_bool(data); - } else if ( !strcmp( node->name, "paper_width" ) ) { - style->paper_width = get_float(data); - } else if ( !strcmp( node->name, "paper_height" ) ) { - style->paper_height = get_float(data); - } else if ( !strcmp( node->name, "top_margin" ) ) { - style->top_margin = get_float(data); - } else if ( !strcmp( node->name, "left_margin" ) ) { - style->left_margin = get_float(data); - } else if ( !strcmp( node->name, "bottom_margin" ) ) { - style->bottom_margin = get_float(data); - } else if ( !strcmp( node->name, "right_margin" ) ) { - style->right_margin = get_float(data); - } else if ( !strcmp( node->name, "page_width" ) ) { - style->page_width = get_float(data); - } else if ( !strcmp( node->name, "page_height" ) ) { - style->page_height = get_float(data); - } else if ( !strcmp( node->name, "orientation" ) ) { - if ( data ) { - lowify(data); - style->orientation_portrait = strcmp(data, "landscape"); - } else { - style->orientation_portrait = TRUE; - } - } else if ( !strcmp( node->name, "header_font" ) ) { - get_font( data, &(style->header_font) ); - } else if ( !strcmp( node->name, "left_header" ) ) { - get_string(data, &(style->left_header)); - } else if ( !strcmp( node->name, "center_header" ) ) { - get_string(data, &(style->center_header)); - } else if ( !strcmp( node->name, "right_header" ) ) { - get_string(data, &(style->right_header)); - } else if ( !strcmp( node->name, "footer_font" ) ) { - get_font( data, &(style->footer_font) ); - } else if ( !strcmp( node->name, "left_footer" ) ) { - get_string(data, &(style->left_footer)); - } else if ( !strcmp( node->name, "center_footer" ) ) { - get_string(data, &(style->center_footer)); - } else if ( !strcmp( node->name, "right_footer" ) ) { - get_string(data, &(style->right_footer)); - } else if ( !strcmp( node->name, "reverse_on_even_pages" ) ) { - style->reverse_on_even_pages = get_bool(data); - } - if ( data ) - xmlFree (data); - } - xmlFreeDoc(styledoc); - } -} - -static gint -e_contact_print_close(GnomeDialog *dialog, gpointer data) -{ - return FALSE; -} - -static void -e_contact_print_button(GnomeDialog *dialog, gint button, gpointer data) -{ - EContactPrintContext ctxt; - EContactPrintStyle style; - GnomePrintMaster *master; - GtkWidget *preview; - GnomePrintContext *pc; - void *book = gtk_object_get_data(GTK_OBJECT(dialog), "book"); - GList *shown_fields = gtk_object_get_data(GTK_OBJECT(dialog), "shown_fields"); - gdouble font_size; - switch( button ) { - case GNOME_PRINT_PRINT: - master = gnome_print_master_new_from_dialog( GNOME_PRINT_DIALOG(dialog) ); - pc = gnome_print_master_get_context( master ); - e_contact_build_style(&style); - - ctxt.x = 0; - ctxt.y = 0; - ctxt.column = 0; - ctxt.style = &style; - ctxt.master = master; - ctxt.first_section = TRUE; - ctxt.first_char_on_page = 'A' - 1; - - font_size = 72 * ctxt.style->page_height / 27.0 / 2.0; - ctxt.letter_heading_font = gnome_font_new(gnome_font_get_name(ctxt.style->headings_font), ctxt.style->headings_font->size * 1.5); - ctxt.letter_tab_font = gnome_font_new(gnome_font_get_name(ctxt.style->headings_font), font_size); - - ctxt.pc = GNOME_PRINT_CONTEXT(gnome_print_multipage_new_from_sizes(pc, - 72 * style.paper_width, - 72 * style.paper_height, - 72 * style.page_width, - 72 * style.page_height)); - - e_contact_do_print(book, &ctxt, shown_fields); - gnome_print_master_print(master); - gtk_object_unref(GTK_OBJECT(ctxt.pc)); - gtk_object_unref(GTK_OBJECT(master)); - gnome_dialog_close(dialog); - break; - case GNOME_PRINT_PREVIEW: - master = gnome_print_master_new_from_dialog( GNOME_PRINT_DIALOG(dialog) ); - pc = gnome_print_master_get_context( master ); - e_contact_build_style(&style); - - ctxt.x = 0; - ctxt.y = 0; - ctxt.column = 0; - ctxt.style = &style; - ctxt.master = master; - ctxt.first_section = TRUE; - ctxt.first_char_on_page = 'A' - 1; - - font_size = 72 * ctxt.style->page_height / 27.0 / 2.0; - ctxt.letter_heading_font = gnome_font_new(gnome_font_get_name(ctxt.style->headings_font), ctxt.style->headings_font->size * 1.5); - ctxt.letter_tab_font = gnome_font_new(gnome_font_get_name(ctxt.style->headings_font), font_size); - - ctxt.pc = GNOME_PRINT_CONTEXT(gnome_print_multipage_new_from_sizes(pc, - 72 * style.paper_width, - 72 * style.paper_height, - 72 * style.page_width, - 72 * style.page_height)); - - e_contact_do_print(book, &ctxt, shown_fields); - preview = GTK_WIDGET(gnome_print_master_preview_new(master, "Print Preview")); - gtk_widget_show_all(preview); - gtk_object_unref(GTK_OBJECT(ctxt.pc)); - gtk_object_unref(GTK_OBJECT(master)); - break; - case GNOME_PRINT_CANCEL: - gnome_dialog_close(dialog); - break; - } -} - -GtkWidget * -e_contact_print_dialog_new(void *book, GList *shown_fields) -{ - GtkWidget *dialog; - - - dialog = gnome_print_dialog_new("Print cards", GNOME_PRINT_DIALOG_RANGE | GNOME_PRINT_DIALOG_COPIES); - gnome_print_dialog_construct_range_any(GNOME_PRINT_DIALOG(dialog), GNOME_PRINT_RANGE_ALL | GNOME_PRINT_RANGE_SELECTION, - NULL, NULL, NULL); - - gtk_object_set_data(GTK_OBJECT(dialog), "book", book); - gtk_object_set_data(GTK_OBJECT(dialog), "shown_fields", shown_fields); - gtk_signal_connect(GTK_OBJECT(dialog), - "clicked", GTK_SIGNAL_FUNC(e_contact_print_button), NULL); - gtk_signal_connect(GTK_OBJECT(dialog), - "close", GTK_SIGNAL_FUNC(e_contact_print_close), NULL); - return dialog; -} diff --git a/addressbook/printing/e-contact-print.glade b/addressbook/printing/e-contact-print.glade deleted file mode 100644 index c078929d07..0000000000 --- a/addressbook/printing/e-contact-print.glade +++ /dev/null @@ -1,1993 +0,0 @@ - - - - - Printing - printing - False - False - False - - - - GnomeDialog - print-edit-style - False - Page Setup: - GTK_WINDOW_TOPLEVEL - GTK_WIN_POS_NONE - False - False - False - False - False - False - - - GtkVBox - GnomeDialog:vbox - dialog-vbox1 - False - 8 - - 4 - True - True - - - - GtkVBox - vbox-contact-print-style-editor - False - 5 - - 0 - True - True - - - - GtkHBox - hbox2 - 5 - False - 16 - - 0 - True - True - - - - GtkLabel - label8 - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 0 - 0 - - 0 - False - False - - - - - GtkEntry - label-style-name - True - False - True - 0 - - - 0 - False - False - - - - - - GtkNotebook - notebook1 - True - True - True - GTK_POS_TOP - False - 2 - 2 - False - - 0 - True - True - - - - GtkVBox - vbox2 - 5 - False - 5 - - - GtkAlignment - alignment1 - 0.5 - 0.5 - 0 - 0 - - 0 - True - True - - - - GtkFrame - frame5 - - 0 - GTK_SHADOW_ETCHED_IN - - - Placeholder - - - - - - GtkHBox - hbox1 - True - 7 - - 0 - True - True - - - - GtkFrame - frame6 - - 0 - GTK_SHADOW_ETCHED_IN - - 0 - True - True - - - - GtkAlignment - alignment4 - 0 - 0 - 0 - 0 - - - GtkTable - table1 - 8 - 6 - 5 - False - 0 - 0 - - - GtkLabel - label5 - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - - 0 - 1 - 4 - 5 - 0 - 0 - False - False - False - False - True - True - - - - - GtkLabel - label4 - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - - 0 - 1 - 0 - 1 - 0 - 0 - False - False - False - False - True - True - - - - - GtkAlignment - alignment2 - 0 - 0.5 - 0 - 0 - - 1 - 5 - 0 - 1 - 0 - 0 - False - False - False - False - True - True - - - - GtkRadioButton - radiobutton1 - True - - True - True - - - - - GtkCheckButton - checkbutton1 - True - - False - True - - 1 - 5 - 4 - 5 - 0 - 0 - False - False - False - False - True - True - - - - - GtkCheckButton - checkbutton2 - True - - False - True - - 1 - 5 - 5 - 6 - 0 - 0 - False - False - False - False - True - True - - - - - GtkAlignment - alignment3 - 0 - 0.5 - 0 - 0 - - 1 - 5 - 1 - 2 - 0 - 0 - False - False - False - False - True - True - - - - GtkRadioButton - radiobutton2 - True - - False - True - - - - - GtkLabel - label6 - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - - 0 - 3 - 2 - 3 - 0 - 2 - False - False - False - False - True - True - - - - - GtkLabel - label7 - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - - 0 - 3 - 3 - 4 - 0 - 2 - False - False - False - False - True - True - - - - - GtkAlignment - alignment6 - 0 - 0.5 - 0 - 0 - - 3 - 4 - 3 - 4 - 0 - 2 - False - False - False - False - True - True - - - - GtkSpinButton - spinbutton2 - True - 1 - 0 - False - GTK_UPDATE_ALWAYS - False - False - 2 - 0 - 100 - 1 - 10 - 10 - - - - - GtkAlignment - alignment5 - 0 - 0.5 - 0 - 0 - - 3 - 4 - 2 - 3 - 0 - 2 - False - False - False - False - True - True - - - - GtkSpinButton - spinbutton1 - 45 - True - 1 - 0 - False - GTK_UPDATE_ALWAYS - False - False - 1 - 0 - 100 - 1 - 10 - 10 - - - - - - - - GtkVBox - vbox3 - False - 8 - - 0 - True - True - - - - GtkFrame - frame7 - - 0 - GTK_SHADOW_ETCHED_IN - - 0 - True - True - - - - GtkTable - table2 - 8 - 2 - 2 - False - 13 - 8 - - - GtkAlignment - alignment7 - 0.5 - 1 - 1 - 0 - - 1 - 2 - 1 - 2 - 0 - 0 - False - False - False - False - True - True - - - - GtkButton - button6 - True - - - - - - GtkAlignment - alignment8 - 0.5 - 1 - 1 - 0 - - 1 - 2 - 0 - 1 - 0 - 0 - False - False - False - False - True - True - - - - GtkButton - button5 - 90 - True - - - - - - GtkVBox - vbox4 - False - 0 - - 0 - 1 - 0 - 1 - 0 - 0 - True - False - False - False - True - True - - - - GtkLabel - label10 - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - - 0 - False - False - - - - - GtkEntry - entry3 - 100 - True - True - True - 0 - 10 pt. Tahoma - - 0 - False - False - - - - - - GtkVBox - vbox5 - False - 0 - - 0 - 1 - 1 - 2 - 0 - 0 - True - False - False - False - True - True - - - - GtkLabel - label9 - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - - 0 - False - False - - - - - GtkEntry - entry2 - 100 - True - True - True - 0 - 8 pt. Tahoma - - 0 - False - False - - - - - - - - GtkFrame - frame8 - - 0 - GTK_SHADOW_ETCHED_IN - - 0 - True - True - - - - GtkCheckButton - checkbutton3 - True - - False - True - - - - - - - - GtkLabel - Notebook:tab - label1 - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 0 - 0 - - - - GtkHBox - hbox3 - True - 0 - - - GtkVBox - vbox6 - False - 0 - - 0 - True - True - - - - GtkFrame - frame9 - - 0 - GTK_SHADOW_ETCHED_IN - - 0 - True - True - - - - GtkVBox - vbox16 - 10 - False - 0 - - - GtkVBox - vbox17 - False - 0 - - 0 - True - True - - - - GtkLabel - label21 - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - - 0 - False - False - - - - - GtkScrolledWindow - scrolledwindow1 - GTK_POLICY_ALWAYS - GTK_POLICY_ALWAYS - GTK_UPDATE_CONTINUOUS - GTK_UPDATE_CONTINUOUS - - 0 - True - True - - - - GtkCList - clist1 - True - 1 - 80 - GTK_SELECTION_SINGLE - False - GTK_SHADOW_IN - - - GtkLabel - CList:title - label26 - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 0 - 0 - - - - - - - GtkVBox - vbox18 - False - 0 - - 0 - True - True - - - - GtkLabel - label24 - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - - 0 - False - False - - - - - GtkHBox - hbox5 - True - 0 - - 0 - True - True - - - - GtkLabel - label27 - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 0 - 0 - - 0 - False - False - - - - - GtkEntry - entry9 - 1 - True - True - True - 0 - - - 0 - True - True - - - - - GtkLabel - label28 - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 0 - 0 - - 0 - False - False - - - - - GtkEntry - entry10 - 1 - True - True - True - 0 - - - 0 - True - True - - - - - - - GtkVBox - vbox19 - False - 0 - - 0 - True - True - - - - GtkLabel - label25 - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - - 0 - False - False - - - - - GtkCombo - combo1 - False - True - False - True - False - - - 0 - False - False - - - - GtkEntry - GtkCombo:entry - combo-entry1 - True - True - True - 0 - - - - - - - - - GtkFrame - frame10 - - 0 - GTK_SHADOW_ETCHED_IN - - 0 - True - True - - - - GtkTable - table4 - 15 - 2 - 4 - True - 6 - 9 - - - GtkLabel - label29 - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - - 0 - 1 - 0 - 1 - 0 - 0 - False - True - False - False - True - True - - - - - GtkLabel - label30 - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - - 0 - 1 - 1 - 2 - 0 - 0 - False - True - False - False - True - True - - - - - GtkLabel - label31 - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - - 2 - 3 - 0 - 1 - 0 - 0 - False - True - False - False - True - True - - - - - GtkEntry - entry11 - 1 - True - True - True - 0 - - - 1 - 2 - 0 - 1 - 0 - 0 - True - False - False - False - True - False - - - - - GtkEntry - entry12 - 1 - True - True - True - 0 - - - 3 - 4 - 0 - 1 - 0 - 0 - True - False - False - False - True - False - - - - - GtkEntry - entry13 - 1 - True - True - True - 0 - - - 3 - 4 - 1 - 2 - 0 - 0 - True - False - False - False - True - False - - - - - GtkEntry - entry14 - 1 - True - True - True - 0 - - - 1 - 2 - 1 - 2 - 0 - 0 - True - False - False - False - True - False - - - - - GtkLabel - label32 - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - - 2 - 3 - 1 - 2 - 0 - 0 - False - True - False - False - True - True - - - - - - - - GtkVBox - vbox7 - False - 0 - - 0 - True - True - - - - GtkFrame - frame11 - - 0 - GTK_SHADOW_ETCHED_IN - - 0 - True - True - - - - GtkVBox - vbox8 - 10 - False - 0 - - - GtkVBox - vbox20 - False - 0 - - 0 - True - True - - - - GtkLabel - label33 - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - - 0 - False - False - - - - - GtkScrolledWindow - scrolledwindow2 - GTK_POLICY_ALWAYS - GTK_POLICY_ALWAYS - GTK_UPDATE_CONTINUOUS - GTK_UPDATE_CONTINUOUS - - 0 - True - True - - - - GtkCList - clist2 - True - 1 - 80 - GTK_SELECTION_SINGLE - False - GTK_SHADOW_IN - - - GtkLabel - CList:title - label35 - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 0 - 0 - - - - - - - GtkVBox - vbox21 - False - 0 - - 0 - True - True - - - - GtkLabel - label34 - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - - 0 - False - False - - - - - GtkHBox - hbox6 - True - 0 - - 0 - True - True - - - - GtkLabel - label36 - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 0 - 0 - - 0 - False - False - - - - - GtkEntry - entry15 - 1 - True - True - True - 0 - - - 0 - True - True - - - - - GtkLabel - label37 - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 0 - 0 - - 0 - False - False - - - - - GtkEntry - entry16 - 1 - True - True - True - 0 - - - 0 - True - True - - - - - - - - - GtkFrame - frame12 - - 0 - GTK_SHADOW_ETCHED_IN - - 0 - True - True - - - - GtkHBox - hbox4 - False - 10 - - - Placeholder - - - - GtkVBox - vbox9 - False - 5 - - 0 - True - True - - - - GtkAlignment - alignment9 - 0 - 1 - 0 - 0 - - 0 - True - True - - - - GtkRadioButton - radiobutton3 - True - - False - True - - - - - GtkAlignment - alignment10 - 0 - 0 - 0 - 0 - - 0 - True - True - - - - GtkRadioButton - radiobutton4 - True - - False - True - - - - - - - - - - GtkLabel - Notebook:tab - label2 - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 0 - 0 - - - - GtkVBox - vbox10 - 8 - False - 0 - - - GtkTable - table5 - 4 - 3 - True - 4 - 4 - - 0 - True - True - - - - GtkAlignment - alignment15 - 0 - 1 - 0 - 0 - - 1 - 2 - 2 - 3 - 0 - 0 - False - False - False - False - True - True - - - - GtkButton - button11 - True - - - - - - GtkText - text10 - 50 - True - False - - - 0 - 1 - 1 - 2 - 0 - 0 - False - True - False - False - True - True - - - - - GtkText - text11 - 50 - True - False - - - 2 - 3 - 1 - 2 - 0 - 0 - True - False - False - False - True - True - - - - - GtkText - text12 - 50 - True - False - - - 1 - 2 - 1 - 2 - 0 - 0 - False - False - False - False - True - True - - - - - GtkText - text13 - 50 - True - False - - - 0 - 1 - 3 - 4 - 0 - 0 - False - True - False - False - True - True - - - - - GtkText - text14 - 5 - True - False - - - 1 - 2 - 3 - 4 - 0 - 0 - False - False - False - False - True - True - - - - - GtkText - text15 - 50 - True - False - - - 2 - 3 - 3 - 4 - 0 - 0 - False - False - False - False - True - True - - - - - GtkAlignment - alignment16 - 0.5 - 1 - 1 - 0 - - 0 - 1 - 0 - 1 - 0 - 0 - True - False - False - False - True - True - - - - GtkVBox - vbox14 - False - 0 - - - GtkLabel - label14 - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - - 0 - False - False - - - - - GtkEntry - entry7 - True - True - True - 0 - - - 0 - False - False - - - - - - - GtkAlignment - alignment17 - 0.5 - 1 - 1 - 0 - - 0 - 1 - 2 - 3 - 0 - 0 - True - False - False - False - True - True - - - - GtkVBox - vbox15 - False - 0 - - - GtkLabel - label15 - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - - 0 - False - False - - - - - GtkEntry - entry8 - True - True - True - 0 - - - 0 - False - False - - - - - - - GtkAlignment - alignment14 - 0 - 1 - 0 - 0 - - 1 - 2 - 0 - 1 - 0 - 0 - False - False - False - False - True - True - - - - GtkButton - button10 - True - - - - - - - GtkHBox - hbox7 - False - 0 - - 0 - False - True - - - - GtkToolbar - toolbar1 - GTK_ORIENTATION_HORIZONTAL - GTK_TOOLBAR_ICONS - 5 - GTK_TOOLBAR_SPACE_EMPTY - GTK_RELIEF_NORMAL - True - - 0 - True - False - - - - Placeholder - - - - Placeholder - - - - Placeholder - - - - Placeholder - - - - Placeholder - - - - - - GtkCheckButton - checkbutton4 - True - - False - True - - 0 - False - False - - - - - - GtkLabel - Notebook:tab - label3 - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 0 - 0 - - - - - - GtkHButtonBox - GnomeDialog:action_area - dialog-action_area1 - GTK_BUTTONBOX_END - 8 - 85 - 27 - 7 - 0 - - 0 - False - True - GTK_PACK_END - - - - GtkButton - button1 - True - True - GNOME_STOCK_BUTTON_OK - - - - GtkButton - button2 - True - True - GNOME_STOCK_BUTTON_APPLY - - - - GtkButton - button3 - True - True - GNOME_STOCK_BUTTON_CANCEL - - - - - - diff --git a/addressbook/printing/e-contact-print.h b/addressbook/printing/e-contact-print.h deleted file mode 100644 index 28a0d14441..0000000000 --- a/addressbook/printing/e-contact-print.h +++ /dev/null @@ -1,31 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * e-contact-print.h - * Copyright (C) 2000 Helix Code, Inc. - * Author: Chris Lahey - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef E_CONTACT_PRINT_H -#define E_CONTACT_PRINT_H - -#include -#include "e-contact-print-types.h" - -GtkWidget *e_contact_print_dialog_new(void *book, GList *shown_fields); - -#endif /* E_CONTACT_PRINT_H */ diff --git a/addressbook/printing/medbook.ecps b/addressbook/printing/medbook.ecps deleted file mode 100644 index 2031f39b92..0000000000 --- a/addressbook/printing/medbook.ecps +++ /dev/null @@ -1,30 +0,0 @@ - diff --git a/addressbook/printing/phonelist.ecps b/addressbook/printing/phonelist.ecps deleted file mode 100644 index 53ca294d36..0000000000 --- a/addressbook/printing/phonelist.ecps +++ /dev/null @@ -1,29 +0,0 @@ - diff --git a/addressbook/printing/smallbook.ecps b/addressbook/printing/smallbook.ecps deleted file mode 100644 index 5844851bfb..0000000000 --- a/addressbook/printing/smallbook.ecps +++ /dev/null @@ -1,30 +0,0 @@ - diff --git a/addressbook/printing/test-contact-print-style-editor.c b/addressbook/printing/test-contact-print-style-editor.c deleted file mode 100644 index d4dccc0b87..0000000000 --- a/addressbook/printing/test-contact-print-style-editor.c +++ /dev/null @@ -1,87 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * test-contact-print-style-editor.c - * Copyright (C) 2000 Helix Code, Inc. - * Author: Chris Lahey - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include "config.h" - -#include -#include "e-contact-print-style-editor.h" - -/* This is a horrible thing to do, but it is just a test. */ -GtkWidget *editor; - -static void destroy_callback(GtkWidget *app, gpointer data) -{ - static int count = 2; - count --; - if ( count <= 0 ) - exit(0); -} - -#if 0 -static void about_callback( GtkWidget *widget, gpointer data ) -{ - - const gchar *authors[] = - { - "Christopher James Lahey ", - NULL - }; - - GtkWidget *about = - gnome_about_new ( _( "Contact Print Style Editor Test" ), VERSION, - _( "Copyright (C) 2000, Helix Code, Inc." ), - authors, - _( "This should test the contact print style editor widget" ), - NULL); - gtk_widget_show (about); -} -#endif - -int main( int argc, char *argv[] ) -{ - GtkWidget *app; - - /* bindtextdomain (PACKAGE, GNOMELOCALEDIR); - textdomain (PACKAGE);*/ - - gnome_init( "Contact Print Style Editor Test", VERSION, argc, argv); - - glade_gnome_init (); - - app = gnome_app_new("Contact Print Style Editor Test", NULL); - - editor = e_contact_print_style_editor_new(""); - - gnome_app_set_contents( GNOME_APP( app ), editor ); - - /* Connect the signals */ - gtk_signal_connect( GTK_OBJECT( app ), "destroy", - GTK_SIGNAL_FUNC( destroy_callback ), - ( gpointer ) app ); - - gtk_widget_show_all( app ); - - gtk_main(); - - /* Not reached. */ - return 0; -} diff --git a/addressbook/printing/test-print.c b/addressbook/printing/test-print.c deleted file mode 100644 index 7b438eed31..0000000000 --- a/addressbook/printing/test-print.c +++ /dev/null @@ -1,82 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * test-print.c - * Copyright (C) 2000 Helix Code, Inc. - * Author: Chris Lahey - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include "config.h" - -#include -#include -#include "e-contact-print.h" - -/* This is a horrible thing to do, but it is just a test. */ -GtkWidget *print; - -static gint test_close(GnomeDialog *dialog, gpointer data) -{ - exit(0); - return 1; -} - -#if 0 -static void about_callback( GtkWidget *widget, gpointer data ) -{ - - const gchar *authors[] = - { - "Christopher James Lahey ", - NULL - }; - - GtkWidget *about = - gnome_about_new ( _( "Contact Print Test" ), VERSION, - _( "Copyright (C) 2000, Helix Code, Inc." ), - authors, - _( "This should test the contact print code" ), - NULL); - gtk_widget_show (about); -} -#endif - -int main( int argc, char *argv[] ) -{ - GList *shown_fields = NULL; - - /* bindtextdomain (PACKAGE, GNOMELOCALEDIR); - textdomain (PACKAGE);*/ - - gnome_init( "Contact Print Test", VERSION, argc, argv); - - glade_gnome_init (); - - shown_fields = g_list_append(shown_fields, "First field"); - shown_fields = g_list_append(shown_fields, "Second field"); - shown_fields = g_list_append(shown_fields, "Third field"); - shown_fields = g_list_append(shown_fields, "Fourth field"); - - print = e_contact_print_dialog_new(NULL, shown_fields); - gtk_widget_show_all(print); - gtk_signal_connect(GTK_OBJECT(print), "close", GTK_SIGNAL_FUNC(test_close), NULL); - - gtk_main(); - - /* Not reached. */ - return 0; -} -- cgit v1.2.3