Javier Jardón has proposed merging lp:~jjardon/indicator-datetime/fix-775113 into lp:indicator-datetime.
Requested reviews: Indicator Applet Developers (indicator-applet-developers) Related bugs: Bug #775113 in Indicator Date and Time: "Custom time format in datetime applet cannot handle some format specifiers" https://bugs.launchpad.net/indicator-datetime/+bug/775113 For more details, see: https://code.launchpad.net/~jjardon/indicator-datetime/fix-775113/+merge/73839 -- https://code.launchpad.net/~jjardon/indicator-datetime/fix-775113/+merge/73839 Your team ayatana-commits is subscribed to branch lp:indicator-datetime.
=== modified file 'configure.ac' --- configure.ac 2011-08-18 15:57:14 +0000 +++ configure.ac 2011-09-02 15:13:35 +0000 @@ -69,6 +69,7 @@ GLIB_REQUIRED_VERSION=2.26 GTK3_REQUIRED_VERSION=3.1.4 GCONF_REQUIRED_VERSION=2.31 +UPOWER_REQUIRED_VERSION=0.9.5 AS_IF([test "x$with_gtk" = x3], [PKG_CHECK_MODULES(INDICATOR, indicator3-0.4 >= $INDICATOR_REQUIRED_VERSION @@ -88,6 +89,7 @@ ) PKG_CHECK_MODULES(SERVICE, indicator3-0.4 >= $INDICATOR_REQUIRED_VERSION + upower-glib >= UPOWER_REQUIRED_VERSION glib-2.0 >= $GLIB_REQUIRED_VERSION dbusmenu-glib-0.4 >= $DBUSMENUGLIB_REQUIRED_VERSION dbusmenu-gtk3-0.4 >= $DBUSMENUGTK_REQUIRED_VERSION === modified file 'src/datetime-service.c' --- src/datetime-service.c 2011-09-01 17:05:17 +0000 +++ src/datetime-service.c 2011-09-02 15:13:35 +0000 @@ -38,6 +38,8 @@ #include <geoclue/geoclue-master.h> #include <geoclue/geoclue-master-client.h> +#include <libupower-glib/upower.h> + #include <time.h> #include <libecal/e-cal.h> #include <libical/ical.h> @@ -85,6 +87,7 @@ static time_t start_time_appointments = (time_t) 0; GSettings *conf; GConfClient* gconf; +UpClient *up_client; /* Geoclue trackers */ @@ -323,6 +326,15 @@ return FALSE; } +static void +upower_notify_resume_cb (UpClient *client, + UpSleepKind sleep_kind, + gpointer *user_data) +{ + datetime_interface_update(DATETIME_INTERFACE(user_data)); + update_datetime (NULL); +} + /* Run a particular program based on an activation */ static void activate_cb (DbusmenuMenuitem * menuitem, guint timestamp, const gchar *command) @@ -1185,19 +1197,23 @@ static void setup_timer (void) { + GDateTime *datetime; + gint hour, min, sec; + if (timer != 0) { g_source_remove(timer); timer = 0; } - time_t t; - t = time(NULL); - struct tm * ltime = localtime(&t); + datetime = g_date_time_new_now_local (); + hour = g_date_time_get_hour (datetime); + min = g_date_time_get_minute (datetime); + sec = g_date_time_get_second (datetime); - timer = g_timeout_add_seconds(((23 - ltime->tm_hour) * 60 * 60) + - ((59 - ltime->tm_min) * 60) + - ((60 - ltime->tm_sec)) + 60 /* one minute past */, - timer_func, NULL); + timer = g_timeout_add_seconds (((23 - hour) * 60 * 60) + + ((59 - min) * 60) + + ((60 - sec)) + 60 /* one minute past */, + timer_func, NULL); return; } @@ -1487,6 +1503,10 @@ "org.freedesktop.ConsoleKit.Manager", NULL, system_proxy_cb, dbus); + up_client = up_client_new (); + g_signal_connect (up_client, "notify-resume", + G_CALLBACK (upower_notify_resume_cb), dbus); + mainloop = g_main_loop_new(NULL, FALSE); g_main_loop_run(mainloop); === modified file 'src/indicator-datetime.c' --- src/indicator-datetime.c 2011-08-25 14:46:51 +0000 +++ src/indicator-datetime.c 2011-09-02 15:13:35 +0000 @@ -215,7 +215,7 @@ PROP_TIME_FORMAT, g_param_spec_int(PROP_TIME_FORMAT_S, "A choice of which format should be used on the panel", - "Chooses between letting the locale choose the time, 12-hour time, 24-time or using the custom string passed to strftime().", + "Chooses between letting the locale choose the time, 12-hour time, 24-time or using the custom string passed to g_date_time_format().", SETTINGS_TIME_LOCALE, /* min */ SETTINGS_TIME_CUSTOM, /* max */ SETTINGS_TIME_LOCALE, /* default */ @@ -245,7 +245,7 @@ PROP_CUSTOM_TIME_FORMAT, g_param_spec_string(PROP_CUSTOM_TIME_FORMAT_S, "The format that is used to show the time on the panel.", - "A format string in the form used to pass to strftime to make a string for displaying on the panel.", + "A format string in the form used to pass to g_date_time_format() to make a string for displaying on the panel.", DEFAULT_TIME_FORMAT, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); @@ -775,6 +775,12 @@ } else { timestr = g_date_time_format(datetime_now, format); + if (timestr == NULL) { + g_warning ("The custom date format is not valid, check the + g_date_time_format() documentation for the supported + format specifiers "); + timestr = g_strdup ("Date format not supported"); + } } gboolean use_markup = FALSE;
_______________________________________________ Mailing list: https://launchpad.net/~ayatana-commits Post to : ayatana-commits@lists.launchpad.net Unsubscribe : https://launchpad.net/~ayatana-commits More help : https://help.launchpad.net/ListHelp