506 |
appdata_t *appdata; |
appdata_t *appdata; |
507 |
GtkWidget *dialog, *list, *show_btn; |
GtkWidget *dialog, *list, *show_btn; |
508 |
GtkListStore *store; |
GtkListStore *store; |
509 |
|
object_t *object; /* object this list relates to, NULL if global */ |
510 |
} relation_context_t; |
} relation_context_t; |
511 |
|
|
512 |
enum { |
enum { |
868 |
RELATION_COL_NAME, GTK_SORT_ASCENDING); |
RELATION_COL_NAME, GTK_SORT_ASCENDING); |
869 |
|
|
870 |
GtkTreeIter iter; |
GtkTreeIter iter; |
871 |
relation_t *relation = context->appdata->osm->relation; |
relation_t *relation = NULL; |
872 |
while(relation) { |
relation_chain_t *rchain = NULL; |
|
char *name = relation_get_descriptive_name(relation); |
|
873 |
|
|
874 |
guint num = osm_relation_members_num(relation); |
if(context->object) |
875 |
|
rchain = osm_object_to_relation(context->appdata->osm, context->object); |
876 |
|
else |
877 |
|
relation = context->appdata->osm->relation; |
878 |
|
|
879 |
|
while(relation || rchain) { |
880 |
|
relation_t *rel = relation?relation:rchain->relation; |
881 |
|
|
882 |
|
char *name = relation_get_descriptive_name(rel); |
883 |
|
guint num = osm_relation_members_num(rel); |
884 |
|
|
885 |
/* Append a row and fill in some data */ |
/* Append a row and fill in some data */ |
886 |
gtk_list_store_append(context->store, &iter); |
gtk_list_store_append(context->store, &iter); |
887 |
gtk_list_store_set(context->store, &iter, |
gtk_list_store_set(context->store, &iter, |
888 |
RELATION_COL_ID, relation->id, |
RELATION_COL_ID, rel->id, |
889 |
RELATION_COL_TYPE, |
RELATION_COL_TYPE, |
890 |
osm_tag_get_by_key(relation->tag, "type"), |
osm_tag_get_by_key(rel->tag, "type"), |
891 |
RELATION_COL_NAME, name, |
RELATION_COL_NAME, name, |
892 |
RELATION_COL_MEMBERS, num, |
RELATION_COL_MEMBERS, num, |
893 |
RELATION_COL_DATA, relation, |
RELATION_COL_DATA, rel, |
894 |
-1); |
-1); |
895 |
|
|
896 |
relation = relation->next; |
if(relation) relation = relation->next; |
897 |
|
if(rchain) rchain = rchain->next; |
898 |
} |
} |
899 |
|
|
900 |
|
if(rchain) |
901 |
|
osm_relation_chain_free(rchain); |
902 |
|
|
903 |
g_object_unref(context->store); |
g_object_unref(context->store); |
904 |
|
|
915 |
} |
} |
916 |
|
|
917 |
/* a global view on all relations */ |
/* a global view on all relations */ |
918 |
void relation_list(appdata_t *appdata) { |
void relation_list(GtkWidget *parent, appdata_t *appdata, object_t *object) { |
919 |
relation_context_t *context = g_new0(relation_context_t, 1); |
relation_context_t *context = g_new0(relation_context_t, 1); |
920 |
context->appdata = appdata; |
context->appdata = appdata; |
921 |
|
|
922 |
printf("relation list\n"); |
char *str = NULL; |
923 |
|
if(!object) |
924 |
|
str = g_strdup(_("All relations")); |
925 |
|
else { |
926 |
|
str = g_strdup_printf(_("Relations of %s"), osm_object_string(object)); |
927 |
|
context->object = object; |
928 |
|
} |
929 |
|
|
930 |
context->dialog = |
context->dialog = |
931 |
misc_dialog_new(MISC_DIALOG_LARGE, _("All relations"), |
misc_dialog_new(MISC_DIALOG_LARGE, str, |
932 |
GTK_WINDOW(appdata->window), |
GTK_WINDOW(parent), |
933 |
GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, |
GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, |
934 |
NULL); |
NULL); |
935 |
|
|
936 |
|
g_free(str); |
937 |
|
|
938 |
gtk_dialog_set_default_response(GTK_DIALOG(context->dialog), |
gtk_dialog_set_default_response(GTK_DIALOG(context->dialog), |
939 |
GTK_RESPONSE_CLOSE); |
GTK_RESPONSE_CLOSE); |
959 |
g_free(context); |
g_free(context); |
960 |
} |
} |
961 |
|
|
|
|
|
962 |
// vim:et:ts=8:sw=2:sts=2:ai |
// vim:et:ts=8:sw=2:sts=2:ai |