X-Git-Url: https://vcs.maemo.org/git/?a=blobdiff_plain;f=src%2Fel-home-applet.c;h=1145b61ba5d75d750b482763e3f62733c5d7846a;hb=9c9915002adba45b1e20daa2d95babb76633026c;hp=ab65dbc0716560fad753d3a5971f60defc4a3b5e;hpb=fe78a609a712a6f3db3348172dff0cd49c870a52;p=conv-inbox diff --git a/src/el-home-applet.c b/src/el-home-applet.c index ab65dbc..1145b61 100644 --- a/src/el-home-applet.c +++ b/src/el-home-applet.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -143,6 +144,8 @@ struct _ELHomeAppletPrivate gchar *local_id; gchar *group_uid; OssoABookContact *contact; + + gboolean time_fmt_24h; }; HD_DEFINE_PLUGIN_MODULE (ELHomeApplet, el_home_applet, HD_TYPE_HOME_PLUGIN_ITEM); @@ -151,8 +154,8 @@ const gchar* g_module_check_init (GModule *module); const gchar* g_module_check_init (GModule *module) { - g_module_make_resident (module); - return NULL; + g_module_make_resident (module); + return NULL; } static void @@ -921,25 +924,40 @@ start_aggregator (ELHomeApplet *self) } static gchar* -format_time (time_t t) +format_time (time_t t, gboolean time_fmt_24h) { - static const guint RESULT_SIZE = 32; + static const guint RESULT_SIZE = 64; time_t now; struct tm now_tm, t_tm; - const gchar *format = "%x %X"; + const gchar *time_format; gchar *result = g_malloc0 (RESULT_SIZE); now = time (NULL); localtime_r (&now, &now_tm); localtime_r (&t, &t_tm); + if (time_fmt_24h) + time_format = "wdgt_va_24h_time"; + else + time_format = now_tm.tm_hour > 11 ? + "wdgt_va_12h_time_pm": + "wdgt_va_12h_time_am"; + if ((now_tm.tm_year == t_tm.tm_year) && (now_tm.tm_mon == t_tm.tm_mon) && (now_tm.tm_mday == t_tm.tm_mday)) - format = "%X"; - - strftime (result, RESULT_SIZE, format, &t_tm); + strftime (result, + RESULT_SIZE, + dgettext ("hildon-libs", time_format), + &t_tm); + else { + gchar *full_format = g_strdup_printf ("%s %s", + dgettext ("hildon-libs", "wdgt_va_date"), + dgettext ("hildon-libs", time_format)); + strftime (result, RESULT_SIZE, full_format, &t_tm); + g_free (full_format); + } return result; } @@ -970,7 +988,7 @@ show_event (ELHomeApplet *self, RTComElIter *it) priv->event_id = g_value_get_int (g_value_array_get_nth (event, 0)); received_t = g_value_get_int (g_value_array_get_nth (event, 1)); - received = format_time (received_t); + received = format_time (received_t, priv->time_fmt_24h); priv->local_id = _VARR_DUP_STR (event, 2); priv->remote_id = _VARR_DUP_STR (event, 3); if (priv->remote_id && priv->remote_id[0]) { @@ -1485,6 +1503,28 @@ new_event_cb (RTComEl *backend, 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) { @@ -1632,9 +1672,7 @@ button_release_event_cb (GtkWidget *widget, self); } else -#ifndef DEBUG_LAYOUT mark_as_read (self); -#endif break; default:; } @@ -1674,13 +1712,14 @@ el_home_applet_init (ELHomeApplet *self) GtkWidget *event_box; GtkWidget *hbox, *vbox, *align, *footer; GtkWidget *w; + GConfClient *gconf; 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"); + priv->unread = gtk_label_new (NULL); gtk_misc_set_alignment (GTK_MISC (priv->unread), 0.0f, 0.5f); @@ -1691,7 +1730,7 @@ el_home_applet_init (ELHomeApplet *self) 0.5f, 0.5f); - priv->sender = gtk_label_new ("asdf asdf asdf asdf asdf"); + priv->sender = gtk_label_new (NULL); gtk_misc_set_alignment (GTK_MISC (priv->sender), 0.5f, 0.55f); @@ -1703,8 +1742,6 @@ el_home_applet_init (ELHomeApplet *self) C_WIDTH, HILDON_ICON_PIXEL_SIZE_THUMB); - priv->message = g_strdup ("One two three four five six seven eight nine ten"); - /* construt empty table */ priv->empty = gtk_fixed_new (); @@ -1734,7 +1771,7 @@ el_home_applet_init (ELHomeApplet *self) gtk_widget_hide (GTK_WIDGET (priv->empty)); GTK_WIDGET_SET_FLAGS (priv->empty, GTK_NO_SHOW_ALL); - priv->received = gtk_label_new ("aewf aewf aewf awef"); + priv->received = gtk_label_new (NULL); gtk_misc_set_alignment (GTK_MISC (priv->received), 1.0f, 0.5f); @@ -1802,7 +1839,6 @@ el_home_applet_init (ELHomeApplet *self) gtk_widget_show_all (GTK_WIDGET (event_box)); -#ifndef DEBUG_LAYOUT priv->eventlogger = rtcom_el_new (); g_signal_connect (priv->eventlogger, "new-event", @@ -1812,11 +1848,28 @@ el_home_applet_init (ELHomeApplet *self) "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); osso_abook_init_with_name (PACKAGE, NULL); + gconf = gconf_client_get_default (); + priv->time_fmt_24h = gconf_client_get_bool (gconf, + "/apps/clock/time-format", + NULL); + g_object_unref (gconf); + add_new_idle (self); -#endif } static void @@ -1832,4 +1885,3 @@ el_home_applet_class_init (ELHomeAppletClass *klass) g_type_class_add_private (klass, sizeof (ELHomeAppletPrivate)); } -