aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook/gui/component/select-names/e-select-names-manager.c
diff options
context:
space:
mode:
authorChristopher James Lahey <clahey@helixcode.com>2000-07-09 18:42:20 +0800
committerChris Lahey <clahey@src.gnome.org>2000-07-09 18:42:20 +0800
commitabd6ce3b53f239441f5a655a362d057e16622b62 (patch)
tree5ba8625433f5ad981de03e71e8e1c8668423de3f /addressbook/gui/component/select-names/e-select-names-manager.c
parent4bd225790a301c68d7a5df24617f071881d705b9 (diff)
downloadgsoc2013-evolution-abd6ce3b53f239441f5a655a362d057e16622b62.tar
gsoc2013-evolution-abd6ce3b53f239441f5a655a362d057e16622b62.tar.gz
gsoc2013-evolution-abd6ce3b53f239441f5a655a362d057e16622b62.tar.bz2
gsoc2013-evolution-abd6ce3b53f239441f5a655a362d057e16622b62.tar.lz
gsoc2013-evolution-abd6ce3b53f239441f5a655a362d057e16622b62.tar.xz
gsoc2013-evolution-abd6ce3b53f239441f5a655a362d057e16622b62.tar.zst
gsoc2013-evolution-abd6ce3b53f239441f5a655a362d057e16622b62.zip
Removed unused do_nothing_cb function.
2000-07-09 Christopher James Lahey <clahey@helixcode.com> * gui/component/addressbook.c: Removed unused do_nothing_cb function. * gui/component/select-names/e-select-names-manager.c, gui/component/select-names/e-select-names-manager.h: Made the OK and Cancel buttons in the ESelectNames dialog we create work properly. * gui/component/select-names/e-select-names-model.c, gui/component/select-names/e-select-names-model.h: Added e_select_names_model_duplicate. * gui/component/select-names/e-select-names-text-model.c: Made the text be set correctly if there's already data in the source when the text model is created. * gui/component/select-names/e-select-names.c, gui/component/select-names/e-select-names.h: Removed handling of the buttons (the user of this dialog will have to handle them.) Added e_select_names_get_source. Fixed some typos. svn path=/trunk/; revision=4007
Diffstat (limited to 'addressbook/gui/component/select-names/e-select-names-manager.c')
-rw-r--r--addressbook/gui/component/select-names/e-select-names-manager.c112
1 files changed, 107 insertions, 5 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 9b19fbe3f7..b67ea282e9 100644
--- a/addressbook/gui/component/select-names/e-select-names-manager.c
+++ b/addressbook/gui/component/select-names/e-select-names-manager.c
@@ -31,6 +31,11 @@ typedef struct {
ESelectNamesModel *model;
} ESelectNamesManagerSection;
+typedef struct {
+ char *id;
+ EEntry *entry;
+} ESelectNamesManagerEntry;
+
static void e_select_names_manager_init (ESelectNamesManager *manager);
static void e_select_names_manager_class_init (ESelectNamesManagerClass *klass);
@@ -110,6 +115,7 @@ e_select_names_manager_destroy (GtkObject *object)
manager = E_SELECT_NAMES_MANAGER (object);
gtk_object_unref(GTK_OBJECT(manager->sections));
+ gtk_object_unref(GTK_OBJECT(manager->entries));
}
@@ -172,6 +178,30 @@ section_free(void *sec, void *data)
g_free(section);
}
+static void *
+entry_copy(const void *ent, void *data)
+{
+ const ESelectNamesManagerEntry *entry = ent;
+ ESelectNamesManagerEntry *newent;
+
+ newent = g_new(ESelectNamesManagerEntry, 1);
+ newent->id = g_strdup(entry->id);
+ newent->entry = entry->entry;
+ if (newent->entry)
+ gtk_object_ref(GTK_OBJECT(newent->entry));
+ return newent;
+}
+
+static void
+entry_free(void *ent, void *data)
+{
+ ESelectNamesManagerEntry *entry = ent;
+ g_free(entry->id);
+ if (entry->entry)
+ gtk_object_unref(GTK_OBJECT(entry->entry));
+ g_free(entry);
+}
+
/**
* e_select_names_manager_init:
*/
@@ -179,6 +209,7 @@ static void
e_select_names_manager_init (ESelectNamesManager *manager)
{
manager->sections = e_list_new(section_copy, section_free, manager);
+ manager->entries = e_list_new(entry_copy, entry_free, manager);
}
void e_select_names_manager_add_section (ESelectNamesManager *manager,
@@ -195,29 +226,96 @@ void e_select_names_manager_add_section (
section_free(section, manager);
}
+static void
+entry_destroyed(EEntry *entry, ESelectNamesManager *manager)
+{
+ if(!GTK_OBJECT_DESTROYED(manager)) {
+ EIterator *iterator = e_list_get_iterator(manager->entries);
+ for (e_iterator_reset(iterator); e_iterator_is_valid(iterator); e_iterator_next(iterator)) {
+ const ESelectNamesManagerEntry *this_entry = e_iterator_get(iterator);
+ if(entry == this_entry->entry) {
+ e_iterator_delete(iterator);
+ break;
+ }
+ }
+ }
+ gtk_object_unref(GTK_OBJECT(manager));
+}
+
GtkWidget *e_select_names_manager_create_entry (ESelectNamesManager *manager,
const char *id)
{
- GtkWidget *entry;
ETextModel *model;
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)) {
- entry = GTK_WIDGET(e_entry_new());
+ ESelectNamesManagerEntry *entry;
+ EEntry *eentry;
+ eentry = E_ENTRY(e_entry_new());
+
+ entry = g_new(ESelectNamesManagerEntry, 1);
+ entry->entry = eentry;
+ entry->id = (char *)id;
model = e_select_names_text_model_new(section->model);
- gtk_object_set(GTK_OBJECT(entry),
+ e_list_append(manager->entries, entry);
+ g_free(entry);
+
+ gtk_object_set(GTK_OBJECT(eentry),
"model", model,
"editable", TRUE,
"use_ellipsis", TRUE,
NULL);
- return entry;
+ gtk_signal_connect(GTK_OBJECT(eentry), "destroy",
+ GTK_SIGNAL_FUNC(entry_destroyed), manager);
+ gtk_object_ref(GTK_OBJECT(manager));
+ return GTK_WIDGET(eentry);
}
}
return NULL;
}
+static void
+e_select_names_clicked(ESelectNames *dialog, gint button, ESelectNamesManager *manager)
+{
+ switch(button) {
+ case 0: {
+ EList *list = manager->sections;
+ EIterator *iterator = e_list_get_iterator(list);
+ for (e_iterator_reset(iterator); e_iterator_is_valid(iterator); e_iterator_next(iterator)) {
+ ESelectNamesManagerSection *section = (void *) e_iterator_get(iterator);
+ ESelectNamesModel *source = e_select_names_get_source(dialog, section->id);
+ if (section->model)
+ gtk_object_unref(GTK_OBJECT(section->model));
+ section->model = source;
+ /* Don't ref because get_source returns a conceptual ref_count of 1. */
+ }
+ gtk_object_unref(GTK_OBJECT(iterator));
+
+ list = manager->entries;
+ iterator = e_list_get_iterator(list);
+ for (e_iterator_reset(iterator); e_iterator_is_valid(iterator); e_iterator_next(iterator)) {
+ ESelectNamesManagerEntry *entry = (void *) e_iterator_get(iterator);
+ ESelectNamesModel *source = e_select_names_get_source(dialog, entry->id);
+ if (source) {
+ ETextModel *model = e_select_names_text_model_new(source);
+ if (model) {
+ gtk_object_set(GTK_OBJECT(entry->entry),
+ "model", model,
+ NULL);
+ gtk_object_unref(GTK_OBJECT(source));
+ }
+ gtk_object_unref(GTK_OBJECT(model));
+ }
+ }
+ gtk_object_unref(GTK_OBJECT(iterator));
+ break;
+ }
+ }
+ gnome_dialog_close(GNOME_DIALOG(dialog));
+}
+
void e_select_names_manager_activate_dialog (ESelectNamesManager *manager,
const char *id)
{
@@ -226,8 +324,12 @@ void e_select_names_manager_activate_dialog (
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);
+ ESelectNamesModel *newmodel = e_select_names_model_duplicate(section->model);
+ e_select_names_add_section(names, section->id, section->title, newmodel);
+ gtk_object_unref(GTK_OBJECT(newmodel));
}
+ gtk_signal_connect(GTK_OBJECT(names), "clicked",
+ GTK_SIGNAL_FUNC(e_select_names_clicked), manager);
gtk_widget_show(GTK_WIDGET(names));
}