Changeset 3320


Ignore:
Timestamp:
11/01/07 17:21:18 (6 years ago)
Author:
chris
Message:
  • src/worldclock-main.c: (map_button_press_event_cb), (main): Use a static map and add code to find the nearest timezone to where the user clicks
Location:
trunk/src/target/OM-2007.2/applications/openmoko-worldclock2
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/target/OM-2007.2/applications/openmoko-worldclock2/ChangeLog

    r3313 r3320  
     12007-11-01  Chris Lord  <chris@openedhand.com> 
     2 
     3        * src/worldclock-main.c: (map_button_press_event_cb), (main): 
     4        Use a static map and add code to find the nearest timezone to where the 
     5        user clicks 
     6 
    172007-10-31  Chris Lord  <chris@openedhand.com> 
    28 
  • trunk/src/target/OM-2007.2/applications/openmoko-worldclock2/src/worldclock-main.c

    r3313 r3320  
    2525#include <time.h> 
    2626#include <sys/time.h> 
     27#include <math.h> 
    2728#include "worldclock-data.h" 
    2829 
     
    269270                           WorldClockData *data) 
    270271{ 
    271         gdouble lat, lon; 
     272        GList *markers, *m; 
     273        gdouble lat, lon, old_distance; 
     274        JanaGtkWorldMapMarker *marker; 
    272275         
    273276        jana_gtk_world_map_get_latlon (map, event->x, event->y, &lat, &lon); 
    274         g_message ("Map clicked at latitude, longitude: %lg, %lg", lat, lon); 
     277        markers = jana_gtk_world_map_get_markers (map); 
     278         
     279        marker = NULL; 
     280        old_distance = G_MAXDOUBLE; 
     281        for (m = markers; m; m = m->next) { 
     282                gdouble distance; 
     283                JanaGtkWorldMapMarker *marker2 = 
     284                        (JanaGtkWorldMapMarker *)m->data; 
     285                 
     286                distance = sqrt (pow (marker2->lat - lat, 2) + 
     287                        pow (marker2->lon - lon, 2)); 
     288                if (distance < old_distance) { 
     289                        marker = marker2; 
     290                        old_distance = distance; 
     291                } 
     292        } 
     293         
     294        if (marker) { 
     295                WorldClockZoneData *tzdata = (WorldClockZoneData *) 
     296                        g_object_get_data (G_OBJECT (marker), "zone"); 
     297                g_debug ("Nearest location: %s", tzdata->name); 
     298        } 
     299         
     300        g_list_free (markers); 
    275301         
    276302        return FALSE; 
     
    321347        /* Create scrolling map */ 
    322348        data.map = jana_gtk_world_map_new (); 
     349        jana_gtk_world_map_set_width (JANA_GTK_WORLD_MAP (data.map), 2048); 
     350        jana_gtk_world_map_set_height (JANA_GTK_WORLD_MAP (data.map), 1024); 
     351        jana_gtk_world_map_set_static (JANA_GTK_WORLD_MAP (data.map), TRUE); 
    323352        add_marks (&data); 
    324353        gtk_widget_add_events (GTK_WIDGET (data.map), GDK_BUTTON_PRESS_MASK); 
Note: See TracChangeset for help on using the changeset viewer.