~ubuntu-branches/ubuntu/oneiric/indicator-datetime/oneiric

« back to all changes in this revision

Viewing changes to src/datetime-service.c

  • Committer: Bazaar Package Importer
  • Author(s): Ted Gould
  • Date: 2011-08-18 15:36:21 UTC
  • mfrom: (1.1.19 upstream)
  • Revision ID: james.westby@ubuntu.com-20110818153621-4chopu19xv1qh3j4
Tags: 0.2.93-0ubuntu1
New upstream release.
∘ Use cleaner GDateTime API
∘ Use locale preferred date format (LP: #729056)
∘ Use real ellipsis (LP: #621339)

Show diffs side-by-side

added added

removed removed

Lines of Context:
299
299
static gboolean
300
300
update_datetime (gpointer user_data)
301
301
{
 
302
        GDateTime *datetime;
 
303
        gchar *utf8;
 
304
 
302
305
        g_debug("Updating Date/Time");
303
306
 
304
 
        gchar longstr[128];
305
 
        time_t t;
306
 
        struct tm *ltime;
307
 
 
308
 
        t = time(NULL);
309
 
        ltime = localtime(&t);
310
 
        if (ltime == NULL) {
 
307
        datetime = g_date_time_new_now_local ();
 
308
        if (datetime == NULL) {
311
309
                g_warning("Error getting local time");
312
310
                dbusmenu_menuitem_property_set(date, DBUSMENU_MENUITEM_PROP_LABEL, _("Error getting time"));
 
311
                g_date_time_unref (datetime);
313
312
                return FALSE;
314
313
        }
315
314
 
316
 
        /* Translators: strftime(3) style date format on top of the menu when you click on the clock */
317
 
        strftime(longstr, 128, _("%A, %e %B %Y"), ltime);
318
 
        
319
 
        gchar * utf8 = g_locale_to_utf8(longstr, -1, NULL, NULL, NULL);
 
315
        /* eranslators: strftime(3) style date format on top of the menu when you click on the clock */
 
316
        utf8 = g_date_time_format (datetime, _("%A, %e %B %Y"));
 
317
 
320
318
        dbusmenu_menuitem_property_set(date, DBUSMENU_MENUITEM_PROP_LABEL, utf8);
 
319
 
 
320
        g_date_time_unref (datetime);
321
321
        g_free(utf8);
322
322
 
323
323
        return FALSE;
492
492
                dbusmenu_menuitem_property_set(events_separator, DBUSMENU_MENUITEM_PROP_TYPE, DBUSMENU_CLIENT_TYPES_SEPARATOR);
493
493
                dbusmenu_menuitem_child_add_position(root, events_separator, 2);
494
494
                add_appointment = dbusmenu_menuitem_new();
495
 
                dbusmenu_menuitem_property_set (add_appointment, DBUSMENU_MENUITEM_PROP_LABEL, _("Add Event..."));
 
495
                dbusmenu_menuitem_property_set (add_appointment, DBUSMENU_MENUITEM_PROP_LABEL, _("Add Event…"));
496
496
                dbusmenu_menuitem_property_set_bool(add_appointment, DBUSMENU_MENUITEM_PROP_ENABLED, TRUE);
497
497
                g_signal_connect(G_OBJECT(add_appointment), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(activate_cb), "evolution -c calendar");
498
498
                dbusmenu_menuitem_child_add_position (root, add_appointment, 3);
701
701
 
702
702
        // Get today & work out query times
703
703
        time(&curtime);
704
 
        struct tm *today = localtime(&curtime);
 
704
        struct tm *today = localtime(&curtime);
705
705
        const int mday = today->tm_mday;
706
706
        const int mon = today->tm_mon;
707
707
        const int year = today->tm_year;
1064
1064
        g_debug("Building Menus.");
1065
1065
        if (date == NULL) {
1066
1066
                date = dbusmenu_menuitem_new();
1067
 
                dbusmenu_menuitem_property_set     (date, DBUSMENU_MENUITEM_PROP_LABEL, _("No date yet..."));
 
1067
                dbusmenu_menuitem_property_set     (date, DBUSMENU_MENUITEM_PROP_LABEL, _("No date yet…"));
1068
1068
                dbusmenu_menuitem_property_set_bool(date, DBUSMENU_MENUITEM_PROP_ENABLED, FALSE);
1069
1069
                dbusmenu_menuitem_child_append(root, date);
1070
1070
 
1116
1116
                dbusmenu_menuitem_child_append(root, separator);
1117
1117
 
1118
1118
                settings = dbusmenu_menuitem_new();
1119
 
                dbusmenu_menuitem_property_set     (settings, DBUSMENU_MENUITEM_PROP_LABEL, _("Time & Date Settings..."));
 
1119
                dbusmenu_menuitem_property_set     (settings, DBUSMENU_MENUITEM_PROP_LABEL, _("Time & Date Settings…"));
1120
1120
                /* insensitive until we check for available apps */
1121
1121
                dbusmenu_menuitem_property_set_bool(settings, DBUSMENU_MENUITEM_PROP_ENABLED, FALSE);
1122
1122
                g_signal_connect(G_OBJECT(settings), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(activate_cb), "gnome-control-center indicator-datetime");