gnome-panel r11028 - trunk/applets/clock
- From: vuntz svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-panel r11028 - trunk/applets/clock
- Date: Thu, 10 Apr 2008 04:49:18 +0100 (BST)
Author: vuntz
Date: Thu Apr 10 04:49:18 2008
New Revision: 11028
URL: http://svn.gnome.org/viewvc/gnome-panel?rev=11028&view=rev
Log:
2008-04-10 Vincent Untz <vuntz gnome org>
Rework to not load two svg files on creation (once for the initial file
and once for the current time of day file). Can save between 0.01s and
0.02s per tile.
* clock-face.c: (clock_face_init): initial time of day is invalid
(update_time): renamed from update_timeofday() and update the current
time here
(clock_face_refresh): do not update time here
(clock_face_new): do not load a face directly, but call update_time()
that will have the side effect of loading one
(clock_face_new_with_location): ditto
Modified:
trunk/applets/clock/ChangeLog
trunk/applets/clock/clock-face.c
Modified: trunk/applets/clock/clock-face.c
==============================================================================
--- trunk/applets/clock/clock-face.c (original)
+++ trunk/applets/clock/clock-face.c Thu Apr 10 04:49:18 2008
@@ -37,7 +37,8 @@
CLOCK_FACE_MORNING,
CLOCK_FACE_DAY,
CLOCK_FACE_EVENING,
- CLOCK_FACE_NIGHT
+ CLOCK_FACE_NIGHT,
+ CLOCK_FACE_INVALID
} ClockFaceTimeOfDay;
struct _ClockFacePrivate
@@ -89,7 +90,7 @@
ClockFacePrivate *priv = CLOCK_FACE_GET_PRIVATE (this);
priv->size = CLOCK_FACE_SMALL;
- priv->timeofday = CLOCK_FACE_DAY;
+ priv->timeofday = CLOCK_FACE_INVALID;
priv->location = NULL;
priv->size_widget = NULL;
@@ -295,13 +296,22 @@
}
static void
-update_timeofday (ClockFace *this)
+update_time (ClockFace *this)
{
ClockFacePrivate *priv;
ClockFaceTimeOfDay timeofday;
priv = CLOCK_FACE_GET_PRIVATE (this);
+ /* update the time */
+ if (priv->location) {
+ clock_location_localtime (priv->location, &priv->time);
+ } else {
+ time_t timet;
+ time (&timet);
+ localtime_r (&timet, &priv->time);
+ }
+
/* FIXME this should be a gconf setting
* currently we hardcode
* morning 7-9
@@ -348,16 +358,7 @@
return FALSE;
}
- /* update the time */
- if (priv->location) {
- clock_location_localtime (priv->location, &priv->time);
- } else {
- time_t timet;
- time (&timet);
- localtime_r (&timet, &priv->time);
- }
-
- update_timeofday (this);
+ update_time (this);
clock_face_redraw_canvas (this);
@@ -370,9 +371,11 @@
GObject *obj = g_object_new (INTL_TYPE_CLOCK_FACE, NULL);
ClockFacePrivate *priv = CLOCK_FACE_GET_PRIVATE (obj);
+ /* FIXME: this is horribly broken from a GObject perspective.
+ * Everything should be done in the constructor */
priv->size = size;
- clock_face_load_face (CLOCK_FACE (obj), -1, -1);
+ update_time (CLOCK_FACE (obj));
return GTK_WIDGET (obj);
}
@@ -382,12 +385,15 @@
ClockLocation *loc,
GtkWidget *size_widget)
{
- ClockFace *obj = CLOCK_FACE (clock_face_new (size));
+ GObject *obj = g_object_new (INTL_TYPE_CLOCK_FACE, NULL);
ClockFacePrivate *priv = CLOCK_FACE_GET_PRIVATE (obj);
+ priv->size = size;
priv->location = g_object_ref (loc);
priv->size_widget = g_object_ref (size_widget);
+ update_time (CLOCK_FACE (obj));
+
return GTK_WIDGET (obj);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]