OssoABookContact *contact;
gboolean time_fmt_24h;
+
+ guint init_timer;
};
HD_DEFINE_PLUGIN_MODULE (ELHomeApplet, el_home_applet, HD_TYPE_HOME_PLUGIN_ITEM);
{
ELHomeAppletPrivate *priv = self->priv;
+ g_return_if_fail (priv->contact);
+
gtk_label_set_text (GTK_LABEL (priv->sender),
osso_abook_contact_get_display_name (priv->contact));
resize_sender (priv);
}
static void
-reset_contact (ELHomeApplet *self)
+reset_contact (ELHomeApplet *self, gboolean resize)
{
ELHomeAppletPrivate *priv = self->priv;
priv->contact = NULL;
}
- resize_sender (priv);
+ if (resize)
+ resize_sender (priv);
}
static void
for (contact_id = ids; *contact_id; contact_id++) {
if (strcmp (*contact_id, priv->contact_id) == 0) {
- reset_contact (self);
+ reset_contact (self, TRUE);
gtk_widget_queue_draw (GTK_WIDGET (self));
return;
}
if (strcmp (*contact_id, uid) == 0) {
- reset_contact (self);
+ reset_contact (self, TRUE);
resolve_contact (self);
gtk_widget_queue_draw (GTK_WIDGET (self));
return;
}
static void
-clean_contact (ELHomeApplet *self)
+clean_contact (ELHomeApplet *self, gboolean resize)
{
ELHomeAppletPrivate *priv = self->priv;
- reset_contact (self);
+ reset_contact (self, resize);
if (priv->aggregator) {
if (priv->aggregator_ready_closure){
{
ELHomeAppletPrivate *priv = EL_HOME_APPLET(self)->priv;
+ if (priv->init_timer) {
+ g_source_remove (priv->init_timer);
+ priv->init_timer = 0;
+ }
+
stop_scroll_anim (priv);
if (priv->idle_id) {
g_source_remove (priv->idle_id);
}
clean_state (EL_HOME_APPLET (self));
- clean_contact (EL_HOME_APPLET (self));
+ clean_contact (EL_HOME_APPLET (self), FALSE);
G_OBJECT_CLASS (el_home_applet_parent_class)->dispose (self);
}
if (priv->event_id >= 0) {
gboolean new_account = g_strcmp0 (priv->local_id, local_id);
- if (g_strcmp0 (priv->remote_id, remote_id) || new_account) {
- clean_contact (self);
+ if (g_strcmp0 (priv->remote_id, remote_id) ||
+ new_account ||
+ !priv->contact) {
+ clean_contact (self, TRUE);
start_aggregator (self);
}
- else {
+ else if (priv->contact) {
show_contact (self);
}
dgettext ("rtcom-messaging-ui",
"messaging_ap_conversations"));
- clean_contact (self);
+ clean_contact (self, TRUE);
gtk_widget_hide (priv->icon);
}
ELHomeAppletPrivate *priv = self->priv;
read_event (self);
- priv->unread_count = query_unread_events (priv->eventlogger);
+
+ if (priv->event_id >= 0)
+ priv->unread_count = query_unread_events (priv->eventlogger);
+ else
+ priv->unread_count = 0;
+
update_unread_label (self);
priv->idle_id = 0;
add_new_idle (self);
}
+static void
+all_deleted_cb (RTComEl *backend,
+ const gchar *service,
+ ELHomeApplet *self)
+{
+ new_event_cb (backend,
+ 0,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ service,
+ self);
+}
+
+static void
+refresh_hint_cb (RTComEl *backend,
+ ELHomeApplet *self)
+{
+ add_new_idle (self);
+}
+
static gboolean
scroll_anim_cb (ELHomeApplet *self)
{
return FALSE;
}
+static gboolean
+init_eventlogger (ELHomeApplet *self)
+{
+ ELHomeAppletPrivate *priv = self->priv;
+
+ priv->eventlogger = rtcom_el_new ();
+
+ /* check that db is initialized */
+ gpointer *db = NULL;
+ g_object_get (priv->eventlogger, "db", &db, NULL);
+ if (!db) {
+ static int trial = 0;
+
+ g_object_unref (priv->eventlogger);
+ priv->eventlogger = NULL;
+
+ if (trial == 0) {
+ trial++;
+ priv->init_timer = g_timeout_add_seconds (5,
+ (GSourceFunc)init_eventlogger,
+ self);
+ return TRUE; /* return value doesn't matter */
+ }
+ else if (trial < 5) {
+ trial++;
+ return TRUE;
+ }
+ else {
+ g_error ("Failed to init eventlogger");
+ return FALSE;
+ }
+ }
+
+ g_signal_connect (priv->eventlogger,
+ "new-event",
+ G_CALLBACK (new_event_cb),
+ self);
+ g_signal_connect (priv->eventlogger,
+ "event-updated",
+ G_CALLBACK (new_event_cb),
+ self);
+ g_signal_connect (priv->eventlogger,
+ "event-deleted",
+ G_CALLBACK (new_event_cb),
+ self);
+ g_signal_connect (priv->eventlogger,
+ "all-deleted",
+ G_CALLBACK (all_deleted_cb),
+ self);
+ g_signal_connect (priv->eventlogger,
+ "refresh-hint",
+ G_CALLBACK (refresh_hint_cb),
+ self);
+
+ add_new_idle (self);
+
+ priv->init_timer = 0;
+
+ return FALSE;
+}
+
static void
el_home_applet_init (ELHomeApplet *self)
{
gtk_widget_show_all (GTK_WIDGET (event_box));
- 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 (new_event_cb),
- self);
osso_abook_init_with_name (PACKAGE, NULL);
NULL);
g_object_unref (gconf);
- add_new_idle (self);
+ init_eventlogger (self);
}
static void