#include <libosso-abook/osso-abook-aggregator.h>
#include <libosso-abook/osso-abook-contact.h>
#include <libosso-abook/osso-abook-waitable.h>
-#include <libosso-abook/osso-abook-contact.h>
+#include <libosso-abook/osso-abook-presence.h>
+#include <libosso-abook/osso-abook-avatar.h>
#include <libosso-abook/osso-abook-touch-contact-starter.h>
#include <libosso-abook/osso-abook-temporary-contact-dialog.h>
#include <libosso-abook/osso-abook-account-manager.h>
#define MESSAGE_HEIGHT (C_HEIGHT - HEADER_HEIGHT - FOOTER_HEIGHT)
#define MESSAGE_WIDTH (C_WIDTH - 2*HILDON_MARGIN_DEFAULT)
-#define SERVICE_ICON_SIZE HILDON_ICON_PIXEL_SIZE_SMALL
#define AVATAR_SIZE HILDON_ICON_PIXEL_SIZE_THUMB
#define AVATAR_X (C_WIDTH - AVATAR_SIZE - HILDON_MARGIN_DEFAULT)
PangoFontDescription *font_desc;
GdkPixbuf *avatar_pixbuf;
+ GdkPixbuf *presence_pixbuf;
guint idle_id;
1.0f);
cairo_stroke (cr);
}
-#if 0
- if (priv->service_pixbuf) {
- guint x = C_WIDTH - SERVICE_ICON_SIZE - HILDON_MARGIN_DEFAULT;
- guint y = (HEADER_HEIGHT - SERVICE_ICON_SIZE)/2;
+ if (priv->presence_pixbuf) {
+ guint x = C_WIDTH - HILDON_ICON_PIXEL_SIZE_XSMALL - HILDON_MARGIN_DEFAULT;
+ guint y = (HEADER_HEIGHT - HILDON_ICON_PIXEL_SIZE_XSMALL)/2;
if (priv->avatar_pixbuf)
x -= AVATAR_SIZE + HILDON_MARGIN_DEFAULT;
cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
gdk_cairo_set_source_pixbuf (cr,
- priv->service_pixbuf,
- x, y);
+ priv->presence_pixbuf,
+ x,
+ y);
cairo_paint (cr);
}
-#endif
+
if (priv->message) {
/* draw footer unread part bg */
return GTK_WIDGET_CLASS (el_home_applet_parent_class)->expose_event (self, event);
}
+static void
+update_presence_pixbuf (ELHomeApplet *self,
+ OssoABookPresence *presence)
+{
+ ELHomeAppletPrivate *priv = self->priv;
+ const gchar *icon_name = osso_abook_presence_get_icon_name (presence);
+
+ if (priv->presence_pixbuf) {
+ g_object_unref (priv->presence_pixbuf);
+ priv->presence_pixbuf = NULL;
+ }
+ g_warning ("presence %s", icon_name);
+ if (icon_name)
+ priv->presence_pixbuf = gtk_icon_theme_load_icon
+ (gtk_icon_theme_get_default (),
+ icon_name,
+ HILDON_ICON_PIXEL_SIZE_XSMALL,
+ 0, NULL);
+
+ gtk_widget_queue_draw (GTK_WIDGET (self));
+}
+
+static void
+presence_updated (OssoABookPresence *presence,
+ GParamSpec *spec,
+ gpointer *user_data)
+{
+ ELHomeApplet *self = EL_HOME_APPLET(user_data);
+
+ if (!OSSO_ABOOK_IS_CONTACT(self->priv->contact))
+ return;
+
+ update_presence_pixbuf (self, presence);
+}
static void
clean_state (ELHomeApplet *self)
priv->avatar_pixbuf = NULL;
}
+ if (priv->presence_pixbuf) {
+ g_object_unref (priv->presence_pixbuf);
+ priv->presence_pixbuf = NULL;
+ }
+
if (priv->message) {
g_free (priv->message);
priv->message = NULL;
}
if (priv->contact) {
+ g_signal_handlers_disconnect_by_func (priv->contact,
+ presence_updated,
+ self);
g_object_unref (priv->contact);
priv->contact = NULL;
}
HILDON_ICON_PIXEL_SIZE_THUMB);
}
+
+ update_presence_pixbuf (self,
+ OSSO_ABOOK_PRESENCE (priv->contact));
+ g_signal_connect (priv->contact,
+ "notify::presence-status",
+ G_CALLBACK (presence_updated),
+ self);
#if 0
if (priv->avatar_pixbuf) {
gtk_image_set_from_pixbuf (GTK_IMAGE (priv->avatar),
if (icon_name) {
gtk_image_set_from_icon_name (GTK_IMAGE (priv->icon),
icon_name,
- HILDON_ICON_SIZE_SMALL);
+ HILDON_ICON_SIZE_XSMALL);
gtk_widget_show (priv->icon);
}