Index: configure.ac
===================================================================
RCS file: /cvs/gnome/contact-lookup-applet/configure.ac,v
retrieving revision 1.43
diff -d -u -r1.43 configure.ac
--- configure.ac	14 May 2005 10:52:53 -0000	1.43
+++ configure.ac	8 Jul 2005 16:52:47 -0000
@@ -52,6 +52,12 @@
 AC_SUBST(EVO_CFLAGS)
 AC_SUBST(EVO_LIBS)
 
+dnl Galago
+PKG_CHECK_MODULES(GALAGO_GTK, libgalago-gtk,
+        AC_DEFINE(USE_GALAGO_GTK, 1, [Use libgalago-gtk]))
+AC_SUBST(GALAGO_GTK_CFLAGS)
+AC_SUBST(GALAGO_GTK_LIBS)
+
 AC_OUTPUT([
 Makefile
 data/Makefile
Index: src/Makefile.am
===================================================================
RCS file: /cvs/gnome/contact-lookup-applet/src/Makefile.am,v
retrieving revision 1.8
diff -d -u -r1.8 Makefile.am
--- src/Makefile.am	10 Apr 2005 17:12:28 -0000	1.8
+++ src/Makefile.am	8 Jul 2005 16:52:47 -0000
@@ -30,5 +30,5 @@
 	glade-utils.h \
 	glade-utils.c
 
-contact_lookup_applet_CFLAGS = $(GTK_CFLAGS) $(PANEL_CFLAGS) $(EVO_CFLAGS) $(GLADE_CFLAGS) -Wall
-contact_lookup_applet_LDADD = $(GTK_LIBS) $(PANEL_LIBS) $(EVO_LIBS) $(GLADE_LIBS) libecontactentry.la
+contact_lookup_applet_CFLAGS = $(GTK_CFLAGS) $(PANEL_CFLAGS) $(EVO_CFLAGS) $(GLADE_CFLAGS) $(GALAGO_GTK_CFLAGS) -Wall
+contact_lookup_applet_LDADD = $(GTK_LIBS) $(PANEL_LIBS) $(EVO_LIBS) $(GLADE_LIBS) $(GALAGO_GTK_LIBS) libecontactentry.la
Index: src/contact-dialog.c
===================================================================
RCS file: /cvs/gnome/contact-lookup-applet/src/contact-dialog.c,v
retrieving revision 1.14
diff -d -u -r1.14 contact-dialog.c
--- src/contact-dialog.c	4 Oct 2004 19:37:40 -0000	1.14
+++ src/contact-dialog.c	8 Jul 2005 16:52:48 -0000
@@ -33,6 +33,10 @@
 #include <libebook/e-contact.h>
 #include <libgnome/gnome-url.h>
 
+#ifdef USE_GALAGO_GTK
+#include <libgalago-gtk/galago-gtk.h>
+#endif
+
 #include "glade-utils.h"
 
 static void
@@ -122,23 +126,131 @@
 static void
 destroy_cb (GtkObject *object, EContact *contact)
 {
+  GList *l, *signals;
+
   g_return_if_fail (E_IS_CONTACT (contact));
+
+  signals = g_object_get_data (G_OBJECT (object), "presence_signal_ids");
+
+  if (signals != NULL) {
+    for (l = signals; l != NULL; l = l->next) {
+      galago_signals_disconnect_by_id (GPOINTER_TO_INT (l->data));
+    }
+
+    g_list_free (signals);
+  }
+
   g_object_unref (contact);
 }
 
 
+#ifdef USE_GALAGO_GTK
+static void
+update_presence_icon(GalagoPresence *presence, const char *property,
+                     GtkTreeModel *model) {
+
+  gboolean cont;
+  GtkTreeIter iter;
+  GalagoAccount *account = galago_presence_get_account (presence);
+
+  for (cont = gtk_tree_model_get_iter_first (model, &iter);
+       cont;
+       cont = gtk_tree_model_iter_next (model, &iter)) {
+
+    GalagoAccount *temp_account;
+
+    gtk_tree_model_get (model, &iter, 2, &temp_account, -1);
+
+    if (temp_account == account) {
+      GdkPixbuf *pixbuf;
+
+      pixbuf = galago_gdk_pixbuf_new_from_account (account, 16, 16);
+
+      gtk_list_store_set (GTK_LIST_STORE (model), &iter, 0, pixbuf, -1);
+
+      if (pixbuf != NULL) {
+        g_object_unref (G_OBJECT (pixbuf));
+      }
+
+      break;
+    }
+  }
+}
+
+static GalagoAccount *
+get_account_from_contact(GtkWidget *dialog, GtkListStore *store, const char *icon_name, const char *username) {
+  GalagoService *service;
+  GalagoAccount *account;
+  GalagoPresence *presence;
+  const char *service_id = NULL;
+
+  if (!strcmp (icon_name, "im-aim")) {
+    service_id = GALAGO_SERVICE_ID_AIM;
+  } else if (!strcmp (icon_name, "im-groupwise")) {
+    service_id = GALAGO_SERVICE_ID_GROUPWISE;
+  } else if (!strcmp (icon_name, "im-jabber")) {
+    service_id = GALAGO_SERVICE_ID_JABBER;
+  } else if (!strcmp (icon_name, "im-yahoo")) {
+    service_id = GALAGO_SERVICE_ID_YAHOO;
+  } else if (!strcmp (icon_name, "im-msn")) {
+    service_id = GALAGO_SERVICE_ID_MSN;
+  } else if (!strcmp (icon_name, "im-icq")) {
+    service_id = GALAGO_SERVICE_ID_ICQ;
+  } else {
+    return NULL;
+  }
+
+  service = galago_core_get_service (service_id, FALSE, TRUE);
+  if (service == NULL) {
+    return NULL;
+  }
+
+  account = galago_service_get_account (service, username, TRUE);
+  if (account == NULL) {
+      return NULL;
+  }
+
+  presence = galago_account_get_presence (account, TRUE);
+
+  if (presence != NULL) {
+    unsigned long updated_id;
+    GList *ids = g_object_get_data (G_OBJECT (dialog), "presence_signal_ids");
+
+    updated_id = galago_signal_connect (presence, "updated",
+                                        GALAGO_CALLBACK (update_presence_icon),
+                                        store);
+
+    ids = g_list_append (ids, GINT_TO_POINTER (updated_id));
+    g_object_set_data (G_OBJECT (dialog), "presence_signal_ids", ids);
+  }
+
+  return account;
+}
+#endif /* USE_GALAGO_GTK */
+
+
 static void 
-populate_from_fields (GtkListStore *store, EContactInfo fields[], EContact *contact) {
+populate_from_fields (GtkWidget *dialog, GtkListStore *store, EContactInfo fields[], EContact *contact) {
   int i;
 
   for(i = 0; fields[i].field != -1; i++) {
     GtkTreeIter iter;
     GdkPixbuf *pixbuf;
     const char *data;
+    void *state_data = NULL;
     
     data = e_contact_get_const (contact, fields[i].field);
     if (data && *data != '\0') {
       if (fields[i].image) {
+#ifdef USE_GALAGO_GTK
+        GalagoAccount *account;
+        if (galago_is_connected() &&
+            (account = get_account_from_contact (dialog, store, fields[i].image, data)) != NULL) {
+            pixbuf = galago_gdk_pixbuf_new_from_account (account, 16, 16);
+            state_data = account;
+        }
+        else
+#endif
         pixbuf = get_icon (fields[i].image, 16);
       } else {
         pixbuf = NULL;
@@ -148,17 +260,18 @@
       gtk_list_store_set (store, &iter,
                           0, pixbuf,
                           1, data,
+                          2, state_data,
                           -1);
     }
   }
 }
 
 
-static void create_combo(EContact *contact, GtkWidget *combo, GtkWidget *box, EContactInfo fields[]) {
+static void create_combo(GtkWidget *dialog, EContact *contact, GtkWidget *combo, GtkWidget *box, EContactInfo fields[]) {
   GtkListStore *store;
   GtkCellRenderer *renderer;
   
-  store = gtk_list_store_new (2, GDK_TYPE_PIXBUF, G_TYPE_STRING);
+  store = gtk_list_store_new (3, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_POINTER);
   renderer = gtk_cell_renderer_pixbuf_new ();
   gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), renderer, FALSE);
   gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo), renderer, "pixbuf", 0, NULL);
@@ -167,7 +280,7 @@
   gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), renderer, TRUE);
   gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo), renderer, "text", 1, NULL);
   
