228 |
return name; |
return name; |
229 |
} |
} |
230 |
|
|
231 |
|
static gboolean relation_info_dialog(GtkWidget *parent, appdata_t *appdata, |
232 |
|
relation_t *relation) { |
233 |
|
|
234 |
|
object_t object = { .type = RELATION }; |
235 |
|
object.relation = relation; |
236 |
|
return info_dialog(parent, appdata, &object); |
237 |
|
} |
238 |
|
|
239 |
static void on_relation_item_add(GtkWidget *but, relitem_context_t *context) { |
static void on_relation_item_add(GtkWidget *but, relitem_context_t *context) { |
240 |
/* create a new relation */ |
/* create a new relation */ |
241 |
|
|
242 |
relation_t *relation = osm_relation_new(); |
relation_t *relation = osm_relation_new(); |
243 |
if(!info_dialog(context->dialog, context->appdata, relation)) { |
if(!relation_info_dialog(context->dialog, context->appdata, relation)) { |
244 |
printf("tag edit cancelled\n"); |
printf("tag edit cancelled\n"); |
245 |
osm_relation_free(relation); |
osm_relation_free(relation); |
246 |
} else { |
} else { |
285 |
|
|
286 |
printf("edit relation item #%ld\n", sel->id); |
printf("edit relation item #%ld\n", sel->id); |
287 |
|
|
288 |
if (!info_dialog(context->dialog, context->appdata, sel)) |
if (!relation_info_dialog(context->dialog, context->appdata, sel)) |
289 |
return; |
return; |
290 |
|
|
291 |
// Locate the changed item |
// Locate the changed item |
472 |
g_object_unref(context->store); |
g_object_unref(context->store); |
473 |
|
|
474 |
list_set_static_buttons(context->list, G_CALLBACK(on_relation_item_add), |
list_set_static_buttons(context->list, G_CALLBACK(on_relation_item_add), |
475 |
G_CALLBACK(on_relation_item_edit),G_CALLBACK(on_relation_item_remove), context); |
G_CALLBACK(on_relation_item_edit),G_CALLBACK(on_relation_item_remove), |
476 |
|
context); |
477 |
|
|
478 |
relation_item_list_selected(context, FALSE); |
relation_item_list_selected(context, FALSE); |
479 |
|
|
529 |
|
|
530 |
typedef struct { |
typedef struct { |
531 |
appdata_t *appdata; |
appdata_t *appdata; |
532 |
GtkWidget *dialog, *list; |
GtkWidget *dialog, *list, *show_btn; |
533 |
GtkListStore *store; |
GtkListStore *store; |
534 |
} relation_context_t; |
} relation_context_t; |
535 |
|
|
561 |
|
|
562 |
list_button_enable(context->list, LIST_BUTTON_USER0, |
list_button_enable(context->list, LIST_BUTTON_USER0, |
563 |
(selected != NULL) && (selected->member != NULL)); |
(selected != NULL) && (selected->member != NULL)); |
564 |
|
gtk_widget_set_sensitive(context->show_btn, |
565 |
|
(selected != NULL) && (selected->member != NULL)); |
566 |
|
|
567 |
list_button_enable(context->list, LIST_BUTTON_REMOVE, selected != NULL); |
list_button_enable(context->list, LIST_BUTTON_REMOVE, selected != NULL); |
568 |
list_button_enable(context->list, LIST_BUTTON_EDIT, selected != NULL); |
list_button_enable(context->list, LIST_BUTTON_EDIT, selected != NULL); |
758 |
/* create a new relation */ |
/* create a new relation */ |
759 |
|
|
760 |
relation_t *relation = osm_relation_new(); |
relation_t *relation = osm_relation_new(); |
761 |
if(!info_dialog(context->dialog, context->appdata, relation)) { |
if(!relation_info_dialog(context->dialog, context->appdata, relation)) { |
762 |
printf("tag edit cancelled\n"); |
printf("tag edit cancelled\n"); |
763 |
osm_relation_free(relation); |
osm_relation_free(relation); |
764 |
} else { |
} else { |
797 |
|
|
798 |
printf("edit relation #%ld\n", sel->id); |
printf("edit relation #%ld\n", sel->id); |
799 |
|
|
800 |
if (!info_dialog(context->dialog, context->appdata, sel)) |
if (!relation_info_dialog(context->dialog, context->appdata, sel)) |
801 |
return; |
return; |
802 |
|
|
803 |
// Locate the changed item |
// Locate the changed item |
860 |
static GtkWidget *relation_list_widget(relation_context_t *context) { |
static GtkWidget *relation_list_widget(relation_context_t *context) { |
861 |
context->list = list_new(LIST_HILDON_WITH_HEADERS); |
context->list = list_new(LIST_HILDON_WITH_HEADERS); |
862 |
|
|
863 |
list_set_selection_function(context->list, relation_list_selection_func, context); |
list_set_selection_function(context->list, relation_list_selection_func, |
864 |
|
context); |
865 |
|
|
866 |
list_set_columns(context->list, |
list_set_columns(context->list, |
867 |
_("Id"), RELATION_COL_ID, 0, |
_("Id"), RELATION_COL_ID, 0, |
937 |
LIST_OF_RELATIONS_DIALOG_WIDTH, |
LIST_OF_RELATIONS_DIALOG_WIDTH, |
938 |
LIST_OF_RELATIONS_DIALOG_HEIGHT); |
LIST_OF_RELATIONS_DIALOG_HEIGHT); |
939 |
|
|
940 |
|
context->show_btn = gtk_dialog_add_button(GTK_DIALOG(context->dialog), |
941 |
|
_("Select"), GTK_RESPONSE_HELP); |
942 |
|
|
943 |
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(context->dialog)->vbox), |
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(context->dialog)->vbox), |
944 |
relation_list_widget(context), TRUE, TRUE, 0); |
relation_list_widget(context), TRUE, TRUE, 0); |
945 |
|
|
946 |
/* ----------------------------------- */ |
/* ----------------------------------- */ |
947 |
|
|
948 |
|
|
949 |
gtk_widget_show_all(context->dialog); |
gtk_widget_show_all(context->dialog); |
950 |
gtk_dialog_run(GTK_DIALOG(context->dialog)); |
if(gtk_dialog_run(GTK_DIALOG(context->dialog)) == GTK_RESPONSE_HELP) { |
951 |
gtk_widget_destroy(context->dialog); |
map_item_deselect(appdata); |
952 |
|
|
953 |
|
relation_t *sel = get_selected_relation(context); |
954 |
|
if(sel) map_relation_select(appdata, sel); |
955 |
|
} |
956 |
|
|
957 |
|
gtk_widget_destroy(context->dialog); |
958 |
g_free(context); |
g_free(context); |
959 |
} |
} |
960 |
|
|