aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook/gui/component/select-names
diff options
context:
space:
mode:
authorChristopher James Lahey <clahey@helixcode.com>2000-07-08 00:14:27 +0800
committerChris Lahey <clahey@src.gnome.org>2000-07-08 00:14:27 +0800
commit661cc2d0ef7f97a064543032b088d5092c36b4cb (patch)
treedd22ad7aca692e439e66c55ce56968bff64fa8c9 /addressbook/gui/component/select-names
parenta4a1a93648db15b869ee67a19b7aad1873b5f9c7 (diff)
downloadgsoc2013-evolution-661cc2d0ef7f97a064543032b088d5092c36b4cb.tar.gz
gsoc2013-evolution-661cc2d0ef7f97a064543032b088d5092c36b4cb.tar.zst
gsoc2013-evolution-661cc2d0ef7f97a064543032b088d5092c36b4cb.zip
Since ELDAPServer->port is a char *, allocate a string with the number 389
2000-07-07 Christopher James Lahey <clahey@helixcode.com> * gui/component/addressbook.c (new_server_cb): Since ELDAPServer->port is a char *, allocate a string with the number 389 contained. * gui/component/addressbook.c: Make the select names test test the new code instead of the old way of getting to an ESelectNames dialog. * gui/component/select-names/e-select-names-manager.c: Coded storing the model for each section, creating an entry and returning it, and for activating the dialog. Wrote a bit of the get_cards code, but not all of it. * gui/component/select-names/e-select-names-model.c, gui/component/select-names/e-select-names-model.h: Coded all of the code needed to make ESelectNamesTextModel work (it doesn't yet, but all the code should be there.) Removed E_SELECT_NAMES_MODEL_DATA_TYPE_SEPARATION_MATERIAL. * gui/component/select-names/e-select-names-table-model.c, gui/component/select-names/e-select-names-text-model.c: Changed these to compensate for removal of E_SELECT_NAMES_MODEL_DATA_TYPE_SEPARATION_MATERIAL. * gui/component/select-names/e-select-names-table-model.h, gui/component/select-names/e-select-names-text-model.h: Fixed some silly typos. * gui/component/select-names/e-select-names.c, gui/component/select-names/e-select-names.h: Added a parameter to add_section that lets you specify the source ESelectNamesModel. svn path=/trunk/; revision=3948
Diffstat (limited to 'addressbook/gui/component/select-names')
-rw-r--r--addressbook/gui/component/select-names/e-select-names-manager.c25
-rw-r--r--addressbook/gui/component/select-names/e-select-names-model.c115
-rw-r--r--addressbook/gui/component/select-names/e-select-names-model.h1
-rw-r--r--addressbook/gui/component/select-names/e-select-names-table-model.c7
-rw-r--r--addressbook/gui/component/select-names/e-select-names-table-model.h2
-rw-r--r--addressbook/gui/component/select-names/e-select-names-text-model.c12
-rw-r--r--addressbook/gui/component/select-names/e-select-names-text-model.h2
-rw-r--r--addressbook/gui/component/select-names/e-select-names.c5
-rw-r--r--addressbook/gui/component/select-names/e-select-names.h4
9 files changed, 155 insertions, 18 deletions
diff --git a/addressbook/gui/component/select-names/e-select-names-manager.c b/addressbook/gui/component/select-names/e-select-names-manager.c
index ac59787932..2eea09f985 100644
--- a/addressbook/gui/component/select-names/e-select-names-manager.c
+++ b/addressbook/gui/component/select-names/e-select-names-manager.c
@@ -15,6 +15,7 @@
#include "e-select-names-manager.h"
#include "e-select-names-model.h"
#include "e-select-names-text-model.h"
+#include "e-select-names.h"
#include "widgets/e-text/e-entry.h"
/* Object argument IDs */
@@ -154,6 +155,9 @@ section_copy(const void *sec, void *data)
newsec = g_new(ESelectNamesManagerSection, 1);
newsec->id = g_strdup(section->id);
newsec->title = g_strdup(section->title);
+ newsec->model = section->model;
+ if (newsec->model)
+ gtk_object_ref(GTK_OBJECT(newsec->model));
return newsec;
}
@@ -163,6 +167,8 @@ section_free(void *sec, void *data)
ESelectNamesManagerSection *section = sec;
g_free(section->id);
g_free(section->title);
+ if (section->model)
+ gtk_object_unref(GTK_OBJECT(section->model));
g_free(section);
}
@@ -184,6 +190,7 @@ void e_select_names_manager_add_section (
section = g_new(ESelectNamesManagerSection, 1);
section->id = g_strdup(id);
section->title = g_strdup(title);
+ section->model = e_select_names_model_new();
e_list_append(manager->sections, section);
section_free(section, manager);
}
@@ -195,7 +202,7 @@ GtkWidget *e_select_names_manager_create_entry (
ETextModel *model;
EIterator *iterator;
iterator = e_list_get_iterator(manager->sections);
- for (; e_iterator_is_valid(iterator); e_iterator_next(iterator)) {
+ for (e_iterator_reset(iterator); e_iterator_is_valid(iterator); e_iterator_next(iterator)) {
const ESelectNamesManagerSection *section = e_iterator_get(iterator);
if (!strcmp(section->id, id)) {
entry = GTK_WIDGET(e_entry_new());
@@ -212,11 +219,27 @@ GtkWidget *e_select_names_manager_create_entry (
void e_select_names_manager_activate_dialog (ESelectNamesManager *manager,
char *id)
{
+ ESelectNames *names = E_SELECT_NAMES(e_select_names_new());
+ EIterator *iterator;
+ iterator = e_list_get_iterator(manager->sections);
+ for (e_iterator_reset(iterator); e_iterator_is_valid(iterator); e_iterator_next(iterator)) {
+ const ESelectNamesManagerSection *section = e_iterator_get(iterator);
+ e_select_names_add_section(names, section->id, section->title, section->model);
+ }
+ gtk_widget_show(GTK_WIDGET(names));
}
/* Of type ECard */
EList *e_select_names_manager_get_cards (ESelectNamesManager *manager,
char *id)
{
+ EIterator *iterator;
+ iterator = e_list_get_iterator(manager->sections);
+ for (e_iterator_reset(iterator); e_iterator_is_valid(iterator); e_iterator_next(iterator)) {
+ const ESelectNamesManagerSection *section = e_iterator_get(iterator);
+ if (!strcmp(section->id, id)) {
+
+ }
+ }
return NULL;
}
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 f819a1197e..5bf9562646 100644
--- a/addressbook/gui/component/select-names/e-select-names-model.c
+++ b/addressbook/gui/component/select-names/e-select-names-model.c
@@ -199,12 +199,56 @@ EList *e_select_names_model_get_data (ESelect
return model->data;
}
+static void
+e_select_names_model_changed (ESelectNamesModel *model)
+{
+ gtk_signal_emit(GTK_OBJECT(model),
+ e_select_names_model_signals[E_SELECT_NAMES_MODEL_CHANGED]);
+}
+
void
e_select_names_model_insert (ESelectNamesModel *model,
- EIterator *iterator, /* Must be one of the iterators in the model. */
+ EIterator *iterator, /* Must be one of the iterators in the model, or NULL if the list is empty. */
int index,
char *data)
{
+ gchar **strings = g_strsplit(data, ",", -1);
+ int i;
+ 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;
+ }
+ if (strings[0]) {
+ ESelectNamesModelData *node = (void *) e_iterator_get(iterator);
+ gchar *temp = g_strdup_printf("%.*s%s%s", index, node->string, strings[0], node->string + index);
+ g_free(node->string);
+ node->string = temp;
+ }
+ for (i = 0; strings[i]; i++) {
+ ESelectNamesModelData *node = (void *) e_iterator_get(iterator);
+ gchar *temp = g_strdup_printf("%.*s", index, node->string);
+ gchar *temp2 = g_strdup_printf("%s%s", strings[0], node->string + index);
+
+ g_free(node->string);
+ node->type = E_SELECT_NAMES_MODEL_DATA_TYPE_STRING_ADDRESS;
+ node->string = temp;
+ if (node->card)
+ gtk_object_unref(GTK_OBJECT(node->card));
+ node->card = NULL;
+
+ node = g_new(ESelectNamesModelData, 1);
+ node->type = E_SELECT_NAMES_MODEL_DATA_TYPE_STRING_ADDRESS;
+ node->card = NULL;
+ node->string = temp2;
+ e_iterator_insert(iterator, node, 0);
+ g_free(node->string);
+ g_free(node);
+ }
+ e_select_names_model_changed(model);
}
void
@@ -214,6 +258,11 @@ e_select_names_model_insert_length (ESelectNamesModel *model,
char *data,
int length)
{
+ gchar *string = g_new(char, length + 1);
+ strncpy(string, data, length);
+ string[length] = 0;
+ e_select_names_model_insert(model, iterator, index, string);
+ g_free(string);
}
void
@@ -222,15 +271,77 @@ e_select_names_model_delete (ESelectNamesModel *model,
int index,
int length)
{
+ while (length > 0 && e_iterator_is_valid(iterator)) {
+ ESelectNamesModelData *node = (void *) e_iterator_get(iterator);
+ int this_length = strlen(node->string);
+ if (this_length <= index + length) {
+ gchar *temp = g_strdup_printf("%.*s", index, node->string);
+ g_free(node->string);
+ node->string = temp;
+ length -= this_length - index;
+ } else {
+ gchar *temp = g_strdup_printf("%.*s%s", index, node->string, node->string + index + length);
+ g_free(node->string);
+ node->string = temp;
+ length = 0;
+ }
+
+ if (length > 0) {
+ e_iterator_next(iterator);
+ if (e_iterator_is_valid(iterator)) {
+ ESelectNamesModelData *node2 = (void *) e_iterator_get(iterator);
+ gchar *temp = g_strdup_printf("%s%s", node->string, node2->string);
+ g_free(node2->string);
+ node2->string = temp;
+ e_iterator_prev(iterator);
+ e_iterator_delete(iterator);
+ }
+ }
+ }
+ e_select_names_model_changed(model);
}
void
e_select_names_model_replace (ESelectNamesModel *model,
EIterator *iterator, /* Must be one of the iterators in the model. */
int index,
- int replacement_length,
+ int length,
char *data)
{
+ while (length > 0 && e_iterator_is_valid(iterator)) {
+ ESelectNamesModelData *node = (void *) e_iterator_get(iterator);
+ int this_length = strlen(node->string);
+ if (this_length <= index + length) {
+ gchar *temp = g_strdup_printf("%.*s", index, node->string);
+ g_free(node->string);
+ node->string = temp;
+ length -= this_length - index;
+ } else {
+ gchar *temp = g_strdup_printf("%.*s%s", index, node->string, node->string + index + length);
+ g_free(node->string);
+ node->string = temp;
+ length = 0;
+ }
+
+ if (length > 0) {
+ e_iterator_next(iterator);
+ if (e_iterator_is_valid(iterator)) {
+ ESelectNamesModelData *node2 = (void *) e_iterator_get(iterator);
+ gchar *temp = g_strdup_printf("%s%s", node->string, node2->string);
+ g_free(node2->string);
+ node2->string = temp;
+ e_iterator_prev(iterator);
+ e_iterator_delete(iterator);
+ }
+ }
+ }
+ if (!e_iterator_is_valid(iterator)) {
+ ESelectNamesModelData *node;
+ e_iterator_last(iterator);
+ node = (void *) e_iterator_get(iterator);
+ index = strlen(node->string);
+ }
+ e_select_names_model_insert (model, iterator, index, data);
}
diff --git a/addressbook/gui/component/select-names/e-select-names-model.h b/addressbook/gui/component/select-names/e-select-names-model.h
index 313b4dee25..6dd36e51fa 100644
--- a/addressbook/gui/component/select-names/e-select-names-model.h
+++ b/addressbook/gui/component/select-names/e-select-names-model.h
@@ -29,7 +29,6 @@ typedef struct _ESelectNamesModelClass ESelectNamesModelClass;
enum _ESelectNamesModelDataType {
E_SELECT_NAMES_MODEL_DATA_TYPE_CARD,
E_SELECT_NAMES_MODEL_DATA_TYPE_STRING_ADDRESS,
- E_SELECT_NAMES_MODEL_DATA_TYPE_SEPARATION_MATERIAL,
};
struct _ESelectNamesModelData {
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 7f4d916435..2109eea0a0 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
@@ -111,10 +111,7 @@ fill_in_info (ESelectNamesTableModel *model)
EIterator *iterator = e_list_get_iterator(list);
int count = 0;
for (e_iterator_reset(iterator); e_iterator_is_valid(iterator); e_iterator_next(iterator)) {
- const ESelectNamesModelData *data = e_iterator_get(iterator);
- if (data->type != E_SELECT_NAMES_MODEL_DATA_TYPE_SEPARATION_MATERIAL) {
- count ++;
- }
+ count ++;
}
model->count = count;
model->data = g_new(ESelectNamesTableModelData, count);
@@ -135,8 +132,6 @@ fill_in_info (ESelectNamesTableModel *model)
model->data[count].email = g_strdup(data->string);
count ++;
break;
- case E_SELECT_NAMES_MODEL_DATA_TYPE_SEPARATION_MATERIAL:
- break;
}
}
} else {
diff --git a/addressbook/gui/component/select-names/e-select-names-table-model.h b/addressbook/gui/component/select-names/e-select-names-table-model.h
index 9afc3f7a12..e0f0f5d804 100644
--- a/addressbook/gui/component/select-names/e-select-names-table-model.h
+++ b/addressbook/gui/component/select-names/e-select-names-table-model.h
@@ -40,7 +40,7 @@ struct _ESelectNamesTableModel {
};
struct _ESelectNamesTableModelClass {
- ETableModel parent_class;
+ ETableModelClass parent_class;
};
ETableModel *e_select_names_table_model_new (ESelectNamesModel *source);
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 abbbae3321..3838e974f6 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
@@ -146,7 +146,7 @@ e_select_names_text_model_insert (ETextModel *model, gint position, gchar
position,
text);
} else {
- position -= this_length;
+ position -= this_length + 1;
}
}
}
@@ -165,8 +165,9 @@ e_select_names_text_model_insert_length (ETextModel *model, gint position, gchar
position,
text,
length);
+ break;
} else {
- position -= this_length;
+ position -= this_length + 1;
}
}
}
@@ -184,8 +185,9 @@ e_select_names_text_model_delete (ETextModel *model, gint position, gint
iterator,
position,
length);
+ break;
} else {
- position -= this_length;
+ position -= this_length + 1;
}
}
}
@@ -204,8 +206,10 @@ e_select_names_text_model_model_changed (ESelectNamesModel *source,
for (e_iterator_reset(iterator); e_iterator_is_valid(iterator); e_iterator_next(iterator)) {
const ESelectNamesModelData *data = e_iterator_get(iterator);
length += strlen(data->string);
+ length ++;
length_count++;
}
+ length --;
g_free(model->lengths);
model->lengths = g_new(int, length_count + 1);
@@ -221,8 +225,10 @@ e_select_names_text_model_model_changed (ESelectNamesModel *source,
strcpy(stringp, data->string);
this_length = strlen(stringp);
stringp += this_length;
+ *(stringp++) = ',';
*(lengthsp++) = this_length;
}
+ stringp --;
*stringp = 0;
*lengthsp = -1;
g_free(E_TEXT_MODEL(model)->text);
diff --git a/addressbook/gui/component/select-names/e-select-names-text-model.h b/addressbook/gui/component/select-names/e-select-names-text-model.h
index 564886ffc9..aa23544251 100644
--- a/addressbook/gui/component/select-names/e-select-names-text-model.h
+++ b/addressbook/gui/component/select-names/e-select-names-text-model.h
@@ -33,7 +33,7 @@ struct _ESelectNamesTextModel {
};
struct _ESelectNamesTextModelClass {
- ETextModel parent_class;
+ ETextModelClass parent_class;
};
ETextModel *e_select_names_text_model_new (ESelectNamesModel *source);
diff --git a/addressbook/gui/component/select-names/e-select-names.c b/addressbook/gui/component/select-names/e-select-names.c
index c5791bb9bd..b5e366a953 100644
--- a/addressbook/gui/component/select-names/e-select-names.c
+++ b/addressbook/gui/component/select-names/e-select-names.c
@@ -28,6 +28,7 @@
#include <addressbook/gui/component/e-addressbook-model.h>
#include <addressbook/gui/component/e-cardlist-model.h>
#include <addressbook/backend/ebook/e-book.h>
+#include "e-select-names-table-model.h"
static void e_select_names_init (ESelectNames *card);
static void e_select_names_class_init (ESelectNamesClass *klass);
@@ -248,7 +249,7 @@ button_clicked(GtkWidget *button, ESelectNamesChild *child)
}
void
-e_select_names_add_section(ESelectNames *e_select_names, char *name, char *id)
+e_select_names_add_section(ESelectNames *e_select_names, char *name, char *id, ESelectNamesModel *source)
{
ESelectNamesChild *child;
GtkWidget *button;
@@ -288,7 +289,7 @@ e_select_names_add_section(ESelectNames *e_select_names, char *name, char *id)
GTK_FILL, GTK_FILL,
0, 0);
- model = e_cardlist_model_new();
+ model = e_select_names_table_model_new(source);
header = e_table_header_new ();
cell_left_just = e_cell_text_new (model, NULL, GTK_JUSTIFY_LEFT);
e_table_header_add_column (header, e_table_col_new (0, "Full Name", 1.0, 20, cell_left_just,
diff --git a/addressbook/gui/component/select-names/e-select-names.h b/addressbook/gui/component/select-names/e-select-names.h
index c9d4619db2..c0d37aec9a 100644
--- a/addressbook/gui/component/select-names/e-select-names.h
+++ b/addressbook/gui/component/select-names/e-select-names.h
@@ -25,6 +25,7 @@
#include <glade/glade.h>
#include <e-util/e-list.h>
#include <widgets/e-table/e-table.h>
+#include "e-select-names-model.h"
#ifdef __cplusplus
extern "C" {
@@ -73,7 +74,8 @@ GtkWidget *e_select_names_new (void);
GtkType e_select_names_get_type (void);
void e_select_names_add_section (ESelectNames *e_select_names,
char *name,
- char *id);
+ char *id,
+ ESelectNamesModel *source);
/* Returns a ref counted list of addresses. */
EList *e_select_names_get_section (ESelectNames *e_select_names,
char *id);