~ubuntu-branches/ubuntu/utopic/gnome-system-tools/utopic-updates

« back to all changes in this revision

Viewing changes to src/time/e-map/e-map-test.c

  • Committer: Package Import Robot
  • Author(s): Michael Terry
  • Date: 2011-12-16 17:08:20 UTC
  • mfrom: (1.5.13) (1.2.14 sid)
  • Revision ID: package-import@ubuntu.com-20111216170820-6dsj6ctf071oxqea
Tags: 3.0.0-2ubuntu1
* Merge from Debian, remaining changes:
  - Split out gnome-network-admin
  - Split out gnome-time-admin
  - Drop gnome-control-center to Suggests
  - 25_sambashare_group_definition.patch
  - 26_user_profiles_conf.patch
  - 80_gst-packages-common.patch
  - 81_gst-packages-shares-admin.patch
  - 82_gst-packages-time-admin.patch
  - 91_shares_services_detection.patch
  - 95_timezone_point_selection.patch
  - 96_ubuntu_ntp_pool.patch
  - fix-missing-header-ftbfs-amd64.patch
* debian/patches/80_gst-packages-common.patch,
  debian/patches/81_gst-packages-shares-admin.patch:
  - Update for GTK+ 3
* debian/patches/92_fix_add_needed_linking.patch,
  debian/patches/97_fix_setting_password_from_random_entry.patch:
  - Dropped, applied upstream
* debian/patches/remove_g_thread_init.patch:
  - Remove obsolete and dropped API g_thread_init()

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
 
2
 
 
3
#include "e-map.h"
 
4
 
 
5
GtkWidget *window, *scroll;
 
6
EMap *map;
 
7
EMapPoint *point = NULL, *highlight_point = NULL;
 
8
int id;
 
9
 
 
10
 
 
11
static gint
 
12
flash(gpointer data)
 
13
{
 
14
        if (!point) return TRUE;
 
15
 
 
16
        if (e_map_point_get_color_rgba (point) == 0xf010d0ff)
 
17
                e_map_point_set_color_rgba (map, point, 0x000000ff);
 
18
        else
 
19
                e_map_point_set_color_rgba (map, point, 0xf010d0ff);
 
20
        
 
21
        return(TRUE);
 
22
}
 
23
 
 
24
 
 
25
static gboolean
 
26
motion (GtkWidget *widget, GdkEventMotion *event, gpointer user_data)
 
27
{
 
28
        double longitude, latitude;
 
29
        
 
30
        e_map_window_to_world (map, (double) event->x, (double) event->y,
 
31
                               &longitude, &latitude);
 
32
 
 
33
        if (highlight_point && highlight_point != point)
 
34
                e_map_point_set_color_rgba (map, highlight_point, 0xf010d0ff);
 
35
 
 
36
        highlight_point =
 
37
                e_map_get_closest_point (map, longitude, latitude, TRUE);
 
38
        
 
39
        if (highlight_point && highlight_point != point)
 
40
                e_map_point_set_color_rgba (map, highlight_point, 0xffff60ff);
 
41
 
 
42
        return(TRUE);
 
43
}
 
44
 
 
45
 
 
46
static gboolean
 
47
button_pressed (GtkWidget *w, GdkEventButton *event, gpointer data)
 
48
{
 
49
        double longitude, latitude;
 
50
        
 
51
        e_map_window_to_world (map, (double) event->x, (double) event->y,
 
52
                               &longitude, &latitude);
 
53
 
 
54
        if (event->button != 1)
 
55
                e_map_zoom_out (map);
 
56
        else
 
57
                e_map_zoom_to_location (map, longitude, latitude);
 
58
 
 
59
        if (point) e_map_point_set_color_rgba (map, point, 0xf010d0ff);
 
60
 
 
61
        point = highlight_point;
 
62
        
 
63
        return TRUE;
 
64
}
 
65
 
 
66
 
 
67
int
 
68
main (int argc, char *argv[])
 
69
{
 
70
        gtk_init (&argc, &argv);
 
71
  
 
72
        window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
 
73
        scroll = gtk_scrolled_window_new(GTK_POLICY_ALWAYS, GTK_POLICY_ALWAYS);
 
74
        map = e_map_new();
 
75
  
 
76
        gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(scroll));
 
77
        gtk_container_add(GTK_CONTAINER(scroll), GTK_WIDGET(map));
 
78
 
 
79
        e_map_set_smooth_zoom(E_MAP(map), TRUE);
 
80
        e_map_add_point(E_MAP(map), NULL, 40.0, 0.0, 0xf010d0ff);
 
81
        e_map_add_point(E_MAP(map), NULL, 10.0, 0.0, 0xf010d0ff);
 
82
        point = e_map_add_point(E_MAP(map), NULL, 25.0, 40.0, 0xf010d0ff);
 
83
        
 
84
        g_signal_connect(G_OBJECT (map), "motion-notify-event",
 
85
                         G_CALLBACK (motion), NULL);
 
86
        g_signal_connect(G_OBJECT(map), "button-press-event",
 
87
                         G_CALLBACK (button_pressed), NULL);
 
88
 
 
89
        gtk_widget_show_all(window);
 
90
        id = g_timeout_add(100, flash, NULL);
 
91
        gtk_main();
 
92
        return(0);
 
93
}