diff options
Diffstat (limited to 'addressbook/gui')
-rw-r--r-- | addressbook/gui/component/GNOME_Evolution_Addressbook.oaf.in | 19 | ||||
-rw-r--r-- | addressbook/gui/component/GNOME_Evolution_Addressbook.oafinfo | 19 | ||||
-rw-r--r-- | addressbook/gui/component/addressbook.oafinfo | 19 | ||||
-rw-r--r-- | addressbook/gui/minicard/.cvsignore | 1 | ||||
-rw-r--r-- | addressbook/gui/minicard/Makefile.am | 20 | ||||
-rw-r--r-- | addressbook/gui/minicard/e-minicard-control.c | 8 | ||||
-rw-r--r-- | addressbook/gui/minicard/e-minicard-control.oafinfo | 38 | ||||
-rw-r--r-- | addressbook/gui/minicard/e-minicard-widget-test.c | 115 | ||||
-rw-r--r-- | addressbook/gui/minicard/e-minicard.c | 93 | ||||
-rw-r--r-- | addressbook/gui/widgets/Makefile.am | 20 | ||||
-rw-r--r-- | addressbook/gui/widgets/e-minicard-control.c | 8 | ||||
-rw-r--r-- | addressbook/gui/widgets/e-minicard-widget-test.c | 115 | ||||
-rw-r--r-- | addressbook/gui/widgets/e-minicard.c | 93 |
13 files changed, 446 insertions, 122 deletions
diff --git a/addressbook/gui/component/GNOME_Evolution_Addressbook.oaf.in b/addressbook/gui/component/GNOME_Evolution_Addressbook.oaf.in index 15820b2e03..08e01f3b22 100644 --- a/addressbook/gui/component/GNOME_Evolution_Addressbook.oaf.in +++ b/addressbook/gui/component/GNOME_Evolution_Addressbook.oaf.in @@ -13,6 +13,25 @@ </oaf_server> +<oaf_server iid="OAFIID:e_minicard_factory:f9542709-fb31-4c6a-bc00-d462ba41e4b9" + type="factory" + location="OAFIID:control-factory:addressbook:3e10597b-0591-4d45-b082-d781b7aa6e17"> + + <oaf_attribute name="repo_ids" type="stringv"> + <item value="IDL:Bonobo/Control:1.0"/> + <item value="IDL:Bonobo/PersistStream:1.0"/> + </oaf_attribute> + + <oaf_attribute name="bonobo:supported_mime_types" type="stringv"> + <item value="text/vCard"/> + <item value="text/x-vCard"/> + </oaf_attribute> + + <oaf_attribute name="description" type="string" + value="Factory for the Evolution addressbook minicard control."/> + +</oaf_server> + <oaf_server iid="OAFIID:control:addressbook:851f883b-2fe7-4c94-a1e3-a1f2a7a03c49" type="factory" location="OAFIID:control-factory:addressbook:3e10597b-0591-4d45-b082-d781b7aa6e17"> diff --git a/addressbook/gui/component/GNOME_Evolution_Addressbook.oafinfo b/addressbook/gui/component/GNOME_Evolution_Addressbook.oafinfo index 15820b2e03..08e01f3b22 100644 --- a/addressbook/gui/component/GNOME_Evolution_Addressbook.oafinfo +++ b/addressbook/gui/component/GNOME_Evolution_Addressbook.oafinfo @@ -13,6 +13,25 @@ </oaf_server> +<oaf_server iid="OAFIID:e_minicard_factory:f9542709-fb31-4c6a-bc00-d462ba41e4b9" + type="factory" + location="OAFIID:control-factory:addressbook:3e10597b-0591-4d45-b082-d781b7aa6e17"> + + <oaf_attribute name="repo_ids" type="stringv"> + <item value="IDL:Bonobo/Control:1.0"/> + <item value="IDL:Bonobo/PersistStream:1.0"/> + </oaf_attribute> + + <oaf_attribute name="bonobo:supported_mime_types" type="stringv"> + <item value="text/vCard"/> + <item value="text/x-vCard"/> + </oaf_attribute> + + <oaf_attribute name="description" type="string" + value="Factory for the Evolution addressbook minicard control."/> + +</oaf_server> + <oaf_server iid="OAFIID:control:addressbook:851f883b-2fe7-4c94-a1e3-a1f2a7a03c49" type="factory" location="OAFIID:control-factory:addressbook:3e10597b-0591-4d45-b082-d781b7aa6e17"> diff --git a/addressbook/gui/component/addressbook.oafinfo b/addressbook/gui/component/addressbook.oafinfo index 15820b2e03..08e01f3b22 100644 --- a/addressbook/gui/component/addressbook.oafinfo +++ b/addressbook/gui/component/addressbook.oafinfo @@ -13,6 +13,25 @@ </oaf_server> +<oaf_server iid="OAFIID:e_minicard_factory:f9542709-fb31-4c6a-bc00-d462ba41e4b9" + type="factory" + location="OAFIID:control-factory:addressbook:3e10597b-0591-4d45-b082-d781b7aa6e17"> + + <oaf_attribute name="repo_ids" type="stringv"> + <item value="IDL:Bonobo/Control:1.0"/> + <item value="IDL:Bonobo/PersistStream:1.0"/> + </oaf_attribute> + + <oaf_attribute name="bonobo:supported_mime_types" type="stringv"> + <item value="text/vCard"/> + <item value="text/x-vCard"/> + </oaf_attribute> + + <oaf_attribute name="description" type="string" + value="Factory for the Evolution addressbook minicard control."/> + +</oaf_server> + <oaf_server iid="OAFIID:control:addressbook:851f883b-2fe7-4c94-a1e3-a1f2a7a03c49" type="factory" location="OAFIID:control-factory:addressbook:3e10597b-0591-4d45-b082-d781b7aa6e17"> diff --git a/addressbook/gui/minicard/.cvsignore b/addressbook/gui/minicard/.cvsignore index 800a11cc3e..472fd2593f 100644 --- a/addressbook/gui/minicard/.cvsignore +++ b/addressbook/gui/minicard/.cvsignore @@ -8,4 +8,5 @@ Makefile.in minicard-label-test minicard-test minicard-view-test +minicard-widget-test reflow-test diff --git a/addressbook/gui/minicard/Makefile.am b/addressbook/gui/minicard/Makefile.am index 1a288fa088..b337754531 100644 --- a/addressbook/gui/minicard/Makefile.am +++ b/addressbook/gui/minicard/Makefile.am @@ -28,6 +28,7 @@ libeminicard_a_SOURCES = \ e-reflow.h noinst_PROGRAMS = \ + minicard-widget-test \ minicard-label-test \ minicard-test \ reflow-test \ @@ -100,3 +101,22 @@ minicard_view_test_LDADD = \ $(top_builddir)/widgets/misc/libemiscwidgets.a \ $(top_builddir)/e-util/libeutil.la \ $(top_builddir)/widgets/e-text/libetext.a + +minicard_widget_test_SOURCES = \ + e-minicard-widget-test.c + +minicard_widget_test_LDADD = \ + $(EXTRA_GNOME_LIBS) \ + $(GNOMEGNORBA_LIBS) \ + $(BONOBO_GNOME_LIBS) \ + libeminicard.a \ + $(top_builddir)/addressbook/backend/ebook/libebook.la \ + $(top_builddir)/e-util/libeutil.la \ + $(top_builddir)/libversit/libversit.la \ + $(top_builddir)/addressbook/ename/libename.la \ + $(top_builddir)/addressbook/contact-editor/libecontacteditor.a \ + $(top_builddir)/addressbook/printing/libecontactprint.a \ + $(top_builddir)/widgets/e-table/libetable.a \ + $(top_builddir)/widgets/misc/libemiscwidgets.a \ + $(top_builddir)/e-util/libeutil.la \ + $(top_builddir)/widgets/e-text/libetext.a diff --git a/addressbook/gui/minicard/e-minicard-control.c b/addressbook/gui/minicard/e-minicard-control.c index 3cda9b4ead..ab8aedff96 100644 --- a/addressbook/gui/minicard/e-minicard-control.c +++ b/addressbook/gui/minicard/e-minicard-control.c @@ -139,8 +139,7 @@ pstream_load (BonoboPersistStream *ps, const Bonobo_Stream stream, char *vcard; GtkWidget *minicard = data; - if (*type && g_strcasecmp (type, "text/plain") != 0 && - g_strcasecmp (type, "text/vCard") != 0 && + if (*type && g_strcasecmp (type, "text/vCard") != 0 && g_strcasecmp (type, "text/x-vCard") != 0) { CORBA_exception_set (ev, CORBA_USER_EXCEPTION, ex_Bonobo_Persist_WrongDataType, NULL); @@ -176,8 +175,7 @@ pstream_save (BonoboPersistStream *ps, const Bonobo_Stream stream, EMinicardWidget *minicard = data; int length; - if (*type && g_strcasecmp (type, "text/plain") != 0 && - g_strcasecmp (type, "text/vCard") != 0 && + if (*type && g_strcasecmp (type, "text/vCard") != 0 && g_strcasecmp (type, "text/x-vCard") != 0) { CORBA_exception_set (ev, CORBA_USER_EXCEPTION, ex_Bonobo_Persist_WrongDataType, NULL); @@ -242,7 +240,7 @@ static Bonobo_Persist_ContentTypeList * pstream_get_content_types (BonoboPersistStream *ps, void *closure, CORBA_Environment *ev) { - return bonobo_persist_generate_content_types (3, "text/plain", "text/vCard", "text/x-vCard"); + return bonobo_persist_generate_content_types (2, "text/vCard", "text/x-vCard"); } static BonoboObject * diff --git a/addressbook/gui/minicard/e-minicard-control.oafinfo b/addressbook/gui/minicard/e-minicard-control.oafinfo deleted file mode 100644 index 9e74cf1344..0000000000 --- a/addressbook/gui/minicard/e-minicard-control.oafinfo +++ /dev/null @@ -1,38 +0,0 @@ -<oaf_info> - -<oaf_server iid="OAFIID:bonobo_clock_factory:ec4961f3-7a16-4ace-9463-b112e4bc4186" type="exe" location="sample-control-factory"> -<oaf_attribute name="repo_ids" type="stringv"> -<item value="IDL:GNOME/GenericFactory:1.0"/> -</oaf_attribute> -<oaf_attribute name="name" type="string" value="Clock control factory"/> -<oaf_attribute name="description" type="string" value="Factory for the sample BonoboClock control"/> -</oaf_server> - -<oaf_server iid="OAFIID:bonobo_clock:d42cc651-44ae-4f69-a10d-a0b6b2cc6ecc" type="factory" location="OAFIID:bonobo_clock_factory:ec4961f3-7a16-4ace-9463-b112e4bc4186"> -<oaf_attribute name="repo_ids" type="stringv"> -<item value="IDL:Bonobo/Unknown:1.0"/> -<item value="IDL:Bonobo/Control:1.0"/> -</oaf_attribute> -<oaf_attribute name="name" type="string" value="Clock control"/> -<oaf_attribute name="description" type="string" value="A sample Bonobo control which displays a clock."/> -</oaf_server> - -<oaf_server iid="OAFIID:bonobo_entry_factory:ef3e3c33-43e2-4f7c-9ca9-9479104608d6" type="exe" location="sample-control-factory"> -<oaf_attribute name="repo_ids" type="stringv"> -<item value="IDL:GNOME/GenericFactory:1.0"/> -</oaf_attribute> -<oaf_attribute name="name" type="string" value="Entry control factory"/> -<oaf_attribute name="description" type="string" value="Factory for the sample GtkEntry control"/> -</oaf_server> - -<oaf_server iid="OAFIID:bonobo_entry:04e49c0b-95e2-4305-88a7-9f6721ddfa51" type="factory" location="OAFIID:bonobo_entry_factory:ef3e3c33-43e2-4f7c-9ca9-9479104608d6"> -<oaf_attribute name="repo_ids" type="stringv"> -<item value="IDL:Bonobo/Unknown:1.0"/> -<item value="IDL:Bonobo/Control:1.0"/> -</oaf_attribute> -<oaf_attribute name="name" type="string" value="Entry control"/> -<oaf_attribute name="description" type="string" value="A sample Bonbobo control wrapping a Gtk Entry widget."/> -</oaf_server> - -</oaf_info> - diff --git a/addressbook/gui/minicard/e-minicard-widget-test.c b/addressbook/gui/minicard/e-minicard-widget-test.c new file mode 100644 index 0000000000..cbdd2f69b6 --- /dev/null +++ b/addressbook/gui/minicard/e-minicard-widget-test.c @@ -0,0 +1,115 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* test-minicard.c + * + * Copyright (C) 2000 Helix Code, Inc. + * Author: Chris Lahey <clahey@helixcode.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#define TEST_VCARD \ +"BEGIN:VCARD +" \ +"FN:Nat +" \ +"N:Friedman;Nat;D;Mr. +" \ +"ORG:Helix Code, Inc. +" \ +"TITLE:Head Geek +" \ +"ROLE:Programmer/Executive +" \ +"BDAY:1977-08-06 +" \ +"TEL;WORK:617 679 1984 +" \ +"TEL;CELL:123 456 7890 +" \ +"EMAIL;INTERNET:nat@nat.org +" \ +"EMAIL;INTERNET:nat@helixcode.com +" \ +"ADR;WORK;POSTAL:P.O. Box 101;;;Any Town;CA;91921-1234; +" \ +"ADR;HOME;POSTAL;INTL:P.O. Box 202;;;Any Town 2;MI;12344-4321;USA +" \ +"END:VCARD +" \ +" +" + +#include "config.h" + +#include <gnome.h> +#include "e-minicard-widget.h" + +/* This is a horrible thing to do, but it is just a test. */ + +static void destroy_callback(GtkWidget *app, gpointer data) +{ + exit(0); +} + +#if 0 +static void about_callback( GtkWidget *widget, gpointer data ) +{ + + const gchar *authors[] = + { + "Christopher James Lahey <clahey@umich.edu>", + NULL + }; + + GtkWidget *about = + gnome_about_new ( _( "Minicard Widget Test" ), VERSION, + _( "Copyright (C) 2000, Helix Code, Inc." ), + authors, + _( "This should test the minicard widget" ), + NULL); + gtk_widget_show (about); +} +#endif + +int main( int argc, char *argv[] ) +{ + GtkWidget *app; + GtkWidget *minicard; + int i; + ECard *card; + char *vcard; + + /* bindtextdomain (PACKAGE, GNOMELOCALEDIR); + textdomain (PACKAGE);*/ + + gnome_init( "Minicard Widget Test", VERSION, argc, argv); + app = gnome_app_new("Minicard Widget Test", NULL); + + minicard = e_minicard_widget_new(); + card = e_card_new(TEST_VCARD); + gtk_object_set(GTK_OBJECT(minicard), + "card", card, + NULL); + + gnome_app_set_contents( GNOME_APP( app ), minicard ); + + /* Connect the signals */ + gtk_signal_connect( GTK_OBJECT( app ), "destroy", + GTK_SIGNAL_FUNC( destroy_callback ), + ( gpointer ) app ); + + gtk_widget_show_all( app ); + + gtk_main(); + + /* Not reached. */ + return 0; +} diff --git a/addressbook/gui/minicard/e-minicard.c b/addressbook/gui/minicard/e-minicard.c index 68f6ccfc05..2fa1d3c080 100644 --- a/addressbook/gui/minicard/e-minicard.c +++ b/addressbook/gui/minicard/e-minicard.c @@ -418,20 +418,30 @@ e_minicard_event (GnomeCanvasItem *item, GdkEvent *event) NULL ); e_minicard->has_focus = TRUE; } else { - EBook *book; + EBook *book = NULL; e_card_simple_sync_card(e_minicard->simple); + + if (E_IS_MINICARD_VIEW(GNOME_CANVAS_ITEM(e_minicard)->parent)) { + + gtk_object_get(GTK_OBJECT(GNOME_CANVAS_ITEM(e_minicard)->parent), + "book", &book, + NULL); + + } - gtk_object_get(GTK_OBJECT(GNOME_CANVAS_ITEM(e_minicard)->parent), - "book", &book, - NULL); - + if (book) { + /* Add the card in the contact editor to our ebook */ - e_book_commit_card (book, - e_minicard->card, - card_changed_cb, - NULL); - + e_book_commit_card (book, + e_minicard->card, + card_changed_cb, + NULL); + } else { + remodel(e_minicard); + e_canvas_item_request_reflow(GNOME_CANVAS_ITEM(e_minicard)); + } + gnome_canvas_item_set( e_minicard->rect, "outline_color", NULL, NULL ); @@ -449,35 +459,44 @@ e_minicard_event (GnomeCanvasItem *item, GdkEvent *event) if (event->button.button == 1) { e_canvas_item_grab_focus(item); } else if (event->button.button == 3) { - EPopupMenu menu[] = { {"Save as VCard", NULL, GTK_SIGNAL_FUNC(save_as), 0}, - {"Print", NULL, GTK_SIGNAL_FUNC(print), 0}, - {"Delete", NULL, GTK_SIGNAL_FUNC(delete), 0}, - {NULL, NULL, NULL, 0}}; - e_popup_menu_run (menu, (GdkEventButton *)event, 0, e_minicard); + if (E_IS_MINICARD_VIEW(item->parent)) { + EPopupMenu menu[] = { {"Save as VCard", NULL, GTK_SIGNAL_FUNC(save_as), 0}, + {"Print", NULL, GTK_SIGNAL_FUNC(print), 0}, + {"Delete", NULL, GTK_SIGNAL_FUNC(delete), 0}, + {NULL, NULL, NULL, 0}}; + e_popup_menu_run (menu, (GdkEventButton *)event, 0, e_minicard); + } else { + EPopupMenu menu[] = { {"Save as VCard", NULL, GTK_SIGNAL_FUNC(save_as), 0}, + {"Print", NULL, GTK_SIGNAL_FUNC(print), 0}, + {NULL, NULL, NULL, 0}}; + e_popup_menu_run (menu, (GdkEventButton *)event, 0, e_minicard); + } } break; case GDK_2BUTTON_PRESS: if (event->button.button == 1 && E_IS_MINICARD_VIEW(item->parent)) { EContactEditor *ce; - EBook *book; - - gtk_object_get(GTK_OBJECT(item->parent), - "book", &book, - NULL); - g_assert (E_IS_BOOK (book)); - + EBook *book = NULL; + if (E_IS_MINICARD_VIEW(item->parent)) { + + gtk_object_get(GTK_OBJECT(item->parent), + "book", &book, + NULL); + } ce = e_contact_editor_new (e_minicard->card, FALSE); - gtk_signal_connect (GTK_OBJECT (ce), "add_card", - GTK_SIGNAL_FUNC (add_card_cb), book); - gtk_signal_connect (GTK_OBJECT (ce), "commit_card", - GTK_SIGNAL_FUNC (commit_card_cb), book); - gtk_signal_connect (GTK_OBJECT (ce), "delete_card", - GTK_SIGNAL_FUNC (delete_card_cb), book); + if (book != NULL) { + gtk_signal_connect (GTK_OBJECT (ce), "add_card", + GTK_SIGNAL_FUNC (add_card_cb), book); + gtk_signal_connect (GTK_OBJECT (ce), "commit_card", + GTK_SIGNAL_FUNC (commit_card_cb), book); + gtk_signal_connect (GTK_OBJECT (ce), "delete_card", + GTK_SIGNAL_FUNC (delete_card_cb), book); + } + gtk_signal_connect (GTK_OBJECT (ce), "editor_closed", GTK_SIGNAL_FUNC (editor_closed_cb), NULL); - return TRUE; } break; @@ -524,17 +543,17 @@ e_minicard_event (GnomeCanvasItem *item, GdkEvent *event) static void e_minicard_resize_children( EMinicard *e_minicard ) { - if ( GTK_OBJECT_FLAGS( e_minicard ) & GNOME_CANVAS_ITEM_REALIZED ) { - GList *list; - + GList *list; + + if (e_minicard->header_text) { gnome_canvas_item_set( e_minicard->header_text, "width", (double) e_minicard->width - 12, NULL ); - for ( list = e_minicard->fields; list; list = g_list_next( list ) ) { - gnome_canvas_item_set( E_MINICARD_FIELD( list->data )->label, - "width", (double) e_minicard->width - 4.0, - NULL ); - } + } + for ( list = e_minicard->fields; list; list = g_list_next( list ) ) { + gnome_canvas_item_set( E_MINICARD_FIELD( list->data )->label, + "width", (double) e_minicard->width - 4.0, + NULL ); } } diff --git a/addressbook/gui/widgets/Makefile.am b/addressbook/gui/widgets/Makefile.am index 1a288fa088..b337754531 100644 --- a/addressbook/gui/widgets/Makefile.am +++ b/addressbook/gui/widgets/Makefile.am @@ -28,6 +28,7 @@ libeminicard_a_SOURCES = \ e-reflow.h noinst_PROGRAMS = \ + minicard-widget-test \ minicard-label-test \ minicard-test \ reflow-test \ @@ -100,3 +101,22 @@ minicard_view_test_LDADD = \ $(top_builddir)/widgets/misc/libemiscwidgets.a \ $(top_builddir)/e-util/libeutil.la \ $(top_builddir)/widgets/e-text/libetext.a + +minicard_widget_test_SOURCES = \ + e-minicard-widget-test.c + +minicard_widget_test_LDADD = \ + $(EXTRA_GNOME_LIBS) \ + $(GNOMEGNORBA_LIBS) \ + $(BONOBO_GNOME_LIBS) \ + libeminicard.a \ + $(top_builddir)/addressbook/backend/ebook/libebook.la \ + $(top_builddir)/e-util/libeutil.la \ + $(top_builddir)/libversit/libversit.la \ + $(top_builddir)/addressbook/ename/libename.la \ + $(top_builddir)/addressbook/contact-editor/libecontacteditor.a \ + $(top_builddir)/addressbook/printing/libecontactprint.a \ + $(top_builddir)/widgets/e-table/libetable.a \ + $(top_builddir)/widgets/misc/libemiscwidgets.a \ + $(top_builddir)/e-util/libeutil.la \ + $(top_builddir)/widgets/e-text/libetext.a diff --git a/addressbook/gui/widgets/e-minicard-control.c b/addressbook/gui/widgets/e-minicard-control.c index 3cda9b4ead..ab8aedff96 100644 --- a/addressbook/gui/widgets/e-minicard-control.c +++ b/addressbook/gui/widgets/e-minicard-control.c @@ -139,8 +139,7 @@ pstream_load (BonoboPersistStream *ps, const Bonobo_Stream stream, char *vcard; GtkWidget *minicard = data; - if (*type && g_strcasecmp (type, "text/plain") != 0 && - g_strcasecmp (type, "text/vCard") != 0 && + if (*type && g_strcasecmp (type, "text/vCard") != 0 && g_strcasecmp (type, "text/x-vCard") != 0) { CORBA_exception_set (ev, CORBA_USER_EXCEPTION, ex_Bonobo_Persist_WrongDataType, NULL); @@ -176,8 +175,7 @@ pstream_save (BonoboPersistStream *ps, const Bonobo_Stream stream, EMinicardWidget *minicard = data; int length; - if (*type && g_strcasecmp (type, "text/plain") != 0 && - g_strcasecmp (type, "text/vCard") != 0 && + if (*type && g_strcasecmp (type, "text/vCard") != 0 && g_strcasecmp (type, "text/x-vCard") != 0) { CORBA_exception_set (ev, CORBA_USER_EXCEPTION, ex_Bonobo_Persist_WrongDataType, NULL); @@ -242,7 +240,7 @@ static Bonobo_Persist_ContentTypeList * pstream_get_content_types (BonoboPersistStream *ps, void *closure, CORBA_Environment *ev) { - return bonobo_persist_generate_content_types (3, "text/plain", "text/vCard", "text/x-vCard"); + return bonobo_persist_generate_content_types (2, "text/vCard", "text/x-vCard"); } static BonoboObject * diff --git a/addressbook/gui/widgets/e-minicard-widget-test.c b/addressbook/gui/widgets/e-minicard-widget-test.c new file mode 100644 index 0000000000..cbdd2f69b6 --- /dev/null +++ b/addressbook/gui/widgets/e-minicard-widget-test.c @@ -0,0 +1,115 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* test-minicard.c + * + * Copyright (C) 2000 Helix Code, Inc. + * Author: Chris Lahey <clahey@helixcode.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#define TEST_VCARD \ +"BEGIN:VCARD +" \ +"FN:Nat +" \ +"N:Friedman;Nat;D;Mr. +" \ +"ORG:Helix Code, Inc. +" \ +"TITLE:Head Geek +" \ +"ROLE:Programmer/Executive +" \ +"BDAY:1977-08-06 +" \ +"TEL;WORK:617 679 1984 +" \ +"TEL;CELL:123 456 7890 +" \ +"EMAIL;INTERNET:nat@nat.org +" \ +"EMAIL;INTERNET:nat@helixcode.com +" \ +"ADR;WORK;POSTAL:P.O. Box 101;;;Any Town;CA;91921-1234; +" \ +"ADR;HOME;POSTAL;INTL:P.O. Box 202;;;Any Town 2;MI;12344-4321;USA +" \ +"END:VCARD +" \ +" +" + +#include "config.h" + +#include <gnome.h> +#include "e-minicard-widget.h" + +/* This is a horrible thing to do, but it is just a test. */ + +static void destroy_callback(GtkWidget *app, gpointer data) +{ + exit(0); +} + +#if 0 +static void about_callback( GtkWidget *widget, gpointer data ) +{ + + const gchar *authors[] = + { + "Christopher James Lahey <clahey@umich.edu>", + NULL + }; + + GtkWidget *about = + gnome_about_new ( _( "Minicard Widget Test" ), VERSION, + _( "Copyright (C) 2000, Helix Code, Inc." ), + authors, + _( "This should test the minicard widget" ), + NULL); + gtk_widget_show (about); +} +#endif + +int main( int argc, char *argv[] ) +{ + GtkWidget *app; + GtkWidget *minicard; + int i; + ECard *card; + char *vcard; + + /* bindtextdomain (PACKAGE, GNOMELOCALEDIR); + textdomain (PACKAGE);*/ + + gnome_init( "Minicard Widget Test", VERSION, argc, argv); + app = gnome_app_new("Minicard Widget Test", NULL); + + minicard = e_minicard_widget_new(); + card = e_card_new(TEST_VCARD); + gtk_object_set(GTK_OBJECT(minicard), + "card", card, + NULL); + + gnome_app_set_contents( GNOME_APP( app ), minicard ); + + /* Connect the signals */ + gtk_signal_connect( GTK_OBJECT( app ), "destroy", + GTK_SIGNAL_FUNC( destroy_callback ), + ( gpointer ) app ); + + gtk_widget_show_all( app ); + + gtk_main(); + + /* Not reached. */ + return 0; +} diff --git a/addressbook/gui/widgets/e-minicard.c b/addressbook/gui/widgets/e-minicard.c index 68f6ccfc05..2fa1d3c080 100644 --- a/addressbook/gui/widgets/e-minicard.c +++ b/addressbook/gui/widgets/e-minicard.c @@ -418,20 +418,30 @@ e_minicard_event (GnomeCanvasItem *item, GdkEvent *event) NULL ); e_minicard->has_focus = TRUE; } else { - EBook *book; + EBook *book = NULL; e_card_simple_sync_card(e_minicard->simple); + + if (E_IS_MINICARD_VIEW(GNOME_CANVAS_ITEM(e_minicard)->parent)) { + + gtk_object_get(GTK_OBJECT(GNOME_CANVAS_ITEM(e_minicard)->parent), + "book", &book, + NULL); + + } - gtk_object_get(GTK_OBJECT(GNOME_CANVAS_ITEM(e_minicard)->parent), - "book", &book, - NULL); - + if (book) { + /* Add the card in the contact editor to our ebook */ - e_book_commit_card (book, - e_minicard->card, - card_changed_cb, - NULL); - + e_book_commit_card (book, + e_minicard->card, + card_changed_cb, + NULL); + } else { + remodel(e_minicard); + e_canvas_item_request_reflow(GNOME_CANVAS_ITEM(e_minicard)); + } + gnome_canvas_item_set( e_minicard->rect, "outline_color", NULL, NULL ); @@ -449,35 +459,44 @@ e_minicard_event (GnomeCanvasItem *item, GdkEvent *event) if (event->button.button == 1) { e_canvas_item_grab_focus(item); } else if (event->button.button == 3) { - EPopupMenu menu[] = { {"Save as VCard", NULL, GTK_SIGNAL_FUNC(save_as), 0}, - {"Print", NULL, GTK_SIGNAL_FUNC(print), 0}, - {"Delete", NULL, GTK_SIGNAL_FUNC(delete), 0}, - {NULL, NULL, NULL, 0}}; - e_popup_menu_run (menu, (GdkEventButton *)event, 0, e_minicard); + if (E_IS_MINICARD_VIEW(item->parent)) { + EPopupMenu menu[] = { {"Save as VCard", NULL, GTK_SIGNAL_FUNC(save_as), 0}, + {"Print", NULL, GTK_SIGNAL_FUNC(print), 0}, + {"Delete", NULL, GTK_SIGNAL_FUNC(delete), 0}, + {NULL, NULL, NULL, 0}}; + e_popup_menu_run (menu, (GdkEventButton *)event, 0, e_minicard); + } else { + EPopupMenu menu[] = { {"Save as VCard", NULL, GTK_SIGNAL_FUNC(save_as), 0}, + {"Print", NULL, GTK_SIGNAL_FUNC(print), 0}, + {NULL, NULL, NULL, 0}}; + e_popup_menu_run (menu, (GdkEventButton *)event, 0, e_minicard); + } } break; case GDK_2BUTTON_PRESS: if (event->button.button == 1 && E_IS_MINICARD_VIEW(item->parent)) { EContactEditor *ce; - EBook *book; - - gtk_object_get(GTK_OBJECT(item->parent), - "book", &book, - NULL); - g_assert (E_IS_BOOK (book)); - + EBook *book = NULL; + if (E_IS_MINICARD_VIEW(item->parent)) { + + gtk_object_get(GTK_OBJECT(item->parent), + "book", &book, + NULL); + } ce = e_contact_editor_new (e_minicard->card, FALSE); - gtk_signal_connect (GTK_OBJECT (ce), "add_card", - GTK_SIGNAL_FUNC (add_card_cb), book); - gtk_signal_connect (GTK_OBJECT (ce), "commit_card", - GTK_SIGNAL_FUNC (commit_card_cb), book); - gtk_signal_connect (GTK_OBJECT (ce), "delete_card", - GTK_SIGNAL_FUNC (delete_card_cb), book); + if (book != NULL) { + gtk_signal_connect (GTK_OBJECT (ce), "add_card", + GTK_SIGNAL_FUNC (add_card_cb), book); + gtk_signal_connect (GTK_OBJECT (ce), "commit_card", + GTK_SIGNAL_FUNC (commit_card_cb), book); + gtk_signal_connect (GTK_OBJECT (ce), "delete_card", + GTK_SIGNAL_FUNC (delete_card_cb), book); + } + gtk_signal_connect (GTK_OBJECT (ce), "editor_closed", GTK_SIGNAL_FUNC (editor_closed_cb), NULL); - return TRUE; } break; @@ -524,17 +543,17 @@ e_minicard_event (GnomeCanvasItem *item, GdkEvent *event) static void e_minicard_resize_children( EMinicard *e_minicard ) { - if ( GTK_OBJECT_FLAGS( e_minicard ) & GNOME_CANVAS_ITEM_REALIZED ) { - GList *list; - + GList *list; + + if (e_minicard->header_text) { gnome_canvas_item_set( e_minicard->header_text, "width", (double) e_minicard->width - 12, NULL ); - for ( list = e_minicard->fields; list; list = g_list_next( list ) ) { - gnome_canvas_item_set( E_MINICARD_FIELD( list->data )->label, - "width", (double) e_minicard->width - 4.0, - NULL ); - } + } + for ( list = e_minicard->fields; list; list = g_list_next( list ) ) { + gnome_canvas_item_set( E_MINICARD_FIELD( list->data )->label, + "width", (double) e_minicard->width - 4.0, + NULL ); } } |