18 |
*/ |
*/ |
19 |
|
|
20 |
#include "appdata.h" |
#include "appdata.h" |
21 |
|
#include "osm-gps-map.h" |
22 |
|
|
23 |
typedef struct { |
typedef struct { |
24 |
GtkWidget *dialog, *notebook; |
GtkWidget *dialog, *notebook; |
35 |
gboolean is_mil; |
gboolean is_mil; |
36 |
} extent; |
} extent; |
37 |
|
|
38 |
|
#ifdef USE_HILDON |
39 |
struct { |
struct { |
40 |
GtkWidget *fetch; |
GtkWidget *fetch; |
41 |
} mmapper; |
} mmapper; |
42 |
|
#endif |
43 |
|
|
44 |
|
struct { |
45 |
|
GtkWidget *widget; |
46 |
|
GtkWidget *zoomin, *zoomout; |
47 |
|
} map; |
48 |
|
|
49 |
} context_t; |
} context_t; |
50 |
|
|
213 |
} |
} |
214 |
#endif |
#endif |
215 |
|
|
216 |
|
static void map_zoom(context_t *context, int step) { |
217 |
|
int zoom; |
218 |
|
OsmGpsMap *map = OSM_GPS_MAP(context->map.widget); |
219 |
|
g_object_get(map, "zoom", &zoom, NULL); |
220 |
|
zoom = osm_gps_map_set_zoom(map, zoom+step); |
221 |
|
|
222 |
|
/* enable/disable zoom buttons as required */ |
223 |
|
gtk_widget_set_sensitive(context->map.zoomin, zoom<17); |
224 |
|
gtk_widget_set_sensitive(context->map.zoomout, zoom>1); |
225 |
|
} |
226 |
|
|
227 |
|
static gboolean |
228 |
|
cb_map_zoomin(GtkButton *button, context_t *context) { |
229 |
|
map_zoom(context, +1); |
230 |
|
return FALSE; |
231 |
|
} |
232 |
|
|
233 |
|
static gboolean |
234 |
|
cb_map_zoomout(GtkButton *button, context_t *context) { |
235 |
|
map_zoom(context, -1); |
236 |
|
return FALSE; |
237 |
|
} |
238 |
|
|
239 |
gboolean area_edit(area_edit_t *area) { |
gboolean area_edit(area_edit_t *area) { |
240 |
gboolean ok = FALSE; |
gboolean ok = FALSE; |
241 |
|
|
248 |
context.max.lon = area->max->lon; |
context.max.lon = area->max->lon; |
249 |
|
|
250 |
context.dialog = |
context.dialog = |
251 |
misc_dialog_new(MISC_DIALOG_NOSIZE, _("Area editor"), |
misc_dialog_new(MISC_DIALOG_HIGH, _("Area editor"), |
252 |
GTK_WINDOW(area->parent), |
GTK_WINDOW(area->parent), |
253 |
GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, |
GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, |
254 |
GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, |
GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, |
277 |
context.maxlon = pos_lon_label_new(area->max->lon); |
context.maxlon = pos_lon_label_new(area->max->lon); |
278 |
gtk_table_attach_defaults(GTK_TABLE(table), context.maxlon, 2, 3, 2, 3); |
gtk_table_attach_defaults(GTK_TABLE(table), context.maxlon, 2, 3, 2, 3); |
279 |
|
|
280 |
gtk_box_pack_start_defaults(GTK_BOX(GTK_DIALOG(context.dialog)->vbox), |
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(context.dialog)->vbox), |
281 |
table); |
table, FALSE, FALSE, 0); |
282 |
|
|
283 |
context.notebook = gtk_notebook_new(); |
context.notebook = gtk_notebook_new(); |
284 |
|
|
285 |
/* ------------ direct min/max edit --------------- */ |
/* ------------ direct min/max edit --------------- */ |
286 |
|
|
287 |
|
GtkWidget *vbox = gtk_vbox_new(FALSE, 10); |
288 |
table = gtk_table_new(3, 3, FALSE); // x, y |
table = gtk_table_new(3, 3, FALSE); // x, y |
289 |
|
|
290 |
label = gtk_label_new(_("Min:")); |
label = gtk_label_new(_("Min:")); |
320 |
label = gtk_label_new(_("(recommended min/max diff <0.03 degrees)")); |
label = gtk_label_new(_("(recommended min/max diff <0.03 degrees)")); |
321 |
gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 3, 2, 3); |
gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 3, 2, 3); |
322 |
|
|
323 |
|
gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0); |
324 |
gtk_notebook_append_page(GTK_NOTEBOOK(context.notebook), |
gtk_notebook_append_page(GTK_NOTEBOOK(context.notebook), |
325 |
table, gtk_label_new(_("Direct"))); |
vbox, gtk_label_new(_("Direct"))); |
326 |
|
|
327 |
/* ------------- center/extent edit ------------------------ */ |
/* ------------- center/extent edit ------------------------ */ |
328 |
|
|
329 |
|
vbox = gtk_vbox_new(FALSE, 10); |
330 |
table = gtk_table_new(3, 4, FALSE); // x, y |
table = gtk_table_new(3, 4, FALSE); // x, y |
331 |
|
|
332 |
label = gtk_label_new(_("Center:")); |
label = gtk_label_new(_("Center:")); |
378 |
label = gtk_label_new(_("(recommended width/height < 2km/1.25mi)")); |
label = gtk_label_new(_("(recommended width/height < 2km/1.25mi)")); |
379 |
gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 3, 3, 4); |
gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 3, 3, 4); |
380 |
|
|
381 |
|
gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0); |
382 |
gtk_notebook_append_page(GTK_NOTEBOOK(context.notebook), |
gtk_notebook_append_page(GTK_NOTEBOOK(context.notebook), |
383 |
table, gtk_label_new(_("Extent"))); |
vbox, gtk_label_new(_("Extent"))); |
384 |
|
|
385 |
#ifdef USE_HILDON |
#ifdef USE_HILDON |
386 |
/* ------------- fetch from maemo mapper ------------------------ */ |
/* ------------- fetch from maemo mapper ------------------------ */ |
387 |
|
|
388 |
GtkWidget *vbox = gtk_vbox_new(FALSE, 8); |
vbox = gtk_vbox_new(FALSE, 8); |
389 |
context.mmapper.fetch = |
context.mmapper.fetch = |
390 |
gtk_button_new_with_label(_("Get from Maemo Mapper")); |
gtk_button_new_with_label(_("Get from Maemo Mapper")); |
391 |
gtk_box_pack_start_defaults(GTK_BOX(vbox), context.mmapper.fetch); |
gtk_box_pack_start(GTK_BOX(vbox), context.mmapper.fetch, FALSE, FALSE, 0); |
392 |
|
|
393 |
g_signal_connect(G_OBJECT(context.mmapper.fetch), "clicked", |
g_signal_connect(G_OBJECT(context.mmapper.fetch), "clicked", |
394 |
G_CALLBACK(callback_fetch_mm_clicked), &context); |
G_CALLBACK(callback_fetch_mm_clicked), &context); |
|
// gtk_widget_set_sensitive(context.mmapper.fetch, context.area->mmpos->valid); |
|
395 |
|
|
396 |
/* --- hint --- */ |
/* --- hint --- */ |
397 |
label = gtk_label_new(_("(recommended MM zoom level < 7)")); |
label = gtk_label_new(_("(recommended MM zoom level < 7)")); |
398 |
gtk_box_pack_start_defaults(GTK_BOX(vbox), label); |
gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); |
399 |
|
|
400 |
|
|
401 |
gtk_notebook_append_page(GTK_NOTEBOOK(context.notebook), |
gtk_notebook_append_page(GTK_NOTEBOOK(context.notebook), |
402 |
vbox, gtk_label_new(_("Maemo Mapper"))); |
vbox, gtk_label_new(_("Maemo Mapper"))); |
403 |
#endif |
#endif |
404 |
|
|
405 |
|
/* ------------- fetch from map ------------------------ */ |
406 |
|
|
407 |
|
GtkWidget *hbox = gtk_hbox_new(FALSE, 0); |
408 |
|
|
409 |
|
context.map.widget = g_object_new(OSM_TYPE_GPS_MAP, |
410 |
|
"repo-uri", MAP_SOURCE_OPENSTREETMAP, |
411 |
|
"proxy-uri", misc_get_proxy_uri(area->settings), |
412 |
|
NULL); |
413 |
|
|
414 |
|
gtk_box_pack_start_defaults(GTK_BOX(hbox), context.map.widget); |
415 |
|
|
416 |
|
/* zoom button box */ |
417 |
|
vbox = gtk_vbox_new(FALSE,0); |
418 |
|
|
419 |
|
context.map.zoomin = gtk_button_new(); |
420 |
|
gtk_button_set_image(GTK_BUTTON(context.map.zoomin), |
421 |
|
gtk_image_new_from_stock(GTK_STOCK_ZOOM_IN, GTK_ICON_SIZE_MENU)); |
422 |
|
g_signal_connect(context.map.zoomin, "clicked", |
423 |
|
G_CALLBACK(cb_map_zoomin), &context); |
424 |
|
gtk_box_pack_start(GTK_BOX(vbox), context.map.zoomin, FALSE, FALSE, 0); |
425 |
|
|
426 |
|
context.map.zoomout = gtk_button_new(); |
427 |
|
gtk_button_set_image(GTK_BUTTON(context.map.zoomout), |
428 |
|
gtk_image_new_from_stock(GTK_STOCK_ZOOM_OUT, GTK_ICON_SIZE_MENU)); |
429 |
|
g_signal_connect(context.map.zoomout, "clicked", |
430 |
|
G_CALLBACK(cb_map_zoomout), &context); |
431 |
|
gtk_box_pack_start(GTK_BOX(vbox), context.map.zoomout, FALSE, FALSE, 0); |
432 |
|
|
433 |
|
gtk_box_pack_start(GTK_BOX(hbox), vbox, FALSE, FALSE, 0); |
434 |
|
|
435 |
|
gtk_notebook_append_page(GTK_NOTEBOOK(context.notebook), |
436 |
|
hbox, gtk_label_new(_("Map"))); |
437 |
|
|
438 |
|
/* ------------------------------------------------------ */ |
439 |
|
|
440 |
gtk_box_pack_start_defaults(GTK_BOX(GTK_DIALOG(context.dialog)->vbox), |
gtk_box_pack_start_defaults(GTK_BOX(GTK_DIALOG(context.dialog)->vbox), |
441 |
context.notebook); |
context.notebook); |
442 |
|
|