Changeset 3301
- Timestamp:
- 10/29/07 18:54:18 (6 years ago)
- Location:
- trunk/src/target/OM-2007.2/applications/openmoko-worldclock2
- Files:
-
- 4 added
- 5 edited
-
ChangeLog (modified) (1 diff)
-
Makefile.am (modified) (1 diff)
-
configure.ac (modified) (1 diff)
-
data (added)
-
data/Makefile.am (added)
-
src/Makefile.am (modified) (1 diff)
-
src/worldclock-data.c (added)
-
src/worldclock-data.h (added)
-
src/worldclock-main.c (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/target/OM-2007.2/applications/openmoko-worldclock2/ChangeLog
r3241 r3301 1 2007-10-29 Chris Lord <chris@openedhand.com> 2 3 * Makefile.am: 4 * configure.ac: 5 * data/Makefile.am: 6 * src/Makefile.am: 7 * src/worldclock-data.c: 8 * src/worldclock-data.h: 9 * src/worldclock-main.c: (increment_time_timeout), 10 (date_time_changed_cb), (settings_clicked_cb), (add_marks), (main): 11 Add markers for time-zones on the map and add rudimentary system-clock 12 setting functionality 13 1 14 2007-10-22 Chris Lord <chris@openedhand.com> 2 15 -
trunk/src/target/OM-2007.2/applications/openmoko-worldclock2/Makefile.am
r3241 r3301 1 SUBDIRS= src1 SUBDIRS=data src -
trunk/src/target/OM-2007.2/applications/openmoko-worldclock2/configure.ac
r3241 r3301 14 14 PKG_CHECK_MODULES(MOKOUI, libmokoui2 >= 0.3) 15 15 PKG_CHECK_MODULES(JANA, libjana libjana-ecal libjana-gtk) 16 PKG_CHECK_MODULES(NOTIFY, libnotify >= 0.4) 16 17 17 18 AC_OUTPUT([ 18 19 Makefile 20 data/Makefile 19 21 src/Makefile 20 22 ]) -
trunk/src/target/OM-2007.2/applications/openmoko-worldclock2/src/Makefile.am
r3241 r3301 1 1 2 AM_CPPFLAGS = -DPKGDATADIR=\"$(pkgdatadir)\" $(GTK_CFLAGS) $(JANA_CFLAGS) $(MOKOUI_CFLAGS) -Wall3 AM_LDFLAGS = $(GTK_LIBS) $(JANA_LIBS) $(MOKOUI_LIBS) 2 AM_CPPFLAGS = -DPKGDATADIR=\"$(pkgdatadir)\" $(GTK_CFLAGS) $(JANA_CFLAGS) $(MOKOUI_CFLAGS) $(NOTIFY_CFLAGS) -Wall 3 AM_LDFLAGS = $(GTK_LIBS) $(JANA_LIBS) $(MOKOUI_LIBS) $(NOTIFY_LIBS) 4 4 5 5 bin_PROGRAMS=openmoko-worldclock 6 6 7 openmoko_worldclock_SOURCES = worldclock-main.c 7 openmoko_worldclock_SOURCES = \ 8 worldclock-main.c \ 9 worldclock-data.c \ 10 worldclock-data.h 8 11 -
trunk/src/target/OM-2007.2/applications/openmoko-worldclock2/src/worldclock-main.c
r3241 r3301 1 /* 2 * openmoko-worldclock -- OpenMoko Clock Application 3 * 4 * Authored by Chris Lord <chris@openedhand.com> 5 * 6 * Copyright (C) 2007 OpenMoko Inc. 7 * 8 * This program is free software; you can redistribute it and/or modify 9 * it under the terms of the GNU Lesser Public License as published by 10 * the Free Software Foundation; version 2 of the license. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU Lesser Public License for more details. 16 * 17 * Current Version: $Rev$ ($Date$) [$Author$] 18 */ 1 19 2 20 #include <gtk/gtk.h> … … 5 23 #include <libjana-gtk/jana-gtk.h> 6 24 #include <libmokoui2/moko-finger-scroll.h> 25 #include <time.h> 26 #include <sys/time.h> 27 #include "worldclock-data.h" 7 28 8 29 static gchar *location; … … 15 36 16 37 guint render_idle; 38 guint time_idle; 17 39 18 40 gchar *location; … … 58 80 } 59 81 82 static gboolean ignore_next = FALSE; 83 84 static gboolean 85 increment_time_timeout (JanaGtkDateTime *dt) 86 { 87 JanaTime *time; 88 89 ignore_next = TRUE; 90 91 time = jana_gtk_date_time_get_time (dt); 92 jana_time_set_seconds (time, jana_time_get_seconds (time) + 1); 93 jana_gtk_date_time_set_time (dt, time); 94 g_object_unref (time); 95 96 return TRUE; 97 } 98 99 static void 100 date_time_changed_cb (JanaGtkDateTime *dt, WorldClockData *data) 101 { 102 if (ignore_next) { 103 ignore_next = FALSE; 104 return; 105 } 106 if (data->time_idle) { 107 g_source_remove (data->time_idle); 108 data->time_idle = 0; 109 } 110 } 111 112 static void 113 settings_clicked_cb (GtkToolButton *button, WorldClockData *data) 114 { 115 GtkWidget *time_dialog, *datetime; 116 gchar *location; 117 JanaTime *time; 118 119 time_dialog = gtk_dialog_new_with_buttons ("Set time", 120 GTK_WINDOW (data->window), 121 GTK_DIALOG_NO_SEPARATOR | GTK_DIALOG_MODAL, 122 GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, NULL); 123 124 location = jana_ecal_utils_guess_location (); 125 time = jana_ecal_utils_time_now (location); 126 g_free (location); 127 datetime = jana_gtk_date_time_new (time); 128 jana_gtk_date_time_set_editable (JANA_GTK_DATE_TIME (datetime), TRUE); 129 g_object_unref (time); 130 131 g_signal_connect (datetime, "changed", 132 G_CALLBACK (date_time_changed_cb), data); 133 134 #if GLIB_CHECK_VERSION(2,14,0) 135 data->time_idle = g_timeout_add_seconds (1, (GSourceFunc) 136 increment_time_timeout, datetime); 137 #else 138 data->time_idle = g_timeout_add (1000, (GSourceFunc) 139 increment_time_timeout, datetime); 140 #endif 141 142 gtk_container_add (GTK_CONTAINER ( 143 GTK_DIALOG (time_dialog)->vbox), datetime); 144 gtk_widget_show (datetime); 145 146 gtk_dialog_run (GTK_DIALOG (time_dialog)); 147 148 /* Set system time */ 149 if (data->time_idle) { 150 /* Time hasn't changed, don't set */ 151 g_source_remove (data->time_idle); 152 } else { 153 struct timeval time_tv; 154 struct tm time_tm; 155 156 time = jana_gtk_date_time_get_time ( 157 JANA_GTK_DATE_TIME (datetime)); 158 159 /* TODO: Maybe this should convert to UTC before setting? */ 160 time_tm = jana_utils_time_to_tm (time); 161 time_tv.tv_sec = timegm (&time_tm); 162 time_tv.tv_usec = 0; 163 164 settimeofday (&time_tv, NULL); 165 166 g_object_unref (time); 167 } 168 169 gtk_widget_destroy (time_dialog); 170 } 171 60 172 static gboolean 61 173 set_time (GtkWidget *map) … … 91 203 g_source_remove (data->render_idle); 92 204 gtk_widget_hide (data->load_window); 205 } 206 207 static void 208 add_marks (WorldClockData *data) 209 { 210 gint i, width, height; 211 212 gtk_icon_size_lookup (GTK_ICON_SIZE_MENU, &width, &height); 213 214 for (i = 0; i < G_N_ELEMENTS (world_clock_tzdata); i++) { 215 JanaGtkWorldMapMarker *mark; 216 gchar *path, *image_name; 217 GdkPixbuf *pixbuf; 218 219 GError *error = NULL; 220 221 image_name = g_strdelimit (g_utf8_strdown ( 222 world_clock_tzdata[i].country, -1), " '", '_'); 223 path = g_strconcat (PKGDATADIR G_DIR_SEPARATOR_S, 224 image_name, ".svg", NULL); 225 g_free (image_name); 226 227 if (!g_file_test (path, G_FILE_TEST_EXISTS)) { 228 pixbuf = NULL; 229 } else if (!(pixbuf = gdk_pixbuf_new_from_file_at_size (path, 230 width, -1, &error))) { 231 g_warning ("Error loading '%s': %s", 232 path, error->message); 233 g_error_free (error); 234 } 235 if (pixbuf) 236 mark = jana_gtk_world_map_marker_pixbuf_new (pixbuf); 237 else 238 mark = jana_gtk_world_map_marker_new (); 239 240 g_object_set_data (G_OBJECT (mark), "zone", 241 (gpointer)(&world_clock_tzdata[i])); 242 jana_gtk_world_map_add_marker (JANA_GTK_WORLD_MAP (data->map), 243 mark, world_clock_tzdata[i].lat, 244 world_clock_tzdata[i].lon); 245 g_free (path); 246 } 93 247 } 94 248 … … 111 265 toolbar = gtk_toolbar_new (); 112 266 267 /* Settings button */ 268 button = worldclock_utils_toolbutton_new (GTK_STOCK_PREFERENCES); 269 gtk_toolbar_insert (GTK_TOOLBAR (toolbar), button, 0); 270 gtk_toolbar_insert (GTK_TOOLBAR (toolbar), 271 gtk_separator_tool_item_new (), 0); 272 g_signal_connect (button, "clicked", 273 G_CALLBACK (settings_clicked_cb), &data); 274 113 275 /* Zoom in button */ 114 276 button = worldclock_utils_toolbutton_new (GTK_STOCK_ZOOM_IN); … … 129 291 /* Create scrolling map */ 130 292 data.map = jana_gtk_world_map_new (); 293 add_marks (&data); 131 294 scroll = moko_finger_scroll_new (); 132 295 moko_finger_scroll_add_with_viewport (MOKO_FINGER_SCROLL (scroll), … … 174 337 "gtk-font-name", "Sans 6", 175 338 NULL); 339 #endif 176 340 gtk_window_set_default_size (GTK_WINDOW (data.window), 480, 600); 177 #endif178 341 179 342 location = jana_ecal_utils_guess_location ();
Note: See TracChangeset
for help on using the changeset viewer.
