diff options
author | Christopher James Lahey <clahey@helixcode.com> | 2000-04-09 06:10:47 +0800 |
---|---|---|
committer | Chris Lahey <clahey@src.gnome.org> | 2000-04-09 06:10:47 +0800 |
commit | 58e7df4e0376d1248ced78659d27d61adc1434b9 (patch) | |
tree | edda4073e9e79d89b8bb9a34498049259998718d /widgets/e-minicard/e-minicard.c | |
parent | 6beb74f53508f0f92ad5ed0fe7e823b6a5be76f3 (diff) | |
download | gsoc2013-evolution-58e7df4e0376d1248ced78659d27d61adc1434b9.tar gsoc2013-evolution-58e7df4e0376d1248ced78659d27d61adc1434b9.tar.gz gsoc2013-evolution-58e7df4e0376d1248ced78659d27d61adc1434b9.tar.bz2 gsoc2013-evolution-58e7df4e0376d1248ced78659d27d61adc1434b9.tar.lz gsoc2013-evolution-58e7df4e0376d1248ced78659d27d61adc1434b9.tar.xz gsoc2013-evolution-58e7df4e0376d1248ced78659d27d61adc1434b9.tar.zst gsoc2013-evolution-58e7df4e0376d1248ced78659d27d61adc1434b9.zip |
pixmap_DATA isn't defined so don't use it as a variable.
2000-04-08 Christopher James Lahey <clahey@helixcode.com>
* art/Makefile.am: pixmap_DATA isn't defined so don't use it as a variable.
* addressbook/gui/component/,
addressbook/gui/component/.cvsignore, addressbook/gui/Makefile.am,
addressbook/gui/component/addressbook-factory.c,
addressbook/gui/component/addressbook.c,
addressbook/gui/component/addressbook.gnorba,
addressbook/gui/component/addressbook.h: New directory to proivde
the component for contact management. Simply uses an e-minicard-view.
* addressbook/gui/minicard/e-minicard-view.c,
addressbook/gui/minicard/e-minicard-view.h: New subclass of
e-reflow-sorted that takes an EBook and uses it to compute the
card data to display.
* addressbook/gui/minicard/e-minicard.c,
addressbook/gui/minicard/e-minicard.h: This now backends to a
ECard instead of a ETableModel.
* addressbook/gui/minicard/e-reflow.c,
addressbook/gui/minicard/e-reflow.h: This now has a virtualized
add method.
* addressbook/gui/minicard/e-reflow-sorted.c,
addressbook/gui/minicard/e-reflow-sorted.h: New subclass of
e-reflow that allows the data to be sorted on the fly.
* addressbook/gui/minicard/test-minicard-view.c: New test to test
the new minicard view.
* addressbook/gui/minicard/test-reflow.c: Uses the new ECard
backend of the e-minicard.
* addressbook/gui/minicard/.cvsignore,
addressbook/gui/minicard/Makefile.am: Added new test. Fixed
dependencies. Added new files.
* addressbook/gui/, addressbook/gui/Makefile.am,
addressbook/gui/.cvsignore: New directory for addressbook gui
bits. Added subdirectories. Created an initial .cvsignore.
* addressbook/Makefile.am (SUBDIRS): Removed demo and added gui.
* addressbook/backend/pas/pas-backend-file.c: Added code to do
notification on bookviews when changes in the backend are made.
* addressbook/backend/pas/pas-book-view.c,
addressbook/backend/pas/pas-book-view.h: Added helper functions to
notify the view about the addition or modification of a single
card. Fixed a mistaken extra free.
* addressbook/backend/ebook/e-card-list-iterator.h: Fixed
incorrect parent class.
* addressbook/backend/ebook/test-client.c: Made this accept an
optional parameter that specifies the vcard to add.
* configure.in: Replaced widgets/e-minicard/Makefile and
addressbook/demo/Makefile with addressbook/gui/minicard/Makefile
and addressbook/gui/component/Makefile respectively.
* widgets/Makefile.am: Removed e-minicard since it's being moved
to addressbook/gui/minicard.
* widgets/e-text/e-text.c: Fixed the border width around tooltips
and made the main tooltip area yellow.
From camel/ChangeLog:
2000-04-08 Christopher James Lahey <clahey@helixcode.com>
* providers/smtp/.cvsignore: Added a .cvsignore file.
From calendar/ChangeLog:
2000-04-08 Christopher James Lahey <clahey@helixcode.com>
* gui/Makefile.am: Removed linking with libetable and libeminicard
since they weren't being used.
svn path=/trunk/; revision=2343
Diffstat (limited to 'widgets/e-minicard/e-minicard.c')
-rw-r--r-- | widgets/e-minicard/e-minicard.c | 216 |
1 files changed, 126 insertions, 90 deletions
diff --git a/widgets/e-minicard/e-minicard.c b/widgets/e-minicard/e-minicard.c index 2a98a574c7..02c7670df9 100644 --- a/widgets/e-minicard/e-minicard.c +++ b/widgets/e-minicard/e-minicard.c @@ -24,7 +24,7 @@ #include "e-minicard.h" #include "e-minicard-label.h" #include "e-text.h" -#include "e-table-text-model.h" +#include "e-book.h" #include "e-canvas.h" #include "e-util.h" #include "e-canvas-utils.h" @@ -49,9 +49,7 @@ enum { ARG_WIDTH, ARG_HEIGHT, ARG_HAS_FOCUS, - ARG_CARD, - ARG_MODEL, - ARG_ROW + ARG_CARD }; GtkType @@ -98,10 +96,6 @@ e_minicard_class_init (EMinicardClass *klass) GTK_ARG_READWRITE, ARG_HAS_FOCUS); gtk_object_add_arg_type ("EMinicard::card", GTK_TYPE_OBJECT, GTK_ARG_READWRITE, ARG_CARD); - gtk_object_add_arg_type ("EMinicard::model", GTK_TYPE_OBJECT, - GTK_ARG_READWRITE, ARG_MODEL); - gtk_object_add_arg_type ("EMinicard::row", GTK_TYPE_INT, - GTK_ARG_READWRITE, ARG_ROW); object_class->set_arg = e_minicard_set_arg; object_class->get_arg = e_minicard_get_arg; @@ -123,8 +117,7 @@ e_minicard_init (EMinicard *minicard) minicard->height = 10; minicard->has_focus = FALSE; - minicard->model = NULL; - minicard->row = 0; + minicard->card = NULL; e_canvas_item_set_reflow_callback(GNOME_CANVAS_ITEM(minicard), e_minicard_reflow); } @@ -164,21 +157,11 @@ e_minicard_set_arg (GtkObject *o, GtkArg *arg, guint arg_id) e_canvas_item_grab_focus(item); break; case ARG_CARD: - /* e_minicard->card = GTK_VALUE_OBJECT (*arg); - _update_card(e_minicard); - gnome_canvas_item_request_update (item);*/ - break; - case ARG_MODEL: - if (e_minicard->model) - gtk_object_unref (e_minicard->model); - e_minicard->model = E_TABLE_MODEL(GTK_VALUE_OBJECT (*arg)); - if (e_minicard->model) - gtk_object_ref (e_minicard->model); - remodel(e_minicard); - e_canvas_item_request_reflow(item); - break; - case ARG_ROW: - e_minicard->row = GTK_VALUE_INT (*arg); + if (e_minicard->card) + gtk_object_unref (GTK_OBJECT(e_minicard->card)); + e_minicard->card = E_CARD(GTK_VALUE_OBJECT (*arg)); + if (e_minicard->card) + gtk_object_ref (GTK_OBJECT(e_minicard->card)); remodel(e_minicard); e_canvas_item_request_reflow(item); break; @@ -203,13 +186,7 @@ e_minicard_get_arg (GtkObject *object, GtkArg *arg, guint arg_id) GTK_VALUE_ENUM (*arg) = e_minicard->has_focus ? E_FOCUS_CURRENT : E_FOCUS_NONE; break; case ARG_CARD: - /* GTK_VALUE_OBJECT (*arg) = e_minicard->card; */ - break; - case ARG_MODEL: - GTK_VALUE_OBJECT (*arg) = GTK_OBJECT(e_minicard->model); - break; - case ARG_ROW: - GTK_VALUE_INT (*arg) = e_minicard->row; + GTK_VALUE_OBJECT (*arg) = GTK_OBJECT(e_minicard->card); break; default: arg->type = GTK_TYPE_INVALID; @@ -227,8 +204,8 @@ e_minicard_destroy (GtkObject *object) e_minicard = E_MINICARD (object); - if (e_minicard->model) - gtk_object_unref (e_minicard->model); + if (e_minicard->card) + gtk_object_unref (GTK_OBJECT(e_minicard->card)); if (GTK_OBJECT_CLASS (parent_class)->destroy) (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); @@ -239,7 +216,6 @@ e_minicard_realize (GnomeCanvasItem *item) { EMinicard *e_minicard; GnomeCanvasGroup *group; - GnomeCanvasItem *new_item; e_minicard = E_MINICARD (item); group = GNOME_CANVAS_GROUP( item ); @@ -276,46 +252,10 @@ e_minicard_realize (GnomeCanvasItem *item) "use_ellipsis", TRUE, "font", "lucidasans-bold-10", "fill_color", "black", - "text", "Chris Lahey", + "text", "", NULL ); e_canvas_item_move_absolute(e_minicard->header_text, 6, 6); - new_item = e_minicard_label_new(group); - gnome_canvas_item_set( new_item, - "width", e_minicard->width - 4.0, - "fieldname", "Email:", - "field", "clahey@address.com", - NULL ); - e_minicard->fields = g_list_append( e_minicard->fields, new_item); - e_canvas_item_move_absolute(new_item, 2, e_minicard->height); - - new_item = e_minicard_label_new(group); - gnome_canvas_item_set( new_item, - "width", e_minicard->width - 4, - "fieldname", "Full Name:", - "field", "Christopher James Lahey", - NULL ); - e_minicard->fields = g_list_append( e_minicard->fields, new_item); - e_canvas_item_move_absolute(new_item, 2, e_minicard->height); - - new_item = e_minicard_label_new(group); - gnome_canvas_item_set( new_item, - "width", e_minicard->width - 4, - "fieldname", "Street Address:", - "field", "100 Main St\nHome town, USA", - NULL ); - e_minicard->fields = g_list_append( e_minicard->fields, new_item); - e_canvas_item_move_absolute(new_item, 2, e_minicard->height); - - new_item = e_minicard_label_new(group); - gnome_canvas_item_set( new_item, - "width", e_minicard->width - 4, - "fieldname", "Phone:", - "field", "000-0000", - NULL ); - e_minicard->fields = g_list_append( e_minicard->fields, new_item); - e_canvas_item_move_absolute(new_item, 2, e_minicard->height); - remodel(e_minicard); e_canvas_item_request_reflow(item); @@ -439,31 +379,92 @@ e_minicard_resize_children( EMinicard *e_minicard ) } static void -remodel( EMinicard *e_minicard ) +add_field (EMinicard *e_minicard, char *fieldname, char* field) { + GnomeCanvasItem *new_item; GnomeCanvasGroup *group; group = GNOME_CANVAS_GROUP( e_minicard ); - if ( e_minicard->model ) { - gint column = 0; - GList *list = e_minicard->fields; - ETableTextModel *model; - for ( ; list; list = list->next, column++ ) { - ETableTextModel *model = e_table_text_model_new(e_minicard->model, e_minicard->row, column); - gnome_canvas_item_set(GNOME_CANVAS_ITEM(list->data), - "text_model", model, - NULL); - gtk_object_sink(GTK_OBJECT(model)); + new_item = e_minicard_label_new(group); + gnome_canvas_item_set( new_item, + "width", e_minicard->width - 4.0, + "fieldname", fieldname, + "field", field, + NULL ); + e_minicard->fields = g_list_append( e_minicard->fields, new_item); + e_canvas_item_move_absolute(new_item, 2, e_minicard->height); +} + + +static void +remodel( EMinicard *e_minicard ) +{ + if (e_minicard->card) { + char *fname; + ECardList *address_list; + ECardList *phone_list; + ECardList *email_list; + + ECardIterator *iterator; + + GList *list; + + for ( list = e_minicard->fields; list; list = g_list_next( list ) ) { + gtk_object_destroy( GTK_OBJECT( list->data ) ); } - if ( e_minicard->header_text ) { - model = e_table_text_model_new(e_minicard->model, e_minicard->row, 1); - gnome_canvas_item_set(GNOME_CANVAS_ITEM(e_minicard->header_text), - "model", model, - NULL); - gtk_object_sink(GTK_OBJECT(model)); + g_list_free(e_minicard->fields); + e_minicard->fields = NULL; + + gtk_object_get(GTK_OBJECT(e_minicard->card), + "full_name", &fname, + "address", &address_list, + "phone", &phone_list, + "email", &email_list, + NULL); + + if (fname) { + add_field(e_minicard, "Name:", fname); + if (e_minicard->header_text) + gnome_canvas_item_set(e_minicard->header_text, + "text", fname, + NULL); + } else + if (e_minicard->header_text) + gnome_canvas_item_set(e_minicard->header_text, + "text", "", + NULL); + if (address_list) { + for (iterator = e_card_list_get_iterator(address_list); e_card_iterator_is_valid(iterator); e_card_iterator_next(iterator)) { + const ECardDeliveryAddress *address = e_card_iterator_get(iterator); + if (address->flags & ADDR_WORK) { + add_field(e_minicard, "Work Address:", address->city); + } else if (address->flags & ADDR_HOME) { + add_field(e_minicard, "Home Address:", address->city); + } else { + add_field(e_minicard, "Address:", address->city); + } + } + } + if (phone_list) { + for (iterator = e_card_list_get_iterator(phone_list); e_card_iterator_is_valid(iterator); e_card_iterator_next(iterator)) { + const ECardPhone *phone = e_card_iterator_get(iterator); + if (phone->flags & E_CARD_PHONE_WORK) { + add_field(e_minicard, "Work Phone:", phone->number); + } else if (phone->flags & E_CARD_PHONE_HOME) { + add_field(e_minicard, "Home Phone:", phone->number); + } else if (phone->flags & E_CARD_PHONE_CELL) { + add_field(e_minicard, "Mobile Phone:", phone->number); + } else { + add_field(e_minicard, "Phone:", phone->number); + } + } + } + if (email_list) { + for (iterator = e_card_list_get_iterator(email_list); e_card_iterator_is_valid(iterator); e_card_iterator_next(iterator)) { + add_field(e_minicard, "Email:", (char *) e_card_iterator_get(iterator)); + } } - } } @@ -513,3 +514,38 @@ e_minicard_reflow( GnomeCanvasItem *item, int flags ) e_canvas_item_request_parent_reflow(item); } } + +char * +e_minicard_get_card_id (EMinicard *minicard) +{ + g_return_val_if_fail(minicard != NULL, NULL); + g_return_val_if_fail(E_IS_MINICARD(minicard), NULL); + + if (minicard->card) { + return e_card_get_id(minicard->card); + } else { + return NULL; + } +} + +int +e_minicard_compare (EMinicard *minicard1, EMinicard *minicard2) +{ + g_return_val_if_fail(minicard1 != NULL, 0); + g_return_val_if_fail(E_IS_MINICARD(minicard1), 0); + g_return_val_if_fail(minicard2 != NULL, 0); + g_return_val_if_fail(E_IS_MINICARD(minicard2), 0); + + if (minicard1->card && minicard2->card) { + char *fname1, *fname2; + gtk_object_get(GTK_OBJECT(minicard1->card), + "full_name", &fname1, + NULL); + gtk_object_get(GTK_OBJECT(minicard2->card), + "full_name", &fname2, + NULL); + return strcmp(fname1, fname2); + } else { + return 0; + } +} |