aboutsummaryrefslogtreecommitdiff
path: root/src/datetime-service.c
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2010-07-12 15:09:39 -0500
committerTed Gould <ted@gould.cx>2010-07-12 15:09:39 -0500
commit4117028fe68956d4c8b1db460a908a5779410421 (patch)
treeb6eb89f431c7f259c0b0a8a974ac9eba8758706a /src/datetime-service.c
parent4edb23e4a529f287cec6bbc18153b2e65df11f32 (diff)
downloadayatana-indicator-datetime-4117028fe68956d4c8b1db460a908a5779410421.tar.gz
ayatana-indicator-datetime-4117028fe68956d4c8b1db460a908a5779410421.tar.bz2
ayatana-indicator-datetime-4117028fe68956d4c8b1db460a908a5779410421.zip
Setting up the update of the label for the date.
Diffstat (limited to 'src/datetime-service.c')
-rw-r--r--src/datetime-service.c32
1 files changed, 31 insertions, 1 deletions
diff --git a/src/datetime-service.c b/src/datetime-service.c
index 06b64c1..37e5af4 100644
--- a/src/datetime-service.c
+++ b/src/datetime-service.c
@@ -19,6 +19,34 @@ static DbusmenuMenuitem * root = NULL;
static DbusmenuMenuitem * date = NULL;
static DbusmenuMenuitem * calendar = NULL;
+/* Updates the label in the date menuitem */
+static gboolean
+update_datetime (gpointer user_data)
+{
+ g_debug("Updating Date/Time");
+
+ gchar longstr[128];
+ time_t t;
+ struct tm *ltime;
+
+ t = time(NULL);
+ ltime = localtime(&t);
+ if (ltime == NULL) {
+ g_warning("Error getting local time");
+ dbusmenu_menuitem_property_set(date, DBUSMENU_MENUITEM_PROP_LABEL, _("Error getting time"));
+ return FALSE;
+ }
+
+ /* Note: may require some localization tweaks */
+ strftime(longstr, 128, "%A, %e %B %Y", ltime);
+
+ gchar * utf8 = g_locale_to_utf8(longstr, -1, NULL, NULL, NULL);
+ dbusmenu_menuitem_property_set(date, DBUSMENU_MENUITEM_PROP_LABEL, utf8);
+ g_free(utf8);
+
+ return FALSE;
+}
+
/* Run a particular program based on an activation */
static void
activate_cb (DbusmenuMenuitem * menuitem, guint timestamp, const gchar *command)
@@ -65,7 +93,9 @@ build_menus (DbusmenuMenuitem * root)
dbusmenu_menuitem_property_set (date, DBUSMENU_MENUITEM_PROP_LABEL, _("No date yet..."));
dbusmenu_menuitem_property_set_bool(date, DBUSMENU_MENUITEM_PROP_ENABLED, FALSE);
dbusmenu_menuitem_child_append(root, date);
- //update_label(self);
+
+ g_idle_add(update_datetime, NULL);
+ /* TODO: Set up updating daily */
}
if (calendar == NULL) {