aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook
diff options
context:
space:
mode:
authorChristopher James Lahey <clahey@helixcode.com>2000-06-11 06:35:06 +0800
committerChris Lahey <clahey@src.gnome.org>2000-06-11 06:35:06 +0800
commit8139fd12a7fcc74935a4d318f0f9554f2e2b03c2 (patch)
tree41a8bd8640d637ac91a7fdeecbf790c291647c0b /addressbook
parentd8756e6c59a8f14ff603cecc671c14ba51fe6b4e (diff)
downloadgsoc2013-evolution-8139fd12a7fcc74935a4d318f0f9554f2e2b03c2.tar
gsoc2013-evolution-8139fd12a7fcc74935a4d318f0f9554f2e2b03c2.tar.gz
gsoc2013-evolution-8139fd12a7fcc74935a4d318f0f9554f2e2b03c2.tar.bz2
gsoc2013-evolution-8139fd12a7fcc74935a4d318f0f9554f2e2b03c2.tar.lz
gsoc2013-evolution-8139fd12a7fcc74935a4d318f0f9554f2e2b03c2.tar.xz
gsoc2013-evolution-8139fd12a7fcc74935a4d318f0f9554f2e2b03c2.tar.zst
gsoc2013-evolution-8139fd12a7fcc74935a4d318f0f9554f2e2b03c2.zip
Renamed a bunch of functions for better readability.
2000-06-10 Christopher James Lahey <clahey@helixcode.com> * gui/component/e-cardlist-model.c: Renamed a bunch of functions for better readability. * gui/component/e-select-names.c, gui/component/e-select-names.h: This should be a working dialog now. * gui/component/select-names.glade: Changed the name & creation function of the ETable here. svn path=/trunk/; revision=3514
Diffstat (limited to 'addressbook')
-rw-r--r--addressbook/ChangeLog11
-rw-r--r--addressbook/gui/component/e-cardlist-model.c64
-rw-r--r--addressbook/gui/component/e-select-names.c87
-rw-r--r--addressbook/gui/component/e-select-names.h4
-rw-r--r--addressbook/gui/component/select-names.glade6
5 files changed, 119 insertions, 53 deletions
diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog
index ecce5293ba..f9209657e6 100644
--- a/addressbook/ChangeLog
+++ b/addressbook/ChangeLog
@@ -1,5 +1,16 @@
2000-06-10 Christopher James Lahey <clahey@helixcode.com>
+ * gui/component/e-cardlist-model.c: Renamed a bunch of functions
+ for better readability.
+
+ * gui/component/e-select-names.c, gui/component/e-select-names.h:
+ This should be a working dialog now.
+
+ * gui/component/select-names.glade: Changed the name & creation
+ function of the ETable here.
+
+2000-06-10 Christopher James Lahey <clahey@helixcode.com>
+
* gui/component/select-names.glade,
gui/component/select-names.glade.h: Glade files for Select Names
dialog.
diff --git a/addressbook/gui/component/e-cardlist-model.c b/addressbook/gui/component/e-cardlist-model.c
index eb6793ec6f..032eb6c16c 100644
--- a/addressbook/gui/component/e-cardlist-model.c
+++ b/addressbook/gui/component/e-cardlist-model.c
@@ -17,7 +17,7 @@
#define PARENT_TYPE e_table_model_get_type()
static void
-addressbook_destroy(GtkObject *object)
+e_cardlist_model_destroy(GtkObject *object)
{
ECardlistModel *model = E_CARDLIST_MODEL(object);
int i;
@@ -30,44 +30,44 @@ addressbook_destroy(GtkObject *object)
/* This function returns the number of columns in our ETableModel. */
static int
-addressbook_col_count (ETableModel *etc)
+e_cardlist_model_col_count (ETableModel *etc)
{
return E_CARD_SIMPLE_FIELD_LAST;
}
/* This function returns the number of rows in our ETableModel. */
static int
-addressbook_row_count (ETableModel *etc)
+e_cardlist_model_row_count (ETableModel *etc)
{
- ECardlistModel *addressbook = E_CARDLIST_MODEL(etc);
- return addressbook->data_count;
+ ECardlistModel *e_cardlist_model = E_CARDLIST_MODEL(etc);
+ return e_cardlist_model->data_count;
}
/* This function returns the value at a particular point in our ETableModel. */
static void *
-addressbook_value_at (ETableModel *etc, int col, int row)
+e_cardlist_model_value_at (ETableModel *etc, int col, int row)
{
- ECardlistModel *addressbook = E_CARDLIST_MODEL(etc);
+ ECardlistModel *e_cardlist_model = E_CARDLIST_MODEL(etc);
const char *value;
- if ( col >= E_CARD_SIMPLE_FIELD_LAST - 1|| row >= addressbook->data_count )
+ if ( col >= E_CARD_SIMPLE_FIELD_LAST - 1|| row >= e_cardlist_model->data_count )
return NULL;
- value = e_card_simple_get_const(addressbook->data[row],
+ value = e_card_simple_get_const(e_cardlist_model->data[row],
col + 1);
return (void *)(value ? value : "");
}
/* This function sets the value at a particular point in our ETableModel. */
static void
-addressbook_set_value_at (ETableModel *etc, int col, int row, const void *val)
+e_cardlist_model_set_value_at (ETableModel *etc, int col, int row, const void *val)
{
- ECardlistModel *addressbook = E_CARDLIST_MODEL(etc);
+ ECardlistModel *e_cardlist_model = E_CARDLIST_MODEL(etc);
ECard *card;
- if ( col >= E_CARD_SIMPLE_FIELD_LAST - 1|| row >= addressbook->data_count )
+ if ( col >= E_CARD_SIMPLE_FIELD_LAST - 1|| row >= e_cardlist_model->data_count )
return;
- e_card_simple_set(addressbook->data[row],
+ e_card_simple_set(e_cardlist_model->data[row],
col + 1,
val);
- gtk_object_get(GTK_OBJECT(addressbook->data[row]),
+ gtk_object_get(GTK_OBJECT(e_cardlist_model->data[row]),
"card", &card,
NULL);
if ( !etc->frozen )
@@ -76,33 +76,33 @@ addressbook_set_value_at (ETableModel *etc, int col, int row, const void *val)
/* This function returns whether a particular cell is editable. */
static gboolean
-addressbook_is_cell_editable (ETableModel *etc, int col, int row)
+e_cardlist_model_is_cell_editable (ETableModel *etc, int col, int row)
{
return TRUE;
}
/* This function duplicates the value passed to it. */
static void *
-addressbook_duplicate_value (ETableModel *etc, int col, const void *value)
+e_cardlist_model_duplicate_value (ETableModel *etc, int col, const void *value)
{
return g_strdup(value);
}
/* This function frees the value passed to it. */
static void
-addressbook_free_value (ETableModel *etc, int col, void *value)
+e_cardlist_model_free_value (ETableModel *etc, int col, void *value)
{
g_free(value);
}
static void *
-addressbook_initialize_value (ETableModel *etc, int col)
+e_cardlist_model_initialize_value (ETableModel *etc, int col)
{
return g_strdup("");
}
static gboolean
-addressbook_value_is_empty (ETableModel *etc, int col, const void *value)
+e_cardlist_model_value_is_empty (ETableModel *etc, int col, const void *value)
{
return !(value && *(char *)value);
}
@@ -110,7 +110,7 @@ addressbook_value_is_empty (ETableModel *etc, int col, const void *value)
/* This function is for when the model is unfrozen. This can mostly
be ignored for simple models. */
static void
-addressbook_thaw (ETableModel *etc)
+e_cardlist_model_thaw (ETableModel *etc)
{
e_table_model_changed(etc);
}
@@ -157,18 +157,18 @@ e_cardlist_model_class_init (GtkObjectClass *object_class)
{
ETableModelClass *model_class = (ETableModelClass *) object_class;
- object_class->destroy = addressbook_destroy;
-
- model_class->column_count = addressbook_col_count;
- model_class->row_count = addressbook_row_count;
- model_class->value_at = addressbook_value_at;
- model_class->set_value_at = addressbook_set_value_at;
- model_class->is_cell_editable = addressbook_is_cell_editable;
- model_class->duplicate_value = addressbook_duplicate_value;
- model_class->free_value = addressbook_free_value;
- model_class->initialize_value = addressbook_initialize_value;
- model_class->value_is_empty = addressbook_value_is_empty;
- model_class->thaw = addressbook_thaw;
+ object_class->destroy = e_cardlist_model_destroy;
+
+ model_class->column_count = e_cardlist_model_col_count;
+ model_class->row_count = e_cardlist_model_row_count;
+ model_class->value_at = e_cardlist_model_value_at;
+ model_class->set_value_at = e_cardlist_model_set_value_at;
+ model_class->is_cell_editable = e_cardlist_model_is_cell_editable;
+ model_class->duplicate_value = e_cardlist_model_duplicate_value;
+ model_class->free_value = e_cardlist_model_free_value;
+ model_class->initialize_value = e_cardlist_model_initialize_value;
+ model_class->value_is_empty = e_cardlist_model_value_is_empty;
+ model_class->thaw = e_cardlist_model_thaw;
}
static void
diff --git a/addressbook/gui/component/e-select-names.c b/addressbook/gui/component/e-select-names.c
index 986a1102af..2f2d2abec2 100644
--- a/addressbook/gui/component/e-select-names.c
+++ b/addressbook/gui/component/e-select-names.c
@@ -45,8 +45,9 @@ enum {
};
typedef struct {
- char *title;
- ETableModel *model;
+ char *title;
+ ETableModel *model;
+ ESelectNames *names;
} ESelectNamesChild;
GtkType
@@ -107,7 +108,6 @@ set_book(EBook *book, EBookStatus status, ETableModel *model)
gtk_object_set(GTK_OBJECT(model),
"book", book,
NULL);
- gtk_object_unref(GTK_OBJECT(model));
gtk_object_unref(GTK_OBJECT(book));
}
@@ -118,6 +118,7 @@ e_addressbook_create_ebook_table(char *name, char *string1, char *string2, int n
ETableHeader *header;
ECell *cell_left_just;
EBook *book;
+ GtkWidget *table;
char *filename;
char *uri;
@@ -136,7 +137,15 @@ e_addressbook_create_ebook_table(char *name, char *string1, char *string2, int n
e_book_load_uri(book, uri, (EBookCallback) set_book, model);
g_free(uri);
g_free(filename);
- return e_table_new (header, model, SPEC);
+ table = e_table_new (header, model, SPEC);
+ gtk_object_set_data(GTK_OBJECT(table), "model", model);
+ return table;
+}
+
+static void
+set_current_selection(ETable *table, int row, ESelectNames *names)
+{
+ names->currently_selected = row;
}
static void
@@ -163,17 +172,13 @@ e_select_names_init (ESelectNames *e_select_names)
GNOME_STOCK_BUTTON_CANCEL,
NULL);
-#if 0
- widget = glade_xml_get_widget(e_select_names->gui, "button-fullname");
- if (widget && GTK_IS_BUTTON(widget))
- gtk_signal_connect(GTK_OBJECT(widget), "clicked",
- full_name_clicked, e_select_names);
-
- widget = glade_xml_get_widget(e_select_names->gui, "button-categories");
- if (widget && GTK_IS_BUTTON(widget))
- gtk_signal_connect(GTK_OBJECT(widget), "clicked",
- categories_clicked, e_select_names);
-#endif
+ 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");
+
+ e_select_names->currently_selected = -1;
+
+ gtk_signal_connect(GTK_OBJECT(e_select_names->table), "cursor_change",
+ GTK_SIGNAL_FUNC(set_current_selection), e_select_names);
}
static void e_select_names_child_free(char *key, ESelectNamesChild *child, ESelectNames *e_select_names)
@@ -183,7 +188,7 @@ static void e_select_names_child_free(char *key, ESelectNamesChild *child, ESele
g_free(key);
}
-void
+static void
e_select_names_destroy (GtkObject *object) {
ESelectNames *e_select_names = E_SELECT_NAMES(object);
@@ -226,6 +231,18 @@ e_select_names_get_arg (GtkObject *object, GtkArg *arg, guint arg_id)
}
}
+static void
+button_clicked(GtkWidget *button, ESelectNamesChild *child)
+{
+ ESelectNames *names = child->names;
+ int row = names->currently_selected;
+ if (row != -1) {
+ ECard *card = e_addressbook_model_get_card(E_ADDRESSBOOK_MODEL(names->model), row);
+ e_cardlist_model_add(E_CARDLIST_MODEL(child->model), &card, 1);
+ gtk_object_unref(GTK_OBJECT(card));
+ }
+}
+
void
e_select_names_add_section(ESelectNames *e_select_names, char *name, char *id)
{
@@ -248,6 +265,8 @@ e_select_names_add_section(ESelectNames *e_select_names, char *name, char *id)
child = g_new(ESelectNamesChild, 1);
+ child->names = e_select_names;
+
e_select_names->child_count++;
alignment = gtk_alignment_new(0, 0, 1, 0);
@@ -256,6 +275,8 @@ e_select_names_add_section(ESelectNames *e_select_names, char *name, char *id)
g_free(label);
gtk_container_add(GTK_CONTAINER(alignment), button);
gtk_widget_show_all(alignment);
+ gtk_signal_connect(GTK_OBJECT(button), "clicked",
+ GTK_SIGNAL_FUNC(button_clicked), child);
gtk_table_attach(table, alignment,
0, 1,
e_select_names->child_count,
@@ -273,6 +294,8 @@ e_select_names_add_section(ESelectNames *e_select_names, char *name, char *id)
child->model = model;
gtk_object_ref(GTK_OBJECT(child->model));
+ gtk_widget_show(etable);
+
gtk_table_attach(table, etable,
1, 2,
e_select_names->child_count,
@@ -281,9 +304,37 @@ e_select_names_add_section(ESelectNames *e_select_names, char *name, char *id)
0, 0);
}
+static void *
+card_copy(const void *value, void *closure)
+{
+ gtk_object_ref(GTK_OBJECT(value));
+ return (void *)value;
+}
+
+static void
+card_free(void *value, void *closure)
+{
+ gtk_object_unref(GTK_OBJECT(value));
+}
+
ECardList *
e_select_names_get_section(ESelectNames *e_select_names, char *id)
{
-
- return NULL;
+ ESelectNamesChild *child;
+ int i;
+ int rows;
+ ECardList *list;
+
+ child = g_hash_table_lookup(e_select_names->children, id);
+ if (!child)
+ return NULL;
+ rows = e_table_model_row_count(child->model);
+
+ list = e_card_list_new(card_copy, card_free, NULL);
+ for (i = 0; i < rows; i++) {
+ ECard *card = e_cardlist_model_get(E_CARDLIST_MODEL(child->model), i);
+ e_card_list_append(list, card);
+ gtk_object_unref(GTK_OBJECT(card));
+ }
+ return list;
}
diff --git a/addressbook/gui/component/e-select-names.h b/addressbook/gui/component/e-select-names.h
index 4356180694..23780e2cf5 100644
--- a/addressbook/gui/component/e-select-names.h
+++ b/addressbook/gui/component/e-select-names.h
@@ -24,6 +24,7 @@
#include <gnome.h>
#include <glade/glade.h>
#include <addressbook/backend/ebook/e-card-list.h>
+#include <widgets/e-table/e-table.h>
#ifdef __cplusplus
extern "C" {
@@ -57,6 +58,9 @@ struct _ESelectNames
GHashTable *children; /* Of type char * to ESelectNamesChild */
int child_count;
+ ETable *table;
+ ETableModel *model;
+ int currently_selected;
};
struct _ESelectNamesClass
diff --git a/addressbook/gui/component/select-names.glade b/addressbook/gui/component/select-names.glade
index 1e06437ed1..6165eb0b0a 100644
--- a/addressbook/gui/component/select-names.glade
+++ b/addressbook/gui/component/select-names.glade
@@ -167,11 +167,11 @@
<widget>
<class>Custom</class>
- <name>source</name>
- <creation_function></creation_function>
+ <name>table-source</name>
+ <creation_function>e_addressbook_create_ebook_table</creation_function>
<int1>0</int1>
<int2>0</int2>
- <last_modification_time>Wed, 31 May 2000 03:06:00 GMT</last_modification_time>
+ <last_modification_time>Sat, 10 Jun 2000 22:02:57 GMT</last_modification_time>
<child>
<left_attach>0</left_attach>
<right_attach>1</right_attach>