From a2d460b54b167a639bf05662d2f0de46acf73400 Mon Sep 17 00:00:00 2001 From: nobody Date: Thu, 6 Jul 2000 04:58:12 +0000 Subject: This commit was manufactured by cvs2svn to create tag 'BEFORE_GTK_1_3_CHANGES'. svn path=/tags/BEFORE_GTK_1_3_CHANGES/; revision=3911 --- addressbook/gui/.cvsignore | 6 - addressbook/gui/Makefile.am | 1 - addressbook/gui/component/.cvsignore | 10 - .../component/GNOME_Evolution_Addressbook.oaf.in | 56 - .../component/GNOME_Evolution_Addressbook.oafinfo | 56 - addressbook/gui/component/Makefile.am | 89 - addressbook/gui/component/addressbook-component.c | 132 -- addressbook/gui/component/addressbook-component.h | 29 - addressbook/gui/component/addressbook-factory.c | 82 - addressbook/gui/component/addressbook.c | 1143 ---------- addressbook/gui/component/addressbook.gnorba | 23 - addressbook/gui/component/addressbook.h | 9 - addressbook/gui/component/addressbook.oafinfo | 56 - addressbook/gui/component/alphabet.glade | 357 --- addressbook/gui/component/alphabet.glade.h | 34 - addressbook/gui/component/e-addressbook-model.c | 396 ---- addressbook/gui/component/e-addressbook-model.h | 52 - addressbook/gui/component/e-cardlist-model.c | 226 -- addressbook/gui/component/e-cardlist-model.h | 42 - addressbook/gui/component/e-ldap-server-dialog.c | 143 -- addressbook/gui/component/e-ldap-server-dialog.h | 9 - addressbook/gui/component/e-ldap-storage.c | 230 -- addressbook/gui/component/e-ldap-storage.h | 42 - addressbook/gui/component/ldap-server-dialog.glade | 400 ---- .../gui/component/ldap-server-dialog.glade.h | 11 - addressbook/gui/component/select-names/.cvsignore | 7 - addressbook/gui/component/select-names/Makefile.am | 46 - .../select-names/e-select-names-manager.c | 222 -- .../select-names/e-select-names-manager.h | 52 - .../component/select-names/e-select-names-model.c | 200 -- .../component/select-names/e-select-names-model.h | 67 - .../select-names/e-select-names-table-model.c | 157 -- .../select-names/e-select-names-table-model.h | 42 - .../select-names/e-select-names-text-model.c | 265 --- .../select-names/e-select-names-text-model.h | 44 - .../gui/component/select-names/e-select-names.c | 344 --- .../gui/component/select-names/e-select-names.h | 86 - .../gui/component/select-names/recipient.glade | 61 - .../gui/component/select-names/select-names.glade | 245 -- .../component/select-names/select-names.glade.h | 10 - addressbook/gui/contact-editor/.cvsignore | 8 - addressbook/gui/contact-editor/Makefile.am | 56 - addressbook/gui/contact-editor/arrow.png | Bin 174 -> 0 bytes addressbook/gui/contact-editor/briefcase.png | Bin 390 -> 0 bytes .../gui/contact-editor/categories-strings.h | 9 - addressbook/gui/contact-editor/categories.glade | 190 -- .../gui/contact-editor/contact-editor.glade | 2331 -------------------- .../contact-editor/e-contact-editor-categories.c | 467 ---- .../contact-editor/e-contact-editor-categories.h | 83 - .../gui/contact-editor/e-contact-editor-fullname.c | 214 -- .../gui/contact-editor/e-contact-editor-fullname.h | 75 - .../gui/contact-editor/e-contact-editor-strings.h | 41 - addressbook/gui/contact-editor/e-contact-editor.c | 1702 -------------- addressbook/gui/contact-editor/e-contact-editor.h | 110 - addressbook/gui/contact-editor/e-contact-save-as.c | 77 - addressbook/gui/contact-editor/e-contact-save-as.h | 42 - addressbook/gui/contact-editor/email.png | Bin 331 -> 0 bytes addressbook/gui/contact-editor/fullname-strings.h | 25 - addressbook/gui/contact-editor/fullname.glade | 391 ---- 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 | 142 -- addressbook/gui/contact-editor/web.png | Bin 573 -> 0 bytes addressbook/gui/minicard/.cvsignore | 11 - addressbook/gui/minicard/Makefile.am | 94 - addressbook/gui/minicard/e-minicard-label.c | 446 ---- addressbook/gui/minicard/e-minicard-label.h | 83 - addressbook/gui/minicard/e-minicard-view.c | 426 ---- addressbook/gui/minicard/e-minicard-view.h | 95 - addressbook/gui/minicard/e-minicard.c | 728 ------ addressbook/gui/minicard/e-minicard.h | 98 - addressbook/gui/minicard/e-reflow-sorted.c | 272 --- addressbook/gui/minicard/e-reflow-sorted.h | 90 - addressbook/gui/minicard/e-reflow.c | 848 ------- addressbook/gui/minicard/e-reflow.h | 112 - addressbook/gui/minicard/test-minicard-label.c | 126 -- addressbook/gui/minicard/test-minicard-view.c | 206 -- addressbook/gui/minicard/test-minicard.c | 115 - addressbook/gui/minicard/test-reflow.c | 191 -- addressbook/gui/widgets/Makefile.am | 94 - addressbook/gui/widgets/alphabet.glade | 357 --- addressbook/gui/widgets/alphabet.glade.h | 34 - addressbook/gui/widgets/e-addressbook-model.c | 396 ---- addressbook/gui/widgets/e-addressbook-model.h | 52 - addressbook/gui/widgets/e-minicard-label.c | 446 ---- addressbook/gui/widgets/e-minicard-label.h | 83 - addressbook/gui/widgets/e-minicard-view.c | 426 ---- addressbook/gui/widgets/e-minicard-view.h | 95 - addressbook/gui/widgets/e-minicard.c | 728 ------ addressbook/gui/widgets/e-minicard.h | 98 - addressbook/gui/widgets/test-minicard-label.c | 126 -- addressbook/gui/widgets/test-minicard-view.c | 206 -- addressbook/gui/widgets/test-minicard.c | 115 - addressbook/gui/widgets/test-reflow.c | 191 -- 97 files changed, 18833 deletions(-) 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/GNOME_Evolution_Addressbook.oaf.in delete mode 100644 addressbook/gui/component/GNOME_Evolution_Addressbook.oafinfo delete mode 100644 addressbook/gui/component/Makefile.am delete mode 100644 addressbook/gui/component/addressbook-component.c delete mode 100644 addressbook/gui/component/addressbook-component.h delete mode 100644 addressbook/gui/component/addressbook-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/component/addressbook.oafinfo delete mode 100644 addressbook/gui/component/alphabet.glade delete mode 100644 addressbook/gui/component/alphabet.glade.h delete mode 100644 addressbook/gui/component/e-addressbook-model.c delete mode 100644 addressbook/gui/component/e-addressbook-model.h delete mode 100644 addressbook/gui/component/e-cardlist-model.c delete mode 100644 addressbook/gui/component/e-cardlist-model.h delete mode 100644 addressbook/gui/component/e-ldap-server-dialog.c delete mode 100644 addressbook/gui/component/e-ldap-server-dialog.h delete mode 100644 addressbook/gui/component/e-ldap-storage.c delete mode 100644 addressbook/gui/component/e-ldap-storage.h delete mode 100644 addressbook/gui/component/ldap-server-dialog.glade delete mode 100644 addressbook/gui/component/ldap-server-dialog.glade.h delete mode 100644 addressbook/gui/component/select-names/.cvsignore delete mode 100644 addressbook/gui/component/select-names/Makefile.am delete mode 100644 addressbook/gui/component/select-names/e-select-names-manager.c delete mode 100644 addressbook/gui/component/select-names/e-select-names-manager.h delete mode 100644 addressbook/gui/component/select-names/e-select-names-model.c delete mode 100644 addressbook/gui/component/select-names/e-select-names-model.h delete mode 100644 addressbook/gui/component/select-names/e-select-names-table-model.c delete mode 100644 addressbook/gui/component/select-names/e-select-names-table-model.h delete mode 100644 addressbook/gui/component/select-names/e-select-names-text-model.c delete mode 100644 addressbook/gui/component/select-names/e-select-names-text-model.h delete mode 100644 addressbook/gui/component/select-names/e-select-names.c delete mode 100644 addressbook/gui/component/select-names/e-select-names.h delete mode 100644 addressbook/gui/component/select-names/recipient.glade delete mode 100644 addressbook/gui/component/select-names/select-names.glade delete mode 100644 addressbook/gui/component/select-names/select-names.glade.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/categories-strings.h delete mode 100644 addressbook/gui/contact-editor/categories.glade delete mode 100644 addressbook/gui/contact-editor/contact-editor.glade delete mode 100644 addressbook/gui/contact-editor/e-contact-editor-categories.c delete mode 100644 addressbook/gui/contact-editor/e-contact-editor-categories.h delete mode 100644 addressbook/gui/contact-editor/e-contact-editor-fullname.c delete mode 100644 addressbook/gui/contact-editor/e-contact-editor-fullname.h 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/e-contact-save-as.c delete mode 100644 addressbook/gui/contact-editor/e-contact-save-as.h delete mode 100644 addressbook/gui/contact-editor/email.png delete mode 100644 addressbook/gui/contact-editor/fullname-strings.h delete mode 100644 addressbook/gui/contact-editor/fullname.glade 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/alphabet.glade delete mode 100644 addressbook/gui/widgets/alphabet.glade.h delete mode 100644 addressbook/gui/widgets/e-addressbook-model.c delete mode 100644 addressbook/gui/widgets/e-addressbook-model.h 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 (limited to 'addressbook/gui') 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 a8ecb5d170..0000000000 --- a/addressbook/gui/component/.cvsignore +++ /dev/null @@ -1,10 +0,0 @@ -.deps -.libs -.pure -Makefile -Makefile.in -*.lo -*.la -evolution-addressbook -evolution-addressbook.pure -test-addressbook diff --git a/addressbook/gui/component/GNOME_Evolution_Addressbook.oaf.in b/addressbook/gui/component/GNOME_Evolution_Addressbook.oaf.in deleted file mode 100644 index 15820b2e03..0000000000 --- a/addressbook/gui/component/GNOME_Evolution_Addressbook.oaf.in +++ /dev/null @@ -1,56 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/addressbook/gui/component/GNOME_Evolution_Addressbook.oafinfo b/addressbook/gui/component/GNOME_Evolution_Addressbook.oafinfo deleted file mode 100644 index 15820b2e03..0000000000 --- a/addressbook/gui/component/GNOME_Evolution_Addressbook.oafinfo +++ /dev/null @@ -1,56 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/addressbook/gui/component/Makefile.am b/addressbook/gui/component/Makefile.am deleted file mode 100644 index 389f51f9ba..0000000000 --- a/addressbook/gui/component/Makefile.am +++ /dev/null @@ -1,89 +0,0 @@ -SUBDIRS = select-names - -CPPFLAGS = \ - -DEVOLUTION_GLADEDIR=\""$(gladedir)"\" - -INCLUDES = \ - -DG_LOG_DOMAIN=\"evolution-addressbook\" \ - $(EXTRA_GNOME_CFLAGS) \ - $(GNOME_INCLUDEDIR) \ - -I$(top_srcdir) \ - -I$(top_builddir) \ - -I$(top_srcdir)/shell \ - -I$(top_builddir)/shell \ - -I$(top_srcdir)/widgets/e-text \ - -I$(top_srcdir)/widgets/e-table \ - -I$(top_srcdir)/addressbook/gui/minicard \ - -I$(top_srcdir)/addressbook/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-component.c \ - addressbook-component.h \ - addressbook-factory.c \ - addressbook.c \ - addressbook.h \ - e-addressbook-model.c \ - e-addressbook-model.h \ - e-cardlist-model.c \ - e-cardlist-model.h \ - e-ldap-server-dialog.c \ - e-ldap-server-dialog.h \ - e-ldap-storage.c \ - e-ldap-storage.h - -evolution_addressbook_LDADD = \ - select-names/libeselectnames.la \ - $(top_builddir)/shell/libeshell.a \ - $(EXTRA_GNOME_LIBS) \ - $(BONOBO_HTML_GNOME_LIBS) \ - $(top_builddir)/addressbook/gui/minicard/libeminicard.a \ - $(top_builddir)/addressbook/backend/ebook/libebook.la \ - $(top_builddir)/addressbook/ename/libename.la \ - $(top_builddir)/addressbook/contact-editor/libecontacteditor.a \ - $(top_builddir)/libversit/libversit.la \ - $(top_builddir)/widgets/e-text/libetext.a \ - $(top_builddir)/widgets/e-table/libetable.a \ - $(top_builddir)/widgets/misc/libemiscwidgets.a \ - $(top_builddir)/e-util/libeutil.la \ - $(top_builddir)/addressbook/printing/libecontactprint.a - -evolution_addressbook_LDFLAGS = `gnome-config --libs gdk_pixbuf` - -if USING_OAF -oafdir = $(datadir)/oaf -oaf_DATA = addressbook.oafinfo -else -gnorbadir = $(sysconfdir)/CORBA/servers -gnorba_DATA = addressbook.gnorba -endif - -gladedir = $(datadir)/evolution/glade -glade_DATA = ldap-server-dialog.glade ldap-server-dialog.glade.h alphabet.glade - -EXTRA_DIST = \ - $(glade_DATA) \ - addressbook.gnorba \ - addressbook.oafinfo \ - alphabet.glade.h - -if ENABLE_PURIFY -PLINK = $(LIBTOOL) --mode=link $(PURIFY) $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ - -all-local: evolution-addressbook.pure - -evolution-addressbook.pure: evolution-addressbook - @rm -f evolution-addressbook.pure - $(PLINK) $(evolution_addressbook_LDFLAGS) $(evolution_addressbook_OBJECTS) $(evolution_addressbook_LDADD) $(LIBS) - -endif diff --git a/addressbook/gui/component/addressbook-component.c b/addressbook/gui/component/addressbook-component.c deleted file mode 100644 index b6b682d18d..0000000000 --- a/addressbook/gui/component/addressbook-component.c +++ /dev/null @@ -1,132 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* addressbook-component.c - * - * Copyright (C) 2000 Helix Code, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Author: Ettore Perazzoli - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include - -#include "evolution-shell-component.h" -#include "evolution-storage.h" - -#include "addressbook-component.h" -#include "addressbook.h" -#include "e-ldap-storage.h" - - -#ifdef USING_OAF -#define COMPONENT_FACTORY_ID "OAFIID:evolution-shell-component-factory:addressbook:dbf3bba0-4b0a-4f07-899b-1ec56fdf38a0" -#else -#define COMPONENT_FACTORY_ID "evolution-shell-component-factory:addressbook" -#endif - -static BonoboGenericFactory *factory = NULL; - -static const EvolutionShellComponentFolderType folder_types[] = { - { "contacts", "evolution-contacts.png" }, - { NULL, NULL } -}; - -#ifdef HAVE_LDAP -extern void setup_ldap_storage (EvolutionShellComponent *shell_component); -#endif - - -/* EvolutionShellComponent methods and signals. */ - -static EvolutionShellComponentResult -create_view (EvolutionShellComponent *shell_component, - const char *physical_uri, - const char *type, - BonoboControl **control_return, - void *closure) -{ - BonoboControl *control; - - if (g_strcasecmp (type, "contacts") != 0) - return EVOLUTION_SHELL_COMPONENT_UNSUPPORTEDTYPE; - - control = addressbook_factory_new_control (); - bonobo_control_set_property (control, "folder_uri", physical_uri, NULL); - - *control_return = control; - - return EVOLUTION_SHELL_COMPONENT_OK; -} - -static int owner_count = 0; - -static void -owner_set_cb (EvolutionShellComponent *shell_component, - EvolutionShellClient *shell_client, - gpointer user_data) -{ - owner_count ++; - - setup_ldap_storage (shell_component); -} - -static void -owner_unset_cb (EvolutionShellComponent *shell_component, - Evolution_Shell shell_interface, - gpointer user_data) -{ - owner_count --; - if (owner_count == 0) - gtk_main_quit(); -} - - -/* The factory function. */ - -static BonoboObject * -factory_fn (BonoboGenericFactory *factory, - void *closure) -{ - EvolutionShellComponent *shell_component; - - shell_component = evolution_shell_component_new (folder_types, create_view, NULL, NULL, NULL); - - gtk_signal_connect (GTK_OBJECT (shell_component), "owner_set", - GTK_SIGNAL_FUNC (owner_set_cb), NULL); - - gtk_signal_connect (GTK_OBJECT (shell_component), "owner_unset", - GTK_SIGNAL_FUNC (owner_unset_cb), NULL); - - return BONOBO_OBJECT (shell_component); -} - - -void -addressbook_component_factory_init (void) -{ - if (factory != NULL) - return; - - factory = bonobo_generic_factory_new (COMPONENT_FACTORY_ID, factory_fn, NULL); - - if (factory == NULL) - g_error ("Cannot initialize the Evolution addressbook factory."); -} - diff --git a/addressbook/gui/component/addressbook-component.h b/addressbook/gui/component/addressbook-component.h deleted file mode 100644 index ec37da694a..0000000000 --- a/addressbook/gui/component/addressbook-component.h +++ /dev/null @@ -1,29 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* addressbook-component.h - * - * Copyright (C) 2000 Helix Code, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Author: Ettore Perazzoli - */ - -#ifndef _ADDRESSBOOK_COMPONENT_H -#define _ADDRESSBOOK_COMPONENT_H - -void addressbook_component_factory_init (void); - -#endif /* _ADDRESSBOOK_COMPONENT_H */ diff --git a/addressbook/gui/component/addressbook-factory.c b/addressbook/gui/component/addressbook-factory.c deleted file mode 100644 index f16c321b68..0000000000 --- a/addressbook/gui/component/addressbook-factory.c +++ /dev/null @@ -1,82 +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" -#include "addressbook-component.h" - -#ifdef USING_OAF - -#include - -static void -init_corba (int *argc, char **argv) -{ - gnome_init_with_popt_table ("evolution-addressbook", "0.0", - *argc, argv, oaf_popt_options, 0, NULL); - - oaf_init (*argc, argv); -} - -#else - -#include - -static void -init_corba (int *argc, char **argv) -{ - CORBA_Environment ev; - - CORBA_exception_init (&ev); - - gnome_CORBA_init_with_popt_table ( - "evolution-addressbook", "0.0", - argc, argv, NULL, 0, NULL, GNORBA_INIT_SERVER_FUNC, &ev); - - CORBA_exception_free (&ev); -} - -#endif - -static void -init_bonobo (int argc, char **argv) -{ - if (bonobo_init (CORBA_OBJECT_NIL, CORBA_OBJECT_NIL, CORBA_OBJECT_NIL) == FALSE) - g_error (_("Could not initialize Bonobo")); - - glade_gnome_init (); -} - -int -main (int argc, char **argv) -{ - init_corba (&argc, argv); - - init_bonobo (argc, argv); - - /* FIXME: Messy names here. This file should be `main.c'. `addressbook.c' should - be `addressbook-control-factory.c' and the functions should be called - `addressbook_control_factory_something()'. And `addressbook-component.c' - should be `addressbook-component-factory.c'. */ - - addressbook_factory_init (); - addressbook_component_factory_init (); - - e_cursors_init(); - - bonobo_main (); - - return 0; -} diff --git a/addressbook/gui/component/addressbook.c b/addressbook/gui/component/addressbook.c deleted file mode 100644 index f248e1e4bd..0000000000 --- a/addressbook/gui/component/addressbook.c +++ /dev/null @@ -1,1143 +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 -#include -#include "e-minicard-view.h" - -#include -#include - -#include -#include -#include "e-contact-editor.h" -#include "e-contact-save-as.h" -#include "e-ldap-server-dialog.h" -#include -#include -#include -#include - -#include - -#ifdef USING_OAF -#define CONTROL_FACTORY_ID "OAFIID:control-factory:addressbook:3e10597b-0591-4d45-b082-d781b7aa6e17" -#else -#define CONTROL_FACTORY_ID "control-factory:addressbook" -#endif - -#define PROPERTY_FOLDER_URI "folder_uri" - -#define PROPERTY_FOLDER_URI_IDX 1 - -typedef enum { - ADDRESSBOOK_VIEW_NONE, /* initialized to this */ - ADDRESSBOOK_VIEW_TABLE, - ADDRESSBOOK_VIEW_MINICARD -} AddressbookViewType; - -typedef struct { - AddressbookViewType view_type; - EBook *book; - GtkWidget *vbox; - GtkWidget *minicard_hbox; - GtkWidget *canvas; - GnomeCanvasItem *view; - GnomeCanvasItem *rect; - GtkWidget *table; - ETableModel *model; - ECardSimple *simple; - GtkAllocation last_alloc; - BonoboControl *control; - BonoboPropertyBag *properties; - char *uri; -} AddressbookView; - -static void change_view_type (AddressbookView *view, AddressbookViewType view_type); - -static void -control_deactivate (BonoboControl *control, BonoboUIHandler *uih) -{ - /* how to remove a menu item */ - bonobo_ui_handler_menu_remove (uih, "/File/Print"); - bonobo_ui_handler_menu_remove (uih, "/File/TestSelectNames"); - bonobo_ui_handler_menu_remove (uih, "/View/"); - bonobo_ui_handler_menu_remove (uih, "/View/Toggle View"); - bonobo_ui_handler_menu_remove (uih, "/Actions/New Contact"); -#ifdef HAVE_LDAP - bonobo_ui_handler_menu_remove (uih, "/Actions/New Directory Server"); -#endif - /* remove our toolbar */ - bonobo_ui_handler_dock_remove (uih, "/Toolbar"); -} - -static void -do_nothing_cb (BonoboUIHandler *uih, void *user_data, const char *path) -{ - g_print ("Yow! I am called back!\n"); -} - -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 -card_modified_cb (EBook* book, EBookStatus status, - gpointer user_data) -{ - g_print ("%s: %s(): a card was modified\n", __FILE__, __FUNCTION__); -} - -/* Callback for the add_card signal from the contact editor */ -static void -add_card_cb (EContactEditor *ce, ECard *card, gpointer data) -{ - EBook *book; - - book = E_BOOK (data); - e_book_add_card (book, card, card_added_cb, NULL); -} - -/* Callback for the commit_card signal from the contact editor */ -static void -commit_card_cb (EContactEditor *ce, ECard *card, gpointer data) -{ - EBook *book; - - book = E_BOOK (data); - e_book_commit_card (book, card, card_modified_cb, NULL); -} - -/* Callback used when the contact editor is closed */ -static void -editor_closed_cb (EContactEditor *ce, gpointer data) -{ - gtk_object_unref (GTK_OBJECT (ce)); -} - -static void -new_contact_cb (BonoboUIHandler *uih, void *user_data, const char *path) -{ - ECard *card; - EBook *book; - EContactEditor *ce; - AddressbookView *view = (AddressbookView *) user_data; - GtkObject *object; - - card = e_card_new(""); - - if (view->view) - object = GTK_OBJECT(view->view); - else - object = GTK_OBJECT(view->model); - - gtk_object_get(object, "book", &book, NULL); - g_assert (E_IS_BOOK (book)); - - ce = e_contact_editor_new (card, TRUE); - - gtk_signal_connect (GTK_OBJECT (ce), "add_card", - GTK_SIGNAL_FUNC (add_card_cb), book); - gtk_signal_connect (GTK_OBJECT (ce), "commit_card", - GTK_SIGNAL_FUNC (commit_card_cb), book); - gtk_signal_connect (GTK_OBJECT (ce), "editor_closed", - GTK_SIGNAL_FUNC (editor_closed_cb), NULL); - - gtk_object_sink(GTK_OBJECT(card)); -} - -static void -toggle_view_as_cb (BonoboUIHandler *uih, void *user_data, const char *path) -{ - AddressbookView *view = user_data; - - if (view->view_type == ADDRESSBOOK_VIEW_TABLE) - change_view_type (view, ADDRESSBOOK_VIEW_MINICARD); - else - change_view_type (view, ADDRESSBOOK_VIEW_TABLE); -} - -#ifdef HAVE_LDAP -static void -null_cb (EBook *book, EBookStatus status, gpointer closure) -{ -} - -static void -new_server_cb (BonoboUIHandler *uih, void *user_data, const char *path) -{ - ELDAPServer *server = g_new (ELDAPServer, 1); - EBook *book; - AddressbookView *view = (AddressbookView *) user_data; - GtkObject *object; - - /* fill in the defaults */ - server->name = g_strdup(""); - server->host = g_strdup(""); - server->port = 389; - server->description = g_strdup(""); - server->rootdn = g_strdup(""); - server->uri = g_strdup_printf ("ldap://%s:%d/%s", server->host, server->port, server->rootdn); - e_ldap_server_editor_show (server); - - if (view->view) - object = GTK_OBJECT(view->view); - else - object = GTK_OBJECT(view->model); - gtk_object_get(object, "book", &book, NULL); - g_assert (E_IS_BOOK (book)); - - /* write out the new server info */ - e_ldap_storage_add_server (server); - - /* now update the view */ - e_book_unload_uri (book); - if (! e_book_load_uri (book, server->uri, null_cb, NULL)) { - g_warning ("error calling load_uri!\n"); - } -} -#endif - -static char * -get_query (AddressbookView *view) -{ - GtkObject *object; - char *query = NULL; - - if (view->view) - object = GTK_OBJECT(view->view); - else - object = GTK_OBJECT(view->model); - - if (object) - gtk_object_get (object, "query", &query, NULL); - - return query; -} - -static void -set_query (AddressbookView *view, char *query) -{ - GtkObject *object; - - if (view->view) - object = GTK_OBJECT(view->view); - else - object = GTK_OBJECT(view->model); - - gtk_object_set (object, - "query", query, - NULL); -} - -static void -set_book(AddressbookView *view) -{ - if (view->book) - gtk_object_set(view->view ? GTK_OBJECT(view->view) : GTK_OBJECT(view->model), - "book", view->book, - NULL); -} - -static void -find_contact_cb (BonoboUIHandler *uih, void *user_data, const char *path) -{ - gint result; - GtkWidget* search_entry = gtk_entry_new(); - gchar* search_text; - AddressbookView *view = (AddressbookView *) user_data; - - GtkWidget* dlg = gnome_dialog_new ("Search Contacts", "Find", - GNOME_STOCK_BUTTON_CANCEL, NULL); - - search_text = get_query (view); - 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)); - set_query (view, search_text); - } - -} - -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) -{ - AddressbookView *view = (AddressbookView *) user_data; - if (view->view) - e_minicard_view_remove_selection (E_MINICARD_VIEW(view->view), card_deleted_cb, NULL); -} - -static void -e_contact_print_destroy(GnomeDialog *dialog, gpointer data) -{ - ETable *table = gtk_object_get_data(GTK_OBJECT(dialog), "table"); - EPrintable *printable = gtk_object_get_data(GTK_OBJECT(dialog), "printable"); - gtk_object_unref(GTK_OBJECT(printable)); - gtk_object_unref(GTK_OBJECT(table)); -} - -static void -e_contact_print_button(GnomeDialog *dialog, gint button, gpointer data) -{ - GnomePrintMaster *master; - GnomePrintContext *pc; - EPrintable *printable = gtk_object_get_data(GTK_OBJECT(dialog), "printable"); - GtkWidget *preview; - 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_printable_reset(printable); - while (e_printable_data_left(printable)) { - if (gnome_print_gsave(pc) == -1) - /* FIXME */; - if (gnome_print_translate(pc, .5 * 72, .5 * 72) == -1) - /* FIXME */; - e_printable_print_page(printable, - pc, - 7.5 * 72, - 10.5 * 72, - TRUE); - if (gnome_print_grestore(pc) == -1) - /* FIXME */; - if (gnome_print_showpage(pc) == -1) - /* FIXME */; - } - gnome_print_master_close(master); - gnome_print_master_print(master); - 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_printable_reset(printable); - while (e_printable_data_left(printable)) { - if (gnome_print_gsave(pc) == -1) - /* FIXME */; - if (gnome_print_translate(pc, .5 * 72, .5 * 72) == -1) - /* FIXME */; - e_printable_print_page(printable, - pc, - 7.5 * 72, - 10.5 * 72, - TRUE); - if (gnome_print_grestore(pc) == -1) - /* FIXME */; - if (gnome_print_showpage(pc) == -1) - /* FIXME */; - } - gnome_print_master_close(master); - preview = GTK_WIDGET(gnome_print_master_preview_new(master, "Print Preview")); - gtk_widget_show_all(preview); - gtk_object_unref(GTK_OBJECT(master)); - break; - case GNOME_PRINT_CANCEL: - gnome_dialog_close(dialog); - break; - } -} - -static void -print_cb (BonoboUIHandler *uih, void *user_data, const char *path) -{ - AddressbookView *view = (AddressbookView *) user_data; - if (view->view) { - char *query = get_query(view); - GtkWidget *print = e_contact_print_dialog_new(view->book, query); - g_free(query); - gtk_widget_show_all(print); - } else { - GtkWidget *dialog; - EPrintable *printable; - - 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); - - printable = e_table_get_printable(E_TABLE(view->table)); - - gtk_object_ref(GTK_OBJECT(view->table)); - - gtk_object_set_data(GTK_OBJECT(dialog), "table", view->table); - gtk_object_set_data(GTK_OBJECT(dialog), "printable", printable); - - gtk_signal_connect(GTK_OBJECT(dialog), - "clicked", GTK_SIGNAL_FUNC(e_contact_print_button), NULL); - gtk_signal_connect(GTK_OBJECT(dialog), - "destroy", GTK_SIGNAL_FUNC(e_contact_print_destroy), NULL); - gtk_widget_show(dialog); - } -} - -static void -test_select_names_cb (BonoboUIHandler *uih, void *user_data, const char *path) -{ - ESelectNames *names = E_SELECT_NAMES(e_select_names_new()); - - e_select_names_add_section(names, _("To"), "to"); - e_select_names_add_section(names, _("From"), "from"); - e_select_names_add_section(names, _("Cc"), "cc"); - gtk_widget_show(GTK_WIDGET(names)); -} - -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, gpointer user_data) -{ - char* search_word = gtk_entry_get_text(GTK_ENTRY(widget)); - char* search_query; - AddressbookView *view = (AddressbookView *) user_data; - - 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\" \"\")"); - - set_query(view, search_query); - - 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, - AddressbookView *view) -{ - Bonobo_UIHandler remote_uih; - GtkWidget *toolbar, *toolbar_frame; - 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_separator (uih, "/View/", -1); - - bonobo_ui_handler_menu_new_item (uih, "/File/Print", - N_("Print"), - NULL, -1, - BONOBO_UI_HANDLER_PIXMAP_NONE, NULL, - 0, 0, print_cb, - (gpointer) view); - - bonobo_ui_handler_menu_new_item (uih, "/File/TestSelectNames", - N_("Test Select Names"), - NULL, -1, - BONOBO_UI_HANDLER_PIXMAP_NONE, NULL, - 0, 0, test_select_names_cb, - (gpointer) view); - - bonobo_ui_handler_menu_new_item (uih, "/View/Toggle View", - N_("As _Table"), - NULL, -1, - BONOBO_UI_HANDLER_PIXMAP_NONE, NULL, - 0, 0, toggle_view_as_cb, - (gpointer)view); - - 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)view); - -#ifdef HAVE_LDAP - bonobo_ui_handler_menu_new_item (uih, "/Actions/New Directory Server", - N_("N_ew Directory Server"), - NULL, -1, - BONOBO_UI_HANDLER_PIXMAP_NONE, NULL, - 0, 0, new_server_cb, - (gpointer)view); -#endif - - toolbar = gtk_toolbar_new (GTK_ORIENTATION_HORIZONTAL, - GTK_TOOLBAR_BOTH); - - gnome_app_fill_toolbar_with_data (GTK_TOOLBAR (toolbar), - gnome_toolbar, - NULL, 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, view); - - gtk_box_pack_start (GTK_BOX (hbox), - quick_search_widget, - FALSE, TRUE, 0); - - gtk_widget_show_all (hbox); - - toolbar_frame = gtk_frame_new (NULL); - gtk_frame_set_shadow_type (GTK_FRAME (toolbar_frame), GTK_SHADOW_OUT); - gtk_container_add (GTK_CONTAINER (toolbar_frame), hbox); - gtk_widget_show (toolbar_frame); - - gtk_widget_show_all (toolbar_frame); - - toolbar_control = bonobo_control_new (toolbar_frame); - bonobo_ui_handler_dock_add ( - uih, "/Toolbar", - bonobo_object_corba_objref (BONOBO_OBJECT (toolbar_control)), - GNOME_DOCK_ITEM_BEH_EXCLUSIVE, - GNOME_DOCK_TOP, - 1, 1, 0); -} - -static void -control_activate_cb (BonoboControl *control, - gboolean activate, - AddressbookView *view) -{ - BonoboUIHandler *uih; - - uih = bonobo_control_get_ui_handler (control); - g_assert (uih); - - if (activate) - control_activate (control, uih, view); - else - control_deactivate (control, uih); -} - -static void -addressbook_view_free(AddressbookView *view) -{ - if (view->properties) - bonobo_object_unref(BONOBO_OBJECT(view->properties)); - if (view->book) - gtk_object_unref(GTK_OBJECT(view->book)); - g_free(view->uri); - g_free(view); -} - -static void -book_open_cb (EBook *book, EBookStatus status, gpointer closure) -{ - AddressbookView *view = closure; - if (status == E_BOOK_STATUS_SUCCESS) { - set_book (view); - } else { - GtkWidget *warning_dialog, *label, *href; - warning_dialog = gnome_dialog_new ( - _("Unable to open addressbook"), - GNOME_STOCK_BUTTON_CLOSE, - NULL); - - label = gtk_label_new ( - _("We were unable to open this addressbook. This either\n" - "means you have entered an incorrect URI, or have tried\n" - "to access an LDAP server and don't have LDAP support\n" - "compiled in. If you've entered a URI, check the URI for\n" - "correctness and reenter. If not, you probably have\n" - "attempted to access an LDAP server. If you wish to be\n" - "able to use LDAP, you'll need to download and install\n" - "OpenLDAP and recompile and install evolution.\n")); - gtk_misc_set_alignment(GTK_MISC(label), - 0, .5); - gtk_label_set_justify(GTK_LABEL(label), - GTK_JUSTIFY_LEFT); - gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (warning_dialog)->vbox), - label, TRUE, TRUE, 0); - gtk_widget_show (label); - - href = gnome_href_new ("http://www.openldap.org/", "OpenLDAP at http://www.openldap.org/"); - gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (warning_dialog)->vbox), - href, FALSE, FALSE, 0); - gtk_widget_show (href); - - gnome_dialog_run (GNOME_DIALOG (warning_dialog)); - - gtk_object_destroy (GTK_OBJECT (warning_dialog)); - } -} - -static void destroy_callback(GtkWidget *widget, gpointer data) -{ - AddressbookView *view = data; - addressbook_view_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 void -get_prop (BonoboPropertyBag *bag, - BonoboArg *arg, - guint arg_id, - gpointer user_data) -{ - AddressbookView *view = user_data; - - switch (arg_id) { - - case PROPERTY_FOLDER_URI_IDX: - if (view && view->uri) - BONOBO_ARG_SET_STRING (arg, view->uri); - else - BONOBO_ARG_SET_STRING (arg, ""); - break; - - default: - g_warning ("Unhandled arg %d\n", arg_id); - } -} - -static void -set_prop (BonoboPropertyBag *bag, - const BonoboArg *arg, - guint arg_id, - gpointer user_data) -{ - AddressbookView *view = user_data; - - char *uri_data; - - switch (arg_id) { - - case PROPERTY_FOLDER_URI_IDX: - if (view->uri) { - /* we've already had a uri set on this view, so unload it */ - e_book_unload_uri (view->book); - g_free (view->uri); - } - - view->uri = g_strdup(BONOBO_ARG_GET_STRING (arg)); - - if (!strncmp (view->uri, "file:", 5)) { - char *file_name = g_concat_dir_and_file(view->uri + 7, "addressbook.db"); - uri_data = g_strdup_printf("file://%s", file_name); - g_free(file_name); - } - else { - uri_data = g_strdup (view->uri); - } - - if (! e_book_load_uri (view->book, uri_data, book_open_cb, view)) - printf ("error calling load_uri!\n"); - - g_free(uri_data); - - break; - - default: - g_warning ("Unhandled arg %d\n", arg_id); - break; - } -} - -#define SPEC " \ - \ - \ - 0 \ - 1 \ - 2 \ - 3 \ - 4 \ - 5 \ - 6 \ - 7 \ - 8 \ - 10 \ - \ - \ - \ - \ -" - -static void -teardown_minicard_view (AddressbookView *view) -{ - if (view->view) { - gtk_object_destroy(GTK_OBJECT(view->view)); - view->view = NULL; - } - if (view->minicard_hbox) { - gtk_widget_destroy(view->minicard_hbox); - view->minicard_hbox = NULL; - } - - view->canvas = NULL; -} - -typedef struct { - AddressbookView *view; - char letter; -} LetterClosure; - -static void -jump_to_letter(GtkWidget *button, LetterClosure *closure) -{ - if (closure->view->view) - e_minicard_view_jump_to_letter(E_MINICARD_VIEW(closure->view->view), closure->letter); -} - -static void -free_closure(GtkWidget *button, LetterClosure *closure) -{ - g_free(closure); -} - -static void -connect_button (AddressbookView *view, GladeXML *gui, char letter) -{ - char *name; - GtkWidget *button; - LetterClosure *closure; - name = g_strdup_printf("button-%c", letter); - button = glade_xml_get_widget(gui, name); - g_free(name); - if (!button) - return; - closure = g_new(LetterClosure, 1); - closure->view = view; - closure->letter = letter; - gtk_signal_connect(GTK_OBJECT(button), "clicked", - GTK_SIGNAL_FUNC(jump_to_letter), closure); - gtk_signal_connect(GTK_OBJECT(button), "destroy", - GTK_SIGNAL_FUNC(free_closure), closure); -} - -static GtkWidget * -create_alphabet (AddressbookView *view) -{ - GtkWidget *widget; - char letter; - GladeXML *gui = glade_xml_new (EVOLUTION_GLADEDIR "/alphabet.glade", NULL); - - widget = glade_xml_get_widget(gui, "scrolledwindow-top"); - if (!widget) { - return NULL; - } - - connect_button(view, gui, '1'); - for (letter = 'a'; letter <= 'z'; letter ++) { - connect_button(view, gui, letter); - } - - gtk_object_unref(GTK_OBJECT(gui)); - return widget; -} - -static void -create_minicard_view (AddressbookView *view, char *initial_query) -{ - GtkWidget *scrollbar; - GtkWidget *vbox; - GtkWidget *alphabet; - - gtk_widget_push_visual (gdk_rgb_get_visual ()); - gtk_widget_push_colormap (gdk_rgb_get_cmap ()); - - view->minicard_hbox = gtk_hbox_new(FALSE, 0); - - 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); - - gtk_box_pack_start(GTK_BOX(view->minicard_hbox), vbox, TRUE, TRUE, 0); - - alphabet = create_alphabet(view); - if (alphabet) { - gtk_object_ref(GTK_OBJECT(alphabet)); - gtk_widget_unparent(alphabet); - gtk_box_pack_start(GTK_BOX(view->minicard_hbox), alphabet, FALSE, FALSE, 0); - gtk_object_unref(GTK_OBJECT(alphabet)); - } - - gtk_box_pack_start(GTK_BOX(view->vbox), view->minicard_hbox, TRUE, TRUE, 0); - - gtk_widget_show_all( GTK_WIDGET(view->minicard_hbox) ); - - /* Connect the signals */ - gtk_signal_connect( GTK_OBJECT( view->canvas ), "size_allocate", - GTK_SIGNAL_FUNC( allocate_callback ), - ( gpointer ) view ); - -#if 0 - gdk_window_set_back_pixmap( - GTK_LAYOUT(view->canvas)->bin_window, NULL, FALSE); -#endif - - gtk_widget_pop_visual (); - gtk_widget_pop_colormap (); -} - -static void -teardown_table_view (AddressbookView *view) -{ - if (view->table) { - gtk_widget_destroy (GTK_WIDGET (view->table)); - view->table = NULL; - } - if (view->model) { - gtk_object_unref (GTK_OBJECT (view->model)); - view->model = NULL; - } - if (view->simple) { - gtk_object_destroy (GTK_OBJECT (view->simple)); - view->simple = NULL; - } -} - -static void -table_double_click(ETable *table, gint row, AddressbookView *view) -{ - ECard *card = e_addressbook_model_get_card(E_ADDRESSBOOK_MODEL(view->model), row); - EBook *book; - EContactEditor *ce; - - gtk_object_get(GTK_OBJECT(view->model), - "book", &book, - NULL); - - g_assert (E_IS_BOOK (book)); - - ce = e_contact_editor_new (card, FALSE); - - gtk_signal_connect (GTK_OBJECT (ce), "add_card", - GTK_SIGNAL_FUNC (add_card_cb), book); - gtk_signal_connect (GTK_OBJECT (ce), "commit_card", - GTK_SIGNAL_FUNC (commit_card_cb), book); - gtk_signal_connect (GTK_OBJECT (ce), "editor_closed", - GTK_SIGNAL_FUNC (editor_closed_cb), NULL); - - gtk_object_unref(GTK_OBJECT(card)); -} - -static void -save_as (GtkWidget *widget, ECard *card) -{ - e_contact_save_as(_("Save as VCard"), card); -} - -static gint -table_right_click(ETable *table, gint row, gint col, GdkEvent *event, AddressbookView *view) -{ - ECard *card = e_addressbook_model_get_card(E_ADDRESSBOOK_MODEL(view->model), row); - EPopupMenu menu[] = { {"Save as VCard", NULL, GTK_SIGNAL_FUNC(save_as), 0}, {NULL, NULL, NULL, 0} }; - - e_popup_menu_run (menu, (GdkEventButton *)event, 0, card); - - return TRUE; -} - -static void -create_table_view (AddressbookView *view, char *initial_query) -{ - ECell *cell_left_just; - ETableHeader *e_table_header; - int i; - - view->simple = e_card_simple_new(NULL); - - view->model = e_addressbook_model_new(); - - /* - 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 (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 < E_CARD_SIMPLE_FIELD_LAST - 1; i++){ - /* Create the column. */ - ETableCol *ecol = e_table_col_new ( - i, e_card_simple_get_name(view->simple, i+1), - 1.0, 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. */ - view->table = e_table_new (e_table_header, E_TABLE_MODEL(view->model), SPEC); - - gtk_signal_connect(GTK_OBJECT(view->table), "double_click", - GTK_SIGNAL_FUNC(table_double_click), view); - gtk_signal_connect(GTK_OBJECT(view->table), "right_click", - GTK_SIGNAL_FUNC(table_right_click), view); - - gtk_object_set (GTK_OBJECT(view->table), - "click_to_add_message", _("* Click here to add a contact *"), - NULL); - - gtk_box_pack_start(GTK_BOX(view->vbox), view->table, TRUE, TRUE, 0); - - gtk_widget_show_all( GTK_WIDGET(view->table) ); -} - -static void -change_view_type (AddressbookView *view, AddressbookViewType view_type) -{ - char *query = NULL; - BonoboUIHandler *uih = bonobo_control_get_ui_handler (view->control); - - if (view_type == view->view_type) - return; - - if (view->view_type != ADDRESSBOOK_VIEW_NONE) - query = get_query(view); - else - query = g_strdup("(contains \"full_name\" \"\")"); - - - switch (view_type) { - case ADDRESSBOOK_VIEW_MINICARD: - teardown_table_view (view); - create_minicard_view (view, query); - if (uih) - bonobo_ui_handler_menu_set_label (uih, "/View/Toggle View", - N_("As _Table")); - break; - case ADDRESSBOOK_VIEW_TABLE: - teardown_minicard_view (view); - create_table_view (view, query); - if (uih) - bonobo_ui_handler_menu_set_label (uih, "/View/Toggle View", - N_("As _Minicards")); - break; - default: - g_warning ("view_type must be either TABLE or MINICARD\n"); - g_free (query); - return; - } - - view->view_type = view_type; - - /* set the book */ - set_book (view); - - /* and reset the query */ - if (query) - set_query (view, query); - g_free (query); -} - - -BonoboControl * -addressbook_factory_new_control (void) -{ - AddressbookView *view; - - view = g_new0 (AddressbookView, 1); - - view->vbox = gtk_vbox_new(FALSE, 0); - - gtk_signal_connect( GTK_OBJECT( view->vbox ), "destroy", - GTK_SIGNAL_FUNC( destroy_callback ), - ( gpointer ) view ); - - /* Create the control. */ - view->control = bonobo_control_new(view->vbox); - - view->model = NULL; - view->view = NULL; - - /* create the initial view */ - change_view_type (view, ADDRESSBOOK_VIEW_MINICARD); - - gtk_widget_show_all( view->vbox ); - - /* create the view's ebook */ - view->book = e_book_new (); - - view->properties = bonobo_property_bag_new (get_prop, set_prop, view); - - bonobo_property_bag_add ( - view->properties, PROPERTY_FOLDER_URI, PROPERTY_FOLDER_URI_IDX, - BONOBO_ARG_STRING, NULL, _("The URI that the Folder Browser will display"), 0); - - bonobo_control_set_property_bag (view->control, - view->properties); - - view->uri = NULL; - - gtk_signal_connect (GTK_OBJECT (view->control), "activate", - control_activate_cb, view); - - return view->control; -} - -static BonoboObject * -addressbook_factory (BonoboGenericFactory *Factory, void *closure) -{ - return BONOBO_OBJECT (addressbook_factory_new_control ()); -} - -void -addressbook_factory_init (void) -{ - static BonoboGenericFactory *addressbook_control_factory = NULL; - - if (addressbook_control_factory != NULL) - return; - - addressbook_control_factory = bonobo_generic_factory_new (CONTROL_FACTORY_ID, - 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 bc3830686d..0000000000 --- a/addressbook/gui/component/addressbook.gnorba +++ /dev/null @@ -1,23 +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 - -[evolution-shell-component-factory:addressbook] -type=exe -repo_id=IDL:GNOME/GenericFactory:1.0 -description=Factory for the Evolution addressbook component. -location_info=evolution-addressbook - -[evolution-shell-component:addressbook] -type=factory -repo_id=IDL:Evolution/ShellComponent:1.0 -description=Evolution component for handling contacts. -location_info=evolution-shell-component-factory:addressbook diff --git a/addressbook/gui/component/addressbook.h b/addressbook/gui/component/addressbook.h deleted file mode 100644 index 66c5a7e4e6..0000000000 --- a/addressbook/gui/component/addressbook.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef __ADDRESSBOOK_H__ -#define __ADDRESSBOOK_H__ - -#include - -BonoboControl *addressbook_factory_new_control (void); -void addressbook_factory_init (void); - -#endif /* __ADDRESSBOOK_H__ */ diff --git a/addressbook/gui/component/addressbook.oafinfo b/addressbook/gui/component/addressbook.oafinfo deleted file mode 100644 index 15820b2e03..0000000000 --- a/addressbook/gui/component/addressbook.oafinfo +++ /dev/null @@ -1,56 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/addressbook/gui/component/alphabet.glade b/addressbook/gui/component/alphabet.glade deleted file mode 100644 index bc6e5f3798..0000000000 --- a/addressbook/gui/component/alphabet.glade +++ /dev/null @@ -1,357 +0,0 @@ - - - - - alphabet - alphabet - - src - pixmaps - C - True - True - True - False - False - False - True - True - alphabet.glade.h - - - - GtkWindow - window2 - False - window2 - GTK_WINDOW_TOPLEVEL - GTK_WIN_POS_NONE - False - False - True - False - - - GtkScrolledWindow - scrolledwindow-top - GTK_POLICY_NEVER - GTK_POLICY_AUTOMATIC - GTK_UPDATE_CONTINUOUS - GTK_UPDATE_CONTINUOUS - - - GtkViewport - viewport1 - 4 - GTK_SHADOW_NONE - - - GtkVBox - vbox2 - 27 - False - 4 - - - GtkButton - button-1 - - - 0 - False - False - - - - - GtkButton - button-a - - - 0 - False - False - - - - - GtkButton - button-b - - - 0 - False - False - - - - - GtkButton - button-c - - - 0 - False - False - - - - - GtkButton - button-d - - - 0 - False - False - - - - - GtkButton - button-e - - - 0 - False - False - - - - - GtkButton - button-f - - - 0 - False - False - - - - - GtkButton - button-g - - - 0 - False - False - - - - - GtkButton - button-h - - - 0 - False - False - - - - - GtkButton - button-i - - - 0 - False - False - - - - - GtkButton - button-j - - - 0 - False - False - - - - - GtkButton - button-k - - - 0 - False - False - - - - - GtkButton - button-l - - - 0 - False - False - - - - - GtkButton - button-m - - - 0 - False - False - - - - - GtkButton - button-n - - - 0 - False - False - - - - - GtkButton - button-o - - - 0 - False - False - - - - - GtkButton - button-p - - - 0 - False - False - - - - - GtkButton - button-q - - - 0 - False - False - - - - - GtkButton - button-r - - - 0 - False - False - - - - - GtkButton - button-s - - - 0 - False - False - - - - - GtkButton - button-t - - - 0 - False - False - - - - - GtkButton - button-u - - - 0 - False - False - - - - - GtkButton - button-v - - - 0 - False - False - - - - - GtkButton - button-w - True - - - 0 - False - False - - - - - GtkButton - button-x - - - 0 - False - False - - - - - GtkButton - button-y - - - 0 - False - False - - - - - GtkButton - button-z - - - 0 - False - False - - - - - - - - diff --git a/addressbook/gui/component/alphabet.glade.h b/addressbook/gui/component/alphabet.glade.h deleted file mode 100644 index 2448eeb4fc..0000000000 --- a/addressbook/gui/component/alphabet.glade.h +++ /dev/null @@ -1,34 +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_("window2"); -gchar *s = N_("123"); -gchar *s = N_("a"); -gchar *s = N_("b"); -gchar *s = N_("c"); -gchar *s = N_("d"); -gchar *s = N_("e"); -gchar *s = N_("f"); -gchar *s = N_("g"); -gchar *s = N_("h"); -gchar *s = N_("i"); -gchar *s = N_("j"); -gchar *s = N_("k"); -gchar *s = N_("l"); -gchar *s = N_("m"); -gchar *s = N_("n"); -gchar *s = N_("o"); -gchar *s = N_("p"); -gchar *s = N_("q"); -gchar *s = N_("r"); -gchar *s = N_("s"); -gchar *s = N_("t"); -gchar *s = N_("u"); -gchar *s = N_("v"); -gchar *s = N_("w"); -gchar *s = N_("x"); -gchar *s = N_("y"); -gchar *s = N_("z"); diff --git a/addressbook/gui/component/e-addressbook-model.c b/addressbook/gui/component/e-addressbook-model.c deleted file mode 100644 index 7deda52c98..0000000000 --- a/addressbook/gui/component/e-addressbook-model.c +++ /dev/null @@ -1,396 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * - * Author: - * Christopher James Lahey - * - * (C) 1999 Helix Code, Inc. - */ - -#include -#include "e-addressbook-model.h" -#include -#include -#include -#include - -#define PARENT_TYPE e_table_model_get_type() -ETableModelClass *parent_class; - -/* - * EAddressbookModel callbacks - * These are the callbacks that define the behavior of our custom model. - */ -static void e_addressbook_model_set_arg (GtkObject *o, GtkArg *arg, guint arg_id); -static void e_addressbook_model_get_arg (GtkObject *object, GtkArg *arg, guint arg_id); - - -enum { - ARG_0, - ARG_BOOK, - ARG_QUERY, -}; - -static void -addressbook_destroy(GtkObject *object) -{ - EAddressbookModel *model = E_ADDRESSBOOK_MODEL(object); - int i; - - if (model->get_view_idle) - g_source_remove(model->get_view_idle); - if (model->book_view && model->create_card_id) - gtk_signal_disconnect(GTK_OBJECT (model->book_view), - model->create_card_id); - if (model->book_view && model->remove_card_id) - gtk_signal_disconnect(GTK_OBJECT (model->book_view), - model->remove_card_id); - if (model->book_view && model->modify_card_id) - gtk_signal_disconnect(GTK_OBJECT (model->book_view), - model->modify_card_id); - 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); -} - -/* This function returns the number of columns in our ETableModel. */ -static int -addressbook_col_count (ETableModel *etc) -{ - return E_CARD_SIMPLE_FIELD_LAST; -} - -/* This function returns the number of rows in our ETableModel. */ -static int -addressbook_row_count (ETableModel *etc) -{ - EAddressbookModel *addressbook = E_ADDRESSBOOK_MODEL(etc); - return addressbook->data_count; -} - -/* This function returns the value at a particular point in our ETableModel. */ -static void * -addressbook_value_at (ETableModel *etc, int col, int row) -{ - EAddressbookModel *addressbook = E_ADDRESSBOOK_MODEL(etc); - const char *value; - if ( col >= E_CARD_SIMPLE_FIELD_LAST - 1|| row >= addressbook->data_count ) - return NULL; - value = e_card_simple_get_const(addressbook->data[row], - col + 1); - return (void *)(value ? value : ""); -} - -/* This function sets the value at a particular point in our ETableModel. */ -static void -addressbook_set_value_at (ETableModel *etc, int col, int row, const void *val) -{ - EAddressbookModel *addressbook = E_ADDRESSBOOK_MODEL(etc); - ECard *card; - if ( col >= E_CARD_SIMPLE_FIELD_LAST - 1|| row >= addressbook->data_count ) - return; - e_card_simple_set(addressbook->data[row], - col + 1, - val); - gtk_object_get(GTK_OBJECT(addressbook->data[row]), - "card", &card, - NULL); - e_book_commit_card(addressbook->book, card, NULL, NULL); - - e_table_model_cell_changed(etc, col, row); -} - -/* This function returns whether a particular cell is editable. */ -static gboolean -addressbook_is_cell_editable (ETableModel *etc, int col, int row) -{ - return TRUE; -} - -static gint -addressbook_append_row (ETableModel *etm) -{ - ECard *card; - EAddressbookModel *model = E_ADDRESSBOOK_MODEL(etm); - model->data = g_realloc(model->data, (model->data_count + 1) * sizeof(ECard *)); - card = e_card_new(""); - model->data[model->data_count++] = e_card_simple_new (card); - gtk_object_unref(GTK_OBJECT(card)); - e_table_model_row_inserted(E_TABLE_MODEL(model), model->data_count - 1); - return model->data_count - 1; -} - -/* This function duplicates the value passed to it. */ -static void * -addressbook_duplicate_value (ETableModel *etc, int col, const void *value) -{ - return g_strdup(value); -} - -/* This function frees the value passed to it. */ -static void -addressbook_free_value (ETableModel *etc, int col, void *value) -{ - g_free(value); -} - -static void * -addressbook_initialize_value (ETableModel *etc, int col) -{ - return g_strdup(""); -} - -static gboolean -addressbook_value_is_empty (ETableModel *etc, int col, const void *value) -{ - return !(value && *(char *)value); -} - -static char * -addressbook_value_to_string (ETableModel *etc, int col, const void *value) -{ - return g_strdup(value); -} - -static void -create_card(EBookView *book_view, - const GList *cards, - EAddressbookModel *model) -{ - model->data = g_realloc(model->data, (model->data_count + g_list_length((GList *)cards)) * sizeof(ECard *)); - for ( ; cards; cards = cards->next) { - model->data[model->data_count++] = e_card_simple_new (E_CARD(cards->data)); - e_table_model_row_inserted(E_TABLE_MODEL(model), model->data_count - 1); - } -} - -static void -remove_card(EBookView *book_view, - const char *id, - EAddressbookModel *model) -{ - int i; - for ( i = 0; i < model->data_count; i++) { - if ( !strcmp(e_card_simple_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_row_deleted(E_TABLE_MODEL(model), i); - } - } -} - -static void -modify_card(EBookView *book_view, - const GList *cards, - EAddressbookModel *model) -{ - for ( ; cards; cards = cards->next) { - int i; - for ( i = 0; i < model->data_count; i++) { - if ( !strcmp(e_card_simple_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_simple_new(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_addressbook_model_class_init (GtkObjectClass *object_class) -{ - ETableModelClass *model_class = (ETableModelClass *) object_class; - - parent_class = gtk_type_class (PARENT_TYPE); - - object_class->destroy = addressbook_destroy; - object_class->set_arg = e_addressbook_model_set_arg; - object_class->get_arg = e_addressbook_model_get_arg; - - gtk_object_add_arg_type ("EAddressbookModel::book", GTK_TYPE_OBJECT, - GTK_ARG_READWRITE, ARG_BOOK); - gtk_object_add_arg_type ("EAddressbookModel::query", GTK_TYPE_STRING, - GTK_ARG_READWRITE, ARG_QUERY); - - model_class->column_count = addressbook_col_count; - model_class->row_count = addressbook_row_count; - model_class->value_at = addressbook_value_at; - model_class->set_value_at = addressbook_set_value_at; - model_class->is_cell_editable = addressbook_is_cell_editable; - model_class->append_row = addressbook_append_row; - model_class->duplicate_value = addressbook_duplicate_value; - model_class->free_value = addressbook_free_value; - model_class->initialize_value = addressbook_initialize_value; - model_class->value_is_empty = addressbook_value_is_empty; - model_class->value_to_string = addressbook_value_to_string; -} - -static void -e_addressbook_model_init (GtkObject *object) -{ - EAddressbookModel *model = E_ADDRESSBOOK_MODEL(object); - model->book = NULL; - model->query = g_strdup("(contains \"full_name\" \"\")"); - model->book_view = NULL; - model->get_view_idle = 0; - model->create_card_id = 0; - model->remove_card_id = 0; - model->modify_card_id = 0; - model->data = NULL; - model->data_count = 0; -} - -static void -book_view_loaded (EBook *book, EBookStatus status, EBookView *book_view, gpointer closure) -{ - EAddressbookModel *model = closure; - int i; - if (model->book_view && model->create_card_id) - gtk_signal_disconnect(GTK_OBJECT (model->book_view), - model->create_card_id); - if (model->book_view && model->remove_card_id) - gtk_signal_disconnect(GTK_OBJECT (model->book_view), - model->remove_card_id); - if (model->book_view && model->modify_card_id) - gtk_signal_disconnect(GTK_OBJECT (model->book_view), - model->modify_card_id); - if (model->book_view) - gtk_object_unref(GTK_OBJECT(model->book_view)); - model->book_view = book_view; - if (model->book_view) - gtk_object_ref(GTK_OBJECT(model->book_view)); - model->create_card_id = gtk_signal_connect(GTK_OBJECT(model->book_view), - "card_added", - GTK_SIGNAL_FUNC(create_card), - model); - model->remove_card_id = gtk_signal_connect(GTK_OBJECT(model->book_view), - "card_removed", - GTK_SIGNAL_FUNC(remove_card), - model); - model->modify_card_id = gtk_signal_connect(GTK_OBJECT(model->book_view), - "card_changed", - GTK_SIGNAL_FUNC(modify_card), - model); - - for ( i = 0; i < model->data_count; i++ ) { - gtk_object_unref(GTK_OBJECT(model->data[i])); - } - g_free(model->data); - model->data = NULL; - model->data_count = 0; - e_table_model_changed(E_TABLE_MODEL(model)); -} - -static gboolean -get_view(EAddressbookModel *model) -{ - if (model->book && model->query) - e_book_get_book_view(model->book, model->query, book_view_loaded, model); - - model->get_view_idle = 0; - return FALSE; -} - -ECard * -e_addressbook_model_get_card(EAddressbookModel *model, - int row) -{ - if (model->data && row < model->data_count) { - ECard *card; - gtk_object_get(GTK_OBJECT(model->data[row]), - "card", &card, - NULL); - gtk_object_ref(GTK_OBJECT(card)); - return card; - } - return NULL; -} - -static void -e_addressbook_model_set_arg (GtkObject *o, GtkArg *arg, guint arg_id) -{ - EAddressbookModel *model; - - model = E_ADDRESSBOOK_MODEL (o); - - switch (arg_id){ - case ARG_BOOK: - if (model->book) - gtk_object_unref(GTK_OBJECT(model->book)); - model->book = E_BOOK(GTK_VALUE_OBJECT (*arg)); - if (model->book) { - gtk_object_ref(GTK_OBJECT(model->book)); - if (model->get_view_idle == 0) - model->get_view_idle = g_idle_add((GSourceFunc)get_view, model); - } - break; - case ARG_QUERY: - if (model->query) - g_free(model->query); - model->query = g_strdup(GTK_VALUE_STRING (*arg)); - if (model->get_view_idle == 0) - model->get_view_idle = g_idle_add((GSourceFunc)get_view, model); - break; - } -} - -static void -e_addressbook_model_get_arg (GtkObject *object, GtkArg *arg, guint arg_id) -{ - EAddressbookModel *e_addressbook_model; - - e_addressbook_model = E_ADDRESSBOOK_MODEL (object); - - switch (arg_id) { - case ARG_BOOK: - GTK_VALUE_OBJECT (*arg) = GTK_OBJECT(e_addressbook_model->book); - break; - case ARG_QUERY: - GTK_VALUE_STRING (*arg) = g_strdup(e_addressbook_model->query); - break; - default: - arg->type = GTK_TYPE_INVALID; - break; - } -} - -GtkType -e_addressbook_model_get_type (void) -{ - static GtkType type = 0; - - if (!type){ - GtkTypeInfo info = { - "EAddressbookModel", - sizeof (EAddressbookModel), - sizeof (EAddressbookModelClass), - (GtkClassInitFunc) e_addressbook_model_class_init, - (GtkObjectInitFunc) e_addressbook_model_init, - NULL, /* reserved 1 */ - NULL, /* reserved 2 */ - (GtkClassInitFunc) NULL - }; - - type = gtk_type_unique (PARENT_TYPE, &info); - } - - return type; -} - -ETableModel * -e_addressbook_model_new (void) -{ - EAddressbookModel *et; - - et = gtk_type_new (e_addressbook_model_get_type ()); - - return E_TABLE_MODEL(et); -} diff --git a/addressbook/gui/component/e-addressbook-model.h b/addressbook/gui/component/e-addressbook-model.h deleted file mode 100644 index bff9a21d00..0000000000 --- a/addressbook/gui/component/e-addressbook-model.h +++ /dev/null @@ -1,52 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -#ifndef _E_ADDRESSBOOK_MODEL_H_ -#define _E_ADDRESSBOOK_MODEL_H_ - -#include "e-table-model.h" -#include -#include -#include - -#define E_ADDRESSBOOK_MODEL_TYPE (e_addressbook_model_get_type ()) -#define E_ADDRESSBOOK_MODEL(o) (GTK_CHECK_CAST ((o), E_ADDRESSBOOK_MODEL_TYPE, EAddressbookModel)) -#define E_ADDRESSBOOK_MODEL_CLASS(k) (GTK_CHECK_CLASS_CAST((k), E_ADDRESSBOOK_MODEL_TYPE, EAddressbookModelClass)) -#define E_IS_ADDRESSBOOK_MODEL(o) (GTK_CHECK_TYPE ((o), E_ADDRESSBOOK_MODEL_TYPE)) -#define E_IS_ADDRESSBOOK_MODEL_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), E_ADDRESSBOOK_MODEL_TYPE)) - -/* Virtual Column list: - 0 Email - 1 Full Name - 2 Street - 3 Phone -*/ - -typedef struct { - ETableModel parent; - - /* item specific fields */ - EBook *book; - char *query; - EBookView *book_view; - - int get_view_idle; - - ECardSimple **data; - int data_count; - - int create_card_id, remove_card_id, modify_card_id; -} EAddressbookModel; - - -typedef struct { - ETableModelClass parent_class; -} EAddressbookModelClass; - - -GtkType e_addressbook_model_get_type (void); -ETableModel *e_addressbook_model_new (void); - -/* Returns object with ref count of 1. */ -ECard *e_addressbook_model_get_card(EAddressbookModel *model, - int row); - -#endif /* _E_ADDRESSBOOK_MODEL_H_ */ diff --git a/addressbook/gui/component/e-cardlist-model.c b/addressbook/gui/component/e-cardlist-model.c deleted file mode 100644 index 23b61d58be..0000000000 --- a/addressbook/gui/component/e-cardlist-model.c +++ /dev/null @@ -1,226 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * - * Author: - * Christopher James Lahey - * - * (C) 1999 Helix Code, Inc. - */ - -#include -#include "e-cardlist-model.h" -#include -#include -#include -#include - -#define PARENT_TYPE e_table_model_get_type() - -static void -e_cardlist_model_destroy(GtkObject *object) -{ - ECardlistModel *model = E_CARDLIST_MODEL(object); - int i; - - for ( i = 0; i < model->data_count; i++ ) { - gtk_object_unref(GTK_OBJECT(model->data[i])); - } - g_free(model->data); -} - -/* This function returns the number of columns in our ETableModel. */ -static int -e_cardlist_model_col_count (ETableModel *etc) -{ - return E_CARD_SIMPLE_FIELD_LAST; -} - -/* This function returns the number of rows in our ETableModel. */ -static int -e_cardlist_model_row_count (ETableModel *etc) -{ - ECardlistModel *e_cardlist_model = E_CARDLIST_MODEL(etc); - return e_cardlist_model->data_count; -} - -/* This function returns the value at a particular point in our ETableModel. */ -static void * -e_cardlist_model_value_at (ETableModel *etc, int col, int row) -{ - ECardlistModel *e_cardlist_model = E_CARDLIST_MODEL(etc); - const char *value; - if ( col >= E_CARD_SIMPLE_FIELD_LAST - 1|| row >= e_cardlist_model->data_count ) - return NULL; - value = e_card_simple_get_const(e_cardlist_model->data[row], - col + 1); - return (void *)(value ? value : ""); -} - -/* This function sets the value at a particular point in our ETableModel. */ -static void -e_cardlist_model_set_value_at (ETableModel *etc, int col, int row, const void *val) -{ - ECardlistModel *e_cardlist_model = E_CARDLIST_MODEL(etc); - ECard *card; - if ( col >= E_CARD_SIMPLE_FIELD_LAST - 1|| row >= e_cardlist_model->data_count ) - return; - e_card_simple_set(e_cardlist_model->data[row], - col + 1, - val); - gtk_object_get(GTK_OBJECT(e_cardlist_model->data[row]), - "card", &card, - NULL); - - e_table_model_cell_changed(etc, col, row); -} - -/* This function returns whether a particular cell is editable. */ -static gboolean -e_cardlist_model_is_cell_editable (ETableModel *etc, int col, int row) -{ - return TRUE; -} - -/* This function duplicates the value passed to it. */ -static void * -e_cardlist_model_duplicate_value (ETableModel *etc, int col, const void *value) -{ - return g_strdup(value); -} - -/* This function frees the value passed to it. */ -static void -e_cardlist_model_free_value (ETableModel *etc, int col, void *value) -{ - g_free(value); -} - -static void * -e_cardlist_model_initialize_value (ETableModel *etc, int col) -{ - return g_strdup(""); -} - -static gboolean -e_cardlist_model_value_is_empty (ETableModel *etc, int col, const void *value) -{ - return !(value && *(char *)value); -} - -static char * -e_cardlist_model_value_to_string (ETableModel *etc, int col, const void *value) -{ - return g_strdup(value); -} - -void -e_cardlist_model_add(ECardlistModel *model, - ECard **cards, - int count) -{ - int i; - model->data = g_realloc(model->data, model->data_count + count * sizeof(ECard *)); - for (i = 0; i < count; i++) { - gboolean found = FALSE; - gchar *id = e_card_get_id(cards[i]); - for ( i = 0; i < model->data_count; i++) { - if ( !strcmp(e_card_simple_get_id(model->data[i]), id) ) { - found = TRUE; - } - } - if (!found) { - gtk_object_ref(GTK_OBJECT(cards[i])); - model->data[model->data_count++] = e_card_simple_new (cards[i]); - e_table_model_row_inserted(E_TABLE_MODEL(model), model->data_count - 1); - } - } -} - -void -e_cardlist_model_remove(ECardlistModel *model, - const char *id) -{ - int i; - for ( i = 0; i < model->data_count; i++) { - if ( !strcmp(e_card_simple_get_id(model->data[i]), id) ) { - gtk_object_unref(GTK_OBJECT(model->data[i])); - memmove(model->data + i, model->data + i + 1, (model->data_count - i - 1) * sizeof (ECard *)); - e_table_model_row_deleted(E_TABLE_MODEL(model), i); - } - } -} - -static void -e_cardlist_model_class_init (GtkObjectClass *object_class) -{ - ETableModelClass *model_class = (ETableModelClass *) object_class; - - object_class->destroy = e_cardlist_model_destroy; - - model_class->column_count = e_cardlist_model_col_count; - model_class->row_count = e_cardlist_model_row_count; - model_class->value_at = e_cardlist_model_value_at; - model_class->set_value_at = e_cardlist_model_set_value_at; - model_class->is_cell_editable = e_cardlist_model_is_cell_editable; - model_class->duplicate_value = e_cardlist_model_duplicate_value; - model_class->free_value = e_cardlist_model_free_value; - model_class->initialize_value = e_cardlist_model_initialize_value; - model_class->value_is_empty = e_cardlist_model_value_is_empty; - model_class->value_to_string = e_cardlist_model_value_to_string; -} - -static void -e_cardlist_model_init (GtkObject *object) -{ - ECardlistModel *model = E_CARDLIST_MODEL(object); - model->data = NULL; - model->data_count = 0; -} - -ECard * -e_cardlist_model_get(ECardlistModel *model, - int row) -{ - if (model->data && row < model->data_count) { - ECard *card; - gtk_object_get(GTK_OBJECT(model->data[row]), - "card", &card, - NULL); - gtk_object_ref(GTK_OBJECT(card)); - return card; - } - return NULL; -} - -GtkType -e_cardlist_model_get_type (void) -{ - static GtkType type = 0; - - if (!type){ - GtkTypeInfo info = { - "ECardlistModel", - sizeof (ECardlistModel), - sizeof (ECardlistModelClass), - (GtkClassInitFunc) e_cardlist_model_class_init, - (GtkObjectInitFunc) e_cardlist_model_init, - NULL, /* reserved 1 */ - NULL, /* reserved 2 */ - (GtkClassInitFunc) NULL - }; - - type = gtk_type_unique (PARENT_TYPE, &info); - } - - return type; -} - -ETableModel * -e_cardlist_model_new (void) -{ - ECardlistModel *et; - - et = gtk_type_new (e_cardlist_model_get_type ()); - - return E_TABLE_MODEL(et); -} diff --git a/addressbook/gui/component/e-cardlist-model.h b/addressbook/gui/component/e-cardlist-model.h deleted file mode 100644 index b7df356342..0000000000 --- a/addressbook/gui/component/e-cardlist-model.h +++ /dev/null @@ -1,42 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -#ifndef _E_CARDLIST_MODEL_H_ -#define _E_CARDLIST_MODEL_H_ - -#include "e-table-model.h" -#include -#include -#include - -#define E_CARDLIST_MODEL_TYPE (e_cardlist_model_get_type ()) -#define E_CARDLIST_MODEL(o) (GTK_CHECK_CAST ((o), E_CARDLIST_MODEL_TYPE, ECardlistModel)) -#define E_CARDLIST_MODEL_CLASS(k) (GTK_CHECK_CLASS_CAST((k), E_CARDLIST_MODEL_TYPE, ECardlistModelClass)) -#define E_IS_CARDLIST_MODEL(o) (GTK_CHECK_TYPE ((o), E_CARDLIST_MODEL_TYPE)) -#define E_IS_CARDLIST_MODEL_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), E_CARDLIST_MODEL_TYPE)) - -typedef struct { - ETableModel parent; - - /* item specific fields */ - ECardSimple **data; - int data_count; -} ECardlistModel; - - -typedef struct { - ETableModelClass parent_class; -} ECardlistModelClass; - - -GtkType e_cardlist_model_get_type (void); -ETableModel *e_cardlist_model_new (void); - -/* Returns object with an extra ref count. */ -ECard *e_cardlist_model_get (ECardlistModel *model, - int row); -void e_cardlist_model_add (ECardlistModel *model, - ECard **card, - int count); -void e_cardlist_model_remove (ECardlistModel *model, - const char *id); - -#endif /* _E_CARDLIST_MODEL_H_ */ diff --git a/addressbook/gui/component/e-ldap-server-dialog.c b/addressbook/gui/component/e-ldap-server-dialog.c deleted file mode 100644 index 2242282f3f..0000000000 --- a/addressbook/gui/component/e-ldap-server-dialog.c +++ /dev/null @@ -1,143 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * e-ldap-server-dialog.c - * Copyright (C) 2000 Helix Code, Inc. - * Author: Chris Toshok - * - * 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-ldap-server-dialog.h" - -typedef struct { - GladeXML *gui; - GtkWidget *dialog; - ELDAPServer *server; -} ELDAPServerDialog; - -static void -fill_in_server_info (ELDAPServerDialog *dialog) -{ - ELDAPServer *ldap_server = dialog->server; - GtkEditable *editable; - int position; - char buf[128]; - - /* the name */ - position = 0; - editable = GTK_EDITABLE(glade_xml_get_widget(dialog->gui, "name-entry")); - gtk_editable_delete_text (editable, 0, -1); - gtk_editable_insert_text (editable, ldap_server->name, strlen (ldap_server->name), &position); - - /* the server description */ - position = 0; - editable = GTK_EDITABLE(glade_xml_get_widget(dialog->gui, "description-entry")); - gtk_editable_delete_text (editable, 0, -1); - gtk_editable_insert_text (editable, ldap_server->description, strlen (ldap_server->description), &position); - - /* the server hostname */ - position = 0; - editable = GTK_EDITABLE(glade_xml_get_widget(dialog->gui, "server-entry")); - gtk_editable_delete_text (editable, 0, -1); - gtk_editable_insert_text (editable, ldap_server->host, strlen (ldap_server->host), &position); - - /* the server port */ - position = 0; - g_snprintf (buf, sizeof(buf), "%d", ldap_server->port); - editable = GTK_EDITABLE(glade_xml_get_widget(dialog->gui, "port-entry")); - gtk_editable_delete_text (editable, 0, -1); - gtk_editable_insert_text (editable, buf, strlen (buf), &position); - - /* the root dn */ - position = 0; - editable = GTK_EDITABLE(glade_xml_get_widget(dialog->gui, "root-dn-entry")); - gtk_editable_delete_text (editable, 0, -1); - gtk_editable_insert_text (editable, ldap_server->rootdn, strlen (ldap_server->rootdn), &position); -} - -static void -extract_server_info (ELDAPServerDialog *dialog) -{ - ELDAPServer *ldap_server = dialog->server; - GtkEditable *editable; - char *description, *server, *port, *rootdn, *name; - - /* the server name */ - editable = GTK_EDITABLE(glade_xml_get_widget(dialog->gui, "name-entry")); - name = gtk_editable_get_chars(editable, 0, -1); - if (name && *name) { - if (ldap_server->name) - g_free(ldap_server->name); - ldap_server->name = name; - } - - /* the server description */ - editable = GTK_EDITABLE(glade_xml_get_widget(dialog->gui, "description-entry")); - description = gtk_editable_get_chars(editable, 0, -1); - if (description && *description) { - if (ldap_server->description) - g_free(ldap_server->description); - ldap_server->description = description; - } - - /* the server hostname */ - editable = GTK_EDITABLE(glade_xml_get_widget(dialog->gui, "server-entry")); - server = gtk_editable_get_chars(editable, 0, -1); - if (server && *server) { - if (ldap_server->host) - g_free(ldap_server->host); - ldap_server->host = server; - } - - /* the server port */ - editable = GTK_EDITABLE(glade_xml_get_widget(dialog->gui, "port-entry")); - port = gtk_editable_get_chars(editable, 0, -1); - if (port && *port) { - ldap_server->port = atoi(port); - } - g_free(port); - - /* the root dn */ - editable = GTK_EDITABLE(glade_xml_get_widget(dialog->gui, "root-dn-entry")); - rootdn = gtk_editable_get_chars(editable, 0, -1); - if (rootdn && *rootdn) { - if (ldap_server->rootdn) - g_free (ldap_server->rootdn); - ldap_server->rootdn = rootdn; - } -} - -void -e_ldap_server_editor_show(ELDAPServer *server) -{ - ELDAPServerDialog *dialog = g_new0 (ELDAPServerDialog, 1); - - dialog->server = server; - dialog->gui = glade_xml_new (EVOLUTION_GLADEDIR "/ldap-server-dialog.glade", NULL); - - dialog->dialog = glade_xml_get_widget(dialog->gui, "ldap-server-dialog"); - - fill_in_server_info (dialog); - - gnome_dialog_run (GNOME_DIALOG(dialog->dialog)); - - extract_server_info (dialog); - - gnome_dialog_close (GNOME_DIALOG(dialog->dialog)); -} diff --git a/addressbook/gui/component/e-ldap-server-dialog.h b/addressbook/gui/component/e-ldap-server-dialog.h deleted file mode 100644 index e5ae169f5c..0000000000 --- a/addressbook/gui/component/e-ldap-server-dialog.h +++ /dev/null @@ -1,9 +0,0 @@ - -#ifndef __E_LDAP_SERVER_DIALOG_H__ -#define __E_LDAP_SERVER_DIALOG_H__ - -#include "e-ldap-storage.h" - -void e_ldap_server_editor_show(ELDAPServer *server); - -#endif /* __E_LDAP_SERVER_DIALOG_H__ */ diff --git a/addressbook/gui/component/e-ldap-storage.c b/addressbook/gui/component/e-ldap-storage.c deleted file mode 100644 index ab3fc21fdb..0000000000 --- a/addressbook/gui/component/e-ldap-storage.c +++ /dev/null @@ -1,230 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-ldap-storage.c - * - * Copyright (C) 2000 Helix Code, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Author: Chris Toshok - */ - -/* The ldap server file goes like this: - - - - - LDAP Server - This is my company address book. - ldap://ldap.somewhere.net/ - - - - FIXME: Do we want to use a namespace for this? - FIXME: Do we want to have an internationalized description? - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include - -#include "evolution-shell-component.h" -#include "evolution-storage.h" - -#include -#include - -#include "e-ldap-storage.h" -#include "e-ldap-server-dialog.h" - -#include "e-util/e-util.h" -#include "e-util/e-xml-utils.h" - -#define LDAPSERVER_XML "ldapservers.xml" - -static gboolean load_ldap_data (EvolutionStorage *storage, const char *file_path); -static gboolean save_ldap_data (const char *file_path); - -GHashTable *servers; -EvolutionStorage *storage; - -void -setup_ldap_storage (EvolutionShellComponent *shell_component) -{ - EvolutionShellClient *shell_client; - Evolution_Shell corba_shell; - char *path; - - shell_client = evolution_shell_component_get_owner (shell_component); - if (shell_client == CORBA_OBJECT_NIL) { - g_warning ("We have no shell!?"); - return; - } - - corba_shell = bonobo_object_corba_objref (BONOBO_OBJECT (shell_client)); - - storage = evolution_storage_new (_("External Directories")); - if (evolution_storage_register_on_shell (storage, corba_shell) != EVOLUTION_STORAGE_OK) { - g_warning ("Cannot register storage"); - return; - } - - /* save the storage for later */ - servers = g_hash_table_new (g_str_hash, g_str_equal); - - gtk_object_set_data (GTK_OBJECT (shell_component), "e-storage", storage); - - path = g_strdup_printf ("%s/evolution/" LDAPSERVER_XML, g_get_home_dir()); - load_ldap_data (storage, path); - g_free (path); -} - -static char * -get_string_value (xmlNode *node, - const char *name) -{ - xmlNode *p; - xmlChar *xml_string; - char *retval; - - p = e_xml_get_child_by_name (node, (xmlChar *) name); - if (p == NULL) - return NULL; - - p = e_xml_get_child_by_name (p, (xmlChar *) "text"); - if (p == NULL) - return NULL; - - xml_string = xmlNodeListGetString (node->doc, p, 1); - retval = g_strdup ((char *) xml_string); - xmlFree (xml_string); - - return retval; -} - -static gboolean -load_ldap_data (EvolutionStorage *storage, - const char *file_path) -{ - xmlDoc *doc; - xmlNode *root; - xmlNode *child; - - doc = xmlParseFile (file_path); - if (doc == NULL) { - return FALSE; - } - - root = xmlDocGetRootElement (doc); - if (root == NULL || strcmp (root->name, "contactservers") != 0) { - xmlFreeDoc (doc); - return FALSE; - } - - for (child = root->childs; child; child = child->next) { - char *path; - ELDAPServer *server; - - if (strcmp (child->name, "contactserver")) { - g_warning ("unknown node '%s' in %s", child->name, file_path); - continue; - } - - server = g_new (ELDAPServer, 1); - - server->name = get_string_value (child, "name"); - server->uri = get_string_value (child, "uri"); - server->description = get_string_value (child, "description"); - - path = g_strdup_printf ("/%s", server->name); - evolution_storage_new_folder (storage, path, "contacts", server->uri, server->description); - - g_hash_table_insert (servers, server->name, server); - - g_free (path); - } - - xmlFreeDoc (doc); - - return TRUE; -} - -static void -ldap_server_foreach(gpointer key, gpointer value, gpointer user_data) -{ - ELDAPServer *server = (ELDAPServer*)value; - xmlNode *root = (xmlNode*)user_data; - xmlNode *server_root = xmlNewDocNode (root, NULL, - (xmlChar *) "contactserver", NULL); - - xmlAddChild (root, server_root); - - xmlNewChild (server_root, NULL, (xmlChar *) "name", - (xmlChar *) server->name); - - xmlNewChild (server_root, NULL, (xmlChar *) "uri", - (xmlChar *) server->uri); - - if (server->description) - xmlNewChild (server_root, NULL, (xmlChar *) "description", - (xmlChar *) server->description); -} - -static gboolean -save_ldap_data (const char *file_path) -{ - xmlDoc *doc; - xmlNode *root; - - doc = xmlNewDoc ((xmlChar *) "1.0"); - root = xmlNewDocNode (doc, NULL, (xmlChar *) "contactservers", NULL); - xmlDocSetRootElement (doc, root); - - g_hash_table_foreach (servers, ldap_server_foreach, root); - - if (xmlSaveFile (file_path, doc) < 0) { - unlink (file_path); - xmlFreeDoc (doc); - return FALSE; - } - - xmlFreeDoc (doc); - return TRUE; -} - -void -e_ldap_storage_add_server (ELDAPServer *server) -{ - char *path; - /* add it to our hashtable */ - g_hash_table_insert (servers, server->name, server); - - /* and then to the ui */ - path = g_strdup_printf ("/%s", server->name); - evolution_storage_new_folder (storage, path, "contacts", server->uri, server->description); - - g_free (path); - - path = g_strdup_printf ("%s/evolution/" LDAPSERVER_XML, g_get_home_dir()); - save_ldap_data (path); - g_free (path); -} - -void -e_ldap_storage_remove_server (char *name) -{ -} diff --git a/addressbook/gui/component/e-ldap-storage.h b/addressbook/gui/component/e-ldap-storage.h deleted file mode 100644 index cf11e9a6fb..0000000000 --- a/addressbook/gui/component/e-ldap-storage.h +++ /dev/null @@ -1,42 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* e-ldap-storage.h - * - * Copyright (C) 2000 Helix Code, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Author: Chris Toshok - */ - -#ifndef __E_LDAP_STORAGE_H__ -#define __E_LDAP_STORAGE_H__ - -#include "evolution-shell-component.h" - -typedef struct { - char *name; - char *description; - char *host; - int port; - char *rootdn; - char *uri; -} ELDAPServer; - -void setup_ldap_storage (EvolutionShellComponent *shell_component); -void e_ldap_storage_add_server (ELDAPServer *server); -void e_ldap_storage_remove_server (char *name); - -#endif /* __E_LDAP_STORAGE_H__ */ diff --git a/addressbook/gui/component/ldap-server-dialog.glade b/addressbook/gui/component/ldap-server-dialog.glade deleted file mode 100644 index a4dad9c2c2..0000000000 --- a/addressbook/gui/component/ldap-server-dialog.glade +++ /dev/null @@ -1,400 +0,0 @@ - - - - - newserver - newserver - - src - pixmaps - C - True - True - False - True - ldap-server-dialog.glade.h - - - - GnomeDialog - ldap-server-dialog - GTK_WINDOW_TOPLEVEL - GTK_WIN_POS_NONE - False - False - False - False - False - False - - - GtkVBox - GnomeDialog:vbox - dialog-vbox1 - False - 8 - - 4 - True - True - - - - GtkHButtonBox - GnomeDialog:action_area - dialog-action_area1 - GTK_BUTTONBOX_END - 8 - 85 - 27 - 7 - 0 - - 0 - False - True - GTK_PACK_END - - - - GtkButton - button1 - True - True - GNOME_STOCK_BUTTON_OK - - - - GtkButton - button3 - True - True - GNOME_STOCK_BUTTON_CANCEL - - - - - GtkVBox - vbox1 - False - 0 - - 0 - True - True - - - - GtkTable - table2 - 5 - 2 - False - 0 - 0 - - 0 - True - True - - - - GtkEntry - description-entry - True - True - True - 0 - - - 1 - 2 - 1 - 2 - 0 - 0 - True - False - False - False - True - False - - - - - GtkEntry - server-entry - True - True - True - 0 - - - 1 - 2 - 2 - 3 - 0 - 0 - True - False - False - False - True - False - - - - - GtkEntry - port-entry - True - True - True - 0 - - - 1 - 2 - 3 - 4 - 0 - 0 - True - False - False - False - True - False - - - - - GtkEntry - root-dn-entry - True - True - True - 0 - - - 1 - 2 - 4 - 5 - 0 - 0 - True - False - False - False - True - False - - - - - GtkAlignment - alignment1 - 0.5 - 0.5 - 1 - 1 - - 0 - 1 - 1 - 2 - 0 - 0 - True - False - False - False - True - True - - - - GtkLabel - label1 - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - - - - - GtkAlignment - alignment2 - 0.5 - 0.5 - 1 - 1 - - 0 - 1 - 2 - 3 - 0 - 0 - False - False - False - False - True - True - - - - GtkLabel - label2 - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - - - - - GtkAlignment - alignment3 - 0.5 - 0.5 - 1 - 1 - - 0 - 1 - 3 - 4 - 0 - 0 - False - False - False - False - True - True - - - - GtkLabel - label3 - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - - - - - GtkAlignment - alignment4 - 0.5 - 0.5 - 1 - 1 - - 0 - 1 - 4 - 5 - 0 - 0 - False - False - False - False - True - True - - - - GtkLabel - label4 - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - - - - - GtkEntry - name-entry - True - True - True - 0 - - - 1 - 2 - 0 - 1 - 0 - 0 - True - False - False - False - True - False - - - - - GtkAlignment - alignment5 - 0 - 0.5 - 1 - 1 - - 0 - 1 - 0 - 1 - 0 - 0 - False - False - False - False - True - True - - - - GtkLabel - label5 - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - - - - - - - - diff --git a/addressbook/gui/component/ldap-server-dialog.glade.h b/addressbook/gui/component/ldap-server-dialog.glade.h deleted file mode 100644 index c99dfa3cb5..0000000000 --- a/addressbook/gui/component/ldap-server-dialog.glade.h +++ /dev/null @@ -1,11 +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_("Description:"); -gchar *s = N_("LDAP Server:"); -gchar *s = N_("Port Number:"); -gchar *s = N_("Root DN:"); -gchar *s = N_("Name:"); diff --git a/addressbook/gui/component/select-names/.cvsignore b/addressbook/gui/component/select-names/.cvsignore deleted file mode 100644 index d6c55c7345..0000000000 --- a/addressbook/gui/component/select-names/.cvsignore +++ /dev/null @@ -1,7 +0,0 @@ -.deps -.libs -.pure -Makefile -Makefile.in -*.lo -*.la diff --git a/addressbook/gui/component/select-names/Makefile.am b/addressbook/gui/component/select-names/Makefile.am deleted file mode 100644 index f028eeeb89..0000000000 --- a/addressbook/gui/component/select-names/Makefile.am +++ /dev/null @@ -1,46 +0,0 @@ -CPPFLAGS = \ - -DEVOLUTION_GLADEDIR=\""$(gladedir)"\" - -INCLUDES = \ - -DG_LOG_DOMAIN=\"evolution-addressbook\" \ - $(EXTRA_GNOME_CFLAGS) \ - $(GNOME_INCLUDEDIR) \ - -I$(top_srcdir) \ - -I$(top_builddir) \ - -I$(top_srcdir)/shell \ - -I$(top_builddir)/shell \ - -I$(top_srcdir)/widgets/e-text \ - -I$(top_srcdir)/widgets/e-table \ - -I$(top_srcdir)/addressbook/gui/minicard \ - -I$(top_srcdir)/addressbook/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)"\" - -lib_LTLIBRARIES = libeselectnames.la - -libeselectnames_la_SOURCES = \ - e-select-names-manager.c \ - e-select-names-manager.h \ - e-select-names-model.c \ - e-select-names-model.h \ - e-select-names-table-model.c \ - e-select-names-table-model.h \ - e-select-names-text-model.c \ - e-select-names-text-model.h \ - e-select-names.c \ - e-select-names.h - - -gladedir = $(datadir)/evolution/glade -glade_DATA = select-names.glade - -EXTRA_DIST = \ - $(glade_DATA) \ - select-names.glade.h - diff --git a/addressbook/gui/component/select-names/e-select-names-manager.c b/addressbook/gui/component/select-names/e-select-names-manager.c deleted file mode 100644 index ac59787932..0000000000 --- a/addressbook/gui/component/select-names/e-select-names-manager.c +++ /dev/null @@ -1,222 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Authors: - * Chris Lahey - * - * Copyright (C) 2000 Helix Code, Inc. - */ - -#include -#include -#include -#include -#include - -#include "e-select-names-manager.h" -#include "e-select-names-model.h" -#include "e-select-names-text-model.h" -#include "widgets/e-text/e-entry.h" - -/* Object argument IDs */ -enum { - ARG_0, - ARG_CARD, -}; - - -typedef struct { - char *id; - char *title; - ESelectNamesModel *model; -} ESelectNamesManagerSection; - -static void e_select_names_manager_init (ESelectNamesManager *manager); -static void e_select_names_manager_class_init (ESelectNamesManagerClass *klass); - -static void e_select_names_manager_destroy (GtkObject *object); -static void e_select_names_manager_set_arg (GtkObject *object, GtkArg *arg, guint arg_id); -static void e_select_names_manager_get_arg (GtkObject *object, GtkArg *arg, guint arg_id); - -/** - * e_select_names_manager_get_type: - * @void: - * - * Registers the &ESelectNamesManager class if necessary, and returns the type ID - * associated to it. - * - * Return value: The type ID of the &ESelectNamesManager class. - **/ -GtkType -e_select_names_manager_get_type (void) -{ - static GtkType manager_type = 0; - - if (!manager_type) { - GtkTypeInfo manager_info = { - "ESelectNamesManager", - sizeof (ESelectNamesManager), - sizeof (ESelectNamesManagerClass), - (GtkClassInitFunc) e_select_names_manager_class_init, - (GtkObjectInitFunc) e_select_names_manager_init, - NULL, /* reserved_1 */ - NULL, /* reserved_2 */ - (GtkClassInitFunc) NULL - }; - - manager_type = gtk_type_unique (gtk_object_get_type (), &manager_info); - } - - return manager_type; -} - -/** - * e_select_names_manager_new: - * @VCard: a string in vCard format - * - * Returns: a new #ESelectNamesManager that wraps the @VCard. - */ -ESelectNamesManager * -e_select_names_manager_new (void) -{ - ESelectNamesManager *manager = E_SELECT_NAMES_MANAGER(gtk_type_new(e_select_names_manager_get_type())); - return manager; -} - -static void -e_select_names_manager_class_init (ESelectNamesManagerClass *klass) -{ - GtkObjectClass *object_class; - - object_class = GTK_OBJECT_CLASS(klass); - - gtk_object_add_arg_type ("ESelectNamesManager::card", - GTK_TYPE_OBJECT, GTK_ARG_READWRITE, ARG_CARD); - - object_class->destroy = e_select_names_manager_destroy; - object_class->get_arg = e_select_names_manager_get_arg; - object_class->set_arg = e_select_names_manager_set_arg; -} - -/* - * ESelectNamesManager lifecycle management and vcard loading/saving. - */ - -static void -e_select_names_manager_destroy (GtkObject *object) -{ - ESelectNamesManager *manager; - - manager = E_SELECT_NAMES_MANAGER (object); - - gtk_object_unref(GTK_OBJECT(manager->sections)); -} - - -/* Set_arg handler for the manager */ -static void -e_select_names_manager_set_arg (GtkObject *object, GtkArg *arg, guint arg_id) -{ - ESelectNamesManager *manager; - - manager = E_SELECT_NAMES_MANAGER (object); - - switch (arg_id) { - case ARG_CARD: - break; - default: - return; - } -} - -/* Get_arg handler for the manager */ -static void -e_select_names_manager_get_arg (GtkObject *object, GtkArg *arg, guint arg_id) -{ - ESelectNamesManager *manager; - - manager = E_SELECT_NAMES_MANAGER (object); - - switch (arg_id) { - case ARG_CARD: - break; - default: - arg->type = GTK_TYPE_INVALID; - break; - } -} - -static void * -section_copy(const void *sec, void *data) -{ - const ESelectNamesManagerSection *section = sec; - ESelectNamesManagerSection *newsec; - - newsec = g_new(ESelectNamesManagerSection, 1); - newsec->id = g_strdup(section->id); - newsec->title = g_strdup(section->title); - return newsec; -} - -static void -section_free(void *sec, void *data) -{ - ESelectNamesManagerSection *section = sec; - g_free(section->id); - g_free(section->title); - g_free(section); -} - -/** - * e_select_names_manager_init: - */ -static void -e_select_names_manager_init (ESelectNamesManager *manager) -{ - manager->sections = e_list_new(section_copy, section_free, manager); -} - -void e_select_names_manager_add_section (ESelectNamesManager *manager, - char *id, - char *title) -{ - ESelectNamesManagerSection *section; - - section = g_new(ESelectNamesManagerSection, 1); - section->id = g_strdup(id); - section->title = g_strdup(title); - e_list_append(manager->sections, section); - section_free(section, manager); -} - -GtkWidget *e_select_names_manager_create_entry (ESelectNamesManager *manager, - char *id) -{ - GtkWidget *entry; - ETextModel *model; - EIterator *iterator; - iterator = e_list_get_iterator(manager->sections); - for (; e_iterator_is_valid(iterator); e_iterator_next(iterator)) { - const ESelectNamesManagerSection *section = e_iterator_get(iterator); - if (!strcmp(section->id, id)) { - entry = GTK_WIDGET(e_entry_new()); - model = e_select_names_text_model_new(section->model); - gtk_object_set(GTK_OBJECT(entry), - "model", model, - NULL); - return entry; - } - } - return NULL; -} - -void e_select_names_manager_activate_dialog (ESelectNamesManager *manager, - char *id) -{ -} - -/* Of type ECard */ -EList *e_select_names_manager_get_cards (ESelectNamesManager *manager, - char *id) -{ - return NULL; -} diff --git a/addressbook/gui/component/select-names/e-select-names-manager.h b/addressbook/gui/component/select-names/e-select-names-manager.h deleted file mode 100644 index 600644f01a..0000000000 --- a/addressbook/gui/component/select-names/e-select-names-manager.h +++ /dev/null @@ -1,52 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Authors: - * Chris Lahey - * - * Copyright (C) 2000 Helix Code, Inc. - */ - -#ifndef __E_SELECT_NAMES_MANAGER_H__ -#define __E_SELECT_NAMES_MANAGER_H__ - -#include -#include -#include -#include - -#define E_TYPE_SELECT_NAMES_MANAGER (e_select_names_manager_get_type ()) -#define E_SELECT_NAMES_MANAGER(obj) (GTK_CHECK_CAST ((obj), E_TYPE_SELECT_NAMES_MANAGER, ESelectNamesManager)) -#define E_SELECT_NAMES_MANAGER_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_TYPE_SELECT_NAMES_MANAGER, ESelectNamesManagerClass)) -#define E_IS_SELECT_NAMES_MANAGER(obj) (GTK_CHECK_TYPE ((obj), E_TYPE_SELECT_NAMES_MANAGER)) -#define E_IS_SELECT_NAMES_MANAGER_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), E_TYPE_SELECT_NAMES_MANAGER)) - -typedef struct _ESelectNamesManager ESelectNamesManager; -typedef struct _ESelectNamesManagerClass ESelectNamesManagerClass; - -struct _ESelectNamesManager { - GtkObject object; - - EList *sections; -}; - -struct _ESelectNamesManagerClass { - GtkObjectClass parent_class; -}; - -ESelectNamesManager *e_select_names_manager_new (void); -void e_select_names_manager_add_section (ESelectNamesManager *manager, - char *id, - char *title); -GtkWidget *e_select_names_manager_create_entry (ESelectNamesManager *manager, - char *id); -void e_select_names_manager_activate_dialog (ESelectNamesManager *manager, - char *id); - -/* Of type ECard */ -EList *e_select_names_manager_get_cards (ESelectNamesManager *manager, - char *id); - -/* Standard Gtk function */ -GtkType e_select_names_manager_get_type (void); - -#endif /* ! __E_SELECT_NAMES_MANAGER_H__ */ diff --git a/addressbook/gui/component/select-names/e-select-names-model.c b/addressbook/gui/component/select-names/e-select-names-model.c deleted file mode 100644 index 8399136dd8..0000000000 --- a/addressbook/gui/component/select-names/e-select-names-model.c +++ /dev/null @@ -1,200 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Authors: - * Chris Lahey - * - * Copyright (C) 2000 Helix Code, Inc. - */ - -#include -#include -#include -#include -#include - -#include "e-select-names-model.h" - -enum { - E_SELECT_NAMES_MODEL_CHANGED, - E_SELECT_NAMES_MODEL_LAST_SIGNAL -}; - -static guint e_select_names_model_signals[E_SELECT_NAMES_MODEL_LAST_SIGNAL] = { 0 }; - -/* Object argument IDs */ -enum { - ARG_0, - ARG_CARD, -}; - -static void e_select_names_model_init (ESelectNamesModel *model); -static void e_select_names_model_class_init (ESelectNamesModelClass *klass); - -static void e_select_names_model_destroy (GtkObject *object); -static void e_select_names_model_set_arg (GtkObject *object, GtkArg *arg, guint arg_id); -static void e_select_names_model_get_arg (GtkObject *object, GtkArg *arg, guint arg_id); - -/** - * e_select_names_model_get_type: - * @void: - * - * Registers the &ESelectNamesModel class if necessary, and returns the type ID - * associated to it. - * - * Return value: The type ID of the &ESelectNamesModel class. - **/ -GtkType -e_select_names_model_get_type (void) -{ - static GtkType model_type = 0; - - if (!model_type) { - GtkTypeInfo model_info = { - "ESelectNamesModel", - sizeof (ESelectNamesModel), - sizeof (ESelectNamesModelClass), - (GtkClassInitFunc) e_select_names_model_class_init, - (GtkObjectInitFunc) e_select_names_model_init, - NULL, /* reserved_1 */ - NULL, /* reserved_2 */ - (GtkClassInitFunc) NULL - }; - - model_type = gtk_type_unique (gtk_object_get_type (), &model_info); - } - - return model_type; -} - -/** - * e_select_names_model_new: - * @VCard: a string in vCard format - * - * Returns: a new #ESelectNamesModel that wraps the @VCard. - */ -ESelectNamesModel * -e_select_names_model_new (void) -{ - ESelectNamesModel *model = E_SELECT_NAMES_MODEL(gtk_type_new(e_select_names_model_get_type())); - return model; -} - -static void -e_select_names_model_class_init (ESelectNamesModelClass *klass) -{ - GtkObjectClass *object_class; - - object_class = GTK_OBJECT_CLASS(klass); - - e_select_names_model_signals[E_SELECT_NAMES_MODEL_CHANGED] = - gtk_signal_new ("changed", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (ESelectNamesModelClass, changed), - gtk_marshal_NONE__NONE, - GTK_TYPE_NONE, 0); - - gtk_object_class_add_signals (object_class, e_select_names_model_signals, E_SELECT_NAMES_MODEL_LAST_SIGNAL); - - gtk_object_add_arg_type ("ESelectNamesModel::card", - GTK_TYPE_OBJECT, GTK_ARG_READWRITE, ARG_CARD); - - klass->changed = NULL; - - object_class->destroy = e_select_names_model_destroy; - object_class->get_arg = e_select_names_model_get_arg; - object_class->set_arg = e_select_names_model_set_arg; -} - -/* - * ESelectNamesModel lifecycle management and vcard loading/saving. - */ - -static void -e_select_names_model_destroy (GtkObject *object) -{ - ESelectNamesModel *model; - - model = E_SELECT_NAMES_MODEL (object); - - gtk_object_unref(GTK_OBJECT(model->data)); -} - - -/* Set_arg handler for the model */ -static void -e_select_names_model_set_arg (GtkObject *object, GtkArg *arg, guint arg_id) -{ - ESelectNamesModel *model; - - model = E_SELECT_NAMES_MODEL (object); - - switch (arg_id) { - case ARG_CARD: - break; - default: - return; - } -} - -/* Get_arg handler for the model */ -static void -e_select_names_model_get_arg (GtkObject *object, GtkArg *arg, guint arg_id) -{ - ESelectNamesModel *model; - - model = E_SELECT_NAMES_MODEL (object); - - switch (arg_id) { - case ARG_CARD: - break; - default: - arg->type = GTK_TYPE_INVALID; - break; - } -} - -static void * -data_copy(const void *sec, void *data) -{ - const ESelectNamesModelData *section = sec; - ESelectNamesModelData *newsec; - - newsec = g_new(ESelectNamesModelData, 1); - newsec->type = section->type; - newsec->card = section->card; - if (newsec->card) - gtk_object_ref(GTK_OBJECT(newsec->card)); - newsec->string = g_strdup(section->string); - return newsec; -} - -static void -data_free(void *sec, void *data) -{ - ESelectNamesModelData *section = sec; - if (section->card) - gtk_object_unref(GTK_OBJECT(section->card)); - g_free(section->string); - g_free(section); -} - -/** - * e_select_names_model_init: - */ -static void -e_select_names_model_init (ESelectNamesModel *model) -{ - model->data = e_list_new(data_copy, data_free, model); -} - -/* Of type ECard */ -EList *e_select_names_model_get_cards (ESelectNamesModel *model) -{ - return NULL; -} - -EList *e_select_names_model_get_data (ESelectNamesModel *model) -{ - return model->data; -} diff --git a/addressbook/gui/component/select-names/e-select-names-model.h b/addressbook/gui/component/select-names/e-select-names-model.h deleted file mode 100644 index 20c90818f7..0000000000 --- a/addressbook/gui/component/select-names/e-select-names-model.h +++ /dev/null @@ -1,67 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Authors: - * Chris Lahey - * - * Copyright (C) 2000 Helix Code, Inc. - */ - -#ifndef __E_SELECT_NAMES_MODEL_H__ -#define __E_SELECT_NAMES_MODEL_H__ - -#include -#include -#include -#include -#include - -#define E_TYPE_SELECT_NAMES_MODEL (e_select_names_model_get_type ()) -#define E_SELECT_NAMES_MODEL(obj) (GTK_CHECK_CAST ((obj), E_TYPE_SELECT_NAMES_MODEL, ESelectNamesModel)) -#define E_SELECT_NAMES_MODEL_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_TYPE_SELECT_NAMES_MODEL, ESelectNamesModelClass)) -#define E_IS_SELECT_NAMES_MODEL(obj) (GTK_CHECK_TYPE ((obj), E_TYPE_SELECT_NAMES_MODEL)) -#define E_IS_SELECT_NAMES_MODEL_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), E_TYPE_SELECT_NAMES_MODEL)) - -typedef enum _ESelectNamesModelDataType ESelectNamesModelDataType; -typedef struct _ESelectNamesModelData ESelectNamesModelData; -typedef struct _ESelectNamesModel ESelectNamesModel; -typedef struct _ESelectNamesModelClass ESelectNamesModelClass; - -enum _ESelectNamesModelDataType { - E_SELECT_NAMES_MODEL_DATA_TYPE_CARD, - E_SELECT_NAMES_MODEL_DATA_TYPE_STRING_ADDRESS, - E_SELECT_NAMES_MODEL_DATA_TYPE_SEPARATION_MATERIAL, -}; - -struct _ESelectNamesModelData { - ESelectNamesModelDataType type; - ECard *card; - char *string; -}; - -struct _ESelectNamesModel { - GtkObject object; - - char *id; - char *title; - - EList *data; /* Of type ESelectNamesModelData. */ -}; - -struct _ESelectNamesModelClass { - GtkObjectClass parent_class; - - void (*changed) (ESelectNamesModel *model); -}; - -ESelectNamesModel *e_select_names_model_new (void); - -/* Of type ECard */ -EList *e_select_names_model_get_cards (ESelectNamesModel *model); - -/* Of type ESelectNamesModelData */ -EList *e_select_names_model_get_data (ESelectNamesModel *model); - -/* Standard Gtk function */ -GtkType e_select_names_model_get_type (void); - -#endif /* ! __E_SELECT_NAMES_MODEL_H__ */ diff --git a/addressbook/gui/component/select-names/e-select-names-table-model.c b/addressbook/gui/component/select-names/e-select-names-table-model.c deleted file mode 100644 index dc3edda5f9..0000000000 --- a/addressbook/gui/component/select-names/e-select-names-table-model.c +++ /dev/null @@ -1,157 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Authors: - * Chris Lahey - * - * Copyright (C) 2000 Helix Code, Inc. - */ - -#include -#include -#include -#include -#include - -#include "e-select-names-table-model.h" - -/* Object argument IDs */ -enum { - ARG_0, - ARG_SOURCE, -}; - -static void e_select_names_table_model_init (ESelectNamesTableModel *model); -static void e_select_names_table_model_class_init (ESelectNamesTableModelClass *klass); - -static void e_select_names_table_model_destroy (GtkObject *object); -static void e_select_names_table_model_set_arg (GtkObject *object, GtkArg *arg, guint arg_id); -static void e_select_names_table_model_get_arg (GtkObject *object, GtkArg *arg, guint arg_id); - -/** - * e_select_names_table_model_get_type: - * @void: - * - * Registers the &ESelectNamesTableModel class if necessary, and returns the type ID - * associated to it. - * - * Return value: The type ID of the &ESelectNamesTableModel class. - **/ -GtkType -e_select_names_table_model_get_type (void) -{ - static GtkType model_type = 0; - - if (!model_type) { - GtkTypeInfo model_info = { - "ESelectNamesTableModel", - sizeof (ESelectNamesTableModel), - sizeof (ESelectNamesTableModelClass), - (GtkClassInitFunc) e_select_names_table_model_class_init, - (GtkObjectInitFunc) e_select_names_table_model_init, - NULL, /* reserved_1 */ - NULL, /* reserved_2 */ - (GtkClassInitFunc) NULL - }; - - model_type = gtk_type_unique (e_table_model_get_type (), &model_info); - } - - return model_type; -} - -/** - * e_select_names_table_model_new: - * @VCard: a string in vCard format - * - * Returns: a new #ESelectNamesTableModel that wraps the @VCard. - */ -ETableModel * -e_select_names_table_model_new (ESelectNamesModel *source) -{ - ETableModel *model = E_TABLE_MODEL(gtk_type_new(e_select_names_table_model_get_type())); - gtk_object_set(GTK_OBJECT(model), - "source", source, - NULL); - return model; -} - -static void -e_select_names_table_model_class_init (ESelectNamesTableModelClass *klass) -{ - GtkObjectClass *object_class; - ETableModelClass *table_model_class; - - object_class = GTK_OBJECT_CLASS(klass); - table_model_class = E_TABLE_MODEL_CLASS(klass); - - gtk_object_add_arg_type ("ESelectNamesTableModel::source", - GTK_TYPE_OBJECT, GTK_ARG_READWRITE, ARG_SOURCE); - - object_class->destroy = e_select_names_table_model_destroy; - object_class->get_arg = e_select_names_table_model_get_arg; - object_class->set_arg = e_select_names_table_model_set_arg; -} - -/* - * ESelectNamesTableModel lifecycle management and vcard loading/saving. - */ - -static void -e_select_names_table_model_destroy (GtkObject *object) -{ - ESelectNamesTableModel *model; - - model = E_SELECT_NAMES_TABLE_MODEL (object); - - if (model->source) - gtk_object_unref(GTK_OBJECT(model->source)); -} - - -/* Set_arg handler for the model */ -static void -e_select_names_table_model_set_arg (GtkObject *object, GtkArg *arg, guint arg_id) -{ - ESelectNamesTableModel *model; - - model = E_SELECT_NAMES_TABLE_MODEL (object); - - switch (arg_id) { - case ARG_SOURCE: - if (model->source) - gtk_object_unref(GTK_OBJECT(model->source)); - model->source = E_SELECT_NAMES_MODEL(GTK_VALUE_OBJECT(*arg)); - if (model->source) - gtk_object_ref(GTK_OBJECT(model->source)); - break; - default: - return; - } -} - -/* Get_arg handler for the model */ -static void -e_select_names_table_model_get_arg (GtkObject *object, GtkArg *arg, guint arg_id) -{ - ESelectNamesTableModel *model; - - model = E_SELECT_NAMES_TABLE_MODEL (object); - - switch (arg_id) { - case ARG_SOURCE: - GTK_VALUE_OBJECT(*arg) = GTK_OBJECT(model->source); - break; - default: - arg->type = GTK_TYPE_INVALID; - break; - } -} - -/** - * e_select_names_table_model_init: - */ -static void -e_select_names_table_model_init (ESelectNamesTableModel *model) -{ - model->source = NULL; -} diff --git a/addressbook/gui/component/select-names/e-select-names-table-model.h b/addressbook/gui/component/select-names/e-select-names-table-model.h deleted file mode 100644 index 94cbaff13a..0000000000 --- a/addressbook/gui/component/select-names/e-select-names-table-model.h +++ /dev/null @@ -1,42 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Authors: - * Chris Lahey - * - * Copyright (C) 2000 Helix Code, Inc. - */ - -#ifndef __E_SELECT_NAMES_TABLE_MODEL_H__ -#define __E_SELECT_NAMES_TABLE_MODEL_H__ - -#include -#include -#include -#include "e-select-names-model.h" -#include - -#define E_TYPE_SELECT_NAMES_TABLE_MODEL (e_select_names_table_model_get_type ()) -#define E_SELECT_NAMES_TABLE_MODEL(obj) (GTK_CHECK_CAST ((obj), E_TYPE_SELECT_NAMES_TABLE_MODEL, ESelectNamesTableModel)) -#define E_SELECT_NAMES_TABLE_MODEL_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_TYPE_SELECT_NAMES_TABLE_MODEL, ESelectNamesTableModelClass)) -#define E_IS_SELECT_NAMES_TABLE_MODEL(obj) (GTK_CHECK_TYPE ((obj), E_TYPE_SELECT_NAMES_TABLE_MODEL)) -#define E_IS_SELECT_NAMES_TABLE_MODEL_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), E_TYPE_SELECT_NAMES_TABLE_MODEL)) - -typedef struct _ESelectNamesTableModel ESelectNamesTableModel; -typedef struct _ESelectNamesTableModelClass ESelectNamesTableModelClass; - -struct _ESelectNamesTableModel { - ETableModel parent; - - ESelectNamesModel *source; -}; - -struct _ESelectNamesTableModelClass { - ETableModel parent_class; -}; - -ETableModel *e_select_names_table_model_new (ESelectNamesModel *source); - -/* Standard Gtk function */ -GtkType e_select_names_table_model_get_type (void); - -#endif /* ! __E_SELECT_NAMES_TABLE_MODEL_H__ */ diff --git a/addressbook/gui/component/select-names/e-select-names-text-model.c b/addressbook/gui/component/select-names/e-select-names-text-model.c deleted file mode 100644 index db273796f3..0000000000 --- a/addressbook/gui/component/select-names/e-select-names-text-model.c +++ /dev/null @@ -1,265 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Authors: - * Chris Lahey - * - * Copyright (C) 2000 Helix Code, Inc. - */ - -#include -#include -#include -#include -#include - -#include "e-select-names-text-model.h" - -/* Object argument IDs */ -enum { - ARG_0, - ARG_SOURCE, -}; - -static void e_select_names_text_model_init (ESelectNamesTextModel *model); -static void e_select_names_text_model_class_init (ESelectNamesTextModelClass *klass); - -static void e_select_names_text_model_destroy (GtkObject *object); -static void e_select_names_text_model_set_arg (GtkObject *object, GtkArg *arg, guint arg_id); -static void e_select_names_text_model_get_arg (GtkObject *object, GtkArg *arg, guint arg_id); - -static void e_select_names_text_model_set_text (ETextModel *model, gchar *text); -static void e_select_names_text_model_insert (ETextModel *model, gint position, gchar *text); -static void e_select_names_text_model_insert_length (ETextModel *model, gint position, gchar *text, gint length); -static void e_select_names_text_model_delete (ETextModel *model, gint position, gint length); - -static void e_select_names_text_model_model_changed (ESelectNamesModel *source, - ESelectNamesTextModel *model); - - -ETextModelClass *parent_class; -#define PARENT_TYPE e_text_model_get_type() - -/** - * e_select_names_text_model_get_type: - * @void: - * - * Registers the &ESelectNamesTextModel class if necessary, and returns the type ID - * associated to it. - * - * Return value: The type ID of the &ESelectNamesTextModel class. - **/ -GtkType -e_select_names_text_model_get_type (void) -{ - static GtkType model_type = 0; - - if (!model_type) { - GtkTypeInfo model_info = { - "ESelectNamesTextModel", - sizeof (ESelectNamesTextModel), - sizeof (ESelectNamesTextModelClass), - (GtkClassInitFunc) e_select_names_text_model_class_init, - (GtkObjectInitFunc) e_select_names_text_model_init, - NULL, /* reserved_1 */ - NULL, /* reserved_2 */ - (GtkClassInitFunc) NULL - }; - - model_type = gtk_type_unique (PARENT_TYPE, &model_info); - } - - return model_type; -} - -/** - * e_select_names_text_model_new: - * @VCard: a string in vCard format - * - * Returns: a new #ESelectNamesTextModel that wraps the @VCard. - */ -ETextModel * -e_select_names_text_model_new (ESelectNamesModel *source) -{ - ETextModel *model = E_TEXT_MODEL(gtk_type_new(e_select_names_text_model_get_type())); - gtk_object_set(GTK_OBJECT(model), - "source", source, - NULL); - return model; -} - -static void -e_select_names_text_model_class_init (ESelectNamesTextModelClass *klass) -{ - GtkObjectClass *object_class; - ETextModelClass *text_model_class; - - object_class = GTK_OBJECT_CLASS(klass); - text_model_class = E_TEXT_MODEL_CLASS(klass); - - parent_class = gtk_type_class(PARENT_TYPE); - - gtk_object_add_arg_type ("ESelectNamesTextModel::source", - GTK_TYPE_OBJECT, GTK_ARG_READWRITE, ARG_SOURCE); - - object_class->destroy = e_select_names_text_model_destroy; - object_class->get_arg = e_select_names_text_model_get_arg; - object_class->set_arg = e_select_names_text_model_set_arg; - - text_model_class->set_text = e_select_names_text_model_set_text; - text_model_class->insert = e_select_names_text_model_insert; - text_model_class->insert_length = e_select_names_text_model_insert_length; - text_model_class->delete = e_select_names_text_model_delete; -} - -static void -e_select_names_text_model_set_text (ETextModel *model, gchar *text) -{ -#if 0 - e_select_names_model_clear(model); -#endif -} - -static void -e_select_names_text_model_insert (ETextModel *model, gint position, gchar *text) -{ -} - -static void -e_select_names_text_model_insert_length (ETextModel *model, gint position, gchar *text, gint length) -{ -} - -static void -e_select_names_text_model_delete (ETextModel *model, gint position, gint length) -{ -} - -static void -e_select_names_text_model_model_changed (ESelectNamesModel *source, - ESelectNamesTextModel *model) -{ - EList *list = e_select_names_model_get_data(source); - EIterator *iterator = e_list_get_iterator(list); - int length = 0; - int length_count = 0; - int *lengthsp; - char *string; - char *stringp; - for (e_iterator_reset(iterator); e_iterator_is_valid(iterator); e_iterator_next(iterator)) { - const ESelectNamesModelData *data = e_iterator_get(iterator); - length += strlen(data->string); - length_count++; - } - - g_free(model->lengths); - model->lengths = g_new(int, length_count + 1); - lengthsp = model->lengths; - - string = g_new(char, length + 1); - stringp = string; - *stringp = 0; - for (e_iterator_reset(iterator); e_iterator_is_valid(iterator); e_iterator_next(iterator)) { - const ESelectNamesModelData *data = e_iterator_get(iterator); - int this_length; - - strcpy(stringp, data->string); - this_length = strlen(stringp); - stringp += this_length; - *(lengthsp++) = this_length; - } - *stringp = 0; - *lengthsp = -1; - g_free(E_TEXT_MODEL(model)->text); - E_TEXT_MODEL(model)->text = string; -} - - -static void -e_select_names_text_model_add_source (ESelectNamesTextModel *model, - ESelectNamesModel *source) -{ - model->source = source; - if (model->source) - gtk_object_ref(GTK_OBJECT(model->source)); - model->source_changed_id = gtk_signal_connect(GTK_OBJECT(model->source), "changed", - GTK_SIGNAL_FUNC(e_select_names_text_model_model_changed), - model); -} - -static void -e_select_names_text_model_drop_source (ESelectNamesTextModel *model) -{ - if (model->source_changed_id) - gtk_signal_disconnect(GTK_OBJECT(model->source), model->source_changed_id); - if (model->source) - gtk_object_unref(GTK_OBJECT(model->source)); - model->source = NULL; - model->source_changed_id = 0; -} - -/* - * ESelectNamesTextModel lifecycle management and vcard loading/saving. - */ - -static void -e_select_names_text_model_destroy (GtkObject *object) -{ - ESelectNamesTextModel *model; - - model = E_SELECT_NAMES_TEXT_MODEL (object); - - e_select_names_text_model_drop_source(model); - g_free(model->lengths); - - if (GTK_OBJECT_CLASS(parent_class)->destroy) - GTK_OBJECT_CLASS(parent_class)->destroy(object); -} - - -/* Set_arg handler for the model */ -static void -e_select_names_text_model_set_arg (GtkObject *object, GtkArg *arg, guint arg_id) -{ - ESelectNamesTextModel *model; - - model = E_SELECT_NAMES_TEXT_MODEL (object); - - switch (arg_id) { - case ARG_SOURCE: - e_select_names_text_model_drop_source(model); - e_select_names_text_model_add_source(model, E_SELECT_NAMES_MODEL(GTK_VALUE_OBJECT(*arg))); - break; - default: - return; - } -} - -/* Get_arg handler for the model */ -static void -e_select_names_text_model_get_arg (GtkObject *object, GtkArg *arg, guint arg_id) -{ - ESelectNamesTextModel *model; - - model = E_SELECT_NAMES_TEXT_MODEL (object); - - switch (arg_id) { - case ARG_SOURCE: - GTK_VALUE_OBJECT(*arg) = GTK_OBJECT(model->source); - break; - default: - arg->type = GTK_TYPE_INVALID; - break; - } -} - -/** - * e_select_names_text_model_init: - */ -static void -e_select_names_text_model_init (ESelectNamesTextModel *model) -{ - model->source = NULL; - model->source_changed_id = 0; - model->lengths = NULL; -} - diff --git a/addressbook/gui/component/select-names/e-select-names-text-model.h b/addressbook/gui/component/select-names/e-select-names-text-model.h deleted file mode 100644 index 564886ffc9..0000000000 --- a/addressbook/gui/component/select-names/e-select-names-text-model.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. - */ - -#ifndef __E_SELECT_NAMES_TEXT_MODEL_H__ -#define __E_SELECT_NAMES_TEXT_MODEL_H__ - -#include -#include -#include -#include "e-select-names-model.h" -#include - -#define E_TYPE_SELECT_NAMES_TEXT_MODEL (e_select_names_text_model_get_type ()) -#define E_SELECT_NAMES_TEXT_MODEL(obj) (GTK_CHECK_CAST ((obj), E_TYPE_SELECT_NAMES_TEXT_MODEL, ESelectNamesTextModel)) -#define E_SELECT_NAMES_TEXT_MODEL_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_TYPE_SELECT_NAMES_TEXT_MODEL, ESelectNamesTextModelClass)) -#define E_IS_SELECT_NAMES_TEXT_MODEL(obj) (GTK_CHECK_TYPE ((obj), E_TYPE_SELECT_NAMES_TEXT_MODEL)) -#define E_IS_SELECT_NAMES_TEXT_MODEL_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), E_TYPE_SELECT_NAMES_TEXT_MODEL)) - -typedef struct _ESelectNamesTextModel ESelectNamesTextModel; -typedef struct _ESelectNamesTextModelClass ESelectNamesTextModelClass; - -struct _ESelectNamesTextModel { - ETextModel parent; - - ESelectNamesModel *source; - int source_changed_id; - int *lengths; -}; - -struct _ESelectNamesTextModelClass { - ETextModel parent_class; -}; - -ETextModel *e_select_names_text_model_new (ESelectNamesModel *source); - -/* Standard Gtk function */ -GtkType e_select_names_text_model_get_type (void); - -#endif /* ! __E_SELECT_NAMES_TEXT_MODEL_H__ */ diff --git a/addressbook/gui/component/select-names/e-select-names.c b/addressbook/gui/component/select-names/e-select-names.c deleted file mode 100644 index c5791bb9bd..0000000000 --- a/addressbook/gui/component/select-names/e-select-names.c +++ /dev/null @@ -1,344 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* e-select-names.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-select-names.h" -#include -#include -#include -#include -#include -#include - -static void e_select_names_init (ESelectNames *card); -static void e_select_names_class_init (ESelectNamesClass *klass); -static void e_select_names_set_arg (GtkObject *o, GtkArg *arg, guint arg_id); -static void e_select_names_get_arg (GtkObject *object, GtkArg *arg, guint arg_id); -static void e_select_names_destroy (GtkObject *object); - -static GnomeDialogClass *parent_class = NULL; -#define PARENT_TYPE gnome_dialog_get_type() - -/* The arguments we take */ -enum { - ARG_0, - ARG_BOOK, - ARG_QUERY, -}; - -typedef struct { - char *title; - ETableModel *model; - ESelectNames *names; -} ESelectNamesChild; - -GtkType -e_select_names_get_type (void) -{ - static GtkType type = 0; - - if (!type) { - static const GtkTypeInfo info = - { - "ESelectNames", - sizeof (ESelectNames), - sizeof (ESelectNamesClass), - (GtkClassInitFunc) e_select_names_class_init, - (GtkObjectInitFunc) e_select_names_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - type = gtk_type_unique (PARENT_TYPE, &info); - } - - return type; -} - -static void -e_select_names_class_init (ESelectNamesClass *klass) -{ - GtkObjectClass *object_class; - - object_class = (GtkObjectClass*) klass; - - parent_class = gtk_type_class (PARENT_TYPE); - - gtk_object_add_arg_type ("ESelectNames::book", GTK_TYPE_OBJECT, - GTK_ARG_READWRITE, ARG_BOOK); - gtk_object_add_arg_type ("ESelectNames::query", GTK_TYPE_STRING, - GTK_ARG_READWRITE, ARG_QUERY); - - object_class->set_arg = e_select_names_set_arg; - object_class->get_arg = e_select_names_get_arg; - object_class->destroy = e_select_names_destroy; -} - -#define SPEC " \ - \ - 0 \ - 2 \ - \ - \ -" - -GtkWidget *e_addressbook_create_ebook_table(char *name, char *string1, char *string2, int num1, int num2); - -static void -set_book(EBook *book, EBookStatus status, ETableModel *model) -{ - gtk_object_set(GTK_OBJECT(model), - "book", book, - NULL); - gtk_object_unref(GTK_OBJECT(book)); -} - -GtkWidget * -e_addressbook_create_ebook_table(char *name, char *string1, char *string2, int num1, int num2) -{ - ETableModel *model; - ETableHeader *header; - ECell *cell_left_just; - EBook *book; - GtkWidget *table; - char *filename; - char *uri; - - model = e_addressbook_model_new(); - cell_left_just = e_cell_text_new (model, NULL, GTK_JUSTIFY_LEFT); - - header = e_table_header_new (); - e_table_header_add_column (header, e_table_col_new (0, "Full Name", 1.0, 20, cell_left_just, - g_str_compare, TRUE), 0); - - book = e_book_new(); - gtk_object_ref(GTK_OBJECT(model)); - gtk_object_ref(GTK_OBJECT(book)); - filename = gnome_util_prepend_user_home("evolution/local/Contacts/addressbook.db"); - uri = g_strdup_printf("file://%s", filename); - e_book_load_uri(book, uri, (EBookCallback) set_book, model); - g_free(uri); - g_free(filename); - table = e_table_new (header, model, SPEC); - gtk_object_set_data(GTK_OBJECT(table), "model", model); - return table; -} - -static void -set_current_selection(ETable *table, int row, ESelectNames *names) -{ - names->currently_selected = row; -} - -static void -e_select_names_init (ESelectNames *e_select_names) -{ - GladeXML *gui; - GtkWidget *widget; - - gui = glade_xml_new (EVOLUTION_GLADEDIR "/select-names.glade", NULL); - e_select_names->gui = gui; - - e_select_names->children = g_hash_table_new(g_str_hash, g_str_equal); - e_select_names->child_count = 0; - - widget = glade_xml_get_widget(gui, "table-top"); - if (!widget) { - return; - } - gtk_widget_ref(widget); - gtk_widget_unparent(widget); - gtk_box_pack_start(GTK_BOX(GNOME_DIALOG(e_select_names)->vbox), widget, TRUE, TRUE, 0); - gtk_widget_unref(widget); - - gnome_dialog_append_buttons(GNOME_DIALOG(e_select_names), - GNOME_STOCK_BUTTON_OK, - GNOME_STOCK_BUTTON_CANCEL, - NULL); - - e_select_names->table = E_TABLE(glade_xml_get_widget(gui, "table-source")); - e_select_names->model = gtk_object_get_data(GTK_OBJECT(e_select_names->table), "model"); - - e_select_names->currently_selected = -1; - - gtk_signal_connect(GTK_OBJECT(e_select_names->table), "cursor_change", - GTK_SIGNAL_FUNC(set_current_selection), e_select_names); -} - -static void e_select_names_child_free(char *key, ESelectNamesChild *child, ESelectNames *e_select_names) -{ - g_free(child->title); - gtk_object_unref(GTK_OBJECT(child->model)); - g_free(key); -} - -static void -e_select_names_destroy (GtkObject *object) { - ESelectNames *e_select_names = E_SELECT_NAMES(object); - - gtk_object_unref(GTK_OBJECT(e_select_names->gui)); - g_hash_table_foreach(e_select_names->children, (GHFunc) e_select_names_child_free, e_select_names); - g_hash_table_destroy(e_select_names->children); -} - -GtkWidget* -e_select_names_new (void) -{ - GtkWidget *widget = GTK_WIDGET (gtk_type_new (e_select_names_get_type ())); - return widget; -} - -static void -e_select_names_set_arg (GtkObject *o, GtkArg *arg, guint arg_id) -{ - ESelectNames *editor; - - editor = E_SELECT_NAMES (o); - - switch (arg_id){ - default: - return; - } -} - -static void -e_select_names_get_arg (GtkObject *object, GtkArg *arg, guint arg_id) -{ - ESelectNames *e_select_names; - - e_select_names = E_SELECT_NAMES (object); - - switch (arg_id) { - default: - arg->type = GTK_TYPE_INVALID; - break; - } -} - -static void -button_clicked(GtkWidget *button, ESelectNamesChild *child) -{ - ESelectNames *names = child->names; - int row = names->currently_selected; - if (row != -1) { - ECard *card = e_addressbook_model_get_card(E_ADDRESSBOOK_MODEL(names->model), row); - e_cardlist_model_add(E_CARDLIST_MODEL(child->model), &card, 1); - gtk_object_unref(GTK_OBJECT(card)); - } -} - -void -e_select_names_add_section(ESelectNames *e_select_names, char *name, char *id) -{ - ESelectNamesChild *child; - GtkWidget *button; - GtkWidget *alignment; - GtkTable *table; - char *label; - - ETableModel *model; - GtkWidget *etable; - ETableHeader *header; - ECell *cell_left_just; - - if (g_hash_table_lookup(e_select_names->children, id)) { - return; - } - - table = GTK_TABLE(glade_xml_get_widget (e_select_names->gui, "table-recipients")); - - child = g_new(ESelectNamesChild, 1); - - child->names = e_select_names; - - e_select_names->child_count++; - - alignment = gtk_alignment_new(0, 0, 1, 0); - label = g_strdup_printf("%s ->", _(name)); - button = gtk_button_new_with_label(label); - g_free(label); - gtk_container_add(GTK_CONTAINER(alignment), button); - gtk_widget_show_all(alignment); - gtk_signal_connect(GTK_OBJECT(button), "clicked", - GTK_SIGNAL_FUNC(button_clicked), child); - gtk_table_attach(table, alignment, - 0, 1, - e_select_names->child_count, - e_select_names->child_count + 1, - GTK_FILL, GTK_FILL, - 0, 0); - - model = e_cardlist_model_new(); - header = e_table_header_new (); - cell_left_just = e_cell_text_new (model, NULL, GTK_JUSTIFY_LEFT); - e_table_header_add_column (header, e_table_col_new (0, "Full Name", 1.0, 20, cell_left_just, - g_str_compare, TRUE), 0); - etable = e_table_new (header, model, SPEC); - - child->model = model; - gtk_object_ref(GTK_OBJECT(child->model)); - - gtk_widget_show(etable); - - gtk_table_attach(table, etable, - 1, 2, - e_select_names->child_count, - e_select_names->child_count + 1, - GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_EXPAND, - 0, 0); -} - -static void * -card_copy(const void *value, void *closure) -{ - gtk_object_ref(GTK_OBJECT(value)); - return (void *)value; -} - -static void -card_free(void *value, void *closure) -{ - gtk_object_unref(GTK_OBJECT(value)); -} - -EList * -e_select_names_get_section(ESelectNames *e_select_names, char *id) -{ - ESelectNamesChild *child; - int i; - int rows; - EList *list; - - child = g_hash_table_lookup(e_select_names->children, id); - if (!child) - return NULL; - rows = e_table_model_row_count(child->model); - - list = e_list_new(card_copy, card_free, NULL); - for (i = 0; i < rows; i++) { - ECard *card = e_cardlist_model_get(E_CARDLIST_MODEL(child->model), i); - e_list_append(list, card); - gtk_object_unref(GTK_OBJECT(card)); - } - return list; -} diff --git a/addressbook/gui/component/select-names/e-select-names.h b/addressbook/gui/component/select-names/e-select-names.h deleted file mode 100644 index c9d4619db2..0000000000 --- a/addressbook/gui/component/select-names/e-select-names.h +++ /dev/null @@ -1,86 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* e-select-names.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_SELECT_NAMES_H__ -#define __E_SELECT_NAMES_H__ - -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - -/* ESelectNames - A dialog displaying information about a contact. - * - * The following arguments are available: - * - * name type read/write description - * -------------------------------------------------------------------------------- - */ - -#define E_SELECT_NAMES_TYPE (e_select_names_get_type ()) -#define E_SELECT_NAMES(obj) (GTK_CHECK_CAST ((obj), E_SELECT_NAMES_TYPE, ESelectNames)) -#define E_SELECT_NAMES_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_SELECT_NAMES_TYPE, ESelectNamesClass)) -#define E_IS_SELECT_NAMES(obj) (GTK_CHECK_TYPE ((obj), E_SELECT_NAMES_TYPE)) -#define E_IS_SELECT_NAMES_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), E_SELECT_NAMES_TYPE)) - - -typedef struct _ESelectNames ESelectNames; -typedef struct _ESelectNamesClass ESelectNamesClass; - -struct _ESelectNames -{ - GnomeDialog parent; - - /* item specific fields */ - GladeXML *gui; - - GHashTable *children; /* Of type char * to ESelectNamesChild */ - int child_count; - ETable *table; - ETableModel *model; - int currently_selected; -}; - -struct _ESelectNamesClass -{ - GnomeDialogClass parent_class; -}; - - -GtkWidget *e_select_names_new (void); -GtkType e_select_names_get_type (void); -void e_select_names_add_section (ESelectNames *e_select_names, - char *name, - char *id); -/* Returns a ref counted list of addresses. */ -EList *e_select_names_get_section (ESelectNames *e_select_names, - char *id); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - - -#endif /* __E_SELECT_NAMES_H__ */ diff --git a/addressbook/gui/component/select-names/recipient.glade b/addressbook/gui/component/select-names/recipient.glade deleted file mode 100644 index b60972d094..0000000000 --- a/addressbook/gui/component/select-names/recipient.glade +++ /dev/null @@ -1,61 +0,0 @@ - - - - - Recipient - recipient - - src - pixmaps - C - True - True - True - False - False - False - True - - - - GtkWindow - window1 - False - window1 - GTK_WINDOW_TOPLEVEL - GTK_WIN_POS_NONE - False - False - True - False - - - GtkHBox - hbox-top - False - 4 - - - GtkAlignment - alignment1 - 1.08033e-07 - 0 - 1 - 0 - - 0 - False - True - - - - GtkButton - text-button - True - - - - - - - diff --git a/addressbook/gui/component/select-names/select-names.glade b/addressbook/gui/component/select-names/select-names.glade deleted file mode 100644 index 46da911228..0000000000 --- a/addressbook/gui/component/select-names/select-names.glade +++ /dev/null @@ -1,245 +0,0 @@ - - - - - Select-names - select-names - - src - pixmaps - C - True - True - False - False - False - True - select-names.glade.h - - - - GnomeDialog - dialog-top - False - Select Names - GTK_WINDOW_TOPLEVEL - GTK_WIN_POS_NONE - False - False - True - False - False - False - - - GtkVBox - GnomeDialog:vbox - dialog-vbox1 - False - 8 - - 4 - True - True - - - - GtkHButtonBox - GnomeDialog:action_area - dialog-action_area1 - GTK_BUTTONBOX_END - 8 - 85 - 27 - 7 - 0 - - 0 - False - True - GTK_PACK_END - - - - GtkButton - button1 - True - True - GNOME_STOCK_BUTTON_OK - - - - GtkButton - button3 - True - True - GNOME_STOCK_BUTTON_CANCEL - - - - - GtkTable - table-top - 3 - 2 - False - 6 - 6 - - 0 - True - True - - - - GtkHBox - hbox1 - False - 4 - - 0 - 1 - 1 - 2 - 0 - 0 - True - False - False - False - True - True - - - - GtkEntry - entry-find - True - True - True - True - 0 - - - 0 - True - True - - - - - GtkButton - button-find - True - - - 0 - False - False - - - - - - GtkAccelLabel - accellabel1 - - GTK_JUSTIFY_LEFT - False - 0 - 0 - 0 - 0 - - 0 - 1 - 0 - 1 - 0 - 0 - True - False - False - False - True - True - - - - - Custom - table-source - e_addressbook_create_ebook_table - 0 - 0 - Sat, 10 Jun 2000 22:02:57 GMT - - 0 - 1 - 2 - 3 - 0 - 0 - True - True - False - False - True - True - - - - - GtkTable - table-recipients - 1 - 2 - False - 4 - 4 - - 1 - 2 - 2 - 3 - 0 - 0 - True - False - False - False - True - True - - - - GtkAccelLabel - accellabel2 - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - - 1 - 2 - 0 - 1 - 0 - 0 - True - False - False - False - True - True - - - - - - - - diff --git a/addressbook/gui/component/select-names/select-names.glade.h b/addressbook/gui/component/select-names/select-names.glade.h deleted file mode 100644 index a21ddce689..0000000000 --- a/addressbook/gui/component/select-names/select-names.glade.h +++ /dev/null @@ -1,10 +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_("Select Names"); -gchar *s = N_("Find..."); -gchar *s = N_("T_ype name or select from List:"); -gchar *s = N_("Message Recipients"); diff --git a/addressbook/gui/contact-editor/.cvsignore b/addressbook/gui/contact-editor/.cvsignore deleted file mode 100644 index 6fd0b5075c..0000000000 --- a/addressbook/gui/contact-editor/.cvsignore +++ /dev/null @@ -1,8 +0,0 @@ -.deps -.libs -.pure -Makefile -Makefile.in -*.lo -*.la -contact-editor-test diff --git a/addressbook/gui/contact-editor/Makefile.am b/addressbook/gui/contact-editor/Makefile.am deleted file mode 100644 index d7729421b1..0000000000 --- a/addressbook/gui/contact-editor/Makefile.am +++ /dev/null @@ -1,56 +0,0 @@ -CPPFLAGS = \ - -DEVOLUTION_GLADEDIR=\""$(gladedir)"\" \ - -DDATADIR=\""$(datadir)"\" - -INCLUDES = \ - $(BONOBO_GNOME_CFLAGS) \ - -I$(top_srcdir) \ - -I$(top_srcdir)/addressbook/ \ - -I$(top_srcdir)/addressbook/backend \ - -I$(top_srcdir)/widgets/e-table \ - -DG_LOG_DOMAIN=\"contact-editor\" - -noinst_LIBRARIES = \ - libecontacteditor.a - -libecontacteditor_a_SOURCES = \ - e-contact-editor-categories.c \ - e-contact-editor-categories.h \ - e-contact-editor-fullname.c \ - e-contact-editor-fullname.h \ - e-contact-editor.c \ - e-contact-editor.h \ - e-contact-save-as.c \ - e-contact-save-as.h - -noinst_PROGRAMS = \ - contact-editor-test - -contact_editor_test_SOURCES = \ - test-editor.c - -contact_editor_test_LDADD = \ - libecontacteditor.a \ - $(top_builddir)/e-util/libeutil.la \ - $(top_builddir)/addressbook/backend/ebook/libebook.la \ - $(top_builddir)/addressbook/ename/libename.la \ - $(top_builddir)/libversit/libversit.la \ - $(GNOMEGNORBA_LIBS) \ - $(BONOBO_GNOME_LIBS) \ - $(top_builddir)/widgets/e-table/libetable.a \ - $(top_builddir)/widgets/misc/libemiscwidgets.a \ - $(top_builddir)/e-util/libeutil.la \ - $(top_builddir)/widgets/e-text/libetext.a \ - $(EXTRA_GNOME_LIBS) - -gladedir = $(datadir)/evolution/glade - -glade_DATA = \ - contact-editor.glade \ - fullname.glade \ - categories.glade - -EXTRA_DIST = $(glade_DATA) \ - e-contact-editor-strings.h \ - fullname-strings.h \ - categories-strings.h diff --git a/addressbook/gui/contact-editor/arrow.png b/addressbook/gui/contact-editor/arrow.png deleted file mode 100644 index b102356c78..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/categories-strings.h b/addressbook/gui/contact-editor/categories-strings.h deleted file mode 100644 index 813018a00e..0000000000 --- a/addressbook/gui/contact-editor/categories-strings.h +++ /dev/null @@ -1,9 +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_("categories"); -gchar *s = N_("Item(s) belong to these categories:"); -gchar *s = N_("Available Categories:"); diff --git a/addressbook/gui/contact-editor/categories.glade b/addressbook/gui/contact-editor/categories.glade deleted file mode 100644 index bf78008940..0000000000 --- a/addressbook/gui/contact-editor/categories.glade +++ /dev/null @@ -1,190 +0,0 @@ - - - - - categories - categories - - src - pixmaps - C - True - False - False - False - False - False - False - interface.c - interface.h - callbacks.c - callbacks.h - support.c - support.h - True - categories-strings.h - - - - GnomeDialog - categories - True - False - categories - GTK_WINDOW_TOPLEVEL - GTK_WIN_POS_NONE - False - False - True - False - False - False - - - GtkVBox - GnomeDialog:vbox - dialog-vbox1 - True - False - 8 - - 4 - True - True - - - - GtkTable - table-categories - True - 4 - 1 - False - 0 - 0 - - 0 - True - True - - - - GtkAccelLabel - accellabel1 - True - - GTK_JUSTIFY_LEFT - False - 0 - 0.5 - 0 - 0 - - 0 - 1 - 0 - 1 - 0 - 0 - False - False - False - False - True - True - - - - - GtkAccelLabel - accellabel2 - True - - GTK_JUSTIFY_LEFT - False - 0 - 0.5 - 0 - 0 - - 0 - 1 - 2 - 3 - 0 - 0 - False - False - False - False - True - True - - - - - GtkEntry - entry-categories - True - True - True - True - 0 - - - 0 - 1 - 1 - 2 - 0 - 0 - True - False - False - False - True - False - - - - - - GtkHButtonBox - GnomeDialog:action_area - dialog-action_area1 - True - GTK_BUTTONBOX_END - 8 - 85 - 27 - 7 - 0 - - 0 - False - True - GTK_PACK_END - - - - GtkButton - button1 - True - True - True - GNOME_STOCK_BUTTON_OK - - - - GtkButton - button3 - True - True - True - GNOME_STOCK_BUTTON_CANCEL - - - - - - diff --git a/addressbook/gui/contact-editor/contact-editor.glade b/addressbook/gui/contact-editor/contact-editor.glade deleted file mode 100644 index 7f11886b28..0000000000 --- a/addressbook/gui/contact-editor/contact-editor.glade +++ /dev/null @@ -1,2331 +0,0 @@ - - - - - Contact-editor - contact-editor - - src - pixmaps - C - True - True - True - False - False - False - False - True - e-contact-editor-strings.h - - - - GnomeDialog - dialog2 - 2 - False - GTK_WINDOW_TOPLEVEL - GTK_WIN_POS_NONE - False - False - False - False - False - False - - - GtkVBox - GnomeDialog:vbox - dialog-vbox2 - False - 4 - - 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 - 2 - - 0 - True - True - - - - GtkEntry - entry2 - True - True - True - 0 - - - 0 - 2 - 1 - 2 - 0 - 0 - True - False - False - False - True - False - - - - - GtkVBox - vbox1 - False - 2 - - 1 - 2 - 0 - 1 - 0 - 0 - False - True - False - False - True - True - - - - GtkButton - button31 - 2 - True - - - 0 - False - False - - - - - GtkButton - button32 - 2 - 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 - 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 - True - 0 - - - - - - - - - GnomeApp - contact editor - Contact Editor - GTK_WINDOW_TOPLEVEL - GTK_WIN_POS_NONE - False - False - True - False - True - - - GnomeDock - GnomeApp:dock - dock1 - True - - 0 - True - True - - - - GtkNotebook - GnomeDock:contents - notebook-contact-editor - True - True - True - GTK_POS_TOP - False - 2 - 2 - False - - - GtkTable - table-contact-editor-general - 7 - 14 - 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 - - - - - GtkText - text-address - 1 - 1 - True - True - - - 7 - 8 - 5 - 9 - 0 - 0 - True - False - False - False - True - True - - - - - GtkButton - button-fullname - True - - - 1 - 3 - 0 - 1 - 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 - - - - - GtkAlignment - alignment3 - 1 - 0.5 - 0 - 1 - - 2 - 3 - 5 - 6 - 0 - 0 - False - False - False - False - True - True - - - - GtkButton - button-email1 - - - 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 - - - - - - GtkHSeparator - hseparator4 - - 4 - 8 - 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 - - - - - - GtkEntry - entry-fullname - True - True - True - True - True - 0 - - - 3 - 4 - 0 - 1 - 0 - 0 - True - False - False - False - True - False - - - - - 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 - - - - - GtkEntry - entry-email1 - True - True - True - 0 - - - 3 - 4 - 5 - 6 - 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 - - - - - GtkHSeparator - hseparator5 - - 0 - 4 - 4 - 5 - 0 - 2 - True - False - False - False - True - False - - - - - GtkCombo - combo-file-as - False - True - True - True - False - - - 3 - 4 - 3 - 4 - 0 - 0 - True - False - False - False - True - False - - - - GtkEntry - GtkCombo:entry - entry-file-as - True - True - True - 0 - - - - - - GtkHSeparator - hseparator6 - - 0 - 4 - 7 - 8 - 0 - 2 - True - False - False - False - True - True - - - - - GtkAlignment - alignment10 - 0.5 - 0 - 1 - 1 - - 3 - 4 - 6 - 7 - 0 - 0 - True - False - True - True - True - True - - - - GtkCheckButton - checkbutton-htmlmail - - False - True - - - - - GtkAlignment - alignment4 - 1 - 0.5 - 0 - 0 - - 6 - 7 - 5 - 6 - 0 - 0 - False - False - False - False - True - True - - - - GtkButton - button-address - - - Placeholder - - - - - - GtkLabel - address-label - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - text-address - - 5 - 7 - 6 - 7 - 0 - 0 - False - False - False - False - True - True - - - - - GtkEventBox - eventbox1 - - 5 - 6 - 0 - 1 - 0 - 0 - False - False - False - False - True - True - - - - GtkLabel - label-phone1 - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - entry-phone1 - - - - - GtkEventBox - eventbox2 - - 5 - 6 - 1 - 2 - 0 - 0 - False - False - False - False - True - True - - - - GtkLabel - label-phone2 - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - entry-phone2 - - - - - GtkEventBox - eventbox3 - - 5 - 6 - 2 - 3 - 0 - 0 - False - False - False - False - True - True - - - - GtkLabel - label-phone3 - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - entry-phone3 - - - - - GtkEventBox - eventbox4 - - 5 - 6 - 3 - 4 - 0 - 0 - False - False - False - False - True - True - - - - GtkLabel - label-phone4 - - GTK_JUSTIFY_LEFT - False - 0 - 0.5 - 0 - 0 - entry-phone4 - - - - - GtkEventBox - eventbox5 - - 1 - 2 - 5 - 6 - 0 - 0 - False - False - False - False - True - True - - - - GtkLabel - label-email1 - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - entry-email1 - - - - - GtkEventBox - eventbox-business - - 5 - 6 - 5 - 6 - 0 - 0 - False - False - False - False - True - True - - - - GtkLabel - label-address - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - text-address - - - - - GtkAlignment - alignment2 - 0 - 0 - 0 - 0 - - 7 - 8 - 9 - 10 - 0 - 0 - True - False - False - False - True - True - - - - GtkCheckButton - checkbutton-mailingaddress - - False - True - - - - - GtkHSeparator - hseparator9 - - 0 - 4 - 11 - 12 - 0 - 2 - True - False - False - False - True - True - - - - - GtkHSeparator - hseparator10 - - 4 - 8 - 11 - 12 - 0 - 0 - True - False - False - False - True - True - - - - - GtkAlignment - alignment12 - 0.5 - 0.5 - 1 - 0 - - 1 - 3 - 12 - 13 - 0 - 0 - False - False - False - False - True - True - - - - GtkButton - button-contacts - True - - - - - - GtkAlignment - alignment15 - 0.5 - 0.5 - 1 - 0 - - 7 - 8 - 12 - 13 - 0 - 0 - True - False - False - False - True - True - - - - GtkEntry - entry-categories - True - True - True - 0 - - - - - - GtkAlignment - alignment14 - 0.5 - 0.5 - 1 - 0 - - 3 - 4 - 12 - 13 - 0 - 0 - True - False - False - False - True - True - - - - GtkEntry - entry-contacts - True - True - True - 0 - - - - - - GtkAlignment - alignment16 - 0.5 - 0.5 - 1 - 0 - - 5 - 7 - 12 - 13 - 0 - 0 - False - False - False - False - True - True - - - - GtkButton - button-categories - True - - - - - - GtkEventBox - eventbox7 - - 1 - 3 - 1 - 2 - 0 - 0 - False - False - False - False - True - True - - - - GtkLabel - label34 - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - entry-jobtitle - - - - - Custom - custom1 - e_create_image_widget - malehead.png - - 0 - 0 - Thu, 18 May 2000 12:19:47 GMT - - 0 - 1 - 0 - 4 - 0 - 0 - False - False - False - False - True - True - - - - - Custom - custom2 - e_create_image_widget - cellphone.png - - 0 - 0 - Thu, 18 May 2000 12:20:02 GMT - - 4 - 5 - 0 - 4 - 0 - 0 - False - False - False - False - True - True - - - - - Custom - custom3 - e_create_image_widget - envelope.png - - 0 - 0 - Thu, 18 May 2000 12:19:51 GMT - - 0 - 1 - 5 - 7 - 0 - 0 - False - False - False - False - True - True - - - - - Custom - custom4 - e_create_image_widget - house.png - - 0 - 0 - Thu, 18 May 2000 12:20:06 GMT - - 4 - 5 - 5 - 10 - 0 - 0 - False - False - False - False - True - True - - - - - Custom - custom5 - e_create_image_widget - evolution-contacts.png - - 0 - 0 - Thu, 18 May 2000 12:19:59 GMT - - 0 - 1 - 12 - 14 - 0 - 0 - False - False - False - False - True - True - - - - - Custom - custom6 - e_create_image_widget - briefcase.png - - 0 - 0 - Thu, 18 May 2000 12:20:09 GMT - - 4 - 5 - 12 - 14 - 0 - 0 - False - False - False - False - True - True - - - - - Custom - custom10 - e_create_image_widget - globe.png - - 0 - 0 - Thu, 18 May 2000 12:19:56 GMT - - 0 - 1 - 8 - 10 - 0 - 0 - False - False - False - False - True - True - - - - - GtkLabel - label35 - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - entry-company - - 1 - 3 - 2 - 3 - 0 - 0 - False - False - False - False - True - True - - - - - - GtkLabel - Notebook:tab - label15 - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 0 - 0 - - - - GtkTable - table-contact-editor-details - 7 - 9 - 6 - False - 4 - 4 - - - GtkLabel - label21 - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - entry-department - - 1 - 2 - 0 - 1 - 0 - 0 - False - False - False - False - True - True - - - - - GtkLabel - label22 - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - entry-office - - 1 - 2 - 1 - 2 - 0 - 0 - False - False - False - False - True - True - - - - - GtkLabel - label23 - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - entry-profession - - 1 - 2 - 2 - 3 - 0 - 0 - False - False - False - False - True - True - - - - - GtkLabel - label24 - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - entry-nickname - - 1 - 2 - 4 - 5 - 0 - 0 - False - False - False - False - True - True - - - - - GtkLabel - label25 - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - entry-spouse - - 1 - 2 - 5 - 6 - 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 - entry-assistant - - 3 - 4 - 1 - 2 - 0 - 0 - False - False - False - False - True - True - - - - - GtkLabel - label29 - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - entry-manager - - 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 - entry-spouse - 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 - - - - - 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 - entry-assistant - True - True - True - 0 - - - 4 - 6 - 1 - 2 - 0 - 0 - True - False - False - False - True - False - - - - - GtkEntry - entry-manager - True - True - True - 0 - - - 4 - 6 - 0 - 1 - 0 - 0 - True - False - False - False - True - False - - - - - GtkHSeparator - hseparator7 - - 0 - 6 - 3 - 4 - 0 - 2 - False - False - False - False - True - True - - - - - GtkLabel - label33 - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - - 1 - 2 - 7 - 8 - 0 - 0 - False - False - False - False - True - True - - - - - GtkHSeparator - hseparator8 - - 0 - 6 - 6 - 7 - 0 - 0 - True - False - False - False - True - True - - - - - Custom - custom7 - e_create_image_widget - briefcase.png - - 0 - 0 - Thu, 18 May 2000 12:20:13 GMT - - 0 - 1 - 0 - 2 - 0 - 0 - False - False - False - False - True - True - - - - - Custom - custom8 - e_create_image_widget - malehead.png - - 0 - 0 - Thu, 18 May 2000 12:20:16 GMT - - 0 - 1 - 4 - 6 - 0 - 0 - False - False - False - False - True - True - - - - - GtkScrolledWindow - scrolledwindow2 - GTK_POLICY_AUTOMATIC - GTK_POLICY_AUTOMATIC - GTK_UPDATE_CONTINUOUS - GTK_UPDATE_CONTINUOUS - - 1 - 6 - 8 - 9 - 0 - 0 - True - True - False - False - True - True - - - - GtkText - text-comments - True - True - - - - - - Custom - custom9 - e_create_image_widget - globe.png - - 0 - 0 - Thu, 18 May 2000 12:20:19 GMT - - 0 - 1 - 7 - 9 - 0 - 0 - False - False - False - False - True - True - - - - - - GtkLabel - Notebook:tab - label16 - - GTK_JUSTIFY_CENTER - False - 0.5 - 0.5 - 0 - 0 - - - - - - GnomeAppBar - GnomeApp:appbar - appbar1 - True - True - - 0 - True - True - - - - - diff --git a/addressbook/gui/contact-editor/e-contact-editor-categories.c b/addressbook/gui/contact-editor/e-contact-editor-categories.c deleted file mode 100644 index 03e1265795..0000000000 --- a/addressbook/gui/contact-editor/e-contact-editor-categories.c +++ /dev/null @@ -1,467 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * e-contact-editor-categories.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 -#include -#include -#include - -static void e_contact_editor_categories_init (EContactEditorCategories *card); -static void e_contact_editor_categories_class_init (EContactEditorCategoriesClass *klass); -static void e_contact_editor_categories_set_arg (GtkObject *o, GtkArg *arg, guint arg_id); -static void e_contact_editor_categories_get_arg (GtkObject *object, GtkArg *arg, guint arg_id); -static void e_contact_editor_categories_destroy (GtkObject *object); -static int e_contact_editor_categories_col_count (ETableModel *etc, gpointer data); -static int e_contact_editor_categories_row_count (ETableModel *etc, gpointer data); -static void *e_contact_editor_categories_value_at (ETableModel *etc, int col, int row, gpointer data); -static void e_contact_editor_categories_set_value_at (ETableModel *etc, int col, int row, const void *val, gpointer data); -static gboolean e_contact_editor_categories_is_cell_editable (ETableModel *etc, int col, int row, gpointer data); -static void *e_contact_editor_categories_duplicate_value (ETableModel *etc, int col, const void *value, gpointer data); -static void e_contact_editor_categories_free_value (ETableModel *etc, int col, void *value, gpointer data); -static void *e_contact_editor_categories_initialize_value (ETableModel *etc, int col, gpointer data); -static gboolean e_contact_editor_categories_value_is_empty (ETableModel *etc, int col, const void *value, gpointer data); -static char * e_contact_editor_categories_value_to_string (ETableModel *etc, int col, const void *value, gpointer data); - -static GnomeDialogClass *parent_class = NULL; - -/* The arguments we take */ -enum { - ARG_0, - ARG_CATEGORIES -}; - -GtkType -e_contact_editor_categories_get_type (void) -{ - static GtkType contact_editor_categories_type = 0; - - if (!contact_editor_categories_type) - { - static const GtkTypeInfo contact_editor_categories_info = - { - "EContactEditorCategories", - sizeof (EContactEditorCategories), - sizeof (EContactEditorCategoriesClass), - (GtkClassInitFunc) e_contact_editor_categories_class_init, - (GtkObjectInitFunc) e_contact_editor_categories_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - contact_editor_categories_type = gtk_type_unique (gnome_dialog_get_type (), &contact_editor_categories_info); - } - - return contact_editor_categories_type; -} - -static void -e_contact_editor_categories_class_init (EContactEditorCategoriesClass *klass) -{ - GtkObjectClass *object_class; - GnomeDialogClass *dialog_class; - - object_class = (GtkObjectClass*) klass; - dialog_class = (GnomeDialogClass *) klass; - - parent_class = gtk_type_class (gnome_dialog_get_type ()); - - gtk_object_add_arg_type ("EContactEditorCategories::categories", GTK_TYPE_STRING, - GTK_ARG_READWRITE, ARG_CATEGORIES); - - object_class->set_arg = e_contact_editor_categories_set_arg; - object_class->get_arg = e_contact_editor_categories_get_arg; - object_class->destroy = e_contact_editor_categories_destroy; -} - -gchar *builtin_categories[] = { - "Business", - "Competition", - "Favorites", - "Gifts", - "Goals/Objectives", - "Holiday", - "Holiday Cards", - "Hot Contacts", - "Ideas", - "International", - "Key Customer", - "Miscellaneous", - "Personal", - "Phone Calls", - "Status", - "Strategies", - "Suppliers", - "Time & Expenses", - "VIP", - "Waiting", -}; - -#define BUILTIN_CATEGORY_COUNT (sizeof(builtin_categories) / sizeof(builtin_categories[0])) - -static void -add_list_unique(EContactEditorCategories *categories, char *string) -{ - int k; - char *temp = e_strdup_strip(string); - char **list = categories->category_list; - - if (!*temp) { - g_free(temp); - return; - } - for (k = 0; k < categories->list_length; k++) { - if (!strcmp(list[k], temp)) { - categories->selected_list[k] = TRUE; - break; - } - } - if (k == categories->list_length) { - categories->selected_list[categories->list_length] = TRUE; - list[categories->list_length++] = temp; - } else { - g_free(temp); - } -} - -static void -do_parse_categories(EContactEditorCategories *categories) -{ - char *str = categories->categories; - int length = strlen(str); - char *copy = g_new(char, length + 1); - int i, j; - char **list; - int count = 1; - - for (i = 0; i < categories->list_length; i++) - g_free(categories->category_list[i]); - g_free(categories->category_list); - g_free(categories->selected_list); - - for (i = 0; str[i]; i++) { - switch (str[i]) { - case '\\': - i++; - if (!str[i]) - i--; - break; - case ',': - count ++; - break; - } - } - list = g_new(char *, count + 1 + BUILTIN_CATEGORY_COUNT); - categories->category_list = list; - - categories->selected_list = g_new(gboolean, count + 1 + BUILTIN_CATEGORY_COUNT); - - for (count = 0; count < BUILTIN_CATEGORY_COUNT; count++) { - list[count] = g_strdup(builtin_categories[count]); - categories->selected_list[count] = 0; - } - - categories->list_length = count; - - for (i = 0, j = 0; str[i]; i++, j++) { - switch (str[i]) { - case '\\': - i++; - if (str[i]) { - copy[j] = str[i]; - } else - i--; - break; - case ',': - copy[j] = 0; - add_list_unique(categories, copy); - j = -1; - break; - default: - copy[j] = str[i]; - break; - } - } - copy[j] = 0; - add_list_unique(categories, copy); - g_free(copy); - e_table_model_changed(categories->model); -} - -static void -e_contact_editor_categories_entry_change (GtkWidget *entry, - EContactEditorCategories *categories) -{ - g_free(categories->categories); - categories->categories = g_strdup(gtk_entry_get_text(GTK_ENTRY(entry))); - do_parse_categories(categories); -} - - -#define INITIAL_SPEC " \ - \ - 0 \ - 1 \ - \ - \ -" - -static void -e_contact_editor_categories_init (EContactEditorCategories *categories) -{ - GladeXML *gui; - GtkWidget *table; - ECell *cell_left_just; - ECell *cell_checkbox; - ETableHeader *header; - ETableCol *col; - GtkWidget *e_table; - - categories->list_length = 0; - categories->category_list = NULL; - categories->selected_list = NULL; - categories->categories = NULL; - - gnome_dialog_append_button ( GNOME_DIALOG(categories), - GNOME_STOCK_BUTTON_OK); - - gnome_dialog_append_button ( GNOME_DIALOG(categories), - GNOME_STOCK_BUTTON_CANCEL); - - gtk_window_set_policy(GTK_WINDOW(categories), FALSE, TRUE, FALSE); - - gui = glade_xml_new (EVOLUTION_GLADEDIR "/categories.glade", NULL); - categories->gui = gui; - - table = glade_xml_get_widget(gui, "table-categories"); - gtk_widget_ref(table); - gtk_container_remove(GTK_CONTAINER(table->parent), table); - gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (categories)->vbox), table, TRUE, TRUE, 0); - gtk_widget_unref(table); - - categories->entry = glade_xml_get_widget(gui, "entry-categories"); - - gtk_signal_connect(GTK_OBJECT(categories->entry), "changed", - GTK_SIGNAL_FUNC(e_contact_editor_categories_entry_change), categories); - - categories->model = e_table_simple_new(e_contact_editor_categories_col_count, - e_contact_editor_categories_row_count, - e_contact_editor_categories_value_at, - e_contact_editor_categories_set_value_at, - e_contact_editor_categories_is_cell_editable, - e_contact_editor_categories_duplicate_value, - e_contact_editor_categories_free_value, - e_contact_editor_categories_initialize_value, - e_contact_editor_categories_value_is_empty, - e_contact_editor_categories_value_to_string, - categories); - - header = e_table_header_new(); - - cell_checkbox = e_cell_checkbox_new(); - col = e_table_col_new (0, "", - 0, 20, cell_checkbox, - g_int_compare, TRUE); - e_table_header_add_column (header, col, 0); - - cell_left_just = e_cell_text_new (categories->model, NULL, GTK_JUSTIFY_LEFT); - col = e_table_col_new (1, "Category", - 1.0, 20, cell_left_just, - g_str_compare, TRUE); - e_table_header_add_column (header, col, 1); - - e_table = e_table_new (header, categories->model, INITIAL_SPEC); - - gtk_object_sink(GTK_OBJECT(categories->model)); - - gtk_widget_show(e_table); - - gtk_table_attach_defaults(GTK_TABLE(table), - e_table, - 0, 1, - 3, 4); -} - -void -e_contact_editor_categories_destroy (GtkObject *object) -{ - EContactEditorCategories *categories = E_CONTACT_EDITOR_CATEGORIES(object); - int i; - - if (categories->gui) - gtk_object_unref(GTK_OBJECT(categories->gui)); - - g_free(categories->categories); - for (i = 0; i < categories->list_length; i++) - g_free(categories->category_list[i]); - g_free(categories->category_list); - g_free(categories->selected_list); -} - -GtkWidget* -e_contact_editor_categories_new (char *categories) -{ - GtkWidget *widget = GTK_WIDGET (gtk_type_new (e_contact_editor_categories_get_type ())); - gtk_object_set (GTK_OBJECT(widget), - "categories", categories, - NULL); - return widget; -} - -static void -e_contact_editor_categories_set_arg (GtkObject *o, GtkArg *arg, guint arg_id) -{ - EContactEditorCategories *e_contact_editor_categories; - - e_contact_editor_categories = E_CONTACT_EDITOR_CATEGORIES (o); - - switch (arg_id){ - case ARG_CATEGORIES: - gtk_entry_set_text(GTK_ENTRY(e_contact_editor_categories->entry), GTK_VALUE_STRING (*arg)); - break; - } -} - -static void -e_contact_editor_categories_get_arg (GtkObject *object, GtkArg *arg, guint arg_id) -{ - EContactEditorCategories *e_contact_editor_categories; - - e_contact_editor_categories = E_CONTACT_EDITOR_CATEGORIES (object); - - switch (arg_id) { - case ARG_CATEGORIES: - GTK_VALUE_STRING (*arg) = g_strdup(e_contact_editor_categories->categories); - break; - default: - arg->type = GTK_TYPE_INVALID; - break; - } -} - -/* This function returns the number of columns in our ETableModel. */ -static int -e_contact_editor_categories_col_count (ETableModel *etc, gpointer data) -{ - return 2; -} - -/* This function returns the number of rows in our ETableModel. */ -static int -e_contact_editor_categories_row_count (ETableModel *etc, gpointer data) -{ - EContactEditorCategories *categories = E_CONTACT_EDITOR_CATEGORIES(data); - return categories->list_length; -} - -/* This function returns the value at a particular point in our ETableModel. */ -static void * -e_contact_editor_categories_value_at (ETableModel *etc, int col, int row, gpointer data) -{ - EContactEditorCategories *categories = E_CONTACT_EDITOR_CATEGORIES(data); - if (col == 0) - return (void *) categories->selected_list[row]; - else - return categories->category_list[row]; -} - -/* This function sets the value at a particular point in our ETableModel. */ -static void -e_contact_editor_categories_set_value_at (ETableModel *etc, int col, int row, const void *val, gpointer data) -{ - EContactEditorCategories *categories = E_CONTACT_EDITOR_CATEGORIES(data); - if ( col == 0 ) { - char **strs; - int i, j; - char *string; - categories->selected_list[row] = (gboolean) val; - strs = g_new(char *, categories->list_length + 1); - for (i = 0, j = 0; i < categories->list_length; i++) { - if (categories->selected_list[i]) - strs[j++] = categories->category_list[i]; - } - strs[j] = 0; - string = g_strjoinv(", ", strs); - gtk_entry_set_text(GTK_ENTRY(categories->entry), string); - g_free(string); - g_free(strs); - } - if ( col == 1 ) - return; -} - -/* This function returns whether a particular cell is editable. */ -static gboolean -e_contact_editor_categories_is_cell_editable (ETableModel *etc, int col, int row, gpointer data) -{ - return col == 0; -} - -/* This function duplicates the value passed to it. */ -static void * -e_contact_editor_categories_duplicate_value (ETableModel *etc, int col, const void *value, gpointer data) -{ - if (col == 0) - return (void *)value; - else - return g_strdup(value); -} - -/* This function frees the value passed to it. */ -static void -e_contact_editor_categories_free_value (ETableModel *etc, int col, void *value, gpointer data) -{ - if (col == 0) - return; - else - g_free(value); -} - -static void * -e_contact_editor_categories_initialize_value (ETableModel *etc, int col, gpointer data) -{ - if (col == 0) - return NULL; - else - return g_strdup(""); -} - -static gboolean -e_contact_editor_categories_value_is_empty (ETableModel *etc, int col, const void *value, gpointer data) -{ - if (col == 0) - return value == NULL; - else - return !(value && *(char *)value); -} - -static char * -e_contact_editor_categories_value_to_string (ETableModel *etc, int col, const void *value, gpointer data) -{ - if (col == 0) - return g_strdup_printf("%d", (int) value); - else - return g_strdup(value); -} diff --git a/addressbook/gui/contact-editor/e-contact-editor-categories.h b/addressbook/gui/contact-editor/e-contact-editor-categories.h deleted file mode 100644 index 529ef71b68..0000000000 --- a/addressbook/gui/contact-editor/e-contact-editor-categories.h +++ /dev/null @@ -1,83 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* e-contact-editor-categories.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_CATEGORIES_H__ -#define __E_CONTACT_EDITOR_CATEGORIES_H__ - -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - -/* EContactEditorCategories - A dialog displaying information about a contact. - * - * The following arguments are available: - * - * name type read/write description - * -------------------------------------------------------------------------------- - * name ECardName * RW The card currently being edited. Returns a copy. - */ - -#define E_CONTACT_EDITOR_CATEGORIES_TYPE (e_contact_editor_categories_get_type ()) -#define E_CONTACT_EDITOR_CATEGORIES(obj) (GTK_CHECK_CAST ((obj), E_CONTACT_EDITOR_CATEGORIES_TYPE, EContactEditorCategories)) -#define E_CONTACT_EDITOR_CATEGORIES_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_CONTACT_EDITOR_CATEGORIES_TYPE, EContactEditorCategoriesClass)) -#define E_IS_CONTACT_EDITOR_CATEGORIES(obj) (GTK_CHECK_TYPE ((obj), E_CONTACT_EDITOR_CATEGORIES_TYPE)) -#define E_IS_CONTACT_EDITOR_CATEGORIES_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), E_CONTACT_EDITOR_CATEGORIES_TYPE)) - - -typedef struct _EContactEditorCategories EContactEditorCategories; -typedef struct _EContactEditorCategoriesClass EContactEditorCategoriesClass; - -struct _EContactEditorCategories -{ - GnomeDialog parent; - - /* item specific fields */ - char *categories; - GtkWidget *entry; - ETableModel *model; - - int list_length; - char **category_list; - gboolean *selected_list; - - GladeXML *gui; -}; - -struct _EContactEditorCategoriesClass -{ - GnomeDialogClass parent_class; -}; - - -GtkWidget *e_contact_editor_categories_new(char *categories); -GtkType e_contact_editor_categories_get_type (void); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - - -#endif /* __E_CONTACT_EDITOR_CATEGORIES_H__ */ diff --git a/addressbook/gui/contact-editor/e-contact-editor-fullname.c b/addressbook/gui/contact-editor/e-contact-editor-fullname.c deleted file mode 100644 index b2e598fdde..0000000000 --- a/addressbook/gui/contact-editor/e-contact-editor-fullname.c +++ /dev/null @@ -1,214 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * e-contact-editor-fullname.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 - -static void e_contact_editor_fullname_init (EContactEditorFullname *card); -static void e_contact_editor_fullname_class_init (EContactEditorFullnameClass *klass); -static void e_contact_editor_fullname_set_arg (GtkObject *o, GtkArg *arg, guint arg_id); -static void e_contact_editor_fullname_get_arg (GtkObject *object, GtkArg *arg, guint arg_id); -static void e_contact_editor_fullname_destroy (GtkObject *object); - -static void fill_in_info(EContactEditorFullname *editor); -static void extract_info(EContactEditorFullname *editor); - -static GnomeDialogClass *parent_class = NULL; - -/* The arguments we take */ -enum { - ARG_0, - ARG_NAME -}; - -GtkType -e_contact_editor_fullname_get_type (void) -{ - static GtkType contact_editor_fullname_type = 0; - - if (!contact_editor_fullname_type) - { - static const GtkTypeInfo contact_editor_fullname_info = - { - "EContactEditorFullname", - sizeof (EContactEditorFullname), - sizeof (EContactEditorFullnameClass), - (GtkClassInitFunc) e_contact_editor_fullname_class_init, - (GtkObjectInitFunc) e_contact_editor_fullname_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - contact_editor_fullname_type = gtk_type_unique (gnome_dialog_get_type (), &contact_editor_fullname_info); - } - - return contact_editor_fullname_type; -} - -static void -e_contact_editor_fullname_class_init (EContactEditorFullnameClass *klass) -{ - GtkObjectClass *object_class; - GnomeDialogClass *dialog_class; - - object_class = (GtkObjectClass*) klass; - dialog_class = (GnomeDialogClass *) klass; - - parent_class = gtk_type_class (gnome_dialog_get_type ()); - - gtk_object_add_arg_type ("EContactEditorFullname::name", GTK_TYPE_POINTER, - GTK_ARG_READWRITE, ARG_NAME); - - object_class->set_arg = e_contact_editor_fullname_set_arg; - object_class->get_arg = e_contact_editor_fullname_get_arg; - object_class->destroy = e_contact_editor_fullname_destroy; -} - -static void -e_contact_editor_fullname_init (EContactEditorFullname *e_contact_editor_fullname) -{ - GladeXML *gui; - GtkWidget *widget; - - gnome_dialog_append_button ( GNOME_DIALOG(e_contact_editor_fullname), - GNOME_STOCK_BUTTON_OK); - - gnome_dialog_append_button ( GNOME_DIALOG(e_contact_editor_fullname), - GNOME_STOCK_BUTTON_CANCEL); - - gtk_window_set_policy(GTK_WINDOW(e_contact_editor_fullname), TRUE, TRUE, FALSE); - - e_contact_editor_fullname->name = NULL; - gui = glade_xml_new (EVOLUTION_GLADEDIR "/fullname.glade", NULL); - e_contact_editor_fullname->gui = gui; - - widget = glade_xml_get_widget(gui, "table-checkfullname"); - gtk_widget_ref(widget); - gtk_container_remove(GTK_CONTAINER(widget->parent), widget); - gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (e_contact_editor_fullname)->vbox), widget, TRUE, TRUE, 0); - gtk_widget_unref(widget); -} - -void -e_contact_editor_fullname_destroy (GtkObject *object) -{ - EContactEditorFullname *e_contact_editor_fullname = E_CONTACT_EDITOR_FULLNAME(object); - - if (e_contact_editor_fullname->gui) - gtk_object_unref(GTK_OBJECT(e_contact_editor_fullname->gui)); - e_card_name_free(e_contact_editor_fullname->name); -} - -GtkWidget* -e_contact_editor_fullname_new (ECardName *name) -{ - GtkWidget *widget = GTK_WIDGET (gtk_type_new (e_contact_editor_fullname_get_type ())); - gtk_object_set (GTK_OBJECT(widget), - "name", name, - NULL); - return widget; -} - -static void -e_contact_editor_fullname_set_arg (GtkObject *o, GtkArg *arg, guint arg_id) -{ - EContactEditorFullname *e_contact_editor_fullname; - - e_contact_editor_fullname = E_CONTACT_EDITOR_FULLNAME (o); - - switch (arg_id){ - case ARG_NAME: - if (e_contact_editor_fullname->name) - e_card_name_free(e_contact_editor_fullname->name); - e_contact_editor_fullname->name = e_card_name_copy(GTK_VALUE_POINTER (*arg)); - fill_in_info(e_contact_editor_fullname); - break; - } -} - -static void -e_contact_editor_fullname_get_arg (GtkObject *object, GtkArg *arg, guint arg_id) -{ - EContactEditorFullname *e_contact_editor_fullname; - - e_contact_editor_fullname = E_CONTACT_EDITOR_FULLNAME (object); - - switch (arg_id) { - case ARG_NAME: - extract_info(e_contact_editor_fullname); - GTK_VALUE_POINTER (*arg) = e_card_name_copy(e_contact_editor_fullname->name); - break; - default: - arg->type = GTK_TYPE_INVALID; - break; - } -} - -static void -fill_in_field(EContactEditorFullname *editor, char *field, char *string) -{ - GtkEntry *entry = GTK_ENTRY(glade_xml_get_widget(editor->gui, field)); - if (entry) { - if (string) - gtk_entry_set_text(entry, string); - else - gtk_entry_set_text(entry, ""); - } -} - -static void -fill_in_info(EContactEditorFullname *editor) -{ - ECardName *name = editor->name; - if (name) { - fill_in_field(editor, "entry-title", name->prefix); - fill_in_field(editor, "entry-first", name->given); - fill_in_field(editor, "entry-middle", name->additional); - fill_in_field(editor, "entry-last", name->family); - fill_in_field(editor, "entry-suffix", name->suffix); - } -} - -static char * -extract_field(EContactEditorFullname *editor, char *field) -{ - GtkEntry *entry = GTK_ENTRY(glade_xml_get_widget(editor->gui, field)); - if (entry) - return g_strdup(gtk_entry_get_text(entry)); - else - return NULL; -} - -static void -extract_info(EContactEditorFullname *editor) -{ - ECardName *name = editor->name; - if (!name) - name = e_card_name_new(); - name->prefix = extract_field(editor, "entry-title" ); - name->given = extract_field(editor, "entry-first" ); - name->additional = extract_field(editor, "entry-middle"); - name->family = extract_field(editor, "entry-last" ); - name->suffix = extract_field(editor, "entry-suffix"); -} diff --git a/addressbook/gui/contact-editor/e-contact-editor-fullname.h b/addressbook/gui/contact-editor/e-contact-editor-fullname.h deleted file mode 100644 index 409ffc72d0..0000000000 --- a/addressbook/gui/contact-editor/e-contact-editor-fullname.h +++ /dev/null @@ -1,75 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* e-contact-editor-fullname.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_FULLNAME_H__ -#define __E_CONTACT_EDITOR_FULLNAME_H__ - -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - -/* EContactEditorFullname - A dialog displaying information about a contact. - * - * The following arguments are available: - * - * name type read/write description - * -------------------------------------------------------------------------------- - * name ECardName * RW The card currently being edited. Returns a copy. - */ - -#define E_CONTACT_EDITOR_FULLNAME_TYPE (e_contact_editor_fullname_get_type ()) -#define E_CONTACT_EDITOR_FULLNAME(obj) (GTK_CHECK_CAST ((obj), E_CONTACT_EDITOR_FULLNAME_TYPE, EContactEditorFullname)) -#define E_CONTACT_EDITOR_FULLNAME_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_CONTACT_EDITOR_FULLNAME_TYPE, EContactEditorFullnameClass)) -#define E_IS_CONTACT_EDITOR_FULLNAME(obj) (GTK_CHECK_TYPE ((obj), E_CONTACT_EDITOR_FULLNAME_TYPE)) -#define E_IS_CONTACT_EDITOR_FULLNAME_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), E_CONTACT_EDITOR_FULLNAME_TYPE)) - - -typedef struct _EContactEditorFullname EContactEditorFullname; -typedef struct _EContactEditorFullnameClass EContactEditorFullnameClass; - -struct _EContactEditorFullname -{ - GnomeDialog parent; - - /* item specific fields */ - ECardName *name; - GladeXML *gui; -}; - -struct _EContactEditorFullnameClass -{ - GnomeDialogClass parent_class; -}; - - -GtkWidget *e_contact_editor_fullname_new(ECardName *name); -GtkType e_contact_editor_fullname_get_type (void); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - - -#endif /* __E_CONTACT_EDITOR_FULLNAME_H__ */ 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 d5ac9daf24..0000000000 --- a/addressbook/gui/contact-editor/e-contact-editor-strings.h +++ /dev/null @@ -1,41 +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_("_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"); -gchar *s = N_("Contact Editor"); -gchar *s = N_("_Full Name..."); -gchar *s = N_("File As:"); -gchar *s = N_("Web page address:"); -gchar *s = N_("Wants to receive _HTML mail"); -gchar *s = N_("Address:"); -gchar *s = N_("_Business"); -gchar *s = N_("_Home"); -gchar *s = N_("Business _Fax"); -gchar *s = N_("_Mobile"); -gchar *s = N_("Primary Email"); -gchar *s = N_("B_usiness"); -gchar *s = N_("_This is the mailing address"); -gchar *s = N_("C_ontacts..."); -gchar *s = N_("Ca_tegories..."); -gchar *s = N_("_Job title:"); -gchar *s = N_("_Company:"); -gchar *s = N_("General"); -gchar *s = N_("_Department:"); -gchar *s = N_("_Office:"); -gchar *s = N_("_Profession:"); -gchar *s = N_("_Nickname:"); -gchar *s = N_("_Spouse:"); -gchar *s = N_("_Birthday:"); -gchar *s = N_("_Assistant's name:"); -gchar *s = N_("_Manager's Name:"); -gchar *s = N_("Anni_versary:"); -gchar *s = N_("No_tes:"); -gchar *s = N_("Details"); 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 cedd798edf..0000000000 --- a/addressbook/gui/contact-editor/e-contact-editor.c +++ /dev/null @@ -1,1702 +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" -#include -#include -#include -#include -#include -#include - -/* Signal IDs */ -enum { - ADD_CARD, - COMMIT_CARD, - EDITOR_CLOSED, - LAST_SIGNAL -}; - -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); - -#if 0 -static GtkWidget *e_contact_editor_build_dialog(EContactEditor *editor, gchar *entry_id, gchar *label_id, gchar *title, GList **list, GnomeUIInfo **info); -#endif -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 void set_fields(EContactEditor *editor); -static void set_address_field(EContactEditor *editor, int result); -static void add_field_callback(GtkWidget *widget, EContactEditor *editor); - -static GtkObjectClass *parent_class = NULL; - -static guint contact_editor_signals[LAST_SIGNAL]; - -/* The arguments we take */ -enum { - ARG_0, - ARG_CARD, - ARG_IS_NEW_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_TYPE_OBJECT, &contact_editor_info); - } - - return contact_editor_type; -} - -static void -e_contact_editor_class_init (EContactEditorClass *klass) -{ - GtkObjectClass *object_class; - - object_class = (GtkObjectClass*) klass; - - parent_class = gtk_type_class (GTK_TYPE_OBJECT); - - gtk_object_add_arg_type ("EContactEditor::card", GTK_TYPE_OBJECT, - GTK_ARG_READWRITE, ARG_CARD); - gtk_object_add_arg_type ("EContactEditor::is_new_card", GTK_TYPE_BOOL, - GTK_ARG_READWRITE, ARG_IS_NEW_CARD); - - contact_editor_signals[ADD_CARD] = - gtk_signal_new ("add_card", - GTK_RUN_FIRST, - object_class->type, - GTK_SIGNAL_OFFSET (EContactEditorClass, add_card), - gtk_marshal_NONE__OBJECT, - GTK_TYPE_NONE, 1, - GTK_TYPE_OBJECT); - - contact_editor_signals[COMMIT_CARD] = - gtk_signal_new ("commit_card", - GTK_RUN_FIRST, - object_class->type, - GTK_SIGNAL_OFFSET (EContactEditorClass, commit_card), - gtk_marshal_NONE__OBJECT, - GTK_TYPE_NONE, 1, - GTK_TYPE_OBJECT); - - contact_editor_signals[EDITOR_CLOSED] = - gtk_signal_new ("editor_closed", - GTK_RUN_FIRST, - object_class->type, - GTK_SIGNAL_OFFSET (EContactEditorClass, editor_closed), - gtk_marshal_NONE__NONE, - GTK_TYPE_NONE, 0); - - gtk_object_class_add_signals (object_class, contact_editor_signals, LAST_SIGNAL); - - 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 -_replace_button(EContactEditor *editor, gchar *button_xml, gchar *image, GtkSignalFunc func) -{ - GladeXML *gui = editor->gui; - GtkWidget *button = glade_xml_get_widget(gui, button_xml); - GtkWidget *pixmap; - gchar *image_temp; - if (button && GTK_IS_BUTTON(button)) { - image_temp = g_strdup_printf("%s%s", DATADIR "/evolution/", image); - pixmap = e_create_image_widget(NULL, image_temp, NULL, 0, 0); - gtk_container_add(GTK_CONTAINER(button), - pixmap); - g_free(image_temp); - gtk_widget_show(pixmap); - 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-address", "arrow.png", _address_arrow_pressed); - _replace_button(editor, "button-email1", "arrow.png", _email_arrow_pressed); -} - -static void -phone_entry_changed (GtkWidget *widget, EContactEditor *editor) -{ - int which; - gchar *string; - GtkEntry *entry = GTK_ENTRY(widget); - ECardPhone *phone; - - if ( widget == glade_xml_get_widget(editor->gui, "entry-phone1") ) { - which = 1; - } else if ( widget == glade_xml_get_widget(editor->gui, "entry-phone2") ) { - which = 2; - } else if ( widget == glade_xml_get_widget(editor->gui, "entry-phone3") ) { - which = 3; - } else if ( widget == glade_xml_get_widget(editor->gui, "entry-phone4") ) { - which = 4; - } else - return; - string = gtk_entry_get_text(entry); - phone = e_card_phone_new(); - phone->number = string; - e_card_simple_set_phone(editor->simple, editor->phone_choice[which - 1], phone); - phone->number = NULL; - e_card_phone_free(phone); - set_fields(editor); -} - -static void -email_entry_changed (GtkWidget *widget, EContactEditor *editor) -{ - gchar *string; - GtkEntry *entry = GTK_ENTRY(widget); - - string = gtk_entry_get_text(entry); - - e_card_simple_set_email(editor->simple, editor->email_choice, string); -} - -static void -address_text_changed (GtkWidget *widget, EContactEditor *editor) -{ - GtkEditable *editable = GTK_EDITABLE(widget); - ECardAddrLabel *address; - - if (editor->address_choice == -1) - return; - - address = e_card_address_label_new(); - address->data = gtk_editable_get_chars(editable, 0, -1); - e_card_simple_set_address(editor->simple, editor->address_choice, address); - e_card_address_label_free(address); -} - -/* This function tells you whether name_to_style will make sense. */ -static gboolean -style_makes_sense(const ECardName *name, char *company, int style) -{ - switch (style) { - case 0: /* Fall Through */ - case 1: - return TRUE; - case 2: - if (company && *company) - return TRUE; - else - return FALSE; - case 3: /* Fall Through */ - case 4: - if (company && *company && ((name->given && *name->given) || (name->family && *name->family))) - return TRUE; - else - return FALSE; - default: - return FALSE; - } -} - -static char * -name_to_style(const ECardName *name, char *company, int style) -{ - char *string; - char *strings[4], **stringptr; - char *substring; - switch (style) { - case 0: - stringptr = strings; - if (name->family && *name->family) - *(stringptr++) = name->family; - if (name->given && *name->given) - *(stringptr++) = name->given; - *stringptr = NULL; - string = g_strjoinv(", ", strings); - break; - case 1: - stringptr = strings; - if (name->given && *name->given) - *(stringptr++) = name->given; - if (name->family && *name->family) - *(stringptr++) = name->family; - *stringptr = NULL; - string = g_strjoinv(" ", strings); - break; - case 2: - string = g_strdup(company); - break; - case 3: /* Fall Through */ - case 4: - stringptr = strings; - if (name->family && *name->family) - *(stringptr++) = name->family; - if (name->given && *name->given) - *(stringptr++) = name->given; - *stringptr = NULL; - substring = g_strjoinv(", ", strings); - if (!(company && *company)) - company = ""; - if (style == 3) - string = g_strdup_printf("%s (%s)", substring, company); - else - string = g_strdup_printf("%s (%s)", company, substring); - g_free(substring); - break; - default: - string = g_strdup(""); - } - return string; -} - -static int -file_as_get_style (EContactEditor *editor) -{ - GtkEntry *file_as = GTK_ENTRY(glade_xml_get_widget(editor->gui, "entry-file-as")); - char *filestring = gtk_entry_get_text(file_as); - char *trystring; - ECardName *name = editor->name; - int i; - int style; - - if (!name) return 0; - - style = -1; - for (i = 0; i < 5; i++) { - trystring = name_to_style(name, editor->company, i); - if (!strcmp(trystring, filestring)) { - g_free(trystring); - return i; - } - g_free(trystring); - } - return -1; -} - -static void -file_as_set_style(EContactEditor *editor, int style) -{ - char *string; - int i; - GList *strings = NULL; - GtkEntry *file_as = GTK_ENTRY(glade_xml_get_widget(editor->gui, "entry-file-as")); - GtkWidget *widget; - - - if (style == -1) { - string = g_strdup(gtk_entry_get_text(file_as)); - strings = g_list_append(strings, string); - } - - for (i = 0; i < 5; i++) { - if (style_makes_sense(editor->name, editor->company, i)) { - string = name_to_style(editor->name, editor->company, i); - strings = g_list_append(strings, string); - } - } - - widget = glade_xml_get_widget(editor->gui, "combo-file-as"); - if (widget && GTK_IS_COMBO(widget)) { - GtkCombo *combo = GTK_COMBO(widget); - gtk_combo_set_popdown_strings(combo, strings); - g_list_foreach(strings, (GFunc) g_free, NULL); - g_list_free(strings); - } - - if (style != -1) { - string = name_to_style(editor->name, editor->company, style); - gtk_entry_set_text(file_as, string); - g_free(string); - } -} - -static void -name_entry_changed (GtkWidget *widget, EContactEditor *editor) -{ - GtkWidget *file_as; - int style = 0; - - file_as = glade_xml_get_widget(editor->gui, "entry-file-as"); - - if (file_as && GTK_IS_ENTRY(file_as)) { - style = file_as_get_style(editor); - } - - e_card_name_free(editor->name); - editor->name = e_card_name_from_string(gtk_entry_get_text(GTK_ENTRY(widget))); - - if (file_as && GTK_IS_ENTRY(file_as)) { - file_as_set_style(editor, style); - } -} - -static void -company_entry_changed (GtkWidget *widget, EContactEditor *editor) -{ - int style = 0; - GtkWidget *file_as; - - file_as = glade_xml_get_widget(editor->gui, "entry-file-as"); - - if (file_as && GTK_IS_ENTRY(file_as)) { - style = file_as_get_style(editor); - } - - g_free(editor->company); - - editor->company = g_strdup(gtk_entry_get_text(GTK_ENTRY(widget))); - - if (file_as && GTK_IS_ENTRY(file_as)) { - file_as_set_style(editor, style); - } -} - -static void -set_entry_changed_signal_phone(EContactEditor *editor, char *id) -{ - GtkWidget *widget = glade_xml_get_widget(editor->gui, id); - if (widget && GTK_IS_ENTRY(widget)) - gtk_signal_connect(GTK_OBJECT(widget), "changed", - phone_entry_changed, editor); -} - -static void -set_entry_changed_signals(EContactEditor *editor) -{ - GtkWidget *widget; - set_entry_changed_signal_phone(editor, "entry-phone1"); - set_entry_changed_signal_phone(editor, "entry-phone2"); - set_entry_changed_signal_phone(editor, "entry-phone3"); - set_entry_changed_signal_phone(editor, "entry-phone4"); - widget = glade_xml_get_widget(editor->gui, "entry-email1"); - if (widget && GTK_IS_ENTRY(widget)) { - gtk_signal_connect(GTK_OBJECT(widget), "changed", - email_entry_changed, editor); - } - widget = glade_xml_get_widget(editor->gui, "text-address"); - if (widget && GTK_IS_TEXT(widget)) { - gtk_signal_connect(GTK_OBJECT(widget), "changed", - address_text_changed, editor); - } - widget = glade_xml_get_widget(editor->gui, "entry-fullname"); - if (widget && GTK_IS_ENTRY(widget)) { - gtk_signal_connect(GTK_OBJECT(widget), "changed", - name_entry_changed, editor); - } - widget = glade_xml_get_widget(editor->gui, "entry-company"); - if (widget && GTK_IS_ENTRY(widget)) { - gtk_signal_connect(GTK_OBJECT(widget), "changed", - company_entry_changed, editor); - } -} - -static void -full_name_clicked(GtkWidget *button, EContactEditor *editor) -{ - GnomeDialog *dialog = GNOME_DIALOG(e_contact_editor_fullname_new(editor->name)); - int result; - gtk_widget_show(GTK_WIDGET(dialog)); - result = gnome_dialog_run_and_close (dialog); - if (result == 0) { - ECardName *name; - GtkWidget *fname_widget; - - gtk_object_get(GTK_OBJECT(dialog), - "name", &name, - NULL); - e_card_name_free(editor->name); - editor->name = e_card_name_copy(name); - - fname_widget = glade_xml_get_widget(editor->gui, "entry-fullname"); - if (fname_widget && GTK_IS_ENTRY(fname_widget)) { - char *full_name = e_card_name_to_string(name); - gtk_entry_set_text(GTK_ENTRY(fname_widget), full_name); - g_free(full_name); - } - } - gtk_object_unref(GTK_OBJECT(dialog)); -} - -static void -categories_clicked(GtkWidget *button, EContactEditor *editor) -{ - char *categories; - GnomeDialog *dialog; - int result; - GtkWidget *entry = glade_xml_get_widget(editor->gui, "entry-categories"); - if (entry && GTK_IS_ENTRY(entry)) - categories = gtk_entry_get_text(GTK_ENTRY(entry)); - else if (editor->card) - gtk_object_get(GTK_OBJECT(editor->card), - "categories", &categories, - NULL); - dialog = GNOME_DIALOG(e_contact_editor_categories_new(categories)); - gtk_widget_show(GTK_WIDGET(dialog)); - result = gnome_dialog_run (dialog); - if (result == 0) { - gtk_object_get(GTK_OBJECT(dialog), - "categories", &categories, - NULL); - if (entry && GTK_IS_ENTRY(entry)) - gtk_entry_set_text(GTK_ENTRY(entry), categories); - else - gtk_object_set(GTK_OBJECT(editor->card), - "categories", categories, - NULL); - g_free(categories); - } - gtk_object_destroy(GTK_OBJECT(dialog)); - if (!entry) - g_free(categories); -} - -/* Emits the signal to request saving a card */ -static void -save_card (EContactEditor *ce) -{ - extract_info (ce); - e_card_simple_sync_card (ce->simple); - - if (ce->is_new_card) - gtk_signal_emit (GTK_OBJECT (ce), contact_editor_signals[ADD_CARD], - ce->card); - else - gtk_signal_emit (GTK_OBJECT (ce), contact_editor_signals[COMMIT_CARD], - ce->card); - - /* FIXME: should we set the ce->is_new_card here or have the client code - * set the "is_new_card" argument on the contact editor object? - */ - - ce->is_new_card = FALSE; -} - -/* Closes the dialog box and emits the appropriate signals */ -static void -close_dialog (EContactEditor *ce) -{ - g_assert (ce->app != NULL); - - gtk_widget_destroy (ce->app); - ce->app = NULL; - - gtk_signal_emit (GTK_OBJECT (ce), contact_editor_signals[EDITOR_CLOSED]); -} - -/* Menu callbacks */ - -/* File/Save callback */ -static void -file_save_cb (GtkWidget *widget, gpointer data) -{ - EContactEditor *ce; - - ce = E_CONTACT_EDITOR (data); - save_card (ce); -} - -/* File/Close callback */ -static void -file_close_cb (GtkWidget *widget, gpointer data) -{ - EContactEditor *ce; - - ce = E_CONTACT_EDITOR (data); - close_dialog (ce); -} - -static void -file_save_as_cb (GtkWidget *widget, gpointer data) -{ - EContactEditor *ce; - ECard *card; - - ce = E_CONTACT_EDITOR (data); - - extract_info (ce); - e_card_simple_sync_card (ce->simple); - - card = ce->card; - e_contact_save_as("Save as VCard", card); -} - -/* Menu bar */ - -static GnomeUIInfo file_new_menu[] = { - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Appointment"), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Meeting Re_quest"), NULL, NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Mail Message"), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Contact"), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Task"), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Task _Request"), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Journal Entry"), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Note"), NULL, NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Ch_oose Form..."), NULL, NULL), - GNOMEUIINFO_END -}; - -static GnomeUIInfo file_page_setup_menu[] = { - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Memo Style"), NULL, NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Define Print _Styles..."), NULL, NULL), - GNOMEUIINFO_END -}; - -static GnomeUIInfo file_menu[] = { - GNOMEUIINFO_MENU_NEW_SUBTREE (file_new_menu), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_ITEM_NONE (N_("FIXME: S_end"), NULL, NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_MENU_SAVE_ITEM (file_save_cb, NULL), - GNOMEUIINFO_MENU_SAVE_AS_ITEM (file_save_as_cb, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Save Attac_hments..."), NULL, NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Delete"), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Move to Folder..."), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Cop_y to Folder..."), NULL, NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_SUBTREE (N_("Page Set_up"), file_page_setup_menu), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Print Pre_view"), NULL, NULL), - GNOMEUIINFO_MENU_PRINT_ITEM (NULL, NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_MENU_PROPERTIES_ITEM (NULL, NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_MENU_CLOSE_ITEM (file_close_cb, NULL), - GNOMEUIINFO_END -}; - -static GnomeUIInfo edit_object_menu[] = { - GNOMEUIINFO_ITEM_NONE ("FIXME: what goes here?", NULL, NULL), - GNOMEUIINFO_END -}; - -static GnomeUIInfo edit_menu[] = { - GNOMEUIINFO_MENU_UNDO_ITEM (NULL, NULL), - GNOMEUIINFO_MENU_REDO_ITEM (NULL, NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_MENU_CUT_ITEM (NULL, NULL), - GNOMEUIINFO_MENU_COPY_ITEM (NULL, NULL), - GNOMEUIINFO_MENU_PASTE_ITEM (NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Paste _Special..."), NULL, NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_MENU_CLEAR_ITEM (NULL, NULL), - GNOMEUIINFO_MENU_SELECT_ALL_ITEM (NULL, NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Mark as U_nread"), NULL, NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_MENU_FIND_ITEM (NULL, NULL), - GNOMEUIINFO_MENU_FIND_AGAIN_ITEM (NULL, NULL), - GNOMEUIINFO_SUBTREE (N_("_Object"), edit_object_menu), - GNOMEUIINFO_END -}; - -static GnomeUIInfo view_previous_menu[] = { - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Item"), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Unread Item"), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Fi_rst Item in Folder"), NULL, NULL), - GNOMEUIINFO_END -}; - -static GnomeUIInfo view_next_menu[] = { - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Item"), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Unread Item"), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Last Item in Folder"), NULL, NULL), - GNOMEUIINFO_END -}; - -static GnomeUIInfo view_toolbars_menu[] = { - { GNOME_APP_UI_TOGGLEITEM, N_("FIXME: _Standard"), NULL, NULL, NULL, NULL, - GNOME_APP_PIXMAP_NONE, NULL, 0, 0, NULL }, - { GNOME_APP_UI_TOGGLEITEM, N_("FIXME: __Formatting"), NULL, NULL, NULL, NULL, - GNOME_APP_PIXMAP_NONE, NULL, 0, 0, NULL }, - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Customize..."), NULL, NULL), - GNOMEUIINFO_END -}; - -static GnomeUIInfo view_menu[] = { - GNOMEUIINFO_SUBTREE (N_("Pre_vious"), view_previous_menu), - GNOMEUIINFO_SUBTREE (N_("Ne_xt"), view_next_menu), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_SUBTREE (N_("_Toolbars"), view_toolbars_menu), - GNOMEUIINFO_END -}; - -static GnomeUIInfo insert_menu[] = { - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _File..."), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: It_em..."), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Object..."), NULL, NULL), - GNOMEUIINFO_END -}; - -static GnomeUIInfo format_menu[] = { - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Font..."), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Paragraph..."), NULL, NULL), - GNOMEUIINFO_END -}; - -static GnomeUIInfo tools_forms_menu[] = { - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Ch_oose Form..."), NULL, NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Desi_gn This Form"), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: D_esign a Form..."), NULL, NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Publish _Form..."), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Pu_blish Form As..."), NULL, NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Script _Debugger"), NULL, NULL), - GNOMEUIINFO_END -}; - -static GnomeUIInfo tools_menu[] = { - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Spelling..."), NULL, NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_SUBTREE (N_("_Forms"), tools_forms_menu), - GNOMEUIINFO_END -}; - -static GnomeUIInfo actions_menu[] = { - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _New Contact"), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: New _Contact from Same Company"), NULL, NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_ITEM_NONE (N_("FIXME: New _Letter to Contact"), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: New _Message to Contact"), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: New Meetin_g with Contact"), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Plan a Meeting..."), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: New _Task for Contact"), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: New _Journal Entry for Contact"), NULL, NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Flag for Follow Up..."), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Display Map of Address"), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: _Open Web Page"), NULL, NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Forward as _vCard"), NULL, NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: For_ward"), NULL, NULL) -}; - -static GnomeUIInfo help_menu[] = { - GNOMEUIINFO_ITEM_NONE ("FIXME: fix Bonobo so it supports help items!", NULL, NULL), - GNOMEUIINFO_END -}; - -static GnomeUIInfo main_menu[] = { - GNOMEUIINFO_MENU_FILE_TREE (file_menu), - GNOMEUIINFO_MENU_EDIT_TREE (edit_menu), - GNOMEUIINFO_MENU_VIEW_TREE (view_menu), - GNOMEUIINFO_SUBTREE (N_("_Insert"), insert_menu), - GNOMEUIINFO_SUBTREE (N_("F_ormat"), format_menu), - GNOMEUIINFO_SUBTREE (N_("_Tools"), tools_menu), - GNOMEUIINFO_SUBTREE (N_("Actio_ns"), actions_menu), - GNOMEUIINFO_MENU_HELP_TREE (help_menu), - GNOMEUIINFO_END -}; - -/* Creates the menu bar for the contact editor */ -static void -create_menu (EContactEditor *ce) -{ - BonoboUIHandlerMenuItem *list; - - bonobo_ui_handler_create_menubar (ce->uih); - - list = bonobo_ui_handler_menu_parse_uiinfo_list_with_data (main_menu, ce); - bonobo_ui_handler_menu_add_list (ce->uih, "/", list); -} - -/* Toolbar/Save and Close callback */ -static void -tb_save_and_close_cb (GtkWidget *widget, gpointer data) -{ - EContactEditor *ce; - - ce = E_CONTACT_EDITOR (data); - save_card (ce); - close_dialog (ce); -} - -/* Toolbar */ - -static GnomeUIInfo toolbar[] = { - GNOMEUIINFO_ITEM_STOCK (N_("FIXME: Save and Close"), - N_("Save the appointment and close the dialog box"), - tb_save_and_close_cb, - GNOME_STOCK_PIXMAP_SAVE), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Print..."), - N_("Print this item"), NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Insert File..."), - N_("Insert a file as an attachment"), NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Recurrence..."), - N_("Configure recurrence rules"), NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Invite Attendees..."), - N_("Invite attendees to a meeting"), NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Delete"), - N_("Delete this item"), NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Previous"), - N_("Go to the previous item"), NULL), - GNOMEUIINFO_ITEM_NONE (N_("FIXME: Next"), - N_("Go to the next item"), NULL), - GNOMEUIINFO_ITEM_STOCK (N_("FIXME: Help"), - N_("See online help"), NULL, GNOME_STOCK_PIXMAP_HELP), - GNOMEUIINFO_END -}; - -/* Creates the toolbar for the contact editor */ -static void -create_toolbar (EContactEditor *ce) -{ - BonoboUIHandlerToolbarItem *list; - GnomeDockItem *dock_item; - GtkWidget *toolbar_child; - - bonobo_ui_handler_create_toolbar (ce->uih, "Toolbar"); - - /* Fetch the toolbar. What a pain in the ass. */ - - dock_item = gnome_app_get_dock_item_by_name (GNOME_APP (ce->app), GNOME_APP_TOOLBAR_NAME); - g_assert (dock_item != NULL); - - toolbar_child = gnome_dock_item_get_child (dock_item); - g_assert (toolbar_child != NULL && GTK_IS_TOOLBAR (toolbar_child)); - - /* Turn off labels as GtkToolbar sucks */ - gtk_toolbar_set_style (GTK_TOOLBAR (toolbar_child), GTK_TOOLBAR_ICONS); - - list = bonobo_ui_handler_toolbar_parse_uiinfo_list_with_data (toolbar, ce); - bonobo_ui_handler_toolbar_add_list (ce->uih, "/Toolbar", list); -} - -/* Callback used when the dialog box is destroyed */ -static gint -app_delete_event_cb (GtkWidget *widget, GdkEvent *event, gpointer data) -{ - EContactEditor *ce; - - ce = E_CONTACT_EDITOR (data); - - close_dialog (ce); - return TRUE; -} - -static void -e_contact_editor_init (EContactEditor *e_contact_editor) -{ - GladeXML *gui; - GtkWidget *widget; - - 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; - e_contact_editor->name = NULL; - e_contact_editor->company = g_strdup(""); - - e_contact_editor->email_choice = 0; - e_contact_editor->phone_choice[0] = E_CARD_SIMPLE_PHONE_ID_BUSINESS; - e_contact_editor->phone_choice[1] = E_CARD_SIMPLE_PHONE_ID_HOME; - e_contact_editor->phone_choice[2] = E_CARD_SIMPLE_PHONE_ID_BUSINESS_FAX; - e_contact_editor->phone_choice[3] = E_CARD_SIMPLE_PHONE_ID_MOBILE; - e_contact_editor->address_choice = 0; - - e_contact_editor->arbitrary_fields = NULL; - - e_contact_editor->simple = e_card_simple_new(NULL); - - e_contact_editor->card = NULL; - - gui = glade_xml_new (EVOLUTION_GLADEDIR "/contact-editor.glade", NULL); - e_contact_editor->gui = gui; - - e_contact_editor->app = glade_xml_get_widget (gui, "contact editor"); - - e_container_foreach_leaf (GTK_CONTAINER (e_contact_editor->app), - (GtkCallback) add_field_callback, - e_contact_editor); - - _replace_buttons(e_contact_editor); - set_entry_changed_signals(e_contact_editor); - - widget = glade_xml_get_widget(e_contact_editor->gui, "button-fullname"); - if (widget && GTK_IS_BUTTON(widget)) - gtk_signal_connect(GTK_OBJECT(widget), "clicked", - full_name_clicked, e_contact_editor); - - widget = glade_xml_get_widget(e_contact_editor->gui, "button-categories"); - if (widget && GTK_IS_BUTTON(widget)) - gtk_signal_connect(GTK_OBJECT(widget), "clicked", - categories_clicked, e_contact_editor); - - /* Build the menu and toolbar */ - - e_contact_editor->uih = bonobo_ui_handler_new (); - if (!e_contact_editor->uih) { - g_message ("e_contact_editor_init(): eeeeek, could not create the UI handler!"); - return; - } - - bonobo_ui_handler_set_app (e_contact_editor->uih, GNOME_APP (e_contact_editor->app)); - - create_menu (e_contact_editor); - create_toolbar (e_contact_editor); - - /* Connect to the deletion of the dialog */ - - gtk_signal_connect (GTK_OBJECT (e_contact_editor->app), "delete_event", - GTK_SIGNAL_FUNC (app_delete_event_cb), e_contact_editor); -} - -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); - } - - if (e_contact_editor->simple) - gtk_object_unref(GTK_OBJECT(e_contact_editor->simple)); - - g_free (e_contact_editor->company); - - gtk_object_unref(GTK_OBJECT(e_contact_editor->gui)); -} - -EContactEditor * -e_contact_editor_new (ECard *card, gboolean is_new_card) -{ - EContactEditor *ce; - - ce = E_CONTACT_EDITOR (gtk_type_new (E_CONTACT_EDITOR_TYPE)); - - gtk_object_set (GTK_OBJECT (ce), - "card", card, - "is_new_card", is_new_card, - NULL); - - gtk_widget_show (ce->app); - return ce; -} - -static void -e_contact_editor_set_arg (GtkObject *o, GtkArg *arg, guint arg_id) -{ - EContactEditor *editor; - - editor = E_CONTACT_EDITOR (o); - - switch (arg_id){ - case ARG_CARD: - if (editor->card) - gtk_object_unref(GTK_OBJECT(editor->card)); - editor->card = e_card_duplicate(E_CARD(GTK_VALUE_OBJECT (*arg))); - gtk_object_set(GTK_OBJECT(editor->simple), - "card", editor->card, - NULL); - fill_in_info(editor); - break; - - case ARG_IS_NEW_CARD: - editor->is_new_card = GTK_VALUE_BOOL (*arg) ? TRUE : FALSE; - 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: - e_card_simple_sync_card(e_contact_editor->simple); - extract_info(e_contact_editor); - GTK_VALUE_OBJECT (*arg) = GTK_OBJECT(e_contact_editor->card); - break; - - case ARG_IS_NEW_CARD: - GTK_VALUE_BOOL (*arg) = e_contact_editor->is_new_card ? TRUE : FALSE; - 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 gint -_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 0 - if (menu_item == g_list_length (*list)) { - e_contact_editor_build_dialog(editor, entry, label, dialog_title, list, info); - } else { -#endif - GtkWidget *label_widget = glade_xml_get_widget(editor->gui, label); - if (label_widget && GTK_IS_LABEL(label_widget)) { - gtk_object_set(GTK_OBJECT(label_widget), - "label", g_list_nth_data(*list, menu_item), - NULL); - } -#if 0 - } -#endif - } - return menu_item; -} - -static void -e_contact_editor_build_ui_info(GList *list, GnomeUIInfo **infop) -{ - GnomeUIInfo *info; - GnomeUIInfo singleton = { GNOME_APP_UI_TOGGLEITEM, 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] = end; - - *infop = info; -} - -#if 0 -static void -_dialog_clicked(GtkWidget *dialog, gint button, EContactEditor *editor) -{ - GtkWidget *label = gtk_object_get_data(GTK_OBJECT(dialog), - "e_contact_editor_label"); - - 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: - if (label && GTK_IS_LABEL(label)) { - 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; -} -#endif - -static void -_phone_arrow_pressed (GtkWidget *widget, GdkEventButton *button, EContactEditor *editor) -{ - int which; - int i; - gchar *label; - gchar *entry; - int result; - 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); - } - - for(i = 0; i < E_CARD_SIMPLE_PHONE_ID_LAST; i++) { - const ECardPhone *phone = e_card_simple_get_phone(editor->simple, i); - gboolean checked; - checked = phone && phone->number && *phone->number; - gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(editor->phone_info[i].widget), - checked); - gtk_check_menu_item_set_show_toggle(GTK_CHECK_MENU_ITEM(editor->phone_info[i].widget), - TRUE); - } - - result = _arrow_pressed (widget, button, editor, editor->phone_popup, &editor->phone_list, &editor->phone_info, label, entry, "Add new phone number type"); - - if (result != -1) { - editor->phone_choice[which - 1] = result; - set_fields(editor); - } - - g_free(label); - g_free(entry); -} - -static void -_email_arrow_pressed (GtkWidget *widget, GdkEventButton *button, EContactEditor *editor) -{ - int i; - int result; - if (editor->email_list == NULL) { - static char *info[] = { - N_("Primary 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); - } - - for(i = 0; i < E_CARD_SIMPLE_EMAIL_ID_LAST; i++) { - const char *string = e_card_simple_get_email(editor->simple, i); - gboolean checked; - checked = string && *string; - gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(editor->email_info[i].widget), - checked); - gtk_check_menu_item_set_show_toggle(GTK_CHECK_MENU_ITEM(editor->email_info[i].widget), - TRUE); - } - - result = _arrow_pressed (widget, button, editor, editor->email_popup, &editor->email_list, &editor->email_info, "label-email1", "entry-email1", "Add new Email type"); - - if (result != -1) { - editor->email_choice = result; - set_fields(editor); - } -} - -static void -_address_arrow_pressed (GtkWidget *widget, GdkEventButton *button, EContactEditor *editor) -{ - int i; - int result; - 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); - } - - for(i = 0; i < E_CARD_SIMPLE_ADDRESS_ID_LAST; i++) { - const ECardAddrLabel *address = e_card_simple_get_address(editor->simple, i); - gboolean checked; - checked = address && address->data && *address->data; - gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(editor->address_info[i].widget), - checked); - gtk_check_menu_item_set_show_toggle(GTK_CHECK_MENU_ITEM(editor->address_info[i].widget), - TRUE); - } - - result = _arrow_pressed (widget, button, editor, editor->address_popup, &editor->address_list, &editor->address_info, "label-address", "text-address", "Add new Address type"); - - if (result != -1) { - set_address_field(editor, result); - } -} - -static void -set_field(GtkEntry *entry, const char *string) -{ - char *oldstring = gtk_entry_get_text(entry); - if (!string) - string = ""; - if (strcmp(string, oldstring)) - gtk_entry_set_text(entry, string); -} - -static void -set_phone_field(GtkWidget *entry, const ECardPhone *phone) -{ - set_field(GTK_ENTRY(entry), phone ? phone->number : ""); -} - -static void -set_fields(EContactEditor *editor) -{ - GtkWidget *entry; - - entry = glade_xml_get_widget(editor->gui, "entry-phone1"); - if (entry && GTK_IS_ENTRY(entry)) - set_phone_field(entry, e_card_simple_get_phone(editor->simple, editor->phone_choice[0])); - - entry = glade_xml_get_widget(editor->gui, "entry-phone2"); - if (entry && GTK_IS_ENTRY(entry)) - set_phone_field(entry, e_card_simple_get_phone(editor->simple, editor->phone_choice[1])); - - entry = glade_xml_get_widget(editor->gui, "entry-phone3"); - if (entry && GTK_IS_ENTRY(entry)) - set_phone_field(entry, e_card_simple_get_phone(editor->simple, editor->phone_choice[2])); - - entry = glade_xml_get_widget(editor->gui, "entry-phone4"); - if (entry && GTK_IS_ENTRY(entry)) - set_phone_field(entry, e_card_simple_get_phone(editor->simple, editor->phone_choice[3])); - - entry = glade_xml_get_widget(editor->gui, "entry-email1"); - if (entry && GTK_IS_ENTRY(entry)) - set_field(GTK_ENTRY(entry), e_card_simple_get_email(editor->simple, editor->email_choice)); - - set_address_field(editor, -1); -} - -static void -set_address_field(EContactEditor *editor, int result) -{ - GtkWidget *widget; - - widget = glade_xml_get_widget(editor->gui, "text-address"); - - if (widget && GTK_IS_TEXT(widget)) { - int position; - GtkEditable *editable; - const ECardAddrLabel *address; - - if (result == -1) - result = editor->address_choice; - editor->address_choice = -1; - - position = 0; - editable = GTK_EDITABLE(widget); - gtk_editable_delete_text(editable, 0, -1); - address = e_card_simple_get_address(editor->simple, result); - if (address && address->data) - gtk_editable_insert_text(editable, address->data, strlen(address->data), &position); - - editor->address_choice = result; - } -} - -static void -add_field_callback(GtkWidget *widget, EContactEditor *editor) -{ - const char *name; - int i; - static const char *builtins[] = { - "entry-fullname", - "entry-web", - "entry-company", - "entry-department", - "entry-office", - "entry-jobtitle", - "entry-profession", - "entry-manager", - "entry-assistant", - "entry-nickname", - "entry-spouse", - "text-comments", - "entry-categories", - "entry-contacts", - "entry-file-as", - "dateedit-anniversary", - "dateedit-birthday", - "entry-phone1", - "entry-phone2", - "entry-phone3", - "entry-phone4", - "entry-email1", - "text-address", - "checkbutton-mailingaddress", - "checkbutton-htmlmail", - NULL - }; - name = glade_get_widget_name(widget); - if (name) { - for (i = 0; builtins[i]; i++) { - if (!strcmp(name, builtins[i])) - return; - } - if (GTK_IS_ENTRY(widget) || GTK_IS_TEXT(widget)) { - editor->arbitrary_fields = g_list_prepend(editor->arbitrary_fields, g_strdup(name)); - } - } -} - -struct { - char *id; - char *key; -} field_mapping [] = { - { "entry-fullname", "full_name" }, - { "entry-web", "url" }, - { "entry-company", "org" }, - { "entry-department", "org_unit" }, - { "entry-office", "office" }, - { "entry-jobtitle", "title" }, - { "entry-profession", "role" }, - { "entry-manager", "manager" }, - { "entry-assistant", "assistant" }, - { "entry-nickname", "nickname" }, - { "entry-spouse", "spouse" }, - { "text-comments", "note" }, - { "entry-categories", "categories" }, -}; - -static void -fill_in_field(EContactEditor *editor, char *id, char *value) -{ - GtkWidget *widget = glade_xml_get_widget(editor->gui, id); - if (widget && GTK_IS_EDITABLE(widget)) { - int position = 0; - GtkEditable *editable = GTK_EDITABLE(widget); - gtk_editable_delete_text(editable, 0, -1); - if (value) - gtk_editable_insert_text(editable, value, strlen(value), &position); - } -} - -static void -fill_in_card_field(EContactEditor *editor, ECard *card, char *id, char *key) -{ - char *string; - gtk_object_get(GTK_OBJECT(card), - key, &string, - NULL); - fill_in_field(editor, id, string); -} - -static void -fill_in_single_field(EContactEditor *editor, char *name) -{ - ECardSimple *simple = editor->simple; - GtkWidget *widget = glade_xml_get_widget(editor->gui, name); - if (widget && GTK_IS_EDITABLE(widget)) { - int position = 0; - GtkEditable *editable = GTK_EDITABLE(widget); - const ECardArbitrary *arbitrary; - - gtk_editable_delete_text(editable, 0, -1); - arbitrary = e_card_simple_get_arbitrary(simple, - name); - if (arbitrary && arbitrary->value) - gtk_editable_insert_text(editable, arbitrary->value, strlen(arbitrary->value), &position); - } -} - -static void -fill_in_info(EContactEditor *editor) -{ - ECard *card = editor->card; - if (card) { - char *file_as; - ECardName *name; - const ECardDate *anniversary; - const ECardDate *bday; - int i; - GtkWidget *widget; - GList *list; - - gtk_object_get(GTK_OBJECT(card), - "file_as", &file_as, - "name", &name, - "anniversary", &anniversary, - "birth_date", &bday, - NULL); - - for (i = 0; i < sizeof(field_mapping) / sizeof(field_mapping[0]); i++) { - fill_in_card_field(editor, card, field_mapping[i].id, field_mapping[i].key); - } - - for (list = editor->arbitrary_fields; list; list = list->next) { - fill_in_single_field(editor, list->data); - } - - /* File as has to come after company and name or else it'll get messed up when setting them. */ - fill_in_field(editor, "entry-file-as", file_as); - - e_card_name_free(editor->name); - editor->name = e_card_name_copy(name); - - widget = glade_xml_get_widget(editor->gui, "dateedit-anniversary"); - if (anniversary && widget && GNOME_IS_DATE_EDIT(widget)) { - struct tm time_struct = {0,0,0,0,0,0,0,0,0}; - time_t time_val; - GnomeDateEdit *dateedit; - - time_struct.tm_mday = anniversary->day; - time_struct.tm_mon = anniversary->month - 1; - time_struct.tm_year = anniversary->year - 1900; - time_val = mktime(&time_struct); - dateedit = GNOME_DATE_EDIT(widget); - gnome_date_edit_set_time(dateedit, time_val); - } - - widget = glade_xml_get_widget(editor->gui, "dateedit-birthday"); - if (bday && widget && GNOME_IS_DATE_EDIT(widget)) { - 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 - 1; - time_struct.tm_year = bday->year - 1900; - time_val = mktime(&time_struct); - dateedit = GNOME_DATE_EDIT(widget); - gnome_date_edit_set_time(dateedit, time_val); - } - - set_fields(editor); - } -} - -static void -extract_field(EContactEditor *editor, ECard *card, char *editable_id, char *key) -{ - GtkWidget *widget = glade_xml_get_widget(editor->gui, editable_id); - if (widget && GTK_IS_EDITABLE(widget)) { - GtkEditable *editable = GTK_EDITABLE(widget); - char *string = gtk_editable_get_chars(editable, 0, -1); - if (string && *string) - gtk_object_set(GTK_OBJECT(card), - key, string, - NULL); - else - gtk_object_set(GTK_OBJECT(card), - key, NULL, - NULL); - g_free(string); - } -} - -static void -extract_single_field(EContactEditor *editor, char *name) -{ - GtkWidget *widget = glade_xml_get_widget(editor->gui, name); - ECardSimple *simple = editor->simple; - if (widget && GTK_IS_EDITABLE(widget)) { - GtkEditable *editable = GTK_EDITABLE(widget); - char *string = gtk_editable_get_chars(editable, 0, -1); - - if (string && *string) - e_card_simple_set_arbitrary(simple, - name, - NULL, - string); - else - e_card_simple_set_arbitrary(simple, - name, - NULL, - NULL); - g_free(string); - } -} - -static void -extract_info(EContactEditor *editor) -{ - ECard *card = editor->card; - if (card) { - ECardDate *anniversary; - ECardDate *bday; - struct tm time_struct; - time_t time_val; - int i; - GtkWidget *widget; - GList *list; - - widget = glade_xml_get_widget(editor->gui, "entry-file-as"); - if (widget && GTK_IS_EDITABLE(widget)) { - GtkEditable *editable = GTK_EDITABLE(widget); - char *string = gtk_editable_get_chars(editable, 0, -1); - if (string && *string) - gtk_object_set(GTK_OBJECT(card), - "file_as", string, - NULL); - g_free(string); - } - - for (i = 0; i < sizeof(field_mapping) / sizeof(field_mapping[0]); i++) { - extract_field(editor, card, field_mapping[i].id, field_mapping[i].key); - } - - for (list = editor->arbitrary_fields; list; list = list->next) { - extract_single_field(editor, list->data); - } - - if (editor->name) - gtk_object_set(GTK_OBJECT(card), - "name", editor->name, - NULL); - - widget = glade_xml_get_widget(editor->gui, "dateedit-anniversary"); - if (widget && GNOME_IS_DATE_EDIT(widget)) { - time_val = gnome_date_edit_get_date(GNOME_DATE_EDIT(widget)); - gmtime_r(&time_val, - &time_struct); - anniversary = g_new(ECardDate, 1); - anniversary->day = time_struct.tm_mday; - anniversary->month = time_struct.tm_mon + 1; - anniversary->year = time_struct.tm_year + 1900; - gtk_object_set(GTK_OBJECT(card), - "anniversary", anniversary, - NULL); - } - - widget = glade_xml_get_widget(editor->gui, "dateedit-birthday"); - if (widget && GNOME_IS_DATE_EDIT(widget)) { - time_val = gnome_date_edit_get_date(GNOME_DATE_EDIT(widget)); - gmtime_r(&time_val, - &time_struct); - bday = g_new(ECardDate, 1); - bday->day = time_struct.tm_mday; - bday->month = time_struct.tm_mon + 1; - bday->year = time_struct.tm_year + 1900; - 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 8eae2bf1b5..0000000000 --- a/addressbook/gui/contact-editor/e-contact-editor.h +++ /dev/null @@ -1,110 +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 -#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 * RW 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 -{ - GtkObject object; - - /* item specific fields */ - ECard *card; - ECardSimple *simple; - - /* UI handler */ - BonoboUIHandler *uih; - - GladeXML *gui; - GtkWidget *app; - 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; - - ECardName *name; - char *company; - - ECardSimpleEmailId email_choice; - ECardSimplePhoneId phone_choice[4]; - ECardSimpleAddressId address_choice; - - GList *arbitrary_fields; - - /* Whether we are editing a new card or an existing one */ - guint is_new_card : 1; -}; - -struct _EContactEditorClass -{ - GtkObjectClass parent_class; - - /* Notification signals */ - - void (* add_card) (EContactEditor *ce, ECard *card); - void (* commit_card) (EContactEditor *ce, ECard *card); - void (* editor_closed) (EContactEditor *ce); -}; - - -EContactEditor *e_contact_editor_new (ECard *card, gboolean is_new_card); -GtkType e_contact_editor_get_type (void); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - - -#endif /* __E_CONTACT_EDITOR_H__ */ diff --git a/addressbook/gui/contact-editor/e-contact-save-as.c b/addressbook/gui/contact-editor/e-contact-save-as.c deleted file mode 100644 index 51cb2619e7..0000000000 --- a/addressbook/gui/contact-editor/e-contact-save-as.c +++ /dev/null @@ -1,77 +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. - */ - -#include -#include -#include -#include - -typedef struct { - GtkFileSelection *filesel; - ECard *card; -} SaveAsInfo; - -static void -save_it(GtkWidget *widget, SaveAsInfo *info) -{ - char *vcard = e_card_get_vcard(info->card); - const char *filename = gtk_file_selection_get_filename(info->filesel); - e_write_file(filename, vcard, O_WRONLY | O_CREAT | O_EXCL | O_TRUNC); - g_free(vcard); - gtk_object_unref(GTK_OBJECT(info->card)); - gtk_widget_destroy(GTK_WIDGET(info->filesel)); - g_free(info); -} - -static void -close_it(GtkWidget *widget, SaveAsInfo *info) -{ - gtk_object_unref(GTK_OBJECT(info->card)); - gtk_widget_destroy(GTK_WIDGET(info->filesel)); - g_free(info); -} - -static void -delete_it(GtkWidget *widget, SaveAsInfo *info) -{ - gtk_object_unref(GTK_OBJECT(info->card)); - g_free(info); -} - -void -e_contact_save_as(char *title, ECard *card) -{ - GtkFileSelection *filesel; - SaveAsInfo *info = g_new(SaveAsInfo, 1); - - filesel = GTK_FILE_SELECTION(gtk_file_selection_new(title)); - - info->filesel = filesel; - info->card = e_card_duplicate(card); - - gtk_signal_connect(GTK_OBJECT(filesel->ok_button), "clicked", - save_it, info); - gtk_signal_connect(GTK_OBJECT(filesel->cancel_button), "clicked", - close_it, info); - gtk_signal_connect(GTK_OBJECT(filesel), "delete_event", - delete_it, info); - gtk_widget_show(GTK_WIDGET(filesel)); -} diff --git a/addressbook/gui/contact-editor/e-contact-save-as.h b/addressbook/gui/contact-editor/e-contact-save-as.h deleted file mode 100644 index e6af13e8fd..0000000000 --- a/addressbook/gui/contact-editor/e-contact-save-as.h +++ /dev/null @@ -1,42 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* e-contact-save-as.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_SAVE_AS_H__ -#define __E_CONTACT_SAVE_AS_H__ - -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - -void -e_contact_save_as(gchar *title, ECard *card); - -#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/fullname-strings.h b/addressbook/gui/contact-editor/fullname-strings.h deleted file mode 100644 index 0c84dfdc8f..0000000000 --- a/addressbook/gui/contact-editor/fullname-strings.h +++ /dev/null @@ -1,25 +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_("Check Full Name"); -gchar *s = N_("_Title:"); -gchar *s = N_("_First:"); -gchar *s = N_("_Middle:"); -gchar *s = N_("_Last:"); -gchar *s = N_("_Suffix:"); -gchar *s = N_("\n" - "Mr.\n" - "Mrs.\n" - "Dr.\n" - ""); -gchar *s = N_("\n" - "Sr.\n" - "Jr.\n" - "I\n" - "II\n" - "III\n" - "Esq.\n" - ""); diff --git a/addressbook/gui/contact-editor/fullname.glade b/addressbook/gui/contact-editor/fullname.glade deleted file mode 100644 index 8f811c5616..0000000000 --- a/addressbook/gui/contact-editor/fullname.glade +++ /dev/null @@ -1,391 +0,0 @@ - - - - - fullname - fullname - - src - pixmaps - C - True - True - True - False - False - False - True - interface.c - interface.h - callbacks.c - callbacks.h - support.c - support.h - True - fullname-strings.h - - - - GnomeDialog - dialog-checkfullname - False - Check Full Name - GTK_WINDOW_TOPLEVEL - GTK_WIN_POS_NONE - True - True - True - False - False - False - - - GtkVBox - GnomeDialog:vbox - vbox-container - False - 8 - - 4 - True - True - - - - GtkTable - table-checkfullname - 8 - 5 - 3 - False - 6 - 21 - - 0 - True - True - - - - GtkAccelLabel - accellabel1 - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - - 0 - 1 - 0 - 1 - 0 - 0 - False - False - False - False - True - True - - - - - GtkAccelLabel - accellabel2 - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - - 0 - 1 - 1 - 2 - 0 - 0 - False - False - False - False - True - True - - - - - GtkAccelLabel - accellabel3 - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - - 0 - 1 - 2 - 3 - 0 - 0 - False - False - False - False - True - True - - - - - GtkAccelLabel - accellabel4 - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - - 0 - 1 - 3 - 4 - 0 - 0 - False - False - False - False - True - True - - - - - GtkAccelLabel - accellabel5 - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - - 0 - 1 - 4 - 5 - 0 - 0 - False - False - False - False - True - True - - - - - GtkCombo - combo-title - False - True - False - True - False - -Mr. -Mrs. -Dr. - - - 1 - 2 - 0 - 1 - 0 - 0 - True - False - False - False - True - False - - - - GtkEntry - GtkCombo:entry - entry-title - True - True - True - 0 - - - - - - GtkCombo - combo-suffix - False - True - False - True - False - -Sr. -Jr. -I -II -III -Esq. - - - 1 - 2 - 4 - 5 - 0 - 0 - True - False - False - False - True - False - - - - GtkEntry - GtkCombo:entry - entry-suffix - True - True - True - 0 - - - - - - GtkEntry - entry-first - True - True - True - 0 - - - 1 - 3 - 1 - 2 - 0 - 0 - True - False - False - False - True - False - - - - - GtkEntry - entry-middle - True - True - True - 0 - - - 1 - 3 - 2 - 3 - 0 - 0 - True - False - False - False - True - False - - - - - GtkEntry - entry-last - True - True - True - 0 - - - 1 - 3 - 3 - 4 - 0 - 0 - True - False - False - False - True - False - - - - - - GtkHButtonBox - GnomeDialog:action_area - hbuttonbox1 - 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_CANCEL - - - - - - 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 80db2fe848..0000000000 --- a/addressbook/gui/contact-editor/test-editor.c +++ /dev/null @@ -1,142 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * test-editor.c - * Copyright (C) 2000 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); -} - -/* Callback used when a contact editor is closed */ -static void -editor_closed_cb (EContactEditor *ce, gpointer data) -{ - static int count = 2; - - count--; - gtk_object_unref (GTK_OBJECT (ce)); - - 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; - EContactEditor *ce; - - /* bindtextdomain (PACKAGE, GNOMELOCALEDIR); - textdomain (PACKAGE);*/ - - gnome_init( "Contact Editor Test", VERSION, argc, argv); - - glade_gnome_init (); - - cardstr = NULL; - if (argc == 2) - cardstr = read_file (argv [1]); - - if (cardstr == NULL) - cardstr = TEST_VCARD; - - ce = e_contact_editor_new (e_card_new (cardstr), TRUE); - gtk_signal_connect (GTK_OBJECT (ce), "editor_closed", - GTK_SIGNAL_FUNC (editor_closed_cb), NULL); - - ce = e_contact_editor_new (e_card_new (cardstr), TRUE); - gtk_signal_connect (GTK_OBJECT (ce), "editor_closed", - GTK_SIGNAL_FUNC (editor_closed_cb), NULL); - - 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 800a11cc3e..0000000000 --- a/addressbook/gui/minicard/.cvsignore +++ /dev/null @@ -1,11 +0,0 @@ -.deps -.libs -.pure -Makefile -Makefile.in -*.lo -*.la -minicard-label-test -minicard-test -minicard-view-test -reflow-test diff --git a/addressbook/gui/minicard/Makefile.am b/addressbook/gui/minicard/Makefile.am deleted file mode 100644 index 0eb7946ac5..0000000000 --- a/addressbook/gui/minicard/Makefile.am +++ /dev/null @@ -1,94 +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 \ - $(BONOBO_GNOME_CFLAGS) - -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 \ - $(BONOBO_GNOME_LIBS) \ - $(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 \ - $(BONOBO_GNOME_LIBS) \ - $(top_builddir)/addressbook/backend/ebook/libebook.la \ - $(top_builddir)/e-util/libeutil.la \ - $(top_builddir)/libversit/libversit.la \ - $(top_builddir)/addressbook/ename/libename.la \ - $(top_builddir)/addressbook/contact-editor/libecontacteditor.a \ - $(top_builddir)/widgets/e-table/libetable.a \ - $(top_builddir)/widgets/misc/libemiscwidgets.a \ - $(top_builddir)/e-util/libeutil.la \ - $(top_builddir)/widgets/e-text/libetext.a - -reflow_test_SOURCES = \ - test-reflow.c - -reflow_test_LDADD = \ - $(EXTRA_GNOME_LIBS) \ - $(GNOMEGNORBA_LIBS) \ - $(BONOBO_GNOME_LIBS) \ - libeminicard.a \ - $(top_builddir)/addressbook/backend/ebook/libebook.la \ - $(top_builddir)/e-util/libeutil.la \ - $(top_builddir)/libversit/libversit.la \ - $(top_builddir)/addressbook/ename/libename.la \ - $(top_builddir)/addressbook/contact-editor/libecontacteditor.a \ - $(top_builddir)/widgets/e-table/libetable.a \ - $(top_builddir)/widgets/misc/libemiscwidgets.a \ - $(top_builddir)/e-util/libeutil.la \ - $(top_builddir)/widgets/e-text/libetext.a - -minicard_view_test_SOURCES = \ - test-minicard-view.c - -minicard_view_test_LDADD = \ - $(EXTRA_GNOME_LIBS) \ - $(GNOMEGNORBA_LIBS) \ - $(BONOBO_GNOME_LIBS) \ - libeminicard.a \ - $(top_builddir)/addressbook/backend/ebook/libebook.la \ - $(top_builddir)/e-util/libeutil.la \ - $(top_builddir)/libversit/libversit.la \ - $(top_builddir)/addressbook/ename/libename.la \ - $(top_builddir)/addressbook/contact-editor/libecontacteditor.a \ - $(top_builddir)/widgets/e-table/libetable.a \ - $(top_builddir)/widgets/misc/libemiscwidgets.a \ - $(top_builddir)/e-util/libeutil.la \ - $(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 e765a89f21..0000000000 --- a/addressbook/gui/minicard/e-minicard-label.c +++ /dev/null @@ -1,446 +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, - ARG_MAX_FIELD_NAME_WIDTH, -}; - -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); - gtk_object_add_arg_type ("EMinicardLabel::max_field_name_length", GTK_TYPE_DOUBLE, - GTK_ARG_READWRITE, ARG_MAX_FIELD_NAME_WIDTH); - - 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; - - minicard_label->max_field_name_length = -1; - - e_canvas_item_set_reflow_callback(GNOME_CANVAS_ITEM(minicard_label), e_minicard_label_reflow); -} - -static void -e_minicard_label_set_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; - case ARG_MAX_FIELD_NAME_WIDTH: - e_minicard_label->max_field_name_length = GTK_VALUE_DOUBLE (*arg); - 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; - case ARG_MAX_FIELD_NAME_WIDTH: - GTK_VALUE_DOUBLE (*arg) = e_minicard_label->max_field_name_length; - 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) -{ - double left_width; - if (e_minicard_label->max_field_name_length != -1 && ((e_minicard_label->width / 2) - 4 > e_minicard_label->max_field_name_length)) - left_width = e_minicard_label->max_field_name_length; - else - left_width = e_minicard_label->width / 2 - 4; - - gnome_canvas_item_set( e_minicard_label->fieldname, - "clip_width", (double) ( left_width ), - NULL ); - gnome_canvas_item_set( e_minicard_label->field, - "clip_width", (double) ( e_minicard_label->width - 8 - left_width ), - 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; - gdouble left_width; - - 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 ); - - if (e_minicard_label->max_field_name_length != -1 && ((e_minicard_label->width / 2) - 4 > e_minicard_label->max_field_name_length)) - left_width = e_minicard_label->max_field_name_length; - else - left_width = e_minicard_label->width / 2 - 4; - - e_canvas_item_move_absolute(e_minicard_label->field, left_width + 6, 1); - - if (old_height != e_minicard_label->height) - e_canvas_item_request_parent_reflow(item); -} - -GnomeCanvasItem * -e_minicard_label_new(GnomeCanvasGroup *parent) -{ - GnomeCanvasItem *item = gnome_canvas_item_new(parent, e_minicard_label_get_type(), NULL); - 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 08eb51ee53..0000000000 --- a/addressbook/gui/minicard/e-minicard-label.h +++ /dev/null @@ -1,83 +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; - double max_field_name_length; - 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 28f8243dff..0000000000 --- a/addressbook/gui/minicard/e-minicard-view.c +++ /dev/null @@ -1,426 +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" -#include "e-contact-editor.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); -static gboolean e_minicard_view_event (GnomeCanvasItem *item, GdkEvent *event); -static void canvas_destroy (GtkObject *object, EMinicardView *view); -static void disconnect_signals (EMinicardView *view); - -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; - - item_class->event = e_minicard_view_event; - - /* 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; - view->canvas_destroy_id = 0; - - gtk_object_set(GTK_OBJECT(view), - "empty_message", _("\n\nThere are no items to show in this view\n\n" - "Double-click here to create a new Contact."), - NULL); - - 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)) { - ECard *card = cards->data; - gchar *id = e_card_get_id(card); - GnomeCanvasItem *item = e_reflow_sorted_get_item(E_REFLOW_SORTED(view), id); - if (item && !GTK_OBJECT_DESTROYED(item)) { - gnome_canvas_item_set(item, - "card", card, - NULL); - e_reflow_sorted_reorder_item(E_REFLOW_SORTED(view), id); - } - } -} - -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; - disconnect_signals(view); - if (view->book_view) - gtk_object_unref(GTK_OBJECT(view->book_view)); - - if (!view->canvas_destroy_id) - view->canvas_destroy_id = - gtk_signal_connect(GTK_OBJECT(GNOME_CANVAS_ITEM(view)->canvas), - "destroy", GTK_SIGNAL_FUNC(canvas_destroy), - 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_unref, NULL); - 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) -{ - if (view->book && view->query) - 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: - 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->canvas_destroy_id) - gtk_signal_disconnect(GTK_OBJECT (GNOME_CANVAS_ITEM(view)->canvas), - view->canvas_destroy_id); - disconnect_signals(view); - g_free(view->query); - if (view->book) - gtk_object_unref(GTK_OBJECT(view->book)); - if (view->book_view) - gtk_object_unref(GTK_OBJECT(view->book_view)); - - GTK_OBJECT_CLASS(parent_class)->destroy (object); -} - -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 -card_changed_cb (EBook* book, EBookStatus status, gpointer user_data) -{ - g_print ("%s: %s(): a card was changed with status %d\n", __FILE__, __FUNCTION__, status); -} - -/* Callback for the add_card signal from the contact editor */ -static void -add_card_cb (EContactEditor *ce, ECard *card, gpointer data) -{ - EBook *book; - - book = E_BOOK (data); - e_book_add_card (book, card, card_added_cb, NULL); -} - -/* Callback for the commit_card signal from the contact editor */ -static void -commit_card_cb (EContactEditor *ce, ECard *card, gpointer data) -{ - EBook *book; - - book = E_BOOK (data); - e_book_commit_card (book, card, card_changed_cb, NULL); -} - -/* Callback used when the contact editor is closed */ -static void -editor_closed_cb (EContactEditor *ce, gpointer data) -{ - gtk_object_unref (GTK_OBJECT (ce)); -} - -static gboolean -e_minicard_view_event (GnomeCanvasItem *item, GdkEvent *event) -{ - EMinicardView *view; - - view = E_MINICARD_VIEW (item); - - switch( event->type ) { - case GDK_2BUTTON_PRESS: - if (((GdkEventButton *)event)->button == 1) - { - ECard *card; - EContactEditor *ce; - EBook *book; - - card = e_card_new(""); - - gtk_object_get(GTK_OBJECT(view), "book", &book, NULL); - g_assert (E_IS_BOOK (book)); - - ce = e_contact_editor_new (card, TRUE); - - gtk_signal_connect (GTK_OBJECT (ce), "add_card", - GTK_SIGNAL_FUNC (add_card_cb), book); - gtk_signal_connect (GTK_OBJECT (ce), "commit_card", - GTK_SIGNAL_FUNC (commit_card_cb), book); - gtk_signal_connect (GTK_OBJECT (ce), "editor_closed", - GTK_SIGNAL_FUNC (editor_closed_cb), NULL); - - gtk_object_sink(GTK_OBJECT(card)); - } - return TRUE; - default: - if (GNOME_CANVAS_ITEM_CLASS(parent_class)->event) - return GNOME_CANVAS_ITEM_CLASS(parent_class)->event(item, event); - else - return FALSE; - break; - } -} - -static void -disconnect_signals(EMinicardView *view) -{ - 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); -} - -static void -canvas_destroy(GtkObject *object, EMinicardView *view) -{ - disconnect_signals(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; - } - } - } -} - -static int -compare_to_letter(EMinicard *card, char *letter) -{ - g_return_val_if_fail(card != NULL, 0); - g_return_val_if_fail(E_IS_MINICARD(card), 0); - - if (*letter == '1') - return 1; - - if (card->card) { - char *file_as; - gtk_object_get(GTK_OBJECT(card->card), - "file_as", &file_as, - NULL); - if (file_as) - return strncasecmp(file_as, letter, 1); - else - return 0; - } else { - return 0; - } -} - -void e_minicard_view_jump_to_letter (EMinicardView *view, - char letter) -{ - e_reflow_sorted_jump(E_REFLOW_SORTED(view), - (GCompareFunc) compare_to_letter, - &letter); -} diff --git a/addressbook/gui/minicard/e-minicard-view.h b/addressbook/gui/minicard/e-minicard-view.h deleted file mode 100644 index a166a6ade1..0000000000 --- a/addressbook/gui/minicard/e-minicard-view.h +++ /dev/null @@ -1,95 +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 canvas_destroy_id; - - 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); -void e_minicard_view_jump_to_letter (EMinicardView *view, - char letter); - -#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 4a73fc8eb4..0000000000 --- a/addressbook/gui/minicard/e-minicard.c +++ /dev/null @@ -1,728 +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 -#include "e-contact-editor.h" -#include "e-contact-save-as.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; - -typedef struct _EMinicardField EMinicardField; - -struct _EMinicardField { - ECardSimpleField field; - GnomeCanvasItem *label; -}; - -#define E_MINICARD_FIELD(field) ((EMinicardField *)(field)) - -static void -e_minicard_field_destroy(EMinicardField *field) -{ - gtk_object_destroy(GTK_OBJECT(field->label)); - g_free(field); -} - -/* 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; - minicard->simple = e_card_simple_new(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(E_MINICARD_FIELD(e_minicard->fields->data)->label, - "has_focus", GTK_VALUE_ENUM(*arg), - NULL); - } else if ( GTK_VALUE_ENUM(*arg) == E_FOCUS_END ) { - gnome_canvas_item_set(E_MINICARD_FIELD(g_list_last(e_minicard->fields)->data)->label, - "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)); - gtk_object_set(GTK_OBJECT(e_minicard->simple), - "card", e_minicard->card, - NULL); - 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: - e_card_simple_sync_card(e_minicard->simple); - 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); - - g_list_foreach(e_minicard->fields, (GFunc) e_minicard_field_destroy, NULL); - g_list_free(e_minicard->fields); - - if (e_minicard->card) - gtk_object_unref (GTK_OBJECT(e_minicard->card)); - if (e_minicard->simple) - gtk_object_unref (GTK_OBJECT(e_minicard->simple)); - - 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_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 -card_changed_cb (EBook* book, EBookStatus status, gpointer user_data) -{ - g_print ("%s: %s(): a card was changed with status %d\n", __FILE__, __FUNCTION__, status); -} - -static void -save_as (GtkWidget *widget, EMinicard *minicard) -{ - e_card_simple_sync_card(minicard->simple); - e_contact_save_as(_("Save as VCard"), minicard->card); -} - -/* Callback for the add_card signal from the contact editor */ -static void -add_card_cb (EContactEditor *ce, ECard *card, gpointer data) -{ - EBook *book; - - book = E_BOOK (data); - e_book_add_card (book, card, card_added_cb, NULL); -} - -/* Callback for the commit_card signal from the contact editor */ -static void -commit_card_cb (EContactEditor *ce, ECard *card, gpointer data) -{ - EBook *book; - - book = E_BOOK (data); - e_book_commit_card (book, card, card_changed_cb, NULL); -} - -/* Callback used when the contact editor is closed */ -static void -editor_closed_cb (EContactEditor *ce, gpointer data) -{ - gtk_object_unref (GTK_OBJECT (ce)); -} - -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 { - EBook *book; - - e_card_simple_sync_card(e_minicard->simple); - - gtk_object_get(GTK_OBJECT(GNOME_CANVAS_ITEM(e_minicard)->parent), - "book", &book, - NULL); - - /* Add the card in the contact editor to our ebook */ - e_book_commit_card (book, - e_minicard->card, - card_changed_cb, - NULL); - - 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); - } else if (event->button.button == 3) { - EPopupMenu menu[] = { {"Save as VCard", NULL, GTK_SIGNAL_FUNC(save_as), 0}, {NULL, NULL, NULL, 0} }; - e_popup_menu_run (menu, (GdkEventButton *)event, 0, e_minicard); - } - break; - - case GDK_2BUTTON_PRESS: - if (event->button.button == 1 && E_IS_MINICARD_VIEW(item->parent)) { - EContactEditor *ce; - EBook *book; - - gtk_object_get(GTK_OBJECT(item->parent), - "book", &book, - NULL); - g_assert (E_IS_BOOK (book)); - - ce = e_contact_editor_new (e_minicard->card, FALSE); - - gtk_signal_connect (GTK_OBJECT (ce), "add_card", - GTK_SIGNAL_FUNC (add_card_cb), book); - gtk_signal_connect (GTK_OBJECT (ce), "commit_card", - GTK_SIGNAL_FUNC (commit_card_cb), book); - gtk_signal_connect (GTK_OBJECT (ce), "editor_closed", - GTK_SIGNAL_FUNC (editor_closed_cb), NULL); - - return TRUE; - } - 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) { - EMinicardField *field = E_MINICARD_FIELD(list->data); - GnomeCanvasItem *item = field->label; - 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) { - EMinicardField *field = E_MINICARD_FIELD(list->data); - GnomeCanvasItem *item = field->label; - 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( E_MINICARD_FIELD( list->data )->label, - "width", (double) e_minicard->width - 4.0, - NULL ); - } - } -} - -static void -field_changed (EText *text, EMinicard *e_minicard) -{ - ECardSimpleType type; - char *string; - - type = GPOINTER_TO_INT - (gtk_object_get_data(GTK_OBJECT(text), - "EMinicard:field")); - gtk_object_get(GTK_OBJECT(text), - "text", &string, - NULL); - e_card_simple_set(e_minicard->simple, - type, - string); - g_free(string); -} - -static void -add_field (EMinicard *e_minicard, ECardSimpleField field, gdouble left_width) -{ - GnomeCanvasItem *new_item; - GnomeCanvasGroup *group; - ECardSimpleType type; - EMinicardField *minicard_field; - char *name; - char *string; - - group = GNOME_CANVAS_GROUP( e_minicard ); - - type = e_card_simple_type(e_minicard->simple, field); - name = g_strdup_printf("%s:", e_card_simple_get_name(e_minicard->simple, field)); - string = e_card_simple_get(e_minicard->simple, field); - - new_item = e_minicard_label_new(group); - gnome_canvas_item_set( new_item, - "width", e_minicard->width - 4.0, - "fieldname", name, - "field", string, - "max_field_name_length", left_width, - NULL ); - gtk_signal_connect(GTK_OBJECT(E_MINICARD_LABEL(new_item)->field), - "changed", GTK_SIGNAL_FUNC(field_changed), e_minicard); - gtk_object_set_data(GTK_OBJECT(E_MINICARD_LABEL(new_item)->field), - "EMinicard:field", - GINT_TO_POINTER(field)); - - minicard_field = g_new(EMinicardField, 1); - minicard_field->field = field; - minicard_field->label = new_item; - - e_minicard->fields = g_list_append( e_minicard->fields, minicard_field); - e_canvas_item_move_absolute(new_item, 2, e_minicard->height); - g_free(name); - g_free(string); -} - -static gdouble -get_left_width(EMinicard *e_minicard) -{ - gchar *name; - ECardSimpleField field; - gdouble width = -1; - static GdkFont *font = NULL; - - if (font == NULL) { - font = gdk_font_load("lucidasans-10"); - } - - for(field = E_CARD_SIMPLE_FIELD_FULL_NAME; field != E_CARD_SIMPLE_FIELD_LAST; field++) { - gdouble this_width; - name = g_strdup_printf("%s:", e_card_simple_get_name(e_minicard->simple, field)); - this_width = gdk_text_width(font, name, strlen(name)); - if (width < this_width) - width = this_width; - g_free(name); - } - return width; -} - -static void -remodel( EMinicard *e_minicard ) -{ - int count = 0; - if (e_minicard->simple) { - ECardSimpleField field; - GList *list; - char *file_as; - gdouble left_width = -1; - - if (e_minicard->header_text) { - file_as = e_card_simple_get(e_minicard->simple, E_CARD_SIMPLE_FIELD_FILE_AS); - gnome_canvas_item_set( e_minicard->header_text, - "text", file_as ? file_as : "", - NULL ); - g_free(file_as); - } - - list = e_minicard->fields; - e_minicard->fields = NULL; - - for(field = E_CARD_SIMPLE_FIELD_FULL_NAME; field != E_CARD_SIMPLE_FIELD_LAST && count < 5; field++) { - EMinicardField *minicard_field = NULL; - - if (list) - minicard_field = list->data; - if (minicard_field && minicard_field->field == field) { - GList *this_list = list; - char *string; - - string = e_card_simple_get(e_minicard->simple, field); - if (string && *string) { - e_minicard->fields = g_list_append(e_minicard->fields, minicard_field); - gtk_object_set(GTK_OBJECT(minicard_field->label), - "field", string, - NULL); - count ++; - } else { - e_minicard_field_destroy(minicard_field); - } - list = g_list_remove_link(list, this_list); - g_list_free_1(this_list); - g_free(string); - } else { - char *string; - if (left_width == -1) { - left_width = get_left_width(e_minicard); - } - - string = e_card_simple_get(e_minicard->simple, field); - if (string && *string) { - add_field(e_minicard, field, left_width); - count++; - } - g_free(string); - } - } - - g_list_foreach(list, (GFunc) e_minicard_field_destroy, NULL); - g_list_free(list); - } -} - -static void -e_minicard_reflow( GnomeCanvasItem *item, int flags ) -{ - EMinicard *e_minicard = E_MINICARD(item); - if ( GTK_OBJECT_FLAGS( e_minicard ) & GNOME_CANVAS_ITEM_REALIZED ) { - GList *list; - gdouble text_height; - gint old_height; - - old_height = e_minicard->height; - - 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)) { - EMinicardField *field = E_MINICARD_FIELD(list->data); - GnomeCanvasItem *item = field->label; - gtk_object_get (GTK_OBJECT(item), - "height", &text_height, - NULL); - e_canvas_item_move_absolute(item, 2, e_minicard->height); - e_minicard->height += text_height; - } - e_minicard->height += 2; - - gnome_canvas_item_set( e_minicard->rect, - "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 ""; - } -} - -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 *file_as1, *file_as2; - gtk_object_get(GTK_OBJECT(minicard1->card), - "file_as", &file_as1, - NULL); - gtk_object_get(GTK_OBJECT(minicard2->card), - "file_as", &file_as2, - NULL); - if (file_as1 && file_as2) - return strcasecmp(file_as1, file_as2); - if (file_as1) - return -1; - if (file_as2) - return 1; - return strcmp(e_minicard_get_card_id(minicard1), e_minicard_get_card_id(minicard2)); - } else { - return 0; - } -} diff --git a/addressbook/gui/minicard/e-minicard.h b/addressbook/gui/minicard/e-minicard.h deleted file mode 100644 index 47da8110c2..0000000000 --- a/addressbook/gui/minicard/e-minicard.h +++ /dev/null @@ -1,98 +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 -#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; - ECardSimple *simple; - - GnomeCanvasItem *rect; - GnomeCanvasItem *header_rect; - GnomeCanvasItem *header_text; - - GList *fields; /* Of type EMinicardField */ - 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 2d2dcee787..0000000000 --- a/addressbook/gui/minicard/e-reflow-sorted.c +++ /dev/null @@ -1,272 +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); - -#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 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; - } -} - -static GList * -e_reflow_sorted_get_list(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)) { - return list; - } - } - } - return NULL; -} - -void -e_reflow_sorted_remove_item(EReflowSorted *e_reflow_sorted, const gchar *id) -{ - GList *list; - GnomeCanvasItem *item = NULL; - - list = e_reflow_sorted_get_list(e_reflow_sorted, id); - if (list) - item = list->data; - - if (item) { - EReflow *reflow = E_REFLOW(e_reflow_sorted); - reflow->items = g_list_remove_link(reflow->items, list); - g_list_free_1(list); - gtk_object_unref(GTK_OBJECT(item)); - gtk_object_destroy(GTK_OBJECT(item)); - if ( GTK_OBJECT_FLAGS( e_reflow_sorted ) & GNOME_CANVAS_ITEM_REALIZED ) { - e_canvas_item_request_reflow(GNOME_CANVAS_ITEM(e_reflow_sorted)); - e_reflow_post_add_item(E_REFLOW(e_reflow_sorted), NULL); - } - } -} - -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); - } -} - -GnomeCanvasItem * -e_reflow_sorted_get_item(EReflowSorted *e_reflow_sorted, const gchar *id) -{ - GList *list; - list = e_reflow_sorted_get_list(e_reflow_sorted, id); - if (list) - return list->data; - else - return NULL; -} - -void -e_reflow_sorted_reorder_item(EReflowSorted *e_reflow_sorted, const gchar *id) -{ - GList *list; - GnomeCanvasItem *item = NULL; - - list = e_reflow_sorted_get_list(e_reflow_sorted, id); - if (list) - item = list->data; - if (item) { - EReflow *reflow = E_REFLOW(e_reflow_sorted); - reflow->items = g_list_remove_link(reflow->items, list); - gtk_object_unref(GTK_OBJECT(item)); - g_list_free_1(list); - e_reflow_sorted_add_item(reflow, item); - e_canvas_item_request_reflow(GNOME_CANVAS_ITEM(e_reflow_sorted)); - } -} - -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); - gtk_object_ref(GTK_OBJECT(item)); - - 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(GNOME_CANVAS_ITEM(e_reflow_sorted)); - } - } - e_reflow_post_add_item(reflow, item); -} - -void e_reflow_sorted_jump (EReflowSorted *sorted, - GCompareFunc compare_func, - void *value) -{ - int columns = 0; - EReflow *reflow = E_REFLOW(sorted); - GList *list; - GtkAdjustment *adjustment; - - for (list = reflow->columns; list; list = g_list_next(list)) { - if (compare_func(((GList *)list->data)->data, value) >= 0) { - GList *last = list->prev; - if (last) { - GList *walk; - for (walk = last->data; walk != list->data; walk = g_list_next(walk)) { - if (compare_func(walk->data, value) >= 0) { - columns --; - break; - } - } - } - adjustment = gtk_layout_get_hadjustment(GTK_LAYOUT(GNOME_CANVAS_ITEM(sorted)->canvas)); - gtk_adjustment_set_value(adjustment, (reflow->column_width + E_REFLOW_FULL_GUTTER) * columns); - return; - } - columns ++; - } - columns --; - adjustment = gtk_layout_get_hadjustment(GTK_LAYOUT(GNOME_CANVAS_ITEM(sorted)->canvas)); - gtk_adjustment_set_value(adjustment, (reflow->column_width + E_REFLOW_FULL_GUTTER) * columns); -} diff --git a/addressbook/gui/minicard/e-reflow-sorted.h b/addressbook/gui/minicard/e-reflow-sorted.h deleted file mode 100644 index 7adfa2c045..0000000000 --- a/addressbook/gui/minicard/e-reflow-sorted.h +++ /dev/null @@ -1,90 +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); -void e_reflow_sorted_reorder_item (EReflowSorted *e_reflow_sorted, const gchar *id); -GnomeCanvasItem *e_reflow_sorted_get_item (EReflowSorted *e_reflow_sorted, const gchar *id); -GtkType e_reflow_sorted_get_type (void); -void e_reflow_sorted_jump (EReflowSorted *sorted, GCompareFunc compare_func, void *value); - -#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 ba7bf36c4d..0000000000 --- a/addressbook/gui/minicard/e-reflow.c +++ /dev/null @@ -1,848 +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 "e-text.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 set_empty(EReflow *e_reflow); - -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, - ARG_EMPTY_MESSAGE, -}; - -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); - gtk_object_add_arg_type ("EReflow::empty_message", GTK_TYPE_STRING, - GTK_ARG_READWRITE, ARG_EMPTY_MESSAGE); - - 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->empty_message = NULL; - reflow->empty_text = NULL; - - 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); - if (GNOME_CANVAS_ITEM_REALIZED & GTK_OBJECT_FLAGS(o)) - set_empty(e_reflow); - e_canvas_item_request_reflow(item); - break; - case ARG_EMPTY_MESSAGE: - g_free(e_reflow->empty_message); - e_reflow->empty_message = g_strdup(GTK_VALUE_STRING (*arg)); - if (GNOME_CANVAS_ITEM_REALIZED & GTK_OBJECT_FLAGS(o)) - set_empty(e_reflow); - } -} - -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; - case ARG_EMPTY_MESSAGE: - GTK_VALUE_STRING (*arg) = g_strdup(e_reflow->empty_message); - break; - default: - arg->type = GTK_TYPE_INVALID; - break; - } -} - -static void -e_reflow_destroy (GtkObject *object) -{ - EReflow *reflow = E_REFLOW(object); - - g_list_foreach(reflow->items, (GFunc) gtk_object_unref, NULL); - g_list_free(reflow->items); - reflow->items = NULL; - - g_free(reflow->empty_message); - - GTK_OBJECT_CLASS(parent_class)->destroy (object); -} - -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); - } - - set_empty(e_reflow); - - 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); - gtk_object_ref(GTK_OBJECT(item)); - if ( GTK_OBJECT_FLAGS( e_reflow ) & GNOME_CANVAS_ITEM_REALIZED ) { - gnome_canvas_item_set(item, - "width", (double) e_reflow->column_width, - NULL); - e_reflow_post_add_item(e_reflow, item); - 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 = 0; - 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 -set_empty(EReflow *e_reflow) -{ - if (e_reflow->items == NULL) { - if (e_reflow->empty_text) { - if (e_reflow->empty_message) { - gnome_canvas_item_set(e_reflow->empty_text, - "width", e_reflow->minimum_width, - "text", e_reflow->empty_message, - NULL); - e_canvas_item_move_absolute(e_reflow->empty_text, - e_reflow->minimum_width / 2, - 0); - } else { - gtk_object_destroy(GTK_OBJECT(e_reflow->empty_text)); - e_reflow->empty_text = NULL; - } - } else { - if (e_reflow->empty_message) - e_reflow->empty_text = - gnome_canvas_item_new(GNOME_CANVAS_GROUP(e_reflow), - e_text_get_type(), - "anchor", GTK_ANCHOR_N, - "width", e_reflow->minimum_width, - "clip", TRUE, - "use_ellipsis", TRUE, - "font_gdk", GTK_WIDGET(GNOME_CANVAS_ITEM(e_reflow)->canvas)->style->font, - "fill_color", "black", - "justification", GTK_JUSTIFY_CENTER, - "text", e_reflow->empty_message, - NULL); - e_canvas_item_move_absolute(e_reflow->empty_text, - e_reflow->minimum_width / 2, - 0); - } - } else { - if (e_reflow->empty_text) { - gtk_object_destroy(GTK_OBJECT(e_reflow->empty_text)); - e_reflow->empty_text = NULL; - } - } -} - -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); -} - -void -e_reflow_post_add_item(EReflow *e_reflow, GnomeCanvasItem *item) -{ - set_empty(e_reflow); -} diff --git a/addressbook/gui/minicard/e-reflow.h b/addressbook/gui/minicard/e-reflow.h deleted file mode 100644 index eb66b094a5..0000000000 --- a/addressbook/gui/minicard/e-reflow.h +++ /dev/null @@ -1,112 +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 */ - - GnomeCanvasItem *empty_text; - gchar *empty_message; - - 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); - -/* Internal usage only: */ -void e_reflow_post_add_item(EReflow *e_reflow, GnomeCanvasItem *item); - -#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 57bc69222a..0000000000 --- a/addressbook/gui/minicard/test-minicard-label.c +++ /dev/null @@ -1,126 +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, - "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 e16ca675b3..0000000000 --- a/addressbook/gui/minicard/test-minicard.c +++ /dev/null @@ -1,115 +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(), - "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 dacaeb055c..0000000000 --- a/addressbook/gui/minicard/test-reflow.c +++ /dev/null @@ -1,191 +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(), - "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 0eb7946ac5..0000000000 --- a/addressbook/gui/widgets/Makefile.am +++ /dev/null @@ -1,94 +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 \ - $(BONOBO_GNOME_CFLAGS) - -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 \ - $(BONOBO_GNOME_LIBS) \ - $(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 \ - $(BONOBO_GNOME_LIBS) \ - $(top_builddir)/addressbook/backend/ebook/libebook.la \ - $(top_builddir)/e-util/libeutil.la \ - $(top_builddir)/libversit/libversit.la \ - $(top_builddir)/addressbook/ename/libename.la \ - $(top_builddir)/addressbook/contact-editor/libecontacteditor.a \ - $(top_builddir)/widgets/e-table/libetable.a \ - $(top_builddir)/widgets/misc/libemiscwidgets.a \ - $(top_builddir)/e-util/libeutil.la \ - $(top_builddir)/widgets/e-text/libetext.a - -reflow_test_SOURCES = \ - test-reflow.c - -reflow_test_LDADD = \ - $(EXTRA_GNOME_LIBS) \ - $(GNOMEGNORBA_LIBS) \ - $(BONOBO_GNOME_LIBS) \ - libeminicard.a \ - $(top_builddir)/addressbook/backend/ebook/libebook.la \ - $(top_builddir)/e-util/libeutil.la \ - $(top_builddir)/libversit/libversit.la \ - $(top_builddir)/addressbook/ename/libename.la \ - $(top_builddir)/addressbook/contact-editor/libecontacteditor.a \ - $(top_builddir)/widgets/e-table/libetable.a \ - $(top_builddir)/widgets/misc/libemiscwidgets.a \ - $(top_builddir)/e-util/libeutil.la \ - $(top_builddir)/widgets/e-text/libetext.a - -minicard_view_test_SOURCES = \ - test-minicard-view.c - -minicard_view_test_LDADD = \ - $(EXTRA_GNOME_LIBS) \ - $(GNOMEGNORBA_LIBS) \ - $(BONOBO_GNOME_LIBS) \ - libeminicard.a \ - $(top_builddir)/addressbook/backend/ebook/libebook.la \ - $(top_builddir)/e-util/libeutil.la \ - $(top_builddir)/libversit/libversit.la \ - $(top_builddir)/addressbook/ename/libename.la \ - $(top_builddir)/addressbook/contact-editor/libecontacteditor.a \ - $(top_builddir)/widgets/e-table/libetable.a \ - $(top_builddir)/widgets/misc/libemiscwidgets.a \ - $(top_builddir)/e-util/libeutil.la \ - $(top_builddir)/widgets/e-text/libetext.a diff --git a/addressbook/gui/widgets/alphabet.glade b/addressbook/gui/widgets/alphabet.glade deleted file mode 100644 index bc6e5f3798..0000000000 --- a/addressbook/gui/widgets/alphabet.glade +++ /dev/null @@ -1,357 +0,0 @@ - - - - - alphabet - alphabet - - src - pixmaps - C - True - True - True - False - False - False - True - True - alphabet.glade.h - - - - GtkWindow - window2 - False - window2 - GTK_WINDOW_TOPLEVEL - GTK_WIN_POS_NONE - False - False - True - False - - - GtkScrolledWindow - scrolledwindow-top - GTK_POLICY_NEVER - GTK_POLICY_AUTOMATIC - GTK_UPDATE_CONTINUOUS - GTK_UPDATE_CONTINUOUS - - - GtkViewport - viewport1 - 4 - GTK_SHADOW_NONE - - - GtkVBox - vbox2 - 27 - False - 4 - - - GtkButton - button-1 - - - 0 - False - False - - - - - GtkButton - button-a - - - 0 - False - False - - - - - GtkButton - button-b - - - 0 - False - False - - - - - GtkButton - button-c - - - 0 - False - False - - - - - GtkButton - button-d - - - 0 - False - False - - - - - GtkButton - button-e - - - 0 - False - False - - - - - GtkButton - button-f - - - 0 - False - False - - - - - GtkButton - button-g - - - 0 - False - False - - - - - GtkButton - button-h - - - 0 - False - False - - - - - GtkButton - button-i - - - 0 - False - False - - - - - GtkButton - button-j - - - 0 - False - False - - - - - GtkButton - button-k - - - 0 - False - False - - - - - GtkButton - button-l - - - 0 - False - False - - - - - GtkButton - button-m - - - 0 - False - False - - - - - GtkButton - button-n - - - 0 - False - False - - - - - GtkButton - button-o - - - 0 - False - False - - - - - GtkButton - button-p - - - 0 - False - False - - - - - GtkButton - button-q - - - 0 - False - False - - - - - GtkButton - button-r - - - 0 - False - False - - - - - GtkButton - button-s - - - 0 - False - False - - - - - GtkButton - button-t - - - 0 - False - False - - - - - GtkButton - button-u - - - 0 - False - False - - - - - GtkButton - button-v - - - 0 - False - False - - - - - GtkButton - button-w - True - - - 0 - False - False - - - - - GtkButton - button-x - - - 0 - False - False - - - - - GtkButton - button-y - - - 0 - False - False - - - - - GtkButton - button-z - - - 0 - False - False - - - - - - - - diff --git a/addressbook/gui/widgets/alphabet.glade.h b/addressbook/gui/widgets/alphabet.glade.h deleted file mode 100644 index 2448eeb4fc..0000000000 --- a/addressbook/gui/widgets/alphabet.glade.h +++ /dev/null @@ -1,34 +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_("window2"); -gchar *s = N_("123"); -gchar *s = N_("a"); -gchar *s = N_("b"); -gchar *s = N_("c"); -gchar *s = N_("d"); -gchar *s = N_("e"); -gchar *s = N_("f"); -gchar *s = N_("g"); -gchar *s = N_("h"); -gchar *s = N_("i"); -gchar *s = N_("j"); -gchar *s = N_("k"); -gchar *s = N_("l"); -gchar *s = N_("m"); -gchar *s = N_("n"); -gchar *s = N_("o"); -gchar *s = N_("p"); -gchar *s = N_("q"); -gchar *s = N_("r"); -gchar *s = N_("s"); -gchar *s = N_("t"); -gchar *s = N_("u"); -gchar *s = N_("v"); -gchar *s = N_("w"); -gchar *s = N_("x"); -gchar *s = N_("y"); -gchar *s = N_("z"); diff --git a/addressbook/gui/widgets/e-addressbook-model.c b/addressbook/gui/widgets/e-addressbook-model.c deleted file mode 100644 index 7deda52c98..0000000000 --- a/addressbook/gui/widgets/e-addressbook-model.c +++ /dev/null @@ -1,396 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * - * Author: - * Christopher James Lahey - * - * (C) 1999 Helix Code, Inc. - */ - -#include -#include "e-addressbook-model.h" -#include -#include -#include -#include - -#define PARENT_TYPE e_table_model_get_type() -ETableModelClass *parent_class; - -/* - * EAddressbookModel callbacks - * These are the callbacks that define the behavior of our custom model. - */ -static void e_addressbook_model_set_arg (GtkObject *o, GtkArg *arg, guint arg_id); -static void e_addressbook_model_get_arg (GtkObject *object, GtkArg *arg, guint arg_id); - - -enum { - ARG_0, - ARG_BOOK, - ARG_QUERY, -}; - -static void -addressbook_destroy(GtkObject *object) -{ - EAddressbookModel *model = E_ADDRESSBOOK_MODEL(object); - int i; - - if (model->get_view_idle) - g_source_remove(model->get_view_idle); - if (model->book_view && model->create_card_id) - gtk_signal_disconnect(GTK_OBJECT (model->book_view), - model->create_card_id); - if (model->book_view && model->remove_card_id) - gtk_signal_disconnect(GTK_OBJECT (model->book_view), - model->remove_card_id); - if (model->book_view && model->modify_card_id) - gtk_signal_disconnect(GTK_OBJECT (model->book_view), - model->modify_card_id); - 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); -} - -/* This function returns the number of columns in our ETableModel. */ -static int -addressbook_col_count (ETableModel *etc) -{ - return E_CARD_SIMPLE_FIELD_LAST; -} - -/* This function returns the number of rows in our ETableModel. */ -static int -addressbook_row_count (ETableModel *etc) -{ - EAddressbookModel *addressbook = E_ADDRESSBOOK_MODEL(etc); - return addressbook->data_count; -} - -/* This function returns the value at a particular point in our ETableModel. */ -static void * -addressbook_value_at (ETableModel *etc, int col, int row) -{ - EAddressbookModel *addressbook = E_ADDRESSBOOK_MODEL(etc); - const char *value; - if ( col >= E_CARD_SIMPLE_FIELD_LAST - 1|| row >= addressbook->data_count ) - return NULL; - value = e_card_simple_get_const(addressbook->data[row], - col + 1); - return (void *)(value ? value : ""); -} - -/* This function sets the value at a particular point in our ETableModel. */ -static void -addressbook_set_value_at (ETableModel *etc, int col, int row, const void *val) -{ - EAddressbookModel *addressbook = E_ADDRESSBOOK_MODEL(etc); - ECard *card; - if ( col >= E_CARD_SIMPLE_FIELD_LAST - 1|| row >= addressbook->data_count ) - return; - e_card_simple_set(addressbook->data[row], - col + 1, - val); - gtk_object_get(GTK_OBJECT(addressbook->data[row]), - "card", &card, - NULL); - e_book_commit_card(addressbook->book, card, NULL, NULL); - - e_table_model_cell_changed(etc, col, row); -} - -/* This function returns whether a particular cell is editable. */ -static gboolean -addressbook_is_cell_editable (ETableModel *etc, int col, int row) -{ - return TRUE; -} - -static gint -addressbook_append_row (ETableModel *etm) -{ - ECard *card; - EAddressbookModel *model = E_ADDRESSBOOK_MODEL(etm); - model->data = g_realloc(model->data, (model->data_count + 1) * sizeof(ECard *)); - card = e_card_new(""); - model->data[model->data_count++] = e_card_simple_new (card); - gtk_object_unref(GTK_OBJECT(card)); - e_table_model_row_inserted(E_TABLE_MODEL(model), model->data_count - 1); - return model->data_count - 1; -} - -/* This function duplicates the value passed to it. */ -static void * -addressbook_duplicate_value (ETableModel *etc, int col, const void *value) -{ - return g_strdup(value); -} - -/* This function frees the value passed to it. */ -static void -addressbook_free_value (ETableModel *etc, int col, void *value) -{ - g_free(value); -} - -static void * -addressbook_initialize_value (ETableModel *etc, int col) -{ - return g_strdup(""); -} - -static gboolean -addressbook_value_is_empty (ETableModel *etc, int col, const void *value) -{ - return !(value && *(char *)value); -} - -static char * -addressbook_value_to_string (ETableModel *etc, int col, const void *value) -{ - return g_strdup(value); -} - -static void -create_card(EBookView *book_view, - const GList *cards, - EAddressbookModel *model) -{ - model->data = g_realloc(model->data, (model->data_count + g_list_length((GList *)cards)) * sizeof(ECard *)); - for ( ; cards; cards = cards->next) { - model->data[model->data_count++] = e_card_simple_new (E_CARD(cards->data)); - e_table_model_row_inserted(E_TABLE_MODEL(model), model->data_count - 1); - } -} - -static void -remove_card(EBookView *book_view, - const char *id, - EAddressbookModel *model) -{ - int i; - for ( i = 0; i < model->data_count; i++) { - if ( !strcmp(e_card_simple_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_row_deleted(E_TABLE_MODEL(model), i); - } - } -} - -static void -modify_card(EBookView *book_view, - const GList *cards, - EAddressbookModel *model) -{ - for ( ; cards; cards = cards->next) { - int i; - for ( i = 0; i < model->data_count; i++) { - if ( !strcmp(e_card_simple_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_simple_new(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_addressbook_model_class_init (GtkObjectClass *object_class) -{ - ETableModelClass *model_class = (ETableModelClass *) object_class; - - parent_class = gtk_type_class (PARENT_TYPE); - - object_class->destroy = addressbook_destroy; - object_class->set_arg = e_addressbook_model_set_arg; - object_class->get_arg = e_addressbook_model_get_arg; - - gtk_object_add_arg_type ("EAddressbookModel::book", GTK_TYPE_OBJECT, - GTK_ARG_READWRITE, ARG_BOOK); - gtk_object_add_arg_type ("EAddressbookModel::query", GTK_TYPE_STRING, - GTK_ARG_READWRITE, ARG_QUERY); - - model_class->column_count = addressbook_col_count; - model_class->row_count = addressbook_row_count; - model_class->value_at = addressbook_value_at; - model_class->set_value_at = addressbook_set_value_at; - model_class->is_cell_editable = addressbook_is_cell_editable; - model_class->append_row = addressbook_append_row; - model_class->duplicate_value = addressbook_duplicate_value; - model_class->free_value = addressbook_free_value; - model_class->initialize_value = addressbook_initialize_value; - model_class->value_is_empty = addressbook_value_is_empty; - model_class->value_to_string = addressbook_value_to_string; -} - -static void -e_addressbook_model_init (GtkObject *object) -{ - EAddressbookModel *model = E_ADDRESSBOOK_MODEL(object); - model->book = NULL; - model->query = g_strdup("(contains \"full_name\" \"\")"); - model->book_view = NULL; - model->get_view_idle = 0; - model->create_card_id = 0; - model->remove_card_id = 0; - model->modify_card_id = 0; - model->data = NULL; - model->data_count = 0; -} - -static void -book_view_loaded (EBook *book, EBookStatus status, EBookView *book_view, gpointer closure) -{ - EAddressbookModel *model = closure; - int i; - if (model->book_view && model->create_card_id) - gtk_signal_disconnect(GTK_OBJECT (model->book_view), - model->create_card_id); - if (model->book_view && model->remove_card_id) - gtk_signal_disconnect(GTK_OBJECT (model->book_view), - model->remove_card_id); - if (model->book_view && model->modify_card_id) - gtk_signal_disconnect(GTK_OBJECT (model->book_view), - model->modify_card_id); - if (model->book_view) - gtk_object_unref(GTK_OBJECT(model->book_view)); - model->book_view = book_view; - if (model->book_view) - gtk_object_ref(GTK_OBJECT(model->book_view)); - model->create_card_id = gtk_signal_connect(GTK_OBJECT(model->book_view), - "card_added", - GTK_SIGNAL_FUNC(create_card), - model); - model->remove_card_id = gtk_signal_connect(GTK_OBJECT(model->book_view), - "card_removed", - GTK_SIGNAL_FUNC(remove_card), - model); - model->modify_card_id = gtk_signal_connect(GTK_OBJECT(model->book_view), - "card_changed", - GTK_SIGNAL_FUNC(modify_card), - model); - - for ( i = 0; i < model->data_count; i++ ) { - gtk_object_unref(GTK_OBJECT(model->data[i])); - } - g_free(model->data); - model->data = NULL; - model->data_count = 0; - e_table_model_changed(E_TABLE_MODEL(model)); -} - -static gboolean -get_view(EAddressbookModel *model) -{ - if (model->book && model->query) - e_book_get_book_view(model->book, model->query, book_view_loaded, model); - - model->get_view_idle = 0; - return FALSE; -} - -ECard * -e_addressbook_model_get_card(EAddressbookModel *model, - int row) -{ - if (model->data && row < model->data_count) { - ECard *card; - gtk_object_get(GTK_OBJECT(model->data[row]), - "card", &card, - NULL); - gtk_object_ref(GTK_OBJECT(card)); - return card; - } - return NULL; -} - -static void -e_addressbook_model_set_arg (GtkObject *o, GtkArg *arg, guint arg_id) -{ - EAddressbookModel *model; - - model = E_ADDRESSBOOK_MODEL (o); - - switch (arg_id){ - case ARG_BOOK: - if (model->book) - gtk_object_unref(GTK_OBJECT(model->book)); - model->book = E_BOOK(GTK_VALUE_OBJECT (*arg)); - if (model->book) { - gtk_object_ref(GTK_OBJECT(model->book)); - if (model->get_view_idle == 0) - model->get_view_idle = g_idle_add((GSourceFunc)get_view, model); - } - break; - case ARG_QUERY: - if (model->query) - g_free(model->query); - model->query = g_strdup(GTK_VALUE_STRING (*arg)); - if (model->get_view_idle == 0) - model->get_view_idle = g_idle_add((GSourceFunc)get_view, model); - break; - } -} - -static void -e_addressbook_model_get_arg (GtkObject *object, GtkArg *arg, guint arg_id) -{ - EAddressbookModel *e_addressbook_model; - - e_addressbook_model = E_ADDRESSBOOK_MODEL (object); - - switch (arg_id) { - case ARG_BOOK: - GTK_VALUE_OBJECT (*arg) = GTK_OBJECT(e_addressbook_model->book); - break; - case ARG_QUERY: - GTK_VALUE_STRING (*arg) = g_strdup(e_addressbook_model->query); - break; - default: - arg->type = GTK_TYPE_INVALID; - break; - } -} - -GtkType -e_addressbook_model_get_type (void) -{ - static GtkType type = 0; - - if (!type){ - GtkTypeInfo info = { - "EAddressbookModel", - sizeof (EAddressbookModel), - sizeof (EAddressbookModelClass), - (GtkClassInitFunc) e_addressbook_model_class_init, - (GtkObjectInitFunc) e_addressbook_model_init, - NULL, /* reserved 1 */ - NULL, /* reserved 2 */ - (GtkClassInitFunc) NULL - }; - - type = gtk_type_unique (PARENT_TYPE, &info); - } - - return type; -} - -ETableModel * -e_addressbook_model_new (void) -{ - EAddressbookModel *et; - - et = gtk_type_new (e_addressbook_model_get_type ()); - - return E_TABLE_MODEL(et); -} diff --git a/addressbook/gui/widgets/e-addressbook-model.h b/addressbook/gui/widgets/e-addressbook-model.h deleted file mode 100644 index bff9a21d00..0000000000 --- a/addressbook/gui/widgets/e-addressbook-model.h +++ /dev/null @@ -1,52 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -#ifndef _E_ADDRESSBOOK_MODEL_H_ -#define _E_ADDRESSBOOK_MODEL_H_ - -#include "e-table-model.h" -#include -#include -#include - -#define E_ADDRESSBOOK_MODEL_TYPE (e_addressbook_model_get_type ()) -#define E_ADDRESSBOOK_MODEL(o) (GTK_CHECK_CAST ((o), E_ADDRESSBOOK_MODEL_TYPE, EAddressbookModel)) -#define E_ADDRESSBOOK_MODEL_CLASS(k) (GTK_CHECK_CLASS_CAST((k), E_ADDRESSBOOK_MODEL_TYPE, EAddressbookModelClass)) -#define E_IS_ADDRESSBOOK_MODEL(o) (GTK_CHECK_TYPE ((o), E_ADDRESSBOOK_MODEL_TYPE)) -#define E_IS_ADDRESSBOOK_MODEL_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), E_ADDRESSBOOK_MODEL_TYPE)) - -/* Virtual Column list: - 0 Email - 1 Full Name - 2 Street - 3 Phone -*/ - -typedef struct { - ETableModel parent; - - /* item specific fields */ - EBook *book; - char *query; - EBookView *book_view; - - int get_view_idle; - - ECardSimple **data; - int data_count; - - int create_card_id, remove_card_id, modify_card_id; -} EAddressbookModel; - - -typedef struct { - ETableModelClass parent_class; -} EAddressbookModelClass; - - -GtkType e_addressbook_model_get_type (void); -ETableModel *e_addressbook_model_new (void); - -/* Returns object with ref count of 1. */ -ECard *e_addressbook_model_get_card(EAddressbookModel *model, - int row); - -#endif /* _E_ADDRESSBOOK_MODEL_H_ */ diff --git a/addressbook/gui/widgets/e-minicard-label.c b/addressbook/gui/widgets/e-minicard-label.c deleted file mode 100644 index e765a89f21..0000000000 --- a/addressbook/gui/widgets/e-minicard-label.c +++ /dev/null @@ -1,446 +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, - ARG_MAX_FIELD_NAME_WIDTH, -}; - -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); - gtk_object_add_arg_type ("EMinicardLabel::max_field_name_length", GTK_TYPE_DOUBLE, - GTK_ARG_READWRITE, ARG_MAX_FIELD_NAME_WIDTH); - - 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; - - minicard_label->max_field_name_length = -1; - - e_canvas_item_set_reflow_callback(GNOME_CANVAS_ITEM(minicard_label), e_minicard_label_reflow); -} - -static void -e_minicard_label_set_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; - case ARG_MAX_FIELD_NAME_WIDTH: - e_minicard_label->max_field_name_length = GTK_VALUE_DOUBLE (*arg); - 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; - case ARG_MAX_FIELD_NAME_WIDTH: - GTK_VALUE_DOUBLE (*arg) = e_minicard_label->max_field_name_length; - 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) -{ - double left_width; - if (e_minicard_label->max_field_name_length != -1 && ((e_minicard_label->width / 2) - 4 > e_minicard_label->max_field_name_length)) - left_width = e_minicard_label->max_field_name_length; - else - left_width = e_minicard_label->width / 2 - 4; - - gnome_canvas_item_set( e_minicard_label->fieldname, - "clip_width", (double) ( left_width ), - NULL ); - gnome_canvas_item_set( e_minicard_label->field, - "clip_width", (double) ( e_minicard_label->width - 8 - left_width ), - 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; - gdouble left_width; - - 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 ); - - if (e_minicard_label->max_field_name_length != -1 && ((e_minicard_label->width / 2) - 4 > e_minicard_label->max_field_name_length)) - left_width = e_minicard_label->max_field_name_length; - else - left_width = e_minicard_label->width / 2 - 4; - - e_canvas_item_move_absolute(e_minicard_label->field, left_width + 6, 1); - - if (old_height != e_minicard_label->height) - e_canvas_item_request_parent_reflow(item); -} - -GnomeCanvasItem * -e_minicard_label_new(GnomeCanvasGroup *parent) -{ - GnomeCanvasItem *item = gnome_canvas_item_new(parent, e_minicard_label_get_type(), NULL); - 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 08eb51ee53..0000000000 --- a/addressbook/gui/widgets/e-minicard-label.h +++ /dev/null @@ -1,83 +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; - double max_field_name_length; - 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 28f8243dff..0000000000 --- a/addressbook/gui/widgets/e-minicard-view.c +++ /dev/null @@ -1,426 +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" -#include "e-contact-editor.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); -static gboolean e_minicard_view_event (GnomeCanvasItem *item, GdkEvent *event); -static void canvas_destroy (GtkObject *object, EMinicardView *view); -static void disconnect_signals (EMinicardView *view); - -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; - - item_class->event = e_minicard_view_event; - - /* 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; - view->canvas_destroy_id = 0; - - gtk_object_set(GTK_OBJECT(view), - "empty_message", _("\n\nThere are no items to show in this view\n\n" - "Double-click here to create a new Contact."), - NULL); - - 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)) { - ECard *card = cards->data; - gchar *id = e_card_get_id(card); - GnomeCanvasItem *item = e_reflow_sorted_get_item(E_REFLOW_SORTED(view), id); - if (item && !GTK_OBJECT_DESTROYED(item)) { - gnome_canvas_item_set(item, - "card", card, - NULL); - e_reflow_sorted_reorder_item(E_REFLOW_SORTED(view), id); - } - } -} - -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; - disconnect_signals(view); - if (view->book_view) - gtk_object_unref(GTK_OBJECT(view->book_view)); - - if (!view->canvas_destroy_id) - view->canvas_destroy_id = - gtk_signal_connect(GTK_OBJECT(GNOME_CANVAS_ITEM(view)->canvas), - "destroy", GTK_SIGNAL_FUNC(canvas_destroy), - 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_unref, NULL); - 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) -{ - if (view->book && view->query) - 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: - 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->canvas_destroy_id) - gtk_signal_disconnect(GTK_OBJECT (GNOME_CANVAS_ITEM(view)->canvas), - view->canvas_destroy_id); - disconnect_signals(view); - g_free(view->query); - if (view->book) - gtk_object_unref(GTK_OBJECT(view->book)); - if (view->book_view) - gtk_object_unref(GTK_OBJECT(view->book_view)); - - GTK_OBJECT_CLASS(parent_class)->destroy (object); -} - -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 -card_changed_cb (EBook* book, EBookStatus status, gpointer user_data) -{ - g_print ("%s: %s(): a card was changed with status %d\n", __FILE__, __FUNCTION__, status); -} - -/* Callback for the add_card signal from the contact editor */ -static void -add_card_cb (EContactEditor *ce, ECard *card, gpointer data) -{ - EBook *book; - - book = E_BOOK (data); - e_book_add_card (book, card, card_added_cb, NULL); -} - -/* Callback for the commit_card signal from the contact editor */ -static void -commit_card_cb (EContactEditor *ce, ECard *card, gpointer data) -{ - EBook *book; - - book = E_BOOK (data); - e_book_commit_card (book, card, card_changed_cb, NULL); -} - -/* Callback used when the contact editor is closed */ -static void -editor_closed_cb (EContactEditor *ce, gpointer data) -{ - gtk_object_unref (GTK_OBJECT (ce)); -} - -static gboolean -e_minicard_view_event (GnomeCanvasItem *item, GdkEvent *event) -{ - EMinicardView *view; - - view = E_MINICARD_VIEW (item); - - switch( event->type ) { - case GDK_2BUTTON_PRESS: - if (((GdkEventButton *)event)->button == 1) - { - ECard *card; - EContactEditor *ce; - EBook *book; - - card = e_card_new(""); - - gtk_object_get(GTK_OBJECT(view), "book", &book, NULL); - g_assert (E_IS_BOOK (book)); - - ce = e_contact_editor_new (card, TRUE); - - gtk_signal_connect (GTK_OBJECT (ce), "add_card", - GTK_SIGNAL_FUNC (add_card_cb), book); - gtk_signal_connect (GTK_OBJECT (ce), "commit_card", - GTK_SIGNAL_FUNC (commit_card_cb), book); - gtk_signal_connect (GTK_OBJECT (ce), "editor_closed", - GTK_SIGNAL_FUNC (editor_closed_cb), NULL); - - gtk_object_sink(GTK_OBJECT(card)); - } - return TRUE; - default: - if (GNOME_CANVAS_ITEM_CLASS(parent_class)->event) - return GNOME_CANVAS_ITEM_CLASS(parent_class)->event(item, event); - else - return FALSE; - break; - } -} - -static void -disconnect_signals(EMinicardView *view) -{ - 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); -} - -static void -canvas_destroy(GtkObject *object, EMinicardView *view) -{ - disconnect_signals(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; - } - } - } -} - -static int -compare_to_letter(EMinicard *card, char *letter) -{ - g_return_val_if_fail(card != NULL, 0); - g_return_val_if_fail(E_IS_MINICARD(card), 0); - - if (*letter == '1') - return 1; - - if (card->card) { - char *file_as; - gtk_object_get(GTK_OBJECT(card->card), - "file_as", &file_as, - NULL); - if (file_as) - return strncasecmp(file_as, letter, 1); - else - return 0; - } else { - return 0; - } -} - -void e_minicard_view_jump_to_letter (EMinicardView *view, - char letter) -{ - e_reflow_sorted_jump(E_REFLOW_SORTED(view), - (GCompareFunc) compare_to_letter, - &letter); -} diff --git a/addressbook/gui/widgets/e-minicard-view.h b/addressbook/gui/widgets/e-minicard-view.h deleted file mode 100644 index a166a6ade1..0000000000 --- a/addressbook/gui/widgets/e-minicard-view.h +++ /dev/null @@ -1,95 +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 canvas_destroy_id; - - 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); -void e_minicard_view_jump_to_letter (EMinicardView *view, - char letter); - -#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 4a73fc8eb4..0000000000 --- a/addressbook/gui/widgets/e-minicard.c +++ /dev/null @@ -1,728 +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 -#include "e-contact-editor.h" -#include "e-contact-save-as.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; - -typedef struct _EMinicardField EMinicardField; - -struct _EMinicardField { - ECardSimpleField field; - GnomeCanvasItem *label; -}; - -#define E_MINICARD_FIELD(field) ((EMinicardField *)(field)) - -static void -e_minicard_field_destroy(EMinicardField *field) -{ - gtk_object_destroy(GTK_OBJECT(field->label)); - g_free(field); -} - -/* 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; - minicard->simple = e_card_simple_new(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(E_MINICARD_FIELD(e_minicard->fields->data)->label, - "has_focus", GTK_VALUE_ENUM(*arg), - NULL); - } else if ( GTK_VALUE_ENUM(*arg) == E_FOCUS_END ) { - gnome_canvas_item_set(E_MINICARD_FIELD(g_list_last(e_minicard->fields)->data)->label, - "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)); - gtk_object_set(GTK_OBJECT(e_minicard->simple), - "card", e_minicard->card, - NULL); - 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: - e_card_simple_sync_card(e_minicard->simple); - 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); - - g_list_foreach(e_minicard->fields, (GFunc) e_minicard_field_destroy, NULL); - g_list_free(e_minicard->fields); - - if (e_minicard->card) - gtk_object_unref (GTK_OBJECT(e_minicard->card)); - if (e_minicard->simple) - gtk_object_unref (GTK_OBJECT(e_minicard->simple)); - - 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_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 -card_changed_cb (EBook* book, EBookStatus status, gpointer user_data) -{ - g_print ("%s: %s(): a card was changed with status %d\n", __FILE__, __FUNCTION__, status); -} - -static void -save_as (GtkWidget *widget, EMinicard *minicard) -{ - e_card_simple_sync_card(minicard->simple); - e_contact_save_as(_("Save as VCard"), minicard->card); -} - -/* Callback for the add_card signal from the contact editor */ -static void -add_card_cb (EContactEditor *ce, ECard *card, gpointer data) -{ - EBook *book; - - book = E_BOOK (data); - e_book_add_card (book, card, card_added_cb, NULL); -} - -/* Callback for the commit_card signal from the contact editor */ -static void -commit_card_cb (EContactEditor *ce, ECard *card, gpointer data) -{ - EBook *book; - - book = E_BOOK (data); - e_book_commit_card (book, card, card_changed_cb, NULL); -} - -/* Callback used when the contact editor is closed */ -static void -editor_closed_cb (EContactEditor *ce, gpointer data) -{ - gtk_object_unref (GTK_OBJECT (ce)); -} - -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 { - EBook *book; - - e_card_simple_sync_card(e_minicard->simple); - - gtk_object_get(GTK_OBJECT(GNOME_CANVAS_ITEM(e_minicard)->parent), - "book", &book, - NULL); - - /* Add the card in the contact editor to our ebook */ - e_book_commit_card (book, - e_minicard->card, - card_changed_cb, - NULL); - - 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); - } else if (event->button.button == 3) { - EPopupMenu menu[] = { {"Save as VCard", NULL, GTK_SIGNAL_FUNC(save_as), 0}, {NULL, NULL, NULL, 0} }; - e_popup_menu_run (menu, (GdkEventButton *)event, 0, e_minicard); - } - break; - - case GDK_2BUTTON_PRESS: - if (event->button.button == 1 && E_IS_MINICARD_VIEW(item->parent)) { - EContactEditor *ce; - EBook *book; - - gtk_object_get(GTK_OBJECT(item->parent), - "book", &book, - NULL); - g_assert (E_IS_BOOK (book)); - - ce = e_contact_editor_new (e_minicard->card, FALSE); - - gtk_signal_connect (GTK_OBJECT (ce), "add_card", - GTK_SIGNAL_FUNC (add_card_cb), book); - gtk_signal_connect (GTK_OBJECT (ce), "commit_card", - GTK_SIGNAL_FUNC (commit_card_cb), book); - gtk_signal_connect (GTK_OBJECT (ce), "editor_closed", - GTK_SIGNAL_FUNC (editor_closed_cb), NULL); - - return TRUE; - } - 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) { - EMinicardField *field = E_MINICARD_FIELD(list->data); - GnomeCanvasItem *item = field->label; - 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) { - EMinicardField *field = E_MINICARD_FIELD(list->data); - GnomeCanvasItem *item = field->label; - 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( E_MINICARD_FIELD( list->data )->label, - "width", (double) e_minicard->width - 4.0, - NULL ); - } - } -} - -static void -field_changed (EText *text, EMinicard *e_minicard) -{ - ECardSimpleType type; - char *string; - - type = GPOINTER_TO_INT - (gtk_object_get_data(GTK_OBJECT(text), - "EMinicard:field")); - gtk_object_get(GTK_OBJECT(text), - "text", &string, - NULL); - e_card_simple_set(e_minicard->simple, - type, - string); - g_free(string); -} - -static void -add_field (EMinicard *e_minicard, ECardSimpleField field, gdouble left_width) -{ - GnomeCanvasItem *new_item; - GnomeCanvasGroup *group; - ECardSimpleType type; - EMinicardField *minicard_field; - char *name; - char *string; - - group = GNOME_CANVAS_GROUP( e_minicard ); - - type = e_card_simple_type(e_minicard->simple, field); - name = g_strdup_printf("%s:", e_card_simple_get_name(e_minicard->simple, field)); - string = e_card_simple_get(e_minicard->simple, field); - - new_item = e_minicard_label_new(group); - gnome_canvas_item_set( new_item, - "width", e_minicard->width - 4.0, - "fieldname", name, - "field", string, - "max_field_name_length", left_width, - NULL ); - gtk_signal_connect(GTK_OBJECT(E_MINICARD_LABEL(new_item)->field), - "changed", GTK_SIGNAL_FUNC(field_changed), e_minicard); - gtk_object_set_data(GTK_OBJECT(E_MINICARD_LABEL(new_item)->field), - "EMinicard:field", - GINT_TO_POINTER(field)); - - minicard_field = g_new(EMinicardField, 1); - minicard_field->field = field; - minicard_field->label = new_item; - - e_minicard->fields = g_list_append( e_minicard->fields, minicard_field); - e_canvas_item_move_absolute(new_item, 2, e_minicard->height); - g_free(name); - g_free(string); -} - -static gdouble -get_left_width(EMinicard *e_minicard) -{ - gchar *name; - ECardSimpleField field; - gdouble width = -1; - static GdkFont *font = NULL; - - if (font == NULL) { - font = gdk_font_load("lucidasans-10"); - } - - for(field = E_CARD_SIMPLE_FIELD_FULL_NAME; field != E_CARD_SIMPLE_FIELD_LAST; field++) { - gdouble this_width; - name = g_strdup_printf("%s:", e_card_simple_get_name(e_minicard->simple, field)); - this_width = gdk_text_width(font, name, strlen(name)); - if (width < this_width) - width = this_width; - g_free(name); - } - return width; -} - -static void -remodel( EMinicard *e_minicard ) -{ - int count = 0; - if (e_minicard->simple) { - ECardSimpleField field; - GList *list; - char *file_as; - gdouble left_width = -1; - - if (e_minicard->header_text) { - file_as = e_card_simple_get(e_minicard->simple, E_CARD_SIMPLE_FIELD_FILE_AS); - gnome_canvas_item_set( e_minicard->header_text, - "text", file_as ? file_as : "", - NULL ); - g_free(file_as); - } - - list = e_minicard->fields; - e_minicard->fields = NULL; - - for(field = E_CARD_SIMPLE_FIELD_FULL_NAME; field != E_CARD_SIMPLE_FIELD_LAST && count < 5; field++) { - EMinicardField *minicard_field = NULL; - - if (list) - minicard_field = list->data; - if (minicard_field && minicard_field->field == field) { - GList *this_list = list; - char *string; - - string = e_card_simple_get(e_minicard->simple, field); - if (string && *string) { - e_minicard->fields = g_list_append(e_minicard->fields, minicard_field); - gtk_object_set(GTK_OBJECT(minicard_field->label), - "field", string, - NULL); - count ++; - } else { - e_minicard_field_destroy(minicard_field); - } - list = g_list_remove_link(list, this_list); - g_list_free_1(this_list); - g_free(string); - } else { - char *string; - if (left_width == -1) { - left_width = get_left_width(e_minicard); - } - - string = e_card_simple_get(e_minicard->simple, field); - if (string && *string) { - add_field(e_minicard, field, left_width); - count++; - } - g_free(string); - } - } - - g_list_foreach(list, (GFunc) e_minicard_field_destroy, NULL); - g_list_free(list); - } -} - -static void -e_minicard_reflow( GnomeCanvasItem *item, int flags ) -{ - EMinicard *e_minicard = E_MINICARD(item); - if ( GTK_OBJECT_FLAGS( e_minicard ) & GNOME_CANVAS_ITEM_REALIZED ) { - GList *list; - gdouble text_height; - gint old_height; - - old_height = e_minicard->height; - - 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)) { - EMinicardField *field = E_MINICARD_FIELD(list->data); - GnomeCanvasItem *item = field->label; - gtk_object_get (GTK_OBJECT(item), - "height", &text_height, - NULL); - e_canvas_item_move_absolute(item, 2, e_minicard->height); - e_minicard->height += text_height; - } - e_minicard->height += 2; - - gnome_canvas_item_set( e_minicard->rect, - "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 ""; - } -} - -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 *file_as1, *file_as2; - gtk_object_get(GTK_OBJECT(minicard1->card), - "file_as", &file_as1, - NULL); - gtk_object_get(GTK_OBJECT(minicard2->card), - "file_as", &file_as2, - NULL); - if (file_as1 && file_as2) - return strcasecmp(file_as1, file_as2); - if (file_as1) - return -1; - if (file_as2) - return 1; - return strcmp(e_minicard_get_card_id(minicard1), e_minicard_get_card_id(minicard2)); - } else { - return 0; - } -} diff --git a/addressbook/gui/widgets/e-minicard.h b/addressbook/gui/widgets/e-minicard.h deleted file mode 100644 index 47da8110c2..0000000000 --- a/addressbook/gui/widgets/e-minicard.h +++ /dev/null @@ -1,98 +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 -#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; - ECardSimple *simple; - - GnomeCanvasItem *rect; - GnomeCanvasItem *header_rect; - GnomeCanvasItem *header_text; - - GList *fields; /* Of type EMinicardField */ - 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 57bc69222a..0000000000 --- a/addressbook/gui/widgets/test-minicard-label.c +++ /dev/null @@ -1,126 +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, - "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 e16ca675b3..0000000000 --- a/addressbook/gui/widgets/test-minicard.c +++ /dev/null @@ -1,115 +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(), - "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 dacaeb055c..0000000000 --- a/addressbook/gui/widgets/test-reflow.c +++ /dev/null @@ -1,191 +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(), - "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; -} -- cgit v1.2.3