diff options
author | Christopher James Lahey <clahey@helixcode.com> | 2000-08-20 07:36:35 +0800 |
---|---|---|
committer | Chris Lahey <clahey@src.gnome.org> | 2000-08-20 07:36:35 +0800 |
commit | d56dbcd9247a965250888c0486464f976e668057 (patch) | |
tree | 9ad294f7fafd65cb7c531d11586a910806b39ef5 | |
parent | 862d1f25dea4fde774aca9b8e849f22b2e0b9d93 (diff) | |
download | gsoc2013-evolution-d56dbcd9247a965250888c0486464f976e668057.tar gsoc2013-evolution-d56dbcd9247a965250888c0486464f976e668057.tar.gz gsoc2013-evolution-d56dbcd9247a965250888c0486464f976e668057.tar.bz2 gsoc2013-evolution-d56dbcd9247a965250888c0486464f976e668057.tar.lz gsoc2013-evolution-d56dbcd9247a965250888c0486464f976e668057.tar.xz gsoc2013-evolution-d56dbcd9247a965250888c0486464f976e668057.tar.zst gsoc2013-evolution-d56dbcd9247a965250888c0486464f976e668057.zip |
Changed this to use ECardSimple.
2000-08-19 Christopher James Lahey <clahey@helixcode.com>
* conduit/address-conduit.c, conduit/address-conduit.h: Changed
this to use ECardSimple.
* contact-editor/e-contact-editor.c: Fixed a memory leak.
* gui/component/addressbook.c: Added stuff to the right click
menu. Activated the new search dialog that doesn't quite work
yet.
* gui/minicard/e-minicard-view.c: Fixed some run time warnings.
svn path=/trunk/; revision=4882
-rw-r--r-- | addressbook/ChangeLog | 13 | ||||
-rw-r--r-- | addressbook/conduit/address-conduit.c | 154 | ||||
-rw-r--r-- | addressbook/conduit/address-conduit.h | 1 | ||||
-rw-r--r-- | addressbook/contact-editor/e-contact-editor.c | 1 | ||||
-rw-r--r-- | addressbook/gui/component/addressbook.c | 83 | ||||
-rw-r--r-- | addressbook/gui/contact-editor/e-contact-editor.c | 1 | ||||
-rw-r--r-- | addressbook/gui/minicard/e-minicard-view.c | 10 | ||||
-rw-r--r-- | addressbook/gui/widgets/e-minicard-view.c | 10 |
8 files changed, 194 insertions, 79 deletions
diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog index 839ac48ca2..03001f30dc 100644 --- a/addressbook/ChangeLog +++ b/addressbook/ChangeLog @@ -1,3 +1,16 @@ +2000-08-19 Christopher James Lahey <clahey@helixcode.com> + + * conduit/address-conduit.c, conduit/address-conduit.h: Changed + this to use ECardSimple. + + * contact-editor/e-contact-editor.c: Fixed a memory leak. + + * gui/component/addressbook.c: Added stuff to the right click + menu. Activated the new search dialog that doesn't quite work + yet. + + * gui/minicard/e-minicard-view.c: Fixed some run time warnings. + 2000-08-15 Larry Ewing <lewing@helixcode.com> * gui/minicard/e-minicard.c (e_minicard_event): use style colors diff --git a/addressbook/conduit/address-conduit.c b/addressbook/conduit/address-conduit.c index 0c79daaaee..d863d22af4 100644 --- a/addressbook/conduit/address-conduit.c +++ b/addressbook/conduit/address-conduit.c @@ -18,7 +18,6 @@ #include <gpilotd/gnome-pilot-conduit.h> #include <gpilotd/gnome-pilot-conduit-standard-abs.h> #include <address-conduit.h> -#include <libversit/vcc.h> #include "ebook/e-book-types.h" #include <bonobo.h> @@ -275,93 +274,106 @@ static ECard * ecard_from_remote_record(AddressbookConduitContext *ctxt, PilotRecord *remote) { - ECard *ecard; struct Address address; - VObject *vobj; - VObject *nameprop, *addressprop; + ECard *ecard; + ECardSimple *simple; int i; - char *temp; + char *string; + char *stringparts[4]; + char *commaparts[3]; + char *spaceparts[3]; + char *commastring, *spacestring; g_return_val_if_fail(remote!=NULL,NULL); memset (&address, 0, sizeof (struct Address)); unpack_Address (&address, remote->record, remote->length); - - vobj = newVObject (VCCardProp); - nameprop = addProp (vobj, VCNameProp); - -#define ADD_PROP(v,pilotprop,vprop) \ - if (address.entry [(pilotprop)]) \ - addPropValue ((v), (vprop), address.entry [(pilotprop)]) - - ADD_PROP (nameprop, entryFirstname, VCGivenNameProp); - ADD_PROP (nameprop, entryLastname, VCFamilyNameProp); - - addressprop = addProp (vobj, VCAdrProp); - - ADD_PROP (addressprop, entryAddress, VCStreetAddressProp); - ADD_PROP (addressprop, entryCity, VCCityProp); - ADD_PROP (addressprop, entryState, VCRegionProp); - ADD_PROP (addressprop, entryZip, VCPostalCodeProp); - ADD_PROP (addressprop, entryCountry, VCCountryNameProp); - ADD_PROP (vobj, entryTitle, VCTitleProp); - if (address.entry [entryCompany]) { - VObject *orgprop; - orgprop = addProp (vobj, VCOrgProp); - ADD_PROP (orgprop, entryCompany, VCOrgNameProp); - } + ecard = e_card_new(""); + simple = e_card_simple_new(ecard); + +#define get(pilotprop) \ + (address.entry [(pilotprop)]) +#define check(pilotprop) \ + (address.entry [(pilotprop)] && *address.entry [(pilotprop)]) + + i = 0; + if (check(entryFirstname)) + stringparts[i++] = get(entryFirstname); + if (check(entryLastname)) + stringparts[i++] = get(entryLastname); + stringparts[i] = NULL; + string = g_strjoinv(" ", stringparts); + e_card_simple_set(simple, E_CARD_SIMPLE_FIELD_FULL_NAME, string); + g_free(string); + + i = 0; + if (check (entryAddress)) + spaceparts[i++] = get (entryAddress); + if (check (entryZip)) + spaceparts[i++] = get (entryZip); + spaceparts[i] = 0; + spacestring = g_strjoinv(" ", spaceparts); + + i = 0; + if (check (entryCity)) + commaparts[i++] = get (entryCity); + if (spacestring && *spacestring) + commaparts[i++] = spacestring; + commaparts[i] = 0; + commastring = g_strjoinv(", ", commaparts); + + i = 0; + if (check (entryAddress)) + stringparts[i++] = get (entryAddress); + if (commastring && *commastring) + stringparts[i++] = commastring; + if (check (entryCountry)) + stringparts[i++] = get (entryCountry); + stringparts[i] = NULL; + string = g_strjoinv("\n", stringparts); + e_card_simple_set(simple, E_CARD_SIMPLE_FIELD_ADDRESS_HOME, string); + + g_free(spacestring); + g_free(commastring); + g_free(string); + + if (check (entryTitle)) + e_card_simple_set(simple, E_CARD_SIMPLE_FIELD_TITLE, get (entryTitle)); + + if (check (entryCompany)) + e_card_simple_set(simple, E_CARD_SIMPLE_FIELD_ORG, get (entryCompany)); for (i = entryPhone1; i <= entryPhone5; i ++) { - if (address.entry [i]) { + if (address.entry [i] && *(address.entry [i])) { char *phonelabel = ctxt->ai.phoneLabels[address.phoneLabel[i - entryPhone1]]; - if (!strcmp (phonelabel, "E-mail")) { - VObject *emailprop = addPropValue (vobj, - VCEmailAddressProp, - address.entry[i]); - addProp (emailprop, VCInternetProp); - } - else { - const char* phone_type = VCHomeProp; - VObject *phoneprop = addPropValue (vobj, - VCTelephoneProp, - address.entry[i]); - - printf ("added '%s' phone entry %s\n", - phonelabel, - address.entry[i]); - - if (!strcmp (phonelabel, "Home")) - phone_type = VCHomeProp; - else if (!strcmp (phonelabel, "Work")) - phone_type = VCWorkProp; - else if (!strcmp (phonelabel, "Fax")) - phone_type = VCFaxProp; - else if (!strcmp (phonelabel, "Other")) - phone_type = VCHomeProp; /* XXX */ - else if (!strcmp (phonelabel, "Main")) { /* XXX */ - addProp (phoneprop, VCHomeProp); - phone_type = VCPreferredProp; - } - else if (!strcmp (phonelabel, "Pager")) - phone_type = VCPagerProp; - else if (!strcmp (phonelabel, "Mobile")) - phone_type = VCCellularProp; - addProp (phoneprop, phone_type); - } + if (!strcmp (phonelabel, "E-mail")) + e_card_simple_set(simple, E_CARD_SIMPLE_FIELD_EMAIL, address.entry[i]); + else if (!strcmp (phonelabel, "Home")) + e_card_simple_set(simple, E_CARD_SIMPLE_FIELD_PHONE_HOME, address.entry[i]); + else if (!strcmp (phonelabel, "Work")) + e_card_simple_set(simple, E_CARD_SIMPLE_FIELD_PHONE_BUSINESS, address.entry[i]); + else if (!strcmp (phonelabel, "Fax")) + e_card_simple_set(simple, E_CARD_SIMPLE_FIELD_PHONE_BUSINESS_FAX, address.entry[i]); + else if (!strcmp (phonelabel, "Other")) + e_card_simple_set(simple, E_CARD_SIMPLE_FIELD_PHONE_OTHER, address.entry[i]); + else if (!strcmp (phonelabel, "Main")) + e_card_simple_set(simple, E_CARD_SIMPLE_FIELD_PHONE_PRIMARY, address.entry[i]); + else if (!strcmp (phonelabel, "Pager")) + e_card_simple_set(simple, E_CARD_SIMPLE_FIELD_PHONE_PAGER, address.entry[i]); + else if (!strcmp (phonelabel, "Mobile")) + e_card_simple_set(simple, E_CARD_SIMPLE_FIELD_PHONE_MOBILE, address.entry[i]); } } -#undef ADD_PROP - - temp = writeMemVObject (NULL, NULL, vobj); - ecard = e_card_new (temp); - free (temp); - cleanVObject (vobj); +#undef get +#undef set free_Address(&address); gtk_object_set (GTK_OBJECT(ecard), "pilot_id", remote->ID, NULL); + gtk_object_unref(GTK_OBJECT(simple)); + return ecard; } @@ -1186,7 +1198,9 @@ conduit_get_gpilot_conduit (guint32 pilotId) printf ("in address's conduit_get_gpilot_conduit\n"); #ifdef NEED_OAF_INIT_HACK +#ifndef NO_WARNINGS #warning "need a better way to do this" +#endif /* we need to find wombat with oaf, so make sure oaf is initialized here. once the desktop is converted to oaf and gpilotd is built with oaf, this can go away */ diff --git a/addressbook/conduit/address-conduit.h b/addressbook/conduit/address-conduit.h index e379b55ee0..9858504fd7 100644 --- a/addressbook/conduit/address-conduit.h +++ b/addressbook/conduit/address-conduit.h @@ -11,6 +11,7 @@ #include <gpilotd/gnome-pilot-conduit.h> #include <gpilotd/gnome-pilot-conduit-standard-abs.h> #include "ebook/e-card.h" +#include "ebook/e-card-simple.h" #include "ebook/e-book.h" #include "ebook/e-book-view.h" diff --git a/addressbook/contact-editor/e-contact-editor.c b/addressbook/contact-editor/e-contact-editor.c index dd4ec4d567..e8062d83b9 100644 --- a/addressbook/contact-editor/e-contact-editor.c +++ b/addressbook/contact-editor/e-contact-editor.c @@ -938,6 +938,7 @@ setup_tab_order(GladeXML *gui) 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); } } diff --git a/addressbook/gui/component/addressbook.c b/addressbook/gui/component/addressbook.c index 5834d2f857..6a997cd2a4 100644 --- a/addressbook/gui/component/addressbook.c +++ b/addressbook/gui/component/addressbook.c @@ -20,6 +20,7 @@ #include <e-util/e-util.h> #include <e-util/e-popup-menu.h> #include "e-minicard-view-widget.h" +#include "addressbook/gui/search/e-addressbook-search-dialog.h" #include <e-table.h> #include <e-cell-text.h> @@ -85,6 +86,7 @@ control_deactivate (BonoboControl *control, BonoboUIHandler *uih) #ifdef HAVE_LDAP bonobo_ui_handler_menu_remove (uih, "/Actions/New Directory Server"); #endif + bonobo_ui_handler_menu_remove (uih, "/Tools/Search"); /* remove our toolbar */ bonobo_ui_handler_dock_remove (uih, "/Toolbar"); } @@ -225,6 +227,23 @@ new_server_cb (BonoboUIHandler *uih, void *user_data, const char *path) } #endif +static void +search_cb (BonoboUIHandler *uih, void *user_data, const char *path) +{ + EBook *book; + AddressbookView *view = (AddressbookView *) user_data; + GtkObject *object; + + if (view->minicard_view) + object = GTK_OBJECT(view->minicard_view); + else + object = GTK_OBJECT(view->model); + gtk_object_get(object, "book", &book, NULL); + g_assert (E_IS_BOOK (book)); + + gtk_widget_show(e_addressbook_search_dialog_new(book)); +} + static char * get_query (AddressbookView *view) { @@ -521,6 +540,13 @@ control_activate (BonoboControl *control, BonoboUIHandler *uih, (gpointer)view); #endif + bonobo_ui_handler_menu_new_item (uih, "/Tools/Search", + N_("_Search for contacts"), + NULL, -1, + BONOBO_UI_HANDLER_PIXMAP_STOCK, GNOME_STOCK_MENU_SEARCH, + 0, 0, search_cb, + (gpointer)view); + toolbar = gtk_toolbar_new (GTK_ORIENTATION_HORIZONTAL, GTK_TOOLBAR_BOTH); @@ -870,19 +896,66 @@ table_double_click(ETableScrolled *table, gint row, AddressbookView *view) gtk_object_unref(GTK_OBJECT(card)); } +typedef struct { + EBook *book; + ECard *card; +} CardAndBook; + +static void +card_and_book_free (CardAndBook *card_and_book) +{ + gtk_object_unref(GTK_OBJECT(card_and_book->card)); + gtk_object_unref(GTK_OBJECT(card_and_book->book)); +} + +static void +save_as (GtkWidget *widget, CardAndBook *card_and_book) +{ + e_contact_save_as(_("Save as VCard"), card_and_book->card); + card_and_book_free(card_and_book); +} + +static void +print (GtkWidget *widget, CardAndBook *card_and_book) +{ + gtk_widget_show(e_contact_print_card_dialog_new(card_and_book->card)); + card_and_book_free(card_and_book); +} + static void -save_as (GtkWidget *widget, ECard *card) +delete (GtkWidget *widget, CardAndBook *card_and_book) { - e_contact_save_as(_("Save as VCard"), card); + if (e_contact_editor_confirm_delete()) { + /* Add the card in the contact editor to our ebook */ + e_book_remove_card (card_and_book->book, + card_and_book->card, + NULL, + NULL); + } + card_and_book_free(card_and_book); } static gint table_right_click(ETableScrolled *table, gint row, gint col, GdkEvent *event, AddressbookView *view) { - ECard *card = e_addressbook_model_get_card(E_ADDRESSBOOK_MODEL(view->model), row); - EPopupMenu menu[] = { {"Save as VCard", NULL, GTK_SIGNAL_FUNC(save_as), 0}, {NULL, NULL, NULL, 0} }; + CardAndBook *card_and_book; + + 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} + }; + + card_and_book = g_new(CardAndBook, 1); + card_and_book->card = e_addressbook_model_get_card(E_ADDRESSBOOK_MODEL(view->model), row); + gtk_object_get(GTK_OBJECT(view->model), + "book", &(card_and_book->book), + NULL); + + gtk_object_ref(GTK_OBJECT(card_and_book->book)); - e_popup_menu_run (menu, (GdkEventButton *)event, 0, 0, card); + e_popup_menu_run (menu, (GdkEventButton *)event, 0, 0, card_and_book); return TRUE; } diff --git a/addressbook/gui/contact-editor/e-contact-editor.c b/addressbook/gui/contact-editor/e-contact-editor.c index dd4ec4d567..e8062d83b9 100644 --- a/addressbook/gui/contact-editor/e-contact-editor.c +++ b/addressbook/gui/contact-editor/e-contact-editor.c @@ -938,6 +938,7 @@ setup_tab_order(GladeXML *gui) 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); } } diff --git a/addressbook/gui/minicard/e-minicard-view.c b/addressbook/gui/minicard/e-minicard-view.c index 8e275bdb2b..011ff9158f 100644 --- a/addressbook/gui/minicard/e-minicard-view.c +++ b/addressbook/gui/minicard/e-minicard-view.c @@ -211,12 +211,14 @@ e_minicard_view_set_arg (GtkObject *o, GtkArg *arg, guint arg_id) case ARG_BOOK: if (view->book) gtk_object_unref(GTK_OBJECT(view->book)); - view->book = E_BOOK(GTK_VALUE_OBJECT (*arg)); - if (view->book) { + if (GTK_VALUE_OBJECT (*arg)) { + view->book = E_BOOK(GTK_VALUE_OBJECT (*arg)); gtk_object_ref(GTK_OBJECT(view->book)); if (view->get_view_idle == 0) view->get_view_idle = g_idle_add((GSourceFunc)get_view, view); } + else + view->book = NULL; break; case ARG_QUERY: g_free(view->query); @@ -360,6 +362,10 @@ disconnect_signals(EMinicardView *view) if (view->book_view && view->modify_card_id) gtk_signal_disconnect(GTK_OBJECT (view->book_view), view->modify_card_id); + + view->create_card_id = 0; + view->remove_card_id = 0; + view->modify_card_id = 0; } static void diff --git a/addressbook/gui/widgets/e-minicard-view.c b/addressbook/gui/widgets/e-minicard-view.c index 8e275bdb2b..011ff9158f 100644 --- a/addressbook/gui/widgets/e-minicard-view.c +++ b/addressbook/gui/widgets/e-minicard-view.c @@ -211,12 +211,14 @@ e_minicard_view_set_arg (GtkObject *o, GtkArg *arg, guint arg_id) case ARG_BOOK: if (view->book) gtk_object_unref(GTK_OBJECT(view->book)); - view->book = E_BOOK(GTK_VALUE_OBJECT (*arg)); - if (view->book) { + if (GTK_VALUE_OBJECT (*arg)) { + view->book = E_BOOK(GTK_VALUE_OBJECT (*arg)); gtk_object_ref(GTK_OBJECT(view->book)); if (view->get_view_idle == 0) view->get_view_idle = g_idle_add((GSourceFunc)get_view, view); } + else + view->book = NULL; break; case ARG_QUERY: g_free(view->query); @@ -360,6 +362,10 @@ disconnect_signals(EMinicardView *view) if (view->book_view && view->modify_card_id) gtk_signal_disconnect(GTK_OBJECT (view->book_view), view->modify_card_id); + + view->create_card_id = 0; + view->remove_card_id = 0; + view->modify_card_id = 0; } static void |