-  populate_from_fields (store, fields, contact);
+  populate_from_fields (dialog, store, fields, contact);
   
   if (gtk_tree_model_iter_n_children (GTK_TREE_MODEL (store), NULL) > 0) {
     gtk_combo_box_set_model (GTK_COMBO_BOX (combo), GTK_TREE_MODEL (store));
@@ -364,10 +477,10 @@
   }
 
   /* Instant Messaging */
-  create_combo (contact, im_combo, im_box, contactinfo_im);
+  create_combo (dialog, contact, im_combo, im_box, contactinfo_im);
   
   /* Email */
-  create_combo (contact, email_combo, email_box, contactinfo_email);
+  create_combo (dialog, contact, email_combo, email_box, contactinfo_email);
   g_signal_connect (email_button, "clicked", (GCallback)send_email_clicked_cb, email_combo);
 
   g_signal_connect (dialog, "key-press-event", (GCallback)keypress_event_cb, NULL);
Index: src/contact-lookup-applet.c
===================================================================
RCS file: /cvs/gnome/contact-lookup-applet/src/contact-lookup-applet.c,v
retrieving revision 1.27
diff -d -u -r1.27 contact-lookup-applet.c
--- src/contact-lookup-applet.c	30 May 2005 09:22:25 -0000	1.27
+++ src/contact-lookup-applet.c	8 Jul 2005 16:52:48 -0000
@@ -42,6 +42,10 @@
 #include <libebook/e-contact.h>
 #include <libedataserver/e-source-list.h>
 
+#ifdef USE_GALAGO_GTK
+#include <libgalago/galago.h>
+#endif
+
 #define GCONF_COMPLETION "/apps/evolution/addressbook"
 #define GCONF_COMPLETION_SOURCES GCONF_COMPLETION "/sources"
 #define GCONF_COMPLETION_LENGTH GCONF_COMPLETION "/minimum_query_length"
@@ -231,6 +235,10 @@
 {
   EvoLookupApplet *applet;
   GtkWidget *hbox;
+
+  if (!galago_glib_init("contact-lookup-applet", FALSE, NULL)) {
+	  return FALSE;
+  }
   
   applet = g_new0 (EvoLookupApplet, 1);
   applet->applet_widget = GTK_WIDGET (parent_applet);

