~elementary-os/elementaryos/os-patch-gnome-control-center-precise

« back to all changes in this revision

Viewing changes to panels/datetime/test-timezone-gfx.c

  • Committer: Sergey "Shnatsel" Davidoff
  • Date: 2012-05-18 13:02:50 UTC
  • Revision ID: shnatsel@gmail.com-20120518130250-2u99ldq61a42rbt7
Initial import, version 1:3.4.1-0ubuntu2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <config.h>
 
2
#include <locale.h>
 
3
 
 
4
#include "tz.h"
 
5
 
 
6
int main (int argc, char **argv)
 
7
{
 
8
        TzDB *db;
 
9
        GPtrArray *locs;
 
10
        guint i;
 
11
        char *pixmap_dir;
 
12
        int retval = 0;
 
13
 
 
14
        setlocale (LC_ALL, "");
 
15
 
 
16
        if (argc == 2) {
 
17
                pixmap_dir = g_strdup (argv[1]);
 
18
        } else if (argc == 1) {
 
19
                pixmap_dir = g_strdup ("data/");
 
20
        } else {
 
21
                g_message ("Usage: %s [PIXMAP DIRECTORY]", argv[0]);
 
22
                return 1;
 
23
        }
 
24
 
 
25
        db = tz_load_db ();
 
26
        locs = tz_get_locations (db);
 
27
        for (i = 0; i < locs->len ; i++) {
 
28
                TzLocation *loc = locs->pdata[i];
 
29
                TzInfo *info;
 
30
                char *filename, *path;
 
31
                gdouble selected_offset;
 
32
                char buf[16];
 
33
 
 
34
                info = tz_info_from_location (loc);
 
35
                selected_offset = tz_location_get_utc_offset (loc)
 
36
                        / (60.0*60.0) + ((info->daylight) ? -1.0 : 0.0);
 
37
 
 
38
                filename = g_strdup_printf ("timezone_%s.png",
 
39
                                            g_ascii_formatd (buf, sizeof (buf),
 
40
                                                             "%g", selected_offset));
 
41
                path = g_build_filename (pixmap_dir, filename, NULL);
 
42
 
 
43
                if (g_file_test (path, G_FILE_TEST_IS_REGULAR) == FALSE) {
 
44
                        g_message ("File '%s' missing for zone '%s'", filename, loc->zone);
 
45
                        retval = 1;
 
46
                }
 
47
 
 
48
                g_free (filename);
 
49
                g_free (path);
 
50
        }
 
51
        tz_db_free (db);
 
52
        g_free (pixmap_dir);
 
53
 
 
54
        return retval;
 
55
}