Merge lp:~ev/timezonemap/timezonelocation into lp:timezonemap

Proposed by Evan
Status: Merged
Merged at revision: 15
Proposed branch: lp:~ev/timezonemap/timezonelocation
Merge into: lp:timezonemap
Diff against target: 771 lines (+340/-129)
5 files modified
src/cc-timezone-map.c (+61/-23)
src/cc-timezone-map.h (+1/-1)
src/test-timezone.c (+9/-3)
src/tz.c (+221/-83)
src/tz.h (+48/-19)
To merge this branch: bzr merge lp:~ev/timezonemap/timezonelocation
Reviewer Review Type Date Requested Status
Michael Terry Pending
Review via email: mp+70122@code.launchpad.net

Description of the change

This branch exposes the timezone locations as GObjects. Do you think it's better to do this across the board, as I've done here, or to push the location private struct to the header, so that cc-timezone-map.c can use it?

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/cc-timezone-map.c'
2--- src/cc-timezone-map.c 2011-07-29 09:01:38 +0000
3+++ src/cc-timezone-map.c 2011-08-02 08:06:15 +0000
4@@ -63,7 +63,7 @@
5 gchar *watermark;
6
7 TzDB *tzdb;
8- TzLocation *location;
9+ CcTimezoneLocation *location;
10 GHashTable *alias_db;
11 };
12
13@@ -813,8 +813,16 @@
14 g_clear_error (&err);
15 }
16
17- pointx = convert_longtitude_to_x (priv->location->longitude, alloc.width);
18- pointy = convert_latitude_to_y (priv->location->latitude, alloc.height);
19+ GValue lat = {0};
20+ GValue lon = {0};
21+ g_value_init (&lat, G_TYPE_DOUBLE);
22+ g_value_init (&lon, G_TYPE_DOUBLE);
23+ g_object_get_property(G_OBJECT (priv->location), "latitude", &lat);
24+ g_object_get_property(G_OBJECT (priv->location), "longitude", &lon);
25+ pointx = convert_longtitude_to_x (g_value_get_double(&lon), alloc.width);
26+ pointy = convert_latitude_to_y (g_value_get_double(&lat), alloc.height);
27+ g_value_unset (&lon);
28+ g_value_unset (&lat);
29
30 if (pointy > alloc.height)
31 pointy = alloc.height;
32@@ -854,20 +862,31 @@
33 0,
34 NULL,
35 NULL,
36- g_cclosure_marshal_VOID__POINTER,
37+ g_cclosure_marshal_VOID__OBJECT,
38 G_TYPE_NONE, 1,
39- G_TYPE_POINTER);
40+ CC_TYPE_TIMEZONE_LOCATION);
41 }
42
43
44 static gint
45-sort_locations (TzLocation *a,
46- TzLocation *b)
47+sort_locations (CcTimezoneLocation *a,
48+ CcTimezoneLocation *b)
49 {
50- if (a->dist > b->dist)
51+ GValue val_a = {0};
52+ GValue val_b = {0};
53+ gdouble dist_a, dist_b;
54+ g_value_init (&val_a, G_TYPE_DOUBLE);
55+ g_value_init (&val_b, G_TYPE_DOUBLE);
56+ g_object_get_property(G_OBJECT (a), "dist", &val_a);
57+ g_object_get_property(G_OBJECT (b), "dist", &val_b);
58+ dist_a = g_value_get_double(&val_a);
59+ dist_b = g_value_get_double(&val_b);
60+ g_value_unset (&val_a);
61+ g_value_unset (&val_b);
62+ if (dist_a > dist_b)
63 return 1;
64
65- if (a->dist < b->dist)
66+ if (dist_a < dist_b)
67 return -1;
68
69 return 0;
70@@ -875,7 +894,7 @@
71
72 static void
73 set_location (CcTimezoneMap *map,
74- TzLocation *location)
75+ CcTimezoneLocation *location)
76 {
77 CcTimezoneMapPrivate *priv = map->priv;
78 TzInfo *info;
79@@ -892,7 +911,7 @@
80 tz_info_free (info);
81 }
82
83-static TzLocation *
84+static CcTimezoneLocation *
85 get_loc_for_xy (GtkWidget * widget, gint x, gint y)
86 {
87 CcTimezoneMapPrivate *priv = CC_TIMEZONE_MAP (widget)->priv;
88@@ -906,6 +925,13 @@
89 GList *distances = NULL;
90 GtkAllocation alloc;
91
92+ GValue glon = {0};
93+ GValue glat = {0};
94+ GValue gdist = {0};
95+ g_value_init (&glon, G_TYPE_DOUBLE);
96+ g_value_init (&glat, G_TYPE_DOUBLE);
97+ g_value_init (&gdist, G_TYPE_DOUBLE);
98+
99 rowstride = priv->visible_map_rowstride;
100 pixels = priv->visible_map_pixels;
101
102@@ -937,22 +963,27 @@
103 for (i = 0; i < array->len; i++)
104 {
105 gdouble pointx, pointy, dx, dy;
106- TzLocation *loc = array->pdata[i];
107+ CcTimezoneLocation *loc = array->pdata[i];
108
109- pointx = convert_longtitude_to_x (loc->longitude, width);
110- pointy = convert_latitude_to_y (loc->latitude, height);
111+ g_object_get_property(G_OBJECT (loc), "longitude", &glon);
112+ g_object_get_property(G_OBJECT (loc), "latitude", &glat);
113+ pointx = convert_longtitude_to_x (g_value_get_double(&glon), width);
114+ pointy = convert_latitude_to_y (g_value_get_double(&glat), height);
115
116 dx = pointx - x;
117 dy = pointy - y;
118
119- loc->dist = dx * dx + dy * dy;
120+ g_value_set_double(&gdist, (gdouble) dx * dx + dy * dy);
121+ g_object_set_property(G_OBJECT (loc), "dist", &gdist);
122 distances = g_list_prepend (distances, loc);
123-
124 }
125 distances = g_list_sort (distances, (GCompareFunc) sort_locations);
126
127- TzLocation * loc = (TzLocation*) distances->data;
128+ CcTimezoneLocation * loc = (CcTimezoneLocation*) distances->data;
129
130+ g_value_unset (&glon);
131+ g_value_unset (&glat);
132+ g_value_unset (&gdist);
133 g_list_free (distances);
134
135 return loc;
136@@ -962,7 +993,7 @@
137 button_press_event (GtkWidget *widget,
138 GdkEventButton *event)
139 {
140- TzLocation * loc = get_loc_for_xy (widget, event->x, event->y);
141+ CcTimezoneLocation * loc = get_loc_for_xy (widget, event->x, event->y);
142 set_location (CC_TIMEZONE_MAP (widget), loc);
143 return TRUE;
144 }
145@@ -1087,6 +1118,8 @@
146 GPtrArray *locations;
147 guint i;
148 char *real_tz;
149+ GValue zone = {0};
150+ g_value_init (&zone, G_TYPE_STRING);
151
152 real_tz = g_hash_table_lookup (map->priv->alias_db, timezone);
153
154@@ -1094,9 +1127,10 @@
155
156 for (i = 0; i < locations->len; i++)
157 {
158- TzLocation *loc = locations->pdata[i];
159+ CcTimezoneLocation *loc = locations->pdata[i];
160+ g_object_get_property(G_OBJECT (loc), "zone", &zone);
161
162- if (!g_strcmp0 (loc->zone, real_tz ? real_tz : timezone))
163+ if (!g_strcmp0 (g_value_get_string(&zone), real_tz ? real_tz : timezone))
164 {
165 set_location (map, loc);
166 break;
167@@ -1104,6 +1138,7 @@
168 }
169
170 gtk_widget_queue_draw (GTK_WIDGET (map));
171+ g_value_unset (&zone);
172 }
173
174 void
175@@ -1132,11 +1167,14 @@
176 }
177 else {
178 GtkAllocation alloc;
179+ GValue val_zone = {0};
180+ g_value_init (&val_zone, G_TYPE_STRING);
181 gtk_widget_get_allocation (GTK_WIDGET (map), &alloc);
182 x = convert_longtitude_to_x(lon, alloc.width);
183 y = convert_latitude_to_y(lat, alloc.height);
184- TzLocation * loc = get_loc_for_xy(GTK_WIDGET (map), x, y);
185- return loc->zone;
186+ CcTimezoneLocation * loc = get_loc_for_xy(GTK_WIDGET (map), x, y);
187+ g_value_unset (&val_zone);
188+ return g_value_get_string(&val_zone);
189 }
190 }
191
192@@ -1150,7 +1188,7 @@
193 gtk_widget_queue_draw (GTK_WIDGET (map));
194 }
195
196-TzLocation *
197+CcTimezoneLocation *
198 cc_timezone_map_get_location (CcTimezoneMap *map)
199 {
200 return map->priv->location;
201
202=== modified file 'src/cc-timezone-map.h'
203--- src/cc-timezone-map.h 2011-07-28 15:18:24 +0000
204+++ src/cc-timezone-map.h 2011-08-02 08:06:15 +0000
205@@ -78,7 +78,7 @@
206 gdouble lon, gdouble lat);
207 const gchar * cc_timezone_map_get_timezone_at_coords (CcTimezoneMap *map,
208 gdouble lon, gdouble lat);
209-TzLocation * cc_timezone_map_get_location (CcTimezoneMap *map);
210+CcTimezoneLocation * cc_timezone_map_get_location (CcTimezoneMap *map);
211
212 G_END_DECLS
213
214
215=== modified file 'src/test-timezone.c'
216--- src/test-timezone.c 2011-07-28 15:28:24 +0000
217+++ src/test-timezone.c 2011-08-02 08:06:15 +0000
218@@ -22,14 +22,20 @@
219 return 1;
220 }
221
222+ g_type_init();
223+ GValue zone = {0};
224+ g_value_init(&zone, G_TYPE_STRING);
225+
226 db = tz_load_db ();
227 locs = tz_get_locations (db);
228 for (i = 0; i < locs->len ; i++) {
229- TzLocation *loc = locs->pdata[i];
230+ CcTimezoneLocation *loc = locs->pdata[i];
231+
232 TzInfo *info;
233 char *filename, *path;
234 gdouble selected_offset;
235- char buf[16];
236+ char buf[16];
237+ g_object_get_property(G_OBJECT (loc), "zone", &zone);
238
239 info = tz_info_from_location (loc);
240 selected_offset = tz_location_get_utc_offset (loc)
241@@ -41,7 +47,7 @@
242 path = g_build_filename (pixmap_dir, filename, NULL);
243
244 if (g_file_test (path, G_FILE_TEST_IS_REGULAR) == FALSE) {
245- g_message ("File '%s' missing for zone '%s'", filename, loc->zone);
246+ g_message ("File '%s' missing for zone '%s'", filename, g_value_get_string(&zone));
247 retval = 1;
248 }
249
250
251=== modified file 'src/tz.c'
252--- src/tz.c 2011-07-28 15:18:24 +0000
253+++ src/tz.c 2011-08-02 08:06:15 +0000
254@@ -30,6 +30,7 @@
255 #include <time.h>
256 #include <math.h>
257 #include <string.h>
258+#include <float.h>
259 #include "tz.h"
260
261
262@@ -40,6 +41,202 @@
263 static void sort_locations_by_country (GPtrArray *locations);
264 static gchar * tz_data_file_get (void);
265
266+G_DEFINE_TYPE (CcTimezoneLocation, cc_timezone_location, G_TYPE_OBJECT)
267+
268+#define TIMEZONE_LOCATION_PRIVATE(o) \
269+ (G_TYPE_INSTANCE_GET_PRIVATE ((o), CC_TYPE_TIMEZONE_LOCATION, CcTimezoneLocationPrivate))
270+
271+struct _CcTimezoneLocationPrivate
272+{
273+ gchar *country;
274+ gdouble latitude;
275+ gdouble longitude;
276+ gchar *zone;
277+ gchar *comment;
278+
279+ gdouble dist; /* distance to clicked point for comparison */
280+};
281+
282+enum {
283+ PROP_0,
284+ PROP_COUNTRY,
285+ PROP_LATITUDE,
286+ PROP_LONGITUDE,
287+ PROP_ZONE,
288+ PROP_COMMENT,
289+ PROP_DIST
290+};
291+
292+static void
293+cc_timezone_location_get_property (GObject *object,
294+ guint property_id,
295+ GValue *value,
296+ GParamSpec *pspec)
297+{
298+ CcTimezoneLocationPrivate *priv = CC_TIMEZONE_LOCATION (object)->priv;
299+ switch (property_id)
300+ {
301+ case PROP_COUNTRY:
302+ g_value_set_string (value, priv->country);
303+ break;
304+ case PROP_LATITUDE:
305+ g_value_set_double (value, priv->latitude);
306+ break;
307+ case PROP_LONGITUDE:
308+ g_value_set_double (value, priv->longitude);
309+ break;
310+ case PROP_ZONE:
311+ g_value_set_string (value, priv->zone);
312+ break;
313+ case PROP_COMMENT:
314+ g_value_set_string (value, priv->comment);
315+ break;
316+ case PROP_DIST:
317+ g_value_set_double (value, priv->dist);
318+ break;
319+ default:
320+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
321+ }
322+}
323+
324+static void
325+cc_timezone_location_set_property (GObject *object,
326+ guint property_id,
327+ const GValue *value,
328+ GParamSpec *pspec)
329+{
330+ CcTimezoneLocationPrivate *priv = CC_TIMEZONE_LOCATION (object)->priv;
331+ switch (property_id)
332+ {
333+ case PROP_COUNTRY:
334+ priv->country = g_value_get_string(value);
335+ break;
336+ case PROP_LATITUDE:
337+ priv->latitude = g_value_get_double(value);
338+ break;
339+ case PROP_LONGITUDE:
340+ priv->longitude = g_value_get_double(value);
341+ break;
342+ case PROP_ZONE:
343+ priv->zone = g_value_get_string(value);
344+ break;
345+ case PROP_COMMENT:
346+ priv->comment = g_value_get_string(value);
347+ break;
348+ case PROP_DIST:
349+ priv->dist = g_value_get_double(value);
350+ break;
351+ default:
352+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
353+ }
354+}
355+
356+static void
357+cc_timezone_location_dispose (GObject *object)
358+{
359+ CcTimezoneLocationPrivate *priv = CC_TIMEZONE_LOCATION (object)->priv;
360+
361+ if (priv->country)
362+ {
363+ g_object_unref (priv->country);
364+ priv->country = NULL;
365+ }
366+
367+ if (priv->zone)
368+ {
369+ g_object_unref (priv->zone);
370+ priv->zone = NULL;
371+ }
372+
373+ if (priv->comment)
374+ {
375+ g_object_unref (priv->comment);
376+ priv->comment = NULL;
377+ }
378+
379+ G_OBJECT_CLASS (cc_timezone_location_parent_class)->dispose (object);
380+}
381+
382+static void
383+cc_timezone_location_finalize (GObject *object)
384+{
385+ CcTimezoneLocationPrivate *priv = CC_TIMEZONE_LOCATION (object)->priv;
386+ G_OBJECT_CLASS (cc_timezone_location_parent_class)->finalize (object);
387+}
388+
389+static void
390+cc_timezone_location_class_init (CcTimezoneLocationClass *klass)
391+{
392+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
393+ g_type_class_add_private (klass, sizeof (CcTimezoneLocationPrivate));
394+
395+ object_class->get_property = cc_timezone_location_get_property;
396+ object_class->set_property = cc_timezone_location_set_property;
397+ object_class->dispose = cc_timezone_location_dispose;
398+ object_class->finalize = cc_timezone_location_finalize;
399+
400+ g_object_class_install_property(object_class,
401+ PROP_COUNTRY,
402+ g_param_spec_string ("country",
403+ "Country",
404+ "The country for the location",
405+ "",
406+ G_PARAM_READWRITE));
407+ g_object_class_install_property(object_class,
408+ PROP_LATITUDE,
409+ g_param_spec_double ("latitude",
410+ "Latitude",
411+ "The latitude for the location",
412+ -90.0,
413+ 90.0,
414+ 0.0,
415+ G_PARAM_READWRITE));
416+ g_object_class_install_property(object_class,
417+ PROP_LONGITUDE,
418+ g_param_spec_double ("longitude",
419+ "Longitude",
420+ "The longitude for the location",
421+ -180.0,
422+ 180.0,
423+ 0.0,
424+ G_PARAM_READWRITE));
425+ g_object_class_install_property(object_class,
426+ PROP_ZONE,
427+ g_param_spec_string ("zone",
428+ "Zone",
429+ "The time zone for the location",
430+ "",
431+ G_PARAM_READWRITE));
432+ g_object_class_install_property(object_class,
433+ PROP_COMMENT,
434+ g_param_spec_string ("Comment",
435+ "Comment",
436+ "A comment for the location",
437+ "",
438+ G_PARAM_READWRITE));
439+ g_object_class_install_property(object_class,
440+ PROP_DIST,
441+ g_param_spec_double ("dist",
442+ "Distance",
443+ "The distance for the location",
444+ 0.0,
445+ DBL_MAX,
446+ 0.0,
447+ G_PARAM_READWRITE));
448+}
449+
450+static void
451+cc_timezone_location_init (CcTimezoneLocation *self) {
452+ CcTimezoneLocationPrivate *priv;
453+ priv = self->priv = TIMEZONE_LOCATION_PRIVATE (self);
454+}
455+
456+CcTimezoneLocation *
457+cc_timezone_location_new (void)
458+{
459+ return g_object_new (CC_TYPE_TIMEZONE_LOCATION, NULL);
460+}
461+
462
463 /* ---------------- *
464 * Public interface *
465@@ -71,7 +268,7 @@
466 {
467 gchar **tmpstrarr;
468 gchar *latstr, *lngstr, *p;
469- TzLocation *loc;
470+ CcTimezoneLocation *loc;
471
472 if (*buf == '#') continue;
473
474@@ -84,21 +281,21 @@
475 lngstr = g_strdup (p);
476 *p = '\0';
477
478- loc = g_new0 (TzLocation, 1);
479- loc->country = g_strdup (tmpstrarr[0]);
480- loc->zone = g_strdup (tmpstrarr[2]);
481- loc->latitude = convert_pos (latstr, 2);
482- loc->longitude = convert_pos (lngstr, 3);
483+ loc = cc_timezone_location_new ();
484+ loc->priv->country = g_strdup (tmpstrarr[0]);
485+ loc->priv->zone = g_strdup (tmpstrarr[2]);
486+ loc->priv->latitude = convert_pos (latstr, 2);
487+ loc->priv->longitude = convert_pos (lngstr, 3);
488
489 #ifdef __sun
490 if (tmpstrarr[3] && *tmpstrarr[3] == '-' && tmpstrarr[4])
491 loc->comment = g_strdup (tmpstrarr[4]);
492
493 if (tmpstrarr[3] && *tmpstrarr[3] != '-' && !islower(loc->zone)) {
494- TzLocation *locgrp;
495+ CcTimezoneLocation *locgrp;
496
497 /* duplicate entry */
498- locgrp = g_new0 (TzLocation, 1);
499+ locgrp = cc_timezone_location_new ();
500 locgrp->country = g_strdup (tmpstrarr[0]);
501 locgrp->zone = g_strdup (tmpstrarr[3]);
502 locgrp->latitude = convert_pos (latstr, 2);
503@@ -108,7 +305,7 @@
504 g_ptr_array_add (tz_db->locations, (gpointer) locgrp);
505 }
506 #else
507- loc->comment = (tmpstrarr[3]) ? g_strdup(tmpstrarr[3]) : NULL;
508+ loc->priv->comment = (tmpstrarr[3]) ? g_strdup(tmpstrarr[3]) : NULL;
509 #endif
510
511 g_ptr_array_add (tz_db->locations, (gpointer) loc);
512@@ -128,32 +325,22 @@
513 return tz_db;
514 }
515
516-static void
517-tz_location_free (TzLocation *loc)
518-{
519- g_free (loc->country);
520- g_free (loc->zone);
521- g_free (loc->comment);
522-
523- g_free (loc);
524-}
525-
526 void
527 tz_db_free (TzDB *db)
528 {
529- g_ptr_array_foreach (db->locations, (GFunc) tz_location_free, NULL);
530+ g_ptr_array_foreach (db->locations, (GFunc) g_object_unref, NULL);
531 g_ptr_array_free (db->locations, TRUE);
532 g_free (db);
533 }
534
535 static gint
536-sort_locations (TzLocation *a,
537- TzLocation *b)
538+sort_locations (CcTimezoneLocation *a,
539+ CcTimezoneLocation *b)
540 {
541- if (a->dist > b->dist)
542+ if (a->priv->dist > b->priv->dist)
543 return 1;
544
545- if (a->dist < b->dist)
546+ if (a->priv->dist < b->priv->dist)
547 return -1;
548
549 return 0;
550@@ -201,37 +388,8 @@
551 return db->locations;
552 }
553
554-
555-gchar *
556-tz_location_get_country (TzLocation *loc)
557-{
558- return loc->country;
559-}
560-
561-
562-gchar *
563-tz_location_get_zone (TzLocation *loc)
564-{
565- return loc->zone;
566-}
567-
568-
569-gchar *
570-tz_location_get_comment (TzLocation *loc)
571-{
572- return loc->comment;
573-}
574-
575-
576-void
577-tz_location_get_position (TzLocation *loc, double *longitude, double *latitude)
578-{
579- *longitude = loc->longitude;
580- *latitude = loc->latitude;
581-}
582-
583 glong
584-tz_location_get_utc_offset (TzLocation *loc)
585+tz_location_get_utc_offset (CcTimezoneLocation *loc)
586 {
587 TzInfo *tz_info;
588 glong offset;
589@@ -243,7 +401,7 @@
590 }
591
592 gint
593-tz_location_set_locally (TzLocation *loc)
594+tz_location_set_locally (CcTimezoneLocation *loc)
595 {
596 time_t curtime;
597 struct tm *curzone;
598@@ -251,13 +409,13 @@
599 gint correction = 0;
600
601 g_return_val_if_fail (loc != NULL, 0);
602- g_return_val_if_fail (loc->zone != NULL, 0);
603+ g_return_val_if_fail (loc->priv->zone != NULL, 0);
604
605 curtime = time (NULL);
606 curzone = localtime (&curtime);
607 is_dst = curzone->tm_isdst;
608
609- setenv ("TZ", loc->zone, 1);
610+ setenv ("TZ", loc->priv->zone, 1);
611 #if 0
612 curtime = time (NULL);
613 curzone = localtime (&curtime);
614@@ -274,16 +432,16 @@
615 }
616
617 TzInfo *
618-tz_info_from_location (TzLocation *loc)
619+tz_info_from_location (CcTimezoneLocation *loc)
620 {
621 TzInfo *tzinfo;
622 time_t curtime;
623 struct tm *curzone;
624
625 g_return_val_if_fail (loc != NULL, NULL);
626- g_return_val_if_fail (loc->zone != NULL, NULL);
627+ g_return_val_if_fail (loc->priv->zone != NULL, NULL);
628
629- setenv ("TZ", loc->zone, 1);
630+ setenv ("TZ", loc->priv->zone, 1);
631
632 #if 0
633 tzset ();
634@@ -361,33 +519,13 @@
635 else return t1 - t2/pow (10.0, strlen(fraction));
636 }
637
638-
639-#if 0
640-
641-/* Currently not working */
642-static void
643-free_tzdata (TzLocation *tz)
644-{
645-
646- if (tz->country)
647- g_free(tz->country);
648- if (tz->zone)
649- g_free(tz->zone);
650- if (tz->comment)
651- g_free(tz->comment);
652-
653- g_free(tz);
654-}
655-#endif
656-
657-
658 static int
659 compare_country_names (const void *a, const void *b)
660 {
661- const TzLocation *tza = * (TzLocation **) a;
662- const TzLocation *tzb = * (TzLocation **) b;
663+ const CcTimezoneLocation *tza = * (CcTimezoneLocation **) a;
664+ const CcTimezoneLocation *tzb = * (CcTimezoneLocation **) b;
665
666- return strcmp (tza->zone, tzb->zone);
667+ return strcmp (tza->priv->zone, tzb->priv->zone);
668 }
669
670
671
672=== modified file 'src/tz.h'
673--- src/tz.h 2011-07-28 15:18:24 +0000
674+++ src/tz.h 2011-08-02 08:06:15 +0000
675@@ -27,6 +27,7 @@
676 #define _E_TZ_H
677
678 #include <glib.h>
679+#include <glib-object.h>
680
681 #ifndef __sun
682 # define TZ_DATA_FILE "/usr/share/zoneinfo/zone.tab"
683@@ -34,9 +35,50 @@
684 # define TZ_DATA_FILE "/usr/share/lib/zoneinfo/tab/zone_sun.tab"
685 #endif
686
687+G_BEGIN_DECLS
688+
689+#define CC_TYPE_TIMEZONE_LOCATION cc_timezone_location_get_type()
690+
691+#define CC_TIMEZONE_LOCATION(obj) \
692+ (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
693+ CC_TYPE_TIMEZONE_LOCATION, CcTimezoneLocation))
694+
695+#define CC_TIMEZONE_LOCATION_CLASS(klass) \
696+ (G_TYPE_CHECK_CLASS_CAST ((klass), \
697+ CC_TYPE_TIMEZONE_LOCATION, CcTimezoneLocationClass))
698+
699+#define CC_IS_TIMEZONE_LOCATION(obj) \
700+ (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
701+ CC_TYPE_TIMEZONE_LOCATION))
702+
703+#define CC_IS_TIMEZONE_LOCATION_CLASS(klass) \
704+ (G_TYPE_CHECK_CLASS_TYPE ((klass), \
705+ CC_TYPE_TIMEZONE_LOCATION))
706+
707+#define CC_TIMEZONE_LOCATION_GET_CLASS(obj) \
708+ (G_TYPE_INSTANCE_GET_CLASS ((obj), \
709+ CC_TYPE_TIMEZONE_LOCATION, CcTimezoneLocationClass))
710+
711 typedef struct _TzDB TzDB;
712-typedef struct _TzLocation TzLocation;
713 typedef struct _TzInfo TzInfo;
714+typedef struct _CcTimezoneLocation CcTimezoneLocation;
715+typedef struct _CcTimezoneLocationClass CcTimezoneLocationClass;
716+typedef struct _CcTimezoneLocationPrivate CcTimezoneLocationPrivate;
717+
718+struct _CcTimezoneLocation
719+{
720+ GObject parent;
721+ CcTimezoneLocationPrivate *priv;
722+};
723+
724+struct _CcTimezoneLocationClass
725+{
726+ GObjectClass parent_class;
727+};
728+
729+GType cc_timezone_location_get_type (void) G_GNUC_CONST;
730+
731+CcTimezoneLocation *cc_timezone_location_new (void);
732
733
734 struct _TzDB
735@@ -44,16 +86,6 @@
736 GPtrArray *locations;
737 };
738
739-struct _TzLocation
740-{
741- gchar *country;
742- gdouble latitude;
743- gdouble longitude;
744- gchar *zone;
745- gchar *comment;
746-
747- gdouble dist; /* distance to clicked point for comparison */
748-};
749
750 /* see the glibc info page information on time zone information */
751 /* tzname_normal is the default name for the timezone */
752@@ -73,14 +105,11 @@
753 TzDB *tz_load_db (void);
754 void tz_db_free (TzDB *db);
755 GPtrArray *tz_get_locations (TzDB *db);
756-void tz_location_get_position (TzLocation *loc,
757- double *longitude, double *latitude);
758-char *tz_location_get_country (TzLocation *loc);
759-gchar *tz_location_get_zone (TzLocation *loc);
760-gchar *tz_location_get_comment (TzLocation *loc);
761-glong tz_location_get_utc_offset (TzLocation *loc);
762-gint tz_location_set_locally (TzLocation *loc);
763-TzInfo *tz_info_from_location (TzLocation *loc);
764+glong tz_location_get_utc_offset (CcTimezoneLocation *loc);
765+gint tz_location_set_locally (CcTimezoneLocation *loc);
766+TzInfo *tz_info_from_location (CcTimezoneLocation *loc);
767 void tz_info_free (TzInfo *tz_info);
768
769+G_END_DECLS
770+
771 #endif

Subscribers

People subscribed via source and target branches

to all changes: