gnome-panel r11009 - trunk/applets/clock
- From: vuntz svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-panel r11009 - trunk/applets/clock
- Date: Tue, 8 Apr 2008 14:50:17 +0100 (BST)
Author: vuntz
Date: Tue Apr 8 14:50:16 2008
New Revision: 11009
URL: http://svn.gnome.org/viewvc/gnome-panel?rev=11009&view=rev
Log:
2008-04-08 Vincent Untz <vuntz gnome org>
* clock-map.c: add enums for markers and an array for marker files
(clock_map_new),: do not load the marker pixbuf here
(clock_map_init): do it here, with a simple loop
(clock_map_finalize):
(clock_map_place_location): trivial updates to use the enum
Modified:
trunk/applets/clock/ChangeLog
trunk/applets/clock/clock-map.c
Modified: trunk/applets/clock/clock-map.c
==============================================================================
--- trunk/applets/clock/clock-map.c (original)
+++ trunk/applets/clock/clock-map.c Tue Apr 8 14:50:16 2008
@@ -20,6 +20,19 @@
LAST_SIGNAL
};
+enum {
+ MARKER_NORMAL = 0,
+ MARKER_HILIGHT,
+ MARKER_CURRENT,
+ MARKER_NB
+};
+
+static char *marker_files[MARKER_NB] = {
+ ICONDIR "/clock-map-location-marker.png",
+ ICONDIR "/clock-map-location-hilight.png",
+ ICONDIR "/clock-map-location-current.png"
+};
+
static guint signals[LAST_SIGNAL];
typedef struct {
@@ -31,7 +44,7 @@
guint highlight_timeout_id;
GdkPixbuf *stock_map_pixbuf;
- GdkPixbuf *location_marker_pixbuf[3];
+ GdkPixbuf *location_marker_pixbuf[MARKER_NB];
GdkPixbuf *location_map_pixbuf;
@@ -65,13 +78,6 @@
this = g_object_new (CLOCK_MAP_TYPE, NULL);
priv = PRIVATE (this);
- priv->location_marker_pixbuf[0] = gdk_pixbuf_new_from_file
- (ICONDIR "/clock-map-location-marker.png", NULL);
- priv->location_marker_pixbuf[1] = gdk_pixbuf_new_from_file
- (ICONDIR "/clock-map-location-hilight.png", NULL);
- priv->location_marker_pixbuf[2] = gdk_pixbuf_new_from_file
- (ICONDIR "/clock-map-location-current.png", NULL);
-
clock_map_refresh (this);
return this;
@@ -115,6 +121,7 @@
static void
clock_map_init (ClockMap *this)
{
+ int i;
ClockMapPrivate *priv = PRIVATE (this);
GTK_WIDGET_SET_FLAGS (this, GTK_NO_WINDOW);
@@ -122,9 +129,12 @@
priv->last_refresh = 0;
priv->highlight_timeout_id = 0;
priv->stock_map_pixbuf = NULL;
- priv->location_marker_pixbuf[0] = NULL;
- priv->location_marker_pixbuf[1] = NULL;
- priv->location_marker_pixbuf[2] = NULL;
+
+ g_assert (sizeof (marker_files)/sizeof (char *) == MARKER_NB);
+ for (i = 0; i < MARKER_NB; i++) {
+ priv->location_marker_pixbuf[i] = gdk_pixbuf_new_from_file
+ (marker_files[i], NULL);
+ }
}
static void
@@ -143,7 +153,7 @@
priv->stock_map_pixbuf = NULL;
}
- for (i = 0; i < 3; i++) {
+ for (i = 0; i < MARKER_NB; i++) {
if (priv->location_marker_pixbuf[i]) {
gdk_pixbuf_unref (priv->location_marker_pixbuf[i]);
priv->location_marker_pixbuf[i] = NULL;
@@ -411,11 +421,11 @@
clock_location_get_coords (loc, &latitude, &longitude);
if (hilight)
- marker = 1;
+ marker = MARKER_HILIGHT;
else if (clock_location_is_current (loc))
- marker = 2;
+ marker = MARKER_CURRENT;
else
- marker = 0;
+ marker = MARKER_NORMAL;
clock_map_mark (this, latitude, longitude, marker);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]