From 8cb68557aebb62334f68beeea60cf3bbf5930f9e Mon Sep 17 00:00:00 2001 From: Chris Toshok Date: Mon, 25 Jun 2001 01:09:43 +0000 Subject: correct path to libecontacteditor.a. (minicard_widget_test_LDADD): same. 2001-06-24 Chris Toshok * gui/widgets/Makefile.am (minicard_test_LDADD): correct path to libecontacteditor.a. (minicard_widget_test_LDADD): same. (INCLUDES): same, for the includes. * gui/widgets/e-minicard.h: correct e-contact-editor.h path. * gui/widgets/e-addressbook-util.h: correct path to e-contact-editor.h, and add e-contact-list-editor.h. Add prototype for e_addressbook_show_contact_list_editor. * gui/widgets/e-addressbook-util.c: remove #include "e-contact-editor.h" (our header includes it.) (added_cb): rename card_added_cb to this, and make it so it can be reused in both the list and card cases. remove the g_print too. (modified_cb): same for modified case. (deleted_cb): same for deleted case. (editor_closed_cb): change first arg to GtkObject* so we can reuse this for both list and card. (e_addressbook_show_contact_editor): use added_cb, modified_cb, deleted_cb, and pass FALSE as user_data. (e_addressbook_show_contact_list_editor): new function, same as above but creating a contact-list-editor, and pass TRUE as user_data. * gui/component/e-address-popup.c: correct path to contact-editor. * gui/component/e-address-widget.c: same. * gui/component/select-names/e-select-names-popup.c: same. * gui/component/select-names/e-select-names-text-model.c: same. * gui/component/addressbook.c (new_contact_list_cb): new function. (update_command_state): update ContactNewList command. (verbs): remove ViewAll from the toolbar from the verb list. Add ContactNewList. (pixmaps): same for pixmaps. * gui/component/Makefile.am (evolution_addressbook_LDADD): new path for contact-editor. (INCLUDES): same. * gui/contact-list-editor/e-contact-list-model.h: * gui/contact-list-editor/e-contact-list-model.c: * gui/contact-list-editor/e-contact-list-editor.h: * gui/contact-list-editor/e-contact-list-editor.c: * gui/contact-list-editor/Makefile.am: Initial contact-list editor commit. * gui/Makefile.am (SUBDIRS): add contact-editor. * Makefile.am: (SUBDIRS): remove contact-editor. svn path=/trunk/; revision=10463 --- addressbook/ChangeLog | 56 + addressbook/Makefile.am | 2 +- addressbook/contact-editor/Makefile.am | 63 - addressbook/contact-editor/arrow.png | Bin 174 -> 0 bytes addressbook/contact-editor/contact-editor.glade | 2334 -------------------- .../contact-editor/e-contact-editor-address.c | 243 -- .../contact-editor/e-contact-editor-address.h | 78 - .../e-contact-editor-confirm-delete.glade | 83 - .../contact-editor/e-contact-editor-fullname.c | 243 -- .../contact-editor/e-contact-editor-fullname.h | 78 - addressbook/contact-editor/e-contact-editor.c | 2308 ------------------- addressbook/contact-editor/e-contact-editor.h | 131 -- addressbook/contact-editor/e-contact-quick-add.c | 416 ---- addressbook/contact-editor/e-contact-quick-add.h | 41 - addressbook/contact-editor/e-contact-save-as.c | 100 - addressbook/contact-editor/e-contact-save-as.h | 43 - addressbook/contact-editor/fulladdr.glade | 475 ---- addressbook/contact-editor/fullname.glade | 389 ---- addressbook/contact-editor/test-editor.c | 145 -- addressbook/gui/Makefile.am | 2 +- addressbook/gui/component/Makefile.am | 42 +- addressbook/gui/component/addressbook.c | 38 +- addressbook/gui/component/e-address-popup.c | 4 +- addressbook/gui/component/e-address-widget.c | 2 +- .../component/select-names/e-select-names-popup.c | 4 +- .../select-names/e-select-names-text-model.c | 2 +- addressbook/gui/contact-list-editor/.cvsignore | 3 + addressbook/gui/contact-list-editor/Makefile.am | 29 + .../contact-list-editor/contact-list-editor.glade | 287 +++ .../contact-list-editor/e-contact-list-editor.c | 499 +++++ .../contact-list-editor/e-contact-list-editor.h | 108 + .../gui/contact-list-editor/e-contact-list-model.c | 190 ++ .../gui/contact-list-editor/e-contact-list-model.h | 42 + addressbook/gui/widgets/Makefile.am | 8 +- addressbook/gui/widgets/e-addressbook-util.c | 57 +- addressbook/gui/widgets/e-addressbook-util.h | 6 +- addressbook/gui/widgets/e-minicard.h | 2 +- 37 files changed, 1315 insertions(+), 7238 deletions(-) delete mode 100644 addressbook/contact-editor/Makefile.am delete mode 100644 addressbook/contact-editor/arrow.png delete mode 100644 addressbook/contact-editor/contact-editor.glade delete mode 100644 addressbook/contact-editor/e-contact-editor-address.c delete mode 100644 addressbook/contact-editor/e-contact-editor-address.h delete mode 100644 addressbook/contact-editor/e-contact-editor-confirm-delete.glade delete mode 100644 addressbook/contact-editor/e-contact-editor-fullname.c delete mode 100644 addressbook/contact-editor/e-contact-editor-fullname.h delete mode 100644 addressbook/contact-editor/e-contact-editor.c delete mode 100644 addressbook/contact-editor/e-contact-editor.h delete mode 100644 addressbook/contact-editor/e-contact-quick-add.c delete mode 100644 addressbook/contact-editor/e-contact-quick-add.h delete mode 100644 addressbook/contact-editor/e-contact-save-as.c delete mode 100644 addressbook/contact-editor/e-contact-save-as.h delete mode 100644 addressbook/contact-editor/fulladdr.glade delete mode 100644 addressbook/contact-editor/fullname.glade delete mode 100644 addressbook/contact-editor/test-editor.c create mode 100644 addressbook/gui/contact-list-editor/.cvsignore create mode 100644 addressbook/gui/contact-list-editor/Makefile.am create mode 100644 addressbook/gui/contact-list-editor/contact-list-editor.glade create mode 100644 addressbook/gui/contact-list-editor/e-contact-list-editor.c create mode 100644 addressbook/gui/contact-list-editor/e-contact-list-editor.h create mode 100644 addressbook/gui/contact-list-editor/e-contact-list-model.c create mode 100644 addressbook/gui/contact-list-editor/e-contact-list-model.h (limited to 'addressbook') diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog index b5cdb76d65..c4548d3788 100644 --- a/addressbook/ChangeLog +++ b/addressbook/ChangeLog @@ -1,3 +1,59 @@ +2001-06-24 Chris Toshok + + * gui/widgets/Makefile.am (minicard_test_LDADD): correct path to + libecontacteditor.a. + (minicard_widget_test_LDADD): same. + (INCLUDES): same, for the includes. + + * gui/widgets/e-minicard.h: correct e-contact-editor.h path. + + * gui/widgets/e-addressbook-util.h: correct path to + e-contact-editor.h, and add e-contact-list-editor.h. Add + prototype for e_addressbook_show_contact_list_editor. + + * gui/widgets/e-addressbook-util.c: remove #include + "e-contact-editor.h" (our header includes it.) + (added_cb): rename card_added_cb to this, and make it so it can be + reused in both the list and card cases. remove the g_print too. + (modified_cb): same for modified case. + (deleted_cb): same for deleted case. + (editor_closed_cb): change first arg to GtkObject* so we can reuse + this for both list and card. + (e_addressbook_show_contact_editor): use added_cb, modified_cb, + deleted_cb, and pass FALSE as user_data. + (e_addressbook_show_contact_list_editor): new function, same as + above but creating a contact-list-editor, and pass TRUE as + user_data. + + * gui/component/e-address-popup.c: correct path to contact-editor. + + * gui/component/e-address-widget.c: same. + + * gui/component/select-names/e-select-names-popup.c: same. + + * gui/component/select-names/e-select-names-text-model.c: same. + + * gui/component/addressbook.c (new_contact_list_cb): new function. + (update_command_state): update ContactNewList command. + (verbs): remove ViewAll from the toolbar from the verb list. Add + ContactNewList. + (pixmaps): same for pixmaps. + + * gui/component/Makefile.am (evolution_addressbook_LDADD): new + path for contact-editor. + (INCLUDES): same. + + * gui/contact-list-editor/e-contact-list-model.h: + * gui/contact-list-editor/e-contact-list-model.c: + * gui/contact-list-editor/e-contact-list-editor.h: + * gui/contact-list-editor/e-contact-list-editor.c: + * gui/contact-list-editor/Makefile.am: Initial contact-list editor + commit. + + * gui/Makefile.am (SUBDIRS): add contact-editor. + + * Makefile.am: (SUBDIRS): remove contact-editor. + 2001-06-21 Jon Trowbridge * gui/component/select-names/e-select-names-popup.c diff --git a/addressbook/Makefile.am b/addressbook/Makefile.am index cc89ee5aeb..9aad9c1b30 100644 --- a/addressbook/Makefile.am +++ b/addressbook/Makefile.am @@ -3,5 +3,5 @@ CONDUIT_SUBDIR=conduit endif SUBDIRS = \ - backend printing contact-editor gui $(CONDUIT_SUBDIR) + backend printing gui $(CONDUIT_SUBDIR) diff --git a/addressbook/contact-editor/Makefile.am b/addressbook/contact-editor/Makefile.am deleted file mode 100644 index 6d3567b2f7..0000000000 --- a/addressbook/contact-editor/Makefile.am +++ /dev/null @@ -1,63 +0,0 @@ -INCLUDES = \ - $(BONOBO_GNOME_CFLAGS) \ - $(EXTRA_GNOME_CFLAGS) \ - -I$(top_srcdir) \ - -I$(top_srcdir)/addressbook/ \ - -I$(top_srcdir)/addressbook/backend \ - -I$(top_srcdir)/addressbook/gui/merging \ - -I$(top_srcdir)/widgets/e-table \ - -DEVOLUTION_GLADEDIR=\""$(gladedir)"\" \ - -DDATADIR=\""$(datadir)"\" \ - -DEVOLUTION_DATADIR=\""$(datadir)"\" \ - -DEVOLUTIONDIR=\""$(evolutiondir)"\" \ - -DG_LOG_DOMAIN=\"contact-editor\" - -noinst_LIBRARIES = \ - libecontacteditor.a - -libecontacteditor_a_SOURCES = \ - e-contact-editor-address.c \ - e-contact-editor-address.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 \ - e-contact-quick-add.c \ - e-contact-quick-add.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/printing/libecontactprint.a \ -# $(top_builddir)/addressbook/backend/ebook/libebook.la \ -# $(top_builddir)/e-util/ename/libename.la \ -# $(top_builddir)/libversit/libversit.la \ -# $(GNOMEGNORBA_LIBS) \ -# $(BONOBO_GNOME_LIBS) \ -# $(top_builddir)/widgets/misc/libemiscwidgets.a \ -# $(top_builddir)/e-util/libeutil.la \ -# $(GNOME_PRINT_LIBS) \ -# $(EXTRA_GNOME_LIBS) - -evolutiondir = $(datadir)/evolution - -evolution_DATA = arrow.png - -gladedir = $(datadir)/evolution/glade - -glade_DATA = \ - contact-editor.glade \ - fulladdr.glade \ - fullname.glade \ - e-contact-editor-confirm-delete.glade - -EXTRA_DIST = $(evolution_DATA) \ - $(glade_DATA) diff --git a/addressbook/contact-editor/arrow.png b/addressbook/contact-editor/arrow.png deleted file mode 100644 index b102356c78..0000000000 Binary files a/addressbook/contact-editor/arrow.png and /dev/null differ diff --git a/addressbook/contact-editor/contact-editor.glade b/addressbook/contact-editor/contact-editor.glade deleted file mode 100644 index af5d17d954..0000000000 --- a/addressbook/contact-editor/contact-editor.glade +++ /dev/null @@ -1,2334 +0,0 @@ - - - - - Contact-editor - contact-editor - - src - pixmaps - C - True - True - True - False - False - False - False - - - - 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 - - GTK_RELIEF_NORMAL - - 0 - False - False - - - - - GtkButton - button32 - 2 - True - - GTK_RELIEF_NORMAL - - 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 - False - 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 - - GTK_RELIEF_NORMAL - - 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 - GTK_RELIEF_NORMAL - - - Placeholder - - - - - - GtkAlignment - alignment5 - 1 - 0.5 - 0 - 0 - - 6 - 7 - 3 - 4 - 0 - 0 - False - False - False - False - True - True - - - - GtkButton - button-phone4 - GTK_RELIEF_NORMAL - - - Placeholder - - - - - - GtkAlignment - alignment7 - 1 - 0.5 - 0 - 0 - - 6 - 7 - 1 - 2 - 0 - 0 - False - False - False - False - True - True - - - - GtkButton - button-phone2 - GTK_RELIEF_NORMAL - - - Placeholder - - - - - - GtkAlignment - alignment8 - 1 - 0.5 - 0 - 0 - - 6 - 7 - 0 - 1 - 0 - 0 - False - False - False - False - True - True - - - - GtkButton - button-phone1 - GTK_RELIEF_NORMAL - - - 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 - GTK_RELIEF_NORMAL - - - 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 - GTK_RELIEF_NORMAL - - - Placeholder - - - - - - 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 - - - - - 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 - - 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 - alignment-contacts - 0.5 - 0.5 - 1 - 0 - - 1 - 3 - 12 - 13 - 0 - 0 - False - False - False - False - True - True - - - - GtkButton - button-contacts - True - - GTK_RELIEF_NORMAL - - - - - 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 - - GTK_RELIEF_NORMAL - - - - - GtkEventBox - eventbox7 - - 1 - 3 - 1 - 2 - 0 - 0 - False - False - False - False - True - True - - - - GtkLabel - label-jobtitle - - 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-plain.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 - label-company - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - entry-company - - 1 - 3 - 2 - 3 - 0 - 0 - False - False - False - False - True - True - - - - - GtkButton - button-fulladdr - True - - GTK_RELIEF_NORMAL - - 5 - 7 - 6 - 7 - 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 - label-department - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - entry-department - - 1 - 2 - 0 - 1 - 0 - 0 - False - False - False - False - True - True - - - - - GtkLabel - label-office - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - entry-office - - 1 - 2 - 1 - 2 - 0 - 0 - False - False - False - False - True - True - - - - - GtkLabel - label-profession - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - entry-profession - - 1 - 2 - 2 - 3 - 0 - 0 - False - False - False - False - True - True - - - - - GtkLabel - label-nickname - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - entry-nickname - - 1 - 2 - 4 - 5 - 0 - 0 - False - False - False - False - True - True - - - - - GtkLabel - label-spouse - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - entry-spouse - - 1 - 2 - 5 - 6 - 0 - 0 - False - False - False - False - True - True - - - - - GtkLabel - label-birthday - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - - 3 - 4 - 4 - 5 - 0 - 0 - False - False - False - False - True - True - - - - - GtkLabel - label-assistant - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - entry-assistant - - 3 - 4 - 1 - 2 - 0 - 0 - False - False - False - False - True - True - - - - - GtkLabel - label-manager - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - entry-manager - - 3 - 4 - 0 - 1 - 0 - 0 - False - False - False - False - True - True - - - - - GtkLabel - label-anniversary - - 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 - - - - - 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 - label-comments - - 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 - - - - - Custom - dateedit-anniversary - e_contact_editor_create_date - 0 - 0 - Tue, 05 Jun 2001 02:36:32 GMT - - 4 - 6 - 5 - 6 - 0 - 0 - True - False - False - False - True - True - - - - - Custom - dateedit-birthday - e_contact_editor_create_date - 0 - 0 - Tue, 05 Jun 2001 02:36:27 GMT - - 4 - 6 - 4 - 5 - 0 - 0 - True - 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/contact-editor/e-contact-editor-address.c b/addressbook/contact-editor/e-contact-editor-address.c deleted file mode 100644 index 1fe9337503..0000000000 --- a/addressbook/contact-editor/e-contact-editor-address.c +++ /dev/null @@ -1,243 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * e-contact-editor-address.c - * Copyright (C) 2000 Ximian, Inc. - * Author: Chris Lahey - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of 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 - -static void e_contact_editor_address_init (EContactEditorAddress *card); -static void e_contact_editor_address_class_init (EContactEditorAddressClass *klass); -static void e_contact_editor_address_set_arg (GtkObject *o, GtkArg *arg, guint arg_id); -static void e_contact_editor_address_get_arg (GtkObject *object, GtkArg *arg, guint arg_id); -static void e_contact_editor_address_destroy (GtkObject *object); - -static void fill_in_info(EContactEditorAddress *editor); -static void extract_info(EContactEditorAddress *editor); - -static GnomeDialogClass *parent_class = NULL; - -/* The arguments we take */ -enum { - ARG_0, - ARG_ADDRESS, - ARG_IS_READ_ONLY -}; - -GtkType -e_contact_editor_address_get_type (void) -{ - static GtkType contact_editor_address_type = 0; - - if (!contact_editor_address_type) - { - static const GtkTypeInfo contact_editor_address_info = - { - "EContactEditorAddress", - sizeof (EContactEditorAddress), - sizeof (EContactEditorAddressClass), - (GtkClassInitFunc) e_contact_editor_address_class_init, - (GtkObjectInitFunc) e_contact_editor_address_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - contact_editor_address_type = gtk_type_unique (gnome_dialog_get_type (), &contact_editor_address_info); - } - - return contact_editor_address_type; -} - -static void -e_contact_editor_address_class_init (EContactEditorAddressClass *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 ("EContactEditorAddress::address", GTK_TYPE_POINTER, - GTK_ARG_READWRITE, ARG_ADDRESS); - gtk_object_add_arg_type ("EContactEditorAddress::editable", GTK_TYPE_BOOL, - GTK_ARG_READWRITE, ARG_IS_READ_ONLY); - - object_class->set_arg = e_contact_editor_address_set_arg; - object_class->get_arg = e_contact_editor_address_get_arg; - object_class->destroy = e_contact_editor_address_destroy; -} - -static void -e_contact_editor_address_init (EContactEditorAddress *e_contact_editor_address) -{ - GladeXML *gui; - GtkWidget *widget; - - gnome_dialog_append_button ( GNOME_DIALOG(e_contact_editor_address), - GNOME_STOCK_BUTTON_OK); - - gnome_dialog_append_button ( GNOME_DIALOG(e_contact_editor_address), - GNOME_STOCK_BUTTON_CANCEL); - - gtk_window_set_policy(GTK_WINDOW(e_contact_editor_address), FALSE, TRUE, FALSE); - - e_contact_editor_address->address = NULL; - - gui = glade_xml_new (EVOLUTION_GLADEDIR "/fulladdr.glade", NULL); - e_contact_editor_address->gui = gui; - - widget = glade_xml_get_widget(gui, "table-checkaddress"); - gtk_widget_ref(widget); - gtk_container_remove(GTK_CONTAINER(widget->parent), widget); - gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (e_contact_editor_address)->vbox), widget, TRUE, TRUE, 0); - gtk_widget_unref(widget); -} - -void -e_contact_editor_address_destroy (GtkObject *object) -{ - EContactEditorAddress *e_contact_editor_address = E_CONTACT_EDITOR_ADDRESS(object); - - if (e_contact_editor_address->gui) - gtk_object_unref(GTK_OBJECT(e_contact_editor_address->gui)); - e_card_delivery_address_free(e_contact_editor_address->address); -} - -GtkWidget* -e_contact_editor_address_new (const ECardDeliveryAddress *address) -{ - GtkWidget *widget = GTK_WIDGET (gtk_type_new (e_contact_editor_address_get_type ())); - gtk_object_set (GTK_OBJECT(widget), - "address", address, - NULL); - return widget; -} - -static void -e_contact_editor_address_set_arg (GtkObject *o, GtkArg *arg, guint arg_id) -{ - EContactEditorAddress *e_contact_editor_address; - - e_contact_editor_address = E_CONTACT_EDITOR_ADDRESS (o); - - switch (arg_id){ - case ARG_ADDRESS: - if (e_contact_editor_address->address) - e_card_delivery_address_free(e_contact_editor_address->address); - e_contact_editor_address->address = e_card_delivery_address_copy(GTK_VALUE_POINTER (*arg)); - fill_in_info(e_contact_editor_address); - break; - case ARG_IS_READ_ONLY: { - int i; - char *entry_names[] = { - "entry-street", - "entry-city", - "entry-ext", - "entry-po", - "entry-region", - "combo-country", - "entry-code", - NULL - }; - e_contact_editor_address->editable = GTK_VALUE_BOOL (*arg) ? TRUE : FALSE; - for (i = 0; entry_names[i] != NULL; i ++) { - gtk_widget_set_sensitive (glade_xml_get_widget(e_contact_editor_address->gui, entry_names[i]), e_contact_editor_address->editable); - } - break; - } - } -} - -static void -e_contact_editor_address_get_arg (GtkObject *object, GtkArg *arg, guint arg_id) -{ - EContactEditorAddress *e_contact_editor_address; - - e_contact_editor_address = E_CONTACT_EDITOR_ADDRESS (object); - - switch (arg_id) { - case ARG_ADDRESS: - extract_info(e_contact_editor_address); - GTK_VALUE_POINTER (*arg) = e_card_delivery_address_copy(e_contact_editor_address->address); - break; - case ARG_IS_READ_ONLY: - GTK_VALUE_BOOL (*arg) = e_contact_editor_address->editable ? TRUE : FALSE; - break; - default: - arg->type = GTK_TYPE_INVALID; - break; - } -} - -static void -fill_in_field(EContactEditorAddress *editor, char *field, char *string) -{ - GtkEditable *editable = GTK_EDITABLE(glade_xml_get_widget(editor->gui, field)); - if (editable) { - e_utf8_gtk_editable_set_text(editable, string); - } -} - -static void -fill_in_info(EContactEditorAddress *editor) -{ - ECardDeliveryAddress *address = editor->address; - if (address) { - fill_in_field(editor, "entry-street" , address->street ); - fill_in_field(editor, "entry-po" , address->po ); - fill_in_field(editor, "entry-ext" , address->ext ); - fill_in_field(editor, "entry-city" , address->city ); - fill_in_field(editor, "entry-region" , address->region ); - fill_in_field(editor, "entry-code" , address->code ); - fill_in_field(editor, "entry-country", address->country); - } -} - -static char * -extract_field(EContactEditorAddress *editor, char *field) -{ - GtkEditable *editable = GTK_EDITABLE(glade_xml_get_widget(editor->gui, field)); - if (editable) - return e_utf8_gtk_editable_get_text(editable); - else - return NULL; -} - -static void -extract_info(EContactEditorAddress *editor) -{ - ECardDeliveryAddress *address = editor->address; - if (!address) { - address = e_card_delivery_address_new(); - editor->address = address; - } - address->street = extract_field(editor, "entry-street" ); - address->po = extract_field(editor, "entry-po" ); - address->ext = extract_field(editor, "entry-ext" ); - address->city = extract_field(editor, "entry-city" ); - address->region = extract_field(editor, "entry-region" ); - address->code = extract_field(editor, "entry-code" ); - address->country = extract_field(editor, "entry-country"); -} diff --git a/addressbook/contact-editor/e-contact-editor-address.h b/addressbook/contact-editor/e-contact-editor-address.h deleted file mode 100644 index f4031bea2f..0000000000 --- a/addressbook/contact-editor/e-contact-editor-address.h +++ /dev/null @@ -1,78 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* e-contact-editor-address.h - * Copyright (C) 2000 Ximian, Inc. - * Author: Chris Lahey - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of 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_ADDRESS_H__ -#define __E_CONTACT_EDITOR_ADDRESS_H__ - -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - -/* EContactEditorAddress - 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_ADDRESS_TYPE (e_contact_editor_address_get_type ()) -#define E_CONTACT_EDITOR_ADDRESS(obj) (GTK_CHECK_CAST ((obj), E_CONTACT_EDITOR_ADDRESS_TYPE, EContactEditorAddress)) -#define E_CONTACT_EDITOR_ADDRESS_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_CONTACT_EDITOR_ADDRESS_TYPE, EContactEditorAddressClass)) -#define E_IS_CONTACT_EDITOR_ADDRESS(obj) (GTK_CHECK_TYPE ((obj), E_CONTACT_EDITOR_ADDRESS_TYPE)) -#define E_IS_CONTACT_EDITOR_ADDRESS_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), E_CONTACT_EDITOR_ADDRESS_TYPE)) - - -typedef struct _EContactEditorAddress EContactEditorAddress; -typedef struct _EContactEditorAddressClass EContactEditorAddressClass; - -struct _EContactEditorAddress -{ - GnomeDialog parent; - - /* item specific fields */ - ECardDeliveryAddress *address; - - guint editable : 1; - - GladeXML *gui; -}; - -struct _EContactEditorAddressClass -{ - GnomeDialogClass parent_class; -}; - - -GtkWidget *e_contact_editor_address_new(const ECardDeliveryAddress *name); -GtkType e_contact_editor_address_get_type (void); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - - -#endif /* __E_CONTACT_EDITOR_ADDRESS_H__ */ diff --git a/addressbook/contact-editor/e-contact-editor-confirm-delete.glade b/addressbook/contact-editor/e-contact-editor-confirm-delete.glade deleted file mode 100644 index b91a040d46..0000000000 --- a/addressbook/contact-editor/e-contact-editor-confirm-delete.glade +++ /dev/null @@ -1,83 +0,0 @@ - - - - - e-contact-editor-confirm-delete - e-contact-editor-confirm-delete - - src - pixmaps - C - True - True - True - False - False - False - True - - - - GnomeMessageBox - confirm-dialog - GNOME_MESSAGE_BOX_QUESTION - Are you sure you want -to delete this contact? - Delete Contact? - GTK_WIN_POS_NONE - False - False - False - False - True - 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 - button2 - True - True - GNOME_STOCK_BUTTON_CANCEL - - - - - - diff --git a/addressbook/contact-editor/e-contact-editor-fullname.c b/addressbook/contact-editor/e-contact-editor-fullname.c deleted file mode 100644 index cf97854956..0000000000 --- a/addressbook/contact-editor/e-contact-editor-fullname.c +++ /dev/null @@ -1,243 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * e-contact-editor-fullname.c - * Copyright (C) 2000 Ximian, Inc. - * Author: Chris Lahey - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of 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-contact-editor-fullname.h" - -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, - ARG_IS_READ_ONLY -}; - -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); - - gtk_object_add_arg_type ("EContactEditorFullname::editable", GTK_TYPE_BOOL, - GTK_ARG_READWRITE, ARG_IS_READ_ONLY); - - 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 (const 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; - case ARG_IS_READ_ONLY: { - int i; - char *entry_names[] = { - "combo-title", - "combo-suffix", - "entry-first", - "entry-middle", - "entry-last", - NULL - }; - e_contact_editor_fullname->editable = GTK_VALUE_BOOL (*arg) ? TRUE : FALSE; - for (i = 0; entry_names[i] != NULL; i ++) { - gtk_widget_set_sensitive (glade_xml_get_widget(e_contact_editor_fullname->gui, - entry_names[i]), - e_contact_editor_fullname->editable); - } - 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; - case ARG_IS_READ_ONLY: - GTK_VALUE_BOOL (*arg) = e_contact_editor_fullname->editable ? TRUE : FALSE; - 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) - e_utf8_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 e_utf8_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(); - editor->name = name; - } - - 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/contact-editor/e-contact-editor-fullname.h b/addressbook/contact-editor/e-contact-editor-fullname.h deleted file mode 100644 index 82411c0606..0000000000 --- a/addressbook/contact-editor/e-contact-editor-fullname.h +++ /dev/null @@ -1,78 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* e-contact-editor-fullname.h - * Copyright (C) 2000 Ximian, Inc. - * Author: Chris Lahey - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of 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; - - /* Whether the dialog will accept modifications */ - guint editable : 1; -}; - -struct _EContactEditorFullnameClass -{ - GnomeDialogClass parent_class; -}; - - -GtkWidget *e_contact_editor_fullname_new(const ECardName *name); -GtkType e_contact_editor_fullname_get_type (void); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - - -#endif /* __E_CONTACT_EDITOR_FULLNAME_H__ */ diff --git a/addressbook/contact-editor/e-contact-editor.c b/addressbook/contact-editor/e-contact-editor.c deleted file mode 100644 index 41a58e0ca4..0000000000 --- a/addressbook/contact-editor/e-contact-editor.c +++ /dev/null @@ -1,2308 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * e-contact-editor.c - * Copyright (C) 2000 Ximian, Inc. - * Author: Chris Lahey - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of 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 -#include - -#include -#include -#include -#include -#include -#include -#include - -#include "addressbook/printing/e-contact-print.h" -#include "addressbook/printing/e-contact-print-envelope.h" -#include "e-util/e-gui-utils.h" -#include "widgets/misc/e-dateedit.h" - -#include "e-card-merging.h" - -#include "e-contact-editor.h" -#include "e-contact-editor-address.h" -#include "e-contact-editor-fullname.h" -#include "e-contact-save-as.h" - -/* Signal IDs */ -enum { - CARD_ADDED, - CARD_MODIFIED, - CARD_DELETED, - 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 enable_writable_fields(EContactEditor *editor); -static void set_editable(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 void command_state_changed (EContactEditor *ce); -static void close_dialog (EContactEditor *ce); - -static GtkObjectClass *parent_class = NULL; - -static guint contact_editor_signals[LAST_SIGNAL]; - -/* The arguments we take */ -enum { - ARG_0, - ARG_BOOK, - ARG_CARD, - ARG_IS_NEW_CARD, - ARG_EDITABLE, - ARG_WRITABLE_FIELDS -}; - -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; -} - -typedef void (*GtkSignal_NONE__INT_OBJECT) (GtkObject * object, - gint arg1, - GtkObject *arg2, - gpointer user_data); - -static void -e_marshal_NONE__INT_OBJECT (GtkObject * object, - GtkSignalFunc func, - gpointer func_data, GtkArg * args) -{ - GtkSignal_NONE__INT_OBJECT rfunc; - rfunc = (GtkSignal_NONE__INT_OBJECT) func; - (*rfunc) (object, - GTK_VALUE_INT (args[0]), - GTK_VALUE_OBJECT (args[1]), - func_data); -} - -static void -e_contact_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::book", GTK_TYPE_OBJECT, - GTK_ARG_READWRITE, ARG_BOOK); - 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); - gtk_object_add_arg_type ("EContactEditor::writable_fields", GTK_TYPE_POINTER, - GTK_ARG_READWRITE, ARG_WRITABLE_FIELDS); - gtk_object_add_arg_type ("EContactEditor::editable", GTK_TYPE_BOOL, - GTK_ARG_READWRITE, ARG_EDITABLE); - - contact_editor_signals[CARD_ADDED] = - gtk_signal_new ("card_added", - GTK_RUN_FIRST, - object_class->type, - GTK_SIGNAL_OFFSET (EContactEditorClass, card_added), - e_marshal_NONE__INT_OBJECT, - GTK_TYPE_NONE, 2, - GTK_TYPE_INT, GTK_TYPE_OBJECT); - - contact_editor_signals[CARD_MODIFIED] = - gtk_signal_new ("card_modified", - GTK_RUN_FIRST, - object_class->type, - GTK_SIGNAL_OFFSET (EContactEditorClass, card_modified), - e_marshal_NONE__INT_OBJECT, - GTK_TYPE_NONE, 2, - GTK_TYPE_INT, GTK_TYPE_OBJECT); - - contact_editor_signals[CARD_DELETED] = - gtk_signal_new ("card_deleted", - GTK_RUN_FIRST, - object_class->type, - GTK_SIGNAL_OFFSET (EContactEditorClass, card_deleted), - e_marshal_NONE__INT_OBJECT, - GTK_TYPE_NONE, 2, - GTK_TYPE_INT, 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", EVOLUTIONDIR, 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 -wants_html_changed (GtkWidget *widget, EContactEditor *editor) -{ - gboolean wants_html; - gtk_object_get(GTK_OBJECT(widget), - "active", &wants_html, - NULL); - gtk_object_set(GTK_OBJECT(editor->card), - "wants_html", wants_html, - NULL); - - if (!editor->changed) { - editor->changed = TRUE; - command_state_changed (editor); - } -} - -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 = e_utf8_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); -#if 0 - phone->number = NULL; -#endif - e_card_phone_free(phone); - set_fields(editor); - - if (!editor->changed) { - editor->changed = TRUE; - command_state_changed (editor); - } -} - -static void -email_entry_changed (GtkWidget *widget, EContactEditor *editor) -{ - gchar *string; - GtkEntry *entry = GTK_ENTRY(widget); - - string = e_utf8_gtk_entry_get_text(entry); - - e_card_simple_set_email(editor->simple, editor->email_choice, string); - - g_free (string); - - if (!editor->changed) { - editor->changed = TRUE; - command_state_changed (editor); - } -} - -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 = e_utf8_gtk_editable_get_chars(editable, 0, -1); - - e_card_simple_set_address(editor->simple, editor->address_choice, address); - e_card_address_label_free(address); - - if (!editor->changed) { - editor->changed = TRUE; - command_state_changed (editor); - } -} - -/* 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 && ((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) { - 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) { - 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) { - 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; - char *trystring; - ECardName *name = editor->name; - int i; - int style; - - if (!(file_as && GTK_IS_ENTRY(file_as))) - return -1; - - filestring = e_utf8_gtk_entry_get_text(file_as); - - style = -1; - for (i = 0; i < 5; i++) { - trystring = name_to_style(name, editor->company, i); - if (!strcmp(trystring, filestring)) { - g_free(trystring); - g_free(filestring); - return i; - } - g_free(trystring); - } - g_free (filestring); - 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 (!(file_as && GTK_IS_ENTRY(file_as))) - return; - - if (style == -1) { - string = e_utf8_gtk_entry_get_text(file_as); - strings = g_list_append(strings, string); - } - - widget = glade_xml_get_widget(editor->gui, "combo-file-as"); - - for (i = 0; i < 5; i++) { - if (style_makes_sense(editor->name, editor->company, i)) { - char *u; - u = name_to_style(editor->name, editor->company, i); - string = e_utf8_to_gtk_string (widget, u); - g_free (u); - if (string) strings = g_list_append(strings, string); - } - } - - 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); - e_utf8_gtk_entry_set_text(file_as, string); - g_free(string); - } -} - -static void -name_entry_changed (GtkWidget *widget, EContactEditor *editor) -{ - int style = 0; - char *string; - - style = file_as_get_style(editor); - - e_card_name_free(editor->name); - - string = e_utf8_gtk_entry_get_text (GTK_ENTRY(widget)); - editor->name = e_card_name_from_string(string); - g_free (string); - - file_as_set_style(editor, style); - - if (!editor->changed) { - editor->changed = TRUE; - command_state_changed (editor); - } -} - -static void -company_entry_changed (GtkWidget *widget, EContactEditor *editor) -{ - int style = 0; - - style = file_as_get_style(editor); - - g_free(editor->company); - - editor->company = e_utf8_gtk_entry_get_text(GTK_ENTRY(widget)); - - file_as_set_style(editor, style); - - if (!editor->changed) { - editor->changed = TRUE; - command_state_changed (editor); - } -} - -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_object_set (GTK_OBJECT (dialog), - "editable", editor->editable, - NULL); - gtk_widget_show(GTK_WIDGET(dialog)); - result = gnome_dialog_run (dialog); - - if (result == 0) { - ECardName *name; - GtkWidget *fname_widget; - int style = 0; - - gtk_object_get(GTK_OBJECT(dialog), - "name", &name, - NULL); - - style = file_as_get_style(editor); - - 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); - e_utf8_gtk_entry_set_text(GTK_ENTRY(fname_widget), full_name); - g_free(full_name); - } - - e_card_name_free(editor->name); - editor->name = e_card_name_copy(name); - - file_as_set_style(editor, style); - } - gtk_object_unref(GTK_OBJECT(dialog)); -} - -static void -full_addr_clicked(GtkWidget *button, EContactEditor *editor) -{ - GnomeDialog *dialog; - int result; - const ECardDeliveryAddress *address; - - address = e_card_simple_get_delivery_address(editor->simple, editor->address_choice); - - dialog = GNOME_DIALOG(e_contact_editor_address_new(address)); - gtk_object_set (GTK_OBJECT (dialog), - "editable", editor->editable, - NULL); - gtk_widget_show(GTK_WIDGET(dialog)); - - result = gnome_dialog_run (dialog); - if (result == 0) { - ECardDeliveryAddress *new_address; - GtkWidget *address_widget; - - gtk_object_get(GTK_OBJECT(dialog), - "address", &new_address, - NULL); - - address_widget = glade_xml_get_widget(editor->gui, "text-address"); - if (address_widget && GTK_IS_EDITABLE(address_widget)) { - char *string = e_card_delivery_address_to_string(new_address); - e_utf8_gtk_editable_set_text(GTK_EDITABLE(address_widget), string); - g_free(string); - } else { - ECardAddrLabel *address = e_card_delivery_address_to_label(new_address); - e_card_simple_set_address(editor->simple, editor->address_choice, address); - e_card_address_label_free(address); - } - - e_card_simple_set_delivery_address(editor->simple, editor->address_choice, new_address); - - e_card_delivery_address_free(new_address); - } - 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 = e_utf8_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_categories_new(categories)); - gtk_object_set(GTK_OBJECT(dialog), - "header", _("This contact belongs to these categories:"), - NULL); - gtk_widget_show(GTK_WIDGET(dialog)); - result = gnome_dialog_run (dialog); - g_free (categories); - if (result == 0) { - gtk_object_get(GTK_OBJECT(dialog), - "categories", &categories, - NULL); - if (entry && GTK_IS_ENTRY(entry)) - e_utf8_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 0 - if (!entry) - g_free(categories); -#endif -} - -typedef struct { - EContactEditor *ce; - gboolean should_close; -} EditorCloseStruct; - -static void -card_added_cb (EBook *book, EBookStatus status, const char *id, EditorCloseStruct *ecs) -{ - EContactEditor *ce = ecs->ce; - gboolean should_close = ecs->should_close; - - g_free (ecs); - - gtk_signal_emit (GTK_OBJECT (ce), contact_editor_signals[CARD_ADDED], - status, ce->card); - - if (status == E_BOOK_STATUS_SUCCESS) { - ce->is_new_card = FALSE; - - if (should_close) - close_dialog (ce); - } -} - -static void -card_modified_cb (EBook *book, EBookStatus status, EditorCloseStruct *ecs) -{ - EContactEditor *ce = ecs->ce; - gboolean should_close = ecs->should_close; - - g_free (ecs); - - gtk_signal_emit (GTK_OBJECT (ce), contact_editor_signals[CARD_MODIFIED], - status, ce->card); - - if (status == E_BOOK_STATUS_SUCCESS) { - if (should_close) - close_dialog (ce); - } -} - -/* Emits the signal to request saving a card */ -static void -save_card (EContactEditor *ce, gboolean should_close) -{ - extract_info (ce); - e_card_simple_sync_card (ce->simple); - - if (ce->book) { - EditorCloseStruct *ecs = g_new(EditorCloseStruct, 1); - - ecs->ce = ce; - ecs->should_close = should_close; - - if (ce->is_new_card) - e_card_merging_book_add_card (ce->book, ce->card, GTK_SIGNAL_FUNC(card_added_cb), ecs); - else - e_card_merging_book_commit_card (ce->book, ce->card, GTK_SIGNAL_FUNC(card_modified_cb), ecs); - } -} - -/* 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, FALSE); -} - -/* 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); -} - -static void -file_send_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_card_send(card, E_CARD_DISPOSITION_AS_ATTACHMENT); -} - -static void -file_send_to_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_card_send(card, E_CARD_DISPOSITION_AS_TO); -} - -gboolean -e_contact_editor_confirm_delete(GtkWindow *parent) -{ - GnomeDialog *dialog; - GladeXML *gui; - int result; - - gui = glade_xml_new (EVOLUTION_GLADEDIR "/e-contact-editor-confirm-delete.glade", NULL); - - dialog = GNOME_DIALOG(glade_xml_get_widget(gui, "confirm-dialog")); - - gnome_dialog_set_parent(dialog, parent); - - result = gnome_dialog_run_and_close(dialog); - - gtk_object_unref(GTK_OBJECT(gui)); - - return !result; -} - -static void -card_deleted_cb (EBook *book, EBookStatus status, EContactEditor *ce) -{ - gtk_signal_emit (GTK_OBJECT (ce), contact_editor_signals[CARD_DELETED], - status, ce->card); -} - -static void -delete_cb (GtkWidget *widget, gpointer data) -{ - EContactEditor *ce = E_CONTACT_EDITOR (data); - ECard *card = ce->card; - ECardSimple *simple = ce->simple; - - gtk_object_ref(GTK_OBJECT(card)); - gtk_object_ref(GTK_OBJECT(simple)); - - if (e_contact_editor_confirm_delete(GTK_WINDOW(ce->app))) { - - extract_info (ce); - e_card_simple_sync_card (simple); - - if (!ce->is_new_card && ce->book) - e_book_remove_card (ce->book, card, GTK_SIGNAL_FUNC(card_deleted_cb), ce); - } - - gtk_object_unref(GTK_OBJECT(card)); - gtk_object_unref(GTK_OBJECT(simple)); -} - -/* Emits the signal to request printing a card */ -static void -print_cb (BonoboUIComponent *uih, void *data, const char *path) -{ - EContactEditor *ce; - - ce = E_CONTACT_EDITOR (data); - - extract_info (ce); - e_card_simple_sync_card (ce->simple); - - gtk_widget_show(e_contact_print_card_dialog_new(ce->card)); -} - -/* Emits the signal to request printing a card */ -static void -print_envelope_cb (BonoboUIComponent *uih, void *data, const char *path) -{ - EContactEditor *ce; - - ce = E_CONTACT_EDITOR (data); - - extract_info (ce); - e_card_simple_sync_card (ce->simple); - - gtk_widget_show(e_contact_print_envelope_dialog_new(ce->card)); -} - -/* Toolbar/Save and Close callback */ -static void -tb_save_and_close_cb (BonoboUIComponent *uih, void *data, const char *path) -{ - EContactEditor *ce; - - ce = E_CONTACT_EDITOR (data); - save_card (ce, TRUE); -} - -static -BonoboUIVerb verbs [] = { - BONOBO_UI_UNSAFE_VERB ("ContactEditorSave", file_save_cb), - BONOBO_UI_UNSAFE_VERB ("ContactEditorSaveAs", file_save_as_cb), - BONOBO_UI_UNSAFE_VERB ("ContactEditorSaveClose", tb_save_and_close_cb), - BONOBO_UI_UNSAFE_VERB ("ContactEditorSendAs", file_send_as_cb), - BONOBO_UI_UNSAFE_VERB ("ContactEditorSendTo", file_send_to_cb), - BONOBO_UI_UNSAFE_VERB ("ContactEditorDelete", delete_cb), - BONOBO_UI_UNSAFE_VERB ("ContactEditorPrint", print_cb), - BONOBO_UI_UNSAFE_VERB ("ContactEditorPrintEnvelope", print_envelope_cb), - /* BONOBO_UI_UNSAFE_VERB ("ContactEditorPageSetup", file_page_setup_menu), */ - BONOBO_UI_UNSAFE_VERB ("ContactEditorClose", file_close_cb), - - BONOBO_UI_VERB_END -}; - -static void -create_ui (EContactEditor *ce) -{ - bonobo_ui_component_add_verb_list_with_data ( - ce->uic, verbs, ce); - - bonobo_ui_util_set_ui (ce->uic, EVOLUTION_DATADIR, - "evolution-contact-editor.xml", - "evolution-contact-editor"); -} - -/* 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 GList * -add_to_tab_order(GList *list, GladeXML *gui, char *name) -{ - GtkWidget *widget = glade_xml_get_widget(gui, name); - return g_list_prepend(list, widget); -} - -static void -setup_tab_order(GladeXML *gui) -{ - GtkWidget *container; - GList *list = NULL; - - container = glade_xml_get_widget(gui, "table-contact-editor-general"); - - if (container) { - list = add_to_tab_order(list, gui, "entry-fullname"); - list = add_to_tab_order(list, gui, "entry-jobtitle"); - list = add_to_tab_order(list, gui, "entry-company"); - list = add_to_tab_order(list, gui, "combo-file-as"); - list = add_to_tab_order(list, gui, "entry-phone1"); - list = add_to_tab_order(list, gui, "entry-phone2"); - list = add_to_tab_order(list, gui, "entry-phone3"); - list = add_to_tab_order(list, gui, "entry-phone4"); - list = g_list_reverse(list); - e_container_change_tab_order(GTK_CONTAINER(container), list); - g_list_free(list); - - list = NULL; - list = add_to_tab_order(list, gui, "entry-email1"); - list = add_to_tab_order(list, gui, "entry-web"); - list = add_to_tab_order(list, gui, "text-address"); - list = add_to_tab_order(list, gui, "alignment-contacts"); - list = g_list_reverse(list); - e_container_change_tab_order(GTK_CONTAINER(container), list); - g_list_free(list); - } -} - -static void -e_contact_editor_init (EContactEditor *e_contact_editor) -{ - GladeXML *gui; - GtkWidget *widget; - GtkWidget *bonobo_win; - GtkWidget *wants_html; - BonoboUIContainer *container; - - 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 = e_card_name_new(); - 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; - e_contact_editor->changed = FALSE; - - gui = glade_xml_new (EVOLUTION_GLADEDIR "/contact-editor.glade", NULL); - e_contact_editor->gui = gui; - - setup_tab_order(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); - - wants_html = glade_xml_get_widget(e_contact_editor->gui, "checkbutton-htmlmail"); - if (wants_html && GTK_IS_TOGGLE_BUTTON(wants_html)) - gtk_signal_connect(GTK_OBJECT(wants_html), "toggled", - wants_html_changed, 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-fulladdr"); - if (widget && GTK_IS_BUTTON(widget)) - gtk_signal_connect(GTK_OBJECT(widget), "clicked", - full_addr_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); - - - /* Construct the app */ - bonobo_win = bonobo_window_new ("contact-editor-dialog", "Contact Editor"); - - /* FIXME: The sucking bit */ - { - GtkWidget *contents; - - contents = gnome_dock_get_client_area ( - GNOME_DOCK (GNOME_APP (e_contact_editor->app)->dock)); - if (!contents) { - g_message ("contact_editor_construct(): Could not get contents"); - return; - } - gtk_widget_ref (contents); - gtk_container_remove (GTK_CONTAINER (contents->parent), contents); - bonobo_window_set_contents (BONOBO_WINDOW (bonobo_win), contents); - gtk_widget_destroy (e_contact_editor->app); - e_contact_editor->app = bonobo_win; - } - - /* Build the menu and toolbar */ - - container = bonobo_ui_container_new (); - bonobo_ui_container_set_win (container, BONOBO_WINDOW (e_contact_editor->app)); - - e_contact_editor->uic = bonobo_ui_component_new_default (); - if (!e_contact_editor->uic) { - g_message ("e_contact_editor_init(): eeeeek, could not create the UI handler!"); - return; - } - bonobo_ui_component_set_container (e_contact_editor->uic, - bonobo_object_corba_objref ( - BONOBO_OBJECT (container))); - - create_ui (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->writable_fields) { - gtk_object_unref(GTK_OBJECT(e_contact_editor->writable_fields)); - } - 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)); - - if (e_contact_editor->book) - gtk_object_unref(GTK_OBJECT(e_contact_editor->book)); - - if (e_contact_editor->name) - e_card_name_free(e_contact_editor->name); - - g_free (e_contact_editor->company); - - gtk_object_unref(GTK_OBJECT(e_contact_editor->gui)); -} - -static void -command_state_changed (EContactEditor *ce) -{ - bonobo_ui_component_set_prop (ce->uic, - "/commands/ContactEditorSaveClose", - "sensitive", - ce->changed ? "1" : "0", NULL); - bonobo_ui_component_set_prop (ce->uic, - "/commands/ContactEditorSave", - "sensitive", - ce->changed ? "1" : "0", NULL); - bonobo_ui_component_set_prop (ce->uic, - "/commands/ContactEditorDelete", - "sensitive", - (ce->editable && !ce->is_new_card) ? "1" : "0", NULL); -} - -static void -supported_fields_cb (EBook *book, EBookStatus status, - EList *fields, EContactEditor *ce) -{ - gtk_object_set (GTK_OBJECT (ce), - "writable_fields", fields, - NULL); - - e_contact_editor_show (ce); - - command_state_changed (ce); -} - -EContactEditor * -e_contact_editor_new (EBook *book, - ECard *card, - gboolean is_new_card, - gboolean editable) -{ - EContactEditor *ce; - - ce = E_CONTACT_EDITOR (gtk_type_new (E_CONTACT_EDITOR_TYPE)); - - gtk_object_set (GTK_OBJECT (ce), - "book", book, - "card", card, - "is_new_card", is_new_card, - "editable", editable, - NULL); - - if (book) - e_book_get_supported_fields (book, (EBookFieldsCallback)supported_fields_cb, ce); - - 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_BOOK: - if (editor->book) - gtk_object_unref(GTK_OBJECT(editor->book)); - editor->book = E_BOOK(GTK_VALUE_OBJECT (*arg)); - gtk_object_ref (GTK_OBJECT (editor->book)); - /* XXX more here about editable/etc. */ - break; - case ARG_CARD: - if (editor->card) - gtk_object_unref(GTK_OBJECT(editor->card)); - editor->card = e_card_duplicate(E_CARD(GTK_VALUE_OBJECT (*arg))); - gtk_object_set(GTK_OBJECT(editor->simple), - "card", editor->card, - NULL); - fill_in_info(editor); - editor->changed = FALSE; - break; - - case ARG_IS_NEW_CARD: - editor->is_new_card = GTK_VALUE_BOOL (*arg) ? TRUE : FALSE; - break; - - case ARG_EDITABLE: { - gboolean new_value = GTK_VALUE_BOOL (*arg) ? TRUE : FALSE; - gboolean changed = (editor->editable != new_value); - - editor->editable = new_value; - - if (changed) { - set_editable (editor); - command_state_changed (editor); - } - break; - } - case ARG_WRITABLE_FIELDS: - if (editor->writable_fields) - gtk_object_unref(GTK_OBJECT(editor->writable_fields)); - editor->writable_fields = GTK_VALUE_POINTER (*arg); - if (editor->writable_fields) - gtk_object_ref (GTK_OBJECT (editor->writable_fields)); - else - editor->writable_fields = e_list_new(NULL, NULL, NULL); - enable_writable_fields (editor); - break; - } -} - -static void -e_contact_editor_get_arg (GtkObject *object, GtkArg *arg, guint arg_id) -{ - EContactEditor *e_contact_editor; - - e_contact_editor = E_CONTACT_EDITOR (object); - - switch (arg_id) { - case ARG_BOOK: - GTK_VALUE_OBJECT (*arg) = GTK_OBJECT(e_contact_editor->book); - break; - - 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; - - case ARG_EDITABLE: - GTK_VALUE_BOOL (*arg) = e_contact_editor->editable ? TRUE : FALSE; - break; - - case ARG_WRITABLE_FIELDS: - if (e_contact_editor->writable_fields) - GTK_VALUE_POINTER (*arg) = e_list_duplicate (e_contact_editor->writable_fields); - else - GTK_VALUE_POINTER (*arg) = NULL; - 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; -} - -static void -e_contact_editor_build_phone_ui (EContactEditor *editor) -{ - int i; - - 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); - } -} - -static void -e_contact_editor_build_email_ui (EContactEditor *editor) -{ - int i; - - 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); - } -} - -static void -e_contact_editor_build_address_ui (EContactEditor *editor) -{ - int i; - - if (editor->address_list == NULL) { - static char *info[] = { - N_("Business"), - N_("Home"), - N_("Other") - }; - - for (i = 0; i < sizeof(info) / sizeof(info[0]); i++) { - editor->address_list = g_list_append(editor->address_list, g_strdup(info[i])); - } - } - if (editor->address_info == NULL) { - e_contact_editor_build_ui_info(editor->address_list, &editor->address_info); - - if ( editor->address_popup ) - gtk_widget_unref(editor->address_popup); - - editor->address_popup = gnome_popup_menu_new(editor->address_info); - } -} -#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, e_utf8_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); - - e_contact_editor_build_phone_ui (editor); - - 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); - gtk_widget_set_sensitive (glade_xml_get_widget (editor->gui, label), TRUE); - gtk_widget_set_sensitive (glade_xml_get_widget (editor->gui, entry), editor->editable); - } - - g_free(label); - g_free(entry); -} - -static void -_email_arrow_pressed (GtkWidget *widget, GdkEventButton *button, EContactEditor *editor) -{ - int i; - int result; - - e_contact_editor_build_email_ui (editor); - - 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); - - /* make sure the buttons/entry is/are sensitive */ - gtk_widget_set_sensitive (glade_xml_get_widget (editor->gui, "label-email1"), TRUE); - gtk_widget_set_sensitive (glade_xml_get_widget (editor->gui, "entry-email1"), editor->editable); - gtk_widget_set_sensitive (glade_xml_get_widget (editor->gui, "checkbutton-htmlmail"), editor->editable); - } -} - -static void -_address_arrow_pressed (GtkWidget *widget, GdkEventButton *button, EContactEditor *editor) -{ - int i; - int result; - - e_contact_editor_build_address_ui (editor); - - 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); - - /* make sure the buttons/entry is/are sensitive */ - gtk_widget_set_sensitive (glade_xml_get_widget (editor->gui, "label-address"), TRUE); - gtk_widget_set_sensitive (glade_xml_get_widget (editor->gui, "button-fulladdr"), editor->editable); - gtk_widget_set_sensitive (glade_xml_get_widget (editor->gui, "text-address"), editor->editable); - } -} - -static void -set_field(GtkEntry *entry, const char *string) -{ - char *oldstring = e_utf8_gtk_entry_get_text(entry); - if (!string) - string = ""; - if (strcmp(string, oldstring)) - e_utf8_gtk_entry_set_text(entry, string); - g_free (oldstring); -} - -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) { - gchar *u = e_utf8_to_gtk_string ((GtkWidget *) editable, address->data); - gtk_editable_insert_text(editable, u, strlen(u), &position); - g_free (u); - } - - 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) { - gchar *u = e_utf8_to_gtk_string ((GtkWidget *) editable, value); - gtk_editable_insert_text(editable, u, strlen(u), &position); - g_free (u); - } - } -} - -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) { - gchar *u = e_utf8_to_gtk_string ((GtkWidget *) editable, arbitrary->value); - gtk_editable_insert_text(editable, u, strlen(u), &position); - g_free (u); - } - } -} - -static void -disable_widget_foreach (char *key, GtkWidget *widget, gpointer closure) -{ - gtk_widget_set_sensitive (widget, FALSE); -} - -static struct { - char *widget_name; - ECardSimpleField field_id; - gboolean desensitize_for_read_only; -} widget_field_mappings[] = { - { "entry-web", E_CARD_SIMPLE_FIELD_URL, TRUE }, - { "accellabel-web", E_CARD_SIMPLE_FIELD_URL }, - - { "entry-jobtitle", E_CARD_SIMPLE_FIELD_TITLE, TRUE }, - { "label-jobtitle", E_CARD_SIMPLE_FIELD_TITLE }, - - { "entry-company", E_CARD_SIMPLE_FIELD_ORG, TRUE }, - { "label-company", E_CARD_SIMPLE_FIELD_ORG }, - - { "combo-file-as", E_CARD_SIMPLE_FIELD_FILE_AS, TRUE }, - { "entry-file-as", E_CARD_SIMPLE_FIELD_FILE_AS, TRUE }, - { "accellabel-fileas", E_CARD_SIMPLE_FIELD_FILE_AS }, - - { "label-department", E_CARD_SIMPLE_FIELD_ORG_UNIT }, - { "entry-department", E_CARD_SIMPLE_FIELD_ORG_UNIT, TRUE }, - - { "label-office", E_CARD_SIMPLE_FIELD_OFFICE }, - { "entry-office", E_CARD_SIMPLE_FIELD_OFFICE, TRUE }, - - { "label-profession", E_CARD_SIMPLE_FIELD_ROLE }, - { "entry-profession", E_CARD_SIMPLE_FIELD_ROLE, TRUE }, - - { "label-manager", E_CARD_SIMPLE_FIELD_MANAGER }, - { "entry-manager", E_CARD_SIMPLE_FIELD_MANAGER, TRUE }, - - { "label-assistant", E_CARD_SIMPLE_FIELD_ASSISTANT }, - { "entry-assistant", E_CARD_SIMPLE_FIELD_ASSISTANT, TRUE }, - - { "label-nickname", E_CARD_SIMPLE_FIELD_NICKNAME }, - { "entry-nickname", E_CARD_SIMPLE_FIELD_NICKNAME, TRUE }, - - { "label-spouse", E_CARD_SIMPLE_FIELD_SPOUSE }, - { "entry-spouse", E_CARD_SIMPLE_FIELD_SPOUSE, TRUE }, - - { "label-birthday", E_CARD_SIMPLE_FIELD_BIRTH_DATE }, - { "dateedit-birthday", E_CARD_SIMPLE_FIELD_BIRTH_DATE, TRUE }, - - { "label-anniversary", E_CARD_SIMPLE_FIELD_ANNIVERSARY }, - { "dateedit-anniversary", E_CARD_SIMPLE_FIELD_ANNIVERSARY, TRUE }, - - { "label-comments", E_CARD_SIMPLE_FIELD_NOTE }, - { "text-comments", E_CARD_SIMPLE_FIELD_NOTE, TRUE }, - - { "button-fullname", E_CARD_SIMPLE_FIELD_FULL_NAME }, - { "entry-fullname", E_CARD_SIMPLE_FIELD_FULL_NAME, TRUE }, - - { "button-categories", E_CARD_SIMPLE_FIELD_CATEGORIES, TRUE }, - { "entry-categories", E_CARD_SIMPLE_FIELD_CATEGORIES, TRUE } -}; -static int num_widget_field_mappings = sizeof(widget_field_mappings) / sizeof (widget_field_mappings[0]); - -static void -enable_writable_fields(EContactEditor *editor) -{ - EList *fields = editor->writable_fields; - EIterator *iter; - GHashTable *dropdown_hash, *supported_hash; - int i; - ECardSimple *simple; - ECard *card; - char *widget_name; - - if (!fields) - return; - - card = e_card_new (""); - simple = e_card_simple_new (card); - - dropdown_hash = g_hash_table_new (g_str_hash, g_str_equal); - supported_hash = g_hash_table_new (g_str_hash, g_str_equal); - - /* build our hashtable of the drop down menu items */ - e_contact_editor_build_phone_ui (editor); - for (i = 0; i < E_CARD_SIMPLE_PHONE_ID_LAST; i ++) - g_hash_table_insert (dropdown_hash, - (char*)e_card_simple_get_ecard_field(simple, e_card_simple_map_phone_to_field (i)), - editor->phone_info[i].widget); - e_contact_editor_build_email_ui (editor); - for (i = 0; i < E_CARD_SIMPLE_EMAIL_ID_LAST; i ++) - g_hash_table_insert (dropdown_hash, - (char*)e_card_simple_get_ecard_field(simple, e_card_simple_map_email_to_field (i)), - editor->email_info[i].widget); - e_contact_editor_build_address_ui (editor); - for (i = 0; i < E_CARD_SIMPLE_ADDRESS_ID_LAST; i ++) - g_hash_table_insert (dropdown_hash, - (char*)e_card_simple_get_ecard_field(simple, e_card_simple_map_address_to_field (i)), - editor->address_info[i].widget); - - /* then disable them all */ - g_hash_table_foreach (dropdown_hash, (GHFunc)disable_widget_foreach, NULL); - - /* disable the label widgets for the dropdowns (4 phone, 1 - email and the toggle button, and 1 address and one for - the full adress button */ - for (i = 0; i < 4; i ++) { - widget_name = g_strdup_printf ("label-phone%d", i+1); - gtk_widget_set_sensitive (glade_xml_get_widget (editor->gui, widget_name), FALSE); - g_free (widget_name); - widget_name = g_strdup_printf ("entry-phone%d", i+1); - gtk_widget_set_sensitive (glade_xml_get_widget (editor->gui, widget_name), FALSE); - g_free (widget_name); - } - gtk_widget_set_sensitive (glade_xml_get_widget (editor->gui, "label-email1"), FALSE); - gtk_widget_set_sensitive (glade_xml_get_widget (editor->gui, "entry-email1"), FALSE); - gtk_widget_set_sensitive (glade_xml_get_widget (editor->gui, "checkbutton-htmlmail"), FALSE); - gtk_widget_set_sensitive (glade_xml_get_widget (editor->gui, "label-address"), FALSE); - gtk_widget_set_sensitive (glade_xml_get_widget (editor->gui, "button-fulladdr"), FALSE); - gtk_widget_set_sensitive (glade_xml_get_widget (editor->gui, "text-address"), FALSE); - - /* enable widgets that map directly from a field to a widget (the drop down items) */ - iter = e_list_get_iterator (fields); - for (; e_iterator_is_valid (iter); e_iterator_next (iter)) { - char *field = (char*)e_iterator_get (iter); - GtkWidget *widget = g_hash_table_lookup (dropdown_hash, field); - - if (widget) { - gtk_widget_set_sensitive (widget, TRUE); - } - else { - /* if it's not a field that's handled by the - dropdown items, add it to the has to be - used in the second step */ - g_hash_table_insert (supported_hash, field, field); - } - - /* ugh - this is needed to make sure we don't have a - disabled label next to a drop down when the item in - the menu (the one reflected in the label) is - enabled. */ - if (!strcmp (field, e_card_simple_get_ecard_field (simple, e_card_simple_map_email_to_field(editor->email_choice)))) { - gtk_widget_set_sensitive (glade_xml_get_widget (editor->gui, "label-email1"), TRUE); - gtk_widget_set_sensitive (glade_xml_get_widget (editor->gui, "entry-email1"), editor->editable); - gtk_widget_set_sensitive (glade_xml_get_widget (editor->gui, "checkbutton-htmlmail"), TRUE); - } - else if (!strcmp (field, e_card_simple_get_ecard_field (simple, e_card_simple_map_address_to_field(editor->address_choice)))) { - gtk_widget_set_sensitive (glade_xml_get_widget (editor->gui, "label-address"), TRUE); - gtk_widget_set_sensitive (glade_xml_get_widget (editor->gui, "button-fulladdr"), editor->editable); - gtk_widget_set_sensitive (glade_xml_get_widget (editor->gui, "text-address"), editor->editable); - } - else for (i = 0; i < 4; i ++) { - if (!strcmp (field, e_card_simple_get_ecard_field (simple, e_card_simple_map_phone_to_field(editor->phone_choice[i])))) { - widget_name = g_strdup_printf ("label-phone%d", i+1); - gtk_widget_set_sensitive (glade_xml_get_widget (editor->gui, widget_name), TRUE); - g_free (widget_name); - widget_name = g_strdup_printf ("entry-phone%d", i+1); - gtk_widget_set_sensitive (glade_xml_get_widget (editor->gui, widget_name), editor->editable); - g_free (widget_name); - } - } - } - - /* handle the label next to the dropdown widgets */ - - for (i = 0; i < num_widget_field_mappings; i ++) { - gboolean enabled = g_hash_table_lookup (supported_hash, - e_card_simple_get_ecard_field (simple, - widget_field_mappings[i].field_id)) != NULL; - gtk_widget_set_sensitive (glade_xml_get_widget(editor->gui, - widget_field_mappings[i].widget_name), enabled); - } - - g_hash_table_destroy (dropdown_hash); - g_hash_table_destroy (supported_hash); - gtk_object_unref (GTK_OBJECT(simple)); - gtk_object_unref (GTK_OBJECT(card)); -} - -static void -set_editable (EContactEditor *editor) -{ - int i; - char *label, *entry; - /* set the sensitivity of all the non-dropdown entry/texts/dateedits */ - for (i = 0; i < num_widget_field_mappings; i ++) { - if (widget_field_mappings[i].desensitize_for_read_only) - gtk_widget_set_sensitive (glade_xml_get_widget(editor->gui, - widget_field_mappings[i].widget_name), editor->editable); - } - - /* handle the phone dropdown entries */ - for (i = 0; i < 4; i ++) { - label = g_strdup_printf ("label-phone%d", i+1); - entry = g_strdup_printf ("entry-phone%d", i+1); - - if (GTK_WIDGET_IS_SENSITIVE (glade_xml_get_widget (editor->gui, label))) - gtk_widget_set_sensitive (glade_xml_get_widget(editor->gui, - entry), editor->editable); - - g_free (label); - g_free (entry); - } - - /* handle the email dropdown entry */ - label = "label-email1"; - entry = "entry-email1"; - if (GTK_WIDGET_IS_SENSITIVE (glade_xml_get_widget (editor->gui, label))) { - gtk_widget_set_sensitive (glade_xml_get_widget(editor->gui, - entry), editor->editable); - gtk_widget_set_sensitive (glade_xml_get_widget(editor->gui, - "checkbutton-htmlmail"), editor->editable); - } - - /* handle the address dropdown entry */ - label = "label-address"; - entry = "text-address"; - if (GTK_WIDGET_IS_SENSITIVE (glade_xml_get_widget (editor->gui, label))) - gtk_widget_set_sensitive (glade_xml_get_widget(editor->gui, - entry), editor->editable); -} - -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; - gboolean wants_html, wants_html_set; - - gtk_object_get(GTK_OBJECT(card), - "file_as", &file_as, - "name", &name, - "anniversary", &anniversary, - "birth_date", &bday, - "wants_html_set",&wants_html_set, - "wants_html", &wants_html, - 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); - } - - if (wants_html_set) { - GtkWidget *widget = glade_xml_get_widget(editor->gui, "checkbutton-htmlmail"); - if (widget && GTK_IS_CHECK_BUTTON(widget)) { - gtk_object_set(GTK_OBJECT(widget), - "active", wants_html, - NULL); - } - } - - /* 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 (widget && E_IS_DATE_EDIT(widget)) { - EDateEdit *dateedit; - dateedit = E_DATE_EDIT(widget); - if (anniversary) - e_date_edit_set_date (dateedit, - anniversary->year, - anniversary->month, - anniversary->day); - else - e_date_edit_set_time (dateedit, -1); - } - - widget = glade_xml_get_widget(editor->gui, "dateedit-birthday"); - if (widget && E_IS_DATE_EDIT(widget)) { - EDateEdit *dateedit; - dateedit = E_DATE_EDIT(widget); - if (bday) - e_date_edit_set_date (dateedit, - bday->year, - bday->month, - bday->day); - else - e_date_edit_set_time (dateedit, -1); - } - - 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 = e_utf8_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); - - if (string) 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 = e_utf8_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); - if (string) g_free(string); - } -} - -static void -extract_info(EContactEditor *editor) -{ - ECard *card = editor->card; - if (card) { - ECardDate anniversary; - ECardDate bday; - 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 = e_utf8_gtk_editable_get_chars(editable, 0, -1); - - if (string && *string) - gtk_object_set(GTK_OBJECT(card), - "file_as", string, - NULL); - - if (string) 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 && E_IS_DATE_EDIT(widget)) { - if (e_date_edit_get_date (E_DATE_EDIT (widget), - &anniversary.year, - &anniversary.month, - &anniversary.day)) { - g_print ("%d %d %d\n", anniversary.year, anniversary.month, anniversary.day); - gtk_object_set(GTK_OBJECT(card), - "anniversary", &anniversary, - NULL); - } else - gtk_object_set(GTK_OBJECT(card), - "anniversary", NULL, - NULL); - } - - widget = glade_xml_get_widget(editor->gui, "dateedit-birthday"); - if (widget && E_IS_DATE_EDIT(widget)) { - if (e_date_edit_get_date (E_DATE_EDIT (widget), - &bday.year, - &bday.month, - &bday.day)) { - g_print ("%d %d %d\n", bday.year, bday.month, bday.day); - gtk_object_set(GTK_OBJECT(card), - "birth_date", &bday, - NULL); - } else - gtk_object_set(GTK_OBJECT(card), - "birth_date", NULL, - NULL); - } - } -} - -/** - * e_contact_editor_raise: - * @config: The %EContactEditor object. - * - * Raises the dialog associated with this %EContactEditor object. - */ -void -e_contact_editor_raise (EContactEditor *editor) -{ - gdk_window_raise (GTK_WIDGET (editor->app)->window); -} - -/** - * e_contact_editor_show: - * @ce: The %EContactEditor object. - * - * Shows the dialog associated with this %EContactEditor object. - */ -void -e_contact_editor_show (EContactEditor *ce) -{ - gtk_widget_show (ce->app); -} - -GtkWidget * -e_contact_editor_create_date(gchar *name, - gchar *string1, gchar *string2, - gint int1, gint int2); - -GtkWidget * -e_contact_editor_create_date(gchar *name, - gchar *string1, gchar *string2, - gint int1, gint int2) -{ - GtkWidget *widget = e_date_edit_new (); - e_date_edit_set_allow_no_date_set (E_DATE_EDIT (widget), - TRUE); - e_date_edit_set_show_time (E_DATE_EDIT (widget), FALSE); - e_date_edit_set_time (E_DATE_EDIT (widget), -1); - return widget; -} diff --git a/addressbook/contact-editor/e-contact-editor.h b/addressbook/contact-editor/e-contact-editor.h deleted file mode 100644 index d4ebd7d676..0000000000 --- a/addressbook/contact-editor/e-contact-editor.h +++ /dev/null @@ -1,131 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* e-contact-editor.h - * Copyright (C) 2000 Ximian, Inc. - * Author: Chris Lahey - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of 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 "addressbook/backend/ebook/e-book.h" -#include "addressbook/backend/ebook/e-card.h" -#include "addressbook/backend/ebook/e-card-simple.h" - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - -/* 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 */ - EBook *book; - ECard *card; - ECardSimple *simple; - - /* UI handler */ - BonoboUIComponent *uic; - - 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; - - /* Whether the card has been changed since bringing up the contact editor */ - guint changed : 1; - - /* Whether the contact editor will accept modifications */ - guint editable : 1; - - EList *writable_fields; -}; - -struct _EContactEditorClass -{ - GtkObjectClass parent_class; - - /* Notification signals */ - - void (* card_added) (EContactEditor *ce, EBookStatus status, ECard *card); - void (* card_modified) (EContactEditor *ce, EBookStatus status, ECard *card); - void (* card_deleted) (EContactEditor *ce, EBookStatus status, ECard *card); - void (* editor_closed) (EContactEditor *ce); -}; - -EContactEditor *e_contact_editor_new (EBook *book, - ECard *card, - gboolean is_new_card, - gboolean editable); -GtkType e_contact_editor_get_type (void); -void e_contact_editor_show (EContactEditor *editor); -void e_contact_editor_close (EContactEditor *editor); -void e_contact_editor_raise (EContactEditor *editor); - - -gboolean e_contact_editor_confirm_delete (GtkWindow *parent); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - - -#endif /* __E_CONTACT_EDITOR_H__ */ diff --git a/addressbook/contact-editor/e-contact-quick-add.c b/addressbook/contact-editor/e-contact-quick-add.c deleted file mode 100644 index 096f038dd7..0000000000 --- a/addressbook/contact-editor/e-contact-quick-add.c +++ /dev/null @@ -1,416 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * e-contact-quick-add.c - * - * Copyright (C) 2001 Ximian, Inc. - * - * Developed by Jon Trowbridge - */ - -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of 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. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "e-contact-editor.h" -#include "e-contact-quick-add.h" -#include "e-card-merging.h" - -typedef struct _QuickAdd QuickAdd; -struct _QuickAdd { - gchar *name; - gchar *email; - ECard *card; - - EContactQuickAddCallback cb; - gpointer closure; - - GtkWidget *name_entry; - GtkWidget *email_entry; - - gint refs; - -}; - -static QuickAdd * -quick_add_new (void) -{ - QuickAdd *qa = g_new0 (QuickAdd, 1); - qa->card = e_card_new (""); - qa->refs = 1; - return qa; -} - -static void -quick_add_ref (QuickAdd *qa) -{ - if (qa) { - ++qa->refs; - } -} - -static void -quick_add_unref (QuickAdd *qa) -{ - if (qa) { - --qa->refs; - if (qa->refs == 0) { - g_message ("freeing %s / %s", qa->name, qa->email); - g_free (qa->name); - g_free (qa->email); - gtk_object_unref (GTK_OBJECT (qa->card)); - g_free (qa); - } - } -} - -static void -quick_add_set_name (QuickAdd *qa, const gchar *name) -{ - ECardSimple *simple; - - g_free (qa->name); - qa->name = g_strdup (name); - - simple = e_card_simple_new (qa->card); - e_card_simple_set (simple, E_CARD_SIMPLE_FIELD_FULL_NAME, name); - e_card_simple_sync_card (simple); - gtk_object_unref (GTK_OBJECT (simple)); -} - -static void -quick_add_set_email (QuickAdd *qa, const gchar *email) -{ - ECardSimple *simple; - - g_free (qa->email); - qa->email = g_strdup (email); - - simple = e_card_simple_new (qa->card); - e_card_simple_set (simple, E_CARD_SIMPLE_FIELD_EMAIL, email); - e_card_simple_sync_card (simple); - gtk_object_unref (GTK_OBJECT (simple)); -} - -static void -merge_cb (EBook *book, gpointer closure) -{ - QuickAdd *qa = (QuickAdd *) closure; - - if (book != NULL) { - e_card_merging_book_add_card (book, qa->card, NULL, NULL); - if (qa->cb) - qa->cb (qa->card, qa->closure); - } else { - /* Something went wrong. */ - if (qa->cb) - qa->cb (NULL, qa->closure); - } - - quick_add_unref (qa); -} - -static void -quick_add_merge_card (QuickAdd *qa) -{ - quick_add_ref (qa); - e_book_use_local_address_book (merge_cb, qa); -} - - -/* - * Raise a contact editor with all fields editable, and hook up all signals accordingly. - */ - -static void -card_added_cb (EContactEditor *ce, EBookStatus status, ECard *card, gpointer closure) -{ - QuickAdd *qa = (QuickAdd *) closure; - - if (qa->cb) - qa->cb (qa->card, qa->closure); - - quick_add_unref (qa); -} - -static void -editor_closed_cb (GtkWidget *w, gpointer closure) -{ - QuickAdd *qa = (QuickAdd *) closure; - g_warning ("editor_closed_cb"); - quick_add_unref (qa); - gtk_object_unref (GTK_OBJECT (w)); -} - -static void -ce_have_book (EBook *book, gpointer closure) -{ - QuickAdd *qa = (QuickAdd *) closure; - - if (book == NULL) { - g_warning ("Couldn't open local address book."); - quick_add_unref (qa); - } else { - EContactEditor *contact_editor = e_contact_editor_new (book, qa->card, TRUE, FALSE /* XXX */); - - gtk_signal_connect (GTK_OBJECT (contact_editor), - "card_added", - GTK_SIGNAL_FUNC (card_added_cb), - qa); - gtk_signal_connect (GTK_OBJECT (contact_editor), - "editor_closed", - GTK_SIGNAL_FUNC (editor_closed_cb), - qa); - } -} - -static void -edit_card (QuickAdd *qa) -{ - e_book_use_local_address_book (ce_have_book, qa); -} - -static void -clicked_cb (GtkWidget *w, gint button, gpointer closure) -{ - QuickAdd *qa = (QuickAdd *) closure; - - /* Get data out of entries. */ - if (button == 0 || button == 1) { - gchar *name = NULL; - gchar *email = NULL; - - if (qa->name_entry) { - gchar *tmp; - tmp = gtk_editable_get_chars (GTK_EDITABLE (qa->name_entry), 0, -1); - name = e_utf8_from_gtk_string (qa->name_entry, tmp); - g_free (tmp); - } - - if (qa->email_entry) { - gchar *tmp; - tmp = gtk_editable_get_chars (GTK_EDITABLE (qa->email_entry), 0, -1); - email = e_utf8_from_gtk_string (qa->email_entry, tmp); - g_free (tmp); - } - - quick_add_set_name (qa, name); - quick_add_set_email (qa, email); - - g_free (name); - g_free (email); - } - - gtk_widget_destroy (w); - - if (button == 0) { - - /* OK */ - quick_add_merge_card (qa); - - } else if (button == 1) { - - /* EDIT FULL */ - edit_card (qa); - - } else { - /* CANCEL */ - quick_add_unref (qa); - } - -} - -static GtkWidget * -build_quick_add_dialog (QuickAdd *qa) -{ - GtkWidget *dialog; - GtkTable *table; - const gint xpad=1, ypad=1; - - g_return_val_if_fail (qa != NULL, NULL); - - dialog = gnome_dialog_new (_("Contact Quick-Add"), - GNOME_STOCK_BUTTON_OK, - _("Edit Full"), - GNOME_STOCK_BUTTON_CANCEL, - NULL); - - gtk_signal_connect (GTK_OBJECT (dialog), - "clicked", - clicked_cb, - qa); - - qa->name_entry = gtk_entry_new (); - if (qa->name) { - gchar *str = e_utf8_to_gtk_string (qa->name_entry, qa->name); - gtk_entry_set_text (GTK_ENTRY (qa->name_entry), str); - g_free (str); - } - - - qa->email_entry = gtk_entry_new (); - if (qa->email) { - gchar *str = e_utf8_to_gtk_string (qa->email_entry, qa->email); - gtk_entry_set_text (GTK_ENTRY (qa->email_entry), str); - g_free (str); - } - - table = GTK_TABLE (gtk_table_new (2, 2, FALSE)); - - gtk_table_attach (table, gtk_label_new (_("Full Name")), - 0, 1, 0, 1, - 0, 0, xpad, ypad); - gtk_table_attach (table, qa->name_entry, - 1, 2, 0, 1, - GTK_EXPAND | GTK_FILL, GTK_EXPAND, xpad, ypad); - gtk_table_attach (table, gtk_label_new (_("E-mail")), - 0, 1, 1, 2, - 0, 0, xpad, ypad); - gtk_table_attach (table, qa->email_entry, - 1, 2, 1, 2, - GTK_EXPAND | GTK_FILL, GTK_EXPAND, xpad, ypad); - - gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (dialog)->vbox), - GTK_WIDGET (table), - TRUE, TRUE, 0); - gtk_widget_show_all (GTK_WIDGET (table)); - - - return dialog; -} - -void -e_contact_quick_add (const gchar *name, const gchar *email, - EContactQuickAddCallback cb, gpointer closure) -{ - QuickAdd *qa; - GtkWidget *dialog; - - /* We need to have *something* to work with. */ - if (name == NULL && email == NULL) { - if (cb) - cb (NULL, closure); - return; - } - - qa = quick_add_new (); - qa->cb = cb; - qa->closure = closure; - if (name) - quick_add_set_name (qa, name); - if (email) - quick_add_set_email (qa, email); - - dialog = build_quick_add_dialog (qa); - gtk_widget_show_all (dialog); -} - -void -e_contact_quick_add_free_form (const gchar *text, EContactQuickAddCallback cb, gpointer closure) -{ - gchar *name=NULL, *email=NULL; - const gchar *last_at, *s; - gboolean in_quote; - - if (text == NULL) { - e_contact_quick_add (NULL, NULL, cb, closure); - return; - } - - /* Look for things that look like e-mail addresses embedded in text */ - in_quote = FALSE; - last_at = NULL; - for (s = text; *s; ++s) { - if (*s == '@' && !in_quote) - last_at = s; - else if (*s == '"') - in_quote = !in_quote; - } - - - if (last_at == NULL) { - /* No at sign, so we treat it all as the name */ - name = g_strdup (text); - } else { - gboolean bad_char = FALSE; - - /* walk backwards to whitespace or a < or a quote... */ - while (last_at >= text && !bad_char - && !(isspace ((gint) *last_at) || *last_at == '<' || *last_at == '"')) { - /* Check for some stuff that can't appear in a legal e-mail address. */ - if (*last_at == '[' - || *last_at == ']' - || *last_at == '(' - || *last_at == ')') - bad_char = TRUE; - --last_at; - } - if (last_at < text) - last_at = text; - - /* ...and then split the text there */ - if (!bad_char) { - if (text < last_at) - name = g_strndup (text, last_at-text); - email = g_strdup (last_at); - } - } - - /* If all else has failed, make it the name. */ - if (name == NULL && email == NULL) - name = g_strdup (text); - - - /* Clean up name */ - if (name && *name) - g_strstrip (name); - - /* Clean up email, remove bracketing <>s */ - if (email && *email) { - gboolean changed = FALSE; - g_strstrip (email); - if (*email == '<') { - *email = ' '; - changed = TRUE; - } - if (email[strlen (email)-1] == '>') { - email[strlen (email)-1] = ' '; - changed = TRUE; - } - if (changed) - g_strstrip (email); - } - - - e_contact_quick_add (name, email, cb, closure); - g_free (name); - g_free (email); -} diff --git a/addressbook/contact-editor/e-contact-quick-add.h b/addressbook/contact-editor/e-contact-quick-add.h deleted file mode 100644 index e01256a163..0000000000 --- a/addressbook/contact-editor/e-contact-quick-add.h +++ /dev/null @@ -1,41 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * e-contact-quick-add.h - * - * Copyright (C) 2001 Ximian, Inc. - * - * Developed by Jon Trowbridge - */ - -/* - * This program is free software; you can redistribute it and/or - * modify it under the terms of 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. - */ - -#ifndef __E_CONTACT_QUICK_ADD_H__ -#define __E_CONTACT_QUICK_ADD_H__ - -#include - -typedef void (*EContactQuickAddCallback) (ECard *new_card, gpointer closure); - -void e_contact_quick_add (const gchar *name, const gchar *email, - EContactQuickAddCallback cb, gpointer closure); - -void e_contact_quick_add_free_form (const gchar *text, EContactQuickAddCallback cb, gpointer closure); - -#endif /* __E_CONTACT_QUICK_ADD_H__ */ - diff --git a/addressbook/contact-editor/e-contact-save-as.c b/addressbook/contact-editor/e-contact-save-as.c deleted file mode 100644 index 0d2b81f2bd..0000000000 --- a/addressbook/contact-editor/e-contact-save-as.c +++ /dev/null @@ -1,100 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* e-contact-editor.h - * Copyright (C) 2000 Ximian, Inc. - * Author: Chris Lahey - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of 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 "e-contact-save-as.h" - -typedef struct { - GtkFileSelection *filesel; - char *vcard; -} SaveAsInfo; - -static void -save_it(GtkWidget *widget, SaveAsInfo *info) -{ - const char *filename = gtk_file_selection_get_filename (info->filesel); - - e_write_file (filename, info->vcard, O_WRONLY | O_CREAT | O_EXCL | O_TRUNC); - - g_free (info->vcard); - gtk_widget_destroy(GTK_WIDGET(info->filesel)); - g_free(info); -} - -static void -close_it(GtkWidget *widget, SaveAsInfo *info) -{ - g_free (info->vcard); - gtk_widget_destroy (GTK_WIDGET (info->filesel)); - g_free (info); -} - -static void -delete_it(GtkWidget *widget, SaveAsInfo *info) -{ - g_free (info->vcard); - 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->vcard = e_card_get_vcard(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)); -} - -void -e_contact_list_save_as(char *title, GList *list) -{ - GtkFileSelection *filesel; - SaveAsInfo *info = g_new(SaveAsInfo, 1); - - filesel = GTK_FILE_SELECTION(gtk_file_selection_new(title)); - - info->filesel = filesel; - info->vcard = e_card_list_get_vcard (list); - - 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/contact-editor/e-contact-save-as.h b/addressbook/contact-editor/e-contact-save-as.h deleted file mode 100644 index 75bd6ce957..0000000000 --- a/addressbook/contact-editor/e-contact-save-as.h +++ /dev/null @@ -1,43 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* e-contact-save-as.h - * Copyright (C) 2000 Ximian, Inc. - * Author: Chris Lahey - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of 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 "addressbook/backend/ebook/e-card.h" -#include "addressbook/backend/ebook/e-card-simple.h" - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - -void -e_contact_save_as(gchar *title, ECard *card); -void -e_contact_list_save_as(gchar *title, GList *list); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - - -#endif /* __E_CONTACT_EDITOR_H__ */ diff --git a/addressbook/contact-editor/fulladdr.glade b/addressbook/contact-editor/fulladdr.glade deleted file mode 100644 index 46d1a180b6..0000000000 --- a/addressbook/contact-editor/fulladdr.glade +++ /dev/null @@ -1,475 +0,0 @@ - - - - - fulladdr - fulladdr - - src - pixmaps - C - True - True - True - False - False - False - - - - GnomeDialog - dialog-checkaddress - False - Check Address - GTK_WINDOW_TOPLEVEL - GTK_WIN_POS_NONE - True - False - True - False - False - False - - - GtkVBox - GnomeDialog:vbox - vbox-container - 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 - button1 - True - True - True - GNOME_STOCK_BUTTON_OK - - - - GtkButton - button2 - True - True - GNOME_STOCK_BUTTON_CANCEL - - - - - GtkTable - table-checkaddress - 8 - 4 - 4 - False - 6 - 6 - - 0 - True - True - - - - GtkLabel - label2 - - GTK_JUSTIFY_LEFT - False - 1 - 0.5 - 0 - 0 - entry-street - - 0 - 1 - 0 - 1 - 0 - 0 - False - False - False - False - True - True - - - - - GtkLabel - label4 - - GTK_JUSTIFY_CENTER - False - 1 - 0.5 - 0 - 0 - entry-city - - 0 - 1 - 2 - 3 - 0 - 0 - False - False - False - False - True - True - - - - - GtkEntry - entry-city - True - True - True - 0 - - - 1 - 2 - 2 - 3 - 0 - 0 - True - False - False - False - True - True - - - - - GtkEntry - entry-ext - 100 - True - True - True - 0 - - - 1 - 2 - 1 - 2 - 0 - 0 - True - False - False - False - True - True - - - - - GtkLabel - label8 - - GTK_JUSTIFY_CENTER - False - 1 - 0.5 - 0 - 0 - entry-po - - 2 - 3 - 1 - 2 - 0 - 0 - False - False - False - False - True - True - - - - - GtkLabel - label3 - - GTK_JUSTIFY_CENTER - False - 1 - 0.5 - 0 - 0 - entry-ext - - 0 - 1 - 1 - 2 - 0 - 0 - False - False - False - False - True - True - - - - - GtkEntry - entry-po - 100 - True - True - True - 0 - - - 3 - 4 - 1 - 2 - 0 - 0 - False - False - False - False - True - True - - - - - GtkEntry - entry-street - True - True - True - True - 0 - - - 1 - 4 - 0 - 1 - 0 - 0 - True - False - False - False - True - True - - - - - GtkLabel - label5 - - GTK_JUSTIFY_CENTER - False - 1 - 0.5 - 0 - 0 - entry-region - - 0 - 1 - 3 - 4 - 0 - 0 - False - False - False - False - True - True - - - - - GtkEntry - entry-region - True - True - True - 0 - - - 1 - 2 - 3 - 4 - 0 - 0 - True - False - False - False - True - True - - - - - GtkCombo - combo-country - 100 - False - True - False - True - False - USA -Canada -Finland - - - 3 - 4 - 3 - 4 - 0 - 0 - False - False - False - False - True - True - - - - GtkEntry - GtkCombo:entry - entry-country - True - True - True - 0 - - - - - - GtkEntry - entry-code - 100 - True - True - True - 0 - - - 3 - 4 - 2 - 3 - 0 - 0 - False - False - False - False - True - True - - - - - GtkLabel - label6 - - GTK_JUSTIFY_CENTER - False - 1 - 0.5 - 0 - 0 - entry-code - - 2 - 3 - 2 - 3 - 0 - 0 - False - False - False - False - True - True - - - - - GtkLabel - label7 - - GTK_JUSTIFY_CENTER - False - 1 - 0.5 - 0 - 0 - entry-country - - 2 - 3 - 3 - 4 - 0 - 0 - False - False - False - False - True - True - - - - - - - diff --git a/addressbook/contact-editor/fullname.glade b/addressbook/contact-editor/fullname.glade deleted file mode 100644 index 17be70647c..0000000000 --- a/addressbook/contact-editor/fullname.glade +++ /dev/null @@ -1,389 +0,0 @@ - - - - - fullname - fullname - - src - pixmaps - C - True - True - True - False - False - False - - - - 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 - - - - 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 - - - - - GtkTable - table-checkfullname - 8 - 5 - 3 - False - 6 - 21 - - 0 - True - True - - - - GtkCombo - combo-title - False - True - False - True - False - -Mr. -Mrs. -Ms. -Miss -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 - - - - - GtkLabel - label2 - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - entry-first - - 0 - 1 - 1 - 2 - 0 - 0 - False - False - False - False - True - True - - - - - GtkLabel - label1 - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - entry-title - - 0 - 1 - 0 - 1 - 0 - 0 - False - False - False - False - True - True - - - - - GtkLabel - label3 - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - entry-middle - - 0 - 1 - 2 - 3 - 0 - 0 - False - False - False - False - True - True - - - - - GtkLabel - label5 - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - entry-last - - 0 - 1 - 3 - 4 - 0 - 0 - False - False - False - False - True - True - - - - - GtkLabel - label4 - - GTK_JUSTIFY_CENTER - False - 0 - 0.5 - 0 - 0 - entry-suffix - - 0 - 1 - 4 - 5 - 0 - 0 - False - False - False - False - True - True - - - - - - - diff --git a/addressbook/contact-editor/test-editor.c b/addressbook/contact-editor/test-editor.c deleted file mode 100644 index 4842a93bf2..0000000000 --- a/addressbook/contact-editor/test-editor.c +++ /dev/null @@ -1,145 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * test-editor.c - * Copyright (C) 2000 Ximian, Inc. - * Author: Chris Lahey - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of 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 -#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@ximian.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, Ximian, 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, NULL, FALSE); - 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, NULL, FALSE); - 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/Makefile.am b/addressbook/gui/Makefile.am index 8ba306c0d3..6b0850da5d 100644 --- a/addressbook/gui/Makefile.am +++ b/addressbook/gui/Makefile.am @@ -1 +1 @@ -SUBDIRS = merging widgets search component +SUBDIRS = contact-editor contact-list-editor merging widgets search component diff --git a/addressbook/gui/component/Makefile.am b/addressbook/gui/component/Makefile.am index 6f38d86436..d58c768328 100644 --- a/addressbook/gui/component/Makefile.am +++ b/addressbook/gui/component/Makefile.am @@ -1,24 +1,25 @@ SUBDIRS = select-names -INCLUDES = \ - -DG_LOG_DOMAIN=\"evolution-addressbook\" \ - $(EXTRA_GNOME_CFLAGS) \ - $(GNOME_INCLUDEDIR) \ - -I$(top_srcdir) \ - -I$(top_builddir) \ - -I$(top_srcdir)/shell \ - -I$(top_builddir)/shell \ - -I$(top_srcdir)/widgets/misc \ - -I$(top_srcdir)/addressbook/gui/minicard \ - -I$(top_srcdir)/addressbook/gui/widgets \ - -I$(top_srcdir)/addressbook/contact-editor \ - -I$(top_srcdir)/addressbook/backend \ - -I$(top_builddir)/addressbook/backend \ - $(BONOBO_HTML_GNOME_CFLAGS) \ - -DEVOLUTION_DATADIR=\""$(datadir)"\" \ - -DEVOLUTION_GLADEDIR=\""$(gladedir)"\" \ - -DEVOLUTION_ICONSDIR=\""$(iconsdir)"\" \ - -DEVOLUTION_LOCALEDIR=\""$(localedir)"\" \ +INCLUDES = \ + -DG_LOG_DOMAIN=\"evolution-addressbook\" \ + $(EXTRA_GNOME_CFLAGS) \ + $(GNOME_INCLUDEDIR) \ + -I$(top_srcdir) \ + -I$(top_builddir) \ + -I$(top_srcdir)/shell \ + -I$(top_builddir)/shell \ + -I$(top_srcdir)/widgets/misc \ + -I$(top_srcdir)/addressbook/gui/contact-editor \ + -I$(top_srcdir)/addressbook/gui/contact-list-editor \ + -I$(top_srcdir)/addressbook/gui/minicard \ + -I$(top_srcdir)/addressbook/gui/widgets \ + -I$(top_srcdir)/addressbook/backend \ + -I$(top_builddir)/addressbook/backend \ + $(BONOBO_HTML_GNOME_CFLAGS) \ + -DEVOLUTION_DATADIR=\""$(datadir)"\" \ + -DEVOLUTION_GLADEDIR=\""$(gladedir)"\" \ + -DEVOLUTION_ICONSDIR=\""$(iconsdir)"\" \ + -DEVOLUTION_LOCALEDIR=\""$(localedir)"\" \ -DCAMEL_PROVIDERDIR=\""$(providerdir)"\" bin_PROGRAMS = \ @@ -49,7 +50,8 @@ evolution_addressbook_LDADD = \ $(top_builddir)/addressbook/gui/widgets/libeminicard.a \ $(top_builddir)/addressbook/backend/ebook/libebook.la \ $(top_builddir)/e-util/ename/libename.la \ - $(top_builddir)/addressbook/contact-editor/libecontacteditor.a \ + $(top_builddir)/addressbook/gui/contact-list-editor/libecontactlisteditor.a \ + $(top_builddir)/addressbook/gui/contact-editor/libecontacteditor.a \ $(top_builddir)/libversit/libversit.la \ $(top_builddir)/widgets/misc/libemiscwidgets.a \ $(top_builddir)/addressbook/printing/libecontactprint.a \ diff --git a/addressbook/gui/component/addressbook.c b/addressbook/gui/component/addressbook.c index 2936855d57..bd51a3515e 100644 --- a/addressbook/gui/component/addressbook.c +++ b/addressbook/gui/component/addressbook.c @@ -67,6 +67,21 @@ new_contact_cb (BonoboUIComponent *uih, void *user_data, const char *path) e_addressbook_show_contact_editor (book, e_card_new(""), TRUE, e_addressbook_view_can_create(view->view)); } +static void +new_contact_list_cb (BonoboUIComponent *uih, void *user_data, const char *path) +{ + EBook *book; + AddressbookView *view = (AddressbookView *) user_data; + + gtk_object_get(GTK_OBJECT(view->view), + "book", &book, + NULL); + + g_assert (E_IS_BOOK (book)); + + e_addressbook_show_contact_list_editor (book, e_card_new(""), TRUE, e_addressbook_view_can_create(view->view)); +} + static void config_cb (BonoboUIComponent *uih, void *user_data, const char *path) { @@ -101,13 +116,6 @@ print_cb (BonoboUIComponent *uih, void *user_data, const char *path) e_addressbook_view_print(view->view); } -static void -show_all_contacts_cb (BonoboUIComponent *uih, void *user_data, const char *path) -{ - AddressbookView *view = (AddressbookView *) user_data; - e_addressbook_view_show_all(view->view); -} - static void stop_loading_cb (BonoboUIComponent *uih, void *user_data, const char *path) { @@ -153,6 +161,10 @@ update_command_state (EAddressbookView *eav, AddressbookView *view) "/commands/ContactNew", "sensitive", e_addressbook_view_can_create (view->view) ? "1" : "0", NULL); + bonobo_ui_component_set_prop (uic, + "/commands/ContactNewList", + "sensitive", + e_addressbook_view_can_create (view->view) ? "1" : "0", NULL); /* Print Contact */ bonobo_ui_component_set_prop (uic, @@ -184,14 +196,6 @@ update_command_state (EAddressbookView *eav, AddressbookView *view) e_addressbook_view_can_select_all (view->view) ? "1" : "0", NULL); - /* View All Contacts */ -#if 0 - /* this is always enabled */ - bonobo_ui_component_set_prop (uic, - "/Toolbar/ContactViewAll", - "sensitive", "1", NULL); -#endif - /* Stop */ bonobo_ui_component_set_prop (uic, "/commands/ContactStop", @@ -212,8 +216,8 @@ BonoboUIVerb verbs [] = { BONOBO_UI_UNSAFE_VERB ("AddressbookConfig", config_cb), BONOBO_UI_UNSAFE_VERB ("ContactNew", new_contact_cb), + BONOBO_UI_UNSAFE_VERB ("ContactNewList", new_contact_list_cb), BONOBO_UI_UNSAFE_VERB ("ContactDelete", delete_contact_cb), - BONOBO_UI_UNSAFE_VERB ("ContactViewAll", show_all_contacts_cb), BONOBO_UI_UNSAFE_VERB ("ContactStop", stop_loading_cb), BONOBO_UI_UNSAFE_VERB ("ContactsCut", cut_contacts_cb), @@ -230,8 +234,8 @@ static EPixmap pixmaps [] = { E_PIXMAP ("/menu/File/Print/ContactsPrintPreview", "print-preview.xpm"), E_PIXMAP ("/menu/Tools/Component/AddressbookConfig", "configure_16_addressbook.xpm"), - E_PIXMAP ("/Toolbar/ContactViewAll", "all_contacts.xpm"), E_PIXMAP ("/Toolbar/ContactNew", "new_contact.xpm"), + E_PIXMAP ("/Toolbar/ContactNewList", "all_contacts.xpm"), E_PIXMAP_END }; diff --git a/addressbook/gui/component/e-address-popup.c b/addressbook/gui/component/e-address-popup.c index 0d01e3f162..cedaf84a5f 100644 --- a/addressbook/gui/component/e-address-popup.c +++ b/addressbook/gui/component/e-address-popup.c @@ -34,8 +34,8 @@ #include #include #include -#include -#include +#include +#include #include #include static GtkObjectClass *parent_class; diff --git a/addressbook/gui/component/e-address-widget.c b/addressbook/gui/component/e-address-widget.c index f69ce5c58d..2f81c70b36 100644 --- a/addressbook/gui/component/e-address-widget.c +++ b/addressbook/gui/component/e-address-widget.c @@ -30,7 +30,7 @@ #include #include #include -#include +#include #include "e-address-widget.h" static void e_address_widget_class_init (EAddressWidgetClass *klass); diff --git a/addressbook/gui/component/select-names/e-select-names-popup.c b/addressbook/gui/component/select-names/e-select-names-popup.c index 03dadf2d80..fb05ff686a 100644 --- a/addressbook/gui/component/select-names/e-select-names-popup.c +++ b/addressbook/gui/component/select-names/e-select-names-popup.c @@ -39,8 +39,8 @@ #include #include -#include -#include +#include +#include #include "e-addressbook-util.h" #include "e-select-names-popup.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 index c9d1d1177f..7c87c887f5 100644 --- a/addressbook/gui/component/select-names/e-select-names-text-model.c +++ b/addressbook/gui/component/select-names/e-select-names-text-model.c @@ -16,7 +16,7 @@ #include -#include +#include #include "e-select-names-text-model.h" #include "e-addressbook-util.h" diff --git a/addressbook/gui/contact-list-editor/.cvsignore b/addressbook/gui/contact-list-editor/.cvsignore new file mode 100644 index 0000000000..e440fafdac --- /dev/null +++ b/addressbook/gui/contact-list-editor/.cvsignore @@ -0,0 +1,3 @@ +Makefile.in +Makefile +.deps diff --git a/addressbook/gui/contact-list-editor/Makefile.am b/addressbook/gui/contact-list-editor/Makefile.am new file mode 100644 index 0000000000..5e6229a833 --- /dev/null +++ b/addressbook/gui/contact-list-editor/Makefile.am @@ -0,0 +1,29 @@ +INCLUDES = \ + $(BONOBO_GNOME_CFLAGS) \ + $(EXTRA_GNOME_CFLAGS) \ + -I$(top_srcdir) \ + -I$(top_srcdir)/addressbook/ \ + -I$(top_srcdir)/addressbook/backend \ + -I$(top_srcdir)/addressbook/gui/merging \ + -I$(top_srcdir)/widgets/e-table \ + -DEVOLUTION_GLADEDIR=\""$(gladedir)"\" \ + -DDATADIR=\""$(datadir)"\" \ + -DEVOLUTION_DATADIR=\""$(datadir)"\" \ + -DEVOLUTIONDIR=\""$(evolutiondir)"\" \ + -DG_LOG_DOMAIN=\"contact-list-editor\" + +noinst_LIBRARIES = \ + libecontactlisteditor.a + +libecontactlisteditor_a_SOURCES = \ + e-contact-list-editor.c \ + e-contact-list-editor.h \ + e-contact-list-model.c \ + e-contact-list-model.h + +gladedir = $(datadir)/evolution/glade + +glade_DATA = \ + contact-list-editor.glade + +EXTRA_DIST = $(glade_DATA) diff --git a/addressbook/gui/contact-list-editor/contact-list-editor.glade b/addressbook/gui/contact-list-editor/contact-list-editor.glade new file mode 100644 index 0000000000..56317384f3 --- /dev/null +++ b/addressbook/gui/contact-list-editor/contact-list-editor.glade @@ -0,0 +1,287 @@ + + + + + contact-list-editor + contact-list-editor + + src + pixmaps + C + True + True + + + + GnomeApp + contact list editor + contact-list-editor + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_NONE + False + False + True + False + True + + + GnomeDock + GnomeApp:dock + dock1 + True + + 0 + True + True + + + + GtkTable + GnomeDock:contents + table1 + 13 + 6 + 4 + False + 5 + 5 + + + Custom + contact-list-table + e_contact_list_editor_create_table + + 0 + 0 + Sat, 23 Jun 2001 06:00:16 GMT + + 1 + 3 + 4 + 6 + 0 + 0 + True + True + False + False + True + True + + + + + GtkEntry + email-entry + True + True + True + 0 + + + 1 + 3 + 3 + 4 + 0 + 0 + True + False + False + False + True + False + + + + + GtkLabel + label1 + + GTK_JUSTIFY_CENTER + False + 0 + 0.5 + 0 + 0 + + 1 + 3 + 2 + 3 + 0 + 0 + False + False + False + False + True + False + + + + + GtkLabel + label2 + + GTK_JUSTIFY_LEFT + False + 0 + 0.5 + 0 + 0 + + 1 + 2 + 0 + 1 + 0 + 0 + False + False + False + False + True + False + + + + + GtkEntry + list-name-entry + True + True + True + 0 + + + 2 + 3 + 0 + 1 + 0 + 0 + True + False + False + False + True + False + + + + + GtkVButtonBox + vbuttonbox2 + GTK_BUTTONBOX_START + 10 + 85 + 27 + 7 + 0 + + 3 + 4 + 4 + 6 + 0 + 0 + False + False + False + False + True + True + + + + GtkButton + remove-button + True + True + + GTK_RELIEF_NORMAL + + + + + GtkHSeparator + hseparator1 + + 1 + 4 + 1 + 2 + 0 + 0 + False + False + False + False + True + True + + + + + GtkVButtonBox + vbuttonbox3 + GTK_BUTTONBOX_DEFAULT_STYLE + 10 + 85 + 27 + 0 + 0 + + 3 + 4 + 3 + 4 + 0 + 0 + False + False + False + False + True + True + + + + GtkButton + add-email-button + True + True + + GTK_RELIEF_NORMAL + + + + + Custom + custom2 + e_create_image_widget + evolution-contacts-plain.png + 0 + 0 + Sat, 23 Jun 2001 05:59:21 GMT + + 0 + 1 + 0 + 6 + 0 + 0 + False + False + False + False + True + True + + + + + + + diff --git a/addressbook/gui/contact-list-editor/e-contact-list-editor.c b/addressbook/gui/contact-list-editor/e-contact-list-editor.c new file mode 100644 index 0000000000..f95cb936af --- /dev/null +++ b/addressbook/gui/contact-list-editor/e-contact-list-editor.c @@ -0,0 +1,499 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* e-contact-list-editor.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 "e-contact-list-editor.h" +#include "e-contact-list-model.h" + +#include +#include +#include +#include "widgets/misc/e-dateedit.h" + +/* Signal IDs */ +enum { + LIST_ADDED, + LIST_MODIFIED, + LIST_DELETED, + EDITOR_CLOSED, + LAST_SIGNAL +}; + +static void e_contact_list_editor_init (EContactListEditor *editor); +static void e_contact_list_editor_class_init (EContactListEditorClass *klass); +static void e_contact_list_editor_set_arg (GtkObject *o, GtkArg *arg, guint arg_id); +static void e_contact_list_editor_get_arg (GtkObject *object, GtkArg *arg, guint arg_id); +static void e_contact_list_editor_destroy (GtkObject *object); + +static void create_ui (EContactListEditor *ce); +static void set_editable (EContactListEditor *editor); +static void command_state_changed (EContactListEditor *editor); + +static void add_email_cb (GtkWidget *w, EContactListEditor *editor); +static void remove_entry_cb (GtkWidget *w, EContactListEditor *editor); +static void list_name_changed_cb (GtkWidget *w, EContactListEditor *editor); + +static GtkObjectClass *parent_class = NULL; + +static guint contact_list_editor_signals[LAST_SIGNAL]; + +/* The arguments we take */ +enum { + ARG_0, + ARG_BOOK, + ARG_CARD, + ARG_IS_NEW_LIST, + ARG_EDITABLE +}; + +GtkType +e_contact_list_editor_get_type (void) +{ + static GtkType contact_list_editor_type = 0; + + if (!contact_list_editor_type) + { + static const GtkTypeInfo contact_list_editor_info = + { + "EContactListEditor", + sizeof (EContactListEditor), + sizeof (EContactListEditorClass), + (GtkClassInitFunc) e_contact_list_editor_class_init, + (GtkObjectInitFunc) e_contact_list_editor_init, + /* reserved_1 */ NULL, + /* reserved_2 */ NULL, + (GtkClassInitFunc) NULL, + }; + + contact_list_editor_type = gtk_type_unique (GTK_TYPE_OBJECT, &contact_list_editor_info); + } + + return contact_list_editor_type; +} + + +typedef void (*GtkSignal_NONE__INT_OBJECT) (GtkObject * object, + gint arg1, + GtkObject *arg2, + gpointer user_data); + +static void +e_marshal_NONE__INT_OBJECT (GtkObject * object, + GtkSignalFunc func, + gpointer func_data, GtkArg * args) +{ + GtkSignal_NONE__INT_OBJECT rfunc; + rfunc = (GtkSignal_NONE__INT_OBJECT) func; + (*rfunc) (object, + GTK_VALUE_INT (args[0]), + GTK_VALUE_OBJECT (args[1]), + func_data); +} + +static void +e_contact_list_editor_class_init (EContactListEditorClass *klass) +{ + GtkObjectClass *object_class; + + object_class = (GtkObjectClass*) klass; + + parent_class = gtk_type_class (GTK_TYPE_OBJECT); + + gtk_object_add_arg_type ("EContactListEditor::book", GTK_TYPE_OBJECT, + GTK_ARG_READWRITE, ARG_BOOK); + gtk_object_add_arg_type ("EContactListEditor::card", GTK_TYPE_OBJECT, + GTK_ARG_READWRITE, ARG_CARD); + gtk_object_add_arg_type ("EContactListEditor::is_new_list", GTK_TYPE_BOOL, + GTK_ARG_READWRITE, ARG_IS_NEW_LIST); + gtk_object_add_arg_type ("EContactListEditor::editable", GTK_TYPE_BOOL, + GTK_ARG_READWRITE, ARG_EDITABLE); + + contact_list_editor_signals[LIST_ADDED] = + gtk_signal_new ("list_added", + GTK_RUN_FIRST, + object_class->type, + GTK_SIGNAL_OFFSET (EContactListEditorClass, list_added), + e_marshal_NONE__INT_OBJECT, + GTK_TYPE_NONE, 2, + GTK_TYPE_INT, GTK_TYPE_OBJECT); + + contact_list_editor_signals[LIST_MODIFIED] = + gtk_signal_new ("list_modified", + GTK_RUN_FIRST, + object_class->type, + GTK_SIGNAL_OFFSET (EContactListEditorClass, list_modified), + e_marshal_NONE__INT_OBJECT, + GTK_TYPE_NONE, 2, + GTK_TYPE_INT, GTK_TYPE_OBJECT); + + contact_list_editor_signals[LIST_DELETED] = + gtk_signal_new ("list_deleted", + GTK_RUN_FIRST, + object_class->type, + GTK_SIGNAL_OFFSET (EContactListEditorClass, list_deleted), + e_marshal_NONE__INT_OBJECT, + GTK_TYPE_NONE, 2, + GTK_TYPE_INT, GTK_TYPE_OBJECT); + + contact_list_editor_signals[EDITOR_CLOSED] = + gtk_signal_new ("editor_closed", + GTK_RUN_FIRST, + object_class->type, + GTK_SIGNAL_OFFSET (EContactListEditorClass, editor_closed), + gtk_marshal_NONE__NONE, + GTK_TYPE_NONE, 0); + + gtk_object_class_add_signals (object_class, contact_list_editor_signals, LAST_SIGNAL); + + object_class->set_arg = e_contact_list_editor_set_arg; + object_class->get_arg = e_contact_list_editor_get_arg; + object_class->destroy = e_contact_list_editor_destroy; +} + +static void +e_contact_list_editor_init (EContactListEditor *editor) +{ + GladeXML *gui; + GtkWidget *bonobo_win; + BonoboUIContainer *container; + + editor->card = NULL; + editor->changed = FALSE; + editor->editable = TRUE; + editor->is_new_list = FALSE; + + gui = glade_xml_new (EVOLUTION_GLADEDIR "/contact-list-editor.glade", NULL); + editor->gui = gui; + + editor->app = glade_xml_get_widget (gui, "contact list editor"); + editor->table = glade_xml_get_widget (gui, "contact-list-table"); + editor->add_button = glade_xml_get_widget (editor->gui, "add-email-button"); + editor->remove_button = glade_xml_get_widget (editor->gui, "remove-button"); + editor->email_entry =glade_xml_get_widget (gui, "email-entry"); + editor->list_name_entry =glade_xml_get_widget (gui, "list-name-entry"); + editor->model = gtk_object_get_data (GTK_OBJECT(editor->table), "model"); + + /* Construct the app */ + bonobo_win = bonobo_window_new ("contact-list-editor", "Contact List Editor"); + + /* FIXME: The sucking bit */ + { + GtkWidget *contents; + + contents = gnome_dock_get_client_area ( + GNOME_DOCK (GNOME_APP (editor->app)->dock)); + if (!contents) { + g_message ("contact_list_editor_construct(): Could not get contents"); + return; + } + gtk_widget_ref (contents); + gtk_container_remove (GTK_CONTAINER (contents->parent), contents); + bonobo_window_set_contents (BONOBO_WINDOW (bonobo_win), contents); + gtk_widget_destroy (editor->app); + editor->app = bonobo_win; + } + + /* Build the menu and toolbar */ + + container = bonobo_ui_container_new (); + bonobo_ui_container_set_win (container, BONOBO_WINDOW (editor->app)); + + editor->uic = bonobo_ui_component_new_default (); + if (!editor->uic) { + g_message ("e_contact_list_editor_init(): eeeeek, could not create the UI handler!"); + return; + } + bonobo_ui_component_set_container (editor->uic, + bonobo_object_corba_objref ( + BONOBO_OBJECT (container))); + + create_ui (editor); + + /* connect signals */ + gtk_signal_connect (GTK_OBJECT(editor->add_button), + "clicked", GTK_SIGNAL_FUNC(add_email_cb), editor); + gtk_signal_connect (GTK_OBJECT(editor->email_entry), + "activate", GTK_SIGNAL_FUNC(add_email_cb), editor); + gtk_signal_connect (GTK_OBJECT(editor->remove_button), + "clicked", GTK_SIGNAL_FUNC(remove_entry_cb), editor); + gtk_signal_connect (GTK_OBJECT(editor->list_name_entry), + "changed", GTK_SIGNAL_FUNC(list_name_changed_cb), editor); + + command_state_changed (editor); + + /* Connect to the deletion of the dialog */ + +#if 0 + gtk_signal_connect (GTK_OBJECT (editor->app), "delete_event", + GTK_SIGNAL_FUNC (app_delete_event_cb), editor); +#endif +} + +static void +e_contact_list_editor_destroy (GtkObject *object) +{ +} + +static +BonoboUIVerb verbs [] = { +#if 0 + BONOBO_UI_UNSAFE_VERB ("ContactEditorSave", file_save_cb), + BONOBO_UI_UNSAFE_VERB ("ContactEditorSaveAs", file_save_as_cb), + BONOBO_UI_UNSAFE_VERB ("ContactEditorSaveClose", tb_save_and_close_cb), + BONOBO_UI_UNSAFE_VERB ("ContactEditorSendAs", file_send_as_cb), + BONOBO_UI_UNSAFE_VERB ("ContactEditorSendTo", file_send_to_cb), + BONOBO_UI_UNSAFE_VERB ("ContactEditorDelete", delete_cb), + BONOBO_UI_UNSAFE_VERB ("ContactEditorPrint", print_cb), + BONOBO_UI_UNSAFE_VERB ("ContactEditorPrintEnvelope", print_envelope_cb), + /* BONOBO_UI_UNSAFE_VERB ("ContactEditorPageSetup", file_page_setup_menu), */ + BONOBO_UI_UNSAFE_VERB ("ContactEditorClose", file_close_cb), +#endif + BONOBO_UI_VERB_END +}; + +static void +create_ui (EContactListEditor *ce) +{ + bonobo_ui_component_add_verb_list_with_data ( + ce->uic, verbs, ce); + + bonobo_ui_util_set_ui (ce->uic, EVOLUTION_DATADIR, + "evolution-contact-list-editor.xml", + "evolution-contact-list-editor"); +} + +EContactListEditor * +e_contact_list_editor_new (EBook *book, + ECard *list_card, + gboolean is_new_list, + gboolean editable) +{ + EContactListEditor *ce; + + ce = E_CONTACT_LIST_EDITOR (gtk_type_new (E_CONTACT_LIST_EDITOR_TYPE)); + + gtk_object_set (GTK_OBJECT (ce), + "book", book, + "card", list_card, + "is_new_list", is_new_list, + "editable", editable, + NULL); + + return ce; +} + +static void +e_contact_list_editor_set_arg (GtkObject *o, GtkArg *arg, guint arg_id) +{ + EContactListEditor *editor; + + editor = E_CONTACT_LIST_EDITOR (o); + + switch (arg_id){ + case ARG_BOOK: + if (editor->book) + gtk_object_unref(GTK_OBJECT(editor->book)); + editor->book = E_BOOK(GTK_VALUE_OBJECT (*arg)); + gtk_object_ref (GTK_OBJECT (editor->book)); + /* XXX more here about editable/etc. */ + break; + case ARG_CARD: + if (editor->card) + gtk_object_unref(GTK_OBJECT(editor->card)); + editor->card = e_card_duplicate(E_CARD(GTK_VALUE_OBJECT (*arg))); +#if 0 + fill_in_info(editor); +#endif + editor->changed = FALSE; + break; + + case ARG_IS_NEW_LIST: { + gboolean new_value = GTK_VALUE_BOOL (*arg) ? TRUE : FALSE; + gboolean changed = (editor->is_new_list != new_value); + + editor->is_new_list = new_value; + + if (changed) + command_state_changed (editor); + break; + } + + case ARG_EDITABLE: { + gboolean new_value = GTK_VALUE_BOOL (*arg) ? TRUE : FALSE; + gboolean changed = (editor->editable != new_value); + + editor->editable = new_value; + + if (changed) { + set_editable (editor); + command_state_changed (editor); + } + break; + } + + } +} + +static void +e_contact_list_editor_get_arg (GtkObject *object, GtkArg *arg, guint arg_id) +{ + EContactListEditor *editor; + + editor = E_CONTACT_LIST_EDITOR (object); + + switch (arg_id) { + case ARG_BOOK: + GTK_VALUE_OBJECT (*arg) = GTK_OBJECT(editor->book); + break; + + case ARG_CARD: +#if 0 + e_card_simple_sync_card(editor->simple); + extract_info(editor); +#endif + GTK_VALUE_OBJECT (*arg) = GTK_OBJECT(editor->card); + break; + + case ARG_IS_NEW_LIST: + GTK_VALUE_BOOL (*arg) = editor->is_new_list ? TRUE : FALSE; + break; + + case ARG_EDITABLE: + GTK_VALUE_BOOL (*arg) = editor->editable ? TRUE : FALSE; + break; + default: + arg->type = GTK_TYPE_INVALID; + break; + } +} + +void +e_contact_list_editor_show (EContactListEditor *editor) +{ + gtk_widget_show (editor->app); +} + +void +e_contact_list_editor_close (EContactListEditor *editor) +{ +} + +void +e_contact_list_editor_raise (EContactListEditor *editor) +{ +} + +#define SPEC " \ + \ + \ + \ + \ + \ +" + +GtkWidget * +e_contact_list_editor_create_table(gchar *name, + gchar *string1, gchar *string2, + gint int1, gint int2); + +GtkWidget * +e_contact_list_editor_create_table(gchar *name, + gchar *string1, gchar *string2, + gint int1, gint int2) +{ + + ETableModel *model; + GtkWidget *table; + + model = e_contact_list_model_new (); + + table = e_table_scrolled_new (model, NULL, SPEC, NULL); + + gtk_object_set_data(GTK_OBJECT(table), "model", model); + + return table; +} + +static void +add_email_cb (GtkWidget *w, EContactListEditor *editor) +{ + char *text = gtk_entry_get_text (GTK_ENTRY(editor->email_entry)); + + if (text && *text) + e_contact_list_model_add_email (E_CONTACT_LIST_MODEL(editor->model), text); + + gtk_entry_set_text (GTK_ENTRY(editor->email_entry), ""); + + if (!editor->changed) { + editor->changed = TRUE; + command_state_changed (editor); + } +} + +static void +remove_row (int model_row, EContactListEditor *editor) +{ + e_contact_list_model_remove_row (E_CONTACT_LIST_MODEL (editor->model), model_row); +} + +static void +remove_entry_cb (GtkWidget *w, EContactListEditor *editor) +{ + e_table_selected_row_foreach (e_table_scrolled_get_table(E_TABLE_SCROLLED(editor->table)), + (EForeachFunc)remove_row, editor); +} + +static void +list_name_changed_cb (GtkWidget *w, EContactListEditor *editor) +{ + if (!editor->changed) { + editor->changed = TRUE; + command_state_changed (editor); + } +} + +static void +set_editable (EContactListEditor *editor) +{ + gtk_widget_set_sensitive (editor->email_entry, editor->editable); + gtk_widget_set_sensitive (editor->list_name_entry, editor->editable); + gtk_widget_set_sensitive (editor->add_button, editor->editable); + gtk_widget_set_sensitive (editor->remove_button, editor->editable); + gtk_widget_set_sensitive (editor->table, editor->editable); +} + +static void +command_state_changed (EContactListEditor *editor) +{ + bonobo_ui_component_set_prop (editor->uic, + "/commands/ContactListEditorSaveClose", + "sensitive", + editor->changed && editor->editable ? "1" : "0", NULL); + + bonobo_ui_component_set_prop (editor->uic, + "/commands/ContactListEditorSave", + "sensitive", + editor->changed && editor->editable ? "1" : "0", NULL); + + bonobo_ui_component_set_prop (editor->uic, + "/commands/ContactListEditorDelete", + "sensitive", + editor->editable && !editor->is_new_list ? "1" : "0", NULL); +} diff --git a/addressbook/gui/contact-list-editor/e-contact-list-editor.h b/addressbook/gui/contact-list-editor/e-contact-list-editor.h new file mode 100644 index 0000000000..55badc3016 --- /dev/null +++ b/addressbook/gui/contact-list-editor/e-contact-list-editor.h @@ -0,0 +1,108 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* e-contact-list-editor.h + * 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. + */ +#ifndef __E_CONTACT_LIST_EDITOR_H__ +#define __E_CONTACT_LIST_EDITOR_H__ + +#include +#include +#include +#include +#include + +#include "addressbook/backend/ebook/e-book.h" +#include "addressbook/backend/ebook/e-card.h" +#include "addressbook/backend/ebook/e-card-simple.h" + +#ifdef __cplusplus +extern "C" { +#pragma } +#endif /* __cplusplus */ + +#define E_CONTACT_LIST_EDITOR_TYPE (e_contact_list_editor_get_type ()) +#define E_CONTACT_LIST_EDITOR(obj) (GTK_CHECK_CAST ((obj), E_CONTACT_LIST_EDITOR_TYPE, EContactListEditor)) +#define E_CONTACT_LIST_EDITOR_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_CONTACT_LIST_EDITOR_TYPE, EContactListEditorClass)) +#define E_IS_CONTACT_LIST_EDITOR(obj) (GTK_CHECK_TYPE ((obj), E_CONTACT_LIST_EDITOR_TYPE)) +#define E_IS_CONTACT_LIST_EDITOR_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), E_CONTACT_LIST_EDITOR_TYPE)) + + +typedef struct _EContactListEditor EContactListEditor; +typedef struct _EContactListEditorClass EContactListEditorClass; + +struct _EContactListEditor +{ + GtkObject object; + + /* item specific fields */ + EBook *book; + ECard *card; + + /* UI handler */ + BonoboUIComponent *uic; + + GladeXML *gui; + GtkWidget *app; + + GtkWidget *table; + ETableModel *model; + GtkWidget *email_entry; + GtkWidget *list_name_entry; + GtkWidget *add_button; + GtkWidget *remove_button; + + /* Whether we are editing a new card or an existing one */ + guint is_new_list : 1; + + /* Whether the card has been changed since bringing up the contact editor */ + guint changed : 1; + + /* Whether the contact editor will accept modifications */ + guint editable : 1; +}; + +struct _EContactListEditorClass +{ + GtkObjectClass parent_class; + + /* Notification signals */ + + void (* list_added) (EContactListEditor *cle, EBookStatus status, ECard *card); + void (* list_modified) (EContactListEditor *cle, EBookStatus status, ECard *card); + void (* list_deleted) (EContactListEditor *cle, EBookStatus status, ECard *card); + void (* editor_closed) (EContactListEditor *cle); +}; + +EContactListEditor *e_contact_list_editor_new (EBook *book, + ECard *list_card, + gboolean is_new_list, + gboolean editable); +GtkType e_contact_list_editor_get_type (void); +void e_contact_list_editor_show (EContactListEditor *editor); +void e_contact_list_editor_close (EContactListEditor *editor); +void e_contact_list_editor_raise (EContactListEditor *editor); + +gboolean e_contact_list_editor_confirm_delete (GtkWindow *parent); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +#endif /* __E_CONTACT_LIST_EDITOR_H__ */ diff --git a/addressbook/gui/contact-list-editor/e-contact-list-model.c b/addressbook/gui/contact-list-editor/e-contact-list-model.c new file mode 100644 index 0000000000..8d8831a6ab --- /dev/null +++ b/addressbook/gui/contact-list-editor/e-contact-list-model.c @@ -0,0 +1,190 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ + +#include +#include "e-contact-list-model.h" + +#define PARENT_TYPE e_table_model_get_type() +ETableModelClass *parent_class; + +#define COLS 1 + +/* This function returns the number of columns in our ETableModel. */ +static int +contact_list_col_count (ETableModel *etc) +{ + return COLS; +} + +/* This function returns the number of rows in our ETableModel. */ +static int +contact_list_row_count (ETableModel *etc) +{ + EContactListModel *model = E_CONTACT_LIST_MODEL (etc); + return model->simple_count + model->email_count; +} + +/* This function returns the value at a particular point in our ETableModel. */ +static void * +contact_list_value_at (ETableModel *etc, int col, int row) +{ + EContactListModel *model = E_CONTACT_LIST_MODEL (etc); + + if (row < model->simple_count) + return (char*)e_card_simple_get_const (model->simples[row], E_CARD_SIMPLE_FIELD_EMAIL); + else + return model->emails [row - model->simple_count]; +} + +/* This function sets the value at a particular point in our ETableModel. */ +static void +contact_list_set_value_at (ETableModel *etc, int col, int row, const void *val) +{ + /* nothing */ +} + +/* This function returns whether a particular cell is editable. */ +static gboolean +contact_list_is_cell_editable (ETableModel *etc, int col, int row) +{ + return FALSE; +} + +/* This function duplicates the value passed to it. */ +static void * +contact_list_duplicate_value (ETableModel *etc, int col, const void *value) +{ + return g_strdup(value); +} + +/* This function frees the value passed to it. */ +static void +contact_list_free_value (ETableModel *etc, int col, void *value) +{ + g_free(value); +} + +static void * +contact_list_initialize_value (ETableModel *etc, int col) +{ + return g_strdup(""); +} + +static gboolean +contact_list_value_is_empty (ETableModel *etc, int col, const void *value) +{ + return !(value && *(char *)value); +} + +static char * +contact_list_value_to_string (ETableModel *etc, int col, const void *value) +{ + return g_strdup(value); +} + +static void +contact_list_model_destroy (GtkObject *o) +{ +} + +static void +e_contact_list_model_class_init (GtkObjectClass *object_class) +{ + ETableModelClass *model_class = (ETableModelClass *) object_class; + + parent_class = gtk_type_class (PARENT_TYPE); + + object_class->destroy = contact_list_model_destroy; + + model_class->column_count = contact_list_col_count; + model_class->row_count = contact_list_row_count; + model_class->value_at = contact_list_value_at; + model_class->set_value_at = contact_list_set_value_at; + model_class->is_cell_editable = contact_list_is_cell_editable; + model_class->duplicate_value = contact_list_duplicate_value; + model_class->free_value = contact_list_free_value; + model_class->initialize_value = contact_list_initialize_value; + model_class->value_is_empty = contact_list_value_is_empty; + model_class->value_to_string = contact_list_value_to_string; +} + +static void +e_contact_list_model_init (GtkObject *object) +{ + EContactListModel *model = E_CONTACT_LIST_MODEL(object); + + model->simples = NULL; + model->simple_count = 0; + model->emails = NULL; + model->email_count = 0; +} + +GtkType +e_contact_list_model_get_type (void) +{ + static GtkType type = 0; + + if (!type){ + GtkTypeInfo info = { + "EContactListModel", + sizeof (EContactListModel), + sizeof (EContactListModelClass), + (GtkClassInitFunc) e_contact_list_model_class_init, + (GtkObjectInitFunc) e_contact_list_model_init, + NULL, /* reserved 1 */ + NULL, /* reserved 2 */ + (GtkClassInitFunc) NULL + }; + + type = gtk_type_unique (PARENT_TYPE, &info); + } + + return type; +} + +void +e_contact_list_model_construct (EContactListModel *model) +{ +} + +ETableModel * +e_contact_list_model_new () +{ + EContactListModel *model; + + model = gtk_type_new (e_contact_list_model_get_type ()); + + e_contact_list_model_construct (model); + + return E_TABLE_MODEL(model); +} + +void +e_contact_list_model_add_email (EContactListModel *model, + const char *email) +{ + model->email_count ++; + model->emails = g_renew (char*, model->emails, model->email_count); + model->emails[model->email_count - 1] = g_strdup (email); + e_table_model_changed (E_TABLE_MODEL (model)); +} + +void +e_contact_list_model_add_card (EContactListModel *model, + ECardSimple *simple) +{ +} + +void +e_contact_list_model_remove_row (EContactListModel *model, int row) +{ + if (row < model->simple_count) { + memcpy (model->simples + row, model->simples + row + 1, model->simple_count - row); + model->simple_count --; + } + else { + int email_row = row - model->simple_count; + memcpy (model->emails + email_row, model->emails + email_row + 1, model->email_count - email_row); + model->email_count --; + } + e_table_model_row_deleted (E_TABLE_MODEL (model), row); +} diff --git a/addressbook/gui/contact-list-editor/e-contact-list-model.h b/addressbook/gui/contact-list-editor/e-contact-list-model.h new file mode 100644 index 0000000000..da9be77b49 --- /dev/null +++ b/addressbook/gui/contact-list-editor/e-contact-list-model.h @@ -0,0 +1,42 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +#ifndef _E_CONTACT_LIST_MODEL_H_ +#define _E_CONTACT_LIST_MODEL_H_ + +#include +#include "addressbook/backend/ebook/e-book.h" +#include "addressbook/backend/ebook/e-book-view.h" +#include "addressbook/backend/ebook/e-card-simple.h" + +#define E_CONTACT_LIST_MODEL_TYPE (e_contact_list_model_get_type ()) +#define E_CONTACT_LIST_MODEL(o) (GTK_CHECK_CAST ((o), E_CONTACT_LIST_MODEL_TYPE, EContactListModel)) +#define E_CONTACT_LIST_MODEL_CLASS(k) (GTK_CHECK_CLASS_CAST((k), E_CONTACT_LIST_MODEL_TYPE, EContactListModelClass)) +#define E_IS_CONTACT_LIST_MODEL(o) (GTK_CHECK_TYPE ((o), E_CONTACT_LIST_MODEL_TYPE)) +#define E_IS_CONTACT_LIST_MODEL_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), E_CONTACT_LIST_MODEL_TYPE)) + +typedef struct _EContactListModel EContactListModel; +typedef struct _EContactListModelClass EContactListModelClass; + +struct _EContactListModel { + ETableModel parent; + + ECardSimple **simples; + int simple_count; + char **emails; + int email_count; +}; + + +struct _EContactListModelClass { + ETableModelClass parent_class; +}; + + +GtkType e_contact_list_model_get_type (void); +void e_contact_list_model_construct (EContactListModel *model); +ETableModel *e_contact_list_model_new (void); + +void e_contact_list_model_add_email (EContactListModel *model, const char *email); +void e_contact_list_model_add_card (EContactListModel *model, ECardSimple *simple); +void e_contact_list_model_remove_row (EContactListModel *model, int row); + +#endif /* _E_CONTACT_LIST_MODEL_H_ */ diff --git a/addressbook/gui/widgets/Makefile.am b/addressbook/gui/widgets/Makefile.am index a375965a66..9619363732 100644 --- a/addressbook/gui/widgets/Makefile.am +++ b/addressbook/gui/widgets/Makefile.am @@ -4,7 +4,7 @@ INCLUDES = \ -DEVOLUTION_DATADIR=\""$(datadir)"\" \ -I$(top_srcdir) \ -I$(top_srcdir)/addressbook/backend/ebook \ - -I$(top_srcdir)/addressbook/contact-editor \ + -I$(top_srcdir)/addressbook/gui/contact-editor \ -I$(top_srcdir)/addressbook/gui/merging \ -I$(top_srcdir)/widgets/misc \ $(BONOBO_GNOME_CFLAGS) \ @@ -66,7 +66,8 @@ minicard_test_LDADD = \ $(top_builddir)/e-util/libeutil.la \ $(top_builddir)/libversit/libversit.la \ $(top_builddir)/e-util/ename/libename.la \ - $(top_builddir)/addressbook/contact-editor/libecontacteditor.a \ + $(top_builddir)/addressbook/gui/contact-editor/libecontacteditor.a \ + $(top_builddir)/addressbook/gui/contact-list-editor/libecontactlisteditor.a \ $(top_builddir)/addressbook/printing/libecontactprint.a \ $(top_builddir)/addressbook/gui/merging/libecardmerging.a \ $(top_builddir)/widgets/misc/libemiscwidgets.a \ @@ -118,7 +119,8 @@ minicard_widget_test_LDADD = \ $(top_builddir)/e-util/libeutil.la \ $(top_builddir)/libversit/libversit.la \ $(top_builddir)/e-util/ename/libename.la \ - $(top_builddir)/addressbook/contact-editor/libecontacteditor.a \ + $(top_builddir)/addressbook/gui/contact-editor/libecontacteditor.a \ + $(top_builddir)/addressbook/gui/contact-list-editor/libecontactlisteditor.a \ $(top_builddir)/addressbook/printing/libecontactprint.a \ $(top_builddir)/widgets/misc/libemiscwidgets.a \ $(top_builddir)/e-util/libeutil.la \ diff --git a/addressbook/gui/widgets/e-addressbook-util.c b/addressbook/gui/widgets/e-addressbook-util.c index 7ec044adf8..9aaa554547 100644 --- a/addressbook/gui/widgets/e-addressbook-util.c +++ b/addressbook/gui/widgets/e-addressbook-util.c @@ -25,7 +25,6 @@ #include #include "e-addressbook-util.h" -#include "e-contact-editor.h" #include "e-card-merging.h" void @@ -53,39 +52,38 @@ e_addressbook_error_dialog (const gchar *msg, EBookStatus status) static void -card_added_cb (EBook* book, EBookStatus status, const char *id, - gpointer user_data) +added_cb (EBook* book, EBookStatus status, const char *id, + gboolean is_list) { - g_print ("%s: %s(): a card was added\n", __FILE__, __FUNCTION__); if (status != E_BOOK_STATUS_SUCCESS) { - e_addressbook_error_dialog (_("Error adding card"), status); + e_addressbook_error_dialog (is_list ? _("Error adding list") : _("Error adding card"), status); } } static void -card_modified_cb (EBook* book, EBookStatus status, - gpointer user_data) +modified_cb (EBook* book, EBookStatus status, + gboolean is_list) { - g_print ("%s: %s(): a card was modified\n", __FILE__, __FUNCTION__); if (status != E_BOOK_STATUS_SUCCESS) { - e_addressbook_error_dialog (_("Error modifying card"), status); + e_addressbook_error_dialog (is_list ? _("Error modifying list") : _("Error modifying card"), + status); } } static void -card_deleted_cb (EBook* book, EBookStatus status, - gpointer user_data) +deleted_cb (EBook* book, EBookStatus status, + gboolean is_list) { - g_print ("%s: %s(): a card was removed\n", __FILE__, __FUNCTION__); if (status != E_BOOK_STATUS_SUCCESS) { - e_addressbook_error_dialog (_("Error removing card"), status); + e_addressbook_error_dialog (is_list ? _("Error removing list") : _("Error removing card"), + status); } } static void -editor_closed_cb (EContactEditor *ce, gpointer data) +editor_closed_cb (GtkObject *editor, gpointer data) { - gtk_object_unref (GTK_OBJECT (ce)); + gtk_object_unref (editor); } EContactEditor * @@ -98,13 +96,36 @@ e_addressbook_show_contact_editor (EBook *book, ECard *card, ce = e_contact_editor_new (book, card, is_new_card, editable); gtk_signal_connect (GTK_OBJECT (ce), "card_added", - GTK_SIGNAL_FUNC (card_added_cb), NULL); + GTK_SIGNAL_FUNC (added_cb), GINT_TO_POINTER (FALSE)); gtk_signal_connect (GTK_OBJECT (ce), "card_modified", - GTK_SIGNAL_FUNC (card_modified_cb), NULL); + GTK_SIGNAL_FUNC (modified_cb), GINT_TO_POINTER (FALSE)); gtk_signal_connect (GTK_OBJECT (ce), "card_deleted", - GTK_SIGNAL_FUNC (card_deleted_cb), NULL); + GTK_SIGNAL_FUNC (deleted_cb), GINT_TO_POINTER (FALSE)); gtk_signal_connect (GTK_OBJECT (ce), "editor_closed", GTK_SIGNAL_FUNC (editor_closed_cb), NULL); return ce; } + +EContactListEditor * +e_addressbook_show_contact_list_editor (EBook *book, ECard *card, + gboolean is_new_card, + gboolean editable) +{ + EContactListEditor *ce; + + ce = e_contact_list_editor_new (book, card, is_new_card, editable); + + gtk_signal_connect (GTK_OBJECT (ce), "list_added", + GTK_SIGNAL_FUNC (added_cb), GINT_TO_POINTER (TRUE)); + gtk_signal_connect (GTK_OBJECT (ce), "list_modified", + GTK_SIGNAL_FUNC (modified_cb), GINT_TO_POINTER (TRUE)); + gtk_signal_connect (GTK_OBJECT (ce), "list_deleted", + GTK_SIGNAL_FUNC (deleted_cb), GINT_TO_POINTER (TRUE)); + gtk_signal_connect (GTK_OBJECT (ce), "editor_closed", + GTK_SIGNAL_FUNC (editor_closed_cb), GINT_TO_POINTER (TRUE)); + + e_contact_list_editor_show (ce); + + return ce; +} diff --git a/addressbook/gui/widgets/e-addressbook-util.h b/addressbook/gui/widgets/e-addressbook-util.h index 3e222f7154..1f3ffe074d 100644 --- a/addressbook/gui/widgets/e-addressbook-util.h +++ b/addressbook/gui/widgets/e-addressbook-util.h @@ -22,7 +22,8 @@ #define __E_ADDRESSBOOK_UTIL_H__ #include "addressbook/backend/ebook/e-book.h" -#include "addressbook/contact-editor/e-contact-editor.h" +#include "addressbook/gui/contact-editor/e-contact-editor.h" +#include "addressbook/gui/contact-list-editor/e-contact-list-editor.h" #ifdef __cplusplus extern "C" { @@ -34,6 +35,9 @@ void e_addressbook_error_dialog (const gchar *msg, EContactEditor* e_addressbook_show_contact_editor (EBook *book, ECard *card, gboolean is_new_card, gboolean editable); +EContactListEditor * e_addressbook_show_contact_list_editor (EBook *book, ECard *card, + gboolean is_new_card, + gboolean editable); #ifdef __cplusplus } diff --git a/addressbook/gui/widgets/e-minicard.h b/addressbook/gui/widgets/e-minicard.h index 88c34b97d3..ae54ad63ec 100644 --- a/addressbook/gui/widgets/e-minicard.h +++ b/addressbook/gui/widgets/e-minicard.h @@ -22,7 +22,7 @@ #define __E_MINICARD_H__ #include -#include "addressbook/contact-editor/e-contact-editor.h" +#include "addressbook/gui/contact-editor/e-contact-editor.h" #include "addressbook/backend/ebook/e-card.h" #include "addressbook/backend/ebook/e-card-simple.h" -- cgit v1.2.3