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; |
141 |
GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, |
GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, |
142 |
NULL); |
NULL); |
143 |
|
|
144 |
|
#ifdef USE_HILDON |
145 |
|
gtk_window_set_default_size(GTK_WINDOW(dialog), 500, 100); |
146 |
|
#else |
147 |
|
gtk_window_set_default_size(GTK_WINDOW(dialog), 400, 100); |
148 |
|
#endif |
149 |
|
|
150 |
gtk_dialog_set_default_response(GTK_DIALOG(dialog), |
gtk_dialog_set_default_response(GTK_DIALOG(dialog), |
151 |
GTK_RESPONSE_ACCEPT); |
GTK_RESPONSE_ACCEPT); |
152 |
|
|
153 |
GtkWidget *label, *key, *value; |
GtkWidget *label, *key, *value; |
154 |
GtkWidget *table = gtk_table_new(2, 2, FALSE); |
GtkWidget *table = gtk_table_new(2, 2, FALSE); |
155 |
|
|
156 |
gtk_table_attach_defaults(GTK_TABLE(table), |
gtk_table_attach(GTK_TABLE(table), label = gtk_label_new(_("Key:")), |
157 |
label = gtk_label_new(_("Key:")), 0, 1, 0, 1); |
0, 1, 0, 1, 0, 0, 0, 0); |
158 |
gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f); |
gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f); |
159 |
gtk_table_attach_defaults(GTK_TABLE(table), |
gtk_table_attach_defaults(GTK_TABLE(table), |
160 |
key = gtk_entry_new(), 1, 2, 0, 1); |
key = gtk_entry_new(), 1, 2, 0, 1); |
161 |
gtk_entry_set_activates_default(GTK_ENTRY(key), TRUE); |
gtk_entry_set_activates_default(GTK_ENTRY(key), TRUE); |
162 |
HILDON_ENTRY_NO_AUTOCAP(key); |
HILDON_ENTRY_NO_AUTOCAP(key); |
163 |
|
|
164 |
gtk_table_attach_defaults(GTK_TABLE(table), |
gtk_table_attach(GTK_TABLE(table), label = gtk_label_new(_("Value:")), |
165 |
label = gtk_label_new(_("Value:")), 0, 1, 1, 2); |
0, 1, 1, 2, 0, 0, 0, 0); |
166 |
gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f); |
gtk_misc_set_alignment(GTK_MISC(label), 1.f, 0.5f); |
167 |
gtk_table_attach_defaults(GTK_TABLE(table), |
gtk_table_attach_defaults(GTK_TABLE(table), |
168 |
value = gtk_entry_new(), 1, 2, 1, 2); |
value = gtk_entry_new(), 1, 2, 1, 2); |
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); |
|
context->view = gtk_tree_view_new(); |
|
282 |
|
|
283 |
gtk_tree_selection_set_select_function( |
list_set_static_buttons(context->list, G_CALLBACK(on_tag_add), |
284 |
gtk_tree_view_get_selection(GTK_TREE_VIEW(context->view)), |
G_CALLBACK(on_tag_edit), G_CALLBACK(on_tag_remove), context); |
285 |
view_selection_func, |
|
286 |
context, NULL); |
list_set_selection_function(context->list, view_selection_func, context); |
287 |
|
|
288 |
/* --- "Key" column --- */ |
list_set_user_buttons(context->list, |
289 |
GtkCellRenderer *renderer = gtk_cell_renderer_text_new(); |
LIST_BUTTON_USER0, _("Last..."), on_tag_last, |
290 |
g_object_set(renderer, |
0); |
291 |
"ellipsize", PANGO_ELLIPSIZE_END, |
|
292 |
"background", "red", |
/* setup both columns */ |
293 |
NULL ); |
list_set_columns(context->list, |
294 |
GtkTreeViewColumn *column = gtk_tree_view_column_new_with_attributes( |
_("Key"), TAG_COL_KEY, |
295 |
_("Key"), renderer, |
LIST_FLAG_ELLIPSIZE|LIST_FLAG_CAN_HIGHLIGHT, TAG_COL_COLLISION, |
296 |
"text", TAG_COL_KEY, |
_("Value"), TAG_COL_VALUE, |
297 |
"background-set", TAG_COL_COLLISION, |
LIST_FLAG_ELLIPSIZE, |
298 |
NULL); |
NULL); |
299 |
gtk_tree_view_column_set_expand(column, TRUE); |
|
300 |
gtk_tree_view_insert_column(GTK_TREE_VIEW(context->view), column, -1); |
GtkWidget *presets = josm_presets_select(context->appdata, context); |
301 |
|
if(presets) |
302 |
/* --- "Value" column --- */ |
list_set_custom_user_button(context->list, LIST_BUTTON_USER1, presets); |
303 |
renderer = gtk_cell_renderer_text_new(); |
|
304 |
g_object_set(renderer, |
/* disable if no appropriate "last" tags have been stored or if the */ |
305 |
"ellipsize", PANGO_ELLIPSIZE_END, |
/* selected item isn't a node or way */ |
306 |
NULL ); |
if(((context->object.type == NODE) && |
307 |
column = gtk_tree_view_column_new_with_attributes( |
(!context->appdata->map->last_node_tags)) || |
308 |
_("Value"), renderer, |
((context->object.type == WAY) && |
309 |
"text", TAG_COL_VALUE, |
(!context->appdata->map->last_way_tags)) || |
310 |
NULL); |
((context->object.type != NODE) && (context->object.type != WAY))) |
311 |
gtk_tree_view_column_set_expand(column, TRUE); |
list_button_enable(context->list, LIST_BUTTON_USER0, FALSE); |
|
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; |
|
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); |
|
|
|
|
|
|
|
|
gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); |
|
|
return vbox; |
|
336 |
} |
} |
337 |
|
|
338 |
/* edit tags of currently selected node or way or of the relation */ |
/* edit tags of currently selected node or way or of the relation */ |
339 |
/* given */ |
/* given */ |
340 |
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); |
|
341 |
|
|
342 |
tag_context_t *context = g_new0(tag_context_t, 1); |
tag_context_t *context = g_new0(tag_context_t, 1); |
343 |
user_t *user = NULL; |
user_t *user = NULL; |
348 |
context->appdata = appdata; |
context->appdata = appdata; |
349 |
context->tag = &work_copy; |
context->tag = &work_copy; |
350 |
|
|
351 |
if(!relation) { |
/* use implicit selection if not explicitely given */ |
352 |
switch(appdata->map->selected.type) { |
if(!object) { |
353 |
case MAP_TYPE_NODE: |
g_assert((appdata->map->selected.object.type == NODE) || |
354 |
str = g_strdup_printf(_("Node #%ld"), appdata->map->selected.node->id); |
(appdata->map->selected.object.type == WAY) || |
355 |
user = appdata->map->selected.node->user; |
(appdata->map->selected.object.type == RELATION)); |
356 |
work_copy = osm_tags_copy(appdata->map->selected.node->tag, FALSE); |
|
357 |
stime = appdata->map->selected.node->time; |
context->object = appdata->map->selected.object; |
358 |
context->type = NODE; |
} else |
359 |
break; |
context->object = *object; |
360 |
case MAP_TYPE_WAY: |
|
361 |
str = g_strdup_printf(_("Way #%ld"), appdata->map->selected.way->id); |
switch(context->object.type) { |
362 |
user = appdata->map->selected.way->user; |
case NODE: |
363 |
work_copy = osm_tags_copy(appdata->map->selected.way->tag, FALSE); |
str = g_strdup_printf(_("Node #%ld"), context->object.node->id); |
364 |
stime = appdata->map->selected.way->time; |
user = context->object.node->user; |
365 |
context->type = WAY; |
work_copy = osm_tags_copy(context->object.node->tag, FALSE); |
366 |
break; |
stime = context->object.node->time; |
367 |
default: |
context->presets_type = PRESETS_TYPE_NODE; |
368 |
g_assert((appdata->map->selected.type == MAP_TYPE_NODE) || |
break; |
369 |
(appdata->map->selected.type == MAP_TYPE_WAY)); |
|
370 |
break; |
case WAY: |
371 |
} |
str = g_strdup_printf(_("Way #%ld"), context->object.way->id); |
372 |
} else { |
user = context->object.way->user; |
373 |
str = g_strdup_printf(_("Relation #%ld"), relation->id); |
work_copy = osm_tags_copy(context->object.way->tag, FALSE); |
374 |
user = relation->user; |
stime = context->object.way->time; |
375 |
work_copy = osm_tags_copy(relation->tag, FALSE); |
context->presets_type = PRESETS_TYPE_WAY; |
376 |
stime = relation->time; |
|
377 |
context->type = RELATION; |
if(osm_way_get_last_node(context->object.way) == |
378 |
|
osm_way_get_first_node(context->object.way)) |
379 |
|
context->presets_type |= PRESETS_TYPE_CLOSEDWAY; |
380 |
|
|
381 |
|
break; |
382 |
|
|
383 |
|
case RELATION: |
384 |
|
str = g_strdup_printf(_("Relation #%ld"), context->object.relation->id); |
385 |
|
user = context->object.relation->user; |
386 |
|
work_copy = osm_tags_copy(context->object.relation->tag, FALSE); |
387 |
|
stime = context->object.relation->time; |
388 |
|
context->presets_type = PRESETS_TYPE_RELATION; |
389 |
|
break; |
390 |
|
|
391 |
|
default: |
392 |
|
g_assert((context->object.type == NODE) || |
393 |
|
(context->object.type == WAY) || |
394 |
|
(context->object.type == RELATION)); |
395 |
|
break; |
396 |
} |
} |
397 |
|
|
398 |
context->dialog = gtk_dialog_new_with_buttons(str, |
context->dialog = gtk_dialog_new_with_buttons(str, |
407 |
|
|
408 |
/* making the dialog a little wider makes it less "crowded" */ |
/* making the dialog a little wider makes it less "crowded" */ |
409 |
#ifdef USE_HILDON |
#ifdef USE_HILDON |
410 |
gtk_window_set_default_size(GTK_WINDOW(context->dialog), 500, 300); |
gtk_window_set_default_size(GTK_WINDOW(context->dialog), 500, 400); |
411 |
#else |
#else |
412 |
gtk_window_set_default_size(GTK_WINDOW(context->dialog), 400, 200); |
// Conversely, desktop builds should display a little narrower |
413 |
|
gtk_window_set_default_size(GTK_WINDOW(context->dialog), 400, 300); |
414 |
#endif |
#endif |
415 |
|
|
416 |
GtkWidget *label; |
GtkWidget *label; |
435 |
gtk_table_attach_defaults(GTK_TABLE(table), label, 1, 2, 0, 1); |
gtk_table_attach_defaults(GTK_TABLE(table), label, 1, 2, 0, 1); |
436 |
|
|
437 |
/* ------------ coordinate (only for nodes) ----------------- */ |
/* ------------ coordinate (only for nodes) ----------------- */ |
438 |
if(!relation) { |
switch(context->object.type) { |
439 |
if(appdata->map->selected.type == MAP_TYPE_NODE) { |
case NODE: { |
440 |
char pos_str[32]; |
char pos_str[32]; |
441 |
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); |
442 |
label = gtk_label_new(pos_str); |
label = gtk_label_new(pos_str); |
443 |
gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 1, 2); |
gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 1, 2); |
444 |
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); |
445 |
label = gtk_label_new(pos_str); |
label = gtk_label_new(pos_str); |
446 |
gtk_table_attach_defaults(GTK_TABLE(table), label, 1, 2, 1, 2); |
gtk_table_attach_defaults(GTK_TABLE(table), label, 1, 2, 1, 2); |
447 |
} else { |
} break; |
448 |
char *nodes_str = g_strdup_printf(_("Length: %u nodes"), |
|
449 |
osm_way_number_of_nodes(appdata->map->selected.way)); |
case WAY: { |
450 |
label = gtk_label_new(nodes_str); |
char *nodes_str = g_strdup_printf(_("Length: %u nodes"), |
451 |
gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 1, 2); |
osm_way_number_of_nodes(context->object.way)); |
452 |
g_free(nodes_str); |
label = gtk_label_new(nodes_str); |
453 |
|
gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 1, 2); |
454 |
char *type_str = g_strdup_printf("%s (%s)", |
g_free(nodes_str); |
455 |
(osm_way_get_last_node(appdata->map->selected.way) == |
|
456 |
osm_way_get_first_node(appdata->map->selected.way))? |
char *type_str = g_strdup_printf("%s (%s)", |
457 |
"closed way":"open way", |
(osm_way_get_last_node(context->object.way) == |
458 |
(appdata->map->selected.way->draw.flags & OSM_DRAW_FLAG_AREA)? |
osm_way_get_first_node(context->object.way))? |
459 |
"area":"line"); |
"closed way":"open way", |
460 |
|
(context->object.way->draw.flags & OSM_DRAW_FLAG_AREA)? |
461 |
|
"area":"line"); |
462 |
|
|
463 |
label = gtk_label_new(type_str); |
label = gtk_label_new(type_str); |
464 |
gtk_table_attach_defaults(GTK_TABLE(table), label, 1, 2, 1, 2); |
gtk_table_attach_defaults(GTK_TABLE(table), label, 1, 2, 1, 2); |
465 |
g_free(type_str); |
g_free(type_str); |
466 |
} |
} break; |
467 |
} else { |
|
468 |
|
case RELATION: { |
469 |
/* relations tell something about their members */ |
/* relations tell something about their members */ |
470 |
gint nodes = 0, ways = 0, relations = 0; |
gint nodes = 0, ways = 0, relations = 0; |
471 |
member_t *member = relation->member; |
member_t *member = context->object.relation->member; |
472 |
while(member) { |
while(member) { |
473 |
switch(member->type) { |
switch(member->type) { |
474 |
case NODE: |
case NODE: |
483 |
case RELATION_ID: |
case RELATION_ID: |
484 |
relations++; |
relations++; |
485 |
break; |
break; |
486 |
|
|
487 |
default: |
default: |
488 |
break; |
break; |
489 |
} |
} |
496 |
|
|
497 |
gtk_table_attach_defaults(GTK_TABLE(table), gtk_label_new(str), 0, 2, 1, 2); |
gtk_table_attach_defaults(GTK_TABLE(table), gtk_label_new(str), 0, 2, 1, 2); |
498 |
g_free(str); |
g_free(str); |
499 |
} |
break; |
500 |
|
|
501 |
|
default: |
502 |
|
printf("ERROR: No node, way or relation\n"); |
503 |
|
g_assert(0); |
504 |
|
break; |
505 |
|
} } |
506 |
|
|
507 |
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(context->dialog)->vbox), table, |
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(context->dialog)->vbox), table, |
508 |
FALSE, FALSE, 0); |
FALSE, FALSE, 0); |
516 |
/* ----------------------------------- */ |
/* ----------------------------------- */ |
517 |
|
|
518 |
gtk_widget_show_all(context->dialog); |
gtk_widget_show_all(context->dialog); |
519 |
|
gboolean ok = FALSE; |
520 |
|
|
521 |
if(gtk_dialog_run(GTK_DIALOG(context->dialog)) == GTK_RESPONSE_ACCEPT) { |
if(gtk_dialog_run(GTK_DIALOG(context->dialog)) == GTK_RESPONSE_ACCEPT) { |
522 |
|
ok = TRUE; |
523 |
|
|
524 |
gtk_widget_destroy(context->dialog); |
gtk_widget_destroy(context->dialog); |
525 |
|
|
526 |
if(!relation) { |
/* replace original tags with work copy */ |
527 |
/* replace original tags with work copy */ |
switch(context->object.type) { |
528 |
switch(appdata->map->selected.type) { |
|
529 |
|
case NODE: |
530 |
case MAP_TYPE_NODE: |
osm_tags_free(context->object.node->tag); |
531 |
osm_tags_free(appdata->map->selected.node->tag); |
context->object.node->tag = osm_tags_copy(work_copy, TRUE); |
532 |
appdata->map->selected.node->tag = osm_tags_copy(work_copy, TRUE); |
break; |
|
break; |
|
533 |
|
|
534 |
case MAP_TYPE_WAY: |
case WAY: |
535 |
osm_tags_free(appdata->map->selected.way->tag); |
osm_tags_free(context->object.way->tag); |
536 |
appdata->map->selected.way->tag = osm_tags_copy(work_copy, TRUE); |
context->object.way->tag = osm_tags_copy(work_copy, TRUE); |
537 |
break; |
break; |
538 |
|
|
539 |
default: |
case RELATION: |
540 |
break; |
osm_tags_free(context->object.relation->tag); |
541 |
} |
context->object.relation->tag = osm_tags_copy(work_copy, TRUE); |
542 |
|
break; |
543 |
/* since nodes being parts of ways but with no tags are invisible, */ |
|
544 |
/* the result of editing them may have changed their visibility */ |
default: |
545 |
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; |
|
546 |
} |
} |
547 |
|
|
548 |
|
/* since nodes being parts of ways but with no tags are invisible, */ |
549 |
|
/* the result of editing them may have changed their visibility */ |
550 |
|
if(!object && context->object.type != RELATION) |
551 |
|
map_item_redraw(appdata, &appdata->map->selected); |
552 |
|
|
553 |
|
osm_object_set_flags(&context->object, OSM_FLAG_DIRTY, 0); |
554 |
} else { |
} else { |
555 |
gtk_widget_destroy(context->dialog); |
gtk_widget_destroy(context->dialog); |
556 |
osm_tags_free(work_copy); |
osm_tags_free(work_copy); |
557 |
} |
} |
558 |
|
|
559 |
g_free(context); |
g_free(context); |
560 |
|
return ok; |
561 |
} |
} |