Initial commit
authorArtem Garmash <artemgarmash@gmail.com>
Sun, 27 Jun 2010 19:08:39 +0000 (22:08 +0300)
committerArtem Garmash <artem.garmash@nokia.com>
Sun, 27 Jun 2010 19:13:33 +0000 (22:13 +0300)
18 files changed:
.gitignore [new file with mode: 0644]
AUTHORS [new file with mode: 0644]
ChangeLog [new file with mode: 0644]
Makefile.am [new file with mode: 0644]
NEWS [new file with mode: 0644]
README [new file with mode: 0644]
autogen.sh [new file with mode: 0755]
configure.ac [new file with mode: 0644]
debian/changelog [new file with mode: 0644]
debian/compat [new file with mode: 0644]
debian/control [new file with mode: 0644]
debian/conversations-inbox-widget.install [new file with mode: 0644]
debian/rules [new file with mode: 0755]
src/Makefile.am [new file with mode: 0644]
src/conversations-inbox-widget.desktop [new file with mode: 0644]
src/el-home-applet.c [new file with mode: 0644]
src/el-home-applet.h [new file with mode: 0644]
welcome [deleted file]

diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..31134ed
--- /dev/null
@@ -0,0 +1,39 @@
+*-stamp
+gdbrc*
+COPYING
+INSTALL
+compile
+
+debian/files
+debian/conversations-inbox-widget.substvars
+debian/conversations-inbox-widget/
+debian/stamp-autotools-files
+debian/stamp-makefile-build
+debian/tmp/
+src/conversations-inbox-widget
+po/Makefile.in.in
+po/POTFILES
+po/stamp-it
+
+Makefile
+Makefile.in
+Makefile.local
+aclocal.m4
+autom4te.cache
+config.*
+configure
+depcomp
+gtk-doc.make
+install-sh
+intltool-*
+libtool
+ltmain.sh
+missing
+mkinstalldirs
+stamp-h1
+*.[ao]
+*.l[ao]
+*.swp
+.libs
+.deps
+
diff --git a/AUTHORS b/AUTHORS
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/ChangeLog b/ChangeLog
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/Makefile.am b/Makefile.am
new file mode 100644 (file)
index 0000000..f963eff
--- /dev/null
@@ -0,0 +1 @@
+SUBDIRS = src
\ No newline at end of file
diff --git a/NEWS b/NEWS
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/README b/README
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/autogen.sh b/autogen.sh
new file mode 100755 (executable)
index 0000000..d68a142
--- /dev/null
@@ -0,0 +1,3 @@
+#! /bin/sh
+autoreconf -v --install || exit 1
+./configure "$@"
diff --git a/configure.ac b/configure.ac
new file mode 100644 (file)
index 0000000..783f03d
--- /dev/null
@@ -0,0 +1,35 @@
+AC_PREREQ(2.53)
+AC_INIT(conversations-inbox-widget, 0.0.4)
+AM_INIT_AUTOMAKE([-Wall])
+AC_CONFIG_SRCDIR(src/el-home-applet.c)
+AM_CONFIG_HEADER(config.h)
+
+AC_PROG_CC
+AC_STDC_HEADERS
+AC_PROG_LIBTOOL
+AM_PATH_GLIB_2_0([2.16.0])
+
+CFLAGS="$CFLAGS -Wall -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls"
+
+PKG_CHECK_MODULES([LIBEVENT_LOGGER],
+                  [rtcom-eventlogger])
+
+hildonhomedesktopentrydir=`pkg-config libhildondesktop-1 --variable=hildonhomedesktopentrydir`
+AC_SUBST(hildonhomedesktopentrydir)
+hildondesktoplibdir=`pkg-config libhildondesktop-1 --variable=hildondesktoplibdir`
+AC_SUBST(hildondesktoplibdir)
+
+PKG_CHECK_MODULES([LIBHILDONDESKTOP],
+                   [libhildondesktop-1 >= 2.1.7])
+
+AC_ARG_ENABLE([debug],
+              [AS_HELP_STRING([--enable-debug], [enable debugging])],
+             [enable_debug=${enableval}], [enalbe_debug=no])
+
+if test "x$enable_debug" != "xyes"; then
+    CFLAGS="$CFLAGS -DG_DEBUG_DISABLE"
+fi
+
+AC_OUTPUT([Makefile
+           src/Makefile
+])
diff --git a/debian/changelog b/debian/changelog
new file mode 100644 (file)
index 0000000..b4a81f5
--- /dev/null
@@ -0,0 +1,23 @@
+conversations-inbox-widget (0.0.4) unstable; urgency=low
+
+  * Fix read counter glitches
+
+ -- Artem Garmash <artemgarmash@gmail.com>  Thu, 15 Oct 2009 19:22:56 +0300
+
+conversations-inbox-widget (0.0.3) unstable; urgency=low
+
+  * Show unread message counter
+
+ -- Artem Garmash <artemgarmash@gmail.com>  Sat,  3 Oct 2009 21:35:14 +0300
+
+conversations-inbox-widget (0.0.2) unstable; urgency=low
+
+  * Improved layout, theme support
+
+ -- Artem Garmash <artemgarmash@gmail.com>  Sun, 27 Sep 2009 14:05:22 +0300
+
+conversations-inbox-widget (0.0.1) unstable; urgency=low
+
+  * Initial release
+
+ -- Artem Garmash <artemgarmash@gmail.com>  Mon, 14 Sep 2009 11:34:26 +0300
diff --git a/debian/compat b/debian/compat
new file mode 100644 (file)
index 0000000..7ed6ff8
--- /dev/null
@@ -0,0 +1 @@
+5
diff --git a/debian/control b/debian/control
new file mode 100644 (file)
index 0000000..995bdd0
--- /dev/null
@@ -0,0 +1,14 @@
+Source: conversations-inbox-widget
+Priority: extra
+Section: user/desktop
+Maintainer: Artem Garmash <artemgarmash@gmail.com>
+Build-Depends: debhelper (>= 4.0.0), cdbs, autotools-dev, librtcom-eventlogger-dev,
+ libhildondesktop1-dev (>= 2.1.7)
+Standards-Version: 3.6.2
+
+Package: conversations-inbox-widget
+Section: user/desktop
+Architecture: any
+Depends: ${shlibs:Depends}
+Description: Conversations Inbox Widget
+ Check incoming SMS and IM messages right from your desktop.
\ No newline at end of file
diff --git a/debian/conversations-inbox-widget.install b/debian/conversations-inbox-widget.install
new file mode 100644 (file)
index 0000000..6beeac8
--- /dev/null
@@ -0,0 +1,2 @@
+usr/lib/hildon-desktop/conversations-inbox-widget.so
+usr/share/applications/hildon-home/conversations-inbox-widget.desktop
diff --git a/debian/rules b/debian/rules
new file mode 100755 (executable)
index 0000000..8f04856
--- /dev/null
@@ -0,0 +1,19 @@
+#!/usr/bin/make -f
+
+include /usr/share/cdbs/1/rules/debhelper.mk
+include /usr/share/cdbs/1/class/autotools.mk
+
+DEB_DH_INSTALL_SOURCEDIR=debian/tmp
+DEB_DESTDIR=$(CURDIR)/debian/tmp
+
+ifneq (,$(findstring debug,$(DEB_BUILD_OPTIONS)))
+        DEB_CONFIGURE_EXTRA_FLAGS += --enable-debug
+endif
+
+# Use soft-float and thumb mode if it enabled.
+ifneq (,$(findstring thumb,$(DEB_BUILD_OPTIONS)))
+       CFLAGS += -mthumb
+endif
+
+makebuilddir/conversations-inbox-widget::
+       autoreconf -v -i
diff --git a/src/Makefile.am b/src/Makefile.am
new file mode 100644 (file)
index 0000000..05aa533
--- /dev/null
@@ -0,0 +1,12 @@
+hildondesktoplib_LTLIBRARIES = conversations-inbox-widget.la
+
+conversations_inbox_widget_la_CPPFLAGS = \
+    $(LIBHILDONDESKTOP_CFLAGS) \
+    $(LIBEVENT_LOGGER_CFLAGS)
+
+conversations_inbox_widget_la_LDFLAGS = -module -avoid-version
+conversations_inbox_widget_la_LIBADD = $(LIBHILDONDESKTOP_LIBS) $(LIBEVENT_LOGGER_LIBS)
+
+conversations_inbox_widget_la_SOURCES = el-home-applet.c el-home-applet.h
+
+hildonhomedesktopentry_DATA = conversations-inbox-widget.desktop
\ No newline at end of file
diff --git a/src/conversations-inbox-widget.desktop b/src/conversations-inbox-widget.desktop
new file mode 100644 (file)
index 0000000..cbd0f26
--- /dev/null
@@ -0,0 +1,7 @@
+[Desktop Entry]
+Name=Conversations Inbox
+Comment=SMS and IM messages preview home applet
+Type=default
+X-Path=conversations-inbox-widget.so
+X-Multiple-Instances=false
+X-Text-Domain=none
diff --git a/src/el-home-applet.c b/src/el-home-applet.c
new file mode 100644 (file)
index 0000000..fe48da6
--- /dev/null
@@ -0,0 +1,591 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
+/*
+ *  Copyright (C) 2009 Artem Garmash. All rights reserved.
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Contact: Artem Garmash <artemgarmash@gmail.com>
+ *
+ */
+
+#include "config.h"
+#include "el-home-applet.h"
+
+#include <hildon/hildon.h>
+#include <rtcom-eventlogger/eventlogger.h>
+#include <sqlite3.h>
+#include <string.h>
+
+#define EL_HOME_APPLET_GET_PRIVATE(obj) ( \
+        G_TYPE_INSTANCE_GET_PRIVATE (obj, \
+                EL_TYPE_HOME_APPLET, ELHomeAppletPrivate))
+
+#define BOX_WIDTH 352
+#define BOX_HEIGHT 252
+
+#define C_WIDTH (BOX_WIDTH - 2*HILDON_MARGIN_HALF)
+#define C_HEIGHT (BOX_HEIGHT - 2*HILDON_MARGIN_HALF)
+#define C_X HILDON_MARGIN_HALF
+#define C_Y HILDON_MARGIN_HALF
+
+#define HEADER_HEIGHT 48
+#define MESSAGE_HEIGHT (C_HEIGHT - HEADER_HEIGHT)
+#define MESSAGE_WIDTH (C_WIDTH - 2*HILDON_MARGIN_DEFAULT)
+
+#define BOX_RADIOUS 10
+
+struct _ELHomeAppletPrivate
+{
+        RTComEl *eventlogger;
+
+        GtkWidget *sender;
+        GtkWidget *message;
+        GtkWidget *icon;
+        GtkWidget *unread;
+
+        gint       event_id;
+
+        gboolean   active;
+
+        guint unread_count;
+
+        const gchar *current_font;
+};
+
+HD_DEFINE_PLUGIN_MODULE (ELHomeApplet, el_home_applet, HD_TYPE_HOME_PLUGIN_ITEM);
+
+const gchar* g_module_check_init(GModule *module);
+const gchar*
+g_module_check_init(GModule *module)
+{
+       g_module_make_resident (module);
+       return NULL;
+}
+
+static void
+el_home_applet_class_finalize (ELHomeAppletClass *klass)
+{
+}
+
+static void
+el_home_applet_realize (GtkWidget *widget)
+{
+        GdkScreen *screen;
+
+        screen = gtk_widget_get_screen (widget);
+        gtk_widget_set_colormap (widget,
+                                 gdk_screen_get_rgba_colormap (screen));
+
+        gtk_widget_set_app_paintable (widget,
+                                      TRUE);
+
+        GTK_WIDGET_CLASS (el_home_applet_parent_class)->realize (widget);
+}
+
+/*
+ * Thanks http://cairographics.org/cookbook/roundedrectangles/
+ */
+static void
+rounded_rectangle (cairo_t *cr,
+                   double   x,
+                   double   y,
+                   double   w,
+                   double   h,
+                   double   r)
+{
+        cairo_move_to (cr, x + r, y);
+        cairo_line_to (cr, x + w - r, y);
+        cairo_curve_to (cr, x + w, y,
+                        x + w, y,
+                        x + w, y + r);
+        cairo_line_to (cr, x + w, y + h - r);
+        cairo_curve_to (cr, x + w, y + h,
+                        x + w, y + h,
+                        x + w - r, y + h);
+        cairo_line_to (cr, x + r, y + h);
+        cairo_curve_to (cr, x, y + h,
+                        x, y + h,
+                        x, y + h - r);
+        cairo_line_to (cr, x, y + r);
+        cairo_curve_to (cr, x, y,
+                        x, y,
+                        x + r, y);
+}
+
+static gboolean
+expose_event (GtkWidget *self, GdkEventExpose *event)
+{
+        ELHomeAppletPrivate *priv = EL_HOME_APPLET(self)->priv;
+
+        cairo_t *cr;
+        GdkColor color;
+        float red, green, blue;
+
+        /* find theme active color */
+        gtk_style_lookup_color (self->style, "ActiveTextColor", &color);
+        red = color.red/(float)G_MAXUINT16;
+        green = color.green/(float)G_MAXUINT16;
+        blue = color.blue/(float)G_MAXUINT16;
+
+        cr = gdk_cairo_create (self->window);
+        gdk_cairo_region (cr, event->region);
+        cairo_clip (cr);
+
+        cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
+
+        cairo_set_source_rgba (cr, 0.4f, 0.4f, 0.4f, 0.1f);
+        cairo_set_line_width (cr, 3.0f);
+
+        rounded_rectangle (cr,
+                           C_X,
+                           C_Y,
+                           BOX_WIDTH - 2*C_X,
+                           BOX_HEIGHT - 2*C_Y,
+                           BOX_RADIOUS);
+
+        cairo_close_path(cr);
+        cairo_stroke (cr);
+
+        cairo_set_line_width (cr, 1.0f);
+
+        cairo_translate (cr, C_X, C_Y);
+        cairo_move_to (cr, 0, HEADER_HEIGHT);
+        cairo_line_to (cr, 0, BOX_RADIOUS);
+        cairo_curve_to (cr, 0, 0, 0, 0, BOX_RADIOUS, 0);
+        cairo_line_to (cr, C_WIDTH - BOX_RADIOUS, 0);
+        cairo_curve_to (cr, C_WIDTH, 0, C_WIDTH, 0, C_WIDTH, BOX_RADIOUS);
+        cairo_line_to (cr, C_WIDTH, HEADER_HEIGHT);
+        cairo_line_to (cr, 0, HEADER_HEIGHT);
+
+        cairo_close_path(cr);
+
+        cairo_set_source_rgba (cr, 0.2f, 0.2f, 0.2f, 0.8f);
+        cairo_fill_preserve (cr);
+        cairo_set_source_rgba (cr, red, green, blue, 1.0f);
+        cairo_stroke (cr);
+
+        cairo_move_to (cr, 0, HEADER_HEIGHT);
+        cairo_line_to (cr, 0, C_HEIGHT - BOX_RADIOUS);
+        cairo_curve_to (cr, 0, C_HEIGHT, 0, C_HEIGHT, BOX_RADIOUS, C_HEIGHT);
+        cairo_line_to (cr, C_WIDTH - BOX_RADIOUS, C_HEIGHT);
+        cairo_curve_to (cr, C_WIDTH, C_HEIGHT, C_WIDTH, C_HEIGHT, C_WIDTH, C_HEIGHT - BOX_RADIOUS);
+        cairo_line_to (cr, C_WIDTH, HEADER_HEIGHT);
+        cairo_line_to (cr, 0, HEADER_HEIGHT);
+        cairo_close_path(cr);
+
+        if (priv->active)
+                cairo_set_source_rgba (cr, red, green, blue, 0.8f);
+        else
+                cairo_set_source_rgba (cr, 0.4f, 0.4f, 0.4f, 0.8f);
+        cairo_fill (cr);
+
+        /* cairo_set_source_rgba (cr, red, green, blue, 1.0f); */
+        /* cairo_translate (cr, -C_X, -C_Y); */
+        /* rounded_rectangle (cr, */
+        /*                    C_X, */
+        /*                    C_Y, */
+        /*                    BOX_WIDTH - 2*C_X, */
+        /*                    BOX_HEIGHT - 2*C_Y, */
+        /*                    BOX_RADIOUS); */
+        /* cairo_close_path(cr); */
+        /* cairo_stroke (cr); */
+
+        cairo_destroy (cr);
+
+        return GTK_WIDGET_CLASS (el_home_applet_parent_class)->expose_event (self, event);
+}
+
+static void
+dispose (GObject *self)
+{
+        ELHomeAppletPrivate *priv = EL_HOME_APPLET(self)->priv;
+
+        if (priv->eventlogger){
+                g_object_unref (priv->eventlogger);
+                priv->eventlogger = NULL;
+        }
+
+        G_OBJECT_CLASS (el_home_applet_parent_class)->dispose (self);
+}
+
+static void
+finalize (GObject *self)
+{
+        G_OBJECT_CLASS (el_home_applet_parent_class)->finalize (self);
+}
+
+static void
+show_event (ELHomeApplet *self, RTComElIter *it)
+{
+        ELHomeAppletPrivate *priv = self->priv;
+
+        gchar *message = NULL;
+        gchar *remote = NULL;
+        const gchar *icon_name = NULL;
+
+        if (it && rtcom_el_iter_first (it)){
+                rtcom_el_iter_dup_string (it, "free-text", &message);
+                if (message){
+                        const gchar *service;
+
+                        rtcom_el_iter_get_int (it, "id", &priv->event_id);
+
+                        if(!rtcom_el_iter_dup_string (it, "remote-name", &remote))
+                                rtcom_el_iter_dup_string (it, "remote-id", &remote);
+                        service = rtcom_el_iter_get_service (it);
+                        if (!g_strcmp0 (service, "RTCOM_EL_SERVICE_SMS"))
+                                icon_name = "chat_unread_sms";
+                        else if (!g_strcmp0 (service, "RTCOM_EL_SERVICE_CHAT"))
+                                icon_name = "chat_unread_chat";
+                }
+        }
+        else{
+                priv->event_id = -1;
+        }
+
+        gtk_label_set_text (GTK_LABEL (priv->message), message);
+        gtk_label_set_text (GTK_LABEL (priv->sender), remote);
+        if (icon_name){
+                const gchar *current_icon_name;
+                gtk_image_get_icon_name (GTK_IMAGE (priv->icon),
+                                         &current_icon_name,
+                                         NULL);
+                if (g_strcmp0 (current_icon_name, icon_name))
+                        gtk_image_set_from_icon_name (GTK_IMAGE (priv->icon),
+                                                      icon_name,
+                                                      HILDON_ICON_SIZE_FINGER);
+                gtk_widget_show (priv->icon);
+        }
+        else
+                gtk_widget_hide (priv->icon);
+
+        g_free (message);
+        g_free (remote);
+}
+
+static RTComElIter*
+make_query (RTComEl *el, gint event_id)
+{
+        RTComElQuery *query = NULL;
+        RTComElIter *it = NULL;
+
+        static const gchar *services[] = {"RTCOM_EL_SERVICE_SMS",
+                                          "RTCOM_EL_SERVICE_CHAT",
+                                          NULL};
+        static const gchar *event_types[] = {"RTCOM_EL_EVENTTYPE_SMS_INBOUND",
+                                             "RTCOM_EL_EVENTTYPE_CHAT_INBOUND",
+                                             NULL};
+
+        query = rtcom_el_query_new (el);
+        rtcom_el_query_set_limit (query, 1);
+        if (event_id >= 0){
+                rtcom_el_query_prepare (query,
+                                        "is-read", FALSE, RTCOM_EL_OP_EQUAL,
+                                        "id", event_id, RTCOM_EL_OP_EQUAL,
+                                        "service", services, RTCOM_EL_OP_IN_STRV,
+                                        "event-type", event_types, RTCOM_EL_OP_IN_STRV,
+                                        NULL);
+        }
+        else{
+                rtcom_el_query_prepare (query,
+                                        "is-read", FALSE, RTCOM_EL_OP_EQUAL,
+                                        "service", services, RTCOM_EL_OP_IN_STRV,
+                                        "event-type", event_types, RTCOM_EL_OP_IN_STRV,
+                                        NULL);
+        }
+        it = rtcom_el_get_events (el, query);
+        g_object_unref(query);
+
+        return it;
+}
+
+static void
+update_unread_label (ELHomeApplet *self)
+{
+        ELHomeAppletPrivate *priv = self->priv;
+        gchar *text;
+
+        text = g_strdup_printf ("%d", priv->unread_count);
+        gtk_label_set_text (GTK_LABEL (priv->unread), text);
+        g_free (text);
+}
+
+static gint
+query_unread_events (RTComEl *el)
+{
+        sqlite3 *db;
+        sqlite3_stmt *stmt;
+        int ret;
+        gint count = 0;
+
+        g_object_get (el, "db", &db, NULL);
+
+        if (sqlite3_prepare_v2 (db,
+                                "SELECT SUM(total_events)-SUM(read_events) FROM GroupCache;",
+                                -1,
+                                &stmt,
+                                NULL) != SQLITE_OK){
+                g_error ("%s: can't compile SQL", G_STRFUNC);
+                return -1;
+        }
+
+        while (SQLITE_BUSY == (ret = sqlite3_step (stmt)));
+
+        if (ret == SQLITE_ROW){
+                count = sqlite3_column_int (stmt, 0);
+        }
+        else{
+                g_error ("%s: error while executing SQL", G_STRFUNC);
+        }
+
+        sqlite3_finalize (stmt);
+
+        return count;
+}
+
+static void
+read_event (ELHomeApplet *self)
+{
+        ELHomeAppletPrivate *priv = self->priv;
+        RTComElIter *it = NULL;
+
+        it = make_query (priv->eventlogger, -1);
+        show_event (self, it);
+        if (it) g_object_unref (it);
+}
+
+static void
+mark_as_read (ELHomeApplet *self)
+{
+        ELHomeAppletPrivate *priv = self->priv;
+
+        if (priv->event_id >= 0){
+                rtcom_el_set_read_event (priv->eventlogger,
+                                         priv->event_id,
+                                         TRUE,
+                                         NULL);
+                read_event (self);
+                priv->unread_count--;
+                update_unread_label (self);
+        }
+}
+
+static void
+new_event_cb (RTComEl      *backend,
+              gint          event_id,
+              const gchar  *local_uid,
+              const gchar  *remote_uid,
+              const gchar  *remote_ebook_uid,
+              const gchar  *group_uid,
+              const gchar  *service,
+              ELHomeApplet *self)
+{
+        ELHomeAppletPrivate *priv = self->priv;
+        RTComElIter *it = NULL;
+
+        it = make_query (priv->eventlogger, event_id);
+        if (it){
+                if (rtcom_el_iter_first (it)){
+                        show_event (self, it);
+                        priv->unread_count++;
+                        update_unread_label (self);
+                }
+                g_object_unref (it);
+        }
+}
+
+static void
+event_updated_cb (RTComEl      *backend,
+                  gint          event_id,
+                  const gchar  *local_uid,
+                  const gchar  *remote_uid,
+                  const gchar  *remote_ebook_uid,
+                  const gchar  *group_uid,
+                  const gchar  *service,
+                  ELHomeApplet *self)
+{
+        ELHomeAppletPrivate *priv = self->priv;
+
+        if (event_id == priv->event_id)
+                read_event (self);
+
+        priv->unread_count = query_unread_events (priv->eventlogger);
+        update_unread_label (self);
+}
+
+static gboolean
+button_release_event_cb (GtkWidget      *widget,
+                         GdkEventButton *event,
+                         ELHomeApplet   *self)
+{
+        ELHomeAppletPrivate *priv = self->priv;
+
+        if (priv->active){
+                priv->active = FALSE;
+                gtk_widget_queue_draw (widget);
+#ifndef DEBUG_LAYOUT
+                mark_as_read (self);
+#endif
+        }
+
+        return TRUE;
+}
+
+static gboolean
+button_press_event_cb (GtkWidget      *widget,
+                       GdkEventButton *event,
+                       ELHomeApplet   *self)
+{
+        ELHomeAppletPrivate *priv = self->priv;
+
+        if (priv->event_id > 0){
+                priv->active = TRUE;
+                gtk_widget_queue_draw (widget);
+        }
+
+        return TRUE;
+}
+
+static gboolean
+leave_notify_event_cb (GtkWidget        *widget,
+                       GdkEventCrossing *event,
+                       ELHomeApplet     *self)
+{
+        ELHomeAppletPrivate *priv = self->priv;
+
+        if (priv->active){
+                priv->active = FALSE;
+                gtk_widget_queue_draw (widget);
+        }
+
+        return FALSE;
+}
+
+static void
+el_home_applet_init (ELHomeApplet *self)
+{
+        ELHomeAppletPrivate *priv;
+        GtkWidget *event_box;
+        GtkWidget *hbox, *vbox, *align;
+
+        self->priv = EL_HOME_APPLET_GET_PRIVATE (self);
+        priv = self->priv;
+
+        gtk_widget_set_app_paintable (GTK_WIDGET (self), TRUE);
+
+        priv->unread = gtk_label_new ("12");
+        hildon_helper_set_logical_color (priv->unread,
+                                         GTK_RC_FG,
+                                         GTK_STATE_NORMAL,
+                                         "ActiveTextColor");
+        gtk_misc_set_alignment (GTK_MISC (priv->unread),
+                                1.0f,
+                                0.5f);
+        gtk_widget_set_size_request (priv->unread,
+                                     -1,
+                                     HEADER_HEIGHT);
+
+        priv->icon = gtk_image_new_from_icon_name ("chat_unread_sms",
+                                                   HILDON_ICON_SIZE_FINGER);
+        gtk_misc_set_alignment (GTK_MISC (priv->icon),
+                                0.5f,
+                                0.5f);
+
+        priv->sender = gtk_label_new ("asdf asdf asdf asdf asdf");
+        gtk_misc_set_alignment (GTK_MISC (priv->sender),
+                                0.5f,
+                                0.5f);
+        gtk_label_set_ellipsize (GTK_LABEL (priv->sender),
+                                 PANGO_ELLIPSIZE_END);
+        gtk_widget_set_name (priv->sender, "hildon-shadow-label");
+        hildon_helper_set_logical_font (priv->sender, "SystemFont");
+
+        priv->message = g_object_new (GTK_TYPE_LABEL,
+                                      "label", "asdf asdf adsf asdf asdf asdf asdf asdf",
+                                      "wrap", TRUE,
+                                      "wrap-mode", PANGO_WRAP_WORD_CHAR,
+                                      NULL);
+
+        gtk_misc_set_alignment (GTK_MISC (priv->message),
+                                0.0f,
+                                0.0f);
+        gtk_widget_set_size_request (priv->message,
+                                     MESSAGE_WIDTH,
+                                     MESSAGE_HEIGHT);
+        gtk_widget_set_name (priv->message, "hildon-shadow-label");
+
+        hbox = gtk_hbox_new (FALSE, 0);
+        gtk_box_pack_start (GTK_BOX (hbox), priv->unread, FALSE, FALSE, 0);
+        gtk_box_pack_start (GTK_BOX (hbox), priv->icon, FALSE, FALSE, 0);
+        gtk_box_pack_start (GTK_BOX (hbox), priv->sender, TRUE, TRUE, 0);
+
+        vbox = gtk_vbox_new (FALSE, 0);
+        gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
+        gtk_box_pack_start (GTK_BOX (vbox), priv->message, TRUE, TRUE, 0);
+
+        align = gtk_alignment_new (0.5f, 0.0f, 1.0f, 1.0f);
+        gtk_alignment_set_padding (GTK_ALIGNMENT (align),
+                                   0, 0, HILDON_MARGIN_DEFAULT, HILDON_MARGIN_DEFAULT);
+
+        gtk_container_set_border_width (GTK_CONTAINER (vbox), HILDON_MARGIN_HALF);
+
+        event_box = gtk_event_box_new ();
+        gtk_event_box_set_visible_window (GTK_EVENT_BOX (event_box), FALSE);
+        gtk_widget_set_size_request (event_box, BOX_WIDTH, BOX_HEIGHT);
+
+        gtk_container_add (GTK_CONTAINER (align), vbox);
+        gtk_container_add (GTK_CONTAINER (event_box), align);
+        gtk_container_add (GTK_CONTAINER (self), event_box);
+
+        g_signal_connect (event_box, "button-press-event",
+                G_CALLBACK (button_press_event_cb), self);
+        g_signal_connect (event_box, "button-release-event",
+                G_CALLBACK (button_release_event_cb), self);
+        g_signal_connect (event_box, "leave-notify-event",
+                G_CALLBACK (leave_notify_event_cb), self);
+
+        gtk_widget_show_all (GTK_WIDGET (event_box));
+
+#ifndef DEBUG_LAYOUT
+        priv->eventlogger = rtcom_el_new ();
+        g_signal_connect (priv->eventlogger,
+                          "new-event",
+                          G_CALLBACK (new_event_cb),
+                          self);
+        g_signal_connect (priv->eventlogger,
+                          "event-updated",
+                          G_CALLBACK (event_updated_cb),
+                          self);
+
+        read_event (self);
+        priv->unread_count = query_unread_events (priv->eventlogger);
+        update_unread_label (self);
+#endif
+}
+
+static void
+el_home_applet_class_init (ELHomeAppletClass *klass)
+{
+        GObjectClass *object_class = G_OBJECT_CLASS (klass);
+        GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+
+        object_class->dispose = dispose;
+        object_class->finalize = finalize;
+        widget_class->expose_event = expose_event;
+        widget_class->realize = el_home_applet_realize;
+
+        g_type_class_add_private (klass, sizeof (ELHomeAppletPrivate));
+}
+
diff --git a/src/el-home-applet.h b/src/el-home-applet.h
new file mode 100644 (file)
index 0000000..3ac88ac
--- /dev/null
@@ -0,0 +1,57 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
+/*
+ *  Copyright (C) 2009 Artem Garmash. All rights reserved.
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Contact: Artem Garmash <artemgarmash@gmail.com>
+ *
+ */
+
+#ifndef __EL_HOME_APPLET_H__
+#define __EL_HOME_APPLET_H__
+
+#include <libhildondesktop/libhildondesktop.h>
+
+G_BEGIN_DECLS
+
+#define EL_TYPE_HOME_APPLET            (el_home_applet_get_type ())
+#define EL_HOME_APPLET(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), EL_TYPE_HOME_APPLET, ELHomeApplet))
+#define EL_HOME_APPLET_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), EL_TYPE_HOME_APPLET, ELHomeAppletClass))
+#define EL_IS_HOME_APPLET(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EL_TYPE_HOME_APPLET))
+#define EL_IS_HOME_APPLET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EL_TYPE_HOME_APPLET))
+#define EL_HOME_APPLET_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), EL_TYPE_HOME_APPLET, ELHomeAppletClass))
+
+typedef struct _ELHomeApplet        ELHomeApplet;
+typedef struct _ELHomeAppletClass   ELHomeAppletClass;
+typedef struct _ELHomeAppletPrivate ELHomeAppletPrivate;
+
+struct _ELHomeApplet
+{
+        HDHomePluginItem parent;
+
+        ELHomeAppletPrivate  *priv;
+};
+
+struct _ELHomeAppletClass
+{
+        HDHomePluginItemClass parent;
+};
+
+GType el_home_applet_get_type (void);
+
+G_END_DECLS
+
+#endif
diff --git a/welcome b/welcome
deleted file mode 100644 (file)
index e69de29..0000000