From 1c4fe770ac9faad5103a520598f1755186cf248c Mon Sep 17 00:00:00 2001 From: Jon Trowbridge Date: Fri, 5 Oct 2001 20:52:01 +0000 Subject: Check to make sure our call to e_addressbook_model_get_card doesn't return 2001-10-05 Jon Trowbridge * gui/component/select-names/e-select-names.c (real_add_address_cb): Check to make sure our call to e_addressbook_model_get_card doesn't return NULL. * gui/widgets/e-addressbook-model.c (e_addressbook_model_get_card): Chek that we aren't requesting a negative row. * gui/contact-list-editor/e-contact-list-editor.c (add_email_cb): Move to the bottom of the scrolled window, so we can see the address we just added. (table_drag_data_received_cb): Move to the bottom of the scrolled window, so we can see the contact we just dropped. * gui/component/addressbook.c (addressbook_factory_new_control): We don't own the string returned by e_categories_master_list_nth, so terrible things will happen if we free it. (Bug 10916) svn path=/trunk/; revision=13469 --- addressbook/ChangeLog | 20 ++++++++++++++++++++ addressbook/gui/component/addressbook.c | 4 +--- .../gui/component/select-names/e-select-names.c | 19 +++++++++---------- .../gui/contact-list-editor/e-contact-list-editor.c | 14 +++++++++++++- addressbook/gui/widgets/e-addressbook-model.c | 2 +- 5 files changed, 44 insertions(+), 15 deletions(-) diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog index 780a72205b..800d5e5682 100644 --- a/addressbook/ChangeLog +++ b/addressbook/ChangeLog @@ -1,3 +1,23 @@ +2001-10-05 Jon Trowbridge + + * gui/component/select-names/e-select-names.c + (real_add_address_cb): Check to make sure our call to + e_addressbook_model_get_card doesn't return NULL. + + * gui/widgets/e-addressbook-model.c + (e_addressbook_model_get_card): Chek that we aren't requesting a + negative row. + + * gui/contact-list-editor/e-contact-list-editor.c (add_email_cb): + Move to the bottom of the scrolled window, so we can see the + address we just added. + (table_drag_data_received_cb): Move to the bottom of the scrolled + window, so we can see the contact we just dropped. + + * gui/component/addressbook.c (addressbook_factory_new_control): + We don't own the string returned by e_categories_master_list_nth, + so terrible things will happen if we free it. (Bug 10916) + 2001-10-05 Chris Toshok * gui/widgets/e-addressbook-view.c (e_addressbook_view_set_arg): diff --git a/addressbook/gui/component/addressbook.c b/addressbook/gui/component/addressbook.c index eb7cd4afb5..17e6ed4e3d 100644 --- a/addressbook/gui/component/addressbook.c +++ b/addressbook/gui/component/addressbook.c @@ -898,12 +898,10 @@ addressbook_factory_new_control (void) subitems[0].translate = FALSE; for (i=0; iwithout), model_row); - card = e_addressbook_model_get_card(E_ADDRESSBOOK_MODEL(names->model), mapped_row); - - - e_destination_set_card (dest, card, 0); + card = e_addressbook_model_get_card (E_ADDRESSBOOK_MODEL(names->model), mapped_row); + + if (card != NULL) { + e_destination_set_card (dest, card, 0); - e_select_names_model_append (child->source, dest); - e_select_names_model_clean (child->source); + e_select_names_model_append (child->source, dest); + e_select_names_model_clean (child->source); - gtk_object_unref(GTK_OBJECT(card)); + gtk_object_unref(GTK_OBJECT(card)); + } } static void @@ -702,7 +703,6 @@ button_clicked(GtkWidget *button, ESelectNamesChild *child) static void remove_address(ETable *table, int row, int col, GdkEvent *event, ESelectNamesChild *child) { - g_message ("remove row %d", row); e_select_names_model_delete (child->source, row); } @@ -720,8 +720,7 @@ etable_selection_foreach_cb (int row, void *data) /* Build a list of rows in reverse order, then remove them, necessary because otherwise it'll start trying to delete rows out of index in ETableModel */ - selected_rows = g_slist_prepend (selected_rows, - GINT_TO_POINTER (row)); + selected_rows = g_slist_prepend (selected_rows, GINT_TO_POINTER (row)); } static void diff --git a/addressbook/gui/contact-list-editor/e-contact-list-editor.c b/addressbook/gui/contact-list-editor/e-contact-list-editor.c index 92919c402e..041bf6d9d8 100644 --- a/addressbook/gui/contact-list-editor/e-contact-list-editor.c +++ b/addressbook/gui/contact-list-editor/e-contact-list-editor.c @@ -593,11 +593,17 @@ e_contact_list_editor_create_table(gchar *name, static void add_email_cb (GtkWidget *w, EContactListEditor *editor) { + GtkAdjustment *adj = e_scroll_frame_get_vadjustment (E_SCROLL_FRAME (editor->table)); char *text = gtk_entry_get_text (GTK_ENTRY(editor->email_entry)); - if (text && *text) + if (text && *text) { e_contact_list_model_add_email (E_CONTACT_LIST_MODEL(editor->model), text); + /* Skip to the end of the list */ + if (adj->upper - adj->lower > adj->page_size) + gtk_adjustment_set_value (adj, adj->upper); + } + gtk_entry_set_text (GTK_ENTRY(editor->email_entry), ""); if (!editor->changed) { @@ -720,12 +726,14 @@ table_drag_data_received_cb (ETable *table, int row, int col, GtkSelectionData *selection_data, guint info, guint time, EContactListEditor *editor) { + GtkAdjustment *adj = e_scroll_frame_get_vadjustment (E_SCROLL_FRAME (editor->table)); char *target_type; gboolean changed = FALSE; target_type = gdk_atom_name (selection_data->target); if (!strcmp (target_type, VCARD_TYPE)) { + GList *card_list = e_card_load_cards_from_string_with_default_charset (selection_data->data, "ISO-8859-1"); GList *c; @@ -745,6 +753,10 @@ table_drag_data_received_cb (ETable *table, int row, int col, } g_list_foreach (card_list, (GFunc)gtk_object_unref, NULL); g_list_free (card_list); + + /* Skip to the end of the list */ + if (adj->upper - adj->lower > adj->page_size) + gtk_adjustment_set_value (adj, adj->upper); } if (changed && !editor->changed) { diff --git a/addressbook/gui/widgets/e-addressbook-model.c b/addressbook/gui/widgets/e-addressbook-model.c index d3c59fbcfd..fd67d5fd23 100644 --- a/addressbook/gui/widgets/e-addressbook-model.c +++ b/addressbook/gui/widgets/e-addressbook-model.c @@ -419,7 +419,7 @@ ECard * e_addressbook_model_get_card(EAddressbookModel *model, int row) { - if (model->data && row < model->data_count) { + if (model->data && 0 <= row && row < model->data_count) { ECard *card; card = e_card_duplicate (model->data[row]); return card; -- cgit v1.2.3