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; |
135 |
gtk_tree_model_get(model, &iter, TAG_COL_DATA, &tag, -1); |
gtk_tree_model_get(model, &iter, TAG_COL_DATA, &tag, -1); |
136 |
printf("got %s/%s\n", tag->key, tag->value); |
printf("got %s/%s\n", tag->key, tag->value); |
137 |
|
|
138 |
GtkWidget *dialog = gtk_dialog_new_with_buttons(_("Edit Tag"), |
GtkWidget *dialog = misc_dialog_new(MISC_DIALOG_SMALL, _("Edit Tag"), |
139 |
GTK_WINDOW(context->dialog), GTK_DIALOG_MODAL, |
GTK_WINDOW(context->dialog), |
140 |
GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, |
GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, |
141 |
GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, |
GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, |
142 |
NULL); |
NULL); |
|
|
|
|
#ifdef USE_HILDON |
|
|
gtk_window_set_default_size(GTK_WINDOW(dialog), 500, 100); |
|
|
#else |
|
|
gtk_window_set_default_size(GTK_WINDOW(dialog), 400, 100); |
|
|
#endif |
|
143 |
|
|
144 |
gtk_dialog_set_default_response(GTK_DIALOG(dialog), |
gtk_dialog_set_default_response(GTK_DIALOG(dialog), |
145 |
GTK_RESPONSE_ACCEPT); |
GTK_RESPONSE_ACCEPT); |
205 |
_("This will overwrite all tags of this %s with the " |
_("This will overwrite all tags of this %s with the " |
206 |
"ones from the %s selected last.\n\n" |
"ones from the %s selected last.\n\n" |
207 |
"Do you really want this?"), |
"Do you really want this?"), |
208 |
type_name[context->type], type_name[context->type])) { |
type_name[context->object.type], type_name[context->object.type])) { |
209 |
|
|
210 |
osm_tags_free(*context->tag); |
osm_tags_free(*context->tag); |
211 |
|
|
212 |
if(context->type == NODE) |
if(context->object.type == NODE) |
213 |
*context->tag = osm_tags_copy(context->appdata->map->last_node_tags, TRUE); |
*context->tag = osm_tags_copy(context->appdata->map->last_node_tags, TRUE); |
214 |
else |
else |
215 |
*context->tag = osm_tags_copy(context->appdata->map->last_way_tags, TRUE); |
*context->tag = osm_tags_copy(context->appdata->map->last_way_tags, TRUE); |
245 |
TAG_COL_DATA, *tag, |
TAG_COL_DATA, *tag, |
246 |
-1); |
-1); |
247 |
|
|
248 |
gtk_tree_selection_select_iter(gtk_tree_view_get_selection( |
gtk_tree_selection_select_iter( |
249 |
GTK_TREE_VIEW(context->view)), &iter); |
list_get_selection(context->list), &iter); |
250 |
|
|
251 |
if(!tag_edit(context)) { |
if(!tag_edit(context)) { |
252 |
printf("cancelled\n"); |
printf("cancelled\n"); |
272 |
} |
} |
273 |
|
|
274 |
static GtkWidget *tag_widget(tag_context_t *context) { |
static GtkWidget *tag_widget(tag_context_t *context) { |
275 |
GtkWidget *vbox = gtk_vbox_new(FALSE,3); |
context->list = list_new(LIST_HILDON_WITH_HEADERS_ON_MAEMO5); |
276 |
context->view = gtk_tree_view_new(); |
|
277 |
|
list_set_static_buttons(context->list, G_CALLBACK(on_tag_add), |
278 |
|
G_CALLBACK(on_tag_edit), G_CALLBACK(on_tag_remove), context); |
279 |
|
|
280 |
|
list_set_selection_function(context->list, view_selection_func, context); |
281 |
|
|
282 |
|
list_set_user_buttons(context->list, |
283 |
|
LIST_BUTTON_USER0, _("Last"), on_tag_last, |
284 |
|
0); |
285 |
|
|
286 |
|
/* setup both columns */ |
287 |
|
list_set_columns(context->list, |
288 |
|
_("Key"), TAG_COL_KEY, |
289 |
|
LIST_FLAG_ELLIPSIZE|LIST_FLAG_CAN_HIGHLIGHT, TAG_COL_COLLISION, |
290 |
|
_("Value"), TAG_COL_VALUE, |
291 |
|
LIST_FLAG_ELLIPSIZE, |
292 |
|
NULL); |
293 |
|
|
294 |
|
GtkWidget *presets = josm_presets_select(context->appdata, context); |
295 |
|
if(presets) |
296 |
|
list_set_custom_user_button(context->list, LIST_BUTTON_USER1, presets); |
297 |
|
|
298 |
gtk_tree_selection_set_select_function( |
/* disable if no appropriate "last" tags have been stored or if the */ |
299 |
gtk_tree_view_get_selection(GTK_TREE_VIEW(context->view)), |
/* selected item isn't a node or way */ |
300 |
view_selection_func, |
if(((context->object.type == NODE) && |
301 |
context, NULL); |
(!context->appdata->map->last_node_tags)) || |
302 |
|
((context->object.type == WAY) && |
303 |
/* --- "Key" column --- */ |
(!context->appdata->map->last_way_tags)) || |
304 |
GtkCellRenderer *renderer = gtk_cell_renderer_text_new(); |
((context->object.type != NODE) && (context->object.type != WAY))) |
305 |
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); |
|
306 |
|
|
307 |
/* build and fill the store */ |
/* --------- build and fill the store ------------ */ |
308 |
context->store = gtk_list_store_new(TAG_NUM_COLS, |
context->store = gtk_list_store_new(TAG_NUM_COLS, |
309 |
G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_POINTER); |
G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_POINTER); |
310 |
|
|
311 |
gtk_tree_view_set_model(GTK_TREE_VIEW(context->view), |
list_set_store(context->list, context->store); |
|
GTK_TREE_MODEL(context->store)); |
|
312 |
|
|
313 |
GtkTreeIter iter; |
GtkTreeIter iter; |
314 |
tag_t *tag = *context->tag; |
tag_t *tag = *context->tag; |
326 |
|
|
327 |
g_object_unref(context->store); |
g_object_unref(context->store); |
328 |
|
|
329 |
/* put it into a scrolled window */ |
return context->list; |
330 |
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); |
|
|
|
|
331 |
|
|
332 |
gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); |
static void on_relation_members(GtkWidget *but, tag_context_t *context) { |
333 |
return vbox; |
g_assert(context->object.type == RELATION); |
334 |
|
relation_show_members(context->dialog, context->object.relation); |
335 |
} |
} |
336 |
|
|
337 |
/* edit tags of currently selected node or way or of the relation */ |
/* edit tags of currently selected node or way or of the relation */ |
338 |
/* given */ |
/* given */ |
339 |
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); |
|
340 |
|
|
341 |
tag_context_t *context = g_new0(tag_context_t, 1); |
tag_context_t *context = g_new0(tag_context_t, 1); |
342 |
user_t *user = NULL; |
user_t *user = NULL; |
347 |
context->appdata = appdata; |
context->appdata = appdata; |
348 |
context->tag = &work_copy; |
context->tag = &work_copy; |
349 |
|
|
350 |
if(!relation) { |
/* use implicit selection if not explicitely given */ |
351 |
switch(appdata->map->selected.type) { |
if(!object) { |
352 |
case MAP_TYPE_NODE: |
g_assert((appdata->map->selected.object.type == NODE) || |
353 |
str = g_strdup_printf(_("Node #%ld"), appdata->map->selected.node->id); |
(appdata->map->selected.object.type == WAY) || |
354 |
user = appdata->map->selected.node->user; |
(appdata->map->selected.object.type == RELATION)); |
355 |
work_copy = osm_tags_copy(appdata->map->selected.node->tag, FALSE); |
|
356 |
stime = appdata->map->selected.node->time; |
context->object = appdata->map->selected.object; |
357 |
context->type = NODE; |
} else |
358 |
context->presets_type = PRESETS_TYPE_NODE; |
context->object = *object; |
359 |
break; |
|
360 |
case MAP_TYPE_WAY: |
switch(context->object.type) { |
361 |
str = g_strdup_printf(_("Way #%ld"), appdata->map->selected.way->id); |
case NODE: |
362 |
user = appdata->map->selected.way->user; |
str = g_strdup_printf(_("Node #" ITEM_ID_FORMAT), context->object.node->id); |
363 |
work_copy = osm_tags_copy(appdata->map->selected.way->tag, FALSE); |
user = context->object.node->user; |
364 |
stime = appdata->map->selected.way->time; |
work_copy = osm_tags_copy(context->object.node->tag, FALSE); |
365 |
context->type = WAY; |
stime = context->object.node->time; |
366 |
context->presets_type = PRESETS_TYPE_WAY; |
context->presets_type = PRESETS_TYPE_NODE; |
367 |
|
break; |
368 |
if(osm_way_get_last_node(appdata->map->selected.way) == |
|
369 |
osm_way_get_first_node(appdata->map->selected.way)) |
case WAY: |
370 |
context->presets_type |= PRESETS_TYPE_CLOSEDWAY; |
str = g_strdup_printf(_("Way #" ITEM_ID_FORMAT), context->object.way->id); |
371 |
|
user = context->object.way->user; |
372 |
break; |
work_copy = osm_tags_copy(context->object.way->tag, FALSE); |
373 |
default: |
stime = context->object.way->time; |
374 |
g_assert((appdata->map->selected.type == MAP_TYPE_NODE) || |
context->presets_type = PRESETS_TYPE_WAY; |
375 |
(appdata->map->selected.type == MAP_TYPE_WAY)); |
|
376 |
break; |
if(osm_way_get_last_node(context->object.way) == |
377 |
} |
osm_way_get_first_node(context->object.way)) |
378 |
} else { |
context->presets_type |= PRESETS_TYPE_CLOSEDWAY; |
379 |
str = g_strdup_printf(_("Relation #%ld"), relation->id); |
|
380 |
user = relation->user; |
break; |
381 |
work_copy = osm_tags_copy(relation->tag, FALSE); |
|
382 |
stime = relation->time; |
case RELATION: |
383 |
context->type = RELATION; |
str = g_strdup_printf(_("Relation #" ITEM_ID_FORMAT), |
384 |
|
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; |
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 = misc_dialog_new(MISC_DIALOG_LARGE, str, |
399 |
GTK_WINDOW(parent), GTK_DIALOG_MODAL, |
GTK_WINDOW(parent), |
400 |
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, |
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, |
401 |
GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, |
GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, |
402 |
NULL); |
NULL); |
405 |
gtk_dialog_set_default_response(GTK_DIALOG(context->dialog), |
gtk_dialog_set_default_response(GTK_DIALOG(context->dialog), |
406 |
GTK_RESPONSE_ACCEPT); |
GTK_RESPONSE_ACCEPT); |
407 |
|
|
|
/* making the dialog a little wider makes it less "crowded" */ |
|
|
#ifdef USE_HILDON |
|
|
gtk_window_set_default_size(GTK_WINDOW(context->dialog), 500, 300); |
|
|
#else |
|
|
gtk_window_set_default_size(GTK_WINDOW(context->dialog), 400, 200); |
|
|
#endif |
|
|
|
|
408 |
GtkWidget *label; |
GtkWidget *label; |
409 |
GtkWidget *table = gtk_table_new(2, 2, FALSE); // x, y |
GtkWidget *table = gtk_table_new(2, 2, FALSE); // x, y |
410 |
|
|
411 |
/* ------------ user ----------------- */ |
/* ------------ user ----------------- */ |
412 |
char *u_str = NULL; |
if(user) { |
413 |
if(user) u_str = g_strdup_printf(_("User: %s"), user->name); |
label = gtk_label_new(user->name); |
414 |
else u_str = g_strdup_printf(_("User: ---")); |
gtk_label_set_ellipsize(GTK_LABEL(label), PANGO_ELLIPSIZE_END); |
415 |
label = gtk_label_new(u_str); |
gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 0, 1); |
416 |
gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 0, 1); |
} |
|
g_free(u_str); |
|
417 |
|
|
418 |
/* ------------ time ----------------- */ |
/* ------------ time ----------------- */ |
419 |
|
|
420 |
struct tm *loctime = localtime(&stime); |
struct tm *loctime = localtime(&stime); |
421 |
char time_str[32]; |
char time_str[32]; |
422 |
strftime(time_str, sizeof(time_str), "%x %X", loctime); |
strftime(time_str, sizeof(time_str), "%x %X", loctime); |
423 |
char *t_str = g_strdup_printf(_("Time: %s"), time_str); |
label = gtk_label_new(time_str); |
|
label = gtk_label_new(t_str); |
|
|
g_free(t_str); |
|
424 |
gtk_table_attach_defaults(GTK_TABLE(table), label, 1, 2, 0, 1); |
gtk_table_attach_defaults(GTK_TABLE(table), label, 1, 2, 0, 1); |
425 |
|
|
426 |
/* ------------ coordinate (only for nodes) ----------------- */ |
/* ------------ coordinate (only for nodes) ----------------- */ |
427 |
if(!relation) { |
switch(context->object.type) { |
428 |
if(appdata->map->selected.type == MAP_TYPE_NODE) { |
case NODE: { |
429 |
char pos_str[32]; |
char pos_str[32]; |
430 |
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); |
431 |
label = gtk_label_new(pos_str); |
label = gtk_label_new(pos_str); |
432 |
gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 1, 2); |
gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 1, 2); |
433 |
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); |
434 |
label = gtk_label_new(pos_str); |
label = gtk_label_new(pos_str); |
435 |
gtk_table_attach_defaults(GTK_TABLE(table), label, 1, 2, 1, 2); |
gtk_table_attach_defaults(GTK_TABLE(table), label, 1, 2, 1, 2); |
436 |
} else { |
} break; |
437 |
char *nodes_str = g_strdup_printf(_("Length: %u nodes"), |
|
438 |
osm_way_number_of_nodes(appdata->map->selected.way)); |
case WAY: { |
439 |
label = gtk_label_new(nodes_str); |
char *nodes_str = g_strdup_printf(_("Length: %u nodes"), |
440 |
gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 1, 2); |
osm_way_number_of_nodes(context->object.way)); |
441 |
g_free(nodes_str); |
label = gtk_label_new(nodes_str); |
442 |
|
gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 1, 2); |
443 |
char *type_str = g_strdup_printf("%s (%s)", |
g_free(nodes_str); |
444 |
(osm_way_get_last_node(appdata->map->selected.way) == |
|
445 |
osm_way_get_first_node(appdata->map->selected.way))? |
char *type_str = g_strdup_printf("%s (%s)", |
446 |
"closed way":"open way", |
(osm_way_get_last_node(context->object.way) == |
447 |
(appdata->map->selected.way->draw.flags & OSM_DRAW_FLAG_AREA)? |
osm_way_get_first_node(context->object.way))? |
448 |
"area":"line"); |
"closed way":"open way", |
449 |
|
(context->object.way->draw.flags & OSM_DRAW_FLAG_AREA)? |
450 |
|
"area":"line"); |
451 |
|
|
452 |
label = gtk_label_new(type_str); |
label = gtk_label_new(type_str); |
453 |
gtk_table_attach_defaults(GTK_TABLE(table), label, 1, 2, 1, 2); |
gtk_table_attach_defaults(GTK_TABLE(table), label, 1, 2, 1, 2); |
454 |
g_free(type_str); |
g_free(type_str); |
455 |
} |
} break; |
456 |
} else { |
|
457 |
|
case RELATION: { |
458 |
/* relations tell something about their members */ |
/* relations tell something about their members */ |
459 |
gint nodes = 0, ways = 0, relations = 0; |
gint nodes = 0, ways = 0, relations = 0; |
460 |
member_t *member = relation->member; |
member_t *member = context->object.relation->member; |
461 |
while(member) { |
while(member) { |
462 |
switch(member->type) { |
switch(member->object.type) { |
463 |
case NODE: |
case NODE: |
464 |
case NODE_ID: |
case NODE_ID: |
465 |
nodes++; |
nodes++; |
472 |
case RELATION_ID: |
case RELATION_ID: |
473 |
relations++; |
relations++; |
474 |
break; |
break; |
475 |
|
|
476 |
default: |
default: |
477 |
break; |
break; |
478 |
} |
} |
480 |
member = member->next; |
member = member->next; |
481 |
} |
} |
482 |
|
|
483 |
char *str = g_strdup_printf(_("Members: %d nodes, %d ways, %d relations"), |
char *str = |
484 |
nodes, ways, relations); |
g_strdup_printf(_("Members: %d nodes, %d ways, %d relations"), |
485 |
|
nodes, ways, relations); |
486 |
|
|
487 |
|
GtkWidget *member_btn = gtk_button_new_with_label(str); |
488 |
|
gtk_signal_connect(GTK_OBJECT(member_btn), "clicked", |
489 |
|
GTK_SIGNAL_FUNC(on_relation_members), context); |
490 |
|
gtk_table_attach_defaults(GTK_TABLE(table), member_btn, 0, 2, 1, 2); |
491 |
|
|
|
gtk_table_attach_defaults(GTK_TABLE(table), gtk_label_new(str), 0, 2, 1, 2); |
|
492 |
g_free(str); |
g_free(str); |
493 |
} |
break; |
494 |
|
|
495 |
|
default: |
496 |
|
printf("ERROR: No node, way or relation\n"); |
497 |
|
g_assert(0); |
498 |
|
break; |
499 |
|
} } |
500 |
|
|
501 |
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(context->dialog)->vbox), table, |
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(context->dialog)->vbox), table, |
502 |
FALSE, FALSE, 0); |
FALSE, FALSE, 0); |
510 |
/* ----------------------------------- */ |
/* ----------------------------------- */ |
511 |
|
|
512 |
gtk_widget_show_all(context->dialog); |
gtk_widget_show_all(context->dialog); |
513 |
|
gboolean ok = FALSE; |
514 |
|
|
515 |
if(gtk_dialog_run(GTK_DIALOG(context->dialog)) == GTK_RESPONSE_ACCEPT) { |
if(gtk_dialog_run(GTK_DIALOG(context->dialog)) == GTK_RESPONSE_ACCEPT) { |
516 |
|
ok = TRUE; |
517 |
|
|
518 |
gtk_widget_destroy(context->dialog); |
gtk_widget_destroy(context->dialog); |
519 |
|
|
520 |
if(!relation) { |
/* replace original tags with work copy */ |
521 |
/* replace original tags with work copy */ |
switch(context->object.type) { |
522 |
switch(appdata->map->selected.type) { |
|
523 |
|
case NODE: |
524 |
case MAP_TYPE_NODE: |
osm_tags_free(context->object.node->tag); |
525 |
osm_tags_free(appdata->map->selected.node->tag); |
context->object.node->tag = osm_tags_copy(work_copy, TRUE); |
526 |
appdata->map->selected.node->tag = osm_tags_copy(work_copy, TRUE); |
break; |
|
break; |
|
527 |
|
|
528 |
case MAP_TYPE_WAY: |
case WAY: |
529 |
osm_tags_free(appdata->map->selected.way->tag); |
osm_tags_free(context->object.way->tag); |
530 |
appdata->map->selected.way->tag = osm_tags_copy(work_copy, TRUE); |
context->object.way->tag = osm_tags_copy(work_copy, TRUE); |
531 |
break; |
break; |
532 |
|
|
533 |
default: |
case RELATION: |
534 |
break; |
osm_tags_free(context->object.relation->tag); |
535 |
} |
context->object.relation->tag = osm_tags_copy(work_copy, TRUE); |
536 |
|
break; |
537 |
/* since nodes being parts of ways but with no tags are invisible, */ |
|
538 |
/* the result of editing them may have changed their visibility */ |
default: |
539 |
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; |
|
540 |
} |
} |
541 |
|
|
542 |
|
/* since nodes being parts of ways but with no tags are invisible, */ |
543 |
|
/* the result of editing them may have changed their visibility */ |
544 |
|
if(!object && context->object.type != RELATION) |
545 |
|
map_item_redraw(appdata, &appdata->map->selected); |
546 |
|
|
547 |
|
osm_object_set_flags(&context->object, OSM_FLAG_DIRTY, 0); |
548 |
} else { |
} else { |
549 |
gtk_widget_destroy(context->dialog); |
gtk_widget_destroy(context->dialog); |
550 |
osm_tags_free(work_copy); |
osm_tags_free(work_copy); |
551 |
} |
} |
552 |
|
|
553 |
g_free(context); |
g_free(context); |
554 |
|
return ok; |
555 |
} |
} |