aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook
diff options
context:
space:
mode:
Diffstat (limited to 'addressbook')
-rw-r--r--addressbook/ChangeLog34
-rw-r--r--addressbook/gui/component/addressbook.c42
-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
11 files changed, 224 insertions, 25 deletions
diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog
index 61b0e1025e..5fca8a3f10 100644
--- a/addressbook/ChangeLog
+++ b/addressbook/ChangeLog
@@ -1,3 +1,37 @@
+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.
+
2000-07-06 Chris Toshok <toshok@helixcode.com>
* gui/component/e-ldap-storage.h: add scope to ELDAPServer, and
diff --git a/addressbook/gui/component/addressbook.c b/addressbook/gui/component/addressbook.c
index f248e1e4bd..134365f6e8 100644
--- a/addressbook/gui/component/addressbook.c
+++ b/addressbook/gui/component/addressbook.c
@@ -27,6 +27,7 @@
#include <e-addressbook-model.h>
#include <select-names/e-select-names.h>
+#include <select-names/e-select-names-manager.h>
#include "e-contact-editor.h"
#include "e-contact-save-as.h"
#include "e-ldap-server-dialog.h"
@@ -194,10 +195,10 @@ new_server_cb (BonoboUIHandler *uih, void *user_data, const char *path)
/* fill in the defaults */
server->name = g_strdup("");
server->host = g_strdup("");
- server->port = 389;
+ server->port = g_strdup_printf("%d", 389);
server->description = g_strdup("");
server->rootdn = g_strdup("");
- server->uri = g_strdup_printf ("ldap://%s:%d/%s", server->host, server->port, server->rootdn);
+ server->uri = g_strdup_printf ("ldap://%s:%s/%s", server->host, server->port, server->rootdn);
e_ldap_server_editor_show (server);
if (view->view)
@@ -408,14 +409,41 @@ print_cb (BonoboUIHandler *uih, void *user_data, const char *path)
}
static void
+open_dialog(GtkWidget *button, ESelectNamesManager *manager)
+{
+ char *id = gtk_object_get_data(GTK_OBJECT(button), "id");
+ e_select_names_manager_activate_dialog(manager, id);
+}
+
+static void
test_select_names_cb (BonoboUIHandler *uih, void *user_data, const char *path)
{
- ESelectNames *names = E_SELECT_NAMES(e_select_names_new());
+ ESelectNamesManager *manager = e_select_names_manager_new();
+ GtkWidget *window;
+ GtkWidget *table;
+ int row = 0;
+ char *sections[] = {"to", "from", "cc"};
+ char *titles[] = {N_("To"), N_("From"), N_("Cc")};
+
+ for (row = 0; row < 3; row ++)
+ e_select_names_manager_add_section(manager, sections[row], _(titles[row]));
+
+
+ window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+ table = gtk_table_new(3, 2, FALSE);
- e_select_names_add_section(names, _("To"), "to");
- e_select_names_add_section(names, _("From"), "from");
- e_select_names_add_section(names, _("Cc"), "cc");
- gtk_widget_show(GTK_WIDGET(names));
+ for (row = 0; row < 3; row ++) {
+ GtkWidget *button = gtk_button_new_with_label(_(titles[row]));
+ GtkWidget *entry = e_select_names_manager_create_entry(manager, sections[row]);
+
+ gtk_object_set_data(GTK_OBJECT(button), "id", g_strdup(sections[row]));
+ gtk_signal_connect(GTK_OBJECT(button), "clicked",
+ GTK_SIGNAL_FUNC(open_dialog), manager);
+ gtk_table_attach(GTK_TABLE(table), button, 0, 1, row, row + 1, GTK_FILL, GTK_FILL, 0, 0);
+ gtk_table_attach(GTK_TABLE(table), entry, 1, 2, row, row + 1, GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0);
+ }
+ gtk_container_add(GTK_CONTAINER(window), table);
+ gtk_widget_show_all(window);
}
static GnomeUIInfo gnome_toolbar [] = {
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);