aboutsummaryrefslogtreecommitdiffstats
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
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
-rw-r--r--addressbook/ChangeLog23
-rw-r--r--addressbook/gui/component/addressbook.c6
-rw-r--r--addressbook/gui/component/select-names/e-select-names-manager.c112
-rw-r--r--addressbook/gui/component/select-names/e-select-names-manager.h1
-rw-r--r--addressbook/gui/component/select-names/e-select-names-model.c16
-rw-r--r--addressbook/gui/component/select-names/e-select-names-model.h1
-rw-r--r--addressbook/gui/component/select-names/e-select-names-text-model.c1
-rw-r--r--addressbook/gui/component/select-names/e-select-names.c33
-rw-r--r--addressbook/gui/component/select-names/e-select-names.h20
9 files changed, 177 insertions, 36 deletions
diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog
index af81f03a56..300a089533 100644
--- a/addressbook/ChangeLog
+++ b/addressbook/ChangeLog
@@ -1,3 +1,26 @@
+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.
+
2000-07-09 Not Zed <NotZed@HelixCode.com>
* gui/component/addressbook.c: Link the toolbar print button to
diff --git a/addressbook/gui/component/addressbook.c b/addressbook/gui/component/addressbook.c
index b41aa08a03..4929963689 100644
--- a/addressbook/gui/component/addressbook.c
+++ b/addressbook/gui/component/addressbook.c
@@ -90,12 +90,6 @@ control_deactivate (BonoboControl *control, BonoboUIHandler *uih)
}
static void
-do_nothing_cb (BonoboUIHandler *uih, void *user_data, const char *path)
-{
- g_print ("Yow! I am called back!\n");
-}
-
-static void
card_added_cb (EBook* book, EBookStatus status, const char *id,
gpointer user_data)
{
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));
}
diff --git a/addressbook/gui/component/select-names/e-select-names-manager.h b/addressbook/gui/component/select-names/e-select-names-manager.h
index f2423e667b..b05348ae79 100644
--- a/addressbook/gui/component/select-names/e-select-names-manager.h
+++ b/addressbook/gui/component/select-names/e-select-names-manager.h
@@ -27,6 +27,7 @@ struct _ESelectNamesManager {
GtkObject object;
EList *sections;
+ EList *entries;
};
struct _ESelectNamesManagerClass {
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 94fb3d980a..fcf945259a 100644
--- a/addressbook/gui/component/select-names/e-select-names-model.c
+++ b/addressbook/gui/component/select-names/e-select-names-model.c
@@ -81,6 +81,22 @@ e_select_names_model_new (void)
return model;
}
+/**
+ * e_select_names_model_new:
+ * @VCard: a string in vCard format
+ *
+ * Returns: a new #ESelectNamesModel that wraps the @VCard.
+ */
+ESelectNamesModel *
+e_select_names_model_duplicate (ESelectNamesModel *old)
+{
+ ESelectNamesModel *model = E_SELECT_NAMES_MODEL(gtk_type_new(e_select_names_model_get_type()));
+ model->data = e_list_duplicate(old->data);
+ model->id = g_strdup(old->id);
+ model->title = g_strdup(old->title);
+ return model;
+}
+
static void
e_select_names_model_class_init (ESelectNamesModelClass *klass)
{
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 6dd36e51fa..4ea1bdc8db 100644
--- a/addressbook/gui/component/select-names/e-select-names-model.h
+++ b/addressbook/gui/component/select-names/e-select-names-model.h
@@ -53,6 +53,7 @@ struct _ESelectNamesModelClass {
};
ESelectNamesModel *e_select_names_model_new (void);
+ESelectNamesModel *e_select_names_model_duplicate (ESelectNamesModel *old);
/* These lengths are allowed to go over objects and act just like the text model does. */
void e_select_names_model_insert (ESelectNamesModel *model,
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 7fa7b87892..71934c46dc 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
@@ -84,6 +84,7 @@ e_select_names_text_model_new (ESelectNamesModel *source)
gtk_object_set(GTK_OBJECT(model),
"source", source,
NULL);
+ e_select_names_text_model_model_changed (source, E_SELECT_NAMES_TEXT_MODEL(model));
return model;
}
diff --git a/addressbook/gui/component/select-names/e-select-names.c b/addressbook/gui/component/select-names/e-select-names.c
index 172f3e0d83..90b64b1183 100644
--- a/addressbook/gui/component/select-names/e-select-names.c
+++ b/addressbook/gui/component/select-names/e-select-names.c
@@ -169,18 +169,6 @@ set_current_selection(ETable *table, int row, ESelectNames *names)
}
static void
-e_select_names_clicked(ESelectNames *dialog, gint button, ESelectNames *data)
-{
- switch(button) {
- case 0:
- break;
- case 1:
- break;
- }
- gnome_dialog_close(GNOME_DIALOG(dialog));
-}
-
-static void
e_select_names_init (ESelectNames *e_select_names)
{
GladeXML *gui;
@@ -206,9 +194,6 @@ 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");
@@ -341,11 +326,12 @@ e_select_names_add_section(ESelectNames *e_select_names, char *name, char *id, E
child = g_new(ESelectNamesChild, 1);
child->names = e_select_names;
+ child->title = g_strdup(_(name));
e_select_names->child_count++;
alignment = gtk_alignment_new(0, 0, 1, 0);
- label = g_strdup_printf("%s ->", _(name));
+ label = g_strdup_printf("%s ->", child->title);
button = gtk_button_new_with_label(label);
g_free(label);
gtk_container_add(GTK_CONTAINER(alignment), button);
@@ -386,6 +372,8 @@ e_select_names_add_section(ESelectNames *e_select_names, char *name, char *id, E
e_select_names->child_count + 1,
GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_EXPAND,
0, 0);
+
+ g_hash_table_insert(e_select_names->children, g_strdup(id), child);
}
static void *
@@ -422,3 +410,16 @@ e_select_names_get_section(ESelectNames *e_select_names, char *id)
}
return list;
}
+
+ESelectNamesModel *
+e_select_names_get_source(ESelectNames *e_select_names,
+ char *id)
+{
+ ESelectNamesChild *child = g_hash_table_lookup(e_select_names->children, id);
+ if (child) {
+ if (child->source)
+ gtk_object_ref(GTK_OBJECT(child->source));
+ return child->source;
+ } else
+ return NULL;
+}
diff --git a/addressbook/gui/component/select-names/e-select-names.h b/addressbook/gui/component/select-names/e-select-names.h
index c0d37aec9a..369996eb43 100644
--- a/addressbook/gui/component/select-names/e-select-names.h
+++ b/addressbook/gui/component/select-names/e-select-names.h
@@ -46,7 +46,6 @@ extern "C" {
#define E_IS_SELECT_NAMES(obj) (GTK_CHECK_TYPE ((obj), E_SELECT_NAMES_TYPE))
#define E_IS_SELECT_NAMES_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), E_SELECT_NAMES_TYPE))
-
typedef struct _ESelectNames ESelectNames;
typedef struct _ESelectNamesClass ESelectNamesClass;
@@ -70,15 +69,18 @@ struct _ESelectNamesClass
};
-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,
- ESelectNamesModel *source);
+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,
+ ESelectNamesModel *source);
+ESelectNamesModel *e_select_names_get_source (ESelectNames *e_select_names,
+ char *id);
/* Returns a ref counted list of addresses. */
-EList *e_select_names_get_section (ESelectNames *e_select_names,
- char *id);
+EList *e_select_names_get_section (ESelectNames *e_select_names,
+ char *id);
#ifdef __cplusplus
}