43 |
gpointer userdata) { |
gpointer userdata) { |
44 |
tag_context_t *context = (tag_context_t*)userdata; |
tag_context_t *context = (tag_context_t*)userdata; |
45 |
GtkTreeIter iter; |
GtkTreeIter iter; |
46 |
|
|
47 |
if(gtk_tree_model_get_iter(model, &iter, path)) { |
if(gtk_tree_model_get_iter(model, &iter, path)) { |
48 |
g_assert(gtk_tree_path_get_depth(path) == 1); |
g_assert(gtk_tree_path_get_depth(path) == 1); |
49 |
|
|
50 |
tag_t *tag; |
tag_t *tag; |
51 |
gtk_tree_model_get(model, &iter, TAG_COL_DATA, &tag, -1); |
gtk_tree_model_get(model, &iter, TAG_COL_DATA, &tag, -1); |
52 |
|
|
|
if(context->but_remove && context->but_edit) { |
|
|
|
|
53 |
/* you just cannot delete or edit the "created_by" tag */ |
/* you just cannot delete or edit the "created_by" tag */ |
54 |
if(context->but_remove && context->but_edit) { |
if(strcasecmp(tag->key, "created_by") == 0) { |
55 |
if(strcasecmp(tag->key, "created_by") == 0) { |
list_button_enable(context->list, LIST_BUTTON_REMOVE, FALSE); |
56 |
gtk_widget_set_sensitive(context->but_remove, FALSE); |
list_button_enable(context->list, LIST_BUTTON_EDIT, FALSE); |
57 |
gtk_widget_set_sensitive(context->but_edit, FALSE); |
} else { |
58 |
} else { |
list_button_enable(context->list, LIST_BUTTON_REMOVE, TRUE); |
59 |
gtk_widget_set_sensitive(context->but_remove, TRUE); |
list_button_enable(context->list, LIST_BUTTON_EDIT, TRUE); |
|
gtk_widget_set_sensitive(context->but_edit, TRUE); |
|
|
} |
|
|
} |
|
60 |
} |
} |
61 |
} |
} |
62 |
|
|
85 |
} |
} |
86 |
|
|
87 |
static void on_tag_remove(GtkWidget *but, tag_context_t *context) { |
static void on_tag_remove(GtkWidget *but, tag_context_t *context) { |
|
GtkTreeSelection *selection; |
|
88 |
GtkTreeModel *model; |
GtkTreeModel *model; |
89 |
GtkTreeIter iter; |
GtkTreeIter iter; |
90 |
|
|
91 |
selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(context->view)); |
GtkTreeSelection *selection = list_get_selection(context->list); |
92 |
if(gtk_tree_selection_get_selected(selection, &model, &iter)) { |
if(gtk_tree_selection_get_selected(selection, &model, &iter)) { |
93 |
tag_t *tag; |
tag_t *tag; |
94 |
gtk_tree_model_get(model, &iter, TAG_COL_DATA, &tag, -1); |
gtk_tree_model_get(model, &iter, TAG_COL_DATA, &tag, -1); |
111 |
} |
} |
112 |
|
|
113 |
/* disable remove and edit buttons */ |
/* disable remove and edit buttons */ |
114 |
gtk_widget_set_sensitive(context->but_remove, FALSE); |
list_button_enable(context->list, LIST_BUTTON_REMOVE, FALSE); |
115 |
gtk_widget_set_sensitive(context->but_edit, FALSE); |
list_button_enable(context->list, LIST_BUTTON_EDIT, FALSE); |
116 |
} |
} |
117 |
|
|
118 |
static gboolean tag_edit(tag_context_t *context) { |
static gboolean tag_edit(tag_context_t *context) { |
121 |
GtkTreeIter iter; |
GtkTreeIter iter; |
122 |
tag_t *tag; |
tag_t *tag; |
123 |
|
|
124 |
GtkTreeSelection *sel = gtk_tree_view_get_selection( |
GtkTreeSelection *sel = list_get_selection(context->list); |
|
GTK_TREE_VIEW(context->view)); |
|
125 |
if(!sel) { |
if(!sel) { |
126 |
printf("got no selection object\n"); |
printf("got no selection object\n"); |
127 |
return FALSE; |
return FALSE; |
211 |
_("This will overwrite all tags of this %s with the " |
_("This will overwrite all tags of this %s with the " |
212 |
"ones from the %s selected last.\n\n" |
"ones from the %s selected last.\n\n" |
213 |
"Do you really want this?"), |
"Do you really want this?"), |
214 |
type_name[context->type], type_name[context->type])) { |
type_name[context->object.type], type_name[context->object.type])) { |
215 |
|
|
216 |
osm_tags_free(*context->tag); |
osm_tags_free(*context->tag); |
217 |
|
|
218 |
if(context->type == NODE) |
if(context->object.type == NODE) |
219 |
*context->tag = osm_tags_copy(context->appdata->map->last_node_tags, TRUE); |
*context->tag = osm_tags_copy(context->appdata->map->last_node_tags, TRUE); |
220 |
else |
else |
221 |
*context->tag = osm_tags_copy(context->appdata->map->last_way_tags, TRUE); |
*context->tag = osm_tags_copy(context->appdata->map->last_way_tags, TRUE); |
251 |
TAG_COL_DATA, *tag, |
TAG_COL_DATA, *tag, |
252 |
-1); |
-1); |
253 |
|
|
254 |
gtk_tree_selection_select_iter(gtk_tree_view_get_selection( |
gtk_tree_selection_select_iter( |
255 |
GTK_TREE_VIEW(context->view)), &iter); |
list_get_selection(context->list), &iter); |
256 |
|
|
257 |
if(!tag_edit(context)) { |
if(!tag_edit(context)) { |
258 |
printf("cancelled\n"); |
printf("cancelled\n"); |
278 |
} |
} |
279 |
|
|
280 |
static GtkWidget *tag_widget(tag_context_t *context) { |
static GtkWidget *tag_widget(tag_context_t *context) { |
281 |
GtkWidget *vbox = gtk_vbox_new(FALSE,3); |
context->list = list_new(LIST_HILDON_WITH_HEADERS_ON_MAEMO5); |
282 |
context->view = gtk_tree_view_new(); |
|
283 |
|
list_set_static_buttons(context->list, G_CALLBACK(on_tag_add), |
284 |
|
G_CALLBACK(on_tag_edit), G_CALLBACK(on_tag_remove), context); |
285 |
|
|
286 |
|
list_set_selection_function(context->list, view_selection_func, context); |
287 |
|
|
288 |
|
list_set_user_buttons(context->list, |
289 |
|
LIST_BUTTON_USER0, _("Last..."), on_tag_last, |
290 |
|
0); |
291 |
|
|
292 |
|
/* setup both columns */ |
293 |
|
list_set_columns(context->list, |
294 |
|
_("Key"), TAG_COL_KEY, |
295 |
|
LIST_FLAG_ELLIPSIZE|LIST_FLAG_CAN_HIGHLIGHT, TAG_COL_COLLISION, |
296 |
|
_("Value"), TAG_COL_VALUE, |
297 |
|
LIST_FLAG_ELLIPSIZE, |
298 |
|
NULL); |
299 |
|
|
300 |
|
GtkWidget *presets = josm_presets_select(context->appdata, context); |
301 |
|
if(presets) |
302 |
|
list_set_custom_user_button(context->list, LIST_BUTTON_USER1, presets); |
303 |
|
|
304 |
gtk_tree_selection_set_select_function( |
/* disable if no appropriate "last" tags have been stored or if the */ |
305 |
gtk_tree_view_get_selection(GTK_TREE_VIEW(context->view)), |
/* selected item isn't a node or way */ |
306 |
view_selection_func, |
if(((context->object.type == NODE) && |
307 |
context, NULL); |
(!context->appdata->map->last_node_tags)) || |
308 |
|
((context->object.type == WAY) && |
309 |
/* --- "Key" column --- */ |
(!context->appdata->map->last_way_tags)) || |
310 |
GtkCellRenderer *renderer = gtk_cell_renderer_text_new(); |
((context->object.type != NODE) && (context->object.type != WAY))) |
311 |
g_object_set(renderer, |
list_button_enable(context->list, LIST_BUTTON_USER0, FALSE); |
|
"ellipsize", PANGO_ELLIPSIZE_END, |
|
|
"background", "red", |
|
|
NULL ); |
|
|
GtkTreeViewColumn *column = gtk_tree_view_column_new_with_attributes( |
|
|
_("Key"), renderer, |
|
|
"text", TAG_COL_KEY, |
|
|
"background-set", TAG_COL_COLLISION, |
|
|
NULL); |
|
|
gtk_tree_view_column_set_expand(column, TRUE); |
|
|
gtk_tree_view_insert_column(GTK_TREE_VIEW(context->view), column, -1); |
|
|
|
|
|
/* --- "Value" column --- */ |
|
|
renderer = gtk_cell_renderer_text_new(); |
|
|
g_object_set(renderer, |
|
|
"ellipsize", PANGO_ELLIPSIZE_END, |
|
|
NULL ); |
|
|
column = gtk_tree_view_column_new_with_attributes( |
|
|
_("Value"), renderer, |
|
|
"text", TAG_COL_VALUE, |
|
|
NULL); |
|
|
gtk_tree_view_column_set_expand(column, TRUE); |
|
|
gtk_tree_view_insert_column(GTK_TREE_VIEW(context->view), column, -1); |
|
312 |
|
|
313 |
/* build and fill the store */ |
/* --------- build and fill the store ------------ */ |
314 |
context->store = gtk_list_store_new(TAG_NUM_COLS, |
context->store = gtk_list_store_new(TAG_NUM_COLS, |
315 |
G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_POINTER); |
G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_POINTER); |
316 |
|
|
317 |
gtk_tree_view_set_model(GTK_TREE_VIEW(context->view), |
list_set_store(context->list, context->store); |
|
GTK_TREE_MODEL(context->store)); |
|
318 |
|
|
319 |
GtkTreeIter iter; |
GtkTreeIter iter; |
320 |
tag_t *tag = *context->tag; |
tag_t *tag = *context->tag; |
332 |
|
|
333 |
g_object_unref(context->store); |
g_object_unref(context->store); |
334 |
|
|
335 |
/* put it into a scrolled window */ |
return context->list; |
336 |
GtkWidget *scrolled_window = gtk_scrolled_window_new(NULL, NULL); |
} |
|
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window), |
|
|
GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); |
|
|
gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled_window), |
|
|
GTK_SHADOW_ETCHED_IN); |
|
|
// gtk_container_set_border_width(GTK_CONTAINER(scrolled_window), 3); |
|
|
gtk_container_add(GTK_CONTAINER(scrolled_window), context->view); |
|
|
gtk_box_pack_start_defaults(GTK_BOX(vbox), scrolled_window); |
|
|
|
|
|
/* ------- button box ------------ */ |
|
|
|
|
|
GtkWidget *hbox = gtk_hbox_new(TRUE,3); |
|
|
|
|
|
GtkWidget *but_last = gtk_button_new_with_label(_("Last...")); |
|
|
gtk_box_pack_start_defaults(GTK_BOX(hbox), but_last); |
|
|
|
|
|
/* disable if no appropriate "last" tags have been stored or if the */ |
|
|
/* selected item isn't a node or way */ |
|
|
if(((context->type == NODE) && |
|
|
(!context->appdata->map->last_node_tags)) || |
|
|
((context->type == WAY) && |
|
|
(!context->appdata->map->last_way_tags)) || |
|
|
((context->type != NODE) && (context->type != WAY))) |
|
|
gtk_widget_set_sensitive(but_last, FALSE); |
|
|
|
|
|
gtk_signal_connect(GTK_OBJECT(but_last), "clicked", |
|
|
GTK_SIGNAL_FUNC(on_tag_last), context); |
|
|
|
|
|
GtkWidget *presets = josm_presets_select(context->appdata, context); |
|
|
if(presets) gtk_box_pack_start_defaults(GTK_BOX(hbox), presets); |
|
|
|
|
|
context->but_add = gtk_button_new_with_label(_("Add...")); |
|
|
gtk_box_pack_start_defaults(GTK_BOX(hbox), context->but_add); |
|
|
gtk_signal_connect(GTK_OBJECT(context->but_add), "clicked", |
|
|
GTK_SIGNAL_FUNC(on_tag_add), context); |
|
|
|
|
|
context->but_edit = gtk_button_new_with_label(_("Edit...")); |
|
|
gtk_widget_set_sensitive(context->but_edit, FALSE); |
|
|
gtk_box_pack_start_defaults(GTK_BOX(hbox), context->but_edit); |
|
|
gtk_signal_connect(GTK_OBJECT(context->but_edit), "clicked", |
|
|
GTK_SIGNAL_FUNC(on_tag_edit), context); |
|
|
|
|
|
context->but_remove = gtk_button_new_with_label(_("Remove")); |
|
|
gtk_widget_set_sensitive(context->but_remove, FALSE); |
|
|
gtk_box_pack_start_defaults(GTK_BOX(hbox), context->but_remove); |
|
|
gtk_signal_connect(GTK_OBJECT(context->but_remove), "clicked", |
|
|
GTK_SIGNAL_FUNC(on_tag_remove), context); |
|
|
|
|
337 |
|
|
338 |
gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); |
static void on_relation_members(GtkWidget *but, tag_context_t *context) { |
339 |
return vbox; |
g_assert(context->object.type == RELATION); |
340 |
|
relation_show_members(context->dialog, context->object.relation); |
341 |
} |
} |
342 |
|
|
343 |
/* edit tags of currently selected node or way or of the relation */ |
/* edit tags of currently selected node or way or of the relation */ |
344 |
/* given */ |
/* given */ |
345 |
void info_dialog(GtkWidget *parent, appdata_t *appdata, relation_t *relation) { |
gboolean info_dialog(GtkWidget *parent, appdata_t *appdata, object_t *object) { |
|
if(!relation) |
|
|
g_assert(appdata->map->selected.type != MAP_TYPE_ILLEGAL); |
|
346 |
|
|
347 |
tag_context_t *context = g_new0(tag_context_t, 1); |
tag_context_t *context = g_new0(tag_context_t, 1); |
348 |
user_t *user = NULL; |
user_t *user = NULL; |
353 |
context->appdata = appdata; |
context->appdata = appdata; |
354 |
context->tag = &work_copy; |
context->tag = &work_copy; |
355 |
|
|
356 |
if(!relation) { |
/* use implicit selection if not explicitely given */ |
357 |
switch(appdata->map->selected.type) { |
if(!object) { |
358 |
case MAP_TYPE_NODE: |
g_assert((appdata->map->selected.object.type == NODE) || |
359 |
str = g_strdup_printf(_("Node #%ld"), appdata->map->selected.node->id); |
(appdata->map->selected.object.type == WAY) || |
360 |
user = appdata->map->selected.node->user; |
(appdata->map->selected.object.type == RELATION)); |
361 |
work_copy = osm_tags_copy(appdata->map->selected.node->tag, FALSE); |
|
362 |
stime = appdata->map->selected.node->time; |
context->object = appdata->map->selected.object; |
363 |
context->type = NODE; |
} else |
364 |
context->presets_type = PRESETS_TYPE_NODE; |
context->object = *object; |
365 |
break; |
|
366 |
case MAP_TYPE_WAY: |
switch(context->object.type) { |
367 |
str = g_strdup_printf(_("Way #%ld"), appdata->map->selected.way->id); |
case NODE: |
368 |
user = appdata->map->selected.way->user; |
str = g_strdup_printf(_("Node #" ITEM_ID_FORMAT), context->object.node->id); |
369 |
work_copy = osm_tags_copy(appdata->map->selected.way->tag, FALSE); |
user = context->object.node->user; |
370 |
stime = appdata->map->selected.way->time; |
work_copy = osm_tags_copy(context->object.node->tag, FALSE); |
371 |
context->type = WAY; |
stime = context->object.node->time; |
372 |
context->presets_type = PRESETS_TYPE_WAY; |
context->presets_type = PRESETS_TYPE_NODE; |
373 |
|
break; |
374 |
if(osm_way_get_last_node(appdata->map->selected.way) == |
|
375 |
osm_way_get_first_node(appdata->map->selected.way)) |
case WAY: |
376 |
context->presets_type |= PRESETS_TYPE_CLOSEDWAY; |
str = g_strdup_printf(_("Way #" ITEM_ID_FORMAT), context->object.way->id); |
377 |
|
user = context->object.way->user; |
378 |
break; |
work_copy = osm_tags_copy(context->object.way->tag, FALSE); |
379 |
default: |
stime = context->object.way->time; |
380 |
g_assert((appdata->map->selected.type == MAP_TYPE_NODE) || |
context->presets_type = PRESETS_TYPE_WAY; |
381 |
(appdata->map->selected.type == MAP_TYPE_WAY)); |
|
382 |
break; |
if(osm_way_get_last_node(context->object.way) == |
383 |
} |
osm_way_get_first_node(context->object.way)) |
384 |
} else { |
context->presets_type |= PRESETS_TYPE_CLOSEDWAY; |
385 |
str = g_strdup_printf(_("Relation #%ld"), relation->id); |
|
386 |
user = relation->user; |
break; |
387 |
work_copy = osm_tags_copy(relation->tag, FALSE); |
|
388 |
stime = relation->time; |
case RELATION: |
389 |
context->type = RELATION; |
str = g_strdup_printf(_("Relation #" ITEM_ID_FORMAT), |
390 |
|
context->object.relation->id); |
391 |
|
user = context->object.relation->user; |
392 |
|
work_copy = osm_tags_copy(context->object.relation->tag, FALSE); |
393 |
|
stime = context->object.relation->time; |
394 |
context->presets_type = PRESETS_TYPE_RELATION; |
context->presets_type = PRESETS_TYPE_RELATION; |
395 |
|
break; |
396 |
|
|
397 |
|
default: |
398 |
|
g_assert((context->object.type == NODE) || |
399 |
|
(context->object.type == WAY) || |
400 |
|
(context->object.type == RELATION)); |
401 |
|
break; |
402 |
} |
} |
403 |
|
|
404 |
context->dialog = gtk_dialog_new_with_buttons(str, |
context->dialog = gtk_dialog_new_with_buttons(str, |
413 |
|
|
414 |
/* making the dialog a little wider makes it less "crowded" */ |
/* making the dialog a little wider makes it less "crowded" */ |
415 |
#ifdef USE_HILDON |
#ifdef USE_HILDON |
416 |
gtk_window_set_default_size(GTK_WINDOW(context->dialog), 500, 300); |
gtk_window_set_default_size(GTK_WINDOW(context->dialog), 500, 400); |
417 |
#else |
#else |
418 |
gtk_window_set_default_size(GTK_WINDOW(context->dialog), 400, 200); |
// Conversely, desktop builds should display a little narrower |
419 |
|
gtk_window_set_default_size(GTK_WINDOW(context->dialog), 400, 300); |
420 |
#endif |
#endif |
421 |
|
|
422 |
GtkWidget *label; |
GtkWidget *label; |
441 |
gtk_table_attach_defaults(GTK_TABLE(table), label, 1, 2, 0, 1); |
gtk_table_attach_defaults(GTK_TABLE(table), label, 1, 2, 0, 1); |
442 |
|
|
443 |
/* ------------ coordinate (only for nodes) ----------------- */ |
/* ------------ coordinate (only for nodes) ----------------- */ |
444 |
if(!relation) { |
switch(context->object.type) { |
445 |
if(appdata->map->selected.type == MAP_TYPE_NODE) { |
case NODE: { |
446 |
char pos_str[32]; |
char pos_str[32]; |
447 |
pos_lat_str(pos_str, sizeof(pos_str),appdata->map->selected.node->pos.lat); |
pos_lat_str(pos_str, sizeof(pos_str), context->object.node->pos.lat); |
448 |
label = gtk_label_new(pos_str); |
label = gtk_label_new(pos_str); |
449 |
gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 1, 2); |
gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 1, 2); |
450 |
pos_lat_str(pos_str, sizeof(pos_str),appdata->map->selected.node->pos.lon); |
pos_lat_str(pos_str, sizeof(pos_str), context->object.node->pos.lon); |
451 |
label = gtk_label_new(pos_str); |
label = gtk_label_new(pos_str); |
452 |
gtk_table_attach_defaults(GTK_TABLE(table), label, 1, 2, 1, 2); |
gtk_table_attach_defaults(GTK_TABLE(table), label, 1, 2, 1, 2); |
453 |
} else { |
} break; |
454 |
char *nodes_str = g_strdup_printf(_("Length: %u nodes"), |
|
455 |
osm_way_number_of_nodes(appdata->map->selected.way)); |
case WAY: { |
456 |
label = gtk_label_new(nodes_str); |
char *nodes_str = g_strdup_printf(_("Length: %u nodes"), |
457 |
gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 1, 2); |
osm_way_number_of_nodes(context->object.way)); |
458 |
g_free(nodes_str); |
label = gtk_label_new(nodes_str); |
459 |
|
gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 1, 2); |
460 |
char *type_str = g_strdup_printf("%s (%s)", |
g_free(nodes_str); |
461 |
(osm_way_get_last_node(appdata->map->selected.way) == |
|
462 |
osm_way_get_first_node(appdata->map->selected.way))? |
char *type_str = g_strdup_printf("%s (%s)", |
463 |
"closed way":"open way", |
(osm_way_get_last_node(context->object.way) == |
464 |
(appdata->map->selected.way->draw.flags & OSM_DRAW_FLAG_AREA)? |
osm_way_get_first_node(context->object.way))? |
465 |
"area":"line"); |
"closed way":"open way", |
466 |
|
(context->object.way->draw.flags & OSM_DRAW_FLAG_AREA)? |
467 |
|
"area":"line"); |
468 |
|
|
469 |
label = gtk_label_new(type_str); |
label = gtk_label_new(type_str); |
470 |
gtk_table_attach_defaults(GTK_TABLE(table), label, 1, 2, 1, 2); |
gtk_table_attach_defaults(GTK_TABLE(table), label, 1, 2, 1, 2); |
471 |
g_free(type_str); |
g_free(type_str); |
472 |
} |
} break; |
473 |
} else { |
|
474 |
|
case RELATION: { |
475 |
/* relations tell something about their members */ |
/* relations tell something about their members */ |
476 |
gint nodes = 0, ways = 0, relations = 0; |
gint nodes = 0, ways = 0, relations = 0; |
477 |
member_t *member = relation->member; |
member_t *member = context->object.relation->member; |
478 |
while(member) { |
while(member) { |
479 |
switch(member->type) { |
switch(member->object.type) { |
480 |
case NODE: |
case NODE: |
481 |
case NODE_ID: |
case NODE_ID: |
482 |
nodes++; |
nodes++; |
489 |
case RELATION_ID: |
case RELATION_ID: |
490 |
relations++; |
relations++; |
491 |
break; |
break; |
492 |
|
|
493 |
default: |
default: |
494 |
break; |
break; |
495 |
} |
} |
497 |
member = member->next; |
member = member->next; |
498 |
} |
} |
499 |
|
|
500 |
char *str = g_strdup_printf(_("Members: %d nodes, %d ways, %d relations"), |
char *str = |
501 |
nodes, ways, relations); |
g_strdup_printf(_("Members: %d nodes, %d ways, %d relations"), |
502 |
|
nodes, ways, relations); |
503 |
|
|
504 |
|
GtkWidget *member_btn = gtk_button_new_with_label(str); |
505 |
|
gtk_signal_connect(GTK_OBJECT(member_btn), "clicked", |
506 |
|
GTK_SIGNAL_FUNC(on_relation_members), context); |
507 |
|
gtk_table_attach_defaults(GTK_TABLE(table), member_btn, 0, 2, 1, 2); |
508 |
|
|
|
gtk_table_attach_defaults(GTK_TABLE(table), gtk_label_new(str), 0, 2, 1, 2); |
|
509 |
g_free(str); |
g_free(str); |
510 |
} |
break; |
511 |
|
|
512 |
|
default: |
513 |
|
printf("ERROR: No node, way or relation\n"); |
514 |
|
g_assert(0); |
515 |
|
break; |
516 |
|
} } |
517 |
|
|
518 |
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(context->dialog)->vbox), table, |
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(context->dialog)->vbox), table, |
519 |
FALSE, FALSE, 0); |
FALSE, FALSE, 0); |
527 |
/* ----------------------------------- */ |
/* ----------------------------------- */ |
528 |
|
|
529 |
gtk_widget_show_all(context->dialog); |
gtk_widget_show_all(context->dialog); |
530 |
|
gboolean ok = FALSE; |
531 |
|
|
532 |
if(gtk_dialog_run(GTK_DIALOG(context->dialog)) == GTK_RESPONSE_ACCEPT) { |
if(gtk_dialog_run(GTK_DIALOG(context->dialog)) == GTK_RESPONSE_ACCEPT) { |
533 |
|
ok = TRUE; |
534 |
|
|
535 |
gtk_widget_destroy(context->dialog); |
gtk_widget_destroy(context->dialog); |
536 |
|
|
537 |
if(!relation) { |
/* replace original tags with work copy */ |
538 |
/* replace original tags with work copy */ |
switch(context->object.type) { |
539 |
switch(appdata->map->selected.type) { |
|
540 |
|
case NODE: |
541 |
case MAP_TYPE_NODE: |
osm_tags_free(context->object.node->tag); |
542 |
osm_tags_free(appdata->map->selected.node->tag); |
context->object.node->tag = osm_tags_copy(work_copy, TRUE); |
543 |
appdata->map->selected.node->tag = osm_tags_copy(work_copy, TRUE); |
break; |
|
break; |
|
544 |
|
|
545 |
case MAP_TYPE_WAY: |
case WAY: |
546 |
osm_tags_free(appdata->map->selected.way->tag); |
osm_tags_free(context->object.way->tag); |
547 |
appdata->map->selected.way->tag = osm_tags_copy(work_copy, TRUE); |
context->object.way->tag = osm_tags_copy(work_copy, TRUE); |
548 |
break; |
break; |
549 |
|
|
550 |
default: |
case RELATION: |
551 |
break; |
osm_tags_free(context->object.relation->tag); |
552 |
} |
context->object.relation->tag = osm_tags_copy(work_copy, TRUE); |
553 |
|
break; |
554 |
/* since nodes being parts of ways but with no tags are invisible, */ |
|
555 |
/* the result of editing them may have changed their visibility */ |
default: |
556 |
map_item_redraw(appdata, &appdata->map->selected); |
break; |
|
map_item_set_flags(&context->appdata->map->selected, OSM_FLAG_DIRTY, 0); |
|
|
} else { |
|
|
osm_tags_free(relation->tag); |
|
|
relation->tag = osm_tags_copy(work_copy, TRUE); |
|
|
relation->flags |= OSM_FLAG_DIRTY; |
|
557 |
} |
} |
558 |
|
|
559 |
|
/* since nodes being parts of ways but with no tags are invisible, */ |
560 |
|
/* the result of editing them may have changed their visibility */ |
561 |
|
if(!object && context->object.type != RELATION) |
562 |
|
map_item_redraw(appdata, &appdata->map->selected); |
563 |
|
|
564 |
|
osm_object_set_flags(&context->object, OSM_FLAG_DIRTY, 0); |
565 |
} else { |
} else { |
566 |
gtk_widget_destroy(context->dialog); |
gtk_widget_destroy(context->dialog); |
567 |
osm_tags_free(work_copy); |
osm_tags_free(work_copy); |
568 |
} |
} |
569 |
|
|
570 |
g_free(context); |
g_free(context); |
571 |
|
return ok; |
572 |
} |
} |