Author: nick
Date: 2007-07-08 10:03:02 +0000 (Sun, 08 Jul 2007)
New Revision: 25899
Modified:
xfce4-panel/trunk/ChangeLog
xfce4-panel/trunk/plugins/clock/clock-analog.c
xfce4-panel/trunk/plugins/clock/clock-binary.c
xfce4-panel/trunk/plugins/clock/clock-dialog.c
xfce4-panel/trunk/plugins/clock/clock-digital.c
xfce4-panel/trunk/plugins/clock/clock-lcd.c
xfce4-panel/trunk/plugins/clock/clock.c
xfce4-panel/trunk/plugins/clock/clock.h
Log:
* plugins/clock/clock-digital.c: Allow markup and center the string.
* plugins/clock/*: Move the localtime functions into 1 util and allow usage
without locatime_r.
Modified: xfce4-panel/trunk/ChangeLog
===================================================================
--- xfce4-panel/trunk/ChangeLog 2007-07-08 08:27:50 UTC (rev 25898)
+++ xfce4-panel/trunk/ChangeLog 2007-07-08 10:03:02 UTC (rev 25899)
@@ -1,3 +1,9 @@
+2007-07-08 12:00 nick
+
+ * plugins/clock/clock-digital.c: Allow markup and center the string.
+ * plugins/clock/*: Move the localtime functions into 1 util and allow
+ usage without locatime_r.
+
2007-07-07 10:32 nick
* plugins/clock/clock-lcd.c: Typo, the 8 was test code.
Modified: xfce4-panel/trunk/plugins/clock/clock-analog.c
===================================================================
--- xfce4-panel/trunk/plugins/clock/clock-analog.c 2007-07-08 08:27:50 UTC
(rev 25898)
+++ xfce4-panel/trunk/plugins/clock/clock-analog.c 2007-07-08 10:03:02 UTC
(rev 25899)
@@ -232,7 +232,6 @@
gdouble xc, yc;
gdouble angle, radius;
cairo_t *cr;
- time_t now = time (0);
struct tm tm;
g_return_val_if_fail (XFCE_CLOCK_IS_ANALOG (clock), FALSE);
@@ -252,7 +251,7 @@
if (G_LIKELY (cr != NULL))
{
/* get the local time */
- localtime_r (&now, &tm);
+ xfce_clock_util_get_localtime (&tm);
/* set the line properties */
cairo_set_line_width (cr, 1);
Modified: xfce4-panel/trunk/plugins/clock/clock-binary.c
===================================================================
--- xfce4-panel/trunk/plugins/clock/clock-binary.c 2007-07-08 08:27:50 UTC
(rev 25898)
+++ xfce4-panel/trunk/plugins/clock/clock-binary.c 2007-07-08 10:03:02 UTC
(rev 25899)
@@ -264,7 +264,6 @@
gint decimal_bcd[] = {80, 40, 20, 10, 8, 4, 2, 1};
cairo_t *cr;
GdkColor active, inactive;
- time_t now = time (0);
struct tm tm;
g_return_val_if_fail (XFCE_CLOCK_IS_BINARY (clock), FALSE);
@@ -298,7 +297,7 @@
if (G_LIKELY (cr != NULL))
{
/* get the current time */
- localtime_r (&now, &tm);
+ xfce_clock_util_get_localtime (&tm);
/* walk the three or two time parts */
for (i = 0; i < columns; i++)
Modified: xfce4-panel/trunk/plugins/clock/clock-dialog.c
===================================================================
--- xfce4-panel/trunk/plugins/clock/clock-dialog.c 2007-07-08 08:27:50 UTC
(rev 25898)
+++ xfce4-panel/trunk/plugins/clock/clock-dialog.c 2007-07-08 10:03:02 UTC
(rev 25899)
@@ -318,13 +318,12 @@
const gchar *current_format)
{
gint i;
- time_t now = time (0);
struct tm tm;
gchar *string;
gboolean has_active = FALSE;
/* get the local time */
- localtime_r (&now, &tm);
+ xfce_clock_util_get_localtime (&tm);
for (i = 0; formats[i] != NULL; i++)
{
Modified: xfce4-panel/trunk/plugins/clock/clock-digital.c
===================================================================
--- xfce4-panel/trunk/plugins/clock/clock-digital.c 2007-07-08 08:27:50 UTC
(rev 25898)
+++ xfce4-panel/trunk/plugins/clock/clock-digital.c 2007-07-08 10:03:02 UTC
(rev 25899)
@@ -121,6 +121,9 @@
{
/* init */
clock->format = NULL;
+
+ /* center text */
+ gtk_label_set_justify (GTK_LABEL (clock), GTK_JUSTIFY_CENTER);
}
@@ -202,20 +205,19 @@
{
XfceClockDigital *clock = XFCE_CLOCK_DIGITAL (user_data);
gchar *string;
- time_t now = time (0);
struct tm tm;
g_return_val_if_fail (XFCE_CLOCK_IS_DIGITAL (clock), FALSE);
g_return_val_if_fail (clock->format != NULL, FALSE);
/* get the local time */
- localtime_r (&now, &tm);
+ xfce_clock_util_get_localtime (&tm);
/* get the string */
string = xfce_clock_util_strdup_strftime (clock->format, &tm);
/* set the new label */
- gtk_label_set_text (GTK_LABEL (clock), string);
+ gtk_label_set_markup (GTK_LABEL (clock), string);
/* cleanup */
g_free (string);
Modified: xfce4-panel/trunk/plugins/clock/clock-lcd.c
===================================================================
--- xfce4-panel/trunk/plugins/clock/clock-lcd.c 2007-07-08 08:27:50 UTC (rev
25898)
+++ xfce4-panel/trunk/plugins/clock/clock-lcd.c 2007-07-08 10:03:02 UTC (rev
25899)
@@ -282,7 +282,6 @@
gdouble offset_x, offset_y;
gint ticks, i;
gdouble size;
- time_t now = time (0);
struct tm tm;
g_return_val_if_fail (XFCE_CLOCK_IS_LCD (clock), FALSE);
@@ -303,7 +302,7 @@
if (G_LIKELY (cr != NULL))
{
/* get the local time */
- localtime_r (&now, &tm);
+ xfce_clock_util_get_localtime (&tm);
/* draw the hours */
ticks = tm.tm_hour;
@@ -372,11 +371,10 @@
{
gdouble ratio;
gint ticks;
- time_t now = time (0);
struct tm tm;
/* get the local time */
- localtime_r (&now, &tm);
+ xfce_clock_util_get_localtime (&tm);
/* hour + minutes */
ratio = (3 * 0.5 + 6 * RELATIVE_SPACE);
Modified: xfce4-panel/trunk/plugins/clock/clock.c
===================================================================
--- xfce4-panel/trunk/plugins/clock/clock.c 2007-07-08 08:27:50 UTC (rev
25898)
+++ xfce4-panel/trunk/plugins/clock/clock.c 2007-07-08 10:03:02 UTC (rev
25899)
@@ -54,6 +54,23 @@
/** utilities **/
+void
+xfce_clock_util_get_localtime (struct tm *tm)
+{
+ time_t now = time (0);
+
+#ifndef HAVE_LOCALTIME_R
+ struct tm *tmbuf;
+
+ tmbuf = localtime (&now);
+ *tm = *tmbuf;
+#else
+ localtime_r (&now, tm);
+#endif
+}
+
+
+
static guint
xfce_clock_util_interval_from_format (const gchar *format)
{
@@ -93,7 +110,6 @@
static guint
xfce_clock_util_next_interval (guint timeout_interval)
{
- time_t now = time (0);
struct tm tm;
GTimeVal timeval;
guint interval;
@@ -105,7 +121,7 @@
interval = 1000 - (timeval.tv_usec / 1000);
/* get current time */
- localtime_r (&now, &tm);
+ xfce_clock_util_get_localtime (&tm);
/* add the interval time to the next update */
switch (timeout_interval)
@@ -165,9 +181,8 @@
{
ClockPlugin *clock = (ClockPlugin *) user_data;
gchar *string;
- time_t now = time (0);
+ static GtkTooltips *tooltips = NULL;
struct tm tm;
- static GtkTooltips *tooltips = NULL;
g_return_val_if_fail (clock->tooltip_format != NULL, TRUE);
@@ -176,7 +191,7 @@
tooltips = gtk_tooltips_new ();
/* get the local time */
- localtime_r (&now, &tm);
+ xfce_clock_util_get_localtime (&tm);
/* get the string */
string = xfce_clock_util_strdup_strftime (clock->tooltip_format, &tm);
Modified: xfce4-panel/trunk/plugins/clock/clock.h
===================================================================
--- xfce4-panel/trunk/plugins/clock/clock.h 2007-07-08 08:27:50 UTC (rev
25898)
+++ xfce4-panel/trunk/plugins/clock/clock.h 2007-07-08 10:03:02 UTC (rev
25899)
@@ -82,6 +82,9 @@
};
+
+void xfce_clock_util_get_localtime (struct tm *tm)
G_GNUC_INTERNAL;
+
gchar *xfce_clock_util_strdup_strftime (const gchar *format,
const struct tm *tm)
G_GNUC_MALLOC G_GNUC_INTERNAL;
_______________________________________________
Xfce4-commits mailing list
[email protected]
http://foo-projects.org/mailman/listinfo/xfce4-commits