From a451a634c20ffb820fd07700b9bb88fbd29df2b9 Mon Sep 17 00:00:00 2001 From: Christopher James Lahey Date: Sun, 9 Jul 2000 01:24:53 +0000 Subject: Include e-select-names-factory.h. 2000-07-08 Christopher James Lahey * gui/component/addressbook-factory.c: Include e-select-names-factory.h. * gui/component/select-names/e-select-names-model.c: Handle a NULL iterator properly in the replace function. * gui/component/select-names/e-select-names-table-model.c: Fill in info properly in the value_at function. * gui/component/select-names/e-select-names-text-model.c: Don't strlen a NULL text object. * gui/component/select-names/e-select-names.c: Close if the person hits ok or cancel (doesn't yet actually undo changes if Cancel is hit.) Handle removing addresses when they're double clicked on. * gui/component/select-names/select-names.glade, gui/component/select-names/select-names.glade.h: Hid some unused fields and changed the text at the top of the dialog. svn path=/trunk/; revision=3989 --- addressbook/gui/component/addressbook-factory.c | 1 + .../component/select-names/e-select-names-model.c | 21 ++++++++++++++-- .../select-names/e-select-names-table-model.c | 1 + .../select-names/e-select-names-text-model.c | 15 ++++++++---- .../gui/component/select-names/e-select-names.c | 28 ++++++++++++++++++++++ .../gui/component/select-names/select-names.glade | 4 +++- .../component/select-names/select-names.glade.h | 2 +- 7 files changed, 64 insertions(+), 8 deletions(-) (limited to 'addressbook/gui') diff --git a/addressbook/gui/component/addressbook-factory.c b/addressbook/gui/component/addressbook-factory.c index 27f5adedaf..e83933debf 100644 --- a/addressbook/gui/component/addressbook-factory.c +++ b/addressbook/gui/component/addressbook-factory.c @@ -16,6 +16,7 @@ #include "addressbook.h" #include "addressbook-component.h" +#include "select-names/e-select-names-factory.h" #ifdef USING_OAF diff --git a/addressbook/gui/component/select-names/e-select-names-model.c b/addressbook/gui/component/select-names/e-select-names-model.c index c131c4d66f..94fb3d980a 100644 --- a/addressbook/gui/component/select-names/e-select-names-model.c +++ b/addressbook/gui/component/select-names/e-select-names-model.c @@ -260,6 +260,8 @@ e_select_names_model_insert (ESelectNamesModel *model, iterator = e_list_get_iterator(model->data); index = 0; + } else { + gtk_object_ref(GTK_OBJECT(iterator)); } if (strings[0]) { ESelectNamesModelData *node = (void *) e_iterator_get(iterator); @@ -288,6 +290,7 @@ e_select_names_model_insert (ESelectNamesModel *model, g_free(node); } e_select_names_model_changed(model); + gtk_object_unref(GTK_OBJECT(iterator)); } void @@ -347,6 +350,16 @@ e_select_names_model_replace (ESelectNamesModel *model, int length, char *data) { + if (iterator == NULL) { + ESelectNamesModelData new = {E_SELECT_NAMES_MODEL_DATA_TYPE_STRING_ADDRESS, NULL, ""}; + + e_list_append(model->data, &new); + iterator = e_list_get_iterator(model->data); + + index = 0; + } else { + gtk_object_ref(GTK_OBJECT(iterator)); + } while (length > 0 && e_iterator_is_valid(iterator)) { ESelectNamesModelData *node = (void *) e_iterator_get(iterator); int this_length = strlen(node->string); @@ -377,10 +390,14 @@ e_select_names_model_replace (ESelectNamesModel *model, if (!e_iterator_is_valid(iterator)) { ESelectNamesModelData *node; e_iterator_last(iterator); - node = (void *) e_iterator_get(iterator); - index = strlen(node->string); + if (e_iterator_is_valid(iterator)) { + node = (void *) e_iterator_get(iterator); + index = strlen(node->string); + } else + index = 0; } e_select_names_model_insert (model, iterator, index, data); + gtk_object_unref(GTK_OBJECT(iterator)); } diff --git a/addressbook/gui/component/select-names/e-select-names-table-model.c b/addressbook/gui/component/select-names/e-select-names-table-model.c index b6e13bf81b..2e33fdfe85 100644 --- a/addressbook/gui/component/select-names/e-select-names-table-model.c +++ b/addressbook/gui/component/select-names/e-select-names-table-model.c @@ -195,6 +195,7 @@ e_select_names_table_model_value_at (ETableModel *etc, int col, int row) { ESelectNamesTableModel *e_select_names_table_model = E_SELECT_NAMES_TABLE_MODEL(etc); if (e_select_names_table_model->data == NULL) { + fill_in_info(e_select_names_table_model); } switch (col) { case 0: 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 dd28a50239..7fa7b87892 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 @@ -123,6 +123,10 @@ e_select_names_text_model_set_text (ETextModel *model, gchar *text) { ESelectNamesModel *source = E_SELECT_NAMES_TEXT_MODEL(model)->source; EIterator *iterator = e_list_get_iterator(e_select_names_model_get_data(source)); + int length = 0; + if (model->text) { + length = strlen(model->text); + } e_iterator_reset(iterator); if (!e_iterator_is_valid(iterator)) { @@ -132,7 +136,7 @@ e_select_names_text_model_set_text (ETextModel *model, gchar *text) e_select_names_model_replace(source, iterator, 0, - strlen(model->text), + length, text); if (iterator) gtk_object_unref(GTK_OBJECT(iterator)); @@ -230,7 +234,8 @@ e_select_names_text_model_model_changed (ESelectNamesModel *source, length ++; length_count++; } - length --; + if (length > 0) + length --; g_free(model->lengths); model->lengths = g_new(int, length_count + 1); @@ -249,8 +254,10 @@ e_select_names_text_model_model_changed (ESelectNamesModel *source, *(stringp++) = ','; *(lengthsp++) = this_length; } - stringp --; - *stringp = 0; + if (stringp != string) { + stringp --; + *stringp = 0; + } *lengthsp = -1; g_free(E_TEXT_MODEL(model)->text); E_TEXT_MODEL(model)->text = string; diff --git a/addressbook/gui/component/select-names/e-select-names.c b/addressbook/gui/component/select-names/e-select-names.c index a588b10770..555f195514 100644 --- a/addressbook/gui/component/select-names/e-select-names.c +++ b/addressbook/gui/component/select-names/e-select-names.c @@ -168,6 +168,17 @@ set_current_selection(ETable *table, int row, ESelectNames *names) names->currently_selected = row; } +static void +e_select_names_clicked(ESelectNames *dialog, gint button, ESelectNames *data) +{ + switch(button) { + case 0: + break; + case 1: + break; + } +} + static void e_select_names_init (ESelectNames *e_select_names) { @@ -194,6 +205,9 @@ e_select_names_init (ESelectNames *e_select_names) GNOME_STOCK_BUTTON_CANCEL, NULL); + gtk_signal_connect(GTK_OBJECT(e_select_names), "clicked", + GTK_SIGNAL_FUNC(e_select_names_clicked), e_select_names); + e_select_names->table = E_TABLE(glade_xml_get_widget(gui, "table-source")); e_select_names->model = gtk_object_get_data(GTK_OBJECT(e_select_names->table), "model"); @@ -292,6 +306,17 @@ button_clicked(GtkWidget *button, ESelectNamesChild *child) } } +static void +remove_address(ETable *table, int row, ESelectNamesChild *child) +{ + EIterator *iterator = e_list_get_iterator(e_select_names_model_get_data(child->source)); + e_iterator_reset(iterator); + for (; row > 0; row--) { + e_iterator_next(iterator); + } + e_select_names_model_remove_item(child->source, iterator); +} + void e_select_names_add_section(ESelectNames *e_select_names, char *name, char *id, ESelectNamesModel *source) { @@ -340,6 +365,9 @@ e_select_names_add_section(ESelectNames *e_select_names, char *name, char *id, E g_str_compare, TRUE), 0); etable = e_table_new (header, model, SPEC2); + gtk_signal_connect(GTK_OBJECT(etable), "double_click", + GTK_SIGNAL_FUNC(remove_address), child); + gtk_object_set(GTK_OBJECT(etable), "cursor_mode", E_TABLE_CURSOR_LINE, NULL); diff --git a/addressbook/gui/component/select-names/select-names.glade b/addressbook/gui/component/select-names/select-names.glade index 46da911228..90ca93bd3a 100644 --- a/addressbook/gui/component/select-names/select-names.glade +++ b/addressbook/gui/component/select-names/select-names.glade @@ -114,6 +114,7 @@ GtkEntry entry-find + False True True True @@ -130,6 +131,7 @@ GtkButton button-find + False True @@ -143,7 +145,7 @@ GtkAccelLabel accellabel1 - + GTK_JUSTIFY_LEFT False 0 diff --git a/addressbook/gui/component/select-names/select-names.glade.h b/addressbook/gui/component/select-names/select-names.glade.h index a21ddce689..1cb9702956 100644 --- a/addressbook/gui/component/select-names/select-names.glade.h +++ b/addressbook/gui/component/select-names/select-names.glade.h @@ -6,5 +6,5 @@ gchar *s = N_("Select Names"); gchar *s = N_("Find..."); -gchar *s = N_("T_ype name or select from List:"); +gchar *s = N_("Select name from List:"); gchar *s = N_("Message Recipients"); -- cgit v1.2.3