[Goodies-commits] r4859 - in xfce4-datetime-plugin/trunk: . panel-plugin
Diego Ongaro
ongardie at xfce.org
Thu May 29 23:01:09 CEST 2008
Author: ongardie
Date: 2008-05-29 21:01:09 +0000 (Thu, 29 May 2008)
New Revision: 4859
Modified:
xfce4-datetime-plugin/trunk/ChangeLog
xfce4-datetime-plugin/trunk/panel-plugin/datetime.c
Log:
Always update every second when seconds are shown (Bug #4117)
Modified: xfce4-datetime-plugin/trunk/ChangeLog
===================================================================
--- xfce4-datetime-plugin/trunk/ChangeLog 2008-05-29 14:08:32 UTC (rev 4858)
+++ xfce4-datetime-plugin/trunk/ChangeLog 2008-05-29 21:01:09 UTC (rev 4859)
@@ -1,3 +1,8 @@
+2008-05-29 Diego Ongaro <ongardie at gmail.com>
+
+ * panel-plugin/datetime.c: Always update every second when seconds are
+ shown (Bug #4117)
+
2008-05-27 Diego Ongaro <ongardie at gmail.com>
* panel-plugin/datetime.c: "Fix tooltip hiding" uses gtk2.12 function,
Modified: xfce4-datetime-plugin/trunk/panel-plugin/datetime.c
===================================================================
--- xfce4-datetime-plugin/trunk/panel-plugin/datetime.c 2008-05-29 14:08:32 UTC (rev 4858)
+++ xfce4-datetime-plugin/trunk/panel-plugin/datetime.c 2008-05-29 21:01:09 UTC (rev 4859)
@@ -2,6 +2,7 @@
*
* Copyright (C) 2003 Choe Hwanjin(krisna at kldp.org)
* Copyright (c) 2006 Remco den Breeje <remco at sx.mine.nu>
+ * Copyright (c) 2008 Diego Ongaro <ongardie at gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as published
@@ -36,6 +37,7 @@
#include "datetime-dialog.h"
#define USE_GTK_TOOLTIP_API GTK_CHECK_VERSION(2,12,0)
+#define DATETIME_MAX_STRLEN 256
/*
* Get date/time string
@@ -43,7 +45,7 @@
gchar * datetime_do_utf8strftime(const char *format, const struct tm *tm)
{
int len;
- gchar buf[256];
+ gchar buf[DATETIME_MAX_STRLEN];
gchar *utf8str = NULL;
/* get formatted date/time */
@@ -59,6 +61,42 @@
return utf8str;
}
+/**
+ * Check whether date/time format shows seconds
+ */
+static gboolean datetime_format_has_seconds(const gchar *format)
+{
+ static struct tm time_struct = {
+ .tm_sec = 0,
+ .tm_min = 0,
+ .tm_hour = 0,
+ .tm_mday = 1,
+ .tm_mon = 0,
+ .tm_year = 0,
+ .tm_wday = 0,
+ .tm_yday = 0,
+ .tm_isdst = 0
+ };
+ int len1;
+ int len2;
+ gchar buf1[DATETIME_MAX_STRLEN];
+ gchar buf2[DATETIME_MAX_STRLEN];
+
+ time_struct.tm_sec = 1;
+ len1 = strftime(buf1, sizeof(buf1)-1, format, &time_struct);
+ if (len1 == 0)
+ return FALSE;
+ buf1[len1] = '\0';
+
+ time_struct.tm_sec = 2;
+ len2 = strftime(buf2, sizeof(buf2)-1, format, &time_struct);
+ if (len2 == 0)
+ return FALSE;
+ buf2[len2] = '\0';
+
+ return len1 != len2 || strcmp(buf1, buf2) != 0;
+}
+
/*
* set date and time labels
*/
@@ -417,14 +455,8 @@
g_source_remove(datetime->timeout_id);
}
- if (strstr(datetime->date_format, "%S") != NULL ||
- strstr(datetime->date_format, "%s") != NULL ||
- strstr(datetime->date_format, "%r") != NULL ||
- strstr(datetime->date_format, "%T") != NULL ||
- strstr(datetime->time_format, "%S") != NULL ||
- strstr(datetime->time_format, "%s") != NULL ||
- strstr(datetime->time_format, "%r") != NULL ||
- strstr(datetime->time_format, "%T") != NULL)
+ if (datetime_format_has_seconds(datetime->date_format) ||
+ datetime_format_has_seconds(datetime->time_format))
{
datetime->timeout_id = g_timeout_add(1000, datetime_update, datetime);
}
More information about the Goodies-commits
mailing list