19 |
|
|
20 |
#include "appdata.h" |
#include "appdata.h" |
21 |
|
|
22 |
|
/* UI sizes */ |
23 |
|
|
24 |
|
#ifdef USE_HILDON |
25 |
|
// Making the dialog a little wider makes it less "crowded" |
26 |
|
static const guint LIST_OF_RELATIONS_DIALOG_WIDTH = 500; |
27 |
|
static const guint LIST_OF_RELATIONS_DIALOG_HEIGHT = 300; |
28 |
|
static const guint LIST_OF_MEMBERS_DIALOG_WIDTH = 500; |
29 |
|
static const guint LIST_OF_MEMBERS_DIALOG_HEIGHT = 300; |
30 |
|
#else |
31 |
|
// Desktop mode dialogs should be narrower and taller |
32 |
|
static const guint LIST_OF_RELATIONS_DIALOG_WIDTH = 475; |
33 |
|
static const guint LIST_OF_RELATIONS_DIALOG_HEIGHT = 350; |
34 |
|
static const guint LIST_OF_MEMBERS_DIALOG_WIDTH = 450; |
35 |
|
static const guint LIST_OF_MEMBERS_DIALOG_HEIGHT = 350; |
36 |
|
#endif |
37 |
|
|
38 |
|
|
39 |
|
/* ------------------------- some generic treeview helpers -----------------------*/ |
40 |
|
|
41 |
|
|
42 |
|
static void |
43 |
|
list_pre_inplace_edit_tweak (GtkTreeModel *model) |
44 |
|
{ |
45 |
|
// Remove any current sort ordering, leaving items where they are. |
46 |
|
gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(model), |
47 |
|
GTK_TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID, |
48 |
|
GTK_SORT_ASCENDING); |
49 |
|
} |
50 |
|
|
51 |
|
|
52 |
|
/* Refocus a GtkTreeView an item specified by iter, unselecting the current |
53 |
|
selection and optionally highlighting the new one. Typically called after |
54 |
|
making an edit to an item with a covering sub-dialog. */ |
55 |
|
|
56 |
|
static void |
57 |
|
list_focus_on (GtkTreeView *view, GtkTreeModel *model, |
58 |
|
GtkTreeIter *iter, gboolean highlight) |
59 |
|
{ |
60 |
|
// Handle de/reselection |
61 |
|
GtkTreeSelection *sel = gtk_tree_view_get_selection(view); |
62 |
|
gtk_tree_selection_unselect_all(sel); |
63 |
|
|
64 |
|
// Scroll to it, since it might now be out of view. |
65 |
|
GtkTreePath *path = gtk_tree_model_get_path(model, iter); |
66 |
|
gtk_tree_view_scroll_to_cell(view, path, NULL, FALSE, 0, 0); |
67 |
|
gtk_tree_path_free(path); |
68 |
|
|
69 |
|
// reselect |
70 |
|
if (highlight) |
71 |
|
gtk_tree_selection_select_iter(sel, iter); |
72 |
|
} |
73 |
|
|
74 |
|
|
75 |
/* --------------- relation dialog for an item (node or way) ----------- */ |
/* --------------- relation dialog for an item (node or way) ----------- */ |
76 |
|
|
77 |
typedef struct { |
typedef struct { |
269 |
return TRUE; /* allow selection state to change */ |
return TRUE; /* allow selection state to change */ |
270 |
} |
} |
271 |
|
|
272 |
|
/* try to find something descriptive */ |
273 |
|
static char *relation_get_descriptive_name(relation_t *relation) { |
274 |
|
char *name = osm_tag_get_by_key(relation->tag, "ref"); |
275 |
|
if (!name) |
276 |
|
name = osm_tag_get_by_key(relation->tag, "name"); |
277 |
|
if (!name) |
278 |
|
name = osm_tag_get_by_key(relation->tag, "note"); |
279 |
|
if (!name) |
280 |
|
name = osm_tag_get_by_key(relation->tag, "fix" "me"); |
281 |
|
return name; |
282 |
|
} |
283 |
|
|
284 |
static void on_relation_item_add(GtkWidget *but, relitem_context_t *context) { |
static void on_relation_item_add(GtkWidget *but, relitem_context_t *context) { |
285 |
/* create a new relation */ |
/* create a new relation */ |
286 |
|
|
294 |
/* add to list */ |
/* add to list */ |
295 |
|
|
296 |
/* append a row for the new data */ |
/* append a row for the new data */ |
297 |
/* try to find something descriptive */ |
char *name = relation_get_descriptive_name(relation); |
|
char *name = osm_tag_get_by_key(relation->tag, "name"); |
|
|
if(!name) name = osm_tag_get_by_key(relation->tag, "ref"); |
|
298 |
|
|
299 |
GtkTreeIter iter; |
GtkTreeIter iter; |
300 |
gtk_list_store_append(context->store, &iter); |
gtk_list_store_append(context->store, &iter); |
333 |
relation_t *sel = get_selection(context); |
relation_t *sel = get_selection(context); |
334 |
if(!sel) return; |
if(!sel) return; |
335 |
|
|
336 |
printf("edit relation #%ld\n", sel->id); |
printf("edit relation item #%ld\n", sel->id); |
337 |
|
|
338 |
|
if (!info_dialog(context->dialog, context->appdata, sel)) |
339 |
|
return; |
340 |
|
|
341 |
|
// Locate the changed item |
342 |
|
GtkTreeIter iter; |
343 |
|
gboolean valid = gtk_tree_model_get_iter_first( |
344 |
|
GTK_TREE_MODEL(context->store), &iter); |
345 |
|
while (valid) { |
346 |
|
relation_t *row_rel; |
347 |
|
gtk_tree_model_get(GTK_TREE_MODEL(context->store), &iter, |
348 |
|
RELITEM_COL_DATA, &row_rel, |
349 |
|
-1); |
350 |
|
if (row_rel == sel) |
351 |
|
break; |
352 |
|
valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(context->store), &iter); |
353 |
|
} |
354 |
|
if (!valid) |
355 |
|
return; |
356 |
|
|
357 |
info_dialog(context->dialog, context->appdata, sel); |
// Found it. Update all visible fields that belong to the relation iself. |
358 |
|
gtk_list_store_set(context->store, &iter, |
359 |
|
RELITEM_COL_TYPE, osm_tag_get_by_key(sel->tag, "type"), |
360 |
|
RELITEM_COL_NAME, relation_get_descriptive_name(sel), |
361 |
|
-1); |
362 |
|
|
363 |
|
// Order will probably have changed, so refocus |
364 |
|
list_focus_on(GTK_TREE_VIEW(context->view), GTK_TREE_MODEL(context->store), |
365 |
|
&iter, TRUE); |
366 |
} |
} |
367 |
|
|
368 |
/* remove the selected relation */ |
/* remove the selected relation */ |
435 |
RELITEM_COL_DATA, &relation, |
RELITEM_COL_DATA, &relation, |
436 |
-1); |
-1); |
437 |
|
|
438 |
|
list_pre_inplace_edit_tweak(GTK_TREE_MODEL(context->store)); |
439 |
|
|
440 |
if(!enabled) { |
if(!enabled) { |
441 |
printf("will now become be part of this relation\n"); |
printf("will now become be part of this relation\n"); |
442 |
if(relation_add_item(context->dialog, relation, context->item)) |
if(relation_add_item(context->dialog, relation, context->item)) |
453 |
RELITEM_COL_ROLE, NULL, |
RELITEM_COL_ROLE, NULL, |
454 |
-1); |
-1); |
455 |
} |
} |
456 |
|
|
457 |
} |
} |
458 |
|
|
459 |
static gboolean relitem_is_in_relation(relation_item_t *item, relation_t *relation) { |
static gboolean relitem_is_in_relation(relation_item_t *item, relation_t *relation) { |
491 |
|
|
492 |
/* --- "selected" column --- */ |
/* --- "selected" column --- */ |
493 |
GtkCellRenderer *renderer = gtk_cell_renderer_toggle_new(); |
GtkCellRenderer *renderer = gtk_cell_renderer_toggle_new(); |
494 |
|
GtkTreeViewColumn *column = gtk_tree_view_column_new_with_attributes( |
495 |
|
_(""), renderer, "active", RELITEM_COL_SELECTED, NULL); |
496 |
g_signal_connect(renderer, "toggled", G_CALLBACK(relitem_toggled), context); |
g_signal_connect(renderer, "toggled", G_CALLBACK(relitem_toggled), context); |
497 |
gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(context->view), |
gtk_tree_view_column_set_sort_column_id(column, RELITEM_COL_SELECTED); |
498 |
-1, _(""), renderer, |
gtk_tree_view_insert_column(GTK_TREE_VIEW(context->view), column, -1); |
|
"active", RELITEM_COL_SELECTED, |
|
|
NULL); |
|
499 |
|
|
500 |
/* --- "Type" column --- */ |
/* --- "Type" column --- */ |
501 |
renderer = gtk_cell_renderer_text_new(); |
renderer = gtk_cell_renderer_text_new(); |
502 |
gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(context->view), |
column = gtk_tree_view_column_new_with_attributes(_("Type"), renderer, |
503 |
-1, _("Type"), renderer, "text", RELITEM_COL_TYPE, NULL); |
"text", RELITEM_COL_TYPE, NULL); |
504 |
|
gtk_tree_view_column_set_sort_column_id(column, RELITEM_COL_TYPE); |
505 |
|
gtk_tree_view_insert_column(GTK_TREE_VIEW(context->view), column, -1); |
506 |
|
|
507 |
/* --- "Role" column --- */ |
/* --- "Role" column --- */ |
508 |
renderer = gtk_cell_renderer_text_new(); |
renderer = gtk_cell_renderer_text_new(); |
509 |
gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(context->view), |
column = gtk_tree_view_column_new_with_attributes(_("Role"), renderer, |
510 |
-1, _("Role"), renderer, "text", RELITEM_COL_ROLE, NULL); |
"text", RELITEM_COL_ROLE, NULL); |
511 |
|
gtk_tree_view_column_set_sort_column_id(column, RELITEM_COL_ROLE); |
512 |
|
gtk_tree_view_insert_column(GTK_TREE_VIEW(context->view), column, -1); |
513 |
|
|
514 |
/* --- "Name" column --- */ |
/* --- "Name" column --- */ |
515 |
renderer = gtk_cell_renderer_text_new(); |
renderer = gtk_cell_renderer_text_new(); |
516 |
g_object_set(renderer, "ellipsize", PANGO_ELLIPSIZE_END, NULL); |
g_object_set(renderer, "ellipsize", PANGO_ELLIPSIZE_END, NULL); |
517 |
GtkTreeViewColumn *column = |
column = gtk_tree_view_column_new_with_attributes(_("Name"), renderer, |
|
gtk_tree_view_column_new_with_attributes(_("Name"), renderer, |
|
518 |
"text", RELITEM_COL_NAME, NULL); |
"text", RELITEM_COL_NAME, NULL); |
519 |
gtk_tree_view_column_set_expand(column, TRUE); |
gtk_tree_view_column_set_expand(column, TRUE); |
520 |
|
gtk_tree_view_column_set_sort_column_id(column, RELITEM_COL_NAME); |
521 |
gtk_tree_view_insert_column(GTK_TREE_VIEW(context->view), column, -1); |
gtk_tree_view_insert_column(GTK_TREE_VIEW(context->view), column, -1); |
522 |
|
|
523 |
|
|
529 |
gtk_tree_view_set_model(GTK_TREE_VIEW(context->view), |
gtk_tree_view_set_model(GTK_TREE_VIEW(context->view), |
530 |
GTK_TREE_MODEL(context->store)); |
GTK_TREE_MODEL(context->store)); |
531 |
|
|
532 |
|
// Debatable whether to sort by the "selected" or the "Name" column by |
533 |
|
// default. Both are be useful, in different ways. |
534 |
|
gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(context->store), |
535 |
|
RELITEM_COL_NAME, GTK_SORT_ASCENDING); |
536 |
|
|
537 |
GtkTreeIter iter; |
GtkTreeIter iter; |
538 |
relation_t *relation = context->appdata->osm->relation; |
relation_t *relation = context->appdata->osm->relation; |
539 |
while(relation) { |
while(relation) { |
540 |
/* try to find something descriptive */ |
/* try to find something descriptive */ |
541 |
char *name = osm_tag_get_by_key(relation->tag, "name"); |
char *name = relation_get_descriptive_name(relation); |
|
if(!name) name = osm_tag_get_by_key(relation->tag, "ref"); |
|
542 |
|
|
543 |
/* Append a row and fill in some data */ |
/* Append a row and fill in some data */ |
544 |
gtk_list_store_append(context->store, &iter); |
gtk_list_store_append(context->store, &iter); |
621 |
gtk_dialog_set_default_response(GTK_DIALOG(context->dialog), |
gtk_dialog_set_default_response(GTK_DIALOG(context->dialog), |
622 |
GTK_RESPONSE_CLOSE); |
GTK_RESPONSE_CLOSE); |
623 |
|
|
624 |
/* making the dialog a little wider makes it less "crowded" */ |
gtk_window_set_default_size(GTK_WINDOW(context->dialog), |
625 |
#ifdef USE_HILDON |
LIST_OF_RELATIONS_DIALOG_WIDTH, |
626 |
gtk_window_set_default_size(GTK_WINDOW(context->dialog), 500, 300); |
LIST_OF_RELATIONS_DIALOG_HEIGHT); |
|
#else |
|
|
gtk_window_set_default_size(GTK_WINDOW(context->dialog), 400, 200); |
|
|
#endif |
|
627 |
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(context->dialog)->vbox), |
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(context->dialog)->vbox), |
628 |
relation_item_list_widget(context), TRUE, TRUE, 0); |
relation_item_list_widget(context), TRUE, TRUE, 0); |
629 |
|
|
851 |
gtk_dialog_set_default_response(GTK_DIALOG(mcontext->dialog), |
gtk_dialog_set_default_response(GTK_DIALOG(mcontext->dialog), |
852 |
GTK_RESPONSE_CLOSE); |
GTK_RESPONSE_CLOSE); |
853 |
|
|
854 |
/* making the dialog a little wider makes it less "crowded" */ |
gtk_window_set_default_size(GTK_WINDOW(mcontext->dialog), |
855 |
#ifdef USE_HILDON |
LIST_OF_MEMBERS_DIALOG_WIDTH, |
856 |
gtk_window_set_default_size(GTK_WINDOW(mcontext->dialog), 500, 300); |
LIST_OF_MEMBERS_DIALOG_HEIGHT); |
|
#else |
|
|
gtk_window_set_default_size(GTK_WINDOW(mcontext->dialog), 400, 200); |
|
|
#endif |
|
857 |
|
|
858 |
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(mcontext->dialog)->vbox), |
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(mcontext->dialog)->vbox), |
859 |
member_list_widget(mcontext), TRUE, TRUE, 0); |
member_list_widget(mcontext), TRUE, TRUE, 0); |
878 |
osm_relation_attach(context->appdata->osm, relation); |
osm_relation_attach(context->appdata->osm, relation); |
879 |
|
|
880 |
/* append a row for the new data */ |
/* append a row for the new data */ |
|
/* try to find something descriptive */ |
|
881 |
|
|
882 |
char *id = g_strdup_printf("#%ld", relation->id); |
char *name = relation_get_descriptive_name(relation); |
883 |
|
|
884 |
/* try to find something descriptive */ |
guint num = osm_relation_members_num(relation); |
|
char *name = osm_tag_get_by_key(relation->tag, "name"); |
|
|
if(!name) name = osm_tag_get_by_key(relation->tag, "ref"); |
|
|
|
|
|
char *num = g_strdup_printf("%d", osm_relation_members_num(relation)); |
|
885 |
|
|
886 |
/* Append a row and fill in some data */ |
/* Append a row and fill in some data */ |
887 |
GtkTreeIter iter; |
GtkTreeIter iter; |
888 |
gtk_list_store_append(context->store, &iter); |
gtk_list_store_append(context->store, &iter); |
889 |
gtk_list_store_set(context->store, &iter, |
gtk_list_store_set(context->store, &iter, |
890 |
RELATION_COL_ID, id, |
RELATION_COL_ID, relation->id, |
891 |
RELATION_COL_TYPE, |
RELATION_COL_TYPE, |
892 |
osm_tag_get_by_key(relation->tag, "type"), |
osm_tag_get_by_key(relation->tag, "type"), |
893 |
RELATION_COL_NAME, name, |
RELATION_COL_NAME, name, |
895 |
RELATION_COL_DATA, relation, |
RELATION_COL_DATA, relation, |
896 |
-1); |
-1); |
897 |
|
|
|
g_free(id); |
|
|
g_free(num); |
|
|
|
|
898 |
gtk_tree_selection_select_iter(gtk_tree_view_get_selection( |
gtk_tree_selection_select_iter(gtk_tree_view_get_selection( |
899 |
GTK_TREE_VIEW(context->view)), &iter); |
GTK_TREE_VIEW(context->view)), &iter); |
900 |
|
|
911 |
|
|
912 |
printf("edit relation #%ld\n", sel->id); |
printf("edit relation #%ld\n", sel->id); |
913 |
|
|
914 |
info_dialog(context->dialog, context->appdata, sel); |
if (!info_dialog(context->dialog, context->appdata, sel)) |
915 |
|
return; |
916 |
|
|
917 |
|
// Locate the changed item |
918 |
|
GtkTreeIter iter; |
919 |
|
gboolean valid = gtk_tree_model_get_iter_first( |
920 |
|
GTK_TREE_MODEL(context->store), &iter); |
921 |
|
while (valid) { |
922 |
|
relation_t *row_rel; |
923 |
|
gtk_tree_model_get(GTK_TREE_MODEL(context->store), &iter, |
924 |
|
RELATION_COL_DATA, &row_rel, |
925 |
|
-1); |
926 |
|
if (row_rel == sel) |
927 |
|
break; |
928 |
|
valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(context->store), &iter); |
929 |
|
} |
930 |
|
if (!valid) |
931 |
|
return; |
932 |
|
|
933 |
|
// Found it. Update all visible fields. |
934 |
|
gtk_list_store_set(context->store, &iter, |
935 |
|
RELATION_COL_ID, sel->id, |
936 |
|
RELATION_COL_TYPE, osm_tag_get_by_key(sel->tag, "type"), |
937 |
|
RELATION_COL_NAME, relation_get_descriptive_name(sel), |
938 |
|
RELATION_COL_MEMBERS, osm_relation_members_num(sel), |
939 |
|
-1); |
940 |
|
|
941 |
|
// Order will probably have changed, so refocus |
942 |
|
list_focus_on(GTK_TREE_VIEW(context->view), GTK_TREE_MODEL(context->store), |
943 |
|
&iter, TRUE); |
944 |
} |
} |
945 |
|
|
946 |
|
|
947 |
/* remove the selected relation */ |
/* remove the selected relation */ |
948 |
static void on_relation_remove(GtkWidget *but, relation_context_t *context) { |
static void on_relation_remove(GtkWidget *but, relation_context_t *context) { |
949 |
relation_t *sel = get_selected_relation(context); |
relation_t *sel = get_selected_relation(context); |
984 |
|
|
985 |
/* --- "id" column --- */ |
/* --- "id" column --- */ |
986 |
GtkCellRenderer *renderer = gtk_cell_renderer_text_new(); |
GtkCellRenderer *renderer = gtk_cell_renderer_text_new(); |
987 |
gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(context->view), |
GtkTreeViewColumn *column = gtk_tree_view_column_new_with_attributes( |
988 |
-1, _("Id"), renderer, "text", RELATION_COL_ID, NULL); |
_("Id"), renderer, "text", RELATION_COL_ID, NULL); |
989 |
|
gtk_tree_view_column_set_sort_column_id(column, RELATION_COL_ID); |
990 |
|
gtk_tree_view_insert_column(GTK_TREE_VIEW(context->view), column, -1); |
991 |
|
|
992 |
/* --- "Type" column --- */ |
/* --- "Type" column --- */ |
993 |
renderer = gtk_cell_renderer_text_new(); |
renderer = gtk_cell_renderer_text_new(); |
994 |
gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(context->view), |
column = gtk_tree_view_column_new_with_attributes(_("Type"), renderer, |
995 |
-1, _("Type"), renderer, "text", RELATION_COL_TYPE, NULL); |
"text", RELATION_COL_TYPE, NULL); |
996 |
|
gtk_tree_view_column_set_sort_column_id(column, RELATION_COL_TYPE); |
997 |
|
gtk_tree_view_insert_column(GTK_TREE_VIEW(context->view), column, -1); |
998 |
|
|
999 |
/* --- "Name" column --- */ |
/* --- "Name" column --- */ |
1000 |
renderer = gtk_cell_renderer_text_new(); |
renderer = gtk_cell_renderer_text_new(); |
1001 |
g_object_set(renderer, "ellipsize", PANGO_ELLIPSIZE_END, NULL); |
g_object_set(renderer, "ellipsize", PANGO_ELLIPSIZE_END, NULL); |
1002 |
GtkTreeViewColumn *column = |
column = gtk_tree_view_column_new_with_attributes(_("Name"), renderer, |
|
gtk_tree_view_column_new_with_attributes(_("Name"), renderer, |
|
1003 |
"text", RELATION_COL_NAME, NULL); |
"text", RELATION_COL_NAME, NULL); |
1004 |
gtk_tree_view_column_set_expand(column, TRUE); |
gtk_tree_view_column_set_expand(column, TRUE); |
1005 |
|
gtk_tree_view_column_set_sort_column_id(column, RELATION_COL_NAME); |
1006 |
gtk_tree_view_insert_column(GTK_TREE_VIEW(context->view), column, -1); |
gtk_tree_view_insert_column(GTK_TREE_VIEW(context->view), column, -1); |
1007 |
|
|
1008 |
/* --- "members" column --- */ |
/* --- "members" column --- */ |
1009 |
renderer = gtk_cell_renderer_text_new(); |
renderer = gtk_cell_renderer_text_new(); |
1010 |
gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(context->view), |
column = gtk_tree_view_column_new_with_attributes(_("Members"), renderer, |
1011 |
-1, _("Members"), renderer, "text", RELATION_COL_MEMBERS, NULL); |
"text", RELATION_COL_MEMBERS, NULL); |
1012 |
|
gtk_tree_view_column_set_sort_column_id(column, RELATION_COL_MEMBERS); |
1013 |
|
gtk_tree_view_insert_column(GTK_TREE_VIEW(context->view), column, -1); |
1014 |
|
|
1015 |
/* build and fill the store */ |
/* build and fill the store */ |
1016 |
context->store = gtk_list_store_new(RELATION_NUM_COLS, |
context->store = gtk_list_store_new(RELATION_NUM_COLS, |
1017 |
G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, |
G_TYPE_ITEM_ID_T, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_UINT, |
1018 |
G_TYPE_POINTER); |
G_TYPE_POINTER); |
1019 |
|
|
1020 |
gtk_tree_view_set_model(GTK_TREE_VIEW(context->view), |
gtk_tree_view_set_model(GTK_TREE_VIEW(context->view), |
1021 |
GTK_TREE_MODEL(context->store)); |
GTK_TREE_MODEL(context->store)); |
1022 |
|
|
1023 |
|
// Sorting by ref/name by default is useful for places with lots of numbered |
1024 |
|
// bus routes. Especially for small screens. |
1025 |
|
gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(context->store), |
1026 |
|
RELATION_COL_NAME, GTK_SORT_ASCENDING); |
1027 |
|
|
1028 |
GtkTreeIter iter; |
GtkTreeIter iter; |
1029 |
relation_t *relation = context->appdata->osm->relation; |
relation_t *relation = context->appdata->osm->relation; |
1030 |
while(relation) { |
while(relation) { |
1031 |
char *id = g_strdup_printf("#%ld", relation->id); |
char *name = relation_get_descriptive_name(relation); |
|
|
|
|
/* try to find something descriptive */ |
|
|
char *name = osm_tag_get_by_key(relation->tag, "name"); |
|
|
if(!name) name = osm_tag_get_by_key(relation->tag, "ref"); |
|
1032 |
|
|
1033 |
char *num = g_strdup_printf("%d", osm_relation_members_num(relation)); |
guint num = osm_relation_members_num(relation); |
1034 |
|
|
1035 |
/* Append a row and fill in some data */ |
/* Append a row and fill in some data */ |
1036 |
gtk_list_store_append(context->store, &iter); |
gtk_list_store_append(context->store, &iter); |
1037 |
gtk_list_store_set(context->store, &iter, |
gtk_list_store_set(context->store, &iter, |
1038 |
RELATION_COL_ID, id, |
RELATION_COL_ID, relation->id, |
1039 |
RELATION_COL_TYPE, |
RELATION_COL_TYPE, |
1040 |
osm_tag_get_by_key(relation->tag, "type"), |
osm_tag_get_by_key(relation->tag, "type"), |
1041 |
RELATION_COL_NAME, name, |
RELATION_COL_NAME, name, |
1042 |
RELATION_COL_MEMBERS, num, |
RELATION_COL_MEMBERS, num, |
1043 |
RELATION_COL_DATA, relation, |
RELATION_COL_DATA, relation, |
1044 |
-1); |
-1); |
1045 |
|
|
|
g_free(id); |
|
|
g_free(num); |
|
1046 |
relation = relation->next; |
relation = relation->next; |
1047 |
} |
} |
1048 |
|
|
1107 |
gtk_dialog_set_default_response(GTK_DIALOG(context->dialog), |
gtk_dialog_set_default_response(GTK_DIALOG(context->dialog), |
1108 |
GTK_RESPONSE_CLOSE); |
GTK_RESPONSE_CLOSE); |
1109 |
|
|
1110 |
/* making the dialog a little wider makes it less "crowded" */ |
gtk_window_set_default_size(GTK_WINDOW(context->dialog), |
1111 |
#ifdef USE_HILDON |
LIST_OF_RELATIONS_DIALOG_WIDTH, |
1112 |
gtk_window_set_default_size(GTK_WINDOW(context->dialog), 500, 300); |
LIST_OF_RELATIONS_DIALOG_HEIGHT); |
1113 |
#else |
|
|
gtk_window_set_default_size(GTK_WINDOW(context->dialog), 400, 200); |
|
|
#endif |
|
1114 |
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(context->dialog)->vbox), |
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(context->dialog)->vbox), |
1115 |
relation_list_widget(context), TRUE, TRUE, 0); |
relation_list_widget(context), TRUE, TRUE, 0); |
1116 |
|
|
1122 |
|
|
1123 |
g_free(context); |
g_free(context); |
1124 |
} |
} |
1125 |
|
|
1126 |
|
|
1127 |
|
// vim:et:ts=8:sw=2:sts=2:ai |