3b7ba5e5ac48f931f965ebc3b0ff6f50837a0b29
[conv-inbox] / src / el-home-applet.c
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
2 /*
3  *  Copyright (C) 2009 Artem Garmash. All rights reserved.
4  *
5  *  This program is free software; you can redistribute it and/or modify
6  *  it under the terms of the GNU General Public License as published by
7  *  the Free Software Foundation; either version 2 of the License, or
8  *  (at your option) any later version.
9  *
10  *  This program is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  *  GNU General Public License for more details.
14  *
15  *  You should have received a copy of the GNU General Public License
16  *  along with this program; if not, write to the Free Software
17  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18  *
19  * Contact: Artem Garmash <artemgarmash@gmail.com>
20  *
21  */
22
23 #include "config.h"
24 #include "el-home-applet.h"
25
26 #include <hildon/hildon.h>
27 #include <rtcom-eventlogger/eventlogger.h>
28 #include <sqlite3.h>
29 #include <string.h>
30
31 #define EL_HOME_APPLET_GET_PRIVATE(obj) ( \
32         G_TYPE_INSTANCE_GET_PRIVATE (obj, \
33                 EL_TYPE_HOME_APPLET, ELHomeAppletPrivate))
34
35 #define BOX_WIDTH 352
36 #define BOX_HEIGHT 266
37
38 #define C_WIDTH (BOX_WIDTH - 2*HILDON_MARGIN_HALF)
39 #define C_HEIGHT (BOX_HEIGHT - 2*HILDON_MARGIN_HALF)
40 #define C_X HILDON_MARGIN_HALF
41 #define C_Y HILDON_MARGIN_HALF
42
43 #define HEADER_HEIGHT 48
44 #define MESSAGE_HEIGHT (C_HEIGHT - HEADER_HEIGHT)
45 #define MESSAGE_WIDTH (C_WIDTH - 2*HILDON_MARGIN_DEFAULT)
46
47 #define BOX_RADIOUS 10
48
49 struct _ELHomeAppletPrivate
50 {
51         RTComEl *eventlogger;
52
53         GtkWidget *sender;
54         GtkWidget *message;
55         GtkWidget *icon;
56         GtkWidget *unread;
57         GtkWidget *received;
58
59         gint       event_id;
60
61         gboolean   active;
62
63         guint unread_count;
64
65         const gchar *current_font;
66
67         guint idle_id;
68         /* new or updated event id */
69         gint  new_event_id;
70
71         GtkWidget *empty;
72 };
73
74 HD_DEFINE_PLUGIN_MODULE (ELHomeApplet, el_home_applet, HD_TYPE_HOME_PLUGIN_ITEM);
75
76 const gchar* g_module_check_init(GModule *module);
77 const gchar*
78 g_module_check_init(GModule *module)
79 {
80         g_module_make_resident (module);
81         return NULL;
82 }
83
84 static void
85 el_home_applet_class_finalize (ELHomeAppletClass *klass)
86 {
87 }
88
89 static void
90 el_home_applet_realize (GtkWidget *widget)
91 {
92         GdkScreen *screen;
93
94         screen = gtk_widget_get_screen (widget);
95         gtk_widget_set_colormap (widget,
96                                  gdk_screen_get_rgba_colormap (screen));
97
98         gtk_widget_set_app_paintable (widget,
99                                       TRUE);
100
101         GTK_WIDGET_CLASS (el_home_applet_parent_class)->realize (widget);
102 }
103
104 /*
105  * Thanks http://cairographics.org/cookbook/roundedrectangles/
106  */
107 static void
108 rounded_rectangle (cairo_t *cr,
109                    double   x,
110                    double   y,
111                    double   w,
112                    double   h,
113                    double   r)
114 {
115         cairo_move_to (cr, x + r, y);
116         cairo_line_to (cr, x + w - r, y);
117         cairo_curve_to (cr, x + w, y,
118                         x + w, y,
119                         x + w, y + r);
120         cairo_line_to (cr, x + w, y + h - r);
121         cairo_curve_to (cr, x + w, y + h,
122                         x + w, y + h,
123                         x + w - r, y + h);
124         cairo_line_to (cr, x + r, y + h);
125         cairo_curve_to (cr, x, y + h,
126                         x, y + h,
127                         x, y + h - r);
128         cairo_line_to (cr, x, y + r);
129         cairo_curve_to (cr, x, y,
130                         x, y,
131                         x + r, y);
132 }
133
134 static gboolean
135 expose_event (GtkWidget *self, GdkEventExpose *event)
136 {
137         ELHomeAppletPrivate *priv = EL_HOME_APPLET(self)->priv;
138
139         cairo_t *cr;
140         GdkColor color;
141         float red, green, blue;
142
143         /* find theme active color */
144         gtk_style_lookup_color (self->style, "ActiveTextColor", &color);
145         red = color.red/(float)G_MAXUINT16;
146         green = color.green/(float)G_MAXUINT16;
147         blue = color.blue/(float)G_MAXUINT16;
148
149         cr = gdk_cairo_create (self->window);
150         gdk_cairo_region (cr, event->region);
151         cairo_clip (cr);
152
153         /* draw bound box */
154         cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
155
156         cairo_set_source_rgba (cr, 0.4f, 0.4f, 0.4f, 0.1f);
157         cairo_set_line_width (cr, 3.0f);
158
159         rounded_rectangle (cr,
160                            C_X,
161                            C_Y,
162                            BOX_WIDTH - 2*C_X,
163                            BOX_HEIGHT - 2*C_Y,
164                            BOX_RADIOUS);
165
166         cairo_close_path(cr);
167         cairo_stroke (cr);
168
169         /* draw header */
170         cairo_set_line_width (cr, 1.0f);
171
172         cairo_translate (cr, C_X, C_Y);
173         cairo_move_to (cr, 0, HEADER_HEIGHT);
174         cairo_line_to (cr, 0, BOX_RADIOUS);
175         cairo_curve_to (cr, 0, 0, 0, 0, BOX_RADIOUS, 0);
176         cairo_line_to (cr, C_WIDTH - BOX_RADIOUS, 0);
177         cairo_curve_to (cr, C_WIDTH, 0, C_WIDTH, 0, C_WIDTH, BOX_RADIOUS);
178         cairo_line_to (cr, C_WIDTH, HEADER_HEIGHT);
179         cairo_line_to (cr, 0, HEADER_HEIGHT);
180
181         cairo_close_path(cr);
182
183         cairo_set_source_rgba (cr, 0.2f, 0.2f, 0.2f, 0.8f);
184         cairo_fill_preserve (cr);
185         cairo_set_source_rgba (cr, red, green, blue, 1.0f);
186         cairo_stroke (cr);
187
188         /* draw body */
189         cairo_move_to (cr, 0, HEADER_HEIGHT);
190         cairo_line_to (cr, 0, C_HEIGHT - BOX_RADIOUS);
191         cairo_curve_to (cr, 0, C_HEIGHT, 0, C_HEIGHT, BOX_RADIOUS, C_HEIGHT);
192         cairo_line_to (cr, C_WIDTH - BOX_RADIOUS, C_HEIGHT);
193         cairo_curve_to (cr, C_WIDTH, C_HEIGHT, C_WIDTH, C_HEIGHT, C_WIDTH, C_HEIGHT - BOX_RADIOUS);
194         cairo_line_to (cr, C_WIDTH, HEADER_HEIGHT);
195         cairo_line_to (cr, 0, HEADER_HEIGHT);
196         cairo_close_path(cr);
197
198         /* draw body filling depending on (in)active state */
199         cairo_pattern_t *grad;
200         grad = cairo_pattern_create_linear(0, HEADER_HEIGHT,
201                                            0, C_HEIGHT);
202
203         if (priv->active){
204                 cairo_pattern_add_color_stop_rgba (grad, 0.5f,
205                                                    red, green, blue, 0.8f);
206                 cairo_pattern_add_color_stop_rgba (grad, 1.0f,
207                                                    red/2, green/2, blue/2, 0.8f);
208         }
209         else {
210                 cairo_pattern_add_color_stop_rgba (grad, 0.5f,
211                                                    0.4f, 0.4f, 0.4f, 0.8f);
212                 cairo_pattern_add_color_stop_rgba (grad, 1.0f,
213                                                    0.2f, 0.2f, 0.2f, 0.8f);
214         }
215         cairo_set_source (cr, grad);
216         cairo_fill (cr);
217
218         /* cairo_set_source_rgba (cr, red, green, blue, 1.0f); */
219         /* cairo_translate (cr, -C_X, -C_Y); */
220         /* rounded_rectangle (cr, */
221         /*                    C_X, */
222         /*                    C_Y, */
223         /*                    BOX_WIDTH - 2*C_X, */
224         /*                    BOX_HEIGHT - 2*C_Y, */
225         /*                    BOX_RADIOUS); */
226         /* cairo_close_path(cr); */
227         /* cairo_stroke (cr); */
228         cairo_pattern_destroy (grad);
229         cairo_destroy (cr);
230
231         return GTK_WIDGET_CLASS (el_home_applet_parent_class)->expose_event (self, event);
232 }
233
234 static void
235 dispose (GObject *self)
236 {
237         ELHomeAppletPrivate *priv = EL_HOME_APPLET(self)->priv;
238
239         if (priv->idle_id){
240                 g_source_remove (priv->idle_id);
241                 priv->idle_id = 0;
242         }
243         if (priv->eventlogger){
244                 g_object_unref (priv->eventlogger);
245                 priv->eventlogger = NULL;
246         }
247
248         G_OBJECT_CLASS (el_home_applet_parent_class)->dispose (self);
249 }
250
251 static void
252 finalize (GObject *self)
253 {
254         G_OBJECT_CLASS (el_home_applet_parent_class)->finalize (self);
255 }
256
257 static gchar*
258 format_time (time_t t)
259 {
260         static const guint RESULT_SIZE = 32;
261
262         time_t now;
263         struct tm now_tm, t_tm;
264         const gchar *format = "%Y.%m.%d %T";
265         gchar *result = g_malloc0 (RESULT_SIZE);
266
267         now = time (NULL);
268         localtime_r (&now, &now_tm);
269         localtime_r (&t, &t_tm);
270
271         if ((now_tm.tm_year == t_tm.tm_year) &&
272             (now_tm.tm_mon  == t_tm.tm_mon) &&
273             (now_tm.tm_mday == t_tm.tm_mday))
274                 format = "%T";
275
276         strftime (result, RESULT_SIZE, format, &t_tm);
277
278         return result;
279 }
280
281 static void
282 show_event (ELHomeApplet *self, RTComElIter *it)
283 {
284         ELHomeAppletPrivate *priv = self->priv;
285
286         gchar *message = NULL;
287         gchar *remote = NULL;
288         gchar *received = NULL;
289         const gchar *icon_name = NULL;
290
291         if (it && rtcom_el_iter_first (it)){
292                 rtcom_el_iter_dup_string (it, "free-text", &message);
293                 if (message){
294                         const gchar *service;
295                         time_t received_t;
296
297                         rtcom_el_iter_get_int (it, "id", &priv->event_id);
298                         if (rtcom_el_iter_get_int (it, "start-time", (gint*)&received_t))
299                                 received = format_time (received_t);
300
301                         if(!rtcom_el_iter_dup_string (it, "remote-name", &remote))
302                                 rtcom_el_iter_dup_string (it, "remote-id", &remote);
303                         service = rtcom_el_iter_get_service (it);
304                         if (!g_strcmp0 (service, "RTCOM_EL_SERVICE_SMS"))
305                                 icon_name = "chat_unread_sms";
306                         else if (!g_strcmp0 (service, "RTCOM_EL_SERVICE_CHAT"))
307                                 icon_name = "chat_unread_chat";
308                 }
309         }
310         else{
311                 priv->event_id = -1;
312         }
313
314         if (message){
315                 if (!GTK_WIDGET_VISIBLE (priv->message))
316                         gtk_widget_show (priv->message);
317                 gtk_label_set_text (GTK_LABEL (priv->message), message);
318         }
319         else{
320                 gtk_widget_hide (priv->message);
321                 gtk_widget_show (priv->empty);
322         }
323
324         gtk_label_set_text (GTK_LABEL (priv->sender), remote);
325         gtk_label_set_text (GTK_LABEL (priv->received), received);
326
327         if (icon_name){
328                 const gchar *current_icon_name;
329                 gtk_image_get_icon_name (GTK_IMAGE (priv->icon),
330                                          &current_icon_name,
331                                          NULL);
332                 if (g_strcmp0 (current_icon_name, icon_name))
333                         gtk_image_set_from_icon_name (GTK_IMAGE (priv->icon),
334                                                       icon_name,
335                                                       HILDON_ICON_SIZE_FINGER);
336                 gtk_widget_show (priv->icon);
337         }
338         else
339                 gtk_widget_hide (priv->icon);
340
341         g_free (message);
342         g_free (remote);
343 }
344
345 static RTComElIter*
346 make_query (RTComEl *el, gint event_id)
347 {
348         RTComElQuery *query = NULL;
349         RTComElIter *it = NULL;
350
351         static const gchar *services[] = {"RTCOM_EL_SERVICE_SMS",
352                                           "RTCOM_EL_SERVICE_CHAT",
353                                           NULL};
354         static const gchar *event_types[] = {"RTCOM_EL_EVENTTYPE_SMS_INBOUND",
355                                              "RTCOM_EL_EVENTTYPE_CHAT_INBOUND",
356                                              NULL};
357
358         query = rtcom_el_query_new (el);
359         rtcom_el_query_set_limit (query, 1);
360         if (event_id >= 0){
361                 rtcom_el_query_prepare (query,
362                                         "is-read", FALSE, RTCOM_EL_OP_EQUAL,
363                                         "id", event_id, RTCOM_EL_OP_EQUAL,
364                                         "service", services, RTCOM_EL_OP_IN_STRV,
365                                         "event-type", event_types, RTCOM_EL_OP_IN_STRV,
366                                         NULL);
367         }
368         else{
369                 rtcom_el_query_prepare (query,
370                                         "is-read", FALSE, RTCOM_EL_OP_EQUAL,
371                                         "service", services, RTCOM_EL_OP_IN_STRV,
372                                         "event-type", event_types, RTCOM_EL_OP_IN_STRV,
373                                         NULL);
374         }
375         it = rtcom_el_get_events (el, query);
376         g_object_unref(query);
377
378         return it;
379 }
380
381 static void
382 update_unread_label (ELHomeApplet *self)
383 {
384         ELHomeAppletPrivate *priv = self->priv;
385         gchar *text;
386
387         if (priv->unread_count > 0){
388                 text = g_strdup_printf ("%d", priv->unread_count);
389                 gtk_label_set_text (GTK_LABEL (priv->unread), text);
390                 g_free (text);
391         }
392         else
393                 gtk_label_set_text (GTK_LABEL (priv->unread), NULL);
394 }
395
396 static gint
397 query_unread_events (RTComEl *el)
398 {
399         sqlite3 *db;
400         sqlite3_stmt *stmt;
401         int ret;
402         gint count = 0;
403
404         g_object_get (el, "db", &db, NULL);
405
406         if (sqlite3_prepare_v2 (db,
407                                 "SELECT SUM(total_events)-SUM(read_events) FROM GroupCache;",
408                                 -1,
409                                 &stmt,
410                                 NULL) != SQLITE_OK){
411                 g_error ("%s: can't compile SQL", G_STRFUNC);
412                 return -1;
413         }
414
415         while (SQLITE_BUSY == (ret = sqlite3_step (stmt)));
416
417         if (ret == SQLITE_ROW){
418                 count = sqlite3_column_int (stmt, 0);
419         }
420         else{
421                 g_error ("%s: error while executing SQL", G_STRFUNC);
422         }
423
424         sqlite3_finalize (stmt);
425
426         return count;
427 }
428
429 static void
430 read_event (ELHomeApplet *self)
431 {
432         ELHomeAppletPrivate *priv = self->priv;
433         RTComElIter *it = NULL;
434
435         it = make_query (priv->eventlogger, -1);
436         show_event (self, it);
437         if (it) g_object_unref (it);
438 }
439
440 static void
441 mark_as_read (ELHomeApplet *self)
442 {
443         ELHomeAppletPrivate *priv = self->priv;
444
445         if (priv->event_id >= 0){
446                 rtcom_el_set_read_event (priv->eventlogger,
447                                          priv->event_id,
448                                          TRUE,
449                                          NULL);
450                 read_event (self);
451                 priv->unread_count--;
452                 update_unread_label (self);
453         }
454 }
455
456 static gboolean
457 read_new_event (ELHomeApplet *self)
458 {
459         ELHomeAppletPrivate *priv = self->priv;
460
461         if (priv->new_event_id >= 0){
462                 RTComElIter *it = NULL;
463                 it = make_query (priv->eventlogger, priv->new_event_id);
464                 if (it){
465                         if (rtcom_el_iter_first (it))
466                                 show_event (self, it);
467                         g_object_unref (it);
468                 }
469                 priv->unread_count = query_unread_events (priv->eventlogger);
470                 update_unread_label (self);
471         }
472         priv->new_event_id = -1;
473         priv->idle_id = 0;
474
475         return FALSE;
476 }
477
478 static void
479 add_new_idle (ELHomeApplet *self)
480 {
481         ELHomeAppletPrivate *priv = self->priv;
482
483         if (priv->idle_id)
484                 g_source_remove (priv->idle_id);
485         priv->idle_id = g_idle_add ((GSourceFunc)read_new_event,
486                                     self);
487 }
488
489 static void
490 new_event_cb (RTComEl      *backend,
491               gint          event_id,
492               const gchar  *local_uid,
493               const gchar  *remote_uid,
494               const gchar  *remote_ebook_uid,
495               const gchar  *group_uid,
496               const gchar  *service,
497               ELHomeApplet *self)
498 {
499         ELHomeAppletPrivate *priv = self->priv;
500
501         priv->new_event_id = event_id;
502         add_new_idle (self);
503 }
504
505 static gboolean
506 button_release_event_cb (GtkWidget      *widget,
507                          GdkEventButton *event,
508                          ELHomeApplet   *self)
509 {
510         ELHomeAppletPrivate *priv = self->priv;
511
512         if (priv->active){
513                 priv->active = FALSE;
514                 gtk_widget_queue_draw (widget);
515 #ifndef DEBUG_LAYOUT
516                 mark_as_read (self);
517 #endif
518         }
519
520         return TRUE;
521 }
522
523 static gboolean
524 button_press_event_cb (GtkWidget      *widget,
525                        GdkEventButton *event,
526                        ELHomeApplet   *self)
527 {
528         ELHomeAppletPrivate *priv = self->priv;
529
530         if (priv->event_id > 0){
531                 priv->active = TRUE;
532                 gtk_widget_queue_draw (widget);
533         }
534
535         return TRUE;
536 }
537
538 static gboolean
539 leave_notify_event_cb (GtkWidget        *widget,
540                        GdkEventCrossing *event,
541                        ELHomeApplet     *self)
542 {
543         ELHomeAppletPrivate *priv = self->priv;
544
545         if (priv->active){
546                 priv->active = FALSE;
547                 gtk_widget_queue_draw (widget);
548         }
549
550         return FALSE;
551 }
552
553 static void
554 el_home_applet_init (ELHomeApplet *self)
555 {
556         ELHomeAppletPrivate *priv;
557         GtkWidget *event_box;
558         GtkWidget *hbox, *vbox, *align;
559
560         self->priv = EL_HOME_APPLET_GET_PRIVATE (self);
561         priv = self->priv;
562
563         gtk_widget_set_app_paintable (GTK_WIDGET (self), TRUE);
564
565         priv->unread = gtk_label_new ("12");
566         hildon_helper_set_logical_color (priv->unread,
567                                          GTK_RC_FG,
568                                          GTK_STATE_NORMAL,
569                                          "ActiveTextColor");
570         gtk_misc_set_alignment (GTK_MISC (priv->unread),
571                                 1.0f,
572                                 0.5f);
573         gtk_widget_set_size_request (priv->unread,
574                                      -1,
575                                      HEADER_HEIGHT);
576
577         priv->icon = gtk_image_new_from_icon_name ("chat_unread_sms",
578                                                    HILDON_ICON_SIZE_FINGER);
579         gtk_misc_set_alignment (GTK_MISC (priv->icon),
580                                 0.5f,
581                                 0.5f);
582
583         priv->sender = gtk_label_new ("asdf asdf asdf asdf asdf");
584         gtk_misc_set_alignment (GTK_MISC (priv->sender),
585                                 0.5f,
586                                 0.5f);
587         gtk_label_set_ellipsize (GTK_LABEL (priv->sender),
588                                  PANGO_ELLIPSIZE_END);
589         gtk_widget_set_name (priv->sender, "hildon-shadow-label");
590         hildon_helper_set_logical_font (priv->sender, "SystemFont");
591
592         priv->message = g_object_new (GTK_TYPE_LABEL,
593                                       "label", "asdf asdf adsf asdf asdf asdf asdf asdf",
594                                       "wrap", TRUE,
595                                       "wrap-mode", PANGO_WRAP_WORD_CHAR,
596                                       NULL);
597
598         gtk_misc_set_alignment (GTK_MISC (priv->message),
599                                 0.0f,
600                                 0.0f);
601         gtk_widget_set_size_request (priv->message,
602                                      MESSAGE_WIDTH,
603                                      MESSAGE_HEIGHT);
604         gtk_widget_set_name (priv->message, "hildon-shadow-label");
605
606         /* TODO: l10n */
607         priv->empty = gtk_label_new ("No new messages");
608         gtk_widget_set_name (priv->empty, "hildon-shadow-label");
609         GTK_WIDGET_SET_FLAGS (priv->empty, GTK_NO_SHOW_ALL);
610
611         priv->received = gtk_label_new ("aewf aewf aewf awef");
612         gtk_misc_set_alignment (GTK_MISC (priv->received),
613                                 1.0f,
614                                 0.5f);
615         gtk_widget_set_size_request (priv->received,
616                                      MESSAGE_WIDTH,
617                                      -1);
618         hildon_helper_set_logical_font (priv->received, "SmallSystemFont");
619         gtk_widget_set_name (priv->received, "hildon-shadow-label");
620
621         hbox = gtk_hbox_new (FALSE, 0);
622         gtk_box_pack_start (GTK_BOX (hbox), priv->unread, FALSE, FALSE, 0);
623         gtk_box_pack_start (GTK_BOX (hbox), priv->icon, FALSE, FALSE, 0);
624         gtk_box_pack_start (GTK_BOX (hbox), priv->sender, TRUE, TRUE, 0);
625
626         vbox = gtk_vbox_new (FALSE, 0);
627         gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
628         gtk_box_pack_start (GTK_BOX (vbox), priv->message, TRUE, TRUE, 0);
629         gtk_box_pack_start (GTK_BOX (vbox), priv->empty, FALSE, FALSE, 0);
630         gtk_box_pack_start (GTK_BOX (vbox), priv->received, FALSE, FALSE, 0);
631
632         align = gtk_alignment_new (0.5f, 0.0f, 1.0f, 1.0f);
633         gtk_alignment_set_padding (GTK_ALIGNMENT (align),
634                                    0, 0, HILDON_MARGIN_DEFAULT, HILDON_MARGIN_DEFAULT);
635
636         gtk_container_set_border_width (GTK_CONTAINER (vbox), HILDON_MARGIN_HALF);
637
638         event_box = gtk_event_box_new ();
639         gtk_event_box_set_visible_window (GTK_EVENT_BOX (event_box), FALSE);
640         gtk_widget_set_size_request (event_box, BOX_WIDTH, BOX_HEIGHT);
641
642         gtk_container_add (GTK_CONTAINER (align), vbox);
643         gtk_container_add (GTK_CONTAINER (event_box), align);
644         gtk_container_add (GTK_CONTAINER (self), event_box);
645
646         g_signal_connect (event_box, "button-press-event",
647                 G_CALLBACK (button_press_event_cb), self);
648         g_signal_connect (event_box, "button-release-event",
649                 G_CALLBACK (button_release_event_cb), self);
650         g_signal_connect (event_box, "leave-notify-event",
651                 G_CALLBACK (leave_notify_event_cb), self);
652
653         gtk_widget_show_all (GTK_WIDGET (event_box));
654
655 #ifndef DEBUG_LAYOUT
656         priv->eventlogger = rtcom_el_new ();
657         g_signal_connect (priv->eventlogger,
658                           "new-event",
659                           G_CALLBACK (new_event_cb),
660                           self);
661         g_signal_connect (priv->eventlogger,
662                           "event-updated",
663                           G_CALLBACK (new_event_cb),
664                           self);
665
666         read_event (self);
667         priv->unread_count = query_unread_events (priv->eventlogger);
668         update_unread_label (self);
669 #endif
670 }
671
672 static void
673 el_home_applet_class_init (ELHomeAppletClass *klass)
674 {
675         GObjectClass *object_class = G_OBJECT_CLASS (klass);
676         GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
677
678         object_class->dispose = dispose;
679         object_class->finalize = finalize;
680         widget_class->expose_event = expose_event;
681         widget_class->realize = el_home_applet_realize;
682
683         g_type_class_add_private (klass, sizeof (ELHomeAppletPrivate));
684 }
685