/* * Author: Chris Lord * * Copyright (c) 2007 OpenedHand Ltd - http://www.openedhand.com/ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * */ #include #include #include static GtkWidget *map; static gchar *location; gboolean first = TRUE; static gboolean set_time (GtkWidget *clock) { JanaTime *time; time = jana_ecal_utils_time_now (location); jana_gtk_clock_set_time (JANA_GTK_CLOCK (clock), time); if (first || (jana_time_get_seconds (time) == 0)) { /* Update every minute */ jana_gtk_world_map_set_time (JANA_GTK_WORLD_MAP (map), time); first = FALSE; } g_object_unref (time); return TRUE; } static gboolean button_press_event_cb (JanaGtkWorldMap *map, GdkEventButton *event) { gdouble lat, lon; jana_gtk_world_map_get_latlon (map, event->x, event->y, &lat, &lon); g_message ("Map clicked at latitude, longitude: %lg, %lg", lat, lon); return FALSE; } int main (int argc, char **argv) { guint id; GtkWidget *window, *align, *clock; gtk_init (&argc, &argv); window = gtk_window_new (GTK_WINDOW_TOPLEVEL); map = jana_gtk_world_map_new (); clock = jana_gtk_clock_new (); jana_gtk_clock_set_show_seconds (JANA_GTK_CLOCK (clock), TRUE); jana_gtk_clock_set_draw_shadow (JANA_GTK_CLOCK (clock), TRUE); align = gtk_alignment_new (1.0, 1.0, 0.3, 0.3); gtk_container_add (GTK_CONTAINER (align), clock); gtk_container_add (GTK_CONTAINER (map), align); gtk_container_add (GTK_CONTAINER (window), map); gtk_window_set_default_size (GTK_WINDOW (window), 480, 320); gtk_widget_show_all (window); gtk_widget_add_events (GTK_WIDGET (map), GDK_BUTTON_PRESS_MASK); g_signal_connect (map, "button-press-event", G_CALLBACK (button_press_event_cb), NULL); g_signal_connect (window, "delete-event", G_CALLBACK (gtk_main_quit), NULL); location = jana_ecal_utils_guess_location (); id = g_timeout_add (1000, (GSourceFunc)set_time, clock); set_time (clock); gtk_main (); g_source_remove (id); g_free (location); return 0; }