aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook
diff options
context:
space:
mode:
authorChris Toshok <toshok@helixcode.com>2001-01-10 07:08:08 +0800
committerChris Toshok <toshok@src.gnome.org>2001-01-10 07:08:08 +0800
commit289cbd41bc8c3bdfe417f3c78e5061bbed07dcfb (patch)
treee08629bc6de08c1bb1411e65963c757338aafd0d /addressbook
parent70fe2fd985176bdcf7c8fcc433f0b640f2b52432 (diff)
downloadgsoc2013-evolution-289cbd41bc8c3bdfe417f3c78e5061bbed07dcfb.tar.gz
gsoc2013-evolution-289cbd41bc8c3bdfe417f3c78e5061bbed07dcfb.tar.zst
gsoc2013-evolution-289cbd41bc8c3bdfe417f3c78e5061bbed07dcfb.zip
register our status_message signal. (status_message): new function, emit
2001-01-09 Chris Toshok <toshok@helixcode.com> * gui/widgets/e-minicard-view-widget.c (e_minicard_view_widget_class_init): register our status_message signal. (status_message): new function, emit our status_message signal. (e_minicard_view_widget_realize): connect to the EMinicardView's status_message signal. * gui/widgets/e-minicard-view-widget.h: add status_message signal. * gui/widgets/e-minicard-view.c (e_minicard_view_class_init): register our status_message signal. (e_minicard_view_init): init status_message_id. (status_message): new function, emit our status_message signal. (book_view_loaded): connect to the EBookView's status_message signal. (disconnect_signals): disconnect status_message_id. * gui/widgets/e-minicard-view.h: add status_mesage_id, and status_message signal. * gui/widgets/e-addressbook-model.c (status_message): new function, emit our status_message. (e_addressbook_model_class_init): register our "status_message" signal. (book_view_loaded): connect to the EBookView's status_message signal, so we can chain it to our parent. (e_addressbook_model_init): init status_message_id. (remove_book_view): disconnect status_message_id. * gui/widgets/e-addressbook-model.h: add status_message_id, and status_message signal. * backend/pas/pas-backend-ldap.c change the objectclass we create objects with to "inetOrgPerson" as it encompasses the fields we use. (create_dn_from_ecard): remove the mail/org handling from here. we just prepend cn=$cn onto the base dn. (create_card_handler): remove the NULL that build_mods_from_ecards adds at the end, and insert our objectClass. (modify_card_handler): call search_for_dn to get the ECardSimple of the old card, since it might (and does in the current code) doing a brute force search. (search_for_dn): new function, to search for an entry by its dn. right now we brute force (objectclass=*) under the base dn and compare dn's. going to add a first pass that explodes the dn and searches that way, using (objectclass=*) as a last resort. also, here's where we'd put the extensibleMatch code if we want to go that route. * backend/ebook/e-card.c (e_card_set_arg): if we're setting the full name regenerate ecard->name. svn path=/trunk/; revision=7345
Diffstat (limited to 'addressbook')
-rw-r--r--addressbook/ChangeLog49
-rw-r--r--addressbook/backend/pas/pas-backend-ldap.c159
-rw-r--r--addressbook/gui/widgets/e-addressbook-model.c36
-rw-r--r--addressbook/gui/widgets/e-addressbook-model.h18
-rw-r--r--addressbook/gui/widgets/e-addressbook-view.c14
-rw-r--r--addressbook/gui/widgets/e-minicard-view-widget.c34
-rw-r--r--addressbook/gui/widgets/e-minicard-view-widget.h5
-rw-r--r--addressbook/gui/widgets/e-minicard-view.c36
-rw-r--r--addressbook/gui/widgets/e-minicard-view.h7
9 files changed, 277 insertions, 81 deletions
diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog
index 99b57ff51b..4d42549a5e 100644
--- a/addressbook/ChangeLog
+++ b/addressbook/ChangeLog
@@ -1,5 +1,54 @@
2001-01-09 Chris Toshok <toshok@helixcode.com>
+ * gui/widgets/e-minicard-view-widget.c
+ (e_minicard_view_widget_class_init): register our status_message
+ signal.
+ (status_message): new function, emit our status_message signal.
+ (e_minicard_view_widget_realize): connect to the EMinicardView's
+ status_message signal.
+
+ * gui/widgets/e-minicard-view-widget.h: add status_message signal.
+
+ * gui/widgets/e-minicard-view.c (e_minicard_view_class_init):
+ register our status_message signal.
+ (e_minicard_view_init): init status_message_id.
+ (status_message): new function, emit our status_message signal.
+ (book_view_loaded): connect to the EBookView's status_message
+ signal.
+ (disconnect_signals): disconnect status_message_id.
+
+ * gui/widgets/e-minicard-view.h: add status_mesage_id, and
+ status_message signal.
+
+ * gui/widgets/e-addressbook-model.c (status_message): new
+ function, emit our status_message.
+ (e_addressbook_model_class_init): register our "status_message"
+ signal.
+ (book_view_loaded): connect to the EBookView's status_message
+ signal, so we can chain it to our parent.
+ (e_addressbook_model_init): init status_message_id.
+ (remove_book_view): disconnect status_message_id.
+
+ * gui/widgets/e-addressbook-model.h: add status_message_id, and
+ status_message signal.
+
+ * backend/pas/pas-backend-ldap.c change the objectclass we create
+ objects with to "inetOrgPerson" as it encompasses the fields we
+ use.
+ (create_dn_from_ecard): remove the mail/org handling from
+ here. we just prepend cn=$cn onto the base dn.
+ (create_card_handler): remove the NULL that build_mods_from_ecards
+ adds at the end, and insert our objectClass.
+ (modify_card_handler): call search_for_dn to get the ECardSimple
+ of the old card, since it might (and does in the current code)
+ doing a brute force search.
+ (search_for_dn): new function, to search for an entry by its dn.
+ right now we brute force (objectclass=*) under the base dn and
+ compare dn's. going to add a first pass that explodes the dn and
+ searches that way, using (objectclass=*) as a last resort. also,
+ here's where we'd put the extensibleMatch code if we want to go
+ that route.
+
* backend/ebook/e-card.c (e_card_set_arg): if we're setting the
full name regenerate ecard->name.
diff --git a/addressbook/backend/pas/pas-backend-ldap.c b/addressbook/backend/pas/pas-backend-ldap.c
index 1aa49cd17b..f7898708ad 100644
--- a/addressbook/backend/pas/pas-backend-ldap.c
+++ b/addressbook/backend/pas/pas-backend-ldap.c
@@ -42,7 +42,7 @@
#define LDAP_MAX_SEARCH_RESPONSES 100
/* this really needs addressing */
-#define OBJECT_CLASS "person"
+#define OBJECT_CLASS "inetOrgPerson"
static gchar *query_prop_to_ldap(gchar *query_prop);
@@ -133,6 +133,7 @@ struct prop_info {
#define DN_NORMAL_PROP(fid,q,a) {fid, q, a, PROP_TYPE_NORMAL | PROP_DN, NULL}
#define DN_LIST_PROP(fid,q,a,ctor,ber,cmp) {fid, q, a, PROP_TYPE_LIST | PROP_DN, ctor, ber, cmp}
+#define LIST_PROP(fid,q,a,ctor,ber,cmp) {fid, q, a, PROP_TYPE_LIST, ctor, ber, cmp}
#define NORMAL_PROP(fid,q,a) {fid, q, a, PROP_TYPE_NORMAL, NULL}
DN_NORMAL_PROP (E_CARD_SIMPLE_FIELD_FULL_NAME, "full_name", "cn" ),
@@ -140,7 +141,7 @@ struct prop_info {
NORMAL_PROP (E_CARD_SIMPLE_FIELD_TITLE, "title", "title"),
DN_NORMAL_PROP (E_CARD_SIMPLE_FIELD_ORG, "org", "o"),
NORMAL_PROP (E_CARD_SIMPLE_FIELD_PHONE_PRIMARY, "phone", "telephonenumber"),
- DN_LIST_PROP (E_CARD_SIMPLE_FIELD_EMAIL, "email", "mail", email_populate_func, email_ber_func, email_compare_func)
+ LIST_PROP (E_CARD_SIMPLE_FIELD_EMAIL, "email", "mail", email_populate_func, email_ber_func, email_compare_func)
#undef DN_NORMAL_PROP
#undef DN_LIST_PROP
@@ -352,47 +353,25 @@ ldap_error_to_response (int ldap_error)
static char *
-create_dn_from_ecard (ECardSimple *card)
+create_dn_from_ecard (ECardSimple *card, const char *root_dn)
{
- char *o, *o_part = NULL;
- const char *mail;
- char *mail_part = NULL;
char *cn, *cn_part = NULL;
char *dn;
gboolean need_comma = FALSE;
- o = e_card_simple_get (card, E_CARD_SIMPLE_FIELD_ORG);
- if (o) {
- o_part = g_strdup_printf ("o=%s", o);
- need_comma = TRUE;
- }
- else {
- o_part = g_strdup ("");
- need_comma = FALSE;
- }
-
- mail = e_card_simple_get_email (card, E_CARD_SIMPLE_EMAIL_ID_EMAIL);
- if (mail) {
- mail_part = g_strdup_printf ("mail=%s%s", mail, need_comma ? "," : "");
- need_comma = TRUE;
- }
- else {
- mail_part = g_strdup ("");
- }
-
cn = e_card_simple_get (card, E_CARD_SIMPLE_FIELD_FULL_NAME);
if (cn) {
- cn_part = g_strdup_printf ("cn=\"%s\"%s", cn, need_comma ? "," : "");
+ cn_part = g_strdup_printf ("cn=%s%s", cn, need_comma ? "," : "");
}
else {
cn_part = g_strdup ("");
}
- dn = g_strdup_printf ("%s%s%s", cn_part, mail_part, o_part);
+ dn = g_strdup_printf ("%s%s%s", cn_part,
+ (root_dn && strlen(root_dn)) ? "," : "",
+ (root_dn && strlen(root_dn)) ? root_dn: "");
g_free (cn_part);
- g_free (mail_part);
- g_free (o_part);
g_print ("generated dn: %s\n", dn);
@@ -469,7 +448,7 @@ build_mods_from_ecards (ECardSimple *current, ECardSimple *new, gboolean *new_dn
if (prop_info[i].prop_type & PROP_TYPE_NORMAL) {
mod->mod_values = g_new (char*, 2);
- mod->mod_values[0] = e_card_simple_get (new, prop_info[i].field_id);
+ mod->mod_values[0] = new_prop;
mod->mod_values[1] = NULL;
}
else {
@@ -478,6 +457,7 @@ build_mods_from_ecards (ECardSimple *current, ECardSimple *new, gboolean *new_dn
g_ptr_array_add (result, mod);
}
+
}
/* NULL terminate the list of modifications */
@@ -522,27 +502,34 @@ create_card_handler (PASBackend *backend, LDAPOp *op)
LDAPMod *objectclass_mod;
LDAP *ldap;
+ printf ("vcard = %s\n", create_op->vcard);
+
new_ecard = e_card_new (create_op->vcard);
new_card = e_card_simple_new (new_ecard);
- dn = create_dn_from_ecard (new_card);
+ dn = create_dn_from_ecard (new_card, bl->priv->ldap_rootdn);
ldap = bl->priv->ldap;
/* build our mods */
mod_array = build_mods_from_ecards (NULL, new_card, NULL);
- objectclass_mod = g_new (LDAPMod, 1);
+ /* remove the NULL at the end */
+ g_ptr_array_remove (mod_array, NULL);
+
+ objectclass_mod = g_new (LDAPMod, 1);
objectclass_mod->mod_op = LDAP_MOD_ADD;
- objectclass_mod->mod_type = g_strdup ("objectclass");
+ objectclass_mod->mod_type = g_strdup ("objectClass");
objectclass_mod->mod_values = g_new (char*, 1);
objectclass_mod->mod_values[0] = g_strdup (OBJECT_CLASS);
objectclass_mod->mod_values[1] = NULL;
-
g_ptr_array_add (mod_array, objectclass_mod);
+ g_ptr_array_add (mod_array, NULL);
+
ldap_mods = (LDAPMod**)mod_array->pdata;
+ g_print ("adding card dn: %s\n", dn);
/* actually perform the ldap add */
ldap_error = ldap_add_s (ldap, dn, ldap_mods);
@@ -641,6 +628,50 @@ typedef struct {
char *vcard;
} LDAPModifyOp;
+static ECardSimple *
+search_for_dn (PASBackendLDAP *bl, const char *dn)
+{
+#if 0
+ char **attrs;
+#endif
+ char *query;
+ LDAP *ldap = bl->priv->ldap;
+ LDAPMessage *res, *e;
+ ECardSimple *result = NULL;
+
+#if 0
+ /* this is broken because if we (say) modify the cn and can't
+ modify the dn (because it overlaps), we lose the ability to
+ search by that component of the dn. */
+ attrs = ldap_explode_dn (dn, 0);
+ query = g_strdup_printf ("(%s)", attrs[0]);
+ printf ("searching for %s\n", query);
+#else
+ query = g_strdup ("(objectclass=*)");
+#endif
+
+ if (ldap_search_s (ldap,
+ bl->priv->ldap_rootdn,
+ bl->priv->ldap_scope,
+ query,
+ NULL, 0, &res) != -1) {
+ e = ldap_first_entry (ldap, res);
+ while (NULL != e) {
+ if (!strcmp (ldap_get_dn (ldap, e), dn)) {
+ printf ("found it\n");
+ result = build_card_from_entry (ldap, e);
+ break;
+ }
+ e = ldap_next_entry (ldap, e);
+ }
+
+ ldap_msgfree(res);
+ }
+
+ g_free (query);
+ return result;
+}
+
static gboolean
modify_card_handler (PASBackend *backend, LDAPOp *op)
{
@@ -649,63 +680,43 @@ modify_card_handler (PASBackend *backend, LDAPOp *op)
ECard *new_ecard;
char *id;
int response;
- int ldap_error;
- LDAPMessage *res, *e;
- char *query;
+ int ldap_error = LDAP_SUCCESS;
GPtrArray *mod_array;
LDAPMod **ldap_mods;
LDAP *ldap;
+ ECardSimple *current_card;
new_ecard = e_card_new (modify_op->vcard);
id = e_card_get_id(new_ecard);
ldap = bl->priv->ldap;
- /* we don't get sent the original vcard along with the new one
- in this call, so we have to query the ldap server for the
- original record so we can compute our delta. */
- query = g_strdup_printf ("(dn=%s)", id);
- ldap_error = ldap_search_s (ldap,
- bl->priv->ldap_rootdn,
- bl->priv->ldap_scope,
- query, NULL, 0, &res);
+ current_card = search_for_dn (bl, id);
- if (ldap_error == LDAP_SUCCESS) {
- /* get the single card from the list (we're guaranteed
- either 1 or 0 since we looked up by dn, which is
- unique) */
- e = ldap_first_entry (ldap, res);
- if (e) {
- ECardSimple *new_card = e_card_simple_new (new_ecard);
- ECardSimple *current_card = build_card_from_entry (ldap, e);
- gboolean need_new_dn;
-
- /* build our mods */
- mod_array = build_mods_from_ecards (current_card, new_card, &need_new_dn);
- if (mod_array->len > 0) {
- ldap_mods = (LDAPMod**)mod_array->pdata;
-
- /* actually perform the ldap modify */
- ldap_error = ldap_modify_s (ldap, id, ldap_mods);
- g_print ("ldap_modify_s returned 0x%x (%s) status\n", ldap_error, ldap_err2string(ldap_error));
- }
- else {
- g_print ("modify list empty. on modification sent\n");
- }
+ if (current_card) {
+ ECardSimple *new_card = e_card_simple_new (new_ecard);
+ gboolean need_new_dn;
- /* and clean up */
- free_mods (mod_array);
- gtk_object_unref (GTK_OBJECT(new_card));
- gtk_object_unref (GTK_OBJECT(current_card));
+ /* build our mods */
+ mod_array = build_mods_from_ecards (current_card, new_card, &need_new_dn);
+ if (mod_array->len > 0) {
+ ldap_mods = (LDAPMod**)mod_array->pdata;
+
+ /* actually perform the ldap modify */
+ ldap_error = ldap_modify_s (ldap, id, ldap_mods);
+ g_print ("ldap_modify_s returned 0x%x (%s) status\n", ldap_error, ldap_err2string(ldap_error));
}
else {
- g_print ("didn't find original card\n");
+ g_print ("modify list empty. no modification sent\n");
}
- ldap_msgfree(res);
+ /* and clean up */
+ free_mods (mod_array);
+ gtk_object_unref (GTK_OBJECT(new_card));
+ gtk_object_unref (GTK_OBJECT(current_card));
}
else {
- g_print ("ldap_search_s returned 0x%x (%s) status\n", ldap_error, ldap_err2string(ldap_error));
+ g_print ("didn't find original card\n");
}
response = ldap_error_to_response (ldap_error);
diff --git a/addressbook/gui/widgets/e-addressbook-model.c b/addressbook/gui/widgets/e-addressbook-model.c
index 35c8dda745..c40c21f3bb 100644
--- a/addressbook/gui/widgets/e-addressbook-model.c
+++ b/addressbook/gui/widgets/e-addressbook-model.c
@@ -32,6 +32,13 @@ enum {
ARG_EDITABLE,
};
+enum {
+ STATUS_MESSAGE,
+ LAST_SIGNAL
+};
+
+static guint e_addressbook_model_signals [LAST_SIGNAL] = {0, };
+
static void
remove_book_view(EAddressbookModel *model)
{
@@ -44,10 +51,14 @@ remove_book_view(EAddressbookModel *model)
if (model->book_view && model->modify_card_id)
gtk_signal_disconnect(GTK_OBJECT (model->book_view),
model->modify_card_id);
+ if (model->book_view && model->status_message_id)
+ gtk_signal_disconnect(GTK_OBJECT (model->book_view),
+ model->status_message_id);
model->create_card_id = 0;
model->remove_card_id = 0;
model->modify_card_id = 0;
+ model->status_message_id = 0;
if (model->book_view)
gtk_object_unref(GTK_OBJECT(model->book_view));
@@ -236,6 +247,16 @@ modify_card(EBookView *book_view,
}
static void
+status_message (EBookView *book_view,
+ char* status,
+ EAddressbookModel *model)
+{
+ gtk_signal_emit (GTK_OBJECT (model),
+ e_addressbook_model_signals [STATUS_MESSAGE],
+ status);
+}
+
+static void
e_addressbook_model_class_init (GtkObjectClass *object_class)
{
ETableModelClass *model_class = (ETableModelClass *) object_class;
@@ -252,6 +273,16 @@ e_addressbook_model_class_init (GtkObjectClass *object_class)
GTK_ARG_READWRITE, ARG_QUERY);
gtk_object_add_arg_type ("EAddressbookModel::editable", GTK_TYPE_BOOL,
GTK_ARG_READWRITE, ARG_EDITABLE);
+
+ e_addressbook_model_signals [STATUS_MESSAGE] =
+ gtk_signal_new ("status_message",
+ GTK_RUN_LAST,
+ object_class->type,
+ GTK_SIGNAL_OFFSET (EAddressbookModelClass, status_message),
+ gtk_marshal_NONE__POINTER,
+ GTK_TYPE_NONE, 1, GTK_TYPE_POINTER);
+
+ gtk_object_class_add_signals (object_class, e_addressbook_model_signals, LAST_SIGNAL);
model_class->column_count = addressbook_col_count;
model_class->row_count = addressbook_row_count;
@@ -277,6 +308,7 @@ e_addressbook_model_init (GtkObject *object)
model->create_card_id = 0;
model->remove_card_id = 0;
model->modify_card_id = 0;
+ model->status_message_id = 0;
model->data = NULL;
model->data_count = 0;
model->editable = TRUE;
@@ -304,6 +336,10 @@ book_view_loaded (EBook *book, EBookStatus status, EBookView *book_view, gpointe
"card_changed",
GTK_SIGNAL_FUNC(modify_card),
model);
+ model->status_message_id = gtk_signal_connect(GTK_OBJECT(model->book_view),
+ "status_message",
+ GTK_SIGNAL_FUNC(status_message),
+ model);
for ( i = 0; i < model->data_count; i++ ) {
gtk_object_unref(GTK_OBJECT(model->data[i]));
diff --git a/addressbook/gui/widgets/e-addressbook-model.h b/addressbook/gui/widgets/e-addressbook-model.h
index 860fb641ac..79a606b314 100644
--- a/addressbook/gui/widgets/e-addressbook-model.h
+++ b/addressbook/gui/widgets/e-addressbook-model.h
@@ -20,7 +20,10 @@
3 Phone
*/
-typedef struct {
+typedef struct _EAddressbookModel EAddressbookModel;
+typedef struct _EAddressbookModelClass EAddressbookModelClass;
+
+struct _EAddressbookModel {
ETableModel parent;
/* item specific fields */
@@ -33,16 +36,21 @@ typedef struct {
ECardSimple **data;
int data_count;
- int create_card_id, remove_card_id, modify_card_id;
+ int create_card_id, remove_card_id, modify_card_id, status_message_id;
guint editable : 1;
guint first_get_view : 1;
-} EAddressbookModel;
+};
-typedef struct {
+struct _EAddressbookModelClass {
ETableModelClass parent_class;
-} EAddressbookModelClass;
+
+ /*
+ * Signals
+ */
+ void (*status_message) (EAddressbookModel *model, const gchar *message);
+};
GtkType e_addressbook_model_get_type (void);
diff --git a/addressbook/gui/widgets/e-addressbook-view.c b/addressbook/gui/widgets/e-addressbook-view.c
index 816c83ca36..416b1e71e6 100644
--- a/addressbook/gui/widgets/e-addressbook-view.c
+++ b/addressbook/gui/widgets/e-addressbook-view.c
@@ -152,8 +152,9 @@ e_addressbook_view_set_arg (GtkObject *object, GtkArg *arg, guint arg_id)
switch (arg_id){
case ARG_BOOK:
- if (eav->book)
+ if (eav->book) {
gtk_object_unref(GTK_OBJECT(eav->book));
+ }
if (GTK_VALUE_OBJECT(*arg)) {
eav->book = E_BOOK(GTK_VALUE_OBJECT(*arg));
gtk_object_ref(GTK_OBJECT(eav->book));
@@ -534,6 +535,12 @@ table_right_click(ETableScrolled *table, gint row, gint col, GdkEvent *event, EA
return FALSE;
}
+static void
+status_message (GtkObject *object, const gchar *message, EAddressbookView *eav)
+{
+ printf ("status = %s\n", message);
+}
+
#define SPEC "<?xml version=\"1.0\"?> \
<ETableSpecification click-to-add=\"true\" draw-grid=\"true\" _click-to-add-message=\"* Click here to add a contact *\"> \
<ETableColumn model_col= \"0\" _title=\"Name\" expansion=\"1.0\" minimum_width=\"20\" resizable=\"true\" cell=\"string\" compare=\"string\"/> \
@@ -641,6 +648,11 @@ change_view_type (EAddressbookView *view, EAddressbookViewType view_type)
view->view_type = view_type;
+ gtk_signal_connect (view->object,
+ "status_message",
+ GTK_SIGNAL_FUNC (status_message),
+ view);
+
gtk_object_set(view->object,
"query", view->query,
"book", view->book,
diff --git a/addressbook/gui/widgets/e-minicard-view-widget.c b/addressbook/gui/widgets/e-minicard-view-widget.c
index c6809bf1d0..fbbcd6cf00 100644
--- a/addressbook/gui/widgets/e-minicard-view-widget.c
+++ b/addressbook/gui/widgets/e-minicard-view-widget.c
@@ -42,6 +42,14 @@ enum {
ARG_QUERY
};
+enum {
+ STATUS_MESSAGE,
+ LAST_SIGNAL
+};
+
+static guint e_minicard_view_widget_signals [LAST_SIGNAL] = {0, };
+
+
GtkType
e_minicard_view_widget_get_type (void)
{
@@ -85,6 +93,16 @@ e_minicard_view_widget_class_init (EMinicardViewWidgetClass *klass)
gtk_object_add_arg_type ("EMinicardViewWidget::query", GTK_TYPE_STRING,
GTK_ARG_READWRITE, ARG_QUERY);
+ e_minicard_view_widget_signals [STATUS_MESSAGE] =
+ gtk_signal_new ("status_message",
+ GTK_RUN_LAST,
+ object_class->type,
+ GTK_SIGNAL_OFFSET (EMinicardViewWidgetClass, status_message),
+ gtk_marshal_NONE__POINTER,
+ GTK_TYPE_NONE, 1, GTK_TYPE_POINTER);
+
+ gtk_object_class_add_signals (object_class, e_minicard_view_widget_signals, LAST_SIGNAL);
+
object_class->set_arg = e_minicard_view_widget_set_arg;
object_class->get_arg = e_minicard_view_widget_get_arg;
object_class->destroy = e_minicard_view_widget_destroy;
@@ -176,6 +194,16 @@ e_minicard_view_widget_destroy (GtkObject *object)
}
static void
+status_message (EMinicardView *mini_view,
+ char* status,
+ EMinicardViewWidget *view)
+{
+ gtk_signal_emit (GTK_OBJECT (view),
+ e_minicard_view_widget_signals [STATUS_MESSAGE],
+ status);
+}
+
+static void
e_minicard_view_widget_realize (GtkWidget *widget)
{
EMinicardViewWidget *view = E_MINICARD_VIEW_WIDGET(widget);
@@ -196,6 +224,12 @@ e_minicard_view_widget_realize (GtkWidget *widget)
"height", (double) 100,
"minimum_width", (double) 100,
NULL );
+
+ gtk_signal_connect(GTK_OBJECT(view->emv),
+ "status_message",
+ GTK_SIGNAL_FUNC(status_message),
+ view);
+
gtk_object_set(GTK_OBJECT(view->emv),
"book", view->book,
"query", view->query,
diff --git a/addressbook/gui/widgets/e-minicard-view-widget.h b/addressbook/gui/widgets/e-minicard-view-widget.h
index cf20c9a4df..0deb920ffa 100644
--- a/addressbook/gui/widgets/e-minicard-view-widget.h
+++ b/addressbook/gui/widgets/e-minicard-view-widget.h
@@ -55,6 +55,11 @@ struct _EMinicardViewWidget
struct _EMinicardViewWidgetClass
{
ECanvasClass parent_class;
+
+ /*
+ * Signals
+ */
+ void (*status_message) (EMinicardView *mini_view, const gchar *message);
};
GtkType e_minicard_view_widget_get_type (void);
diff --git a/addressbook/gui/widgets/e-minicard-view.c b/addressbook/gui/widgets/e-minicard-view.c
index 7169e41542..d3f08b71ab 100644
--- a/addressbook/gui/widgets/e-minicard-view.c
+++ b/addressbook/gui/widgets/e-minicard-view.c
@@ -44,6 +44,13 @@ enum {
ARG_QUERY
};
+enum {
+ STATUS_MESSAGE,
+ LAST_SIGNAL
+};
+
+static guint e_minicard_view_signals [LAST_SIGNAL] = {0, };
+
GtkType
e_minicard_view_get_type (void)
{
@@ -84,6 +91,16 @@ e_minicard_view_class_init (EMinicardViewClass *klass)
GTK_ARG_READWRITE, ARG_BOOK);
gtk_object_add_arg_type ("EMinicardView::query", GTK_TYPE_STRING,
GTK_ARG_READWRITE, ARG_QUERY);
+
+ e_minicard_view_signals [STATUS_MESSAGE] =
+ gtk_signal_new ("status_message",
+ GTK_RUN_LAST,
+ object_class->type,
+ GTK_SIGNAL_OFFSET (EMinicardViewClass, status_message),
+ gtk_marshal_NONE__POINTER,
+ GTK_TYPE_NONE, 1, GTK_TYPE_POINTER);
+
+ gtk_object_class_add_signals (object_class, e_minicard_view_signals, LAST_SIGNAL);
object_class->set_arg = e_minicard_view_set_arg;
object_class->get_arg = e_minicard_view_get_arg;
@@ -104,6 +121,7 @@ e_minicard_view_init (EMinicardView *view)
view->create_card_id = 0;
view->remove_card_id = 0;
view->modify_card_id = 0;
+ view->status_message_id = 0;
view->canvas_destroy_id = 0;
view->first_get_view = TRUE;
@@ -145,6 +163,16 @@ modify_card(EBookView *book_view, const GList *cards, EMinicardView *view)
}
static void
+status_message (EBookView *book_view,
+ char* status,
+ EMinicardView *view)
+{
+ gtk_signal_emit (GTK_OBJECT (view),
+ e_minicard_view_signals [STATUS_MESSAGE],
+ status);
+}
+
+static void
remove_card(EBookView *book_view, const char *id, EMinicardView *view)
{
e_reflow_sorted_remove_item(E_REFLOW_SORTED(view), id);
@@ -181,6 +209,10 @@ book_view_loaded (EBook *book, EBookStatus status, EBookView *book_view, gpointe
"card_changed",
GTK_SIGNAL_FUNC(modify_card),
view);
+ view->status_message_id = gtk_signal_connect(GTK_OBJECT(view->book_view),
+ "status_message",
+ GTK_SIGNAL_FUNC(status_message),
+ view);
g_list_foreach(E_REFLOW(view)->items, (GFunc) gtk_object_unref, NULL);
g_list_foreach(E_REFLOW(view)->items, (GFunc) gtk_object_destroy, NULL);
@@ -373,10 +405,14 @@ disconnect_signals(EMinicardView *view)
if (view->book_view && view->modify_card_id)
gtk_signal_disconnect(GTK_OBJECT (view->book_view),
view->modify_card_id);
+ if (view->book_view && view->status_message_id)
+ gtk_signal_disconnect(GTK_OBJECT (view->book_view),
+ view->status_message_id);
view->create_card_id = 0;
view->remove_card_id = 0;
view->modify_card_id = 0;
+ view->status_message_id = 0;
}
static void
diff --git a/addressbook/gui/widgets/e-minicard-view.h b/addressbook/gui/widgets/e-minicard-view.h
index e4c1be870a..804290d427 100644
--- a/addressbook/gui/widgets/e-minicard-view.h
+++ b/addressbook/gui/widgets/e-minicard-view.h
@@ -72,7 +72,7 @@ struct _EMinicardView
int canvas_destroy_id;
- int create_card_id, remove_card_id, modify_card_id;
+ int create_card_id, remove_card_id, modify_card_id, status_message_id;
guint first_get_view : 1;
};
@@ -80,6 +80,11 @@ struct _EMinicardView
struct _EMinicardViewClass
{
EReflowSortedClass parent_class;
+
+ /*
+ * Signals
+ */
+ void (*status_message) (EMinicardView *mini_view, const gchar *message);
};
GtkType e_minicard_view_get_type (void);