From ed9511eca85ec9e55c9cfaa26118b3ab528a48e4 Mon Sep 17 00:00:00 2001 From: Kaj-Michael Lang Date: Sat, 3 Nov 2007 19:03:08 +0200 Subject: [PATCH] Add click on POI info dialog using gtkhtml for nice output --- src/map.c | 2 ++ src/poi-gui.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++ src/poi-gui.h | 2 ++ 3 files changed, 58 insertions(+) diff --git a/src/map.c b/src/map.c index 2024f30..dfd22c1 100644 --- a/src/map.c +++ b/src/map.c @@ -1192,6 +1192,8 @@ case 1: unit2latlon(ux, uy, lat, lon); if (map_poi_find_at_latlon(lat, lon, &poi_id)==TRUE) { g_printf("POI: %d\n", poi_id); + if (poi_info_dialog(poi_id)==FALSE) + g_printerr("Huh? Failed to display info dialog\n"); } else { map_drag_start(event->x, event->y); } diff --git a/src/poi-gui.c b/src/poi-gui.c index 790d915..dddaa85 100644 --- a/src/poi-gui.c +++ b/src/poi-gui.c @@ -16,6 +16,7 @@ #include #include #include +#include #include "utils.h" #include "poi.h" @@ -675,6 +676,59 @@ if (poi_category_list()) return TRUE; } +gboolean +poi_info_dialog(guint poi_id) +{ +GtkWidget *dialog; +GtkWidget *info; +GtkWidget *sw; +poi_info *p; +gchar *phtml; + +p=poi_get_by_id(poi_id); +if (!p) + return FALSE; + +phtml=g_strdup_printf( + "" + "%s
" + "
Lat: %f
Lon: %f
" + "
%s
%s
" + "
URL:%s
Postal Code:%s
" + "", + strlen(p->label)>0 ? p->label : "Unnamed POI", + p->lat, p->lon, + p->cat_desc ? p->cat_desc : "", + p->desc ? p->desc : "", + p->url ? p->url : "", + p->postal_code ? p->postal_code : ""); + +dialog=gtk_dialog_new_with_buttons(_("POI"), + GTK_WINDOW(_window), + GTK_DIALOG_MODAL, + GTK_STOCK_OK, + GTK_RESPONSE_ACCEPT, + NULL); + +info=gtk_html_new(); +gtk_html_set_editable(GTK_HTML(info), FALSE); +sw=gtk_scrolled_window_new(NULL, NULL); +gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); +gtk_container_add(GTK_CONTAINER(sw), info); +gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), sw, TRUE, TRUE, 0); + +gtk_html_load_from_string(info, phtml, -1); + +gtk_window_set_default_size(GTK_WINDOW(dialog), 400, 250); +gtk_widget_show_all(dialog); +gtk_dialog_run(dialog); +gtk_widget_destroy(dialog); + +g_free(phtml); +poi_free(p); + +return TRUE; +} /** * poi_edit_dialog * diff --git a/src/poi-gui.h b/src/poi-gui.h index b4d5987..9afe6f0 100644 --- a/src/poi-gui.h +++ b/src/poi-gui.h @@ -33,6 +33,8 @@ gboolean poi_edit_dialog(POIAction action, poi_info *poi); gboolean poi_search_dialog(GtkListStore *store, poi_info *poi, gdouble lat, gdouble lon); gboolean poi_quick_dialog(gdouble lat, gdouble lon); +gboolean poi_info_dialog(guint poi_id); + gboolean poi_category_dialog(guint cat_id); gboolean poi_category_list(); -- 2.39.5