diff -up gnome-panel-2.21.91/applets/clock/clock-location-tile.h.localtime gnome-panel-2.21.91/applets/clock/clock-location-tile.h
--- gnome-panel-2.21.91/applets/clock/clock-location-tile.h.localtime 2008-02-11 16:15:51.000000000 -0500
+++ gnome-panel-2.21.91/applets/clock/clock-location-tile.h 2008-02-17 19:26:15.000000000 -0500
@@ -28,7 +28,7 @@ typedef struct
void (* tile_pressed) (ClockLocationTile *tile);
void (* timezone_set) (ClockLocationTile *tile);
void (* weather_updated) (ClockLocationTile *tile, GdkPixbuf *weather_icon, const char *temperature);
- char *(* need_formatted_time) (ClockLocationTile *tile);
+ int (* need_clock_format) (ClockLocationTile *tile);
} ClockLocationTileClass;
GType clock_location_tile_get_type (void);
@@ -40,7 +40,8 @@ ClockLocation *clock_location_tile_get_l
void weather_info_setup_tooltip (WeatherInfo *info, GtkTooltip *tip);
-void clock_location_tile_refresh (ClockLocationTile *this);
+void clock_location_tile_refresh (ClockLocationTile *this,
+ gboolean force_refresh);
G_END_DECLS
#endif /* __CLOCK_H__ */
diff -up gnome-panel-2.21.91/applets/clock/clock.c.localtime gnome-panel-2.21.91/applets/clock/clock.c
--- gnome-panel-2.21.91/applets/clock/clock.c.localtime 2008-02-11 16:15:51.000000000 -0500
+++ gnome-panel-2.21.91/applets/clock/clock.c 2008-02-17 19:25:23.000000000 -0500
@@ -508,7 +508,7 @@ update_location_tiles (ClockData *cd)
ClockLocationTile *tile;
tile = CLOCK_LOCATION_TILE (l->data);
- clock_location_tile_refresh (tile);
+ clock_location_tile_refresh (tile, FALSE);
}
}
@@ -1084,12 +1084,12 @@ location_tile_weather_updated_cb (ClockL
gtk_label_set_text (GTK_LABEL (cd->panel_temperature_label), temperature);
}
-static char *
-location_tile_need_formatted_time_cb (ClockLocationTile *tile, gpointer data)
+static ClockFormat
+location_tile_need_clock_format_cb(ClockLocationTile *tile, gpointer data)
{
ClockData *cd = data;
- return format_time (cd);
+ return cd->format;
}
static void
@@ -1133,8 +1133,10 @@ create_cities_section (ClockData *cd)
G_CALLBACK (location_tile_timezone_set_cb), cd);
g_signal_connect (city, "weather-updated",
G_CALLBACK (location_tile_weather_updated_cb), cd);
- g_signal_connect (city, "need-formatted-time",
- G_CALLBACK (location_tile_need_formatted_time_cb), cd);
+ g_signal_connect (city, "need-clock-format",
+ G_CALLBACK (location_tile_need_clock_format_cb), cd);
+
+ clock_location_tile_refresh (city, TRUE);
gtk_box_pack_start (GTK_BOX (cd->cities_section),
GTK_WIDGET (city),
diff -up gnome-panel-2.21.91/applets/clock/clock-location-tile.c.localtime gnome-panel-2.21.91/applets/clock/clock-location-tile.c
--- gnome-panel-2.21.91/applets/clock/clock-location-tile.c.localtime 2008-02-11 16:15:51.000000000 -0500
+++ gnome-panel-2.21.91/applets/clock/clock-location-tile.c 2008-02-17 19:26:03.000000000 -0500
@@ -11,6 +11,7 @@
#include "clock-face.h"
#include "clock-location-tile.h"
#include "clock-location.h"
+#include "clock-utils.h"
#include "clock-marshallers.h"
#include "set-timezone.h"
@@ -20,7 +21,7 @@ enum {
TILE_PRESSED,
TIMEZONE_SET,
WEATHER_UPDATED,
- NEED_FORMATTED_TIME,
+ NEED_CLOCK_FORMAT,
LAST_SIGNAL
};
@@ -122,14 +123,15 @@ clock_location_tile_class_init (ClockLoc
G_TYPE_NONE, 2,
G_TYPE_OBJECT,
G_TYPE_STRING);
- signals[NEED_FORMATTED_TIME] = g_signal_new ("need-formatted-time",
- G_TYPE_FROM_CLASS (g_obj_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (ClockLocationTileClass, need_formatted_time),
- NULL,
- NULL,
- _clock_marshal_STRING__VOID,
- G_TYPE_STRING, 0);
+
+ signals[NEED_CLOCK_FORMAT] = g_signal_new ("need-clock-format",
+ G_TYPE_FROM_CLASS (g_obj_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (ClockLocationTileClass, need_clock_format),
+ NULL,
+ NULL,
+ _clock_marshal_INT__VOID,
+ G_TYPE_INT, 0);
}
static void
@@ -310,7 +312,7 @@ clock_location_tile_fill (ClockLocationT
gtk_container_add (GTK_CONTAINER (priv->box), alignment);
gtk_container_add (GTK_CONTAINER (this), priv->box);
- clock_location_tile_refresh (this);
+ clock_location_tile_refresh (this, TRUE);
}
static gboolean
@@ -378,13 +380,72 @@ emit_weather_updated (ClockLocationTile
g_signal_emit (this, signals[WEATHER_UPDATED], 0, weather_icon, temperature);
}
+static char *
+format_time (struct tm *now,
+ char *tzname,
+ ClockFormat clock_format,
+ long offset)
+{
+ char buf[256];
+ char *format;
+ time_t local_t;
+ struct tm local_now;
+ char *utf8;
+ char *tmp;
+ long hours, minutes;
+
+ time (&local_t);
+ localtime_r (&local_t, &local_now);
+
+ if (local_now.tm_wday != now->tm_wday) {
+ if (clock_format == CLOCK_FORMAT_12) {
+ format = _("%l:%M <small>%p (%A)</small>");
+ }
+ else {
+ format = _("%H:%M <small>(%A)</small>");
+ }
+ }
+ else {
+ if (clock_format == CLOCK_FORMAT_12) {
+ format = _("%l:%M <small>%p</small>");
+ }
+ else {
+ format = _("%H:%M");
+ }
+ }
+
+ if (strftime (buf, sizeof (buf), format, now) <= 0) {
+ strcpy (buf, "???");
+ }
+
+ hours = offset / 3600;
+ minutes = labs (offset % 3600) / 60;
+
+ if (hours != 0 && minutes != 0) {
+ tmp = g_strdup_printf ("%s <small>%s %+ld:%ld</small>", buf, tzname, hours, minutes);
+ }
+ else if (hours != 0) {
+ tmp = g_strdup_printf ("%s <small>%s %+ld</small>", buf, tzname, hours);
+ }
+ else {
+ tmp = g_strdup_printf ("%s <small>%s</small>", buf, tzname);
+ }
+
+ utf8 = g_locale_to_utf8 (tmp, -1, NULL, NULL, NULL);
+
+ g_free (tmp);
+
+ return utf8;
+}
+
void
-clock_location_tile_refresh (ClockLocationTile *this)
+clock_location_tile_refresh (ClockLocationTile *this, gboolean force_refresh)
{
ClockLocationTilePrivate *priv = PRIVATE (this);
- gchar *tmp, *tmp2, *tzname;
+ gchar *tmp, *tzname;
struct tm now;
long offset, hours, minutes;
+ int format;
g_return_if_fail (IS_CLOCK_LOCATION_TILE (this));
@@ -411,7 +472,7 @@ clock_location_tile_refresh (ClockLocati
clock_face_refresh (CLOCK_FACE (priv->clock_face));
}
- if (!clock_needs_label_refresh (this)) {
+ if (!force_refresh && !clock_needs_label_refresh (this)) {
return;
}
@@ -426,26 +487,15 @@ clock_location_tile_refresh (ClockLocati
gtk_label_set_markup (GTK_LABEL (priv->city_label), tmp);
g_free (tmp);
- tmp = NULL;
- g_signal_emit (this, signals[NEED_FORMATTED_TIME], 0, &tmp);
+ g_signal_emit (this, signals[NEED_CLOCK_FORMAT], 0, &format);
offset = - priv->last_offset;
- hours = offset / 3600;
- minutes = labs (offset % 3600) / 60;
+ tmp = format_time (&now, tzname, format, offset);
- if (hours != 0 && minutes != 0)
- tmp2 = g_strdup_printf ("%s <small>%+ld:%ld</small>", tmp ? tmp : "", hours, minutes);
- else if (hours != 0)
- tmp2 = g_strdup_printf ("%s <small>%+ld</small>", tmp ? tmp : "", hours);
- else {
- tmp2 = tmp;
- tmp = NULL;
- }
+ gtk_label_set_markup (GTK_LABEL (priv->time_label), tmp);
- gtk_label_set_markup (GTK_LABEL (priv->time_label), tmp2);
g_free (tmp);
- g_free (tmp2);
}
void
diff -up gnome-panel-2.21.91/applets/clock/clock-marshallers.list.localtime gnome-panel-2.21.91/applets/clock/clock-marshallers.list
--- gnome-panel-2.21.91/applets/clock/clock-marshallers.list.localtime 2008-02-11 16:15:51.000000000 -0500
+++ gnome-panel-2.21.91/applets/clock/clock-marshallers.list 2008-02-17 19:25:23.000000000 -0500
@@ -3,4 +3,4 @@ VOID:OBJECT
VOID:POINTER
POINTER:VOID
VOID:OBJECT,STRING
-STRING:VOID
+INT:VOID